@flowgram.ai/form-materials 0.4.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/index.js +723 -401
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.mts +132 -29
- package/dist/index.d.ts +132 -29
- package/dist/index.js +839 -510
- package/dist/index.js.map +1 -1
- package/package.json +6 -5
- package/src/components/batch-outputs/index.tsx +3 -2
- package/src/components/dynamic-value-input/hooks.ts +1 -1
- package/src/components/dynamic-value-input/index.tsx +1 -1
- package/src/components/dynamic-value-input/styles.tsx +14 -4
- package/src/components/index.ts +2 -0
- package/src/components/inputs-values/index.tsx +3 -3
- package/src/components/inputs-values/styles.tsx +1 -1
- package/src/components/inputs-values-tree/hooks/use-child-list.tsx +71 -0
- package/src/components/inputs-values-tree/index.tsx +56 -0
- package/src/components/inputs-values-tree/row.tsx +163 -0
- package/src/components/inputs-values-tree/styles.tsx +128 -0
- package/src/components/inputs-values-tree/types.ts +21 -0
- package/src/components/json-schema-editor/default-value.tsx +1 -3
- package/src/components/json-schema-editor/hooks.tsx +13 -2
- package/src/components/json-schema-editor/index.tsx +17 -57
- package/src/components/json-schema-editor/styles.tsx +12 -55
- package/src/components/json-schema-editor/types.ts +0 -1
- package/src/components/prompt-editor/index.tsx +10 -3
- package/src/effects/auto-rename-ref/index.ts +7 -54
- package/src/form-plugins/infer-inputs-plugin/index.ts +3 -75
- package/src/hooks/use-object-list/index.tsx +34 -6
- package/src/plugins/json-schema-preset/manager.ts +1 -0
- package/src/plugins/json-schema-preset/type-definition/string.tsx +18 -9
- package/src/shared/flow-value/index.ts +6 -0
- package/src/shared/flow-value/schema.ts +38 -0
- package/src/shared/flow-value/utils.ts +201 -0
- package/src/shared/index.ts +1 -0
- package/src/typings/flow-value/index.ts +2 -0
- package/src/components/json-schema-editor/components/blur-input.tsx +0 -27
- package/src/plugins/disable-declaration-plugin/config.json +0 -5
- package/src/plugins/json-schema-preset/config.json +0 -9
- /package/src/components/{inputs-values/components/blur-input.tsx → blur-input/index.tsx} +0 -0
package/dist/index.js
CHANGED
|
@@ -34,6 +34,7 @@ __export(src_exports, {
|
|
|
34
34
|
AssignRows: () => AssignRows,
|
|
35
35
|
BatchOutputs: () => BatchOutputs,
|
|
36
36
|
BatchVariableSelector: () => BatchVariableSelector,
|
|
37
|
+
BlurInput: () => BlurInput,
|
|
37
38
|
CodeEditor: () => CodeEditor,
|
|
38
39
|
CodeEditorMini: () => CodeEditorMini,
|
|
39
40
|
ConditionRow: () => ConditionRow,
|
|
@@ -44,14 +45,16 @@ __export(src_exports, {
|
|
|
44
45
|
DisplaySchemaTag: () => DisplaySchemaTag,
|
|
45
46
|
DisplaySchemaTree: () => DisplaySchemaTree,
|
|
46
47
|
DynamicValueInput: () => DynamicValueInput,
|
|
48
|
+
FlowValueUtils: () => FlowValueUtils,
|
|
47
49
|
InjectDynamicValueInput: () => InjectDynamicValueInput,
|
|
48
50
|
InjectTypeSelector: () => InjectTypeSelector,
|
|
49
51
|
InjectVariableSelector: () => InjectVariableSelector,
|
|
50
52
|
InputsValues: () => InputsValues,
|
|
53
|
+
InputsValuesTree: () => InputsValuesTree,
|
|
51
54
|
JsonEditorWithVariables: () => JsonEditorWithVariables,
|
|
52
55
|
JsonSchemaEditor: () => JsonSchemaEditor,
|
|
53
56
|
JsonSchemaTypePresetProvider: () => JsonSchemaTypePresetProvider,
|
|
54
|
-
JsonSchemaUtils: () =>
|
|
57
|
+
JsonSchemaUtils: () => import_json_schema4.JsonSchemaUtils,
|
|
55
58
|
PromptEditor: () => PromptEditor,
|
|
56
59
|
PromptEditorWithInputs: () => PromptEditorWithInputs,
|
|
57
60
|
PromptEditorWithVariables: () => PromptEditorWithVariables,
|
|
@@ -179,18 +182,171 @@ function createInjectMaterial(Component, params) {
|
|
|
179
182
|
return InjectComponent;
|
|
180
183
|
}
|
|
181
184
|
|
|
185
|
+
// src/shared/flow-value/utils.ts
|
|
186
|
+
var import_lodash2 = require("lodash");
|
|
187
|
+
var import_json_schema = require("@flowgram.ai/json-schema");
|
|
188
|
+
|
|
189
|
+
// src/shared/flow-value/schema.ts
|
|
190
|
+
var import_zod = __toESM(require("zod"));
|
|
191
|
+
var extraSchema = import_zod.default.object({
|
|
192
|
+
index: import_zod.default.number().optional()
|
|
193
|
+
}).optional();
|
|
194
|
+
var constantSchema = import_zod.default.object({
|
|
195
|
+
type: import_zod.default.literal("constant"),
|
|
196
|
+
content: import_zod.default.union([import_zod.default.string(), import_zod.default.number(), import_zod.default.boolean()]).optional(),
|
|
197
|
+
schema: import_zod.default.any().optional(),
|
|
198
|
+
extra: extraSchema
|
|
199
|
+
});
|
|
200
|
+
var refSchema = import_zod.default.object({
|
|
201
|
+
type: import_zod.default.literal("ref"),
|
|
202
|
+
content: import_zod.default.array(import_zod.default.string()).optional(),
|
|
203
|
+
extra: extraSchema
|
|
204
|
+
});
|
|
205
|
+
var expressionSchema = import_zod.default.object({
|
|
206
|
+
type: import_zod.default.literal("expression"),
|
|
207
|
+
content: import_zod.default.string().optional(),
|
|
208
|
+
extra: extraSchema
|
|
209
|
+
});
|
|
210
|
+
var templateSchema = import_zod.default.object({
|
|
211
|
+
type: import_zod.default.literal("template"),
|
|
212
|
+
content: import_zod.default.string().optional(),
|
|
213
|
+
extra: extraSchema
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
// src/shared/flow-value/utils.ts
|
|
217
|
+
var FlowValueUtils;
|
|
218
|
+
((FlowValueUtils2) => {
|
|
219
|
+
function isConstant(value) {
|
|
220
|
+
return constantSchema.safeParse(value).success;
|
|
221
|
+
}
|
|
222
|
+
FlowValueUtils2.isConstant = isConstant;
|
|
223
|
+
function isRef(value) {
|
|
224
|
+
return refSchema.safeParse(value).success;
|
|
225
|
+
}
|
|
226
|
+
FlowValueUtils2.isRef = isRef;
|
|
227
|
+
function isExpression(value) {
|
|
228
|
+
return expressionSchema.safeParse(value).success;
|
|
229
|
+
}
|
|
230
|
+
FlowValueUtils2.isExpression = isExpression;
|
|
231
|
+
function isTemplate(value) {
|
|
232
|
+
return templateSchema.safeParse(value).success;
|
|
233
|
+
}
|
|
234
|
+
FlowValueUtils2.isTemplate = isTemplate;
|
|
235
|
+
function isConstantOrRef(value) {
|
|
236
|
+
return isConstant(value) || isRef(value);
|
|
237
|
+
}
|
|
238
|
+
FlowValueUtils2.isConstantOrRef = isConstantOrRef;
|
|
239
|
+
function isFlowValue(value) {
|
|
240
|
+
return isConstant(value) || isRef(value) || isExpression(value) || isTemplate(value);
|
|
241
|
+
}
|
|
242
|
+
FlowValueUtils2.isFlowValue = isFlowValue;
|
|
243
|
+
function* traverse(value, options) {
|
|
244
|
+
const { includeTypes = ["ref", "template"], path = "" } = options;
|
|
245
|
+
if ((0, import_lodash2.isPlainObject)(value)) {
|
|
246
|
+
if (isRef(value) && includeTypes.includes("ref")) {
|
|
247
|
+
yield { value, path };
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
if (isTemplate(value) && includeTypes.includes("template")) {
|
|
251
|
+
yield { value, path };
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
254
|
+
if (isExpression(value) && includeTypes.includes("expression")) {
|
|
255
|
+
yield { value, path };
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
if (isConstant(value) && includeTypes.includes("constant")) {
|
|
259
|
+
yield { value, path };
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
262
|
+
for (const [_key, _value] of Object.entries(value)) {
|
|
263
|
+
yield* traverse(_value, { ...options, path: `${path}.${_key}` });
|
|
264
|
+
}
|
|
265
|
+
return;
|
|
266
|
+
}
|
|
267
|
+
if ((0, import_lodash2.isArray)(value)) {
|
|
268
|
+
for (const [_idx, _value] of value.entries()) {
|
|
269
|
+
yield* traverse(_value, { ...options, path: `${path}[${_idx}]` });
|
|
270
|
+
}
|
|
271
|
+
return;
|
|
272
|
+
}
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
275
|
+
FlowValueUtils2.traverse = traverse;
|
|
276
|
+
function getTemplateKeyPaths2(value) {
|
|
277
|
+
const keyPathReg = /{{(.*?)}}/g;
|
|
278
|
+
return (0, import_lodash2.uniq)(value.content?.match(keyPathReg) || []).map(
|
|
279
|
+
(_keyPath) => _keyPath.slice(2, -2).split(".")
|
|
280
|
+
);
|
|
281
|
+
}
|
|
282
|
+
FlowValueUtils2.getTemplateKeyPaths = getTemplateKeyPaths2;
|
|
283
|
+
function inferConstantJsonSchema(value) {
|
|
284
|
+
if (value?.schema) {
|
|
285
|
+
return value.schema;
|
|
286
|
+
}
|
|
287
|
+
if (typeof value.content === "string") {
|
|
288
|
+
return {
|
|
289
|
+
type: "string"
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
if (typeof value.content === "number") {
|
|
293
|
+
return {
|
|
294
|
+
type: "number"
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
if (typeof value.content === "boolean") {
|
|
298
|
+
return {
|
|
299
|
+
type: "boolean"
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
if ((0, import_lodash2.isObject)(value.content)) {
|
|
303
|
+
return {
|
|
304
|
+
type: "object"
|
|
305
|
+
};
|
|
306
|
+
}
|
|
307
|
+
return void 0;
|
|
308
|
+
}
|
|
309
|
+
FlowValueUtils2.inferConstantJsonSchema = inferConstantJsonSchema;
|
|
310
|
+
function inferJsonSchema(values, scope) {
|
|
311
|
+
if ((0, import_lodash2.isPlainObject)(values)) {
|
|
312
|
+
if (isConstant(values)) {
|
|
313
|
+
return inferConstantJsonSchema(values);
|
|
314
|
+
}
|
|
315
|
+
if (isRef(values)) {
|
|
316
|
+
const variable = scope.available.getByKeyPath(values?.content);
|
|
317
|
+
const schema = variable?.type ? import_json_schema.JsonSchemaUtils.astToSchema(variable?.type) : void 0;
|
|
318
|
+
return schema;
|
|
319
|
+
}
|
|
320
|
+
if (isTemplate(values)) {
|
|
321
|
+
return { type: "string" };
|
|
322
|
+
}
|
|
323
|
+
return {
|
|
324
|
+
type: "object",
|
|
325
|
+
properties: Object.keys(values).reduce((acc, key) => {
|
|
326
|
+
const schema = inferJsonSchema(values[key], scope);
|
|
327
|
+
if (schema) {
|
|
328
|
+
acc[key] = schema;
|
|
329
|
+
}
|
|
330
|
+
return acc;
|
|
331
|
+
}, {})
|
|
332
|
+
};
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
FlowValueUtils2.inferJsonSchema = inferJsonSchema;
|
|
336
|
+
})(FlowValueUtils || (FlowValueUtils = {}));
|
|
337
|
+
|
|
182
338
|
// src/components/variable-selector/use-variable-tree.tsx
|
|
183
339
|
var import_react12 = __toESM(require("react"));
|
|
184
|
-
var
|
|
340
|
+
var import_json_schema5 = require("@flowgram.ai/json-schema");
|
|
185
341
|
var import_editor11 = require("@flowgram.ai/editor");
|
|
186
342
|
var import_semi_ui5 = require("@douyinfe/semi-ui");
|
|
187
343
|
|
|
188
344
|
// src/plugins/json-schema-preset/index.tsx
|
|
189
345
|
var import_react11 = __toESM(require("react"));
|
|
190
|
-
var
|
|
346
|
+
var import_json_schema4 = require("@flowgram.ai/json-schema");
|
|
191
347
|
|
|
192
348
|
// src/plugins/json-schema-preset/type-definition/index.tsx
|
|
193
|
-
var
|
|
349
|
+
var import_json_schema2 = require("@flowgram.ai/json-schema");
|
|
194
350
|
|
|
195
351
|
// src/plugins/json-schema-preset/type-definition/string.tsx
|
|
196
352
|
var import_react2 = __toESM(require("react"));
|
|
@@ -198,11 +354,20 @@ var import_editor2 = require("@flowgram.ai/editor");
|
|
|
198
354
|
var import_semi_ui = require("@douyinfe/semi-ui");
|
|
199
355
|
var stringRegistry = {
|
|
200
356
|
type: "string",
|
|
201
|
-
ConstantRenderer: (props) => /* @__PURE__ */ import_react2.default.createElement(
|
|
202
|
-
import_semi_ui.
|
|
357
|
+
ConstantRenderer: (props) => props?.enableMultiLineStr ? /* @__PURE__ */ import_react2.default.createElement(
|
|
358
|
+
import_semi_ui.TextArea,
|
|
203
359
|
{
|
|
360
|
+
autosize: true,
|
|
361
|
+
rows: 1,
|
|
204
362
|
placeholder: import_editor2.I18n.t("Please Input String"),
|
|
363
|
+
disabled: props.readonly,
|
|
364
|
+
...props
|
|
365
|
+
}
|
|
366
|
+
) : /* @__PURE__ */ import_react2.default.createElement(
|
|
367
|
+
import_semi_ui.Input,
|
|
368
|
+
{
|
|
205
369
|
size: "small",
|
|
370
|
+
placeholder: import_editor2.I18n.t("Please Input String"),
|
|
206
371
|
disabled: props.readonly,
|
|
207
372
|
...props
|
|
208
373
|
}
|
|
@@ -681,27 +846,27 @@ var jsonSchemaTypePreset = [
|
|
|
681
846
|
booleanRegistry,
|
|
682
847
|
arrayRegistry
|
|
683
848
|
];
|
|
684
|
-
jsonSchemaTypePreset.forEach((_type) =>
|
|
849
|
+
jsonSchemaTypePreset.forEach((_type) => import_json_schema2.jsonSchemaTypeManager.register(_type));
|
|
685
850
|
|
|
686
851
|
// src/plugins/json-schema-preset/create-type-preset-plugin.tsx
|
|
687
|
-
var
|
|
852
|
+
var import_json_schema3 = require("@flowgram.ai/json-schema");
|
|
688
853
|
var import_editor9 = require("@flowgram.ai/editor");
|
|
689
854
|
var createTypePresetPlugin = (0, import_editor9.definePluginCreator)({
|
|
690
855
|
onInit(ctx, opts) {
|
|
691
|
-
const typeManager = ctx.get(
|
|
856
|
+
const typeManager = ctx.get(import_json_schema3.BaseTypeManager);
|
|
692
857
|
jsonSchemaTypePreset.forEach((_type) => typeManager.register(_type));
|
|
693
858
|
opts.types?.forEach((_type) => typeManager.register(_type));
|
|
694
859
|
opts.unregisterTypes?.forEach((_type) => typeManager.unregister(_type));
|
|
695
860
|
},
|
|
696
|
-
containerModules: [
|
|
861
|
+
containerModules: [import_json_schema3.jsonSchemaContainerModule]
|
|
697
862
|
});
|
|
698
863
|
|
|
699
864
|
// src/plugins/json-schema-preset/index.tsx
|
|
700
|
-
var useTypeManager = () => (0,
|
|
865
|
+
var useTypeManager = () => (0, import_json_schema4.useTypeManager)();
|
|
701
866
|
var JsonSchemaTypePresetProvider = ({
|
|
702
867
|
types = [],
|
|
703
868
|
children
|
|
704
|
-
}) => /* @__PURE__ */ import_react11.default.createElement(
|
|
869
|
+
}) => /* @__PURE__ */ import_react11.default.createElement(import_json_schema4.TypePresetProvider, { types: [...jsonSchemaTypePreset, ...types] }, children);
|
|
705
870
|
|
|
706
871
|
// src/plugins/disable-declaration-plugin/create-disable-declaration-plugin.ts
|
|
707
872
|
var import_editor10 = require("@flowgram.ai/editor");
|
|
@@ -735,7 +900,7 @@ function useVariableTree(params) {
|
|
|
735
900
|
}
|
|
736
901
|
return variable.meta.icon;
|
|
737
902
|
}
|
|
738
|
-
const schema =
|
|
903
|
+
const schema = import_json_schema5.JsonSchemaUtils.astToSchema(variable.type, { drilldownObject: false });
|
|
739
904
|
return /* @__PURE__ */ import_react12.default.createElement(import_semi_ui5.Icon, { size: "small", svg: typeManager.getDisplayIcon(schema || {}) });
|
|
740
905
|
}, []);
|
|
741
906
|
const renderVariable = (variable, parentFields = []) => {
|
|
@@ -749,8 +914,8 @@ function useVariableTree(params) {
|
|
|
749
914
|
}
|
|
750
915
|
const keyPath = [...parentFields.map((_field) => _field.key), variable.key];
|
|
751
916
|
const key = keyPath.join(".");
|
|
752
|
-
const isSchemaInclude = includeSchema ?
|
|
753
|
-
const isSchemaExclude = excludeSchema ?
|
|
917
|
+
const isSchemaInclude = includeSchema ? import_json_schema5.JsonSchemaUtils.isASTMatchSchema(type, includeSchema) : true;
|
|
918
|
+
const isSchemaExclude = excludeSchema ? import_json_schema5.JsonSchemaUtils.isASTMatchSchema(type, excludeSchema) : false;
|
|
754
919
|
const isCustomSkip = customSkip ? customSkip(variable) : false;
|
|
755
920
|
const isMetaDisabled = variable.meta?.disabled;
|
|
756
921
|
const isSchemaMatch = isSchemaInclude && !isSchemaExclude && !isCustomSkip && !isMetaDisabled;
|
|
@@ -986,8 +1151,29 @@ var import_editor14 = require("@flowgram.ai/editor");
|
|
|
986
1151
|
var import_semi_ui10 = require("@douyinfe/semi-ui");
|
|
987
1152
|
var import_semi_icons3 = require("@douyinfe/semi-icons");
|
|
988
1153
|
|
|
989
|
-
// src/components/
|
|
1154
|
+
// src/components/blur-input/index.tsx
|
|
990
1155
|
var import_react15 = __toESM(require("react"));
|
|
1156
|
+
var import_input = __toESM(require("@douyinfe/semi-ui/lib/es/input"));
|
|
1157
|
+
function BlurInput(props) {
|
|
1158
|
+
const [value, setValue] = (0, import_react15.useState)("");
|
|
1159
|
+
(0, import_react15.useEffect)(() => {
|
|
1160
|
+
setValue(props.value);
|
|
1161
|
+
}, [props.value]);
|
|
1162
|
+
return /* @__PURE__ */ import_react15.default.createElement(
|
|
1163
|
+
import_input.default,
|
|
1164
|
+
{
|
|
1165
|
+
...props,
|
|
1166
|
+
value,
|
|
1167
|
+
onChange: (value2) => {
|
|
1168
|
+
setValue(value2);
|
|
1169
|
+
},
|
|
1170
|
+
onBlur: (e) => props.onChange?.(value, e)
|
|
1171
|
+
}
|
|
1172
|
+
);
|
|
1173
|
+
}
|
|
1174
|
+
|
|
1175
|
+
// src/components/json-schema-editor/styles.tsx
|
|
1176
|
+
var import_react16 = __toESM(require("react"));
|
|
991
1177
|
var import_styled_components3 = __toESM(require("styled-components"));
|
|
992
1178
|
var import_semi_icons2 = __toESM(require("@douyinfe/semi-icons"));
|
|
993
1179
|
var UIContainer = import_styled_components3.default.div`
|
|
@@ -1016,32 +1202,30 @@ var UILabel = import_styled_components3.default.div`
|
|
|
1016
1202
|
font-weight: 400;
|
|
1017
1203
|
margin-bottom: 2px;
|
|
1018
1204
|
`;
|
|
1019
|
-
var
|
|
1205
|
+
var UITreeItems = import_styled_components3.default.div`
|
|
1020
1206
|
display: grid;
|
|
1021
1207
|
grid-template-columns: auto 1fr;
|
|
1022
1208
|
|
|
1023
1209
|
${({ $shrink }) => $shrink && import_styled_components3.css`
|
|
1024
|
-
padding-left:
|
|
1210
|
+
padding-left: 3px;
|
|
1025
1211
|
margin-top: 10px;
|
|
1026
1212
|
`}
|
|
1027
1213
|
`;
|
|
1028
|
-
var
|
|
1214
|
+
var UITreeItemLeft = import_styled_components3.default.div`
|
|
1029
1215
|
grid-column: 1;
|
|
1030
1216
|
position: relative;
|
|
1031
1217
|
width: 16px;
|
|
1032
1218
|
|
|
1033
|
-
${({ $showLine, $isLast, $
|
|
1034
|
-
let height = "100%";
|
|
1035
|
-
|
|
1036
|
-
height = "24px";
|
|
1037
|
-
}
|
|
1219
|
+
${({ $showLine, $isLast, $showCollapse }) => {
|
|
1220
|
+
let height = $isLast ? "24px" : "100%";
|
|
1221
|
+
let width = $showCollapse ? "12px" : "30px";
|
|
1038
1222
|
return $showLine && import_styled_components3.css`
|
|
1039
1223
|
&::before {
|
|
1040
1224
|
/* 竖线 */
|
|
1041
1225
|
content: '';
|
|
1042
1226
|
height: ${height};
|
|
1043
1227
|
position: absolute;
|
|
1044
|
-
left: -
|
|
1228
|
+
left: -14px;
|
|
1045
1229
|
top: -16px;
|
|
1046
1230
|
width: 1px;
|
|
1047
1231
|
background: #d9d9d9;
|
|
@@ -1052,9 +1236,9 @@ var UIPropertyLeft = import_styled_components3.default.div`
|
|
|
1052
1236
|
/* 横线 */
|
|
1053
1237
|
content: '';
|
|
1054
1238
|
position: absolute;
|
|
1055
|
-
left: -
|
|
1239
|
+
left: -14px; // 横线起点和竖线对齐
|
|
1056
1240
|
top: 8px; // 跟随你的行高调整
|
|
1057
|
-
width:
|
|
1241
|
+
width: ${width}; // 横线长度
|
|
1058
1242
|
height: 1px;
|
|
1059
1243
|
background: #d9d9d9;
|
|
1060
1244
|
display: block;
|
|
@@ -1062,7 +1246,7 @@ var UIPropertyLeft = import_styled_components3.default.div`
|
|
|
1062
1246
|
`;
|
|
1063
1247
|
}}
|
|
1064
1248
|
`;
|
|
1065
|
-
var
|
|
1249
|
+
var UITreeItemRight = import_styled_components3.default.div`
|
|
1066
1250
|
grid-column: 2;
|
|
1067
1251
|
margin-bottom: 10px;
|
|
1068
1252
|
|
|
@@ -1070,35 +1254,11 @@ var UIPropertyRight = import_styled_components3.default.div`
|
|
|
1070
1254
|
margin-bottom: 0px;
|
|
1071
1255
|
}
|
|
1072
1256
|
`;
|
|
1073
|
-
var
|
|
1257
|
+
var UITreeItemMain = import_styled_components3.default.div`
|
|
1074
1258
|
display: flex;
|
|
1075
1259
|
flex-direction: column;
|
|
1076
1260
|
gap: 10px;
|
|
1077
1261
|
position: relative;
|
|
1078
|
-
|
|
1079
|
-
${({ $expand, type, $collapse, $showCollapse }) => {
|
|
1080
|
-
const beforeElement = `
|
|
1081
|
-
&::before {
|
|
1082
|
-
/* \u7AD6\u7EBF */
|
|
1083
|
-
content: '';
|
|
1084
|
-
height: 100%;
|
|
1085
|
-
position: absolute;
|
|
1086
|
-
left: -12px;
|
|
1087
|
-
top: 18px;
|
|
1088
|
-
width: 1px;
|
|
1089
|
-
background: #d9d9d9;
|
|
1090
|
-
display: block;
|
|
1091
|
-
}`;
|
|
1092
|
-
return $expand && import_styled_components3.css`
|
|
1093
|
-
background-color: #f5f5f5;
|
|
1094
|
-
padding: 10px;
|
|
1095
|
-
border-radius: 4px;
|
|
1096
|
-
|
|
1097
|
-
${$showCollapse && $collapse && (type === "array" || type === "object") && import_styled_components3.css`
|
|
1098
|
-
${beforeElement}
|
|
1099
|
-
`}
|
|
1100
|
-
`;
|
|
1101
|
-
}}
|
|
1102
1262
|
`;
|
|
1103
1263
|
var UICollapsible = import_styled_components3.default.div`
|
|
1104
1264
|
display: none;
|
|
@@ -1115,7 +1275,7 @@ var UIRequired = import_styled_components3.default.div``;
|
|
|
1115
1275
|
var UIActions = import_styled_components3.default.div`
|
|
1116
1276
|
white-space: nowrap;
|
|
1117
1277
|
`;
|
|
1118
|
-
var iconAddChildrenSvg = /* @__PURE__ */
|
|
1278
|
+
var iconAddChildrenSvg = /* @__PURE__ */ import_react16.default.createElement(
|
|
1119
1279
|
"svg",
|
|
1120
1280
|
{
|
|
1121
1281
|
className: "icon-icon icon-icon-coz_add_node ",
|
|
@@ -1125,7 +1285,7 @@ var iconAddChildrenSvg = /* @__PURE__ */ import_react15.default.createElement(
|
|
|
1125
1285
|
fill: "currentColor",
|
|
1126
1286
|
xmlns: "http://www.w3.org/2000/svg"
|
|
1127
1287
|
},
|
|
1128
|
-
/* @__PURE__ */
|
|
1288
|
+
/* @__PURE__ */ import_react16.default.createElement(
|
|
1129
1289
|
"path",
|
|
1130
1290
|
{
|
|
1131
1291
|
fillRule: "evenodd",
|
|
@@ -1133,9 +1293,9 @@ var iconAddChildrenSvg = /* @__PURE__ */ import_react15.default.createElement(
|
|
|
1133
1293
|
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"
|
|
1134
1294
|
}
|
|
1135
1295
|
),
|
|
1136
|
-
/* @__PURE__ */
|
|
1296
|
+
/* @__PURE__ */ import_react16.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" })
|
|
1137
1297
|
);
|
|
1138
|
-
var IconAddChildren = () => /* @__PURE__ */
|
|
1298
|
+
var IconAddChildren = () => /* @__PURE__ */ import_react16.default.createElement(import_semi_icons2.default, { size: "small", svg: iconAddChildrenSvg });
|
|
1139
1299
|
var DefaultValueWrapper = import_styled_components3.default.div`
|
|
1140
1300
|
margin: 0;
|
|
1141
1301
|
`;
|
|
@@ -1150,29 +1310,36 @@ var ConstantInputWrapper = import_styled_components3.default.div`
|
|
|
1150
1310
|
`;
|
|
1151
1311
|
|
|
1152
1312
|
// src/components/json-schema-editor/hooks.tsx
|
|
1153
|
-
var
|
|
1154
|
-
var
|
|
1313
|
+
var import_react17 = require("react");
|
|
1314
|
+
var import_lodash3 = require("lodash");
|
|
1155
1315
|
var import_immer = require("immer");
|
|
1156
|
-
var
|
|
1316
|
+
var import_json_schema6 = require("@flowgram.ai/json-schema");
|
|
1157
1317
|
var _id = 0;
|
|
1158
1318
|
function genId() {
|
|
1159
1319
|
return _id++;
|
|
1160
1320
|
}
|
|
1161
1321
|
function usePropertiesEdit(value, onChange) {
|
|
1162
|
-
const typeManager = (0,
|
|
1322
|
+
const typeManager = (0, import_json_schema6.useTypeManager)();
|
|
1163
1323
|
const drilldownSchema = typeManager.getPropertiesParent(value || {});
|
|
1164
1324
|
const canAddField = typeManager.canAddField(value || {});
|
|
1165
|
-
const [propertyList, setPropertyList] = (0,
|
|
1166
|
-
(0,
|
|
1325
|
+
const [propertyList, setPropertyList] = (0, import_react17.useState)([]);
|
|
1326
|
+
const effectVersion = (0, import_react17.useRef)(0);
|
|
1327
|
+
const changeVersion = (0, import_react17.useRef)(0);
|
|
1328
|
+
(0, import_react17.useEffect)(() => {
|
|
1329
|
+
effectVersion.current = effectVersion.current + 1;
|
|
1330
|
+
if (effectVersion.current === changeVersion.current) {
|
|
1331
|
+
return;
|
|
1332
|
+
}
|
|
1333
|
+
effectVersion.current = changeVersion.current;
|
|
1167
1334
|
setPropertyList((_list) => {
|
|
1168
1335
|
const newNames = Object.entries(drilldownSchema?.properties || {}).sort(([, a], [, b]) => (a.extra?.index ?? 0) - (b.extra?.index ?? 0)).map(([key]) => key);
|
|
1169
1336
|
const oldNames = _list.map((item) => item.name).filter(Boolean);
|
|
1170
|
-
const addNames = (0,
|
|
1337
|
+
const addNames = (0, import_lodash3.difference)(newNames, oldNames);
|
|
1171
1338
|
return _list.filter((item) => !item.name || newNames.includes(item.name)).map((item) => ({
|
|
1172
1339
|
key: item.key,
|
|
1173
1340
|
name: item.name,
|
|
1174
1341
|
isPropertyRequired: drilldownSchema?.required?.includes(item.name || "") || false,
|
|
1175
|
-
...item
|
|
1342
|
+
...drilldownSchema?.properties?.[item.name || ""] || item || {}
|
|
1176
1343
|
})).concat(
|
|
1177
1344
|
addNames.map((_name) => ({
|
|
1178
1345
|
key: genId(),
|
|
@@ -1184,6 +1351,7 @@ function usePropertiesEdit(value, onChange) {
|
|
|
1184
1351
|
});
|
|
1185
1352
|
}, [drilldownSchema]);
|
|
1186
1353
|
const updatePropertyList = (updater) => {
|
|
1354
|
+
changeVersion.current = changeVersion.current + 1;
|
|
1187
1355
|
setPropertyList((_list) => {
|
|
1188
1356
|
const next = updater(_list);
|
|
1189
1357
|
const nextProperties = {};
|
|
@@ -1192,7 +1360,7 @@ function usePropertiesEdit(value, onChange) {
|
|
|
1192
1360
|
if (!_property.name) {
|
|
1193
1361
|
continue;
|
|
1194
1362
|
}
|
|
1195
|
-
nextProperties[_property.name] = (0,
|
|
1363
|
+
nextProperties[_property.name] = (0, import_lodash3.omit)(_property, ["key", "name", "isPropertyRequired"]);
|
|
1196
1364
|
if (_property.isPropertyRequired) {
|
|
1197
1365
|
nextRequired.push(_property.name);
|
|
1198
1366
|
}
|
|
@@ -1224,7 +1392,7 @@ function usePropertiesEdit(value, onChange) {
|
|
|
1224
1392
|
(_list) => _list.map((_property) => _property.key === key ? nextValue : _property)
|
|
1225
1393
|
);
|
|
1226
1394
|
};
|
|
1227
|
-
(0,
|
|
1395
|
+
(0, import_react17.useEffect)(() => {
|
|
1228
1396
|
if (!canAddField) {
|
|
1229
1397
|
setPropertyList([]);
|
|
1230
1398
|
}
|
|
@@ -1239,16 +1407,16 @@ function usePropertiesEdit(value, onChange) {
|
|
|
1239
1407
|
}
|
|
1240
1408
|
|
|
1241
1409
|
// src/components/json-schema-editor/default-value.tsx
|
|
1242
|
-
var
|
|
1410
|
+
var import_react19 = __toESM(require("react"));
|
|
1243
1411
|
var import_editor13 = require("@flowgram.ai/editor");
|
|
1244
1412
|
|
|
1245
1413
|
// src/components/constant-input/index.tsx
|
|
1246
|
-
var
|
|
1414
|
+
var import_react18 = __toESM(require("react"));
|
|
1247
1415
|
var import_semi_ui9 = require("@douyinfe/semi-ui");
|
|
1248
1416
|
function ConstantInput(props) {
|
|
1249
1417
|
const { value, onChange, schema, strategies, fallbackRenderer, readonly, ...rest } = props;
|
|
1250
1418
|
const typeManager = useTypeManager();
|
|
1251
|
-
const Renderer2 = (0,
|
|
1419
|
+
const Renderer2 = (0, import_react18.useMemo)(() => {
|
|
1252
1420
|
const strategy = (strategies || []).find((_strategy) => _strategy.hit(schema));
|
|
1253
1421
|
if (!strategy) {
|
|
1254
1422
|
return typeManager.getTypeBySchema(schema)?.ConstantRenderer;
|
|
@@ -1257,53 +1425,33 @@ function ConstantInput(props) {
|
|
|
1257
1425
|
}, [strategies, schema]);
|
|
1258
1426
|
if (!Renderer2) {
|
|
1259
1427
|
if (fallbackRenderer) {
|
|
1260
|
-
return
|
|
1428
|
+
return import_react18.default.createElement(fallbackRenderer, {
|
|
1261
1429
|
value,
|
|
1262
1430
|
onChange,
|
|
1263
1431
|
readonly,
|
|
1264
1432
|
...rest
|
|
1265
1433
|
});
|
|
1266
1434
|
}
|
|
1267
|
-
return /* @__PURE__ */
|
|
1435
|
+
return /* @__PURE__ */ import_react18.default.createElement(import_semi_ui9.Input, { size: "small", disabled: true, placeholder: "Unsupported type" });
|
|
1268
1436
|
}
|
|
1269
|
-
return /* @__PURE__ */
|
|
1437
|
+
return /* @__PURE__ */ import_react18.default.createElement(Renderer2, { value, onChange, readonly, ...rest });
|
|
1270
1438
|
}
|
|
1271
1439
|
|
|
1272
1440
|
// src/components/json-schema-editor/default-value.tsx
|
|
1273
1441
|
function DefaultValue(props) {
|
|
1274
1442
|
const { value, schema, onChange, placeholder } = props;
|
|
1275
|
-
return /* @__PURE__ */
|
|
1443
|
+
return /* @__PURE__ */ import_react19.default.createElement(ConstantInputWrapper, null, /* @__PURE__ */ import_react19.default.createElement(
|
|
1276
1444
|
ConstantInput,
|
|
1277
1445
|
{
|
|
1278
1446
|
value,
|
|
1279
1447
|
onChange: (_v) => onChange(_v),
|
|
1280
1448
|
schema: schema || { type: "string" },
|
|
1281
|
-
placeholder: placeholder ?? import_editor13.I18n.t("Default value if parameter is not provided")
|
|
1449
|
+
placeholder: placeholder ?? import_editor13.I18n.t("Default value if parameter is not provided"),
|
|
1450
|
+
enableMultiLineStr: true
|
|
1282
1451
|
}
|
|
1283
1452
|
));
|
|
1284
1453
|
}
|
|
1285
1454
|
|
|
1286
|
-
// src/components/json-schema-editor/components/blur-input.tsx
|
|
1287
|
-
var import_react19 = __toESM(require("react"));
|
|
1288
|
-
var import_input = __toESM(require("@douyinfe/semi-ui/lib/es/input"));
|
|
1289
|
-
function BlurInput(props) {
|
|
1290
|
-
const [value, setValue] = (0, import_react19.useState)("");
|
|
1291
|
-
(0, import_react19.useEffect)(() => {
|
|
1292
|
-
setValue(props.value);
|
|
1293
|
-
}, [props.value]);
|
|
1294
|
-
return /* @__PURE__ */ import_react19.default.createElement(
|
|
1295
|
-
import_input.default,
|
|
1296
|
-
{
|
|
1297
|
-
...props,
|
|
1298
|
-
value,
|
|
1299
|
-
onChange: (value2) => {
|
|
1300
|
-
setValue(value2);
|
|
1301
|
-
},
|
|
1302
|
-
onBlur: (e) => props.onChange?.(value, e)
|
|
1303
|
-
}
|
|
1304
|
-
);
|
|
1305
|
-
}
|
|
1306
|
-
|
|
1307
1455
|
// src/components/json-schema-editor/index.tsx
|
|
1308
1456
|
var DEFAULT = { type: "object" };
|
|
1309
1457
|
function JsonSchemaEditor(props) {
|
|
@@ -1312,14 +1460,13 @@ function JsonSchemaEditor(props) {
|
|
|
1312
1460
|
value,
|
|
1313
1461
|
onChangeProps
|
|
1314
1462
|
);
|
|
1315
|
-
return /* @__PURE__ */ import_react20.default.createElement(UIContainer, { className: props.className }, /* @__PURE__ */ import_react20.default.createElement(
|
|
1463
|
+
return /* @__PURE__ */ import_react20.default.createElement(UIContainer, { className: props.className }, /* @__PURE__ */ import_react20.default.createElement(UITreeItems, null, propertyList.map((_property) => /* @__PURE__ */ import_react20.default.createElement(
|
|
1316
1464
|
PropertyEdit,
|
|
1317
1465
|
{
|
|
1318
1466
|
readonly,
|
|
1319
1467
|
key: _property.key,
|
|
1320
1468
|
value: _property,
|
|
1321
1469
|
config,
|
|
1322
|
-
$index: index,
|
|
1323
1470
|
onChange: (_v) => {
|
|
1324
1471
|
onEditProperty(_property.key, _v);
|
|
1325
1472
|
},
|
|
@@ -1340,20 +1487,7 @@ function JsonSchemaEditor(props) {
|
|
|
1340
1487
|
));
|
|
1341
1488
|
}
|
|
1342
1489
|
function PropertyEdit(props) {
|
|
1343
|
-
const {
|
|
1344
|
-
value,
|
|
1345
|
-
config,
|
|
1346
|
-
readonly,
|
|
1347
|
-
$level = 0,
|
|
1348
|
-
onChange: onChangeProps,
|
|
1349
|
-
onRemove,
|
|
1350
|
-
$index,
|
|
1351
|
-
$isFirst,
|
|
1352
|
-
$isLast,
|
|
1353
|
-
$parentExpand = false,
|
|
1354
|
-
$parentType = "",
|
|
1355
|
-
$showLine
|
|
1356
|
-
} = props;
|
|
1490
|
+
const { value, config, readonly, $level = 0, onChange: onChangeProps, onRemove, $isLast } = props;
|
|
1357
1491
|
const [expand, setExpand] = (0, import_react20.useState)(false);
|
|
1358
1492
|
const [collapse, setCollapse] = (0, import_react20.useState)(false);
|
|
1359
1493
|
const { name, type, items, default: defaultValue, description, isPropertyRequired } = value || {};
|
|
@@ -1366,109 +1500,84 @@ function PropertyEdit(props) {
|
|
|
1366
1500
|
});
|
|
1367
1501
|
};
|
|
1368
1502
|
const showCollapse = canAddField && propertyList.length > 0;
|
|
1369
|
-
return /* @__PURE__ */ import_react20.default.createElement(import_react20.default.Fragment, null, /* @__PURE__ */ import_react20.default.createElement(
|
|
1370
|
-
|
|
1371
|
-
{
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
type
|
|
1389
|
-
},
|
|
1390
|
-
/* @__PURE__ */ import_react20.default.createElement(UIRow, null, /* @__PURE__ */ import_react20.default.createElement(UIName, null, /* @__PURE__ */ import_react20.default.createElement(
|
|
1391
|
-
BlurInput,
|
|
1392
|
-
{
|
|
1393
|
-
disabled: readonly,
|
|
1394
|
-
placeholder: config?.placeholder ?? "Input Variable Name",
|
|
1395
|
-
size: "small",
|
|
1396
|
-
value: name,
|
|
1397
|
-
onChange: (value2) => onChange("name", value2)
|
|
1398
|
-
}
|
|
1399
|
-
)), /* @__PURE__ */ import_react20.default.createElement(UIType, null, /* @__PURE__ */ import_react20.default.createElement(
|
|
1400
|
-
InjectTypeSelector,
|
|
1401
|
-
{
|
|
1402
|
-
value: typeSelectorValue,
|
|
1403
|
-
readonly,
|
|
1404
|
-
onChange: (_value) => {
|
|
1405
|
-
onChangeProps?.({
|
|
1406
|
-
...value || {},
|
|
1407
|
-
..._value
|
|
1408
|
-
});
|
|
1409
|
-
}
|
|
1410
|
-
}
|
|
1411
|
-
)), /* @__PURE__ */ import_react20.default.createElement(UIRequired, null, /* @__PURE__ */ import_react20.default.createElement(
|
|
1412
|
-
import_semi_ui10.Checkbox,
|
|
1413
|
-
{
|
|
1414
|
-
disabled: readonly,
|
|
1415
|
-
checked: isPropertyRequired,
|
|
1416
|
-
onChange: (e) => onChange("isPropertyRequired", e.target.checked)
|
|
1417
|
-
}
|
|
1418
|
-
)), /* @__PURE__ */ import_react20.default.createElement(UIActions, null, /* @__PURE__ */ import_react20.default.createElement(
|
|
1419
|
-
import_semi_ui10.IconButton,
|
|
1420
|
-
{
|
|
1421
|
-
disabled: readonly,
|
|
1422
|
-
size: "small",
|
|
1423
|
-
theme: "borderless",
|
|
1424
|
-
icon: expand ? /* @__PURE__ */ import_react20.default.createElement(import_semi_icons3.IconShrink, { size: "small" }) : /* @__PURE__ */ import_react20.default.createElement(import_semi_icons3.IconExpand, { size: "small" }),
|
|
1425
|
-
onClick: () => {
|
|
1426
|
-
setExpand((_expand) => !_expand);
|
|
1427
|
-
}
|
|
1428
|
-
}
|
|
1429
|
-
), canAddField && /* @__PURE__ */ import_react20.default.createElement(
|
|
1430
|
-
import_semi_ui10.IconButton,
|
|
1431
|
-
{
|
|
1432
|
-
disabled: readonly,
|
|
1433
|
-
size: "small",
|
|
1434
|
-
theme: "borderless",
|
|
1435
|
-
icon: /* @__PURE__ */ import_react20.default.createElement(IconAddChildren, null),
|
|
1436
|
-
onClick: () => {
|
|
1437
|
-
onAddProperty();
|
|
1438
|
-
setCollapse(true);
|
|
1439
|
-
}
|
|
1440
|
-
}
|
|
1441
|
-
), /* @__PURE__ */ import_react20.default.createElement(
|
|
1442
|
-
import_semi_ui10.IconButton,
|
|
1443
|
-
{
|
|
1444
|
-
disabled: readonly,
|
|
1445
|
-
size: "small",
|
|
1446
|
-
theme: "borderless",
|
|
1447
|
-
icon: /* @__PURE__ */ import_react20.default.createElement(import_semi_icons3.IconMinus, { size: "small" }),
|
|
1448
|
-
onClick: onRemove
|
|
1503
|
+
return /* @__PURE__ */ import_react20.default.createElement(import_react20.default.Fragment, null, /* @__PURE__ */ import_react20.default.createElement(UITreeItemLeft, { $isLast, $showLine: $level > 0, $showCollapse: showCollapse }, showCollapse && /* @__PURE__ */ import_react20.default.createElement(UICollapseTrigger, { onClick: () => setCollapse((_collapse) => !_collapse) }, collapse ? /* @__PURE__ */ import_react20.default.createElement(import_semi_icons3.IconChevronDown, { size: "small" }) : /* @__PURE__ */ import_react20.default.createElement(import_semi_icons3.IconChevronRight, { size: "small" }))), /* @__PURE__ */ import_react20.default.createElement(UITreeItemRight, null, /* @__PURE__ */ import_react20.default.createElement(UITreeItemMain, null, /* @__PURE__ */ import_react20.default.createElement(UIRow, null, /* @__PURE__ */ import_react20.default.createElement(UIName, null, /* @__PURE__ */ import_react20.default.createElement(
|
|
1504
|
+
BlurInput,
|
|
1505
|
+
{
|
|
1506
|
+
disabled: readonly,
|
|
1507
|
+
placeholder: config?.placeholder ?? "Input Variable Name",
|
|
1508
|
+
size: "small",
|
|
1509
|
+
value: name,
|
|
1510
|
+
onChange: (value2) => onChange("name", value2)
|
|
1511
|
+
}
|
|
1512
|
+
)), /* @__PURE__ */ import_react20.default.createElement(UIType, null, /* @__PURE__ */ import_react20.default.createElement(
|
|
1513
|
+
InjectTypeSelector,
|
|
1514
|
+
{
|
|
1515
|
+
value: typeSelectorValue,
|
|
1516
|
+
readonly,
|
|
1517
|
+
onChange: (_value) => {
|
|
1518
|
+
onChangeProps?.({
|
|
1519
|
+
...value || {},
|
|
1520
|
+
..._value
|
|
1521
|
+
});
|
|
1449
1522
|
}
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1523
|
+
}
|
|
1524
|
+
)), /* @__PURE__ */ import_react20.default.createElement(UIRequired, null, /* @__PURE__ */ import_react20.default.createElement(
|
|
1525
|
+
import_semi_ui10.Checkbox,
|
|
1526
|
+
{
|
|
1527
|
+
disabled: readonly,
|
|
1528
|
+
checked: isPropertyRequired,
|
|
1529
|
+
onChange: (e) => onChange("isPropertyRequired", e.target.checked)
|
|
1530
|
+
}
|
|
1531
|
+
)), /* @__PURE__ */ import_react20.default.createElement(UIActions, null, /* @__PURE__ */ import_react20.default.createElement(
|
|
1532
|
+
import_semi_ui10.IconButton,
|
|
1533
|
+
{
|
|
1534
|
+
disabled: readonly,
|
|
1535
|
+
size: "small",
|
|
1536
|
+
theme: "borderless",
|
|
1537
|
+
icon: expand ? /* @__PURE__ */ import_react20.default.createElement(import_semi_icons3.IconShrink, { size: "small" }) : /* @__PURE__ */ import_react20.default.createElement(import_semi_icons3.IconExpand, { size: "small" }),
|
|
1538
|
+
onClick: () => {
|
|
1539
|
+
setExpand((_expand) => !_expand);
|
|
1459
1540
|
}
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1541
|
+
}
|
|
1542
|
+
), canAddField && /* @__PURE__ */ import_react20.default.createElement(
|
|
1543
|
+
import_semi_ui10.IconButton,
|
|
1544
|
+
{
|
|
1545
|
+
disabled: readonly,
|
|
1546
|
+
size: "small",
|
|
1547
|
+
theme: "borderless",
|
|
1548
|
+
icon: /* @__PURE__ */ import_react20.default.createElement(IconAddChildren, null),
|
|
1549
|
+
onClick: () => {
|
|
1550
|
+
onAddProperty();
|
|
1551
|
+
setCollapse(true);
|
|
1469
1552
|
}
|
|
1470
|
-
|
|
1471
|
-
),
|
|
1553
|
+
}
|
|
1554
|
+
), /* @__PURE__ */ import_react20.default.createElement(
|
|
1555
|
+
import_semi_ui10.IconButton,
|
|
1556
|
+
{
|
|
1557
|
+
disabled: readonly,
|
|
1558
|
+
size: "small",
|
|
1559
|
+
theme: "borderless",
|
|
1560
|
+
icon: /* @__PURE__ */ import_react20.default.createElement(import_semi_icons3.IconMinus, { size: "small" }),
|
|
1561
|
+
onClick: onRemove
|
|
1562
|
+
}
|
|
1563
|
+
))), expand && /* @__PURE__ */ import_react20.default.createElement(UIExpandDetail, null, /* @__PURE__ */ import_react20.default.createElement(UILabel, null, config?.descTitle ?? import_editor14.I18n.t("Description")), /* @__PURE__ */ import_react20.default.createElement(
|
|
1564
|
+
BlurInput,
|
|
1565
|
+
{
|
|
1566
|
+
disabled: readonly,
|
|
1567
|
+
size: "small",
|
|
1568
|
+
value: description,
|
|
1569
|
+
onChange: (value2) => onChange("description", value2),
|
|
1570
|
+
placeholder: config?.descPlaceholder ?? import_editor14.I18n.t("Help LLM to understand the property")
|
|
1571
|
+
}
|
|
1572
|
+
), $level === 0 && /* @__PURE__ */ import_react20.default.createElement(import_react20.default.Fragment, null, /* @__PURE__ */ import_react20.default.createElement(UILabel, { style: { marginTop: 10 } }, config?.defaultValueTitle ?? import_editor14.I18n.t("Default Value")), /* @__PURE__ */ import_react20.default.createElement(DefaultValueWrapper, null, /* @__PURE__ */ import_react20.default.createElement(
|
|
1573
|
+
DefaultValue,
|
|
1574
|
+
{
|
|
1575
|
+
value: defaultValue,
|
|
1576
|
+
schema: value,
|
|
1577
|
+
placeholder: config?.defaultValuePlaceholder ?? import_editor14.I18n.t("Default Value"),
|
|
1578
|
+
onChange: (value2) => onChange("default", value2)
|
|
1579
|
+
}
|
|
1580
|
+
))))), showCollapse && /* @__PURE__ */ import_react20.default.createElement(UICollapsible, { $collapse: collapse }, /* @__PURE__ */ import_react20.default.createElement(UITreeItems, { $shrink: true }, propertyList.map((_property, index) => /* @__PURE__ */ import_react20.default.createElement(
|
|
1472
1581
|
PropertyEdit,
|
|
1473
1582
|
{
|
|
1474
1583
|
readonly,
|
|
@@ -1476,18 +1585,13 @@ function PropertyEdit(props) {
|
|
|
1476
1585
|
value: _property,
|
|
1477
1586
|
config,
|
|
1478
1587
|
$level: $level + 1,
|
|
1479
|
-
$parentExpand: expand,
|
|
1480
|
-
$parentType: type,
|
|
1481
1588
|
onChange: (_v) => {
|
|
1482
1589
|
onEditProperty(_property.key, _v);
|
|
1483
1590
|
},
|
|
1484
1591
|
onRemove: () => {
|
|
1485
1592
|
onRemoveProperty(_property.key);
|
|
1486
1593
|
},
|
|
1487
|
-
$isLast: index === propertyList.length - 1
|
|
1488
|
-
$isFirst: index === 0,
|
|
1489
|
-
$index: index,
|
|
1490
|
-
$showLine: true
|
|
1594
|
+
$isLast: index === propertyList.length - 1
|
|
1491
1595
|
}
|
|
1492
1596
|
))))));
|
|
1493
1597
|
}
|
|
@@ -1505,7 +1609,7 @@ function BatchVariableSelector(props) {
|
|
|
1505
1609
|
|
|
1506
1610
|
// src/components/dynamic-value-input/index.tsx
|
|
1507
1611
|
var import_react23 = __toESM(require("react"));
|
|
1508
|
-
var
|
|
1612
|
+
var import_json_schema7 = require("@flowgram.ai/json-schema");
|
|
1509
1613
|
var import_semi_ui11 = require("@douyinfe/semi-ui");
|
|
1510
1614
|
var import_semi_icons4 = require("@douyinfe/semi-icons");
|
|
1511
1615
|
|
|
@@ -1525,6 +1629,8 @@ var UIMain = import_styled_components4.default.div`
|
|
|
1525
1629
|
flex-grow: 1;
|
|
1526
1630
|
overflow: hidden;
|
|
1527
1631
|
min-width: 0;
|
|
1632
|
+
border-left: 1px solid var(--semi-color-border);
|
|
1633
|
+
border-right: 1px solid var(--semi-color-border);
|
|
1528
1634
|
|
|
1529
1635
|
& .semi-tree-select,
|
|
1530
1636
|
& .semi-input-number,
|
|
@@ -1538,17 +1644,25 @@ var UIMain = import_styled_components4.default.div`
|
|
|
1538
1644
|
border: none;
|
|
1539
1645
|
border-radius: 0;
|
|
1540
1646
|
}
|
|
1647
|
+
|
|
1648
|
+
& .semi-input-textarea-wrapper {
|
|
1649
|
+
border: none;
|
|
1650
|
+
border-radius: 0;
|
|
1651
|
+
}
|
|
1652
|
+
|
|
1653
|
+
& .semi-input-textarea {
|
|
1654
|
+
padding: 2px 6px;
|
|
1655
|
+
border: none;
|
|
1656
|
+
border-radius: 0;
|
|
1657
|
+
word-break: break-all;
|
|
1658
|
+
}
|
|
1541
1659
|
`;
|
|
1542
1660
|
var UIType2 = import_styled_components4.default.div`
|
|
1543
|
-
border-right: 1px solid #e5e5e5;
|
|
1544
|
-
|
|
1545
1661
|
& .semi-button {
|
|
1546
1662
|
border-radius: 0;
|
|
1547
1663
|
}
|
|
1548
1664
|
`;
|
|
1549
1665
|
var UITrigger = import_styled_components4.default.div`
|
|
1550
|
-
border-left: 1px solid #e5e5e5;
|
|
1551
|
-
|
|
1552
1666
|
& .semi-button {
|
|
1553
1667
|
border-radius: 0;
|
|
1554
1668
|
}
|
|
@@ -1604,7 +1718,7 @@ function DynamicValueInput({
|
|
|
1604
1718
|
return /* @__PURE__ */ import_react23.default.createElement(TypeSelector, { value: schemaFromProps, readonly: true });
|
|
1605
1719
|
}
|
|
1606
1720
|
if (value?.type === "ref") {
|
|
1607
|
-
const schema = refVariable?.type ?
|
|
1721
|
+
const schema = refVariable?.type ? import_json_schema7.JsonSchemaUtils.astToSchema(refVariable?.type) : void 0;
|
|
1608
1722
|
return /* @__PURE__ */ import_react23.default.createElement(TypeSelector, { value: schema, readonly: true });
|
|
1609
1723
|
}
|
|
1610
1724
|
return /* @__PURE__ */ import_react23.default.createElement(
|
|
@@ -1646,13 +1760,13 @@ function DynamicValueInput({
|
|
|
1646
1760
|
}
|
|
1647
1761
|
);
|
|
1648
1762
|
}
|
|
1649
|
-
const
|
|
1763
|
+
const constantSchema2 = schemaFromProps || selectSchema || { type: "string" };
|
|
1650
1764
|
return /* @__PURE__ */ import_react23.default.createElement(
|
|
1651
1765
|
ConstantInput,
|
|
1652
1766
|
{
|
|
1653
1767
|
value: value?.content,
|
|
1654
|
-
onChange: (_v) => onChange({ type: "constant", content: _v, schema:
|
|
1655
|
-
schema:
|
|
1768
|
+
onChange: (_v) => onChange({ type: "constant", content: _v, schema: constantSchema2 }),
|
|
1769
|
+
schema: constantSchema2 || { type: "string" },
|
|
1656
1770
|
readonly,
|
|
1657
1771
|
strategies: [...constantProps?.strategies || []],
|
|
1658
1772
|
fallbackRenderer: () => /* @__PURE__ */ import_react23.default.createElement(
|
|
@@ -1713,7 +1827,7 @@ var UIValues = import_styled_components5.default.div`
|
|
|
1713
1827
|
|
|
1714
1828
|
// src/components/condition-row/hooks/useRule.ts
|
|
1715
1829
|
var import_react24 = require("react");
|
|
1716
|
-
var
|
|
1830
|
+
var import_json_schema8 = require("@flowgram.ai/json-schema");
|
|
1717
1831
|
var import_editor17 = require("@flowgram.ai/editor");
|
|
1718
1832
|
|
|
1719
1833
|
// src/components/condition-row/constants.ts
|
|
@@ -1846,7 +1960,7 @@ function useRule(left, userRules) {
|
|
|
1846
1960
|
}, [available, left]);
|
|
1847
1961
|
const rule = (0, import_react24.useMemo)(() => {
|
|
1848
1962
|
if (!variable) return void 0;
|
|
1849
|
-
const schema =
|
|
1963
|
+
const schema = import_json_schema8.JsonSchemaUtils.astToSchema(variable.type, { drilldown: false });
|
|
1850
1964
|
return rules[schema?.type];
|
|
1851
1965
|
}, [variable?.type, rules]);
|
|
1852
1966
|
return { rule };
|
|
@@ -1945,13 +2059,14 @@ function ConditionRow({
|
|
|
1945
2059
|
|
|
1946
2060
|
// src/components/batch-outputs/index.tsx
|
|
1947
2061
|
var import_react28 = __toESM(require("react"));
|
|
2062
|
+
var import_editor20 = require("@flowgram.ai/editor");
|
|
1948
2063
|
var import_semi_ui14 = require("@douyinfe/semi-ui");
|
|
1949
2064
|
var import_semi_icons6 = require("@douyinfe/semi-icons");
|
|
1950
2065
|
|
|
1951
2066
|
// src/hooks/use-object-list/index.tsx
|
|
1952
2067
|
var import_react27 = require("react");
|
|
1953
2068
|
var import_nanoid = require("nanoid");
|
|
1954
|
-
var
|
|
2069
|
+
var import_lodash4 = require("lodash");
|
|
1955
2070
|
function genId2() {
|
|
1956
2071
|
return (0, import_nanoid.nanoid)();
|
|
1957
2072
|
}
|
|
@@ -1961,11 +2076,24 @@ function useObjectList({
|
|
|
1961
2076
|
sortIndexKey
|
|
1962
2077
|
}) {
|
|
1963
2078
|
const [list, setList] = (0, import_react27.useState)([]);
|
|
2079
|
+
const effectVersion = (0, import_react27.useRef)(0);
|
|
2080
|
+
const changeVersion = (0, import_react27.useRef)(0);
|
|
2081
|
+
const getSortIndex = (value2) => {
|
|
2082
|
+
if (typeof sortIndexKey === "function") {
|
|
2083
|
+
return (0, import_lodash4.get)(value2, sortIndexKey(value2)) || 0;
|
|
2084
|
+
}
|
|
2085
|
+
return (0, import_lodash4.get)(value2, sortIndexKey || "") || 0;
|
|
2086
|
+
};
|
|
1964
2087
|
(0, import_react27.useEffect)(() => {
|
|
2088
|
+
effectVersion.current = effectVersion.current + 1;
|
|
2089
|
+
if (effectVersion.current === changeVersion.current) {
|
|
2090
|
+
return;
|
|
2091
|
+
}
|
|
2092
|
+
effectVersion.current = changeVersion.current;
|
|
1965
2093
|
setList((_prevList) => {
|
|
1966
|
-
const newKeys = Object.entries(value || {}).sort((a, b) => (
|
|
2094
|
+
const newKeys = Object.entries(value || {}).sort((a, b) => getSortIndex(a[1]) - getSortIndex(b[1])).map(([key]) => key);
|
|
1967
2095
|
const oldKeys = _prevList.map((item) => item.key).filter(Boolean);
|
|
1968
|
-
const addKeys = (0,
|
|
2096
|
+
const addKeys = (0, import_lodash4.difference)(newKeys, oldKeys);
|
|
1969
2097
|
return _prevList.filter((item) => !item.key || newKeys.includes(item.key)).map((item) => ({
|
|
1970
2098
|
id: item.id,
|
|
1971
2099
|
key: item.key,
|
|
@@ -1979,15 +2107,17 @@ function useObjectList({
|
|
|
1979
2107
|
);
|
|
1980
2108
|
});
|
|
1981
2109
|
}, [value]);
|
|
1982
|
-
const add = () => {
|
|
2110
|
+
const add = (defaultValue) => {
|
|
1983
2111
|
setList((prevList) => [
|
|
1984
2112
|
...prevList,
|
|
1985
2113
|
{
|
|
1986
|
-
id: genId2()
|
|
2114
|
+
id: genId2(),
|
|
2115
|
+
value: defaultValue
|
|
1987
2116
|
}
|
|
1988
2117
|
]);
|
|
1989
2118
|
};
|
|
1990
2119
|
const updateValue = (itemId, value2) => {
|
|
2120
|
+
changeVersion.current = changeVersion.current + 1;
|
|
1991
2121
|
setList((prevList) => {
|
|
1992
2122
|
const nextList = prevList.map((_item) => {
|
|
1993
2123
|
if (_item.id === itemId) {
|
|
@@ -2001,8 +2131,9 @@ function useObjectList({
|
|
|
2001
2131
|
onChange(
|
|
2002
2132
|
Object.fromEntries(
|
|
2003
2133
|
nextList.filter((item) => item.key).map((item) => [item.key, item.value]).map((_res, idx) => {
|
|
2004
|
-
|
|
2005
|
-
|
|
2134
|
+
const indexKey = typeof sortIndexKey === "function" ? sortIndexKey(_res[1]) : sortIndexKey;
|
|
2135
|
+
if ((0, import_lodash4.isObject)(_res[1]) && indexKey) {
|
|
2136
|
+
(0, import_lodash4.set)(_res[1], indexKey, idx);
|
|
2006
2137
|
}
|
|
2007
2138
|
return _res;
|
|
2008
2139
|
})
|
|
@@ -2012,6 +2143,7 @@ function useObjectList({
|
|
|
2012
2143
|
});
|
|
2013
2144
|
};
|
|
2014
2145
|
const updateKey = (itemId, key) => {
|
|
2146
|
+
changeVersion.current = changeVersion.current + 1;
|
|
2015
2147
|
setList((prevList) => {
|
|
2016
2148
|
const nextList = prevList.map((_item) => {
|
|
2017
2149
|
if (_item.id === itemId) {
|
|
@@ -2031,6 +2163,7 @@ function useObjectList({
|
|
|
2031
2163
|
});
|
|
2032
2164
|
};
|
|
2033
2165
|
const remove = (itemId) => {
|
|
2166
|
+
changeVersion.current = changeVersion.current + 1;
|
|
2034
2167
|
setList((prevList) => {
|
|
2035
2168
|
const nextList = prevList.filter((_item) => _item.id !== itemId);
|
|
2036
2169
|
onChange(
|
|
@@ -2087,7 +2220,7 @@ function BatchOutputs(props) {
|
|
|
2087
2220
|
size: "small",
|
|
2088
2221
|
onClick: () => remove(item.id)
|
|
2089
2222
|
}
|
|
2090
|
-
)))), /* @__PURE__ */ import_react28.default.createElement(import_semi_ui14.Button, { disabled: readonly, icon: /* @__PURE__ */ import_react28.default.createElement(import_semi_icons6.IconPlus, null), size: "small", onClick: add }, "Add"));
|
|
2223
|
+
)))), /* @__PURE__ */ import_react28.default.createElement(import_semi_ui14.Button, { disabled: readonly, icon: /* @__PURE__ */ import_react28.default.createElement(import_semi_icons6.IconPlus, null), size: "small", onClick: () => add() }, import_editor20.I18n.t("Add")));
|
|
2091
2224
|
}
|
|
2092
2225
|
|
|
2093
2226
|
// src/components/prompt-editor/index.tsx
|
|
@@ -2110,13 +2243,13 @@ var UIContainer4 = import_styled_components7.default.div`
|
|
|
2110
2243
|
// src/components/prompt-editor/extensions/markdown.tsx
|
|
2111
2244
|
var import_react29 = require("react");
|
|
2112
2245
|
var import_react30 = require("@coze-editor/editor/react");
|
|
2113
|
-
var
|
|
2246
|
+
var import_editor21 = require("@coze-editor/editor");
|
|
2114
2247
|
var import_view2 = require("@codemirror/view");
|
|
2115
2248
|
function MarkdownHighlight() {
|
|
2116
2249
|
const injector = (0, import_react30.useInjector)();
|
|
2117
2250
|
(0, import_react29.useLayoutEffect)(
|
|
2118
2251
|
() => injector.inject([
|
|
2119
|
-
|
|
2252
|
+
import_editor21.astDecorator.whole.of((cursor) => {
|
|
2120
2253
|
if (cursor.name.startsWith("ATXHeading")) {
|
|
2121
2254
|
return {
|
|
2122
2255
|
type: "className",
|
|
@@ -2178,13 +2311,13 @@ var language_support_default = LanguageSupport;
|
|
|
2178
2311
|
// src/components/prompt-editor/extensions/jinja.tsx
|
|
2179
2312
|
var import_react33 = require("react");
|
|
2180
2313
|
var import_react34 = require("@coze-editor/editor/react");
|
|
2181
|
-
var
|
|
2314
|
+
var import_editor22 = require("@coze-editor/editor");
|
|
2182
2315
|
var import_view3 = require("@codemirror/view");
|
|
2183
2316
|
function JinjaHighlight() {
|
|
2184
2317
|
const injector = (0, import_react34.useInjector)();
|
|
2185
2318
|
(0, import_react33.useLayoutEffect)(
|
|
2186
2319
|
() => injector.inject([
|
|
2187
|
-
|
|
2320
|
+
import_editor22.astDecorator.whole.of((cursor) => {
|
|
2188
2321
|
if (cursor.name === "JinjaStatementStart" || cursor.name === "JinjaStatementEnd") {
|
|
2189
2322
|
return {
|
|
2190
2323
|
type: "className",
|
|
@@ -2233,7 +2366,8 @@ function PromptEditor(props) {
|
|
|
2233
2366
|
style,
|
|
2234
2367
|
hasError,
|
|
2235
2368
|
children,
|
|
2236
|
-
disableMarkdownHighlight
|
|
2369
|
+
disableMarkdownHighlight,
|
|
2370
|
+
options
|
|
2237
2371
|
} = props || {};
|
|
2238
2372
|
const editorRef = (0, import_react35.useRef)(null);
|
|
2239
2373
|
(0, import_react35.useEffect)(() => {
|
|
@@ -2252,7 +2386,8 @@ function PromptEditor(props) {
|
|
|
2252
2386
|
options: {
|
|
2253
2387
|
readOnly: readonly,
|
|
2254
2388
|
editable: !readonly,
|
|
2255
|
-
placeholder
|
|
2389
|
+
placeholder,
|
|
2390
|
+
...options
|
|
2256
2391
|
},
|
|
2257
2392
|
onChange: (e) => {
|
|
2258
2393
|
onChange({ type: "template", content: e.value });
|
|
@@ -2324,8 +2459,8 @@ function VariableTree() {
|
|
|
2324
2459
|
// src/components/prompt-editor-with-variables/extensions/variable-tag.tsx
|
|
2325
2460
|
var import_react_dom = __toESM(require("react-dom"));
|
|
2326
2461
|
var import_react39 = __toESM(require("react"));
|
|
2327
|
-
var
|
|
2328
|
-
var
|
|
2462
|
+
var import_lodash5 = require("lodash");
|
|
2463
|
+
var import_editor23 = require("@flowgram.ai/editor");
|
|
2329
2464
|
var import_semi_ui17 = require("@douyinfe/semi-ui");
|
|
2330
2465
|
var import_semi_icons7 = require("@douyinfe/semi-icons");
|
|
2331
2466
|
var import_react40 = require("@coze-editor/editor/react");
|
|
@@ -2372,7 +2507,7 @@ var UIPopoverContent2 = import_styled_components8.default.div`
|
|
|
2372
2507
|
var VariableTagWidget = class extends import_view4.WidgetType {
|
|
2373
2508
|
constructor({ keyPath, scope }) {
|
|
2374
2509
|
super();
|
|
2375
|
-
this.toDispose = new
|
|
2510
|
+
this.toDispose = new import_editor23.DisposableCollection();
|
|
2376
2511
|
this.renderIcon = (icon) => {
|
|
2377
2512
|
if (typeof icon === "string") {
|
|
2378
2513
|
return /* @__PURE__ */ import_react39.default.createElement("img", { style: { marginRight: 8 }, width: 12, height: 12, src: icon });
|
|
@@ -2392,7 +2527,7 @@ var VariableTagWidget = class extends import_view4.WidgetType {
|
|
|
2392
2527
|
);
|
|
2393
2528
|
return;
|
|
2394
2529
|
}
|
|
2395
|
-
const rootField = (0,
|
|
2530
|
+
const rootField = (0, import_lodash5.last)(v.parentFields) || v;
|
|
2396
2531
|
const isRoot = v.parentFields.length === 0;
|
|
2397
2532
|
const rootTitle = /* @__PURE__ */ import_react39.default.createElement(UIRootTitle2, null, rootField?.meta.title ? `${rootField.meta.title} ${isRoot ? "" : "-"} ` : "");
|
|
2398
2533
|
const rootIcon = this.renderIcon(rootField?.meta.icon);
|
|
@@ -2410,7 +2545,7 @@ var VariableTagWidget = class extends import_view4.WidgetType {
|
|
|
2410
2545
|
const dom = document.createElement("span");
|
|
2411
2546
|
this.rootDOM = dom;
|
|
2412
2547
|
this.toDispose.push(
|
|
2413
|
-
|
|
2548
|
+
import_editor23.Disposable.create(() => {
|
|
2414
2549
|
import_react_dom.default.unmountComponentAtNode(this.rootDOM);
|
|
2415
2550
|
})
|
|
2416
2551
|
);
|
|
@@ -2427,7 +2562,7 @@ var VariableTagWidget = class extends import_view4.WidgetType {
|
|
|
2427
2562
|
return dom;
|
|
2428
2563
|
}
|
|
2429
2564
|
eq(other) {
|
|
2430
|
-
return (0,
|
|
2565
|
+
return (0, import_lodash5.isEqual)(this.keyPath, other.keyPath);
|
|
2431
2566
|
}
|
|
2432
2567
|
ignoreEvent() {
|
|
2433
2568
|
return false;
|
|
@@ -2438,7 +2573,7 @@ var VariableTagWidget = class extends import_view4.WidgetType {
|
|
|
2438
2573
|
};
|
|
2439
2574
|
function VariableTagInject() {
|
|
2440
2575
|
const injector = (0, import_react40.useInjector)();
|
|
2441
|
-
const scope = (0,
|
|
2576
|
+
const scope = (0, import_editor23.useCurrentScope)();
|
|
2442
2577
|
(0, import_react39.useLayoutEffect)(() => {
|
|
2443
2578
|
const atMatcher = new import_view4.MatchDecorator({
|
|
2444
2579
|
regexp: /\{\{([^\}]+)\}\}/g,
|
|
@@ -2489,16 +2624,16 @@ var import_react44 = require("@coze-editor/editor/react");
|
|
|
2489
2624
|
|
|
2490
2625
|
// src/components/prompt-editor-with-inputs/inputs-picker.tsx
|
|
2491
2626
|
var import_react42 = __toESM(require("react"));
|
|
2492
|
-
var
|
|
2493
|
-
var
|
|
2627
|
+
var import_lodash6 = require("lodash");
|
|
2628
|
+
var import_editor24 = require("@flowgram.ai/editor");
|
|
2494
2629
|
var import_semi_ui18 = require("@douyinfe/semi-ui");
|
|
2495
2630
|
function InputsPicker({
|
|
2496
2631
|
inputsValues,
|
|
2497
2632
|
onSelect
|
|
2498
2633
|
}) {
|
|
2499
|
-
const available = (0,
|
|
2634
|
+
const available = (0, import_editor24.useScopeAvailable)();
|
|
2500
2635
|
const getArrayDrilldown = (type, depth = 1) => {
|
|
2501
|
-
if (
|
|
2636
|
+
if (import_editor24.ASTMatch.isArray(type.items)) {
|
|
2502
2637
|
return getArrayDrilldown(type.items, depth + 1);
|
|
2503
2638
|
}
|
|
2504
2639
|
return { type: type.items, depth };
|
|
@@ -2506,12 +2641,12 @@ function InputsPicker({
|
|
|
2506
2641
|
const renderVariable = (variable, keyPath) => {
|
|
2507
2642
|
let type = variable?.type;
|
|
2508
2643
|
let children;
|
|
2509
|
-
if (
|
|
2644
|
+
if (import_editor24.ASTMatch.isObject(type)) {
|
|
2510
2645
|
children = (type.properties || []).map((_property) => renderVariable(_property, [...keyPath, _property.key])).filter(Boolean);
|
|
2511
2646
|
}
|
|
2512
|
-
if (
|
|
2647
|
+
if (import_editor24.ASTMatch.isArray(type)) {
|
|
2513
2648
|
const drilldown = getArrayDrilldown(type);
|
|
2514
|
-
if (
|
|
2649
|
+
if (import_editor24.ASTMatch.isObject(drilldown.type)) {
|
|
2515
2650
|
children = (drilldown.type.properties || []).map(
|
|
2516
2651
|
(_property) => renderVariable(_property, [
|
|
2517
2652
|
...keyPath,
|
|
@@ -2524,7 +2659,7 @@ function InputsPicker({
|
|
|
2524
2659
|
const key = keyPath.map((_key, idx) => _key === "[0]" || idx === 0 ? _key : `.${_key}`).join("");
|
|
2525
2660
|
return {
|
|
2526
2661
|
key,
|
|
2527
|
-
label: (0,
|
|
2662
|
+
label: (0, import_lodash6.last)(keyPath),
|
|
2528
2663
|
value: key,
|
|
2529
2664
|
children
|
|
2530
2665
|
};
|
|
@@ -2670,8 +2805,8 @@ function VariableTree2() {
|
|
|
2670
2805
|
// src/components/json-editor-with-variables/extensions/variable-tag.tsx
|
|
2671
2806
|
var import_react48 = __toESM(require("react"));
|
|
2672
2807
|
var import_client = require("react-dom/client");
|
|
2673
|
-
var
|
|
2674
|
-
var
|
|
2808
|
+
var import_lodash7 = require("lodash");
|
|
2809
|
+
var import_editor25 = require("@flowgram.ai/editor");
|
|
2675
2810
|
var import_semi_ui22 = require("@douyinfe/semi-ui");
|
|
2676
2811
|
var import_semi_icons8 = require("@douyinfe/semi-icons");
|
|
2677
2812
|
var import_react49 = require("@coze-editor/editor/react");
|
|
@@ -2718,7 +2853,7 @@ var UIPopoverContent3 = import_styled_components9.default.div`
|
|
|
2718
2853
|
var VariableTagWidget2 = class extends import_view5.WidgetType {
|
|
2719
2854
|
constructor({ keyPath, scope }) {
|
|
2720
2855
|
super();
|
|
2721
|
-
this.toDispose = new
|
|
2856
|
+
this.toDispose = new import_editor25.DisposableCollection();
|
|
2722
2857
|
this.renderIcon = (icon) => {
|
|
2723
2858
|
if (typeof icon === "string") {
|
|
2724
2859
|
return /* @__PURE__ */ import_react48.default.createElement("img", { style: { marginRight: 8 }, width: 12, height: 12, src: icon });
|
|
@@ -2735,7 +2870,7 @@ var VariableTagWidget2 = class extends import_view5.WidgetType {
|
|
|
2735
2870
|
);
|
|
2736
2871
|
return;
|
|
2737
2872
|
}
|
|
2738
|
-
const rootField = (0,
|
|
2873
|
+
const rootField = (0, import_lodash7.last)(v.parentFields);
|
|
2739
2874
|
const rootTitle = /* @__PURE__ */ import_react48.default.createElement(UIRootTitle3, null, rootField?.meta.title ? `${rootField.meta.title} -` : "");
|
|
2740
2875
|
const rootIcon = this.renderIcon(rootField?.meta.icon);
|
|
2741
2876
|
this.root.render(
|
|
@@ -2752,7 +2887,7 @@ var VariableTagWidget2 = class extends import_view5.WidgetType {
|
|
|
2752
2887
|
const dom = document.createElement("span");
|
|
2753
2888
|
this.root = (0, import_client.createRoot)(dom);
|
|
2754
2889
|
this.toDispose.push(
|
|
2755
|
-
|
|
2890
|
+
import_editor25.Disposable.create(() => {
|
|
2756
2891
|
this.root.unmount();
|
|
2757
2892
|
})
|
|
2758
2893
|
);
|
|
@@ -2769,7 +2904,7 @@ var VariableTagWidget2 = class extends import_view5.WidgetType {
|
|
|
2769
2904
|
return dom;
|
|
2770
2905
|
}
|
|
2771
2906
|
eq(other) {
|
|
2772
|
-
return (0,
|
|
2907
|
+
return (0, import_lodash7.isEqual)(this.keyPath, other.keyPath);
|
|
2773
2908
|
}
|
|
2774
2909
|
ignoreEvent() {
|
|
2775
2910
|
return false;
|
|
@@ -2780,7 +2915,7 @@ var VariableTagWidget2 = class extends import_view5.WidgetType {
|
|
|
2780
2915
|
};
|
|
2781
2916
|
function VariableTagInject2() {
|
|
2782
2917
|
const injector = (0, import_react49.useInjector)();
|
|
2783
|
-
const scope = (0,
|
|
2918
|
+
const scope = (0, import_editor25.useCurrentScope)();
|
|
2784
2919
|
(0, import_react48.useLayoutEffect)(() => {
|
|
2785
2920
|
const atMatcher = new import_view5.MatchDecorator({
|
|
2786
2921
|
regexp: /\{\{([^\}]+)\}\}/g,
|
|
@@ -2863,8 +2998,8 @@ function JsonEditorWithVariables(props) {
|
|
|
2863
2998
|
}
|
|
2864
2999
|
|
|
2865
3000
|
// src/components/inputs-values/index.tsx
|
|
2866
|
-
var
|
|
2867
|
-
var
|
|
3001
|
+
var import_react51 = __toESM(require("react"));
|
|
3002
|
+
var import_editor26 = require("@flowgram.ai/editor");
|
|
2868
3003
|
var import_semi_ui23 = require("@douyinfe/semi-ui");
|
|
2869
3004
|
var import_semi_icons9 = require("@douyinfe/semi-icons");
|
|
2870
3005
|
|
|
@@ -2878,31 +3013,10 @@ var UIRows2 = import_styled_components10.default.div`
|
|
|
2878
3013
|
`;
|
|
2879
3014
|
var UIRow3 = import_styled_components10.default.div`
|
|
2880
3015
|
display: flex;
|
|
2881
|
-
align-items:
|
|
3016
|
+
align-items: flex-start;
|
|
2882
3017
|
gap: 5px;
|
|
2883
3018
|
`;
|
|
2884
3019
|
|
|
2885
|
-
// src/components/inputs-values/components/blur-input.tsx
|
|
2886
|
-
var import_react51 = __toESM(require("react"));
|
|
2887
|
-
var import_input2 = __toESM(require("@douyinfe/semi-ui/lib/es/input"));
|
|
2888
|
-
function BlurInput2(props) {
|
|
2889
|
-
const [value, setValue] = (0, import_react51.useState)("");
|
|
2890
|
-
(0, import_react51.useEffect)(() => {
|
|
2891
|
-
setValue(props.value);
|
|
2892
|
-
}, [props.value]);
|
|
2893
|
-
return /* @__PURE__ */ import_react51.default.createElement(
|
|
2894
|
-
import_input2.default,
|
|
2895
|
-
{
|
|
2896
|
-
...props,
|
|
2897
|
-
value,
|
|
2898
|
-
onChange: (value2) => {
|
|
2899
|
-
setValue(value2);
|
|
2900
|
-
},
|
|
2901
|
-
onBlur: (e) => props.onChange?.(value, e)
|
|
2902
|
-
}
|
|
2903
|
-
);
|
|
2904
|
-
}
|
|
2905
|
-
|
|
2906
3020
|
// src/components/inputs-values/index.tsx
|
|
2907
3021
|
function InputsValues({
|
|
2908
3022
|
value,
|
|
@@ -2918,17 +3032,17 @@ function InputsValues({
|
|
|
2918
3032
|
onChange,
|
|
2919
3033
|
sortIndexKey: "extra.index"
|
|
2920
3034
|
});
|
|
2921
|
-
return /* @__PURE__ */
|
|
2922
|
-
|
|
3035
|
+
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(
|
|
3036
|
+
BlurInput,
|
|
2923
3037
|
{
|
|
2924
3038
|
style: { width: 100, minWidth: 100, maxWidth: 100 },
|
|
2925
3039
|
disabled: readonly,
|
|
2926
3040
|
size: "small",
|
|
2927
3041
|
value: item.key,
|
|
2928
3042
|
onChange: (v) => updateKey(item.id, v),
|
|
2929
|
-
placeholder:
|
|
3043
|
+
placeholder: import_editor26.I18n.t("Input Key")
|
|
2930
3044
|
}
|
|
2931
|
-
), /* @__PURE__ */
|
|
3045
|
+
), /* @__PURE__ */ import_react51.default.createElement(
|
|
2932
3046
|
InjectDynamicValueInput,
|
|
2933
3047
|
{
|
|
2934
3048
|
style: { flexGrow: 1 },
|
|
@@ -2942,20 +3056,20 @@ function InputsValues({
|
|
|
2942
3056
|
strategies: [...constantProps?.strategies || []]
|
|
2943
3057
|
}
|
|
2944
3058
|
}
|
|
2945
|
-
), /* @__PURE__ */
|
|
3059
|
+
), /* @__PURE__ */ import_react51.default.createElement(
|
|
2946
3060
|
import_semi_ui23.IconButton,
|
|
2947
3061
|
{
|
|
2948
3062
|
disabled: readonly,
|
|
2949
3063
|
theme: "borderless",
|
|
2950
|
-
icon: /* @__PURE__ */
|
|
3064
|
+
icon: /* @__PURE__ */ import_react51.default.createElement(import_semi_icons9.IconDelete, { size: "small" }),
|
|
2951
3065
|
size: "small",
|
|
2952
3066
|
onClick: () => remove(item.id)
|
|
2953
3067
|
}
|
|
2954
|
-
)))), /* @__PURE__ */
|
|
3068
|
+
)))), /* @__PURE__ */ import_react51.default.createElement(import_semi_ui23.Button, { disabled: readonly, icon: /* @__PURE__ */ import_react51.default.createElement(import_semi_icons9.IconPlus, null), size: "small", onClick: () => add() }, import_editor26.I18n.t("Add")));
|
|
2955
3069
|
}
|
|
2956
3070
|
|
|
2957
3071
|
// src/components/display-schema-tree/index.tsx
|
|
2958
|
-
var
|
|
3072
|
+
var import_react52 = __toESM(require("react"));
|
|
2959
3073
|
|
|
2960
3074
|
// src/components/display-schema-tree/styles.tsx
|
|
2961
3075
|
var import_styled_components11 = __toESM(require("styled-components"));
|
|
@@ -3039,7 +3153,7 @@ var TreeItem = import_styled_components11.default.div`
|
|
|
3039
3153
|
|
|
3040
3154
|
// src/components/display-schema-tree/index.tsx
|
|
3041
3155
|
function DisplaySchemaTree(props) {
|
|
3042
|
-
return /* @__PURE__ */
|
|
3156
|
+
return /* @__PURE__ */ import_react52.default.createElement(SchemaTree, { ...props });
|
|
3043
3157
|
}
|
|
3044
3158
|
function SchemaTree(props) {
|
|
3045
3159
|
const {
|
|
@@ -3055,18 +3169,18 @@ function SchemaTree(props) {
|
|
|
3055
3169
|
const icon = typeManager?.getDisplayIcon(schema);
|
|
3056
3170
|
let properties = drilldown && config ? config.getTypeSchemaProperties(schema) : {};
|
|
3057
3171
|
const childEntries = Object.entries(properties || {});
|
|
3058
|
-
return /* @__PURE__ */
|
|
3172
|
+
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, {
|
|
3059
3173
|
className: "tree-icon"
|
|
3060
|
-
}), /* @__PURE__ */
|
|
3174
|
+
}), /* @__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);
|
|
3061
3175
|
}
|
|
3062
3176
|
|
|
3063
3177
|
// src/components/display-outputs/index.tsx
|
|
3064
|
-
var
|
|
3065
|
-
var
|
|
3066
|
-
var
|
|
3178
|
+
var import_react54 = __toESM(require("react"));
|
|
3179
|
+
var import_json_schema9 = require("@flowgram.ai/json-schema");
|
|
3180
|
+
var import_editor27 = require("@flowgram.ai/editor");
|
|
3067
3181
|
|
|
3068
3182
|
// src/components/display-schema-tag/index.tsx
|
|
3069
|
-
var
|
|
3183
|
+
var import_react53 = __toESM(require("react"));
|
|
3070
3184
|
var import_semi_ui25 = require("@douyinfe/semi-ui");
|
|
3071
3185
|
|
|
3072
3186
|
// src/components/display-schema-tag/styles.ts
|
|
@@ -3095,14 +3209,14 @@ var TitleSpan = import_styled_components12.default.span`
|
|
|
3095
3209
|
function DisplaySchemaTag({ value = {}, showIconInTree, title, warning }) {
|
|
3096
3210
|
const typeManager = useTypeManager();
|
|
3097
3211
|
const icon = typeManager?.getDisplayIcon(value) || typeManager.getDisplayIcon({ type: "unknown" });
|
|
3098
|
-
return /* @__PURE__ */
|
|
3212
|
+
return /* @__PURE__ */ import_react53.default.createElement(
|
|
3099
3213
|
import_semi_ui25.Popover,
|
|
3100
3214
|
{
|
|
3101
|
-
content: /* @__PURE__ */
|
|
3215
|
+
content: /* @__PURE__ */ import_react53.default.createElement(PopoverContent, null, /* @__PURE__ */ import_react53.default.createElement(DisplaySchemaTree, { value, typeManager, showIcon: showIconInTree }))
|
|
3102
3216
|
},
|
|
3103
|
-
/* @__PURE__ */
|
|
3217
|
+
/* @__PURE__ */ import_react53.default.createElement(StyledTag, { color: warning ? "amber" : "white" }, icon && import_react53.default.cloneElement(icon, {
|
|
3104
3218
|
className: "tag-icon"
|
|
3105
|
-
}), title && /* @__PURE__ */
|
|
3219
|
+
}), title && /* @__PURE__ */ import_react53.default.createElement(TitleSpan, null, title))
|
|
3106
3220
|
);
|
|
3107
3221
|
}
|
|
3108
3222
|
|
|
@@ -3116,9 +3230,9 @@ var DisplayOutputsWrapper = import_styled_components13.default.div`
|
|
|
3116
3230
|
|
|
3117
3231
|
// src/components/display-outputs/index.tsx
|
|
3118
3232
|
function DisplayOutputs({ value, showIconInTree, displayFromScope }) {
|
|
3119
|
-
const scope = (0,
|
|
3120
|
-
const refresh = (0,
|
|
3121
|
-
(0,
|
|
3233
|
+
const scope = (0, import_editor27.useCurrentScope)();
|
|
3234
|
+
const refresh = (0, import_editor27.useRefresh)();
|
|
3235
|
+
(0, import_react54.useEffect)(() => {
|
|
3122
3236
|
if (!displayFromScope) {
|
|
3123
3237
|
return () => null;
|
|
3124
3238
|
}
|
|
@@ -3132,12 +3246,12 @@ function DisplayOutputs({ value, showIconInTree, displayFromScope }) {
|
|
|
3132
3246
|
const properties = displayFromScope ? scope.output.variables?.reduce((acm, curr) => {
|
|
3133
3247
|
acm = {
|
|
3134
3248
|
...acm,
|
|
3135
|
-
...
|
|
3249
|
+
...import_json_schema9.JsonSchemaUtils.astToSchema(curr.type)?.properties || {}
|
|
3136
3250
|
};
|
|
3137
3251
|
return acm;
|
|
3138
3252
|
}, {}) : value?.properties || {};
|
|
3139
3253
|
const childEntries = Object.entries(properties || {});
|
|
3140
|
-
return /* @__PURE__ */
|
|
3254
|
+
return /* @__PURE__ */ import_react54.default.createElement(DisplayOutputsWrapper, null, childEntries.map(([key, schema]) => /* @__PURE__ */ import_react54.default.createElement(
|
|
3141
3255
|
DisplaySchemaTag,
|
|
3142
3256
|
{
|
|
3143
3257
|
key,
|
|
@@ -3150,15 +3264,15 @@ function DisplayOutputs({ value, showIconInTree, displayFromScope }) {
|
|
|
3150
3264
|
}
|
|
3151
3265
|
|
|
3152
3266
|
// src/components/display-flow-value/index.tsx
|
|
3153
|
-
var
|
|
3154
|
-
var
|
|
3155
|
-
var
|
|
3267
|
+
var import_react55 = __toESM(require("react"));
|
|
3268
|
+
var import_json_schema10 = require("@flowgram.ai/json-schema");
|
|
3269
|
+
var import_editor28 = require("@flowgram.ai/editor");
|
|
3156
3270
|
function DisplayFlowValue({ value, title, showIconInTree }) {
|
|
3157
|
-
const available = (0,
|
|
3271
|
+
const available = (0, import_editor28.useScopeAvailable)();
|
|
3158
3272
|
const variable = value?.type === "ref" ? available.getByKeyPath(value?.content) : void 0;
|
|
3159
|
-
const schema = (0,
|
|
3273
|
+
const schema = (0, import_react55.useMemo)(() => {
|
|
3160
3274
|
if (value?.type === "ref") {
|
|
3161
|
-
return
|
|
3275
|
+
return import_json_schema10.JsonSchemaUtils.astToSchema(variable?.type);
|
|
3162
3276
|
}
|
|
3163
3277
|
if (value?.type === "template") {
|
|
3164
3278
|
return { type: "string" };
|
|
@@ -3179,7 +3293,7 @@ function DisplayFlowValue({ value, title, showIconInTree }) {
|
|
|
3179
3293
|
}
|
|
3180
3294
|
return { type: "unknown" };
|
|
3181
3295
|
}, [value, variable?.hash]);
|
|
3182
|
-
return /* @__PURE__ */
|
|
3296
|
+
return /* @__PURE__ */ import_react55.default.createElement(
|
|
3183
3297
|
DisplaySchemaTag,
|
|
3184
3298
|
{
|
|
3185
3299
|
title,
|
|
@@ -3191,7 +3305,7 @@ function DisplayFlowValue({ value, title, showIconInTree }) {
|
|
|
3191
3305
|
}
|
|
3192
3306
|
|
|
3193
3307
|
// src/components/display-inputs-values/index.tsx
|
|
3194
|
-
var
|
|
3308
|
+
var import_react56 = __toESM(require("react"));
|
|
3195
3309
|
|
|
3196
3310
|
// src/components/display-inputs-values/styles.ts
|
|
3197
3311
|
var import_styled_components14 = __toESM(require("styled-components"));
|
|
@@ -3204,30 +3318,30 @@ var DisplayInputsWrapper = import_styled_components14.default.div`
|
|
|
3204
3318
|
// src/components/display-inputs-values/index.tsx
|
|
3205
3319
|
function DisplayInputsValues({ value, showIconInTree }) {
|
|
3206
3320
|
const childEntries = Object.entries(value || {});
|
|
3207
|
-
return /* @__PURE__ */
|
|
3321
|
+
return /* @__PURE__ */ import_react56.default.createElement(DisplayInputsWrapper, null, childEntries.map(([key, value2]) => /* @__PURE__ */ import_react56.default.createElement(DisplayFlowValue, { key, title: key, value: value2, showIconInTree })));
|
|
3208
3322
|
}
|
|
3209
3323
|
|
|
3210
3324
|
// src/components/assign-rows/index.tsx
|
|
3211
|
-
var
|
|
3212
|
-
var
|
|
3325
|
+
var import_react59 = __toESM(require("react"));
|
|
3326
|
+
var import_editor29 = require("@flowgram.ai/editor");
|
|
3213
3327
|
var import_semi_ui27 = require("@douyinfe/semi-ui");
|
|
3214
3328
|
var import_semi_icons11 = require("@douyinfe/semi-icons");
|
|
3215
3329
|
|
|
3216
3330
|
// src/components/assign-row/index.tsx
|
|
3217
|
-
var
|
|
3331
|
+
var import_react58 = __toESM(require("react"));
|
|
3218
3332
|
var import_semi_ui26 = require("@douyinfe/semi-ui");
|
|
3219
3333
|
var import_semi_icons10 = require("@douyinfe/semi-icons");
|
|
3220
3334
|
|
|
3221
3335
|
// src/components/assign-row/components/blur-input.tsx
|
|
3222
|
-
var
|
|
3223
|
-
var
|
|
3224
|
-
function
|
|
3225
|
-
const [value, setValue] = (0,
|
|
3226
|
-
(0,
|
|
3336
|
+
var import_react57 = __toESM(require("react"));
|
|
3337
|
+
var import_input2 = __toESM(require("@douyinfe/semi-ui/lib/es/input"));
|
|
3338
|
+
function BlurInput2(props) {
|
|
3339
|
+
const [value, setValue] = (0, import_react57.useState)("");
|
|
3340
|
+
(0, import_react57.useEffect)(() => {
|
|
3227
3341
|
setValue(props.value);
|
|
3228
3342
|
}, [props.value]);
|
|
3229
|
-
return /* @__PURE__ */
|
|
3230
|
-
|
|
3343
|
+
return /* @__PURE__ */ import_react57.default.createElement(
|
|
3344
|
+
import_input2.default,
|
|
3231
3345
|
{
|
|
3232
3346
|
...props,
|
|
3233
3347
|
value,
|
|
@@ -3249,7 +3363,7 @@ function AssignRow(props) {
|
|
|
3249
3363
|
onDelete,
|
|
3250
3364
|
readonly
|
|
3251
3365
|
} = props;
|
|
3252
|
-
return /* @__PURE__ */
|
|
3366
|
+
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(
|
|
3253
3367
|
InjectVariableSelector,
|
|
3254
3368
|
{
|
|
3255
3369
|
style: { width: "100%", height: 26 },
|
|
@@ -3260,8 +3374,8 @@ function AssignRow(props) {
|
|
|
3260
3374
|
left: { type: "ref", content: v }
|
|
3261
3375
|
})
|
|
3262
3376
|
}
|
|
3263
|
-
) : /* @__PURE__ */
|
|
3264
|
-
|
|
3377
|
+
) : /* @__PURE__ */ import_react58.default.createElement(
|
|
3378
|
+
BlurInput2,
|
|
3265
3379
|
{
|
|
3266
3380
|
style: { height: 26 },
|
|
3267
3381
|
size: "small",
|
|
@@ -3272,7 +3386,7 @@ function AssignRow(props) {
|
|
|
3272
3386
|
left: v
|
|
3273
3387
|
})
|
|
3274
3388
|
}
|
|
3275
|
-
)), /* @__PURE__ */
|
|
3389
|
+
)), /* @__PURE__ */ import_react58.default.createElement("div", { style: { flexGrow: 1 } }, /* @__PURE__ */ import_react58.default.createElement(
|
|
3276
3390
|
InjectDynamicValueInput,
|
|
3277
3391
|
{
|
|
3278
3392
|
readonly,
|
|
@@ -3282,12 +3396,12 @@ function AssignRow(props) {
|
|
|
3282
3396
|
right: v
|
|
3283
3397
|
})
|
|
3284
3398
|
}
|
|
3285
|
-
)), onDelete && /* @__PURE__ */
|
|
3399
|
+
)), onDelete && /* @__PURE__ */ import_react58.default.createElement("div", null, /* @__PURE__ */ import_react58.default.createElement(
|
|
3286
3400
|
import_semi_ui26.IconButton,
|
|
3287
3401
|
{
|
|
3288
3402
|
size: "small",
|
|
3289
3403
|
theme: "borderless",
|
|
3290
|
-
icon: /* @__PURE__ */
|
|
3404
|
+
icon: /* @__PURE__ */ import_react58.default.createElement(import_semi_icons10.IconMinus, null),
|
|
3291
3405
|
onClick: () => onDelete?.()
|
|
3292
3406
|
}
|
|
3293
3407
|
)));
|
|
@@ -3296,7 +3410,7 @@ function AssignRow(props) {
|
|
|
3296
3410
|
// src/components/assign-rows/index.tsx
|
|
3297
3411
|
function AssignRows(props) {
|
|
3298
3412
|
const { name, readonly } = props;
|
|
3299
|
-
return /* @__PURE__ */
|
|
3413
|
+
return /* @__PURE__ */ import_react59.default.createElement(import_editor29.FieldArray, { name }, ({ field }) => /* @__PURE__ */ import_react59.default.createElement(import_react59.default.Fragment, null, field.map((childField, index) => /* @__PURE__ */ import_react59.default.createElement(
|
|
3300
3414
|
AssignRow,
|
|
3301
3415
|
{
|
|
3302
3416
|
key: childField.key,
|
|
@@ -3307,51 +3421,345 @@ function AssignRows(props) {
|
|
|
3307
3421
|
},
|
|
3308
3422
|
onDelete: () => field.remove(index)
|
|
3309
3423
|
}
|
|
3310
|
-
)), /* @__PURE__ */
|
|
3424
|
+
)), /* @__PURE__ */ import_react59.default.createElement("div", { style: { display: "flex", gap: 5 } }, /* @__PURE__ */ import_react59.default.createElement(
|
|
3311
3425
|
import_semi_ui27.Button,
|
|
3312
3426
|
{
|
|
3313
3427
|
size: "small",
|
|
3314
3428
|
theme: "borderless",
|
|
3315
|
-
icon: /* @__PURE__ */
|
|
3429
|
+
icon: /* @__PURE__ */ import_react59.default.createElement(import_semi_icons11.IconPlus, null),
|
|
3316
3430
|
onClick: () => field.append({ operator: "assign" })
|
|
3317
3431
|
},
|
|
3318
3432
|
"Assign"
|
|
3319
|
-
), /* @__PURE__ */
|
|
3433
|
+
), /* @__PURE__ */ import_react59.default.createElement(
|
|
3320
3434
|
import_semi_ui27.Button,
|
|
3321
3435
|
{
|
|
3322
3436
|
size: "small",
|
|
3323
3437
|
theme: "borderless",
|
|
3324
|
-
icon: /* @__PURE__ */
|
|
3438
|
+
icon: /* @__PURE__ */ import_react59.default.createElement(import_semi_icons11.IconPlus, null),
|
|
3325
3439
|
onClick: () => field.append({ operator: "declare" })
|
|
3326
3440
|
},
|
|
3327
3441
|
"Declaration"
|
|
3328
3442
|
))));
|
|
3329
3443
|
}
|
|
3330
3444
|
|
|
3445
|
+
// src/components/inputs-values-tree/index.tsx
|
|
3446
|
+
var import_react63 = __toESM(require("react"));
|
|
3447
|
+
var import_editor31 = require("@flowgram.ai/editor");
|
|
3448
|
+
var import_semi_ui29 = require("@douyinfe/semi-ui");
|
|
3449
|
+
var import_semi_icons14 = require("@douyinfe/semi-icons");
|
|
3450
|
+
|
|
3451
|
+
// src/components/inputs-values-tree/styles.tsx
|
|
3452
|
+
var import_react60 = __toESM(require("react"));
|
|
3453
|
+
var import_styled_components15 = __toESM(require("styled-components"));
|
|
3454
|
+
var import_semi_icons12 = __toESM(require("@douyinfe/semi-icons"));
|
|
3455
|
+
var UIContainer5 = import_styled_components15.default.div``;
|
|
3456
|
+
var UIRow4 = import_styled_components15.default.div`
|
|
3457
|
+
display: flex;
|
|
3458
|
+
align-items: flex-start;
|
|
3459
|
+
gap: 5px;
|
|
3460
|
+
`;
|
|
3461
|
+
var UICollapseTrigger2 = import_styled_components15.default.div`
|
|
3462
|
+
cursor: pointer;
|
|
3463
|
+
margin-right: 5px;
|
|
3464
|
+
`;
|
|
3465
|
+
var UITreeItems2 = import_styled_components15.default.div`
|
|
3466
|
+
display: grid;
|
|
3467
|
+
grid-template-columns: auto 1fr;
|
|
3468
|
+
|
|
3469
|
+
${({ $shrink }) => $shrink && import_styled_components15.css`
|
|
3470
|
+
padding-left: 3px;
|
|
3471
|
+
margin-top: 10px;
|
|
3472
|
+
`}
|
|
3473
|
+
`;
|
|
3474
|
+
var UITreeItemLeft2 = import_styled_components15.default.div`
|
|
3475
|
+
grid-column: 1;
|
|
3476
|
+
position: relative;
|
|
3477
|
+
width: 16px;
|
|
3478
|
+
|
|
3479
|
+
${({ $showLine, $isLast, $showCollapse }) => {
|
|
3480
|
+
let height = $isLast ? "24px" : "100%";
|
|
3481
|
+
let width = $showCollapse ? "12px" : "30px";
|
|
3482
|
+
return $showLine && import_styled_components15.css`
|
|
3483
|
+
&::before {
|
|
3484
|
+
/* 竖线 */
|
|
3485
|
+
content: '';
|
|
3486
|
+
height: ${height};
|
|
3487
|
+
position: absolute;
|
|
3488
|
+
left: -14px;
|
|
3489
|
+
top: -16px;
|
|
3490
|
+
width: 1px;
|
|
3491
|
+
background: #d9d9d9;
|
|
3492
|
+
display: block;
|
|
3493
|
+
}
|
|
3494
|
+
|
|
3495
|
+
&::after {
|
|
3496
|
+
/* 横线 */
|
|
3497
|
+
content: '';
|
|
3498
|
+
position: absolute;
|
|
3499
|
+
left: -14px; // 横线起点和竖线对齐
|
|
3500
|
+
top: 8px; // 跟随你的行高调整
|
|
3501
|
+
width: ${width}; // 横线长度
|
|
3502
|
+
height: 1px;
|
|
3503
|
+
background: #d9d9d9;
|
|
3504
|
+
display: block;
|
|
3505
|
+
}
|
|
3506
|
+
`;
|
|
3507
|
+
}}
|
|
3508
|
+
`;
|
|
3509
|
+
var UITreeItemRight2 = import_styled_components15.default.div`
|
|
3510
|
+
grid-column: 2;
|
|
3511
|
+
margin-bottom: 10px;
|
|
3512
|
+
|
|
3513
|
+
&:last-child {
|
|
3514
|
+
margin-bottom: 0px;
|
|
3515
|
+
}
|
|
3516
|
+
`;
|
|
3517
|
+
var UITreeItemMain2 = import_styled_components15.default.div`
|
|
3518
|
+
display: flex;
|
|
3519
|
+
flex-direction: column;
|
|
3520
|
+
gap: 10px;
|
|
3521
|
+
position: relative;
|
|
3522
|
+
`;
|
|
3523
|
+
var UICollapsible2 = import_styled_components15.default.div`
|
|
3524
|
+
display: none;
|
|
3525
|
+
|
|
3526
|
+
${({ $collapse }) => $collapse && import_styled_components15.css`
|
|
3527
|
+
display: block;
|
|
3528
|
+
`}
|
|
3529
|
+
`;
|
|
3530
|
+
var UIActions2 = import_styled_components15.default.div`
|
|
3531
|
+
white-space: nowrap;
|
|
3532
|
+
`;
|
|
3533
|
+
var iconAddChildrenSvg2 = /* @__PURE__ */ import_react60.default.createElement(
|
|
3534
|
+
"svg",
|
|
3535
|
+
{
|
|
3536
|
+
className: "icon-icon icon-icon-coz_add_node ",
|
|
3537
|
+
width: "1em",
|
|
3538
|
+
height: "1em",
|
|
3539
|
+
viewBox: "0 0 24 24",
|
|
3540
|
+
fill: "currentColor",
|
|
3541
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
3542
|
+
},
|
|
3543
|
+
/* @__PURE__ */ import_react60.default.createElement(
|
|
3544
|
+
"path",
|
|
3545
|
+
{
|
|
3546
|
+
fillRule: "evenodd",
|
|
3547
|
+
clipRule: "evenodd",
|
|
3548
|
+
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"
|
|
3549
|
+
}
|
|
3550
|
+
),
|
|
3551
|
+
/* @__PURE__ */ import_react60.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" })
|
|
3552
|
+
);
|
|
3553
|
+
var IconAddChildren2 = () => /* @__PURE__ */ import_react60.default.createElement(import_semi_icons12.default, { size: "small", svg: iconAddChildrenSvg2 });
|
|
3554
|
+
|
|
3555
|
+
// src/components/inputs-values-tree/row.tsx
|
|
3556
|
+
var import_react62 = __toESM(require("react"));
|
|
3557
|
+
var import_editor30 = require("@flowgram.ai/editor");
|
|
3558
|
+
var import_semi_ui28 = require("@douyinfe/semi-ui");
|
|
3559
|
+
var import_semi_icons13 = require("@douyinfe/semi-icons");
|
|
3560
|
+
|
|
3561
|
+
// src/components/inputs-values-tree/hooks/use-child-list.tsx
|
|
3562
|
+
var import_react61 = require("react");
|
|
3563
|
+
var import_lodash8 = require("lodash");
|
|
3564
|
+
function useChildList(value, onChange) {
|
|
3565
|
+
const canAddField = (0, import_react61.useMemo)(() => {
|
|
3566
|
+
if (!(0, import_lodash8.isPlainObject)(value)) {
|
|
3567
|
+
return false;
|
|
3568
|
+
}
|
|
3569
|
+
if (FlowValueUtils.isFlowValue(value)) {
|
|
3570
|
+
return FlowValueUtils.isConstant(value) && value?.schema?.type === "object";
|
|
3571
|
+
}
|
|
3572
|
+
return true;
|
|
3573
|
+
}, [value]);
|
|
3574
|
+
const objectListValue = (0, import_react61.useMemo)(() => {
|
|
3575
|
+
if ((0, import_lodash8.isPlainObject)(value)) {
|
|
3576
|
+
if (FlowValueUtils.isFlowValue(value)) {
|
|
3577
|
+
return void 0;
|
|
3578
|
+
}
|
|
3579
|
+
return value;
|
|
3580
|
+
}
|
|
3581
|
+
return void 0;
|
|
3582
|
+
}, [value]);
|
|
3583
|
+
console.log("debugger objectListValue", objectListValue);
|
|
3584
|
+
const { list, add, updateKey, updateValue, remove } = useObjectList({
|
|
3585
|
+
value: objectListValue,
|
|
3586
|
+
onChange: (value2) => {
|
|
3587
|
+
onChange?.(value2);
|
|
3588
|
+
},
|
|
3589
|
+
sortIndexKey: (value2) => FlowValueUtils.isFlowValue(value2) ? "extra.index" : ""
|
|
3590
|
+
});
|
|
3591
|
+
return {
|
|
3592
|
+
canAddField,
|
|
3593
|
+
list,
|
|
3594
|
+
add,
|
|
3595
|
+
updateKey,
|
|
3596
|
+
updateValue,
|
|
3597
|
+
remove
|
|
3598
|
+
};
|
|
3599
|
+
}
|
|
3600
|
+
|
|
3601
|
+
// src/components/inputs-values-tree/row.tsx
|
|
3602
|
+
var AddObjectChildStrategy = {
|
|
3603
|
+
hit: (schema) => schema.type === "object",
|
|
3604
|
+
Renderer: () => /* @__PURE__ */ import_react62.default.createElement(
|
|
3605
|
+
import_semi_ui28.Input,
|
|
3606
|
+
{
|
|
3607
|
+
size: "small",
|
|
3608
|
+
disabled: true,
|
|
3609
|
+
style: { pointerEvents: "none" },
|
|
3610
|
+
value: import_editor30.I18n.t("Configure via child fields")
|
|
3611
|
+
}
|
|
3612
|
+
)
|
|
3613
|
+
};
|
|
3614
|
+
function InputValueRow(props) {
|
|
3615
|
+
const {
|
|
3616
|
+
keyName,
|
|
3617
|
+
value,
|
|
3618
|
+
$level = 0,
|
|
3619
|
+
onUpdateKey,
|
|
3620
|
+
onUpdateValue,
|
|
3621
|
+
$isLast,
|
|
3622
|
+
onRemove,
|
|
3623
|
+
constantProps,
|
|
3624
|
+
hasError,
|
|
3625
|
+
readonly
|
|
3626
|
+
} = props;
|
|
3627
|
+
const [collapse, setCollapse] = (0, import_react62.useState)(false);
|
|
3628
|
+
const { canAddField, list, add, updateKey, updateValue, remove } = useChildList(
|
|
3629
|
+
value,
|
|
3630
|
+
onUpdateValue
|
|
3631
|
+
);
|
|
3632
|
+
const hasChildren = canAddField && list.length > 0;
|
|
3633
|
+
const flowDisplayValue = hasChildren ? { type: "constant", schema: { type: " object" } } : value;
|
|
3634
|
+
return /* @__PURE__ */ import_react62.default.createElement(import_react62.default.Fragment, null, /* @__PURE__ */ import_react62.default.createElement(UITreeItemLeft2, { $isLast, $showLine: $level > 0, $showCollapse: hasChildren }, hasChildren && /* @__PURE__ */ import_react62.default.createElement(UICollapseTrigger2, { onClick: () => setCollapse((_collapse) => !_collapse) }, collapse ? /* @__PURE__ */ import_react62.default.createElement(import_semi_icons13.IconChevronDown, { size: "small" }) : /* @__PURE__ */ import_react62.default.createElement(import_semi_icons13.IconChevronRight, { size: "small" }))), /* @__PURE__ */ import_react62.default.createElement(UITreeItemRight2, null, /* @__PURE__ */ import_react62.default.createElement(UITreeItemMain2, null, /* @__PURE__ */ import_react62.default.createElement(UIRow4, null, /* @__PURE__ */ import_react62.default.createElement(
|
|
3635
|
+
BlurInput,
|
|
3636
|
+
{
|
|
3637
|
+
style: { width: 100, minWidth: 100, maxWidth: 100 },
|
|
3638
|
+
disabled: readonly,
|
|
3639
|
+
size: "small",
|
|
3640
|
+
value: keyName,
|
|
3641
|
+
onChange: (v) => onUpdateKey?.(v),
|
|
3642
|
+
placeholder: import_editor30.I18n.t("Input Key")
|
|
3643
|
+
}
|
|
3644
|
+
), /* @__PURE__ */ import_react62.default.createElement(
|
|
3645
|
+
InjectDynamicValueInput,
|
|
3646
|
+
{
|
|
3647
|
+
style: { flexGrow: 1 },
|
|
3648
|
+
readonly,
|
|
3649
|
+
value: flowDisplayValue,
|
|
3650
|
+
onChange: (v) => onUpdateValue(v),
|
|
3651
|
+
hasError,
|
|
3652
|
+
constantProps: {
|
|
3653
|
+
...constantProps,
|
|
3654
|
+
strategies: [
|
|
3655
|
+
...hasChildren ? [AddObjectChildStrategy] : [],
|
|
3656
|
+
...constantProps?.strategies || []
|
|
3657
|
+
]
|
|
3658
|
+
}
|
|
3659
|
+
}
|
|
3660
|
+
), /* @__PURE__ */ import_react62.default.createElement(UIActions2, null, canAddField && /* @__PURE__ */ import_react62.default.createElement(
|
|
3661
|
+
import_semi_ui28.IconButton,
|
|
3662
|
+
{
|
|
3663
|
+
disabled: readonly,
|
|
3664
|
+
size: "small",
|
|
3665
|
+
theme: "borderless",
|
|
3666
|
+
icon: /* @__PURE__ */ import_react62.default.createElement(IconAddChildren2, null),
|
|
3667
|
+
onClick: () => {
|
|
3668
|
+
add();
|
|
3669
|
+
setCollapse(true);
|
|
3670
|
+
}
|
|
3671
|
+
}
|
|
3672
|
+
), /* @__PURE__ */ import_react62.default.createElement(
|
|
3673
|
+
import_semi_ui28.IconButton,
|
|
3674
|
+
{
|
|
3675
|
+
disabled: readonly,
|
|
3676
|
+
theme: "borderless",
|
|
3677
|
+
icon: /* @__PURE__ */ import_react62.default.createElement(import_semi_icons13.IconDelete, { size: "small" }),
|
|
3678
|
+
size: "small",
|
|
3679
|
+
onClick: () => onRemove?.()
|
|
3680
|
+
}
|
|
3681
|
+
)))), hasChildren && /* @__PURE__ */ import_react62.default.createElement(UICollapsible2, { $collapse: collapse }, /* @__PURE__ */ import_react62.default.createElement(UITreeItems2, { $shrink: true }, list.map((_item, index) => /* @__PURE__ */ import_react62.default.createElement(
|
|
3682
|
+
InputValueRow,
|
|
3683
|
+
{
|
|
3684
|
+
readonly,
|
|
3685
|
+
hasError,
|
|
3686
|
+
constantProps,
|
|
3687
|
+
key: _item.id,
|
|
3688
|
+
keyName: _item.key,
|
|
3689
|
+
value: _item.value,
|
|
3690
|
+
$level: $level + 1,
|
|
3691
|
+
onUpdateValue: (_v) => {
|
|
3692
|
+
updateValue(_item.id, _v);
|
|
3693
|
+
},
|
|
3694
|
+
onUpdateKey: (k) => {
|
|
3695
|
+
updateKey(_item.id, k);
|
|
3696
|
+
},
|
|
3697
|
+
onRemove: () => {
|
|
3698
|
+
remove(_item.id);
|
|
3699
|
+
},
|
|
3700
|
+
$isLast: index === list.length - 1
|
|
3701
|
+
}
|
|
3702
|
+
))))));
|
|
3703
|
+
}
|
|
3704
|
+
|
|
3705
|
+
// src/components/inputs-values-tree/index.tsx
|
|
3706
|
+
function InputsValuesTree(props) {
|
|
3707
|
+
const { value, onChange, readonly, hasError, constantProps } = props;
|
|
3708
|
+
const { list, updateKey, updateValue, remove, add } = useObjectList({
|
|
3709
|
+
value,
|
|
3710
|
+
onChange,
|
|
3711
|
+
sortIndexKey: (value2) => FlowValueUtils.isFlowValue(value2) ? "extra.index" : ""
|
|
3712
|
+
});
|
|
3713
|
+
return /* @__PURE__ */ import_react63.default.createElement("div", null, /* @__PURE__ */ import_react63.default.createElement(UITreeItems2, null, list.map((item) => /* @__PURE__ */ import_react63.default.createElement(
|
|
3714
|
+
InputValueRow,
|
|
3715
|
+
{
|
|
3716
|
+
key: item.id,
|
|
3717
|
+
keyName: item.key,
|
|
3718
|
+
value: item.value,
|
|
3719
|
+
onUpdateKey: (key) => updateKey(item.id, key),
|
|
3720
|
+
onUpdateValue: (value2) => updateValue(item.id, value2),
|
|
3721
|
+
onRemove: () => remove(item.id),
|
|
3722
|
+
readonly,
|
|
3723
|
+
hasError,
|
|
3724
|
+
constantProps
|
|
3725
|
+
}
|
|
3726
|
+
))), /* @__PURE__ */ import_react63.default.createElement(
|
|
3727
|
+
import_semi_ui29.Button,
|
|
3728
|
+
{
|
|
3729
|
+
style: { marginTop: 10, marginLeft: 16 },
|
|
3730
|
+
disabled: readonly,
|
|
3731
|
+
icon: /* @__PURE__ */ import_react63.default.createElement(import_semi_icons14.IconPlus, null),
|
|
3732
|
+
size: "small",
|
|
3733
|
+
onClick: add
|
|
3734
|
+
},
|
|
3735
|
+
import_editor31.I18n.t("Add")
|
|
3736
|
+
));
|
|
3737
|
+
}
|
|
3738
|
+
|
|
3331
3739
|
// src/effects/provide-batch-input/index.ts
|
|
3332
|
-
var
|
|
3333
|
-
var provideBatchInputEffect = (0,
|
|
3740
|
+
var import_editor32 = require("@flowgram.ai/editor");
|
|
3741
|
+
var provideBatchInputEffect = (0, import_editor32.createEffectFromVariableProvider)({
|
|
3334
3742
|
private: true,
|
|
3335
3743
|
parse: (value, ctx) => [
|
|
3336
|
-
|
|
3744
|
+
import_editor32.ASTFactory.createVariableDeclaration({
|
|
3337
3745
|
key: `${ctx.node.id}_locals`,
|
|
3338
3746
|
meta: {
|
|
3339
|
-
title: (0,
|
|
3747
|
+
title: (0, import_editor32.getNodeForm)(ctx.node)?.getValueIn("title"),
|
|
3340
3748
|
icon: ctx.node.getNodeRegistry().info?.icon
|
|
3341
3749
|
},
|
|
3342
|
-
type:
|
|
3750
|
+
type: import_editor32.ASTFactory.createObject({
|
|
3343
3751
|
properties: [
|
|
3344
|
-
|
|
3752
|
+
import_editor32.ASTFactory.createProperty({
|
|
3345
3753
|
key: "item",
|
|
3346
|
-
initializer:
|
|
3347
|
-
enumerateFor:
|
|
3754
|
+
initializer: import_editor32.ASTFactory.createEnumerateExpression({
|
|
3755
|
+
enumerateFor: import_editor32.ASTFactory.createKeyPathExpression({
|
|
3348
3756
|
keyPath: value.content || []
|
|
3349
3757
|
})
|
|
3350
3758
|
})
|
|
3351
3759
|
}),
|
|
3352
|
-
|
|
3760
|
+
import_editor32.ASTFactory.createProperty({
|
|
3353
3761
|
key: "index",
|
|
3354
|
-
type:
|
|
3762
|
+
type: import_editor32.ASTFactory.createNumber()
|
|
3355
3763
|
})
|
|
3356
3764
|
]
|
|
3357
3765
|
})
|
|
@@ -3360,14 +3768,13 @@ var provideBatchInputEffect = (0, import_editor29.createEffectFromVariableProvid
|
|
|
3360
3768
|
});
|
|
3361
3769
|
|
|
3362
3770
|
// src/effects/auto-rename-ref/index.ts
|
|
3363
|
-
var
|
|
3364
|
-
var import_editor30 = require("@flowgram.ai/editor");
|
|
3771
|
+
var import_editor33 = require("@flowgram.ai/editor");
|
|
3365
3772
|
var autoRenameRefEffect = [
|
|
3366
3773
|
{
|
|
3367
|
-
event:
|
|
3774
|
+
event: import_editor33.DataEvent.onValueInit,
|
|
3368
3775
|
effect: (params) => {
|
|
3369
3776
|
const { context, form, name } = params;
|
|
3370
|
-
const renameService = context.node.getService(
|
|
3777
|
+
const renameService = context.node.getService(import_editor33.VariableFieldKeyRenameService);
|
|
3371
3778
|
const disposable = renameService.onRename(({ before, after }) => {
|
|
3372
3779
|
const beforeKeyPath = [
|
|
3373
3780
|
...before.parentFields.map((_field) => _field.key).reverse(),
|
|
@@ -3384,7 +3791,7 @@ var autoRenameRefEffect = [
|
|
|
3384
3791
|
form.setValueIn(_drilldownName, _v);
|
|
3385
3792
|
}
|
|
3386
3793
|
} else if (_v.type === "template") {
|
|
3387
|
-
const templateKeyPaths = getTemplateKeyPaths(_v);
|
|
3794
|
+
const templateKeyPaths = FlowValueUtils.getTemplateKeyPaths(_v);
|
|
3388
3795
|
let hasMatch = false;
|
|
3389
3796
|
templateKeyPaths.forEach((_keyPath) => {
|
|
3390
3797
|
if (isKeyPathMatch(_keyPath, beforeKeyPath)) {
|
|
@@ -3414,65 +3821,38 @@ var autoRenameRefEffect = [
|
|
|
3414
3821
|
function isKeyPathMatch(keyPath = [], targetKeyPath) {
|
|
3415
3822
|
return targetKeyPath.every((_key, index) => _key === keyPath[index]);
|
|
3416
3823
|
}
|
|
3417
|
-
function getTemplateKeyPaths(value) {
|
|
3418
|
-
const keyPathReg = /{{(.*?)}}/g;
|
|
3419
|
-
return (0, import_lodash7.uniq)(value.content?.match(keyPathReg) || []).map(
|
|
3420
|
-
(_keyPath) => _keyPath.slice(2, -2).split(".")
|
|
3421
|
-
);
|
|
3422
|
-
}
|
|
3423
|
-
function isRef(value) {
|
|
3424
|
-
return value?.type === "ref" && Array.isArray(value?.content) && typeof value?.content[0] === "string";
|
|
3425
|
-
}
|
|
3426
|
-
function isTemplate(value) {
|
|
3427
|
-
return value?.type === "template" && typeof value?.content === "string";
|
|
3428
|
-
}
|
|
3429
3824
|
function traverseRef(name, value, cb) {
|
|
3430
|
-
|
|
3431
|
-
|
|
3432
|
-
|
|
3433
|
-
|
|
3434
|
-
|
|
3435
|
-
if (isTemplate(value)) {
|
|
3436
|
-
cb(name, value);
|
|
3437
|
-
return;
|
|
3438
|
-
}
|
|
3439
|
-
Object.entries(value).forEach(([_key, _value]) => {
|
|
3440
|
-
traverseRef(`${name}.${_key}`, _value, cb);
|
|
3441
|
-
});
|
|
3442
|
-
return;
|
|
3443
|
-
}
|
|
3444
|
-
if ((0, import_lodash7.isArray)(value)) {
|
|
3445
|
-
value.forEach((_value, idx) => {
|
|
3446
|
-
traverseRef(`${name}[${idx}]`, _value, cb);
|
|
3447
|
-
});
|
|
3448
|
-
return;
|
|
3825
|
+
for (const { value: _v, path } of FlowValueUtils.traverse(value, {
|
|
3826
|
+
includeTypes: ["ref", "template"],
|
|
3827
|
+
path: name
|
|
3828
|
+
})) {
|
|
3829
|
+
cb(path, _v);
|
|
3449
3830
|
}
|
|
3450
|
-
return;
|
|
3451
3831
|
}
|
|
3452
3832
|
|
|
3453
3833
|
// src/effects/provide-json-schema-outputs/index.ts
|
|
3454
|
-
var
|
|
3455
|
-
var
|
|
3456
|
-
var provideJsonSchemaOutputs = (0,
|
|
3834
|
+
var import_json_schema11 = require("@flowgram.ai/json-schema");
|
|
3835
|
+
var import_editor34 = require("@flowgram.ai/editor");
|
|
3836
|
+
var provideJsonSchemaOutputs = (0, import_editor34.createEffectFromVariableProvider)({
|
|
3457
3837
|
parse: (value, ctx) => [
|
|
3458
|
-
|
|
3838
|
+
import_editor34.ASTFactory.createVariableDeclaration({
|
|
3459
3839
|
key: `${ctx.node.id}`,
|
|
3460
3840
|
meta: {
|
|
3461
|
-
title: (0,
|
|
3841
|
+
title: (0, import_editor34.getNodeForm)(ctx.node)?.getValueIn("title") || ctx.node.id,
|
|
3462
3842
|
icon: ctx.node.getNodeRegistry().info?.icon
|
|
3463
3843
|
},
|
|
3464
|
-
type:
|
|
3844
|
+
type: import_json_schema11.JsonSchemaUtils.schemaToAST(value)
|
|
3465
3845
|
})
|
|
3466
3846
|
]
|
|
3467
3847
|
});
|
|
3468
3848
|
|
|
3469
3849
|
// src/effects/sync-variable-title/index.ts
|
|
3470
|
-
var
|
|
3850
|
+
var import_editor35 = require("@flowgram.ai/editor");
|
|
3471
3851
|
var syncVariableTitle = [
|
|
3472
3852
|
{
|
|
3473
|
-
event:
|
|
3853
|
+
event: import_editor35.DataEvent.onValueChange,
|
|
3474
3854
|
effect: ({ value, context }) => {
|
|
3475
|
-
context.node.getData(
|
|
3855
|
+
context.node.getData(import_editor35.FlowNodeVariableData).allScopes.forEach((_scope) => {
|
|
3476
3856
|
_scope.output.variables.forEach((_var) => {
|
|
3477
3857
|
_var.updateMeta({
|
|
3478
3858
|
..._var.meta || {},
|
|
@@ -3486,17 +3866,17 @@ var syncVariableTitle = [
|
|
|
3486
3866
|
];
|
|
3487
3867
|
|
|
3488
3868
|
// src/effects/validate-when-variable-sync/index.ts
|
|
3489
|
-
var
|
|
3490
|
-
var
|
|
3869
|
+
var import_lodash9 = require("lodash");
|
|
3870
|
+
var import_editor36 = require("@flowgram.ai/editor");
|
|
3491
3871
|
var validateWhenVariableSync = ({
|
|
3492
3872
|
scope
|
|
3493
3873
|
} = {}) => [
|
|
3494
3874
|
{
|
|
3495
|
-
event:
|
|
3875
|
+
event: import_editor36.DataEvent.onValueInit,
|
|
3496
3876
|
effect: ({ context, form }) => {
|
|
3497
|
-
const nodeScope = scope === "private" ? (0,
|
|
3877
|
+
const nodeScope = scope === "private" ? (0, import_editor36.getNodePrivateScope)(context.node) : (0, import_editor36.getNodeScope)(context.node);
|
|
3498
3878
|
const disposable = nodeScope.available.onListOrAnyVarChange(() => {
|
|
3499
|
-
if (!(0,
|
|
3879
|
+
if (!(0, import_lodash9.isEmpty)(form.state.errors)) {
|
|
3500
3880
|
form.validate();
|
|
3501
3881
|
}
|
|
3502
3882
|
});
|
|
@@ -3506,16 +3886,16 @@ var validateWhenVariableSync = ({
|
|
|
3506
3886
|
];
|
|
3507
3887
|
|
|
3508
3888
|
// src/effects/listen-ref-value-change/index.ts
|
|
3509
|
-
var
|
|
3889
|
+
var import_editor37 = require("@flowgram.ai/editor");
|
|
3510
3890
|
var listenRefValueChange = (cb) => [
|
|
3511
3891
|
{
|
|
3512
|
-
event:
|
|
3892
|
+
event: import_editor37.DataEvent.onValueInitOrChange,
|
|
3513
3893
|
effect: (params) => {
|
|
3514
3894
|
const { context, value } = params;
|
|
3515
3895
|
if (value?.type !== "ref") {
|
|
3516
3896
|
return () => null;
|
|
3517
3897
|
}
|
|
3518
|
-
const disposable = (0,
|
|
3898
|
+
const disposable = (0, import_editor37.getNodeScope)(context.node).available.trackByKeyPath(
|
|
3519
3899
|
value?.content || [],
|
|
3520
3900
|
(v) => {
|
|
3521
3901
|
cb({ ...params, variable: v });
|
|
@@ -3529,20 +3909,20 @@ var listenRefValueChange = (cb) => [
|
|
|
3529
3909
|
];
|
|
3530
3910
|
|
|
3531
3911
|
// src/effects/listen-ref-schema-change/index.ts
|
|
3532
|
-
var
|
|
3533
|
-
var
|
|
3912
|
+
var import_json_schema12 = require("@flowgram.ai/json-schema");
|
|
3913
|
+
var import_editor38 = require("@flowgram.ai/editor");
|
|
3534
3914
|
var listenRefSchemaChange = (cb) => [
|
|
3535
3915
|
{
|
|
3536
|
-
event:
|
|
3916
|
+
event: import_editor38.DataEvent.onValueInitOrChange,
|
|
3537
3917
|
effect: (params) => {
|
|
3538
3918
|
const { context, value } = params;
|
|
3539
3919
|
if (value?.type !== "ref") {
|
|
3540
3920
|
return () => null;
|
|
3541
3921
|
}
|
|
3542
|
-
const disposable = (0,
|
|
3922
|
+
const disposable = (0, import_editor38.getNodeScope)(context.node).available.trackByKeyPath(
|
|
3543
3923
|
value?.content || [],
|
|
3544
3924
|
(_type) => {
|
|
3545
|
-
cb({ ...params, schema:
|
|
3925
|
+
cb({ ...params, schema: import_json_schema12.JsonSchemaUtils.astToSchema(_type) });
|
|
3546
3926
|
},
|
|
3547
3927
|
{
|
|
3548
3928
|
selector: (_v) => _v?.type
|
|
@@ -3556,21 +3936,21 @@ var listenRefSchemaChange = (cb) => [
|
|
|
3556
3936
|
];
|
|
3557
3937
|
|
|
3558
3938
|
// src/form-plugins/batch-outputs-plugin/index.ts
|
|
3559
|
-
var
|
|
3560
|
-
var provideBatchOutputsEffect = (0,
|
|
3939
|
+
var import_editor39 = require("@flowgram.ai/editor");
|
|
3940
|
+
var provideBatchOutputsEffect = (0, import_editor39.createEffectFromVariableProvider)({
|
|
3561
3941
|
parse: (value, ctx) => [
|
|
3562
|
-
|
|
3942
|
+
import_editor39.ASTFactory.createVariableDeclaration({
|
|
3563
3943
|
key: `${ctx.node.id}`,
|
|
3564
3944
|
meta: {
|
|
3565
|
-
title: (0,
|
|
3945
|
+
title: (0, import_editor39.getNodeForm)(ctx.node)?.getValueIn("title"),
|
|
3566
3946
|
icon: ctx.node.getNodeRegistry().info?.icon
|
|
3567
3947
|
},
|
|
3568
|
-
type:
|
|
3948
|
+
type: import_editor39.ASTFactory.createObject({
|
|
3569
3949
|
properties: Object.entries(value).map(
|
|
3570
|
-
([_key, value2]) =>
|
|
3950
|
+
([_key, value2]) => import_editor39.ASTFactory.createProperty({
|
|
3571
3951
|
key: _key,
|
|
3572
|
-
initializer:
|
|
3573
|
-
wrapFor:
|
|
3952
|
+
initializer: import_editor39.ASTFactory.createWrapArrayExpression({
|
|
3953
|
+
wrapFor: import_editor39.ASTFactory.createKeyPathExpression({
|
|
3574
3954
|
keyPath: value2?.content || []
|
|
3575
3955
|
})
|
|
3576
3956
|
})
|
|
@@ -3580,7 +3960,7 @@ var provideBatchOutputsEffect = (0, import_editor36.createEffectFromVariableProv
|
|
|
3580
3960
|
})
|
|
3581
3961
|
]
|
|
3582
3962
|
});
|
|
3583
|
-
var createBatchOutputsFormPlugin = (0,
|
|
3963
|
+
var createBatchOutputsFormPlugin = (0, import_editor39.defineFormPluginCreator)({
|
|
3584
3964
|
name: "batch-outputs-plugin",
|
|
3585
3965
|
onSetupFormMeta({ mergeEffect }, { outputKey }) {
|
|
3586
3966
|
mergeEffect({
|
|
@@ -3588,7 +3968,7 @@ var createBatchOutputsFormPlugin = (0, import_editor36.defineFormPluginCreator)(
|
|
|
3588
3968
|
});
|
|
3589
3969
|
},
|
|
3590
3970
|
onInit(ctx, { outputKey }) {
|
|
3591
|
-
const chainTransformService = ctx.node.getService(
|
|
3971
|
+
const chainTransformService = ctx.node.getService(import_editor39.ScopeChainTransformService);
|
|
3592
3972
|
const batchNodeType = ctx.node.flowNodeType;
|
|
3593
3973
|
const transformerId = `${batchNodeType}-outputs`;
|
|
3594
3974
|
if (chainTransformService.hasTransformer(transformerId)) {
|
|
@@ -3598,21 +3978,21 @@ var createBatchOutputsFormPlugin = (0, import_editor36.defineFormPluginCreator)(
|
|
|
3598
3978
|
transformCovers: (covers, ctx2) => {
|
|
3599
3979
|
const node = ctx2.scope.meta?.node;
|
|
3600
3980
|
if (node?.parent?.flowNodeType === batchNodeType) {
|
|
3601
|
-
return [...covers, (0,
|
|
3981
|
+
return [...covers, (0, import_editor39.getNodeScope)(node.parent)];
|
|
3602
3982
|
}
|
|
3603
3983
|
return covers;
|
|
3604
3984
|
},
|
|
3605
3985
|
transformDeps(scopes, ctx2) {
|
|
3606
3986
|
const scopeMeta = ctx2.scope.meta;
|
|
3607
|
-
if (scopeMeta?.type ===
|
|
3987
|
+
if (scopeMeta?.type === import_editor39.FlowNodeScopeType.private) {
|
|
3608
3988
|
return scopes;
|
|
3609
3989
|
}
|
|
3610
3990
|
const node = scopeMeta?.node;
|
|
3611
3991
|
if (node?.flowNodeType === batchNodeType) {
|
|
3612
3992
|
const childBlocks = node.blocks;
|
|
3613
3993
|
return [
|
|
3614
|
-
(0,
|
|
3615
|
-
...childBlocks.map((_childBlock) => (0,
|
|
3994
|
+
(0, import_editor39.getNodePrivateScope)(node),
|
|
3995
|
+
...childBlocks.map((_childBlock) => (0, import_editor39.getNodeScope)(_childBlock))
|
|
3616
3996
|
];
|
|
3617
3997
|
}
|
|
3618
3998
|
return scopes;
|
|
@@ -3622,110 +4002,56 @@ var createBatchOutputsFormPlugin = (0, import_editor36.defineFormPluginCreator)(
|
|
|
3622
4002
|
});
|
|
3623
4003
|
|
|
3624
4004
|
// src/form-plugins/infer-inputs-plugin/index.ts
|
|
3625
|
-
var
|
|
3626
|
-
var
|
|
3627
|
-
var
|
|
3628
|
-
var createInferInputsPlugin = (0, import_editor37.defineFormPluginCreator)({
|
|
4005
|
+
var import_lodash10 = require("lodash");
|
|
4006
|
+
var import_editor40 = require("@flowgram.ai/editor");
|
|
4007
|
+
var createInferInputsPlugin = (0, import_editor40.defineFormPluginCreator)({
|
|
3629
4008
|
onSetupFormMeta({ addFormatOnSubmit }, { sourceKey, targetKey, scope }) {
|
|
3630
4009
|
if (!sourceKey || !targetKey) {
|
|
3631
4010
|
return;
|
|
3632
4011
|
}
|
|
3633
4012
|
addFormatOnSubmit((formData, ctx) => {
|
|
3634
|
-
(0,
|
|
4013
|
+
(0, import_lodash10.set)(
|
|
3635
4014
|
formData,
|
|
3636
4015
|
targetKey,
|
|
3637
|
-
|
|
3638
|
-
(0,
|
|
3639
|
-
scope === "private" ? (0,
|
|
4016
|
+
FlowValueUtils.inferJsonSchema(
|
|
4017
|
+
(0, import_lodash10.get)(formData, sourceKey),
|
|
4018
|
+
scope === "private" ? (0, import_editor40.getNodePrivateScope)(ctx.node) : (0, import_editor40.getNodeScope)(ctx.node)
|
|
3640
4019
|
)
|
|
3641
4020
|
);
|
|
3642
4021
|
return formData;
|
|
3643
4022
|
});
|
|
3644
4023
|
}
|
|
3645
4024
|
});
|
|
3646
|
-
function isRef2(value) {
|
|
3647
|
-
return value?.type === "ref" && Array.isArray(value?.content) && typeof value?.content[0] === "string";
|
|
3648
|
-
}
|
|
3649
|
-
function isTemplate2(value) {
|
|
3650
|
-
return value?.type === "template" && typeof value?.content === "string";
|
|
3651
|
-
}
|
|
3652
|
-
function isConstant(value) {
|
|
3653
|
-
return value?.type === "constant" && typeof value?.content !== "undefined";
|
|
3654
|
-
}
|
|
3655
|
-
var infer = (values, scope) => {
|
|
3656
|
-
if (typeof values === "object") {
|
|
3657
|
-
if (isConstant(values)) {
|
|
3658
|
-
if (values?.schema) {
|
|
3659
|
-
return values.schema;
|
|
3660
|
-
}
|
|
3661
|
-
if (typeof values.content === "string") {
|
|
3662
|
-
return {
|
|
3663
|
-
type: "string"
|
|
3664
|
-
};
|
|
3665
|
-
}
|
|
3666
|
-
if (typeof values.content === "number") {
|
|
3667
|
-
return {
|
|
3668
|
-
type: "number"
|
|
3669
|
-
};
|
|
3670
|
-
}
|
|
3671
|
-
if (typeof values.content === "boolean") {
|
|
3672
|
-
return {
|
|
3673
|
-
type: "boolean"
|
|
3674
|
-
};
|
|
3675
|
-
}
|
|
3676
|
-
}
|
|
3677
|
-
if (isRef2(values)) {
|
|
3678
|
-
const variable = scope.available.getByKeyPath(values?.content);
|
|
3679
|
-
const schema = variable?.type ? import_json_schema12.JsonSchemaUtils.astToSchema(variable?.type) : void 0;
|
|
3680
|
-
return schema;
|
|
3681
|
-
}
|
|
3682
|
-
if (isTemplate2(values)) {
|
|
3683
|
-
return {
|
|
3684
|
-
type: "string"
|
|
3685
|
-
};
|
|
3686
|
-
}
|
|
3687
|
-
return {
|
|
3688
|
-
type: "object",
|
|
3689
|
-
properties: Object.keys(values).reduce((acc, key) => {
|
|
3690
|
-
const schema = infer(values[key], scope);
|
|
3691
|
-
if (schema) {
|
|
3692
|
-
acc[key] = schema;
|
|
3693
|
-
}
|
|
3694
|
-
return acc;
|
|
3695
|
-
}, {})
|
|
3696
|
-
};
|
|
3697
|
-
}
|
|
3698
|
-
};
|
|
3699
4025
|
|
|
3700
4026
|
// src/form-plugins/infer-assign-plugin/index.ts
|
|
3701
|
-
var
|
|
4027
|
+
var import_lodash11 = require("lodash");
|
|
3702
4028
|
var import_json_schema13 = require("@flowgram.ai/json-schema");
|
|
3703
|
-
var
|
|
3704
|
-
var createInferAssignPlugin = (0,
|
|
4029
|
+
var import_editor41 = require("@flowgram.ai/editor");
|
|
4030
|
+
var createInferAssignPlugin = (0, import_editor41.defineFormPluginCreator)({
|
|
3705
4031
|
onSetupFormMeta({ addFormatOnSubmit, mergeEffect }, { assignKey, outputKey }) {
|
|
3706
4032
|
if (!assignKey || !outputKey) {
|
|
3707
4033
|
return;
|
|
3708
4034
|
}
|
|
3709
4035
|
mergeEffect({
|
|
3710
|
-
[assignKey]: (0,
|
|
4036
|
+
[assignKey]: (0, import_editor41.createEffectFromVariableProvider)({
|
|
3711
4037
|
parse: (value, ctx) => {
|
|
3712
|
-
const declareRows = (0,
|
|
4038
|
+
const declareRows = (0, import_lodash11.uniqBy)(
|
|
3713
4039
|
value.filter((_v) => _v.operator === "declare" && _v.left && _v.right),
|
|
3714
4040
|
"left"
|
|
3715
4041
|
);
|
|
3716
4042
|
return [
|
|
3717
|
-
|
|
4043
|
+
import_editor41.ASTFactory.createVariableDeclaration({
|
|
3718
4044
|
key: `${ctx.node.id}`,
|
|
3719
4045
|
meta: {
|
|
3720
|
-
title: (0,
|
|
4046
|
+
title: (0, import_editor41.getNodeForm)(ctx.node)?.getValueIn("title"),
|
|
3721
4047
|
icon: ctx.node.getNodeRegistry().info?.icon
|
|
3722
4048
|
},
|
|
3723
|
-
type:
|
|
4049
|
+
type: import_editor41.ASTFactory.createObject({
|
|
3724
4050
|
properties: declareRows.map(
|
|
3725
|
-
(_v) =>
|
|
4051
|
+
(_v) => import_editor41.ASTFactory.createProperty({
|
|
3726
4052
|
key: _v.left,
|
|
3727
4053
|
type: _v.right?.type === "constant" ? import_json_schema13.JsonSchemaUtils.schemaToAST(_v.right?.schema || {}) : void 0,
|
|
3728
|
-
initializer: _v.right?.type === "ref" ?
|
|
4054
|
+
initializer: _v.right?.type === "ref" ? import_editor41.ASTFactory.createKeyPathExpression({
|
|
3729
4055
|
keyPath: _v.right?.content || []
|
|
3730
4056
|
}) : {}
|
|
3731
4057
|
})
|
|
@@ -3737,10 +4063,10 @@ var createInferAssignPlugin = (0, import_editor38.defineFormPluginCreator)({
|
|
|
3737
4063
|
})
|
|
3738
4064
|
});
|
|
3739
4065
|
addFormatOnSubmit((formData, ctx) => {
|
|
3740
|
-
(0,
|
|
4066
|
+
(0, import_lodash11.set)(
|
|
3741
4067
|
formData,
|
|
3742
4068
|
outputKey,
|
|
3743
|
-
import_json_schema13.JsonSchemaUtils.astToSchema((0,
|
|
4069
|
+
import_json_schema13.JsonSchemaUtils.astToSchema((0, import_editor41.getNodeScope)(ctx.node).output.variables?.[0]?.type)
|
|
3744
4070
|
);
|
|
3745
4071
|
return formData;
|
|
3746
4072
|
});
|
|
@@ -3748,36 +4074,36 @@ var createInferAssignPlugin = (0, import_editor38.defineFormPluginCreator)({
|
|
|
3748
4074
|
});
|
|
3749
4075
|
|
|
3750
4076
|
// src/validate/validate-flow-value/index.tsx
|
|
3751
|
-
var
|
|
3752
|
-
var
|
|
4077
|
+
var import_lodash12 = require("lodash");
|
|
4078
|
+
var import_editor42 = require("@flowgram.ai/editor");
|
|
3753
4079
|
function validateFlowValue(value, ctx) {
|
|
3754
4080
|
const { node, required, errorMessages } = ctx;
|
|
3755
4081
|
const {
|
|
3756
4082
|
required: requiredMessage = "Field is required",
|
|
3757
4083
|
unknownVariable: unknownVariableMessage = "Unknown Variable"
|
|
3758
4084
|
} = errorMessages || {};
|
|
3759
|
-
if (required && ((0,
|
|
4085
|
+
if (required && ((0, import_lodash12.isNil)(value) || (0, import_lodash12.isNil)(value?.content) || value?.content === "")) {
|
|
3760
4086
|
return {
|
|
3761
|
-
level:
|
|
4087
|
+
level: import_editor42.FeedbackLevel.Error,
|
|
3762
4088
|
message: requiredMessage
|
|
3763
4089
|
};
|
|
3764
4090
|
}
|
|
3765
4091
|
if (value?.type === "ref") {
|
|
3766
|
-
const variable = (0,
|
|
4092
|
+
const variable = (0, import_editor42.getNodeScope)(node).available.getByKeyPath(value?.content || []);
|
|
3767
4093
|
if (!variable) {
|
|
3768
4094
|
return {
|
|
3769
|
-
level:
|
|
4095
|
+
level: import_editor42.FeedbackLevel.Error,
|
|
3770
4096
|
message: unknownVariableMessage
|
|
3771
4097
|
};
|
|
3772
4098
|
}
|
|
3773
4099
|
}
|
|
3774
4100
|
if (value?.type === "template") {
|
|
3775
|
-
const allRefs =
|
|
4101
|
+
const allRefs = getTemplateKeyPaths(value);
|
|
3776
4102
|
for (const ref of allRefs) {
|
|
3777
|
-
const variable = (0,
|
|
4103
|
+
const variable = (0, import_editor42.getNodeScope)(node).available.getByKeyPath(ref);
|
|
3778
4104
|
if (!variable) {
|
|
3779
4105
|
return {
|
|
3780
|
-
level:
|
|
4106
|
+
level: import_editor42.FeedbackLevel.Error,
|
|
3781
4107
|
message: unknownVariableMessage
|
|
3782
4108
|
};
|
|
3783
4109
|
}
|
|
@@ -3785,9 +4111,9 @@ function validateFlowValue(value, ctx) {
|
|
|
3785
4111
|
}
|
|
3786
4112
|
return void 0;
|
|
3787
4113
|
}
|
|
3788
|
-
function
|
|
4114
|
+
function getTemplateKeyPaths(value) {
|
|
3789
4115
|
const keyPathReg = /{{(.*?)}}/g;
|
|
3790
|
-
return (0,
|
|
4116
|
+
return (0, import_lodash12.uniq)(value.content?.match(keyPathReg) || []).map(
|
|
3791
4117
|
(_keyPath) => _keyPath.slice(2, -2).split(".")
|
|
3792
4118
|
);
|
|
3793
4119
|
}
|
|
@@ -3797,6 +4123,7 @@ function getTemplateKeyPaths2(value) {
|
|
|
3797
4123
|
AssignRows,
|
|
3798
4124
|
BatchOutputs,
|
|
3799
4125
|
BatchVariableSelector,
|
|
4126
|
+
BlurInput,
|
|
3800
4127
|
CodeEditor,
|
|
3801
4128
|
CodeEditorMini,
|
|
3802
4129
|
ConditionRow,
|
|
@@ -3807,10 +4134,12 @@ function getTemplateKeyPaths2(value) {
|
|
|
3807
4134
|
DisplaySchemaTag,
|
|
3808
4135
|
DisplaySchemaTree,
|
|
3809
4136
|
DynamicValueInput,
|
|
4137
|
+
FlowValueUtils,
|
|
3810
4138
|
InjectDynamicValueInput,
|
|
3811
4139
|
InjectTypeSelector,
|
|
3812
4140
|
InjectVariableSelector,
|
|
3813
4141
|
InputsValues,
|
|
4142
|
+
InputsValuesTree,
|
|
3814
4143
|
JsonEditorWithVariables,
|
|
3815
4144
|
JsonSchemaEditor,
|
|
3816
4145
|
JsonSchemaTypePresetProvider,
|