@flowgram.ai/form-materials 0.1.0-alpha.10 → 0.1.0-alpha.12
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 +10 -1
- package/dist/esm/index.js +1996 -1361
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.mts +328 -114
- package/dist/index.d.ts +328 -114
- package/dist/index.js +2096 -1472
- package/dist/index.js.map +1 -1
- package/package.json +7 -5
- package/src/components/assign-row/components/blur-input.tsx +27 -0
- package/src/components/assign-row/config.json +11 -0
- package/src/components/assign-row/index.tsx +84 -0
- package/src/components/assign-row/types.ts +25 -0
- package/src/components/assign-rows/config.json +11 -0
- package/src/components/assign-rows/index.tsx +59 -0
- package/src/components/batch-outputs/config.json +2 -1
- package/src/components/batch-outputs/index.tsx +4 -12
- 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/config.json +2 -1
- package/src/components/code-editor/index.tsx +23 -1
- package/src/components/code-editor/language-features.ts +23 -3
- package/src/components/code-editor/theme/light.ts +2 -2
- 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/constants.ts +6 -8
- 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 +18 -62
- package/src/components/constant-input/types.ts +6 -9
- 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 +64 -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 +64 -13
- package/src/components/dynamic-value-input/styles.tsx +28 -2
- package/src/components/index.ts +9 -0
- package/src/components/inputs-values/components/blur-input.tsx +27 -0
- package/src/components/inputs-values/config.json +13 -0
- package/src/components/inputs-values/index.tsx +73 -0
- package/src/components/inputs-values/styles.tsx +19 -0
- package/src/components/inputs-values/types.ts +22 -0
- package/src/components/json-editor-with-variables/index.tsx +47 -1
- package/src/components/json-schema-editor/config.json +2 -2
- package/src/components/json-schema-editor/default-value.tsx +1 -1
- package/src/components/json-schema-editor/hooks.tsx +4 -2
- package/src/components/json-schema-editor/index.tsx +15 -2
- package/src/components/json-schema-editor/types.ts +1 -1
- package/src/components/prompt-editor/index.tsx +2 -1
- package/src/components/prompt-editor/types.tsx +1 -0
- package/src/components/prompt-editor-with-inputs/inputs-picker.tsx +1 -1
- package/src/components/prompt-editor-with-variables/extensions/variable-tag.tsx +6 -3
- package/src/components/type-selector/config.json +6 -2
- package/src/components/type-selector/index.tsx +55 -12
- package/src/components/variable-selector/config.json +6 -2
- package/src/components/variable-selector/index.tsx +34 -13
- package/src/components/variable-selector/styles.tsx +18 -8
- package/src/components/variable-selector/use-variable-tree.tsx +19 -22
- package/src/effects/auto-rename-ref/index.ts +59 -8
- package/src/effects/index.ts +3 -1
- package/src/effects/listen-ref-schema-change/config.json +10 -0
- package/src/effects/listen-ref-schema-change/index.ts +56 -0
- package/src/effects/listen-ref-value-change/config.json +9 -0
- package/src/effects/listen-ref-value-change/index.ts +53 -0
- 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/effects/validate-when-variable-sync/config.json +5 -0
- package/src/effects/validate-when-variable-sync/index.ts +35 -0
- package/src/form-plugins/index.ts +3 -1
- package/src/form-plugins/infer-assign-plugin/config.json +7 -0
- package/src/form-plugins/infer-assign-plugin/index.ts +90 -0
- package/src/form-plugins/infer-inputs-plugin/config.json +9 -0
- package/src/form-plugins/infer-inputs-plugin/index.ts +108 -0
- package/src/hooks/index.tsx +6 -0
- package/src/hooks/use-object-list/config.json +8 -0
- package/src/hooks/use-object-list/index.tsx +136 -0
- package/src/index.ts +3 -1
- package/src/{typings/json-schema → plugins/disable-declaration-plugin}/config.json +1 -1
- package/src/plugins/disable-declaration-plugin/create-disable-declaration-plugin.ts +31 -0
- package/src/plugins/disable-declaration-plugin/index.tsx +6 -0
- package/src/plugins/index.ts +7 -0
- package/src/plugins/json-schema-preset/config.json +9 -0
- package/src/plugins/json-schema-preset/create-type-preset-plugin.tsx +28 -0
- package/src/plugins/json-schema-preset/index.tsx +41 -0
- package/src/plugins/json-schema-preset/manager.ts +18 -0
- package/src/plugins/json-schema-preset/type-definition/array.tsx +24 -0
- package/src/plugins/json-schema-preset/type-definition/boolean.tsx +32 -0
- package/src/plugins/json-schema-preset/type-definition/index.tsx +24 -0
- package/src/plugins/json-schema-preset/type-definition/integer.tsx +24 -0
- package/src/plugins/json-schema-preset/type-definition/number.tsx +24 -0
- package/src/plugins/json-schema-preset/type-definition/object.tsx +24 -0
- package/src/plugins/json-schema-preset/type-definition/string.tsx +18 -0
- package/src/{utils → shared}/index.ts +0 -1
- package/src/typings/flow-value/config.json +3 -1
- package/src/typings/flow-value/index.ts +11 -0
- package/src/typings/index.ts +0 -1
- package/src/validate/index.tsx +6 -0
- package/src/validate/validate-flow-value/config.json +7 -0
- package/src/validate/validate-flow-value/index.tsx +73 -0
- package/src/components/batch-outputs/use-list.ts +0 -86
- package/src/components/type-selector/constants.tsx +0 -364
- package/src/effects/provide-batch-outputs/config.json +0 -5
- package/src/effects/provide-batch-outputs/index.ts +0 -38
- 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,589 +30,610 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/index.ts
|
|
31
31
|
var src_exports = {};
|
|
32
32
|
__export(src_exports, {
|
|
33
|
-
|
|
33
|
+
AssignRow: () => AssignRow,
|
|
34
|
+
AssignRows: () => AssignRows,
|
|
34
35
|
BatchOutputs: () => BatchOutputs,
|
|
35
36
|
BatchVariableSelector: () => BatchVariableSelector,
|
|
36
37
|
CodeEditor: () => CodeEditor,
|
|
38
|
+
CodeEditorMini: () => CodeEditorMini,
|
|
37
39
|
ConditionRow: () => ConditionRow,
|
|
38
40
|
ConstantInput: () => ConstantInput,
|
|
41
|
+
DisplayFlowValue: () => DisplayFlowValue,
|
|
42
|
+
DisplayInputsValues: () => DisplayInputsValues,
|
|
43
|
+
DisplayOutputs: () => DisplayOutputs,
|
|
44
|
+
DisplaySchemaTag: () => DisplaySchemaTag,
|
|
45
|
+
DisplaySchemaTree: () => DisplaySchemaTree,
|
|
39
46
|
DynamicValueInput: () => DynamicValueInput,
|
|
47
|
+
InputsValues: () => InputsValues,
|
|
40
48
|
JsonEditorWithVariables: () => JsonEditorWithVariables,
|
|
41
49
|
JsonSchemaEditor: () => JsonSchemaEditor,
|
|
42
|
-
|
|
50
|
+
JsonSchemaTypePresetProvider: () => JsonSchemaTypePresetProvider,
|
|
51
|
+
JsonSchemaUtils: () => import_json_schema3.JsonSchemaUtils,
|
|
43
52
|
PromptEditor: () => PromptEditor,
|
|
44
53
|
PromptEditorWithInputs: () => PromptEditorWithInputs,
|
|
45
54
|
PromptEditorWithVariables: () => PromptEditorWithVariables,
|
|
46
55
|
TypeSelector: () => TypeSelector,
|
|
47
56
|
VariableSelector: () => VariableSelector,
|
|
48
|
-
VariableTypeIcons: () => VariableTypeIcons,
|
|
49
57
|
autoRenameRefEffect: () => autoRenameRefEffect,
|
|
50
58
|
createBatchOutputsFormPlugin: () => createBatchOutputsFormPlugin,
|
|
59
|
+
createDisableDeclarationPlugin: () => createDisableDeclarationPlugin,
|
|
60
|
+
createInferAssignPlugin: () => createInferAssignPlugin,
|
|
61
|
+
createInferInputsPlugin: () => createInferInputsPlugin,
|
|
62
|
+
createTypePresetPlugin: () => createTypePresetPlugin,
|
|
51
63
|
formatLegacyRefOnInit: () => formatLegacyRefOnInit,
|
|
52
64
|
formatLegacyRefOnSubmit: () => formatLegacyRefOnSubmit,
|
|
53
65
|
formatLegacyRefToNewRef: () => formatLegacyRefToNewRef,
|
|
54
66
|
formatNewRefToLegacyRef: () => formatNewRefToLegacyRef,
|
|
55
|
-
getSchemaIcon: () => getSchemaIcon,
|
|
56
67
|
getTypeSelectValue: () => getTypeSelectValue,
|
|
57
68
|
isLegacyFlowRefValueSchema: () => isLegacyFlowRefValueSchema,
|
|
58
69
|
isNewFlowRefValueSchema: () => isNewFlowRefValueSchema,
|
|
70
|
+
listenRefSchemaChange: () => listenRefSchemaChange,
|
|
71
|
+
listenRefValueChange: () => listenRefValueChange,
|
|
59
72
|
parseTypeSelectValue: () => parseTypeSelectValue,
|
|
60
73
|
provideBatchInputEffect: () => provideBatchInputEffect,
|
|
61
74
|
provideBatchOutputsEffect: () => provideBatchOutputsEffect,
|
|
62
75
|
provideJsonSchemaOutputs: () => provideJsonSchemaOutputs,
|
|
63
76
|
syncVariableTitle: () => syncVariableTitle,
|
|
64
|
-
|
|
77
|
+
useTypeManager: () => useTypeManager,
|
|
78
|
+
useVariableTree: () => useVariableTree,
|
|
79
|
+
validateFlowValue: () => validateFlowValue,
|
|
80
|
+
validateWhenVariableSync: () => validateWhenVariableSync
|
|
65
81
|
});
|
|
66
82
|
module.exports = __toCommonJS(src_exports);
|
|
67
83
|
|
|
84
|
+
// ../../../common/temp/node_modules/.pnpm/tsup@8.3.5_typescript@5.8.3/node_modules/tsup/assets/cjs_shims.js
|
|
85
|
+
var getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.src || new URL("main.js", document.baseURI).href;
|
|
86
|
+
var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
|
|
87
|
+
|
|
68
88
|
// src/components/variable-selector/index.tsx
|
|
69
|
-
var
|
|
70
|
-
var
|
|
89
|
+
var import_react12 = __toESM(require("react"));
|
|
90
|
+
var import_semi_ui7 = require("@douyinfe/semi-ui");
|
|
91
|
+
var import_semi_icons = require("@douyinfe/semi-icons");
|
|
71
92
|
|
|
72
93
|
// src/components/variable-selector/use-variable-tree.tsx
|
|
73
|
-
var
|
|
74
|
-
var
|
|
75
|
-
var
|
|
94
|
+
var import_react11 = __toESM(require("react"));
|
|
95
|
+
var import_json_schema4 = require("@flowgram.ai/json-schema");
|
|
96
|
+
var import_editor4 = require("@flowgram.ai/editor");
|
|
97
|
+
var import_semi_ui5 = require("@douyinfe/semi-ui");
|
|
98
|
+
|
|
99
|
+
// src/plugins/json-schema-preset/index.tsx
|
|
100
|
+
var import_react10 = __toESM(require("react"));
|
|
101
|
+
var import_json_schema3 = require("@flowgram.ai/json-schema");
|
|
102
|
+
|
|
103
|
+
// src/plugins/json-schema-preset/type-definition/index.tsx
|
|
104
|
+
var import_json_schema = require("@flowgram.ai/json-schema");
|
|
76
105
|
|
|
77
|
-
// src/
|
|
106
|
+
// src/plugins/json-schema-preset/type-definition/string.tsx
|
|
78
107
|
var import_react = __toESM(require("react"));
|
|
79
|
-
var
|
|
80
|
-
var
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
108
|
+
var import_semi_ui = require("@douyinfe/semi-ui");
|
|
109
|
+
var stringRegistry = {
|
|
110
|
+
type: "string",
|
|
111
|
+
ConstantRenderer: (props) => /* @__PURE__ */ import_react.default.createElement(import_semi_ui.Input, { placeholder: "Please Input String", size: "small", disabled: props.readonly, ...props })
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
// src/plugins/json-schema-preset/type-definition/object.tsx
|
|
115
|
+
var import_react5 = __toESM(require("react"));
|
|
116
|
+
|
|
117
|
+
// src/components/code-editor-mini/index.tsx
|
|
118
|
+
var import_react4 = __toESM(require("react"));
|
|
119
|
+
var import_styled_components = __toESM(require("styled-components"));
|
|
120
|
+
|
|
121
|
+
// src/components/code-editor/index.tsx
|
|
122
|
+
var import_react2 = __toESM(require("react"));
|
|
123
|
+
var import_react3 = require("@coze-editor/editor/react");
|
|
124
|
+
var import_preset_code5 = __toESM(require("@coze-editor/editor/preset-code"));
|
|
125
|
+
var import_view = require("@codemirror/view");
|
|
126
|
+
|
|
127
|
+
// src/components/code-editor/utils.ts
|
|
128
|
+
function getSuffixByLanguageId(languageId) {
|
|
129
|
+
if (languageId === "python") {
|
|
130
|
+
return ".py";
|
|
131
|
+
}
|
|
132
|
+
if (languageId === "typescript") {
|
|
133
|
+
return ".ts";
|
|
134
|
+
}
|
|
135
|
+
if (languageId === "shell") {
|
|
136
|
+
return ".sh";
|
|
137
|
+
}
|
|
138
|
+
if (languageId === "json") {
|
|
139
|
+
return ".json";
|
|
140
|
+
}
|
|
141
|
+
return "";
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// src/components/code-editor/language-features.ts
|
|
145
|
+
var import_preset_code = require("@coze-editor/editor/preset-code");
|
|
146
|
+
var import_language_typescript = require("@coze-editor/editor/language-typescript");
|
|
147
|
+
var import_language_shell = require("@coze-editor/editor/language-shell");
|
|
148
|
+
var import_language_python = require("@coze-editor/editor/language-python");
|
|
149
|
+
var import_language_json = require("@coze-editor/editor/language-json");
|
|
150
|
+
var import_editor = require("@coze-editor/editor");
|
|
151
|
+
import_preset_code.languages.register("python", import_language_python.python);
|
|
152
|
+
import_preset_code.languages.register("shell", import_language_shell.shell);
|
|
153
|
+
import_preset_code.languages.register("typescript", import_language_typescript.typescript);
|
|
154
|
+
import_preset_code.languages.register("json", {
|
|
155
|
+
// mixLanguages is used to solve the problem that interpolation also uses parentheses, which causes incorrect highlighting
|
|
156
|
+
language: (0, import_editor.mixLanguages)({
|
|
157
|
+
outerLanguage: import_language_json.json.language
|
|
158
|
+
}),
|
|
159
|
+
languageService: import_language_json.json.languageService
|
|
160
|
+
});
|
|
161
|
+
var tsWorkerInit = false;
|
|
162
|
+
var initTsWorker = () => {
|
|
163
|
+
if (tsWorkerInit) {
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
tsWorkerInit = true;
|
|
167
|
+
const tsWorker = new Worker(
|
|
168
|
+
new URL(`@coze-editor/editor/language-typescript/worker`, importMetaUrl),
|
|
169
|
+
{ type: "module" }
|
|
170
|
+
);
|
|
171
|
+
import_language_typescript.typescript.languageService.initialize(tsWorker, {
|
|
172
|
+
compilerOptions: {
|
|
173
|
+
// eliminate Promise error
|
|
174
|
+
lib: ["es2015", "dom"],
|
|
175
|
+
noImplicitAny: false
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
// src/components/code-editor/theme/index.ts
|
|
181
|
+
var import_preset_code4 = require("@coze-editor/editor/preset-code");
|
|
182
|
+
|
|
183
|
+
// src/components/code-editor/theme/light.ts
|
|
184
|
+
var import_preset_code2 = require("@coze-editor/editor/preset-code");
|
|
185
|
+
var colors = {
|
|
186
|
+
background: "#F7F7FC",
|
|
187
|
+
// syntax
|
|
188
|
+
comment: "#000A298A",
|
|
189
|
+
key: "#00818C",
|
|
190
|
+
string: "#D1009D",
|
|
191
|
+
number: "#C74200",
|
|
192
|
+
boolean: "#2B57D9",
|
|
193
|
+
null: "#2B57D9",
|
|
194
|
+
separator: "#0F1529D1"
|
|
195
|
+
};
|
|
196
|
+
var lightTheme = (0, import_preset_code2.createTheme)({
|
|
197
|
+
variant: "light",
|
|
198
|
+
settings: {
|
|
199
|
+
background: "#fff",
|
|
200
|
+
foreground: "#000",
|
|
201
|
+
caret: "#000",
|
|
202
|
+
selection: "#d9d9d9",
|
|
203
|
+
gutterBackground: "#f0f0f0",
|
|
204
|
+
gutterForeground: "#666",
|
|
205
|
+
gutterBorderColor: "transparent",
|
|
206
|
+
gutterBorderWidth: 0,
|
|
207
|
+
lineHighlight: "#e1e1e180",
|
|
208
|
+
bracketColors: ["#FFD700", "#DD99FF", "#78B0FF"],
|
|
209
|
+
tooltip: {
|
|
210
|
+
backgroundColor: "#f0f0f0",
|
|
211
|
+
color: "#000",
|
|
212
|
+
border: "1px solid #ccc"
|
|
91
213
|
},
|
|
92
|
-
|
|
93
|
-
"
|
|
94
|
-
{
|
|
95
|
-
fillRule: "evenodd",
|
|
96
|
-
clipRule: "evenodd",
|
|
97
|
-
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",
|
|
98
|
-
fill: "currentColor"
|
|
99
|
-
}
|
|
100
|
-
)
|
|
101
|
-
),
|
|
102
|
-
object: /* @__PURE__ */ import_react.default.createElement(
|
|
103
|
-
"svg",
|
|
104
|
-
{
|
|
105
|
-
width: "1em",
|
|
106
|
-
height: "1em",
|
|
107
|
-
viewBox: "0 0 16 16",
|
|
108
|
-
fill: "none",
|
|
109
|
-
xmlns: "http://www.w3.org/2000/svg"
|
|
214
|
+
link: {
|
|
215
|
+
color: "#007bff"
|
|
110
216
|
},
|
|
111
|
-
|
|
112
|
-
"
|
|
113
|
-
{
|
|
114
|
-
d: "M5.33893 1.5835C5.66613 1.5835 5.93137 1.88142 5.93137 2.20862C5.93137 2.53582 5.66613 2.76838 5.33893 2.76838H4.9099C4.34717 2.76838 4.08062 3.07557 4.08062 3.71921V6.58633C4.08062 7.30996 3.80723 7.84734 3.26798 8.19105C3.11426 8.28902 3.10884 8.55273 3.26068 8.65359C3.80476 9.01503 4.08062 9.53994 4.08062 10.2434V13.1251C4.08062 13.7395 4.34717 14.0613 4.9099 14.0613H5.33893C5.66613 14.0613 5.93137 14.3435 5.93137 14.6707C5.93137 14.9979 5.66613 15.2462 5.33893 15.2462H4.64335C3.99177 15.2462 3.48828 15.0268 3.13287 14.6172C2.80708 14.2369 2.64419 13.7103 2.64419 13.0666V10.3165C2.64419 9.8923 2.55534 9.58511 2.37764 9.39494C2.26816 9.27135 1.80618 9.17938 1.38154 9.11602C1.02726 9.06315 0.759057 8.76744 0.765747 8.4093C0.772379 8.0543 1.03439 7.7566 1.38545 7.70346C1.80778 7.63952 2.26906 7.54968 2.37764 7.43477C2.55534 7.22997 2.64419 6.92278 2.64419 6.51319V3.77772C2.64419 3.11945 2.80708 2.59284 3.13287 2.21251C3.48828 1.78829 3.99177 1.5835 4.64335 1.5835H5.33893Z",
|
|
115
|
-
fill: "currentColor"
|
|
116
|
-
}
|
|
117
|
-
),
|
|
118
|
-
/* @__PURE__ */ import_react.default.createElement(
|
|
119
|
-
"path",
|
|
120
|
-
{
|
|
121
|
-
d: "M10.962 15.2463C10.6348 15.2463 10.3696 14.9483 10.3696 14.6211C10.3696 14.2939 10.6348 14.0614 10.962 14.0614H11.391C11.9538 14.0614 12.2203 13.7542 12.2203 13.1105V10.2434C12.2203 9.51979 12.4937 8.98241 13.033 8.6387C13.1867 8.54073 13.1921 8.27703 13.0403 8.17616C12.4962 7.81472 12.2203 7.28982 12.2203 6.58638V3.70463C12.2203 3.09024 11.9538 2.76842 11.391 2.76842L10.962 2.76842C10.6348 2.76842 10.3696 2.48627 10.3696 2.15907C10.3696 1.83188 10.6348 1.58354 10.962 1.58354L11.6576 1.58354C12.3092 1.58354 12.8127 1.80296 13.1681 2.21255C13.4939 2.59289 13.6568 3.1195 13.6568 3.76314V6.51324C13.6568 6.93745 13.7456 7.24464 13.9233 7.43481C14.03 7.5553 14.4328 7.64858 14.8186 7.71393C15.1718 7.77376 15.4401 8.06977 15.4334 8.42791C15.4268 8.78291 15.1646 9.08018 14.814 9.13633C14.4306 9.19774 14.0291 9.28303 13.9233 9.39499C13.7456 9.59978 13.6568 9.90697 13.6568 10.3166V13.052C13.6568 13.7103 13.4939 14.2369 13.1681 14.6172C12.8127 15.0415 12.3092 15.2463 11.6576 15.2463H10.962Z",
|
|
122
|
-
fill: "currentColor"
|
|
123
|
-
}
|
|
124
|
-
)
|
|
125
|
-
),
|
|
126
|
-
boolean: /* @__PURE__ */ import_react.default.createElement(
|
|
127
|
-
"svg",
|
|
128
|
-
{
|
|
129
|
-
width: "1em",
|
|
130
|
-
height: "1em",
|
|
131
|
-
viewBox: "0 0 16 16",
|
|
132
|
-
fill: "none",
|
|
133
|
-
xmlns: "http://www.w3.org/2000/svg"
|
|
217
|
+
completionItemHover: {
|
|
218
|
+
backgroundColor: "#f0f0f0"
|
|
134
219
|
},
|
|
135
|
-
|
|
136
|
-
"
|
|
137
|
-
{
|
|
138
|
-
fillRule: "evenodd",
|
|
139
|
-
clipRule: "evenodd",
|
|
140
|
-
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",
|
|
141
|
-
fill: "currentColor"
|
|
142
|
-
}
|
|
143
|
-
),
|
|
144
|
-
/* @__PURE__ */ import_react.default.createElement(
|
|
145
|
-
"path",
|
|
146
|
-
{
|
|
147
|
-
fillRule: "evenodd",
|
|
148
|
-
clipRule: "evenodd",
|
|
149
|
-
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",
|
|
150
|
-
fill: "currentColor"
|
|
151
|
-
}
|
|
152
|
-
)
|
|
153
|
-
),
|
|
154
|
-
string: /* @__PURE__ */ import_react.default.createElement(
|
|
155
|
-
"svg",
|
|
156
|
-
{
|
|
157
|
-
width: "1em",
|
|
158
|
-
height: "1em",
|
|
159
|
-
viewBox: "0 0 16 16",
|
|
160
|
-
fill: "none",
|
|
161
|
-
xmlns: "http://www.w3.org/2000/svg"
|
|
220
|
+
completionItemSelected: {
|
|
221
|
+
backgroundColor: "#e0e0e0"
|
|
162
222
|
},
|
|
163
|
-
|
|
164
|
-
"
|
|
165
|
-
{
|
|
166
|
-
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",
|
|
167
|
-
fill: "currentColor"
|
|
168
|
-
}
|
|
169
|
-
),
|
|
170
|
-
/* @__PURE__ */ import_react.default.createElement(
|
|
171
|
-
"path",
|
|
172
|
-
{
|
|
173
|
-
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",
|
|
174
|
-
fill: "currentColor"
|
|
175
|
-
}
|
|
176
|
-
),
|
|
177
|
-
/* @__PURE__ */ import_react.default.createElement(
|
|
178
|
-
"path",
|
|
179
|
-
{
|
|
180
|
-
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",
|
|
181
|
-
fill: "currentColor"
|
|
182
|
-
}
|
|
183
|
-
),
|
|
184
|
-
/* @__PURE__ */ import_react.default.createElement(
|
|
185
|
-
"path",
|
|
186
|
-
{
|
|
187
|
-
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",
|
|
188
|
-
fill: "currentColor"
|
|
189
|
-
}
|
|
190
|
-
)
|
|
191
|
-
),
|
|
192
|
-
integer: /* @__PURE__ */ import_react.default.createElement(
|
|
193
|
-
"svg",
|
|
194
|
-
{
|
|
195
|
-
width: "1em",
|
|
196
|
-
height: "1em",
|
|
197
|
-
viewBox: "0 0 16 16",
|
|
198
|
-
fill: "none",
|
|
199
|
-
xmlns: "http://www.w3.org/2000/svg"
|
|
223
|
+
completionItemIcon: {
|
|
224
|
+
color: "#333"
|
|
200
225
|
},
|
|
201
|
-
|
|
202
|
-
"
|
|
203
|
-
{
|
|
204
|
-
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",
|
|
205
|
-
fill: "currentColor"
|
|
206
|
-
}
|
|
207
|
-
),
|
|
208
|
-
/* @__PURE__ */ import_react.default.createElement(
|
|
209
|
-
"path",
|
|
210
|
-
{
|
|
211
|
-
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",
|
|
212
|
-
fill: "currentColor"
|
|
213
|
-
}
|
|
214
|
-
),
|
|
215
|
-
/* @__PURE__ */ import_react.default.createElement(
|
|
216
|
-
"path",
|
|
217
|
-
{
|
|
218
|
-
d: "M1.668 12.0001V4.78805L0 6.25205V4.89605L1.668 3.45605H2.892V12.0001H1.668Z",
|
|
219
|
-
fill: "currentColor"
|
|
220
|
-
}
|
|
221
|
-
)
|
|
222
|
-
),
|
|
223
|
-
number: /* @__PURE__ */ import_react.default.createElement(
|
|
224
|
-
"svg",
|
|
225
|
-
{
|
|
226
|
-
width: "1em",
|
|
227
|
-
height: "1em",
|
|
228
|
-
viewBox: "0 0 16 16",
|
|
229
|
-
fill: "none",
|
|
230
|
-
xmlns: "http://www.w3.org/2000/svg"
|
|
226
|
+
completionItemLabel: {
|
|
227
|
+
color: "#333"
|
|
231
228
|
},
|
|
232
|
-
|
|
233
|
-
"
|
|
234
|
-
{
|
|
235
|
-
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",
|
|
236
|
-
fill: "currentColor"
|
|
237
|
-
}
|
|
238
|
-
),
|
|
239
|
-
/* @__PURE__ */ import_react.default.createElement(
|
|
240
|
-
"path",
|
|
241
|
-
{
|
|
242
|
-
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",
|
|
243
|
-
fill: "currentColor"
|
|
244
|
-
}
|
|
245
|
-
),
|
|
246
|
-
/* @__PURE__ */ import_react.default.createElement(
|
|
247
|
-
"path",
|
|
248
|
-
{
|
|
249
|
-
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",
|
|
250
|
-
fill: "currentColor"
|
|
251
|
-
}
|
|
252
|
-
)
|
|
253
|
-
),
|
|
254
|
-
array: /* @__PURE__ */ import_react.default.createElement(
|
|
255
|
-
"svg",
|
|
256
|
-
{
|
|
257
|
-
width: "1em",
|
|
258
|
-
height: "1em",
|
|
259
|
-
viewBox: "0 0 16 16",
|
|
260
|
-
fill: "none",
|
|
261
|
-
xmlns: "http://www.w3.org/2000/svg"
|
|
229
|
+
completionItemInfo: {
|
|
230
|
+
color: "#333"
|
|
262
231
|
},
|
|
263
|
-
|
|
264
|
-
"
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
{
|
|
273
|
-
d: "M10.7624 1.00342H13.9961V14.997H10.7624V13.6251H12.6487V2.37534H10.7624V1.00342Z",
|
|
274
|
-
fill: "currentColor"
|
|
275
|
-
}
|
|
276
|
-
)
|
|
277
|
-
),
|
|
278
|
-
stream: /* @__PURE__ */ import_react.default.createElement(
|
|
279
|
-
"svg",
|
|
280
|
-
{
|
|
281
|
-
viewBox: "0 0 1024 1024",
|
|
282
|
-
version: "1.1",
|
|
283
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
284
|
-
width: "1em",
|
|
285
|
-
height: "1em"
|
|
232
|
+
completionItemDetail: {
|
|
233
|
+
color: "#666"
|
|
234
|
+
}
|
|
235
|
+
},
|
|
236
|
+
styles: [
|
|
237
|
+
// JSON
|
|
238
|
+
{
|
|
239
|
+
tag: import_preset_code2.tags.comment,
|
|
240
|
+
color: colors.comment
|
|
286
241
|
},
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
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",
|
|
291
|
-
fill: "currentColor"
|
|
292
|
-
}
|
|
293
|
-
)
|
|
294
|
-
),
|
|
295
|
-
map: /* @__PURE__ */ import_react.default.createElement(
|
|
296
|
-
"svg",
|
|
297
|
-
{
|
|
298
|
-
viewBox: "0 0 1024 1024",
|
|
299
|
-
version: "1.1",
|
|
300
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
301
|
-
width: "1em",
|
|
302
|
-
height: "1em"
|
|
242
|
+
{
|
|
243
|
+
tag: [import_preset_code2.tags.propertyName],
|
|
244
|
+
color: colors.key
|
|
303
245
|
},
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
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",
|
|
308
|
-
fill: "currentColor"
|
|
309
|
-
}
|
|
310
|
-
),
|
|
311
|
-
/* @__PURE__ */ import_react.default.createElement(
|
|
312
|
-
"path",
|
|
313
|
-
{
|
|
314
|
-
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",
|
|
315
|
-
fill: "currentColor"
|
|
316
|
-
}
|
|
317
|
-
)
|
|
318
|
-
)
|
|
319
|
-
};
|
|
320
|
-
var ArrayIcons = {
|
|
321
|
-
object: /* @__PURE__ */ import_react.default.createElement(
|
|
322
|
-
"svg",
|
|
323
|
-
{
|
|
324
|
-
width: "1em",
|
|
325
|
-
height: "1em",
|
|
326
|
-
viewBox: "0 0 16 16",
|
|
327
|
-
fill: "none",
|
|
328
|
-
xmlns: "http://www.w3.org/2000/svg"
|
|
246
|
+
{
|
|
247
|
+
tag: [import_preset_code2.tags.string],
|
|
248
|
+
color: colors.string
|
|
329
249
|
},
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
fillRule: "evenodd",
|
|
334
|
-
clipRule: "evenodd",
|
|
335
|
-
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",
|
|
336
|
-
fill: "currentColor"
|
|
337
|
-
}
|
|
338
|
-
)
|
|
339
|
-
),
|
|
340
|
-
boolean: /* @__PURE__ */ import_react.default.createElement(
|
|
341
|
-
"svg",
|
|
342
|
-
{
|
|
343
|
-
width: "1em",
|
|
344
|
-
height: "1em",
|
|
345
|
-
viewBox: "0 0 16 16",
|
|
346
|
-
fill: "none",
|
|
347
|
-
xmlns: "http://www.w3.org/2000/svg"
|
|
250
|
+
{
|
|
251
|
+
tag: [import_preset_code2.tags.number],
|
|
252
|
+
color: colors.number
|
|
348
253
|
},
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
fillRule: "evenodd",
|
|
353
|
-
clipRule: "evenodd",
|
|
354
|
-
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",
|
|
355
|
-
fill: "currentColor"
|
|
356
|
-
}
|
|
357
|
-
)
|
|
358
|
-
),
|
|
359
|
-
string: /* @__PURE__ */ import_react.default.createElement(
|
|
360
|
-
"svg",
|
|
361
|
-
{
|
|
362
|
-
width: "1em",
|
|
363
|
-
height: "1em",
|
|
364
|
-
viewBox: "0 0 16 16",
|
|
365
|
-
fill: "none",
|
|
366
|
-
xmlns: "http://www.w3.org/2000/svg"
|
|
254
|
+
{
|
|
255
|
+
tag: [import_preset_code2.tags.bool],
|
|
256
|
+
color: colors.boolean
|
|
367
257
|
},
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
fillRule: "evenodd",
|
|
372
|
-
clipRule: "evenodd",
|
|
373
|
-
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",
|
|
374
|
-
fill: "currentColor"
|
|
375
|
-
}
|
|
376
|
-
)
|
|
377
|
-
),
|
|
378
|
-
integer: /* @__PURE__ */ import_react.default.createElement(
|
|
379
|
-
"svg",
|
|
380
|
-
{
|
|
381
|
-
width: "1em",
|
|
382
|
-
height: "1em",
|
|
383
|
-
viewBox: "0 0 16 16",
|
|
384
|
-
fill: "none",
|
|
385
|
-
xmlns: "http://www.w3.org/2000/svg"
|
|
258
|
+
{
|
|
259
|
+
tag: [import_preset_code2.tags.null],
|
|
260
|
+
color: colors.null
|
|
386
261
|
},
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
fillRule: "evenodd",
|
|
391
|
-
clipRule: "evenodd",
|
|
392
|
-
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",
|
|
393
|
-
fill: "currentColor"
|
|
394
|
-
}
|
|
395
|
-
)
|
|
396
|
-
),
|
|
397
|
-
number: /* @__PURE__ */ import_react.default.createElement(
|
|
398
|
-
"svg",
|
|
399
|
-
{
|
|
400
|
-
width: "1em",
|
|
401
|
-
height: "1em",
|
|
402
|
-
viewBox: "0 0 16 16",
|
|
403
|
-
fill: "none",
|
|
404
|
-
xmlns: "http://www.w3.org/2000/svg"
|
|
262
|
+
{
|
|
263
|
+
tag: [import_preset_code2.tags.separator],
|
|
264
|
+
color: colors.separator
|
|
405
265
|
},
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
{
|
|
431
|
-
label: /* @__PURE__ */ import_react.default.createElement("div", { style: labelStyle }, /* @__PURE__ */ import_react.default.createElement(import_semi_icons.default, { size: "small", svg: getSchemaIcon({ type: "integer" }) }), firstUppercase("integer")),
|
|
432
|
-
value: "integer"
|
|
433
|
-
},
|
|
434
|
-
{
|
|
435
|
-
label: /* @__PURE__ */ import_react.default.createElement("div", { style: labelStyle }, /* @__PURE__ */ import_react.default.createElement(import_semi_icons.default, { size: "small", svg: getSchemaIcon({ type: "number" }) }), firstUppercase("number")),
|
|
436
|
-
value: "number"
|
|
437
|
-
},
|
|
438
|
-
{
|
|
439
|
-
label: /* @__PURE__ */ import_react.default.createElement("div", { style: labelStyle }, /* @__PURE__ */ import_react.default.createElement(import_semi_icons.default, { size: "small", svg: getSchemaIcon({ type: "boolean" }) }), firstUppercase("boolean")),
|
|
440
|
-
value: "boolean"
|
|
441
|
-
},
|
|
442
|
-
{
|
|
443
|
-
label: /* @__PURE__ */ import_react.default.createElement("div", { style: labelStyle }, /* @__PURE__ */ import_react.default.createElement(import_semi_icons.default, { size: "small", svg: getSchemaIcon({ type: "object" }) }), firstUppercase("object")),
|
|
444
|
-
value: "object"
|
|
445
|
-
}
|
|
446
|
-
];
|
|
447
|
-
var options = [
|
|
448
|
-
...baseOptions,
|
|
449
|
-
{
|
|
450
|
-
label: /* @__PURE__ */ import_react.default.createElement("div", { style: labelStyle }, /* @__PURE__ */ import_react.default.createElement(import_semi_icons.default, { size: "small", svg: getSchemaIcon({ type: "array" }) }), firstUppercase("array")),
|
|
451
|
-
value: "array",
|
|
452
|
-
children: baseOptions.map((_opt) => ({
|
|
453
|
-
..._opt,
|
|
454
|
-
value: `${_opt.value}`,
|
|
455
|
-
label: /* @__PURE__ */ import_react.default.createElement("div", { style: labelStyle }, /* @__PURE__ */ import_react.default.createElement(
|
|
456
|
-
import_semi_icons.default,
|
|
457
|
-
{
|
|
458
|
-
size: "small",
|
|
459
|
-
svg: getSchemaIcon({ type: "array", items: { type: _opt.value } })
|
|
460
|
-
}
|
|
461
|
-
), firstUppercase(_opt.value))
|
|
462
|
-
}))
|
|
463
|
-
}
|
|
464
|
-
];
|
|
465
|
-
|
|
466
|
-
// src/utils/json-schema/index.ts
|
|
467
|
-
var import_lodash = require("lodash");
|
|
468
|
-
var import_editor = require("@flowgram.ai/editor");
|
|
469
|
-
var JsonSchemaUtils;
|
|
470
|
-
((JsonSchemaUtils2) => {
|
|
471
|
-
function schemaToAST(jsonSchema) {
|
|
472
|
-
const { type, extra } = jsonSchema || {};
|
|
473
|
-
const { weak = false } = extra || {};
|
|
474
|
-
if (!type) {
|
|
475
|
-
return void 0;
|
|
266
|
+
// markdown
|
|
267
|
+
{
|
|
268
|
+
tag: [import_preset_code2.tags.heading],
|
|
269
|
+
color: "#3e76ef"
|
|
270
|
+
},
|
|
271
|
+
{
|
|
272
|
+
tag: [import_preset_code2.tags.processingInstruction],
|
|
273
|
+
color: "#3e76ef"
|
|
274
|
+
},
|
|
275
|
+
// shell
|
|
276
|
+
// curl
|
|
277
|
+
{
|
|
278
|
+
tag: [import_preset_code2.tags.standard(import_preset_code2.tags.variableName)],
|
|
279
|
+
color: "#00804A"
|
|
280
|
+
},
|
|
281
|
+
// -X
|
|
282
|
+
{
|
|
283
|
+
tag: [import_preset_code2.tags.attributeName],
|
|
284
|
+
color: "#C74200"
|
|
285
|
+
},
|
|
286
|
+
// url in string (includes quotes), e.g. "https://..."
|
|
287
|
+
{
|
|
288
|
+
tag: [import_preset_code2.tags.special(import_preset_code2.tags.string)],
|
|
289
|
+
color: "#2B57D9"
|
|
476
290
|
}
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
}
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
291
|
+
]
|
|
292
|
+
});
|
|
293
|
+
|
|
294
|
+
// src/components/code-editor/theme/dark.ts
|
|
295
|
+
var import_preset_code3 = require("@coze-editor/editor/preset-code");
|
|
296
|
+
var colors2 = {
|
|
297
|
+
background: "#151B27",
|
|
298
|
+
// syntax
|
|
299
|
+
comment: "#FFFFFF63",
|
|
300
|
+
key: "#39E5D7",
|
|
301
|
+
string: "#FF94D2",
|
|
302
|
+
number: "#FF9933",
|
|
303
|
+
boolean: "#78B0FF",
|
|
304
|
+
null: "#78B0FF",
|
|
305
|
+
separator: "#FFFFFFC9"
|
|
306
|
+
};
|
|
307
|
+
var darkTheme = (0, import_preset_code3.createTheme)({
|
|
308
|
+
variant: "dark",
|
|
309
|
+
settings: {
|
|
310
|
+
background: colors2.background,
|
|
311
|
+
foreground: "#fff",
|
|
312
|
+
caret: "#AEAFAD",
|
|
313
|
+
selection: "#d9d9d942",
|
|
314
|
+
gutterBackground: colors2.background,
|
|
315
|
+
gutterForeground: "#FFFFFF63",
|
|
316
|
+
gutterBorderColor: "transparent",
|
|
317
|
+
gutterBorderWidth: 0,
|
|
318
|
+
lineHighlight: "#272e3d36",
|
|
319
|
+
bracketColors: ["#FFEF61", "#DD99FF", "#78B0FF"],
|
|
320
|
+
tooltip: {
|
|
321
|
+
backgroundColor: "#363D4D",
|
|
322
|
+
color: "#fff",
|
|
323
|
+
border: "none"
|
|
324
|
+
},
|
|
325
|
+
link: {
|
|
326
|
+
color: "#4daafc"
|
|
327
|
+
},
|
|
328
|
+
completionItemHover: {
|
|
329
|
+
backgroundColor: "#FFFFFF0F"
|
|
330
|
+
},
|
|
331
|
+
completionItemSelected: {
|
|
332
|
+
backgroundColor: "#FFFFFF17"
|
|
333
|
+
},
|
|
334
|
+
completionItemIcon: {
|
|
335
|
+
color: "#FFFFFFC9"
|
|
336
|
+
},
|
|
337
|
+
completionItemLabel: {
|
|
338
|
+
color: "#FFFFFFC9"
|
|
339
|
+
},
|
|
340
|
+
completionItemInfo: {
|
|
341
|
+
color: "#FFFFFFC9"
|
|
342
|
+
},
|
|
343
|
+
completionItemDetail: {
|
|
344
|
+
color: "#FFFFFF63"
|
|
525
345
|
}
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
346
|
+
},
|
|
347
|
+
styles: [
|
|
348
|
+
// json
|
|
349
|
+
{
|
|
350
|
+
tag: import_preset_code3.tags.comment,
|
|
351
|
+
color: colors2.comment
|
|
352
|
+
},
|
|
353
|
+
{
|
|
354
|
+
tag: [import_preset_code3.tags.propertyName],
|
|
355
|
+
color: colors2.key
|
|
356
|
+
},
|
|
357
|
+
{
|
|
358
|
+
tag: [import_preset_code3.tags.string],
|
|
359
|
+
color: colors2.string
|
|
360
|
+
},
|
|
361
|
+
{
|
|
362
|
+
tag: [import_preset_code3.tags.number],
|
|
363
|
+
color: colors2.number
|
|
364
|
+
},
|
|
365
|
+
{
|
|
366
|
+
tag: [import_preset_code3.tags.bool],
|
|
367
|
+
color: colors2.boolean
|
|
368
|
+
},
|
|
369
|
+
{
|
|
370
|
+
tag: [import_preset_code3.tags.null],
|
|
371
|
+
color: colors2.null
|
|
372
|
+
},
|
|
373
|
+
{
|
|
374
|
+
tag: [import_preset_code3.tags.separator],
|
|
375
|
+
color: colors2.separator
|
|
376
|
+
},
|
|
377
|
+
// markdown
|
|
378
|
+
{
|
|
379
|
+
tag: [import_preset_code3.tags.heading],
|
|
380
|
+
color: "#6b6bff"
|
|
381
|
+
},
|
|
382
|
+
{
|
|
383
|
+
tag: [import_preset_code3.tags.processingInstruction],
|
|
384
|
+
color: "#6b6bff"
|
|
385
|
+
},
|
|
386
|
+
// shell
|
|
387
|
+
// curl
|
|
388
|
+
{
|
|
389
|
+
tag: [import_preset_code3.tags.standard(import_preset_code3.tags.variableName)],
|
|
390
|
+
color: "#3BEB84"
|
|
391
|
+
},
|
|
392
|
+
// -X
|
|
393
|
+
{
|
|
394
|
+
tag: [import_preset_code3.tags.attributeName],
|
|
395
|
+
color: "#FF9933"
|
|
396
|
+
},
|
|
397
|
+
// url in string (includes quotes), e.g. "https://..."
|
|
398
|
+
{
|
|
399
|
+
tag: [import_preset_code3.tags.special(import_preset_code3.tags.string)],
|
|
400
|
+
color: "#78B0FF"
|
|
530
401
|
}
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
402
|
+
]
|
|
403
|
+
});
|
|
404
|
+
|
|
405
|
+
// src/components/code-editor/theme/index.ts
|
|
406
|
+
import_preset_code4.themes.register("dark", darkTheme);
|
|
407
|
+
import_preset_code4.themes.register("light", lightTheme);
|
|
408
|
+
|
|
409
|
+
// src/components/code-editor/index.tsx
|
|
410
|
+
var OriginCodeEditor = (0, import_react3.createRenderer)(import_preset_code5.default, [
|
|
411
|
+
import_view.EditorView.theme({
|
|
412
|
+
"&.cm-focused": {
|
|
413
|
+
outline: "none"
|
|
535
414
|
}
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
415
|
+
})
|
|
416
|
+
]);
|
|
417
|
+
function CodeEditor({
|
|
418
|
+
value,
|
|
419
|
+
onChange,
|
|
420
|
+
languageId = "python",
|
|
421
|
+
theme = "light",
|
|
422
|
+
children,
|
|
423
|
+
placeholder,
|
|
424
|
+
activeLinePlaceholder,
|
|
425
|
+
options,
|
|
426
|
+
readonly
|
|
427
|
+
}) {
|
|
428
|
+
const editorRef = (0, import_react2.useRef)(null);
|
|
429
|
+
(0, import_react2.useEffect)(() => {
|
|
430
|
+
if (languageId === "typescript") {
|
|
431
|
+
initTsWorker();
|
|
540
432
|
}
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
typeAST.properties.map((property) => {
|
|
546
|
-
const schema = astToSchema(property.type);
|
|
547
|
-
if (property.meta?.title && schema) {
|
|
548
|
-
schema.title = property.meta.title;
|
|
549
|
-
}
|
|
550
|
-
if (property.meta?.description && schema) {
|
|
551
|
-
schema.description = property.meta.description;
|
|
552
|
-
}
|
|
553
|
-
return [property.key, schema];
|
|
554
|
-
})
|
|
555
|
-
) : {}
|
|
556
|
-
};
|
|
433
|
+
}, [languageId]);
|
|
434
|
+
(0, import_react2.useEffect)(() => {
|
|
435
|
+
if (editorRef.current?.getValue() !== value) {
|
|
436
|
+
editorRef.current?.setValue(String(value || ""));
|
|
557
437
|
}
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
438
|
+
}, [value]);
|
|
439
|
+
return /* @__PURE__ */ import_react2.default.createElement(import_react3.EditorProvider, null, /* @__PURE__ */ import_react2.default.createElement(
|
|
440
|
+
OriginCodeEditor,
|
|
441
|
+
{
|
|
442
|
+
defaultValue: value,
|
|
443
|
+
options: {
|
|
444
|
+
uri: `file:///untitled${getSuffixByLanguageId(languageId)}`,
|
|
445
|
+
languageId,
|
|
446
|
+
theme,
|
|
447
|
+
placeholder,
|
|
448
|
+
readOnly: readonly,
|
|
449
|
+
editable: !readonly,
|
|
450
|
+
...options || {}
|
|
451
|
+
},
|
|
452
|
+
didMount: (editor) => {
|
|
453
|
+
editorRef.current = editor;
|
|
454
|
+
},
|
|
455
|
+
onChange: (e) => onChange?.(e.value)
|
|
456
|
+
},
|
|
457
|
+
activeLinePlaceholder && /* @__PURE__ */ import_react2.default.createElement(import_react3.ActiveLinePlaceholder, null, activeLinePlaceholder),
|
|
458
|
+
children
|
|
459
|
+
));
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
// src/components/code-editor-mini/index.tsx
|
|
463
|
+
var UIMini = import_styled_components.default.div`
|
|
464
|
+
.ͼ1 .cm-content {
|
|
465
|
+
padding: 0;
|
|
466
|
+
}
|
|
467
|
+
`;
|
|
468
|
+
function CodeEditorMini(props) {
|
|
469
|
+
return /* @__PURE__ */ import_react4.default.createElement(UIMini, null, /* @__PURE__ */ import_react4.default.createElement(
|
|
470
|
+
CodeEditor,
|
|
471
|
+
{
|
|
472
|
+
...props,
|
|
473
|
+
options: {
|
|
474
|
+
lineNumbersGutter: false,
|
|
475
|
+
foldGutter: false,
|
|
476
|
+
...props.options || {}
|
|
477
|
+
}
|
|
563
478
|
}
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
479
|
+
));
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
// src/plugins/json-schema-preset/type-definition/object.tsx
|
|
483
|
+
var objectRegistry = {
|
|
484
|
+
type: "object",
|
|
485
|
+
ConstantRenderer: (props) => /* @__PURE__ */ import_react5.default.createElement(
|
|
486
|
+
CodeEditorMini,
|
|
487
|
+
{
|
|
488
|
+
value: props.value,
|
|
489
|
+
onChange: (v) => props.onChange?.(v),
|
|
490
|
+
languageId: "json",
|
|
491
|
+
placeholder: "Please Input Object",
|
|
492
|
+
readonly: props.readonly
|
|
569
493
|
}
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
494
|
+
)
|
|
495
|
+
};
|
|
496
|
+
|
|
497
|
+
// src/plugins/json-schema-preset/type-definition/number.tsx
|
|
498
|
+
var import_react6 = __toESM(require("react"));
|
|
499
|
+
var import_semi_ui2 = require("@douyinfe/semi-ui");
|
|
500
|
+
var numberRegistry = {
|
|
501
|
+
type: "number",
|
|
502
|
+
ConstantRenderer: (props) => /* @__PURE__ */ import_react6.default.createElement(
|
|
503
|
+
import_semi_ui2.InputNumber,
|
|
504
|
+
{
|
|
505
|
+
placeholder: "Please Input Number",
|
|
506
|
+
size: "small",
|
|
507
|
+
disabled: props.readonly,
|
|
508
|
+
hideButtons: true,
|
|
509
|
+
...props
|
|
510
|
+
}
|
|
511
|
+
)
|
|
512
|
+
};
|
|
513
|
+
|
|
514
|
+
// src/plugins/json-schema-preset/type-definition/integer.tsx
|
|
515
|
+
var import_react7 = __toESM(require("react"));
|
|
516
|
+
var import_semi_ui3 = require("@douyinfe/semi-ui");
|
|
517
|
+
var integerRegistry = {
|
|
518
|
+
type: "integer",
|
|
519
|
+
ConstantRenderer: (props) => /* @__PURE__ */ import_react7.default.createElement(
|
|
520
|
+
import_semi_ui3.InputNumber,
|
|
521
|
+
{
|
|
522
|
+
placeholder: "Please Input Integer",
|
|
523
|
+
size: "small",
|
|
524
|
+
disabled: props.readonly,
|
|
525
|
+
precision: 0,
|
|
526
|
+
...props
|
|
574
527
|
}
|
|
575
|
-
|
|
528
|
+
)
|
|
529
|
+
};
|
|
530
|
+
|
|
531
|
+
// src/plugins/json-schema-preset/type-definition/boolean.tsx
|
|
532
|
+
var import_react8 = __toESM(require("react"));
|
|
533
|
+
var import_semi_ui4 = require("@douyinfe/semi-ui");
|
|
534
|
+
var booleanRegistry = {
|
|
535
|
+
type: "boolean",
|
|
536
|
+
ConstantRenderer: (props) => {
|
|
537
|
+
const { value, onChange, ...rest } = props;
|
|
538
|
+
return /* @__PURE__ */ import_react8.default.createElement(
|
|
539
|
+
import_semi_ui4.Select,
|
|
540
|
+
{
|
|
541
|
+
placeholder: "Please Select Boolean",
|
|
542
|
+
size: "small",
|
|
543
|
+
disabled: props.readonly,
|
|
544
|
+
optionList: [
|
|
545
|
+
{ label: "True", value: 1 },
|
|
546
|
+
{ label: "False", value: 0 }
|
|
547
|
+
],
|
|
548
|
+
value: value ? 1 : 0,
|
|
549
|
+
onChange: (value2) => onChange?.(!!value2),
|
|
550
|
+
...rest
|
|
551
|
+
}
|
|
552
|
+
);
|
|
576
553
|
}
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
554
|
+
};
|
|
555
|
+
|
|
556
|
+
// src/plugins/json-schema-preset/type-definition/array.tsx
|
|
557
|
+
var import_react9 = __toESM(require("react"));
|
|
558
|
+
var arrayRegistry = {
|
|
559
|
+
type: "array",
|
|
560
|
+
ConstantRenderer: (props) => /* @__PURE__ */ import_react9.default.createElement(
|
|
561
|
+
CodeEditorMini,
|
|
562
|
+
{
|
|
563
|
+
value: props.value,
|
|
564
|
+
languageId: "json",
|
|
565
|
+
onChange: (v) => props.onChange?.(v),
|
|
566
|
+
placeholder: "Please Input Array",
|
|
567
|
+
readonly: props.readonly
|
|
585
568
|
}
|
|
586
|
-
|
|
569
|
+
)
|
|
570
|
+
};
|
|
571
|
+
|
|
572
|
+
// src/plugins/json-schema-preset/type-definition/index.tsx
|
|
573
|
+
var jsonSchemaTypePreset = [
|
|
574
|
+
stringRegistry,
|
|
575
|
+
objectRegistry,
|
|
576
|
+
numberRegistry,
|
|
577
|
+
integerRegistry,
|
|
578
|
+
booleanRegistry,
|
|
579
|
+
arrayRegistry
|
|
580
|
+
];
|
|
581
|
+
jsonSchemaTypePreset.forEach((_type) => import_json_schema.jsonSchemaTypeManager.register(_type));
|
|
582
|
+
|
|
583
|
+
// src/plugins/json-schema-preset/create-type-preset-plugin.tsx
|
|
584
|
+
var import_json_schema2 = require("@flowgram.ai/json-schema");
|
|
585
|
+
var import_editor2 = require("@flowgram.ai/editor");
|
|
586
|
+
var createTypePresetPlugin = (0, import_editor2.definePluginCreator)({
|
|
587
|
+
onInit(ctx, opts) {
|
|
588
|
+
const typeManager = ctx.get(import_json_schema2.BaseTypeManager);
|
|
589
|
+
jsonSchemaTypePreset.forEach((_type) => typeManager.register(_type));
|
|
590
|
+
opts.types?.forEach((_type) => typeManager.register(_type));
|
|
591
|
+
opts.unregisterTypes?.forEach((_type) => typeManager.unregister(_type));
|
|
592
|
+
},
|
|
593
|
+
containerModules: [import_json_schema2.jsonSchemaContainerModule]
|
|
594
|
+
});
|
|
595
|
+
|
|
596
|
+
// src/plugins/json-schema-preset/index.tsx
|
|
597
|
+
var useTypeManager = () => (0, import_json_schema3.useTypeManager)();
|
|
598
|
+
var JsonSchemaTypePresetProvider = ({
|
|
599
|
+
types = [],
|
|
600
|
+
children
|
|
601
|
+
}) => /* @__PURE__ */ import_react10.default.createElement(import_json_schema3.TypePresetProvider, { types: [...jsonSchemaTypePreset, ...types] }, children);
|
|
602
|
+
|
|
603
|
+
// src/plugins/disable-declaration-plugin/create-disable-declaration-plugin.ts
|
|
604
|
+
var import_editor3 = require("@flowgram.ai/editor");
|
|
605
|
+
var createDisableDeclarationPlugin = (0, import_editor3.definePluginCreator)({
|
|
606
|
+
onInit(ctx) {
|
|
607
|
+
const variableEngine = ctx.get(import_editor3.VariableEngine);
|
|
608
|
+
const handleEvent = (action) => {
|
|
609
|
+
if (import_editor3.ASTMatch.isVariableDeclaration(action.ast)) {
|
|
610
|
+
if (!action.ast.meta?.disabled) {
|
|
611
|
+
action.ast.updateMeta({
|
|
612
|
+
...action.ast.meta || {},
|
|
613
|
+
disabled: true
|
|
614
|
+
});
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
};
|
|
618
|
+
variableEngine.onGlobalEvent("NewAST", handleEvent);
|
|
619
|
+
variableEngine.onGlobalEvent("UpdateAST", handleEvent);
|
|
587
620
|
}
|
|
588
|
-
|
|
589
|
-
})(JsonSchemaUtils || (JsonSchemaUtils = {}));
|
|
621
|
+
});
|
|
590
622
|
|
|
591
623
|
// src/components/variable-selector/use-variable-tree.tsx
|
|
592
624
|
function useVariableTree(params) {
|
|
593
|
-
const { includeSchema, excludeSchema } = params;
|
|
594
|
-
const
|
|
595
|
-
const
|
|
625
|
+
const { includeSchema, excludeSchema, customSkip } = params;
|
|
626
|
+
const typeManager = useTypeManager();
|
|
627
|
+
const variables = (0, import_editor4.useAvailableVariables)();
|
|
628
|
+
const getVariableTypeIcon = (0, import_react11.useCallback)((variable) => {
|
|
596
629
|
if (variable.meta?.icon) {
|
|
597
630
|
if (typeof variable.meta.icon === "string") {
|
|
598
|
-
return /* @__PURE__ */
|
|
631
|
+
return /* @__PURE__ */ import_react11.default.createElement("img", { style: { marginRight: 8 }, width: 12, height: 12, src: variable.meta.icon });
|
|
599
632
|
}
|
|
600
633
|
return variable.meta.icon;
|
|
601
634
|
}
|
|
602
|
-
const
|
|
603
|
-
|
|
604
|
-
return /* @__PURE__ */ import_react2.default.createElement(
|
|
605
|
-
import_semi_ui.Icon,
|
|
606
|
-
{
|
|
607
|
-
size: "small",
|
|
608
|
-
svg: ArrayIcons[_type.items?.kind.toLowerCase()] || VariableTypeIcons.array
|
|
609
|
-
}
|
|
610
|
-
);
|
|
611
|
-
}
|
|
612
|
-
if (import_editor2.ASTMatch.isCustomType(_type)) {
|
|
613
|
-
return /* @__PURE__ */ import_react2.default.createElement(import_semi_ui.Icon, { size: "small", svg: VariableTypeIcons[_type.typeName.toLowerCase()] });
|
|
614
|
-
}
|
|
615
|
-
return /* @__PURE__ */ import_react2.default.createElement(import_semi_ui.Icon, { size: "small", svg: VariableTypeIcons[variable.type?.kind.toLowerCase()] });
|
|
635
|
+
const schema = import_json_schema4.JsonSchemaUtils.astToSchema(variable.type, { drilldownObject: false });
|
|
636
|
+
return /* @__PURE__ */ import_react11.default.createElement(import_semi_ui5.Icon, { size: "small", svg: typeManager.getDisplayIcon(schema || {}) });
|
|
616
637
|
}, []);
|
|
617
638
|
const renderVariable = (variable, parentFields = []) => {
|
|
618
639
|
let type = variable?.type;
|
|
@@ -620,14 +641,16 @@ function useVariableTree(params) {
|
|
|
620
641
|
return null;
|
|
621
642
|
}
|
|
622
643
|
let children;
|
|
623
|
-
if (
|
|
644
|
+
if (import_editor4.ASTMatch.isObject(type)) {
|
|
624
645
|
children = (type.properties || []).map((_property) => renderVariable(_property, [...parentFields, variable])).filter(Boolean);
|
|
625
646
|
}
|
|
626
647
|
const keyPath = [...parentFields.map((_field) => _field.key), variable.key];
|
|
627
648
|
const key = keyPath.join(".");
|
|
628
|
-
const isSchemaInclude = includeSchema ? JsonSchemaUtils.isASTMatchSchema(type, includeSchema) : true;
|
|
629
|
-
const isSchemaExclude = excludeSchema ? JsonSchemaUtils.isASTMatchSchema(type, excludeSchema) : false;
|
|
630
|
-
const
|
|
649
|
+
const isSchemaInclude = includeSchema ? import_json_schema4.JsonSchemaUtils.isASTMatchSchema(type, includeSchema) : true;
|
|
650
|
+
const isSchemaExclude = excludeSchema ? import_json_schema4.JsonSchemaUtils.isASTMatchSchema(type, excludeSchema) : false;
|
|
651
|
+
const isCustomSkip = customSkip ? customSkip(variable) : false;
|
|
652
|
+
const isMetaDisabled = variable.meta?.disabled;
|
|
653
|
+
const isSchemaMatch = isSchemaInclude && !isSchemaExclude && !isCustomSkip && !isMetaDisabled;
|
|
631
654
|
if (!isSchemaMatch && !children?.length) {
|
|
632
655
|
return null;
|
|
633
656
|
}
|
|
@@ -639,16 +662,17 @@ function useVariableTree(params) {
|
|
|
639
662
|
icon: getVariableTypeIcon(variable),
|
|
640
663
|
children,
|
|
641
664
|
disabled: !isSchemaMatch,
|
|
642
|
-
rootMeta: parentFields[0]?.meta
|
|
665
|
+
rootMeta: parentFields[0]?.meta || variable.meta,
|
|
666
|
+
isRoot: !parentFields?.length
|
|
643
667
|
};
|
|
644
668
|
};
|
|
645
669
|
return [...variables.slice(0).reverse()].map((_variable) => renderVariable(_variable)).filter(Boolean);
|
|
646
670
|
}
|
|
647
671
|
|
|
648
672
|
// src/components/variable-selector/styles.tsx
|
|
649
|
-
var
|
|
650
|
-
var
|
|
651
|
-
var UIRootTitle =
|
|
673
|
+
var import_styled_components2 = __toESM(require("styled-components"));
|
|
674
|
+
var import_semi_ui6 = require("@douyinfe/semi-ui");
|
|
675
|
+
var UIRootTitle = import_styled_components2.default.div`
|
|
652
676
|
margin-right: 4px;
|
|
653
677
|
min-width: 20px;
|
|
654
678
|
overflow: hidden;
|
|
@@ -656,13 +680,16 @@ var UIRootTitle = import_styled_components.default.div`
|
|
|
656
680
|
white-space: nowrap;
|
|
657
681
|
color: var(--semi-color-text-2);
|
|
658
682
|
`;
|
|
659
|
-
var UIVarName =
|
|
683
|
+
var UIVarName = import_styled_components2.default.div`
|
|
660
684
|
overflow: hidden;
|
|
661
685
|
text-overflow: ellipsis;
|
|
662
686
|
white-space: nowrap;
|
|
663
|
-
|
|
687
|
+
|
|
688
|
+
${({ $inSelector }) => $inSelector && import_styled_components2.css`
|
|
689
|
+
min-width: 50%;
|
|
690
|
+
`}
|
|
664
691
|
`;
|
|
665
|
-
var UITag = (0,
|
|
692
|
+
var UITag = (0, import_styled_components2.default)(import_semi_ui6.Tag)`
|
|
666
693
|
width: 100%;
|
|
667
694
|
display: flex;
|
|
668
695
|
align-items: center;
|
|
@@ -674,17 +701,14 @@ var UITag = (0, import_styled_components.default)(import_semi_ui2.Tag)`
|
|
|
674
701
|
|
|
675
702
|
&.semi-tag {
|
|
676
703
|
margin: 0;
|
|
704
|
+
height: 22px;
|
|
677
705
|
}
|
|
678
706
|
`;
|
|
679
|
-
var UITreeSelect = (0,
|
|
707
|
+
var UITreeSelect = (0, import_styled_components2.default)(import_semi_ui6.TreeSelect)`
|
|
680
708
|
outline: ${({ $error }) => $error ? "1px solid red" : "none"};
|
|
681
709
|
|
|
682
|
-
height: 22px;
|
|
683
|
-
min-height: 22px;
|
|
684
|
-
line-height: 22px;
|
|
685
|
-
|
|
686
710
|
& .semi-tree-select-selection {
|
|
687
|
-
padding:
|
|
711
|
+
padding: 0px;
|
|
688
712
|
height: 22px;
|
|
689
713
|
}
|
|
690
714
|
|
|
@@ -696,6 +720,13 @@ var UITreeSelect = (0, import_styled_components.default)(import_semi_ui2.TreeSel
|
|
|
696
720
|
padding-left: 10px;
|
|
697
721
|
}
|
|
698
722
|
`;
|
|
723
|
+
var UIPopoverContent = import_styled_components2.default.div`
|
|
724
|
+
padding: 10px;
|
|
725
|
+
display: inline-flex;
|
|
726
|
+
align-items: center;
|
|
727
|
+
justify-content: flex-start;
|
|
728
|
+
white-space: nowrap;
|
|
729
|
+
`;
|
|
699
730
|
|
|
700
731
|
// src/components/variable-selector/index.tsx
|
|
701
732
|
var VariableSelector = ({
|
|
@@ -710,7 +741,7 @@ var VariableSelector = ({
|
|
|
710
741
|
triggerRender
|
|
711
742
|
}) => {
|
|
712
743
|
const treeData = useVariableTree({ includeSchema, excludeSchema });
|
|
713
|
-
const treeValue = (0,
|
|
744
|
+
const treeValue = (0, import_react12.useMemo)(() => {
|
|
714
745
|
if (typeof value === "string") {
|
|
715
746
|
console.warn(
|
|
716
747
|
"The Value of VariableSelector is a string, it should be an ARRAY. \n",
|
|
@@ -722,11 +753,11 @@ var VariableSelector = ({
|
|
|
722
753
|
}, [value]);
|
|
723
754
|
const renderIcon = (icon) => {
|
|
724
755
|
if (typeof icon === "string") {
|
|
725
|
-
return /* @__PURE__ */
|
|
756
|
+
return /* @__PURE__ */ import_react12.default.createElement("img", { style: { marginRight: 8 }, width: 12, height: 12, src: icon });
|
|
726
757
|
}
|
|
727
758
|
return icon;
|
|
728
759
|
};
|
|
729
|
-
return /* @__PURE__ */
|
|
760
|
+
return /* @__PURE__ */ import_react12.default.createElement(import_react12.default.Fragment, null, /* @__PURE__ */ import_react12.default.createElement(
|
|
730
761
|
UITreeSelect,
|
|
731
762
|
{
|
|
732
763
|
dropdownMatchSelectWidth: false,
|
|
@@ -743,10 +774,10 @@ var VariableSelector = ({
|
|
|
743
774
|
},
|
|
744
775
|
renderSelectedItem: (_option) => {
|
|
745
776
|
if (!_option?.keyPath) {
|
|
746
|
-
return /* @__PURE__ */
|
|
777
|
+
return /* @__PURE__ */ import_react12.default.createElement(
|
|
747
778
|
UITag,
|
|
748
779
|
{
|
|
749
|
-
prefixIcon: /* @__PURE__ */
|
|
780
|
+
prefixIcon: /* @__PURE__ */ import_react12.default.createElement(import_semi_icons.IconIssueStroked, null),
|
|
750
781
|
color: "amber",
|
|
751
782
|
closable: !readonly,
|
|
752
783
|
onClose: () => onChange(void 0)
|
|
@@ -754,28 +785,38 @@ var VariableSelector = ({
|
|
|
754
785
|
config?.notFoundContent ?? "Undefined"
|
|
755
786
|
);
|
|
756
787
|
}
|
|
757
|
-
|
|
758
|
-
|
|
788
|
+
const rootIcon = renderIcon(_option.rootMeta?.icon || _option?.icon);
|
|
789
|
+
const rootTitle = /* @__PURE__ */ import_react12.default.createElement(UIRootTitle, null, _option.rootMeta?.title ? `${_option.rootMeta?.title} ${_option.isRoot ? "" : "-"} ` : null);
|
|
790
|
+
return /* @__PURE__ */ import_react12.default.createElement("div", null, /* @__PURE__ */ import_react12.default.createElement(
|
|
791
|
+
import_semi_ui7.Popover,
|
|
759
792
|
{
|
|
760
|
-
|
|
761
|
-
closable: !readonly,
|
|
762
|
-
onClose: () => onChange(void 0)
|
|
793
|
+
content: /* @__PURE__ */ import_react12.default.createElement(UIPopoverContent, null, rootIcon, rootTitle, /* @__PURE__ */ import_react12.default.createElement(UIVarName, null, _option.keyPath.slice(1).join(".")))
|
|
763
794
|
},
|
|
764
|
-
/* @__PURE__ */
|
|
765
|
-
|
|
766
|
-
|
|
795
|
+
/* @__PURE__ */ import_react12.default.createElement(
|
|
796
|
+
UITag,
|
|
797
|
+
{
|
|
798
|
+
prefixIcon: rootIcon,
|
|
799
|
+
closable: !readonly,
|
|
800
|
+
onClose: () => onChange(void 0)
|
|
801
|
+
},
|
|
802
|
+
rootTitle,
|
|
803
|
+
!_option.isRoot && /* @__PURE__ */ import_react12.default.createElement(UIVarName, { $inSelector: true }, _option.label)
|
|
804
|
+
)
|
|
805
|
+
));
|
|
767
806
|
},
|
|
768
807
|
showClear: false,
|
|
769
|
-
arrowIcon: /* @__PURE__ */
|
|
808
|
+
arrowIcon: /* @__PURE__ */ import_react12.default.createElement(import_semi_icons.IconChevronDownStroked, { size: "small" }),
|
|
770
809
|
triggerRender,
|
|
771
|
-
placeholder: config?.placeholder ?? "Select Variable
|
|
810
|
+
placeholder: config?.placeholder ?? "Select Variable"
|
|
772
811
|
}
|
|
773
812
|
));
|
|
774
813
|
};
|
|
775
814
|
|
|
776
815
|
// src/components/type-selector/index.tsx
|
|
777
|
-
var
|
|
778
|
-
var
|
|
816
|
+
var import_react13 = __toESM(require("react"));
|
|
817
|
+
var import_semi_ui8 = require("@douyinfe/semi-ui");
|
|
818
|
+
var labelStyle = { display: "flex", alignItems: "center", gap: 5 };
|
|
819
|
+
var firstUppercase = (str) => str.charAt(0).toUpperCase() + str.slice(1);
|
|
779
820
|
var getTypeSelectValue = (value) => {
|
|
780
821
|
if (value?.type === "array" && value?.items) {
|
|
781
822
|
return [value.type, ...getTypeSelectValue(value.items) || []];
|
|
@@ -790,69 +831,94 @@ var parseTypeSelectValue = (value) => {
|
|
|
790
831
|
return { type };
|
|
791
832
|
};
|
|
792
833
|
function TypeSelector(props) {
|
|
793
|
-
const { value, onChange, disabled, style } = props;
|
|
794
|
-
const selectValue = (0,
|
|
795
|
-
|
|
796
|
-
|
|
834
|
+
const { value, onChange, readonly, disabled, style } = props;
|
|
835
|
+
const selectValue = (0, import_react13.useMemo)(() => getTypeSelectValue(value), [value]);
|
|
836
|
+
const typeManager = useTypeManager();
|
|
837
|
+
const icon = typeManager.getDisplayIcon(value || {});
|
|
838
|
+
const options = (0, import_react13.useMemo)(
|
|
839
|
+
() => typeManager.getTypeRegistriesWithParentType().map((_type) => {
|
|
840
|
+
const isArray2 = _type.type === "array";
|
|
841
|
+
return {
|
|
842
|
+
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)),
|
|
843
|
+
value: _type.type,
|
|
844
|
+
children: isArray2 ? typeManager.getTypeRegistriesWithParentType("array").map((_type2) => ({
|
|
845
|
+
label: /* @__PURE__ */ import_react13.default.createElement("div", { style: labelStyle }, /* @__PURE__ */ import_react13.default.createElement(
|
|
846
|
+
import_semi_ui8.Icon,
|
|
847
|
+
{
|
|
848
|
+
size: "small",
|
|
849
|
+
svg: typeManager.getDisplayIcon({
|
|
850
|
+
type: "array",
|
|
851
|
+
items: { type: _type2.type }
|
|
852
|
+
})
|
|
853
|
+
}
|
|
854
|
+
), firstUppercase(_type2.type)),
|
|
855
|
+
value: _type2.type
|
|
856
|
+
})) : []
|
|
857
|
+
};
|
|
858
|
+
}),
|
|
859
|
+
[]
|
|
860
|
+
);
|
|
861
|
+
return /* @__PURE__ */ import_react13.default.createElement(
|
|
862
|
+
import_semi_ui8.Cascader,
|
|
797
863
|
{
|
|
798
|
-
disabled,
|
|
864
|
+
disabled: readonly || disabled,
|
|
799
865
|
size: "small",
|
|
800
|
-
triggerRender: () => /* @__PURE__ */
|
|
866
|
+
triggerRender: () => /* @__PURE__ */ import_react13.default.createElement(import_semi_ui8.IconButton, { size: "small", style, disabled: readonly || disabled, icon }),
|
|
801
867
|
treeData: options,
|
|
802
868
|
value: selectValue,
|
|
803
869
|
leafOnly: true,
|
|
804
870
|
onChange: (value2) => {
|
|
805
|
-
onChange(parseTypeSelectValue(value2));
|
|
871
|
+
onChange?.(parseTypeSelectValue(value2));
|
|
806
872
|
}
|
|
807
873
|
}
|
|
808
874
|
);
|
|
809
875
|
}
|
|
810
876
|
|
|
811
877
|
// src/components/json-schema-editor/index.tsx
|
|
812
|
-
var
|
|
813
|
-
var
|
|
814
|
-
var
|
|
878
|
+
var import_react19 = __toESM(require("react"));
|
|
879
|
+
var import_semi_ui11 = require("@douyinfe/semi-ui");
|
|
880
|
+
var import_semi_icons4 = require("@douyinfe/semi-icons");
|
|
815
881
|
|
|
816
882
|
// src/components/json-schema-editor/styles.tsx
|
|
817
|
-
var
|
|
818
|
-
var
|
|
819
|
-
var
|
|
820
|
-
var UIContainer =
|
|
883
|
+
var import_react14 = __toESM(require("react"));
|
|
884
|
+
var import_styled_components3 = __toESM(require("styled-components"));
|
|
885
|
+
var import_semi_icons2 = __toESM(require("@douyinfe/semi-icons"));
|
|
886
|
+
var UIContainer = import_styled_components3.default.div`
|
|
821
887
|
/* & .semi-input {
|
|
822
888
|
background-color: #fff;
|
|
823
889
|
border-radius: 6px;
|
|
824
890
|
height: 24px;
|
|
825
891
|
} */
|
|
826
892
|
`;
|
|
827
|
-
var UIRow =
|
|
893
|
+
var UIRow = import_styled_components3.default.div`
|
|
828
894
|
display: flex;
|
|
829
895
|
align-items: center;
|
|
830
896
|
gap: 6px;
|
|
831
897
|
`;
|
|
832
|
-
var UICollapseTrigger =
|
|
898
|
+
var UICollapseTrigger = import_styled_components3.default.div`
|
|
833
899
|
cursor: pointer;
|
|
834
900
|
margin-right: 5px;
|
|
835
901
|
`;
|
|
836
|
-
var UIExpandDetail =
|
|
902
|
+
var UIExpandDetail = import_styled_components3.default.div`
|
|
837
903
|
display: flex;
|
|
838
904
|
flex-direction: column;
|
|
839
905
|
`;
|
|
840
|
-
var UILabel =
|
|
906
|
+
var UILabel = import_styled_components3.default.div`
|
|
841
907
|
font-size: 12px;
|
|
842
908
|
color: #999;
|
|
843
909
|
font-weight: 400;
|
|
844
910
|
margin-bottom: 2px;
|
|
845
911
|
`;
|
|
846
|
-
var UIProperties =
|
|
912
|
+
var UIProperties = import_styled_components3.default.div`
|
|
847
913
|
display: grid;
|
|
848
914
|
grid-template-columns: auto 1fr;
|
|
849
915
|
|
|
850
|
-
${({ $shrink }) => $shrink &&
|
|
916
|
+
${({ $shrink }) => $shrink && import_styled_components3.css`
|
|
851
917
|
padding-left: 10px;
|
|
852
918
|
margin-top: 10px;
|
|
853
919
|
`}
|
|
854
920
|
`;
|
|
855
|
-
var UIPropertyLeft =
|
|
921
|
+
var UIPropertyLeft = import_styled_components3.default.div`
|
|
856
922
|
grid-column: 1;
|
|
857
923
|
position: relative;
|
|
858
924
|
width: 16px;
|
|
@@ -862,7 +928,7 @@ var UIPropertyLeft = import_styled_components2.default.div`
|
|
|
862
928
|
if ($parentType && $isLast) {
|
|
863
929
|
height = "24px";
|
|
864
930
|
}
|
|
865
|
-
return $showLine &&
|
|
931
|
+
return $showLine && import_styled_components3.css`
|
|
866
932
|
&::before {
|
|
867
933
|
/* 竖线 */
|
|
868
934
|
content: '';
|
|
@@ -889,7 +955,7 @@ var UIPropertyLeft = import_styled_components2.default.div`
|
|
|
889
955
|
`;
|
|
890
956
|
}}
|
|
891
957
|
`;
|
|
892
|
-
var UIPropertyRight =
|
|
958
|
+
var UIPropertyRight = import_styled_components3.default.div`
|
|
893
959
|
grid-column: 2;
|
|
894
960
|
margin-bottom: 10px;
|
|
895
961
|
|
|
@@ -897,7 +963,7 @@ var UIPropertyRight = import_styled_components2.default.div`
|
|
|
897
963
|
margin-bottom: 0px;
|
|
898
964
|
}
|
|
899
965
|
`;
|
|
900
|
-
var UIPropertyMain =
|
|
966
|
+
var UIPropertyMain = import_styled_components3.default.div`
|
|
901
967
|
display: flex;
|
|
902
968
|
flex-direction: column;
|
|
903
969
|
gap: 10px;
|
|
@@ -916,33 +982,33 @@ var UIPropertyMain = import_styled_components2.default.div`
|
|
|
916
982
|
background: #d9d9d9;
|
|
917
983
|
display: block;
|
|
918
984
|
}`;
|
|
919
|
-
return $expand &&
|
|
985
|
+
return $expand && import_styled_components3.css`
|
|
920
986
|
background-color: #f5f5f5;
|
|
921
987
|
padding: 10px;
|
|
922
988
|
border-radius: 4px;
|
|
923
989
|
|
|
924
|
-
${$showCollapse && $collapse && (type === "array" || type === "object") &&
|
|
990
|
+
${$showCollapse && $collapse && (type === "array" || type === "object") && import_styled_components3.css`
|
|
925
991
|
${beforeElement}
|
|
926
992
|
`}
|
|
927
993
|
`;
|
|
928
994
|
}}
|
|
929
995
|
`;
|
|
930
|
-
var UICollapsible =
|
|
996
|
+
var UICollapsible = import_styled_components3.default.div`
|
|
931
997
|
display: none;
|
|
932
998
|
|
|
933
|
-
${({ $collapse }) => $collapse &&
|
|
999
|
+
${({ $collapse }) => $collapse && import_styled_components3.css`
|
|
934
1000
|
display: block;
|
|
935
1001
|
`}
|
|
936
1002
|
`;
|
|
937
|
-
var UIName =
|
|
1003
|
+
var UIName = import_styled_components3.default.div`
|
|
938
1004
|
flex-grow: 1;
|
|
939
1005
|
`;
|
|
940
|
-
var UIType =
|
|
941
|
-
var UIRequired =
|
|
942
|
-
var UIActions =
|
|
1006
|
+
var UIType = import_styled_components3.default.div``;
|
|
1007
|
+
var UIRequired = import_styled_components3.default.div``;
|
|
1008
|
+
var UIActions = import_styled_components3.default.div`
|
|
943
1009
|
white-space: nowrap;
|
|
944
1010
|
`;
|
|
945
|
-
var iconAddChildrenSvg = /* @__PURE__ */
|
|
1011
|
+
var iconAddChildrenSvg = /* @__PURE__ */ import_react14.default.createElement(
|
|
946
1012
|
"svg",
|
|
947
1013
|
{
|
|
948
1014
|
className: "icon-icon icon-icon-coz_add_node ",
|
|
@@ -952,7 +1018,7 @@ var iconAddChildrenSvg = /* @__PURE__ */ import_react5.default.createElement(
|
|
|
952
1018
|
fill: "currentColor",
|
|
953
1019
|
xmlns: "http://www.w3.org/2000/svg"
|
|
954
1020
|
},
|
|
955
|
-
/* @__PURE__ */
|
|
1021
|
+
/* @__PURE__ */ import_react14.default.createElement(
|
|
956
1022
|
"path",
|
|
957
1023
|
{
|
|
958
1024
|
fillRule: "evenodd",
|
|
@@ -960,19 +1026,19 @@ var iconAddChildrenSvg = /* @__PURE__ */ import_react5.default.createElement(
|
|
|
960
1026
|
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"
|
|
961
1027
|
}
|
|
962
1028
|
),
|
|
963
|
-
/* @__PURE__ */
|
|
1029
|
+
/* @__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" })
|
|
964
1030
|
);
|
|
965
|
-
var IconAddChildren = () => /* @__PURE__ */
|
|
966
|
-
var DefaultValueWrapper =
|
|
1031
|
+
var IconAddChildren = () => /* @__PURE__ */ import_react14.default.createElement(import_semi_icons2.default, { size: "small", svg: iconAddChildrenSvg });
|
|
1032
|
+
var DefaultValueWrapper = import_styled_components3.default.div`
|
|
967
1033
|
margin: 0;
|
|
968
1034
|
`;
|
|
969
|
-
var JSONViewerWrapper =
|
|
1035
|
+
var JSONViewerWrapper = import_styled_components3.default.div`
|
|
970
1036
|
padding: 0 0 24px;
|
|
971
1037
|
&:first-child {
|
|
972
1038
|
margin-top: 0px;
|
|
973
1039
|
}
|
|
974
1040
|
`;
|
|
975
|
-
var JSONHeader =
|
|
1041
|
+
var JSONHeader = import_styled_components3.default.div`
|
|
976
1042
|
display: flex;
|
|
977
1043
|
justify-content: space-between;
|
|
978
1044
|
align-items: center;
|
|
@@ -981,17 +1047,17 @@ var JSONHeader = import_styled_components2.default.div`
|
|
|
981
1047
|
height: 36px;
|
|
982
1048
|
padding: 0 8px 0 12px;
|
|
983
1049
|
`;
|
|
984
|
-
var JSONHeaderLeft =
|
|
1050
|
+
var JSONHeaderLeft = import_styled_components3.default.div`
|
|
985
1051
|
display: flex;
|
|
986
1052
|
align-items: center;
|
|
987
1053
|
gap: 10px;
|
|
988
1054
|
`;
|
|
989
|
-
var JSONHeaderRight =
|
|
1055
|
+
var JSONHeaderRight = import_styled_components3.default.div`
|
|
990
1056
|
display: flex;
|
|
991
1057
|
align-items: center;
|
|
992
1058
|
gap: 10px;
|
|
993
1059
|
`;
|
|
994
|
-
var ConstantInputWrapper =
|
|
1060
|
+
var ConstantInputWrapper = import_styled_components3.default.div`
|
|
995
1061
|
flex-grow: 1;
|
|
996
1062
|
|
|
997
1063
|
& .semi-tree-select,
|
|
@@ -1002,7 +1068,8 @@ var ConstantInputWrapper = import_styled_components2.default.div`
|
|
|
1002
1068
|
`;
|
|
1003
1069
|
|
|
1004
1070
|
// src/components/json-schema-editor/hooks.tsx
|
|
1005
|
-
var
|
|
1071
|
+
var import_react15 = require("react");
|
|
1072
|
+
var import_lodash = require("lodash");
|
|
1006
1073
|
var _id = 0;
|
|
1007
1074
|
function genId() {
|
|
1008
1075
|
return _id++;
|
|
@@ -1017,9 +1084,9 @@ function getDrilldownSchema(value, path) {
|
|
|
1017
1084
|
return { schema: value, path };
|
|
1018
1085
|
}
|
|
1019
1086
|
function usePropertiesEdit(value, onChange) {
|
|
1020
|
-
const drilldown = (0,
|
|
1087
|
+
const drilldown = (0, import_react15.useMemo)(() => getDrilldownSchema(value), [value, value?.type, value?.items]);
|
|
1021
1088
|
const isDrilldownObject = drilldown.schema?.type === "object";
|
|
1022
|
-
const initPropertyList = (0,
|
|
1089
|
+
const initPropertyList = (0, import_react15.useMemo)(
|
|
1023
1090
|
() => isDrilldownObject ? Object.entries(drilldown.schema?.properties || {}).sort(([, a], [, b]) => (a.extra?.index ?? 0) - (b.extra?.index ?? 0)).map(
|
|
1024
1091
|
([name, _value], index) => ({
|
|
1025
1092
|
key: genId(),
|
|
@@ -1034,9 +1101,9 @@ function usePropertiesEdit(value, onChange) {
|
|
|
1034
1101
|
) : [],
|
|
1035
1102
|
[isDrilldownObject]
|
|
1036
1103
|
);
|
|
1037
|
-
const [propertyList, setPropertyList] = (0,
|
|
1038
|
-
const mountRef = (0,
|
|
1039
|
-
(0,
|
|
1104
|
+
const [propertyList, setPropertyList] = (0, import_react15.useState)(initPropertyList);
|
|
1105
|
+
const mountRef = (0, import_react15.useRef)(false);
|
|
1106
|
+
(0, import_react15.useEffect)(() => {
|
|
1040
1107
|
if (mountRef.current) {
|
|
1041
1108
|
setPropertyList((_list) => {
|
|
1042
1109
|
const nameMap = /* @__PURE__ */ new Map();
|
|
@@ -1075,7 +1142,7 @@ function usePropertiesEdit(value, onChange) {
|
|
|
1075
1142
|
if (!_property.name) {
|
|
1076
1143
|
continue;
|
|
1077
1144
|
}
|
|
1078
|
-
nextProperties[_property.name] = _property;
|
|
1145
|
+
nextProperties[_property.name] = (0, import_lodash.omit)(_property, ["key", "name", "isPropertyRequired"]);
|
|
1079
1146
|
if (_property.isPropertyRequired) {
|
|
1080
1147
|
nextRequired.push(_property.name);
|
|
1081
1148
|
}
|
|
@@ -1104,7 +1171,7 @@ function usePropertiesEdit(value, onChange) {
|
|
|
1104
1171
|
(_list) => _list.map((_property) => _property.key === key ? nextValue : _property)
|
|
1105
1172
|
);
|
|
1106
1173
|
};
|
|
1107
|
-
(0,
|
|
1174
|
+
(0, import_react15.useEffect)(() => {
|
|
1108
1175
|
if (!isDrilldownObject) {
|
|
1109
1176
|
setPropertyList([]);
|
|
1110
1177
|
}
|
|
@@ -1119,9 +1186,9 @@ function usePropertiesEdit(value, onChange) {
|
|
|
1119
1186
|
}
|
|
1120
1187
|
|
|
1121
1188
|
// src/components/json-schema-editor/default-value.tsx
|
|
1122
|
-
var
|
|
1123
|
-
var
|
|
1124
|
-
var
|
|
1189
|
+
var import_react17 = __toESM(require("react"));
|
|
1190
|
+
var import_semi_ui10 = require("@douyinfe/semi-ui");
|
|
1191
|
+
var import_semi_icons3 = require("@douyinfe/semi-icons");
|
|
1125
1192
|
|
|
1126
1193
|
// src/components/json-schema-editor/utils.ts
|
|
1127
1194
|
function getValueType(value) {
|
|
@@ -1143,100 +1210,54 @@ function getValueType(value) {
|
|
|
1143
1210
|
}
|
|
1144
1211
|
|
|
1145
1212
|
// src/components/constant-input/index.tsx
|
|
1146
|
-
var
|
|
1147
|
-
var
|
|
1148
|
-
var defaultStrategies = [
|
|
1149
|
-
{
|
|
1150
|
-
hit: (schema) => schema?.type === "string",
|
|
1151
|
-
Renderer: (props) => /* @__PURE__ */ import_react7.default.createElement(import_semi_ui4.Input, { placeholder: "Please Input String", size: "small", disabled: props.readonly, ...props })
|
|
1152
|
-
},
|
|
1153
|
-
{
|
|
1154
|
-
hit: (schema) => schema?.type === "number",
|
|
1155
|
-
Renderer: (props) => /* @__PURE__ */ import_react7.default.createElement(
|
|
1156
|
-
import_semi_ui4.InputNumber,
|
|
1157
|
-
{
|
|
1158
|
-
placeholder: "Please Input Number",
|
|
1159
|
-
size: "small",
|
|
1160
|
-
disabled: props.readonly,
|
|
1161
|
-
hideButtons: true,
|
|
1162
|
-
...props
|
|
1163
|
-
}
|
|
1164
|
-
)
|
|
1165
|
-
},
|
|
1166
|
-
{
|
|
1167
|
-
hit: (schema) => schema?.type === "integer",
|
|
1168
|
-
Renderer: (props) => /* @__PURE__ */ import_react7.default.createElement(
|
|
1169
|
-
import_semi_ui4.InputNumber,
|
|
1170
|
-
{
|
|
1171
|
-
placeholder: "Please Input Integer",
|
|
1172
|
-
size: "small",
|
|
1173
|
-
disabled: props.readonly,
|
|
1174
|
-
hideButtons: true,
|
|
1175
|
-
precision: 0,
|
|
1176
|
-
...props
|
|
1177
|
-
}
|
|
1178
|
-
)
|
|
1179
|
-
},
|
|
1180
|
-
{
|
|
1181
|
-
hit: (schema) => schema?.type === "boolean",
|
|
1182
|
-
Renderer: (props) => {
|
|
1183
|
-
const { value, onChange, ...rest } = props;
|
|
1184
|
-
return /* @__PURE__ */ import_react7.default.createElement(
|
|
1185
|
-
import_semi_ui4.Select,
|
|
1186
|
-
{
|
|
1187
|
-
placeholder: "Please Select Boolean",
|
|
1188
|
-
size: "small",
|
|
1189
|
-
disabled: props.readonly,
|
|
1190
|
-
optionList: [
|
|
1191
|
-
{ label: "True", value: 1 },
|
|
1192
|
-
{ label: "False", value: 0 }
|
|
1193
|
-
],
|
|
1194
|
-
value: value ? 1 : 0,
|
|
1195
|
-
onChange: (value2) => onChange?.(!!value2),
|
|
1196
|
-
...rest
|
|
1197
|
-
}
|
|
1198
|
-
);
|
|
1199
|
-
}
|
|
1200
|
-
}
|
|
1201
|
-
];
|
|
1213
|
+
var import_react16 = __toESM(require("react"));
|
|
1214
|
+
var import_semi_ui9 = require("@douyinfe/semi-ui");
|
|
1202
1215
|
function ConstantInput(props) {
|
|
1203
|
-
const { value, onChange, schema, strategies
|
|
1204
|
-
const
|
|
1205
|
-
|
|
1206
|
-
[
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1216
|
+
const { value, onChange, schema, strategies, fallbackRenderer, readonly, ...rest } = props;
|
|
1217
|
+
const typeManager = useTypeManager();
|
|
1218
|
+
const Renderer2 = (0, import_react16.useMemo)(() => {
|
|
1219
|
+
const strategy = (strategies || []).find((_strategy) => _strategy.hit(schema));
|
|
1220
|
+
if (!strategy) {
|
|
1221
|
+
return typeManager.getTypeBySchema(schema)?.ConstantRenderer;
|
|
1222
|
+
}
|
|
1210
1223
|
return strategy?.Renderer;
|
|
1211
1224
|
}, [strategies, schema]);
|
|
1212
1225
|
if (!Renderer2) {
|
|
1213
|
-
|
|
1226
|
+
if (fallbackRenderer) {
|
|
1227
|
+
return import_react16.default.createElement(fallbackRenderer, {
|
|
1228
|
+
value,
|
|
1229
|
+
onChange,
|
|
1230
|
+
readonly,
|
|
1231
|
+
...rest
|
|
1232
|
+
});
|
|
1233
|
+
}
|
|
1234
|
+
return /* @__PURE__ */ import_react16.default.createElement(import_semi_ui9.Input, { size: "small", disabled: true, placeholder: "Unsupported type" });
|
|
1214
1235
|
}
|
|
1215
|
-
return /* @__PURE__ */
|
|
1236
|
+
return /* @__PURE__ */ import_react16.default.createElement(Renderer2, { value, onChange, readonly, ...rest });
|
|
1216
1237
|
}
|
|
1217
1238
|
|
|
1218
1239
|
// src/components/json-schema-editor/default-value.tsx
|
|
1219
1240
|
function DefaultValue(props) {
|
|
1220
1241
|
const { value, schema, type, onChange, placeholder, jsonFormatText } = props;
|
|
1221
|
-
const wrapperRef = (0,
|
|
1222
|
-
const JsonViewerRef = (0,
|
|
1223
|
-
const [internalJsonValue, setInternalJsonValue] = (0,
|
|
1242
|
+
const wrapperRef = (0, import_react17.useRef)(null);
|
|
1243
|
+
const JsonViewerRef = (0, import_react17.useRef)(null);
|
|
1244
|
+
const [internalJsonValue, setInternalJsonValue] = (0, import_react17.useState)(
|
|
1224
1245
|
getValueType(value) === "string" ? value : ""
|
|
1225
1246
|
);
|
|
1226
|
-
const handleJsonChange = (0,
|
|
1247
|
+
const handleJsonChange = (0, import_react17.useCallback)((val) => {
|
|
1227
1248
|
if (val !== internalJsonValue) {
|
|
1228
1249
|
setInternalJsonValue(val);
|
|
1229
1250
|
}
|
|
1230
1251
|
}, []);
|
|
1231
|
-
const handleEditComplete = (0,
|
|
1252
|
+
const handleEditComplete = (0, import_react17.useCallback)(() => {
|
|
1232
1253
|
onChange(internalJsonValue);
|
|
1233
1254
|
requestAnimationFrame(() => {
|
|
1234
1255
|
wrapperRef.current?.blur();
|
|
1235
1256
|
});
|
|
1236
1257
|
setJsonReadOnly(true);
|
|
1237
1258
|
}, [internalJsonValue, onChange]);
|
|
1238
|
-
const [jsonReadOnly, setJsonReadOnly] = (0,
|
|
1239
|
-
const handleFormatJson = (0,
|
|
1259
|
+
const [jsonReadOnly, setJsonReadOnly] = (0, import_react17.useState)(true);
|
|
1260
|
+
const handleFormatJson = (0, import_react17.useCallback)(() => {
|
|
1240
1261
|
try {
|
|
1241
1262
|
const parsed = JSON.parse(internalJsonValue);
|
|
1242
1263
|
const formatted = JSON.stringify(parsed, null, 4);
|
|
@@ -1246,16 +1267,16 @@ function DefaultValue(props) {
|
|
|
1246
1267
|
console.error("Invalid JSON:", error);
|
|
1247
1268
|
}
|
|
1248
1269
|
}, [internalJsonValue, onChange]);
|
|
1249
|
-
return type === "object" ? /* @__PURE__ */
|
|
1250
|
-
|
|
1270
|
+
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(
|
|
1271
|
+
import_semi_ui10.IconButton,
|
|
1251
1272
|
{
|
|
1252
|
-
icon: /* @__PURE__ */
|
|
1273
|
+
icon: /* @__PURE__ */ import_react17.default.createElement(import_semi_icons3.IconBrackets, { style: { color: "var(--semi-color-primary)" } }),
|
|
1253
1274
|
size: "small",
|
|
1254
1275
|
type: "tertiary",
|
|
1255
1276
|
theme: "borderless",
|
|
1256
1277
|
onClick: handleFormatJson
|
|
1257
1278
|
}
|
|
1258
|
-
)))), /* @__PURE__ */
|
|
1279
|
+
)))), /* @__PURE__ */ import_react17.default.createElement(
|
|
1259
1280
|
JSONViewerWrapper,
|
|
1260
1281
|
{
|
|
1261
1282
|
ref: wrapperRef,
|
|
@@ -1269,8 +1290,8 @@ function DefaultValue(props) {
|
|
|
1269
1290
|
setJsonReadOnly(false);
|
|
1270
1291
|
}
|
|
1271
1292
|
},
|
|
1272
|
-
/* @__PURE__ */
|
|
1273
|
-
|
|
1293
|
+
/* @__PURE__ */ import_react17.default.createElement(
|
|
1294
|
+
import_semi_ui10.JsonViewer,
|
|
1274
1295
|
{
|
|
1275
1296
|
ref: JsonViewerRef,
|
|
1276
1297
|
value: getValueType(value) === "string" ? value : "",
|
|
@@ -1287,7 +1308,7 @@ function DefaultValue(props) {
|
|
|
1287
1308
|
onChange: handleJsonChange
|
|
1288
1309
|
}
|
|
1289
1310
|
)
|
|
1290
|
-
)) : /* @__PURE__ */
|
|
1311
|
+
)) : /* @__PURE__ */ import_react17.default.createElement(ConstantInputWrapper, null, /* @__PURE__ */ import_react17.default.createElement(
|
|
1291
1312
|
ConstantInput,
|
|
1292
1313
|
{
|
|
1293
1314
|
value,
|
|
@@ -1299,14 +1320,14 @@ function DefaultValue(props) {
|
|
|
1299
1320
|
}
|
|
1300
1321
|
|
|
1301
1322
|
// src/components/json-schema-editor/components/blur-input.tsx
|
|
1302
|
-
var
|
|
1323
|
+
var import_react18 = __toESM(require("react"));
|
|
1303
1324
|
var import_input = __toESM(require("@douyinfe/semi-ui/lib/es/input"));
|
|
1304
1325
|
function BlurInput(props) {
|
|
1305
|
-
const [value, setValue] = (0,
|
|
1306
|
-
(0,
|
|
1326
|
+
const [value, setValue] = (0, import_react18.useState)("");
|
|
1327
|
+
(0, import_react18.useEffect)(() => {
|
|
1307
1328
|
setValue(props.value);
|
|
1308
1329
|
}, [props.value]);
|
|
1309
|
-
return /* @__PURE__ */
|
|
1330
|
+
return /* @__PURE__ */ import_react18.default.createElement(
|
|
1310
1331
|
import_input.default,
|
|
1311
1332
|
{
|
|
1312
1333
|
...props,
|
|
@@ -1321,14 +1342,15 @@ function BlurInput(props) {
|
|
|
1321
1342
|
|
|
1322
1343
|
// src/components/json-schema-editor/index.tsx
|
|
1323
1344
|
function JsonSchemaEditor(props) {
|
|
1324
|
-
const { value = { type: "object" }, config = {}, onChange: onChangeProps } = props;
|
|
1345
|
+
const { value = { type: "object" }, config = {}, onChange: onChangeProps, readonly } = props;
|
|
1325
1346
|
const { propertyList, onAddProperty, onRemoveProperty, onEditProperty } = usePropertiesEdit(
|
|
1326
1347
|
value,
|
|
1327
1348
|
onChangeProps
|
|
1328
1349
|
);
|
|
1329
|
-
return /* @__PURE__ */
|
|
1350
|
+
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(
|
|
1330
1351
|
PropertyEdit,
|
|
1331
1352
|
{
|
|
1353
|
+
readonly,
|
|
1332
1354
|
key: _property.key,
|
|
1333
1355
|
value: _property,
|
|
1334
1356
|
config,
|
|
@@ -1340,12 +1362,13 @@ function JsonSchemaEditor(props) {
|
|
|
1340
1362
|
onRemoveProperty(_property.key);
|
|
1341
1363
|
}
|
|
1342
1364
|
}
|
|
1343
|
-
))), /* @__PURE__ */
|
|
1344
|
-
|
|
1365
|
+
))), /* @__PURE__ */ import_react19.default.createElement(
|
|
1366
|
+
import_semi_ui11.Button,
|
|
1345
1367
|
{
|
|
1368
|
+
disabled: readonly,
|
|
1346
1369
|
size: "small",
|
|
1347
1370
|
style: { marginTop: 10, marginLeft: 16 },
|
|
1348
|
-
icon: /* @__PURE__ */
|
|
1371
|
+
icon: /* @__PURE__ */ import_react19.default.createElement(import_semi_icons4.IconPlus, null),
|
|
1349
1372
|
onClick: onAddProperty
|
|
1350
1373
|
},
|
|
1351
1374
|
config?.addButtonText ?? "Add"
|
|
@@ -1355,6 +1378,7 @@ function PropertyEdit(props) {
|
|
|
1355
1378
|
const {
|
|
1356
1379
|
value,
|
|
1357
1380
|
config,
|
|
1381
|
+
readonly,
|
|
1358
1382
|
$level = 0,
|
|
1359
1383
|
onChange: onChangeProps,
|
|
1360
1384
|
onRemove,
|
|
@@ -1365,10 +1389,10 @@ function PropertyEdit(props) {
|
|
|
1365
1389
|
$parentType = "",
|
|
1366
1390
|
$showLine
|
|
1367
1391
|
} = props;
|
|
1368
|
-
const [expand, setExpand] = (0,
|
|
1369
|
-
const [collapse, setCollapse] = (0,
|
|
1392
|
+
const [expand, setExpand] = (0, import_react19.useState)(false);
|
|
1393
|
+
const [collapse, setCollapse] = (0, import_react19.useState)(false);
|
|
1370
1394
|
const { name, type, items, default: defaultValue, description, isPropertyRequired } = value || {};
|
|
1371
|
-
const typeSelectorValue = (0,
|
|
1395
|
+
const typeSelectorValue = (0, import_react19.useMemo)(() => ({ type, items }), [type, items]);
|
|
1372
1396
|
const { propertyList, isDrilldownObject, onAddProperty, onRemoveProperty, onEditProperty } = usePropertiesEdit(value, onChangeProps);
|
|
1373
1397
|
const onChange = (key, _value) => {
|
|
1374
1398
|
onChangeProps?.({
|
|
@@ -1377,7 +1401,7 @@ function PropertyEdit(props) {
|
|
|
1377
1401
|
});
|
|
1378
1402
|
};
|
|
1379
1403
|
const showCollapse = isDrilldownObject && propertyList.length > 0;
|
|
1380
|
-
return /* @__PURE__ */
|
|
1404
|
+
return /* @__PURE__ */ import_react19.default.createElement(import_react19.default.Fragment, null, /* @__PURE__ */ import_react19.default.createElement(
|
|
1381
1405
|
UIPropertyLeft,
|
|
1382
1406
|
{
|
|
1383
1407
|
type,
|
|
@@ -1389,8 +1413,8 @@ function PropertyEdit(props) {
|
|
|
1389
1413
|
$parentExpand,
|
|
1390
1414
|
$parentType
|
|
1391
1415
|
},
|
|
1392
|
-
showCollapse && /* @__PURE__ */
|
|
1393
|
-
), /* @__PURE__ */
|
|
1416
|
+
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" }))
|
|
1417
|
+
), /* @__PURE__ */ import_react19.default.createElement(UIPropertyRight, null, /* @__PURE__ */ import_react19.default.createElement(
|
|
1394
1418
|
UIPropertyMain,
|
|
1395
1419
|
{
|
|
1396
1420
|
$showCollapse: showCollapse,
|
|
@@ -1398,18 +1422,20 @@ function PropertyEdit(props) {
|
|
|
1398
1422
|
$expand: expand,
|
|
1399
1423
|
type
|
|
1400
1424
|
},
|
|
1401
|
-
/* @__PURE__ */
|
|
1425
|
+
/* @__PURE__ */ import_react19.default.createElement(UIRow, null, /* @__PURE__ */ import_react19.default.createElement(UIName, null, /* @__PURE__ */ import_react19.default.createElement(
|
|
1402
1426
|
BlurInput,
|
|
1403
1427
|
{
|
|
1428
|
+
disabled: readonly,
|
|
1404
1429
|
placeholder: config?.placeholder ?? "Input Variable Name",
|
|
1405
1430
|
size: "small",
|
|
1406
1431
|
value: name,
|
|
1407
1432
|
onChange: (value2) => onChange("name", value2)
|
|
1408
1433
|
}
|
|
1409
|
-
)), /* @__PURE__ */
|
|
1434
|
+
)), /* @__PURE__ */ import_react19.default.createElement(UIType, null, /* @__PURE__ */ import_react19.default.createElement(
|
|
1410
1435
|
TypeSelector,
|
|
1411
1436
|
{
|
|
1412
1437
|
value: typeSelectorValue,
|
|
1438
|
+
readonly,
|
|
1413
1439
|
onChange: (_value) => {
|
|
1414
1440
|
onChangeProps?.({
|
|
1415
1441
|
...value || {},
|
|
@@ -1417,51 +1443,56 @@ function PropertyEdit(props) {
|
|
|
1417
1443
|
});
|
|
1418
1444
|
}
|
|
1419
1445
|
}
|
|
1420
|
-
)), /* @__PURE__ */
|
|
1421
|
-
|
|
1446
|
+
)), /* @__PURE__ */ import_react19.default.createElement(UIRequired, null, /* @__PURE__ */ import_react19.default.createElement(
|
|
1447
|
+
import_semi_ui11.Checkbox,
|
|
1422
1448
|
{
|
|
1449
|
+
disabled: readonly,
|
|
1423
1450
|
checked: isPropertyRequired,
|
|
1424
1451
|
onChange: (e) => onChange("isPropertyRequired", e.target.checked)
|
|
1425
1452
|
}
|
|
1426
|
-
)), /* @__PURE__ */
|
|
1427
|
-
|
|
1453
|
+
)), /* @__PURE__ */ import_react19.default.createElement(UIActions, null, /* @__PURE__ */ import_react19.default.createElement(
|
|
1454
|
+
import_semi_ui11.IconButton,
|
|
1428
1455
|
{
|
|
1456
|
+
disabled: readonly,
|
|
1429
1457
|
size: "small",
|
|
1430
1458
|
theme: "borderless",
|
|
1431
|
-
icon: expand ? /* @__PURE__ */
|
|
1459
|
+
icon: expand ? /* @__PURE__ */ import_react19.default.createElement(import_semi_icons4.IconShrink, { size: "small" }) : /* @__PURE__ */ import_react19.default.createElement(import_semi_icons4.IconExpand, { size: "small" }),
|
|
1432
1460
|
onClick: () => {
|
|
1433
1461
|
setExpand((_expand) => !_expand);
|
|
1434
1462
|
}
|
|
1435
1463
|
}
|
|
1436
|
-
), isDrilldownObject && /* @__PURE__ */
|
|
1437
|
-
|
|
1464
|
+
), isDrilldownObject && /* @__PURE__ */ import_react19.default.createElement(
|
|
1465
|
+
import_semi_ui11.IconButton,
|
|
1438
1466
|
{
|
|
1467
|
+
disabled: readonly,
|
|
1439
1468
|
size: "small",
|
|
1440
1469
|
theme: "borderless",
|
|
1441
|
-
icon: /* @__PURE__ */
|
|
1470
|
+
icon: /* @__PURE__ */ import_react19.default.createElement(IconAddChildren, null),
|
|
1442
1471
|
onClick: () => {
|
|
1443
1472
|
onAddProperty();
|
|
1444
1473
|
setCollapse(true);
|
|
1445
1474
|
}
|
|
1446
1475
|
}
|
|
1447
|
-
), /* @__PURE__ */
|
|
1448
|
-
|
|
1476
|
+
), /* @__PURE__ */ import_react19.default.createElement(
|
|
1477
|
+
import_semi_ui11.IconButton,
|
|
1449
1478
|
{
|
|
1479
|
+
disabled: readonly,
|
|
1450
1480
|
size: "small",
|
|
1451
1481
|
theme: "borderless",
|
|
1452
|
-
icon: /* @__PURE__ */
|
|
1482
|
+
icon: /* @__PURE__ */ import_react19.default.createElement(import_semi_icons4.IconMinus, { size: "small" }),
|
|
1453
1483
|
onClick: onRemove
|
|
1454
1484
|
}
|
|
1455
1485
|
))),
|
|
1456
|
-
expand && /* @__PURE__ */
|
|
1486
|
+
expand && /* @__PURE__ */ import_react19.default.createElement(UIExpandDetail, null, /* @__PURE__ */ import_react19.default.createElement(UILabel, null, config?.descTitle ?? "Description"), /* @__PURE__ */ import_react19.default.createElement(
|
|
1457
1487
|
BlurInput,
|
|
1458
1488
|
{
|
|
1489
|
+
disabled: readonly,
|
|
1459
1490
|
size: "small",
|
|
1460
1491
|
value: description,
|
|
1461
1492
|
onChange: (value2) => onChange("description", value2),
|
|
1462
1493
|
placeholder: config?.descPlaceholder ?? "Help LLM to understand the property"
|
|
1463
1494
|
}
|
|
1464
|
-
), $level === 0 && type && type !== "array" && /* @__PURE__ */
|
|
1495
|
+
), $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(
|
|
1465
1496
|
DefaultValue,
|
|
1466
1497
|
{
|
|
1467
1498
|
value: defaultValue,
|
|
@@ -1472,9 +1503,10 @@ function PropertyEdit(props) {
|
|
|
1472
1503
|
onChange: (value2) => onChange("default", value2)
|
|
1473
1504
|
}
|
|
1474
1505
|
))))
|
|
1475
|
-
), showCollapse && /* @__PURE__ */
|
|
1506
|
+
), 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(
|
|
1476
1507
|
PropertyEdit,
|
|
1477
1508
|
{
|
|
1509
|
+
readonly,
|
|
1478
1510
|
key: _property.key,
|
|
1479
1511
|
value: _property,
|
|
1480
1512
|
config,
|
|
@@ -1496,29 +1528,35 @@ function PropertyEdit(props) {
|
|
|
1496
1528
|
}
|
|
1497
1529
|
|
|
1498
1530
|
// src/components/batch-variable-selector/index.tsx
|
|
1499
|
-
var
|
|
1500
|
-
var
|
|
1531
|
+
var import_react20 = __toESM(require("react"));
|
|
1532
|
+
var import_editor5 = require("@flowgram.ai/editor");
|
|
1501
1533
|
var batchVariableSchema = {
|
|
1502
1534
|
type: "array",
|
|
1503
1535
|
extra: { weak: true }
|
|
1504
1536
|
};
|
|
1505
1537
|
function BatchVariableSelector(props) {
|
|
1506
|
-
return /* @__PURE__ */
|
|
1538
|
+
return /* @__PURE__ */ import_react20.default.createElement(import_editor5.PrivateScopeProvider, null, /* @__PURE__ */ import_react20.default.createElement(VariableSelector, { ...props, includeSchema: batchVariableSchema }));
|
|
1507
1539
|
}
|
|
1508
1540
|
|
|
1509
1541
|
// src/components/dynamic-value-input/index.tsx
|
|
1510
|
-
var
|
|
1511
|
-
var
|
|
1512
|
-
var
|
|
1542
|
+
var import_react22 = __toESM(require("react"));
|
|
1543
|
+
var import_json_schema5 = require("@flowgram.ai/json-schema");
|
|
1544
|
+
var import_semi_ui12 = require("@douyinfe/semi-ui");
|
|
1545
|
+
var import_semi_icons5 = require("@douyinfe/semi-icons");
|
|
1513
1546
|
|
|
1514
1547
|
// src/components/dynamic-value-input/styles.tsx
|
|
1515
|
-
var
|
|
1516
|
-
var UIContainer2 =
|
|
1548
|
+
var import_styled_components4 = __toESM(require("styled-components"));
|
|
1549
|
+
var UIContainer2 = import_styled_components4.default.div`
|
|
1517
1550
|
display: flex;
|
|
1518
1551
|
align-items: center;
|
|
1519
|
-
|
|
1552
|
+
border-radius: 4px;
|
|
1553
|
+
border: 1px solid var(--semi-color-border);
|
|
1554
|
+
|
|
1555
|
+
overflow: hidden;
|
|
1556
|
+
|
|
1557
|
+
background-color: var(--semi-color-fill-0);
|
|
1520
1558
|
`;
|
|
1521
|
-
var UIMain =
|
|
1559
|
+
var UIMain = import_styled_components4.default.div`
|
|
1522
1560
|
flex-grow: 1;
|
|
1523
1561
|
overflow: hidden;
|
|
1524
1562
|
min-width: 0;
|
|
@@ -1527,9 +1565,62 @@ var UIMain = import_styled_components3.default.div`
|
|
|
1527
1565
|
& .semi-input-number,
|
|
1528
1566
|
& .semi-select {
|
|
1529
1567
|
width: 100%;
|
|
1568
|
+
border: none;
|
|
1569
|
+
border-radius: 0;
|
|
1570
|
+
}
|
|
1571
|
+
|
|
1572
|
+
& .semi-input-wrapper {
|
|
1573
|
+
border: none;
|
|
1574
|
+
border-radius: 0;
|
|
1575
|
+
}
|
|
1576
|
+
`;
|
|
1577
|
+
var UIType2 = import_styled_components4.default.div`
|
|
1578
|
+
border-right: 1px solid #e5e5e5;
|
|
1579
|
+
|
|
1580
|
+
& .semi-button {
|
|
1581
|
+
border-radius: 0;
|
|
1582
|
+
}
|
|
1583
|
+
`;
|
|
1584
|
+
var UITrigger = import_styled_components4.default.div`
|
|
1585
|
+
border-left: 1px solid #e5e5e5;
|
|
1586
|
+
|
|
1587
|
+
& .semi-button {
|
|
1588
|
+
border-radius: 0;
|
|
1530
1589
|
}
|
|
1531
1590
|
`;
|
|
1532
|
-
|
|
1591
|
+
|
|
1592
|
+
// src/components/dynamic-value-input/hooks.ts
|
|
1593
|
+
var import_react21 = require("react");
|
|
1594
|
+
var import_editor6 = require("@flowgram.ai/editor");
|
|
1595
|
+
function useRefVariable(value) {
|
|
1596
|
+
const available = (0, import_editor6.useScopeAvailable)();
|
|
1597
|
+
const refVariable = (0, import_react21.useMemo)(() => {
|
|
1598
|
+
if (value?.type === "ref") {
|
|
1599
|
+
return available.getByKeyPath(value.content);
|
|
1600
|
+
}
|
|
1601
|
+
}, [value, available]);
|
|
1602
|
+
return refVariable;
|
|
1603
|
+
}
|
|
1604
|
+
function useSelectSchema(schemaFromProps, constantProps, value) {
|
|
1605
|
+
let defaultSelectSchema = schemaFromProps || constantProps?.schema || { type: "string" };
|
|
1606
|
+
if (value?.type === "constant") {
|
|
1607
|
+
defaultSelectSchema = value?.schema || defaultSelectSchema;
|
|
1608
|
+
}
|
|
1609
|
+
const [selectSchema, setSelectSchema] = (0, import_react21.useState)(defaultSelectSchema);
|
|
1610
|
+
return [selectSchema, setSelectSchema];
|
|
1611
|
+
}
|
|
1612
|
+
function useIncludeSchema(schemaFromProps) {
|
|
1613
|
+
const includeSchema = (0, import_react21.useMemo)(() => {
|
|
1614
|
+
if (!schemaFromProps) {
|
|
1615
|
+
return;
|
|
1616
|
+
}
|
|
1617
|
+
if (schemaFromProps?.type === "number") {
|
|
1618
|
+
return [schemaFromProps, { type: "integer" }];
|
|
1619
|
+
}
|
|
1620
|
+
return { ...schemaFromProps, extra: { ...schemaFromProps?.extra, weak: true } };
|
|
1621
|
+
}, [schemaFromProps]);
|
|
1622
|
+
return includeSchema;
|
|
1623
|
+
}
|
|
1533
1624
|
|
|
1534
1625
|
// src/components/dynamic-value-input/index.tsx
|
|
1535
1626
|
function DynamicValueInput({
|
|
@@ -1537,18 +1628,49 @@ function DynamicValueInput({
|
|
|
1537
1628
|
onChange,
|
|
1538
1629
|
readonly,
|
|
1539
1630
|
style,
|
|
1540
|
-
schema,
|
|
1631
|
+
schema: schemaFromProps,
|
|
1541
1632
|
constantProps
|
|
1542
1633
|
}) {
|
|
1543
|
-
const
|
|
1544
|
-
|
|
1545
|
-
|
|
1634
|
+
const refVariable = useRefVariable(value);
|
|
1635
|
+
const [selectSchema, setSelectSchema] = useSelectSchema(schemaFromProps, constantProps, value);
|
|
1636
|
+
const includeSchema = useIncludeSchema(schemaFromProps);
|
|
1637
|
+
const renderTypeSelector = () => {
|
|
1638
|
+
if (schemaFromProps) {
|
|
1639
|
+
return /* @__PURE__ */ import_react22.default.createElement(TypeSelector, { value: schemaFromProps, readonly: true });
|
|
1640
|
+
}
|
|
1641
|
+
if (value?.type === "ref") {
|
|
1642
|
+
const schema = refVariable?.type ? import_json_schema5.JsonSchemaUtils.astToSchema(refVariable?.type) : void 0;
|
|
1643
|
+
return /* @__PURE__ */ import_react22.default.createElement(TypeSelector, { value: schema, readonly: true });
|
|
1546
1644
|
}
|
|
1547
|
-
return
|
|
1548
|
-
|
|
1645
|
+
return /* @__PURE__ */ import_react22.default.createElement(
|
|
1646
|
+
TypeSelector,
|
|
1647
|
+
{
|
|
1648
|
+
value: selectSchema,
|
|
1649
|
+
onChange: (_v) => {
|
|
1650
|
+
setSelectSchema(_v || { type: "string" });
|
|
1651
|
+
let content;
|
|
1652
|
+
if (_v?.type === "object") {
|
|
1653
|
+
content = "{}";
|
|
1654
|
+
}
|
|
1655
|
+
if (_v?.type === "array") {
|
|
1656
|
+
content = "[]";
|
|
1657
|
+
}
|
|
1658
|
+
if (_v?.type === "boolean") {
|
|
1659
|
+
content = false;
|
|
1660
|
+
}
|
|
1661
|
+
onChange({
|
|
1662
|
+
type: "constant",
|
|
1663
|
+
content,
|
|
1664
|
+
schema: _v || { type: "string" }
|
|
1665
|
+
});
|
|
1666
|
+
},
|
|
1667
|
+
readonly
|
|
1668
|
+
}
|
|
1669
|
+
);
|
|
1670
|
+
};
|
|
1549
1671
|
const renderMain = () => {
|
|
1550
1672
|
if (value?.type === "ref") {
|
|
1551
|
-
return /* @__PURE__ */
|
|
1673
|
+
return /* @__PURE__ */ import_react22.default.createElement(
|
|
1552
1674
|
VariableSelector,
|
|
1553
1675
|
{
|
|
1554
1676
|
style: { width: "100%" },
|
|
@@ -1559,18 +1681,29 @@ function DynamicValueInput({
|
|
|
1559
1681
|
}
|
|
1560
1682
|
);
|
|
1561
1683
|
}
|
|
1562
|
-
|
|
1684
|
+
const constantSchema = schemaFromProps || selectSchema || { type: "string" };
|
|
1685
|
+
return /* @__PURE__ */ import_react22.default.createElement(
|
|
1563
1686
|
ConstantInput,
|
|
1564
1687
|
{
|
|
1565
1688
|
value: value?.content,
|
|
1566
|
-
onChange: (_v) => onChange({ type: "constant", content: _v }),
|
|
1567
|
-
schema:
|
|
1689
|
+
onChange: (_v) => onChange({ type: "constant", content: _v, schema: constantSchema }),
|
|
1690
|
+
schema: constantSchema || { type: "string" },
|
|
1568
1691
|
readonly,
|
|
1692
|
+
strategies: [...constantProps?.strategies || []],
|
|
1693
|
+
fallbackRenderer: () => /* @__PURE__ */ import_react22.default.createElement(
|
|
1694
|
+
VariableSelector,
|
|
1695
|
+
{
|
|
1696
|
+
style: { width: "100%" },
|
|
1697
|
+
onChange: (_v) => onChange(_v ? { type: "ref", content: _v } : void 0),
|
|
1698
|
+
includeSchema,
|
|
1699
|
+
readonly
|
|
1700
|
+
}
|
|
1701
|
+
),
|
|
1569
1702
|
...constantProps
|
|
1570
1703
|
}
|
|
1571
1704
|
);
|
|
1572
1705
|
};
|
|
1573
|
-
const renderTrigger = () => /* @__PURE__ */
|
|
1706
|
+
const renderTrigger = () => /* @__PURE__ */ import_react22.default.createElement(
|
|
1574
1707
|
VariableSelector,
|
|
1575
1708
|
{
|
|
1576
1709
|
style: { width: "100%" },
|
|
@@ -1578,31 +1711,31 @@ function DynamicValueInput({
|
|
|
1578
1711
|
onChange: (_v) => onChange({ type: "ref", content: _v }),
|
|
1579
1712
|
includeSchema,
|
|
1580
1713
|
readonly,
|
|
1581
|
-
triggerRender: () => /* @__PURE__ */
|
|
1714
|
+
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" }) })
|
|
1582
1715
|
}
|
|
1583
1716
|
);
|
|
1584
|
-
return /* @__PURE__ */
|
|
1717
|
+
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()));
|
|
1585
1718
|
}
|
|
1586
1719
|
|
|
1587
1720
|
// src/components/condition-row/index.tsx
|
|
1588
|
-
var
|
|
1589
|
-
var
|
|
1721
|
+
var import_react25 = __toESM(require("react"));
|
|
1722
|
+
var import_semi_ui14 = require("@douyinfe/semi-ui");
|
|
1590
1723
|
|
|
1591
1724
|
// src/components/condition-row/styles.tsx
|
|
1592
|
-
var
|
|
1593
|
-
var UIContainer3 =
|
|
1725
|
+
var import_styled_components5 = __toESM(require("styled-components"));
|
|
1726
|
+
var UIContainer3 = import_styled_components5.default.div`
|
|
1594
1727
|
display: flex;
|
|
1595
1728
|
align-items: center;
|
|
1596
1729
|
gap: 4px;
|
|
1597
1730
|
`;
|
|
1598
|
-
var UIOperator =
|
|
1599
|
-
var UILeft =
|
|
1731
|
+
var UIOperator = import_styled_components5.default.div``;
|
|
1732
|
+
var UILeft = import_styled_components5.default.div`
|
|
1600
1733
|
width: 100%;
|
|
1601
1734
|
`;
|
|
1602
|
-
var UIRight =
|
|
1735
|
+
var UIRight = import_styled_components5.default.div`
|
|
1603
1736
|
width: 100%;
|
|
1604
1737
|
`;
|
|
1605
|
-
var UIValues =
|
|
1738
|
+
var UIValues = import_styled_components5.default.div`
|
|
1606
1739
|
flex-grow: 1;
|
|
1607
1740
|
display: flex;
|
|
1608
1741
|
flex-direction: column;
|
|
@@ -1611,8 +1744,9 @@ var UIValues = import_styled_components4.default.div`
|
|
|
1611
1744
|
`;
|
|
1612
1745
|
|
|
1613
1746
|
// src/components/condition-row/hooks/useRule.ts
|
|
1614
|
-
var
|
|
1615
|
-
var
|
|
1747
|
+
var import_react23 = require("react");
|
|
1748
|
+
var import_json_schema6 = require("@flowgram.ai/json-schema");
|
|
1749
|
+
var import_editor7 = require("@flowgram.ai/editor");
|
|
1616
1750
|
|
|
1617
1751
|
// src/components/condition-row/constants.ts
|
|
1618
1752
|
var rules = {
|
|
@@ -1623,8 +1757,8 @@ var rules = {
|
|
|
1623
1757
|
["not_contains" /* NOT_CONTAINS */]: "string",
|
|
1624
1758
|
["in" /* IN */]: "array",
|
|
1625
1759
|
["nin" /* NIN */]: "array",
|
|
1626
|
-
["is_empty" /* IS_EMPTY */]:
|
|
1627
|
-
["is_not_empty" /* IS_NOT_EMPTY */]:
|
|
1760
|
+
["is_empty" /* IS_EMPTY */]: null,
|
|
1761
|
+
["is_not_empty" /* IS_NOT_EMPTY */]: null
|
|
1628
1762
|
},
|
|
1629
1763
|
number: {
|
|
1630
1764
|
["eq" /* EQ */]: "number",
|
|
@@ -1634,9 +1768,7 @@ var rules = {
|
|
|
1634
1768
|
["lt" /* LT */]: "number",
|
|
1635
1769
|
["lte" /* LTE */]: "number",
|
|
1636
1770
|
["in" /* IN */]: "array",
|
|
1637
|
-
["nin" /* NIN */]: "array"
|
|
1638
|
-
["is_empty" /* IS_EMPTY */]: null,
|
|
1639
|
-
["is_not_empty" /* IS_NOT_EMPTY */]: null
|
|
1771
|
+
["nin" /* NIN */]: "array"
|
|
1640
1772
|
},
|
|
1641
1773
|
integer: {
|
|
1642
1774
|
["eq" /* EQ */]: "number",
|
|
@@ -1646,9 +1778,7 @@ var rules = {
|
|
|
1646
1778
|
["lt" /* LT */]: "number",
|
|
1647
1779
|
["lte" /* LTE */]: "number",
|
|
1648
1780
|
["in" /* IN */]: "array",
|
|
1649
|
-
["nin" /* NIN */]: "array"
|
|
1650
|
-
["is_empty" /* IS_EMPTY */]: null,
|
|
1651
|
-
["is_not_empty" /* IS_NOT_EMPTY */]: null
|
|
1781
|
+
["nin" /* NIN */]: "array"
|
|
1652
1782
|
},
|
|
1653
1783
|
boolean: {
|
|
1654
1784
|
["eq" /* EQ */]: "boolean",
|
|
@@ -1656,9 +1786,7 @@ var rules = {
|
|
|
1656
1786
|
["is_true" /* IS_TRUE */]: null,
|
|
1657
1787
|
["is_false" /* IS_FALSE */]: null,
|
|
1658
1788
|
["in" /* IN */]: "array",
|
|
1659
|
-
["nin" /* NIN */]: "array"
|
|
1660
|
-
["is_empty" /* IS_EMPTY */]: null,
|
|
1661
|
-
["is_not_empty" /* IS_NOT_EMPTY */]: null
|
|
1789
|
+
["nin" /* NIN */]: "array"
|
|
1662
1790
|
},
|
|
1663
1791
|
object: {
|
|
1664
1792
|
["is_empty" /* IS_EMPTY */]: null,
|
|
@@ -1666,7 +1794,11 @@ var rules = {
|
|
|
1666
1794
|
},
|
|
1667
1795
|
array: {
|
|
1668
1796
|
["is_empty" /* IS_EMPTY */]: null,
|
|
1669
|
-
["is_not_empty" /* IS_NOT_EMPTY */]: null
|
|
1797
|
+
["is_not_empty" /* IS_NOT_EMPTY */]: null,
|
|
1798
|
+
["contains" /* CONTAINS */]: "array",
|
|
1799
|
+
["not_contains" /* NOT_CONTAINS */]: "array",
|
|
1800
|
+
["eq" /* EQ */]: "array",
|
|
1801
|
+
["neq" /* NEQ */]: "array"
|
|
1670
1802
|
},
|
|
1671
1803
|
map: {
|
|
1672
1804
|
["is_empty" /* IS_EMPTY */]: null,
|
|
@@ -1736,107 +1868,46 @@ var opConfigs = {
|
|
|
1736
1868
|
}
|
|
1737
1869
|
};
|
|
1738
1870
|
|
|
1739
|
-
// src/utils/format-legacy-refs/index.ts
|
|
1740
|
-
var import_lodash2 = require("lodash");
|
|
1741
|
-
function formatLegacyRefOnSubmit(value) {
|
|
1742
|
-
if ((0, import_lodash2.isObject)(value)) {
|
|
1743
|
-
if (isLegacyFlowRefValueSchema(value)) {
|
|
1744
|
-
return formatLegacyRefToNewRef(value);
|
|
1745
|
-
}
|
|
1746
|
-
return Object.fromEntries(
|
|
1747
|
-
Object.entries(value).map(([key, value2]) => [
|
|
1748
|
-
key,
|
|
1749
|
-
formatLegacyRefOnSubmit(value2)
|
|
1750
|
-
])
|
|
1751
|
-
);
|
|
1752
|
-
}
|
|
1753
|
-
if (Array.isArray(value)) {
|
|
1754
|
-
return value.map(formatLegacyRefOnSubmit);
|
|
1755
|
-
}
|
|
1756
|
-
return value;
|
|
1757
|
-
}
|
|
1758
|
-
function formatLegacyRefOnInit(value) {
|
|
1759
|
-
if ((0, import_lodash2.isObject)(value)) {
|
|
1760
|
-
if (isNewFlowRefValueSchema(value)) {
|
|
1761
|
-
return formatNewRefToLegacyRef(value);
|
|
1762
|
-
}
|
|
1763
|
-
return Object.fromEntries(
|
|
1764
|
-
Object.entries(value).map(([key, value2]) => [
|
|
1765
|
-
key,
|
|
1766
|
-
formatLegacyRefOnInit(value2)
|
|
1767
|
-
])
|
|
1768
|
-
);
|
|
1769
|
-
}
|
|
1770
|
-
if (Array.isArray(value)) {
|
|
1771
|
-
return value.map(formatLegacyRefOnInit);
|
|
1772
|
-
}
|
|
1773
|
-
return value;
|
|
1774
|
-
}
|
|
1775
|
-
function isLegacyFlowRefValueSchema(value) {
|
|
1776
|
-
return (0, import_lodash2.isObject)(value) && Object.keys(value).length === 2 && value.type === "ref" && typeof value.content === "string";
|
|
1777
|
-
}
|
|
1778
|
-
function isNewFlowRefValueSchema(value) {
|
|
1779
|
-
return (0, import_lodash2.isObject)(value) && Object.keys(value).length === 2 && value.type === "ref" && Array.isArray(value.content);
|
|
1780
|
-
}
|
|
1781
|
-
function formatLegacyRefToNewRef(value) {
|
|
1782
|
-
const keyPath = value.content.split(".");
|
|
1783
|
-
if (keyPath[1] === "outputs") {
|
|
1784
|
-
return {
|
|
1785
|
-
type: "ref",
|
|
1786
|
-
content: [`${keyPath[0]}.${keyPath[1]}`, ...keyPath.length > 2 ? keyPath.slice(2) : []]
|
|
1787
|
-
};
|
|
1788
|
-
}
|
|
1789
|
-
return {
|
|
1790
|
-
type: "ref",
|
|
1791
|
-
content: keyPath
|
|
1792
|
-
};
|
|
1793
|
-
}
|
|
1794
|
-
function formatNewRefToLegacyRef(value) {
|
|
1795
|
-
return {
|
|
1796
|
-
type: "ref",
|
|
1797
|
-
content: value.content.join(".")
|
|
1798
|
-
};
|
|
1799
|
-
}
|
|
1800
|
-
|
|
1801
1871
|
// src/components/condition-row/hooks/useRule.ts
|
|
1802
1872
|
function useRule(left) {
|
|
1803
|
-
const available = (0,
|
|
1804
|
-
const variable = (0,
|
|
1873
|
+
const available = (0, import_editor7.useScopeAvailable)();
|
|
1874
|
+
const variable = (0, import_react23.useMemo)(() => {
|
|
1805
1875
|
if (!left) return void 0;
|
|
1806
1876
|
return available.getByKeyPath(left.content);
|
|
1807
1877
|
}, [available, left]);
|
|
1808
|
-
const rule = (0,
|
|
1878
|
+
const rule = (0, import_react23.useMemo)(() => {
|
|
1809
1879
|
if (!variable) return void 0;
|
|
1810
|
-
const schema = JsonSchemaUtils.astToSchema(variable.type, { drilldown: false });
|
|
1880
|
+
const schema = import_json_schema6.JsonSchemaUtils.astToSchema(variable.type, { drilldown: false });
|
|
1811
1881
|
return rules[schema?.type];
|
|
1812
1882
|
}, [variable?.type]);
|
|
1813
1883
|
return { rule };
|
|
1814
1884
|
}
|
|
1815
1885
|
|
|
1816
1886
|
// src/components/condition-row/hooks/useOp.tsx
|
|
1817
|
-
var
|
|
1818
|
-
var
|
|
1819
|
-
var
|
|
1820
|
-
function useOp({ rule, op, onChange }) {
|
|
1821
|
-
const
|
|
1887
|
+
var import_react24 = __toESM(require("react"));
|
|
1888
|
+
var import_semi_ui13 = require("@douyinfe/semi-ui");
|
|
1889
|
+
var import_semi_icons6 = require("@douyinfe/semi-icons");
|
|
1890
|
+
function useOp({ rule, op, onChange, readonly }) {
|
|
1891
|
+
const options = (0, import_react24.useMemo)(
|
|
1822
1892
|
() => Object.keys(rule || {}).map((_op) => ({
|
|
1823
1893
|
...opConfigs[_op] || {},
|
|
1824
1894
|
value: _op
|
|
1825
1895
|
})),
|
|
1826
1896
|
[rule]
|
|
1827
1897
|
);
|
|
1828
|
-
const opConfig = (0,
|
|
1829
|
-
const renderOpSelect = () => /* @__PURE__ */
|
|
1830
|
-
|
|
1898
|
+
const opConfig = (0, import_react24.useMemo)(() => opConfigs[op], [op]);
|
|
1899
|
+
const renderOpSelect = () => /* @__PURE__ */ import_react24.default.createElement(
|
|
1900
|
+
import_semi_ui13.Select,
|
|
1831
1901
|
{
|
|
1832
1902
|
style: { height: 22 },
|
|
1903
|
+
disabled: readonly,
|
|
1833
1904
|
size: "small",
|
|
1834
1905
|
value: op,
|
|
1835
|
-
optionList:
|
|
1906
|
+
optionList: options,
|
|
1836
1907
|
onChange: (v) => {
|
|
1837
1908
|
onChange(v);
|
|
1838
1909
|
},
|
|
1839
|
-
triggerRender: ({ value }) => /* @__PURE__ */
|
|
1910
|
+
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" }))
|
|
1840
1911
|
}
|
|
1841
1912
|
);
|
|
1842
1913
|
return { renderOpSelect, opConfig };
|
|
@@ -1849,13 +1920,14 @@ function ConditionRow({ style, value, onChange, readonly }) {
|
|
|
1849
1920
|
const { renderOpSelect, opConfig } = useOp({
|
|
1850
1921
|
rule,
|
|
1851
1922
|
op: operator,
|
|
1852
|
-
onChange: (v) => onChange({ ...value, operator: v })
|
|
1923
|
+
onChange: (v) => onChange({ ...value, operator: v }),
|
|
1924
|
+
readonly
|
|
1853
1925
|
});
|
|
1854
|
-
const targetSchema = (0,
|
|
1926
|
+
const targetSchema = (0, import_react25.useMemo)(() => {
|
|
1855
1927
|
const targetType = rule?.[operator] || null;
|
|
1856
1928
|
return targetType ? { type: targetType, extra: { weak: true } } : null;
|
|
1857
1929
|
}, [rule, opConfig]);
|
|
1858
|
-
return /* @__PURE__ */
|
|
1930
|
+
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(
|
|
1859
1931
|
VariableSelector,
|
|
1860
1932
|
{
|
|
1861
1933
|
readonly,
|
|
@@ -1869,7 +1941,7 @@ function ConditionRow({ style, value, onChange, readonly }) {
|
|
|
1869
1941
|
}
|
|
1870
1942
|
})
|
|
1871
1943
|
}
|
|
1872
|
-
)), /* @__PURE__ */
|
|
1944
|
+
)), /* @__PURE__ */ import_react25.default.createElement(UIRight, null, targetSchema ? /* @__PURE__ */ import_react25.default.createElement(
|
|
1873
1945
|
DynamicValueInput,
|
|
1874
1946
|
{
|
|
1875
1947
|
readonly: readonly || !rule,
|
|
@@ -1877,8 +1949,8 @@ function ConditionRow({ style, value, onChange, readonly }) {
|
|
|
1877
1949
|
schema: targetSchema,
|
|
1878
1950
|
onChange: (v) => onChange({ ...value, right: v })
|
|
1879
1951
|
}
|
|
1880
|
-
) : /* @__PURE__ */
|
|
1881
|
-
|
|
1952
|
+
) : /* @__PURE__ */ import_react25.default.createElement(
|
|
1953
|
+
import_semi_ui14.Input,
|
|
1882
1954
|
{
|
|
1883
1955
|
size: "small",
|
|
1884
1956
|
disabled: true,
|
|
@@ -1889,28 +1961,32 @@ function ConditionRow({ style, value, onChange, readonly }) {
|
|
|
1889
1961
|
}
|
|
1890
1962
|
|
|
1891
1963
|
// src/components/batch-outputs/index.tsx
|
|
1892
|
-
var
|
|
1893
|
-
var
|
|
1894
|
-
var
|
|
1964
|
+
var import_react27 = __toESM(require("react"));
|
|
1965
|
+
var import_semi_ui15 = require("@douyinfe/semi-ui");
|
|
1966
|
+
var import_semi_icons7 = require("@douyinfe/semi-icons");
|
|
1895
1967
|
|
|
1896
|
-
// src/
|
|
1897
|
-
var
|
|
1898
|
-
var
|
|
1899
|
-
var
|
|
1968
|
+
// src/hooks/use-object-list/index.tsx
|
|
1969
|
+
var import_react26 = require("react");
|
|
1970
|
+
var import_nanoid = require("nanoid");
|
|
1971
|
+
var import_lodash2 = require("lodash");
|
|
1900
1972
|
function genId2() {
|
|
1901
|
-
return
|
|
1973
|
+
return (0, import_nanoid.nanoid)();
|
|
1902
1974
|
}
|
|
1903
|
-
function
|
|
1904
|
-
|
|
1905
|
-
|
|
1975
|
+
function useObjectList({
|
|
1976
|
+
value,
|
|
1977
|
+
onChange,
|
|
1978
|
+
sortIndexKey
|
|
1979
|
+
}) {
|
|
1980
|
+
const [list, setList] = (0, import_react26.useState)([]);
|
|
1981
|
+
(0, import_react26.useEffect)(() => {
|
|
1906
1982
|
setList((_prevList) => {
|
|
1907
|
-
const newKeys = Object.
|
|
1983
|
+
const newKeys = Object.entries(value || {}).sort((a, b) => (0, import_lodash2.get)(a[1], sortIndexKey || 0) - (0, import_lodash2.get)(b[1], sortIndexKey || 0)).map(([key]) => key);
|
|
1908
1984
|
const oldKeys = _prevList.map((item) => item.key).filter(Boolean);
|
|
1909
|
-
const addKeys = (0,
|
|
1985
|
+
const addKeys = (0, import_lodash2.difference)(newKeys, oldKeys);
|
|
1910
1986
|
return _prevList.filter((item) => !item.key || newKeys.includes(item.key)).map((item) => ({
|
|
1911
1987
|
id: item.id,
|
|
1912
1988
|
key: item.key,
|
|
1913
|
-
value: item.key ? value?.[item.key] :
|
|
1989
|
+
value: item.key ? value?.[item.key] : item.value
|
|
1914
1990
|
})).concat(
|
|
1915
1991
|
addKeys.map((_key) => ({
|
|
1916
1992
|
id: genId2(),
|
|
@@ -1928,17 +2004,44 @@ function useList({ value, onChange }) {
|
|
|
1928
2004
|
}
|
|
1929
2005
|
]);
|
|
1930
2006
|
};
|
|
1931
|
-
const
|
|
2007
|
+
const updateValue = (itemId, value2) => {
|
|
1932
2008
|
setList((prevList) => {
|
|
1933
2009
|
const nextList = prevList.map((_item) => {
|
|
1934
|
-
if (_item.id ===
|
|
1935
|
-
return
|
|
2010
|
+
if (_item.id === itemId) {
|
|
2011
|
+
return {
|
|
2012
|
+
..._item,
|
|
2013
|
+
value: value2
|
|
2014
|
+
};
|
|
2015
|
+
}
|
|
2016
|
+
return _item;
|
|
2017
|
+
});
|
|
2018
|
+
onChange(
|
|
2019
|
+
Object.fromEntries(
|
|
2020
|
+
nextList.filter((item) => item.key).map((item) => [item.key, item.value]).map((_res, idx) => {
|
|
2021
|
+
if ((0, import_lodash2.isObject)(_res[1]) && sortIndexKey) {
|
|
2022
|
+
(0, import_lodash2.set)(_res[1], sortIndexKey, idx);
|
|
2023
|
+
}
|
|
2024
|
+
return _res;
|
|
2025
|
+
})
|
|
2026
|
+
)
|
|
2027
|
+
);
|
|
2028
|
+
return nextList;
|
|
2029
|
+
});
|
|
2030
|
+
};
|
|
2031
|
+
const updateKey = (itemId, key) => {
|
|
2032
|
+
setList((prevList) => {
|
|
2033
|
+
const nextList = prevList.map((_item) => {
|
|
2034
|
+
if (_item.id === itemId) {
|
|
2035
|
+
return {
|
|
2036
|
+
..._item,
|
|
2037
|
+
key
|
|
2038
|
+
};
|
|
1936
2039
|
}
|
|
1937
2040
|
return _item;
|
|
1938
2041
|
});
|
|
1939
2042
|
onChange(
|
|
1940
2043
|
Object.fromEntries(
|
|
1941
|
-
nextList.filter((
|
|
2044
|
+
nextList.filter((item) => item.key).map((item) => [item.key, item.value])
|
|
1942
2045
|
)
|
|
1943
2046
|
);
|
|
1944
2047
|
return nextList;
|
|
@@ -1955,18 +2058,18 @@ function useList({ value, onChange }) {
|
|
|
1955
2058
|
return nextList;
|
|
1956
2059
|
});
|
|
1957
2060
|
};
|
|
1958
|
-
return { list, add,
|
|
2061
|
+
return { list, add, updateKey, updateValue, remove };
|
|
1959
2062
|
}
|
|
1960
2063
|
|
|
1961
2064
|
// src/components/batch-outputs/styles.tsx
|
|
1962
|
-
var
|
|
1963
|
-
var UIRows =
|
|
2065
|
+
var import_styled_components6 = __toESM(require("styled-components"));
|
|
2066
|
+
var UIRows = import_styled_components6.default.div`
|
|
1964
2067
|
display: flex;
|
|
1965
2068
|
flex-direction: column;
|
|
1966
2069
|
gap: 10px;
|
|
1967
2070
|
margin-bottom: 10px;
|
|
1968
2071
|
`;
|
|
1969
|
-
var UIRow2 =
|
|
2072
|
+
var UIRow2 = import_styled_components6.default.div`
|
|
1970
2073
|
display: flex;
|
|
1971
2074
|
align-items: center;
|
|
1972
2075
|
gap: 5px;
|
|
@@ -1975,68 +2078,62 @@ var UIRow2 = import_styled_components5.default.div`
|
|
|
1975
2078
|
// src/components/batch-outputs/index.tsx
|
|
1976
2079
|
function BatchOutputs(props) {
|
|
1977
2080
|
const { readonly, style } = props;
|
|
1978
|
-
const { list, add,
|
|
1979
|
-
return /* @__PURE__ */
|
|
1980
|
-
|
|
2081
|
+
const { list, add, updateKey, updateValue, remove } = useObjectList(props);
|
|
2082
|
+
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(
|
|
2083
|
+
import_semi_ui15.Input,
|
|
1981
2084
|
{
|
|
1982
2085
|
style: { width: 100 },
|
|
1983
2086
|
disabled: readonly,
|
|
1984
2087
|
size: "small",
|
|
1985
2088
|
value: item.key,
|
|
1986
|
-
onChange: (v) =>
|
|
2089
|
+
onChange: (v) => updateKey(item.id, v)
|
|
1987
2090
|
}
|
|
1988
|
-
), /* @__PURE__ */
|
|
2091
|
+
), /* @__PURE__ */ import_react27.default.createElement(
|
|
1989
2092
|
VariableSelector,
|
|
1990
2093
|
{
|
|
1991
2094
|
style: { flexGrow: 1 },
|
|
1992
2095
|
readonly,
|
|
1993
2096
|
value: item.value?.content,
|
|
1994
|
-
onChange: (v) =>
|
|
1995
|
-
...item,
|
|
1996
|
-
value: {
|
|
1997
|
-
type: "ref",
|
|
1998
|
-
content: v
|
|
1999
|
-
}
|
|
2000
|
-
})
|
|
2097
|
+
onChange: (v) => updateValue(item.id, { type: "ref", content: v })
|
|
2001
2098
|
}
|
|
2002
|
-
), /* @__PURE__ */
|
|
2003
|
-
|
|
2099
|
+
), /* @__PURE__ */ import_react27.default.createElement(
|
|
2100
|
+
import_semi_ui15.Button,
|
|
2004
2101
|
{
|
|
2005
2102
|
disabled: readonly,
|
|
2006
|
-
icon: /* @__PURE__ */
|
|
2103
|
+
icon: /* @__PURE__ */ import_react27.default.createElement(import_semi_icons7.IconDelete, null),
|
|
2007
2104
|
size: "small",
|
|
2008
2105
|
onClick: () => remove(item.id)
|
|
2009
2106
|
}
|
|
2010
|
-
)))), /* @__PURE__ */
|
|
2107
|
+
)))), /* @__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"));
|
|
2011
2108
|
}
|
|
2012
2109
|
|
|
2013
2110
|
// src/components/prompt-editor/index.tsx
|
|
2014
|
-
var
|
|
2015
|
-
var
|
|
2111
|
+
var import_react34 = __toESM(require("react"));
|
|
2112
|
+
var import_react35 = require("@coze-editor/editor/react");
|
|
2016
2113
|
var import_preset_prompt2 = __toESM(require("@coze-editor/editor/preset-prompt"));
|
|
2017
2114
|
|
|
2018
2115
|
// src/components/prompt-editor/styles.tsx
|
|
2019
|
-
var
|
|
2020
|
-
var UIContainer4 =
|
|
2116
|
+
var import_styled_components7 = __toESM(require("styled-components"));
|
|
2117
|
+
var UIContainer4 = import_styled_components7.default.div`
|
|
2021
2118
|
background-color: var(--semi-color-fill-0);
|
|
2022
2119
|
padding-left: 10px;
|
|
2023
2120
|
padding-right: 6px;
|
|
2024
2121
|
|
|
2025
|
-
${({ $hasError }) => $hasError &&
|
|
2122
|
+
${({ $hasError }) => $hasError && import_styled_components7.css`
|
|
2026
2123
|
border: 1px solid var(--semi-color-danger-6);
|
|
2027
2124
|
`}
|
|
2028
2125
|
`;
|
|
2029
2126
|
|
|
2030
2127
|
// src/components/prompt-editor/extensions/markdown.tsx
|
|
2031
|
-
var
|
|
2032
|
-
var
|
|
2033
|
-
var
|
|
2034
|
-
var
|
|
2128
|
+
var import_react28 = require("react");
|
|
2129
|
+
var import_react29 = require("@coze-editor/editor/react");
|
|
2130
|
+
var import_editor8 = require("@coze-editor/editor");
|
|
2131
|
+
var import_view2 = require("@codemirror/view");
|
|
2035
2132
|
function MarkdownHighlight() {
|
|
2036
|
-
const injector = (0,
|
|
2037
|
-
(0,
|
|
2133
|
+
const injector = (0, import_react29.useInjector)();
|
|
2134
|
+
(0, import_react28.useLayoutEffect)(
|
|
2038
2135
|
() => injector.inject([
|
|
2039
|
-
|
|
2136
|
+
import_editor8.astDecorator.whole.of((cursor) => {
|
|
2040
2137
|
if (cursor.name.startsWith("ATXHeading")) {
|
|
2041
2138
|
return {
|
|
2042
2139
|
type: "className",
|
|
@@ -2062,7 +2159,7 @@ function MarkdownHighlight() {
|
|
|
2062
2159
|
};
|
|
2063
2160
|
}
|
|
2064
2161
|
}),
|
|
2065
|
-
|
|
2162
|
+
import_view2.EditorView.theme({
|
|
2066
2163
|
".heading": {
|
|
2067
2164
|
color: "#00818C",
|
|
2068
2165
|
fontWeight: "bold"
|
|
@@ -2085,26 +2182,26 @@ function MarkdownHighlight() {
|
|
|
2085
2182
|
var markdown_default = MarkdownHighlight;
|
|
2086
2183
|
|
|
2087
2184
|
// src/components/prompt-editor/extensions/language-support.tsx
|
|
2088
|
-
var
|
|
2089
|
-
var
|
|
2185
|
+
var import_react30 = require("react");
|
|
2186
|
+
var import_react31 = require("@coze-editor/editor/react");
|
|
2090
2187
|
var import_preset_prompt = require("@coze-editor/editor/preset-prompt");
|
|
2091
2188
|
function LanguageSupport() {
|
|
2092
|
-
const injector = (0,
|
|
2093
|
-
(0,
|
|
2189
|
+
const injector = (0, import_react31.useInjector)();
|
|
2190
|
+
(0, import_react30.useLayoutEffect)(() => injector.inject([import_preset_prompt.languageSupport]), [injector]);
|
|
2094
2191
|
return null;
|
|
2095
2192
|
}
|
|
2096
2193
|
var language_support_default = LanguageSupport;
|
|
2097
2194
|
|
|
2098
2195
|
// src/components/prompt-editor/extensions/jinja.tsx
|
|
2099
|
-
var
|
|
2100
|
-
var
|
|
2101
|
-
var
|
|
2102
|
-
var
|
|
2196
|
+
var import_react32 = require("react");
|
|
2197
|
+
var import_react33 = require("@coze-editor/editor/react");
|
|
2198
|
+
var import_editor9 = require("@coze-editor/editor");
|
|
2199
|
+
var import_view3 = require("@codemirror/view");
|
|
2103
2200
|
function JinjaHighlight() {
|
|
2104
|
-
const injector = (0,
|
|
2105
|
-
(0,
|
|
2201
|
+
const injector = (0, import_react33.useInjector)();
|
|
2202
|
+
(0, import_react32.useLayoutEffect)(
|
|
2106
2203
|
() => injector.inject([
|
|
2107
|
-
|
|
2204
|
+
import_editor9.astDecorator.whole.of((cursor) => {
|
|
2108
2205
|
if (cursor.name === "JinjaStatementStart" || cursor.name === "JinjaStatementEnd") {
|
|
2109
2206
|
return {
|
|
2110
2207
|
type: "className",
|
|
@@ -2124,7 +2221,7 @@ function JinjaHighlight() {
|
|
|
2124
2221
|
};
|
|
2125
2222
|
}
|
|
2126
2223
|
}),
|
|
2127
|
-
|
|
2224
|
+
import_view3.EditorView.theme({
|
|
2128
2225
|
".jinja-statement-bracket": {
|
|
2129
2226
|
color: "#D1009D"
|
|
2130
2227
|
},
|
|
@@ -2152,16 +2249,17 @@ function PromptEditor(props) {
|
|
|
2152
2249
|
activeLinePlaceholder,
|
|
2153
2250
|
style,
|
|
2154
2251
|
hasError,
|
|
2155
|
-
children
|
|
2252
|
+
children,
|
|
2253
|
+
disableMarkdownHighlight
|
|
2156
2254
|
} = props || {};
|
|
2157
|
-
const editorRef = (0,
|
|
2158
|
-
(0,
|
|
2255
|
+
const editorRef = (0, import_react34.useRef)(null);
|
|
2256
|
+
(0, import_react34.useEffect)(() => {
|
|
2159
2257
|
if (editorRef.current?.getValue() !== value?.content) {
|
|
2160
2258
|
editorRef.current?.setValue(String(value?.content || ""));
|
|
2161
2259
|
}
|
|
2162
2260
|
}, [value]);
|
|
2163
|
-
return /* @__PURE__ */
|
|
2164
|
-
|
|
2261
|
+
return /* @__PURE__ */ import_react34.default.createElement(UIContainer4, { $hasError: hasError, style }, /* @__PURE__ */ import_react34.default.createElement(import_react35.EditorProvider, null, /* @__PURE__ */ import_react34.default.createElement(
|
|
2262
|
+
import_react35.Renderer,
|
|
2165
2263
|
{
|
|
2166
2264
|
didMount: (editor) => {
|
|
2167
2265
|
editorRef.current = editor;
|
|
@@ -2177,23 +2275,23 @@ function PromptEditor(props) {
|
|
|
2177
2275
|
onChange({ type: "template", content: e.value });
|
|
2178
2276
|
}
|
|
2179
2277
|
}
|
|
2180
|
-
), activeLinePlaceholder && /* @__PURE__ */
|
|
2278
|
+
), 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));
|
|
2181
2279
|
}
|
|
2182
2280
|
|
|
2183
2281
|
// src/components/prompt-editor-with-variables/index.tsx
|
|
2184
|
-
var
|
|
2282
|
+
var import_react40 = __toESM(require("react"));
|
|
2185
2283
|
|
|
2186
2284
|
// src/components/prompt-editor-with-variables/extensions/variable-tree.tsx
|
|
2187
|
-
var
|
|
2188
|
-
var
|
|
2189
|
-
var
|
|
2285
|
+
var import_react36 = __toESM(require("react"));
|
|
2286
|
+
var import_semi_ui16 = require("@douyinfe/semi-ui");
|
|
2287
|
+
var import_react37 = require("@coze-editor/editor/react");
|
|
2190
2288
|
function VariableTree() {
|
|
2191
|
-
const [posKey, setPosKey] = (0,
|
|
2192
|
-
const [visible, setVisible] = (0,
|
|
2193
|
-
const [position, setPosition] = (0,
|
|
2194
|
-
const editor = (0,
|
|
2289
|
+
const [posKey, setPosKey] = (0, import_react36.useState)("");
|
|
2290
|
+
const [visible, setVisible] = (0, import_react36.useState)(false);
|
|
2291
|
+
const [position, setPosition] = (0, import_react36.useState)(-1);
|
|
2292
|
+
const editor = (0, import_react37.useEditor)();
|
|
2195
2293
|
function insert(variablePath) {
|
|
2196
|
-
const range = (0,
|
|
2294
|
+
const range = (0, import_react37.getCurrentMentionReplaceRange)(editor.$view.state);
|
|
2197
2295
|
if (!range) {
|
|
2198
2296
|
return;
|
|
2199
2297
|
}
|
|
@@ -2207,21 +2305,21 @@ function VariableTree() {
|
|
|
2207
2305
|
setPosition(e.state.selection.main.head);
|
|
2208
2306
|
setVisible(e.value);
|
|
2209
2307
|
}
|
|
2210
|
-
(0,
|
|
2308
|
+
(0, import_react36.useEffect)(() => {
|
|
2211
2309
|
if (!editor) {
|
|
2212
2310
|
return;
|
|
2213
2311
|
}
|
|
2214
2312
|
}, [editor, visible]);
|
|
2215
2313
|
const treeData = useVariableTree({});
|
|
2216
|
-
return /* @__PURE__ */
|
|
2217
|
-
|
|
2314
|
+
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(
|
|
2315
|
+
import_semi_ui16.Popover,
|
|
2218
2316
|
{
|
|
2219
2317
|
visible,
|
|
2220
2318
|
trigger: "custom",
|
|
2221
2319
|
position: "topLeft",
|
|
2222
2320
|
rePosKey: posKey,
|
|
2223
|
-
content: /* @__PURE__ */
|
|
2224
|
-
|
|
2321
|
+
content: /* @__PURE__ */ import_react36.default.createElement("div", { style: { width: 300 } }, /* @__PURE__ */ import_react36.default.createElement(
|
|
2322
|
+
import_semi_ui16.Tree,
|
|
2225
2323
|
{
|
|
2226
2324
|
treeData,
|
|
2227
2325
|
onSelect: (v) => {
|
|
@@ -2230,8 +2328,8 @@ function VariableTree() {
|
|
|
2230
2328
|
}
|
|
2231
2329
|
))
|
|
2232
2330
|
},
|
|
2233
|
-
/* @__PURE__ */
|
|
2234
|
-
|
|
2331
|
+
/* @__PURE__ */ import_react36.default.createElement(
|
|
2332
|
+
import_react37.PositionMirror,
|
|
2235
2333
|
{
|
|
2236
2334
|
position,
|
|
2237
2335
|
onChange: () => setPosKey(String(Math.random()))
|
|
@@ -2242,18 +2340,18 @@ function VariableTree() {
|
|
|
2242
2340
|
|
|
2243
2341
|
// src/components/prompt-editor-with-variables/extensions/variable-tag.tsx
|
|
2244
2342
|
var import_react_dom = __toESM(require("react-dom"));
|
|
2245
|
-
var
|
|
2246
|
-
var
|
|
2247
|
-
var
|
|
2248
|
-
var
|
|
2249
|
-
var
|
|
2250
|
-
var
|
|
2251
|
-
var
|
|
2343
|
+
var import_react38 = __toESM(require("react"));
|
|
2344
|
+
var import_lodash3 = require("lodash");
|
|
2345
|
+
var import_editor10 = require("@flowgram.ai/editor");
|
|
2346
|
+
var import_semi_ui18 = require("@douyinfe/semi-ui");
|
|
2347
|
+
var import_semi_icons8 = require("@douyinfe/semi-icons");
|
|
2348
|
+
var import_react39 = require("@coze-editor/editor/react");
|
|
2349
|
+
var import_view4 = require("@codemirror/view");
|
|
2252
2350
|
|
|
2253
2351
|
// src/components/prompt-editor-with-variables/styles.tsx
|
|
2254
|
-
var
|
|
2255
|
-
var
|
|
2256
|
-
var UIRootTitle2 =
|
|
2352
|
+
var import_styled_components8 = __toESM(require("styled-components"));
|
|
2353
|
+
var import_semi_ui17 = require("@douyinfe/semi-ui");
|
|
2354
|
+
var UIRootTitle2 = import_styled_components8.default.div`
|
|
2257
2355
|
margin-right: 4px;
|
|
2258
2356
|
min-width: 20px;
|
|
2259
2357
|
overflow: hidden;
|
|
@@ -2261,12 +2359,12 @@ var UIRootTitle2 = import_styled_components7.default.div`
|
|
|
2261
2359
|
white-space: nowrap;
|
|
2262
2360
|
color: var(--semi-color-text-2);
|
|
2263
2361
|
`;
|
|
2264
|
-
var UIVarName2 =
|
|
2362
|
+
var UIVarName2 = import_styled_components8.default.div`
|
|
2265
2363
|
overflow: hidden;
|
|
2266
2364
|
text-overflow: ellipsis;
|
|
2267
2365
|
white-space: nowrap;
|
|
2268
2366
|
`;
|
|
2269
|
-
var UITag2 = (0,
|
|
2367
|
+
var UITag2 = (0, import_styled_components8.default)(import_semi_ui17.Tag)`
|
|
2270
2368
|
display: inline-flex;
|
|
2271
2369
|
align-items: center;
|
|
2272
2370
|
justify-content: flex-start;
|
|
@@ -2280,7 +2378,7 @@ var UITag2 = (0, import_styled_components7.default)(import_semi_ui12.Tag)`
|
|
|
2280
2378
|
margin: 0 5px;
|
|
2281
2379
|
}
|
|
2282
2380
|
`;
|
|
2283
|
-
var
|
|
2381
|
+
var UIPopoverContent2 = import_styled_components8.default.div`
|
|
2284
2382
|
padding: 10px;
|
|
2285
2383
|
display: inline-flex;
|
|
2286
2384
|
align-items: center;
|
|
@@ -2288,13 +2386,13 @@ var UIPopoverContent = import_styled_components7.default.div`
|
|
|
2288
2386
|
`;
|
|
2289
2387
|
|
|
2290
2388
|
// src/components/prompt-editor-with-variables/extensions/variable-tag.tsx
|
|
2291
|
-
var VariableTagWidget = class extends
|
|
2389
|
+
var VariableTagWidget = class extends import_view4.WidgetType {
|
|
2292
2390
|
constructor({ keyPath, scope }) {
|
|
2293
2391
|
super();
|
|
2294
|
-
this.toDispose = new
|
|
2392
|
+
this.toDispose = new import_editor10.DisposableCollection();
|
|
2295
2393
|
this.renderIcon = (icon) => {
|
|
2296
2394
|
if (typeof icon === "string") {
|
|
2297
|
-
return /* @__PURE__ */
|
|
2395
|
+
return /* @__PURE__ */ import_react38.default.createElement("img", { style: { marginRight: 8 }, width: 12, height: 12, src: icon });
|
|
2298
2396
|
}
|
|
2299
2397
|
return icon;
|
|
2300
2398
|
};
|
|
@@ -2307,20 +2405,21 @@ var VariableTagWidget = class extends import_view3.WidgetType {
|
|
|
2307
2405
|
renderVariable(v) {
|
|
2308
2406
|
if (!v) {
|
|
2309
2407
|
this.renderReact(
|
|
2310
|
-
/* @__PURE__ */
|
|
2408
|
+
/* @__PURE__ */ import_react38.default.createElement(UITag2, { prefixIcon: /* @__PURE__ */ import_react38.default.createElement(import_semi_icons8.IconIssueStroked, null), color: "amber" }, "Unknown")
|
|
2311
2409
|
);
|
|
2312
2410
|
return;
|
|
2313
2411
|
}
|
|
2314
|
-
const rootField = (0,
|
|
2315
|
-
const
|
|
2412
|
+
const rootField = (0, import_lodash3.last)(v.parentFields) || v;
|
|
2413
|
+
const isRoot = v.parentFields.length === 0;
|
|
2414
|
+
const rootTitle = /* @__PURE__ */ import_react38.default.createElement(UIRootTitle2, null, rootField?.meta.title ? `${rootField.meta.title} ${isRoot ? "" : "-"} ` : "");
|
|
2316
2415
|
const rootIcon = this.renderIcon(rootField?.meta.icon);
|
|
2317
2416
|
this.renderReact(
|
|
2318
|
-
/* @__PURE__ */
|
|
2319
|
-
|
|
2417
|
+
/* @__PURE__ */ import_react38.default.createElement(
|
|
2418
|
+
import_semi_ui18.Popover,
|
|
2320
2419
|
{
|
|
2321
|
-
content: /* @__PURE__ */
|
|
2420
|
+
content: /* @__PURE__ */ import_react38.default.createElement(UIPopoverContent2, null, rootIcon, rootTitle, /* @__PURE__ */ import_react38.default.createElement(UIVarName2, null, v?.keyPath.slice(1).join(".")))
|
|
2322
2421
|
},
|
|
2323
|
-
/* @__PURE__ */
|
|
2422
|
+
/* @__PURE__ */ import_react38.default.createElement(UITag2, { prefixIcon: rootIcon }, rootTitle, !isRoot && /* @__PURE__ */ import_react38.default.createElement(UIVarName2, null, v?.key))
|
|
2324
2423
|
)
|
|
2325
2424
|
);
|
|
2326
2425
|
}
|
|
@@ -2328,7 +2427,7 @@ var VariableTagWidget = class extends import_view3.WidgetType {
|
|
|
2328
2427
|
const dom = document.createElement("span");
|
|
2329
2428
|
this.rootDOM = dom;
|
|
2330
2429
|
this.toDispose.push(
|
|
2331
|
-
|
|
2430
|
+
import_editor10.Disposable.create(() => {
|
|
2332
2431
|
import_react_dom.default.unmountComponentAtNode(this.rootDOM);
|
|
2333
2432
|
})
|
|
2334
2433
|
);
|
|
@@ -2345,7 +2444,7 @@ var VariableTagWidget = class extends import_view3.WidgetType {
|
|
|
2345
2444
|
return dom;
|
|
2346
2445
|
}
|
|
2347
2446
|
eq(other) {
|
|
2348
|
-
return (0,
|
|
2447
|
+
return (0, import_lodash3.isEqual)(this.keyPath, other.keyPath);
|
|
2349
2448
|
}
|
|
2350
2449
|
ignoreEvent() {
|
|
2351
2450
|
return false;
|
|
@@ -2355,12 +2454,12 @@ var VariableTagWidget = class extends import_view3.WidgetType {
|
|
|
2355
2454
|
}
|
|
2356
2455
|
};
|
|
2357
2456
|
function VariableTagInject() {
|
|
2358
|
-
const injector = (0,
|
|
2359
|
-
const scope = (0,
|
|
2360
|
-
(0,
|
|
2361
|
-
const atMatcher = new
|
|
2457
|
+
const injector = (0, import_react39.useInjector)();
|
|
2458
|
+
const scope = (0, import_editor10.useCurrentScope)();
|
|
2459
|
+
(0, import_react38.useLayoutEffect)(() => {
|
|
2460
|
+
const atMatcher = new import_view4.MatchDecorator({
|
|
2362
2461
|
regexp: /\{\{([^\}]+)\}\}/g,
|
|
2363
|
-
decoration: (match) =>
|
|
2462
|
+
decoration: (match) => import_view4.Decoration.replace({
|
|
2364
2463
|
widget: new VariableTagWidget({
|
|
2365
2464
|
keyPath: match[1]?.split(".") ?? [],
|
|
2366
2465
|
scope
|
|
@@ -2368,7 +2467,7 @@ function VariableTagInject() {
|
|
|
2368
2467
|
})
|
|
2369
2468
|
});
|
|
2370
2469
|
return injector.inject([
|
|
2371
|
-
|
|
2470
|
+
import_view4.ViewPlugin.fromClass(
|
|
2372
2471
|
class {
|
|
2373
2472
|
constructor(view) {
|
|
2374
2473
|
this.view = view;
|
|
@@ -2381,8 +2480,8 @@ function VariableTagInject() {
|
|
|
2381
2480
|
{
|
|
2382
2481
|
decorations: (p) => p.decorations,
|
|
2383
2482
|
provide(p) {
|
|
2384
|
-
return
|
|
2385
|
-
(view) => view.plugin(p)?.decorations ??
|
|
2483
|
+
return import_view4.EditorView.atomicRanges.of(
|
|
2484
|
+
(view) => view.plugin(p)?.decorations ?? import_view4.Decoration.none
|
|
2386
2485
|
);
|
|
2387
2486
|
}
|
|
2388
2487
|
}
|
|
@@ -2394,29 +2493,29 @@ function VariableTagInject() {
|
|
|
2394
2493
|
|
|
2395
2494
|
// src/components/prompt-editor-with-variables/index.tsx
|
|
2396
2495
|
function PromptEditorWithVariables(props) {
|
|
2397
|
-
return /* @__PURE__ */
|
|
2496
|
+
return /* @__PURE__ */ import_react40.default.createElement(PromptEditor, { ...props }, /* @__PURE__ */ import_react40.default.createElement(VariableTree, null), /* @__PURE__ */ import_react40.default.createElement(VariableTagInject, null));
|
|
2398
2497
|
}
|
|
2399
2498
|
|
|
2400
2499
|
// src/components/prompt-editor-with-inputs/index.tsx
|
|
2401
|
-
var
|
|
2500
|
+
var import_react44 = __toESM(require("react"));
|
|
2402
2501
|
|
|
2403
2502
|
// src/components/prompt-editor-with-inputs/extensions/inputs-tree.tsx
|
|
2404
|
-
var
|
|
2405
|
-
var
|
|
2406
|
-
var
|
|
2503
|
+
var import_react42 = __toESM(require("react"));
|
|
2504
|
+
var import_semi_ui20 = require("@douyinfe/semi-ui");
|
|
2505
|
+
var import_react43 = require("@coze-editor/editor/react");
|
|
2407
2506
|
|
|
2408
2507
|
// src/components/prompt-editor-with-inputs/inputs-picker.tsx
|
|
2409
|
-
var
|
|
2410
|
-
var
|
|
2411
|
-
var
|
|
2412
|
-
var
|
|
2508
|
+
var import_react41 = __toESM(require("react"));
|
|
2509
|
+
var import_lodash4 = require("lodash");
|
|
2510
|
+
var import_editor11 = require("@flowgram.ai/editor");
|
|
2511
|
+
var import_semi_ui19 = require("@douyinfe/semi-ui");
|
|
2413
2512
|
function InputsPicker({
|
|
2414
2513
|
inputsValues,
|
|
2415
2514
|
onSelect
|
|
2416
2515
|
}) {
|
|
2417
|
-
const available = (0,
|
|
2516
|
+
const available = (0, import_editor11.useScopeAvailable)();
|
|
2418
2517
|
const getArrayDrilldown = (type, depth = 1) => {
|
|
2419
|
-
if (
|
|
2518
|
+
if (import_editor11.ASTMatch.isArray(type.items)) {
|
|
2420
2519
|
return getArrayDrilldown(type.items, depth + 1);
|
|
2421
2520
|
}
|
|
2422
2521
|
return { type: type.items, depth };
|
|
@@ -2424,12 +2523,12 @@ function InputsPicker({
|
|
|
2424
2523
|
const renderVariable = (variable, keyPath) => {
|
|
2425
2524
|
let type = variable?.type;
|
|
2426
2525
|
let children;
|
|
2427
|
-
if (
|
|
2526
|
+
if (import_editor11.ASTMatch.isObject(type)) {
|
|
2428
2527
|
children = (type.properties || []).map((_property) => renderVariable(_property, [...keyPath, _property.key])).filter(Boolean);
|
|
2429
2528
|
}
|
|
2430
|
-
if (
|
|
2529
|
+
if (import_editor11.ASTMatch.isArray(type)) {
|
|
2431
2530
|
const drilldown = getArrayDrilldown(type);
|
|
2432
|
-
if (
|
|
2531
|
+
if (import_editor11.ASTMatch.isObject(drilldown.type)) {
|
|
2433
2532
|
children = (drilldown.type.properties || []).map(
|
|
2434
2533
|
(_property) => renderVariable(_property, [
|
|
2435
2534
|
...keyPath,
|
|
@@ -2442,14 +2541,14 @@ function InputsPicker({
|
|
|
2442
2541
|
const key = keyPath.map((_key, idx) => _key === "[0]" || idx === 0 ? _key : `.${_key}`).join("");
|
|
2443
2542
|
return {
|
|
2444
2543
|
key,
|
|
2445
|
-
label: (0,
|
|
2544
|
+
label: (0, import_lodash4.last)(keyPath),
|
|
2446
2545
|
value: key,
|
|
2447
2546
|
children
|
|
2448
2547
|
};
|
|
2449
2548
|
};
|
|
2450
|
-
const treeData = (0,
|
|
2549
|
+
const treeData = (0, import_react41.useMemo)(
|
|
2451
2550
|
() => Object.entries(inputsValues).map(([key, value]) => {
|
|
2452
|
-
if (value
|
|
2551
|
+
if (value?.type === "ref") {
|
|
2453
2552
|
const variable = available.getByKeyPath(value.content || []);
|
|
2454
2553
|
if (variable) {
|
|
2455
2554
|
return renderVariable(variable, [key]);
|
|
@@ -2463,392 +2562,82 @@ function InputsPicker({
|
|
|
2463
2562
|
}),
|
|
2464
2563
|
[]
|
|
2465
2564
|
);
|
|
2466
|
-
return /* @__PURE__ */
|
|
2565
|
+
return /* @__PURE__ */ import_react41.default.createElement(import_semi_ui19.Tree, { treeData, onSelect: (v) => onSelect(v) });
|
|
2467
2566
|
}
|
|
2468
2567
|
|
|
2469
2568
|
// src/components/prompt-editor-with-inputs/extensions/inputs-tree.tsx
|
|
2470
2569
|
function InputsTree({ inputsValues }) {
|
|
2471
|
-
const [posKey, setPosKey] = (0,
|
|
2472
|
-
const [visible, setVisible] = (0,
|
|
2473
|
-
const [position, setPosition] = (0,
|
|
2474
|
-
const editor = (0,
|
|
2570
|
+
const [posKey, setPosKey] = (0, import_react42.useState)("");
|
|
2571
|
+
const [visible, setVisible] = (0, import_react42.useState)(false);
|
|
2572
|
+
const [position, setPosition] = (0, import_react42.useState)(-1);
|
|
2573
|
+
const editor = (0, import_react43.useEditor)();
|
|
2475
2574
|
function insert(variablePath) {
|
|
2476
|
-
const range = (0,
|
|
2575
|
+
const range = (0, import_react43.getCurrentMentionReplaceRange)(editor.$view.state);
|
|
2477
2576
|
if (!range) {
|
|
2478
2577
|
return;
|
|
2479
2578
|
}
|
|
2480
2579
|
editor.replaceText({
|
|
2481
2580
|
...range,
|
|
2482
2581
|
text: "{{" + variablePath + "}}"
|
|
2483
|
-
});
|
|
2484
|
-
setVisible(false);
|
|
2485
|
-
}
|
|
2486
|
-
function handleOpenChange(e) {
|
|
2487
|
-
setPosition(e.state.selection.main.head);
|
|
2488
|
-
setVisible(e.value);
|
|
2489
|
-
}
|
|
2490
|
-
(0,
|
|
2491
|
-
if (!editor) {
|
|
2492
|
-
return;
|
|
2493
|
-
}
|
|
2494
|
-
}, [editor, visible]);
|
|
2495
|
-
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(
|
|
2496
|
-
import_semi_ui15.Popover,
|
|
2497
|
-
{
|
|
2498
|
-
visible,
|
|
2499
|
-
trigger: "custom",
|
|
2500
|
-
position: "topLeft",
|
|
2501
|
-
rePosKey: posKey,
|
|
2502
|
-
content: /* @__PURE__ */ import_react32.default.createElement("div", { style: { width: 300 } }, /* @__PURE__ */ import_react32.default.createElement(
|
|
2503
|
-
InputsPicker,
|
|
2504
|
-
{
|
|
2505
|
-
inputsValues,
|
|
2506
|
-
onSelect: (v) => {
|
|
2507
|
-
insert(v);
|
|
2508
|
-
}
|
|
2509
|
-
}
|
|
2510
|
-
))
|
|
2511
|
-
},
|
|
2512
|
-
/* @__PURE__ */ import_react32.default.createElement(
|
|
2513
|
-
import_react33.PositionMirror,
|
|
2514
|
-
{
|
|
2515
|
-
position,
|
|
2516
|
-
onChange: () => setPosKey(String(Math.random()))
|
|
2517
|
-
}
|
|
2518
|
-
)
|
|
2519
|
-
));
|
|
2520
|
-
}
|
|
2521
|
-
|
|
2522
|
-
// src/components/prompt-editor-with-inputs/index.tsx
|
|
2523
|
-
function PromptEditorWithInputs({ inputsValues, ...restProps }) {
|
|
2524
|
-
return /* @__PURE__ */ import_react34.default.createElement(PromptEditor, { ...restProps }, /* @__PURE__ */ import_react34.default.createElement(InputsTree, { inputsValues }));
|
|
2525
|
-
}
|
|
2526
|
-
|
|
2527
|
-
// src/components/code-editor/index.tsx
|
|
2528
|
-
var import_react35 = __toESM(require("react"));
|
|
2529
|
-
var import_react36 = require("@coze-editor/editor/react");
|
|
2530
|
-
var import_preset_code5 = __toESM(require("@coze-editor/editor/preset-code"));
|
|
2531
|
-
var import_view4 = require("@codemirror/view");
|
|
2532
|
-
|
|
2533
|
-
// src/components/code-editor/utils.ts
|
|
2534
|
-
function getSuffixByLanguageId(languageId) {
|
|
2535
|
-
if (languageId === "python") {
|
|
2536
|
-
return ".py";
|
|
2537
|
-
}
|
|
2538
|
-
if (languageId === "typescript") {
|
|
2539
|
-
return ".ts";
|
|
2540
|
-
}
|
|
2541
|
-
if (languageId === "shell") {
|
|
2542
|
-
return ".sh";
|
|
2543
|
-
}
|
|
2544
|
-
if (languageId === "json") {
|
|
2545
|
-
return ".json";
|
|
2546
|
-
}
|
|
2547
|
-
return "";
|
|
2548
|
-
}
|
|
2549
|
-
|
|
2550
|
-
// src/components/code-editor/theme/index.ts
|
|
2551
|
-
var import_preset_code3 = require("@coze-editor/editor/preset-code");
|
|
2552
|
-
|
|
2553
|
-
// src/components/code-editor/theme/light.ts
|
|
2554
|
-
var import_preset_code = require("@coze-editor/editor/preset-code");
|
|
2555
|
-
var colors = {
|
|
2556
|
-
background: "#F7F7FC",
|
|
2557
|
-
// syntax
|
|
2558
|
-
comment: "#000A298A",
|
|
2559
|
-
key: "#00818C",
|
|
2560
|
-
string: "#D1009D",
|
|
2561
|
-
number: "#C74200",
|
|
2562
|
-
boolean: "#2B57D9",
|
|
2563
|
-
null: "#2B57D9",
|
|
2564
|
-
separator: "#0F1529D1"
|
|
2565
|
-
};
|
|
2566
|
-
var lightTheme = (0, import_preset_code.createTheme)({
|
|
2567
|
-
variant: "light",
|
|
2568
|
-
settings: {
|
|
2569
|
-
background: "#fff",
|
|
2570
|
-
foreground: "#000",
|
|
2571
|
-
caret: "#000",
|
|
2572
|
-
selection: "#d9d9d9",
|
|
2573
|
-
gutterBackground: "#f0f0f0",
|
|
2574
|
-
gutterForeground: "#666",
|
|
2575
|
-
gutterBorderColor: "transparent",
|
|
2576
|
-
gutterBorderWidth: 0,
|
|
2577
|
-
lineHighlight: "#f0f0f0",
|
|
2578
|
-
bracketColors: ["#FFEF61", "#DD99FF", "#78B0FF"],
|
|
2579
|
-
tooltip: {
|
|
2580
|
-
backgroundColor: "#f0f0f0",
|
|
2581
|
-
color: "#000",
|
|
2582
|
-
border: "1px solid #ccc"
|
|
2583
|
-
},
|
|
2584
|
-
link: {
|
|
2585
|
-
color: "#007bff"
|
|
2586
|
-
},
|
|
2587
|
-
completionItemHover: {
|
|
2588
|
-
backgroundColor: "#f0f0f0"
|
|
2589
|
-
},
|
|
2590
|
-
completionItemSelected: {
|
|
2591
|
-
backgroundColor: "#e0e0e0"
|
|
2592
|
-
},
|
|
2593
|
-
completionItemIcon: {
|
|
2594
|
-
color: "#333"
|
|
2595
|
-
},
|
|
2596
|
-
completionItemLabel: {
|
|
2597
|
-
color: "#333"
|
|
2598
|
-
},
|
|
2599
|
-
completionItemInfo: {
|
|
2600
|
-
color: "#333"
|
|
2601
|
-
},
|
|
2602
|
-
completionItemDetail: {
|
|
2603
|
-
color: "#666"
|
|
2604
|
-
}
|
|
2605
|
-
},
|
|
2606
|
-
styles: [
|
|
2607
|
-
// JSON
|
|
2608
|
-
{
|
|
2609
|
-
tag: import_preset_code.tags.comment,
|
|
2610
|
-
color: colors.comment
|
|
2611
|
-
},
|
|
2612
|
-
{
|
|
2613
|
-
tag: [import_preset_code.tags.propertyName],
|
|
2614
|
-
color: colors.key
|
|
2615
|
-
},
|
|
2616
|
-
{
|
|
2617
|
-
tag: [import_preset_code.tags.string],
|
|
2618
|
-
color: colors.string
|
|
2619
|
-
},
|
|
2620
|
-
{
|
|
2621
|
-
tag: [import_preset_code.tags.number],
|
|
2622
|
-
color: colors.number
|
|
2623
|
-
},
|
|
2624
|
-
{
|
|
2625
|
-
tag: [import_preset_code.tags.bool],
|
|
2626
|
-
color: colors.boolean
|
|
2627
|
-
},
|
|
2628
|
-
{
|
|
2629
|
-
tag: [import_preset_code.tags.null],
|
|
2630
|
-
color: colors.null
|
|
2631
|
-
},
|
|
2632
|
-
{
|
|
2633
|
-
tag: [import_preset_code.tags.separator],
|
|
2634
|
-
color: colors.separator
|
|
2635
|
-
},
|
|
2636
|
-
// markdown
|
|
2637
|
-
{
|
|
2638
|
-
tag: [import_preset_code.tags.heading],
|
|
2639
|
-
color: "#3e76ef"
|
|
2640
|
-
},
|
|
2641
|
-
{
|
|
2642
|
-
tag: [import_preset_code.tags.processingInstruction],
|
|
2643
|
-
color: "#3e76ef"
|
|
2644
|
-
},
|
|
2645
|
-
// shell
|
|
2646
|
-
// curl
|
|
2647
|
-
{
|
|
2648
|
-
tag: [import_preset_code.tags.standard(import_preset_code.tags.variableName)],
|
|
2649
|
-
color: "#00804A"
|
|
2650
|
-
},
|
|
2651
|
-
// -X
|
|
2652
|
-
{
|
|
2653
|
-
tag: [import_preset_code.tags.attributeName],
|
|
2654
|
-
color: "#C74200"
|
|
2655
|
-
},
|
|
2656
|
-
// url in string (includes quotes), e.g. "https://..."
|
|
2657
|
-
{
|
|
2658
|
-
tag: [import_preset_code.tags.special(import_preset_code.tags.string)],
|
|
2659
|
-
color: "#2B57D9"
|
|
2660
|
-
}
|
|
2661
|
-
]
|
|
2662
|
-
});
|
|
2663
|
-
|
|
2664
|
-
// src/components/code-editor/theme/dark.ts
|
|
2665
|
-
var import_preset_code2 = require("@coze-editor/editor/preset-code");
|
|
2666
|
-
var colors2 = {
|
|
2667
|
-
background: "#151B27",
|
|
2668
|
-
// syntax
|
|
2669
|
-
comment: "#FFFFFF63",
|
|
2670
|
-
key: "#39E5D7",
|
|
2671
|
-
string: "#FF94D2",
|
|
2672
|
-
number: "#FF9933",
|
|
2673
|
-
boolean: "#78B0FF",
|
|
2674
|
-
null: "#78B0FF",
|
|
2675
|
-
separator: "#FFFFFFC9"
|
|
2676
|
-
};
|
|
2677
|
-
var darkTheme = (0, import_preset_code2.createTheme)({
|
|
2678
|
-
variant: "dark",
|
|
2679
|
-
settings: {
|
|
2680
|
-
background: colors2.background,
|
|
2681
|
-
foreground: "#fff",
|
|
2682
|
-
caret: "#AEAFAD",
|
|
2683
|
-
selection: "#d9d9d942",
|
|
2684
|
-
gutterBackground: colors2.background,
|
|
2685
|
-
gutterForeground: "#FFFFFF63",
|
|
2686
|
-
gutterBorderColor: "transparent",
|
|
2687
|
-
gutterBorderWidth: 0,
|
|
2688
|
-
lineHighlight: "#272e3d36",
|
|
2689
|
-
bracketColors: ["#FFEF61", "#DD99FF", "#78B0FF"],
|
|
2690
|
-
tooltip: {
|
|
2691
|
-
backgroundColor: "#363D4D",
|
|
2692
|
-
color: "#fff",
|
|
2693
|
-
border: "none"
|
|
2694
|
-
},
|
|
2695
|
-
link: {
|
|
2696
|
-
color: "#4daafc"
|
|
2697
|
-
},
|
|
2698
|
-
completionItemHover: {
|
|
2699
|
-
backgroundColor: "#FFFFFF0F"
|
|
2700
|
-
},
|
|
2701
|
-
completionItemSelected: {
|
|
2702
|
-
backgroundColor: "#FFFFFF17"
|
|
2703
|
-
},
|
|
2704
|
-
completionItemIcon: {
|
|
2705
|
-
color: "#FFFFFFC9"
|
|
2706
|
-
},
|
|
2707
|
-
completionItemLabel: {
|
|
2708
|
-
color: "#FFFFFFC9"
|
|
2709
|
-
},
|
|
2710
|
-
completionItemInfo: {
|
|
2711
|
-
color: "#FFFFFFC9"
|
|
2712
|
-
},
|
|
2713
|
-
completionItemDetail: {
|
|
2714
|
-
color: "#FFFFFF63"
|
|
2715
|
-
}
|
|
2716
|
-
},
|
|
2717
|
-
styles: [
|
|
2718
|
-
// json
|
|
2719
|
-
{
|
|
2720
|
-
tag: import_preset_code2.tags.comment,
|
|
2721
|
-
color: colors2.comment
|
|
2722
|
-
},
|
|
2723
|
-
{
|
|
2724
|
-
tag: [import_preset_code2.tags.propertyName],
|
|
2725
|
-
color: colors2.key
|
|
2726
|
-
},
|
|
2727
|
-
{
|
|
2728
|
-
tag: [import_preset_code2.tags.string],
|
|
2729
|
-
color: colors2.string
|
|
2730
|
-
},
|
|
2731
|
-
{
|
|
2732
|
-
tag: [import_preset_code2.tags.number],
|
|
2733
|
-
color: colors2.number
|
|
2734
|
-
},
|
|
2735
|
-
{
|
|
2736
|
-
tag: [import_preset_code2.tags.bool],
|
|
2737
|
-
color: colors2.boolean
|
|
2738
|
-
},
|
|
2739
|
-
{
|
|
2740
|
-
tag: [import_preset_code2.tags.null],
|
|
2741
|
-
color: colors2.null
|
|
2742
|
-
},
|
|
2743
|
-
{
|
|
2744
|
-
tag: [import_preset_code2.tags.separator],
|
|
2745
|
-
color: colors2.separator
|
|
2746
|
-
},
|
|
2747
|
-
// markdown
|
|
2748
|
-
{
|
|
2749
|
-
tag: [import_preset_code2.tags.heading],
|
|
2750
|
-
color: "#6b6bff"
|
|
2751
|
-
},
|
|
2752
|
-
{
|
|
2753
|
-
tag: [import_preset_code2.tags.processingInstruction],
|
|
2754
|
-
color: "#6b6bff"
|
|
2755
|
-
},
|
|
2756
|
-
// shell
|
|
2757
|
-
// curl
|
|
2758
|
-
{
|
|
2759
|
-
tag: [import_preset_code2.tags.standard(import_preset_code2.tags.variableName)],
|
|
2760
|
-
color: "#3BEB84"
|
|
2761
|
-
},
|
|
2762
|
-
// -X
|
|
2763
|
-
{
|
|
2764
|
-
tag: [import_preset_code2.tags.attributeName],
|
|
2765
|
-
color: "#FF9933"
|
|
2766
|
-
},
|
|
2767
|
-
// url in string (includes quotes), e.g. "https://..."
|
|
2768
|
-
{
|
|
2769
|
-
tag: [import_preset_code2.tags.special(import_preset_code2.tags.string)],
|
|
2770
|
-
color: "#78B0FF"
|
|
2771
|
-
}
|
|
2772
|
-
]
|
|
2773
|
-
});
|
|
2774
|
-
|
|
2775
|
-
// src/components/code-editor/theme/index.ts
|
|
2776
|
-
import_preset_code3.themes.register("dark", darkTheme);
|
|
2777
|
-
import_preset_code3.themes.register("light", lightTheme);
|
|
2778
|
-
|
|
2779
|
-
// src/components/code-editor/language-features.ts
|
|
2780
|
-
var import_preset_code4 = require("@coze-editor/editor/preset-code");
|
|
2781
|
-
var import_language_shell = require("@coze-editor/editor/language-shell");
|
|
2782
|
-
var import_language_python = require("@coze-editor/editor/language-python");
|
|
2783
|
-
var import_language_json = require("@coze-editor/editor/language-json");
|
|
2784
|
-
var import_editor9 = require("@coze-editor/editor");
|
|
2785
|
-
import_preset_code4.languages.register("python", import_language_python.python);
|
|
2786
|
-
import_preset_code4.languages.register("json", {
|
|
2787
|
-
// mixLanguages is used to solve the problem that interpolation also uses parentheses, which causes incorrect highlighting
|
|
2788
|
-
language: (0, import_editor9.mixLanguages)({
|
|
2789
|
-
outerLanguage: import_language_json.json.language
|
|
2790
|
-
}),
|
|
2791
|
-
languageService: import_language_json.json.languageService
|
|
2792
|
-
});
|
|
2793
|
-
import_preset_code4.languages.register("shell", import_language_shell.shell);
|
|
2794
|
-
|
|
2795
|
-
// src/components/code-editor/index.tsx
|
|
2796
|
-
var OriginCodeEditor = (0, import_react36.createRenderer)(import_preset_code5.default, [
|
|
2797
|
-
import_view4.EditorView.theme({
|
|
2798
|
-
"&.cm-focused": {
|
|
2799
|
-
outline: "none"
|
|
2800
|
-
}
|
|
2801
|
-
})
|
|
2802
|
-
]);
|
|
2803
|
-
function CodeEditor({
|
|
2804
|
-
value,
|
|
2805
|
-
onChange,
|
|
2806
|
-
languageId = "python",
|
|
2807
|
-
theme = "light",
|
|
2808
|
-
children,
|
|
2809
|
-
placeholder,
|
|
2810
|
-
activeLinePlaceholder
|
|
2811
|
-
}) {
|
|
2812
|
-
const editorRef = (0, import_react35.useRef)(null);
|
|
2813
|
-
(0, import_react35.useEffect)(() => {
|
|
2814
|
-
if (editorRef.current?.getValue() !== value) {
|
|
2815
|
-
editorRef.current?.setValue(String(value || ""));
|
|
2582
|
+
});
|
|
2583
|
+
setVisible(false);
|
|
2584
|
+
}
|
|
2585
|
+
function handleOpenChange(e) {
|
|
2586
|
+
setPosition(e.state.selection.main.head);
|
|
2587
|
+
setVisible(e.value);
|
|
2588
|
+
}
|
|
2589
|
+
(0, import_react42.useEffect)(() => {
|
|
2590
|
+
if (!editor) {
|
|
2591
|
+
return;
|
|
2816
2592
|
}
|
|
2817
|
-
}, [
|
|
2818
|
-
return /* @__PURE__ */
|
|
2819
|
-
|
|
2593
|
+
}, [editor, visible]);
|
|
2594
|
+
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(
|
|
2595
|
+
import_semi_ui20.Popover,
|
|
2820
2596
|
{
|
|
2821
|
-
|
|
2822
|
-
|
|
2823
|
-
|
|
2824
|
-
|
|
2825
|
-
|
|
2826
|
-
|
|
2827
|
-
|
|
2828
|
-
|
|
2829
|
-
|
|
2830
|
-
|
|
2831
|
-
|
|
2597
|
+
visible,
|
|
2598
|
+
trigger: "custom",
|
|
2599
|
+
position: "topLeft",
|
|
2600
|
+
rePosKey: posKey,
|
|
2601
|
+
content: /* @__PURE__ */ import_react42.default.createElement("div", { style: { width: 300 } }, /* @__PURE__ */ import_react42.default.createElement(
|
|
2602
|
+
InputsPicker,
|
|
2603
|
+
{
|
|
2604
|
+
inputsValues,
|
|
2605
|
+
onSelect: (v) => {
|
|
2606
|
+
insert(v);
|
|
2607
|
+
}
|
|
2608
|
+
}
|
|
2609
|
+
))
|
|
2832
2610
|
},
|
|
2833
|
-
|
|
2834
|
-
|
|
2611
|
+
/* @__PURE__ */ import_react42.default.createElement(
|
|
2612
|
+
import_react43.PositionMirror,
|
|
2613
|
+
{
|
|
2614
|
+
position,
|
|
2615
|
+
onChange: () => setPosKey(String(Math.random()))
|
|
2616
|
+
}
|
|
2617
|
+
)
|
|
2835
2618
|
));
|
|
2836
2619
|
}
|
|
2837
2620
|
|
|
2621
|
+
// src/components/prompt-editor-with-inputs/index.tsx
|
|
2622
|
+
function PromptEditorWithInputs({ inputsValues, ...restProps }) {
|
|
2623
|
+
return /* @__PURE__ */ import_react44.default.createElement(PromptEditor, { ...restProps }, /* @__PURE__ */ import_react44.default.createElement(InputsTree, { inputsValues }));
|
|
2624
|
+
}
|
|
2625
|
+
|
|
2838
2626
|
// src/components/json-editor-with-variables/index.tsx
|
|
2839
|
-
var
|
|
2627
|
+
var import_react49 = __toESM(require("react"));
|
|
2628
|
+
var import_preset_code6 = require("@coze-editor/editor/preset-code");
|
|
2840
2629
|
|
|
2841
2630
|
// src/components/json-editor-with-variables/extensions/variable-tree.tsx
|
|
2842
|
-
var
|
|
2843
|
-
var
|
|
2844
|
-
var
|
|
2631
|
+
var import_react45 = __toESM(require("react"));
|
|
2632
|
+
var import_semi_ui21 = require("@douyinfe/semi-ui");
|
|
2633
|
+
var import_react46 = require("@coze-editor/editor/react");
|
|
2845
2634
|
function VariableTree2() {
|
|
2846
|
-
const [posKey, setPosKey] = (0,
|
|
2847
|
-
const [visible, setVisible] = (0,
|
|
2848
|
-
const [position, setPosition] = (0,
|
|
2849
|
-
const editor = (0,
|
|
2635
|
+
const [posKey, setPosKey] = (0, import_react45.useState)("");
|
|
2636
|
+
const [visible, setVisible] = (0, import_react45.useState)(false);
|
|
2637
|
+
const [position, setPosition] = (0, import_react45.useState)(-1);
|
|
2638
|
+
const editor = (0, import_react46.useEditor)();
|
|
2850
2639
|
function insert(variablePath) {
|
|
2851
|
-
const range = (0,
|
|
2640
|
+
const range = (0, import_react46.getCurrentMentionReplaceRange)(editor.$view.state);
|
|
2852
2641
|
if (!range) {
|
|
2853
2642
|
return;
|
|
2854
2643
|
}
|
|
@@ -2862,21 +2651,21 @@ function VariableTree2() {
|
|
|
2862
2651
|
setPosition(e.state.selection.main.head);
|
|
2863
2652
|
setVisible(e.value);
|
|
2864
2653
|
}
|
|
2865
|
-
(0,
|
|
2654
|
+
(0, import_react45.useEffect)(() => {
|
|
2866
2655
|
if (!editor) {
|
|
2867
2656
|
return;
|
|
2868
2657
|
}
|
|
2869
2658
|
}, [editor, visible]);
|
|
2870
2659
|
const treeData = useVariableTree({});
|
|
2871
|
-
return /* @__PURE__ */
|
|
2872
|
-
|
|
2660
|
+
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(
|
|
2661
|
+
import_semi_ui21.Popover,
|
|
2873
2662
|
{
|
|
2874
2663
|
visible,
|
|
2875
2664
|
trigger: "custom",
|
|
2876
2665
|
position: "topLeft",
|
|
2877
2666
|
rePosKey: posKey,
|
|
2878
|
-
content: /* @__PURE__ */
|
|
2879
|
-
|
|
2667
|
+
content: /* @__PURE__ */ import_react45.default.createElement("div", { style: { width: 300 } }, /* @__PURE__ */ import_react45.default.createElement(
|
|
2668
|
+
import_semi_ui21.Tree,
|
|
2880
2669
|
{
|
|
2881
2670
|
treeData,
|
|
2882
2671
|
onSelect: (v) => {
|
|
@@ -2885,8 +2674,8 @@ function VariableTree2() {
|
|
|
2885
2674
|
}
|
|
2886
2675
|
))
|
|
2887
2676
|
},
|
|
2888
|
-
/* @__PURE__ */
|
|
2889
|
-
|
|
2677
|
+
/* @__PURE__ */ import_react45.default.createElement(
|
|
2678
|
+
import_react46.PositionMirror,
|
|
2890
2679
|
{
|
|
2891
2680
|
position,
|
|
2892
2681
|
onChange: () => setPosKey(String(Math.random()))
|
|
@@ -2896,19 +2685,19 @@ function VariableTree2() {
|
|
|
2896
2685
|
}
|
|
2897
2686
|
|
|
2898
2687
|
// src/components/json-editor-with-variables/extensions/variable-tag.tsx
|
|
2899
|
-
var
|
|
2688
|
+
var import_react47 = __toESM(require("react"));
|
|
2900
2689
|
var import_client = require("react-dom/client");
|
|
2901
|
-
var
|
|
2902
|
-
var
|
|
2903
|
-
var
|
|
2904
|
-
var
|
|
2905
|
-
var
|
|
2690
|
+
var import_lodash5 = require("lodash");
|
|
2691
|
+
var import_editor12 = require("@flowgram.ai/editor");
|
|
2692
|
+
var import_semi_ui23 = require("@douyinfe/semi-ui");
|
|
2693
|
+
var import_semi_icons9 = require("@douyinfe/semi-icons");
|
|
2694
|
+
var import_react48 = require("@coze-editor/editor/react");
|
|
2906
2695
|
var import_view5 = require("@codemirror/view");
|
|
2907
2696
|
|
|
2908
2697
|
// src/components/json-editor-with-variables/styles.tsx
|
|
2909
|
-
var
|
|
2910
|
-
var
|
|
2911
|
-
var UIRootTitle3 =
|
|
2698
|
+
var import_styled_components9 = __toESM(require("styled-components"));
|
|
2699
|
+
var import_semi_ui22 = require("@douyinfe/semi-ui");
|
|
2700
|
+
var UIRootTitle3 = import_styled_components9.default.div`
|
|
2912
2701
|
margin-right: 4px;
|
|
2913
2702
|
min-width: 20px;
|
|
2914
2703
|
overflow: hidden;
|
|
@@ -2916,12 +2705,12 @@ var UIRootTitle3 = import_styled_components8.default.div`
|
|
|
2916
2705
|
white-space: nowrap;
|
|
2917
2706
|
color: var(--semi-color-text-2);
|
|
2918
2707
|
`;
|
|
2919
|
-
var UIVarName3 =
|
|
2708
|
+
var UIVarName3 = import_styled_components9.default.div`
|
|
2920
2709
|
overflow: hidden;
|
|
2921
2710
|
text-overflow: ellipsis;
|
|
2922
2711
|
white-space: nowrap;
|
|
2923
2712
|
`;
|
|
2924
|
-
var UITag3 = (0,
|
|
2713
|
+
var UITag3 = (0, import_styled_components9.default)(import_semi_ui22.Tag)`
|
|
2925
2714
|
display: inline-flex;
|
|
2926
2715
|
align-items: center;
|
|
2927
2716
|
justify-content: flex-start;
|
|
@@ -2935,7 +2724,7 @@ var UITag3 = (0, import_styled_components8.default)(import_semi_ui17.Tag)`
|
|
|
2935
2724
|
margin: 0 5px;
|
|
2936
2725
|
}
|
|
2937
2726
|
`;
|
|
2938
|
-
var
|
|
2727
|
+
var UIPopoverContent3 = import_styled_components9.default.div`
|
|
2939
2728
|
padding: 10px;
|
|
2940
2729
|
display: inline-flex;
|
|
2941
2730
|
align-items: center;
|
|
@@ -2946,10 +2735,10 @@ var UIPopoverContent2 = import_styled_components8.default.div`
|
|
|
2946
2735
|
var VariableTagWidget2 = class extends import_view5.WidgetType {
|
|
2947
2736
|
constructor({ keyPath, scope }) {
|
|
2948
2737
|
super();
|
|
2949
|
-
this.toDispose = new
|
|
2738
|
+
this.toDispose = new import_editor12.DisposableCollection();
|
|
2950
2739
|
this.renderIcon = (icon) => {
|
|
2951
2740
|
if (typeof icon === "string") {
|
|
2952
|
-
return /* @__PURE__ */
|
|
2741
|
+
return /* @__PURE__ */ import_react47.default.createElement("img", { style: { marginRight: 8 }, width: 12, height: 12, src: icon });
|
|
2953
2742
|
}
|
|
2954
2743
|
return icon;
|
|
2955
2744
|
};
|
|
@@ -2959,20 +2748,20 @@ var VariableTagWidget2 = class extends import_view5.WidgetType {
|
|
|
2959
2748
|
renderVariable(v) {
|
|
2960
2749
|
if (!v) {
|
|
2961
2750
|
this.root.render(
|
|
2962
|
-
/* @__PURE__ */
|
|
2751
|
+
/* @__PURE__ */ import_react47.default.createElement(UITag3, { prefixIcon: /* @__PURE__ */ import_react47.default.createElement(import_semi_icons9.IconIssueStroked, null), color: "amber" }, "Unknown")
|
|
2963
2752
|
);
|
|
2964
2753
|
return;
|
|
2965
2754
|
}
|
|
2966
|
-
const rootField = (0,
|
|
2967
|
-
const rootTitle = /* @__PURE__ */
|
|
2755
|
+
const rootField = (0, import_lodash5.last)(v.parentFields);
|
|
2756
|
+
const rootTitle = /* @__PURE__ */ import_react47.default.createElement(UIRootTitle3, null, rootField?.meta.title ? `${rootField.meta.title} -` : "");
|
|
2968
2757
|
const rootIcon = this.renderIcon(rootField?.meta.icon);
|
|
2969
2758
|
this.root.render(
|
|
2970
|
-
/* @__PURE__ */
|
|
2971
|
-
|
|
2759
|
+
/* @__PURE__ */ import_react47.default.createElement(
|
|
2760
|
+
import_semi_ui23.Popover,
|
|
2972
2761
|
{
|
|
2973
|
-
content: /* @__PURE__ */
|
|
2762
|
+
content: /* @__PURE__ */ import_react47.default.createElement(UIPopoverContent3, null, rootIcon, rootTitle, /* @__PURE__ */ import_react47.default.createElement(UIVarName3, null, v?.keyPath.slice(1).join(".")))
|
|
2974
2763
|
},
|
|
2975
|
-
/* @__PURE__ */
|
|
2764
|
+
/* @__PURE__ */ import_react47.default.createElement(UITag3, { prefixIcon: rootIcon }, rootTitle, /* @__PURE__ */ import_react47.default.createElement(UIVarName3, null, v?.key))
|
|
2976
2765
|
)
|
|
2977
2766
|
);
|
|
2978
2767
|
}
|
|
@@ -2980,7 +2769,7 @@ var VariableTagWidget2 = class extends import_view5.WidgetType {
|
|
|
2980
2769
|
const dom = document.createElement("span");
|
|
2981
2770
|
this.root = (0, import_client.createRoot)(dom);
|
|
2982
2771
|
this.toDispose.push(
|
|
2983
|
-
|
|
2772
|
+
import_editor12.Disposable.create(() => {
|
|
2984
2773
|
this.root.unmount();
|
|
2985
2774
|
})
|
|
2986
2775
|
);
|
|
@@ -2997,7 +2786,7 @@ var VariableTagWidget2 = class extends import_view5.WidgetType {
|
|
|
2997
2786
|
return dom;
|
|
2998
2787
|
}
|
|
2999
2788
|
eq(other) {
|
|
3000
|
-
return (0,
|
|
2789
|
+
return (0, import_lodash5.isEqual)(this.keyPath, other.keyPath);
|
|
3001
2790
|
}
|
|
3002
2791
|
ignoreEvent() {
|
|
3003
2792
|
return false;
|
|
@@ -3007,9 +2796,9 @@ var VariableTagWidget2 = class extends import_view5.WidgetType {
|
|
|
3007
2796
|
}
|
|
3008
2797
|
};
|
|
3009
2798
|
function VariableTagInject2() {
|
|
3010
|
-
const injector = (0,
|
|
3011
|
-
const scope = (0,
|
|
3012
|
-
(0,
|
|
2799
|
+
const injector = (0, import_react48.useInjector)();
|
|
2800
|
+
const scope = (0, import_editor12.useCurrentScope)();
|
|
2801
|
+
(0, import_react47.useLayoutEffect)(() => {
|
|
3013
2802
|
const atMatcher = new import_view5.MatchDecorator({
|
|
3014
2803
|
regexp: /\{\{([^\}]+)\}\}/g,
|
|
3015
2804
|
decoration: (match) => import_view5.Decoration.replace({
|
|
@@ -3018,61 +2807,567 @@ function VariableTagInject2() {
|
|
|
3018
2807
|
scope
|
|
3019
2808
|
})
|
|
3020
2809
|
})
|
|
3021
|
-
});
|
|
3022
|
-
return injector.inject([
|
|
3023
|
-
import_view5.ViewPlugin.fromClass(
|
|
3024
|
-
class {
|
|
3025
|
-
constructor(view) {
|
|
3026
|
-
this.view = view;
|
|
3027
|
-
this.decorations = atMatcher.createDeco(view);
|
|
3028
|
-
}
|
|
3029
|
-
update() {
|
|
3030
|
-
this.decorations = atMatcher.createDeco(this.view);
|
|
3031
|
-
}
|
|
3032
|
-
},
|
|
3033
|
-
{
|
|
3034
|
-
decorations: (p) => p.decorations,
|
|
3035
|
-
provide(p) {
|
|
3036
|
-
return import_view5.EditorView.atomicRanges.of(
|
|
3037
|
-
(view) => view.plugin(p)?.decorations ?? import_view5.Decoration.none
|
|
3038
|
-
);
|
|
3039
|
-
}
|
|
3040
|
-
}
|
|
3041
|
-
)
|
|
3042
|
-
]);
|
|
3043
|
-
}, [injector]);
|
|
3044
|
-
return null;
|
|
2810
|
+
});
|
|
2811
|
+
return injector.inject([
|
|
2812
|
+
import_view5.ViewPlugin.fromClass(
|
|
2813
|
+
class {
|
|
2814
|
+
constructor(view) {
|
|
2815
|
+
this.view = view;
|
|
2816
|
+
this.decorations = atMatcher.createDeco(view);
|
|
2817
|
+
}
|
|
2818
|
+
update() {
|
|
2819
|
+
this.decorations = atMatcher.createDeco(this.view);
|
|
2820
|
+
}
|
|
2821
|
+
},
|
|
2822
|
+
{
|
|
2823
|
+
decorations: (p) => p.decorations,
|
|
2824
|
+
provide(p) {
|
|
2825
|
+
return import_view5.EditorView.atomicRanges.of(
|
|
2826
|
+
(view) => view.plugin(p)?.decorations ?? import_view5.Decoration.none
|
|
2827
|
+
);
|
|
2828
|
+
}
|
|
2829
|
+
}
|
|
2830
|
+
)
|
|
2831
|
+
]);
|
|
2832
|
+
}, [injector]);
|
|
2833
|
+
return null;
|
|
2834
|
+
}
|
|
2835
|
+
|
|
2836
|
+
// src/components/json-editor-with-variables/index.tsx
|
|
2837
|
+
function findAllMatches(inputString, regex) {
|
|
2838
|
+
const globalRegex = new RegExp(
|
|
2839
|
+
regex,
|
|
2840
|
+
regex.flags.includes("g") ? regex.flags : regex.flags + "g"
|
|
2841
|
+
);
|
|
2842
|
+
let match;
|
|
2843
|
+
const matches = [];
|
|
2844
|
+
while ((match = globalRegex.exec(inputString)) !== null) {
|
|
2845
|
+
if (match.index === globalRegex.lastIndex) {
|
|
2846
|
+
globalRegex.lastIndex++;
|
|
2847
|
+
}
|
|
2848
|
+
matches.push({
|
|
2849
|
+
match: match[0],
|
|
2850
|
+
range: [match.index, match.index + match[0].length]
|
|
2851
|
+
});
|
|
2852
|
+
}
|
|
2853
|
+
return matches;
|
|
2854
|
+
}
|
|
2855
|
+
var transformer = (0, import_preset_code6.transformerCreator)((text) => {
|
|
2856
|
+
const originalSource = text.toString();
|
|
2857
|
+
const matches = findAllMatches(originalSource, /\{\{([^\}]*)\}\}/g);
|
|
2858
|
+
if (matches.length > 0) {
|
|
2859
|
+
matches.forEach(({ range }) => {
|
|
2860
|
+
text.replaceRange(range[0], range[1], "null");
|
|
2861
|
+
});
|
|
2862
|
+
}
|
|
2863
|
+
return text;
|
|
2864
|
+
});
|
|
2865
|
+
function JsonEditorWithVariables(props) {
|
|
2866
|
+
return /* @__PURE__ */ import_react49.default.createElement(
|
|
2867
|
+
CodeEditor,
|
|
2868
|
+
{
|
|
2869
|
+
languageId: "json",
|
|
2870
|
+
activeLinePlaceholder: "Press '@' to Select variable",
|
|
2871
|
+
...props,
|
|
2872
|
+
options: {
|
|
2873
|
+
transformer,
|
|
2874
|
+
...props.options || {}
|
|
2875
|
+
}
|
|
2876
|
+
},
|
|
2877
|
+
/* @__PURE__ */ import_react49.default.createElement(VariableTree2, null),
|
|
2878
|
+
/* @__PURE__ */ import_react49.default.createElement(VariableTagInject2, null)
|
|
2879
|
+
);
|
|
2880
|
+
}
|
|
2881
|
+
|
|
2882
|
+
// src/components/inputs-values/index.tsx
|
|
2883
|
+
var import_react51 = __toESM(require("react"));
|
|
2884
|
+
var import_semi_ui24 = require("@douyinfe/semi-ui");
|
|
2885
|
+
var import_semi_icons10 = require("@douyinfe/semi-icons");
|
|
2886
|
+
|
|
2887
|
+
// src/components/inputs-values/styles.tsx
|
|
2888
|
+
var import_styled_components10 = __toESM(require("styled-components"));
|
|
2889
|
+
var UIRows2 = import_styled_components10.default.div`
|
|
2890
|
+
display: flex;
|
|
2891
|
+
flex-direction: column;
|
|
2892
|
+
gap: 10px;
|
|
2893
|
+
margin-bottom: 10px;
|
|
2894
|
+
`;
|
|
2895
|
+
var UIRow3 = import_styled_components10.default.div`
|
|
2896
|
+
display: flex;
|
|
2897
|
+
align-items: center;
|
|
2898
|
+
gap: 5px;
|
|
2899
|
+
`;
|
|
2900
|
+
|
|
2901
|
+
// src/components/inputs-values/components/blur-input.tsx
|
|
2902
|
+
var import_react50 = __toESM(require("react"));
|
|
2903
|
+
var import_input2 = __toESM(require("@douyinfe/semi-ui/lib/es/input"));
|
|
2904
|
+
function BlurInput2(props) {
|
|
2905
|
+
const [value, setValue] = (0, import_react50.useState)("");
|
|
2906
|
+
(0, import_react50.useEffect)(() => {
|
|
2907
|
+
setValue(props.value);
|
|
2908
|
+
}, [props.value]);
|
|
2909
|
+
return /* @__PURE__ */ import_react50.default.createElement(
|
|
2910
|
+
import_input2.default,
|
|
2911
|
+
{
|
|
2912
|
+
...props,
|
|
2913
|
+
value,
|
|
2914
|
+
onChange: (value2) => {
|
|
2915
|
+
setValue(value2);
|
|
2916
|
+
},
|
|
2917
|
+
onBlur: (e) => props.onChange?.(value, e)
|
|
2918
|
+
}
|
|
2919
|
+
);
|
|
2920
|
+
}
|
|
2921
|
+
|
|
2922
|
+
// src/components/inputs-values/index.tsx
|
|
2923
|
+
function InputsValues({
|
|
2924
|
+
value,
|
|
2925
|
+
onChange,
|
|
2926
|
+
style,
|
|
2927
|
+
readonly,
|
|
2928
|
+
constantProps,
|
|
2929
|
+
schema,
|
|
2930
|
+
hasError
|
|
2931
|
+
}) {
|
|
2932
|
+
const { list, updateKey, updateValue, remove, add } = useObjectList({
|
|
2933
|
+
value,
|
|
2934
|
+
onChange,
|
|
2935
|
+
sortIndexKey: "extra.index"
|
|
2936
|
+
});
|
|
2937
|
+
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(
|
|
2938
|
+
BlurInput2,
|
|
2939
|
+
{
|
|
2940
|
+
style: { width: 100, minWidth: 100, maxWidth: 100 },
|
|
2941
|
+
disabled: readonly,
|
|
2942
|
+
size: "small",
|
|
2943
|
+
value: item.key,
|
|
2944
|
+
onChange: (v) => updateKey(item.id, v),
|
|
2945
|
+
placeholder: "Input Key"
|
|
2946
|
+
}
|
|
2947
|
+
), /* @__PURE__ */ import_react51.default.createElement(
|
|
2948
|
+
DynamicValueInput,
|
|
2949
|
+
{
|
|
2950
|
+
style: { flexGrow: 1 },
|
|
2951
|
+
readonly,
|
|
2952
|
+
value: item.value,
|
|
2953
|
+
onChange: (v) => updateValue(item.id, v),
|
|
2954
|
+
schema,
|
|
2955
|
+
hasError,
|
|
2956
|
+
constantProps: {
|
|
2957
|
+
...constantProps,
|
|
2958
|
+
strategies: [...constantProps?.strategies || []]
|
|
2959
|
+
}
|
|
2960
|
+
}
|
|
2961
|
+
), /* @__PURE__ */ import_react51.default.createElement(
|
|
2962
|
+
import_semi_ui24.IconButton,
|
|
2963
|
+
{
|
|
2964
|
+
disabled: readonly,
|
|
2965
|
+
theme: "borderless",
|
|
2966
|
+
icon: /* @__PURE__ */ import_react51.default.createElement(import_semi_icons10.IconDelete, { size: "small" }),
|
|
2967
|
+
size: "small",
|
|
2968
|
+
onClick: () => remove(item.id)
|
|
2969
|
+
}
|
|
2970
|
+
)))), /* @__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"));
|
|
2971
|
+
}
|
|
2972
|
+
|
|
2973
|
+
// src/components/display-schema-tree/index.tsx
|
|
2974
|
+
var import_react52 = __toESM(require("react"));
|
|
2975
|
+
|
|
2976
|
+
// src/components/display-schema-tree/styles.tsx
|
|
2977
|
+
var import_styled_components11 = __toESM(require("styled-components"));
|
|
2978
|
+
var TreeRow = import_styled_components11.default.div`
|
|
2979
|
+
display: flex;
|
|
2980
|
+
align-items: center;
|
|
2981
|
+
|
|
2982
|
+
.tree-icon {
|
|
2983
|
+
margin-right: 8px;
|
|
2984
|
+
width: 14px;
|
|
2985
|
+
height: 14px;
|
|
2986
|
+
}
|
|
2987
|
+
|
|
2988
|
+
height: 27px;
|
|
2989
|
+
white-space: nowrap;
|
|
2990
|
+
`;
|
|
2991
|
+
var HorizontalLine = import_styled_components11.default.div`
|
|
2992
|
+
position: relative;
|
|
2993
|
+
|
|
2994
|
+
&::before,
|
|
2995
|
+
&::after {
|
|
2996
|
+
content: '';
|
|
2997
|
+
position: absolute;
|
|
2998
|
+
background-color: var(--semi-color-text-3);
|
|
2999
|
+
}
|
|
3000
|
+
|
|
3001
|
+
&::after {
|
|
3002
|
+
top: 0px;
|
|
3003
|
+
right: 6px;
|
|
3004
|
+
width: 15px;
|
|
3005
|
+
height: 1px;
|
|
3006
|
+
}
|
|
3007
|
+
`;
|
|
3008
|
+
var TreeTitle = import_styled_components11.default.div`
|
|
3009
|
+
// overflow: hidden;
|
|
3010
|
+
// text-overflow: ellipsis;
|
|
3011
|
+
`;
|
|
3012
|
+
var TreeLevel = import_styled_components11.default.div`
|
|
3013
|
+
padding-left: 30px;
|
|
3014
|
+
position: relative;
|
|
3015
|
+
|
|
3016
|
+
/* &::before {
|
|
3017
|
+
content: '';
|
|
3018
|
+
position: absolute;
|
|
3019
|
+
background-color: var(--semi-color-text-3);
|
|
3020
|
+
top: 0px;
|
|
3021
|
+
bottom: 0px;
|
|
3022
|
+
left: -22px;
|
|
3023
|
+
width: 1px;
|
|
3024
|
+
} */
|
|
3025
|
+
`;
|
|
3026
|
+
var TreeItem = import_styled_components11.default.div`
|
|
3027
|
+
position: relative;
|
|
3028
|
+
|
|
3029
|
+
&::before {
|
|
3030
|
+
content: '';
|
|
3031
|
+
position: absolute;
|
|
3032
|
+
background-color: var(--semi-color-text-3);
|
|
3033
|
+
}
|
|
3034
|
+
|
|
3035
|
+
&:not(:last-child)::before {
|
|
3036
|
+
width: 1px;
|
|
3037
|
+
top: 0;
|
|
3038
|
+
bottom: 0;
|
|
3039
|
+
left: -22px;
|
|
3040
|
+
}
|
|
3041
|
+
|
|
3042
|
+
&:last-child::before {
|
|
3043
|
+
width: 1px;
|
|
3044
|
+
top: 0;
|
|
3045
|
+
height: 14px;
|
|
3046
|
+
left: -22px;
|
|
3047
|
+
}
|
|
3048
|
+
|
|
3049
|
+
${(props) => props.depth === 0 && import_styled_components11.css`
|
|
3050
|
+
&::before {
|
|
3051
|
+
width: 0px !important;
|
|
3052
|
+
}
|
|
3053
|
+
`}
|
|
3054
|
+
`;
|
|
3055
|
+
|
|
3056
|
+
// src/components/display-schema-tree/index.tsx
|
|
3057
|
+
function DisplaySchemaTree(props) {
|
|
3058
|
+
return /* @__PURE__ */ import_react52.default.createElement(SchemaTree, { ...props });
|
|
3059
|
+
}
|
|
3060
|
+
function SchemaTree(props) {
|
|
3061
|
+
const {
|
|
3062
|
+
value: schema = {},
|
|
3063
|
+
drilldown = true,
|
|
3064
|
+
depth = 0,
|
|
3065
|
+
showIcon = true,
|
|
3066
|
+
parentKey = ""
|
|
3067
|
+
} = props || {};
|
|
3068
|
+
const typeManager = useTypeManager();
|
|
3069
|
+
const config = typeManager.getTypeBySchema(schema);
|
|
3070
|
+
const title = typeManager.getComplexText(schema);
|
|
3071
|
+
const icon = typeManager?.getDisplayIcon(schema);
|
|
3072
|
+
let properties = drilldown && config ? config.getTypeSchemaProperties(schema) : {};
|
|
3073
|
+
const childEntries = Object.entries(properties || {});
|
|
3074
|
+
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, {
|
|
3075
|
+
className: "tree-icon"
|
|
3076
|
+
}), /* @__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);
|
|
3077
|
+
}
|
|
3078
|
+
|
|
3079
|
+
// src/components/display-outputs/index.tsx
|
|
3080
|
+
var import_react54 = __toESM(require("react"));
|
|
3081
|
+
var import_json_schema7 = require("@flowgram.ai/json-schema");
|
|
3082
|
+
var import_editor13 = require("@flowgram.ai/editor");
|
|
3083
|
+
|
|
3084
|
+
// src/components/display-schema-tag/index.tsx
|
|
3085
|
+
var import_react53 = __toESM(require("react"));
|
|
3086
|
+
var import_semi_ui26 = require("@douyinfe/semi-ui");
|
|
3087
|
+
|
|
3088
|
+
// src/components/display-schema-tag/styles.ts
|
|
3089
|
+
var import_styled_components12 = __toESM(require("styled-components"));
|
|
3090
|
+
var import_semi_ui25 = require("@douyinfe/semi-ui");
|
|
3091
|
+
var PopoverContent = import_styled_components12.default.div`
|
|
3092
|
+
padding: 10px;
|
|
3093
|
+
`;
|
|
3094
|
+
var StyledTag = (0, import_styled_components12.default)(import_semi_ui25.Tag)`
|
|
3095
|
+
padding: 4px;
|
|
3096
|
+
|
|
3097
|
+
.tag-icon {
|
|
3098
|
+
width: 12px;
|
|
3099
|
+
height: 12px;
|
|
3100
|
+
}
|
|
3101
|
+
`;
|
|
3102
|
+
var TitleSpan = import_styled_components12.default.span`
|
|
3103
|
+
display: inline-block;
|
|
3104
|
+
margin-left: 4px;
|
|
3105
|
+
margin-top: -1px;
|
|
3106
|
+
overflow: hidden;
|
|
3107
|
+
text-overflow: ellipsis;
|
|
3108
|
+
`;
|
|
3109
|
+
|
|
3110
|
+
// src/components/display-schema-tag/index.tsx
|
|
3111
|
+
function DisplaySchemaTag({ value = {}, showIconInTree, title, warning }) {
|
|
3112
|
+
const typeManager = useTypeManager();
|
|
3113
|
+
const icon = typeManager?.getDisplayIcon(value) || typeManager.getDisplayIcon({ type: "unknown" });
|
|
3114
|
+
return /* @__PURE__ */ import_react53.default.createElement(
|
|
3115
|
+
import_semi_ui26.Popover,
|
|
3116
|
+
{
|
|
3117
|
+
content: /* @__PURE__ */ import_react53.default.createElement(PopoverContent, null, /* @__PURE__ */ import_react53.default.createElement(DisplaySchemaTree, { value, typeManager, showIcon: showIconInTree }))
|
|
3118
|
+
},
|
|
3119
|
+
/* @__PURE__ */ import_react53.default.createElement(StyledTag, { color: warning ? "amber" : "white" }, icon && import_react53.default.cloneElement(icon, {
|
|
3120
|
+
className: "tag-icon"
|
|
3121
|
+
}), title && /* @__PURE__ */ import_react53.default.createElement(TitleSpan, null, title))
|
|
3122
|
+
);
|
|
3123
|
+
}
|
|
3124
|
+
|
|
3125
|
+
// src/components/display-outputs/styles.ts
|
|
3126
|
+
var import_styled_components13 = __toESM(require("styled-components"));
|
|
3127
|
+
var DisplayOutputsWrapper = import_styled_components13.default.div`
|
|
3128
|
+
display: flex;
|
|
3129
|
+
gap: 5px;
|
|
3130
|
+
flex-wrap: wrap;
|
|
3131
|
+
`;
|
|
3132
|
+
|
|
3133
|
+
// src/components/display-outputs/index.tsx
|
|
3134
|
+
function DisplayOutputs({ value, showIconInTree, displayFromScope }) {
|
|
3135
|
+
const scope = (0, import_editor13.useCurrentScope)();
|
|
3136
|
+
const refresh = (0, import_editor13.useRefresh)();
|
|
3137
|
+
(0, import_react54.useEffect)(() => {
|
|
3138
|
+
if (!displayFromScope) {
|
|
3139
|
+
return () => null;
|
|
3140
|
+
}
|
|
3141
|
+
const disposable = scope.output.onListOrAnyVarChange(() => {
|
|
3142
|
+
refresh();
|
|
3143
|
+
});
|
|
3144
|
+
return () => {
|
|
3145
|
+
disposable.dispose();
|
|
3146
|
+
};
|
|
3147
|
+
}, [displayFromScope]);
|
|
3148
|
+
const properties = displayFromScope ? scope.output.variables?.reduce((acm, curr) => {
|
|
3149
|
+
acm = {
|
|
3150
|
+
...acm,
|
|
3151
|
+
...import_json_schema7.JsonSchemaUtils.astToSchema(curr.type)?.properties || {}
|
|
3152
|
+
};
|
|
3153
|
+
return acm;
|
|
3154
|
+
}, {}) : value?.properties || {};
|
|
3155
|
+
const childEntries = Object.entries(properties || {});
|
|
3156
|
+
return /* @__PURE__ */ import_react54.default.createElement(DisplayOutputsWrapper, null, childEntries.map(([key, schema]) => /* @__PURE__ */ import_react54.default.createElement(
|
|
3157
|
+
DisplaySchemaTag,
|
|
3158
|
+
{
|
|
3159
|
+
key,
|
|
3160
|
+
title: key,
|
|
3161
|
+
value: schema,
|
|
3162
|
+
showIconInTree,
|
|
3163
|
+
warning: !schema
|
|
3164
|
+
}
|
|
3165
|
+
)));
|
|
3166
|
+
}
|
|
3167
|
+
|
|
3168
|
+
// src/components/display-flow-value/index.tsx
|
|
3169
|
+
var import_react55 = __toESM(require("react"));
|
|
3170
|
+
var import_json_schema8 = require("@flowgram.ai/json-schema");
|
|
3171
|
+
var import_editor14 = require("@flowgram.ai/editor");
|
|
3172
|
+
function DisplayFlowValue({ value, title, showIconInTree }) {
|
|
3173
|
+
const available = (0, import_editor14.useScopeAvailable)();
|
|
3174
|
+
const variable = value?.type === "ref" ? available.getByKeyPath(value?.content) : void 0;
|
|
3175
|
+
const schema = (0, import_react55.useMemo)(() => {
|
|
3176
|
+
if (value?.type === "ref") {
|
|
3177
|
+
return import_json_schema8.JsonSchemaUtils.astToSchema(variable?.type);
|
|
3178
|
+
}
|
|
3179
|
+
if (value?.type === "template") {
|
|
3180
|
+
return { type: "string" };
|
|
3181
|
+
}
|
|
3182
|
+
if (value?.type === "constant") {
|
|
3183
|
+
if (value?.schema) {
|
|
3184
|
+
return value?.schema;
|
|
3185
|
+
}
|
|
3186
|
+
if (typeof value?.content === "string") {
|
|
3187
|
+
return { type: "string" };
|
|
3188
|
+
}
|
|
3189
|
+
if (typeof value?.content === "number") {
|
|
3190
|
+
return { type: "number" };
|
|
3191
|
+
}
|
|
3192
|
+
if (typeof value?.content === "boolean") {
|
|
3193
|
+
return { type: "boolean" };
|
|
3194
|
+
}
|
|
3195
|
+
}
|
|
3196
|
+
return { type: "unknown" };
|
|
3197
|
+
}, [value, variable?.hash]);
|
|
3198
|
+
return /* @__PURE__ */ import_react55.default.createElement(
|
|
3199
|
+
DisplaySchemaTag,
|
|
3200
|
+
{
|
|
3201
|
+
title,
|
|
3202
|
+
value: schema,
|
|
3203
|
+
showIconInTree,
|
|
3204
|
+
warning: value?.type === "ref" && !variable
|
|
3205
|
+
}
|
|
3206
|
+
);
|
|
3207
|
+
}
|
|
3208
|
+
|
|
3209
|
+
// src/components/display-inputs-values/index.tsx
|
|
3210
|
+
var import_react56 = __toESM(require("react"));
|
|
3211
|
+
|
|
3212
|
+
// src/components/display-inputs-values/styles.ts
|
|
3213
|
+
var import_styled_components14 = __toESM(require("styled-components"));
|
|
3214
|
+
var DisplayInputsWrapper = import_styled_components14.default.div`
|
|
3215
|
+
display: flex;
|
|
3216
|
+
gap: 5px;
|
|
3217
|
+
flex-wrap: wrap;
|
|
3218
|
+
`;
|
|
3219
|
+
|
|
3220
|
+
// src/components/display-inputs-values/index.tsx
|
|
3221
|
+
function DisplayInputsValues({ value, showIconInTree }) {
|
|
3222
|
+
const childEntries = Object.entries(value || {});
|
|
3223
|
+
return /* @__PURE__ */ import_react56.default.createElement(DisplayInputsWrapper, null, childEntries.map(([key, value2]) => /* @__PURE__ */ import_react56.default.createElement(DisplayFlowValue, { key, title: key, value: value2, showIconInTree })));
|
|
3224
|
+
}
|
|
3225
|
+
|
|
3226
|
+
// src/components/assign-rows/index.tsx
|
|
3227
|
+
var import_react59 = __toESM(require("react"));
|
|
3228
|
+
var import_editor15 = require("@flowgram.ai/editor");
|
|
3229
|
+
var import_semi_ui28 = require("@douyinfe/semi-ui");
|
|
3230
|
+
var import_semi_icons12 = require("@douyinfe/semi-icons");
|
|
3231
|
+
|
|
3232
|
+
// src/components/assign-row/index.tsx
|
|
3233
|
+
var import_react58 = __toESM(require("react"));
|
|
3234
|
+
var import_semi_ui27 = require("@douyinfe/semi-ui");
|
|
3235
|
+
var import_semi_icons11 = require("@douyinfe/semi-icons");
|
|
3236
|
+
|
|
3237
|
+
// src/components/assign-row/components/blur-input.tsx
|
|
3238
|
+
var import_react57 = __toESM(require("react"));
|
|
3239
|
+
var import_input3 = __toESM(require("@douyinfe/semi-ui/lib/es/input"));
|
|
3240
|
+
function BlurInput3(props) {
|
|
3241
|
+
const [value, setValue] = (0, import_react57.useState)("");
|
|
3242
|
+
(0, import_react57.useEffect)(() => {
|
|
3243
|
+
setValue(props.value);
|
|
3244
|
+
}, [props.value]);
|
|
3245
|
+
return /* @__PURE__ */ import_react57.default.createElement(
|
|
3246
|
+
import_input3.default,
|
|
3247
|
+
{
|
|
3248
|
+
...props,
|
|
3249
|
+
value,
|
|
3250
|
+
onChange: (value2) => {
|
|
3251
|
+
setValue(value2);
|
|
3252
|
+
},
|
|
3253
|
+
onBlur: (e) => props.onChange?.(value, e)
|
|
3254
|
+
}
|
|
3255
|
+
);
|
|
3256
|
+
}
|
|
3257
|
+
|
|
3258
|
+
// src/components/assign-row/index.tsx
|
|
3259
|
+
function AssignRow(props) {
|
|
3260
|
+
const {
|
|
3261
|
+
value = {
|
|
3262
|
+
operator: "assign"
|
|
3263
|
+
},
|
|
3264
|
+
onChange,
|
|
3265
|
+
onDelete,
|
|
3266
|
+
readonly
|
|
3267
|
+
} = props;
|
|
3268
|
+
return /* @__PURE__ */ import_react58.default.createElement("div", { style: { display: "flex", alignItems: "center", gap: 5 } }, /* @__PURE__ */ import_react58.default.createElement("div", { style: { width: 150, minWidth: 150, maxWidth: 150 } }, value?.operator === "assign" ? /* @__PURE__ */ import_react58.default.createElement(
|
|
3269
|
+
VariableSelector,
|
|
3270
|
+
{
|
|
3271
|
+
style: { width: "100%", height: 26 },
|
|
3272
|
+
value: value?.left?.content,
|
|
3273
|
+
config: { placeholder: "Select Left" },
|
|
3274
|
+
onChange: (v) => onChange?.({
|
|
3275
|
+
...value,
|
|
3276
|
+
left: { type: "ref", content: v }
|
|
3277
|
+
})
|
|
3278
|
+
}
|
|
3279
|
+
) : /* @__PURE__ */ import_react58.default.createElement(
|
|
3280
|
+
BlurInput3,
|
|
3281
|
+
{
|
|
3282
|
+
style: { height: 26 },
|
|
3283
|
+
size: "small",
|
|
3284
|
+
placeholder: "Input Name",
|
|
3285
|
+
value: value?.left,
|
|
3286
|
+
onChange: (v) => onChange?.({
|
|
3287
|
+
...value,
|
|
3288
|
+
left: v
|
|
3289
|
+
})
|
|
3290
|
+
}
|
|
3291
|
+
)), /* @__PURE__ */ import_react58.default.createElement("div", { style: { flexGrow: 1 } }, /* @__PURE__ */ import_react58.default.createElement(
|
|
3292
|
+
DynamicValueInput,
|
|
3293
|
+
{
|
|
3294
|
+
readonly,
|
|
3295
|
+
value: value?.right,
|
|
3296
|
+
onChange: (v) => onChange?.({
|
|
3297
|
+
...value,
|
|
3298
|
+
right: v
|
|
3299
|
+
})
|
|
3300
|
+
}
|
|
3301
|
+
)), onDelete && /* @__PURE__ */ import_react58.default.createElement("div", null, /* @__PURE__ */ import_react58.default.createElement(
|
|
3302
|
+
import_semi_ui27.IconButton,
|
|
3303
|
+
{
|
|
3304
|
+
size: "small",
|
|
3305
|
+
theme: "borderless",
|
|
3306
|
+
icon: /* @__PURE__ */ import_react58.default.createElement(import_semi_icons11.IconMinus, null),
|
|
3307
|
+
onClick: () => onDelete?.()
|
|
3308
|
+
}
|
|
3309
|
+
)));
|
|
3045
3310
|
}
|
|
3046
3311
|
|
|
3047
|
-
// src/components/
|
|
3048
|
-
function
|
|
3049
|
-
|
|
3312
|
+
// src/components/assign-rows/index.tsx
|
|
3313
|
+
function AssignRows(props) {
|
|
3314
|
+
const { name, readonly } = props;
|
|
3315
|
+
return /* @__PURE__ */ import_react59.default.createElement(import_editor15.FieldArray, { name }, ({ field }) => /* @__PURE__ */ import_react59.default.createElement(import_react59.default.Fragment, null, field.map((childField, index) => /* @__PURE__ */ import_react59.default.createElement(
|
|
3316
|
+
AssignRow,
|
|
3317
|
+
{
|
|
3318
|
+
key: childField.key,
|
|
3319
|
+
readonly,
|
|
3320
|
+
value: childField.value,
|
|
3321
|
+
onChange: (value) => {
|
|
3322
|
+
childField.onChange(value);
|
|
3323
|
+
},
|
|
3324
|
+
onDelete: () => field.remove(index)
|
|
3325
|
+
}
|
|
3326
|
+
)), /* @__PURE__ */ import_react59.default.createElement("div", { style: { display: "flex", gap: 5 } }, /* @__PURE__ */ import_react59.default.createElement(
|
|
3327
|
+
import_semi_ui28.Button,
|
|
3328
|
+
{
|
|
3329
|
+
size: "small",
|
|
3330
|
+
theme: "borderless",
|
|
3331
|
+
icon: /* @__PURE__ */ import_react59.default.createElement(import_semi_icons12.IconPlus, null),
|
|
3332
|
+
onClick: () => field.append({ operator: "assign" })
|
|
3333
|
+
},
|
|
3334
|
+
"Assign"
|
|
3335
|
+
), /* @__PURE__ */ import_react59.default.createElement(
|
|
3336
|
+
import_semi_ui28.Button,
|
|
3337
|
+
{
|
|
3338
|
+
size: "small",
|
|
3339
|
+
theme: "borderless",
|
|
3340
|
+
icon: /* @__PURE__ */ import_react59.default.createElement(import_semi_icons12.IconPlus, null),
|
|
3341
|
+
onClick: () => field.append({ operator: "declare" })
|
|
3342
|
+
},
|
|
3343
|
+
"Declaration"
|
|
3344
|
+
))));
|
|
3050
3345
|
}
|
|
3051
3346
|
|
|
3052
3347
|
// src/effects/provide-batch-input/index.ts
|
|
3053
|
-
var
|
|
3054
|
-
var provideBatchInputEffect = (0,
|
|
3348
|
+
var import_editor16 = require("@flowgram.ai/editor");
|
|
3349
|
+
var provideBatchInputEffect = (0, import_editor16.createEffectFromVariableProvider)({
|
|
3055
3350
|
private: true,
|
|
3056
3351
|
parse: (value, ctx) => [
|
|
3057
|
-
|
|
3352
|
+
import_editor16.ASTFactory.createVariableDeclaration({
|
|
3058
3353
|
key: `${ctx.node.id}_locals`,
|
|
3059
3354
|
meta: {
|
|
3060
|
-
title: (0,
|
|
3355
|
+
title: (0, import_editor16.getNodeForm)(ctx.node)?.getValueIn("title"),
|
|
3061
3356
|
icon: ctx.node.getNodeRegistry().info?.icon
|
|
3062
3357
|
},
|
|
3063
|
-
type:
|
|
3358
|
+
type: import_editor16.ASTFactory.createObject({
|
|
3064
3359
|
properties: [
|
|
3065
|
-
|
|
3360
|
+
import_editor16.ASTFactory.createProperty({
|
|
3066
3361
|
key: "item",
|
|
3067
|
-
initializer:
|
|
3068
|
-
enumerateFor:
|
|
3362
|
+
initializer: import_editor16.ASTFactory.createEnumerateExpression({
|
|
3363
|
+
enumerateFor: import_editor16.ASTFactory.createKeyPathExpression({
|
|
3069
3364
|
keyPath: value.content || []
|
|
3070
3365
|
})
|
|
3071
3366
|
})
|
|
3072
3367
|
}),
|
|
3073
|
-
|
|
3368
|
+
import_editor16.ASTFactory.createProperty({
|
|
3074
3369
|
key: "index",
|
|
3075
|
-
type:
|
|
3370
|
+
type: import_editor16.ASTFactory.createNumber()
|
|
3076
3371
|
})
|
|
3077
3372
|
]
|
|
3078
3373
|
})
|
|
@@ -3080,41 +3375,15 @@ var provideBatchInputEffect = (0, import_editor11.createEffectFromVariableProvid
|
|
|
3080
3375
|
]
|
|
3081
3376
|
});
|
|
3082
3377
|
|
|
3083
|
-
// src/effects/provide-batch-outputs/index.ts
|
|
3084
|
-
var import_editor12 = require("@flowgram.ai/editor");
|
|
3085
|
-
var provideBatchOutputsEffect = (0, import_editor12.createEffectFromVariableProvider)({
|
|
3086
|
-
parse: (value, ctx) => [
|
|
3087
|
-
import_editor12.ASTFactory.createVariableDeclaration({
|
|
3088
|
-
key: `${ctx.node.id}`,
|
|
3089
|
-
meta: {
|
|
3090
|
-
title: (0, import_editor12.getNodeForm)(ctx.node)?.getValueIn("title"),
|
|
3091
|
-
icon: ctx.node.getNodeRegistry().info?.icon
|
|
3092
|
-
},
|
|
3093
|
-
type: import_editor12.ASTFactory.createObject({
|
|
3094
|
-
properties: Object.entries(value).map(
|
|
3095
|
-
([_key, value2]) => import_editor12.ASTFactory.createProperty({
|
|
3096
|
-
key: _key,
|
|
3097
|
-
initializer: import_editor12.ASTFactory.createWrapArrayExpression({
|
|
3098
|
-
wrapFor: import_editor12.ASTFactory.createKeyPathExpression({
|
|
3099
|
-
keyPath: value2.content || []
|
|
3100
|
-
})
|
|
3101
|
-
})
|
|
3102
|
-
})
|
|
3103
|
-
)
|
|
3104
|
-
})
|
|
3105
|
-
})
|
|
3106
|
-
]
|
|
3107
|
-
});
|
|
3108
|
-
|
|
3109
3378
|
// src/effects/auto-rename-ref/index.ts
|
|
3110
|
-
var
|
|
3111
|
-
var
|
|
3379
|
+
var import_lodash6 = require("lodash");
|
|
3380
|
+
var import_editor17 = require("@flowgram.ai/editor");
|
|
3112
3381
|
var autoRenameRefEffect = [
|
|
3113
3382
|
{
|
|
3114
|
-
event:
|
|
3383
|
+
event: import_editor17.DataEvent.onValueInit,
|
|
3115
3384
|
effect: (params) => {
|
|
3116
3385
|
const { context, form, name } = params;
|
|
3117
|
-
const renameService = context.node.getService(
|
|
3386
|
+
const renameService = context.node.getService(import_editor17.VariableFieldKeyRenameService);
|
|
3118
3387
|
const disposable = renameService.onRename(({ before, after }) => {
|
|
3119
3388
|
const beforeKeyPath = [
|
|
3120
3389
|
...before.parentFields.map((_field) => _field.key).reverse(),
|
|
@@ -3125,9 +3394,30 @@ var autoRenameRefEffect = [
|
|
|
3125
3394
|
after.key
|
|
3126
3395
|
];
|
|
3127
3396
|
traverseRef(name, form.getValueIn(name), (_drilldownName, _v) => {
|
|
3128
|
-
if (
|
|
3129
|
-
|
|
3130
|
-
|
|
3397
|
+
if (_v.type === "ref") {
|
|
3398
|
+
if (isKeyPathMatch(_v.content, beforeKeyPath)) {
|
|
3399
|
+
_v.content = [...afterKeyPath, ...(_v.content || [])?.slice(beforeKeyPath.length)];
|
|
3400
|
+
form.setValueIn(_drilldownName, _v);
|
|
3401
|
+
}
|
|
3402
|
+
} else if (_v.type === "template") {
|
|
3403
|
+
const templateKeyPaths = getTemplateKeyPaths(_v);
|
|
3404
|
+
let hasMatch = false;
|
|
3405
|
+
templateKeyPaths.forEach((_keyPath) => {
|
|
3406
|
+
if (isKeyPathMatch(_keyPath, beforeKeyPath)) {
|
|
3407
|
+
hasMatch = true;
|
|
3408
|
+
const nextKeyPath = [
|
|
3409
|
+
...afterKeyPath,
|
|
3410
|
+
...(_keyPath || [])?.slice(beforeKeyPath.length)
|
|
3411
|
+
];
|
|
3412
|
+
_v.content = _v.content?.replace(
|
|
3413
|
+
`{{${_keyPath.join(".")}}`,
|
|
3414
|
+
`{{${nextKeyPath.join(".")}}`
|
|
3415
|
+
);
|
|
3416
|
+
}
|
|
3417
|
+
});
|
|
3418
|
+
if (hasMatch) {
|
|
3419
|
+
form.setValueIn(_drilldownName, { ..._v });
|
|
3420
|
+
}
|
|
3131
3421
|
}
|
|
3132
3422
|
});
|
|
3133
3423
|
});
|
|
@@ -3137,24 +3427,37 @@ var autoRenameRefEffect = [
|
|
|
3137
3427
|
}
|
|
3138
3428
|
}
|
|
3139
3429
|
];
|
|
3140
|
-
function
|
|
3141
|
-
return targetKeyPath.every((_key, index) => _key ===
|
|
3430
|
+
function isKeyPathMatch(keyPath = [], targetKeyPath) {
|
|
3431
|
+
return targetKeyPath.every((_key, index) => _key === keyPath[index]);
|
|
3432
|
+
}
|
|
3433
|
+
function getTemplateKeyPaths(value) {
|
|
3434
|
+
const keyPathReg = /{{(.*?)}}/g;
|
|
3435
|
+
return (0, import_lodash6.uniq)(value.content?.match(keyPathReg) || []).map(
|
|
3436
|
+
(_keyPath) => _keyPath.slice(2, -2).split(".")
|
|
3437
|
+
);
|
|
3142
3438
|
}
|
|
3143
3439
|
function isRef(value) {
|
|
3144
3440
|
return value?.type === "ref" && Array.isArray(value?.content) && typeof value?.content[0] === "string";
|
|
3145
3441
|
}
|
|
3442
|
+
function isTemplate(value) {
|
|
3443
|
+
return value?.type === "template" && typeof value?.content === "string";
|
|
3444
|
+
}
|
|
3146
3445
|
function traverseRef(name, value, cb) {
|
|
3147
|
-
if ((0,
|
|
3446
|
+
if ((0, import_lodash6.isObject)(value)) {
|
|
3148
3447
|
if (isRef(value)) {
|
|
3149
3448
|
cb(name, value);
|
|
3150
3449
|
return;
|
|
3151
3450
|
}
|
|
3451
|
+
if (isTemplate(value)) {
|
|
3452
|
+
cb(name, value);
|
|
3453
|
+
return;
|
|
3454
|
+
}
|
|
3152
3455
|
Object.entries(value).forEach(([_key, _value]) => {
|
|
3153
3456
|
traverseRef(`${name}.${_key}`, _value, cb);
|
|
3154
3457
|
});
|
|
3155
3458
|
return;
|
|
3156
3459
|
}
|
|
3157
|
-
if ((0,
|
|
3460
|
+
if ((0, import_lodash6.isArray)(value)) {
|
|
3158
3461
|
value.forEach((_value, idx) => {
|
|
3159
3462
|
traverseRef(`${name}[${idx}]`, _value, cb);
|
|
3160
3463
|
});
|
|
@@ -3164,29 +3467,31 @@ function traverseRef(name, value, cb) {
|
|
|
3164
3467
|
}
|
|
3165
3468
|
|
|
3166
3469
|
// src/effects/provide-json-schema-outputs/index.ts
|
|
3167
|
-
var
|
|
3168
|
-
var
|
|
3470
|
+
var import_json_schema9 = require("@flowgram.ai/json-schema");
|
|
3471
|
+
var import_editor18 = require("@flowgram.ai/editor");
|
|
3472
|
+
var provideJsonSchemaOutputs = (0, import_editor18.createEffectFromVariableProvider)({
|
|
3169
3473
|
parse: (value, ctx) => [
|
|
3170
|
-
|
|
3474
|
+
import_editor18.ASTFactory.createVariableDeclaration({
|
|
3171
3475
|
key: `${ctx.node.id}`,
|
|
3172
3476
|
meta: {
|
|
3173
|
-
title: (0,
|
|
3477
|
+
title: (0, import_editor18.getNodeForm)(ctx.node)?.getValueIn("title") || ctx.node.id,
|
|
3174
3478
|
icon: ctx.node.getNodeRegistry().info?.icon
|
|
3175
3479
|
},
|
|
3176
|
-
type: JsonSchemaUtils.schemaToAST(value)
|
|
3480
|
+
type: import_json_schema9.JsonSchemaUtils.schemaToAST(value)
|
|
3177
3481
|
})
|
|
3178
3482
|
]
|
|
3179
3483
|
});
|
|
3180
3484
|
|
|
3181
3485
|
// src/effects/sync-variable-title/index.ts
|
|
3182
|
-
var
|
|
3486
|
+
var import_editor19 = require("@flowgram.ai/editor");
|
|
3183
3487
|
var syncVariableTitle = [
|
|
3184
3488
|
{
|
|
3185
|
-
event:
|
|
3489
|
+
event: import_editor19.DataEvent.onValueChange,
|
|
3186
3490
|
effect: ({ value, context }) => {
|
|
3187
|
-
context.node.getData(
|
|
3491
|
+
context.node.getData(import_editor19.FlowNodeVariableData).allScopes.forEach((_scope) => {
|
|
3188
3492
|
_scope.output.variables.forEach((_var) => {
|
|
3189
3493
|
_var.updateMeta({
|
|
3494
|
+
..._var.meta || {},
|
|
3190
3495
|
title: value || context.node.id,
|
|
3191
3496
|
icon: context.node.getNodeRegistry().info?.icon
|
|
3192
3497
|
});
|
|
@@ -3196,22 +3501,154 @@ var syncVariableTitle = [
|
|
|
3196
3501
|
}
|
|
3197
3502
|
];
|
|
3198
3503
|
|
|
3504
|
+
// src/effects/validate-when-variable-sync/index.ts
|
|
3505
|
+
var import_lodash7 = require("lodash");
|
|
3506
|
+
var import_editor20 = require("@flowgram.ai/editor");
|
|
3507
|
+
var validateWhenVariableSync = ({
|
|
3508
|
+
scope
|
|
3509
|
+
} = {}) => [
|
|
3510
|
+
{
|
|
3511
|
+
event: import_editor20.DataEvent.onValueInit,
|
|
3512
|
+
effect: ({ context, form }) => {
|
|
3513
|
+
const nodeScope = scope === "private" ? (0, import_editor20.getNodePrivateScope)(context.node) : (0, import_editor20.getNodeScope)(context.node);
|
|
3514
|
+
const disposable = nodeScope.available.onListOrAnyVarChange(() => {
|
|
3515
|
+
if (!(0, import_lodash7.isEmpty)(form.state.errors)) {
|
|
3516
|
+
form.validate();
|
|
3517
|
+
}
|
|
3518
|
+
});
|
|
3519
|
+
return () => disposable.dispose();
|
|
3520
|
+
}
|
|
3521
|
+
}
|
|
3522
|
+
];
|
|
3523
|
+
|
|
3524
|
+
// src/effects/listen-ref-value-change/index.ts
|
|
3525
|
+
var import_editor21 = require("@flowgram.ai/editor");
|
|
3526
|
+
var listenRefValueChange = (cb) => [
|
|
3527
|
+
{
|
|
3528
|
+
event: import_editor21.DataEvent.onValueInitOrChange,
|
|
3529
|
+
effect: (params) => {
|
|
3530
|
+
const { context, value } = params;
|
|
3531
|
+
if (value?.type !== "ref") {
|
|
3532
|
+
return () => null;
|
|
3533
|
+
}
|
|
3534
|
+
const disposable = (0, import_editor21.getNodeScope)(context.node).available.trackByKeyPath(
|
|
3535
|
+
value?.content || [],
|
|
3536
|
+
(v) => {
|
|
3537
|
+
cb({ ...params, variable: v });
|
|
3538
|
+
}
|
|
3539
|
+
);
|
|
3540
|
+
return () => {
|
|
3541
|
+
disposable.dispose();
|
|
3542
|
+
};
|
|
3543
|
+
}
|
|
3544
|
+
}
|
|
3545
|
+
];
|
|
3546
|
+
|
|
3547
|
+
// src/effects/listen-ref-schema-change/index.ts
|
|
3548
|
+
var import_json_schema10 = require("@flowgram.ai/json-schema");
|
|
3549
|
+
var import_editor22 = require("@flowgram.ai/editor");
|
|
3550
|
+
var listenRefSchemaChange = (cb) => [
|
|
3551
|
+
{
|
|
3552
|
+
event: import_editor22.DataEvent.onValueInitOrChange,
|
|
3553
|
+
effect: (params) => {
|
|
3554
|
+
const { context, value } = params;
|
|
3555
|
+
if (value?.type !== "ref") {
|
|
3556
|
+
return () => null;
|
|
3557
|
+
}
|
|
3558
|
+
const disposable = (0, import_editor22.getNodeScope)(context.node).available.trackByKeyPath(
|
|
3559
|
+
value?.content || [],
|
|
3560
|
+
(_type) => {
|
|
3561
|
+
cb({ ...params, schema: import_json_schema10.JsonSchemaUtils.astToSchema(_type) });
|
|
3562
|
+
},
|
|
3563
|
+
{
|
|
3564
|
+
selector: (_v) => _v?.type
|
|
3565
|
+
}
|
|
3566
|
+
);
|
|
3567
|
+
return () => {
|
|
3568
|
+
disposable.dispose();
|
|
3569
|
+
};
|
|
3570
|
+
}
|
|
3571
|
+
}
|
|
3572
|
+
];
|
|
3573
|
+
|
|
3574
|
+
// src/shared/format-legacy-refs/index.ts
|
|
3575
|
+
var import_lodash8 = require("lodash");
|
|
3576
|
+
function formatLegacyRefOnSubmit(value) {
|
|
3577
|
+
if ((0, import_lodash8.isObject)(value)) {
|
|
3578
|
+
if (isLegacyFlowRefValueSchema(value)) {
|
|
3579
|
+
return formatLegacyRefToNewRef(value);
|
|
3580
|
+
}
|
|
3581
|
+
return Object.fromEntries(
|
|
3582
|
+
Object.entries(value).map(([key, value2]) => [
|
|
3583
|
+
key,
|
|
3584
|
+
formatLegacyRefOnSubmit(value2)
|
|
3585
|
+
])
|
|
3586
|
+
);
|
|
3587
|
+
}
|
|
3588
|
+
if (Array.isArray(value)) {
|
|
3589
|
+
return value.map(formatLegacyRefOnSubmit);
|
|
3590
|
+
}
|
|
3591
|
+
return value;
|
|
3592
|
+
}
|
|
3593
|
+
function formatLegacyRefOnInit(value) {
|
|
3594
|
+
if ((0, import_lodash8.isObject)(value)) {
|
|
3595
|
+
if (isNewFlowRefValueSchema(value)) {
|
|
3596
|
+
return formatNewRefToLegacyRef(value);
|
|
3597
|
+
}
|
|
3598
|
+
return Object.fromEntries(
|
|
3599
|
+
Object.entries(value).map(([key, value2]) => [
|
|
3600
|
+
key,
|
|
3601
|
+
formatLegacyRefOnInit(value2)
|
|
3602
|
+
])
|
|
3603
|
+
);
|
|
3604
|
+
}
|
|
3605
|
+
if (Array.isArray(value)) {
|
|
3606
|
+
return value.map(formatLegacyRefOnInit);
|
|
3607
|
+
}
|
|
3608
|
+
return value;
|
|
3609
|
+
}
|
|
3610
|
+
function isLegacyFlowRefValueSchema(value) {
|
|
3611
|
+
return (0, import_lodash8.isObject)(value) && Object.keys(value).length === 2 && value.type === "ref" && typeof value.content === "string";
|
|
3612
|
+
}
|
|
3613
|
+
function isNewFlowRefValueSchema(value) {
|
|
3614
|
+
return (0, import_lodash8.isObject)(value) && Object.keys(value).length === 2 && value.type === "ref" && Array.isArray(value.content);
|
|
3615
|
+
}
|
|
3616
|
+
function formatLegacyRefToNewRef(value) {
|
|
3617
|
+
const keyPath = value.content.split(".");
|
|
3618
|
+
if (keyPath[1] === "outputs") {
|
|
3619
|
+
return {
|
|
3620
|
+
type: "ref",
|
|
3621
|
+
content: [`${keyPath[0]}.${keyPath[1]}`, ...keyPath.length > 2 ? keyPath.slice(2) : []]
|
|
3622
|
+
};
|
|
3623
|
+
}
|
|
3624
|
+
return {
|
|
3625
|
+
type: "ref",
|
|
3626
|
+
content: keyPath
|
|
3627
|
+
};
|
|
3628
|
+
}
|
|
3629
|
+
function formatNewRefToLegacyRef(value) {
|
|
3630
|
+
return {
|
|
3631
|
+
type: "ref",
|
|
3632
|
+
content: value.content.join(".")
|
|
3633
|
+
};
|
|
3634
|
+
}
|
|
3635
|
+
|
|
3199
3636
|
// src/form-plugins/batch-outputs-plugin/index.ts
|
|
3200
|
-
var
|
|
3201
|
-
var
|
|
3637
|
+
var import_editor23 = require("@flowgram.ai/editor");
|
|
3638
|
+
var provideBatchOutputsEffect = (0, import_editor23.createEffectFromVariableProvider)({
|
|
3202
3639
|
parse: (value, ctx) => [
|
|
3203
|
-
|
|
3640
|
+
import_editor23.ASTFactory.createVariableDeclaration({
|
|
3204
3641
|
key: `${ctx.node.id}`,
|
|
3205
3642
|
meta: {
|
|
3206
|
-
title: (0,
|
|
3643
|
+
title: (0, import_editor23.getNodeForm)(ctx.node)?.getValueIn("title"),
|
|
3207
3644
|
icon: ctx.node.getNodeRegistry().info?.icon
|
|
3208
3645
|
},
|
|
3209
|
-
type:
|
|
3646
|
+
type: import_editor23.ASTFactory.createObject({
|
|
3210
3647
|
properties: Object.entries(value).map(
|
|
3211
|
-
([_key, value2]) =>
|
|
3648
|
+
([_key, value2]) => import_editor23.ASTFactory.createProperty({
|
|
3212
3649
|
key: _key,
|
|
3213
|
-
initializer:
|
|
3214
|
-
wrapFor:
|
|
3650
|
+
initializer: import_editor23.ASTFactory.createWrapArrayExpression({
|
|
3651
|
+
wrapFor: import_editor23.ASTFactory.createKeyPathExpression({
|
|
3215
3652
|
keyPath: value2?.content || []
|
|
3216
3653
|
})
|
|
3217
3654
|
})
|
|
@@ -3221,15 +3658,15 @@ var provideBatchOutputsEffect2 = (0, import_editor16.createEffectFromVariablePro
|
|
|
3221
3658
|
})
|
|
3222
3659
|
]
|
|
3223
3660
|
});
|
|
3224
|
-
var createBatchOutputsFormPlugin = (0,
|
|
3661
|
+
var createBatchOutputsFormPlugin = (0, import_editor23.defineFormPluginCreator)({
|
|
3225
3662
|
name: "batch-outputs-plugin",
|
|
3226
3663
|
onSetupFormMeta({ mergeEffect }, { outputKey }) {
|
|
3227
3664
|
mergeEffect({
|
|
3228
|
-
[outputKey]:
|
|
3665
|
+
[outputKey]: provideBatchOutputsEffect
|
|
3229
3666
|
});
|
|
3230
3667
|
},
|
|
3231
3668
|
onInit(ctx, { outputKey }) {
|
|
3232
|
-
const chainTransformService = ctx.node.getService(
|
|
3669
|
+
const chainTransformService = ctx.node.getService(import_editor23.ScopeChainTransformService);
|
|
3233
3670
|
const batchNodeType = ctx.node.flowNodeType;
|
|
3234
3671
|
const transformerId = `${batchNodeType}-outputs`;
|
|
3235
3672
|
if (chainTransformService.hasTransformer(transformerId)) {
|
|
@@ -3239,21 +3676,21 @@ var createBatchOutputsFormPlugin = (0, import_editor16.defineFormPluginCreator)(
|
|
|
3239
3676
|
transformCovers: (covers, ctx2) => {
|
|
3240
3677
|
const node = ctx2.scope.meta?.node;
|
|
3241
3678
|
if (node?.parent?.flowNodeType === batchNodeType) {
|
|
3242
|
-
return [...covers, (0,
|
|
3679
|
+
return [...covers, (0, import_editor23.getNodeScope)(node.parent)];
|
|
3243
3680
|
}
|
|
3244
3681
|
return covers;
|
|
3245
3682
|
},
|
|
3246
3683
|
transformDeps(scopes, ctx2) {
|
|
3247
3684
|
const scopeMeta = ctx2.scope.meta;
|
|
3248
|
-
if (scopeMeta?.type ===
|
|
3685
|
+
if (scopeMeta?.type === import_editor23.FlowNodeScopeType.private) {
|
|
3249
3686
|
return scopes;
|
|
3250
3687
|
}
|
|
3251
3688
|
const node = scopeMeta?.node;
|
|
3252
3689
|
if (node?.flowNodeType === batchNodeType) {
|
|
3253
3690
|
const childBlocks = node.blocks;
|
|
3254
3691
|
return [
|
|
3255
|
-
(0,
|
|
3256
|
-
...childBlocks.map((_childBlock) => (0,
|
|
3692
|
+
(0, import_editor23.getNodePrivateScope)(node),
|
|
3693
|
+
...childBlocks.map((_childBlock) => (0, import_editor23.getNodeScope)(_childBlock))
|
|
3257
3694
|
];
|
|
3258
3695
|
}
|
|
3259
3696
|
return scopes;
|
|
@@ -3261,39 +3698,226 @@ var createBatchOutputsFormPlugin = (0, import_editor16.defineFormPluginCreator)(
|
|
|
3261
3698
|
});
|
|
3262
3699
|
}
|
|
3263
3700
|
});
|
|
3701
|
+
|
|
3702
|
+
// src/form-plugins/infer-inputs-plugin/index.ts
|
|
3703
|
+
var import_lodash9 = require("lodash");
|
|
3704
|
+
var import_json_schema11 = require("@flowgram.ai/json-schema");
|
|
3705
|
+
var import_editor24 = require("@flowgram.ai/editor");
|
|
3706
|
+
var createInferInputsPlugin = (0, import_editor24.defineFormPluginCreator)({
|
|
3707
|
+
onSetupFormMeta({ addFormatOnSubmit }, { sourceKey, targetKey, scope }) {
|
|
3708
|
+
if (!sourceKey || !targetKey) {
|
|
3709
|
+
return;
|
|
3710
|
+
}
|
|
3711
|
+
addFormatOnSubmit((formData, ctx) => {
|
|
3712
|
+
(0, import_lodash9.set)(
|
|
3713
|
+
formData,
|
|
3714
|
+
targetKey,
|
|
3715
|
+
infer(
|
|
3716
|
+
(0, import_lodash9.get)(formData, sourceKey),
|
|
3717
|
+
scope === "private" ? (0, import_editor24.getNodePrivateScope)(ctx.node) : (0, import_editor24.getNodeScope)(ctx.node)
|
|
3718
|
+
)
|
|
3719
|
+
);
|
|
3720
|
+
return formData;
|
|
3721
|
+
});
|
|
3722
|
+
}
|
|
3723
|
+
});
|
|
3724
|
+
function isRef2(value) {
|
|
3725
|
+
return value?.type === "ref" && Array.isArray(value?.content) && typeof value?.content[0] === "string";
|
|
3726
|
+
}
|
|
3727
|
+
function isTemplate2(value) {
|
|
3728
|
+
return value?.type === "template" && typeof value?.content === "string";
|
|
3729
|
+
}
|
|
3730
|
+
function isConstant(value) {
|
|
3731
|
+
return value?.type === "constant" && typeof value?.content !== "undefined";
|
|
3732
|
+
}
|
|
3733
|
+
var infer = (values, scope) => {
|
|
3734
|
+
if (typeof values === "object") {
|
|
3735
|
+
if (isConstant(values)) {
|
|
3736
|
+
if (values?.schema) {
|
|
3737
|
+
return values.schema;
|
|
3738
|
+
}
|
|
3739
|
+
if (typeof values.content === "string") {
|
|
3740
|
+
return {
|
|
3741
|
+
type: "string"
|
|
3742
|
+
};
|
|
3743
|
+
}
|
|
3744
|
+
if (typeof values.content === "number") {
|
|
3745
|
+
return {
|
|
3746
|
+
type: "number"
|
|
3747
|
+
};
|
|
3748
|
+
}
|
|
3749
|
+
if (typeof values.content === "boolean") {
|
|
3750
|
+
return {
|
|
3751
|
+
type: "boolean"
|
|
3752
|
+
};
|
|
3753
|
+
}
|
|
3754
|
+
}
|
|
3755
|
+
if (isRef2(values)) {
|
|
3756
|
+
const variable = scope.available.getByKeyPath(values?.content);
|
|
3757
|
+
const schema = variable?.type ? import_json_schema11.JsonSchemaUtils.astToSchema(variable?.type) : void 0;
|
|
3758
|
+
return schema;
|
|
3759
|
+
}
|
|
3760
|
+
if (isTemplate2(values)) {
|
|
3761
|
+
return {
|
|
3762
|
+
type: "string"
|
|
3763
|
+
};
|
|
3764
|
+
}
|
|
3765
|
+
return {
|
|
3766
|
+
type: "object",
|
|
3767
|
+
properties: Object.keys(values).reduce((acc, key) => {
|
|
3768
|
+
const schema = infer(values[key], scope);
|
|
3769
|
+
if (schema) {
|
|
3770
|
+
acc[key] = schema;
|
|
3771
|
+
}
|
|
3772
|
+
return acc;
|
|
3773
|
+
}, {})
|
|
3774
|
+
};
|
|
3775
|
+
}
|
|
3776
|
+
};
|
|
3777
|
+
|
|
3778
|
+
// src/form-plugins/infer-assign-plugin/index.ts
|
|
3779
|
+
var import_lodash10 = require("lodash");
|
|
3780
|
+
var import_json_schema12 = require("@flowgram.ai/json-schema");
|
|
3781
|
+
var import_editor25 = require("@flowgram.ai/editor");
|
|
3782
|
+
var createInferAssignPlugin = (0, import_editor25.defineFormPluginCreator)({
|
|
3783
|
+
onSetupFormMeta({ addFormatOnSubmit, mergeEffect }, { assignKey, outputKey }) {
|
|
3784
|
+
if (!assignKey || !outputKey) {
|
|
3785
|
+
return;
|
|
3786
|
+
}
|
|
3787
|
+
mergeEffect({
|
|
3788
|
+
[assignKey]: (0, import_editor25.createEffectFromVariableProvider)({
|
|
3789
|
+
parse: (value, ctx) => {
|
|
3790
|
+
const declareRows = (0, import_lodash10.uniqBy)(
|
|
3791
|
+
value.filter((_v) => _v.operator === "declare" && _v.left && _v.right),
|
|
3792
|
+
"left"
|
|
3793
|
+
);
|
|
3794
|
+
return [
|
|
3795
|
+
import_editor25.ASTFactory.createVariableDeclaration({
|
|
3796
|
+
key: `${ctx.node.id}`,
|
|
3797
|
+
meta: {
|
|
3798
|
+
title: (0, import_editor25.getNodeForm)(ctx.node)?.getValueIn("title"),
|
|
3799
|
+
icon: ctx.node.getNodeRegistry().info?.icon
|
|
3800
|
+
},
|
|
3801
|
+
type: import_editor25.ASTFactory.createObject({
|
|
3802
|
+
properties: declareRows.map(
|
|
3803
|
+
(_v) => import_editor25.ASTFactory.createProperty({
|
|
3804
|
+
key: _v.left,
|
|
3805
|
+
type: _v.right?.type === "constant" ? import_json_schema12.JsonSchemaUtils.schemaToAST(_v.right?.schema || {}) : void 0,
|
|
3806
|
+
initializer: _v.right?.type === "ref" ? import_editor25.ASTFactory.createKeyPathExpression({
|
|
3807
|
+
keyPath: _v.right?.content || []
|
|
3808
|
+
}) : {}
|
|
3809
|
+
})
|
|
3810
|
+
)
|
|
3811
|
+
})
|
|
3812
|
+
})
|
|
3813
|
+
];
|
|
3814
|
+
}
|
|
3815
|
+
})
|
|
3816
|
+
});
|
|
3817
|
+
addFormatOnSubmit((formData, ctx) => {
|
|
3818
|
+
(0, import_lodash10.set)(
|
|
3819
|
+
formData,
|
|
3820
|
+
outputKey,
|
|
3821
|
+
import_json_schema12.JsonSchemaUtils.astToSchema((0, import_editor25.getNodeScope)(ctx.node).output.variables?.[0]?.type)
|
|
3822
|
+
);
|
|
3823
|
+
return formData;
|
|
3824
|
+
});
|
|
3825
|
+
}
|
|
3826
|
+
});
|
|
3827
|
+
|
|
3828
|
+
// src/validate/validate-flow-value/index.tsx
|
|
3829
|
+
var import_lodash11 = require("lodash");
|
|
3830
|
+
var import_editor26 = require("@flowgram.ai/editor");
|
|
3831
|
+
function validateFlowValue(value, ctx) {
|
|
3832
|
+
const { node, required, errorMessages } = ctx;
|
|
3833
|
+
const {
|
|
3834
|
+
required: requiredMessage = "Field is required",
|
|
3835
|
+
unknownVariable: unknownVariableMessage = "Unknown Variable"
|
|
3836
|
+
} = errorMessages || {};
|
|
3837
|
+
if (required && ((0, import_lodash11.isNil)(value) || (0, import_lodash11.isNil)(value?.content) || value?.content === "")) {
|
|
3838
|
+
return {
|
|
3839
|
+
level: import_editor26.FeedbackLevel.Error,
|
|
3840
|
+
message: requiredMessage
|
|
3841
|
+
};
|
|
3842
|
+
}
|
|
3843
|
+
if (value?.type === "ref") {
|
|
3844
|
+
const variable = (0, import_editor26.getNodeScope)(node).available.getByKeyPath(value?.content || []);
|
|
3845
|
+
if (!variable) {
|
|
3846
|
+
return {
|
|
3847
|
+
level: import_editor26.FeedbackLevel.Error,
|
|
3848
|
+
message: unknownVariableMessage
|
|
3849
|
+
};
|
|
3850
|
+
}
|
|
3851
|
+
}
|
|
3852
|
+
if (value?.type === "template") {
|
|
3853
|
+
const allRefs = getTemplateKeyPaths2(value);
|
|
3854
|
+
for (const ref of allRefs) {
|
|
3855
|
+
const variable = (0, import_editor26.getNodeScope)(node).available.getByKeyPath(ref);
|
|
3856
|
+
if (!variable) {
|
|
3857
|
+
return {
|
|
3858
|
+
level: import_editor26.FeedbackLevel.Error,
|
|
3859
|
+
message: unknownVariableMessage
|
|
3860
|
+
};
|
|
3861
|
+
}
|
|
3862
|
+
}
|
|
3863
|
+
}
|
|
3864
|
+
return void 0;
|
|
3865
|
+
}
|
|
3866
|
+
function getTemplateKeyPaths2(value) {
|
|
3867
|
+
const keyPathReg = /{{(.*?)}}/g;
|
|
3868
|
+
return (0, import_lodash11.uniq)(value.content?.match(keyPathReg) || []).map(
|
|
3869
|
+
(_keyPath) => _keyPath.slice(2, -2).split(".")
|
|
3870
|
+
);
|
|
3871
|
+
}
|
|
3264
3872
|
// Annotate the CommonJS export names for ESM import in node:
|
|
3265
3873
|
0 && (module.exports = {
|
|
3266
|
-
|
|
3874
|
+
AssignRow,
|
|
3875
|
+
AssignRows,
|
|
3267
3876
|
BatchOutputs,
|
|
3268
3877
|
BatchVariableSelector,
|
|
3269
3878
|
CodeEditor,
|
|
3879
|
+
CodeEditorMini,
|
|
3270
3880
|
ConditionRow,
|
|
3271
3881
|
ConstantInput,
|
|
3882
|
+
DisplayFlowValue,
|
|
3883
|
+
DisplayInputsValues,
|
|
3884
|
+
DisplayOutputs,
|
|
3885
|
+
DisplaySchemaTag,
|
|
3886
|
+
DisplaySchemaTree,
|
|
3272
3887
|
DynamicValueInput,
|
|
3888
|
+
InputsValues,
|
|
3273
3889
|
JsonEditorWithVariables,
|
|
3274
3890
|
JsonSchemaEditor,
|
|
3891
|
+
JsonSchemaTypePresetProvider,
|
|
3275
3892
|
JsonSchemaUtils,
|
|
3276
3893
|
PromptEditor,
|
|
3277
3894
|
PromptEditorWithInputs,
|
|
3278
3895
|
PromptEditorWithVariables,
|
|
3279
3896
|
TypeSelector,
|
|
3280
3897
|
VariableSelector,
|
|
3281
|
-
VariableTypeIcons,
|
|
3282
3898
|
autoRenameRefEffect,
|
|
3283
3899
|
createBatchOutputsFormPlugin,
|
|
3900
|
+
createDisableDeclarationPlugin,
|
|
3901
|
+
createInferAssignPlugin,
|
|
3902
|
+
createInferInputsPlugin,
|
|
3903
|
+
createTypePresetPlugin,
|
|
3284
3904
|
formatLegacyRefOnInit,
|
|
3285
3905
|
formatLegacyRefOnSubmit,
|
|
3286
3906
|
formatLegacyRefToNewRef,
|
|
3287
3907
|
formatNewRefToLegacyRef,
|
|
3288
|
-
getSchemaIcon,
|
|
3289
3908
|
getTypeSelectValue,
|
|
3290
3909
|
isLegacyFlowRefValueSchema,
|
|
3291
3910
|
isNewFlowRefValueSchema,
|
|
3911
|
+
listenRefSchemaChange,
|
|
3912
|
+
listenRefValueChange,
|
|
3292
3913
|
parseTypeSelectValue,
|
|
3293
3914
|
provideBatchInputEffect,
|
|
3294
3915
|
provideBatchOutputsEffect,
|
|
3295
3916
|
provideJsonSchemaOutputs,
|
|
3296
3917
|
syncVariableTitle,
|
|
3297
|
-
|
|
3918
|
+
useTypeManager,
|
|
3919
|
+
useVariableTree,
|
|
3920
|
+
validateFlowValue,
|
|
3921
|
+
validateWhenVariableSync
|
|
3298
3922
|
});
|
|
3299
3923
|
//# sourceMappingURL=index.js.map
|