@flowgram.ai/form-materials 0.1.0-alpha.13 → 0.1.0-alpha.14
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 +0 -11
- package/bin/materials.ts +29 -2
- package/dist/esm/chunk-727SU246.js +13 -0
- package/dist/esm/chunk-727SU246.js.map +1 -0
- package/dist/esm/chunk-DEZUEMUM.js +284 -0
- package/dist/esm/chunk-DEZUEMUM.js.map +1 -0
- package/dist/esm/chunk-DUOXDOUE.js +477 -0
- package/dist/esm/chunk-DUOXDOUE.js.map +1 -0
- package/dist/esm/editor-6UMULJYB.js +180 -0
- package/dist/esm/editor-6UMULJYB.js.map +1 -0
- package/dist/esm/editor-EYOQTGMT.js +282 -0
- package/dist/esm/editor-EYOQTGMT.js.map +1 -0
- package/dist/esm/editor-OXPGKPF5.js +167 -0
- package/dist/esm/editor-OXPGKPF5.js.map +1 -0
- package/dist/esm/editor-VO6YAXRC.js +249 -0
- package/dist/esm/editor-VO6YAXRC.js.map +1 -0
- package/dist/esm/editor-XYLKTB6L.js +365 -0
- package/dist/esm/editor-XYLKTB6L.js.map +1 -0
- package/dist/esm/index.js +1110 -2306
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.mts +298 -59
- package/dist/index.d.ts +298 -59
- package/dist/index.js +3932 -2681
- package/dist/index.js.map +1 -1
- package/package.json +9 -8
- package/src/components/batch-outputs/index.tsx +3 -2
- package/src/components/code-editor/editor.tsx +89 -0
- package/src/components/code-editor/index.tsx +5 -89
- package/src/components/code-editor/language-features.ts +18 -18
- package/src/components/code-editor/theme/dark.ts +49 -30
- package/src/components/code-editor/theme/light.ts +56 -32
- package/src/components/code-editor-mini/index.tsx +2 -2
- package/src/components/condition-row/constants.ts +8 -0
- package/src/components/condition-row/index.tsx +4 -0
- package/src/components/db-condition-row/hooks/use-left.tsx +66 -0
- package/src/components/db-condition-row/hooks/use-op.tsx +59 -0
- package/src/components/db-condition-row/index.tsx +93 -0
- package/src/components/db-condition-row/styles.tsx +43 -0
- package/src/components/db-condition-row/types.ts +34 -0
- package/src/components/display-flow-value/index.tsx +2 -12
- package/src/components/display-inputs-values/index.tsx +44 -6
- package/src/components/dynamic-value-input/hooks.ts +25 -4
- package/src/components/dynamic-value-input/index.tsx +21 -12
- package/src/components/dynamic-value-input/styles.tsx +14 -4
- package/src/components/index.ts +3 -0
- package/src/components/inputs-values/index.tsx +14 -3
- package/src/components/inputs-values/styles.tsx +1 -1
- package/src/components/inputs-values-tree/hooks/use-child-list.tsx +76 -0
- package/src/components/inputs-values-tree/index.tsx +62 -0
- package/src/components/inputs-values-tree/row.tsx +177 -0
- package/src/components/inputs-values-tree/styles.tsx +128 -0
- package/src/components/inputs-values-tree/types.ts +21 -0
- package/src/components/json-editor-with-variables/editor.tsx +69 -0
- package/src/components/json-editor-with-variables/extensions/variable-tag.tsx +6 -5
- package/src/components/json-editor-with-variables/index.tsx +5 -59
- package/src/components/json-schema-editor/default-value.tsx +1 -3
- package/src/components/json-schema-editor/hooks.tsx +14 -3
- package/src/components/json-schema-editor/index.tsx +18 -58
- package/src/components/json-schema-editor/styles.tsx +12 -55
- package/src/components/json-schema-editor/types.ts +0 -1
- package/src/components/prompt-editor/editor.tsx +81 -0
- package/src/components/prompt-editor/index.tsx +5 -62
- package/src/components/prompt-editor-with-inputs/editor.tsx +25 -0
- package/src/components/prompt-editor-with-inputs/extensions/inputs-tree.tsx +11 -0
- package/src/components/prompt-editor-with-inputs/index.tsx +5 -16
- package/src/components/prompt-editor-with-inputs/inputs-picker.tsx +34 -17
- package/src/components/prompt-editor-with-variables/editor.tsx +22 -0
- package/src/components/prompt-editor-with-variables/extensions/variable-tag.tsx +12 -20
- package/src/components/prompt-editor-with-variables/extensions/variable-tree.tsx +13 -1
- package/src/components/prompt-editor-with-variables/index.tsx +5 -13
- package/src/components/type-selector/index.tsx +12 -2
- package/src/components/variable-selector/context.tsx +28 -0
- package/src/components/variable-selector/index.tsx +10 -1
- package/src/components/variable-selector/use-variable-tree.tsx +3 -3
- package/src/effects/auto-rename-ref/index.ts +7 -54
- package/src/effects/validate-when-variable-sync/index.ts +1 -1
- package/src/form-plugins/infer-assign-plugin/index.ts +1 -1
- package/src/form-plugins/infer-inputs-plugin/index.ts +4 -76
- package/src/hooks/use-object-list/index.tsx +35 -7
- package/src/index.ts +1 -0
- package/src/plugins/json-schema-preset/manager.ts +1 -0
- package/src/plugins/json-schema-preset/type-definition/date-time.tsx +25 -0
- package/src/plugins/json-schema-preset/type-definition/index.tsx +2 -0
- package/src/plugins/json-schema-preset/type-definition/string.tsx +18 -9
- package/src/shared/flow-value/index.ts +6 -0
- package/src/shared/flow-value/schema.ts +38 -0
- package/src/shared/flow-value/utils.ts +201 -0
- package/src/shared/format-legacy-refs/index.ts +1 -1
- package/src/shared/index.ts +3 -0
- package/src/shared/lazy-suspense/index.tsx +28 -0
- package/src/shared/polyfill-create-root/index.tsx +33 -0
- package/src/typings/flow-value/index.ts +3 -1
- package/src/validate/validate-flow-value/index.tsx +4 -16
- package/src/components/json-schema-editor/components/blur-input.tsx +0 -27
- package/src/plugins/disable-declaration-plugin/config.json +0 -5
- package/src/plugins/json-schema-preset/config.json +0 -9
- /package/src/components/{inputs-values/components/blur-input.tsx → blur-input/index.tsx} +0 -0
package/dist/esm/index.js
CHANGED
|
@@ -1,853 +1,37 @@
|
|
|
1
|
-
// src/components/variable-selector/index.tsx
|
|
2
|
-
import React12, { useMemo } from "react";
|
|
3
|
-
import { I18n as I18n7 } from "@flowgram.ai/editor";
|
|
4
|
-
import { Popover } from "@douyinfe/semi-ui";
|
|
5
|
-
import { IconChevronDownStroked, IconIssueStroked } from "@douyinfe/semi-icons";
|
|
6
|
-
|
|
7
|
-
// src/shared/format-legacy-refs/index.ts
|
|
8
|
-
import { isObject } from "lodash";
|
|
9
|
-
function formatLegacyRefOnSubmit(value) {
|
|
10
|
-
if (isObject(value)) {
|
|
11
|
-
if (isLegacyFlowRefValueSchema(value)) {
|
|
12
|
-
return formatLegacyRefToNewRef(value);
|
|
13
|
-
}
|
|
14
|
-
return Object.fromEntries(
|
|
15
|
-
Object.entries(value).map(([key, value2]) => [
|
|
16
|
-
key,
|
|
17
|
-
formatLegacyRefOnSubmit(value2)
|
|
18
|
-
])
|
|
19
|
-
);
|
|
20
|
-
}
|
|
21
|
-
if (Array.isArray(value)) {
|
|
22
|
-
return value.map(formatLegacyRefOnSubmit);
|
|
23
|
-
}
|
|
24
|
-
return value;
|
|
25
|
-
}
|
|
26
|
-
function formatLegacyRefOnInit(value) {
|
|
27
|
-
if (isObject(value)) {
|
|
28
|
-
if (isNewFlowRefValueSchema(value)) {
|
|
29
|
-
return formatNewRefToLegacyRef(value);
|
|
30
|
-
}
|
|
31
|
-
return Object.fromEntries(
|
|
32
|
-
Object.entries(value).map(([key, value2]) => [
|
|
33
|
-
key,
|
|
34
|
-
formatLegacyRefOnInit(value2)
|
|
35
|
-
])
|
|
36
|
-
);
|
|
37
|
-
}
|
|
38
|
-
if (Array.isArray(value)) {
|
|
39
|
-
return value.map(formatLegacyRefOnInit);
|
|
40
|
-
}
|
|
41
|
-
return value;
|
|
42
|
-
}
|
|
43
|
-
function isLegacyFlowRefValueSchema(value) {
|
|
44
|
-
return isObject(value) && Object.keys(value).length === 2 && value.type === "ref" && typeof value.content === "string";
|
|
45
|
-
}
|
|
46
|
-
function isNewFlowRefValueSchema(value) {
|
|
47
|
-
return isObject(value) && Object.keys(value).length === 2 && value.type === "ref" && Array.isArray(value.content);
|
|
48
|
-
}
|
|
49
|
-
function formatLegacyRefToNewRef(value) {
|
|
50
|
-
const keyPath = value.content.split(".");
|
|
51
|
-
if (keyPath[1] === "outputs") {
|
|
52
|
-
return {
|
|
53
|
-
type: "ref",
|
|
54
|
-
content: [`${keyPath[0]}.${keyPath[1]}`, ...keyPath.length > 2 ? keyPath.slice(2) : []]
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
return {
|
|
58
|
-
type: "ref",
|
|
59
|
-
content: keyPath
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
function formatNewRefToLegacyRef(value) {
|
|
63
|
-
return {
|
|
64
|
-
type: "ref",
|
|
65
|
-
content: value.content.join(".")
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
// src/shared/inject-material/index.tsx
|
|
70
|
-
import React from "react";
|
|
71
1
|
import {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
usePlaygroundContainer
|
|
75
|
-
} from "@flowgram.ai/editor";
|
|
76
|
-
function createInjectMaterial(Component, params) {
|
|
77
|
-
const InjectComponent = (props) => {
|
|
78
|
-
const container = usePlaygroundContainer();
|
|
79
|
-
if (!container?.isBound(FlowRendererRegistry)) {
|
|
80
|
-
return React.createElement(Component, { ...props });
|
|
81
|
-
}
|
|
82
|
-
const rendererRegistry = container.get(FlowRendererRegistry);
|
|
83
|
-
const renderKey = params?.renderKey || Component.renderKey || Component.name || "";
|
|
84
|
-
const renderer = rendererRegistry.tryToGetRendererComponent(renderKey);
|
|
85
|
-
if (renderer?.type !== FlowRendererComponentType.REACT) {
|
|
86
|
-
return React.createElement(Component, { ...props });
|
|
87
|
-
}
|
|
88
|
-
return React.createElement(renderer.renderer, {
|
|
89
|
-
...props
|
|
90
|
-
});
|
|
91
|
-
};
|
|
92
|
-
return InjectComponent;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
// src/components/variable-selector/use-variable-tree.tsx
|
|
96
|
-
import React11, { useCallback } from "react";
|
|
97
|
-
import { JsonSchemaUtils as JsonSchemaUtils2 } from "@flowgram.ai/json-schema";
|
|
98
|
-
import { ASTMatch as ASTMatch2, useAvailableVariables } from "@flowgram.ai/editor";
|
|
99
|
-
import { Icon } from "@douyinfe/semi-ui";
|
|
100
|
-
|
|
101
|
-
// src/plugins/json-schema-preset/index.tsx
|
|
102
|
-
import React10 from "react";
|
|
2
|
+
PromptEditor
|
|
3
|
+
} from "./chunk-727SU246.js";
|
|
103
4
|
import {
|
|
5
|
+
CodeEditor,
|
|
6
|
+
CodeEditorMini,
|
|
7
|
+
InjectVariableSelector,
|
|
8
|
+
JsonSchemaTypePresetProvider,
|
|
104
9
|
JsonSchemaUtils,
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
// src/plugins/json-schema-preset/type-definition/string.tsx
|
|
113
|
-
import React2 from "react";
|
|
114
|
-
import { I18n } from "@flowgram.ai/editor";
|
|
115
|
-
import { Input } from "@douyinfe/semi-ui";
|
|
116
|
-
var stringRegistry = {
|
|
117
|
-
type: "string",
|
|
118
|
-
ConstantRenderer: (props) => /* @__PURE__ */ React2.createElement(
|
|
119
|
-
Input,
|
|
120
|
-
{
|
|
121
|
-
placeholder: I18n.t("Please Input String"),
|
|
122
|
-
size: "small",
|
|
123
|
-
disabled: props.readonly,
|
|
124
|
-
...props
|
|
125
|
-
}
|
|
126
|
-
)
|
|
127
|
-
};
|
|
128
|
-
|
|
129
|
-
// src/plugins/json-schema-preset/type-definition/object.tsx
|
|
130
|
-
import React5 from "react";
|
|
131
|
-
import { I18n as I18n2 } from "@flowgram.ai/editor";
|
|
132
|
-
|
|
133
|
-
// src/components/code-editor-mini/index.tsx
|
|
134
|
-
import React4 from "react";
|
|
135
|
-
import styled from "styled-components";
|
|
136
|
-
|
|
137
|
-
// src/components/code-editor/index.tsx
|
|
138
|
-
import React3, { useEffect, useRef } from "react";
|
|
139
|
-
import {
|
|
140
|
-
ActiveLinePlaceholder,
|
|
141
|
-
createRenderer,
|
|
142
|
-
EditorProvider
|
|
143
|
-
} from "@coze-editor/editor/react";
|
|
144
|
-
import preset from "@coze-editor/editor/preset-code";
|
|
145
|
-
import { EditorView } from "@codemirror/view";
|
|
146
|
-
|
|
147
|
-
// src/components/code-editor/utils.ts
|
|
148
|
-
function getSuffixByLanguageId(languageId) {
|
|
149
|
-
if (languageId === "python") {
|
|
150
|
-
return ".py";
|
|
151
|
-
}
|
|
152
|
-
if (languageId === "typescript") {
|
|
153
|
-
return ".ts";
|
|
154
|
-
}
|
|
155
|
-
if (languageId === "shell") {
|
|
156
|
-
return ".sh";
|
|
157
|
-
}
|
|
158
|
-
if (languageId === "json") {
|
|
159
|
-
return ".json";
|
|
160
|
-
}
|
|
161
|
-
return "";
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
// src/components/code-editor/language-features.ts
|
|
165
|
-
import { languages } from "@coze-editor/editor/preset-code";
|
|
166
|
-
import { typescript } from "@coze-editor/editor/language-typescript";
|
|
167
|
-
import { shell } from "@coze-editor/editor/language-shell";
|
|
168
|
-
import { python } from "@coze-editor/editor/language-python";
|
|
169
|
-
import { json } from "@coze-editor/editor/language-json";
|
|
170
|
-
import { mixLanguages } from "@coze-editor/editor";
|
|
171
|
-
languages.register("python", python);
|
|
172
|
-
languages.register("shell", shell);
|
|
173
|
-
languages.register("typescript", typescript);
|
|
174
|
-
languages.register("json", {
|
|
175
|
-
// mixLanguages is used to solve the problem that interpolation also uses parentheses, which causes incorrect highlighting
|
|
176
|
-
language: mixLanguages({
|
|
177
|
-
outerLanguage: json.language
|
|
178
|
-
}),
|
|
179
|
-
languageService: json.languageService
|
|
180
|
-
});
|
|
181
|
-
var tsWorkerInit = false;
|
|
182
|
-
var initTsWorker = () => {
|
|
183
|
-
if (tsWorkerInit) {
|
|
184
|
-
return;
|
|
185
|
-
}
|
|
186
|
-
tsWorkerInit = true;
|
|
187
|
-
const tsWorker = new Worker(
|
|
188
|
-
new URL(`@coze-editor/editor/language-typescript/worker`, import.meta.url),
|
|
189
|
-
{ type: "module" }
|
|
190
|
-
);
|
|
191
|
-
typescript.languageService.initialize(tsWorker, {
|
|
192
|
-
compilerOptions: {
|
|
193
|
-
// eliminate Promise error
|
|
194
|
-
lib: ["es2015", "dom"],
|
|
195
|
-
noImplicitAny: false
|
|
196
|
-
}
|
|
197
|
-
});
|
|
198
|
-
};
|
|
199
|
-
|
|
200
|
-
// src/components/code-editor/theme/index.ts
|
|
201
|
-
import { themes } from "@coze-editor/editor/preset-code";
|
|
202
|
-
|
|
203
|
-
// src/components/code-editor/theme/light.ts
|
|
204
|
-
import { createTheme, tags as t } from "@coze-editor/editor/preset-code";
|
|
205
|
-
var colors = {
|
|
206
|
-
background: "#F7F7FC",
|
|
207
|
-
// syntax
|
|
208
|
-
comment: "#000A298A",
|
|
209
|
-
key: "#00818C",
|
|
210
|
-
string: "#D1009D",
|
|
211
|
-
number: "#C74200",
|
|
212
|
-
boolean: "#2B57D9",
|
|
213
|
-
null: "#2B57D9",
|
|
214
|
-
separator: "#0F1529D1"
|
|
215
|
-
};
|
|
216
|
-
var lightTheme = createTheme({
|
|
217
|
-
variant: "light",
|
|
218
|
-
settings: {
|
|
219
|
-
background: "#fff",
|
|
220
|
-
foreground: "#000",
|
|
221
|
-
caret: "#000",
|
|
222
|
-
selection: "#d9d9d9",
|
|
223
|
-
gutterBackground: "#f0f0f0",
|
|
224
|
-
gutterForeground: "#666",
|
|
225
|
-
gutterBorderColor: "transparent",
|
|
226
|
-
gutterBorderWidth: 0,
|
|
227
|
-
lineHighlight: "#e1e1e180",
|
|
228
|
-
bracketColors: ["#FFD700", "#DD99FF", "#78B0FF"],
|
|
229
|
-
tooltip: {
|
|
230
|
-
backgroundColor: "#f0f0f0",
|
|
231
|
-
color: "#000",
|
|
232
|
-
border: "1px solid #ccc"
|
|
233
|
-
},
|
|
234
|
-
link: {
|
|
235
|
-
color: "#007bff"
|
|
236
|
-
},
|
|
237
|
-
completionItemHover: {
|
|
238
|
-
backgroundColor: "#f0f0f0"
|
|
239
|
-
},
|
|
240
|
-
completionItemSelected: {
|
|
241
|
-
backgroundColor: "#e0e0e0"
|
|
242
|
-
},
|
|
243
|
-
completionItemIcon: {
|
|
244
|
-
color: "#333"
|
|
245
|
-
},
|
|
246
|
-
completionItemLabel: {
|
|
247
|
-
color: "#333"
|
|
248
|
-
},
|
|
249
|
-
completionItemInfo: {
|
|
250
|
-
color: "#333"
|
|
251
|
-
},
|
|
252
|
-
completionItemDetail: {
|
|
253
|
-
color: "#666"
|
|
254
|
-
}
|
|
255
|
-
},
|
|
256
|
-
styles: [
|
|
257
|
-
// JSON
|
|
258
|
-
{
|
|
259
|
-
tag: t.comment,
|
|
260
|
-
color: colors.comment
|
|
261
|
-
},
|
|
262
|
-
{
|
|
263
|
-
tag: [t.propertyName],
|
|
264
|
-
color: colors.key
|
|
265
|
-
},
|
|
266
|
-
{
|
|
267
|
-
tag: [t.string],
|
|
268
|
-
color: colors.string
|
|
269
|
-
},
|
|
270
|
-
{
|
|
271
|
-
tag: [t.number],
|
|
272
|
-
color: colors.number
|
|
273
|
-
},
|
|
274
|
-
{
|
|
275
|
-
tag: [t.bool],
|
|
276
|
-
color: colors.boolean
|
|
277
|
-
},
|
|
278
|
-
{
|
|
279
|
-
tag: [t.null],
|
|
280
|
-
color: colors.null
|
|
281
|
-
},
|
|
282
|
-
{
|
|
283
|
-
tag: [t.separator],
|
|
284
|
-
color: colors.separator
|
|
285
|
-
},
|
|
286
|
-
// markdown
|
|
287
|
-
{
|
|
288
|
-
tag: [t.heading],
|
|
289
|
-
color: "#3e76ef"
|
|
290
|
-
},
|
|
291
|
-
{
|
|
292
|
-
tag: [t.processingInstruction],
|
|
293
|
-
color: "#3e76ef"
|
|
294
|
-
},
|
|
295
|
-
// shell
|
|
296
|
-
// curl
|
|
297
|
-
{
|
|
298
|
-
tag: [t.standard(t.variableName)],
|
|
299
|
-
color: "#00804A"
|
|
300
|
-
},
|
|
301
|
-
// -X
|
|
302
|
-
{
|
|
303
|
-
tag: [t.attributeName],
|
|
304
|
-
color: "#C74200"
|
|
305
|
-
},
|
|
306
|
-
// url in string (includes quotes), e.g. "https://..."
|
|
307
|
-
{
|
|
308
|
-
tag: [t.special(t.string)],
|
|
309
|
-
color: "#2B57D9"
|
|
310
|
-
}
|
|
311
|
-
]
|
|
312
|
-
});
|
|
313
|
-
|
|
314
|
-
// src/components/code-editor/theme/dark.ts
|
|
315
|
-
import { createTheme as createTheme2, tags as t2 } from "@coze-editor/editor/preset-code";
|
|
316
|
-
var colors2 = {
|
|
317
|
-
background: "#151B27",
|
|
318
|
-
// syntax
|
|
319
|
-
comment: "#FFFFFF63",
|
|
320
|
-
key: "#39E5D7",
|
|
321
|
-
string: "#FF94D2",
|
|
322
|
-
number: "#FF9933",
|
|
323
|
-
boolean: "#78B0FF",
|
|
324
|
-
null: "#78B0FF",
|
|
325
|
-
separator: "#FFFFFFC9"
|
|
326
|
-
};
|
|
327
|
-
var darkTheme = createTheme2({
|
|
328
|
-
variant: "dark",
|
|
329
|
-
settings: {
|
|
330
|
-
background: colors2.background,
|
|
331
|
-
foreground: "#fff",
|
|
332
|
-
caret: "#AEAFAD",
|
|
333
|
-
selection: "#d9d9d942",
|
|
334
|
-
gutterBackground: colors2.background,
|
|
335
|
-
gutterForeground: "#FFFFFF63",
|
|
336
|
-
gutterBorderColor: "transparent",
|
|
337
|
-
gutterBorderWidth: 0,
|
|
338
|
-
lineHighlight: "#272e3d36",
|
|
339
|
-
bracketColors: ["#FFEF61", "#DD99FF", "#78B0FF"],
|
|
340
|
-
tooltip: {
|
|
341
|
-
backgroundColor: "#363D4D",
|
|
342
|
-
color: "#fff",
|
|
343
|
-
border: "none"
|
|
344
|
-
},
|
|
345
|
-
link: {
|
|
346
|
-
color: "#4daafc"
|
|
347
|
-
},
|
|
348
|
-
completionItemHover: {
|
|
349
|
-
backgroundColor: "#FFFFFF0F"
|
|
350
|
-
},
|
|
351
|
-
completionItemSelected: {
|
|
352
|
-
backgroundColor: "#FFFFFF17"
|
|
353
|
-
},
|
|
354
|
-
completionItemIcon: {
|
|
355
|
-
color: "#FFFFFFC9"
|
|
356
|
-
},
|
|
357
|
-
completionItemLabel: {
|
|
358
|
-
color: "#FFFFFFC9"
|
|
359
|
-
},
|
|
360
|
-
completionItemInfo: {
|
|
361
|
-
color: "#FFFFFFC9"
|
|
362
|
-
},
|
|
363
|
-
completionItemDetail: {
|
|
364
|
-
color: "#FFFFFF63"
|
|
365
|
-
}
|
|
366
|
-
},
|
|
367
|
-
styles: [
|
|
368
|
-
// json
|
|
369
|
-
{
|
|
370
|
-
tag: t2.comment,
|
|
371
|
-
color: colors2.comment
|
|
372
|
-
},
|
|
373
|
-
{
|
|
374
|
-
tag: [t2.propertyName],
|
|
375
|
-
color: colors2.key
|
|
376
|
-
},
|
|
377
|
-
{
|
|
378
|
-
tag: [t2.string],
|
|
379
|
-
color: colors2.string
|
|
380
|
-
},
|
|
381
|
-
{
|
|
382
|
-
tag: [t2.number],
|
|
383
|
-
color: colors2.number
|
|
384
|
-
},
|
|
385
|
-
{
|
|
386
|
-
tag: [t2.bool],
|
|
387
|
-
color: colors2.boolean
|
|
388
|
-
},
|
|
389
|
-
{
|
|
390
|
-
tag: [t2.null],
|
|
391
|
-
color: colors2.null
|
|
392
|
-
},
|
|
393
|
-
{
|
|
394
|
-
tag: [t2.separator],
|
|
395
|
-
color: colors2.separator
|
|
396
|
-
},
|
|
397
|
-
// markdown
|
|
398
|
-
{
|
|
399
|
-
tag: [t2.heading],
|
|
400
|
-
color: "#6b6bff"
|
|
401
|
-
},
|
|
402
|
-
{
|
|
403
|
-
tag: [t2.processingInstruction],
|
|
404
|
-
color: "#6b6bff"
|
|
405
|
-
},
|
|
406
|
-
// shell
|
|
407
|
-
// curl
|
|
408
|
-
{
|
|
409
|
-
tag: [t2.standard(t2.variableName)],
|
|
410
|
-
color: "#3BEB84"
|
|
411
|
-
},
|
|
412
|
-
// -X
|
|
413
|
-
{
|
|
414
|
-
tag: [t2.attributeName],
|
|
415
|
-
color: "#FF9933"
|
|
416
|
-
},
|
|
417
|
-
// url in string (includes quotes), e.g. "https://..."
|
|
418
|
-
{
|
|
419
|
-
tag: [t2.special(t2.string)],
|
|
420
|
-
color: "#78B0FF"
|
|
421
|
-
}
|
|
422
|
-
]
|
|
423
|
-
});
|
|
424
|
-
|
|
425
|
-
// src/components/code-editor/theme/index.ts
|
|
426
|
-
themes.register("dark", darkTheme);
|
|
427
|
-
themes.register("light", lightTheme);
|
|
428
|
-
|
|
429
|
-
// src/components/code-editor/index.tsx
|
|
430
|
-
var OriginCodeEditor = createRenderer(preset, [
|
|
431
|
-
EditorView.theme({
|
|
432
|
-
"&.cm-focused": {
|
|
433
|
-
outline: "none"
|
|
434
|
-
}
|
|
435
|
-
})
|
|
436
|
-
]);
|
|
437
|
-
function CodeEditor({
|
|
438
|
-
value,
|
|
439
|
-
onChange,
|
|
440
|
-
languageId = "python",
|
|
441
|
-
theme = "light",
|
|
442
|
-
children,
|
|
443
|
-
placeholder,
|
|
444
|
-
activeLinePlaceholder,
|
|
445
|
-
options,
|
|
446
|
-
readonly
|
|
447
|
-
}) {
|
|
448
|
-
const editorRef = useRef(null);
|
|
449
|
-
useEffect(() => {
|
|
450
|
-
if (languageId === "typescript") {
|
|
451
|
-
initTsWorker();
|
|
452
|
-
}
|
|
453
|
-
}, [languageId]);
|
|
454
|
-
useEffect(() => {
|
|
455
|
-
if (editorRef.current?.getValue() !== value) {
|
|
456
|
-
editorRef.current?.setValue(String(value || ""));
|
|
457
|
-
}
|
|
458
|
-
}, [value]);
|
|
459
|
-
return /* @__PURE__ */ React3.createElement(EditorProvider, null, /* @__PURE__ */ React3.createElement(
|
|
460
|
-
OriginCodeEditor,
|
|
461
|
-
{
|
|
462
|
-
defaultValue: value,
|
|
463
|
-
options: {
|
|
464
|
-
uri: `file:///untitled${getSuffixByLanguageId(languageId)}`,
|
|
465
|
-
languageId,
|
|
466
|
-
theme,
|
|
467
|
-
placeholder,
|
|
468
|
-
readOnly: readonly,
|
|
469
|
-
editable: !readonly,
|
|
470
|
-
...options || {}
|
|
471
|
-
},
|
|
472
|
-
didMount: (editor) => {
|
|
473
|
-
editorRef.current = editor;
|
|
474
|
-
},
|
|
475
|
-
onChange: (e) => onChange?.(e.value)
|
|
476
|
-
},
|
|
477
|
-
activeLinePlaceholder && /* @__PURE__ */ React3.createElement(ActiveLinePlaceholder, null, activeLinePlaceholder),
|
|
478
|
-
children
|
|
479
|
-
));
|
|
480
|
-
}
|
|
481
|
-
|
|
482
|
-
// src/components/code-editor-mini/index.tsx
|
|
483
|
-
var UIMini = styled.div`
|
|
484
|
-
.ͼ1 .cm-content {
|
|
485
|
-
padding: 0;
|
|
486
|
-
}
|
|
487
|
-
`;
|
|
488
|
-
function CodeEditorMini(props) {
|
|
489
|
-
return /* @__PURE__ */ React4.createElement(UIMini, null, /* @__PURE__ */ React4.createElement(
|
|
490
|
-
CodeEditor,
|
|
491
|
-
{
|
|
492
|
-
...props,
|
|
493
|
-
options: {
|
|
494
|
-
lineNumbersGutter: false,
|
|
495
|
-
foldGutter: false,
|
|
496
|
-
...props.options || {}
|
|
497
|
-
}
|
|
498
|
-
}
|
|
499
|
-
));
|
|
500
|
-
}
|
|
501
|
-
|
|
502
|
-
// src/plugins/json-schema-preset/type-definition/object.tsx
|
|
503
|
-
var objectRegistry = {
|
|
504
|
-
type: "object",
|
|
505
|
-
ConstantRenderer: (props) => /* @__PURE__ */ React5.createElement(
|
|
506
|
-
CodeEditorMini,
|
|
507
|
-
{
|
|
508
|
-
value: props.value,
|
|
509
|
-
onChange: (v) => props.onChange?.(v),
|
|
510
|
-
languageId: "json",
|
|
511
|
-
placeholder: I18n2.t("Please Input Object"),
|
|
512
|
-
readonly: props.readonly
|
|
513
|
-
}
|
|
514
|
-
)
|
|
515
|
-
};
|
|
516
|
-
|
|
517
|
-
// src/plugins/json-schema-preset/type-definition/number.tsx
|
|
518
|
-
import React6 from "react";
|
|
519
|
-
import { I18n as I18n3 } from "@flowgram.ai/editor";
|
|
520
|
-
import { InputNumber } from "@douyinfe/semi-ui";
|
|
521
|
-
var numberRegistry = {
|
|
522
|
-
type: "number",
|
|
523
|
-
ConstantRenderer: (props) => /* @__PURE__ */ React6.createElement(
|
|
524
|
-
InputNumber,
|
|
525
|
-
{
|
|
526
|
-
placeholder: I18n3.t("Please Input Number"),
|
|
527
|
-
size: "small",
|
|
528
|
-
disabled: props.readonly,
|
|
529
|
-
hideButtons: true,
|
|
530
|
-
...props
|
|
531
|
-
}
|
|
532
|
-
)
|
|
533
|
-
};
|
|
534
|
-
|
|
535
|
-
// src/plugins/json-schema-preset/type-definition/integer.tsx
|
|
536
|
-
import React7 from "react";
|
|
537
|
-
import { I18n as I18n4 } from "@flowgram.ai/editor";
|
|
538
|
-
import { InputNumber as InputNumber2 } from "@douyinfe/semi-ui";
|
|
539
|
-
var integerRegistry = {
|
|
540
|
-
type: "integer",
|
|
541
|
-
ConstantRenderer: (props) => /* @__PURE__ */ React7.createElement(
|
|
542
|
-
InputNumber2,
|
|
543
|
-
{
|
|
544
|
-
placeholder: I18n4.t("Please Input Integer"),
|
|
545
|
-
size: "small",
|
|
546
|
-
disabled: props.readonly,
|
|
547
|
-
precision: 0,
|
|
548
|
-
...props
|
|
549
|
-
}
|
|
550
|
-
)
|
|
551
|
-
};
|
|
552
|
-
|
|
553
|
-
// src/plugins/json-schema-preset/type-definition/boolean.tsx
|
|
554
|
-
import React8 from "react";
|
|
555
|
-
import { I18n as I18n5 } from "@flowgram.ai/editor";
|
|
556
|
-
import { Select } from "@douyinfe/semi-ui";
|
|
557
|
-
var booleanRegistry = {
|
|
558
|
-
type: "boolean",
|
|
559
|
-
ConstantRenderer: (props) => {
|
|
560
|
-
const { value, onChange, ...rest } = props;
|
|
561
|
-
return /* @__PURE__ */ React8.createElement(
|
|
562
|
-
Select,
|
|
563
|
-
{
|
|
564
|
-
placeholder: I18n5.t("Please Select Boolean"),
|
|
565
|
-
size: "small",
|
|
566
|
-
disabled: props.readonly,
|
|
567
|
-
optionList: [
|
|
568
|
-
{ label: I18n5.t("True"), value: 1 },
|
|
569
|
-
{ label: I18n5.t("False"), value: 0 }
|
|
570
|
-
],
|
|
571
|
-
value: value ? 1 : 0,
|
|
572
|
-
onChange: (value2) => onChange?.(!!value2),
|
|
573
|
-
...rest
|
|
574
|
-
}
|
|
575
|
-
);
|
|
576
|
-
}
|
|
577
|
-
};
|
|
578
|
-
|
|
579
|
-
// src/plugins/json-schema-preset/type-definition/array.tsx
|
|
580
|
-
import React9 from "react";
|
|
581
|
-
import { I18n as I18n6 } from "@flowgram.ai/editor";
|
|
582
|
-
var arrayRegistry = {
|
|
583
|
-
type: "array",
|
|
584
|
-
ConstantRenderer: (props) => /* @__PURE__ */ React9.createElement(
|
|
585
|
-
CodeEditorMini,
|
|
586
|
-
{
|
|
587
|
-
value: props.value,
|
|
588
|
-
languageId: "json",
|
|
589
|
-
onChange: (v) => props.onChange?.(v),
|
|
590
|
-
placeholder: I18n6.t("Please Input Array"),
|
|
591
|
-
readonly: props.readonly
|
|
592
|
-
}
|
|
593
|
-
)
|
|
594
|
-
};
|
|
595
|
-
|
|
596
|
-
// src/plugins/json-schema-preset/type-definition/index.tsx
|
|
597
|
-
var jsonSchemaTypePreset = [
|
|
598
|
-
stringRegistry,
|
|
599
|
-
objectRegistry,
|
|
600
|
-
numberRegistry,
|
|
601
|
-
integerRegistry,
|
|
602
|
-
booleanRegistry,
|
|
603
|
-
arrayRegistry
|
|
604
|
-
];
|
|
605
|
-
jsonSchemaTypePreset.forEach((_type) => jsonSchemaTypeManager.register(_type));
|
|
606
|
-
|
|
607
|
-
// src/plugins/json-schema-preset/create-type-preset-plugin.tsx
|
|
608
|
-
import {
|
|
609
|
-
BaseTypeManager,
|
|
610
|
-
jsonSchemaContainerModule
|
|
611
|
-
} from "@flowgram.ai/json-schema";
|
|
612
|
-
import { definePluginCreator } from "@flowgram.ai/editor";
|
|
613
|
-
var createTypePresetPlugin = definePluginCreator({
|
|
614
|
-
onInit(ctx, opts) {
|
|
615
|
-
const typeManager = ctx.get(BaseTypeManager);
|
|
616
|
-
jsonSchemaTypePreset.forEach((_type) => typeManager.register(_type));
|
|
617
|
-
opts.types?.forEach((_type) => typeManager.register(_type));
|
|
618
|
-
opts.unregisterTypes?.forEach((_type) => typeManager.unregister(_type));
|
|
619
|
-
},
|
|
620
|
-
containerModules: [jsonSchemaContainerModule]
|
|
621
|
-
});
|
|
622
|
-
|
|
623
|
-
// src/plugins/json-schema-preset/index.tsx
|
|
624
|
-
var useTypeManager = () => useOriginTypeManager();
|
|
625
|
-
var JsonSchemaTypePresetProvider = ({
|
|
626
|
-
types = [],
|
|
627
|
-
children
|
|
628
|
-
}) => /* @__PURE__ */ React10.createElement(OriginTypePresetProvider, { types: [...jsonSchemaTypePreset, ...types] }, children);
|
|
629
|
-
|
|
630
|
-
// src/plugins/disable-declaration-plugin/create-disable-declaration-plugin.ts
|
|
10
|
+
VariableSelector,
|
|
11
|
+
VariableSelectorProvider,
|
|
12
|
+
createDisableDeclarationPlugin,
|
|
13
|
+
createTypePresetPlugin,
|
|
14
|
+
useTypeManager,
|
|
15
|
+
useVariableTree
|
|
16
|
+
} from "./chunk-DUOXDOUE.js";
|
|
631
17
|
import {
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
});
|
|
646
|
-
}
|
|
647
|
-
}
|
|
648
|
-
};
|
|
649
|
-
variableEngine.onGlobalEvent("NewAST", handleEvent);
|
|
650
|
-
variableEngine.onGlobalEvent("UpdateAST", handleEvent);
|
|
651
|
-
}
|
|
652
|
-
});
|
|
653
|
-
|
|
654
|
-
// src/components/variable-selector/use-variable-tree.tsx
|
|
655
|
-
function useVariableTree(params) {
|
|
656
|
-
const { includeSchema, excludeSchema, customSkip } = params;
|
|
657
|
-
const typeManager = useTypeManager();
|
|
658
|
-
const variables = useAvailableVariables();
|
|
659
|
-
const getVariableTypeIcon = useCallback((variable) => {
|
|
660
|
-
if (variable.meta?.icon) {
|
|
661
|
-
if (typeof variable.meta.icon === "string") {
|
|
662
|
-
return /* @__PURE__ */ React11.createElement("img", { style: { marginRight: 8 }, width: 12, height: 12, src: variable.meta.icon });
|
|
663
|
-
}
|
|
664
|
-
return variable.meta.icon;
|
|
665
|
-
}
|
|
666
|
-
const schema = JsonSchemaUtils2.astToSchema(variable.type, { drilldownObject: false });
|
|
667
|
-
return /* @__PURE__ */ React11.createElement(Icon, { size: "small", svg: typeManager.getDisplayIcon(schema || {}) });
|
|
668
|
-
}, []);
|
|
669
|
-
const renderVariable = (variable, parentFields = []) => {
|
|
670
|
-
let type = variable?.type;
|
|
671
|
-
if (!type) {
|
|
672
|
-
return null;
|
|
673
|
-
}
|
|
674
|
-
let children;
|
|
675
|
-
if (ASTMatch2.isObject(type)) {
|
|
676
|
-
children = (type.properties || []).map((_property) => renderVariable(_property, [...parentFields, variable])).filter(Boolean);
|
|
677
|
-
}
|
|
678
|
-
const keyPath = [...parentFields.map((_field) => _field.key), variable.key];
|
|
679
|
-
const key = keyPath.join(".");
|
|
680
|
-
const isSchemaInclude = includeSchema ? JsonSchemaUtils2.isASTMatchSchema(type, includeSchema) : true;
|
|
681
|
-
const isSchemaExclude = excludeSchema ? JsonSchemaUtils2.isASTMatchSchema(type, excludeSchema) : false;
|
|
682
|
-
const isCustomSkip = customSkip ? customSkip(variable) : false;
|
|
683
|
-
const isMetaDisabled = variable.meta?.disabled;
|
|
684
|
-
const isSchemaMatch = isSchemaInclude && !isSchemaExclude && !isCustomSkip && !isMetaDisabled;
|
|
685
|
-
if (!isSchemaMatch && !children?.length) {
|
|
686
|
-
return null;
|
|
687
|
-
}
|
|
688
|
-
return {
|
|
689
|
-
key,
|
|
690
|
-
label: variable.meta?.title || variable.key,
|
|
691
|
-
value: key,
|
|
692
|
-
keyPath,
|
|
693
|
-
icon: getVariableTypeIcon(variable),
|
|
694
|
-
children,
|
|
695
|
-
disabled: !isSchemaMatch,
|
|
696
|
-
rootMeta: parentFields[0]?.meta || variable.meta,
|
|
697
|
-
isRoot: !parentFields?.length
|
|
698
|
-
};
|
|
699
|
-
};
|
|
700
|
-
return [...variables.slice(0).reverse()].map((_variable) => renderVariable(_variable)).filter(Boolean);
|
|
701
|
-
}
|
|
702
|
-
|
|
703
|
-
// src/components/variable-selector/styles.tsx
|
|
704
|
-
import styled2, { css } from "styled-components";
|
|
705
|
-
import { Tag, TreeSelect } from "@douyinfe/semi-ui";
|
|
706
|
-
var UIRootTitle = styled2.div`
|
|
707
|
-
margin-right: 4px;
|
|
708
|
-
min-width: 20px;
|
|
709
|
-
overflow: hidden;
|
|
710
|
-
text-overflow: ellipsis;
|
|
711
|
-
white-space: nowrap;
|
|
712
|
-
color: var(--semi-color-text-2);
|
|
713
|
-
`;
|
|
714
|
-
var UIVarName = styled2.div`
|
|
715
|
-
overflow: hidden;
|
|
716
|
-
text-overflow: ellipsis;
|
|
717
|
-
white-space: nowrap;
|
|
718
|
-
|
|
719
|
-
${({ $inSelector }) => $inSelector && css`
|
|
720
|
-
min-width: 50%;
|
|
721
|
-
`}
|
|
722
|
-
`;
|
|
723
|
-
var UITag = styled2(Tag)`
|
|
724
|
-
width: 100%;
|
|
725
|
-
display: flex;
|
|
726
|
-
align-items: center;
|
|
727
|
-
justify-content: flex-start;
|
|
728
|
-
|
|
729
|
-
& .semi-tag-content-center {
|
|
730
|
-
justify-content: flex-start;
|
|
731
|
-
}
|
|
732
|
-
|
|
733
|
-
&.semi-tag {
|
|
734
|
-
margin: 0;
|
|
735
|
-
height: 22px;
|
|
736
|
-
}
|
|
737
|
-
`;
|
|
738
|
-
var UITreeSelect = styled2(TreeSelect)`
|
|
739
|
-
outline: ${({ $error }) => $error ? "1px solid red" : "none"};
|
|
740
|
-
|
|
741
|
-
& .semi-tree-select-selection {
|
|
742
|
-
padding: 0px;
|
|
743
|
-
height: 22px;
|
|
744
|
-
}
|
|
745
|
-
|
|
746
|
-
& .semi-tree-select-selection-content {
|
|
747
|
-
width: 100%;
|
|
748
|
-
}
|
|
749
|
-
|
|
750
|
-
& .semi-tree-select-selection-placeholder {
|
|
751
|
-
padding-left: 10px;
|
|
752
|
-
}
|
|
753
|
-
`;
|
|
754
|
-
var UIPopoverContent = styled2.div`
|
|
755
|
-
padding: 10px;
|
|
756
|
-
display: inline-flex;
|
|
757
|
-
align-items: center;
|
|
758
|
-
justify-content: flex-start;
|
|
759
|
-
white-space: nowrap;
|
|
760
|
-
`;
|
|
761
|
-
|
|
762
|
-
// src/components/variable-selector/index.tsx
|
|
763
|
-
var VariableSelector = ({
|
|
764
|
-
value,
|
|
765
|
-
config = {},
|
|
766
|
-
onChange,
|
|
767
|
-
style,
|
|
768
|
-
readonly = false,
|
|
769
|
-
includeSchema,
|
|
770
|
-
excludeSchema,
|
|
771
|
-
hasError,
|
|
772
|
-
triggerRender
|
|
773
|
-
}) => {
|
|
774
|
-
const treeData = useVariableTree({ includeSchema, excludeSchema });
|
|
775
|
-
const treeValue = useMemo(() => {
|
|
776
|
-
if (typeof value === "string") {
|
|
777
|
-
console.warn(
|
|
778
|
-
"The Value of VariableSelector is a string, it should be an ARRAY. \n",
|
|
779
|
-
"Please check the value of VariableSelector \n"
|
|
780
|
-
);
|
|
781
|
-
return value;
|
|
782
|
-
}
|
|
783
|
-
return value?.join(".");
|
|
784
|
-
}, [value]);
|
|
785
|
-
const renderIcon = (icon) => {
|
|
786
|
-
if (typeof icon === "string") {
|
|
787
|
-
return /* @__PURE__ */ React12.createElement("img", { style: { marginRight: 8 }, width: 12, height: 12, src: icon });
|
|
788
|
-
}
|
|
789
|
-
return icon;
|
|
790
|
-
};
|
|
791
|
-
return /* @__PURE__ */ React12.createElement(React12.Fragment, null, /* @__PURE__ */ React12.createElement(
|
|
792
|
-
UITreeSelect,
|
|
793
|
-
{
|
|
794
|
-
dropdownMatchSelectWidth: false,
|
|
795
|
-
disabled: readonly,
|
|
796
|
-
treeData,
|
|
797
|
-
size: "small",
|
|
798
|
-
value: treeValue,
|
|
799
|
-
clearIcon: null,
|
|
800
|
-
$error: hasError,
|
|
801
|
-
style,
|
|
802
|
-
validateStatus: hasError ? "error" : void 0,
|
|
803
|
-
onChange: (_, _config) => {
|
|
804
|
-
onChange(_config.keyPath);
|
|
805
|
-
},
|
|
806
|
-
renderSelectedItem: (_option) => {
|
|
807
|
-
if (!_option?.keyPath) {
|
|
808
|
-
return /* @__PURE__ */ React12.createElement(
|
|
809
|
-
UITag,
|
|
810
|
-
{
|
|
811
|
-
prefixIcon: /* @__PURE__ */ React12.createElement(IconIssueStroked, null),
|
|
812
|
-
color: "amber",
|
|
813
|
-
closable: !readonly,
|
|
814
|
-
onClose: () => onChange(void 0)
|
|
815
|
-
},
|
|
816
|
-
config?.notFoundContent ?? "Undefined"
|
|
817
|
-
);
|
|
818
|
-
}
|
|
819
|
-
const rootIcon = renderIcon(_option.rootMeta?.icon || _option?.icon);
|
|
820
|
-
const rootTitle = /* @__PURE__ */ React12.createElement(UIRootTitle, null, _option.rootMeta?.title ? `${_option.rootMeta?.title} ${_option.isRoot ? "" : "-"} ` : null);
|
|
821
|
-
return /* @__PURE__ */ React12.createElement("div", null, /* @__PURE__ */ React12.createElement(
|
|
822
|
-
Popover,
|
|
823
|
-
{
|
|
824
|
-
content: /* @__PURE__ */ React12.createElement(UIPopoverContent, null, rootIcon, rootTitle, /* @__PURE__ */ React12.createElement(UIVarName, null, _option.keyPath.slice(1).join(".")))
|
|
825
|
-
},
|
|
826
|
-
/* @__PURE__ */ React12.createElement(
|
|
827
|
-
UITag,
|
|
828
|
-
{
|
|
829
|
-
prefixIcon: rootIcon,
|
|
830
|
-
closable: !readonly,
|
|
831
|
-
onClose: () => onChange(void 0)
|
|
832
|
-
},
|
|
833
|
-
rootTitle,
|
|
834
|
-
!_option.isRoot && /* @__PURE__ */ React12.createElement(UIVarName, { $inSelector: true }, _option.label)
|
|
835
|
-
)
|
|
836
|
-
));
|
|
837
|
-
},
|
|
838
|
-
showClear: false,
|
|
839
|
-
arrowIcon: /* @__PURE__ */ React12.createElement(IconChevronDownStroked, { size: "small" }),
|
|
840
|
-
triggerRender,
|
|
841
|
-
placeholder: config?.placeholder ?? I18n7.t("Select Variable")
|
|
842
|
-
}
|
|
843
|
-
));
|
|
844
|
-
};
|
|
845
|
-
VariableSelector.renderKey = "variable-selector-render-key";
|
|
846
|
-
var InjectVariableSelector = createInjectMaterial(VariableSelector);
|
|
18
|
+
FlowValueUtils,
|
|
19
|
+
createInjectMaterial,
|
|
20
|
+
formatLegacyRefOnInit,
|
|
21
|
+
formatLegacyRefOnSubmit,
|
|
22
|
+
formatLegacyRefToNewRef,
|
|
23
|
+
formatNewRefToLegacyRef,
|
|
24
|
+
isLegacyFlowRefValueSchema,
|
|
25
|
+
isNewFlowRefValueSchema,
|
|
26
|
+
lazySuspense,
|
|
27
|
+
polyfillCreateRoot,
|
|
28
|
+
unstableSetCreateRoot,
|
|
29
|
+
withSuspense
|
|
30
|
+
} from "./chunk-DEZUEMUM.js";
|
|
847
31
|
|
|
848
32
|
// src/components/type-selector/index.tsx
|
|
849
|
-
import
|
|
850
|
-
import { Cascader, Icon
|
|
33
|
+
import React, { useMemo } from "react";
|
|
34
|
+
import { Cascader, Icon, IconButton } from "@douyinfe/semi-ui";
|
|
851
35
|
var labelStyle = { display: "flex", alignItems: "center", gap: 5 };
|
|
852
36
|
var getTypeSelectValue = (value) => {
|
|
853
37
|
if (value?.type === "array" && value?.items) {
|
|
@@ -864,18 +48,18 @@ var parseTypeSelectValue = (value) => {
|
|
|
864
48
|
};
|
|
865
49
|
function TypeSelector(props) {
|
|
866
50
|
const { value, onChange, readonly, disabled, style } = props;
|
|
867
|
-
const selectValue =
|
|
51
|
+
const selectValue = useMemo(() => getTypeSelectValue(value), [value]);
|
|
868
52
|
const typeManager = useTypeManager();
|
|
869
53
|
const icon = typeManager.getDisplayIcon(value || {});
|
|
870
|
-
const options =
|
|
54
|
+
const options = useMemo(
|
|
871
55
|
() => typeManager.getTypeRegistriesWithParentType().map((_type) => {
|
|
872
|
-
const
|
|
56
|
+
const isArray = _type.type === "array";
|
|
873
57
|
return {
|
|
874
|
-
label: /* @__PURE__ */
|
|
58
|
+
label: /* @__PURE__ */ React.createElement("div", { style: labelStyle }, /* @__PURE__ */ React.createElement(Icon, { size: "small", svg: _type.icon }), typeManager.getTypeBySchema(_type)?.label || _type.type),
|
|
875
59
|
value: _type.type,
|
|
876
|
-
children:
|
|
877
|
-
label: /* @__PURE__ */
|
|
878
|
-
|
|
60
|
+
children: isArray ? typeManager.getTypeRegistriesWithParentType("array").map((_type2) => ({
|
|
61
|
+
label: /* @__PURE__ */ React.createElement("div", { style: labelStyle }, /* @__PURE__ */ React.createElement(
|
|
62
|
+
Icon,
|
|
879
63
|
{
|
|
880
64
|
size: "small",
|
|
881
65
|
svg: typeManager.getDisplayIcon({
|
|
@@ -890,12 +74,24 @@ function TypeSelector(props) {
|
|
|
890
74
|
}),
|
|
891
75
|
[]
|
|
892
76
|
);
|
|
893
|
-
|
|
77
|
+
const isDisabled = readonly || disabled;
|
|
78
|
+
return /* @__PURE__ */ React.createElement(
|
|
894
79
|
Cascader,
|
|
895
80
|
{
|
|
896
|
-
disabled:
|
|
81
|
+
disabled: isDisabled,
|
|
897
82
|
size: "small",
|
|
898
|
-
triggerRender: () => /* @__PURE__ */
|
|
83
|
+
triggerRender: () => /* @__PURE__ */ React.createElement(
|
|
84
|
+
IconButton,
|
|
85
|
+
{
|
|
86
|
+
size: "small",
|
|
87
|
+
style: {
|
|
88
|
+
...isDisabled ? { pointerEvents: "none" } : {},
|
|
89
|
+
...style || {}
|
|
90
|
+
},
|
|
91
|
+
disabled: isDisabled,
|
|
92
|
+
icon
|
|
93
|
+
}
|
|
94
|
+
),
|
|
899
95
|
treeData: options,
|
|
900
96
|
value: selectValue,
|
|
901
97
|
leafOnly: true,
|
|
@@ -909,8 +105,8 @@ TypeSelector.renderKey = "type-selector-render-key";
|
|
|
909
105
|
var InjectTypeSelector = createInjectMaterial(TypeSelector);
|
|
910
106
|
|
|
911
107
|
// src/components/json-schema-editor/index.tsx
|
|
912
|
-
import
|
|
913
|
-
import { I18n as
|
|
108
|
+
import React6, { useMemo as useMemo3, useState as useState3 } from "react";
|
|
109
|
+
import { I18n as I18n2 } from "@flowgram.ai/editor";
|
|
914
110
|
import { Button, Checkbox, IconButton as IconButton2 } from "@douyinfe/semi-ui";
|
|
915
111
|
import {
|
|
916
112
|
IconExpand,
|
|
@@ -921,62 +117,81 @@ import {
|
|
|
921
117
|
IconMinus
|
|
922
118
|
} from "@douyinfe/semi-icons";
|
|
923
119
|
|
|
120
|
+
// src/components/blur-input/index.tsx
|
|
121
|
+
import React2, { useEffect, useState } from "react";
|
|
122
|
+
import Input from "@douyinfe/semi-ui/lib/es/input";
|
|
123
|
+
function BlurInput(props) {
|
|
124
|
+
const [value, setValue] = useState("");
|
|
125
|
+
useEffect(() => {
|
|
126
|
+
setValue(props.value);
|
|
127
|
+
}, [props.value]);
|
|
128
|
+
return /* @__PURE__ */ React2.createElement(
|
|
129
|
+
Input,
|
|
130
|
+
{
|
|
131
|
+
...props,
|
|
132
|
+
value,
|
|
133
|
+
onChange: (value2) => {
|
|
134
|
+
setValue(value2);
|
|
135
|
+
},
|
|
136
|
+
onBlur: (e) => props.onChange?.(value, e)
|
|
137
|
+
}
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
|
|
924
141
|
// src/components/json-schema-editor/styles.tsx
|
|
925
|
-
import
|
|
926
|
-
import
|
|
927
|
-
import
|
|
928
|
-
var UIContainer =
|
|
142
|
+
import React3 from "react";
|
|
143
|
+
import styled, { css } from "styled-components";
|
|
144
|
+
import Icon2 from "@douyinfe/semi-icons";
|
|
145
|
+
var UIContainer = styled.div`
|
|
929
146
|
/* & .semi-input {
|
|
930
147
|
background-color: #fff;
|
|
931
148
|
border-radius: 6px;
|
|
932
149
|
height: 24px;
|
|
933
150
|
} */
|
|
934
151
|
`;
|
|
935
|
-
var UIRow =
|
|
152
|
+
var UIRow = styled.div`
|
|
936
153
|
display: flex;
|
|
937
154
|
align-items: center;
|
|
938
155
|
gap: 6px;
|
|
939
156
|
`;
|
|
940
|
-
var UICollapseTrigger =
|
|
157
|
+
var UICollapseTrigger = styled.div`
|
|
941
158
|
cursor: pointer;
|
|
942
159
|
margin-right: 5px;
|
|
943
160
|
`;
|
|
944
|
-
var UIExpandDetail =
|
|
161
|
+
var UIExpandDetail = styled.div`
|
|
945
162
|
display: flex;
|
|
946
163
|
flex-direction: column;
|
|
947
164
|
`;
|
|
948
|
-
var UILabel =
|
|
165
|
+
var UILabel = styled.div`
|
|
949
166
|
font-size: 12px;
|
|
950
167
|
color: #999;
|
|
951
168
|
font-weight: 400;
|
|
952
169
|
margin-bottom: 2px;
|
|
953
170
|
`;
|
|
954
|
-
var
|
|
171
|
+
var UITreeItems = styled.div`
|
|
955
172
|
display: grid;
|
|
956
173
|
grid-template-columns: auto 1fr;
|
|
957
174
|
|
|
958
|
-
${({ $shrink }) => $shrink &&
|
|
959
|
-
padding-left:
|
|
175
|
+
${({ $shrink }) => $shrink && css`
|
|
176
|
+
padding-left: 3px;
|
|
960
177
|
margin-top: 10px;
|
|
961
178
|
`}
|
|
962
179
|
`;
|
|
963
|
-
var
|
|
180
|
+
var UITreeItemLeft = styled.div`
|
|
964
181
|
grid-column: 1;
|
|
965
182
|
position: relative;
|
|
966
183
|
width: 16px;
|
|
967
184
|
|
|
968
|
-
${({ $showLine, $isLast, $
|
|
969
|
-
let height = "100%";
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
}
|
|
973
|
-
return $showLine && css2`
|
|
185
|
+
${({ $showLine, $isLast, $showCollapse }) => {
|
|
186
|
+
let height = $isLast ? "24px" : "100%";
|
|
187
|
+
let width = $showCollapse ? "12px" : "30px";
|
|
188
|
+
return $showLine && css`
|
|
974
189
|
&::before {
|
|
975
190
|
/* 竖线 */
|
|
976
191
|
content: '';
|
|
977
192
|
height: ${height};
|
|
978
193
|
position: absolute;
|
|
979
|
-
left: -
|
|
194
|
+
left: -14px;
|
|
980
195
|
top: -16px;
|
|
981
196
|
width: 1px;
|
|
982
197
|
background: #d9d9d9;
|
|
@@ -987,9 +202,9 @@ var UIPropertyLeft = styled3.div`
|
|
|
987
202
|
/* 横线 */
|
|
988
203
|
content: '';
|
|
989
204
|
position: absolute;
|
|
990
|
-
left: -
|
|
205
|
+
left: -14px; // 横线起点和竖线对齐
|
|
991
206
|
top: 8px; // 跟随你的行高调整
|
|
992
|
-
width:
|
|
207
|
+
width: ${width}; // 横线长度
|
|
993
208
|
height: 1px;
|
|
994
209
|
background: #d9d9d9;
|
|
995
210
|
display: block;
|
|
@@ -997,7 +212,7 @@ var UIPropertyLeft = styled3.div`
|
|
|
997
212
|
`;
|
|
998
213
|
}}
|
|
999
214
|
`;
|
|
1000
|
-
var
|
|
215
|
+
var UITreeItemRight = styled.div`
|
|
1001
216
|
grid-column: 2;
|
|
1002
217
|
margin-bottom: 10px;
|
|
1003
218
|
|
|
@@ -1005,52 +220,28 @@ var UIPropertyRight = styled3.div`
|
|
|
1005
220
|
margin-bottom: 0px;
|
|
1006
221
|
}
|
|
1007
222
|
`;
|
|
1008
|
-
var
|
|
223
|
+
var UITreeItemMain = styled.div`
|
|
1009
224
|
display: flex;
|
|
1010
225
|
flex-direction: column;
|
|
1011
226
|
gap: 10px;
|
|
1012
227
|
position: relative;
|
|
1013
|
-
|
|
1014
|
-
${({ $expand, type, $collapse, $showCollapse }) => {
|
|
1015
|
-
const beforeElement = `
|
|
1016
|
-
&::before {
|
|
1017
|
-
/* \u7AD6\u7EBF */
|
|
1018
|
-
content: '';
|
|
1019
|
-
height: 100%;
|
|
1020
|
-
position: absolute;
|
|
1021
|
-
left: -12px;
|
|
1022
|
-
top: 18px;
|
|
1023
|
-
width: 1px;
|
|
1024
|
-
background: #d9d9d9;
|
|
1025
|
-
display: block;
|
|
1026
|
-
}`;
|
|
1027
|
-
return $expand && css2`
|
|
1028
|
-
background-color: #f5f5f5;
|
|
1029
|
-
padding: 10px;
|
|
1030
|
-
border-radius: 4px;
|
|
1031
|
-
|
|
1032
|
-
${$showCollapse && $collapse && (type === "array" || type === "object") && css2`
|
|
1033
|
-
${beforeElement}
|
|
1034
|
-
`}
|
|
1035
|
-
`;
|
|
1036
|
-
}}
|
|
1037
228
|
`;
|
|
1038
|
-
var UICollapsible =
|
|
229
|
+
var UICollapsible = styled.div`
|
|
1039
230
|
display: none;
|
|
1040
231
|
|
|
1041
|
-
${({ $collapse }) => $collapse &&
|
|
232
|
+
${({ $collapse }) => $collapse && css`
|
|
1042
233
|
display: block;
|
|
1043
234
|
`}
|
|
1044
235
|
`;
|
|
1045
|
-
var UIName =
|
|
236
|
+
var UIName = styled.div`
|
|
1046
237
|
flex-grow: 1;
|
|
1047
238
|
`;
|
|
1048
|
-
var UIType =
|
|
1049
|
-
var UIRequired =
|
|
1050
|
-
var UIActions =
|
|
239
|
+
var UIType = styled.div``;
|
|
240
|
+
var UIRequired = styled.div``;
|
|
241
|
+
var UIActions = styled.div`
|
|
1051
242
|
white-space: nowrap;
|
|
1052
243
|
`;
|
|
1053
|
-
var iconAddChildrenSvg = /* @__PURE__ */
|
|
244
|
+
var iconAddChildrenSvg = /* @__PURE__ */ React3.createElement(
|
|
1054
245
|
"svg",
|
|
1055
246
|
{
|
|
1056
247
|
className: "icon-icon icon-icon-coz_add_node ",
|
|
@@ -1060,7 +251,7 @@ var iconAddChildrenSvg = /* @__PURE__ */ React14.createElement(
|
|
|
1060
251
|
fill: "currentColor",
|
|
1061
252
|
xmlns: "http://www.w3.org/2000/svg"
|
|
1062
253
|
},
|
|
1063
|
-
/* @__PURE__ */
|
|
254
|
+
/* @__PURE__ */ React3.createElement(
|
|
1064
255
|
"path",
|
|
1065
256
|
{
|
|
1066
257
|
fillRule: "evenodd",
|
|
@@ -1068,13 +259,13 @@ var iconAddChildrenSvg = /* @__PURE__ */ React14.createElement(
|
|
|
1068
259
|
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"
|
|
1069
260
|
}
|
|
1070
261
|
),
|
|
1071
|
-
/* @__PURE__ */
|
|
262
|
+
/* @__PURE__ */ React3.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" })
|
|
1072
263
|
);
|
|
1073
|
-
var IconAddChildren = () => /* @__PURE__ */
|
|
1074
|
-
var DefaultValueWrapper =
|
|
264
|
+
var IconAddChildren = () => /* @__PURE__ */ React3.createElement(Icon2, { size: "small", svg: iconAddChildrenSvg });
|
|
265
|
+
var DefaultValueWrapper = styled.div`
|
|
1075
266
|
margin: 0;
|
|
1076
267
|
`;
|
|
1077
|
-
var ConstantInputWrapper =
|
|
268
|
+
var ConstantInputWrapper = styled.div`
|
|
1078
269
|
flex-grow: 1;
|
|
1079
270
|
|
|
1080
271
|
& .semi-tree-select,
|
|
@@ -1085,8 +276,8 @@ var ConstantInputWrapper = styled3.div`
|
|
|
1085
276
|
`;
|
|
1086
277
|
|
|
1087
278
|
// src/components/json-schema-editor/hooks.tsx
|
|
1088
|
-
import { useEffect as useEffect2, useState } from "react";
|
|
1089
|
-
import { difference, omit } from "lodash";
|
|
279
|
+
import { useEffect as useEffect2, useRef, useState as useState2 } from "react";
|
|
280
|
+
import { difference, omit } from "lodash-es";
|
|
1090
281
|
import { produce } from "immer";
|
|
1091
282
|
import { useTypeManager as useTypeManager2 } from "@flowgram.ai/json-schema";
|
|
1092
283
|
var _id = 0;
|
|
@@ -1097,8 +288,15 @@ function usePropertiesEdit(value, onChange) {
|
|
|
1097
288
|
const typeManager = useTypeManager2();
|
|
1098
289
|
const drilldownSchema = typeManager.getPropertiesParent(value || {});
|
|
1099
290
|
const canAddField = typeManager.canAddField(value || {});
|
|
1100
|
-
const [propertyList, setPropertyList] =
|
|
291
|
+
const [propertyList, setPropertyList] = useState2([]);
|
|
292
|
+
const effectVersion = useRef(0);
|
|
293
|
+
const changeVersion = useRef(0);
|
|
1101
294
|
useEffect2(() => {
|
|
295
|
+
effectVersion.current = effectVersion.current + 1;
|
|
296
|
+
if (effectVersion.current === changeVersion.current) {
|
|
297
|
+
return;
|
|
298
|
+
}
|
|
299
|
+
effectVersion.current = changeVersion.current;
|
|
1102
300
|
setPropertyList((_list) => {
|
|
1103
301
|
const newNames = Object.entries(drilldownSchema?.properties || {}).sort(([, a], [, b]) => (a.extra?.index ?? 0) - (b.extra?.index ?? 0)).map(([key]) => key);
|
|
1104
302
|
const oldNames = _list.map((item) => item.name).filter(Boolean);
|
|
@@ -1107,7 +305,7 @@ function usePropertiesEdit(value, onChange) {
|
|
|
1107
305
|
key: item.key,
|
|
1108
306
|
name: item.name,
|
|
1109
307
|
isPropertyRequired: drilldownSchema?.required?.includes(item.name || "") || false,
|
|
1110
|
-
...item
|
|
308
|
+
...drilldownSchema?.properties?.[item.name || ""] || item || {}
|
|
1111
309
|
})).concat(
|
|
1112
310
|
addNames.map((_name) => ({
|
|
1113
311
|
key: genId(),
|
|
@@ -1119,6 +317,7 @@ function usePropertiesEdit(value, onChange) {
|
|
|
1119
317
|
});
|
|
1120
318
|
}, [drilldownSchema]);
|
|
1121
319
|
const updatePropertyList = (updater) => {
|
|
320
|
+
changeVersion.current = changeVersion.current + 1;
|
|
1122
321
|
setPropertyList((_list) => {
|
|
1123
322
|
const next = updater(_list);
|
|
1124
323
|
const nextProperties = {};
|
|
@@ -1174,71 +373,51 @@ function usePropertiesEdit(value, onChange) {
|
|
|
1174
373
|
}
|
|
1175
374
|
|
|
1176
375
|
// src/components/json-schema-editor/default-value.tsx
|
|
1177
|
-
import
|
|
1178
|
-
import { I18n
|
|
376
|
+
import React5 from "react";
|
|
377
|
+
import { I18n } from "@flowgram.ai/editor";
|
|
1179
378
|
|
|
1180
379
|
// src/components/constant-input/index.tsx
|
|
1181
|
-
import
|
|
380
|
+
import React4, { useMemo as useMemo2 } from "react";
|
|
1182
381
|
import { Input as Input2 } from "@douyinfe/semi-ui";
|
|
1183
382
|
function ConstantInput(props) {
|
|
1184
383
|
const { value, onChange, schema, strategies, fallbackRenderer, readonly, ...rest } = props;
|
|
1185
384
|
const typeManager = useTypeManager();
|
|
1186
|
-
const
|
|
385
|
+
const Renderer = useMemo2(() => {
|
|
1187
386
|
const strategy = (strategies || []).find((_strategy) => _strategy.hit(schema));
|
|
1188
387
|
if (!strategy) {
|
|
1189
388
|
return typeManager.getTypeBySchema(schema)?.ConstantRenderer;
|
|
1190
389
|
}
|
|
1191
390
|
return strategy?.Renderer;
|
|
1192
391
|
}, [strategies, schema]);
|
|
1193
|
-
if (!
|
|
392
|
+
if (!Renderer) {
|
|
1194
393
|
if (fallbackRenderer) {
|
|
1195
|
-
return
|
|
394
|
+
return React4.createElement(fallbackRenderer, {
|
|
1196
395
|
value,
|
|
1197
396
|
onChange,
|
|
1198
397
|
readonly,
|
|
1199
398
|
...rest
|
|
1200
399
|
});
|
|
1201
400
|
}
|
|
1202
|
-
return /* @__PURE__ */
|
|
401
|
+
return /* @__PURE__ */ React4.createElement(Input2, { size: "small", disabled: true, placeholder: "Unsupported type" });
|
|
1203
402
|
}
|
|
1204
|
-
return /* @__PURE__ */
|
|
403
|
+
return /* @__PURE__ */ React4.createElement(Renderer, { value, onChange, readonly, ...rest });
|
|
1205
404
|
}
|
|
1206
405
|
|
|
1207
406
|
// src/components/json-schema-editor/default-value.tsx
|
|
1208
407
|
function DefaultValue(props) {
|
|
1209
408
|
const { value, schema, onChange, placeholder } = props;
|
|
1210
|
-
return /* @__PURE__ */
|
|
409
|
+
return /* @__PURE__ */ React5.createElement(ConstantInputWrapper, null, /* @__PURE__ */ React5.createElement(
|
|
1211
410
|
ConstantInput,
|
|
1212
411
|
{
|
|
1213
412
|
value,
|
|
1214
413
|
onChange: (_v) => onChange(_v),
|
|
1215
414
|
schema: schema || { type: "string" },
|
|
1216
|
-
placeholder: placeholder ??
|
|
415
|
+
placeholder: placeholder ?? I18n.t("Default value if parameter is not provided"),
|
|
416
|
+
enableMultiLineStr: true
|
|
1217
417
|
}
|
|
1218
418
|
));
|
|
1219
419
|
}
|
|
1220
420
|
|
|
1221
|
-
// src/components/json-schema-editor/components/blur-input.tsx
|
|
1222
|
-
import React17, { useEffect as useEffect3, useState as useState2 } from "react";
|
|
1223
|
-
import Input3 from "@douyinfe/semi-ui/lib/es/input";
|
|
1224
|
-
function BlurInput(props) {
|
|
1225
|
-
const [value, setValue] = useState2("");
|
|
1226
|
-
useEffect3(() => {
|
|
1227
|
-
setValue(props.value);
|
|
1228
|
-
}, [props.value]);
|
|
1229
|
-
return /* @__PURE__ */ React17.createElement(
|
|
1230
|
-
Input3,
|
|
1231
|
-
{
|
|
1232
|
-
...props,
|
|
1233
|
-
value,
|
|
1234
|
-
onChange: (value2) => {
|
|
1235
|
-
setValue(value2);
|
|
1236
|
-
},
|
|
1237
|
-
onBlur: (e) => props.onChange?.(value, e)
|
|
1238
|
-
}
|
|
1239
|
-
);
|
|
1240
|
-
}
|
|
1241
|
-
|
|
1242
421
|
// src/components/json-schema-editor/index.tsx
|
|
1243
422
|
var DEFAULT = { type: "object" };
|
|
1244
423
|
function JsonSchemaEditor(props) {
|
|
@@ -1247,14 +426,13 @@ function JsonSchemaEditor(props) {
|
|
|
1247
426
|
value,
|
|
1248
427
|
onChangeProps
|
|
1249
428
|
);
|
|
1250
|
-
return /* @__PURE__ */
|
|
429
|
+
return /* @__PURE__ */ React6.createElement(UIContainer, { className: props.className }, /* @__PURE__ */ React6.createElement(UITreeItems, null, propertyList.map((_property) => /* @__PURE__ */ React6.createElement(
|
|
1251
430
|
PropertyEdit,
|
|
1252
431
|
{
|
|
1253
432
|
readonly,
|
|
1254
433
|
key: _property.key,
|
|
1255
434
|
value: _property,
|
|
1256
435
|
config,
|
|
1257
|
-
$index: index,
|
|
1258
436
|
onChange: (_v) => {
|
|
1259
437
|
onEditProperty(_property.key, _v);
|
|
1260
438
|
},
|
|
@@ -1262,37 +440,24 @@ function JsonSchemaEditor(props) {
|
|
|
1262
440
|
onRemoveProperty(_property.key);
|
|
1263
441
|
}
|
|
1264
442
|
}
|
|
1265
|
-
))), /* @__PURE__ */
|
|
443
|
+
))), /* @__PURE__ */ React6.createElement(
|
|
1266
444
|
Button,
|
|
1267
445
|
{
|
|
1268
446
|
disabled: readonly,
|
|
1269
447
|
size: "small",
|
|
1270
448
|
style: { marginTop: 10, marginLeft: 16 },
|
|
1271
|
-
icon: /* @__PURE__ */
|
|
449
|
+
icon: /* @__PURE__ */ React6.createElement(IconPlus, null),
|
|
1272
450
|
onClick: onAddProperty
|
|
1273
451
|
},
|
|
1274
|
-
config?.addButtonText ??
|
|
452
|
+
config?.addButtonText ?? I18n2.t("Add")
|
|
1275
453
|
));
|
|
1276
454
|
}
|
|
1277
455
|
function PropertyEdit(props) {
|
|
1278
|
-
const {
|
|
1279
|
-
value,
|
|
1280
|
-
config,
|
|
1281
|
-
readonly,
|
|
1282
|
-
$level = 0,
|
|
1283
|
-
onChange: onChangeProps,
|
|
1284
|
-
onRemove,
|
|
1285
|
-
$index,
|
|
1286
|
-
$isFirst,
|
|
1287
|
-
$isLast,
|
|
1288
|
-
$parentExpand = false,
|
|
1289
|
-
$parentType = "",
|
|
1290
|
-
$showLine
|
|
1291
|
-
} = props;
|
|
456
|
+
const { value, config, readonly, $level = 0, onChange: onChangeProps, onRemove, $isLast } = props;
|
|
1292
457
|
const [expand, setExpand] = useState3(false);
|
|
1293
458
|
const [collapse, setCollapse] = useState3(false);
|
|
1294
459
|
const { name, type, items, default: defaultValue, description, isPropertyRequired } = value || {};
|
|
1295
|
-
const typeSelectorValue =
|
|
460
|
+
const typeSelectorValue = useMemo3(() => ({ type, items }), [type, items]);
|
|
1296
461
|
const { propertyList, canAddField, onAddProperty, onRemoveProperty, onEditProperty } = usePropertiesEdit(value, onChangeProps);
|
|
1297
462
|
const onChange = (key, _value) => {
|
|
1298
463
|
onChangeProps?.({
|
|
@@ -1301,109 +466,84 @@ function PropertyEdit(props) {
|
|
|
1301
466
|
});
|
|
1302
467
|
};
|
|
1303
468
|
const showCollapse = canAddField && propertyList.length > 0;
|
|
1304
|
-
return /* @__PURE__ */
|
|
1305
|
-
|
|
469
|
+
return /* @__PURE__ */ React6.createElement(React6.Fragment, null, /* @__PURE__ */ React6.createElement(UITreeItemLeft, { $isLast, $showLine: $level > 0, $showCollapse: showCollapse }, showCollapse && /* @__PURE__ */ React6.createElement(UICollapseTrigger, { onClick: () => setCollapse((_collapse) => !_collapse) }, collapse ? /* @__PURE__ */ React6.createElement(IconChevronDown, { size: "small" }) : /* @__PURE__ */ React6.createElement(IconChevronRight, { size: "small" }))), /* @__PURE__ */ React6.createElement(UITreeItemRight, null, /* @__PURE__ */ React6.createElement(UITreeItemMain, null, /* @__PURE__ */ React6.createElement(UIRow, null, /* @__PURE__ */ React6.createElement(UIName, null, /* @__PURE__ */ React6.createElement(
|
|
470
|
+
BlurInput,
|
|
1306
471
|
{
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
},
|
|
1316
|
-
showCollapse && /* @__PURE__ */ React18.createElement(UICollapseTrigger, { onClick: () => setCollapse((_collapse) => !_collapse) }, collapse ? /* @__PURE__ */ React18.createElement(IconChevronDown, { size: "small" }) : /* @__PURE__ */ React18.createElement(IconChevronRight, { size: "small" }))
|
|
1317
|
-
), /* @__PURE__ */ React18.createElement(UIPropertyRight, null, /* @__PURE__ */ React18.createElement(
|
|
1318
|
-
UIPropertyMain,
|
|
472
|
+
disabled: readonly,
|
|
473
|
+
placeholder: config?.placeholder ?? I18n2.t("Input Variable Name"),
|
|
474
|
+
size: "small",
|
|
475
|
+
value: name,
|
|
476
|
+
onChange: (value2) => onChange("name", value2)
|
|
477
|
+
}
|
|
478
|
+
)), /* @__PURE__ */ React6.createElement(UIType, null, /* @__PURE__ */ React6.createElement(
|
|
479
|
+
InjectTypeSelector,
|
|
1319
480
|
{
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
{
|
|
1328
|
-
disabled: readonly,
|
|
1329
|
-
placeholder: config?.placeholder ?? "Input Variable Name",
|
|
1330
|
-
size: "small",
|
|
1331
|
-
value: name,
|
|
1332
|
-
onChange: (value2) => onChange("name", value2)
|
|
1333
|
-
}
|
|
1334
|
-
)), /* @__PURE__ */ React18.createElement(UIType, null, /* @__PURE__ */ React18.createElement(
|
|
1335
|
-
InjectTypeSelector,
|
|
1336
|
-
{
|
|
1337
|
-
value: typeSelectorValue,
|
|
1338
|
-
readonly,
|
|
1339
|
-
onChange: (_value) => {
|
|
1340
|
-
onChangeProps?.({
|
|
1341
|
-
...value || {},
|
|
1342
|
-
..._value
|
|
1343
|
-
});
|
|
1344
|
-
}
|
|
1345
|
-
}
|
|
1346
|
-
)), /* @__PURE__ */ React18.createElement(UIRequired, null, /* @__PURE__ */ React18.createElement(
|
|
1347
|
-
Checkbox,
|
|
1348
|
-
{
|
|
1349
|
-
disabled: readonly,
|
|
1350
|
-
checked: isPropertyRequired,
|
|
1351
|
-
onChange: (e) => onChange("isPropertyRequired", e.target.checked)
|
|
1352
|
-
}
|
|
1353
|
-
)), /* @__PURE__ */ React18.createElement(UIActions, null, /* @__PURE__ */ React18.createElement(
|
|
1354
|
-
IconButton2,
|
|
1355
|
-
{
|
|
1356
|
-
disabled: readonly,
|
|
1357
|
-
size: "small",
|
|
1358
|
-
theme: "borderless",
|
|
1359
|
-
icon: expand ? /* @__PURE__ */ React18.createElement(IconShrink, { size: "small" }) : /* @__PURE__ */ React18.createElement(IconExpand, { size: "small" }),
|
|
1360
|
-
onClick: () => {
|
|
1361
|
-
setExpand((_expand) => !_expand);
|
|
1362
|
-
}
|
|
1363
|
-
}
|
|
1364
|
-
), canAddField && /* @__PURE__ */ React18.createElement(
|
|
1365
|
-
IconButton2,
|
|
1366
|
-
{
|
|
1367
|
-
disabled: readonly,
|
|
1368
|
-
size: "small",
|
|
1369
|
-
theme: "borderless",
|
|
1370
|
-
icon: /* @__PURE__ */ React18.createElement(IconAddChildren, null),
|
|
1371
|
-
onClick: () => {
|
|
1372
|
-
onAddProperty();
|
|
1373
|
-
setCollapse(true);
|
|
1374
|
-
}
|
|
1375
|
-
}
|
|
1376
|
-
), /* @__PURE__ */ React18.createElement(
|
|
1377
|
-
IconButton2,
|
|
1378
|
-
{
|
|
1379
|
-
disabled: readonly,
|
|
1380
|
-
size: "small",
|
|
1381
|
-
theme: "borderless",
|
|
1382
|
-
icon: /* @__PURE__ */ React18.createElement(IconMinus, { size: "small" }),
|
|
1383
|
-
onClick: onRemove
|
|
481
|
+
value: typeSelectorValue,
|
|
482
|
+
readonly,
|
|
483
|
+
onChange: (_value) => {
|
|
484
|
+
onChangeProps?.({
|
|
485
|
+
...value || {},
|
|
486
|
+
..._value
|
|
487
|
+
});
|
|
1384
488
|
}
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
489
|
+
}
|
|
490
|
+
)), /* @__PURE__ */ React6.createElement(UIRequired, null, /* @__PURE__ */ React6.createElement(
|
|
491
|
+
Checkbox,
|
|
492
|
+
{
|
|
493
|
+
disabled: readonly,
|
|
494
|
+
checked: isPropertyRequired,
|
|
495
|
+
onChange: (e) => onChange("isPropertyRequired", e.target.checked)
|
|
496
|
+
}
|
|
497
|
+
)), /* @__PURE__ */ React6.createElement(UIActions, null, /* @__PURE__ */ React6.createElement(
|
|
498
|
+
IconButton2,
|
|
499
|
+
{
|
|
500
|
+
disabled: readonly,
|
|
501
|
+
size: "small",
|
|
502
|
+
theme: "borderless",
|
|
503
|
+
icon: expand ? /* @__PURE__ */ React6.createElement(IconShrink, { size: "small" }) : /* @__PURE__ */ React6.createElement(IconExpand, { size: "small" }),
|
|
504
|
+
onClick: () => {
|
|
505
|
+
setExpand((_expand) => !_expand);
|
|
1394
506
|
}
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
507
|
+
}
|
|
508
|
+
), canAddField && /* @__PURE__ */ React6.createElement(
|
|
509
|
+
IconButton2,
|
|
510
|
+
{
|
|
511
|
+
disabled: readonly,
|
|
512
|
+
size: "small",
|
|
513
|
+
theme: "borderless",
|
|
514
|
+
icon: /* @__PURE__ */ React6.createElement(IconAddChildren, null),
|
|
515
|
+
onClick: () => {
|
|
516
|
+
onAddProperty();
|
|
517
|
+
setCollapse(true);
|
|
1404
518
|
}
|
|
1405
|
-
|
|
1406
|
-
),
|
|
519
|
+
}
|
|
520
|
+
), /* @__PURE__ */ React6.createElement(
|
|
521
|
+
IconButton2,
|
|
522
|
+
{
|
|
523
|
+
disabled: readonly,
|
|
524
|
+
size: "small",
|
|
525
|
+
theme: "borderless",
|
|
526
|
+
icon: /* @__PURE__ */ React6.createElement(IconMinus, { size: "small" }),
|
|
527
|
+
onClick: onRemove
|
|
528
|
+
}
|
|
529
|
+
))), expand && /* @__PURE__ */ React6.createElement(UIExpandDetail, null, /* @__PURE__ */ React6.createElement(UILabel, null, config?.descTitle ?? I18n2.t("Description")), /* @__PURE__ */ React6.createElement(
|
|
530
|
+
BlurInput,
|
|
531
|
+
{
|
|
532
|
+
disabled: readonly,
|
|
533
|
+
size: "small",
|
|
534
|
+
value: description,
|
|
535
|
+
onChange: (value2) => onChange("description", value2),
|
|
536
|
+
placeholder: config?.descPlaceholder ?? I18n2.t("Help LLM to understand the property")
|
|
537
|
+
}
|
|
538
|
+
), $level === 0 && /* @__PURE__ */ React6.createElement(React6.Fragment, null, /* @__PURE__ */ React6.createElement(UILabel, { style: { marginTop: 10 } }, config?.defaultValueTitle ?? I18n2.t("Default Value")), /* @__PURE__ */ React6.createElement(DefaultValueWrapper, null, /* @__PURE__ */ React6.createElement(
|
|
539
|
+
DefaultValue,
|
|
540
|
+
{
|
|
541
|
+
value: defaultValue,
|
|
542
|
+
schema: value,
|
|
543
|
+
placeholder: config?.defaultValuePlaceholder ?? I18n2.t("Default Value"),
|
|
544
|
+
onChange: (value2) => onChange("default", value2)
|
|
545
|
+
}
|
|
546
|
+
))))), showCollapse && /* @__PURE__ */ React6.createElement(UICollapsible, { $collapse: collapse }, /* @__PURE__ */ React6.createElement(UITreeItems, { $shrink: true }, propertyList.map((_property, index) => /* @__PURE__ */ React6.createElement(
|
|
1407
547
|
PropertyEdit,
|
|
1408
548
|
{
|
|
1409
549
|
readonly,
|
|
@@ -1411,42 +551,40 @@ function PropertyEdit(props) {
|
|
|
1411
551
|
value: _property,
|
|
1412
552
|
config,
|
|
1413
553
|
$level: $level + 1,
|
|
1414
|
-
$parentExpand: expand,
|
|
1415
|
-
$parentType: type,
|
|
1416
554
|
onChange: (_v) => {
|
|
1417
555
|
onEditProperty(_property.key, _v);
|
|
1418
556
|
},
|
|
1419
557
|
onRemove: () => {
|
|
1420
558
|
onRemoveProperty(_property.key);
|
|
1421
559
|
},
|
|
1422
|
-
$isLast: index === propertyList.length - 1
|
|
1423
|
-
$isFirst: index === 0,
|
|
1424
|
-
$index: index,
|
|
1425
|
-
$showLine: true
|
|
560
|
+
$isLast: index === propertyList.length - 1
|
|
1426
561
|
}
|
|
1427
562
|
))))));
|
|
1428
563
|
}
|
|
1429
564
|
|
|
1430
565
|
// src/components/batch-variable-selector/index.tsx
|
|
1431
|
-
import
|
|
566
|
+
import React7 from "react";
|
|
1432
567
|
import { PrivateScopeProvider } from "@flowgram.ai/editor";
|
|
1433
568
|
var batchVariableSchema = {
|
|
1434
569
|
type: "array",
|
|
1435
570
|
extra: { weak: true }
|
|
1436
571
|
};
|
|
1437
572
|
function BatchVariableSelector(props) {
|
|
1438
|
-
return /* @__PURE__ */
|
|
573
|
+
return /* @__PURE__ */ React7.createElement(PrivateScopeProvider, null, /* @__PURE__ */ React7.createElement(VariableSelector, { ...props, includeSchema: batchVariableSchema }));
|
|
1439
574
|
}
|
|
1440
575
|
|
|
1441
576
|
// src/components/dynamic-value-input/index.tsx
|
|
1442
|
-
import
|
|
1443
|
-
import {
|
|
577
|
+
import React8 from "react";
|
|
578
|
+
import {
|
|
579
|
+
JsonSchemaUtils as JsonSchemaUtils2,
|
|
580
|
+
useTypeManager as useTypeManager3
|
|
581
|
+
} from "@flowgram.ai/json-schema";
|
|
1444
582
|
import { IconButton as IconButton3 } from "@douyinfe/semi-ui";
|
|
1445
583
|
import { IconSetting } from "@douyinfe/semi-icons";
|
|
1446
584
|
|
|
1447
585
|
// src/components/dynamic-value-input/styles.tsx
|
|
1448
|
-
import
|
|
1449
|
-
var UIContainer2 =
|
|
586
|
+
import styled2 from "styled-components";
|
|
587
|
+
var UIContainer2 = styled2.div`
|
|
1450
588
|
display: flex;
|
|
1451
589
|
align-items: center;
|
|
1452
590
|
border-radius: 4px;
|
|
@@ -1456,10 +594,12 @@ var UIContainer2 = styled4.div`
|
|
|
1456
594
|
|
|
1457
595
|
background-color: var(--semi-color-fill-0);
|
|
1458
596
|
`;
|
|
1459
|
-
var UIMain =
|
|
597
|
+
var UIMain = styled2.div`
|
|
1460
598
|
flex-grow: 1;
|
|
1461
599
|
overflow: hidden;
|
|
1462
600
|
min-width: 0;
|
|
601
|
+
border-left: 1px solid var(--semi-color-border);
|
|
602
|
+
border-right: 1px solid var(--semi-color-border);
|
|
1463
603
|
|
|
1464
604
|
& .semi-tree-select,
|
|
1465
605
|
& .semi-input-number,
|
|
@@ -1473,28 +613,36 @@ var UIMain = styled4.div`
|
|
|
1473
613
|
border: none;
|
|
1474
614
|
border-radius: 0;
|
|
1475
615
|
}
|
|
1476
|
-
`;
|
|
1477
|
-
var UIType2 = styled4.div`
|
|
1478
|
-
border-right: 1px solid #e5e5e5;
|
|
1479
616
|
|
|
617
|
+
& .semi-input-textarea-wrapper {
|
|
618
|
+
border: none;
|
|
619
|
+
border-radius: 0;
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
& .semi-input-textarea {
|
|
623
|
+
padding: 2px 6px;
|
|
624
|
+
border: none;
|
|
625
|
+
border-radius: 0;
|
|
626
|
+
word-break: break-all;
|
|
627
|
+
}
|
|
628
|
+
`;
|
|
629
|
+
var UIType2 = styled2.div`
|
|
1480
630
|
& .semi-button {
|
|
1481
631
|
border-radius: 0;
|
|
1482
632
|
}
|
|
1483
633
|
`;
|
|
1484
|
-
var UITrigger =
|
|
1485
|
-
border-left: 1px solid #e5e5e5;
|
|
1486
|
-
|
|
634
|
+
var UITrigger = styled2.div`
|
|
1487
635
|
& .semi-button {
|
|
1488
636
|
border-radius: 0;
|
|
1489
637
|
}
|
|
1490
638
|
`;
|
|
1491
639
|
|
|
1492
640
|
// src/components/dynamic-value-input/hooks.ts
|
|
1493
|
-
import { useMemo as
|
|
641
|
+
import { useEffect as useEffect3, useMemo as useMemo4, useRef as useRef2, useState as useState4 } from "react";
|
|
1494
642
|
import { useScopeAvailable } from "@flowgram.ai/editor";
|
|
1495
643
|
function useRefVariable(value) {
|
|
1496
644
|
const available = useScopeAvailable();
|
|
1497
|
-
const refVariable =
|
|
645
|
+
const refVariable = useMemo4(() => {
|
|
1498
646
|
if (value?.type === "ref") {
|
|
1499
647
|
return available.getByKeyPath(value.content);
|
|
1500
648
|
}
|
|
@@ -1506,23 +654,45 @@ function useSelectSchema(schemaFromProps, constantProps, value) {
|
|
|
1506
654
|
if (value?.type === "constant") {
|
|
1507
655
|
defaultSelectSchema = value?.schema || defaultSelectSchema;
|
|
1508
656
|
}
|
|
657
|
+
const changeVersion = useRef2(0);
|
|
658
|
+
const effectVersion = useRef2(0);
|
|
1509
659
|
const [selectSchema, setSelectSchema] = useState4(defaultSelectSchema);
|
|
1510
|
-
|
|
660
|
+
useEffect3(() => {
|
|
661
|
+
effectVersion.current += 1;
|
|
662
|
+
if (changeVersion.current === effectVersion.current) {
|
|
663
|
+
return;
|
|
664
|
+
}
|
|
665
|
+
effectVersion.current = changeVersion.current;
|
|
666
|
+
if (value?.type === "constant" && value?.schema) {
|
|
667
|
+
setSelectSchema(value?.schema);
|
|
668
|
+
return;
|
|
669
|
+
}
|
|
670
|
+
}, [value]);
|
|
671
|
+
const setSelectSchemaWithVersionUpdate = (schema) => {
|
|
672
|
+
setSelectSchema(schema);
|
|
673
|
+
changeVersion.current += 1;
|
|
674
|
+
};
|
|
675
|
+
return [selectSchema, setSelectSchemaWithVersionUpdate];
|
|
1511
676
|
}
|
|
1512
677
|
function useIncludeSchema(schemaFromProps) {
|
|
1513
|
-
const includeSchema =
|
|
678
|
+
const includeSchema = useMemo4(() => {
|
|
1514
679
|
if (!schemaFromProps) {
|
|
1515
680
|
return;
|
|
1516
681
|
}
|
|
1517
682
|
if (schemaFromProps?.type === "number") {
|
|
1518
683
|
return [schemaFromProps, { type: "integer" }];
|
|
1519
684
|
}
|
|
1520
|
-
return { ...schemaFromProps, extra: { ...schemaFromProps?.extra
|
|
685
|
+
return { ...schemaFromProps, extra: { weak: true, ...schemaFromProps?.extra } };
|
|
1521
686
|
}, [schemaFromProps]);
|
|
1522
687
|
return includeSchema;
|
|
1523
688
|
}
|
|
1524
689
|
|
|
1525
690
|
// src/components/dynamic-value-input/index.tsx
|
|
691
|
+
var DEFAULT_VALUE = {
|
|
692
|
+
type: "constant",
|
|
693
|
+
content: "",
|
|
694
|
+
schema: { type: "string" }
|
|
695
|
+
};
|
|
1526
696
|
function DynamicValueInput({
|
|
1527
697
|
value,
|
|
1528
698
|
onChange,
|
|
@@ -1534,34 +704,33 @@ function DynamicValueInput({
|
|
|
1534
704
|
const refVariable = useRefVariable(value);
|
|
1535
705
|
const [selectSchema, setSelectSchema] = useSelectSchema(schemaFromProps, constantProps, value);
|
|
1536
706
|
const includeSchema = useIncludeSchema(schemaFromProps);
|
|
707
|
+
const typeManager = useTypeManager3();
|
|
1537
708
|
const renderTypeSelector = () => {
|
|
1538
709
|
if (schemaFromProps) {
|
|
1539
|
-
return /* @__PURE__ */
|
|
710
|
+
return /* @__PURE__ */ React8.createElement(TypeSelector, { value: schemaFromProps, readonly: true });
|
|
1540
711
|
}
|
|
1541
712
|
if (value?.type === "ref") {
|
|
1542
|
-
const schema = refVariable?.type ?
|
|
1543
|
-
return /* @__PURE__ */
|
|
713
|
+
const schema = refVariable?.type ? JsonSchemaUtils2.astToSchema(refVariable?.type) : void 0;
|
|
714
|
+
return /* @__PURE__ */ React8.createElement(TypeSelector, { value: schema, readonly: true });
|
|
1544
715
|
}
|
|
1545
|
-
return /* @__PURE__ */
|
|
716
|
+
return /* @__PURE__ */ React8.createElement(
|
|
1546
717
|
TypeSelector,
|
|
1547
718
|
{
|
|
1548
719
|
value: selectSchema,
|
|
1549
720
|
onChange: (_v) => {
|
|
1550
721
|
setSelectSchema(_v || { type: "string" });
|
|
1551
|
-
|
|
722
|
+
const schema = _v || { type: "string" };
|
|
723
|
+
let content = typeManager.getDefaultValue(schema);
|
|
1552
724
|
if (_v?.type === "object") {
|
|
1553
725
|
content = "{}";
|
|
1554
726
|
}
|
|
1555
727
|
if (_v?.type === "array") {
|
|
1556
728
|
content = "[]";
|
|
1557
729
|
}
|
|
1558
|
-
if (_v?.type === "boolean") {
|
|
1559
|
-
content = false;
|
|
1560
|
-
}
|
|
1561
730
|
onChange({
|
|
1562
731
|
type: "constant",
|
|
1563
732
|
content,
|
|
1564
|
-
schema
|
|
733
|
+
schema
|
|
1565
734
|
});
|
|
1566
735
|
},
|
|
1567
736
|
readonly
|
|
@@ -1570,40 +739,40 @@ function DynamicValueInput({
|
|
|
1570
739
|
};
|
|
1571
740
|
const renderMain = () => {
|
|
1572
741
|
if (value?.type === "ref") {
|
|
1573
|
-
return /* @__PURE__ */
|
|
742
|
+
return /* @__PURE__ */ React8.createElement(
|
|
1574
743
|
InjectVariableSelector,
|
|
1575
744
|
{
|
|
1576
745
|
style: { width: "100%" },
|
|
1577
746
|
value: value?.content,
|
|
1578
|
-
onChange: (_v) => onChange(_v ? { type: "ref", content: _v } :
|
|
747
|
+
onChange: (_v) => onChange(_v ? { type: "ref", content: _v } : DEFAULT_VALUE),
|
|
1579
748
|
includeSchema,
|
|
1580
749
|
readonly
|
|
1581
750
|
}
|
|
1582
751
|
);
|
|
1583
752
|
}
|
|
1584
753
|
const constantSchema = schemaFromProps || selectSchema || { type: "string" };
|
|
1585
|
-
return /* @__PURE__ */
|
|
754
|
+
return /* @__PURE__ */ React8.createElement(
|
|
1586
755
|
ConstantInput,
|
|
1587
756
|
{
|
|
1588
757
|
value: value?.content,
|
|
1589
758
|
onChange: (_v) => onChange({ type: "constant", content: _v, schema: constantSchema }),
|
|
1590
759
|
schema: constantSchema || { type: "string" },
|
|
1591
760
|
readonly,
|
|
1592
|
-
|
|
1593
|
-
fallbackRenderer: () => /* @__PURE__ */ React20.createElement(
|
|
761
|
+
fallbackRenderer: () => /* @__PURE__ */ React8.createElement(
|
|
1594
762
|
InjectVariableSelector,
|
|
1595
763
|
{
|
|
1596
764
|
style: { width: "100%" },
|
|
1597
|
-
onChange: (_v) => onChange(_v ? { type: "ref", content: _v } :
|
|
765
|
+
onChange: (_v) => onChange(_v ? { type: "ref", content: _v } : DEFAULT_VALUE),
|
|
1598
766
|
includeSchema,
|
|
1599
767
|
readonly
|
|
1600
768
|
}
|
|
1601
769
|
),
|
|
1602
|
-
...constantProps
|
|
770
|
+
...constantProps,
|
|
771
|
+
strategies: [...constantProps?.strategies || []]
|
|
1603
772
|
}
|
|
1604
773
|
);
|
|
1605
774
|
};
|
|
1606
|
-
const renderTrigger = () => /* @__PURE__ */
|
|
775
|
+
const renderTrigger = () => /* @__PURE__ */ React8.createElement(
|
|
1607
776
|
InjectVariableSelector,
|
|
1608
777
|
{
|
|
1609
778
|
style: { width: "100%" },
|
|
@@ -1611,34 +780,34 @@ function DynamicValueInput({
|
|
|
1611
780
|
onChange: (_v) => onChange({ type: "ref", content: _v }),
|
|
1612
781
|
includeSchema,
|
|
1613
782
|
readonly,
|
|
1614
|
-
triggerRender: () => /* @__PURE__ */
|
|
783
|
+
triggerRender: () => /* @__PURE__ */ React8.createElement(IconButton3, { disabled: readonly, size: "small", icon: /* @__PURE__ */ React8.createElement(IconSetting, { size: "small" }) })
|
|
1615
784
|
}
|
|
1616
785
|
);
|
|
1617
|
-
return /* @__PURE__ */
|
|
786
|
+
return /* @__PURE__ */ React8.createElement(UIContainer2, { style }, /* @__PURE__ */ React8.createElement(UIType2, null, renderTypeSelector()), /* @__PURE__ */ React8.createElement(UIMain, null, renderMain()), /* @__PURE__ */ React8.createElement(UITrigger, null, renderTrigger()));
|
|
1618
787
|
}
|
|
1619
788
|
DynamicValueInput.renderKey = "dynamic-value-input-render-key";
|
|
1620
789
|
var InjectDynamicValueInput = createInjectMaterial(DynamicValueInput);
|
|
1621
790
|
|
|
1622
791
|
// src/components/condition-row/index.tsx
|
|
1623
|
-
import
|
|
1624
|
-
import { I18n as
|
|
1625
|
-
import { Input as
|
|
792
|
+
import React10, { useMemo as useMemo7 } from "react";
|
|
793
|
+
import { I18n as I18n4 } from "@flowgram.ai/editor";
|
|
794
|
+
import { Input as Input3 } from "@douyinfe/semi-ui";
|
|
1626
795
|
|
|
1627
796
|
// src/components/condition-row/styles.tsx
|
|
1628
|
-
import
|
|
1629
|
-
var UIContainer3 =
|
|
797
|
+
import styled3 from "styled-components";
|
|
798
|
+
var UIContainer3 = styled3.div`
|
|
1630
799
|
display: flex;
|
|
1631
800
|
align-items: center;
|
|
1632
801
|
gap: 4px;
|
|
1633
802
|
`;
|
|
1634
|
-
var UIOperator =
|
|
1635
|
-
var UILeft =
|
|
803
|
+
var UIOperator = styled3.div``;
|
|
804
|
+
var UILeft = styled3.div`
|
|
1636
805
|
width: 100%;
|
|
1637
806
|
`;
|
|
1638
|
-
var UIRight =
|
|
807
|
+
var UIRight = styled3.div`
|
|
1639
808
|
width: 100%;
|
|
1640
809
|
`;
|
|
1641
|
-
var UIValues =
|
|
810
|
+
var UIValues = styled3.div`
|
|
1642
811
|
flex-grow: 1;
|
|
1643
812
|
display: flex;
|
|
1644
813
|
flex-direction: column;
|
|
@@ -1647,8 +816,8 @@ var UIValues = styled5.div`
|
|
|
1647
816
|
`;
|
|
1648
817
|
|
|
1649
818
|
// src/components/condition-row/hooks/useRule.ts
|
|
1650
|
-
import { useMemo as
|
|
1651
|
-
import { JsonSchemaUtils as
|
|
819
|
+
import { useMemo as useMemo5 } from "react";
|
|
820
|
+
import { JsonSchemaUtils as JsonSchemaUtils3 } from "@flowgram.ai/json-schema";
|
|
1652
821
|
import { useScopeAvailable as useScopeAvailable2 } from "@flowgram.ai/editor";
|
|
1653
822
|
|
|
1654
823
|
// src/components/condition-row/constants.ts
|
|
@@ -1706,6 +875,14 @@ var defaultRules = {
|
|
|
1706
875
|
map: {
|
|
1707
876
|
["is_empty" /* IS_EMPTY */]: null,
|
|
1708
877
|
["is_not_empty" /* IS_NOT_EMPTY */]: null
|
|
878
|
+
},
|
|
879
|
+
["date-time"]: {
|
|
880
|
+
["eq" /* EQ */]: "date-time",
|
|
881
|
+
["neq" /* NEQ */]: "date-time",
|
|
882
|
+
["gt" /* GT */]: "date-time",
|
|
883
|
+
["gte" /* GTE */]: "date-time",
|
|
884
|
+
["lt" /* LT */]: "date-time",
|
|
885
|
+
["lte" /* LTE */]: "date-time"
|
|
1709
886
|
}
|
|
1710
887
|
};
|
|
1711
888
|
var defaultOpConfigs = {
|
|
@@ -1774,37 +951,37 @@ var defaultOpConfigs = {
|
|
|
1774
951
|
// src/components/condition-row/hooks/useRule.ts
|
|
1775
952
|
function useRule(left, userRules) {
|
|
1776
953
|
const available = useScopeAvailable2();
|
|
1777
|
-
const rules =
|
|
1778
|
-
const variable =
|
|
954
|
+
const rules = useMemo5(() => ({ ...defaultRules, ...userRules || {} }), [userRules]);
|
|
955
|
+
const variable = useMemo5(() => {
|
|
1779
956
|
if (!left) return void 0;
|
|
1780
957
|
return available.getByKeyPath(left.content);
|
|
1781
958
|
}, [available, left]);
|
|
1782
|
-
const rule =
|
|
959
|
+
const rule = useMemo5(() => {
|
|
1783
960
|
if (!variable) return void 0;
|
|
1784
|
-
const schema =
|
|
961
|
+
const schema = JsonSchemaUtils3.astToSchema(variable.type, { drilldown: false });
|
|
1785
962
|
return rules[schema?.type];
|
|
1786
963
|
}, [variable?.type, rules]);
|
|
1787
964
|
return { rule };
|
|
1788
965
|
}
|
|
1789
966
|
|
|
1790
967
|
// src/components/condition-row/hooks/useOp.tsx
|
|
1791
|
-
import
|
|
1792
|
-
import { I18n as
|
|
1793
|
-
import { Button as Button2, Select
|
|
1794
|
-
import { IconChevronDownStroked
|
|
968
|
+
import React9, { useMemo as useMemo6 } from "react";
|
|
969
|
+
import { I18n as I18n3 } from "@flowgram.ai/editor";
|
|
970
|
+
import { Button as Button2, Select } from "@douyinfe/semi-ui";
|
|
971
|
+
import { IconChevronDownStroked } from "@douyinfe/semi-icons";
|
|
1795
972
|
function useOp({ rule, op, onChange, readonly, userOps }) {
|
|
1796
|
-
const options =
|
|
973
|
+
const options = useMemo6(
|
|
1797
974
|
() => Object.keys(rule || {}).map((_op) => ({
|
|
1798
975
|
...defaultOpConfigs[_op] || {},
|
|
1799
976
|
...userOps?.[_op] || {},
|
|
1800
977
|
value: _op,
|
|
1801
|
-
label:
|
|
978
|
+
label: I18n3.t(userOps?.[_op]?.label || defaultOpConfigs[_op]?.label)
|
|
1802
979
|
})),
|
|
1803
980
|
[rule, userOps]
|
|
1804
981
|
);
|
|
1805
|
-
const opConfig =
|
|
1806
|
-
const renderOpSelect = () => /* @__PURE__ */
|
|
1807
|
-
|
|
982
|
+
const opConfig = useMemo6(() => defaultOpConfigs[op], [op]);
|
|
983
|
+
const renderOpSelect = () => /* @__PURE__ */ React9.createElement(
|
|
984
|
+
Select,
|
|
1808
985
|
{
|
|
1809
986
|
style: { height: 22 },
|
|
1810
987
|
disabled: readonly,
|
|
@@ -1814,7 +991,7 @@ function useOp({ rule, op, onChange, readonly, userOps }) {
|
|
|
1814
991
|
onChange: (v) => {
|
|
1815
992
|
onChange(v);
|
|
1816
993
|
},
|
|
1817
|
-
triggerRender: ({ value }) => /* @__PURE__ */
|
|
994
|
+
triggerRender: ({ value }) => /* @__PURE__ */ React9.createElement(Button2, { size: "small", disabled: !rule }, opConfig?.abbreviation || /* @__PURE__ */ React9.createElement(IconChevronDownStroked, { size: "small" }))
|
|
1818
995
|
}
|
|
1819
996
|
);
|
|
1820
997
|
return { renderOpSelect, opConfig };
|
|
@@ -1841,1041 +1018,403 @@ function ConditionRow({
|
|
|
1841
1018
|
readonly,
|
|
1842
1019
|
userOps: ruleConfig.ops
|
|
1843
1020
|
});
|
|
1844
|
-
const targetSchema =
|
|
1845
|
-
const targetType = rule?.[operator || ""] || null;
|
|
1846
|
-
return targetType ? { type: targetType, extra: { weak: true } } : null;
|
|
1847
|
-
}, [rule, opConfig]);
|
|
1848
|
-
return /* @__PURE__ */
|
|
1849
|
-
InjectVariableSelector,
|
|
1850
|
-
{
|
|
1851
|
-
readonly,
|
|
1852
|
-
style: { width: "100%" },
|
|
1853
|
-
value: left?.content,
|
|
1854
|
-
onChange: (v) => onChange({
|
|
1855
|
-
...value,
|
|
1856
|
-
left: {
|
|
1857
|
-
type: "ref",
|
|
1858
|
-
content: v
|
|
1859
|
-
}
|
|
1860
|
-
})
|
|
1861
|
-
}
|
|
1862
|
-
)), /* @__PURE__ */
|
|
1863
|
-
InjectDynamicValueInput,
|
|
1864
|
-
{
|
|
1865
|
-
readonly: readonly || !rule,
|
|
1866
|
-
value: right,
|
|
1867
|
-
schema: targetSchema,
|
|
1868
|
-
onChange: (v) => onChange({ ...value, right: v })
|
|
1869
|
-
}
|
|
1870
|
-
) : /* @__PURE__ */
|
|
1871
|
-
|
|
1872
|
-
{
|
|
1873
|
-
size: "small",
|
|
1874
|
-
disabled: true,
|
|
1875
|
-
style: { pointerEvents: "none" },
|
|
1876
|
-
value: opConfig?.rightDisplay ||
|
|
1877
|
-
}
|
|
1878
|
-
))));
|
|
1879
|
-
}
|
|
1880
|
-
|
|
1881
|
-
// src/components/batch-outputs/index.tsx
|
|
1882
|
-
import React23 from "react";
|
|
1883
|
-
import { Button as Button3, Input as Input5 } from "@douyinfe/semi-ui";
|
|
1884
|
-
import { IconDelete, IconPlus as IconPlus2 } from "@douyinfe/semi-icons";
|
|
1885
|
-
|
|
1886
|
-
// src/hooks/use-object-list/index.tsx
|
|
1887
|
-
import { useEffect as useEffect4, useState as useState5 } from "react";
|
|
1888
|
-
import { nanoid } from "nanoid";
|
|
1889
|
-
import { difference as difference2, get, isObject as isObject2, set } from "lodash";
|
|
1890
|
-
function genId2() {
|
|
1891
|
-
return nanoid();
|
|
1892
|
-
}
|
|
1893
|
-
function useObjectList({
|
|
1894
|
-
value,
|
|
1895
|
-
onChange,
|
|
1896
|
-
sortIndexKey
|
|
1897
|
-
}) {
|
|
1898
|
-
const [list, setList] = useState5([]);
|
|
1899
|
-
useEffect4(() => {
|
|
1900
|
-
setList((_prevList) => {
|
|
1901
|
-
const newKeys = Object.entries(value || {}).sort((a, b) => get(a[1], sortIndexKey || 0) - get(b[1], sortIndexKey || 0)).map(([key]) => key);
|
|
1902
|
-
const oldKeys = _prevList.map((item) => item.key).filter(Boolean);
|
|
1903
|
-
const addKeys = difference2(newKeys, oldKeys);
|
|
1904
|
-
return _prevList.filter((item) => !item.key || newKeys.includes(item.key)).map((item) => ({
|
|
1905
|
-
id: item.id,
|
|
1906
|
-
key: item.key,
|
|
1907
|
-
value: item.key ? value?.[item.key] : item.value
|
|
1908
|
-
})).concat(
|
|
1909
|
-
addKeys.map((_key) => ({
|
|
1910
|
-
id: genId2(),
|
|
1911
|
-
key: _key,
|
|
1912
|
-
value: value?.[_key]
|
|
1913
|
-
}))
|
|
1914
|
-
);
|
|
1915
|
-
});
|
|
1916
|
-
}, [value]);
|
|
1917
|
-
const add = () => {
|
|
1918
|
-
setList((prevList) => [
|
|
1919
|
-
...prevList,
|
|
1920
|
-
{
|
|
1921
|
-
id: genId2()
|
|
1922
|
-
}
|
|
1923
|
-
]);
|
|
1924
|
-
};
|
|
1925
|
-
const updateValue = (itemId, value2) => {
|
|
1926
|
-
setList((prevList) => {
|
|
1927
|
-
const nextList = prevList.map((_item) => {
|
|
1928
|
-
if (_item.id === itemId) {
|
|
1929
|
-
return {
|
|
1930
|
-
..._item,
|
|
1931
|
-
value: value2
|
|
1932
|
-
};
|
|
1933
|
-
}
|
|
1934
|
-
return _item;
|
|
1935
|
-
});
|
|
1936
|
-
onChange(
|
|
1937
|
-
Object.fromEntries(
|
|
1938
|
-
nextList.filter((item) => item.key).map((item) => [item.key, item.value]).map((_res, idx) => {
|
|
1939
|
-
if (isObject2(_res[1]) && sortIndexKey) {
|
|
1940
|
-
set(_res[1], sortIndexKey, idx);
|
|
1941
|
-
}
|
|
1942
|
-
return _res;
|
|
1943
|
-
})
|
|
1944
|
-
)
|
|
1945
|
-
);
|
|
1946
|
-
return nextList;
|
|
1947
|
-
});
|
|
1948
|
-
};
|
|
1949
|
-
const updateKey = (itemId, key) => {
|
|
1950
|
-
setList((prevList) => {
|
|
1951
|
-
const nextList = prevList.map((_item) => {
|
|
1952
|
-
if (_item.id === itemId) {
|
|
1953
|
-
return {
|
|
1954
|
-
..._item,
|
|
1955
|
-
key
|
|
1956
|
-
};
|
|
1957
|
-
}
|
|
1958
|
-
return _item;
|
|
1959
|
-
});
|
|
1960
|
-
onChange(
|
|
1961
|
-
Object.fromEntries(
|
|
1962
|
-
nextList.filter((item) => item.key).map((item) => [item.key, item.value])
|
|
1963
|
-
)
|
|
1964
|
-
);
|
|
1965
|
-
return nextList;
|
|
1966
|
-
});
|
|
1967
|
-
};
|
|
1968
|
-
const remove = (itemId) => {
|
|
1969
|
-
setList((prevList) => {
|
|
1970
|
-
const nextList = prevList.filter((_item) => _item.id !== itemId);
|
|
1971
|
-
onChange(
|
|
1972
|
-
Object.fromEntries(
|
|
1973
|
-
nextList.filter((item) => item.key).map((item) => [item.key, item.value])
|
|
1974
|
-
)
|
|
1975
|
-
);
|
|
1976
|
-
return nextList;
|
|
1977
|
-
});
|
|
1978
|
-
};
|
|
1979
|
-
return { list, add, updateKey, updateValue, remove };
|
|
1021
|
+
const targetSchema = useMemo7(() => {
|
|
1022
|
+
const targetType = rule?.[operator || ""] || null;
|
|
1023
|
+
return targetType ? { type: targetType, extra: { weak: true } } : null;
|
|
1024
|
+
}, [rule, opConfig]);
|
|
1025
|
+
return /* @__PURE__ */ React10.createElement(UIContainer3, { style }, /* @__PURE__ */ React10.createElement(UIOperator, null, renderOpSelect()), /* @__PURE__ */ React10.createElement(UIValues, null, /* @__PURE__ */ React10.createElement(UILeft, null, /* @__PURE__ */ React10.createElement(
|
|
1026
|
+
InjectVariableSelector,
|
|
1027
|
+
{
|
|
1028
|
+
readonly,
|
|
1029
|
+
style: { width: "100%" },
|
|
1030
|
+
value: left?.content,
|
|
1031
|
+
onChange: (v) => onChange({
|
|
1032
|
+
...value,
|
|
1033
|
+
left: {
|
|
1034
|
+
type: "ref",
|
|
1035
|
+
content: v
|
|
1036
|
+
}
|
|
1037
|
+
})
|
|
1038
|
+
}
|
|
1039
|
+
)), /* @__PURE__ */ React10.createElement(UIRight, null, targetSchema ? /* @__PURE__ */ React10.createElement(
|
|
1040
|
+
InjectDynamicValueInput,
|
|
1041
|
+
{
|
|
1042
|
+
readonly: readonly || !rule,
|
|
1043
|
+
value: right,
|
|
1044
|
+
schema: targetSchema,
|
|
1045
|
+
onChange: (v) => onChange({ ...value, right: v })
|
|
1046
|
+
}
|
|
1047
|
+
) : /* @__PURE__ */ React10.createElement(
|
|
1048
|
+
Input3,
|
|
1049
|
+
{
|
|
1050
|
+
size: "small",
|
|
1051
|
+
disabled: true,
|
|
1052
|
+
style: { pointerEvents: "none" },
|
|
1053
|
+
value: opConfig?.rightDisplay || I18n4.t("Empty")
|
|
1054
|
+
}
|
|
1055
|
+
))));
|
|
1980
1056
|
}
|
|
1057
|
+
ConditionRow.defaultRules = defaultRules;
|
|
1058
|
+
ConditionRow.defaultOpConfigs = defaultOpConfigs;
|
|
1981
1059
|
|
|
1982
|
-
// src/components/
|
|
1983
|
-
import
|
|
1984
|
-
|
|
1060
|
+
// src/components/db-condition-row/index.tsx
|
|
1061
|
+
import React13, { useMemo as useMemo10 } from "react";
|
|
1062
|
+
import { I18n as I18n6 } from "@flowgram.ai/editor";
|
|
1063
|
+
import { Input as Input4 } from "@douyinfe/semi-ui";
|
|
1064
|
+
|
|
1065
|
+
// src/components/db-condition-row/styles.tsx
|
|
1066
|
+
import styled4 from "styled-components";
|
|
1067
|
+
import { Select as Select2 } from "@douyinfe/semi-ui";
|
|
1068
|
+
var UIContainer4 = styled4.div`
|
|
1069
|
+
display: flex;
|
|
1070
|
+
align-items: center;
|
|
1071
|
+
gap: 4px;
|
|
1072
|
+
`;
|
|
1073
|
+
var UIOperator2 = styled4.div``;
|
|
1074
|
+
var UILeft2 = styled4.div`
|
|
1075
|
+
width: 100%;
|
|
1076
|
+
`;
|
|
1077
|
+
var UIRight2 = styled4.div`
|
|
1078
|
+
width: 100%;
|
|
1079
|
+
`;
|
|
1080
|
+
var UIValues2 = styled4.div`
|
|
1081
|
+
flex-grow: 1;
|
|
1985
1082
|
display: flex;
|
|
1986
1083
|
flex-direction: column;
|
|
1987
|
-
|
|
1988
|
-
|
|
1084
|
+
align-items: center;
|
|
1085
|
+
gap: 4px;
|
|
1989
1086
|
`;
|
|
1990
|
-
var
|
|
1087
|
+
var UIOptionLabel = styled4.div`
|
|
1991
1088
|
display: flex;
|
|
1992
1089
|
align-items: center;
|
|
1993
|
-
gap:
|
|
1090
|
+
gap: 10px;
|
|
1091
|
+
`;
|
|
1092
|
+
var UISelect = styled4(Select2)`
|
|
1093
|
+
& .semi-select-selection {
|
|
1094
|
+
margin-left: 5px;
|
|
1095
|
+
}
|
|
1994
1096
|
`;
|
|
1995
1097
|
|
|
1996
|
-
// src/components/
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
1098
|
+
// src/components/db-condition-row/hooks/use-op.tsx
|
|
1099
|
+
import React11, { useMemo as useMemo8 } from "react";
|
|
1100
|
+
import { I18n as I18n5 } from "@flowgram.ai/editor";
|
|
1101
|
+
import { Button as Button3, Select as Select3 } from "@douyinfe/semi-ui";
|
|
1102
|
+
import { IconChevronDownStroked as IconChevronDownStroked2 } from "@douyinfe/semi-icons";
|
|
1103
|
+
var defaultOpConfigs2 = ConditionRow.defaultOpConfigs;
|
|
1104
|
+
function useOp2({ rule, op, onChange, readonly, userOps }) {
|
|
1105
|
+
const options = useMemo8(
|
|
1106
|
+
() => Object.keys(rule || {}).map((_op) => ({
|
|
1107
|
+
...defaultOpConfigs2[_op] || {},
|
|
1108
|
+
...userOps?.[_op] || {},
|
|
1109
|
+
value: _op,
|
|
1110
|
+
label: I18n5.t(userOps?.[_op]?.label || defaultOpConfigs2[_op]?.label)
|
|
1111
|
+
})),
|
|
1112
|
+
[rule, userOps]
|
|
1113
|
+
);
|
|
1114
|
+
const opConfig = useMemo8(() => defaultOpConfigs2[op], [op]);
|
|
1115
|
+
const renderOpSelect = () => /* @__PURE__ */ React11.createElement(
|
|
1116
|
+
Select3,
|
|
2002
1117
|
{
|
|
2003
|
-
style: {
|
|
1118
|
+
style: { height: 22 },
|
|
2004
1119
|
disabled: readonly,
|
|
2005
1120
|
size: "small",
|
|
2006
|
-
value:
|
|
2007
|
-
|
|
1121
|
+
value: op,
|
|
1122
|
+
optionList: options,
|
|
1123
|
+
onChange: (v) => {
|
|
1124
|
+
onChange(v);
|
|
1125
|
+
},
|
|
1126
|
+
triggerRender: ({ value }) => /* @__PURE__ */ React11.createElement(Button3, { size: "small", disabled: !rule }, opConfig?.abbreviation || /* @__PURE__ */ React11.createElement(IconChevronDownStroked2, { size: "small" }))
|
|
2008
1127
|
}
|
|
2009
|
-
)
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
1128
|
+
);
|
|
1129
|
+
return { renderOpSelect, opConfig };
|
|
1130
|
+
}
|
|
1131
|
+
|
|
1132
|
+
// src/components/db-condition-row/hooks/use-left.tsx
|
|
1133
|
+
import { useMemo as useMemo9 } from "react";
|
|
1134
|
+
import React12 from "react";
|
|
1135
|
+
import { useTypeManager as useTypeManager4 } from "@flowgram.ai/json-schema";
|
|
1136
|
+
import { Icon as Icon3 } from "@douyinfe/semi-ui";
|
|
1137
|
+
var defaultRules2 = ConditionRow.defaultRules;
|
|
1138
|
+
function useLeft({ left, options, userRules, readonly, onChange }) {
|
|
1139
|
+
const rules = useMemo9(() => ({ ...defaultRules2, ...userRules || {} }), [userRules]);
|
|
1140
|
+
const typeManager = useTypeManager4();
|
|
1141
|
+
const rule = useMemo9(() => {
|
|
1142
|
+
if (!left) return void 0;
|
|
1143
|
+
const option = options?.find((item) => item.value === left);
|
|
1144
|
+
if (!option?.schema?.type) {
|
|
1145
|
+
return void 0;
|
|
2016
1146
|
}
|
|
2017
|
-
|
|
2018
|
-
|
|
1147
|
+
return rules[option.schema.type];
|
|
1148
|
+
}, [left, options, rules]);
|
|
1149
|
+
const renderDBOptionSelect = () => /* @__PURE__ */ React12.createElement(
|
|
1150
|
+
UISelect,
|
|
2019
1151
|
{
|
|
2020
1152
|
disabled: readonly,
|
|
2021
|
-
icon: /* @__PURE__ */ React23.createElement(IconDelete, null),
|
|
2022
1153
|
size: "small",
|
|
2023
|
-
|
|
1154
|
+
style: { width: "100%" },
|
|
1155
|
+
value: left,
|
|
1156
|
+
onChange: (v) => onChange(v),
|
|
1157
|
+
optionList: options?.map((item) => ({
|
|
1158
|
+
label: /* @__PURE__ */ React12.createElement(UIOptionLabel, null, /* @__PURE__ */ React12.createElement(Icon3, { size: "small", svg: typeManager.getDisplayIcon(item.schema) }), item.label),
|
|
1159
|
+
value: item.value
|
|
1160
|
+
})) || []
|
|
2024
1161
|
}
|
|
2025
|
-
)))), /* @__PURE__ */ React23.createElement(Button3, { disabled: readonly, icon: /* @__PURE__ */ React23.createElement(IconPlus2, null), size: "small", onClick: add }, "Add"));
|
|
2026
|
-
}
|
|
2027
|
-
|
|
2028
|
-
// src/components/prompt-editor/index.tsx
|
|
2029
|
-
import React24, { useEffect as useEffect5, useRef as useRef2 } from "react";
|
|
2030
|
-
import { Renderer, EditorProvider as EditorProvider2, ActiveLinePlaceholder as ActiveLinePlaceholder2 } from "@coze-editor/editor/react";
|
|
2031
|
-
import preset2 from "@coze-editor/editor/preset-prompt";
|
|
2032
|
-
|
|
2033
|
-
// src/components/prompt-editor/styles.tsx
|
|
2034
|
-
import styled7, { css as css3 } from "styled-components";
|
|
2035
|
-
var UIContainer4 = styled7.div`
|
|
2036
|
-
background-color: var(--semi-color-fill-0);
|
|
2037
|
-
padding-left: 10px;
|
|
2038
|
-
padding-right: 6px;
|
|
2039
|
-
|
|
2040
|
-
${({ $hasError }) => $hasError && css3`
|
|
2041
|
-
border: 1px solid var(--semi-color-danger-6);
|
|
2042
|
-
`}
|
|
2043
|
-
`;
|
|
2044
|
-
|
|
2045
|
-
// src/components/prompt-editor/extensions/markdown.tsx
|
|
2046
|
-
import { useLayoutEffect } from "react";
|
|
2047
|
-
import { useInjector } from "@coze-editor/editor/react";
|
|
2048
|
-
import { astDecorator } from "@coze-editor/editor";
|
|
2049
|
-
import { EditorView as EditorView2 } from "@codemirror/view";
|
|
2050
|
-
function MarkdownHighlight() {
|
|
2051
|
-
const injector = useInjector();
|
|
2052
|
-
useLayoutEffect(
|
|
2053
|
-
() => injector.inject([
|
|
2054
|
-
astDecorator.whole.of((cursor) => {
|
|
2055
|
-
if (cursor.name.startsWith("ATXHeading")) {
|
|
2056
|
-
return {
|
|
2057
|
-
type: "className",
|
|
2058
|
-
className: "heading"
|
|
2059
|
-
};
|
|
2060
|
-
}
|
|
2061
|
-
if (cursor.name === "Emphasis") {
|
|
2062
|
-
return {
|
|
2063
|
-
type: "className",
|
|
2064
|
-
className: "emphasis"
|
|
2065
|
-
};
|
|
2066
|
-
}
|
|
2067
|
-
if (cursor.name === "StrongEmphasis") {
|
|
2068
|
-
return {
|
|
2069
|
-
type: "className",
|
|
2070
|
-
className: "strong-emphasis"
|
|
2071
|
-
};
|
|
2072
|
-
}
|
|
2073
|
-
if (cursor.name === "ListMark" || cursor.name === "QuoteMark") {
|
|
2074
|
-
return {
|
|
2075
|
-
type: "className",
|
|
2076
|
-
className: "mark"
|
|
2077
|
-
};
|
|
2078
|
-
}
|
|
2079
|
-
}),
|
|
2080
|
-
EditorView2.theme({
|
|
2081
|
-
".heading": {
|
|
2082
|
-
color: "#00818C",
|
|
2083
|
-
fontWeight: "bold"
|
|
2084
|
-
},
|
|
2085
|
-
".emphasis": {
|
|
2086
|
-
fontStyle: "italic"
|
|
2087
|
-
},
|
|
2088
|
-
".strong-emphasis": {
|
|
2089
|
-
fontWeight: "bold"
|
|
2090
|
-
},
|
|
2091
|
-
".mark": {
|
|
2092
|
-
color: "#4E40E5"
|
|
2093
|
-
}
|
|
2094
|
-
})
|
|
2095
|
-
]),
|
|
2096
|
-
[injector]
|
|
2097
|
-
);
|
|
2098
|
-
return null;
|
|
2099
|
-
}
|
|
2100
|
-
var markdown_default = MarkdownHighlight;
|
|
2101
|
-
|
|
2102
|
-
// src/components/prompt-editor/extensions/language-support.tsx
|
|
2103
|
-
import { useLayoutEffect as useLayoutEffect2 } from "react";
|
|
2104
|
-
import { useInjector as useInjector2 } from "@coze-editor/editor/react";
|
|
2105
|
-
import { languageSupport } from "@coze-editor/editor/preset-prompt";
|
|
2106
|
-
function LanguageSupport() {
|
|
2107
|
-
const injector = useInjector2();
|
|
2108
|
-
useLayoutEffect2(() => injector.inject([languageSupport]), [injector]);
|
|
2109
|
-
return null;
|
|
2110
|
-
}
|
|
2111
|
-
var language_support_default = LanguageSupport;
|
|
2112
|
-
|
|
2113
|
-
// src/components/prompt-editor/extensions/jinja.tsx
|
|
2114
|
-
import { useLayoutEffect as useLayoutEffect3 } from "react";
|
|
2115
|
-
import { useInjector as useInjector3 } from "@coze-editor/editor/react";
|
|
2116
|
-
import { astDecorator as astDecorator2 } from "@coze-editor/editor";
|
|
2117
|
-
import { EditorView as EditorView3 } from "@codemirror/view";
|
|
2118
|
-
function JinjaHighlight() {
|
|
2119
|
-
const injector = useInjector3();
|
|
2120
|
-
useLayoutEffect3(
|
|
2121
|
-
() => injector.inject([
|
|
2122
|
-
astDecorator2.whole.of((cursor) => {
|
|
2123
|
-
if (cursor.name === "JinjaStatementStart" || cursor.name === "JinjaStatementEnd") {
|
|
2124
|
-
return {
|
|
2125
|
-
type: "className",
|
|
2126
|
-
className: "jinja-statement-bracket"
|
|
2127
|
-
};
|
|
2128
|
-
}
|
|
2129
|
-
if (cursor.name === "JinjaComment") {
|
|
2130
|
-
return {
|
|
2131
|
-
type: "className",
|
|
2132
|
-
className: "jinja-comment"
|
|
2133
|
-
};
|
|
2134
|
-
}
|
|
2135
|
-
if (cursor.name === "JinjaExpression") {
|
|
2136
|
-
return {
|
|
2137
|
-
type: "className",
|
|
2138
|
-
className: "jinja-expression"
|
|
2139
|
-
};
|
|
2140
|
-
}
|
|
2141
|
-
}),
|
|
2142
|
-
EditorView3.theme({
|
|
2143
|
-
".jinja-statement-bracket": {
|
|
2144
|
-
color: "#D1009D"
|
|
2145
|
-
},
|
|
2146
|
-
".jinja-comment": {
|
|
2147
|
-
color: "#0607094D"
|
|
2148
|
-
},
|
|
2149
|
-
".jinja-expression": {
|
|
2150
|
-
color: "#4E40E5"
|
|
2151
|
-
}
|
|
2152
|
-
})
|
|
2153
|
-
]),
|
|
2154
|
-
[injector]
|
|
2155
1162
|
);
|
|
2156
|
-
return
|
|
1163
|
+
return { rule, renderDBOptionSelect };
|
|
2157
1164
|
}
|
|
2158
|
-
var jinja_default = JinjaHighlight;
|
|
2159
1165
|
|
|
2160
|
-
// src/components/
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
1166
|
+
// src/components/db-condition-row/index.tsx
|
|
1167
|
+
var defaultRuleConfig2 = {
|
|
1168
|
+
ops: {},
|
|
1169
|
+
rules: {}
|
|
1170
|
+
};
|
|
1171
|
+
function DBConditionRow({
|
|
1172
|
+
style,
|
|
1173
|
+
value,
|
|
1174
|
+
onChange,
|
|
1175
|
+
readonly,
|
|
1176
|
+
options,
|
|
1177
|
+
ruleConfig = defaultRuleConfig2
|
|
1178
|
+
}) {
|
|
1179
|
+
const { left, operator, right } = value || {};
|
|
1180
|
+
const { rule, renderDBOptionSelect } = useLeft({
|
|
1181
|
+
left,
|
|
1182
|
+
options,
|
|
1183
|
+
onChange: (leftKey) => onChange({ ...value, left: leftKey }),
|
|
2165
1184
|
readonly,
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
}
|
|
2178
|
-
}, [
|
|
2179
|
-
return /* @__PURE__ */
|
|
2180
|
-
|
|
1185
|
+
userRules: ruleConfig.rules
|
|
1186
|
+
});
|
|
1187
|
+
const { renderOpSelect, opConfig } = useOp2({
|
|
1188
|
+
rule,
|
|
1189
|
+
op: operator,
|
|
1190
|
+
onChange: (v) => onChange({ ...value, operator: v }),
|
|
1191
|
+
readonly,
|
|
1192
|
+
userOps: ruleConfig.ops
|
|
1193
|
+
});
|
|
1194
|
+
const targetSchema = useMemo10(() => {
|
|
1195
|
+
const targetType = rule?.[operator || ""] || null;
|
|
1196
|
+
return targetType ? { type: targetType, extra: { weak: true } } : null;
|
|
1197
|
+
}, [rule, opConfig]);
|
|
1198
|
+
return /* @__PURE__ */ React13.createElement(UIContainer4, { style }, /* @__PURE__ */ React13.createElement(UIOperator2, null, renderOpSelect()), /* @__PURE__ */ React13.createElement(UIValues2, null, /* @__PURE__ */ React13.createElement(UILeft2, null, renderDBOptionSelect()), /* @__PURE__ */ React13.createElement(UIRight2, null, targetSchema ? /* @__PURE__ */ React13.createElement(
|
|
1199
|
+
InjectDynamicValueInput,
|
|
2181
1200
|
{
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
defaultValue: String(value?.content),
|
|
2187
|
-
options: {
|
|
2188
|
-
readOnly: readonly,
|
|
2189
|
-
editable: !readonly,
|
|
2190
|
-
placeholder
|
|
2191
|
-
},
|
|
2192
|
-
onChange: (e) => {
|
|
2193
|
-
onChange({ type: "template", content: e.value });
|
|
2194
|
-
}
|
|
2195
|
-
}
|
|
2196
|
-
), activeLinePlaceholder && /* @__PURE__ */ React24.createElement(ActiveLinePlaceholder2, null, activeLinePlaceholder), !disableMarkdownHighlight && /* @__PURE__ */ React24.createElement(markdown_default, null), /* @__PURE__ */ React24.createElement(language_support_default, null), /* @__PURE__ */ React24.createElement(jinja_default, null), children));
|
|
2197
|
-
}
|
|
2198
|
-
|
|
2199
|
-
// src/components/prompt-editor-with-variables/index.tsx
|
|
2200
|
-
import React27 from "react";
|
|
2201
|
-
|
|
2202
|
-
// src/components/prompt-editor-with-variables/extensions/variable-tree.tsx
|
|
2203
|
-
import React25, { useEffect as useEffect6, useState as useState6 } from "react";
|
|
2204
|
-
import { Popover as Popover2, Tree } from "@douyinfe/semi-ui";
|
|
2205
|
-
import {
|
|
2206
|
-
Mention,
|
|
2207
|
-
getCurrentMentionReplaceRange,
|
|
2208
|
-
useEditor,
|
|
2209
|
-
PositionMirror
|
|
2210
|
-
} from "@coze-editor/editor/react";
|
|
2211
|
-
function VariableTree() {
|
|
2212
|
-
const [posKey, setPosKey] = useState6("");
|
|
2213
|
-
const [visible, setVisible] = useState6(false);
|
|
2214
|
-
const [position, setPosition] = useState6(-1);
|
|
2215
|
-
const editor = useEditor();
|
|
2216
|
-
function insert(variablePath) {
|
|
2217
|
-
const range = getCurrentMentionReplaceRange(editor.$view.state);
|
|
2218
|
-
if (!range) {
|
|
2219
|
-
return;
|
|
2220
|
-
}
|
|
2221
|
-
editor.replaceText({
|
|
2222
|
-
...range,
|
|
2223
|
-
text: "{{" + variablePath + "}}"
|
|
2224
|
-
});
|
|
2225
|
-
setVisible(false);
|
|
2226
|
-
}
|
|
2227
|
-
function handleOpenChange(e) {
|
|
2228
|
-
setPosition(e.state.selection.main.head);
|
|
2229
|
-
setVisible(e.value);
|
|
2230
|
-
}
|
|
2231
|
-
useEffect6(() => {
|
|
2232
|
-
if (!editor) {
|
|
2233
|
-
return;
|
|
1201
|
+
readonly: readonly || !rule,
|
|
1202
|
+
value: right,
|
|
1203
|
+
schema: targetSchema,
|
|
1204
|
+
onChange: (v) => onChange({ ...value, right: v })
|
|
2234
1205
|
}
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
return /* @__PURE__ */ React25.createElement(React25.Fragment, null, /* @__PURE__ */ React25.createElement(Mention, { triggerCharacters: ["{", "{}", "@"], onOpenChange: handleOpenChange }), /* @__PURE__ */ React25.createElement(
|
|
2238
|
-
Popover2,
|
|
1206
|
+
) : /* @__PURE__ */ React13.createElement(
|
|
1207
|
+
Input4,
|
|
2239
1208
|
{
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
content: /* @__PURE__ */ React25.createElement("div", { style: { width: 300 } }, /* @__PURE__ */ React25.createElement(
|
|
2245
|
-
Tree,
|
|
2246
|
-
{
|
|
2247
|
-
treeData,
|
|
2248
|
-
onSelect: (v) => {
|
|
2249
|
-
insert(v);
|
|
2250
|
-
}
|
|
2251
|
-
}
|
|
2252
|
-
))
|
|
2253
|
-
},
|
|
2254
|
-
/* @__PURE__ */ React25.createElement(
|
|
2255
|
-
PositionMirror,
|
|
2256
|
-
{
|
|
2257
|
-
position,
|
|
2258
|
-
onChange: () => setPosKey(String(Math.random()))
|
|
2259
|
-
}
|
|
2260
|
-
)
|
|
2261
|
-
));
|
|
2262
|
-
}
|
|
2263
|
-
|
|
2264
|
-
// src/components/prompt-editor-with-variables/extensions/variable-tag.tsx
|
|
2265
|
-
import ReactDOM from "react-dom";
|
|
2266
|
-
import React26, { useLayoutEffect as useLayoutEffect4 } from "react";
|
|
2267
|
-
import { isEqual, last } from "lodash";
|
|
2268
|
-
import {
|
|
2269
|
-
Disposable,
|
|
2270
|
-
DisposableCollection,
|
|
2271
|
-
useCurrentScope
|
|
2272
|
-
} from "@flowgram.ai/editor";
|
|
2273
|
-
import { Popover as Popover3 } from "@douyinfe/semi-ui";
|
|
2274
|
-
import { IconIssueStroked as IconIssueStroked2 } from "@douyinfe/semi-icons";
|
|
2275
|
-
import { useInjector as useInjector4 } from "@coze-editor/editor/react";
|
|
2276
|
-
import {
|
|
2277
|
-
Decoration,
|
|
2278
|
-
EditorView as EditorView4,
|
|
2279
|
-
MatchDecorator,
|
|
2280
|
-
ViewPlugin,
|
|
2281
|
-
WidgetType
|
|
2282
|
-
} from "@codemirror/view";
|
|
2283
|
-
|
|
2284
|
-
// src/components/prompt-editor-with-variables/styles.tsx
|
|
2285
|
-
import styled8 from "styled-components";
|
|
2286
|
-
import { Tag as Tag2 } from "@douyinfe/semi-ui";
|
|
2287
|
-
var UIRootTitle2 = styled8.div`
|
|
2288
|
-
margin-right: 4px;
|
|
2289
|
-
min-width: 20px;
|
|
2290
|
-
overflow: hidden;
|
|
2291
|
-
text-overflow: ellipsis;
|
|
2292
|
-
white-space: nowrap;
|
|
2293
|
-
color: var(--semi-color-text-2);
|
|
2294
|
-
`;
|
|
2295
|
-
var UIVarName2 = styled8.div`
|
|
2296
|
-
overflow: hidden;
|
|
2297
|
-
text-overflow: ellipsis;
|
|
2298
|
-
white-space: nowrap;
|
|
2299
|
-
`;
|
|
2300
|
-
var UITag2 = styled8(Tag2)`
|
|
2301
|
-
display: inline-flex;
|
|
2302
|
-
align-items: center;
|
|
2303
|
-
justify-content: flex-start;
|
|
2304
|
-
max-width: 300px;
|
|
2305
|
-
|
|
2306
|
-
& .semi-tag-content-center {
|
|
2307
|
-
justify-content: flex-start;
|
|
2308
|
-
}
|
|
2309
|
-
|
|
2310
|
-
&.semi-tag {
|
|
2311
|
-
margin: 0 5px;
|
|
2312
|
-
}
|
|
2313
|
-
`;
|
|
2314
|
-
var UIPopoverContent2 = styled8.div`
|
|
2315
|
-
padding: 10px;
|
|
2316
|
-
display: inline-flex;
|
|
2317
|
-
align-items: center;
|
|
2318
|
-
justify-content: flex-start;
|
|
2319
|
-
`;
|
|
2320
|
-
|
|
2321
|
-
// src/components/prompt-editor-with-variables/extensions/variable-tag.tsx
|
|
2322
|
-
var VariableTagWidget = class extends WidgetType {
|
|
2323
|
-
constructor({ keyPath, scope }) {
|
|
2324
|
-
super();
|
|
2325
|
-
this.toDispose = new DisposableCollection();
|
|
2326
|
-
this.renderIcon = (icon) => {
|
|
2327
|
-
if (typeof icon === "string") {
|
|
2328
|
-
return /* @__PURE__ */ React26.createElement("img", { style: { marginRight: 8 }, width: 12, height: 12, src: icon });
|
|
2329
|
-
}
|
|
2330
|
-
return icon;
|
|
2331
|
-
};
|
|
2332
|
-
this.keyPath = keyPath;
|
|
2333
|
-
this.scope = scope;
|
|
2334
|
-
}
|
|
2335
|
-
renderReact(jsx) {
|
|
2336
|
-
ReactDOM.render(jsx, this.rootDOM);
|
|
2337
|
-
}
|
|
2338
|
-
renderVariable(v) {
|
|
2339
|
-
if (!v) {
|
|
2340
|
-
this.renderReact(
|
|
2341
|
-
/* @__PURE__ */ React26.createElement(UITag2, { prefixIcon: /* @__PURE__ */ React26.createElement(IconIssueStroked2, null), color: "amber" }, "Unknown")
|
|
2342
|
-
);
|
|
2343
|
-
return;
|
|
1209
|
+
size: "small",
|
|
1210
|
+
disabled: true,
|
|
1211
|
+
style: { pointerEvents: "none" },
|
|
1212
|
+
value: opConfig?.rightDisplay || I18n6.t("Empty")
|
|
2344
1213
|
}
|
|
2345
|
-
|
|
2346
|
-
const isRoot = v.parentFields.length === 0;
|
|
2347
|
-
const rootTitle = /* @__PURE__ */ React26.createElement(UIRootTitle2, null, rootField?.meta.title ? `${rootField.meta.title} ${isRoot ? "" : "-"} ` : "");
|
|
2348
|
-
const rootIcon = this.renderIcon(rootField?.meta.icon);
|
|
2349
|
-
this.renderReact(
|
|
2350
|
-
/* @__PURE__ */ React26.createElement(
|
|
2351
|
-
Popover3,
|
|
2352
|
-
{
|
|
2353
|
-
content: /* @__PURE__ */ React26.createElement(UIPopoverContent2, null, rootIcon, rootTitle, /* @__PURE__ */ React26.createElement(UIVarName2, null, v?.keyPath.slice(1).join(".")))
|
|
2354
|
-
},
|
|
2355
|
-
/* @__PURE__ */ React26.createElement(UITag2, { prefixIcon: rootIcon }, rootTitle, !isRoot && /* @__PURE__ */ React26.createElement(UIVarName2, null, v?.key))
|
|
2356
|
-
)
|
|
2357
|
-
);
|
|
2358
|
-
}
|
|
2359
|
-
toDOM(view) {
|
|
2360
|
-
const dom = document.createElement("span");
|
|
2361
|
-
this.rootDOM = dom;
|
|
2362
|
-
this.toDispose.push(
|
|
2363
|
-
Disposable.create(() => {
|
|
2364
|
-
ReactDOM.unmountComponentAtNode(this.rootDOM);
|
|
2365
|
-
})
|
|
2366
|
-
);
|
|
2367
|
-
this.toDispose.push(
|
|
2368
|
-
this.scope.available.trackByKeyPath(
|
|
2369
|
-
this.keyPath,
|
|
2370
|
-
(v) => {
|
|
2371
|
-
this.renderVariable(v);
|
|
2372
|
-
},
|
|
2373
|
-
{ triggerOnInit: false }
|
|
2374
|
-
)
|
|
2375
|
-
);
|
|
2376
|
-
this.renderVariable(this.scope.available.getByKeyPath(this.keyPath));
|
|
2377
|
-
return dom;
|
|
2378
|
-
}
|
|
2379
|
-
eq(other) {
|
|
2380
|
-
return isEqual(this.keyPath, other.keyPath);
|
|
2381
|
-
}
|
|
2382
|
-
ignoreEvent() {
|
|
2383
|
-
return false;
|
|
2384
|
-
}
|
|
2385
|
-
destroy(dom) {
|
|
2386
|
-
this.toDispose.dispose();
|
|
2387
|
-
}
|
|
2388
|
-
};
|
|
2389
|
-
function VariableTagInject() {
|
|
2390
|
-
const injector = useInjector4();
|
|
2391
|
-
const scope = useCurrentScope();
|
|
2392
|
-
useLayoutEffect4(() => {
|
|
2393
|
-
const atMatcher = new MatchDecorator({
|
|
2394
|
-
regexp: /\{\{([^\}]+)\}\}/g,
|
|
2395
|
-
decoration: (match) => Decoration.replace({
|
|
2396
|
-
widget: new VariableTagWidget({
|
|
2397
|
-
keyPath: match[1]?.split(".") ?? [],
|
|
2398
|
-
scope
|
|
2399
|
-
})
|
|
2400
|
-
})
|
|
2401
|
-
});
|
|
2402
|
-
return injector.inject([
|
|
2403
|
-
ViewPlugin.fromClass(
|
|
2404
|
-
class {
|
|
2405
|
-
constructor(view) {
|
|
2406
|
-
this.view = view;
|
|
2407
|
-
this.decorations = atMatcher.createDeco(view);
|
|
2408
|
-
}
|
|
2409
|
-
update() {
|
|
2410
|
-
this.decorations = atMatcher.createDeco(this.view);
|
|
2411
|
-
}
|
|
2412
|
-
},
|
|
2413
|
-
{
|
|
2414
|
-
decorations: (p) => p.decorations,
|
|
2415
|
-
provide(p) {
|
|
2416
|
-
return EditorView4.atomicRanges.of(
|
|
2417
|
-
(view) => view.plugin(p)?.decorations ?? Decoration.none
|
|
2418
|
-
);
|
|
2419
|
-
}
|
|
2420
|
-
}
|
|
2421
|
-
)
|
|
2422
|
-
]);
|
|
2423
|
-
}, [injector]);
|
|
2424
|
-
return null;
|
|
1214
|
+
))));
|
|
2425
1215
|
}
|
|
2426
1216
|
|
|
2427
|
-
// src/components/
|
|
2428
|
-
|
|
2429
|
-
|
|
1217
|
+
// src/components/batch-outputs/index.tsx
|
|
1218
|
+
import React14 from "react";
|
|
1219
|
+
import { I18n as I18n7 } from "@flowgram.ai/editor";
|
|
1220
|
+
import { Button as Button4, Input as Input5 } from "@douyinfe/semi-ui";
|
|
1221
|
+
import { IconDelete, IconPlus as IconPlus2 } from "@douyinfe/semi-icons";
|
|
1222
|
+
|
|
1223
|
+
// src/hooks/use-object-list/index.tsx
|
|
1224
|
+
import { useEffect as useEffect4, useRef as useRef3, useState as useState5 } from "react";
|
|
1225
|
+
import { nanoid } from "nanoid";
|
|
1226
|
+
import { difference as difference2, get, isObject, set } from "lodash-es";
|
|
1227
|
+
function genId2() {
|
|
1228
|
+
return nanoid();
|
|
2430
1229
|
}
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
// src/components/prompt-editor-with-inputs/extensions/inputs-tree.tsx
|
|
2436
|
-
import React29, { useEffect as useEffect7, useState as useState7 } from "react";
|
|
2437
|
-
import { Popover as Popover4 } from "@douyinfe/semi-ui";
|
|
2438
|
-
import {
|
|
2439
|
-
Mention as Mention2,
|
|
2440
|
-
getCurrentMentionReplaceRange as getCurrentMentionReplaceRange2,
|
|
2441
|
-
useEditor as useEditor2,
|
|
2442
|
-
PositionMirror as PositionMirror2
|
|
2443
|
-
} from "@coze-editor/editor/react";
|
|
2444
|
-
|
|
2445
|
-
// src/components/prompt-editor-with-inputs/inputs-picker.tsx
|
|
2446
|
-
import React28, { useMemo as useMemo9 } from "react";
|
|
2447
|
-
import { last as last2 } from "lodash";
|
|
2448
|
-
import {
|
|
2449
|
-
ASTMatch as ASTMatch3,
|
|
2450
|
-
useScopeAvailable as useScopeAvailable3
|
|
2451
|
-
} from "@flowgram.ai/editor";
|
|
2452
|
-
import { Tree as Tree2 } from "@douyinfe/semi-ui";
|
|
2453
|
-
function InputsPicker({
|
|
2454
|
-
inputsValues,
|
|
2455
|
-
onSelect
|
|
1230
|
+
function useObjectList({
|
|
1231
|
+
value,
|
|
1232
|
+
onChange,
|
|
1233
|
+
sortIndexKey
|
|
2456
1234
|
}) {
|
|
2457
|
-
const
|
|
2458
|
-
const
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
};
|
|
2464
|
-
const renderVariable = (variable, keyPath) => {
|
|
2465
|
-
let type = variable?.type;
|
|
2466
|
-
let children;
|
|
2467
|
-
if (ASTMatch3.isObject(type)) {
|
|
2468
|
-
children = (type.properties || []).map((_property) => renderVariable(_property, [...keyPath, _property.key])).filter(Boolean);
|
|
2469
|
-
}
|
|
2470
|
-
if (ASTMatch3.isArray(type)) {
|
|
2471
|
-
const drilldown = getArrayDrilldown(type);
|
|
2472
|
-
if (ASTMatch3.isObject(drilldown.type)) {
|
|
2473
|
-
children = (drilldown.type.properties || []).map(
|
|
2474
|
-
(_property) => renderVariable(_property, [
|
|
2475
|
-
...keyPath,
|
|
2476
|
-
...new Array(drilldown.depth).fill("[0]"),
|
|
2477
|
-
_property.key
|
|
2478
|
-
])
|
|
2479
|
-
).filter(Boolean);
|
|
2480
|
-
}
|
|
1235
|
+
const [list, setList] = useState5([]);
|
|
1236
|
+
const effectVersion = useRef3(0);
|
|
1237
|
+
const changeVersion = useRef3(0);
|
|
1238
|
+
const getSortIndex = (value2) => {
|
|
1239
|
+
if (typeof sortIndexKey === "function") {
|
|
1240
|
+
return get(value2, sortIndexKey(value2)) || 0;
|
|
2481
1241
|
}
|
|
2482
|
-
|
|
2483
|
-
return {
|
|
2484
|
-
key,
|
|
2485
|
-
label: last2(keyPath),
|
|
2486
|
-
value: key,
|
|
2487
|
-
children
|
|
2488
|
-
};
|
|
1242
|
+
return get(value2, sortIndexKey || "") || 0;
|
|
2489
1243
|
};
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
const variable = available.getByKeyPath(value.content || []);
|
|
2494
|
-
if (variable) {
|
|
2495
|
-
return renderVariable(variable, [key]);
|
|
2496
|
-
}
|
|
2497
|
-
}
|
|
2498
|
-
return {
|
|
2499
|
-
key,
|
|
2500
|
-
value: key,
|
|
2501
|
-
label: key
|
|
2502
|
-
};
|
|
2503
|
-
}),
|
|
2504
|
-
[]
|
|
2505
|
-
);
|
|
2506
|
-
return /* @__PURE__ */ React28.createElement(Tree2, { treeData, onSelect: (v) => onSelect(v) });
|
|
2507
|
-
}
|
|
2508
|
-
|
|
2509
|
-
// src/components/prompt-editor-with-inputs/extensions/inputs-tree.tsx
|
|
2510
|
-
function InputsTree({ inputsValues }) {
|
|
2511
|
-
const [posKey, setPosKey] = useState7("");
|
|
2512
|
-
const [visible, setVisible] = useState7(false);
|
|
2513
|
-
const [position, setPosition] = useState7(-1);
|
|
2514
|
-
const editor = useEditor2();
|
|
2515
|
-
function insert(variablePath) {
|
|
2516
|
-
const range = getCurrentMentionReplaceRange2(editor.$view.state);
|
|
2517
|
-
if (!range) {
|
|
1244
|
+
useEffect4(() => {
|
|
1245
|
+
effectVersion.current = effectVersion.current + 1;
|
|
1246
|
+
if (effectVersion.current === changeVersion.current) {
|
|
2518
1247
|
return;
|
|
2519
1248
|
}
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
|
|
1249
|
+
effectVersion.current = changeVersion.current;
|
|
1250
|
+
setList((_prevList) => {
|
|
1251
|
+
const newKeys = Object.entries(value || {}).sort((a, b) => getSortIndex(a[1]) - getSortIndex(b[1])).map(([key]) => key);
|
|
1252
|
+
const oldKeys = _prevList.map((item) => item.key).filter(Boolean);
|
|
1253
|
+
const addKeys = difference2(newKeys, oldKeys);
|
|
1254
|
+
return _prevList.filter((item) => !item.key || newKeys.includes(item.key)).map((item) => ({
|
|
1255
|
+
id: item.id,
|
|
1256
|
+
key: item.key,
|
|
1257
|
+
value: item.key ? value?.[item.key] : item.value
|
|
1258
|
+
})).concat(
|
|
1259
|
+
addKeys.map((_key) => ({
|
|
1260
|
+
id: genId2(),
|
|
1261
|
+
key: _key,
|
|
1262
|
+
value: value?.[_key]
|
|
1263
|
+
}))
|
|
1264
|
+
);
|
|
2523
1265
|
});
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
setVisible(e.value);
|
|
2529
|
-
}
|
|
2530
|
-
useEffect7(() => {
|
|
2531
|
-
if (!editor) {
|
|
2532
|
-
return;
|
|
2533
|
-
}
|
|
2534
|
-
}, [editor, visible]);
|
|
2535
|
-
return /* @__PURE__ */ React29.createElement(React29.Fragment, null, /* @__PURE__ */ React29.createElement(Mention2, { triggerCharacters: ["{", "{}", "@"], onOpenChange: handleOpenChange }), /* @__PURE__ */ React29.createElement(
|
|
2536
|
-
Popover4,
|
|
2537
|
-
{
|
|
2538
|
-
visible,
|
|
2539
|
-
trigger: "custom",
|
|
2540
|
-
position: "topLeft",
|
|
2541
|
-
rePosKey: posKey,
|
|
2542
|
-
content: /* @__PURE__ */ React29.createElement("div", { style: { width: 300 } }, /* @__PURE__ */ React29.createElement(
|
|
2543
|
-
InputsPicker,
|
|
2544
|
-
{
|
|
2545
|
-
inputsValues,
|
|
2546
|
-
onSelect: (v) => {
|
|
2547
|
-
insert(v);
|
|
2548
|
-
}
|
|
2549
|
-
}
|
|
2550
|
-
))
|
|
2551
|
-
},
|
|
2552
|
-
/* @__PURE__ */ React29.createElement(
|
|
2553
|
-
PositionMirror2,
|
|
1266
|
+
}, [value]);
|
|
1267
|
+
const add = (defaultValue) => {
|
|
1268
|
+
setList((prevList) => [
|
|
1269
|
+
...prevList,
|
|
2554
1270
|
{
|
|
2555
|
-
|
|
2556
|
-
|
|
1271
|
+
id: genId2(),
|
|
1272
|
+
value: defaultValue
|
|
2557
1273
|
}
|
|
2558
|
-
)
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
const editor = useEditor3();
|
|
2585
|
-
function insert(variablePath) {
|
|
2586
|
-
const range = getCurrentMentionReplaceRange3(editor.$view.state);
|
|
2587
|
-
if (!range) {
|
|
2588
|
-
return;
|
|
2589
|
-
}
|
|
2590
|
-
editor.replaceText({
|
|
2591
|
-
...range,
|
|
2592
|
-
text: "{{" + variablePath + "}}"
|
|
1274
|
+
]);
|
|
1275
|
+
};
|
|
1276
|
+
const updateValue = (itemId, value2) => {
|
|
1277
|
+
changeVersion.current = changeVersion.current + 1;
|
|
1278
|
+
setList((prevList) => {
|
|
1279
|
+
const nextList = prevList.map((_item) => {
|
|
1280
|
+
if (_item.id === itemId) {
|
|
1281
|
+
return {
|
|
1282
|
+
..._item,
|
|
1283
|
+
value: value2
|
|
1284
|
+
};
|
|
1285
|
+
}
|
|
1286
|
+
return _item;
|
|
1287
|
+
});
|
|
1288
|
+
onChange(
|
|
1289
|
+
Object.fromEntries(
|
|
1290
|
+
nextList.filter((item) => item.key).map((item) => [item.key, item.value]).map((_res, idx) => {
|
|
1291
|
+
const indexKey = typeof sortIndexKey === "function" ? sortIndexKey(_res[1]) : sortIndexKey;
|
|
1292
|
+
if (isObject(_res[1]) && indexKey) {
|
|
1293
|
+
set(_res[1], indexKey, idx);
|
|
1294
|
+
}
|
|
1295
|
+
return _res;
|
|
1296
|
+
})
|
|
1297
|
+
)
|
|
1298
|
+
);
|
|
1299
|
+
return nextList;
|
|
2593
1300
|
});
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
|
|
2598
|
-
|
|
2599
|
-
|
|
2600
|
-
|
|
2601
|
-
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
}, [editor, visible]);
|
|
2605
|
-
const treeData = useVariableTree({});
|
|
2606
|
-
return /* @__PURE__ */ React31.createElement(React31.Fragment, null, /* @__PURE__ */ React31.createElement(Mention3, { triggerCharacters: ["@"], onOpenChange: handleOpenChange }), /* @__PURE__ */ React31.createElement(
|
|
2607
|
-
Popover5,
|
|
2608
|
-
{
|
|
2609
|
-
visible,
|
|
2610
|
-
trigger: "custom",
|
|
2611
|
-
position: "topLeft",
|
|
2612
|
-
rePosKey: posKey,
|
|
2613
|
-
content: /* @__PURE__ */ React31.createElement("div", { style: { width: 300 } }, /* @__PURE__ */ React31.createElement(
|
|
2614
|
-
Tree3,
|
|
2615
|
-
{
|
|
2616
|
-
treeData,
|
|
2617
|
-
onSelect: (v) => {
|
|
2618
|
-
insert(v);
|
|
2619
|
-
}
|
|
1301
|
+
};
|
|
1302
|
+
const updateKey = (itemId, key) => {
|
|
1303
|
+
changeVersion.current = changeVersion.current + 1;
|
|
1304
|
+
setList((prevList) => {
|
|
1305
|
+
const nextList = prevList.map((_item) => {
|
|
1306
|
+
if (_item.id === itemId) {
|
|
1307
|
+
return {
|
|
1308
|
+
..._item,
|
|
1309
|
+
key
|
|
1310
|
+
};
|
|
2620
1311
|
}
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
)
|
|
2630
|
-
|
|
1312
|
+
return _item;
|
|
1313
|
+
});
|
|
1314
|
+
onChange(
|
|
1315
|
+
Object.fromEntries(
|
|
1316
|
+
nextList.filter((item) => item.key).map((item) => [item.key, item.value])
|
|
1317
|
+
)
|
|
1318
|
+
);
|
|
1319
|
+
return nextList;
|
|
1320
|
+
});
|
|
1321
|
+
};
|
|
1322
|
+
const remove = (itemId) => {
|
|
1323
|
+
changeVersion.current = changeVersion.current + 1;
|
|
1324
|
+
setList((prevList) => {
|
|
1325
|
+
const nextList = prevList.filter((_item) => _item.id !== itemId);
|
|
1326
|
+
onChange(
|
|
1327
|
+
Object.fromEntries(
|
|
1328
|
+
nextList.filter((item) => item.key).map((item) => [item.key, item.value])
|
|
1329
|
+
)
|
|
1330
|
+
);
|
|
1331
|
+
return nextList;
|
|
1332
|
+
});
|
|
1333
|
+
};
|
|
1334
|
+
return { list, add, updateKey, updateValue, remove };
|
|
2631
1335
|
}
|
|
2632
1336
|
|
|
2633
|
-
// src/components/
|
|
2634
|
-
import
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
useCurrentScope as useCurrentScope2
|
|
2641
|
-
} from "@flowgram.ai/editor";
|
|
2642
|
-
import { Popover as Popover6 } from "@douyinfe/semi-ui";
|
|
2643
|
-
import { IconIssueStroked as IconIssueStroked3 } from "@douyinfe/semi-icons";
|
|
2644
|
-
import { useInjector as useInjector5 } from "@coze-editor/editor/react";
|
|
2645
|
-
import {
|
|
2646
|
-
Decoration as Decoration2,
|
|
2647
|
-
EditorView as EditorView5,
|
|
2648
|
-
MatchDecorator as MatchDecorator2,
|
|
2649
|
-
ViewPlugin as ViewPlugin2,
|
|
2650
|
-
WidgetType as WidgetType2
|
|
2651
|
-
} from "@codemirror/view";
|
|
2652
|
-
|
|
2653
|
-
// src/components/json-editor-with-variables/styles.tsx
|
|
2654
|
-
import styled9 from "styled-components";
|
|
2655
|
-
import { Tag as Tag3 } from "@douyinfe/semi-ui";
|
|
2656
|
-
var UIRootTitle3 = styled9.div`
|
|
2657
|
-
margin-right: 4px;
|
|
2658
|
-
min-width: 20px;
|
|
2659
|
-
overflow: hidden;
|
|
2660
|
-
text-overflow: ellipsis;
|
|
2661
|
-
white-space: nowrap;
|
|
2662
|
-
color: var(--semi-color-text-2);
|
|
2663
|
-
`;
|
|
2664
|
-
var UIVarName3 = styled9.div`
|
|
2665
|
-
overflow: hidden;
|
|
2666
|
-
text-overflow: ellipsis;
|
|
2667
|
-
white-space: nowrap;
|
|
2668
|
-
`;
|
|
2669
|
-
var UITag3 = styled9(Tag3)`
|
|
2670
|
-
display: inline-flex;
|
|
2671
|
-
align-items: center;
|
|
2672
|
-
justify-content: flex-start;
|
|
2673
|
-
max-width: 300px;
|
|
2674
|
-
|
|
2675
|
-
& .semi-tag-content-center {
|
|
2676
|
-
justify-content: flex-start;
|
|
2677
|
-
}
|
|
2678
|
-
|
|
2679
|
-
&.semi-tag {
|
|
2680
|
-
margin: 0 5px;
|
|
2681
|
-
}
|
|
1337
|
+
// src/components/batch-outputs/styles.tsx
|
|
1338
|
+
import styled5 from "styled-components";
|
|
1339
|
+
var UIRows = styled5.div`
|
|
1340
|
+
display: flex;
|
|
1341
|
+
flex-direction: column;
|
|
1342
|
+
gap: 10px;
|
|
1343
|
+
margin-bottom: 10px;
|
|
2682
1344
|
`;
|
|
2683
|
-
var
|
|
2684
|
-
|
|
2685
|
-
display: inline-flex;
|
|
1345
|
+
var UIRow2 = styled5.div`
|
|
1346
|
+
display: flex;
|
|
2686
1347
|
align-items: center;
|
|
2687
|
-
|
|
1348
|
+
gap: 5px;
|
|
2688
1349
|
`;
|
|
2689
1350
|
|
|
2690
|
-
// src/components/
|
|
2691
|
-
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
|
|
2697
|
-
|
|
2698
|
-
|
|
2699
|
-
|
|
2700
|
-
|
|
2701
|
-
|
|
2702
|
-
this.scope = scope;
|
|
2703
|
-
}
|
|
2704
|
-
renderVariable(v) {
|
|
2705
|
-
if (!v) {
|
|
2706
|
-
this.root.render(
|
|
2707
|
-
/* @__PURE__ */ React32.createElement(UITag3, { prefixIcon: /* @__PURE__ */ React32.createElement(IconIssueStroked3, null), color: "amber" }, "Unknown")
|
|
2708
|
-
);
|
|
2709
|
-
return;
|
|
1351
|
+
// src/components/batch-outputs/index.tsx
|
|
1352
|
+
function BatchOutputs(props) {
|
|
1353
|
+
const { readonly, style } = props;
|
|
1354
|
+
const { list, add, updateKey, updateValue, remove } = useObjectList(props);
|
|
1355
|
+
return /* @__PURE__ */ React14.createElement("div", null, /* @__PURE__ */ React14.createElement(UIRows, { style }, list.map((item) => /* @__PURE__ */ React14.createElement(UIRow2, { key: item.id }, /* @__PURE__ */ React14.createElement(
|
|
1356
|
+
Input5,
|
|
1357
|
+
{
|
|
1358
|
+
style: { width: 100 },
|
|
1359
|
+
disabled: readonly,
|
|
1360
|
+
size: "small",
|
|
1361
|
+
value: item.key,
|
|
1362
|
+
onChange: (v) => updateKey(item.id, v)
|
|
2710
1363
|
}
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
|
|
2720
|
-
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
|
|
2724
|
-
|
|
2725
|
-
|
|
2726
|
-
|
|
2727
|
-
|
|
2728
|
-
Disposable2.create(() => {
|
|
2729
|
-
this.root.unmount();
|
|
2730
|
-
})
|
|
2731
|
-
);
|
|
2732
|
-
this.toDispose.push(
|
|
2733
|
-
this.scope.available.trackByKeyPath(
|
|
2734
|
-
this.keyPath,
|
|
2735
|
-
(v) => {
|
|
2736
|
-
this.renderVariable(v);
|
|
2737
|
-
},
|
|
2738
|
-
{ triggerOnInit: false }
|
|
2739
|
-
)
|
|
2740
|
-
);
|
|
2741
|
-
this.renderVariable(this.scope.available.getByKeyPath(this.keyPath));
|
|
2742
|
-
return dom;
|
|
2743
|
-
}
|
|
2744
|
-
eq(other) {
|
|
2745
|
-
return isEqual2(this.keyPath, other.keyPath);
|
|
2746
|
-
}
|
|
2747
|
-
ignoreEvent() {
|
|
2748
|
-
return false;
|
|
2749
|
-
}
|
|
2750
|
-
destroy(dom) {
|
|
2751
|
-
this.toDispose.dispose();
|
|
2752
|
-
}
|
|
2753
|
-
};
|
|
2754
|
-
function VariableTagInject2() {
|
|
2755
|
-
const injector = useInjector5();
|
|
2756
|
-
const scope = useCurrentScope2();
|
|
2757
|
-
useLayoutEffect5(() => {
|
|
2758
|
-
const atMatcher = new MatchDecorator2({
|
|
2759
|
-
regexp: /\{\{([^\}]+)\}\}/g,
|
|
2760
|
-
decoration: (match) => Decoration2.replace({
|
|
2761
|
-
widget: new VariableTagWidget2({
|
|
2762
|
-
keyPath: match[1]?.split(".") ?? [],
|
|
2763
|
-
scope
|
|
2764
|
-
})
|
|
2765
|
-
})
|
|
2766
|
-
});
|
|
2767
|
-
return injector.inject([
|
|
2768
|
-
ViewPlugin2.fromClass(
|
|
2769
|
-
class {
|
|
2770
|
-
constructor(view) {
|
|
2771
|
-
this.view = view;
|
|
2772
|
-
this.decorations = atMatcher.createDeco(view);
|
|
2773
|
-
}
|
|
2774
|
-
update() {
|
|
2775
|
-
this.decorations = atMatcher.createDeco(this.view);
|
|
2776
|
-
}
|
|
2777
|
-
},
|
|
2778
|
-
{
|
|
2779
|
-
decorations: (p) => p.decorations,
|
|
2780
|
-
provide(p) {
|
|
2781
|
-
return EditorView5.atomicRanges.of(
|
|
2782
|
-
(view) => view.plugin(p)?.decorations ?? Decoration2.none
|
|
2783
|
-
);
|
|
2784
|
-
}
|
|
2785
|
-
}
|
|
2786
|
-
)
|
|
2787
|
-
]);
|
|
2788
|
-
}, [injector]);
|
|
2789
|
-
return null;
|
|
1364
|
+
), /* @__PURE__ */ React14.createElement(
|
|
1365
|
+
InjectVariableSelector,
|
|
1366
|
+
{
|
|
1367
|
+
style: { flexGrow: 1 },
|
|
1368
|
+
readonly,
|
|
1369
|
+
value: item.value?.content,
|
|
1370
|
+
onChange: (v) => updateValue(item.id, { type: "ref", content: v })
|
|
1371
|
+
}
|
|
1372
|
+
), /* @__PURE__ */ React14.createElement(
|
|
1373
|
+
Button4,
|
|
1374
|
+
{
|
|
1375
|
+
disabled: readonly,
|
|
1376
|
+
icon: /* @__PURE__ */ React14.createElement(IconDelete, null),
|
|
1377
|
+
size: "small",
|
|
1378
|
+
onClick: () => remove(item.id)
|
|
1379
|
+
}
|
|
1380
|
+
)))), /* @__PURE__ */ React14.createElement(Button4, { disabled: readonly, icon: /* @__PURE__ */ React14.createElement(IconPlus2, null), size: "small", onClick: () => add() }, I18n7.t("Add")));
|
|
2790
1381
|
}
|
|
2791
1382
|
|
|
1383
|
+
// src/components/prompt-editor-with-variables/index.tsx
|
|
1384
|
+
var PromptEditorWithVariables = lazySuspense(
|
|
1385
|
+
() => import("./editor-VO6YAXRC.js").then((module) => ({ default: module.PromptEditorWithVariables }))
|
|
1386
|
+
);
|
|
1387
|
+
|
|
1388
|
+
// src/components/prompt-editor-with-inputs/index.tsx
|
|
1389
|
+
var PromptEditorWithInputs = lazySuspense(
|
|
1390
|
+
() => import("./editor-OXPGKPF5.js").then((module) => ({ default: module.PromptEditorWithInputs }))
|
|
1391
|
+
);
|
|
1392
|
+
|
|
2792
1393
|
// src/components/json-editor-with-variables/index.tsx
|
|
2793
|
-
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
regex.flags.includes("g") ? regex.flags : regex.flags + "g"
|
|
2797
|
-
);
|
|
2798
|
-
let match;
|
|
2799
|
-
const matches = [];
|
|
2800
|
-
while ((match = globalRegex.exec(inputString)) !== null) {
|
|
2801
|
-
if (match.index === globalRegex.lastIndex) {
|
|
2802
|
-
globalRegex.lastIndex++;
|
|
2803
|
-
}
|
|
2804
|
-
matches.push({
|
|
2805
|
-
match: match[0],
|
|
2806
|
-
range: [match.index, match.index + match[0].length]
|
|
2807
|
-
});
|
|
2808
|
-
}
|
|
2809
|
-
return matches;
|
|
2810
|
-
}
|
|
2811
|
-
var transformer = transformerCreator((text) => {
|
|
2812
|
-
const originalSource = text.toString();
|
|
2813
|
-
const matches = findAllMatches(originalSource, /\{\{([^\}]*)\}\}/g);
|
|
2814
|
-
if (matches.length > 0) {
|
|
2815
|
-
matches.forEach(({ range }) => {
|
|
2816
|
-
text.replaceRange(range[0], range[1], "null");
|
|
2817
|
-
});
|
|
2818
|
-
}
|
|
2819
|
-
return text;
|
|
2820
|
-
});
|
|
2821
|
-
function JsonEditorWithVariables(props) {
|
|
2822
|
-
return /* @__PURE__ */ React33.createElement(
|
|
2823
|
-
CodeEditor,
|
|
2824
|
-
{
|
|
2825
|
-
languageId: "json",
|
|
2826
|
-
activeLinePlaceholder: "Press '@' to Select variable",
|
|
2827
|
-
...props,
|
|
2828
|
-
options: {
|
|
2829
|
-
transformer,
|
|
2830
|
-
...props.options || {}
|
|
2831
|
-
}
|
|
2832
|
-
},
|
|
2833
|
-
/* @__PURE__ */ React33.createElement(VariableTree2, null),
|
|
2834
|
-
/* @__PURE__ */ React33.createElement(VariableTagInject2, null)
|
|
2835
|
-
);
|
|
2836
|
-
}
|
|
1394
|
+
var JsonEditorWithVariables = lazySuspense(
|
|
1395
|
+
() => import("./editor-EYOQTGMT.js").then((module) => ({ default: module.JsonEditorWithVariables }))
|
|
1396
|
+
);
|
|
2837
1397
|
|
|
2838
1398
|
// src/components/inputs-values/index.tsx
|
|
2839
|
-
import
|
|
2840
|
-
import { I18n as
|
|
2841
|
-
import { Button as
|
|
1399
|
+
import React15 from "react";
|
|
1400
|
+
import { I18n as I18n8 } from "@flowgram.ai/editor";
|
|
1401
|
+
import { Button as Button5, IconButton as IconButton4 } from "@douyinfe/semi-ui";
|
|
2842
1402
|
import { IconDelete as IconDelete2, IconPlus as IconPlus3 } from "@douyinfe/semi-icons";
|
|
2843
1403
|
|
|
2844
1404
|
// src/components/inputs-values/styles.tsx
|
|
2845
|
-
import
|
|
2846
|
-
var UIRows2 =
|
|
1405
|
+
import styled6 from "styled-components";
|
|
1406
|
+
var UIRows2 = styled6.div`
|
|
2847
1407
|
display: flex;
|
|
2848
1408
|
flex-direction: column;
|
|
2849
1409
|
gap: 10px;
|
|
2850
1410
|
margin-bottom: 10px;
|
|
2851
1411
|
`;
|
|
2852
|
-
var UIRow3 =
|
|
1412
|
+
var UIRow3 = styled6.div`
|
|
2853
1413
|
display: flex;
|
|
2854
|
-
align-items:
|
|
1414
|
+
align-items: flex-start;
|
|
2855
1415
|
gap: 5px;
|
|
2856
1416
|
`;
|
|
2857
1417
|
|
|
2858
|
-
// src/components/inputs-values/components/blur-input.tsx
|
|
2859
|
-
import React34, { useEffect as useEffect9, useState as useState9 } from "react";
|
|
2860
|
-
import Input6 from "@douyinfe/semi-ui/lib/es/input";
|
|
2861
|
-
function BlurInput2(props) {
|
|
2862
|
-
const [value, setValue] = useState9("");
|
|
2863
|
-
useEffect9(() => {
|
|
2864
|
-
setValue(props.value);
|
|
2865
|
-
}, [props.value]);
|
|
2866
|
-
return /* @__PURE__ */ React34.createElement(
|
|
2867
|
-
Input6,
|
|
2868
|
-
{
|
|
2869
|
-
...props,
|
|
2870
|
-
value,
|
|
2871
|
-
onChange: (value2) => {
|
|
2872
|
-
setValue(value2);
|
|
2873
|
-
},
|
|
2874
|
-
onBlur: (e) => props.onChange?.(value, e)
|
|
2875
|
-
}
|
|
2876
|
-
);
|
|
2877
|
-
}
|
|
2878
|
-
|
|
2879
1418
|
// src/components/inputs-values/index.tsx
|
|
2880
1419
|
function InputsValues({
|
|
2881
1420
|
value,
|
|
@@ -2891,17 +1430,17 @@ function InputsValues({
|
|
|
2891
1430
|
onChange,
|
|
2892
1431
|
sortIndexKey: "extra.index"
|
|
2893
1432
|
});
|
|
2894
|
-
return /* @__PURE__ */
|
|
2895
|
-
|
|
1433
|
+
return /* @__PURE__ */ React15.createElement("div", null, /* @__PURE__ */ React15.createElement(UIRows2, { style }, list.map((item) => /* @__PURE__ */ React15.createElement(UIRow3, { key: item.id }, /* @__PURE__ */ React15.createElement(
|
|
1434
|
+
BlurInput,
|
|
2896
1435
|
{
|
|
2897
1436
|
style: { width: 100, minWidth: 100, maxWidth: 100 },
|
|
2898
1437
|
disabled: readonly,
|
|
2899
1438
|
size: "small",
|
|
2900
1439
|
value: item.key,
|
|
2901
1440
|
onChange: (v) => updateKey(item.id, v),
|
|
2902
|
-
placeholder:
|
|
1441
|
+
placeholder: I18n8.t("Input Key")
|
|
2903
1442
|
}
|
|
2904
|
-
), /* @__PURE__ */
|
|
1443
|
+
), /* @__PURE__ */ React15.createElement(
|
|
2905
1444
|
InjectDynamicValueInput,
|
|
2906
1445
|
{
|
|
2907
1446
|
style: { flexGrow: 1 },
|
|
@@ -2915,24 +1454,37 @@ function InputsValues({
|
|
|
2915
1454
|
strategies: [...constantProps?.strategies || []]
|
|
2916
1455
|
}
|
|
2917
1456
|
}
|
|
2918
|
-
), /* @__PURE__ */
|
|
1457
|
+
), /* @__PURE__ */ React15.createElement(
|
|
2919
1458
|
IconButton4,
|
|
2920
1459
|
{
|
|
2921
1460
|
disabled: readonly,
|
|
2922
1461
|
theme: "borderless",
|
|
2923
|
-
icon: /* @__PURE__ */
|
|
1462
|
+
icon: /* @__PURE__ */ React15.createElement(IconDelete2, { size: "small" }),
|
|
2924
1463
|
size: "small",
|
|
2925
1464
|
onClick: () => remove(item.id)
|
|
2926
1465
|
}
|
|
2927
|
-
)))), /* @__PURE__ */
|
|
1466
|
+
)))), /* @__PURE__ */ React15.createElement(
|
|
1467
|
+
Button5,
|
|
1468
|
+
{
|
|
1469
|
+
disabled: readonly,
|
|
1470
|
+
icon: /* @__PURE__ */ React15.createElement(IconPlus3, null),
|
|
1471
|
+
size: "small",
|
|
1472
|
+
onClick: () => add({
|
|
1473
|
+
type: "constant",
|
|
1474
|
+
content: "",
|
|
1475
|
+
schema: { type: "string" }
|
|
1476
|
+
})
|
|
1477
|
+
},
|
|
1478
|
+
I18n8.t("Add")
|
|
1479
|
+
));
|
|
2928
1480
|
}
|
|
2929
1481
|
|
|
2930
1482
|
// src/components/display-schema-tree/index.tsx
|
|
2931
|
-
import
|
|
1483
|
+
import React16 from "react";
|
|
2932
1484
|
|
|
2933
1485
|
// src/components/display-schema-tree/styles.tsx
|
|
2934
|
-
import
|
|
2935
|
-
var TreeRow =
|
|
1486
|
+
import styled7, { css as css2 } from "styled-components";
|
|
1487
|
+
var TreeRow = styled7.div`
|
|
2936
1488
|
display: flex;
|
|
2937
1489
|
align-items: center;
|
|
2938
1490
|
|
|
@@ -2945,7 +1497,7 @@ var TreeRow = styled11.div`
|
|
|
2945
1497
|
height: 27px;
|
|
2946
1498
|
white-space: nowrap;
|
|
2947
1499
|
`;
|
|
2948
|
-
var HorizontalLine =
|
|
1500
|
+
var HorizontalLine = styled7.div`
|
|
2949
1501
|
position: relative;
|
|
2950
1502
|
|
|
2951
1503
|
&::before,
|
|
@@ -2962,11 +1514,11 @@ var HorizontalLine = styled11.div`
|
|
|
2962
1514
|
height: 1px;
|
|
2963
1515
|
}
|
|
2964
1516
|
`;
|
|
2965
|
-
var TreeTitle =
|
|
1517
|
+
var TreeTitle = styled7.div`
|
|
2966
1518
|
// overflow: hidden;
|
|
2967
1519
|
// text-overflow: ellipsis;
|
|
2968
1520
|
`;
|
|
2969
|
-
var TreeLevel =
|
|
1521
|
+
var TreeLevel = styled7.div`
|
|
2970
1522
|
padding-left: 30px;
|
|
2971
1523
|
position: relative;
|
|
2972
1524
|
|
|
@@ -2980,7 +1532,7 @@ var TreeLevel = styled11.div`
|
|
|
2980
1532
|
width: 1px;
|
|
2981
1533
|
} */
|
|
2982
1534
|
`;
|
|
2983
|
-
var TreeItem =
|
|
1535
|
+
var TreeItem = styled7.div`
|
|
2984
1536
|
position: relative;
|
|
2985
1537
|
|
|
2986
1538
|
&::before {
|
|
@@ -3003,7 +1555,7 @@ var TreeItem = styled11.div`
|
|
|
3003
1555
|
left: -22px;
|
|
3004
1556
|
}
|
|
3005
1557
|
|
|
3006
|
-
${(props) => props.depth === 0 &&
|
|
1558
|
+
${(props) => props.depth === 0 && css2`
|
|
3007
1559
|
&::before {
|
|
3008
1560
|
width: 0px !important;
|
|
3009
1561
|
}
|
|
@@ -3012,7 +1564,7 @@ var TreeItem = styled11.div`
|
|
|
3012
1564
|
|
|
3013
1565
|
// src/components/display-schema-tree/index.tsx
|
|
3014
1566
|
function DisplaySchemaTree(props) {
|
|
3015
|
-
return /* @__PURE__ */
|
|
1567
|
+
return /* @__PURE__ */ React16.createElement(SchemaTree, { ...props });
|
|
3016
1568
|
}
|
|
3017
1569
|
function SchemaTree(props) {
|
|
3018
1570
|
const {
|
|
@@ -3028,27 +1580,27 @@ function SchemaTree(props) {
|
|
|
3028
1580
|
const icon = typeManager?.getDisplayIcon(schema);
|
|
3029
1581
|
let properties = drilldown && config ? config.getTypeSchemaProperties(schema) : {};
|
|
3030
1582
|
const childEntries = Object.entries(properties || {});
|
|
3031
|
-
return /* @__PURE__ */
|
|
1583
|
+
return /* @__PURE__ */ React16.createElement(TreeItem, { depth, key: parentKey || "root" }, /* @__PURE__ */ React16.createElement(TreeRow, null, depth !== 0 && /* @__PURE__ */ React16.createElement(HorizontalLine, null), showIcon && icon && React16.cloneElement(icon, {
|
|
3032
1584
|
className: "tree-icon"
|
|
3033
|
-
}), /* @__PURE__ */
|
|
1585
|
+
}), /* @__PURE__ */ React16.createElement(TreeTitle, null, parentKey ? /* @__PURE__ */ React16.createElement(React16.Fragment, null, `${parentKey} (`, title, ")") : title)), childEntries?.length ? /* @__PURE__ */ React16.createElement(TreeLevel, null, childEntries.map(([key, value]) => /* @__PURE__ */ React16.createElement(SchemaTree, { key, ...props, parentKey: key, value, depth: depth + 1 }))) : null);
|
|
3034
1586
|
}
|
|
3035
1587
|
|
|
3036
1588
|
// src/components/display-outputs/index.tsx
|
|
3037
|
-
import
|
|
3038
|
-
import { JsonSchemaUtils as
|
|
3039
|
-
import { useCurrentScope
|
|
1589
|
+
import React18, { useEffect as useEffect5 } from "react";
|
|
1590
|
+
import { JsonSchemaUtils as JsonSchemaUtils4 } from "@flowgram.ai/json-schema";
|
|
1591
|
+
import { useCurrentScope, useRefresh } from "@flowgram.ai/editor";
|
|
3040
1592
|
|
|
3041
1593
|
// src/components/display-schema-tag/index.tsx
|
|
3042
|
-
import
|
|
3043
|
-
import { Popover
|
|
1594
|
+
import React17 from "react";
|
|
1595
|
+
import { Popover } from "@douyinfe/semi-ui";
|
|
3044
1596
|
|
|
3045
1597
|
// src/components/display-schema-tag/styles.ts
|
|
3046
|
-
import
|
|
3047
|
-
import { Tag
|
|
3048
|
-
var PopoverContent =
|
|
1598
|
+
import styled8 from "styled-components";
|
|
1599
|
+
import { Tag } from "@douyinfe/semi-ui";
|
|
1600
|
+
var PopoverContent = styled8.div`
|
|
3049
1601
|
padding: 10px;
|
|
3050
1602
|
`;
|
|
3051
|
-
var StyledTag =
|
|
1603
|
+
var StyledTag = styled8(Tag)`
|
|
3052
1604
|
padding: 4px;
|
|
3053
1605
|
|
|
3054
1606
|
.tag-icon {
|
|
@@ -3056,7 +1608,7 @@ var StyledTag = styled12(Tag4)`
|
|
|
3056
1608
|
height: 12px;
|
|
3057
1609
|
}
|
|
3058
1610
|
`;
|
|
3059
|
-
var TitleSpan =
|
|
1611
|
+
var TitleSpan = styled8.span`
|
|
3060
1612
|
display: inline-block;
|
|
3061
1613
|
margin-left: 4px;
|
|
3062
1614
|
margin-top: -1px;
|
|
@@ -3068,20 +1620,20 @@ var TitleSpan = styled12.span`
|
|
|
3068
1620
|
function DisplaySchemaTag({ value = {}, showIconInTree, title, warning }) {
|
|
3069
1621
|
const typeManager = useTypeManager();
|
|
3070
1622
|
const icon = typeManager?.getDisplayIcon(value) || typeManager.getDisplayIcon({ type: "unknown" });
|
|
3071
|
-
return /* @__PURE__ */
|
|
3072
|
-
|
|
1623
|
+
return /* @__PURE__ */ React17.createElement(
|
|
1624
|
+
Popover,
|
|
3073
1625
|
{
|
|
3074
|
-
content: /* @__PURE__ */
|
|
1626
|
+
content: /* @__PURE__ */ React17.createElement(PopoverContent, null, /* @__PURE__ */ React17.createElement(DisplaySchemaTree, { value, typeManager, showIcon: showIconInTree }))
|
|
3075
1627
|
},
|
|
3076
|
-
/* @__PURE__ */
|
|
1628
|
+
/* @__PURE__ */ React17.createElement(StyledTag, { color: warning ? "amber" : "white" }, icon && React17.cloneElement(icon, {
|
|
3077
1629
|
className: "tag-icon"
|
|
3078
|
-
}), title && /* @__PURE__ */
|
|
1630
|
+
}), title && /* @__PURE__ */ React17.createElement(TitleSpan, null, title))
|
|
3079
1631
|
);
|
|
3080
1632
|
}
|
|
3081
1633
|
|
|
3082
1634
|
// src/components/display-outputs/styles.ts
|
|
3083
|
-
import
|
|
3084
|
-
var DisplayOutputsWrapper =
|
|
1635
|
+
import styled9 from "styled-components";
|
|
1636
|
+
var DisplayOutputsWrapper = styled9.div`
|
|
3085
1637
|
display: flex;
|
|
3086
1638
|
gap: 5px;
|
|
3087
1639
|
flex-wrap: wrap;
|
|
@@ -3089,9 +1641,9 @@ var DisplayOutputsWrapper = styled13.div`
|
|
|
3089
1641
|
|
|
3090
1642
|
// src/components/display-outputs/index.tsx
|
|
3091
1643
|
function DisplayOutputs({ value, showIconInTree, displayFromScope }) {
|
|
3092
|
-
const scope =
|
|
1644
|
+
const scope = useCurrentScope();
|
|
3093
1645
|
const refresh = useRefresh();
|
|
3094
|
-
|
|
1646
|
+
useEffect5(() => {
|
|
3095
1647
|
if (!displayFromScope) {
|
|
3096
1648
|
return () => null;
|
|
3097
1649
|
}
|
|
@@ -3105,12 +1657,12 @@ function DisplayOutputs({ value, showIconInTree, displayFromScope }) {
|
|
|
3105
1657
|
const properties = displayFromScope ? scope.output.variables?.reduce((acm, curr) => {
|
|
3106
1658
|
acm = {
|
|
3107
1659
|
...acm,
|
|
3108
|
-
...
|
|
1660
|
+
...JsonSchemaUtils4.astToSchema(curr.type)?.properties || {}
|
|
3109
1661
|
};
|
|
3110
1662
|
return acm;
|
|
3111
1663
|
}, {}) : value?.properties || {};
|
|
3112
1664
|
const childEntries = Object.entries(properties || {});
|
|
3113
|
-
return /* @__PURE__ */
|
|
1665
|
+
return /* @__PURE__ */ React18.createElement(DisplayOutputsWrapper, null, childEntries.map(([key, schema]) => /* @__PURE__ */ React18.createElement(
|
|
3114
1666
|
DisplaySchemaTag,
|
|
3115
1667
|
{
|
|
3116
1668
|
key,
|
|
@@ -3123,36 +1675,25 @@ function DisplayOutputs({ value, showIconInTree, displayFromScope }) {
|
|
|
3123
1675
|
}
|
|
3124
1676
|
|
|
3125
1677
|
// src/components/display-flow-value/index.tsx
|
|
3126
|
-
import
|
|
3127
|
-
import { JsonSchemaUtils as
|
|
3128
|
-
import { useScopeAvailable as
|
|
1678
|
+
import React19, { useMemo as useMemo11 } from "react";
|
|
1679
|
+
import { JsonSchemaUtils as JsonSchemaUtils5 } from "@flowgram.ai/json-schema";
|
|
1680
|
+
import { useScopeAvailable as useScopeAvailable3 } from "@flowgram.ai/editor";
|
|
3129
1681
|
function DisplayFlowValue({ value, title, showIconInTree }) {
|
|
3130
|
-
const available =
|
|
1682
|
+
const available = useScopeAvailable3();
|
|
3131
1683
|
const variable = value?.type === "ref" ? available.getByKeyPath(value?.content) : void 0;
|
|
3132
|
-
const schema =
|
|
1684
|
+
const schema = useMemo11(() => {
|
|
3133
1685
|
if (value?.type === "ref") {
|
|
3134
|
-
return
|
|
1686
|
+
return JsonSchemaUtils5.astToSchema(variable?.type);
|
|
3135
1687
|
}
|
|
3136
1688
|
if (value?.type === "template") {
|
|
3137
1689
|
return { type: "string" };
|
|
3138
1690
|
}
|
|
3139
1691
|
if (value?.type === "constant") {
|
|
3140
|
-
|
|
3141
|
-
return value?.schema;
|
|
3142
|
-
}
|
|
3143
|
-
if (typeof value?.content === "string") {
|
|
3144
|
-
return { type: "string" };
|
|
3145
|
-
}
|
|
3146
|
-
if (typeof value?.content === "number") {
|
|
3147
|
-
return { type: "number" };
|
|
3148
|
-
}
|
|
3149
|
-
if (typeof value?.content === "boolean") {
|
|
3150
|
-
return { type: "boolean" };
|
|
3151
|
-
}
|
|
1692
|
+
return FlowValueUtils.inferConstantJsonSchema(value);
|
|
3152
1693
|
}
|
|
3153
1694
|
return { type: "unknown" };
|
|
3154
1695
|
}, [value, variable?.hash]);
|
|
3155
|
-
return /* @__PURE__ */
|
|
1696
|
+
return /* @__PURE__ */ React19.createElement(
|
|
3156
1697
|
DisplaySchemaTag,
|
|
3157
1698
|
{
|
|
3158
1699
|
title,
|
|
@@ -3164,11 +1705,13 @@ function DisplayFlowValue({ value, title, showIconInTree }) {
|
|
|
3164
1705
|
}
|
|
3165
1706
|
|
|
3166
1707
|
// src/components/display-inputs-values/index.tsx
|
|
3167
|
-
import
|
|
1708
|
+
import React20, { useMemo as useMemo12 } from "react";
|
|
1709
|
+
import { isPlainObject } from "lodash-es";
|
|
1710
|
+
import { useScopeAvailable as useScopeAvailable4 } from "@flowgram.ai/editor";
|
|
3168
1711
|
|
|
3169
1712
|
// src/components/display-inputs-values/styles.ts
|
|
3170
|
-
import
|
|
3171
|
-
var DisplayInputsWrapper =
|
|
1713
|
+
import styled10 from "styled-components";
|
|
1714
|
+
var DisplayInputsWrapper = styled10.div`
|
|
3172
1715
|
display: flex;
|
|
3173
1716
|
gap: 5px;
|
|
3174
1717
|
flex-wrap: wrap;
|
|
@@ -3177,30 +1720,58 @@ var DisplayInputsWrapper = styled14.div`
|
|
|
3177
1720
|
// src/components/display-inputs-values/index.tsx
|
|
3178
1721
|
function DisplayInputsValues({ value, showIconInTree }) {
|
|
3179
1722
|
const childEntries = Object.entries(value || {});
|
|
3180
|
-
return /* @__PURE__ */
|
|
1723
|
+
return /* @__PURE__ */ React20.createElement(DisplayInputsWrapper, null, childEntries.map(([key, value2]) => {
|
|
1724
|
+
if (FlowValueUtils.isFlowValue(value2)) {
|
|
1725
|
+
return /* @__PURE__ */ React20.createElement(DisplayFlowValue, { key, title: key, value: value2, showIconInTree });
|
|
1726
|
+
}
|
|
1727
|
+
if (isPlainObject(value2)) {
|
|
1728
|
+
return /* @__PURE__ */ React20.createElement(
|
|
1729
|
+
DisplayInputsValueAllInTag,
|
|
1730
|
+
{
|
|
1731
|
+
key,
|
|
1732
|
+
title: key,
|
|
1733
|
+
value: value2,
|
|
1734
|
+
showIconInTree
|
|
1735
|
+
}
|
|
1736
|
+
);
|
|
1737
|
+
}
|
|
1738
|
+
return null;
|
|
1739
|
+
}));
|
|
1740
|
+
}
|
|
1741
|
+
function DisplayInputsValueAllInTag({
|
|
1742
|
+
value,
|
|
1743
|
+
title,
|
|
1744
|
+
showIconInTree
|
|
1745
|
+
}) {
|
|
1746
|
+
const available = useScopeAvailable4();
|
|
1747
|
+
const schema = useMemo12(
|
|
1748
|
+
() => FlowValueUtils.inferJsonSchema(value, available.scope),
|
|
1749
|
+
[available.version, value]
|
|
1750
|
+
);
|
|
1751
|
+
return /* @__PURE__ */ React20.createElement(DisplaySchemaTag, { title, value: schema, showIconInTree });
|
|
3181
1752
|
}
|
|
3182
1753
|
|
|
3183
1754
|
// src/components/assign-rows/index.tsx
|
|
3184
|
-
import
|
|
1755
|
+
import React23 from "react";
|
|
3185
1756
|
import { FieldArray } from "@flowgram.ai/editor";
|
|
3186
|
-
import { Button as
|
|
1757
|
+
import { Button as Button6 } from "@douyinfe/semi-ui";
|
|
3187
1758
|
import { IconPlus as IconPlus4 } from "@douyinfe/semi-icons";
|
|
3188
1759
|
|
|
3189
1760
|
// src/components/assign-row/index.tsx
|
|
3190
|
-
import
|
|
1761
|
+
import React22 from "react";
|
|
3191
1762
|
import { IconButton as IconButton5 } from "@douyinfe/semi-ui";
|
|
3192
1763
|
import { IconMinus as IconMinus2 } from "@douyinfe/semi-icons";
|
|
3193
1764
|
|
|
3194
1765
|
// src/components/assign-row/components/blur-input.tsx
|
|
3195
|
-
import
|
|
3196
|
-
import
|
|
3197
|
-
function
|
|
3198
|
-
const [value, setValue] =
|
|
3199
|
-
|
|
1766
|
+
import React21, { useEffect as useEffect6, useState as useState6 } from "react";
|
|
1767
|
+
import Input6 from "@douyinfe/semi-ui/lib/es/input";
|
|
1768
|
+
function BlurInput2(props) {
|
|
1769
|
+
const [value, setValue] = useState6("");
|
|
1770
|
+
useEffect6(() => {
|
|
3200
1771
|
setValue(props.value);
|
|
3201
1772
|
}, [props.value]);
|
|
3202
|
-
return /* @__PURE__ */
|
|
3203
|
-
|
|
1773
|
+
return /* @__PURE__ */ React21.createElement(
|
|
1774
|
+
Input6,
|
|
3204
1775
|
{
|
|
3205
1776
|
...props,
|
|
3206
1777
|
value,
|
|
@@ -3222,7 +1793,7 @@ function AssignRow(props) {
|
|
|
3222
1793
|
onDelete,
|
|
3223
1794
|
readonly
|
|
3224
1795
|
} = props;
|
|
3225
|
-
return /* @__PURE__ */
|
|
1796
|
+
return /* @__PURE__ */ React22.createElement("div", { style: { display: "flex", alignItems: "center", gap: 5 } }, /* @__PURE__ */ React22.createElement("div", { style: { width: 150, minWidth: 150, maxWidth: 150 } }, value?.operator === "assign" ? /* @__PURE__ */ React22.createElement(
|
|
3226
1797
|
InjectVariableSelector,
|
|
3227
1798
|
{
|
|
3228
1799
|
style: { width: "100%", height: 26 },
|
|
@@ -3233,8 +1804,8 @@ function AssignRow(props) {
|
|
|
3233
1804
|
left: { type: "ref", content: v }
|
|
3234
1805
|
})
|
|
3235
1806
|
}
|
|
3236
|
-
) : /* @__PURE__ */
|
|
3237
|
-
|
|
1807
|
+
) : /* @__PURE__ */ React22.createElement(
|
|
1808
|
+
BlurInput2,
|
|
3238
1809
|
{
|
|
3239
1810
|
style: { height: 26 },
|
|
3240
1811
|
size: "small",
|
|
@@ -3245,7 +1816,7 @@ function AssignRow(props) {
|
|
|
3245
1816
|
left: v
|
|
3246
1817
|
})
|
|
3247
1818
|
}
|
|
3248
|
-
)), /* @__PURE__ */
|
|
1819
|
+
)), /* @__PURE__ */ React22.createElement("div", { style: { flexGrow: 1 } }, /* @__PURE__ */ React22.createElement(
|
|
3249
1820
|
InjectDynamicValueInput,
|
|
3250
1821
|
{
|
|
3251
1822
|
readonly,
|
|
@@ -3255,12 +1826,12 @@ function AssignRow(props) {
|
|
|
3255
1826
|
right: v
|
|
3256
1827
|
})
|
|
3257
1828
|
}
|
|
3258
|
-
)), onDelete && /* @__PURE__ */
|
|
1829
|
+
)), onDelete && /* @__PURE__ */ React22.createElement("div", null, /* @__PURE__ */ React22.createElement(
|
|
3259
1830
|
IconButton5,
|
|
3260
1831
|
{
|
|
3261
1832
|
size: "small",
|
|
3262
1833
|
theme: "borderless",
|
|
3263
|
-
icon: /* @__PURE__ */
|
|
1834
|
+
icon: /* @__PURE__ */ React22.createElement(IconMinus2, null),
|
|
3264
1835
|
onClick: () => onDelete?.()
|
|
3265
1836
|
}
|
|
3266
1837
|
)));
|
|
@@ -3269,7 +1840,7 @@ function AssignRow(props) {
|
|
|
3269
1840
|
// src/components/assign-rows/index.tsx
|
|
3270
1841
|
function AssignRows(props) {
|
|
3271
1842
|
const { name, readonly } = props;
|
|
3272
|
-
return /* @__PURE__ */
|
|
1843
|
+
return /* @__PURE__ */ React23.createElement(FieldArray, { name }, ({ field }) => /* @__PURE__ */ React23.createElement(React23.Fragment, null, field.map((childField, index) => /* @__PURE__ */ React23.createElement(
|
|
3273
1844
|
AssignRow,
|
|
3274
1845
|
{
|
|
3275
1846
|
key: childField.key,
|
|
@@ -3280,27 +1851,341 @@ function AssignRows(props) {
|
|
|
3280
1851
|
},
|
|
3281
1852
|
onDelete: () => field.remove(index)
|
|
3282
1853
|
}
|
|
3283
|
-
)), /* @__PURE__ */
|
|
3284
|
-
|
|
1854
|
+
)), /* @__PURE__ */ React23.createElement("div", { style: { display: "flex", gap: 5 } }, /* @__PURE__ */ React23.createElement(
|
|
1855
|
+
Button6,
|
|
3285
1856
|
{
|
|
3286
1857
|
size: "small",
|
|
3287
1858
|
theme: "borderless",
|
|
3288
|
-
icon: /* @__PURE__ */
|
|
1859
|
+
icon: /* @__PURE__ */ React23.createElement(IconPlus4, null),
|
|
3289
1860
|
onClick: () => field.append({ operator: "assign" })
|
|
3290
1861
|
},
|
|
3291
1862
|
"Assign"
|
|
3292
|
-
), /* @__PURE__ */
|
|
3293
|
-
|
|
1863
|
+
), /* @__PURE__ */ React23.createElement(
|
|
1864
|
+
Button6,
|
|
3294
1865
|
{
|
|
3295
1866
|
size: "small",
|
|
3296
1867
|
theme: "borderless",
|
|
3297
|
-
icon: /* @__PURE__ */
|
|
1868
|
+
icon: /* @__PURE__ */ React23.createElement(IconPlus4, null),
|
|
3298
1869
|
onClick: () => field.append({ operator: "declare" })
|
|
3299
1870
|
},
|
|
3300
1871
|
"Declaration"
|
|
3301
1872
|
))));
|
|
3302
1873
|
}
|
|
3303
1874
|
|
|
1875
|
+
// src/components/inputs-values-tree/index.tsx
|
|
1876
|
+
import React26 from "react";
|
|
1877
|
+
import { I18n as I18n10 } from "@flowgram.ai/editor";
|
|
1878
|
+
import { Button as Button7 } from "@douyinfe/semi-ui";
|
|
1879
|
+
import { IconPlus as IconPlus5 } from "@douyinfe/semi-icons";
|
|
1880
|
+
|
|
1881
|
+
// src/components/inputs-values-tree/styles.tsx
|
|
1882
|
+
import React24 from "react";
|
|
1883
|
+
import styled11, { css as css3 } from "styled-components";
|
|
1884
|
+
import Icon4 from "@douyinfe/semi-icons";
|
|
1885
|
+
var UIContainer5 = styled11.div``;
|
|
1886
|
+
var UIRow4 = styled11.div`
|
|
1887
|
+
display: flex;
|
|
1888
|
+
align-items: flex-start;
|
|
1889
|
+
gap: 5px;
|
|
1890
|
+
`;
|
|
1891
|
+
var UICollapseTrigger2 = styled11.div`
|
|
1892
|
+
cursor: pointer;
|
|
1893
|
+
margin-right: 5px;
|
|
1894
|
+
`;
|
|
1895
|
+
var UITreeItems2 = styled11.div`
|
|
1896
|
+
display: grid;
|
|
1897
|
+
grid-template-columns: auto 1fr;
|
|
1898
|
+
|
|
1899
|
+
${({ $shrink }) => $shrink && css3`
|
|
1900
|
+
padding-left: 3px;
|
|
1901
|
+
margin-top: 10px;
|
|
1902
|
+
`}
|
|
1903
|
+
`;
|
|
1904
|
+
var UITreeItemLeft2 = styled11.div`
|
|
1905
|
+
grid-column: 1;
|
|
1906
|
+
position: relative;
|
|
1907
|
+
width: 16px;
|
|
1908
|
+
|
|
1909
|
+
${({ $showLine, $isLast, $showCollapse }) => {
|
|
1910
|
+
let height = $isLast ? "24px" : "100%";
|
|
1911
|
+
let width = $showCollapse ? "12px" : "30px";
|
|
1912
|
+
return $showLine && css3`
|
|
1913
|
+
&::before {
|
|
1914
|
+
/* 竖线 */
|
|
1915
|
+
content: '';
|
|
1916
|
+
height: ${height};
|
|
1917
|
+
position: absolute;
|
|
1918
|
+
left: -14px;
|
|
1919
|
+
top: -16px;
|
|
1920
|
+
width: 1px;
|
|
1921
|
+
background: #d9d9d9;
|
|
1922
|
+
display: block;
|
|
1923
|
+
}
|
|
1924
|
+
|
|
1925
|
+
&::after {
|
|
1926
|
+
/* 横线 */
|
|
1927
|
+
content: '';
|
|
1928
|
+
position: absolute;
|
|
1929
|
+
left: -14px; // 横线起点和竖线对齐
|
|
1930
|
+
top: 8px; // 跟随你的行高调整
|
|
1931
|
+
width: ${width}; // 横线长度
|
|
1932
|
+
height: 1px;
|
|
1933
|
+
background: #d9d9d9;
|
|
1934
|
+
display: block;
|
|
1935
|
+
}
|
|
1936
|
+
`;
|
|
1937
|
+
}}
|
|
1938
|
+
`;
|
|
1939
|
+
var UITreeItemRight2 = styled11.div`
|
|
1940
|
+
grid-column: 2;
|
|
1941
|
+
margin-bottom: 10px;
|
|
1942
|
+
|
|
1943
|
+
&:last-child {
|
|
1944
|
+
margin-bottom: 0px;
|
|
1945
|
+
}
|
|
1946
|
+
`;
|
|
1947
|
+
var UITreeItemMain2 = styled11.div`
|
|
1948
|
+
display: flex;
|
|
1949
|
+
flex-direction: column;
|
|
1950
|
+
gap: 10px;
|
|
1951
|
+
position: relative;
|
|
1952
|
+
`;
|
|
1953
|
+
var UICollapsible2 = styled11.div`
|
|
1954
|
+
display: none;
|
|
1955
|
+
|
|
1956
|
+
${({ $collapse }) => $collapse && css3`
|
|
1957
|
+
display: block;
|
|
1958
|
+
`}
|
|
1959
|
+
`;
|
|
1960
|
+
var UIActions2 = styled11.div`
|
|
1961
|
+
white-space: nowrap;
|
|
1962
|
+
`;
|
|
1963
|
+
var iconAddChildrenSvg2 = /* @__PURE__ */ React24.createElement(
|
|
1964
|
+
"svg",
|
|
1965
|
+
{
|
|
1966
|
+
className: "icon-icon icon-icon-coz_add_node ",
|
|
1967
|
+
width: "1em",
|
|
1968
|
+
height: "1em",
|
|
1969
|
+
viewBox: "0 0 24 24",
|
|
1970
|
+
fill: "currentColor",
|
|
1971
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
1972
|
+
},
|
|
1973
|
+
/* @__PURE__ */ React24.createElement(
|
|
1974
|
+
"path",
|
|
1975
|
+
{
|
|
1976
|
+
fillRule: "evenodd",
|
|
1977
|
+
clipRule: "evenodd",
|
|
1978
|
+
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"
|
|
1979
|
+
}
|
|
1980
|
+
),
|
|
1981
|
+
/* @__PURE__ */ React24.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" })
|
|
1982
|
+
);
|
|
1983
|
+
var IconAddChildren2 = () => /* @__PURE__ */ React24.createElement(Icon4, { size: "small", svg: iconAddChildrenSvg2 });
|
|
1984
|
+
|
|
1985
|
+
// src/components/inputs-values-tree/row.tsx
|
|
1986
|
+
import React25, { useMemo as useMemo14, useState as useState7 } from "react";
|
|
1987
|
+
import { I18n as I18n9 } from "@flowgram.ai/editor";
|
|
1988
|
+
import { IconButton as IconButton6, Input as Input7 } from "@douyinfe/semi-ui";
|
|
1989
|
+
import { IconChevronDown as IconChevronDown2, IconChevronRight as IconChevronRight2, IconDelete as IconDelete3 } from "@douyinfe/semi-icons";
|
|
1990
|
+
|
|
1991
|
+
// src/components/inputs-values-tree/hooks/use-child-list.tsx
|
|
1992
|
+
import { useMemo as useMemo13 } from "react";
|
|
1993
|
+
import { isPlainObject as isPlainObject2 } from "lodash-es";
|
|
1994
|
+
function useChildList(value, onChange) {
|
|
1995
|
+
const canAddField = useMemo13(() => {
|
|
1996
|
+
if (!isPlainObject2(value)) {
|
|
1997
|
+
return false;
|
|
1998
|
+
}
|
|
1999
|
+
if (FlowValueUtils.isFlowValue(value)) {
|
|
2000
|
+
return FlowValueUtils.isConstant(value) && value?.schema?.type === "object";
|
|
2001
|
+
}
|
|
2002
|
+
return true;
|
|
2003
|
+
}, [value]);
|
|
2004
|
+
const objectListValue = useMemo13(() => {
|
|
2005
|
+
if (isPlainObject2(value)) {
|
|
2006
|
+
if (FlowValueUtils.isFlowValue(value)) {
|
|
2007
|
+
return void 0;
|
|
2008
|
+
}
|
|
2009
|
+
return value;
|
|
2010
|
+
}
|
|
2011
|
+
return void 0;
|
|
2012
|
+
}, [value]);
|
|
2013
|
+
const { list, add, updateKey, updateValue, remove } = useObjectList({
|
|
2014
|
+
value: objectListValue,
|
|
2015
|
+
onChange: (value2) => {
|
|
2016
|
+
onChange?.(value2);
|
|
2017
|
+
},
|
|
2018
|
+
sortIndexKey: (value2) => FlowValueUtils.isFlowValue(value2) ? "extra.index" : ""
|
|
2019
|
+
});
|
|
2020
|
+
const hasChildren = useMemo13(
|
|
2021
|
+
() => canAddField && (list.length > 0 || Object.keys(objectListValue || {}).length > 0),
|
|
2022
|
+
[canAddField, list.length, Object.keys(objectListValue || {}).length]
|
|
2023
|
+
);
|
|
2024
|
+
return {
|
|
2025
|
+
canAddField,
|
|
2026
|
+
hasChildren,
|
|
2027
|
+
list,
|
|
2028
|
+
add,
|
|
2029
|
+
updateKey,
|
|
2030
|
+
updateValue,
|
|
2031
|
+
remove
|
|
2032
|
+
};
|
|
2033
|
+
}
|
|
2034
|
+
|
|
2035
|
+
// src/components/inputs-values-tree/row.tsx
|
|
2036
|
+
var AddObjectChildStrategy = {
|
|
2037
|
+
hit: (schema) => schema.type === "object",
|
|
2038
|
+
Renderer: () => /* @__PURE__ */ React25.createElement(
|
|
2039
|
+
Input7,
|
|
2040
|
+
{
|
|
2041
|
+
size: "small",
|
|
2042
|
+
disabled: true,
|
|
2043
|
+
style: { pointerEvents: "none" },
|
|
2044
|
+
value: I18n9.t("Configure via child fields")
|
|
2045
|
+
}
|
|
2046
|
+
)
|
|
2047
|
+
};
|
|
2048
|
+
function InputValueRow(props) {
|
|
2049
|
+
const {
|
|
2050
|
+
keyName,
|
|
2051
|
+
value,
|
|
2052
|
+
$level = 0,
|
|
2053
|
+
onUpdateKey,
|
|
2054
|
+
onUpdateValue,
|
|
2055
|
+
$isLast,
|
|
2056
|
+
onRemove,
|
|
2057
|
+
constantProps,
|
|
2058
|
+
hasError,
|
|
2059
|
+
readonly
|
|
2060
|
+
} = props;
|
|
2061
|
+
const [collapse, setCollapse] = useState7(false);
|
|
2062
|
+
const { canAddField, hasChildren, list, add, updateKey, updateValue, remove } = useChildList(
|
|
2063
|
+
value,
|
|
2064
|
+
onUpdateValue
|
|
2065
|
+
);
|
|
2066
|
+
const strategies = useMemo14(
|
|
2067
|
+
() => [...hasChildren ? [AddObjectChildStrategy] : [], ...constantProps?.strategies || []],
|
|
2068
|
+
[hasChildren, constantProps?.strategies]
|
|
2069
|
+
);
|
|
2070
|
+
const flowDisplayValue = useMemo14(
|
|
2071
|
+
() => hasChildren ? {
|
|
2072
|
+
type: "constant",
|
|
2073
|
+
schema: { type: "object" }
|
|
2074
|
+
} : value,
|
|
2075
|
+
[hasChildren, value]
|
|
2076
|
+
);
|
|
2077
|
+
return /* @__PURE__ */ React25.createElement(React25.Fragment, null, /* @__PURE__ */ React25.createElement(UITreeItemLeft2, { $isLast, $showLine: $level > 0, $showCollapse: hasChildren }, hasChildren && /* @__PURE__ */ React25.createElement(UICollapseTrigger2, { onClick: () => setCollapse((_collapse) => !_collapse) }, collapse ? /* @__PURE__ */ React25.createElement(IconChevronDown2, { size: "small" }) : /* @__PURE__ */ React25.createElement(IconChevronRight2, { size: "small" }))), /* @__PURE__ */ React25.createElement(UITreeItemRight2, null, /* @__PURE__ */ React25.createElement(UITreeItemMain2, null, /* @__PURE__ */ React25.createElement(UIRow4, null, /* @__PURE__ */ React25.createElement(
|
|
2078
|
+
BlurInput,
|
|
2079
|
+
{
|
|
2080
|
+
style: { width: 100, minWidth: 100, maxWidth: 100 },
|
|
2081
|
+
disabled: readonly,
|
|
2082
|
+
size: "small",
|
|
2083
|
+
value: keyName,
|
|
2084
|
+
onChange: (v) => onUpdateKey?.(v),
|
|
2085
|
+
placeholder: I18n9.t("Input Key")
|
|
2086
|
+
}
|
|
2087
|
+
), /* @__PURE__ */ React25.createElement(
|
|
2088
|
+
InjectDynamicValueInput,
|
|
2089
|
+
{
|
|
2090
|
+
style: { flexGrow: 1 },
|
|
2091
|
+
readonly,
|
|
2092
|
+
value: flowDisplayValue,
|
|
2093
|
+
onChange: (v) => onUpdateValue(v),
|
|
2094
|
+
hasError,
|
|
2095
|
+
constantProps: {
|
|
2096
|
+
...constantProps,
|
|
2097
|
+
strategies
|
|
2098
|
+
}
|
|
2099
|
+
}
|
|
2100
|
+
), /* @__PURE__ */ React25.createElement(UIActions2, null, canAddField && /* @__PURE__ */ React25.createElement(
|
|
2101
|
+
IconButton6,
|
|
2102
|
+
{
|
|
2103
|
+
disabled: readonly,
|
|
2104
|
+
size: "small",
|
|
2105
|
+
theme: "borderless",
|
|
2106
|
+
icon: /* @__PURE__ */ React25.createElement(IconAddChildren2, null),
|
|
2107
|
+
onClick: () => {
|
|
2108
|
+
add({
|
|
2109
|
+
type: "constant",
|
|
2110
|
+
content: "",
|
|
2111
|
+
schema: { type: "string" }
|
|
2112
|
+
});
|
|
2113
|
+
setCollapse(true);
|
|
2114
|
+
}
|
|
2115
|
+
}
|
|
2116
|
+
), /* @__PURE__ */ React25.createElement(
|
|
2117
|
+
IconButton6,
|
|
2118
|
+
{
|
|
2119
|
+
disabled: readonly,
|
|
2120
|
+
theme: "borderless",
|
|
2121
|
+
icon: /* @__PURE__ */ React25.createElement(IconDelete3, { size: "small" }),
|
|
2122
|
+
size: "small",
|
|
2123
|
+
onClick: () => onRemove?.()
|
|
2124
|
+
}
|
|
2125
|
+
)))), hasChildren && /* @__PURE__ */ React25.createElement(UICollapsible2, { $collapse: collapse }, /* @__PURE__ */ React25.createElement(UITreeItems2, { $shrink: true }, list.map((_item, index) => /* @__PURE__ */ React25.createElement(
|
|
2126
|
+
InputValueRow,
|
|
2127
|
+
{
|
|
2128
|
+
readonly,
|
|
2129
|
+
hasError,
|
|
2130
|
+
constantProps,
|
|
2131
|
+
key: _item.id,
|
|
2132
|
+
keyName: _item.key,
|
|
2133
|
+
value: _item.value,
|
|
2134
|
+
$level: $level + 1,
|
|
2135
|
+
onUpdateValue: (_v) => {
|
|
2136
|
+
updateValue(_item.id, _v);
|
|
2137
|
+
},
|
|
2138
|
+
onUpdateKey: (k) => {
|
|
2139
|
+
updateKey(_item.id, k);
|
|
2140
|
+
},
|
|
2141
|
+
onRemove: () => {
|
|
2142
|
+
remove(_item.id);
|
|
2143
|
+
},
|
|
2144
|
+
$isLast: index === list.length - 1
|
|
2145
|
+
}
|
|
2146
|
+
))))));
|
|
2147
|
+
}
|
|
2148
|
+
|
|
2149
|
+
// src/components/inputs-values-tree/index.tsx
|
|
2150
|
+
function InputsValuesTree(props) {
|
|
2151
|
+
const { value, onChange, readonly, hasError, constantProps } = props;
|
|
2152
|
+
const { list, updateKey, updateValue, remove, add } = useObjectList({
|
|
2153
|
+
value,
|
|
2154
|
+
onChange,
|
|
2155
|
+
sortIndexKey: (value2) => FlowValueUtils.isFlowValue(value2) ? "extra.index" : ""
|
|
2156
|
+
});
|
|
2157
|
+
return /* @__PURE__ */ React26.createElement("div", null, /* @__PURE__ */ React26.createElement(UITreeItems2, null, list.map((item) => /* @__PURE__ */ React26.createElement(
|
|
2158
|
+
InputValueRow,
|
|
2159
|
+
{
|
|
2160
|
+
key: item.id,
|
|
2161
|
+
keyName: item.key,
|
|
2162
|
+
value: item.value,
|
|
2163
|
+
onUpdateKey: (key) => updateKey(item.id, key),
|
|
2164
|
+
onUpdateValue: (value2) => updateValue(item.id, value2),
|
|
2165
|
+
onRemove: () => remove(item.id),
|
|
2166
|
+
readonly,
|
|
2167
|
+
hasError,
|
|
2168
|
+
constantProps
|
|
2169
|
+
}
|
|
2170
|
+
))), /* @__PURE__ */ React26.createElement(
|
|
2171
|
+
Button7,
|
|
2172
|
+
{
|
|
2173
|
+
style: { marginTop: 10, marginLeft: 16 },
|
|
2174
|
+
disabled: readonly,
|
|
2175
|
+
icon: /* @__PURE__ */ React26.createElement(IconPlus5, null),
|
|
2176
|
+
size: "small",
|
|
2177
|
+
onClick: () => {
|
|
2178
|
+
add({
|
|
2179
|
+
type: "constant",
|
|
2180
|
+
content: "",
|
|
2181
|
+
schema: { type: "string" }
|
|
2182
|
+
});
|
|
2183
|
+
}
|
|
2184
|
+
},
|
|
2185
|
+
I18n10.t("Add")
|
|
2186
|
+
));
|
|
2187
|
+
}
|
|
2188
|
+
|
|
3304
2189
|
// src/effects/provide-batch-input/index.ts
|
|
3305
2190
|
import {
|
|
3306
2191
|
ASTFactory,
|
|
@@ -3337,7 +2222,6 @@ var provideBatchInputEffect = createEffectFromVariableProvider({
|
|
|
3337
2222
|
});
|
|
3338
2223
|
|
|
3339
2224
|
// src/effects/auto-rename-ref/index.ts
|
|
3340
|
-
import { isArray, isObject as isObject3, uniq } from "lodash";
|
|
3341
2225
|
import {
|
|
3342
2226
|
DataEvent,
|
|
3343
2227
|
VariableFieldKeyRenameService
|
|
@@ -3364,7 +2248,7 @@ var autoRenameRefEffect = [
|
|
|
3364
2248
|
form.setValueIn(_drilldownName, _v);
|
|
3365
2249
|
}
|
|
3366
2250
|
} else if (_v.type === "template") {
|
|
3367
|
-
const templateKeyPaths = getTemplateKeyPaths(_v);
|
|
2251
|
+
const templateKeyPaths = FlowValueUtils.getTemplateKeyPaths(_v);
|
|
3368
2252
|
let hasMatch = false;
|
|
3369
2253
|
templateKeyPaths.forEach((_keyPath) => {
|
|
3370
2254
|
if (isKeyPathMatch(_keyPath, beforeKeyPath)) {
|
|
@@ -3394,44 +2278,17 @@ var autoRenameRefEffect = [
|
|
|
3394
2278
|
function isKeyPathMatch(keyPath = [], targetKeyPath) {
|
|
3395
2279
|
return targetKeyPath.every((_key, index) => _key === keyPath[index]);
|
|
3396
2280
|
}
|
|
3397
|
-
function getTemplateKeyPaths(value) {
|
|
3398
|
-
const keyPathReg = /{{(.*?)}}/g;
|
|
3399
|
-
return uniq(value.content?.match(keyPathReg) || []).map(
|
|
3400
|
-
(_keyPath) => _keyPath.slice(2, -2).split(".")
|
|
3401
|
-
);
|
|
3402
|
-
}
|
|
3403
|
-
function isRef(value) {
|
|
3404
|
-
return value?.type === "ref" && Array.isArray(value?.content) && typeof value?.content[0] === "string";
|
|
3405
|
-
}
|
|
3406
|
-
function isTemplate(value) {
|
|
3407
|
-
return value?.type === "template" && typeof value?.content === "string";
|
|
3408
|
-
}
|
|
3409
2281
|
function traverseRef(name, value, cb) {
|
|
3410
|
-
|
|
3411
|
-
|
|
3412
|
-
|
|
3413
|
-
|
|
3414
|
-
|
|
3415
|
-
if (isTemplate(value)) {
|
|
3416
|
-
cb(name, value);
|
|
3417
|
-
return;
|
|
3418
|
-
}
|
|
3419
|
-
Object.entries(value).forEach(([_key, _value]) => {
|
|
3420
|
-
traverseRef(`${name}.${_key}`, _value, cb);
|
|
3421
|
-
});
|
|
3422
|
-
return;
|
|
3423
|
-
}
|
|
3424
|
-
if (isArray(value)) {
|
|
3425
|
-
value.forEach((_value, idx) => {
|
|
3426
|
-
traverseRef(`${name}[${idx}]`, _value, cb);
|
|
3427
|
-
});
|
|
3428
|
-
return;
|
|
2282
|
+
for (const { value: _v, path } of FlowValueUtils.traverse(value, {
|
|
2283
|
+
includeTypes: ["ref", "template"],
|
|
2284
|
+
path: name
|
|
2285
|
+
})) {
|
|
2286
|
+
cb(path, _v);
|
|
3429
2287
|
}
|
|
3430
|
-
return;
|
|
3431
2288
|
}
|
|
3432
2289
|
|
|
3433
2290
|
// src/effects/provide-json-schema-outputs/index.ts
|
|
3434
|
-
import { JsonSchemaUtils as
|
|
2291
|
+
import { JsonSchemaUtils as JsonSchemaUtils6 } from "@flowgram.ai/json-schema";
|
|
3435
2292
|
import {
|
|
3436
2293
|
ASTFactory as ASTFactory2,
|
|
3437
2294
|
createEffectFromVariableProvider as createEffectFromVariableProvider2,
|
|
@@ -3445,7 +2302,7 @@ var provideJsonSchemaOutputs = createEffectFromVariableProvider2({
|
|
|
3445
2302
|
title: getNodeForm2(ctx.node)?.getValueIn("title") || ctx.node.id,
|
|
3446
2303
|
icon: ctx.node.getNodeRegistry().info?.icon
|
|
3447
2304
|
},
|
|
3448
|
-
type:
|
|
2305
|
+
type: JsonSchemaUtils6.schemaToAST(value)
|
|
3449
2306
|
})
|
|
3450
2307
|
]
|
|
3451
2308
|
});
|
|
@@ -3473,7 +2330,7 @@ var syncVariableTitle = [
|
|
|
3473
2330
|
];
|
|
3474
2331
|
|
|
3475
2332
|
// src/effects/validate-when-variable-sync/index.ts
|
|
3476
|
-
import { isEmpty } from "lodash";
|
|
2333
|
+
import { isEmpty } from "lodash-es";
|
|
3477
2334
|
import {
|
|
3478
2335
|
DataEvent as DataEvent3,
|
|
3479
2336
|
getNodeScope,
|
|
@@ -3523,7 +2380,7 @@ var listenRefValueChange = (cb) => [
|
|
|
3523
2380
|
];
|
|
3524
2381
|
|
|
3525
2382
|
// src/effects/listen-ref-schema-change/index.ts
|
|
3526
|
-
import { JsonSchemaUtils as
|
|
2383
|
+
import { JsonSchemaUtils as JsonSchemaUtils7 } from "@flowgram.ai/json-schema";
|
|
3527
2384
|
import {
|
|
3528
2385
|
DataEvent as DataEvent5,
|
|
3529
2386
|
getNodeScope as getNodeScope3
|
|
@@ -3539,7 +2396,7 @@ var listenRefSchemaChange = (cb) => [
|
|
|
3539
2396
|
const disposable = getNodeScope3(context.node).available.trackByKeyPath(
|
|
3540
2397
|
value?.content || [],
|
|
3541
2398
|
(_type) => {
|
|
3542
|
-
cb({ ...params, schema:
|
|
2399
|
+
cb({ ...params, schema: JsonSchemaUtils7.astToSchema(_type) });
|
|
3543
2400
|
},
|
|
3544
2401
|
{
|
|
3545
2402
|
selector: (_v) => _v?.type
|
|
@@ -3628,13 +2485,8 @@ var createBatchOutputsFormPlugin = defineFormPluginCreator({
|
|
|
3628
2485
|
});
|
|
3629
2486
|
|
|
3630
2487
|
// src/form-plugins/infer-inputs-plugin/index.ts
|
|
3631
|
-
import { get as get2, set as set2 } from "lodash";
|
|
3632
|
-
import {
|
|
3633
|
-
import {
|
|
3634
|
-
defineFormPluginCreator as defineFormPluginCreator2,
|
|
3635
|
-
getNodePrivateScope as getNodePrivateScope3,
|
|
3636
|
-
getNodeScope as getNodeScope5
|
|
3637
|
-
} from "@flowgram.ai/editor";
|
|
2488
|
+
import { get as get2, set as set2 } from "lodash-es";
|
|
2489
|
+
import { defineFormPluginCreator as defineFormPluginCreator2, getNodePrivateScope as getNodePrivateScope3, getNodeScope as getNodeScope5 } from "@flowgram.ai/editor";
|
|
3638
2490
|
var createInferInputsPlugin = defineFormPluginCreator2({
|
|
3639
2491
|
onSetupFormMeta({ addFormatOnSubmit }, { sourceKey, targetKey, scope }) {
|
|
3640
2492
|
if (!sourceKey || !targetKey) {
|
|
@@ -3644,7 +2496,7 @@ var createInferInputsPlugin = defineFormPluginCreator2({
|
|
|
3644
2496
|
set2(
|
|
3645
2497
|
formData,
|
|
3646
2498
|
targetKey,
|
|
3647
|
-
|
|
2499
|
+
FlowValueUtils.inferJsonSchema(
|
|
3648
2500
|
get2(formData, sourceKey),
|
|
3649
2501
|
scope === "private" ? getNodePrivateScope3(ctx.node) : getNodeScope5(ctx.node)
|
|
3650
2502
|
)
|
|
@@ -3653,63 +2505,10 @@ var createInferInputsPlugin = defineFormPluginCreator2({
|
|
|
3653
2505
|
});
|
|
3654
2506
|
}
|
|
3655
2507
|
});
|
|
3656
|
-
function isRef2(value) {
|
|
3657
|
-
return value?.type === "ref" && Array.isArray(value?.content) && typeof value?.content[0] === "string";
|
|
3658
|
-
}
|
|
3659
|
-
function isTemplate2(value) {
|
|
3660
|
-
return value?.type === "template" && typeof value?.content === "string";
|
|
3661
|
-
}
|
|
3662
|
-
function isConstant(value) {
|
|
3663
|
-
return value?.type === "constant" && typeof value?.content !== "undefined";
|
|
3664
|
-
}
|
|
3665
|
-
var infer = (values, scope) => {
|
|
3666
|
-
if (typeof values === "object") {
|
|
3667
|
-
if (isConstant(values)) {
|
|
3668
|
-
if (values?.schema) {
|
|
3669
|
-
return values.schema;
|
|
3670
|
-
}
|
|
3671
|
-
if (typeof values.content === "string") {
|
|
3672
|
-
return {
|
|
3673
|
-
type: "string"
|
|
3674
|
-
};
|
|
3675
|
-
}
|
|
3676
|
-
if (typeof values.content === "number") {
|
|
3677
|
-
return {
|
|
3678
|
-
type: "number"
|
|
3679
|
-
};
|
|
3680
|
-
}
|
|
3681
|
-
if (typeof values.content === "boolean") {
|
|
3682
|
-
return {
|
|
3683
|
-
type: "boolean"
|
|
3684
|
-
};
|
|
3685
|
-
}
|
|
3686
|
-
}
|
|
3687
|
-
if (isRef2(values)) {
|
|
3688
|
-
const variable = scope.available.getByKeyPath(values?.content);
|
|
3689
|
-
const schema = variable?.type ? JsonSchemaUtils9.astToSchema(variable?.type) : void 0;
|
|
3690
|
-
return schema;
|
|
3691
|
-
}
|
|
3692
|
-
if (isTemplate2(values)) {
|
|
3693
|
-
return {
|
|
3694
|
-
type: "string"
|
|
3695
|
-
};
|
|
3696
|
-
}
|
|
3697
|
-
return {
|
|
3698
|
-
type: "object",
|
|
3699
|
-
properties: Object.keys(values).reduce((acc, key) => {
|
|
3700
|
-
const schema = infer(values[key], scope);
|
|
3701
|
-
if (schema) {
|
|
3702
|
-
acc[key] = schema;
|
|
3703
|
-
}
|
|
3704
|
-
return acc;
|
|
3705
|
-
}, {})
|
|
3706
|
-
};
|
|
3707
|
-
}
|
|
3708
|
-
};
|
|
3709
2508
|
|
|
3710
2509
|
// src/form-plugins/infer-assign-plugin/index.ts
|
|
3711
|
-
import { set as set3, uniqBy } from "lodash";
|
|
3712
|
-
import { JsonSchemaUtils as
|
|
2510
|
+
import { set as set3, uniqBy } from "lodash-es";
|
|
2511
|
+
import { JsonSchemaUtils as JsonSchemaUtils8 } from "@flowgram.ai/json-schema";
|
|
3713
2512
|
import {
|
|
3714
2513
|
ASTFactory as ASTFactory4,
|
|
3715
2514
|
createEffectFromVariableProvider as createEffectFromVariableProvider4,
|
|
@@ -3740,7 +2539,7 @@ var createInferAssignPlugin = defineFormPluginCreator3({
|
|
|
3740
2539
|
properties: declareRows.map(
|
|
3741
2540
|
(_v) => ASTFactory4.createProperty({
|
|
3742
2541
|
key: _v.left,
|
|
3743
|
-
type: _v.right?.type === "constant" ?
|
|
2542
|
+
type: _v.right?.type === "constant" ? JsonSchemaUtils8.schemaToAST(_v.right?.schema || {}) : void 0,
|
|
3744
2543
|
initializer: _v.right?.type === "ref" ? ASTFactory4.createKeyPathExpression({
|
|
3745
2544
|
keyPath: _v.right?.content || []
|
|
3746
2545
|
}) : {}
|
|
@@ -3756,7 +2555,7 @@ var createInferAssignPlugin = defineFormPluginCreator3({
|
|
|
3756
2555
|
set3(
|
|
3757
2556
|
formData,
|
|
3758
2557
|
outputKey,
|
|
3759
|
-
|
|
2558
|
+
JsonSchemaUtils8.astToSchema(getNodeScope6(ctx.node).output.variables?.[0]?.type)
|
|
3760
2559
|
);
|
|
3761
2560
|
return formData;
|
|
3762
2561
|
});
|
|
@@ -3764,7 +2563,7 @@ var createInferAssignPlugin = defineFormPluginCreator3({
|
|
|
3764
2563
|
});
|
|
3765
2564
|
|
|
3766
2565
|
// src/validate/validate-flow-value/index.tsx
|
|
3767
|
-
import { isNil
|
|
2566
|
+
import { isNil } from "lodash-es";
|
|
3768
2567
|
import { FeedbackLevel, getNodeScope as getNodeScope7 } from "@flowgram.ai/editor";
|
|
3769
2568
|
function validateFlowValue(value, ctx) {
|
|
3770
2569
|
const { node, required, errorMessages } = ctx;
|
|
@@ -3788,7 +2587,7 @@ function validateFlowValue(value, ctx) {
|
|
|
3788
2587
|
}
|
|
3789
2588
|
}
|
|
3790
2589
|
if (value?.type === "template") {
|
|
3791
|
-
const allRefs =
|
|
2590
|
+
const allRefs = FlowValueUtils.getTemplateKeyPaths(value);
|
|
3792
2591
|
for (const ref of allRefs) {
|
|
3793
2592
|
const variable = getNodeScope7(node).available.getByKeyPath(ref);
|
|
3794
2593
|
if (!variable) {
|
|
@@ -3801,31 +2600,30 @@ function validateFlowValue(value, ctx) {
|
|
|
3801
2600
|
}
|
|
3802
2601
|
return void 0;
|
|
3803
2602
|
}
|
|
3804
|
-
function getTemplateKeyPaths2(value) {
|
|
3805
|
-
const keyPathReg = /{{(.*?)}}/g;
|
|
3806
|
-
return uniq2(value.content?.match(keyPathReg) || []).map(
|
|
3807
|
-
(_keyPath) => _keyPath.slice(2, -2).split(".")
|
|
3808
|
-
);
|
|
3809
|
-
}
|
|
3810
2603
|
export {
|
|
3811
2604
|
AssignRow,
|
|
3812
2605
|
AssignRows,
|
|
3813
2606
|
BatchOutputs,
|
|
3814
2607
|
BatchVariableSelector,
|
|
2608
|
+
BlurInput,
|
|
3815
2609
|
CodeEditor,
|
|
3816
2610
|
CodeEditorMini,
|
|
3817
2611
|
ConditionRow,
|
|
3818
2612
|
ConstantInput,
|
|
2613
|
+
DBConditionRow,
|
|
3819
2614
|
DisplayFlowValue,
|
|
2615
|
+
DisplayInputsValueAllInTag,
|
|
3820
2616
|
DisplayInputsValues,
|
|
3821
2617
|
DisplayOutputs,
|
|
3822
2618
|
DisplaySchemaTag,
|
|
3823
2619
|
DisplaySchemaTree,
|
|
3824
2620
|
DynamicValueInput,
|
|
2621
|
+
FlowValueUtils,
|
|
3825
2622
|
InjectDynamicValueInput,
|
|
3826
2623
|
InjectTypeSelector,
|
|
3827
2624
|
InjectVariableSelector,
|
|
3828
2625
|
InputsValues,
|
|
2626
|
+
InputsValuesTree,
|
|
3829
2627
|
JsonEditorWithVariables,
|
|
3830
2628
|
JsonSchemaEditor,
|
|
3831
2629
|
JsonSchemaTypePresetProvider,
|
|
@@ -3835,6 +2633,7 @@ export {
|
|
|
3835
2633
|
PromptEditorWithVariables,
|
|
3836
2634
|
TypeSelector,
|
|
3837
2635
|
VariableSelector,
|
|
2636
|
+
VariableSelectorProvider,
|
|
3838
2637
|
autoRenameRefEffect,
|
|
3839
2638
|
createBatchOutputsFormPlugin,
|
|
3840
2639
|
createDisableDeclarationPlugin,
|
|
@@ -3849,16 +2648,21 @@ export {
|
|
|
3849
2648
|
getTypeSelectValue,
|
|
3850
2649
|
isLegacyFlowRefValueSchema,
|
|
3851
2650
|
isNewFlowRefValueSchema,
|
|
2651
|
+
lazySuspense,
|
|
3852
2652
|
listenRefSchemaChange,
|
|
3853
2653
|
listenRefValueChange,
|
|
3854
2654
|
parseTypeSelectValue,
|
|
2655
|
+
polyfillCreateRoot,
|
|
3855
2656
|
provideBatchInputEffect,
|
|
3856
2657
|
provideBatchOutputsEffect,
|
|
3857
2658
|
provideJsonSchemaOutputs,
|
|
3858
2659
|
syncVariableTitle,
|
|
2660
|
+
unstableSetCreateRoot,
|
|
2661
|
+
useObjectList,
|
|
3859
2662
|
useTypeManager,
|
|
3860
2663
|
useVariableTree,
|
|
3861
2664
|
validateFlowValue,
|
|
3862
|
-
validateWhenVariableSync
|
|
2665
|
+
validateWhenVariableSync,
|
|
2666
|
+
withSuspense
|
|
3863
2667
|
};
|
|
3864
2668
|
//# sourceMappingURL=index.js.map
|