@flowgram.ai/form-materials 0.2.31 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/index.ts +11 -5
- package/bin/materials.ts +1 -1
- package/dist/esm/index.js +1256 -1363
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.mts +232 -202
- package/dist/index.d.ts +232 -202
- package/dist/index.js +1399 -1507
- package/dist/index.js.map +1 -1
- package/package.json +5 -4
- package/src/components/batch-variable-selector/config.json +6 -2
- package/src/components/batch-variable-selector/index.tsx +1 -1
- package/src/components/code-editor/theme/light.ts +1 -1
- package/src/components/code-editor-mini/config.json +7 -0
- package/src/components/code-editor-mini/index.tsx +31 -0
- package/src/components/condition-row/config.json +10 -2
- package/src/components/condition-row/hooks/useOp.tsx +3 -1
- package/src/components/condition-row/hooks/useRule.ts +2 -2
- package/src/components/condition-row/index.tsx +2 -1
- package/src/components/condition-row/types.ts +3 -1
- package/src/components/constant-input/config.json +6 -3
- package/src/components/constant-input/index.tsx +10 -71
- package/src/components/constant-input/types.ts +6 -10
- package/src/components/display-flow-value/config.json +8 -0
- package/src/components/display-flow-value/index.tsx +59 -0
- package/src/components/display-inputs-values/config.json +9 -0
- package/src/components/display-inputs-values/index.tsx +27 -0
- package/src/components/display-inputs-values/styles.ts +12 -0
- package/src/components/display-outputs/config.json +10 -0
- package/src/components/display-outputs/index.tsx +58 -0
- package/src/components/display-outputs/styles.ts +12 -0
- package/src/components/display-schema-tag/config.json +10 -0
- package/src/components/display-schema-tag/index.tsx +44 -0
- package/src/components/display-schema-tag/styles.ts +28 -0
- package/src/components/display-schema-tree/config.json +11 -0
- package/src/components/display-schema-tree/index.tsx +74 -0
- package/src/components/display-schema-tree/styles.tsx +90 -0
- package/src/components/dynamic-value-input/config.json +11 -2
- package/src/components/dynamic-value-input/hooks.ts +53 -0
- package/src/components/dynamic-value-input/index.tsx +30 -28
- package/src/components/index.ts +6 -0
- package/src/components/inputs-values/config.json +2 -1
- package/src/components/inputs-values/types.ts +3 -1
- package/src/components/json-schema-editor/config.json +3 -3
- package/src/components/json-schema-editor/default-value.tsx +1 -1
- package/src/components/json-schema-editor/hooks.tsx +1 -1
- package/src/components/json-schema-editor/index.tsx +1 -1
- package/src/components/json-schema-editor/types.ts +1 -1
- package/src/components/type-selector/config.json +6 -2
- package/src/components/type-selector/index.tsx +47 -11
- package/src/components/variable-selector/config.json +6 -2
- package/src/components/variable-selector/index.tsx +1 -1
- package/src/components/variable-selector/use-variable-tree.tsx +14 -20
- package/src/effects/provide-json-schema-outputs/config.json +4 -5
- package/src/effects/provide-json-schema-outputs/index.ts +1 -3
- package/src/effects/sync-variable-title/index.ts +1 -0
- package/src/form-plugins/infer-inputs-plugin/config.json +3 -1
- package/src/form-plugins/infer-inputs-plugin/index.ts +2 -2
- package/src/index.ts +1 -1
- package/src/{utils → shared}/index.ts +1 -1
- package/src/shared/json-schema-preset/config.json +9 -0
- package/src/shared/json-schema-preset/create-type-preset-plugin.tsx +26 -0
- package/src/shared/json-schema-preset/index.tsx +39 -0
- package/src/shared/json-schema-preset/manager.ts +18 -0
- package/src/shared/json-schema-preset/type-definition/array.tsx +23 -0
- package/src/shared/json-schema-preset/type-definition/boolean.tsx +32 -0
- package/src/shared/json-schema-preset/type-definition/index.tsx +24 -0
- package/src/shared/json-schema-preset/type-definition/integer.tsx +24 -0
- package/src/shared/json-schema-preset/type-definition/number.tsx +24 -0
- package/src/shared/json-schema-preset/type-definition/object.tsx +23 -0
- package/src/shared/json-schema-preset/type-definition/string.tsx +18 -0
- package/src/typings/flow-value/config.json +4 -4
- package/src/typings/flow-value/index.ts +1 -1
- package/src/typings/index.ts +0 -1
- package/src/components/type-selector/constants.tsx +0 -364
- package/src/typings/json-schema/config.json +0 -5
- package/src/typings/json-schema/index.ts +0 -36
- package/src/utils/json-schema/config.json +0 -5
- package/src/utils/json-schema/index.ts +0 -180
- /package/src/{utils → shared}/format-legacy-refs/config.json +0 -0
- /package/src/{utils → shared}/format-legacy-refs/index.ts +0 -0
- /package/src/{utils → shared}/format-legacy-refs/readme.md +0 -0
package/dist/index.js
CHANGED
|
@@ -30,31 +30,36 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/index.ts
|
|
31
31
|
var src_exports = {};
|
|
32
32
|
__export(src_exports, {
|
|
33
|
-
ArrayIcons: () => ArrayIcons,
|
|
34
33
|
BatchOutputs: () => BatchOutputs,
|
|
35
34
|
BatchVariableSelector: () => BatchVariableSelector,
|
|
36
35
|
CodeEditor: () => CodeEditor,
|
|
36
|
+
CodeEditorMini: () => CodeEditorMini,
|
|
37
37
|
ConditionRow: () => ConditionRow,
|
|
38
38
|
ConstantInput: () => ConstantInput,
|
|
39
|
+
DisplayFlowValue: () => DisplayFlowValue,
|
|
40
|
+
DisplayInputsValues: () => DisplayInputsValues,
|
|
41
|
+
DisplayOutputs: () => DisplayOutputs,
|
|
42
|
+
DisplaySchemaTag: () => DisplaySchemaTag,
|
|
43
|
+
DisplaySchemaTree: () => DisplaySchemaTree,
|
|
39
44
|
DynamicValueInput: () => DynamicValueInput,
|
|
40
45
|
InputsValues: () => InputsValues,
|
|
41
46
|
JsonEditorWithVariables: () => JsonEditorWithVariables,
|
|
42
47
|
JsonSchemaEditor: () => JsonSchemaEditor,
|
|
43
|
-
|
|
48
|
+
JsonSchemaTypePresetProvider: () => JsonSchemaTypePresetProvider,
|
|
49
|
+
JsonSchemaUtils: () => import_json_schema3.JsonSchemaUtils,
|
|
44
50
|
PromptEditor: () => PromptEditor,
|
|
45
51
|
PromptEditorWithInputs: () => PromptEditorWithInputs,
|
|
46
52
|
PromptEditorWithVariables: () => PromptEditorWithVariables,
|
|
47
53
|
TypeSelector: () => TypeSelector,
|
|
48
54
|
VariableSelector: () => VariableSelector,
|
|
49
|
-
VariableTypeIcons: () => VariableTypeIcons,
|
|
50
55
|
autoRenameRefEffect: () => autoRenameRefEffect,
|
|
51
56
|
createBatchOutputsFormPlugin: () => createBatchOutputsFormPlugin,
|
|
52
57
|
createInferInputsPlugin: () => createInferInputsPlugin,
|
|
58
|
+
createTypePresetPlugin: () => createTypePresetPlugin,
|
|
53
59
|
formatLegacyRefOnInit: () => formatLegacyRefOnInit,
|
|
54
60
|
formatLegacyRefOnSubmit: () => formatLegacyRefOnSubmit,
|
|
55
61
|
formatLegacyRefToNewRef: () => formatLegacyRefToNewRef,
|
|
56
62
|
formatNewRefToLegacyRef: () => formatNewRefToLegacyRef,
|
|
57
|
-
getSchemaIcon: () => getSchemaIcon,
|
|
58
63
|
getTypeSelectValue: () => getTypeSelectValue,
|
|
59
64
|
isLegacyFlowRefValueSchema: () => isLegacyFlowRefValueSchema,
|
|
60
65
|
isNewFlowRefValueSchema: () => isNewFlowRefValueSchema,
|
|
@@ -63,6 +68,7 @@ __export(src_exports, {
|
|
|
63
68
|
provideBatchOutputsEffect: () => provideBatchOutputsEffect,
|
|
64
69
|
provideJsonSchemaOutputs: () => provideJsonSchemaOutputs,
|
|
65
70
|
syncVariableTitle: () => syncVariableTitle,
|
|
71
|
+
useTypeManager: () => useTypeManager,
|
|
66
72
|
useVariableTree: () => useVariableTree
|
|
67
73
|
});
|
|
68
74
|
module.exports = __toCommonJS(src_exports);
|
|
@@ -72,554 +78,595 @@ var getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${_
|
|
|
72
78
|
var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
|
|
73
79
|
|
|
74
80
|
// src/components/variable-selector/index.tsx
|
|
75
|
-
var
|
|
76
|
-
var
|
|
77
|
-
var
|
|
81
|
+
var import_react12 = __toESM(require("react"));
|
|
82
|
+
var import_semi_ui7 = require("@douyinfe/semi-ui");
|
|
83
|
+
var import_semi_icons = require("@douyinfe/semi-icons");
|
|
78
84
|
|
|
79
85
|
// src/components/variable-selector/use-variable-tree.tsx
|
|
80
|
-
var
|
|
81
|
-
var
|
|
82
|
-
var
|
|
86
|
+
var import_react11 = __toESM(require("react"));
|
|
87
|
+
var import_json_schema4 = require("@flowgram.ai/json-schema");
|
|
88
|
+
var import_editor3 = require("@flowgram.ai/editor");
|
|
89
|
+
var import_semi_ui5 = require("@douyinfe/semi-ui");
|
|
90
|
+
|
|
91
|
+
// src/shared/format-legacy-refs/index.ts
|
|
92
|
+
var import_lodash = require("lodash");
|
|
93
|
+
function formatLegacyRefOnSubmit(value) {
|
|
94
|
+
if ((0, import_lodash.isObject)(value)) {
|
|
95
|
+
if (isLegacyFlowRefValueSchema(value)) {
|
|
96
|
+
return formatLegacyRefToNewRef(value);
|
|
97
|
+
}
|
|
98
|
+
return Object.fromEntries(
|
|
99
|
+
Object.entries(value).map(([key, value2]) => [
|
|
100
|
+
key,
|
|
101
|
+
formatLegacyRefOnSubmit(value2)
|
|
102
|
+
])
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
if (Array.isArray(value)) {
|
|
106
|
+
return value.map(formatLegacyRefOnSubmit);
|
|
107
|
+
}
|
|
108
|
+
return value;
|
|
109
|
+
}
|
|
110
|
+
function formatLegacyRefOnInit(value) {
|
|
111
|
+
if ((0, import_lodash.isObject)(value)) {
|
|
112
|
+
if (isNewFlowRefValueSchema(value)) {
|
|
113
|
+
return formatNewRefToLegacyRef(value);
|
|
114
|
+
}
|
|
115
|
+
return Object.fromEntries(
|
|
116
|
+
Object.entries(value).map(([key, value2]) => [
|
|
117
|
+
key,
|
|
118
|
+
formatLegacyRefOnInit(value2)
|
|
119
|
+
])
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
if (Array.isArray(value)) {
|
|
123
|
+
return value.map(formatLegacyRefOnInit);
|
|
124
|
+
}
|
|
125
|
+
return value;
|
|
126
|
+
}
|
|
127
|
+
function isLegacyFlowRefValueSchema(value) {
|
|
128
|
+
return (0, import_lodash.isObject)(value) && Object.keys(value).length === 2 && value.type === "ref" && typeof value.content === "string";
|
|
129
|
+
}
|
|
130
|
+
function isNewFlowRefValueSchema(value) {
|
|
131
|
+
return (0, import_lodash.isObject)(value) && Object.keys(value).length === 2 && value.type === "ref" && Array.isArray(value.content);
|
|
132
|
+
}
|
|
133
|
+
function formatLegacyRefToNewRef(value) {
|
|
134
|
+
const keyPath = value.content.split(".");
|
|
135
|
+
if (keyPath[1] === "outputs") {
|
|
136
|
+
return {
|
|
137
|
+
type: "ref",
|
|
138
|
+
content: [`${keyPath[0]}.${keyPath[1]}`, ...keyPath.length > 2 ? keyPath.slice(2) : []]
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
return {
|
|
142
|
+
type: "ref",
|
|
143
|
+
content: keyPath
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
function formatNewRefToLegacyRef(value) {
|
|
147
|
+
return {
|
|
148
|
+
type: "ref",
|
|
149
|
+
content: value.content.join(".")
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// src/shared/json-schema-preset/index.tsx
|
|
154
|
+
var import_react10 = __toESM(require("react"));
|
|
155
|
+
var import_json_schema3 = require("@flowgram.ai/json-schema");
|
|
83
156
|
|
|
84
|
-
// src/
|
|
157
|
+
// src/shared/json-schema-preset/type-definition/index.tsx
|
|
158
|
+
var import_json_schema = require("@flowgram.ai/json-schema");
|
|
159
|
+
|
|
160
|
+
// src/shared/json-schema-preset/type-definition/string.tsx
|
|
85
161
|
var import_react = __toESM(require("react"));
|
|
86
|
-
var
|
|
87
|
-
var
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
162
|
+
var import_semi_ui = require("@douyinfe/semi-ui");
|
|
163
|
+
var stringRegistry = {
|
|
164
|
+
type: "string",
|
|
165
|
+
ConstantRenderer: (props) => /* @__PURE__ */ import_react.default.createElement(import_semi_ui.Input, { placeholder: "Please Input String", size: "small", disabled: props.readonly, ...props })
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
// src/shared/json-schema-preset/type-definition/object.tsx
|
|
169
|
+
var import_react5 = __toESM(require("react"));
|
|
170
|
+
|
|
171
|
+
// src/components/code-editor-mini/index.tsx
|
|
172
|
+
var import_react4 = __toESM(require("react"));
|
|
173
|
+
var import_styled_components = __toESM(require("styled-components"));
|
|
174
|
+
|
|
175
|
+
// src/components/code-editor/index.tsx
|
|
176
|
+
var import_react2 = __toESM(require("react"));
|
|
177
|
+
var import_react3 = require("@coze-editor/editor/react");
|
|
178
|
+
var import_preset_code5 = __toESM(require("@coze-editor/editor/preset-code"));
|
|
179
|
+
var import_view = require("@codemirror/view");
|
|
180
|
+
|
|
181
|
+
// src/components/code-editor/utils.ts
|
|
182
|
+
function getSuffixByLanguageId(languageId) {
|
|
183
|
+
if (languageId === "python") {
|
|
184
|
+
return ".py";
|
|
185
|
+
}
|
|
186
|
+
if (languageId === "typescript") {
|
|
187
|
+
return ".ts";
|
|
188
|
+
}
|
|
189
|
+
if (languageId === "shell") {
|
|
190
|
+
return ".sh";
|
|
191
|
+
}
|
|
192
|
+
if (languageId === "json") {
|
|
193
|
+
return ".json";
|
|
194
|
+
}
|
|
195
|
+
return "";
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
// src/components/code-editor/language-features.ts
|
|
199
|
+
var import_preset_code = require("@coze-editor/editor/preset-code");
|
|
200
|
+
var import_language_typescript = require("@coze-editor/editor/language-typescript");
|
|
201
|
+
var import_language_shell = require("@coze-editor/editor/language-shell");
|
|
202
|
+
var import_language_python = require("@coze-editor/editor/language-python");
|
|
203
|
+
var import_language_json = require("@coze-editor/editor/language-json");
|
|
204
|
+
var import_editor = require("@coze-editor/editor");
|
|
205
|
+
import_preset_code.languages.register("python", import_language_python.python);
|
|
206
|
+
import_preset_code.languages.register("shell", import_language_shell.shell);
|
|
207
|
+
import_preset_code.languages.register("typescript", import_language_typescript.typescript);
|
|
208
|
+
import_preset_code.languages.register("json", {
|
|
209
|
+
// mixLanguages is used to solve the problem that interpolation also uses parentheses, which causes incorrect highlighting
|
|
210
|
+
language: (0, import_editor.mixLanguages)({
|
|
211
|
+
outerLanguage: import_language_json.json.language
|
|
212
|
+
}),
|
|
213
|
+
languageService: import_language_json.json.languageService
|
|
214
|
+
});
|
|
215
|
+
var tsWorkerInit = false;
|
|
216
|
+
var initTsWorker = () => {
|
|
217
|
+
if (tsWorkerInit) {
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
tsWorkerInit = true;
|
|
221
|
+
const tsWorker = new Worker(
|
|
222
|
+
new URL(`@coze-editor/editor/language-typescript/worker`, importMetaUrl),
|
|
223
|
+
{ type: "module" }
|
|
224
|
+
);
|
|
225
|
+
import_language_typescript.typescript.languageService.initialize(tsWorker, {
|
|
226
|
+
compilerOptions: {
|
|
227
|
+
// eliminate Promise error
|
|
228
|
+
lib: ["es2015", "dom"],
|
|
229
|
+
noImplicitAny: false
|
|
230
|
+
}
|
|
231
|
+
});
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
// src/components/code-editor/theme/index.ts
|
|
235
|
+
var import_preset_code4 = require("@coze-editor/editor/preset-code");
|
|
236
|
+
|
|
237
|
+
// src/components/code-editor/theme/light.ts
|
|
238
|
+
var import_preset_code2 = require("@coze-editor/editor/preset-code");
|
|
239
|
+
var colors = {
|
|
240
|
+
background: "#F7F7FC",
|
|
241
|
+
// syntax
|
|
242
|
+
comment: "#000A298A",
|
|
243
|
+
key: "#00818C",
|
|
244
|
+
string: "#D1009D",
|
|
245
|
+
number: "#C74200",
|
|
246
|
+
boolean: "#2B57D9",
|
|
247
|
+
null: "#2B57D9",
|
|
248
|
+
separator: "#0F1529D1"
|
|
249
|
+
};
|
|
250
|
+
var lightTheme = (0, import_preset_code2.createTheme)({
|
|
251
|
+
variant: "light",
|
|
252
|
+
settings: {
|
|
253
|
+
background: "#fff",
|
|
254
|
+
foreground: "#000",
|
|
255
|
+
caret: "#000",
|
|
256
|
+
selection: "#d9d9d9",
|
|
257
|
+
gutterBackground: "#f0f0f0",
|
|
258
|
+
gutterForeground: "#666",
|
|
259
|
+
gutterBorderColor: "transparent",
|
|
260
|
+
gutterBorderWidth: 0,
|
|
261
|
+
lineHighlight: "#e1e1e180",
|
|
262
|
+
bracketColors: ["#FFD700", "#DD99FF", "#78B0FF"],
|
|
263
|
+
tooltip: {
|
|
264
|
+
backgroundColor: "#f0f0f0",
|
|
265
|
+
color: "#000",
|
|
266
|
+
border: "1px solid #ccc"
|
|
98
267
|
},
|
|
99
|
-
|
|
100
|
-
"
|
|
101
|
-
{
|
|
102
|
-
fillRule: "evenodd",
|
|
103
|
-
clipRule: "evenodd",
|
|
104
|
-
d: "M5.1 18L4.5032 20.1702C4.24999 21.0909 4.94281 22 5.89773 22C6.54881 22 7.11964 21.565 7.29227 20.9372L8.1 18H12.1L11.5032 20.1702C11.25 21.0909 11.9428 22 12.8977 22C13.5488 22 14.1196 21.565 14.2923 20.9372L15.1 18H19.5C20.3284 18 21 17.3284 21 16.5C21 15.6716 20.3284 15 19.5 15H15.925L17.575 9H20.5C21.3284 9 22 8.32843 22 7.5C22 6.67157 21.3284 6 20.5 6H18.4L18.9968 3.8298C19.25 2.90906 18.5572 2 17.6023 2C16.9512 2 16.3804 2.43504 16.2077 3.06281L15.4 6H11.4L11.9968 3.8298C12.25 2.90906 11.5572 2 10.6023 2C9.95119 2 9.38036 2.43504 9.20773 3.06281L8.4 6H4.5C3.67157 6 3 6.67157 3 7.5C3 8.32843 3.67157 9 4.5 9H7.575L5.925 15H3.5C2.67157 15 2 15.6716 2 16.5C2 17.3284 2.67157 18 3.5 18H5.1ZM8.925 15L10.575 9H14.575L12.925 15H8.925Z",
|
|
105
|
-
fill: "currentColor"
|
|
106
|
-
}
|
|
107
|
-
)
|
|
108
|
-
),
|
|
109
|
-
object: /* @__PURE__ */ import_react.default.createElement(
|
|
110
|
-
"svg",
|
|
111
|
-
{
|
|
112
|
-
width: "1em",
|
|
113
|
-
height: "1em",
|
|
114
|
-
viewBox: "0 0 16 16",
|
|
115
|
-
fill: "none",
|
|
116
|
-
xmlns: "http://www.w3.org/2000/svg"
|
|
268
|
+
link: {
|
|
269
|
+
color: "#007bff"
|
|
117
270
|
},
|
|
118
|
-
|
|
119
|
-
"
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
271
|
+
completionItemHover: {
|
|
272
|
+
backgroundColor: "#f0f0f0"
|
|
273
|
+
},
|
|
274
|
+
completionItemSelected: {
|
|
275
|
+
backgroundColor: "#e0e0e0"
|
|
276
|
+
},
|
|
277
|
+
completionItemIcon: {
|
|
278
|
+
color: "#333"
|
|
279
|
+
},
|
|
280
|
+
completionItemLabel: {
|
|
281
|
+
color: "#333"
|
|
282
|
+
},
|
|
283
|
+
completionItemInfo: {
|
|
284
|
+
color: "#333"
|
|
285
|
+
},
|
|
286
|
+
completionItemDetail: {
|
|
287
|
+
color: "#666"
|
|
288
|
+
}
|
|
289
|
+
},
|
|
290
|
+
styles: [
|
|
291
|
+
// JSON
|
|
135
292
|
{
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
viewBox: "0 0 16 16",
|
|
139
|
-
fill: "none",
|
|
140
|
-
xmlns: "http://www.w3.org/2000/svg"
|
|
293
|
+
tag: import_preset_code2.tags.comment,
|
|
294
|
+
color: colors.comment
|
|
141
295
|
},
|
|
142
|
-
/* @__PURE__ */ import_react.default.createElement(
|
|
143
|
-
"path",
|
|
144
|
-
{
|
|
145
|
-
fillRule: "evenodd",
|
|
146
|
-
clipRule: "evenodd",
|
|
147
|
-
d: "M10.668 4.66683H5.33463C3.49369 4.66683 2.0013 6.15921 2.0013 8.00016C2.0013 9.84111 3.49369 11.3335 5.33463 11.3335H10.668C12.5089 11.3335 14.0013 9.84111 14.0013 8.00016C14.0013 6.15921 12.5089 4.66683 10.668 4.66683ZM5.33463 3.3335C2.75731 3.3335 0.667969 5.42283 0.667969 8.00016C0.667969 10.5775 2.75731 12.6668 5.33463 12.6668H10.668C13.2453 12.6668 15.3346 10.5775 15.3346 8.00016C15.3346 5.42283 13.2453 3.3335 10.668 3.3335H5.33463Z",
|
|
148
|
-
fill: "currentColor"
|
|
149
|
-
}
|
|
150
|
-
),
|
|
151
|
-
/* @__PURE__ */ import_react.default.createElement(
|
|
152
|
-
"path",
|
|
153
|
-
{
|
|
154
|
-
fillRule: "evenodd",
|
|
155
|
-
clipRule: "evenodd",
|
|
156
|
-
d: "M8.66797 8.00016C8.66797 6.89559 9.5634 6.00016 10.668 6.00016C11.7725 6.00016 12.668 6.89559 12.668 8.00016C12.668 9.10473 11.7725 10.0002 10.668 10.0002C9.5634 10.0002 8.66797 9.10473 8.66797 8.00016ZM10.668 7.3335C10.2998 7.3335 10.0013 7.63197 10.0013 8.00016C10.0013 8.36835 10.2998 8.66683 10.668 8.66683C11.0362 8.66683 11.3346 8.36835 11.3346 8.00016C11.3346 7.63197 11.0362 7.3335 10.668 7.3335Z",
|
|
157
|
-
fill: "currentColor"
|
|
158
|
-
}
|
|
159
|
-
)
|
|
160
|
-
),
|
|
161
|
-
string: /* @__PURE__ */ import_react.default.createElement(
|
|
162
|
-
"svg",
|
|
163
296
|
{
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
viewBox: "0 0 16 16",
|
|
167
|
-
fill: "none",
|
|
168
|
-
xmlns: "http://www.w3.org/2000/svg"
|
|
297
|
+
tag: [import_preset_code2.tags.propertyName],
|
|
298
|
+
color: colors.key
|
|
169
299
|
},
|
|
170
|
-
/* @__PURE__ */ import_react.default.createElement(
|
|
171
|
-
"path",
|
|
172
|
-
{
|
|
173
|
-
d: "M9.3342 3.33321C8.96601 3.33321 8.66753 3.63169 8.66753 3.99988C8.66753 4.36807 8.96601 4.66655 9.3342 4.66655H14.6675C15.0357 4.66655 15.3342 4.36807 15.3342 3.99988C15.3342 3.63169 15.0357 3.33321 14.6675 3.33321H9.3342Z",
|
|
174
|
-
fill: "currentColor"
|
|
175
|
-
}
|
|
176
|
-
),
|
|
177
|
-
/* @__PURE__ */ import_react.default.createElement(
|
|
178
|
-
"path",
|
|
179
|
-
{
|
|
180
|
-
d: "M10.0009 7.99988C10.0009 7.63169 10.2993 7.33321 10.6675 7.33321H14.6675C15.0357 7.33321 15.3342 7.63169 15.3342 7.99988C15.3342 8.36807 15.0357 8.66655 14.6675 8.66655H10.6675C10.2993 8.66655 10.0009 8.36807 10.0009 7.99988Z",
|
|
181
|
-
fill: "currentColor"
|
|
182
|
-
}
|
|
183
|
-
),
|
|
184
|
-
/* @__PURE__ */ import_react.default.createElement(
|
|
185
|
-
"path",
|
|
186
|
-
{
|
|
187
|
-
d: "M12.0009 11.3332C11.6327 11.3332 11.3342 11.6317 11.3342 11.9999C11.3342 12.3681 11.6327 12.6665 12.0009 12.6665H14.6675C15.0357 12.6665 15.3342 12.3681 15.3342 11.9999C15.3342 11.6317 15.0357 11.3332 14.6675 11.3332H12.0009Z",
|
|
188
|
-
fill: "currentColor"
|
|
189
|
-
}
|
|
190
|
-
),
|
|
191
|
-
/* @__PURE__ */ import_react.default.createElement(
|
|
192
|
-
"path",
|
|
193
|
-
{
|
|
194
|
-
d: "M9.86659 14.1482L8.23444 10.1844H3.18136C3.13868 10.1844 3.09685 10.1808 3.05616 10.1738L1.66589 14.1129C1.53049 14.4965 1.10971 14.6978 0.726058 14.5624C0.342408 14.427 0.141166 14.0062 0.276572 13.6225L4.37566 2.00848C4.71323 1.05202 6.05321 1.01763 6.4394 1.95552L11.2289 13.5872C11.3838 13.9634 11.2044 14.394 10.8282 14.5489C10.452 14.7038 10.0215 14.5244 9.86659 14.1482ZM5.44412 3.40791L3.57241 8.71109H7.62778L5.44412 3.40791Z",
|
|
195
|
-
fill: "currentColor"
|
|
196
|
-
}
|
|
197
|
-
)
|
|
198
|
-
),
|
|
199
|
-
integer: /* @__PURE__ */ import_react.default.createElement(
|
|
200
|
-
"svg",
|
|
201
300
|
{
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
viewBox: "0 0 16 16",
|
|
205
|
-
fill: "none",
|
|
206
|
-
xmlns: "http://www.w3.org/2000/svg"
|
|
301
|
+
tag: [import_preset_code2.tags.string],
|
|
302
|
+
color: colors.string
|
|
207
303
|
},
|
|
208
|
-
/* @__PURE__ */ import_react.default.createElement(
|
|
209
|
-
"path",
|
|
210
|
-
{
|
|
211
|
-
d: "M15.132 11.4601C15.644 11.0121 15.9 10.3921 15.9 9.60007C15.9 8.60807 15.5 7.93607 14.7 7.58407C15.412 7.23207 15.768 6.62407 15.768 5.76007C15.768 5.05607 15.536 4.48007 15.072 4.03207C14.608 3.59207 14.012 3.37207 13.284 3.37207C12.588 3.37207 12.008 3.58007 11.544 3.99607C11.064 4.42007 10.808 4.98807 10.776 5.70007H12C12.064 4.88407 12.492 4.47607 13.284 4.47607C14.124 4.47607 14.544 4.91607 14.544 5.79607C14.544 6.66007 14.112 7.09207 13.248 7.09207H13.044V8.16007H13.248C14.2 8.16007 14.676 8.62807 14.676 9.56407C14.676 10.5081 14.212 10.9801 13.284 10.9801C12.9 10.9801 12.584 10.8761 12.336 10.6681C12.064 10.4441 11.916 10.1161 11.892 9.68407H10.668C10.692 10.4761 10.964 11.0841 11.484 11.5081C11.948 11.8921 12.548 12.0841 13.284 12.0841C14.036 12.0841 14.652 11.8761 15.132 11.4601Z",
|
|
212
|
-
fill: "currentColor"
|
|
213
|
-
}
|
|
214
|
-
),
|
|
215
|
-
/* @__PURE__ */ import_react.default.createElement(
|
|
216
|
-
"path",
|
|
217
|
-
{
|
|
218
|
-
d: "M4.46875 12.0003V10.9083L7.75675 6.91228C8.06075 6.54428 8.21275 6.16428 8.21275 5.77228C8.21275 4.90828 7.79675 4.47628 6.96475 4.47628C6.60475 4.47628 6.31275 4.57628 6.08875 4.77628C5.83275 5.00828 5.70475 5.34828 5.70475 5.79628H4.48075C4.48075 5.07628 4.71275 4.49228 5.17675 4.04428C5.64075 3.60428 6.23675 3.38428 6.96475 3.38428C7.70075 3.38428 8.29675 3.60028 8.75275 4.03228C9.20875 4.47228 9.43675 5.05628 9.43675 5.78428C9.43675 6.13628 9.36875 6.45628 9.23275 6.74428C9.12075 6.97628 8.92075 7.27228 8.63275 7.63228L5.95675 10.9083H9.43675V12.0003H4.46875Z",
|
|
219
|
-
fill: "currentColor"
|
|
220
|
-
}
|
|
221
|
-
),
|
|
222
|
-
/* @__PURE__ */ import_react.default.createElement(
|
|
223
|
-
"path",
|
|
224
|
-
{
|
|
225
|
-
d: "M1.668 12.0001V4.78805L0 6.25205V4.89605L1.668 3.45605H2.892V12.0001H1.668Z",
|
|
226
|
-
fill: "currentColor"
|
|
227
|
-
}
|
|
228
|
-
)
|
|
229
|
-
),
|
|
230
|
-
number: /* @__PURE__ */ import_react.default.createElement(
|
|
231
|
-
"svg",
|
|
232
304
|
{
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
viewBox: "0 0 16 16",
|
|
236
|
-
fill: "none",
|
|
237
|
-
xmlns: "http://www.w3.org/2000/svg"
|
|
305
|
+
tag: [import_preset_code2.tags.number],
|
|
306
|
+
color: colors.number
|
|
238
307
|
},
|
|
239
|
-
/* @__PURE__ */ import_react.default.createElement(
|
|
240
|
-
"path",
|
|
241
|
-
{
|
|
242
|
-
d: "M3.44151 5.3068C3.44151 3.83404 4.71542 2.64014 6.18818 2.64014C7.66094 2.64014 8.93484 3.83404 8.93484 5.3068V10.6135C8.93484 12.0862 7.66094 13.2801 6.18818 13.2801C4.71542 13.2801 3.44151 12.0862 3.44151 10.6135V5.3068ZM7.60151 5.3068C7.60151 4.57042 6.92456 3.97347 6.18818 3.97347C5.4518 3.97347 4.77484 4.57042 4.77484 5.3068V10.6135C4.77484 11.3498 5.4518 11.9468 6.18818 11.9468C6.92456 11.9468 7.60151 11.3498 7.60151 10.6135V5.3068Z",
|
|
243
|
-
fill: "currentColor"
|
|
244
|
-
}
|
|
245
|
-
),
|
|
246
|
-
/* @__PURE__ */ import_react.default.createElement(
|
|
247
|
-
"path",
|
|
248
|
-
{
|
|
249
|
-
d: "M12.9882 2.64014C11.5154 2.64014 10.2415 3.83404 10.2415 5.3068V10.6135C10.2415 12.0862 11.5154 13.2801 12.9882 13.2801C14.4609 13.2801 15.7348 12.0862 15.7348 10.6135V5.3068C15.7348 3.83404 14.4609 2.64014 12.9882 2.64014ZM14.4015 10.6135C14.4015 11.3498 13.7246 11.9468 12.9882 11.9468C12.2518 11.9468 11.5748 11.3498 11.5748 10.6135V5.3068C11.5748 4.57042 12.2518 3.97347 12.9882 3.97347C13.7246 3.97347 14.4015 4.57042 14.4015 5.3068V10.6135Z",
|
|
250
|
-
fill: "currentColor"
|
|
251
|
-
}
|
|
252
|
-
),
|
|
253
|
-
/* @__PURE__ */ import_react.default.createElement(
|
|
254
|
-
"path",
|
|
255
|
-
{
|
|
256
|
-
d: "M1.21484 13.2001C1.76713 13.2001 2.21484 12.7524 2.21484 12.2001C2.21484 11.6479 1.76713 11.2001 1.21484 11.2001C0.662559 11.2001 0.214844 11.6479 0.214844 12.2001C0.214844 12.7524 0.662559 13.2001 1.21484 13.2001Z",
|
|
257
|
-
fill: "currentColor"
|
|
258
|
-
}
|
|
259
|
-
)
|
|
260
|
-
),
|
|
261
|
-
array: /* @__PURE__ */ import_react.default.createElement(
|
|
262
|
-
"svg",
|
|
263
308
|
{
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
viewBox: "0 0 16 16",
|
|
267
|
-
fill: "none",
|
|
268
|
-
xmlns: "http://www.w3.org/2000/svg"
|
|
309
|
+
tag: [import_preset_code2.tags.bool],
|
|
310
|
+
color: colors.boolean
|
|
269
311
|
},
|
|
270
|
-
/* @__PURE__ */ import_react.default.createElement(
|
|
271
|
-
"path",
|
|
272
|
-
{
|
|
273
|
-
d: "M5.23759 1.00342H2.00391V14.997H5.23759V13.6251H3.35127V2.37534H5.23759V1.00342Z",
|
|
274
|
-
fill: "currentColor"
|
|
275
|
-
}
|
|
276
|
-
),
|
|
277
|
-
/* @__PURE__ */ import_react.default.createElement(
|
|
278
|
-
"path",
|
|
279
|
-
{
|
|
280
|
-
d: "M10.7624 1.00342H13.9961V14.997H10.7624V13.6251H12.6487V2.37534H10.7624V1.00342Z",
|
|
281
|
-
fill: "currentColor"
|
|
282
|
-
}
|
|
283
|
-
)
|
|
284
|
-
),
|
|
285
|
-
stream: /* @__PURE__ */ import_react.default.createElement(
|
|
286
|
-
"svg",
|
|
287
312
|
{
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
291
|
-
width: "1em",
|
|
292
|
-
height: "1em"
|
|
313
|
+
tag: [import_preset_code2.tags.null],
|
|
314
|
+
color: colors.null
|
|
293
315
|
},
|
|
294
|
-
/* @__PURE__ */ import_react.default.createElement(
|
|
295
|
-
"path",
|
|
296
|
-
{
|
|
297
|
-
d: "M879.674 544.51l-158.254-0.221c-8.534 2.287-17.305-2.776-19.588-11.307l-23.862-75.877-74.742 350.891c0 0-1.523 18.507-11.518 18.507s-26.9 0.281-26.9 0.281c-8.259 2.213-16.748-2.687-18.961-10.949l-92.741-457.648-70.305 330.634c-2.261 8.291-11.94 15.206-20.385 12.986l-24.876 0.339c-8.723 2.293-17.685-2.789-20.023-11.349L270.629 544.51 143.993 544.51c-8.831 0-15.993-7.159-15.993-15.993l0-31.986c0-8.831 7.162-15.993 15.993-15.993l157.429-0.516c9.565-0.304 17.685 0.788 20.023 9.351l24.386 76.092 68.642-358.907c0 0 3.4-10.894 14.397-10.894 10.994 0 34.107-0.448 34.107-0.448 8.262-2.213 16.751 2.687 18.965 10.949l91.912 454.126 67.948-326.182c2.213-8.262 8.707-15.161 16.965-12.948l27.316-0.333c8.531-2.287 17.301 2.776 19.588 11.31l46.665 148.4 127.337 0c8.835 0 15.993 7.162 15.993 15.993l0 31.986C895.667 537.352 888.508 544.51 879.674 544.51z",
|
|
298
|
-
fill: "currentColor"
|
|
299
|
-
}
|
|
300
|
-
)
|
|
301
|
-
),
|
|
302
|
-
map: /* @__PURE__ */ import_react.default.createElement(
|
|
303
|
-
"svg",
|
|
304
316
|
{
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
308
|
-
width: "1em",
|
|
309
|
-
height: "1em"
|
|
317
|
+
tag: [import_preset_code2.tags.separator],
|
|
318
|
+
color: colors.separator
|
|
310
319
|
},
|
|
311
|
-
|
|
312
|
-
"path",
|
|
313
|
-
{
|
|
314
|
-
d: "M877.860571 938.642286h-645.851428c-27.574857 0-54.052571-11.337143-73.508572-31.744a110.957714 110.957714 0 0 1-30.500571-76.8V193.828571c0-28.745143 10.971429-56.32 30.500571-76.726857a101.888 101.888 0 0 1 73.508572-31.817143h574.171428c27.501714 0 53.979429 11.337143 73.508572 31.744 19.529143 20.333714 30.500571 48.054857 30.500571 76.8v522.020572a34.157714 34.157714 0 0 1-6.948571 22.820571c-37.156571 19.382857-57.636571 39.350857-57.636572 72.630857 0 39.716571 19.894857 50.029714 57.636572 72.777143a34.816 34.816 0 0 1-8.045714 49.298286 32.256 32.256 0 0 1-17.334858 5.193143z m-32.256-254.537143V193.828571a40.228571 40.228571 0 0 0-39.497142-41.179428H232.009143a40.301714 40.301714 0 0 0-39.497143 41.252571V699.245714c17.773714-9.874286 37.449143-14.994286 57.417143-14.921143h595.675428v-0.073142z m-595.675428 187.245714h566.198857c-22.893714-11.190857-27.940571-39.497143-28.013714-59.977143 0-20.260571 3.218286-43.885714 28.013714-59.904h-566.125714c-31.670857 0-57.417143 26.843429-57.417143 59.977143 0 33.060571 25.746286 59.904 57.344 59.904z",
|
|
315
|
-
fill: "currentColor"
|
|
316
|
-
}
|
|
317
|
-
),
|
|
318
|
-
/* @__PURE__ */ import_react.default.createElement(
|
|
319
|
-
"path",
|
|
320
|
-
{
|
|
321
|
-
d: "M320 128m32.036571 0l-0.073142 0q32.036571 0 32.036571 32.036571l0 511.926858q0 32.036571-32.036571 32.036571l0.073142 0q-32.036571 0-32.036571-32.036571l0-511.926858q0-32.036571 32.036571-32.036571Z",
|
|
322
|
-
fill: "currentColor"
|
|
323
|
-
}
|
|
324
|
-
)
|
|
325
|
-
)
|
|
326
|
-
};
|
|
327
|
-
var ArrayIcons = {
|
|
328
|
-
object: /* @__PURE__ */ import_react.default.createElement(
|
|
329
|
-
"svg",
|
|
320
|
+
// markdown
|
|
330
321
|
{
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
viewBox: "0 0 16 16",
|
|
334
|
-
fill: "none",
|
|
335
|
-
xmlns: "http://www.w3.org/2000/svg"
|
|
322
|
+
tag: [import_preset_code2.tags.heading],
|
|
323
|
+
color: "#3e76ef"
|
|
336
324
|
},
|
|
337
|
-
/* @__PURE__ */ import_react.default.createElement(
|
|
338
|
-
"path",
|
|
339
|
-
{
|
|
340
|
-
fillRule: "evenodd",
|
|
341
|
-
clipRule: "evenodd",
|
|
342
|
-
d: "M0 1.58105H3.6139V2.87326H1.36702V13.1264H3.6139V14.4186H0V1.58105ZM3.41656 13.3264V13.3266H1.17155V13.3264H3.41656ZM0.197344 14.2186H0.199219V1.78125H3.41656V1.78105H0.197344V14.2186ZM12.3861 1.58105H16V14.4186H12.3861V13.1264H14.633V2.87326H12.3861V1.58105ZM12.5834 2.67326V1.78105H15.8027V1.78125H12.5853V2.67326H12.5834ZM12.5853 13.3266V14.2186H12.5834V13.3264H14.8303V2.67345H14.8322V13.3266H12.5853ZM3.82031 5.9091C3.82031 5.18535 4.40703 4.59863 5.13078 4.59863C5.85453 4.59863 6.44124 5.18535 6.44124 5.9091C6.44124 6.56485 5.9596 7.1081 5.33078 7.2044V8.70018H5.32877C5.32982 8.75093 5.33078 8.80912 5.33078 8.87034V9.72111C5.33078 10.0195 5.57268 10.2614 5.87109 10.2614H6.24124C6.55613 10.2614 6.8114 10.5167 6.8114 10.8316C6.8114 11.1465 6.55613 11.4017 6.24124 11.4017H5.87109C4.94291 11.4017 4.19047 10.6493 4.19047 9.72111V6.82186C3.96158 6.58607 3.82031 6.26397 3.82031 5.9091ZM7.33679 5.9091C7.33679 5.59421 7.59205 5.33894 7.90694 5.33894H11.6085C11.9234 5.33894 12.1786 5.59421 12.1786 5.9091C12.1786 6.22399 11.9234 6.47925 11.6085 6.47925H7.90694C7.59205 6.47925 7.33679 6.22399 7.33679 5.9091ZM7.33679 9.86846C7.33679 9.55357 7.59205 9.2983 7.90694 9.2983H11.6085C11.9234 9.2983 12.1786 9.55357 12.1786 9.86846C12.1786 10.1833 11.9234 10.4386 11.6085 10.4386H7.90694C7.59205 10.4386 7.33679 10.1833 7.33679 9.86846Z",
|
|
343
|
-
fill: "currentColor"
|
|
344
|
-
}
|
|
345
|
-
)
|
|
346
|
-
),
|
|
347
|
-
boolean: /* @__PURE__ */ import_react.default.createElement(
|
|
348
|
-
"svg",
|
|
349
325
|
{
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
viewBox: "0 0 16 16",
|
|
353
|
-
fill: "none",
|
|
354
|
-
xmlns: "http://www.w3.org/2000/svg"
|
|
326
|
+
tag: [import_preset_code2.tags.processingInstruction],
|
|
327
|
+
color: "#3e76ef"
|
|
355
328
|
},
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
{
|
|
359
|
-
fillRule: "evenodd",
|
|
360
|
-
clipRule: "evenodd",
|
|
361
|
-
d: "M0 1.58105H3.6139V2.87326H1.36702V13.1264H3.6139V14.4186H0V1.58105ZM3.41656 13.3264V13.3266H1.17155V13.3264H3.41656ZM0.197344 14.2186H0.199219V1.78125H3.41656V1.78105H0.197344V14.2186ZM12.3861 1.58105H16V14.4186H12.3861V13.1264H14.633V2.87326H12.3861V1.58105ZM12.5834 2.67326V1.78105H15.8027V1.78125H12.5853V2.67326H12.5834ZM12.5853 13.3266V14.2186H12.5834V13.3264H14.8303V2.67345H14.8322V13.3266H12.5853ZM2.75 7.99993C2.75 6.14518 4.25358 4.6416 6.10833 4.6416H9.775C11.6298 4.6416 13.1333 6.14518 13.1333 7.99993C13.1333 9.85469 11.6298 11.3583 9.775 11.3583H6.10833C4.25358 11.3583 2.75 9.85469 2.75 7.99993ZM6.10833 5.85827C4.92552 5.85827 3.96667 6.81713 3.96667 7.99993C3.96667 9.18274 4.92552 10.1416 6.10833 10.1416H9.775C10.9578 10.1416 11.9167 9.18274 11.9167 7.99993C11.9167 6.81713 10.9578 5.85827 9.775 5.85827H6.10833ZM8.25 7.99993C8.25 7.1577 8.93277 6.47493 9.775 6.47493C10.6172 6.47493 11.3 7.1577 11.3 7.99993C11.3 8.84217 10.6172 9.52493 9.775 9.52493C8.93277 9.52493 8.25 8.84217 8.25 7.99993ZM9.775 7.6916C9.60471 7.6916 9.46667 7.82965 9.46667 7.99993C9.46667 8.17022 9.60471 8.30827 9.775 8.30827C9.94529 8.30827 10.0833 8.17022 10.0833 7.99993C10.0833 7.82965 9.94529 7.6916 9.775 7.6916Z",
|
|
362
|
-
fill: "currentColor"
|
|
363
|
-
}
|
|
364
|
-
)
|
|
365
|
-
),
|
|
366
|
-
string: /* @__PURE__ */ import_react.default.createElement(
|
|
367
|
-
"svg",
|
|
329
|
+
// shell
|
|
330
|
+
// curl
|
|
368
331
|
{
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
viewBox: "0 0 16 16",
|
|
372
|
-
fill: "none",
|
|
373
|
-
xmlns: "http://www.w3.org/2000/svg"
|
|
332
|
+
tag: [import_preset_code2.tags.standard(import_preset_code2.tags.variableName)],
|
|
333
|
+
color: "#00804A"
|
|
374
334
|
},
|
|
375
|
-
|
|
376
|
-
"path",
|
|
377
|
-
{
|
|
378
|
-
fillRule: "evenodd",
|
|
379
|
-
clipRule: "evenodd",
|
|
380
|
-
d: "M0 1.58105H3.6139V2.87326H1.36702V13.1264H3.6139V14.4186H0V1.58105ZM3.41656 13.3264V13.3266H1.17155V13.3264H3.41656ZM0.197344 14.2186H0.199219V1.78125H3.41656V1.78105H0.197344V14.2186ZM12.3861 1.58105H16V14.4186H12.3861V13.1264H14.633V2.87326H12.3861V1.58105ZM12.5834 2.67326V1.78105H15.8027V1.78125H12.5853V2.67326H12.5834ZM12.5853 13.3266V14.2186H12.5834V13.3264H14.8303V2.67345H14.8322V13.3266H12.5853ZM5.23701 4.07158C5.50364 3.3161 6.56205 3.28894 6.86709 4.02974L10 11.6383C10.1329 11.9609 9.979 12.3302 9.65631 12.4631C9.33363 12.596 8.96434 12.4421 8.83147 12.1194L7.8021 9.61951H4.61903L3.7474 12.0891C3.63126 12.4182 3.27034 12.5908 2.94127 12.4747C2.6122 12.3585 2.43958 11.9976 2.55573 11.6685L5.23701 4.07158ZM6.08814 5.45704L5.06505 8.35579H7.28174L6.08814 5.45704ZM8.81938 6.07534C8.81938 5.75166 9.08177 5.48926 9.40545 5.48926H12.8941C13.2178 5.48926 13.4802 5.75166 13.4802 6.07534C13.4802 6.39902 13.2178 6.66142 12.8941 6.66142H9.40545C9.08177 6.66142 8.81938 6.39902 8.81938 6.07534ZM10.2668 9.69181C10.2668 9.36812 10.5292 9.10573 10.8529 9.10573H12.8941C13.2178 9.10573 13.4802 9.36812 13.4802 9.69181C13.4802 10.0155 13.2178 10.2779 12.8941 10.2779H10.8529C10.5292 10.2779 10.2668 10.0155 10.2668 9.69181Z",
|
|
381
|
-
fill: "currentColor"
|
|
382
|
-
}
|
|
383
|
-
)
|
|
384
|
-
),
|
|
385
|
-
integer: /* @__PURE__ */ import_react.default.createElement(
|
|
386
|
-
"svg",
|
|
335
|
+
// -X
|
|
387
336
|
{
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
viewBox: "0 0 16 16",
|
|
391
|
-
fill: "none",
|
|
392
|
-
xmlns: "http://www.w3.org/2000/svg"
|
|
337
|
+
tag: [import_preset_code2.tags.attributeName],
|
|
338
|
+
color: "#C74200"
|
|
393
339
|
},
|
|
394
|
-
|
|
395
|
-
"path",
|
|
396
|
-
{
|
|
397
|
-
fillRule: "evenodd",
|
|
398
|
-
clipRule: "evenodd",
|
|
399
|
-
d: "M0 1.58105H3.6139V2.87326H1.36702V13.1264H3.6139V14.4186H0V1.58105ZM3.41656 13.3264V13.3266H1.17155V13.3264H3.41656ZM0.197344 14.2186H0.199219V1.78125H3.41656V1.78105H0.197344V14.2186ZM12.3861 1.58105H16V14.4186H12.3861V13.1264H14.633V2.87326H12.3861V1.58105ZM12.5834 2.67326V1.78105H15.8027V1.78125H12.5853V2.67326H12.5834ZM12.5853 13.3266V14.2186H12.5834V13.3264H14.8303V2.67345H14.8322V13.3266H12.5853ZM10.3614 5.22374C10.7161 4.90585 11.1581 4.75 11.6762 4.75C12.2173 4.75 12.6723 4.91467 13.0281 5.25207L13.0291 5.253C13.3852 5.59688 13.561 6.03946 13.561 6.56767C13.561 6.89 13.4945 7.17448 13.3539 7.41445C13.2572 7.57972 13.1279 7.71948 12.9685 7.83428C13.1575 7.95643 13.3099 8.11182 13.4225 8.30109C13.5793 8.5644 13.6531 8.88311 13.6531 9.24936C13.6531 9.83787 13.4612 10.3151 13.0656 10.6612C12.6982 10.9795 12.2305 11.1341 11.6762 11.1341C11.1356 11.1341 10.6805 10.9925 10.324 10.6977C9.92124 10.3691 9.71723 9.90026 9.69942 9.31256L9.69473 9.15802H10.846L10.8539 9.2997C10.8689 9.5698 10.9591 9.75553 11.1096 9.87941L11.1106 9.88027C11.2519 9.99882 11.4365 10.0631 11.6762 10.0631C11.9765 10.0631 12.1743 9.98692 12.2984 9.86071C12.4229 9.73404 12.4984 9.53136 12.4984 9.22422C12.4984 8.92116 12.4215 8.72127 12.2939 8.59581C12.1658 8.46989 11.961 8.39373 11.6511 8.39373H11.3586V7.34788H11.6511C11.9297 7.34788 12.111 7.27834 12.2238 7.16555C12.3366 7.05276 12.4062 6.87138 12.4062 6.59281C12.4062 6.30696 12.3378 6.12041 12.2277 6.00501C12.1188 5.89092 11.9446 5.82098 11.6762 5.82098C11.4248 5.82098 11.2539 5.88537 11.1407 5.99325C11.0268 6.10185 10.9497 6.27522 10.9291 6.5375L10.9183 6.67577H9.76788L9.77492 6.51904C9.79886 5.98644 9.99237 5.54989 10.3614 5.22374ZM5.91032 5.26037C6.26612 4.92297 6.72112 4.7583 7.26219 4.7583C7.80751 4.7583 8.26297 4.91938 8.61401 5.25194L8.61501 5.25289C8.96719 5.59272 9.13852 6.04185 9.13852 6.58435C9.13852 6.84997 9.08709 7.09565 8.9817 7.31883L8.98114 7.31999C8.89563 7.49712 8.74775 7.71415 8.54418 7.96862L8.54322 7.96981L6.87446 10.0127H9.13852V11.0753H5.36909V10.1089L7.69946 7.27679C7.89456 7.04062 7.98374 6.80773 7.98374 6.57597C7.98374 6.29602 7.91626 6.11385 7.8078 6.00122C7.70036 5.88964 7.52811 5.8209 7.26219 5.8209C7.04017 5.8209 6.87439 5.88173 6.75075 5.99193C6.61227 6.11766 6.53226 6.30918 6.53226 6.59273V6.74273H5.37747V6.59273C5.37747 6.05443 5.55248 5.60586 5.90934 5.2613L5.91032 5.26037ZM3.50907 4.80865H4.56964V11.0754H3.41486V6.2201L2.25 7.24249V5.89561L3.50907 4.80865Z",
|
|
400
|
-
fill: "currentColor"
|
|
401
|
-
}
|
|
402
|
-
)
|
|
403
|
-
),
|
|
404
|
-
number: /* @__PURE__ */ import_react.default.createElement(
|
|
405
|
-
"svg",
|
|
340
|
+
// url in string (includes quotes), e.g. "https://..."
|
|
406
341
|
{
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
if (value?.type === "array") {
|
|
426
|
-
return ArrayIcons[value.items?.type || "object"];
|
|
427
|
-
}
|
|
428
|
-
return VariableTypeIcons[value?.type || "object"];
|
|
342
|
+
tag: [import_preset_code2.tags.special(import_preset_code2.tags.string)],
|
|
343
|
+
color: "#2B57D9"
|
|
344
|
+
}
|
|
345
|
+
]
|
|
346
|
+
});
|
|
347
|
+
|
|
348
|
+
// src/components/code-editor/theme/dark.ts
|
|
349
|
+
var import_preset_code3 = require("@coze-editor/editor/preset-code");
|
|
350
|
+
var colors2 = {
|
|
351
|
+
background: "#151B27",
|
|
352
|
+
// syntax
|
|
353
|
+
comment: "#FFFFFF63",
|
|
354
|
+
key: "#39E5D7",
|
|
355
|
+
string: "#FF94D2",
|
|
356
|
+
number: "#FF9933",
|
|
357
|
+
boolean: "#78B0FF",
|
|
358
|
+
null: "#78B0FF",
|
|
359
|
+
separator: "#FFFFFFC9"
|
|
429
360
|
};
|
|
430
|
-
var
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
361
|
+
var darkTheme = (0, import_preset_code3.createTheme)({
|
|
362
|
+
variant: "dark",
|
|
363
|
+
settings: {
|
|
364
|
+
background: colors2.background,
|
|
365
|
+
foreground: "#fff",
|
|
366
|
+
caret: "#AEAFAD",
|
|
367
|
+
selection: "#d9d9d942",
|
|
368
|
+
gutterBackground: colors2.background,
|
|
369
|
+
gutterForeground: "#FFFFFF63",
|
|
370
|
+
gutterBorderColor: "transparent",
|
|
371
|
+
gutterBorderWidth: 0,
|
|
372
|
+
lineHighlight: "#272e3d36",
|
|
373
|
+
bracketColors: ["#FFEF61", "#DD99FF", "#78B0FF"],
|
|
374
|
+
tooltip: {
|
|
375
|
+
backgroundColor: "#363D4D",
|
|
376
|
+
color: "#fff",
|
|
377
|
+
border: "none"
|
|
378
|
+
},
|
|
379
|
+
link: {
|
|
380
|
+
color: "#4daafc"
|
|
381
|
+
},
|
|
382
|
+
completionItemHover: {
|
|
383
|
+
backgroundColor: "#FFFFFF0F"
|
|
384
|
+
},
|
|
385
|
+
completionItemSelected: {
|
|
386
|
+
backgroundColor: "#FFFFFF17"
|
|
387
|
+
},
|
|
388
|
+
completionItemIcon: {
|
|
389
|
+
color: "#FFFFFFC9"
|
|
390
|
+
},
|
|
391
|
+
completionItemLabel: {
|
|
392
|
+
color: "#FFFFFFC9"
|
|
393
|
+
},
|
|
394
|
+
completionItemInfo: {
|
|
395
|
+
color: "#FFFFFFC9"
|
|
396
|
+
},
|
|
397
|
+
completionItemDetail: {
|
|
398
|
+
color: "#FFFFFF63"
|
|
399
|
+
}
|
|
448
400
|
},
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
401
|
+
styles: [
|
|
402
|
+
// json
|
|
403
|
+
{
|
|
404
|
+
tag: import_preset_code3.tags.comment,
|
|
405
|
+
color: colors2.comment
|
|
406
|
+
},
|
|
407
|
+
{
|
|
408
|
+
tag: [import_preset_code3.tags.propertyName],
|
|
409
|
+
color: colors2.key
|
|
410
|
+
},
|
|
411
|
+
{
|
|
412
|
+
tag: [import_preset_code3.tags.string],
|
|
413
|
+
color: colors2.string
|
|
414
|
+
},
|
|
415
|
+
{
|
|
416
|
+
tag: [import_preset_code3.tags.number],
|
|
417
|
+
color: colors2.number
|
|
418
|
+
},
|
|
419
|
+
{
|
|
420
|
+
tag: [import_preset_code3.tags.bool],
|
|
421
|
+
color: colors2.boolean
|
|
422
|
+
},
|
|
423
|
+
{
|
|
424
|
+
tag: [import_preset_code3.tags.null],
|
|
425
|
+
color: colors2.null
|
|
426
|
+
},
|
|
427
|
+
{
|
|
428
|
+
tag: [import_preset_code3.tags.separator],
|
|
429
|
+
color: colors2.separator
|
|
430
|
+
},
|
|
431
|
+
// markdown
|
|
432
|
+
{
|
|
433
|
+
tag: [import_preset_code3.tags.heading],
|
|
434
|
+
color: "#6b6bff"
|
|
435
|
+
},
|
|
436
|
+
{
|
|
437
|
+
tag: [import_preset_code3.tags.processingInstruction],
|
|
438
|
+
color: "#6b6bff"
|
|
439
|
+
},
|
|
440
|
+
// shell
|
|
441
|
+
// curl
|
|
442
|
+
{
|
|
443
|
+
tag: [import_preset_code3.tags.standard(import_preset_code3.tags.variableName)],
|
|
444
|
+
color: "#3BEB84"
|
|
445
|
+
},
|
|
446
|
+
// -X
|
|
447
|
+
{
|
|
448
|
+
tag: [import_preset_code3.tags.attributeName],
|
|
449
|
+
color: "#FF9933"
|
|
450
|
+
},
|
|
451
|
+
// url in string (includes quotes), e.g. "https://..."
|
|
452
|
+
{
|
|
453
|
+
tag: [import_preset_code3.tags.special(import_preset_code3.tags.string)],
|
|
454
|
+
color: "#78B0FF"
|
|
483
455
|
}
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
}
|
|
497
|
-
}))
|
|
498
|
-
});
|
|
499
|
-
case "array":
|
|
500
|
-
if (weak) {
|
|
501
|
-
return { kind: import_editor.ASTKind.Array, weak: true };
|
|
502
|
-
}
|
|
503
|
-
return import_editor.ASTFactory.createArray({
|
|
504
|
-
items: schemaToAST(jsonSchema.items)
|
|
505
|
-
});
|
|
506
|
-
case "map":
|
|
507
|
-
if (weak) {
|
|
508
|
-
return { kind: import_editor.ASTKind.Map, weak: true };
|
|
509
|
-
}
|
|
510
|
-
return import_editor.ASTFactory.createMap({
|
|
511
|
-
valueType: schemaToAST(jsonSchema.additionalProperties)
|
|
512
|
-
});
|
|
513
|
-
case "string":
|
|
514
|
-
return import_editor.ASTFactory.createString();
|
|
515
|
-
case "number":
|
|
516
|
-
return import_editor.ASTFactory.createNumber();
|
|
517
|
-
case "boolean":
|
|
518
|
-
return import_editor.ASTFactory.createBoolean();
|
|
519
|
-
case "integer":
|
|
520
|
-
return import_editor.ASTFactory.createInteger();
|
|
521
|
-
default:
|
|
522
|
-
return import_editor.ASTFactory.createCustomType({ typeName: type });
|
|
523
|
-
}
|
|
524
|
-
}
|
|
525
|
-
JsonSchemaUtils2.schemaToAST = schemaToAST;
|
|
526
|
-
function astToSchema(typeAST, options2) {
|
|
527
|
-
const { drilldown = true } = options2 || {};
|
|
528
|
-
if (import_editor.ASTMatch.isString(typeAST)) {
|
|
529
|
-
return {
|
|
530
|
-
type: "string"
|
|
531
|
-
};
|
|
456
|
+
]
|
|
457
|
+
});
|
|
458
|
+
|
|
459
|
+
// src/components/code-editor/theme/index.ts
|
|
460
|
+
import_preset_code4.themes.register("dark", darkTheme);
|
|
461
|
+
import_preset_code4.themes.register("light", lightTheme);
|
|
462
|
+
|
|
463
|
+
// src/components/code-editor/index.tsx
|
|
464
|
+
var OriginCodeEditor = (0, import_react3.createRenderer)(import_preset_code5.default, [
|
|
465
|
+
import_view.EditorView.theme({
|
|
466
|
+
"&.cm-focused": {
|
|
467
|
+
outline: "none"
|
|
532
468
|
}
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
469
|
+
})
|
|
470
|
+
]);
|
|
471
|
+
function CodeEditor({
|
|
472
|
+
value,
|
|
473
|
+
onChange,
|
|
474
|
+
languageId = "python",
|
|
475
|
+
theme = "light",
|
|
476
|
+
children,
|
|
477
|
+
placeholder,
|
|
478
|
+
activeLinePlaceholder,
|
|
479
|
+
options,
|
|
480
|
+
readonly
|
|
481
|
+
}) {
|
|
482
|
+
const editorRef = (0, import_react2.useRef)(null);
|
|
483
|
+
(0, import_react2.useEffect)(() => {
|
|
484
|
+
if (languageId === "typescript") {
|
|
485
|
+
initTsWorker();
|
|
537
486
|
}
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
487
|
+
}, [languageId]);
|
|
488
|
+
(0, import_react2.useEffect)(() => {
|
|
489
|
+
if (editorRef.current?.getValue() !== value) {
|
|
490
|
+
editorRef.current?.setValue(String(value || ""));
|
|
542
491
|
}
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
492
|
+
}, [value]);
|
|
493
|
+
return /* @__PURE__ */ import_react2.default.createElement(import_react3.EditorProvider, null, /* @__PURE__ */ import_react2.default.createElement(
|
|
494
|
+
OriginCodeEditor,
|
|
495
|
+
{
|
|
496
|
+
defaultValue: value,
|
|
497
|
+
options: {
|
|
498
|
+
uri: `file:///untitled${getSuffixByLanguageId(languageId)}`,
|
|
499
|
+
languageId,
|
|
500
|
+
theme,
|
|
501
|
+
placeholder,
|
|
502
|
+
readOnly: readonly,
|
|
503
|
+
editable: !readonly,
|
|
504
|
+
...options || {}
|
|
505
|
+
},
|
|
506
|
+
didMount: (editor) => {
|
|
507
|
+
editorRef.current = editor;
|
|
508
|
+
},
|
|
509
|
+
onChange: (e) => onChange?.(e.value)
|
|
510
|
+
},
|
|
511
|
+
activeLinePlaceholder && /* @__PURE__ */ import_react2.default.createElement(import_react3.ActiveLinePlaceholder, null, activeLinePlaceholder),
|
|
512
|
+
children
|
|
513
|
+
));
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
// src/components/code-editor-mini/index.tsx
|
|
517
|
+
var UIMini = import_styled_components.default.div`
|
|
518
|
+
.ͼ1 .cm-content {
|
|
519
|
+
padding: 0;
|
|
520
|
+
}
|
|
521
|
+
`;
|
|
522
|
+
function CodeEditorMini(props) {
|
|
523
|
+
return /* @__PURE__ */ import_react4.default.createElement(UIMini, null, /* @__PURE__ */ import_react4.default.createElement(
|
|
524
|
+
CodeEditor,
|
|
525
|
+
{
|
|
526
|
+
...props,
|
|
527
|
+
options: {
|
|
528
|
+
lineNumbersGutter: false,
|
|
529
|
+
foldGutter: false,
|
|
530
|
+
...props.options || {}
|
|
531
|
+
}
|
|
547
532
|
}
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
) : {}
|
|
563
|
-
};
|
|
533
|
+
));
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
// src/shared/json-schema-preset/type-definition/object.tsx
|
|
537
|
+
var objectRegistry = {
|
|
538
|
+
type: "object",
|
|
539
|
+
ConstantRenderer: (props) => /* @__PURE__ */ import_react5.default.createElement(
|
|
540
|
+
CodeEditorMini,
|
|
541
|
+
{
|
|
542
|
+
value: props.value,
|
|
543
|
+
onChange: (v) => props.onChange?.(v),
|
|
544
|
+
languageId: "json",
|
|
545
|
+
placeholder: "Please Input Object",
|
|
546
|
+
readonly: props.readonly
|
|
564
547
|
}
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
548
|
+
)
|
|
549
|
+
};
|
|
550
|
+
|
|
551
|
+
// src/shared/json-schema-preset/type-definition/number.tsx
|
|
552
|
+
var import_react6 = __toESM(require("react"));
|
|
553
|
+
var import_semi_ui2 = require("@douyinfe/semi-ui");
|
|
554
|
+
var numberRegistry = {
|
|
555
|
+
type: "number",
|
|
556
|
+
ConstantRenderer: (props) => /* @__PURE__ */ import_react6.default.createElement(
|
|
557
|
+
import_semi_ui2.InputNumber,
|
|
558
|
+
{
|
|
559
|
+
placeholder: "Please Input Number",
|
|
560
|
+
size: "small",
|
|
561
|
+
disabled: props.readonly,
|
|
562
|
+
hideButtons: true,
|
|
563
|
+
...props
|
|
576
564
|
}
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
565
|
+
)
|
|
566
|
+
};
|
|
567
|
+
|
|
568
|
+
// src/shared/json-schema-preset/type-definition/integer.tsx
|
|
569
|
+
var import_react7 = __toESM(require("react"));
|
|
570
|
+
var import_semi_ui3 = require("@douyinfe/semi-ui");
|
|
571
|
+
var integerRegistry = {
|
|
572
|
+
type: "integer",
|
|
573
|
+
ConstantRenderer: (props) => /* @__PURE__ */ import_react7.default.createElement(
|
|
574
|
+
import_semi_ui3.InputNumber,
|
|
575
|
+
{
|
|
576
|
+
placeholder: "Please Input Integer",
|
|
577
|
+
size: "small",
|
|
578
|
+
disabled: props.readonly,
|
|
579
|
+
precision: 0,
|
|
580
|
+
...props
|
|
581
581
|
}
|
|
582
|
-
|
|
582
|
+
)
|
|
583
|
+
};
|
|
584
|
+
|
|
585
|
+
// src/shared/json-schema-preset/type-definition/boolean.tsx
|
|
586
|
+
var import_react8 = __toESM(require("react"));
|
|
587
|
+
var import_semi_ui4 = require("@douyinfe/semi-ui");
|
|
588
|
+
var booleanRegistry = {
|
|
589
|
+
type: "boolean",
|
|
590
|
+
ConstantRenderer: (props) => {
|
|
591
|
+
const { value, onChange, ...rest } = props;
|
|
592
|
+
return /* @__PURE__ */ import_react8.default.createElement(
|
|
593
|
+
import_semi_ui4.Select,
|
|
594
|
+
{
|
|
595
|
+
placeholder: "Please Select Boolean",
|
|
596
|
+
size: "small",
|
|
597
|
+
disabled: props.readonly,
|
|
598
|
+
optionList: [
|
|
599
|
+
{ label: "True", value: 1 },
|
|
600
|
+
{ label: "False", value: 0 }
|
|
601
|
+
],
|
|
602
|
+
value: value ? 1 : 0,
|
|
603
|
+
onChange: (value2) => onChange?.(!!value2),
|
|
604
|
+
...rest
|
|
605
|
+
}
|
|
606
|
+
);
|
|
583
607
|
}
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
608
|
+
};
|
|
609
|
+
|
|
610
|
+
// src/shared/json-schema-preset/type-definition/array.tsx
|
|
611
|
+
var import_react9 = __toESM(require("react"));
|
|
612
|
+
var arrayRegistry = {
|
|
613
|
+
type: "array",
|
|
614
|
+
ConstantRenderer: (props) => /* @__PURE__ */ import_react9.default.createElement(
|
|
615
|
+
CodeEditorMini,
|
|
616
|
+
{
|
|
617
|
+
value: props.value,
|
|
618
|
+
languageId: "json",
|
|
619
|
+
onChange: (v) => props.onChange?.(v),
|
|
620
|
+
placeholder: "Please Input Array",
|
|
621
|
+
readonly: props.readonly
|
|
592
622
|
}
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
623
|
+
)
|
|
624
|
+
};
|
|
625
|
+
|
|
626
|
+
// src/shared/json-schema-preset/type-definition/index.tsx
|
|
627
|
+
var jsonSchemaTypePreset = [
|
|
628
|
+
stringRegistry,
|
|
629
|
+
objectRegistry,
|
|
630
|
+
numberRegistry,
|
|
631
|
+
integerRegistry,
|
|
632
|
+
booleanRegistry,
|
|
633
|
+
arrayRegistry
|
|
634
|
+
];
|
|
635
|
+
jsonSchemaTypePreset.forEach((_type) => import_json_schema.jsonSchemaTypeManager.register(_type));
|
|
636
|
+
|
|
637
|
+
// src/shared/json-schema-preset/create-type-preset-plugin.tsx
|
|
638
|
+
var import_json_schema2 = require("@flowgram.ai/json-schema");
|
|
639
|
+
var import_editor2 = require("@flowgram.ai/editor");
|
|
640
|
+
var createTypePresetPlugin = (0, import_editor2.definePluginCreator)({
|
|
641
|
+
onInit(ctx, opts) {
|
|
642
|
+
const typeManager = ctx.get(import_json_schema2.BaseTypeManager);
|
|
643
|
+
jsonSchemaTypePreset.forEach((_type) => typeManager.register(_type));
|
|
644
|
+
opts.types.forEach((_type) => typeManager.register(_type));
|
|
645
|
+
},
|
|
646
|
+
containerModules: [import_json_schema2.jsonSchemaContainerModule]
|
|
647
|
+
});
|
|
648
|
+
|
|
649
|
+
// src/shared/json-schema-preset/index.tsx
|
|
650
|
+
var useTypeManager = () => (0, import_json_schema3.useTypeManager)();
|
|
651
|
+
var JsonSchemaTypePresetProvider = ({
|
|
652
|
+
types = [],
|
|
653
|
+
children
|
|
654
|
+
}) => /* @__PURE__ */ import_react10.default.createElement(import_json_schema3.TypePresetProvider, { types: [...jsonSchemaTypePreset, ...types] }, children);
|
|
597
655
|
|
|
598
656
|
// src/components/variable-selector/use-variable-tree.tsx
|
|
599
657
|
function useVariableTree(params) {
|
|
600
658
|
const { includeSchema, excludeSchema, customSkip } = params;
|
|
601
|
-
const
|
|
602
|
-
const
|
|
659
|
+
const typeManager = useTypeManager();
|
|
660
|
+
const variables = (0, import_editor3.useAvailableVariables)();
|
|
661
|
+
const getVariableTypeIcon = (0, import_react11.useCallback)((variable) => {
|
|
603
662
|
if (variable.meta?.icon) {
|
|
604
663
|
if (typeof variable.meta.icon === "string") {
|
|
605
|
-
return /* @__PURE__ */
|
|
664
|
+
return /* @__PURE__ */ import_react11.default.createElement("img", { style: { marginRight: 8 }, width: 12, height: 12, src: variable.meta.icon });
|
|
606
665
|
}
|
|
607
666
|
return variable.meta.icon;
|
|
608
667
|
}
|
|
609
|
-
const
|
|
610
|
-
|
|
611
|
-
return /* @__PURE__ */ import_react2.default.createElement(
|
|
612
|
-
import_semi_ui.Icon,
|
|
613
|
-
{
|
|
614
|
-
size: "small",
|
|
615
|
-
svg: ArrayIcons[_type.items?.kind.toLowerCase()] || VariableTypeIcons.array
|
|
616
|
-
}
|
|
617
|
-
);
|
|
618
|
-
}
|
|
619
|
-
if (import_editor2.ASTMatch.isCustomType(_type)) {
|
|
620
|
-
return /* @__PURE__ */ import_react2.default.createElement(import_semi_ui.Icon, { size: "small", svg: VariableTypeIcons[_type.typeName.toLowerCase()] });
|
|
621
|
-
}
|
|
622
|
-
return /* @__PURE__ */ import_react2.default.createElement(import_semi_ui.Icon, { size: "small", svg: VariableTypeIcons[variable.type?.kind.toLowerCase()] });
|
|
668
|
+
const schema = import_json_schema4.JsonSchemaUtils.astToSchema(variable.type, { drilldownObject: false });
|
|
669
|
+
return /* @__PURE__ */ import_react11.default.createElement(import_semi_ui5.Icon, { size: "small", svg: typeManager.getDisplayIcon(schema || {}) });
|
|
623
670
|
}, []);
|
|
624
671
|
const renderVariable = (variable, parentFields = []) => {
|
|
625
672
|
let type = variable?.type;
|
|
@@ -627,15 +674,16 @@ function useVariableTree(params) {
|
|
|
627
674
|
return null;
|
|
628
675
|
}
|
|
629
676
|
let children;
|
|
630
|
-
if (
|
|
677
|
+
if (import_editor3.ASTMatch.isObject(type)) {
|
|
631
678
|
children = (type.properties || []).map((_property) => renderVariable(_property, [...parentFields, variable])).filter(Boolean);
|
|
632
679
|
}
|
|
633
680
|
const keyPath = [...parentFields.map((_field) => _field.key), variable.key];
|
|
634
681
|
const key = keyPath.join(".");
|
|
635
|
-
const isSchemaInclude = includeSchema ? JsonSchemaUtils.isASTMatchSchema(type, includeSchema) : true;
|
|
636
|
-
const isSchemaExclude = excludeSchema ? JsonSchemaUtils.isASTMatchSchema(type, excludeSchema) : false;
|
|
682
|
+
const isSchemaInclude = includeSchema ? import_json_schema4.JsonSchemaUtils.isASTMatchSchema(type, includeSchema) : true;
|
|
683
|
+
const isSchemaExclude = excludeSchema ? import_json_schema4.JsonSchemaUtils.isASTMatchSchema(type, excludeSchema) : false;
|
|
637
684
|
const isCustomSkip = customSkip ? customSkip(variable) : false;
|
|
638
|
-
const
|
|
685
|
+
const isMetaDisabled = variable.meta?.disabled;
|
|
686
|
+
const isSchemaMatch = isSchemaInclude && !isSchemaExclude && !isCustomSkip && !isMetaDisabled;
|
|
639
687
|
if (!isSchemaMatch && !children?.length) {
|
|
640
688
|
return null;
|
|
641
689
|
}
|
|
@@ -655,9 +703,9 @@ function useVariableTree(params) {
|
|
|
655
703
|
}
|
|
656
704
|
|
|
657
705
|
// src/components/variable-selector/styles.tsx
|
|
658
|
-
var
|
|
659
|
-
var
|
|
660
|
-
var UIRootTitle =
|
|
706
|
+
var import_styled_components2 = __toESM(require("styled-components"));
|
|
707
|
+
var import_semi_ui6 = require("@douyinfe/semi-ui");
|
|
708
|
+
var UIRootTitle = import_styled_components2.default.div`
|
|
661
709
|
margin-right: 4px;
|
|
662
710
|
min-width: 20px;
|
|
663
711
|
overflow: hidden;
|
|
@@ -665,16 +713,16 @@ var UIRootTitle = import_styled_components.default.div`
|
|
|
665
713
|
white-space: nowrap;
|
|
666
714
|
color: var(--semi-color-text-2);
|
|
667
715
|
`;
|
|
668
|
-
var UIVarName =
|
|
716
|
+
var UIVarName = import_styled_components2.default.div`
|
|
669
717
|
overflow: hidden;
|
|
670
718
|
text-overflow: ellipsis;
|
|
671
719
|
white-space: nowrap;
|
|
672
720
|
|
|
673
|
-
${({ $inSelector }) => $inSelector &&
|
|
721
|
+
${({ $inSelector }) => $inSelector && import_styled_components2.css`
|
|
674
722
|
min-width: 50%;
|
|
675
723
|
`}
|
|
676
724
|
`;
|
|
677
|
-
var UITag = (0,
|
|
725
|
+
var UITag = (0, import_styled_components2.default)(import_semi_ui6.Tag)`
|
|
678
726
|
width: 100%;
|
|
679
727
|
display: flex;
|
|
680
728
|
align-items: center;
|
|
@@ -689,7 +737,7 @@ var UITag = (0, import_styled_components.default)(import_semi_ui2.Tag)`
|
|
|
689
737
|
height: 22px;
|
|
690
738
|
}
|
|
691
739
|
`;
|
|
692
|
-
var UITreeSelect = (0,
|
|
740
|
+
var UITreeSelect = (0, import_styled_components2.default)(import_semi_ui6.TreeSelect)`
|
|
693
741
|
outline: ${({ $error }) => $error ? "1px solid red" : "none"};
|
|
694
742
|
|
|
695
743
|
& .semi-tree-select-selection {
|
|
@@ -705,7 +753,7 @@ var UITreeSelect = (0, import_styled_components.default)(import_semi_ui2.TreeSel
|
|
|
705
753
|
padding-left: 10px;
|
|
706
754
|
}
|
|
707
755
|
`;
|
|
708
|
-
var UIPopoverContent =
|
|
756
|
+
var UIPopoverContent = import_styled_components2.default.div`
|
|
709
757
|
padding: 10px;
|
|
710
758
|
display: inline-flex;
|
|
711
759
|
align-items: center;
|
|
@@ -726,7 +774,7 @@ var VariableSelector = ({
|
|
|
726
774
|
triggerRender
|
|
727
775
|
}) => {
|
|
728
776
|
const treeData = useVariableTree({ includeSchema, excludeSchema });
|
|
729
|
-
const treeValue = (0,
|
|
777
|
+
const treeValue = (0, import_react12.useMemo)(() => {
|
|
730
778
|
if (typeof value === "string") {
|
|
731
779
|
console.warn(
|
|
732
780
|
"The Value of VariableSelector is a string, it should be an ARRAY. \n",
|
|
@@ -738,11 +786,11 @@ var VariableSelector = ({
|
|
|
738
786
|
}, [value]);
|
|
739
787
|
const renderIcon = (icon) => {
|
|
740
788
|
if (typeof icon === "string") {
|
|
741
|
-
return /* @__PURE__ */
|
|
789
|
+
return /* @__PURE__ */ import_react12.default.createElement("img", { style: { marginRight: 8 }, width: 12, height: 12, src: icon });
|
|
742
790
|
}
|
|
743
791
|
return icon;
|
|
744
792
|
};
|
|
745
|
-
return /* @__PURE__ */
|
|
793
|
+
return /* @__PURE__ */ import_react12.default.createElement(import_react12.default.Fragment, null, /* @__PURE__ */ import_react12.default.createElement(
|
|
746
794
|
UITreeSelect,
|
|
747
795
|
{
|
|
748
796
|
dropdownMatchSelectWidth: false,
|
|
@@ -759,10 +807,10 @@ var VariableSelector = ({
|
|
|
759
807
|
},
|
|
760
808
|
renderSelectedItem: (_option) => {
|
|
761
809
|
if (!_option?.keyPath) {
|
|
762
|
-
return /* @__PURE__ */
|
|
810
|
+
return /* @__PURE__ */ import_react12.default.createElement(
|
|
763
811
|
UITag,
|
|
764
812
|
{
|
|
765
|
-
prefixIcon: /* @__PURE__ */
|
|
813
|
+
prefixIcon: /* @__PURE__ */ import_react12.default.createElement(import_semi_icons.IconIssueStroked, null),
|
|
766
814
|
color: "amber",
|
|
767
815
|
closable: !readonly,
|
|
768
816
|
onClose: () => onChange(void 0)
|
|
@@ -771,13 +819,13 @@ var VariableSelector = ({
|
|
|
771
819
|
);
|
|
772
820
|
}
|
|
773
821
|
const rootIcon = renderIcon(_option.rootMeta?.icon || _option?.icon);
|
|
774
|
-
const rootTitle = /* @__PURE__ */
|
|
775
|
-
return /* @__PURE__ */
|
|
776
|
-
|
|
822
|
+
const rootTitle = /* @__PURE__ */ import_react12.default.createElement(UIRootTitle, null, _option.rootMeta?.title ? `${_option.rootMeta?.title} ${_option.isRoot ? "" : "-"} ` : null);
|
|
823
|
+
return /* @__PURE__ */ import_react12.default.createElement("div", null, /* @__PURE__ */ import_react12.default.createElement(
|
|
824
|
+
import_semi_ui7.Popover,
|
|
777
825
|
{
|
|
778
|
-
content: /* @__PURE__ */
|
|
826
|
+
content: /* @__PURE__ */ import_react12.default.createElement(UIPopoverContent, null, rootIcon, rootTitle, /* @__PURE__ */ import_react12.default.createElement(UIVarName, null, _option.keyPath.slice(1).join(".")))
|
|
779
827
|
},
|
|
780
|
-
/* @__PURE__ */
|
|
828
|
+
/* @__PURE__ */ import_react12.default.createElement(
|
|
781
829
|
UITag,
|
|
782
830
|
{
|
|
783
831
|
prefixIcon: rootIcon,
|
|
@@ -785,12 +833,12 @@ var VariableSelector = ({
|
|
|
785
833
|
onClose: () => onChange(void 0)
|
|
786
834
|
},
|
|
787
835
|
rootTitle,
|
|
788
|
-
!_option.isRoot && /* @__PURE__ */
|
|
836
|
+
!_option.isRoot && /* @__PURE__ */ import_react12.default.createElement(UIVarName, { $inSelector: true }, _option.label)
|
|
789
837
|
)
|
|
790
838
|
));
|
|
791
839
|
},
|
|
792
840
|
showClear: false,
|
|
793
|
-
arrowIcon: /* @__PURE__ */
|
|
841
|
+
arrowIcon: /* @__PURE__ */ import_react12.default.createElement(import_semi_icons.IconChevronDownStroked, { size: "small" }),
|
|
794
842
|
triggerRender,
|
|
795
843
|
placeholder: config?.placeholder ?? "Select Variable..."
|
|
796
844
|
}
|
|
@@ -798,8 +846,10 @@ var VariableSelector = ({
|
|
|
798
846
|
};
|
|
799
847
|
|
|
800
848
|
// src/components/type-selector/index.tsx
|
|
801
|
-
var
|
|
802
|
-
var
|
|
849
|
+
var import_react13 = __toESM(require("react"));
|
|
850
|
+
var import_semi_ui8 = require("@douyinfe/semi-ui");
|
|
851
|
+
var labelStyle = { display: "flex", alignItems: "center", gap: 5 };
|
|
852
|
+
var firstUppercase = (str) => str.charAt(0).toUpperCase() + str.slice(1);
|
|
803
853
|
var getTypeSelectValue = (value) => {
|
|
804
854
|
if (value?.type === "array" && value?.items) {
|
|
805
855
|
return [value.type, ...getTypeSelectValue(value.items) || []];
|
|
@@ -815,21 +865,38 @@ var parseTypeSelectValue = (value) => {
|
|
|
815
865
|
};
|
|
816
866
|
function TypeSelector(props) {
|
|
817
867
|
const { value, onChange, readonly, disabled, style } = props;
|
|
818
|
-
const selectValue = (0,
|
|
819
|
-
|
|
820
|
-
|
|
868
|
+
const selectValue = (0, import_react13.useMemo)(() => getTypeSelectValue(value), [value]);
|
|
869
|
+
const typeManager = useTypeManager();
|
|
870
|
+
const icon = typeManager.getDisplayIcon(value || {});
|
|
871
|
+
const options = (0, import_react13.useMemo)(
|
|
872
|
+
() => typeManager.getTypeRegistriesWithParentType().map((_type) => {
|
|
873
|
+
const isArray2 = _type.type === "array";
|
|
874
|
+
return {
|
|
875
|
+
label: /* @__PURE__ */ import_react13.default.createElement("div", { style: labelStyle }, /* @__PURE__ */ import_react13.default.createElement(import_semi_ui8.Icon, { size: "small", svg: _type.icon }), firstUppercase(_type.type)),
|
|
876
|
+
value: _type.type,
|
|
877
|
+
children: isArray2 ? typeManager.getTypeRegistriesWithParentType("array").map((_type2) => ({
|
|
878
|
+
label: /* @__PURE__ */ import_react13.default.createElement("div", { style: labelStyle }, /* @__PURE__ */ import_react13.default.createElement(
|
|
879
|
+
import_semi_ui8.Icon,
|
|
880
|
+
{
|
|
881
|
+
size: "small",
|
|
882
|
+
svg: typeManager.getDisplayIcon({
|
|
883
|
+
type: "array",
|
|
884
|
+
items: { type: _type2.type }
|
|
885
|
+
})
|
|
886
|
+
}
|
|
887
|
+
), firstUppercase(_type2.type)),
|
|
888
|
+
value: _type2.type
|
|
889
|
+
})) : []
|
|
890
|
+
};
|
|
891
|
+
}),
|
|
892
|
+
[]
|
|
893
|
+
);
|
|
894
|
+
return /* @__PURE__ */ import_react13.default.createElement(
|
|
895
|
+
import_semi_ui8.Cascader,
|
|
821
896
|
{
|
|
822
897
|
disabled: readonly || disabled,
|
|
823
898
|
size: "small",
|
|
824
|
-
triggerRender: () => /* @__PURE__ */
|
|
825
|
-
import_semi_ui4.IconButton,
|
|
826
|
-
{
|
|
827
|
-
size: "small",
|
|
828
|
-
style,
|
|
829
|
-
disabled: readonly || disabled,
|
|
830
|
-
icon: getSchemaIcon(value)
|
|
831
|
-
}
|
|
832
|
-
),
|
|
899
|
+
triggerRender: () => /* @__PURE__ */ import_react13.default.createElement(import_semi_ui8.IconButton, { size: "small", style, disabled: readonly || disabled, icon }),
|
|
833
900
|
treeData: options,
|
|
834
901
|
value: selectValue,
|
|
835
902
|
leafOnly: true,
|
|
@@ -841,50 +908,50 @@ function TypeSelector(props) {
|
|
|
841
908
|
}
|
|
842
909
|
|
|
843
910
|
// src/components/json-schema-editor/index.tsx
|
|
844
|
-
var
|
|
845
|
-
var
|
|
846
|
-
var
|
|
911
|
+
var import_react19 = __toESM(require("react"));
|
|
912
|
+
var import_semi_ui11 = require("@douyinfe/semi-ui");
|
|
913
|
+
var import_semi_icons4 = require("@douyinfe/semi-icons");
|
|
847
914
|
|
|
848
915
|
// src/components/json-schema-editor/styles.tsx
|
|
849
|
-
var
|
|
850
|
-
var
|
|
851
|
-
var
|
|
852
|
-
var UIContainer =
|
|
916
|
+
var import_react14 = __toESM(require("react"));
|
|
917
|
+
var import_styled_components3 = __toESM(require("styled-components"));
|
|
918
|
+
var import_semi_icons2 = __toESM(require("@douyinfe/semi-icons"));
|
|
919
|
+
var UIContainer = import_styled_components3.default.div`
|
|
853
920
|
/* & .semi-input {
|
|
854
921
|
background-color: #fff;
|
|
855
922
|
border-radius: 6px;
|
|
856
923
|
height: 24px;
|
|
857
924
|
} */
|
|
858
925
|
`;
|
|
859
|
-
var UIRow =
|
|
926
|
+
var UIRow = import_styled_components3.default.div`
|
|
860
927
|
display: flex;
|
|
861
928
|
align-items: center;
|
|
862
929
|
gap: 6px;
|
|
863
930
|
`;
|
|
864
|
-
var UICollapseTrigger =
|
|
931
|
+
var UICollapseTrigger = import_styled_components3.default.div`
|
|
865
932
|
cursor: pointer;
|
|
866
933
|
margin-right: 5px;
|
|
867
934
|
`;
|
|
868
|
-
var UIExpandDetail =
|
|
935
|
+
var UIExpandDetail = import_styled_components3.default.div`
|
|
869
936
|
display: flex;
|
|
870
937
|
flex-direction: column;
|
|
871
938
|
`;
|
|
872
|
-
var UILabel =
|
|
939
|
+
var UILabel = import_styled_components3.default.div`
|
|
873
940
|
font-size: 12px;
|
|
874
941
|
color: #999;
|
|
875
942
|
font-weight: 400;
|
|
876
943
|
margin-bottom: 2px;
|
|
877
944
|
`;
|
|
878
|
-
var UIProperties =
|
|
945
|
+
var UIProperties = import_styled_components3.default.div`
|
|
879
946
|
display: grid;
|
|
880
947
|
grid-template-columns: auto 1fr;
|
|
881
948
|
|
|
882
|
-
${({ $shrink }) => $shrink &&
|
|
949
|
+
${({ $shrink }) => $shrink && import_styled_components3.css`
|
|
883
950
|
padding-left: 10px;
|
|
884
951
|
margin-top: 10px;
|
|
885
952
|
`}
|
|
886
953
|
`;
|
|
887
|
-
var UIPropertyLeft =
|
|
954
|
+
var UIPropertyLeft = import_styled_components3.default.div`
|
|
888
955
|
grid-column: 1;
|
|
889
956
|
position: relative;
|
|
890
957
|
width: 16px;
|
|
@@ -894,7 +961,7 @@ var UIPropertyLeft = import_styled_components2.default.div`
|
|
|
894
961
|
if ($parentType && $isLast) {
|
|
895
962
|
height = "24px";
|
|
896
963
|
}
|
|
897
|
-
return $showLine &&
|
|
964
|
+
return $showLine && import_styled_components3.css`
|
|
898
965
|
&::before {
|
|
899
966
|
/* 竖线 */
|
|
900
967
|
content: '';
|
|
@@ -921,7 +988,7 @@ var UIPropertyLeft = import_styled_components2.default.div`
|
|
|
921
988
|
`;
|
|
922
989
|
}}
|
|
923
990
|
`;
|
|
924
|
-
var UIPropertyRight =
|
|
991
|
+
var UIPropertyRight = import_styled_components3.default.div`
|
|
925
992
|
grid-column: 2;
|
|
926
993
|
margin-bottom: 10px;
|
|
927
994
|
|
|
@@ -929,7 +996,7 @@ var UIPropertyRight = import_styled_components2.default.div`
|
|
|
929
996
|
margin-bottom: 0px;
|
|
930
997
|
}
|
|
931
998
|
`;
|
|
932
|
-
var UIPropertyMain =
|
|
999
|
+
var UIPropertyMain = import_styled_components3.default.div`
|
|
933
1000
|
display: flex;
|
|
934
1001
|
flex-direction: column;
|
|
935
1002
|
gap: 10px;
|
|
@@ -948,33 +1015,33 @@ var UIPropertyMain = import_styled_components2.default.div`
|
|
|
948
1015
|
background: #d9d9d9;
|
|
949
1016
|
display: block;
|
|
950
1017
|
}`;
|
|
951
|
-
return $expand &&
|
|
1018
|
+
return $expand && import_styled_components3.css`
|
|
952
1019
|
background-color: #f5f5f5;
|
|
953
1020
|
padding: 10px;
|
|
954
1021
|
border-radius: 4px;
|
|
955
1022
|
|
|
956
|
-
${$showCollapse && $collapse && (type === "array" || type === "object") &&
|
|
1023
|
+
${$showCollapse && $collapse && (type === "array" || type === "object") && import_styled_components3.css`
|
|
957
1024
|
${beforeElement}
|
|
958
1025
|
`}
|
|
959
1026
|
`;
|
|
960
1027
|
}}
|
|
961
1028
|
`;
|
|
962
|
-
var UICollapsible =
|
|
1029
|
+
var UICollapsible = import_styled_components3.default.div`
|
|
963
1030
|
display: none;
|
|
964
1031
|
|
|
965
|
-
${({ $collapse }) => $collapse &&
|
|
1032
|
+
${({ $collapse }) => $collapse && import_styled_components3.css`
|
|
966
1033
|
display: block;
|
|
967
1034
|
`}
|
|
968
1035
|
`;
|
|
969
|
-
var UIName =
|
|
1036
|
+
var UIName = import_styled_components3.default.div`
|
|
970
1037
|
flex-grow: 1;
|
|
971
1038
|
`;
|
|
972
|
-
var UIType =
|
|
973
|
-
var UIRequired =
|
|
974
|
-
var UIActions =
|
|
1039
|
+
var UIType = import_styled_components3.default.div``;
|
|
1040
|
+
var UIRequired = import_styled_components3.default.div``;
|
|
1041
|
+
var UIActions = import_styled_components3.default.div`
|
|
975
1042
|
white-space: nowrap;
|
|
976
1043
|
`;
|
|
977
|
-
var iconAddChildrenSvg = /* @__PURE__ */
|
|
1044
|
+
var iconAddChildrenSvg = /* @__PURE__ */ import_react14.default.createElement(
|
|
978
1045
|
"svg",
|
|
979
1046
|
{
|
|
980
1047
|
className: "icon-icon icon-icon-coz_add_node ",
|
|
@@ -984,7 +1051,7 @@ var iconAddChildrenSvg = /* @__PURE__ */ import_react5.default.createElement(
|
|
|
984
1051
|
fill: "currentColor",
|
|
985
1052
|
xmlns: "http://www.w3.org/2000/svg"
|
|
986
1053
|
},
|
|
987
|
-
/* @__PURE__ */
|
|
1054
|
+
/* @__PURE__ */ import_react14.default.createElement(
|
|
988
1055
|
"path",
|
|
989
1056
|
{
|
|
990
1057
|
fillRule: "evenodd",
|
|
@@ -992,19 +1059,19 @@ var iconAddChildrenSvg = /* @__PURE__ */ import_react5.default.createElement(
|
|
|
992
1059
|
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"
|
|
993
1060
|
}
|
|
994
1061
|
),
|
|
995
|
-
/* @__PURE__ */
|
|
1062
|
+
/* @__PURE__ */ import_react14.default.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" })
|
|
996
1063
|
);
|
|
997
|
-
var IconAddChildren = () => /* @__PURE__ */
|
|
998
|
-
var DefaultValueWrapper =
|
|
1064
|
+
var IconAddChildren = () => /* @__PURE__ */ import_react14.default.createElement(import_semi_icons2.default, { size: "small", svg: iconAddChildrenSvg });
|
|
1065
|
+
var DefaultValueWrapper = import_styled_components3.default.div`
|
|
999
1066
|
margin: 0;
|
|
1000
1067
|
`;
|
|
1001
|
-
var JSONViewerWrapper =
|
|
1068
|
+
var JSONViewerWrapper = import_styled_components3.default.div`
|
|
1002
1069
|
padding: 0 0 24px;
|
|
1003
1070
|
&:first-child {
|
|
1004
1071
|
margin-top: 0px;
|
|
1005
1072
|
}
|
|
1006
1073
|
`;
|
|
1007
|
-
var JSONHeader =
|
|
1074
|
+
var JSONHeader = import_styled_components3.default.div`
|
|
1008
1075
|
display: flex;
|
|
1009
1076
|
justify-content: space-between;
|
|
1010
1077
|
align-items: center;
|
|
@@ -1013,17 +1080,17 @@ var JSONHeader = import_styled_components2.default.div`
|
|
|
1013
1080
|
height: 36px;
|
|
1014
1081
|
padding: 0 8px 0 12px;
|
|
1015
1082
|
`;
|
|
1016
|
-
var JSONHeaderLeft =
|
|
1083
|
+
var JSONHeaderLeft = import_styled_components3.default.div`
|
|
1017
1084
|
display: flex;
|
|
1018
1085
|
align-items: center;
|
|
1019
1086
|
gap: 10px;
|
|
1020
1087
|
`;
|
|
1021
|
-
var JSONHeaderRight =
|
|
1088
|
+
var JSONHeaderRight = import_styled_components3.default.div`
|
|
1022
1089
|
display: flex;
|
|
1023
1090
|
align-items: center;
|
|
1024
1091
|
gap: 10px;
|
|
1025
1092
|
`;
|
|
1026
|
-
var ConstantInputWrapper =
|
|
1093
|
+
var ConstantInputWrapper = import_styled_components3.default.div`
|
|
1027
1094
|
flex-grow: 1;
|
|
1028
1095
|
|
|
1029
1096
|
& .semi-tree-select,
|
|
@@ -1034,7 +1101,7 @@ var ConstantInputWrapper = import_styled_components2.default.div`
|
|
|
1034
1101
|
`;
|
|
1035
1102
|
|
|
1036
1103
|
// src/components/json-schema-editor/hooks.tsx
|
|
1037
|
-
var
|
|
1104
|
+
var import_react15 = require("react");
|
|
1038
1105
|
var import_lodash2 = require("lodash");
|
|
1039
1106
|
var _id = 0;
|
|
1040
1107
|
function genId() {
|
|
@@ -1050,9 +1117,9 @@ function getDrilldownSchema(value, path) {
|
|
|
1050
1117
|
return { schema: value, path };
|
|
1051
1118
|
}
|
|
1052
1119
|
function usePropertiesEdit(value, onChange) {
|
|
1053
|
-
const drilldown = (0,
|
|
1120
|
+
const drilldown = (0, import_react15.useMemo)(() => getDrilldownSchema(value), [value, value?.type, value?.items]);
|
|
1054
1121
|
const isDrilldownObject = drilldown.schema?.type === "object";
|
|
1055
|
-
const initPropertyList = (0,
|
|
1122
|
+
const initPropertyList = (0, import_react15.useMemo)(
|
|
1056
1123
|
() => isDrilldownObject ? Object.entries(drilldown.schema?.properties || {}).sort(([, a], [, b]) => (a.extra?.index ?? 0) - (b.extra?.index ?? 0)).map(
|
|
1057
1124
|
([name, _value], index) => ({
|
|
1058
1125
|
key: genId(),
|
|
@@ -1067,9 +1134,9 @@ function usePropertiesEdit(value, onChange) {
|
|
|
1067
1134
|
) : [],
|
|
1068
1135
|
[isDrilldownObject]
|
|
1069
1136
|
);
|
|
1070
|
-
const [propertyList, setPropertyList] = (0,
|
|
1071
|
-
const mountRef = (0,
|
|
1072
|
-
(0,
|
|
1137
|
+
const [propertyList, setPropertyList] = (0, import_react15.useState)(initPropertyList);
|
|
1138
|
+
const mountRef = (0, import_react15.useRef)(false);
|
|
1139
|
+
(0, import_react15.useEffect)(() => {
|
|
1073
1140
|
if (mountRef.current) {
|
|
1074
1141
|
setPropertyList((_list) => {
|
|
1075
1142
|
const nameMap = /* @__PURE__ */ new Map();
|
|
@@ -1137,7 +1204,7 @@ function usePropertiesEdit(value, onChange) {
|
|
|
1137
1204
|
(_list) => _list.map((_property) => _property.key === key ? nextValue : _property)
|
|
1138
1205
|
);
|
|
1139
1206
|
};
|
|
1140
|
-
(0,
|
|
1207
|
+
(0, import_react15.useEffect)(() => {
|
|
1141
1208
|
if (!isDrilldownObject) {
|
|
1142
1209
|
setPropertyList([]);
|
|
1143
1210
|
}
|
|
@@ -1152,9 +1219,9 @@ function usePropertiesEdit(value, onChange) {
|
|
|
1152
1219
|
}
|
|
1153
1220
|
|
|
1154
1221
|
// src/components/json-schema-editor/default-value.tsx
|
|
1155
|
-
var
|
|
1156
|
-
var
|
|
1157
|
-
var
|
|
1222
|
+
var import_react17 = __toESM(require("react"));
|
|
1223
|
+
var import_semi_ui10 = require("@douyinfe/semi-ui");
|
|
1224
|
+
var import_semi_icons3 = require("@douyinfe/semi-icons");
|
|
1158
1225
|
|
|
1159
1226
|
// src/components/json-schema-editor/utils.ts
|
|
1160
1227
|
function getValueType(value) {
|
|
@@ -1176,117 +1243,54 @@ function getValueType(value) {
|
|
|
1176
1243
|
}
|
|
1177
1244
|
|
|
1178
1245
|
// src/components/constant-input/index.tsx
|
|
1179
|
-
var
|
|
1180
|
-
var
|
|
1181
|
-
var defaultStrategies = [
|
|
1182
|
-
{
|
|
1183
|
-
hit: (schema) => schema?.type === "string",
|
|
1184
|
-
Renderer: (props) => /* @__PURE__ */ import_react7.default.createElement(import_semi_ui5.Input, { placeholder: "Please Input String", size: "small", disabled: props.readonly, ...props })
|
|
1185
|
-
},
|
|
1186
|
-
{
|
|
1187
|
-
hit: (schema) => schema?.type === "number",
|
|
1188
|
-
Renderer: (props) => /* @__PURE__ */ import_react7.default.createElement(
|
|
1189
|
-
import_semi_ui5.InputNumber,
|
|
1190
|
-
{
|
|
1191
|
-
placeholder: "Please Input Number",
|
|
1192
|
-
size: "small",
|
|
1193
|
-
disabled: props.readonly,
|
|
1194
|
-
hideButtons: true,
|
|
1195
|
-
...props
|
|
1196
|
-
}
|
|
1197
|
-
)
|
|
1198
|
-
},
|
|
1199
|
-
{
|
|
1200
|
-
hit: (schema) => schema?.type === "integer",
|
|
1201
|
-
Renderer: (props) => /* @__PURE__ */ import_react7.default.createElement(
|
|
1202
|
-
import_semi_ui5.InputNumber,
|
|
1203
|
-
{
|
|
1204
|
-
placeholder: "Please Input Integer",
|
|
1205
|
-
size: "small",
|
|
1206
|
-
disabled: props.readonly,
|
|
1207
|
-
hideButtons: true,
|
|
1208
|
-
precision: 0,
|
|
1209
|
-
...props
|
|
1210
|
-
}
|
|
1211
|
-
)
|
|
1212
|
-
},
|
|
1213
|
-
{
|
|
1214
|
-
hit: (schema) => schema?.type === "boolean",
|
|
1215
|
-
Renderer: (props) => {
|
|
1216
|
-
const { value, onChange, ...rest } = props;
|
|
1217
|
-
return /* @__PURE__ */ import_react7.default.createElement(
|
|
1218
|
-
import_semi_ui5.Select,
|
|
1219
|
-
{
|
|
1220
|
-
placeholder: "Please Select Boolean",
|
|
1221
|
-
size: "small",
|
|
1222
|
-
disabled: props.readonly,
|
|
1223
|
-
optionList: [
|
|
1224
|
-
{ label: "True", value: 1 },
|
|
1225
|
-
{ label: "False", value: 0 }
|
|
1226
|
-
],
|
|
1227
|
-
value: value ? 1 : 0,
|
|
1228
|
-
onChange: (value2) => onChange?.(!!value2),
|
|
1229
|
-
...rest
|
|
1230
|
-
}
|
|
1231
|
-
);
|
|
1232
|
-
}
|
|
1233
|
-
}
|
|
1234
|
-
];
|
|
1246
|
+
var import_react16 = __toESM(require("react"));
|
|
1247
|
+
var import_semi_ui9 = require("@douyinfe/semi-ui");
|
|
1235
1248
|
function ConstantInput(props) {
|
|
1236
|
-
const {
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
schema
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
...rest
|
|
1244
|
-
} = props;
|
|
1245
|
-
const strategies = (0, import_react7.useMemo)(
|
|
1246
|
-
// user's extraStrategies first
|
|
1247
|
-
() => [...extraStrategies || [], ...defaultStrategies],
|
|
1248
|
-
[extraStrategies]
|
|
1249
|
-
);
|
|
1250
|
-
const Renderer2 = (0, import_react7.useMemo)(() => {
|
|
1251
|
-
const strategy = strategies.find((_strategy) => _strategy.hit(schema));
|
|
1249
|
+
const { value, onChange, schema, strategies, fallbackRenderer, readonly, ...rest } = props;
|
|
1250
|
+
const typeManager = useTypeManager();
|
|
1251
|
+
const Renderer2 = (0, import_react16.useMemo)(() => {
|
|
1252
|
+
const strategy = (strategies || []).find((_strategy) => _strategy.hit(schema));
|
|
1253
|
+
if (!strategy) {
|
|
1254
|
+
return typeManager.getTypeBySchema(schema)?.ConstantRenderer;
|
|
1255
|
+
}
|
|
1252
1256
|
return strategy?.Renderer;
|
|
1253
1257
|
}, [strategies, schema]);
|
|
1254
1258
|
if (!Renderer2) {
|
|
1255
1259
|
if (fallbackRenderer) {
|
|
1256
|
-
return
|
|
1260
|
+
return import_react16.default.createElement(fallbackRenderer, {
|
|
1257
1261
|
value,
|
|
1258
1262
|
onChange,
|
|
1259
1263
|
readonly,
|
|
1260
1264
|
...rest
|
|
1261
1265
|
});
|
|
1262
1266
|
}
|
|
1263
|
-
return /* @__PURE__ */
|
|
1267
|
+
return /* @__PURE__ */ import_react16.default.createElement(import_semi_ui9.Input, { size: "small", disabled: true, placeholder: "Unsupported type" });
|
|
1264
1268
|
}
|
|
1265
|
-
return /* @__PURE__ */
|
|
1269
|
+
return /* @__PURE__ */ import_react16.default.createElement(Renderer2, { value, onChange, readonly, ...rest });
|
|
1266
1270
|
}
|
|
1267
1271
|
|
|
1268
1272
|
// src/components/json-schema-editor/default-value.tsx
|
|
1269
1273
|
function DefaultValue(props) {
|
|
1270
1274
|
const { value, schema, type, onChange, placeholder, jsonFormatText } = props;
|
|
1271
|
-
const wrapperRef = (0,
|
|
1272
|
-
const JsonViewerRef = (0,
|
|
1273
|
-
const [internalJsonValue, setInternalJsonValue] = (0,
|
|
1275
|
+
const wrapperRef = (0, import_react17.useRef)(null);
|
|
1276
|
+
const JsonViewerRef = (0, import_react17.useRef)(null);
|
|
1277
|
+
const [internalJsonValue, setInternalJsonValue] = (0, import_react17.useState)(
|
|
1274
1278
|
getValueType(value) === "string" ? value : ""
|
|
1275
1279
|
);
|
|
1276
|
-
const handleJsonChange = (0,
|
|
1280
|
+
const handleJsonChange = (0, import_react17.useCallback)((val) => {
|
|
1277
1281
|
if (val !== internalJsonValue) {
|
|
1278
1282
|
setInternalJsonValue(val);
|
|
1279
1283
|
}
|
|
1280
1284
|
}, []);
|
|
1281
|
-
const handleEditComplete = (0,
|
|
1285
|
+
const handleEditComplete = (0, import_react17.useCallback)(() => {
|
|
1282
1286
|
onChange(internalJsonValue);
|
|
1283
1287
|
requestAnimationFrame(() => {
|
|
1284
1288
|
wrapperRef.current?.blur();
|
|
1285
1289
|
});
|
|
1286
1290
|
setJsonReadOnly(true);
|
|
1287
1291
|
}, [internalJsonValue, onChange]);
|
|
1288
|
-
const [jsonReadOnly, setJsonReadOnly] = (0,
|
|
1289
|
-
const handleFormatJson = (0,
|
|
1292
|
+
const [jsonReadOnly, setJsonReadOnly] = (0, import_react17.useState)(true);
|
|
1293
|
+
const handleFormatJson = (0, import_react17.useCallback)(() => {
|
|
1290
1294
|
try {
|
|
1291
1295
|
const parsed = JSON.parse(internalJsonValue);
|
|
1292
1296
|
const formatted = JSON.stringify(parsed, null, 4);
|
|
@@ -1296,16 +1300,16 @@ function DefaultValue(props) {
|
|
|
1296
1300
|
console.error("Invalid JSON:", error);
|
|
1297
1301
|
}
|
|
1298
1302
|
}, [internalJsonValue, onChange]);
|
|
1299
|
-
return type === "object" ? /* @__PURE__ */
|
|
1300
|
-
|
|
1303
|
+
return type === "object" ? /* @__PURE__ */ import_react17.default.createElement(import_react17.default.Fragment, null, /* @__PURE__ */ import_react17.default.createElement(JSONHeader, null, /* @__PURE__ */ import_react17.default.createElement(JSONHeaderLeft, null, "json"), /* @__PURE__ */ import_react17.default.createElement(JSONHeaderRight, null, /* @__PURE__ */ import_react17.default.createElement(import_semi_ui10.Tooltip, { content: jsonFormatText ?? "Format" }, /* @__PURE__ */ import_react17.default.createElement(
|
|
1304
|
+
import_semi_ui10.IconButton,
|
|
1301
1305
|
{
|
|
1302
|
-
icon: /* @__PURE__ */
|
|
1306
|
+
icon: /* @__PURE__ */ import_react17.default.createElement(import_semi_icons3.IconBrackets, { style: { color: "var(--semi-color-primary)" } }),
|
|
1303
1307
|
size: "small",
|
|
1304
1308
|
type: "tertiary",
|
|
1305
1309
|
theme: "borderless",
|
|
1306
1310
|
onClick: handleFormatJson
|
|
1307
1311
|
}
|
|
1308
|
-
)))), /* @__PURE__ */
|
|
1312
|
+
)))), /* @__PURE__ */ import_react17.default.createElement(
|
|
1309
1313
|
JSONViewerWrapper,
|
|
1310
1314
|
{
|
|
1311
1315
|
ref: wrapperRef,
|
|
@@ -1319,8 +1323,8 @@ function DefaultValue(props) {
|
|
|
1319
1323
|
setJsonReadOnly(false);
|
|
1320
1324
|
}
|
|
1321
1325
|
},
|
|
1322
|
-
/* @__PURE__ */
|
|
1323
|
-
|
|
1326
|
+
/* @__PURE__ */ import_react17.default.createElement(
|
|
1327
|
+
import_semi_ui10.JsonViewer,
|
|
1324
1328
|
{
|
|
1325
1329
|
ref: JsonViewerRef,
|
|
1326
1330
|
value: getValueType(value) === "string" ? value : "",
|
|
@@ -1337,7 +1341,7 @@ function DefaultValue(props) {
|
|
|
1337
1341
|
onChange: handleJsonChange
|
|
1338
1342
|
}
|
|
1339
1343
|
)
|
|
1340
|
-
)) : /* @__PURE__ */
|
|
1344
|
+
)) : /* @__PURE__ */ import_react17.default.createElement(ConstantInputWrapper, null, /* @__PURE__ */ import_react17.default.createElement(
|
|
1341
1345
|
ConstantInput,
|
|
1342
1346
|
{
|
|
1343
1347
|
value,
|
|
@@ -1349,14 +1353,14 @@ function DefaultValue(props) {
|
|
|
1349
1353
|
}
|
|
1350
1354
|
|
|
1351
1355
|
// src/components/json-schema-editor/components/blur-input.tsx
|
|
1352
|
-
var
|
|
1356
|
+
var import_react18 = __toESM(require("react"));
|
|
1353
1357
|
var import_input = __toESM(require("@douyinfe/semi-ui/lib/es/input"));
|
|
1354
1358
|
function BlurInput(props) {
|
|
1355
|
-
const [value, setValue] = (0,
|
|
1356
|
-
(0,
|
|
1359
|
+
const [value, setValue] = (0, import_react18.useState)("");
|
|
1360
|
+
(0, import_react18.useEffect)(() => {
|
|
1357
1361
|
setValue(props.value);
|
|
1358
1362
|
}, [props.value]);
|
|
1359
|
-
return /* @__PURE__ */
|
|
1363
|
+
return /* @__PURE__ */ import_react18.default.createElement(
|
|
1360
1364
|
import_input.default,
|
|
1361
1365
|
{
|
|
1362
1366
|
...props,
|
|
@@ -1376,7 +1380,7 @@ function JsonSchemaEditor(props) {
|
|
|
1376
1380
|
value,
|
|
1377
1381
|
onChangeProps
|
|
1378
1382
|
);
|
|
1379
|
-
return /* @__PURE__ */
|
|
1383
|
+
return /* @__PURE__ */ import_react19.default.createElement(UIContainer, { className: props.className }, /* @__PURE__ */ import_react19.default.createElement(UIProperties, null, propertyList.map((_property, index) => /* @__PURE__ */ import_react19.default.createElement(
|
|
1380
1384
|
PropertyEdit,
|
|
1381
1385
|
{
|
|
1382
1386
|
readonly,
|
|
@@ -1391,13 +1395,13 @@ function JsonSchemaEditor(props) {
|
|
|
1391
1395
|
onRemoveProperty(_property.key);
|
|
1392
1396
|
}
|
|
1393
1397
|
}
|
|
1394
|
-
))), /* @__PURE__ */
|
|
1395
|
-
|
|
1398
|
+
))), /* @__PURE__ */ import_react19.default.createElement(
|
|
1399
|
+
import_semi_ui11.Button,
|
|
1396
1400
|
{
|
|
1397
1401
|
disabled: readonly,
|
|
1398
1402
|
size: "small",
|
|
1399
1403
|
style: { marginTop: 10, marginLeft: 16 },
|
|
1400
|
-
icon: /* @__PURE__ */
|
|
1404
|
+
icon: /* @__PURE__ */ import_react19.default.createElement(import_semi_icons4.IconPlus, null),
|
|
1401
1405
|
onClick: onAddProperty
|
|
1402
1406
|
},
|
|
1403
1407
|
config?.addButtonText ?? "Add"
|
|
@@ -1418,10 +1422,10 @@ function PropertyEdit(props) {
|
|
|
1418
1422
|
$parentType = "",
|
|
1419
1423
|
$showLine
|
|
1420
1424
|
} = props;
|
|
1421
|
-
const [expand, setExpand] = (0,
|
|
1422
|
-
const [collapse, setCollapse] = (0,
|
|
1425
|
+
const [expand, setExpand] = (0, import_react19.useState)(false);
|
|
1426
|
+
const [collapse, setCollapse] = (0, import_react19.useState)(false);
|
|
1423
1427
|
const { name, type, items, default: defaultValue, description, isPropertyRequired } = value || {};
|
|
1424
|
-
const typeSelectorValue = (0,
|
|
1428
|
+
const typeSelectorValue = (0, import_react19.useMemo)(() => ({ type, items }), [type, items]);
|
|
1425
1429
|
const { propertyList, isDrilldownObject, onAddProperty, onRemoveProperty, onEditProperty } = usePropertiesEdit(value, onChangeProps);
|
|
1426
1430
|
const onChange = (key, _value) => {
|
|
1427
1431
|
onChangeProps?.({
|
|
@@ -1430,7 +1434,7 @@ function PropertyEdit(props) {
|
|
|
1430
1434
|
});
|
|
1431
1435
|
};
|
|
1432
1436
|
const showCollapse = isDrilldownObject && propertyList.length > 0;
|
|
1433
|
-
return /* @__PURE__ */
|
|
1437
|
+
return /* @__PURE__ */ import_react19.default.createElement(import_react19.default.Fragment, null, /* @__PURE__ */ import_react19.default.createElement(
|
|
1434
1438
|
UIPropertyLeft,
|
|
1435
1439
|
{
|
|
1436
1440
|
type,
|
|
@@ -1442,8 +1446,8 @@ function PropertyEdit(props) {
|
|
|
1442
1446
|
$parentExpand,
|
|
1443
1447
|
$parentType
|
|
1444
1448
|
},
|
|
1445
|
-
showCollapse && /* @__PURE__ */
|
|
1446
|
-
), /* @__PURE__ */
|
|
1449
|
+
showCollapse && /* @__PURE__ */ import_react19.default.createElement(UICollapseTrigger, { onClick: () => setCollapse((_collapse) => !_collapse) }, collapse ? /* @__PURE__ */ import_react19.default.createElement(import_semi_icons4.IconChevronDown, { size: "small" }) : /* @__PURE__ */ import_react19.default.createElement(import_semi_icons4.IconChevronRight, { size: "small" }))
|
|
1450
|
+
), /* @__PURE__ */ import_react19.default.createElement(UIPropertyRight, null, /* @__PURE__ */ import_react19.default.createElement(
|
|
1447
1451
|
UIPropertyMain,
|
|
1448
1452
|
{
|
|
1449
1453
|
$showCollapse: showCollapse,
|
|
@@ -1451,7 +1455,7 @@ function PropertyEdit(props) {
|
|
|
1451
1455
|
$expand: expand,
|
|
1452
1456
|
type
|
|
1453
1457
|
},
|
|
1454
|
-
/* @__PURE__ */
|
|
1458
|
+
/* @__PURE__ */ import_react19.default.createElement(UIRow, null, /* @__PURE__ */ import_react19.default.createElement(UIName, null, /* @__PURE__ */ import_react19.default.createElement(
|
|
1455
1459
|
BlurInput,
|
|
1456
1460
|
{
|
|
1457
1461
|
disabled: readonly,
|
|
@@ -1460,7 +1464,7 @@ function PropertyEdit(props) {
|
|
|
1460
1464
|
value: name,
|
|
1461
1465
|
onChange: (value2) => onChange("name", value2)
|
|
1462
1466
|
}
|
|
1463
|
-
)), /* @__PURE__ */
|
|
1467
|
+
)), /* @__PURE__ */ import_react19.default.createElement(UIType, null, /* @__PURE__ */ import_react19.default.createElement(
|
|
1464
1468
|
TypeSelector,
|
|
1465
1469
|
{
|
|
1466
1470
|
value: typeSelectorValue,
|
|
@@ -1472,47 +1476,47 @@ function PropertyEdit(props) {
|
|
|
1472
1476
|
});
|
|
1473
1477
|
}
|
|
1474
1478
|
}
|
|
1475
|
-
)), /* @__PURE__ */
|
|
1476
|
-
|
|
1479
|
+
)), /* @__PURE__ */ import_react19.default.createElement(UIRequired, null, /* @__PURE__ */ import_react19.default.createElement(
|
|
1480
|
+
import_semi_ui11.Checkbox,
|
|
1477
1481
|
{
|
|
1478
1482
|
disabled: readonly,
|
|
1479
1483
|
checked: isPropertyRequired,
|
|
1480
1484
|
onChange: (e) => onChange("isPropertyRequired", e.target.checked)
|
|
1481
1485
|
}
|
|
1482
|
-
)), /* @__PURE__ */
|
|
1483
|
-
|
|
1486
|
+
)), /* @__PURE__ */ import_react19.default.createElement(UIActions, null, /* @__PURE__ */ import_react19.default.createElement(
|
|
1487
|
+
import_semi_ui11.IconButton,
|
|
1484
1488
|
{
|
|
1485
1489
|
disabled: readonly,
|
|
1486
1490
|
size: "small",
|
|
1487
1491
|
theme: "borderless",
|
|
1488
|
-
icon: expand ? /* @__PURE__ */
|
|
1492
|
+
icon: expand ? /* @__PURE__ */ import_react19.default.createElement(import_semi_icons4.IconShrink, { size: "small" }) : /* @__PURE__ */ import_react19.default.createElement(import_semi_icons4.IconExpand, { size: "small" }),
|
|
1489
1493
|
onClick: () => {
|
|
1490
1494
|
setExpand((_expand) => !_expand);
|
|
1491
1495
|
}
|
|
1492
1496
|
}
|
|
1493
|
-
), isDrilldownObject && /* @__PURE__ */
|
|
1494
|
-
|
|
1497
|
+
), isDrilldownObject && /* @__PURE__ */ import_react19.default.createElement(
|
|
1498
|
+
import_semi_ui11.IconButton,
|
|
1495
1499
|
{
|
|
1496
1500
|
disabled: readonly,
|
|
1497
1501
|
size: "small",
|
|
1498
1502
|
theme: "borderless",
|
|
1499
|
-
icon: /* @__PURE__ */
|
|
1503
|
+
icon: /* @__PURE__ */ import_react19.default.createElement(IconAddChildren, null),
|
|
1500
1504
|
onClick: () => {
|
|
1501
1505
|
onAddProperty();
|
|
1502
1506
|
setCollapse(true);
|
|
1503
1507
|
}
|
|
1504
1508
|
}
|
|
1505
|
-
), /* @__PURE__ */
|
|
1506
|
-
|
|
1509
|
+
), /* @__PURE__ */ import_react19.default.createElement(
|
|
1510
|
+
import_semi_ui11.IconButton,
|
|
1507
1511
|
{
|
|
1508
1512
|
disabled: readonly,
|
|
1509
1513
|
size: "small",
|
|
1510
1514
|
theme: "borderless",
|
|
1511
|
-
icon: /* @__PURE__ */
|
|
1515
|
+
icon: /* @__PURE__ */ import_react19.default.createElement(import_semi_icons4.IconMinus, { size: "small" }),
|
|
1512
1516
|
onClick: onRemove
|
|
1513
1517
|
}
|
|
1514
1518
|
))),
|
|
1515
|
-
expand && /* @__PURE__ */
|
|
1519
|
+
expand && /* @__PURE__ */ import_react19.default.createElement(UIExpandDetail, null, /* @__PURE__ */ import_react19.default.createElement(UILabel, null, config?.descTitle ?? "Description"), /* @__PURE__ */ import_react19.default.createElement(
|
|
1516
1520
|
BlurInput,
|
|
1517
1521
|
{
|
|
1518
1522
|
disabled: readonly,
|
|
@@ -1521,7 +1525,7 @@ function PropertyEdit(props) {
|
|
|
1521
1525
|
onChange: (value2) => onChange("description", value2),
|
|
1522
1526
|
placeholder: config?.descPlaceholder ?? "Help LLM to understand the property"
|
|
1523
1527
|
}
|
|
1524
|
-
), $level === 0 && type && type !== "array" && /* @__PURE__ */
|
|
1528
|
+
), $level === 0 && type && type !== "array" && /* @__PURE__ */ import_react19.default.createElement(import_react19.default.Fragment, null, /* @__PURE__ */ import_react19.default.createElement(UILabel, { style: { marginTop: 10 } }, config?.defaultValueTitle ?? "Default Value"), /* @__PURE__ */ import_react19.default.createElement(DefaultValueWrapper, null, /* @__PURE__ */ import_react19.default.createElement(
|
|
1525
1529
|
DefaultValue,
|
|
1526
1530
|
{
|
|
1527
1531
|
value: defaultValue,
|
|
@@ -1532,7 +1536,7 @@ function PropertyEdit(props) {
|
|
|
1532
1536
|
onChange: (value2) => onChange("default", value2)
|
|
1533
1537
|
}
|
|
1534
1538
|
))))
|
|
1535
|
-
), showCollapse && /* @__PURE__ */
|
|
1539
|
+
), showCollapse && /* @__PURE__ */ import_react19.default.createElement(UICollapsible, { $collapse: collapse }, /* @__PURE__ */ import_react19.default.createElement(UIProperties, { $shrink: true }, propertyList.map((_property, index) => /* @__PURE__ */ import_react19.default.createElement(
|
|
1536
1540
|
PropertyEdit,
|
|
1537
1541
|
{
|
|
1538
1542
|
readonly,
|
|
@@ -1557,87 +1561,25 @@ function PropertyEdit(props) {
|
|
|
1557
1561
|
}
|
|
1558
1562
|
|
|
1559
1563
|
// src/components/batch-variable-selector/index.tsx
|
|
1560
|
-
var
|
|
1561
|
-
var
|
|
1564
|
+
var import_react20 = __toESM(require("react"));
|
|
1565
|
+
var import_editor4 = require("@flowgram.ai/editor");
|
|
1562
1566
|
var batchVariableSchema = {
|
|
1563
1567
|
type: "array",
|
|
1564
1568
|
extra: { weak: true }
|
|
1565
1569
|
};
|
|
1566
1570
|
function BatchVariableSelector(props) {
|
|
1567
|
-
return /* @__PURE__ */
|
|
1571
|
+
return /* @__PURE__ */ import_react20.default.createElement(import_editor4.PrivateScopeProvider, null, /* @__PURE__ */ import_react20.default.createElement(VariableSelector, { ...props, includeSchema: batchVariableSchema }));
|
|
1568
1572
|
}
|
|
1569
1573
|
|
|
1570
1574
|
// src/components/dynamic-value-input/index.tsx
|
|
1571
|
-
var
|
|
1572
|
-
var
|
|
1573
|
-
var
|
|
1574
|
-
var
|
|
1575
|
-
|
|
1576
|
-
// src/utils/format-legacy-refs/index.ts
|
|
1577
|
-
var import_lodash3 = require("lodash");
|
|
1578
|
-
function formatLegacyRefOnSubmit(value) {
|
|
1579
|
-
if ((0, import_lodash3.isObject)(value)) {
|
|
1580
|
-
if (isLegacyFlowRefValueSchema(value)) {
|
|
1581
|
-
return formatLegacyRefToNewRef(value);
|
|
1582
|
-
}
|
|
1583
|
-
return Object.fromEntries(
|
|
1584
|
-
Object.entries(value).map(([key, value2]) => [
|
|
1585
|
-
key,
|
|
1586
|
-
formatLegacyRefOnSubmit(value2)
|
|
1587
|
-
])
|
|
1588
|
-
);
|
|
1589
|
-
}
|
|
1590
|
-
if (Array.isArray(value)) {
|
|
1591
|
-
return value.map(formatLegacyRefOnSubmit);
|
|
1592
|
-
}
|
|
1593
|
-
return value;
|
|
1594
|
-
}
|
|
1595
|
-
function formatLegacyRefOnInit(value) {
|
|
1596
|
-
if ((0, import_lodash3.isObject)(value)) {
|
|
1597
|
-
if (isNewFlowRefValueSchema(value)) {
|
|
1598
|
-
return formatNewRefToLegacyRef(value);
|
|
1599
|
-
}
|
|
1600
|
-
return Object.fromEntries(
|
|
1601
|
-
Object.entries(value).map(([key, value2]) => [
|
|
1602
|
-
key,
|
|
1603
|
-
formatLegacyRefOnInit(value2)
|
|
1604
|
-
])
|
|
1605
|
-
);
|
|
1606
|
-
}
|
|
1607
|
-
if (Array.isArray(value)) {
|
|
1608
|
-
return value.map(formatLegacyRefOnInit);
|
|
1609
|
-
}
|
|
1610
|
-
return value;
|
|
1611
|
-
}
|
|
1612
|
-
function isLegacyFlowRefValueSchema(value) {
|
|
1613
|
-
return (0, import_lodash3.isObject)(value) && Object.keys(value).length === 2 && value.type === "ref" && typeof value.content === "string";
|
|
1614
|
-
}
|
|
1615
|
-
function isNewFlowRefValueSchema(value) {
|
|
1616
|
-
return (0, import_lodash3.isObject)(value) && Object.keys(value).length === 2 && value.type === "ref" && Array.isArray(value.content);
|
|
1617
|
-
}
|
|
1618
|
-
function formatLegacyRefToNewRef(value) {
|
|
1619
|
-
const keyPath = value.content.split(".");
|
|
1620
|
-
if (keyPath[1] === "outputs") {
|
|
1621
|
-
return {
|
|
1622
|
-
type: "ref",
|
|
1623
|
-
content: [`${keyPath[0]}.${keyPath[1]}`, ...keyPath.length > 2 ? keyPath.slice(2) : []]
|
|
1624
|
-
};
|
|
1625
|
-
}
|
|
1626
|
-
return {
|
|
1627
|
-
type: "ref",
|
|
1628
|
-
content: keyPath
|
|
1629
|
-
};
|
|
1630
|
-
}
|
|
1631
|
-
function formatNewRefToLegacyRef(value) {
|
|
1632
|
-
return {
|
|
1633
|
-
type: "ref",
|
|
1634
|
-
content: value.content.join(".")
|
|
1635
|
-
};
|
|
1636
|
-
}
|
|
1575
|
+
var import_react22 = __toESM(require("react"));
|
|
1576
|
+
var import_json_schema5 = require("@flowgram.ai/json-schema");
|
|
1577
|
+
var import_semi_ui12 = require("@douyinfe/semi-ui");
|
|
1578
|
+
var import_semi_icons5 = require("@douyinfe/semi-icons");
|
|
1637
1579
|
|
|
1638
1580
|
// src/components/dynamic-value-input/styles.tsx
|
|
1639
|
-
var
|
|
1640
|
-
var UIContainer2 =
|
|
1581
|
+
var import_styled_components4 = __toESM(require("styled-components"));
|
|
1582
|
+
var UIContainer2 = import_styled_components4.default.div`
|
|
1641
1583
|
display: flex;
|
|
1642
1584
|
align-items: center;
|
|
1643
1585
|
border-radius: 4px;
|
|
@@ -1647,7 +1589,7 @@ var UIContainer2 = import_styled_components3.default.div`
|
|
|
1647
1589
|
|
|
1648
1590
|
background-color: var(--semi-color-fill-0);
|
|
1649
1591
|
`;
|
|
1650
|
-
var UIMain =
|
|
1592
|
+
var UIMain = import_styled_components4.default.div`
|
|
1651
1593
|
flex-grow: 1;
|
|
1652
1594
|
overflow: hidden;
|
|
1653
1595
|
min-width: 0;
|
|
@@ -1665,14 +1607,14 @@ var UIMain = import_styled_components3.default.div`
|
|
|
1665
1607
|
border-radius: 0;
|
|
1666
1608
|
}
|
|
1667
1609
|
`;
|
|
1668
|
-
var UIType2 =
|
|
1610
|
+
var UIType2 = import_styled_components4.default.div`
|
|
1669
1611
|
border-right: 1px solid #e5e5e5;
|
|
1670
1612
|
|
|
1671
1613
|
& .semi-button {
|
|
1672
1614
|
border-radius: 0;
|
|
1673
1615
|
}
|
|
1674
1616
|
`;
|
|
1675
|
-
var UITrigger =
|
|
1617
|
+
var UITrigger = import_styled_components4.default.div`
|
|
1676
1618
|
border-left: 1px solid #e5e5e5;
|
|
1677
1619
|
|
|
1678
1620
|
& .semi-button {
|
|
@@ -1680,6 +1622,39 @@ var UITrigger = import_styled_components3.default.div`
|
|
|
1680
1622
|
}
|
|
1681
1623
|
`;
|
|
1682
1624
|
|
|
1625
|
+
// src/components/dynamic-value-input/hooks.ts
|
|
1626
|
+
var import_react21 = require("react");
|
|
1627
|
+
var import_editor5 = require("@flowgram.ai/editor");
|
|
1628
|
+
function useRefVariable(value) {
|
|
1629
|
+
const available = (0, import_editor5.useScopeAvailable)();
|
|
1630
|
+
const refVariable = (0, import_react21.useMemo)(() => {
|
|
1631
|
+
if (value?.type === "ref") {
|
|
1632
|
+
return available.getByKeyPath(value.content);
|
|
1633
|
+
}
|
|
1634
|
+
}, [value, available]);
|
|
1635
|
+
return refVariable;
|
|
1636
|
+
}
|
|
1637
|
+
function useSelectSchema(schemaFromProps, constantProps, value) {
|
|
1638
|
+
let defaultSelectSchema = schemaFromProps || constantProps?.schema || { type: "string" };
|
|
1639
|
+
if (value?.type === "constant") {
|
|
1640
|
+
defaultSelectSchema = value?.schema || defaultSelectSchema;
|
|
1641
|
+
}
|
|
1642
|
+
const [selectSchema, setSelectSchema] = (0, import_react21.useState)(defaultSelectSchema);
|
|
1643
|
+
return [selectSchema, setSelectSchema];
|
|
1644
|
+
}
|
|
1645
|
+
function useIncludeSchema(schemaFromProps) {
|
|
1646
|
+
const includeSchema = (0, import_react21.useMemo)(() => {
|
|
1647
|
+
if (!schemaFromProps) {
|
|
1648
|
+
return;
|
|
1649
|
+
}
|
|
1650
|
+
if (schemaFromProps?.type === "number") {
|
|
1651
|
+
return [schemaFromProps, { type: "integer" }];
|
|
1652
|
+
}
|
|
1653
|
+
return { ...schemaFromProps, extra: { ...schemaFromProps?.extra, weak: true } };
|
|
1654
|
+
}, [schemaFromProps]);
|
|
1655
|
+
return includeSchema;
|
|
1656
|
+
}
|
|
1657
|
+
|
|
1683
1658
|
// src/components/dynamic-value-input/index.tsx
|
|
1684
1659
|
function DynamicValueInput({
|
|
1685
1660
|
value,
|
|
@@ -1689,44 +1664,46 @@ function DynamicValueInput({
|
|
|
1689
1664
|
schema: schemaFromProps,
|
|
1690
1665
|
constantProps
|
|
1691
1666
|
}) {
|
|
1692
|
-
const
|
|
1693
|
-
const
|
|
1694
|
-
|
|
1695
|
-
return available.getByKeyPath(value.content);
|
|
1696
|
-
}
|
|
1697
|
-
}, [value, available]);
|
|
1698
|
-
const [selectSchema, setSelectSchema] = (0, import_react12.useState)(
|
|
1699
|
-
schemaFromProps || constantProps?.schema || { type: "string" }
|
|
1700
|
-
);
|
|
1667
|
+
const refVariable = useRefVariable(value);
|
|
1668
|
+
const [selectSchema, setSelectSchema] = useSelectSchema(schemaFromProps, constantProps, value);
|
|
1669
|
+
const includeSchema = useIncludeSchema(schemaFromProps);
|
|
1701
1670
|
const renderTypeSelector = () => {
|
|
1702
1671
|
if (schemaFromProps) {
|
|
1703
|
-
return /* @__PURE__ */
|
|
1672
|
+
return /* @__PURE__ */ import_react22.default.createElement(TypeSelector, { value: schemaFromProps, readonly: true });
|
|
1704
1673
|
}
|
|
1705
1674
|
if (value?.type === "ref") {
|
|
1706
|
-
const schema = refVariable?.type ? JsonSchemaUtils.astToSchema(refVariable?.type) : void 0;
|
|
1707
|
-
return /* @__PURE__ */
|
|
1675
|
+
const schema = refVariable?.type ? import_json_schema5.JsonSchemaUtils.astToSchema(refVariable?.type) : void 0;
|
|
1676
|
+
return /* @__PURE__ */ import_react22.default.createElement(TypeSelector, { value: schema, readonly: true });
|
|
1708
1677
|
}
|
|
1709
|
-
return /* @__PURE__ */
|
|
1678
|
+
return /* @__PURE__ */ import_react22.default.createElement(
|
|
1710
1679
|
TypeSelector,
|
|
1711
1680
|
{
|
|
1712
1681
|
value: selectSchema,
|
|
1713
|
-
onChange: (_v) =>
|
|
1682
|
+
onChange: (_v) => {
|
|
1683
|
+
setSelectSchema(_v || { type: "string" });
|
|
1684
|
+
let content;
|
|
1685
|
+
if (_v?.type === "object") {
|
|
1686
|
+
content = "{}";
|
|
1687
|
+
}
|
|
1688
|
+
if (_v?.type === "array") {
|
|
1689
|
+
content = "[]";
|
|
1690
|
+
}
|
|
1691
|
+
if (_v?.type === "boolean") {
|
|
1692
|
+
content = false;
|
|
1693
|
+
}
|
|
1694
|
+
onChange({
|
|
1695
|
+
type: "constant",
|
|
1696
|
+
content,
|
|
1697
|
+
schema: _v || { type: "string" }
|
|
1698
|
+
});
|
|
1699
|
+
},
|
|
1714
1700
|
readonly
|
|
1715
1701
|
}
|
|
1716
1702
|
);
|
|
1717
1703
|
};
|
|
1718
|
-
const includeSchema = (0, import_react12.useMemo)(() => {
|
|
1719
|
-
if (!schemaFromProps) {
|
|
1720
|
-
return;
|
|
1721
|
-
}
|
|
1722
|
-
if (schemaFromProps?.type === "number") {
|
|
1723
|
-
return [schemaFromProps, { type: "integer" }];
|
|
1724
|
-
}
|
|
1725
|
-
return { ...schemaFromProps, extra: { ...schemaFromProps?.extra, weak: true } };
|
|
1726
|
-
}, [schemaFromProps]);
|
|
1727
1704
|
const renderMain = () => {
|
|
1728
1705
|
if (value?.type === "ref") {
|
|
1729
|
-
return /* @__PURE__ */
|
|
1706
|
+
return /* @__PURE__ */ import_react22.default.createElement(
|
|
1730
1707
|
VariableSelector,
|
|
1731
1708
|
{
|
|
1732
1709
|
style: { width: "100%" },
|
|
@@ -1738,7 +1715,7 @@ function DynamicValueInput({
|
|
|
1738
1715
|
);
|
|
1739
1716
|
}
|
|
1740
1717
|
const constantSchema = schemaFromProps || selectSchema || { type: "string" };
|
|
1741
|
-
return /* @__PURE__ */
|
|
1718
|
+
return /* @__PURE__ */ import_react22.default.createElement(
|
|
1742
1719
|
ConstantInput,
|
|
1743
1720
|
{
|
|
1744
1721
|
value: value?.content,
|
|
@@ -1746,7 +1723,7 @@ function DynamicValueInput({
|
|
|
1746
1723
|
schema: constantSchema || { type: "string" },
|
|
1747
1724
|
readonly,
|
|
1748
1725
|
strategies: [...constantProps?.strategies || []],
|
|
1749
|
-
fallbackRenderer: () => /* @__PURE__ */
|
|
1726
|
+
fallbackRenderer: () => /* @__PURE__ */ import_react22.default.createElement(
|
|
1750
1727
|
VariableSelector,
|
|
1751
1728
|
{
|
|
1752
1729
|
style: { width: "100%" },
|
|
@@ -1759,7 +1736,7 @@ function DynamicValueInput({
|
|
|
1759
1736
|
}
|
|
1760
1737
|
);
|
|
1761
1738
|
};
|
|
1762
|
-
const renderTrigger = () => /* @__PURE__ */
|
|
1739
|
+
const renderTrigger = () => /* @__PURE__ */ import_react22.default.createElement(
|
|
1763
1740
|
VariableSelector,
|
|
1764
1741
|
{
|
|
1765
1742
|
style: { width: "100%" },
|
|
@@ -1767,31 +1744,31 @@ function DynamicValueInput({
|
|
|
1767
1744
|
onChange: (_v) => onChange({ type: "ref", content: _v }),
|
|
1768
1745
|
includeSchema,
|
|
1769
1746
|
readonly,
|
|
1770
|
-
triggerRender: () => /* @__PURE__ */
|
|
1747
|
+
triggerRender: () => /* @__PURE__ */ import_react22.default.createElement(import_semi_ui12.IconButton, { disabled: readonly, size: "small", icon: /* @__PURE__ */ import_react22.default.createElement(import_semi_icons5.IconSetting, { size: "small" }) })
|
|
1771
1748
|
}
|
|
1772
1749
|
);
|
|
1773
|
-
return /* @__PURE__ */
|
|
1750
|
+
return /* @__PURE__ */ import_react22.default.createElement(UIContainer2, { style }, /* @__PURE__ */ import_react22.default.createElement(UIType2, null, renderTypeSelector()), /* @__PURE__ */ import_react22.default.createElement(UIMain, null, renderMain()), /* @__PURE__ */ import_react22.default.createElement(UITrigger, null, renderTrigger()));
|
|
1774
1751
|
}
|
|
1775
1752
|
|
|
1776
1753
|
// src/components/condition-row/index.tsx
|
|
1777
|
-
var
|
|
1778
|
-
var
|
|
1754
|
+
var import_react25 = __toESM(require("react"));
|
|
1755
|
+
var import_semi_ui14 = require("@douyinfe/semi-ui");
|
|
1779
1756
|
|
|
1780
1757
|
// src/components/condition-row/styles.tsx
|
|
1781
|
-
var
|
|
1782
|
-
var UIContainer3 =
|
|
1758
|
+
var import_styled_components5 = __toESM(require("styled-components"));
|
|
1759
|
+
var UIContainer3 = import_styled_components5.default.div`
|
|
1783
1760
|
display: flex;
|
|
1784
1761
|
align-items: center;
|
|
1785
1762
|
gap: 4px;
|
|
1786
1763
|
`;
|
|
1787
|
-
var UIOperator =
|
|
1788
|
-
var UILeft =
|
|
1764
|
+
var UIOperator = import_styled_components5.default.div``;
|
|
1765
|
+
var UILeft = import_styled_components5.default.div`
|
|
1789
1766
|
width: 100%;
|
|
1790
1767
|
`;
|
|
1791
|
-
var UIRight =
|
|
1768
|
+
var UIRight = import_styled_components5.default.div`
|
|
1792
1769
|
width: 100%;
|
|
1793
1770
|
`;
|
|
1794
|
-
var UIValues =
|
|
1771
|
+
var UIValues = import_styled_components5.default.div`
|
|
1795
1772
|
flex-grow: 1;
|
|
1796
1773
|
display: flex;
|
|
1797
1774
|
flex-direction: column;
|
|
@@ -1800,8 +1777,9 @@ var UIValues = import_styled_components4.default.div`
|
|
|
1800
1777
|
`;
|
|
1801
1778
|
|
|
1802
1779
|
// src/components/condition-row/hooks/useRule.ts
|
|
1803
|
-
var
|
|
1804
|
-
var
|
|
1780
|
+
var import_react23 = require("react");
|
|
1781
|
+
var import_json_schema6 = require("@flowgram.ai/json-schema");
|
|
1782
|
+
var import_editor6 = require("@flowgram.ai/editor");
|
|
1805
1783
|
|
|
1806
1784
|
// src/components/condition-row/constants.ts
|
|
1807
1785
|
var rules = {
|
|
@@ -1921,43 +1899,44 @@ var opConfigs = {
|
|
|
1921
1899
|
|
|
1922
1900
|
// src/components/condition-row/hooks/useRule.ts
|
|
1923
1901
|
function useRule(left) {
|
|
1924
|
-
const available = (0,
|
|
1925
|
-
const variable = (0,
|
|
1902
|
+
const available = (0, import_editor6.useScopeAvailable)();
|
|
1903
|
+
const variable = (0, import_react23.useMemo)(() => {
|
|
1926
1904
|
if (!left) return void 0;
|
|
1927
1905
|
return available.getByKeyPath(left.content);
|
|
1928
1906
|
}, [available, left]);
|
|
1929
|
-
const rule = (0,
|
|
1907
|
+
const rule = (0, import_react23.useMemo)(() => {
|
|
1930
1908
|
if (!variable) return void 0;
|
|
1931
|
-
const schema = JsonSchemaUtils.astToSchema(variable.type, { drilldown: false });
|
|
1909
|
+
const schema = import_json_schema6.JsonSchemaUtils.astToSchema(variable.type, { drilldown: false });
|
|
1932
1910
|
return rules[schema?.type];
|
|
1933
1911
|
}, [variable?.type]);
|
|
1934
1912
|
return { rule };
|
|
1935
1913
|
}
|
|
1936
1914
|
|
|
1937
1915
|
// src/components/condition-row/hooks/useOp.tsx
|
|
1938
|
-
var
|
|
1939
|
-
var
|
|
1940
|
-
var
|
|
1941
|
-
function useOp({ rule, op, onChange }) {
|
|
1942
|
-
const
|
|
1916
|
+
var import_react24 = __toESM(require("react"));
|
|
1917
|
+
var import_semi_ui13 = require("@douyinfe/semi-ui");
|
|
1918
|
+
var import_semi_icons6 = require("@douyinfe/semi-icons");
|
|
1919
|
+
function useOp({ rule, op, onChange, readonly }) {
|
|
1920
|
+
const options = (0, import_react24.useMemo)(
|
|
1943
1921
|
() => Object.keys(rule || {}).map((_op) => ({
|
|
1944
1922
|
...opConfigs[_op] || {},
|
|
1945
1923
|
value: _op
|
|
1946
1924
|
})),
|
|
1947
1925
|
[rule]
|
|
1948
1926
|
);
|
|
1949
|
-
const opConfig = (0,
|
|
1950
|
-
const renderOpSelect = () => /* @__PURE__ */
|
|
1951
|
-
|
|
1927
|
+
const opConfig = (0, import_react24.useMemo)(() => opConfigs[op], [op]);
|
|
1928
|
+
const renderOpSelect = () => /* @__PURE__ */ import_react24.default.createElement(
|
|
1929
|
+
import_semi_ui13.Select,
|
|
1952
1930
|
{
|
|
1953
1931
|
style: { height: 22 },
|
|
1932
|
+
disabled: readonly,
|
|
1954
1933
|
size: "small",
|
|
1955
1934
|
value: op,
|
|
1956
|
-
optionList:
|
|
1935
|
+
optionList: options,
|
|
1957
1936
|
onChange: (v) => {
|
|
1958
1937
|
onChange(v);
|
|
1959
1938
|
},
|
|
1960
|
-
triggerRender: ({ value }) => /* @__PURE__ */
|
|
1939
|
+
triggerRender: ({ value }) => /* @__PURE__ */ import_react24.default.createElement(import_semi_ui13.Button, { size: "small", disabled: !rule }, opConfig?.abbreviation || /* @__PURE__ */ import_react24.default.createElement(import_semi_icons6.IconChevronDownStroked, { size: "small" }))
|
|
1961
1940
|
}
|
|
1962
1941
|
);
|
|
1963
1942
|
return { renderOpSelect, opConfig };
|
|
@@ -1970,13 +1949,14 @@ function ConditionRow({ style, value, onChange, readonly }) {
|
|
|
1970
1949
|
const { renderOpSelect, opConfig } = useOp({
|
|
1971
1950
|
rule,
|
|
1972
1951
|
op: operator,
|
|
1973
|
-
onChange: (v) => onChange({ ...value, operator: v })
|
|
1952
|
+
onChange: (v) => onChange({ ...value, operator: v }),
|
|
1953
|
+
readonly
|
|
1974
1954
|
});
|
|
1975
|
-
const targetSchema = (0,
|
|
1955
|
+
const targetSchema = (0, import_react25.useMemo)(() => {
|
|
1976
1956
|
const targetType = rule?.[operator] || null;
|
|
1977
1957
|
return targetType ? { type: targetType, extra: { weak: true } } : null;
|
|
1978
1958
|
}, [rule, opConfig]);
|
|
1979
|
-
return /* @__PURE__ */
|
|
1959
|
+
return /* @__PURE__ */ import_react25.default.createElement(UIContainer3, { style }, /* @__PURE__ */ import_react25.default.createElement(UIOperator, null, renderOpSelect()), /* @__PURE__ */ import_react25.default.createElement(UIValues, null, /* @__PURE__ */ import_react25.default.createElement(UILeft, null, /* @__PURE__ */ import_react25.default.createElement(
|
|
1980
1960
|
VariableSelector,
|
|
1981
1961
|
{
|
|
1982
1962
|
readonly,
|
|
@@ -1990,7 +1970,7 @@ function ConditionRow({ style, value, onChange, readonly }) {
|
|
|
1990
1970
|
}
|
|
1991
1971
|
})
|
|
1992
1972
|
}
|
|
1993
|
-
)), /* @__PURE__ */
|
|
1973
|
+
)), /* @__PURE__ */ import_react25.default.createElement(UIRight, null, targetSchema ? /* @__PURE__ */ import_react25.default.createElement(
|
|
1994
1974
|
DynamicValueInput,
|
|
1995
1975
|
{
|
|
1996
1976
|
readonly: readonly || !rule,
|
|
@@ -1998,8 +1978,8 @@ function ConditionRow({ style, value, onChange, readonly }) {
|
|
|
1998
1978
|
schema: targetSchema,
|
|
1999
1979
|
onChange: (v) => onChange({ ...value, right: v })
|
|
2000
1980
|
}
|
|
2001
|
-
) : /* @__PURE__ */
|
|
2002
|
-
|
|
1981
|
+
) : /* @__PURE__ */ import_react25.default.createElement(
|
|
1982
|
+
import_semi_ui14.Input,
|
|
2003
1983
|
{
|
|
2004
1984
|
size: "small",
|
|
2005
1985
|
disabled: true,
|
|
@@ -2010,14 +1990,14 @@ function ConditionRow({ style, value, onChange, readonly }) {
|
|
|
2010
1990
|
}
|
|
2011
1991
|
|
|
2012
1992
|
// src/components/batch-outputs/index.tsx
|
|
2013
|
-
var
|
|
2014
|
-
var
|
|
2015
|
-
var
|
|
1993
|
+
var import_react27 = __toESM(require("react"));
|
|
1994
|
+
var import_semi_ui15 = require("@douyinfe/semi-ui");
|
|
1995
|
+
var import_semi_icons7 = require("@douyinfe/semi-icons");
|
|
2016
1996
|
|
|
2017
1997
|
// src/hooks/use-object-list/index.tsx
|
|
2018
|
-
var
|
|
1998
|
+
var import_react26 = require("react");
|
|
2019
1999
|
var import_nanoid = require("nanoid");
|
|
2020
|
-
var
|
|
2000
|
+
var import_lodash3 = require("lodash");
|
|
2021
2001
|
function genId2() {
|
|
2022
2002
|
return (0, import_nanoid.nanoid)();
|
|
2023
2003
|
}
|
|
@@ -2026,12 +2006,12 @@ function useObjectList({
|
|
|
2026
2006
|
onChange,
|
|
2027
2007
|
sortIndexKey
|
|
2028
2008
|
}) {
|
|
2029
|
-
const [list, setList] = (0,
|
|
2030
|
-
(0,
|
|
2009
|
+
const [list, setList] = (0, import_react26.useState)([]);
|
|
2010
|
+
(0, import_react26.useEffect)(() => {
|
|
2031
2011
|
setList((_prevList) => {
|
|
2032
|
-
const newKeys = Object.entries(value || {}).sort((a, b) => (0,
|
|
2012
|
+
const newKeys = Object.entries(value || {}).sort((a, b) => (0, import_lodash3.get)(a[1], sortIndexKey || 0) - (0, import_lodash3.get)(b[1], sortIndexKey || 0)).map(([key]) => key);
|
|
2033
2013
|
const oldKeys = _prevList.map((item) => item.key).filter(Boolean);
|
|
2034
|
-
const addKeys = (0,
|
|
2014
|
+
const addKeys = (0, import_lodash3.difference)(newKeys, oldKeys);
|
|
2035
2015
|
return _prevList.filter((item) => !item.key || newKeys.includes(item.key)).map((item) => ({
|
|
2036
2016
|
id: item.id,
|
|
2037
2017
|
key: item.key,
|
|
@@ -2067,8 +2047,8 @@ function useObjectList({
|
|
|
2067
2047
|
onChange(
|
|
2068
2048
|
Object.fromEntries(
|
|
2069
2049
|
nextList.filter((item) => item.key).map((item) => [item.key, item.value]).map((_res, idx) => {
|
|
2070
|
-
if ((0,
|
|
2071
|
-
(0,
|
|
2050
|
+
if ((0, import_lodash3.isObject)(_res[1]) && sortIndexKey) {
|
|
2051
|
+
(0, import_lodash3.set)(_res[1], sortIndexKey, idx);
|
|
2072
2052
|
}
|
|
2073
2053
|
return _res;
|
|
2074
2054
|
})
|
|
@@ -2111,14 +2091,14 @@ function useObjectList({
|
|
|
2111
2091
|
}
|
|
2112
2092
|
|
|
2113
2093
|
// src/components/batch-outputs/styles.tsx
|
|
2114
|
-
var
|
|
2115
|
-
var UIRows =
|
|
2094
|
+
var import_styled_components6 = __toESM(require("styled-components"));
|
|
2095
|
+
var UIRows = import_styled_components6.default.div`
|
|
2116
2096
|
display: flex;
|
|
2117
2097
|
flex-direction: column;
|
|
2118
2098
|
gap: 10px;
|
|
2119
2099
|
margin-bottom: 10px;
|
|
2120
2100
|
`;
|
|
2121
|
-
var UIRow2 =
|
|
2101
|
+
var UIRow2 = import_styled_components6.default.div`
|
|
2122
2102
|
display: flex;
|
|
2123
2103
|
align-items: center;
|
|
2124
2104
|
gap: 5px;
|
|
@@ -2128,8 +2108,8 @@ var UIRow2 = import_styled_components5.default.div`
|
|
|
2128
2108
|
function BatchOutputs(props) {
|
|
2129
2109
|
const { readonly, style } = props;
|
|
2130
2110
|
const { list, add, updateKey, updateValue, remove } = useObjectList(props);
|
|
2131
|
-
return /* @__PURE__ */
|
|
2132
|
-
|
|
2111
|
+
return /* @__PURE__ */ import_react27.default.createElement("div", null, /* @__PURE__ */ import_react27.default.createElement(UIRows, { style }, list.map((item) => /* @__PURE__ */ import_react27.default.createElement(UIRow2, { key: item.id }, /* @__PURE__ */ import_react27.default.createElement(
|
|
2112
|
+
import_semi_ui15.Input,
|
|
2133
2113
|
{
|
|
2134
2114
|
style: { width: 100 },
|
|
2135
2115
|
disabled: readonly,
|
|
@@ -2137,7 +2117,7 @@ function BatchOutputs(props) {
|
|
|
2137
2117
|
value: item.key,
|
|
2138
2118
|
onChange: (v) => updateKey(item.id, v)
|
|
2139
2119
|
}
|
|
2140
|
-
), /* @__PURE__ */
|
|
2120
|
+
), /* @__PURE__ */ import_react27.default.createElement(
|
|
2141
2121
|
VariableSelector,
|
|
2142
2122
|
{
|
|
2143
2123
|
style: { flexGrow: 1 },
|
|
@@ -2145,44 +2125,44 @@ function BatchOutputs(props) {
|
|
|
2145
2125
|
value: item.value?.content,
|
|
2146
2126
|
onChange: (v) => updateValue(item.id, { type: "ref", content: v })
|
|
2147
2127
|
}
|
|
2148
|
-
), /* @__PURE__ */
|
|
2149
|
-
|
|
2128
|
+
), /* @__PURE__ */ import_react27.default.createElement(
|
|
2129
|
+
import_semi_ui15.Button,
|
|
2150
2130
|
{
|
|
2151
2131
|
disabled: readonly,
|
|
2152
|
-
icon: /* @__PURE__ */
|
|
2132
|
+
icon: /* @__PURE__ */ import_react27.default.createElement(import_semi_icons7.IconDelete, null),
|
|
2153
2133
|
size: "small",
|
|
2154
2134
|
onClick: () => remove(item.id)
|
|
2155
2135
|
}
|
|
2156
|
-
)))), /* @__PURE__ */
|
|
2136
|
+
)))), /* @__PURE__ */ import_react27.default.createElement(import_semi_ui15.Button, { disabled: readonly, icon: /* @__PURE__ */ import_react27.default.createElement(import_semi_icons7.IconPlus, null), size: "small", onClick: add }, "Add"));
|
|
2157
2137
|
}
|
|
2158
2138
|
|
|
2159
2139
|
// src/components/prompt-editor/index.tsx
|
|
2160
|
-
var
|
|
2161
|
-
var
|
|
2140
|
+
var import_react34 = __toESM(require("react"));
|
|
2141
|
+
var import_react35 = require("@coze-editor/editor/react");
|
|
2162
2142
|
var import_preset_prompt2 = __toESM(require("@coze-editor/editor/preset-prompt"));
|
|
2163
2143
|
|
|
2164
2144
|
// src/components/prompt-editor/styles.tsx
|
|
2165
|
-
var
|
|
2166
|
-
var UIContainer4 =
|
|
2145
|
+
var import_styled_components7 = __toESM(require("styled-components"));
|
|
2146
|
+
var UIContainer4 = import_styled_components7.default.div`
|
|
2167
2147
|
background-color: var(--semi-color-fill-0);
|
|
2168
2148
|
padding-left: 10px;
|
|
2169
2149
|
padding-right: 6px;
|
|
2170
2150
|
|
|
2171
|
-
${({ $hasError }) => $hasError &&
|
|
2151
|
+
${({ $hasError }) => $hasError && import_styled_components7.css`
|
|
2172
2152
|
border: 1px solid var(--semi-color-danger-6);
|
|
2173
2153
|
`}
|
|
2174
2154
|
`;
|
|
2175
2155
|
|
|
2176
2156
|
// src/components/prompt-editor/extensions/markdown.tsx
|
|
2177
|
-
var
|
|
2178
|
-
var
|
|
2179
|
-
var
|
|
2180
|
-
var
|
|
2157
|
+
var import_react28 = require("react");
|
|
2158
|
+
var import_react29 = require("@coze-editor/editor/react");
|
|
2159
|
+
var import_editor7 = require("@coze-editor/editor");
|
|
2160
|
+
var import_view2 = require("@codemirror/view");
|
|
2181
2161
|
function MarkdownHighlight() {
|
|
2182
|
-
const injector = (0,
|
|
2183
|
-
(0,
|
|
2162
|
+
const injector = (0, import_react29.useInjector)();
|
|
2163
|
+
(0, import_react28.useLayoutEffect)(
|
|
2184
2164
|
() => injector.inject([
|
|
2185
|
-
|
|
2165
|
+
import_editor7.astDecorator.whole.of((cursor) => {
|
|
2186
2166
|
if (cursor.name.startsWith("ATXHeading")) {
|
|
2187
2167
|
return {
|
|
2188
2168
|
type: "className",
|
|
@@ -2208,7 +2188,7 @@ function MarkdownHighlight() {
|
|
|
2208
2188
|
};
|
|
2209
2189
|
}
|
|
2210
2190
|
}),
|
|
2211
|
-
|
|
2191
|
+
import_view2.EditorView.theme({
|
|
2212
2192
|
".heading": {
|
|
2213
2193
|
color: "#00818C",
|
|
2214
2194
|
fontWeight: "bold"
|
|
@@ -2231,26 +2211,26 @@ function MarkdownHighlight() {
|
|
|
2231
2211
|
var markdown_default = MarkdownHighlight;
|
|
2232
2212
|
|
|
2233
2213
|
// src/components/prompt-editor/extensions/language-support.tsx
|
|
2234
|
-
var
|
|
2235
|
-
var
|
|
2214
|
+
var import_react30 = require("react");
|
|
2215
|
+
var import_react31 = require("@coze-editor/editor/react");
|
|
2236
2216
|
var import_preset_prompt = require("@coze-editor/editor/preset-prompt");
|
|
2237
2217
|
function LanguageSupport() {
|
|
2238
|
-
const injector = (0,
|
|
2239
|
-
(0,
|
|
2218
|
+
const injector = (0, import_react31.useInjector)();
|
|
2219
|
+
(0, import_react30.useLayoutEffect)(() => injector.inject([import_preset_prompt.languageSupport]), [injector]);
|
|
2240
2220
|
return null;
|
|
2241
2221
|
}
|
|
2242
2222
|
var language_support_default = LanguageSupport;
|
|
2243
2223
|
|
|
2244
2224
|
// src/components/prompt-editor/extensions/jinja.tsx
|
|
2245
|
-
var
|
|
2246
|
-
var
|
|
2247
|
-
var
|
|
2248
|
-
var
|
|
2225
|
+
var import_react32 = require("react");
|
|
2226
|
+
var import_react33 = require("@coze-editor/editor/react");
|
|
2227
|
+
var import_editor8 = require("@coze-editor/editor");
|
|
2228
|
+
var import_view3 = require("@codemirror/view");
|
|
2249
2229
|
function JinjaHighlight() {
|
|
2250
|
-
const injector = (0,
|
|
2251
|
-
(0,
|
|
2230
|
+
const injector = (0, import_react33.useInjector)();
|
|
2231
|
+
(0, import_react32.useLayoutEffect)(
|
|
2252
2232
|
() => injector.inject([
|
|
2253
|
-
|
|
2233
|
+
import_editor8.astDecorator.whole.of((cursor) => {
|
|
2254
2234
|
if (cursor.name === "JinjaStatementStart" || cursor.name === "JinjaStatementEnd") {
|
|
2255
2235
|
return {
|
|
2256
2236
|
type: "className",
|
|
@@ -2270,7 +2250,7 @@ function JinjaHighlight() {
|
|
|
2270
2250
|
};
|
|
2271
2251
|
}
|
|
2272
2252
|
}),
|
|
2273
|
-
|
|
2253
|
+
import_view3.EditorView.theme({
|
|
2274
2254
|
".jinja-statement-bracket": {
|
|
2275
2255
|
color: "#D1009D"
|
|
2276
2256
|
},
|
|
@@ -2301,14 +2281,14 @@ function PromptEditor(props) {
|
|
|
2301
2281
|
children,
|
|
2302
2282
|
disableMarkdownHighlight
|
|
2303
2283
|
} = props || {};
|
|
2304
|
-
const editorRef = (0,
|
|
2305
|
-
(0,
|
|
2284
|
+
const editorRef = (0, import_react34.useRef)(null);
|
|
2285
|
+
(0, import_react34.useEffect)(() => {
|
|
2306
2286
|
if (editorRef.current?.getValue() !== value?.content) {
|
|
2307
2287
|
editorRef.current?.setValue(String(value?.content || ""));
|
|
2308
2288
|
}
|
|
2309
2289
|
}, [value]);
|
|
2310
|
-
return /* @__PURE__ */
|
|
2311
|
-
|
|
2290
|
+
return /* @__PURE__ */ import_react34.default.createElement(UIContainer4, { $hasError: hasError, style }, /* @__PURE__ */ import_react34.default.createElement(import_react35.EditorProvider, null, /* @__PURE__ */ import_react34.default.createElement(
|
|
2291
|
+
import_react35.Renderer,
|
|
2312
2292
|
{
|
|
2313
2293
|
didMount: (editor) => {
|
|
2314
2294
|
editorRef.current = editor;
|
|
@@ -2324,23 +2304,23 @@ function PromptEditor(props) {
|
|
|
2324
2304
|
onChange({ type: "template", content: e.value });
|
|
2325
2305
|
}
|
|
2326
2306
|
}
|
|
2327
|
-
), activeLinePlaceholder && /* @__PURE__ */
|
|
2307
|
+
), activeLinePlaceholder && /* @__PURE__ */ import_react34.default.createElement(import_react35.ActiveLinePlaceholder, null, activeLinePlaceholder), !disableMarkdownHighlight && /* @__PURE__ */ import_react34.default.createElement(markdown_default, null), /* @__PURE__ */ import_react34.default.createElement(language_support_default, null), /* @__PURE__ */ import_react34.default.createElement(jinja_default, null), children));
|
|
2328
2308
|
}
|
|
2329
2309
|
|
|
2330
2310
|
// src/components/prompt-editor-with-variables/index.tsx
|
|
2331
|
-
var
|
|
2311
|
+
var import_react40 = __toESM(require("react"));
|
|
2332
2312
|
|
|
2333
2313
|
// src/components/prompt-editor-with-variables/extensions/variable-tree.tsx
|
|
2334
|
-
var
|
|
2335
|
-
var
|
|
2336
|
-
var
|
|
2314
|
+
var import_react36 = __toESM(require("react"));
|
|
2315
|
+
var import_semi_ui16 = require("@douyinfe/semi-ui");
|
|
2316
|
+
var import_react37 = require("@coze-editor/editor/react");
|
|
2337
2317
|
function VariableTree() {
|
|
2338
|
-
const [posKey, setPosKey] = (0,
|
|
2339
|
-
const [visible, setVisible] = (0,
|
|
2340
|
-
const [position, setPosition] = (0,
|
|
2341
|
-
const editor = (0,
|
|
2318
|
+
const [posKey, setPosKey] = (0, import_react36.useState)("");
|
|
2319
|
+
const [visible, setVisible] = (0, import_react36.useState)(false);
|
|
2320
|
+
const [position, setPosition] = (0, import_react36.useState)(-1);
|
|
2321
|
+
const editor = (0, import_react37.useEditor)();
|
|
2342
2322
|
function insert(variablePath) {
|
|
2343
|
-
const range = (0,
|
|
2323
|
+
const range = (0, import_react37.getCurrentMentionReplaceRange)(editor.$view.state);
|
|
2344
2324
|
if (!range) {
|
|
2345
2325
|
return;
|
|
2346
2326
|
}
|
|
@@ -2354,21 +2334,21 @@ function VariableTree() {
|
|
|
2354
2334
|
setPosition(e.state.selection.main.head);
|
|
2355
2335
|
setVisible(e.value);
|
|
2356
2336
|
}
|
|
2357
|
-
(0,
|
|
2337
|
+
(0, import_react36.useEffect)(() => {
|
|
2358
2338
|
if (!editor) {
|
|
2359
2339
|
return;
|
|
2360
2340
|
}
|
|
2361
2341
|
}, [editor, visible]);
|
|
2362
2342
|
const treeData = useVariableTree({});
|
|
2363
|
-
return /* @__PURE__ */
|
|
2364
|
-
|
|
2343
|
+
return /* @__PURE__ */ import_react36.default.createElement(import_react36.default.Fragment, null, /* @__PURE__ */ import_react36.default.createElement(import_react37.Mention, { triggerCharacters: ["{", "{}", "@"], onOpenChange: handleOpenChange }), /* @__PURE__ */ import_react36.default.createElement(
|
|
2344
|
+
import_semi_ui16.Popover,
|
|
2365
2345
|
{
|
|
2366
2346
|
visible,
|
|
2367
2347
|
trigger: "custom",
|
|
2368
2348
|
position: "topLeft",
|
|
2369
2349
|
rePosKey: posKey,
|
|
2370
|
-
content: /* @__PURE__ */
|
|
2371
|
-
|
|
2350
|
+
content: /* @__PURE__ */ import_react36.default.createElement("div", { style: { width: 300 } }, /* @__PURE__ */ import_react36.default.createElement(
|
|
2351
|
+
import_semi_ui16.Tree,
|
|
2372
2352
|
{
|
|
2373
2353
|
treeData,
|
|
2374
2354
|
onSelect: (v) => {
|
|
@@ -2377,8 +2357,8 @@ function VariableTree() {
|
|
|
2377
2357
|
}
|
|
2378
2358
|
))
|
|
2379
2359
|
},
|
|
2380
|
-
/* @__PURE__ */
|
|
2381
|
-
|
|
2360
|
+
/* @__PURE__ */ import_react36.default.createElement(
|
|
2361
|
+
import_react37.PositionMirror,
|
|
2382
2362
|
{
|
|
2383
2363
|
position,
|
|
2384
2364
|
onChange: () => setPosKey(String(Math.random()))
|
|
@@ -2389,18 +2369,18 @@ function VariableTree() {
|
|
|
2389
2369
|
|
|
2390
2370
|
// src/components/prompt-editor-with-variables/extensions/variable-tag.tsx
|
|
2391
2371
|
var import_react_dom = __toESM(require("react-dom"));
|
|
2392
|
-
var
|
|
2393
|
-
var
|
|
2394
|
-
var
|
|
2395
|
-
var
|
|
2396
|
-
var
|
|
2397
|
-
var
|
|
2398
|
-
var
|
|
2372
|
+
var import_react38 = __toESM(require("react"));
|
|
2373
|
+
var import_lodash4 = require("lodash");
|
|
2374
|
+
var import_editor9 = require("@flowgram.ai/editor");
|
|
2375
|
+
var import_semi_ui18 = require("@douyinfe/semi-ui");
|
|
2376
|
+
var import_semi_icons8 = require("@douyinfe/semi-icons");
|
|
2377
|
+
var import_react39 = require("@coze-editor/editor/react");
|
|
2378
|
+
var import_view4 = require("@codemirror/view");
|
|
2399
2379
|
|
|
2400
2380
|
// src/components/prompt-editor-with-variables/styles.tsx
|
|
2401
|
-
var
|
|
2402
|
-
var
|
|
2403
|
-
var UIRootTitle2 =
|
|
2381
|
+
var import_styled_components8 = __toESM(require("styled-components"));
|
|
2382
|
+
var import_semi_ui17 = require("@douyinfe/semi-ui");
|
|
2383
|
+
var UIRootTitle2 = import_styled_components8.default.div`
|
|
2404
2384
|
margin-right: 4px;
|
|
2405
2385
|
min-width: 20px;
|
|
2406
2386
|
overflow: hidden;
|
|
@@ -2408,12 +2388,12 @@ var UIRootTitle2 = import_styled_components7.default.div`
|
|
|
2408
2388
|
white-space: nowrap;
|
|
2409
2389
|
color: var(--semi-color-text-2);
|
|
2410
2390
|
`;
|
|
2411
|
-
var UIVarName2 =
|
|
2391
|
+
var UIVarName2 = import_styled_components8.default.div`
|
|
2412
2392
|
overflow: hidden;
|
|
2413
2393
|
text-overflow: ellipsis;
|
|
2414
2394
|
white-space: nowrap;
|
|
2415
2395
|
`;
|
|
2416
|
-
var UITag2 = (0,
|
|
2396
|
+
var UITag2 = (0, import_styled_components8.default)(import_semi_ui17.Tag)`
|
|
2417
2397
|
display: inline-flex;
|
|
2418
2398
|
align-items: center;
|
|
2419
2399
|
justify-content: flex-start;
|
|
@@ -2427,7 +2407,7 @@ var UITag2 = (0, import_styled_components7.default)(import_semi_ui13.Tag)`
|
|
|
2427
2407
|
margin: 0 5px;
|
|
2428
2408
|
}
|
|
2429
2409
|
`;
|
|
2430
|
-
var UIPopoverContent2 =
|
|
2410
|
+
var UIPopoverContent2 = import_styled_components8.default.div`
|
|
2431
2411
|
padding: 10px;
|
|
2432
2412
|
display: inline-flex;
|
|
2433
2413
|
align-items: center;
|
|
@@ -2435,13 +2415,13 @@ var UIPopoverContent2 = import_styled_components7.default.div`
|
|
|
2435
2415
|
`;
|
|
2436
2416
|
|
|
2437
2417
|
// src/components/prompt-editor-with-variables/extensions/variable-tag.tsx
|
|
2438
|
-
var VariableTagWidget = class extends
|
|
2418
|
+
var VariableTagWidget = class extends import_view4.WidgetType {
|
|
2439
2419
|
constructor({ keyPath, scope }) {
|
|
2440
2420
|
super();
|
|
2441
|
-
this.toDispose = new
|
|
2421
|
+
this.toDispose = new import_editor9.DisposableCollection();
|
|
2442
2422
|
this.renderIcon = (icon) => {
|
|
2443
2423
|
if (typeof icon === "string") {
|
|
2444
|
-
return /* @__PURE__ */
|
|
2424
|
+
return /* @__PURE__ */ import_react38.default.createElement("img", { style: { marginRight: 8 }, width: 12, height: 12, src: icon });
|
|
2445
2425
|
}
|
|
2446
2426
|
return icon;
|
|
2447
2427
|
};
|
|
@@ -2454,21 +2434,21 @@ var VariableTagWidget = class extends import_view3.WidgetType {
|
|
|
2454
2434
|
renderVariable(v) {
|
|
2455
2435
|
if (!v) {
|
|
2456
2436
|
this.renderReact(
|
|
2457
|
-
/* @__PURE__ */
|
|
2437
|
+
/* @__PURE__ */ import_react38.default.createElement(UITag2, { prefixIcon: /* @__PURE__ */ import_react38.default.createElement(import_semi_icons8.IconIssueStroked, null), color: "amber" }, "Unknown")
|
|
2458
2438
|
);
|
|
2459
2439
|
return;
|
|
2460
2440
|
}
|
|
2461
|
-
const rootField = (0,
|
|
2441
|
+
const rootField = (0, import_lodash4.last)(v.parentFields) || v;
|
|
2462
2442
|
const isRoot = v.parentFields.length === 0;
|
|
2463
|
-
const rootTitle = /* @__PURE__ */
|
|
2443
|
+
const rootTitle = /* @__PURE__ */ import_react38.default.createElement(UIRootTitle2, null, rootField?.meta.title ? `${rootField.meta.title} ${isRoot ? "" : "-"} ` : "");
|
|
2464
2444
|
const rootIcon = this.renderIcon(rootField?.meta.icon);
|
|
2465
2445
|
this.renderReact(
|
|
2466
|
-
/* @__PURE__ */
|
|
2467
|
-
|
|
2446
|
+
/* @__PURE__ */ import_react38.default.createElement(
|
|
2447
|
+
import_semi_ui18.Popover,
|
|
2468
2448
|
{
|
|
2469
|
-
content: /* @__PURE__ */
|
|
2449
|
+
content: /* @__PURE__ */ import_react38.default.createElement(UIPopoverContent2, null, rootIcon, rootTitle, /* @__PURE__ */ import_react38.default.createElement(UIVarName2, null, v?.keyPath.slice(1).join(".")))
|
|
2470
2450
|
},
|
|
2471
|
-
/* @__PURE__ */
|
|
2451
|
+
/* @__PURE__ */ import_react38.default.createElement(UITag2, { prefixIcon: rootIcon }, rootTitle, !isRoot && /* @__PURE__ */ import_react38.default.createElement(UIVarName2, null, v?.key))
|
|
2472
2452
|
)
|
|
2473
2453
|
);
|
|
2474
2454
|
}
|
|
@@ -2476,7 +2456,7 @@ var VariableTagWidget = class extends import_view3.WidgetType {
|
|
|
2476
2456
|
const dom = document.createElement("span");
|
|
2477
2457
|
this.rootDOM = dom;
|
|
2478
2458
|
this.toDispose.push(
|
|
2479
|
-
|
|
2459
|
+
import_editor9.Disposable.create(() => {
|
|
2480
2460
|
import_react_dom.default.unmountComponentAtNode(this.rootDOM);
|
|
2481
2461
|
})
|
|
2482
2462
|
);
|
|
@@ -2493,7 +2473,7 @@ var VariableTagWidget = class extends import_view3.WidgetType {
|
|
|
2493
2473
|
return dom;
|
|
2494
2474
|
}
|
|
2495
2475
|
eq(other) {
|
|
2496
|
-
return (0,
|
|
2476
|
+
return (0, import_lodash4.isEqual)(this.keyPath, other.keyPath);
|
|
2497
2477
|
}
|
|
2498
2478
|
ignoreEvent() {
|
|
2499
2479
|
return false;
|
|
@@ -2503,12 +2483,12 @@ var VariableTagWidget = class extends import_view3.WidgetType {
|
|
|
2503
2483
|
}
|
|
2504
2484
|
};
|
|
2505
2485
|
function VariableTagInject() {
|
|
2506
|
-
const injector = (0,
|
|
2507
|
-
const scope = (0,
|
|
2508
|
-
(0,
|
|
2509
|
-
const atMatcher = new
|
|
2486
|
+
const injector = (0, import_react39.useInjector)();
|
|
2487
|
+
const scope = (0, import_editor9.useCurrentScope)();
|
|
2488
|
+
(0, import_react38.useLayoutEffect)(() => {
|
|
2489
|
+
const atMatcher = new import_view4.MatchDecorator({
|
|
2510
2490
|
regexp: /\{\{([^\}]+)\}\}/g,
|
|
2511
|
-
decoration: (match) =>
|
|
2491
|
+
decoration: (match) => import_view4.Decoration.replace({
|
|
2512
2492
|
widget: new VariableTagWidget({
|
|
2513
2493
|
keyPath: match[1]?.split(".") ?? [],
|
|
2514
2494
|
scope
|
|
@@ -2516,7 +2496,7 @@ function VariableTagInject() {
|
|
|
2516
2496
|
})
|
|
2517
2497
|
});
|
|
2518
2498
|
return injector.inject([
|
|
2519
|
-
|
|
2499
|
+
import_view4.ViewPlugin.fromClass(
|
|
2520
2500
|
class {
|
|
2521
2501
|
constructor(view) {
|
|
2522
2502
|
this.view = view;
|
|
@@ -2529,8 +2509,8 @@ function VariableTagInject() {
|
|
|
2529
2509
|
{
|
|
2530
2510
|
decorations: (p) => p.decorations,
|
|
2531
2511
|
provide(p) {
|
|
2532
|
-
return
|
|
2533
|
-
(view) => view.plugin(p)?.decorations ??
|
|
2512
|
+
return import_view4.EditorView.atomicRanges.of(
|
|
2513
|
+
(view) => view.plugin(p)?.decorations ?? import_view4.Decoration.none
|
|
2534
2514
|
);
|
|
2535
2515
|
}
|
|
2536
2516
|
}
|
|
@@ -2540,494 +2520,153 @@ function VariableTagInject() {
|
|
|
2540
2520
|
return null;
|
|
2541
2521
|
}
|
|
2542
2522
|
|
|
2543
|
-
// src/components/prompt-editor-with-variables/index.tsx
|
|
2544
|
-
function PromptEditorWithVariables(props) {
|
|
2545
|
-
return /* @__PURE__ */
|
|
2546
|
-
}
|
|
2547
|
-
|
|
2548
|
-
// src/components/prompt-editor-with-inputs/index.tsx
|
|
2549
|
-
var import_react34 = __toESM(require("react"));
|
|
2550
|
-
|
|
2551
|
-
// src/components/prompt-editor-with-inputs/extensions/inputs-tree.tsx
|
|
2552
|
-
var import_react32 = __toESM(require("react"));
|
|
2553
|
-
var import_semi_ui16 = require("@douyinfe/semi-ui");
|
|
2554
|
-
var import_react33 = require("@coze-editor/editor/react");
|
|
2555
|
-
|
|
2556
|
-
// src/components/prompt-editor-with-inputs/inputs-picker.tsx
|
|
2557
|
-
var import_react31 = __toESM(require("react"));
|
|
2558
|
-
var import_lodash6 = require("lodash");
|
|
2559
|
-
var import_editor9 = require("@flowgram.ai/editor");
|
|
2560
|
-
var import_semi_ui15 = require("@douyinfe/semi-ui");
|
|
2561
|
-
function InputsPicker({
|
|
2562
|
-
inputsValues,
|
|
2563
|
-
onSelect
|
|
2564
|
-
}) {
|
|
2565
|
-
const available = (0, import_editor9.useScopeAvailable)();
|
|
2566
|
-
const getArrayDrilldown = (type, depth = 1) => {
|
|
2567
|
-
if (import_editor9.ASTMatch.isArray(type.items)) {
|
|
2568
|
-
return getArrayDrilldown(type.items, depth + 1);
|
|
2569
|
-
}
|
|
2570
|
-
return { type: type.items, depth };
|
|
2571
|
-
};
|
|
2572
|
-
const renderVariable = (variable, keyPath) => {
|
|
2573
|
-
let type = variable?.type;
|
|
2574
|
-
let children;
|
|
2575
|
-
if (import_editor9.ASTMatch.isObject(type)) {
|
|
2576
|
-
children = (type.properties || []).map((_property) => renderVariable(_property, [...keyPath, _property.key])).filter(Boolean);
|
|
2577
|
-
}
|
|
2578
|
-
if (import_editor9.ASTMatch.isArray(type)) {
|
|
2579
|
-
const drilldown = getArrayDrilldown(type);
|
|
2580
|
-
if (import_editor9.ASTMatch.isObject(drilldown.type)) {
|
|
2581
|
-
children = (drilldown.type.properties || []).map(
|
|
2582
|
-
(_property) => renderVariable(_property, [
|
|
2583
|
-
...keyPath,
|
|
2584
|
-
...new Array(drilldown.depth).fill("[0]"),
|
|
2585
|
-
_property.key
|
|
2586
|
-
])
|
|
2587
|
-
).filter(Boolean);
|
|
2588
|
-
}
|
|
2589
|
-
}
|
|
2590
|
-
const key = keyPath.map((_key, idx) => _key === "[0]" || idx === 0 ? _key : `.${_key}`).join("");
|
|
2591
|
-
return {
|
|
2592
|
-
key,
|
|
2593
|
-
label: (0, import_lodash6.last)(keyPath),
|
|
2594
|
-
value: key,
|
|
2595
|
-
children
|
|
2596
|
-
};
|
|
2597
|
-
};
|
|
2598
|
-
const treeData = (0, import_react31.useMemo)(
|
|
2599
|
-
() => Object.entries(inputsValues).map(([key, value]) => {
|
|
2600
|
-
if (value?.type === "ref") {
|
|
2601
|
-
const variable = available.getByKeyPath(value.content || []);
|
|
2602
|
-
if (variable) {
|
|
2603
|
-
return renderVariable(variable, [key]);
|
|
2604
|
-
}
|
|
2605
|
-
}
|
|
2606
|
-
return {
|
|
2607
|
-
key,
|
|
2608
|
-
value: key,
|
|
2609
|
-
label: key
|
|
2610
|
-
};
|
|
2611
|
-
}),
|
|
2612
|
-
[]
|
|
2613
|
-
);
|
|
2614
|
-
return /* @__PURE__ */ import_react31.default.createElement(import_semi_ui15.Tree, { treeData, onSelect: (v) => onSelect(v) });
|
|
2615
|
-
}
|
|
2616
|
-
|
|
2617
|
-
// src/components/prompt-editor-with-inputs/extensions/inputs-tree.tsx
|
|
2618
|
-
function InputsTree({ inputsValues }) {
|
|
2619
|
-
const [posKey, setPosKey] = (0, import_react32.useState)("");
|
|
2620
|
-
const [visible, setVisible] = (0, import_react32.useState)(false);
|
|
2621
|
-
const [position, setPosition] = (0, import_react32.useState)(-1);
|
|
2622
|
-
const editor = (0, import_react33.useEditor)();
|
|
2623
|
-
function insert(variablePath) {
|
|
2624
|
-
const range = (0, import_react33.getCurrentMentionReplaceRange)(editor.$view.state);
|
|
2625
|
-
if (!range) {
|
|
2626
|
-
return;
|
|
2627
|
-
}
|
|
2628
|
-
editor.replaceText({
|
|
2629
|
-
...range,
|
|
2630
|
-
text: "{{" + variablePath + "}}"
|
|
2631
|
-
});
|
|
2632
|
-
setVisible(false);
|
|
2633
|
-
}
|
|
2634
|
-
function handleOpenChange(e) {
|
|
2635
|
-
setPosition(e.state.selection.main.head);
|
|
2636
|
-
setVisible(e.value);
|
|
2637
|
-
}
|
|
2638
|
-
(0, import_react32.useEffect)(() => {
|
|
2639
|
-
if (!editor) {
|
|
2640
|
-
return;
|
|
2641
|
-
}
|
|
2642
|
-
}, [editor, visible]);
|
|
2643
|
-
return /* @__PURE__ */ import_react32.default.createElement(import_react32.default.Fragment, null, /* @__PURE__ */ import_react32.default.createElement(import_react33.Mention, { triggerCharacters: ["{", "{}", "@"], onOpenChange: handleOpenChange }), /* @__PURE__ */ import_react32.default.createElement(
|
|
2644
|
-
import_semi_ui16.Popover,
|
|
2645
|
-
{
|
|
2646
|
-
visible,
|
|
2647
|
-
trigger: "custom",
|
|
2648
|
-
position: "topLeft",
|
|
2649
|
-
rePosKey: posKey,
|
|
2650
|
-
content: /* @__PURE__ */ import_react32.default.createElement("div", { style: { width: 300 } }, /* @__PURE__ */ import_react32.default.createElement(
|
|
2651
|
-
InputsPicker,
|
|
2652
|
-
{
|
|
2653
|
-
inputsValues,
|
|
2654
|
-
onSelect: (v) => {
|
|
2655
|
-
insert(v);
|
|
2656
|
-
}
|
|
2657
|
-
}
|
|
2658
|
-
))
|
|
2659
|
-
},
|
|
2660
|
-
/* @__PURE__ */ import_react32.default.createElement(
|
|
2661
|
-
import_react33.PositionMirror,
|
|
2662
|
-
{
|
|
2663
|
-
position,
|
|
2664
|
-
onChange: () => setPosKey(String(Math.random()))
|
|
2665
|
-
}
|
|
2666
|
-
)
|
|
2667
|
-
));
|
|
2668
|
-
}
|
|
2669
|
-
|
|
2670
|
-
// src/components/prompt-editor-with-inputs/index.tsx
|
|
2671
|
-
function PromptEditorWithInputs({ inputsValues, ...restProps }) {
|
|
2672
|
-
return /* @__PURE__ */ import_react34.default.createElement(PromptEditor, { ...restProps }, /* @__PURE__ */ import_react34.default.createElement(InputsTree, { inputsValues }));
|
|
2673
|
-
}
|
|
2674
|
-
|
|
2675
|
-
// src/components/code-editor/index.tsx
|
|
2676
|
-
var import_react35 = __toESM(require("react"));
|
|
2677
|
-
var import_react36 = require("@coze-editor/editor/react");
|
|
2678
|
-
var import_preset_code5 = __toESM(require("@coze-editor/editor/preset-code"));
|
|
2679
|
-
var import_view4 = require("@codemirror/view");
|
|
2680
|
-
|
|
2681
|
-
// src/components/code-editor/utils.ts
|
|
2682
|
-
function getSuffixByLanguageId(languageId) {
|
|
2683
|
-
if (languageId === "python") {
|
|
2684
|
-
return ".py";
|
|
2685
|
-
}
|
|
2686
|
-
if (languageId === "typescript") {
|
|
2687
|
-
return ".ts";
|
|
2688
|
-
}
|
|
2689
|
-
if (languageId === "shell") {
|
|
2690
|
-
return ".sh";
|
|
2691
|
-
}
|
|
2692
|
-
if (languageId === "json") {
|
|
2693
|
-
return ".json";
|
|
2694
|
-
}
|
|
2695
|
-
return "";
|
|
2696
|
-
}
|
|
2697
|
-
|
|
2698
|
-
// src/components/code-editor/language-features.ts
|
|
2699
|
-
var import_preset_code = require("@coze-editor/editor/preset-code");
|
|
2700
|
-
var import_language_typescript = require("@coze-editor/editor/language-typescript");
|
|
2701
|
-
var import_language_shell = require("@coze-editor/editor/language-shell");
|
|
2702
|
-
var import_language_python = require("@coze-editor/editor/language-python");
|
|
2703
|
-
var import_language_json = require("@coze-editor/editor/language-json");
|
|
2704
|
-
var import_editor10 = require("@coze-editor/editor");
|
|
2705
|
-
import_preset_code.languages.register("python", import_language_python.python);
|
|
2706
|
-
import_preset_code.languages.register("shell", import_language_shell.shell);
|
|
2707
|
-
import_preset_code.languages.register("typescript", import_language_typescript.typescript);
|
|
2708
|
-
import_preset_code.languages.register("json", {
|
|
2709
|
-
// mixLanguages is used to solve the problem that interpolation also uses parentheses, which causes incorrect highlighting
|
|
2710
|
-
language: (0, import_editor10.mixLanguages)({
|
|
2711
|
-
outerLanguage: import_language_json.json.language
|
|
2712
|
-
}),
|
|
2713
|
-
languageService: import_language_json.json.languageService
|
|
2714
|
-
});
|
|
2715
|
-
var tsWorkerInit = false;
|
|
2716
|
-
var initTsWorker = () => {
|
|
2717
|
-
if (tsWorkerInit) {
|
|
2718
|
-
return;
|
|
2719
|
-
}
|
|
2720
|
-
tsWorkerInit = true;
|
|
2721
|
-
const tsWorker = new Worker(
|
|
2722
|
-
new URL(`@coze-editor/editor/language-typescript/worker`, importMetaUrl),
|
|
2723
|
-
{ type: "module" }
|
|
2724
|
-
);
|
|
2725
|
-
import_language_typescript.typescript.languageService.initialize(tsWorker, {
|
|
2726
|
-
compilerOptions: {
|
|
2727
|
-
// eliminate Promise error
|
|
2728
|
-
lib: ["es2015", "dom"],
|
|
2729
|
-
noImplicitAny: false
|
|
2730
|
-
}
|
|
2731
|
-
});
|
|
2732
|
-
};
|
|
2733
|
-
|
|
2734
|
-
// src/components/code-editor/theme/index.ts
|
|
2735
|
-
var import_preset_code4 = require("@coze-editor/editor/preset-code");
|
|
2736
|
-
|
|
2737
|
-
// src/components/code-editor/theme/light.ts
|
|
2738
|
-
var import_preset_code2 = require("@coze-editor/editor/preset-code");
|
|
2739
|
-
var colors = {
|
|
2740
|
-
background: "#F7F7FC",
|
|
2741
|
-
// syntax
|
|
2742
|
-
comment: "#000A298A",
|
|
2743
|
-
key: "#00818C",
|
|
2744
|
-
string: "#D1009D",
|
|
2745
|
-
number: "#C74200",
|
|
2746
|
-
boolean: "#2B57D9",
|
|
2747
|
-
null: "#2B57D9",
|
|
2748
|
-
separator: "#0F1529D1"
|
|
2749
|
-
};
|
|
2750
|
-
var lightTheme = (0, import_preset_code2.createTheme)({
|
|
2751
|
-
variant: "light",
|
|
2752
|
-
settings: {
|
|
2753
|
-
background: "#fff",
|
|
2754
|
-
foreground: "#000",
|
|
2755
|
-
caret: "#000",
|
|
2756
|
-
selection: "#d9d9d9",
|
|
2757
|
-
gutterBackground: "#f0f0f0",
|
|
2758
|
-
gutterForeground: "#666",
|
|
2759
|
-
gutterBorderColor: "transparent",
|
|
2760
|
-
gutterBorderWidth: 0,
|
|
2761
|
-
lineHighlight: "#f0f0f0",
|
|
2762
|
-
bracketColors: ["#FFD700", "#DD99FF", "#78B0FF"],
|
|
2763
|
-
tooltip: {
|
|
2764
|
-
backgroundColor: "#f0f0f0",
|
|
2765
|
-
color: "#000",
|
|
2766
|
-
border: "1px solid #ccc"
|
|
2767
|
-
},
|
|
2768
|
-
link: {
|
|
2769
|
-
color: "#007bff"
|
|
2770
|
-
},
|
|
2771
|
-
completionItemHover: {
|
|
2772
|
-
backgroundColor: "#f0f0f0"
|
|
2773
|
-
},
|
|
2774
|
-
completionItemSelected: {
|
|
2775
|
-
backgroundColor: "#e0e0e0"
|
|
2776
|
-
},
|
|
2777
|
-
completionItemIcon: {
|
|
2778
|
-
color: "#333"
|
|
2779
|
-
},
|
|
2780
|
-
completionItemLabel: {
|
|
2781
|
-
color: "#333"
|
|
2782
|
-
},
|
|
2783
|
-
completionItemInfo: {
|
|
2784
|
-
color: "#333"
|
|
2785
|
-
},
|
|
2786
|
-
completionItemDetail: {
|
|
2787
|
-
color: "#666"
|
|
2788
|
-
}
|
|
2789
|
-
},
|
|
2790
|
-
styles: [
|
|
2791
|
-
// JSON
|
|
2792
|
-
{
|
|
2793
|
-
tag: import_preset_code2.tags.comment,
|
|
2794
|
-
color: colors.comment
|
|
2795
|
-
},
|
|
2796
|
-
{
|
|
2797
|
-
tag: [import_preset_code2.tags.propertyName],
|
|
2798
|
-
color: colors.key
|
|
2799
|
-
},
|
|
2800
|
-
{
|
|
2801
|
-
tag: [import_preset_code2.tags.string],
|
|
2802
|
-
color: colors.string
|
|
2803
|
-
},
|
|
2804
|
-
{
|
|
2805
|
-
tag: [import_preset_code2.tags.number],
|
|
2806
|
-
color: colors.number
|
|
2807
|
-
},
|
|
2808
|
-
{
|
|
2809
|
-
tag: [import_preset_code2.tags.bool],
|
|
2810
|
-
color: colors.boolean
|
|
2811
|
-
},
|
|
2812
|
-
{
|
|
2813
|
-
tag: [import_preset_code2.tags.null],
|
|
2814
|
-
color: colors.null
|
|
2815
|
-
},
|
|
2816
|
-
{
|
|
2817
|
-
tag: [import_preset_code2.tags.separator],
|
|
2818
|
-
color: colors.separator
|
|
2819
|
-
},
|
|
2820
|
-
// markdown
|
|
2821
|
-
{
|
|
2822
|
-
tag: [import_preset_code2.tags.heading],
|
|
2823
|
-
color: "#3e76ef"
|
|
2824
|
-
},
|
|
2825
|
-
{
|
|
2826
|
-
tag: [import_preset_code2.tags.processingInstruction],
|
|
2827
|
-
color: "#3e76ef"
|
|
2828
|
-
},
|
|
2829
|
-
// shell
|
|
2830
|
-
// curl
|
|
2831
|
-
{
|
|
2832
|
-
tag: [import_preset_code2.tags.standard(import_preset_code2.tags.variableName)],
|
|
2833
|
-
color: "#00804A"
|
|
2834
|
-
},
|
|
2835
|
-
// -X
|
|
2836
|
-
{
|
|
2837
|
-
tag: [import_preset_code2.tags.attributeName],
|
|
2838
|
-
color: "#C74200"
|
|
2839
|
-
},
|
|
2840
|
-
// url in string (includes quotes), e.g. "https://..."
|
|
2841
|
-
{
|
|
2842
|
-
tag: [import_preset_code2.tags.special(import_preset_code2.tags.string)],
|
|
2843
|
-
color: "#2B57D9"
|
|
2844
|
-
}
|
|
2845
|
-
]
|
|
2846
|
-
});
|
|
2847
|
-
|
|
2848
|
-
// src/components/code-editor/theme/dark.ts
|
|
2849
|
-
var import_preset_code3 = require("@coze-editor/editor/preset-code");
|
|
2850
|
-
var colors2 = {
|
|
2851
|
-
background: "#151B27",
|
|
2852
|
-
// syntax
|
|
2853
|
-
comment: "#FFFFFF63",
|
|
2854
|
-
key: "#39E5D7",
|
|
2855
|
-
string: "#FF94D2",
|
|
2856
|
-
number: "#FF9933",
|
|
2857
|
-
boolean: "#78B0FF",
|
|
2858
|
-
null: "#78B0FF",
|
|
2859
|
-
separator: "#FFFFFFC9"
|
|
2860
|
-
};
|
|
2861
|
-
var darkTheme = (0, import_preset_code3.createTheme)({
|
|
2862
|
-
variant: "dark",
|
|
2863
|
-
settings: {
|
|
2864
|
-
background: colors2.background,
|
|
2865
|
-
foreground: "#fff",
|
|
2866
|
-
caret: "#AEAFAD",
|
|
2867
|
-
selection: "#d9d9d942",
|
|
2868
|
-
gutterBackground: colors2.background,
|
|
2869
|
-
gutterForeground: "#FFFFFF63",
|
|
2870
|
-
gutterBorderColor: "transparent",
|
|
2871
|
-
gutterBorderWidth: 0,
|
|
2872
|
-
lineHighlight: "#272e3d36",
|
|
2873
|
-
bracketColors: ["#FFEF61", "#DD99FF", "#78B0FF"],
|
|
2874
|
-
tooltip: {
|
|
2875
|
-
backgroundColor: "#363D4D",
|
|
2876
|
-
color: "#fff",
|
|
2877
|
-
border: "none"
|
|
2878
|
-
},
|
|
2879
|
-
link: {
|
|
2880
|
-
color: "#4daafc"
|
|
2881
|
-
},
|
|
2882
|
-
completionItemHover: {
|
|
2883
|
-
backgroundColor: "#FFFFFF0F"
|
|
2884
|
-
},
|
|
2885
|
-
completionItemSelected: {
|
|
2886
|
-
backgroundColor: "#FFFFFF17"
|
|
2887
|
-
},
|
|
2888
|
-
completionItemIcon: {
|
|
2889
|
-
color: "#FFFFFFC9"
|
|
2890
|
-
},
|
|
2891
|
-
completionItemLabel: {
|
|
2892
|
-
color: "#FFFFFFC9"
|
|
2893
|
-
},
|
|
2894
|
-
completionItemInfo: {
|
|
2895
|
-
color: "#FFFFFFC9"
|
|
2896
|
-
},
|
|
2897
|
-
completionItemDetail: {
|
|
2898
|
-
color: "#FFFFFF63"
|
|
2899
|
-
}
|
|
2900
|
-
},
|
|
2901
|
-
styles: [
|
|
2902
|
-
// json
|
|
2903
|
-
{
|
|
2904
|
-
tag: import_preset_code3.tags.comment,
|
|
2905
|
-
color: colors2.comment
|
|
2906
|
-
},
|
|
2907
|
-
{
|
|
2908
|
-
tag: [import_preset_code3.tags.propertyName],
|
|
2909
|
-
color: colors2.key
|
|
2910
|
-
},
|
|
2911
|
-
{
|
|
2912
|
-
tag: [import_preset_code3.tags.string],
|
|
2913
|
-
color: colors2.string
|
|
2914
|
-
},
|
|
2915
|
-
{
|
|
2916
|
-
tag: [import_preset_code3.tags.number],
|
|
2917
|
-
color: colors2.number
|
|
2918
|
-
},
|
|
2919
|
-
{
|
|
2920
|
-
tag: [import_preset_code3.tags.bool],
|
|
2921
|
-
color: colors2.boolean
|
|
2922
|
-
},
|
|
2923
|
-
{
|
|
2924
|
-
tag: [import_preset_code3.tags.null],
|
|
2925
|
-
color: colors2.null
|
|
2926
|
-
},
|
|
2927
|
-
{
|
|
2928
|
-
tag: [import_preset_code3.tags.separator],
|
|
2929
|
-
color: colors2.separator
|
|
2930
|
-
},
|
|
2931
|
-
// markdown
|
|
2932
|
-
{
|
|
2933
|
-
tag: [import_preset_code3.tags.heading],
|
|
2934
|
-
color: "#6b6bff"
|
|
2935
|
-
},
|
|
2936
|
-
{
|
|
2937
|
-
tag: [import_preset_code3.tags.processingInstruction],
|
|
2938
|
-
color: "#6b6bff"
|
|
2939
|
-
},
|
|
2940
|
-
// shell
|
|
2941
|
-
// curl
|
|
2942
|
-
{
|
|
2943
|
-
tag: [import_preset_code3.tags.standard(import_preset_code3.tags.variableName)],
|
|
2944
|
-
color: "#3BEB84"
|
|
2945
|
-
},
|
|
2946
|
-
// -X
|
|
2947
|
-
{
|
|
2948
|
-
tag: [import_preset_code3.tags.attributeName],
|
|
2949
|
-
color: "#FF9933"
|
|
2950
|
-
},
|
|
2951
|
-
// url in string (includes quotes), e.g. "https://..."
|
|
2952
|
-
{
|
|
2953
|
-
tag: [import_preset_code3.tags.special(import_preset_code3.tags.string)],
|
|
2954
|
-
color: "#78B0FF"
|
|
2955
|
-
}
|
|
2956
|
-
]
|
|
2957
|
-
});
|
|
2958
|
-
|
|
2959
|
-
// src/components/code-editor/theme/index.ts
|
|
2960
|
-
import_preset_code4.themes.register("dark", darkTheme);
|
|
2961
|
-
import_preset_code4.themes.register("light", lightTheme);
|
|
2523
|
+
// src/components/prompt-editor-with-variables/index.tsx
|
|
2524
|
+
function PromptEditorWithVariables(props) {
|
|
2525
|
+
return /* @__PURE__ */ import_react40.default.createElement(PromptEditor, { ...props }, /* @__PURE__ */ import_react40.default.createElement(VariableTree, null), /* @__PURE__ */ import_react40.default.createElement(VariableTagInject, null));
|
|
2526
|
+
}
|
|
2962
2527
|
|
|
2963
|
-
// src/components/
|
|
2964
|
-
var
|
|
2965
|
-
|
|
2966
|
-
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
|
|
2970
|
-
|
|
2971
|
-
|
|
2972
|
-
|
|
2973
|
-
|
|
2974
|
-
|
|
2975
|
-
|
|
2976
|
-
|
|
2977
|
-
|
|
2978
|
-
|
|
2979
|
-
options: options2,
|
|
2980
|
-
readonly
|
|
2528
|
+
// src/components/prompt-editor-with-inputs/index.tsx
|
|
2529
|
+
var import_react44 = __toESM(require("react"));
|
|
2530
|
+
|
|
2531
|
+
// src/components/prompt-editor-with-inputs/extensions/inputs-tree.tsx
|
|
2532
|
+
var import_react42 = __toESM(require("react"));
|
|
2533
|
+
var import_semi_ui20 = require("@douyinfe/semi-ui");
|
|
2534
|
+
var import_react43 = require("@coze-editor/editor/react");
|
|
2535
|
+
|
|
2536
|
+
// src/components/prompt-editor-with-inputs/inputs-picker.tsx
|
|
2537
|
+
var import_react41 = __toESM(require("react"));
|
|
2538
|
+
var import_lodash5 = require("lodash");
|
|
2539
|
+
var import_editor10 = require("@flowgram.ai/editor");
|
|
2540
|
+
var import_semi_ui19 = require("@douyinfe/semi-ui");
|
|
2541
|
+
function InputsPicker({
|
|
2542
|
+
inputsValues,
|
|
2543
|
+
onSelect
|
|
2981
2544
|
}) {
|
|
2982
|
-
const
|
|
2983
|
-
(
|
|
2984
|
-
if (
|
|
2985
|
-
|
|
2545
|
+
const available = (0, import_editor10.useScopeAvailable)();
|
|
2546
|
+
const getArrayDrilldown = (type, depth = 1) => {
|
|
2547
|
+
if (import_editor10.ASTMatch.isArray(type.items)) {
|
|
2548
|
+
return getArrayDrilldown(type.items, depth + 1);
|
|
2986
2549
|
}
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
|
|
2990
|
-
|
|
2550
|
+
return { type: type.items, depth };
|
|
2551
|
+
};
|
|
2552
|
+
const renderVariable = (variable, keyPath) => {
|
|
2553
|
+
let type = variable?.type;
|
|
2554
|
+
let children;
|
|
2555
|
+
if (import_editor10.ASTMatch.isObject(type)) {
|
|
2556
|
+
children = (type.properties || []).map((_property) => renderVariable(_property, [...keyPath, _property.key])).filter(Boolean);
|
|
2991
2557
|
}
|
|
2992
|
-
|
|
2993
|
-
|
|
2994
|
-
|
|
2558
|
+
if (import_editor10.ASTMatch.isArray(type)) {
|
|
2559
|
+
const drilldown = getArrayDrilldown(type);
|
|
2560
|
+
if (import_editor10.ASTMatch.isObject(drilldown.type)) {
|
|
2561
|
+
children = (drilldown.type.properties || []).map(
|
|
2562
|
+
(_property) => renderVariable(_property, [
|
|
2563
|
+
...keyPath,
|
|
2564
|
+
...new Array(drilldown.depth).fill("[0]"),
|
|
2565
|
+
_property.key
|
|
2566
|
+
])
|
|
2567
|
+
).filter(Boolean);
|
|
2568
|
+
}
|
|
2569
|
+
}
|
|
2570
|
+
const key = keyPath.map((_key, idx) => _key === "[0]" || idx === 0 ? _key : `.${_key}`).join("");
|
|
2571
|
+
return {
|
|
2572
|
+
key,
|
|
2573
|
+
label: (0, import_lodash5.last)(keyPath),
|
|
2574
|
+
value: key,
|
|
2575
|
+
children
|
|
2576
|
+
};
|
|
2577
|
+
};
|
|
2578
|
+
const treeData = (0, import_react41.useMemo)(
|
|
2579
|
+
() => Object.entries(inputsValues).map(([key, value]) => {
|
|
2580
|
+
if (value?.type === "ref") {
|
|
2581
|
+
const variable = available.getByKeyPath(value.content || []);
|
|
2582
|
+
if (variable) {
|
|
2583
|
+
return renderVariable(variable, [key]);
|
|
2584
|
+
}
|
|
2585
|
+
}
|
|
2586
|
+
return {
|
|
2587
|
+
key,
|
|
2588
|
+
value: key,
|
|
2589
|
+
label: key
|
|
2590
|
+
};
|
|
2591
|
+
}),
|
|
2592
|
+
[]
|
|
2593
|
+
);
|
|
2594
|
+
return /* @__PURE__ */ import_react41.default.createElement(import_semi_ui19.Tree, { treeData, onSelect: (v) => onSelect(v) });
|
|
2595
|
+
}
|
|
2596
|
+
|
|
2597
|
+
// src/components/prompt-editor-with-inputs/extensions/inputs-tree.tsx
|
|
2598
|
+
function InputsTree({ inputsValues }) {
|
|
2599
|
+
const [posKey, setPosKey] = (0, import_react42.useState)("");
|
|
2600
|
+
const [visible, setVisible] = (0, import_react42.useState)(false);
|
|
2601
|
+
const [position, setPosition] = (0, import_react42.useState)(-1);
|
|
2602
|
+
const editor = (0, import_react43.useEditor)();
|
|
2603
|
+
function insert(variablePath) {
|
|
2604
|
+
const range = (0, import_react43.getCurrentMentionReplaceRange)(editor.$view.state);
|
|
2605
|
+
if (!range) {
|
|
2606
|
+
return;
|
|
2607
|
+
}
|
|
2608
|
+
editor.replaceText({
|
|
2609
|
+
...range,
|
|
2610
|
+
text: "{{" + variablePath + "}}"
|
|
2611
|
+
});
|
|
2612
|
+
setVisible(false);
|
|
2613
|
+
}
|
|
2614
|
+
function handleOpenChange(e) {
|
|
2615
|
+
setPosition(e.state.selection.main.head);
|
|
2616
|
+
setVisible(e.value);
|
|
2617
|
+
}
|
|
2618
|
+
(0, import_react42.useEffect)(() => {
|
|
2619
|
+
if (!editor) {
|
|
2620
|
+
return;
|
|
2621
|
+
}
|
|
2622
|
+
}, [editor, visible]);
|
|
2623
|
+
return /* @__PURE__ */ import_react42.default.createElement(import_react42.default.Fragment, null, /* @__PURE__ */ import_react42.default.createElement(import_react43.Mention, { triggerCharacters: ["{", "{}", "@"], onOpenChange: handleOpenChange }), /* @__PURE__ */ import_react42.default.createElement(
|
|
2624
|
+
import_semi_ui20.Popover,
|
|
2995
2625
|
{
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
|
|
3000
|
-
|
|
3001
|
-
|
|
3002
|
-
|
|
3003
|
-
|
|
3004
|
-
|
|
3005
|
-
|
|
3006
|
-
|
|
3007
|
-
|
|
3008
|
-
|
|
3009
|
-
onChange: (e) => onChange?.(e.value)
|
|
2626
|
+
visible,
|
|
2627
|
+
trigger: "custom",
|
|
2628
|
+
position: "topLeft",
|
|
2629
|
+
rePosKey: posKey,
|
|
2630
|
+
content: /* @__PURE__ */ import_react42.default.createElement("div", { style: { width: 300 } }, /* @__PURE__ */ import_react42.default.createElement(
|
|
2631
|
+
InputsPicker,
|
|
2632
|
+
{
|
|
2633
|
+
inputsValues,
|
|
2634
|
+
onSelect: (v) => {
|
|
2635
|
+
insert(v);
|
|
2636
|
+
}
|
|
2637
|
+
}
|
|
2638
|
+
))
|
|
3010
2639
|
},
|
|
3011
|
-
|
|
3012
|
-
|
|
2640
|
+
/* @__PURE__ */ import_react42.default.createElement(
|
|
2641
|
+
import_react43.PositionMirror,
|
|
2642
|
+
{
|
|
2643
|
+
position,
|
|
2644
|
+
onChange: () => setPosKey(String(Math.random()))
|
|
2645
|
+
}
|
|
2646
|
+
)
|
|
3013
2647
|
));
|
|
3014
2648
|
}
|
|
3015
2649
|
|
|
2650
|
+
// src/components/prompt-editor-with-inputs/index.tsx
|
|
2651
|
+
function PromptEditorWithInputs({ inputsValues, ...restProps }) {
|
|
2652
|
+
return /* @__PURE__ */ import_react44.default.createElement(PromptEditor, { ...restProps }, /* @__PURE__ */ import_react44.default.createElement(InputsTree, { inputsValues }));
|
|
2653
|
+
}
|
|
2654
|
+
|
|
3016
2655
|
// src/components/json-editor-with-variables/index.tsx
|
|
3017
|
-
var
|
|
2656
|
+
var import_react49 = __toESM(require("react"));
|
|
3018
2657
|
var import_preset_code6 = require("@coze-editor/editor/preset-code");
|
|
3019
2658
|
|
|
3020
2659
|
// src/components/json-editor-with-variables/extensions/variable-tree.tsx
|
|
3021
|
-
var
|
|
3022
|
-
var
|
|
3023
|
-
var
|
|
2660
|
+
var import_react45 = __toESM(require("react"));
|
|
2661
|
+
var import_semi_ui21 = require("@douyinfe/semi-ui");
|
|
2662
|
+
var import_react46 = require("@coze-editor/editor/react");
|
|
3024
2663
|
function VariableTree2() {
|
|
3025
|
-
const [posKey, setPosKey] = (0,
|
|
3026
|
-
const [visible, setVisible] = (0,
|
|
3027
|
-
const [position, setPosition] = (0,
|
|
3028
|
-
const editor = (0,
|
|
2664
|
+
const [posKey, setPosKey] = (0, import_react45.useState)("");
|
|
2665
|
+
const [visible, setVisible] = (0, import_react45.useState)(false);
|
|
2666
|
+
const [position, setPosition] = (0, import_react45.useState)(-1);
|
|
2667
|
+
const editor = (0, import_react46.useEditor)();
|
|
3029
2668
|
function insert(variablePath) {
|
|
3030
|
-
const range = (0,
|
|
2669
|
+
const range = (0, import_react46.getCurrentMentionReplaceRange)(editor.$view.state);
|
|
3031
2670
|
if (!range) {
|
|
3032
2671
|
return;
|
|
3033
2672
|
}
|
|
@@ -3041,21 +2680,21 @@ function VariableTree2() {
|
|
|
3041
2680
|
setPosition(e.state.selection.main.head);
|
|
3042
2681
|
setVisible(e.value);
|
|
3043
2682
|
}
|
|
3044
|
-
(0,
|
|
2683
|
+
(0, import_react45.useEffect)(() => {
|
|
3045
2684
|
if (!editor) {
|
|
3046
2685
|
return;
|
|
3047
2686
|
}
|
|
3048
2687
|
}, [editor, visible]);
|
|
3049
2688
|
const treeData = useVariableTree({});
|
|
3050
|
-
return /* @__PURE__ */
|
|
3051
|
-
|
|
2689
|
+
return /* @__PURE__ */ import_react45.default.createElement(import_react45.default.Fragment, null, /* @__PURE__ */ import_react45.default.createElement(import_react46.Mention, { triggerCharacters: ["@"], onOpenChange: handleOpenChange }), /* @__PURE__ */ import_react45.default.createElement(
|
|
2690
|
+
import_semi_ui21.Popover,
|
|
3052
2691
|
{
|
|
3053
2692
|
visible,
|
|
3054
2693
|
trigger: "custom",
|
|
3055
2694
|
position: "topLeft",
|
|
3056
2695
|
rePosKey: posKey,
|
|
3057
|
-
content: /* @__PURE__ */
|
|
3058
|
-
|
|
2696
|
+
content: /* @__PURE__ */ import_react45.default.createElement("div", { style: { width: 300 } }, /* @__PURE__ */ import_react45.default.createElement(
|
|
2697
|
+
import_semi_ui21.Tree,
|
|
3059
2698
|
{
|
|
3060
2699
|
treeData,
|
|
3061
2700
|
onSelect: (v) => {
|
|
@@ -3064,8 +2703,8 @@ function VariableTree2() {
|
|
|
3064
2703
|
}
|
|
3065
2704
|
))
|
|
3066
2705
|
},
|
|
3067
|
-
/* @__PURE__ */
|
|
3068
|
-
|
|
2706
|
+
/* @__PURE__ */ import_react45.default.createElement(
|
|
2707
|
+
import_react46.PositionMirror,
|
|
3069
2708
|
{
|
|
3070
2709
|
position,
|
|
3071
2710
|
onChange: () => setPosKey(String(Math.random()))
|
|
@@ -3075,19 +2714,19 @@ function VariableTree2() {
|
|
|
3075
2714
|
}
|
|
3076
2715
|
|
|
3077
2716
|
// src/components/json-editor-with-variables/extensions/variable-tag.tsx
|
|
3078
|
-
var
|
|
2717
|
+
var import_react47 = __toESM(require("react"));
|
|
3079
2718
|
var import_client = require("react-dom/client");
|
|
3080
|
-
var
|
|
2719
|
+
var import_lodash6 = require("lodash");
|
|
3081
2720
|
var import_editor11 = require("@flowgram.ai/editor");
|
|
3082
|
-
var
|
|
3083
|
-
var
|
|
3084
|
-
var
|
|
2721
|
+
var import_semi_ui23 = require("@douyinfe/semi-ui");
|
|
2722
|
+
var import_semi_icons9 = require("@douyinfe/semi-icons");
|
|
2723
|
+
var import_react48 = require("@coze-editor/editor/react");
|
|
3085
2724
|
var import_view5 = require("@codemirror/view");
|
|
3086
2725
|
|
|
3087
2726
|
// src/components/json-editor-with-variables/styles.tsx
|
|
3088
|
-
var
|
|
3089
|
-
var
|
|
3090
|
-
var UIRootTitle3 =
|
|
2727
|
+
var import_styled_components9 = __toESM(require("styled-components"));
|
|
2728
|
+
var import_semi_ui22 = require("@douyinfe/semi-ui");
|
|
2729
|
+
var UIRootTitle3 = import_styled_components9.default.div`
|
|
3091
2730
|
margin-right: 4px;
|
|
3092
2731
|
min-width: 20px;
|
|
3093
2732
|
overflow: hidden;
|
|
@@ -3095,12 +2734,12 @@ var UIRootTitle3 = import_styled_components8.default.div`
|
|
|
3095
2734
|
white-space: nowrap;
|
|
3096
2735
|
color: var(--semi-color-text-2);
|
|
3097
2736
|
`;
|
|
3098
|
-
var UIVarName3 =
|
|
2737
|
+
var UIVarName3 = import_styled_components9.default.div`
|
|
3099
2738
|
overflow: hidden;
|
|
3100
2739
|
text-overflow: ellipsis;
|
|
3101
2740
|
white-space: nowrap;
|
|
3102
2741
|
`;
|
|
3103
|
-
var UITag3 = (0,
|
|
2742
|
+
var UITag3 = (0, import_styled_components9.default)(import_semi_ui22.Tag)`
|
|
3104
2743
|
display: inline-flex;
|
|
3105
2744
|
align-items: center;
|
|
3106
2745
|
justify-content: flex-start;
|
|
@@ -3114,7 +2753,7 @@ var UITag3 = (0, import_styled_components8.default)(import_semi_ui18.Tag)`
|
|
|
3114
2753
|
margin: 0 5px;
|
|
3115
2754
|
}
|
|
3116
2755
|
`;
|
|
3117
|
-
var UIPopoverContent3 =
|
|
2756
|
+
var UIPopoverContent3 = import_styled_components9.default.div`
|
|
3118
2757
|
padding: 10px;
|
|
3119
2758
|
display: inline-flex;
|
|
3120
2759
|
align-items: center;
|
|
@@ -3128,7 +2767,7 @@ var VariableTagWidget2 = class extends import_view5.WidgetType {
|
|
|
3128
2767
|
this.toDispose = new import_editor11.DisposableCollection();
|
|
3129
2768
|
this.renderIcon = (icon) => {
|
|
3130
2769
|
if (typeof icon === "string") {
|
|
3131
|
-
return /* @__PURE__ */
|
|
2770
|
+
return /* @__PURE__ */ import_react47.default.createElement("img", { style: { marginRight: 8 }, width: 12, height: 12, src: icon });
|
|
3132
2771
|
}
|
|
3133
2772
|
return icon;
|
|
3134
2773
|
};
|
|
@@ -3138,20 +2777,20 @@ var VariableTagWidget2 = class extends import_view5.WidgetType {
|
|
|
3138
2777
|
renderVariable(v) {
|
|
3139
2778
|
if (!v) {
|
|
3140
2779
|
this.root.render(
|
|
3141
|
-
/* @__PURE__ */
|
|
2780
|
+
/* @__PURE__ */ import_react47.default.createElement(UITag3, { prefixIcon: /* @__PURE__ */ import_react47.default.createElement(import_semi_icons9.IconIssueStroked, null), color: "amber" }, "Unknown")
|
|
3142
2781
|
);
|
|
3143
2782
|
return;
|
|
3144
2783
|
}
|
|
3145
|
-
const rootField = (0,
|
|
3146
|
-
const rootTitle = /* @__PURE__ */
|
|
2784
|
+
const rootField = (0, import_lodash6.last)(v.parentFields);
|
|
2785
|
+
const rootTitle = /* @__PURE__ */ import_react47.default.createElement(UIRootTitle3, null, rootField?.meta.title ? `${rootField.meta.title} -` : "");
|
|
3147
2786
|
const rootIcon = this.renderIcon(rootField?.meta.icon);
|
|
3148
2787
|
this.root.render(
|
|
3149
|
-
/* @__PURE__ */
|
|
3150
|
-
|
|
2788
|
+
/* @__PURE__ */ import_react47.default.createElement(
|
|
2789
|
+
import_semi_ui23.Popover,
|
|
3151
2790
|
{
|
|
3152
|
-
content: /* @__PURE__ */
|
|
2791
|
+
content: /* @__PURE__ */ import_react47.default.createElement(UIPopoverContent3, null, rootIcon, rootTitle, /* @__PURE__ */ import_react47.default.createElement(UIVarName3, null, v?.keyPath.slice(1).join(".")))
|
|
3153
2792
|
},
|
|
3154
|
-
/* @__PURE__ */
|
|
2793
|
+
/* @__PURE__ */ import_react47.default.createElement(UITag3, { prefixIcon: rootIcon }, rootTitle, /* @__PURE__ */ import_react47.default.createElement(UIVarName3, null, v?.key))
|
|
3155
2794
|
)
|
|
3156
2795
|
);
|
|
3157
2796
|
}
|
|
@@ -3176,7 +2815,7 @@ var VariableTagWidget2 = class extends import_view5.WidgetType {
|
|
|
3176
2815
|
return dom;
|
|
3177
2816
|
}
|
|
3178
2817
|
eq(other) {
|
|
3179
|
-
return (0,
|
|
2818
|
+
return (0, import_lodash6.isEqual)(this.keyPath, other.keyPath);
|
|
3180
2819
|
}
|
|
3181
2820
|
ignoreEvent() {
|
|
3182
2821
|
return false;
|
|
@@ -3186,9 +2825,9 @@ var VariableTagWidget2 = class extends import_view5.WidgetType {
|
|
|
3186
2825
|
}
|
|
3187
2826
|
};
|
|
3188
2827
|
function VariableTagInject2() {
|
|
3189
|
-
const injector = (0,
|
|
2828
|
+
const injector = (0, import_react48.useInjector)();
|
|
3190
2829
|
const scope = (0, import_editor11.useCurrentScope)();
|
|
3191
|
-
(0,
|
|
2830
|
+
(0, import_react47.useLayoutEffect)(() => {
|
|
3192
2831
|
const atMatcher = new import_view5.MatchDecorator({
|
|
3193
2832
|
regexp: /\{\{([^\}]+)\}\}/g,
|
|
3194
2833
|
decoration: (match) => import_view5.Decoration.replace({
|
|
@@ -3253,7 +2892,7 @@ var transformer = (0, import_preset_code6.transformerCreator)((text) => {
|
|
|
3253
2892
|
return text;
|
|
3254
2893
|
});
|
|
3255
2894
|
function JsonEditorWithVariables(props) {
|
|
3256
|
-
return /* @__PURE__ */
|
|
2895
|
+
return /* @__PURE__ */ import_react49.default.createElement(
|
|
3257
2896
|
CodeEditor,
|
|
3258
2897
|
{
|
|
3259
2898
|
languageId: "json",
|
|
@@ -3264,39 +2903,39 @@ function JsonEditorWithVariables(props) {
|
|
|
3264
2903
|
...props.options || {}
|
|
3265
2904
|
}
|
|
3266
2905
|
},
|
|
3267
|
-
/* @__PURE__ */
|
|
3268
|
-
/* @__PURE__ */
|
|
2906
|
+
/* @__PURE__ */ import_react49.default.createElement(VariableTree2, null),
|
|
2907
|
+
/* @__PURE__ */ import_react49.default.createElement(VariableTagInject2, null)
|
|
3269
2908
|
);
|
|
3270
2909
|
}
|
|
3271
2910
|
|
|
3272
2911
|
// src/components/inputs-values/index.tsx
|
|
3273
|
-
var
|
|
3274
|
-
var
|
|
3275
|
-
var
|
|
2912
|
+
var import_react51 = __toESM(require("react"));
|
|
2913
|
+
var import_semi_ui24 = require("@douyinfe/semi-ui");
|
|
2914
|
+
var import_semi_icons10 = require("@douyinfe/semi-icons");
|
|
3276
2915
|
|
|
3277
2916
|
// src/components/inputs-values/styles.tsx
|
|
3278
|
-
var
|
|
3279
|
-
var UIRows2 =
|
|
2917
|
+
var import_styled_components10 = __toESM(require("styled-components"));
|
|
2918
|
+
var UIRows2 = import_styled_components10.default.div`
|
|
3280
2919
|
display: flex;
|
|
3281
2920
|
flex-direction: column;
|
|
3282
2921
|
gap: 10px;
|
|
3283
2922
|
margin-bottom: 10px;
|
|
3284
2923
|
`;
|
|
3285
|
-
var UIRow3 =
|
|
2924
|
+
var UIRow3 = import_styled_components10.default.div`
|
|
3286
2925
|
display: flex;
|
|
3287
2926
|
align-items: center;
|
|
3288
2927
|
gap: 5px;
|
|
3289
2928
|
`;
|
|
3290
2929
|
|
|
3291
2930
|
// src/components/inputs-values/components/blur-input.tsx
|
|
3292
|
-
var
|
|
2931
|
+
var import_react50 = __toESM(require("react"));
|
|
3293
2932
|
var import_input2 = __toESM(require("@douyinfe/semi-ui/lib/es/input"));
|
|
3294
2933
|
function BlurInput2(props) {
|
|
3295
|
-
const [value, setValue] = (0,
|
|
3296
|
-
(0,
|
|
2934
|
+
const [value, setValue] = (0, import_react50.useState)("");
|
|
2935
|
+
(0, import_react50.useEffect)(() => {
|
|
3297
2936
|
setValue(props.value);
|
|
3298
2937
|
}, [props.value]);
|
|
3299
|
-
return /* @__PURE__ */
|
|
2938
|
+
return /* @__PURE__ */ import_react50.default.createElement(
|
|
3300
2939
|
import_input2.default,
|
|
3301
2940
|
{
|
|
3302
2941
|
...props,
|
|
@@ -3324,7 +2963,7 @@ function InputsValues({
|
|
|
3324
2963
|
onChange,
|
|
3325
2964
|
sortIndexKey: "extra.index"
|
|
3326
2965
|
});
|
|
3327
|
-
return /* @__PURE__ */
|
|
2966
|
+
return /* @__PURE__ */ import_react51.default.createElement("div", null, /* @__PURE__ */ import_react51.default.createElement(UIRows2, { style }, list.map((item) => /* @__PURE__ */ import_react51.default.createElement(UIRow3, { key: item.id }, /* @__PURE__ */ import_react51.default.createElement(
|
|
3328
2967
|
BlurInput2,
|
|
3329
2968
|
{
|
|
3330
2969
|
style: { width: 100, minWidth: 100, maxWidth: 100 },
|
|
@@ -3334,7 +2973,7 @@ function InputsValues({
|
|
|
3334
2973
|
onChange: (v) => updateKey(item.id, v),
|
|
3335
2974
|
placeholder: "Input Key"
|
|
3336
2975
|
}
|
|
3337
|
-
), /* @__PURE__ */
|
|
2976
|
+
), /* @__PURE__ */ import_react51.default.createElement(
|
|
3338
2977
|
DynamicValueInput,
|
|
3339
2978
|
{
|
|
3340
2979
|
style: { flexGrow: 1 },
|
|
@@ -3348,42 +2987,286 @@ function InputsValues({
|
|
|
3348
2987
|
strategies: [...constantProps?.strategies || []]
|
|
3349
2988
|
}
|
|
3350
2989
|
}
|
|
3351
|
-
), /* @__PURE__ */
|
|
3352
|
-
|
|
2990
|
+
), /* @__PURE__ */ import_react51.default.createElement(
|
|
2991
|
+
import_semi_ui24.IconButton,
|
|
3353
2992
|
{
|
|
3354
2993
|
disabled: readonly,
|
|
3355
2994
|
theme: "borderless",
|
|
3356
|
-
icon: /* @__PURE__ */
|
|
2995
|
+
icon: /* @__PURE__ */ import_react51.default.createElement(import_semi_icons10.IconDelete, { size: "small" }),
|
|
3357
2996
|
size: "small",
|
|
3358
2997
|
onClick: () => remove(item.id)
|
|
3359
2998
|
}
|
|
3360
|
-
)))), /* @__PURE__ */
|
|
2999
|
+
)))), /* @__PURE__ */ import_react51.default.createElement(import_semi_ui24.Button, { disabled: readonly, icon: /* @__PURE__ */ import_react51.default.createElement(import_semi_icons10.IconPlus, null), size: "small", onClick: add }, "Add"));
|
|
3361
3000
|
}
|
|
3362
3001
|
|
|
3363
|
-
// src/
|
|
3002
|
+
// src/components/display-schema-tree/index.tsx
|
|
3003
|
+
var import_react52 = __toESM(require("react"));
|
|
3004
|
+
|
|
3005
|
+
// src/components/display-schema-tree/styles.tsx
|
|
3006
|
+
var import_styled_components11 = __toESM(require("styled-components"));
|
|
3007
|
+
var TreeRow = import_styled_components11.default.div`
|
|
3008
|
+
display: flex;
|
|
3009
|
+
align-items: center;
|
|
3010
|
+
|
|
3011
|
+
.tree-icon {
|
|
3012
|
+
margin-right: 8px;
|
|
3013
|
+
width: 14px;
|
|
3014
|
+
height: 14px;
|
|
3015
|
+
}
|
|
3016
|
+
|
|
3017
|
+
height: 27px;
|
|
3018
|
+
white-space: nowrap;
|
|
3019
|
+
`;
|
|
3020
|
+
var HorizontalLine = import_styled_components11.default.div`
|
|
3021
|
+
position: relative;
|
|
3022
|
+
|
|
3023
|
+
&::before,
|
|
3024
|
+
&::after {
|
|
3025
|
+
content: '';
|
|
3026
|
+
position: absolute;
|
|
3027
|
+
background-color: var(--semi-color-text-3);
|
|
3028
|
+
}
|
|
3029
|
+
|
|
3030
|
+
&::after {
|
|
3031
|
+
top: 0px;
|
|
3032
|
+
right: 6px;
|
|
3033
|
+
width: 15px;
|
|
3034
|
+
height: 1px;
|
|
3035
|
+
}
|
|
3036
|
+
`;
|
|
3037
|
+
var TreeTitle = import_styled_components11.default.div`
|
|
3038
|
+
// overflow: hidden;
|
|
3039
|
+
// text-overflow: ellipsis;
|
|
3040
|
+
`;
|
|
3041
|
+
var TreeLevel = import_styled_components11.default.div`
|
|
3042
|
+
padding-left: 30px;
|
|
3043
|
+
position: relative;
|
|
3044
|
+
|
|
3045
|
+
/* &::before {
|
|
3046
|
+
content: '';
|
|
3047
|
+
position: absolute;
|
|
3048
|
+
background-color: var(--semi-color-text-3);
|
|
3049
|
+
top: 0px;
|
|
3050
|
+
bottom: 0px;
|
|
3051
|
+
left: -22px;
|
|
3052
|
+
width: 1px;
|
|
3053
|
+
} */
|
|
3054
|
+
`;
|
|
3055
|
+
var TreeItem = import_styled_components11.default.div`
|
|
3056
|
+
position: relative;
|
|
3057
|
+
|
|
3058
|
+
&::before {
|
|
3059
|
+
content: '';
|
|
3060
|
+
position: absolute;
|
|
3061
|
+
background-color: var(--semi-color-text-3);
|
|
3062
|
+
}
|
|
3063
|
+
|
|
3064
|
+
&:not(:last-child)::before {
|
|
3065
|
+
width: 1px;
|
|
3066
|
+
top: 0;
|
|
3067
|
+
bottom: 0;
|
|
3068
|
+
left: -22px;
|
|
3069
|
+
}
|
|
3070
|
+
|
|
3071
|
+
&:last-child::before {
|
|
3072
|
+
width: 1px;
|
|
3073
|
+
top: 0;
|
|
3074
|
+
height: 14px;
|
|
3075
|
+
left: -22px;
|
|
3076
|
+
}
|
|
3077
|
+
|
|
3078
|
+
${(props) => props.depth === 0 && import_styled_components11.css`
|
|
3079
|
+
&::before {
|
|
3080
|
+
width: 0px !important;
|
|
3081
|
+
}
|
|
3082
|
+
`}
|
|
3083
|
+
`;
|
|
3084
|
+
|
|
3085
|
+
// src/components/display-schema-tree/index.tsx
|
|
3086
|
+
function DisplaySchemaTree(props) {
|
|
3087
|
+
return /* @__PURE__ */ import_react52.default.createElement(SchemaTree, { ...props });
|
|
3088
|
+
}
|
|
3089
|
+
function SchemaTree(props) {
|
|
3090
|
+
const {
|
|
3091
|
+
value: schema = {},
|
|
3092
|
+
drilldown = true,
|
|
3093
|
+
depth = 0,
|
|
3094
|
+
showIcon = true,
|
|
3095
|
+
parentKey = ""
|
|
3096
|
+
} = props || {};
|
|
3097
|
+
const typeManager = useTypeManager();
|
|
3098
|
+
const config = typeManager.getTypeBySchema(schema);
|
|
3099
|
+
const title = typeManager.getComplexText(schema);
|
|
3100
|
+
const icon = typeManager?.getDisplayIcon(schema);
|
|
3101
|
+
let properties = drilldown && config ? config.getTypeSchemaProperties(schema) : {};
|
|
3102
|
+
const childEntries = Object.entries(properties || {});
|
|
3103
|
+
return /* @__PURE__ */ import_react52.default.createElement(TreeItem, { depth, key: parentKey || "root" }, /* @__PURE__ */ import_react52.default.createElement(TreeRow, null, depth !== 0 && /* @__PURE__ */ import_react52.default.createElement(HorizontalLine, null), showIcon && icon && import_react52.default.cloneElement(icon, {
|
|
3104
|
+
className: "tree-icon"
|
|
3105
|
+
}), /* @__PURE__ */ import_react52.default.createElement(TreeTitle, null, parentKey ? /* @__PURE__ */ import_react52.default.createElement(import_react52.default.Fragment, null, `${parentKey} (`, title, ")") : title)), childEntries?.length ? /* @__PURE__ */ import_react52.default.createElement(TreeLevel, null, childEntries.map(([key, value]) => /* @__PURE__ */ import_react52.default.createElement(SchemaTree, { key, ...props, parentKey: key, value, depth: depth + 1 }))) : null);
|
|
3106
|
+
}
|
|
3107
|
+
|
|
3108
|
+
// src/components/display-outputs/index.tsx
|
|
3109
|
+
var import_react54 = __toESM(require("react"));
|
|
3110
|
+
var import_json_schema7 = require("@flowgram.ai/json-schema");
|
|
3364
3111
|
var import_editor12 = require("@flowgram.ai/editor");
|
|
3365
|
-
|
|
3112
|
+
|
|
3113
|
+
// src/components/display-schema-tag/index.tsx
|
|
3114
|
+
var import_react53 = __toESM(require("react"));
|
|
3115
|
+
var import_semi_ui26 = require("@douyinfe/semi-ui");
|
|
3116
|
+
|
|
3117
|
+
// src/components/display-schema-tag/styles.ts
|
|
3118
|
+
var import_styled_components12 = __toESM(require("styled-components"));
|
|
3119
|
+
var import_semi_ui25 = require("@douyinfe/semi-ui");
|
|
3120
|
+
var PopoverContent = import_styled_components12.default.div`
|
|
3121
|
+
padding: 10px;
|
|
3122
|
+
`;
|
|
3123
|
+
var StyledTag = (0, import_styled_components12.default)(import_semi_ui25.Tag)`
|
|
3124
|
+
padding: 4px;
|
|
3125
|
+
|
|
3126
|
+
.tag-icon {
|
|
3127
|
+
width: 12px;
|
|
3128
|
+
height: 12px;
|
|
3129
|
+
}
|
|
3130
|
+
`;
|
|
3131
|
+
var TitleSpan = import_styled_components12.default.span`
|
|
3132
|
+
display: inline-block;
|
|
3133
|
+
margin-left: 4px;
|
|
3134
|
+
margin-top: -1px;
|
|
3135
|
+
overflow: hidden;
|
|
3136
|
+
text-overflow: ellipsis;
|
|
3137
|
+
`;
|
|
3138
|
+
|
|
3139
|
+
// src/components/display-schema-tag/index.tsx
|
|
3140
|
+
function DisplaySchemaTag({ value = {}, showIconInTree, title, warning }) {
|
|
3141
|
+
const typeManager = useTypeManager();
|
|
3142
|
+
const icon = typeManager?.getDisplayIcon(value) || typeManager.getDisplayIcon({ type: "unknown" });
|
|
3143
|
+
return /* @__PURE__ */ import_react53.default.createElement(
|
|
3144
|
+
import_semi_ui26.Popover,
|
|
3145
|
+
{
|
|
3146
|
+
content: /* @__PURE__ */ import_react53.default.createElement(PopoverContent, null, /* @__PURE__ */ import_react53.default.createElement(DisplaySchemaTree, { value, typeManager, showIcon: showIconInTree }))
|
|
3147
|
+
},
|
|
3148
|
+
/* @__PURE__ */ import_react53.default.createElement(StyledTag, { color: warning ? "amber" : "white" }, icon && import_react53.default.cloneElement(icon, {
|
|
3149
|
+
className: "tag-icon"
|
|
3150
|
+
}), title && /* @__PURE__ */ import_react53.default.createElement(TitleSpan, null, title))
|
|
3151
|
+
);
|
|
3152
|
+
}
|
|
3153
|
+
|
|
3154
|
+
// src/components/display-outputs/styles.ts
|
|
3155
|
+
var import_styled_components13 = __toESM(require("styled-components"));
|
|
3156
|
+
var DisplayOutputsWrapper = import_styled_components13.default.div`
|
|
3157
|
+
display: flex;
|
|
3158
|
+
gap: 5px;
|
|
3159
|
+
flex-wrap: wrap;
|
|
3160
|
+
`;
|
|
3161
|
+
|
|
3162
|
+
// src/components/display-outputs/index.tsx
|
|
3163
|
+
function DisplayOutputs({ value, showIconInTree, displayFromScope }) {
|
|
3164
|
+
const scope = (0, import_editor12.useCurrentScope)();
|
|
3165
|
+
const refresh = (0, import_editor12.useRefresh)();
|
|
3166
|
+
(0, import_react54.useEffect)(() => {
|
|
3167
|
+
if (!displayFromScope) {
|
|
3168
|
+
return () => null;
|
|
3169
|
+
}
|
|
3170
|
+
const disposable = scope.output.onListOrAnyVarChange(() => {
|
|
3171
|
+
refresh();
|
|
3172
|
+
});
|
|
3173
|
+
return () => {
|
|
3174
|
+
disposable.dispose();
|
|
3175
|
+
};
|
|
3176
|
+
}, [displayFromScope]);
|
|
3177
|
+
const properties = displayFromScope ? scope.output.variables?.reduce((acm, curr) => {
|
|
3178
|
+
acm = {
|
|
3179
|
+
...acm,
|
|
3180
|
+
...import_json_schema7.JsonSchemaUtils.astToSchema(curr.type)?.properties || {}
|
|
3181
|
+
};
|
|
3182
|
+
return acm;
|
|
3183
|
+
}, {}) : value?.properties || {};
|
|
3184
|
+
const childEntries = Object.entries(properties || {});
|
|
3185
|
+
return /* @__PURE__ */ import_react54.default.createElement(DisplayOutputsWrapper, null, childEntries.map(([key, schema]) => /* @__PURE__ */ import_react54.default.createElement(DisplaySchemaTag, { key, title: key, value: schema, showIconInTree })));
|
|
3186
|
+
}
|
|
3187
|
+
|
|
3188
|
+
// src/components/display-flow-value/index.tsx
|
|
3189
|
+
var import_react55 = __toESM(require("react"));
|
|
3190
|
+
var import_json_schema8 = require("@flowgram.ai/json-schema");
|
|
3191
|
+
var import_editor13 = require("@flowgram.ai/editor");
|
|
3192
|
+
function DisplayFlowValue({ value, title, showIconInTree }) {
|
|
3193
|
+
const available = (0, import_editor13.useScopeAvailable)();
|
|
3194
|
+
const variable = value?.type === "ref" ? available.getByKeyPath(value?.content) : void 0;
|
|
3195
|
+
const schema = (0, import_react55.useMemo)(() => {
|
|
3196
|
+
if (value?.type === "ref") {
|
|
3197
|
+
return import_json_schema8.JsonSchemaUtils.astToSchema(variable?.type);
|
|
3198
|
+
}
|
|
3199
|
+
if (value?.type === "template") {
|
|
3200
|
+
return { type: "string" };
|
|
3201
|
+
}
|
|
3202
|
+
if (value?.type === "constant") {
|
|
3203
|
+
if (value?.schema) {
|
|
3204
|
+
return value?.schema;
|
|
3205
|
+
}
|
|
3206
|
+
if (typeof value?.content === "string") {
|
|
3207
|
+
return { type: "string" };
|
|
3208
|
+
}
|
|
3209
|
+
if (typeof value?.content === "number") {
|
|
3210
|
+
return { type: "number" };
|
|
3211
|
+
}
|
|
3212
|
+
if (typeof value?.content === "boolean") {
|
|
3213
|
+
return { type: "boolean" };
|
|
3214
|
+
}
|
|
3215
|
+
}
|
|
3216
|
+
return { type: "unknown" };
|
|
3217
|
+
}, [value, variable?.hash]);
|
|
3218
|
+
return /* @__PURE__ */ import_react55.default.createElement(
|
|
3219
|
+
DisplaySchemaTag,
|
|
3220
|
+
{
|
|
3221
|
+
title,
|
|
3222
|
+
value: schema,
|
|
3223
|
+
showIconInTree,
|
|
3224
|
+
warning: value?.type === "ref" && !variable
|
|
3225
|
+
}
|
|
3226
|
+
);
|
|
3227
|
+
}
|
|
3228
|
+
|
|
3229
|
+
// src/components/display-inputs-values/index.tsx
|
|
3230
|
+
var import_react56 = __toESM(require("react"));
|
|
3231
|
+
|
|
3232
|
+
// src/components/display-inputs-values/styles.ts
|
|
3233
|
+
var import_styled_components14 = __toESM(require("styled-components"));
|
|
3234
|
+
var DisplayInputsWrapper = import_styled_components14.default.div`
|
|
3235
|
+
display: flex;
|
|
3236
|
+
gap: 5px;
|
|
3237
|
+
flex-wrap: wrap;
|
|
3238
|
+
`;
|
|
3239
|
+
|
|
3240
|
+
// src/components/display-inputs-values/index.tsx
|
|
3241
|
+
function DisplayInputsValues({ value, showIconInTree }) {
|
|
3242
|
+
const childEntries = Object.entries(value || {});
|
|
3243
|
+
return /* @__PURE__ */ import_react56.default.createElement(DisplayInputsWrapper, null, childEntries.map(([key, value2]) => /* @__PURE__ */ import_react56.default.createElement(DisplayFlowValue, { key, title: key, value: value2, showIconInTree })));
|
|
3244
|
+
}
|
|
3245
|
+
|
|
3246
|
+
// src/effects/provide-batch-input/index.ts
|
|
3247
|
+
var import_editor14 = require("@flowgram.ai/editor");
|
|
3248
|
+
var provideBatchInputEffect = (0, import_editor14.createEffectFromVariableProvider)({
|
|
3366
3249
|
private: true,
|
|
3367
3250
|
parse: (value, ctx) => [
|
|
3368
|
-
|
|
3251
|
+
import_editor14.ASTFactory.createVariableDeclaration({
|
|
3369
3252
|
key: `${ctx.node.id}_locals`,
|
|
3370
3253
|
meta: {
|
|
3371
|
-
title: (0,
|
|
3254
|
+
title: (0, import_editor14.getNodeForm)(ctx.node)?.getValueIn("title"),
|
|
3372
3255
|
icon: ctx.node.getNodeRegistry().info?.icon
|
|
3373
3256
|
},
|
|
3374
|
-
type:
|
|
3257
|
+
type: import_editor14.ASTFactory.createObject({
|
|
3375
3258
|
properties: [
|
|
3376
|
-
|
|
3259
|
+
import_editor14.ASTFactory.createProperty({
|
|
3377
3260
|
key: "item",
|
|
3378
|
-
initializer:
|
|
3379
|
-
enumerateFor:
|
|
3261
|
+
initializer: import_editor14.ASTFactory.createEnumerateExpression({
|
|
3262
|
+
enumerateFor: import_editor14.ASTFactory.createKeyPathExpression({
|
|
3380
3263
|
keyPath: value.content || []
|
|
3381
3264
|
})
|
|
3382
3265
|
})
|
|
3383
3266
|
}),
|
|
3384
|
-
|
|
3267
|
+
import_editor14.ASTFactory.createProperty({
|
|
3385
3268
|
key: "index",
|
|
3386
|
-
type:
|
|
3269
|
+
type: import_editor14.ASTFactory.createNumber()
|
|
3387
3270
|
})
|
|
3388
3271
|
]
|
|
3389
3272
|
})
|
|
@@ -3392,14 +3275,14 @@ var provideBatchInputEffect = (0, import_editor12.createEffectFromVariableProvid
|
|
|
3392
3275
|
});
|
|
3393
3276
|
|
|
3394
3277
|
// src/effects/auto-rename-ref/index.ts
|
|
3395
|
-
var
|
|
3396
|
-
var
|
|
3278
|
+
var import_lodash7 = require("lodash");
|
|
3279
|
+
var import_editor15 = require("@flowgram.ai/editor");
|
|
3397
3280
|
var autoRenameRefEffect = [
|
|
3398
3281
|
{
|
|
3399
|
-
event:
|
|
3282
|
+
event: import_editor15.DataEvent.onValueInit,
|
|
3400
3283
|
effect: (params) => {
|
|
3401
3284
|
const { context, form, name } = params;
|
|
3402
|
-
const renameService = context.node.getService(
|
|
3285
|
+
const renameService = context.node.getService(import_editor15.VariableFieldKeyRenameService);
|
|
3403
3286
|
const disposable = renameService.onRename(({ before, after }) => {
|
|
3404
3287
|
const beforeKeyPath = [
|
|
3405
3288
|
...before.parentFields.map((_field) => _field.key).reverse(),
|
|
@@ -3448,7 +3331,7 @@ function isKeyPathMatch(keyPath = [], targetKeyPath) {
|
|
|
3448
3331
|
}
|
|
3449
3332
|
function getTemplateKeyPaths(value) {
|
|
3450
3333
|
const keyPathReg = /{{(.*?)}}/g;
|
|
3451
|
-
return (0,
|
|
3334
|
+
return (0, import_lodash7.uniq)(value.content?.match(keyPathReg) || []).map(
|
|
3452
3335
|
(_keyPath) => _keyPath.slice(2, -2).split(".")
|
|
3453
3336
|
);
|
|
3454
3337
|
}
|
|
@@ -3459,7 +3342,7 @@ function isTemplate(value) {
|
|
|
3459
3342
|
return value?.type === "template" && typeof value?.content === "string";
|
|
3460
3343
|
}
|
|
3461
3344
|
function traverseRef(name, value, cb) {
|
|
3462
|
-
if ((0,
|
|
3345
|
+
if ((0, import_lodash7.isObject)(value)) {
|
|
3463
3346
|
if (isRef(value)) {
|
|
3464
3347
|
cb(name, value);
|
|
3465
3348
|
return;
|
|
@@ -3473,7 +3356,7 @@ function traverseRef(name, value, cb) {
|
|
|
3473
3356
|
});
|
|
3474
3357
|
return;
|
|
3475
3358
|
}
|
|
3476
|
-
if ((0,
|
|
3359
|
+
if ((0, import_lodash7.isArray)(value)) {
|
|
3477
3360
|
value.forEach((_value, idx) => {
|
|
3478
3361
|
traverseRef(`${name}[${idx}]`, _value, cb);
|
|
3479
3362
|
});
|
|
@@ -3483,29 +3366,31 @@ function traverseRef(name, value, cb) {
|
|
|
3483
3366
|
}
|
|
3484
3367
|
|
|
3485
3368
|
// src/effects/provide-json-schema-outputs/index.ts
|
|
3486
|
-
var
|
|
3487
|
-
var
|
|
3369
|
+
var import_json_schema9 = require("@flowgram.ai/json-schema");
|
|
3370
|
+
var import_editor16 = require("@flowgram.ai/editor");
|
|
3371
|
+
var provideJsonSchemaOutputs = (0, import_editor16.createEffectFromVariableProvider)({
|
|
3488
3372
|
parse: (value, ctx) => [
|
|
3489
|
-
|
|
3373
|
+
import_editor16.ASTFactory.createVariableDeclaration({
|
|
3490
3374
|
key: `${ctx.node.id}`,
|
|
3491
3375
|
meta: {
|
|
3492
|
-
title: (0,
|
|
3376
|
+
title: (0, import_editor16.getNodeForm)(ctx.node)?.getValueIn("title") || ctx.node.id,
|
|
3493
3377
|
icon: ctx.node.getNodeRegistry().info?.icon
|
|
3494
3378
|
},
|
|
3495
|
-
type: JsonSchemaUtils.schemaToAST(value)
|
|
3379
|
+
type: import_json_schema9.JsonSchemaUtils.schemaToAST(value)
|
|
3496
3380
|
})
|
|
3497
3381
|
]
|
|
3498
3382
|
});
|
|
3499
3383
|
|
|
3500
3384
|
// src/effects/sync-variable-title/index.ts
|
|
3501
|
-
var
|
|
3385
|
+
var import_editor17 = require("@flowgram.ai/editor");
|
|
3502
3386
|
var syncVariableTitle = [
|
|
3503
3387
|
{
|
|
3504
|
-
event:
|
|
3388
|
+
event: import_editor17.DataEvent.onValueChange,
|
|
3505
3389
|
effect: ({ value, context }) => {
|
|
3506
|
-
context.node.getData(
|
|
3390
|
+
context.node.getData(import_editor17.FlowNodeVariableData).allScopes.forEach((_scope) => {
|
|
3507
3391
|
_scope.output.variables.forEach((_var) => {
|
|
3508
3392
|
_var.updateMeta({
|
|
3393
|
+
..._var.meta || {},
|
|
3509
3394
|
title: value || context.node.id,
|
|
3510
3395
|
icon: context.node.getNodeRegistry().info?.icon
|
|
3511
3396
|
});
|
|
@@ -3516,21 +3401,21 @@ var syncVariableTitle = [
|
|
|
3516
3401
|
];
|
|
3517
3402
|
|
|
3518
3403
|
// src/form-plugins/batch-outputs-plugin/index.ts
|
|
3519
|
-
var
|
|
3520
|
-
var provideBatchOutputsEffect = (0,
|
|
3404
|
+
var import_editor18 = require("@flowgram.ai/editor");
|
|
3405
|
+
var provideBatchOutputsEffect = (0, import_editor18.createEffectFromVariableProvider)({
|
|
3521
3406
|
parse: (value, ctx) => [
|
|
3522
|
-
|
|
3407
|
+
import_editor18.ASTFactory.createVariableDeclaration({
|
|
3523
3408
|
key: `${ctx.node.id}`,
|
|
3524
3409
|
meta: {
|
|
3525
|
-
title: (0,
|
|
3410
|
+
title: (0, import_editor18.getNodeForm)(ctx.node)?.getValueIn("title"),
|
|
3526
3411
|
icon: ctx.node.getNodeRegistry().info?.icon
|
|
3527
3412
|
},
|
|
3528
|
-
type:
|
|
3413
|
+
type: import_editor18.ASTFactory.createObject({
|
|
3529
3414
|
properties: Object.entries(value).map(
|
|
3530
|
-
([_key, value2]) =>
|
|
3415
|
+
([_key, value2]) => import_editor18.ASTFactory.createProperty({
|
|
3531
3416
|
key: _key,
|
|
3532
|
-
initializer:
|
|
3533
|
-
wrapFor:
|
|
3417
|
+
initializer: import_editor18.ASTFactory.createWrapArrayExpression({
|
|
3418
|
+
wrapFor: import_editor18.ASTFactory.createKeyPathExpression({
|
|
3534
3419
|
keyPath: value2?.content || []
|
|
3535
3420
|
})
|
|
3536
3421
|
})
|
|
@@ -3540,7 +3425,7 @@ var provideBatchOutputsEffect = (0, import_editor16.createEffectFromVariableProv
|
|
|
3540
3425
|
})
|
|
3541
3426
|
]
|
|
3542
3427
|
});
|
|
3543
|
-
var createBatchOutputsFormPlugin = (0,
|
|
3428
|
+
var createBatchOutputsFormPlugin = (0, import_editor18.defineFormPluginCreator)({
|
|
3544
3429
|
name: "batch-outputs-plugin",
|
|
3545
3430
|
onSetupFormMeta({ mergeEffect }, { outputKey }) {
|
|
3546
3431
|
mergeEffect({
|
|
@@ -3548,7 +3433,7 @@ var createBatchOutputsFormPlugin = (0, import_editor16.defineFormPluginCreator)(
|
|
|
3548
3433
|
});
|
|
3549
3434
|
},
|
|
3550
3435
|
onInit(ctx, { outputKey }) {
|
|
3551
|
-
const chainTransformService = ctx.node.getService(
|
|
3436
|
+
const chainTransformService = ctx.node.getService(import_editor18.ScopeChainTransformService);
|
|
3552
3437
|
const batchNodeType = ctx.node.flowNodeType;
|
|
3553
3438
|
const transformerId = `${batchNodeType}-outputs`;
|
|
3554
3439
|
if (chainTransformService.hasTransformer(transformerId)) {
|
|
@@ -3558,21 +3443,21 @@ var createBatchOutputsFormPlugin = (0, import_editor16.defineFormPluginCreator)(
|
|
|
3558
3443
|
transformCovers: (covers, ctx2) => {
|
|
3559
3444
|
const node = ctx2.scope.meta?.node;
|
|
3560
3445
|
if (node?.parent?.flowNodeType === batchNodeType) {
|
|
3561
|
-
return [...covers, (0,
|
|
3446
|
+
return [...covers, (0, import_editor18.getNodeScope)(node.parent)];
|
|
3562
3447
|
}
|
|
3563
3448
|
return covers;
|
|
3564
3449
|
},
|
|
3565
3450
|
transformDeps(scopes, ctx2) {
|
|
3566
3451
|
const scopeMeta = ctx2.scope.meta;
|
|
3567
|
-
if (scopeMeta?.type ===
|
|
3452
|
+
if (scopeMeta?.type === import_editor18.FlowNodeScopeType.private) {
|
|
3568
3453
|
return scopes;
|
|
3569
3454
|
}
|
|
3570
3455
|
const node = scopeMeta?.node;
|
|
3571
3456
|
if (node?.flowNodeType === batchNodeType) {
|
|
3572
3457
|
const childBlocks = node.blocks;
|
|
3573
3458
|
return [
|
|
3574
|
-
(0,
|
|
3575
|
-
...childBlocks.map((_childBlock) => (0,
|
|
3459
|
+
(0, import_editor18.getNodePrivateScope)(node),
|
|
3460
|
+
...childBlocks.map((_childBlock) => (0, import_editor18.getNodeScope)(_childBlock))
|
|
3576
3461
|
];
|
|
3577
3462
|
}
|
|
3578
3463
|
return scopes;
|
|
@@ -3582,20 +3467,21 @@ var createBatchOutputsFormPlugin = (0, import_editor16.defineFormPluginCreator)(
|
|
|
3582
3467
|
});
|
|
3583
3468
|
|
|
3584
3469
|
// src/form-plugins/infer-inputs-plugin/index.ts
|
|
3585
|
-
var
|
|
3586
|
-
var
|
|
3587
|
-
var
|
|
3470
|
+
var import_lodash8 = require("lodash");
|
|
3471
|
+
var import_json_schema10 = require("@flowgram.ai/json-schema");
|
|
3472
|
+
var import_editor19 = require("@flowgram.ai/editor");
|
|
3473
|
+
var createInferInputsPlugin = (0, import_editor19.defineFormPluginCreator)({
|
|
3588
3474
|
onSetupFormMeta({ addFormatOnSubmit }, { sourceKey, targetKey, scope }) {
|
|
3589
3475
|
if (!sourceKey || !targetKey) {
|
|
3590
3476
|
return;
|
|
3591
3477
|
}
|
|
3592
3478
|
addFormatOnSubmit((formData, ctx) => {
|
|
3593
|
-
(0,
|
|
3479
|
+
(0, import_lodash8.set)(
|
|
3594
3480
|
formData,
|
|
3595
3481
|
targetKey,
|
|
3596
3482
|
infer(
|
|
3597
|
-
(0,
|
|
3598
|
-
scope === "private" ? (0,
|
|
3483
|
+
(0, import_lodash8.get)(formData, sourceKey),
|
|
3484
|
+
scope === "private" ? (0, import_editor19.getNodePrivateScope)(ctx.node) : (0, import_editor19.getNodeScope)(ctx.node)
|
|
3599
3485
|
)
|
|
3600
3486
|
);
|
|
3601
3487
|
return formData;
|
|
@@ -3635,7 +3521,7 @@ var infer = (values, scope) => {
|
|
|
3635
3521
|
}
|
|
3636
3522
|
if (isRef2(values)) {
|
|
3637
3523
|
const variable = scope.available.getByKeyPath(values?.content);
|
|
3638
|
-
const schema = variable?.type ? JsonSchemaUtils.astToSchema(variable?.type) : void 0;
|
|
3524
|
+
const schema = variable?.type ? import_json_schema10.JsonSchemaUtils.astToSchema(variable?.type) : void 0;
|
|
3639
3525
|
return schema;
|
|
3640
3526
|
}
|
|
3641
3527
|
if (isTemplate2(values)) {
|
|
@@ -3657,31 +3543,36 @@ var infer = (values, scope) => {
|
|
|
3657
3543
|
};
|
|
3658
3544
|
// Annotate the CommonJS export names for ESM import in node:
|
|
3659
3545
|
0 && (module.exports = {
|
|
3660
|
-
ArrayIcons,
|
|
3661
3546
|
BatchOutputs,
|
|
3662
3547
|
BatchVariableSelector,
|
|
3663
3548
|
CodeEditor,
|
|
3549
|
+
CodeEditorMini,
|
|
3664
3550
|
ConditionRow,
|
|
3665
3551
|
ConstantInput,
|
|
3552
|
+
DisplayFlowValue,
|
|
3553
|
+
DisplayInputsValues,
|
|
3554
|
+
DisplayOutputs,
|
|
3555
|
+
DisplaySchemaTag,
|
|
3556
|
+
DisplaySchemaTree,
|
|
3666
3557
|
DynamicValueInput,
|
|
3667
3558
|
InputsValues,
|
|
3668
3559
|
JsonEditorWithVariables,
|
|
3669
3560
|
JsonSchemaEditor,
|
|
3561
|
+
JsonSchemaTypePresetProvider,
|
|
3670
3562
|
JsonSchemaUtils,
|
|
3671
3563
|
PromptEditor,
|
|
3672
3564
|
PromptEditorWithInputs,
|
|
3673
3565
|
PromptEditorWithVariables,
|
|
3674
3566
|
TypeSelector,
|
|
3675
3567
|
VariableSelector,
|
|
3676
|
-
VariableTypeIcons,
|
|
3677
3568
|
autoRenameRefEffect,
|
|
3678
3569
|
createBatchOutputsFormPlugin,
|
|
3679
3570
|
createInferInputsPlugin,
|
|
3571
|
+
createTypePresetPlugin,
|
|
3680
3572
|
formatLegacyRefOnInit,
|
|
3681
3573
|
formatLegacyRefOnSubmit,
|
|
3682
3574
|
formatLegacyRefToNewRef,
|
|
3683
3575
|
formatNewRefToLegacyRef,
|
|
3684
|
-
getSchemaIcon,
|
|
3685
3576
|
getTypeSelectValue,
|
|
3686
3577
|
isLegacyFlowRefValueSchema,
|
|
3687
3578
|
isNewFlowRefValueSchema,
|
|
@@ -3690,6 +3581,7 @@ var infer = (values, scope) => {
|
|
|
3690
3581
|
provideBatchOutputsEffect,
|
|
3691
3582
|
provideJsonSchemaOutputs,
|
|
3692
3583
|
syncVariableTitle,
|
|
3584
|
+
useTypeManager,
|
|
3693
3585
|
useVariableTree
|
|
3694
3586
|
});
|
|
3695
3587
|
//# sourceMappingURL=index.js.map
|