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