@flowgram.ai/form-materials 0.2.27 → 0.2.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/materials.ts +1 -1
- package/dist/esm/index.js +466 -218
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.mts +53 -15
- package/dist/index.d.ts +53 -15
- package/dist/index.js +475 -225
- package/dist/index.js.map +1 -1
- package/package.json +6 -5
- package/src/components/batch-outputs/config.json +2 -1
- package/src/components/batch-outputs/index.tsx +4 -12
- package/src/components/code-editor/config.json +2 -1
- package/src/components/code-editor/language-features.ts +3 -4
- package/src/components/constant-input/index.tsx +19 -2
- package/src/components/constant-input/types.ts +1 -0
- package/src/components/dynamic-value-input/index.tsx +58 -9
- package/src/components/dynamic-value-input/styles.tsx +28 -2
- package/src/components/index.ts +1 -0
- package/src/components/inputs-values/config.json +12 -0
- package/src/components/inputs-values/index.tsx +60 -0
- package/src/components/inputs-values/styles.tsx +19 -0
- package/src/components/inputs-values/types.ts +19 -0
- package/src/components/json-schema-editor/index.tsx +14 -1
- package/src/components/prompt-editor-with-inputs/inputs-picker.tsx +1 -1
- package/src/components/type-selector/index.tsx +15 -8
- package/src/components/variable-selector/index.tsx +30 -11
- package/src/components/variable-selector/styles.tsx +18 -8
- package/src/effects/index.ts +0 -1
- package/src/form-plugins/index.ts +2 -1
- package/src/form-plugins/infer-inputs-plugin/config.json +7 -0
- package/src/form-plugins/infer-inputs-plugin/index.ts +108 -0
- package/src/hooks/index.tsx +6 -0
- package/src/hooks/use-object-list/config.json +8 -0
- package/src/{components/batch-outputs/use-list.ts → hooks/use-object-list/index.tsx} +49 -12
- package/src/typings/flow-value/config.json +3 -1
- package/src/typings/flow-value/index.ts +3 -0
- package/src/effects/provide-batch-outputs/config.json +0 -5
- package/src/effects/provide-batch-outputs/index.ts +0 -38
package/dist/index.js
CHANGED
|
@@ -37,6 +37,7 @@ __export(src_exports, {
|
|
|
37
37
|
ConditionRow: () => ConditionRow,
|
|
38
38
|
ConstantInput: () => ConstantInput,
|
|
39
39
|
DynamicValueInput: () => DynamicValueInput,
|
|
40
|
+
InputsValues: () => InputsValues,
|
|
40
41
|
JsonEditorWithVariables: () => JsonEditorWithVariables,
|
|
41
42
|
JsonSchemaEditor: () => JsonSchemaEditor,
|
|
42
43
|
JsonSchemaUtils: () => JsonSchemaUtils,
|
|
@@ -48,6 +49,7 @@ __export(src_exports, {
|
|
|
48
49
|
VariableTypeIcons: () => VariableTypeIcons,
|
|
49
50
|
autoRenameRefEffect: () => autoRenameRefEffect,
|
|
50
51
|
createBatchOutputsFormPlugin: () => createBatchOutputsFormPlugin,
|
|
52
|
+
createInferInputsPlugin: () => createInferInputsPlugin,
|
|
51
53
|
formatLegacyRefOnInit: () => formatLegacyRefOnInit,
|
|
52
54
|
formatLegacyRefOnSubmit: () => formatLegacyRefOnSubmit,
|
|
53
55
|
formatLegacyRefToNewRef: () => formatLegacyRefToNewRef,
|
|
@@ -67,6 +69,7 @@ module.exports = __toCommonJS(src_exports);
|
|
|
67
69
|
|
|
68
70
|
// src/components/variable-selector/index.tsx
|
|
69
71
|
var import_react3 = __toESM(require("react"));
|
|
72
|
+
var import_semi_ui3 = require("@douyinfe/semi-ui");
|
|
70
73
|
var import_semi_icons2 = require("@douyinfe/semi-icons");
|
|
71
74
|
|
|
72
75
|
// src/components/variable-selector/use-variable-tree.tsx
|
|
@@ -660,7 +663,10 @@ var UIVarName = import_styled_components.default.div`
|
|
|
660
663
|
overflow: hidden;
|
|
661
664
|
text-overflow: ellipsis;
|
|
662
665
|
white-space: nowrap;
|
|
663
|
-
|
|
666
|
+
|
|
667
|
+
${({ $inSelector }) => $inSelector && import_styled_components.css`
|
|
668
|
+
min-width: 50%;
|
|
669
|
+
`}
|
|
664
670
|
`;
|
|
665
671
|
var UITag = (0, import_styled_components.default)(import_semi_ui2.Tag)`
|
|
666
672
|
width: 100%;
|
|
@@ -674,17 +680,14 @@ var UITag = (0, import_styled_components.default)(import_semi_ui2.Tag)`
|
|
|
674
680
|
|
|
675
681
|
&.semi-tag {
|
|
676
682
|
margin: 0;
|
|
683
|
+
height: 22px;
|
|
677
684
|
}
|
|
678
685
|
`;
|
|
679
686
|
var UITreeSelect = (0, import_styled_components.default)(import_semi_ui2.TreeSelect)`
|
|
680
687
|
outline: ${({ $error }) => $error ? "1px solid red" : "none"};
|
|
681
688
|
|
|
682
|
-
height: 22px;
|
|
683
|
-
min-height: 22px;
|
|
684
|
-
line-height: 22px;
|
|
685
|
-
|
|
686
689
|
& .semi-tree-select-selection {
|
|
687
|
-
padding:
|
|
690
|
+
padding: 0px;
|
|
688
691
|
height: 22px;
|
|
689
692
|
}
|
|
690
693
|
|
|
@@ -696,6 +699,13 @@ var UITreeSelect = (0, import_styled_components.default)(import_semi_ui2.TreeSel
|
|
|
696
699
|
padding-left: 10px;
|
|
697
700
|
}
|
|
698
701
|
`;
|
|
702
|
+
var UIPopoverContent = import_styled_components.default.div`
|
|
703
|
+
padding: 10px;
|
|
704
|
+
display: inline-flex;
|
|
705
|
+
align-items: center;
|
|
706
|
+
justify-content: flex-start;
|
|
707
|
+
white-space: nowrap;
|
|
708
|
+
`;
|
|
699
709
|
|
|
700
710
|
// src/components/variable-selector/index.tsx
|
|
701
711
|
var VariableSelector = ({
|
|
@@ -754,16 +764,24 @@ var VariableSelector = ({
|
|
|
754
764
|
config?.notFoundContent ?? "Undefined"
|
|
755
765
|
);
|
|
756
766
|
}
|
|
757
|
-
|
|
758
|
-
|
|
767
|
+
const rootIcon = renderIcon(_option.rootMeta?.icon || _option?.icon);
|
|
768
|
+
const rootTitle = /* @__PURE__ */ import_react3.default.createElement(UIRootTitle, null, _option.rootMeta?.title ? `${_option.rootMeta?.title} -` : null);
|
|
769
|
+
return /* @__PURE__ */ import_react3.default.createElement("div", null, /* @__PURE__ */ import_react3.default.createElement(
|
|
770
|
+
import_semi_ui3.Popover,
|
|
759
771
|
{
|
|
760
|
-
|
|
761
|
-
closable: !readonly,
|
|
762
|
-
onClose: () => onChange(void 0)
|
|
772
|
+
content: /* @__PURE__ */ import_react3.default.createElement(UIPopoverContent, null, rootIcon, rootTitle, /* @__PURE__ */ import_react3.default.createElement(UIVarName, null, _option.keyPath.slice(1).join(".")))
|
|
763
773
|
},
|
|
764
|
-
/* @__PURE__ */ import_react3.default.createElement(
|
|
765
|
-
|
|
766
|
-
|
|
774
|
+
/* @__PURE__ */ import_react3.default.createElement(
|
|
775
|
+
UITag,
|
|
776
|
+
{
|
|
777
|
+
prefixIcon: rootIcon,
|
|
778
|
+
closable: !readonly,
|
|
779
|
+
onClose: () => onChange(void 0)
|
|
780
|
+
},
|
|
781
|
+
rootTitle,
|
|
782
|
+
/* @__PURE__ */ import_react3.default.createElement(UIVarName, { $inSelector: true }, _option.label)
|
|
783
|
+
)
|
|
784
|
+
));
|
|
767
785
|
},
|
|
768
786
|
showClear: false,
|
|
769
787
|
arrowIcon: /* @__PURE__ */ import_react3.default.createElement(import_semi_icons2.IconChevronDownStroked, { size: "small" }),
|
|
@@ -775,7 +793,7 @@ var VariableSelector = ({
|
|
|
775
793
|
|
|
776
794
|
// src/components/type-selector/index.tsx
|
|
777
795
|
var import_react4 = __toESM(require("react"));
|
|
778
|
-
var
|
|
796
|
+
var import_semi_ui4 = require("@douyinfe/semi-ui");
|
|
779
797
|
var getTypeSelectValue = (value) => {
|
|
780
798
|
if (value?.type === "array" && value?.items) {
|
|
781
799
|
return [value.type, ...getTypeSelectValue(value.items) || []];
|
|
@@ -790,19 +808,27 @@ var parseTypeSelectValue = (value) => {
|
|
|
790
808
|
return { type };
|
|
791
809
|
};
|
|
792
810
|
function TypeSelector(props) {
|
|
793
|
-
const { value, onChange, disabled, style } = props;
|
|
811
|
+
const { value, onChange, readonly, disabled, style } = props;
|
|
794
812
|
const selectValue = (0, import_react4.useMemo)(() => getTypeSelectValue(value), [value]);
|
|
795
813
|
return /* @__PURE__ */ import_react4.default.createElement(
|
|
796
|
-
|
|
814
|
+
import_semi_ui4.Cascader,
|
|
797
815
|
{
|
|
798
|
-
disabled,
|
|
816
|
+
disabled: readonly || disabled,
|
|
799
817
|
size: "small",
|
|
800
|
-
triggerRender: () => /* @__PURE__ */ import_react4.default.createElement(
|
|
818
|
+
triggerRender: () => /* @__PURE__ */ import_react4.default.createElement(
|
|
819
|
+
import_semi_ui4.IconButton,
|
|
820
|
+
{
|
|
821
|
+
size: "small",
|
|
822
|
+
style,
|
|
823
|
+
disabled: readonly || disabled,
|
|
824
|
+
icon: getSchemaIcon(value)
|
|
825
|
+
}
|
|
826
|
+
),
|
|
801
827
|
treeData: options,
|
|
802
828
|
value: selectValue,
|
|
803
829
|
leafOnly: true,
|
|
804
830
|
onChange: (value2) => {
|
|
805
|
-
onChange(parseTypeSelectValue(value2));
|
|
831
|
+
onChange?.(parseTypeSelectValue(value2));
|
|
806
832
|
}
|
|
807
833
|
}
|
|
808
834
|
);
|
|
@@ -810,7 +836,7 @@ function TypeSelector(props) {
|
|
|
810
836
|
|
|
811
837
|
// src/components/json-schema-editor/index.tsx
|
|
812
838
|
var import_react10 = __toESM(require("react"));
|
|
813
|
-
var
|
|
839
|
+
var import_semi_ui7 = require("@douyinfe/semi-ui");
|
|
814
840
|
var import_semi_icons5 = require("@douyinfe/semi-icons");
|
|
815
841
|
|
|
816
842
|
// src/components/json-schema-editor/styles.tsx
|
|
@@ -1121,7 +1147,7 @@ function usePropertiesEdit(value, onChange) {
|
|
|
1121
1147
|
|
|
1122
1148
|
// src/components/json-schema-editor/default-value.tsx
|
|
1123
1149
|
var import_react8 = __toESM(require("react"));
|
|
1124
|
-
var
|
|
1150
|
+
var import_semi_ui6 = require("@douyinfe/semi-ui");
|
|
1125
1151
|
var import_semi_icons4 = require("@douyinfe/semi-icons");
|
|
1126
1152
|
|
|
1127
1153
|
// src/components/json-schema-editor/utils.ts
|
|
@@ -1145,16 +1171,16 @@ function getValueType(value) {
|
|
|
1145
1171
|
|
|
1146
1172
|
// src/components/constant-input/index.tsx
|
|
1147
1173
|
var import_react7 = __toESM(require("react"));
|
|
1148
|
-
var
|
|
1174
|
+
var import_semi_ui5 = require("@douyinfe/semi-ui");
|
|
1149
1175
|
var defaultStrategies = [
|
|
1150
1176
|
{
|
|
1151
1177
|
hit: (schema) => schema?.type === "string",
|
|
1152
|
-
Renderer: (props) => /* @__PURE__ */ import_react7.default.createElement(
|
|
1178
|
+
Renderer: (props) => /* @__PURE__ */ import_react7.default.createElement(import_semi_ui5.Input, { placeholder: "Please Input String", size: "small", disabled: props.readonly, ...props })
|
|
1153
1179
|
},
|
|
1154
1180
|
{
|
|
1155
1181
|
hit: (schema) => schema?.type === "number",
|
|
1156
1182
|
Renderer: (props) => /* @__PURE__ */ import_react7.default.createElement(
|
|
1157
|
-
|
|
1183
|
+
import_semi_ui5.InputNumber,
|
|
1158
1184
|
{
|
|
1159
1185
|
placeholder: "Please Input Number",
|
|
1160
1186
|
size: "small",
|
|
@@ -1167,7 +1193,7 @@ var defaultStrategies = [
|
|
|
1167
1193
|
{
|
|
1168
1194
|
hit: (schema) => schema?.type === "integer",
|
|
1169
1195
|
Renderer: (props) => /* @__PURE__ */ import_react7.default.createElement(
|
|
1170
|
-
|
|
1196
|
+
import_semi_ui5.InputNumber,
|
|
1171
1197
|
{
|
|
1172
1198
|
placeholder: "Please Input Integer",
|
|
1173
1199
|
size: "small",
|
|
@@ -1183,7 +1209,7 @@ var defaultStrategies = [
|
|
|
1183
1209
|
Renderer: (props) => {
|
|
1184
1210
|
const { value, onChange, ...rest } = props;
|
|
1185
1211
|
return /* @__PURE__ */ import_react7.default.createElement(
|
|
1186
|
-
|
|
1212
|
+
import_semi_ui5.Select,
|
|
1187
1213
|
{
|
|
1188
1214
|
placeholder: "Please Select Boolean",
|
|
1189
1215
|
size: "small",
|
|
@@ -1201,9 +1227,18 @@ var defaultStrategies = [
|
|
|
1201
1227
|
}
|
|
1202
1228
|
];
|
|
1203
1229
|
function ConstantInput(props) {
|
|
1204
|
-
const {
|
|
1230
|
+
const {
|
|
1231
|
+
value,
|
|
1232
|
+
onChange,
|
|
1233
|
+
schema,
|
|
1234
|
+
strategies: extraStrategies,
|
|
1235
|
+
fallbackRenderer,
|
|
1236
|
+
readonly,
|
|
1237
|
+
...rest
|
|
1238
|
+
} = props;
|
|
1205
1239
|
const strategies = (0, import_react7.useMemo)(
|
|
1206
|
-
|
|
1240
|
+
// user's extraStrategies first
|
|
1241
|
+
() => [...extraStrategies || [], ...defaultStrategies],
|
|
1207
1242
|
[extraStrategies]
|
|
1208
1243
|
);
|
|
1209
1244
|
const Renderer2 = (0, import_react7.useMemo)(() => {
|
|
@@ -1211,7 +1246,15 @@ function ConstantInput(props) {
|
|
|
1211
1246
|
return strategy?.Renderer;
|
|
1212
1247
|
}, [strategies, schema]);
|
|
1213
1248
|
if (!Renderer2) {
|
|
1214
|
-
|
|
1249
|
+
if (fallbackRenderer) {
|
|
1250
|
+
return import_react7.default.createElement(fallbackRenderer, {
|
|
1251
|
+
value,
|
|
1252
|
+
onChange,
|
|
1253
|
+
readonly,
|
|
1254
|
+
...rest
|
|
1255
|
+
});
|
|
1256
|
+
}
|
|
1257
|
+
return /* @__PURE__ */ import_react7.default.createElement(import_semi_ui5.Input, { size: "small", disabled: true, placeholder: "Unsupported type" });
|
|
1215
1258
|
}
|
|
1216
1259
|
return /* @__PURE__ */ import_react7.default.createElement(Renderer2, { value, onChange, readonly, ...rest });
|
|
1217
1260
|
}
|
|
@@ -1247,8 +1290,8 @@ function DefaultValue(props) {
|
|
|
1247
1290
|
console.error("Invalid JSON:", error);
|
|
1248
1291
|
}
|
|
1249
1292
|
}, [internalJsonValue, onChange]);
|
|
1250
|
-
return type === "object" ? /* @__PURE__ */ import_react8.default.createElement(import_react8.default.Fragment, null, /* @__PURE__ */ import_react8.default.createElement(JSONHeader, null, /* @__PURE__ */ import_react8.default.createElement(JSONHeaderLeft, null, "json"), /* @__PURE__ */ import_react8.default.createElement(JSONHeaderRight, null, /* @__PURE__ */ import_react8.default.createElement(
|
|
1251
|
-
|
|
1293
|
+
return type === "object" ? /* @__PURE__ */ import_react8.default.createElement(import_react8.default.Fragment, null, /* @__PURE__ */ import_react8.default.createElement(JSONHeader, null, /* @__PURE__ */ import_react8.default.createElement(JSONHeaderLeft, null, "json"), /* @__PURE__ */ import_react8.default.createElement(JSONHeaderRight, null, /* @__PURE__ */ import_react8.default.createElement(import_semi_ui6.Tooltip, { content: jsonFormatText ?? "Format" }, /* @__PURE__ */ import_react8.default.createElement(
|
|
1294
|
+
import_semi_ui6.IconButton,
|
|
1252
1295
|
{
|
|
1253
1296
|
icon: /* @__PURE__ */ import_react8.default.createElement(import_semi_icons4.IconBrackets, { style: { color: "var(--semi-color-primary)" } }),
|
|
1254
1297
|
size: "small",
|
|
@@ -1271,7 +1314,7 @@ function DefaultValue(props) {
|
|
|
1271
1314
|
}
|
|
1272
1315
|
},
|
|
1273
1316
|
/* @__PURE__ */ import_react8.default.createElement(
|
|
1274
|
-
|
|
1317
|
+
import_semi_ui6.JsonViewer,
|
|
1275
1318
|
{
|
|
1276
1319
|
ref: JsonViewerRef,
|
|
1277
1320
|
value: getValueType(value) === "string" ? value : "",
|
|
@@ -1322,7 +1365,7 @@ function BlurInput(props) {
|
|
|
1322
1365
|
|
|
1323
1366
|
// src/components/json-schema-editor/index.tsx
|
|
1324
1367
|
function JsonSchemaEditor(props) {
|
|
1325
|
-
const { value = { type: "object" }, config = {}, onChange: onChangeProps } = props;
|
|
1368
|
+
const { value = { type: "object" }, config = {}, onChange: onChangeProps, readonly } = props;
|
|
1326
1369
|
const { propertyList, onAddProperty, onRemoveProperty, onEditProperty } = usePropertiesEdit(
|
|
1327
1370
|
value,
|
|
1328
1371
|
onChangeProps
|
|
@@ -1330,6 +1373,7 @@ function JsonSchemaEditor(props) {
|
|
|
1330
1373
|
return /* @__PURE__ */ import_react10.default.createElement(UIContainer, { className: props.className }, /* @__PURE__ */ import_react10.default.createElement(UIProperties, null, propertyList.map((_property, index) => /* @__PURE__ */ import_react10.default.createElement(
|
|
1331
1374
|
PropertyEdit,
|
|
1332
1375
|
{
|
|
1376
|
+
readonly,
|
|
1333
1377
|
key: _property.key,
|
|
1334
1378
|
value: _property,
|
|
1335
1379
|
config,
|
|
@@ -1342,8 +1386,9 @@ function JsonSchemaEditor(props) {
|
|
|
1342
1386
|
}
|
|
1343
1387
|
}
|
|
1344
1388
|
))), /* @__PURE__ */ import_react10.default.createElement(
|
|
1345
|
-
|
|
1389
|
+
import_semi_ui7.Button,
|
|
1346
1390
|
{
|
|
1391
|
+
disabled: readonly,
|
|
1347
1392
|
size: "small",
|
|
1348
1393
|
style: { marginTop: 10, marginLeft: 16 },
|
|
1349
1394
|
icon: /* @__PURE__ */ import_react10.default.createElement(import_semi_icons5.IconPlus, null),
|
|
@@ -1356,6 +1401,7 @@ function PropertyEdit(props) {
|
|
|
1356
1401
|
const {
|
|
1357
1402
|
value,
|
|
1358
1403
|
config,
|
|
1404
|
+
readonly,
|
|
1359
1405
|
$level = 0,
|
|
1360
1406
|
onChange: onChangeProps,
|
|
1361
1407
|
onRemove,
|
|
@@ -1402,6 +1448,7 @@ function PropertyEdit(props) {
|
|
|
1402
1448
|
/* @__PURE__ */ import_react10.default.createElement(UIRow, null, /* @__PURE__ */ import_react10.default.createElement(UIName, null, /* @__PURE__ */ import_react10.default.createElement(
|
|
1403
1449
|
BlurInput,
|
|
1404
1450
|
{
|
|
1451
|
+
disabled: readonly,
|
|
1405
1452
|
placeholder: config?.placeholder ?? "Input Variable Name",
|
|
1406
1453
|
size: "small",
|
|
1407
1454
|
value: name,
|
|
@@ -1411,6 +1458,7 @@ function PropertyEdit(props) {
|
|
|
1411
1458
|
TypeSelector,
|
|
1412
1459
|
{
|
|
1413
1460
|
value: typeSelectorValue,
|
|
1461
|
+
readonly,
|
|
1414
1462
|
onChange: (_value) => {
|
|
1415
1463
|
onChangeProps?.({
|
|
1416
1464
|
...value || {},
|
|
@@ -1419,14 +1467,16 @@ function PropertyEdit(props) {
|
|
|
1419
1467
|
}
|
|
1420
1468
|
}
|
|
1421
1469
|
)), /* @__PURE__ */ import_react10.default.createElement(UIRequired, null, /* @__PURE__ */ import_react10.default.createElement(
|
|
1422
|
-
|
|
1470
|
+
import_semi_ui7.Checkbox,
|
|
1423
1471
|
{
|
|
1472
|
+
disabled: readonly,
|
|
1424
1473
|
checked: isPropertyRequired,
|
|
1425
1474
|
onChange: (e) => onChange("isPropertyRequired", e.target.checked)
|
|
1426
1475
|
}
|
|
1427
1476
|
)), /* @__PURE__ */ import_react10.default.createElement(UIActions, null, /* @__PURE__ */ import_react10.default.createElement(
|
|
1428
|
-
|
|
1477
|
+
import_semi_ui7.IconButton,
|
|
1429
1478
|
{
|
|
1479
|
+
disabled: readonly,
|
|
1430
1480
|
size: "small",
|
|
1431
1481
|
theme: "borderless",
|
|
1432
1482
|
icon: expand ? /* @__PURE__ */ import_react10.default.createElement(import_semi_icons5.IconShrink, { size: "small" }) : /* @__PURE__ */ import_react10.default.createElement(import_semi_icons5.IconExpand, { size: "small" }),
|
|
@@ -1435,8 +1485,9 @@ function PropertyEdit(props) {
|
|
|
1435
1485
|
}
|
|
1436
1486
|
}
|
|
1437
1487
|
), isDrilldownObject && /* @__PURE__ */ import_react10.default.createElement(
|
|
1438
|
-
|
|
1488
|
+
import_semi_ui7.IconButton,
|
|
1439
1489
|
{
|
|
1490
|
+
disabled: readonly,
|
|
1440
1491
|
size: "small",
|
|
1441
1492
|
theme: "borderless",
|
|
1442
1493
|
icon: /* @__PURE__ */ import_react10.default.createElement(IconAddChildren, null),
|
|
@@ -1446,8 +1497,9 @@ function PropertyEdit(props) {
|
|
|
1446
1497
|
}
|
|
1447
1498
|
}
|
|
1448
1499
|
), /* @__PURE__ */ import_react10.default.createElement(
|
|
1449
|
-
|
|
1500
|
+
import_semi_ui7.IconButton,
|
|
1450
1501
|
{
|
|
1502
|
+
disabled: readonly,
|
|
1451
1503
|
size: "small",
|
|
1452
1504
|
theme: "borderless",
|
|
1453
1505
|
icon: /* @__PURE__ */ import_react10.default.createElement(import_semi_icons5.IconMinus, { size: "small" }),
|
|
@@ -1457,6 +1509,7 @@ function PropertyEdit(props) {
|
|
|
1457
1509
|
expand && /* @__PURE__ */ import_react10.default.createElement(UIExpandDetail, null, /* @__PURE__ */ import_react10.default.createElement(UILabel, null, config?.descTitle ?? "Description"), /* @__PURE__ */ import_react10.default.createElement(
|
|
1458
1510
|
BlurInput,
|
|
1459
1511
|
{
|
|
1512
|
+
disabled: readonly,
|
|
1460
1513
|
size: "small",
|
|
1461
1514
|
value: description,
|
|
1462
1515
|
onChange: (value2) => onChange("description", value2),
|
|
@@ -1476,6 +1529,7 @@ function PropertyEdit(props) {
|
|
|
1476
1529
|
), showCollapse && /* @__PURE__ */ import_react10.default.createElement(UICollapsible, { $collapse: collapse }, /* @__PURE__ */ import_react10.default.createElement(UIProperties, { $shrink: true }, propertyList.map((_property, index) => /* @__PURE__ */ import_react10.default.createElement(
|
|
1477
1530
|
PropertyEdit,
|
|
1478
1531
|
{
|
|
1532
|
+
readonly,
|
|
1479
1533
|
key: _property.key,
|
|
1480
1534
|
value: _property,
|
|
1481
1535
|
config,
|
|
@@ -1509,15 +1563,83 @@ function BatchVariableSelector(props) {
|
|
|
1509
1563
|
|
|
1510
1564
|
// src/components/dynamic-value-input/index.tsx
|
|
1511
1565
|
var import_react12 = __toESM(require("react"));
|
|
1512
|
-
var
|
|
1566
|
+
var import_editor4 = require("@flowgram.ai/editor");
|
|
1567
|
+
var import_semi_ui8 = require("@douyinfe/semi-ui");
|
|
1513
1568
|
var import_semi_icons6 = require("@douyinfe/semi-icons");
|
|
1514
1569
|
|
|
1570
|
+
// src/utils/format-legacy-refs/index.ts
|
|
1571
|
+
var import_lodash3 = require("lodash");
|
|
1572
|
+
function formatLegacyRefOnSubmit(value) {
|
|
1573
|
+
if ((0, import_lodash3.isObject)(value)) {
|
|
1574
|
+
if (isLegacyFlowRefValueSchema(value)) {
|
|
1575
|
+
return formatLegacyRefToNewRef(value);
|
|
1576
|
+
}
|
|
1577
|
+
return Object.fromEntries(
|
|
1578
|
+
Object.entries(value).map(([key, value2]) => [
|
|
1579
|
+
key,
|
|
1580
|
+
formatLegacyRefOnSubmit(value2)
|
|
1581
|
+
])
|
|
1582
|
+
);
|
|
1583
|
+
}
|
|
1584
|
+
if (Array.isArray(value)) {
|
|
1585
|
+
return value.map(formatLegacyRefOnSubmit);
|
|
1586
|
+
}
|
|
1587
|
+
return value;
|
|
1588
|
+
}
|
|
1589
|
+
function formatLegacyRefOnInit(value) {
|
|
1590
|
+
if ((0, import_lodash3.isObject)(value)) {
|
|
1591
|
+
if (isNewFlowRefValueSchema(value)) {
|
|
1592
|
+
return formatNewRefToLegacyRef(value);
|
|
1593
|
+
}
|
|
1594
|
+
return Object.fromEntries(
|
|
1595
|
+
Object.entries(value).map(([key, value2]) => [
|
|
1596
|
+
key,
|
|
1597
|
+
formatLegacyRefOnInit(value2)
|
|
1598
|
+
])
|
|
1599
|
+
);
|
|
1600
|
+
}
|
|
1601
|
+
if (Array.isArray(value)) {
|
|
1602
|
+
return value.map(formatLegacyRefOnInit);
|
|
1603
|
+
}
|
|
1604
|
+
return value;
|
|
1605
|
+
}
|
|
1606
|
+
function isLegacyFlowRefValueSchema(value) {
|
|
1607
|
+
return (0, import_lodash3.isObject)(value) && Object.keys(value).length === 2 && value.type === "ref" && typeof value.content === "string";
|
|
1608
|
+
}
|
|
1609
|
+
function isNewFlowRefValueSchema(value) {
|
|
1610
|
+
return (0, import_lodash3.isObject)(value) && Object.keys(value).length === 2 && value.type === "ref" && Array.isArray(value.content);
|
|
1611
|
+
}
|
|
1612
|
+
function formatLegacyRefToNewRef(value) {
|
|
1613
|
+
const keyPath = value.content.split(".");
|
|
1614
|
+
if (keyPath[1] === "outputs") {
|
|
1615
|
+
return {
|
|
1616
|
+
type: "ref",
|
|
1617
|
+
content: [`${keyPath[0]}.${keyPath[1]}`, ...keyPath.length > 2 ? keyPath.slice(2) : []]
|
|
1618
|
+
};
|
|
1619
|
+
}
|
|
1620
|
+
return {
|
|
1621
|
+
type: "ref",
|
|
1622
|
+
content: keyPath
|
|
1623
|
+
};
|
|
1624
|
+
}
|
|
1625
|
+
function formatNewRefToLegacyRef(value) {
|
|
1626
|
+
return {
|
|
1627
|
+
type: "ref",
|
|
1628
|
+
content: value.content.join(".")
|
|
1629
|
+
};
|
|
1630
|
+
}
|
|
1631
|
+
|
|
1515
1632
|
// src/components/dynamic-value-input/styles.tsx
|
|
1516
1633
|
var import_styled_components3 = __toESM(require("styled-components"));
|
|
1517
1634
|
var UIContainer2 = import_styled_components3.default.div`
|
|
1518
1635
|
display: flex;
|
|
1519
1636
|
align-items: center;
|
|
1520
|
-
|
|
1637
|
+
border-radius: 4px;
|
|
1638
|
+
border: 1px solid var(--semi-color-border);
|
|
1639
|
+
|
|
1640
|
+
overflow: hidden;
|
|
1641
|
+
|
|
1642
|
+
background-color: var(--semi-color-fill-0);
|
|
1521
1643
|
`;
|
|
1522
1644
|
var UIMain = import_styled_components3.default.div`
|
|
1523
1645
|
flex-grow: 1;
|
|
@@ -1528,9 +1650,29 @@ var UIMain = import_styled_components3.default.div`
|
|
|
1528
1650
|
& .semi-input-number,
|
|
1529
1651
|
& .semi-select {
|
|
1530
1652
|
width: 100%;
|
|
1653
|
+
border: none;
|
|
1654
|
+
border-radius: 0;
|
|
1655
|
+
}
|
|
1656
|
+
|
|
1657
|
+
& .semi-input-wrapper {
|
|
1658
|
+
border: none;
|
|
1659
|
+
border-radius: 0;
|
|
1660
|
+
}
|
|
1661
|
+
`;
|
|
1662
|
+
var UIType2 = import_styled_components3.default.div`
|
|
1663
|
+
border-right: 1px solid #e5e5e5;
|
|
1664
|
+
|
|
1665
|
+
& .semi-button {
|
|
1666
|
+
border-radius: 0;
|
|
1667
|
+
}
|
|
1668
|
+
`;
|
|
1669
|
+
var UITrigger = import_styled_components3.default.div`
|
|
1670
|
+
border-left: 1px solid #e5e5e5;
|
|
1671
|
+
|
|
1672
|
+
& .semi-button {
|
|
1673
|
+
border-radius: 0;
|
|
1531
1674
|
}
|
|
1532
1675
|
`;
|
|
1533
|
-
var UITrigger = import_styled_components3.default.div``;
|
|
1534
1676
|
|
|
1535
1677
|
// src/components/dynamic-value-input/index.tsx
|
|
1536
1678
|
function DynamicValueInput({
|
|
@@ -1538,15 +1680,44 @@ function DynamicValueInput({
|
|
|
1538
1680
|
onChange,
|
|
1539
1681
|
readonly,
|
|
1540
1682
|
style,
|
|
1541
|
-
schema,
|
|
1683
|
+
schema: schemaFromProps,
|
|
1542
1684
|
constantProps
|
|
1543
1685
|
}) {
|
|
1686
|
+
const available = (0, import_editor4.useScopeAvailable)();
|
|
1687
|
+
const refVariable = (0, import_react12.useMemo)(() => {
|
|
1688
|
+
if (value?.type === "ref") {
|
|
1689
|
+
return available.getByKeyPath(value.content);
|
|
1690
|
+
}
|
|
1691
|
+
}, [value, available]);
|
|
1692
|
+
const [selectSchema, setSelectSchema] = (0, import_react12.useState)(
|
|
1693
|
+
schemaFromProps || constantProps?.schema || { type: "string" }
|
|
1694
|
+
);
|
|
1695
|
+
const renderTypeSelector = () => {
|
|
1696
|
+
if (schemaFromProps) {
|
|
1697
|
+
return /* @__PURE__ */ import_react12.default.createElement(TypeSelector, { value: schemaFromProps, readonly: true });
|
|
1698
|
+
}
|
|
1699
|
+
if (value?.type === "ref") {
|
|
1700
|
+
const schema = refVariable?.type ? JsonSchemaUtils.astToSchema(refVariable?.type) : void 0;
|
|
1701
|
+
return /* @__PURE__ */ import_react12.default.createElement(TypeSelector, { value: schema, readonly: true });
|
|
1702
|
+
}
|
|
1703
|
+
return /* @__PURE__ */ import_react12.default.createElement(
|
|
1704
|
+
TypeSelector,
|
|
1705
|
+
{
|
|
1706
|
+
value: selectSchema,
|
|
1707
|
+
onChange: (_v) => setSelectSchema(_v || { type: "string" }),
|
|
1708
|
+
readonly
|
|
1709
|
+
}
|
|
1710
|
+
);
|
|
1711
|
+
};
|
|
1544
1712
|
const includeSchema = (0, import_react12.useMemo)(() => {
|
|
1545
|
-
if (
|
|
1546
|
-
return
|
|
1713
|
+
if (!schemaFromProps) {
|
|
1714
|
+
return;
|
|
1547
1715
|
}
|
|
1548
|
-
|
|
1549
|
-
|
|
1716
|
+
if (schemaFromProps?.type === "number") {
|
|
1717
|
+
return [schemaFromProps, { type: "integer" }];
|
|
1718
|
+
}
|
|
1719
|
+
return { ...schemaFromProps, extra: { ...schemaFromProps?.extra, weak: true } };
|
|
1720
|
+
}, [schemaFromProps]);
|
|
1550
1721
|
const renderMain = () => {
|
|
1551
1722
|
if (value?.type === "ref") {
|
|
1552
1723
|
return /* @__PURE__ */ import_react12.default.createElement(
|
|
@@ -1560,13 +1731,24 @@ function DynamicValueInput({
|
|
|
1560
1731
|
}
|
|
1561
1732
|
);
|
|
1562
1733
|
}
|
|
1734
|
+
const constantSchema = schemaFromProps || selectSchema || { type: "string" };
|
|
1563
1735
|
return /* @__PURE__ */ import_react12.default.createElement(
|
|
1564
1736
|
ConstantInput,
|
|
1565
1737
|
{
|
|
1566
1738
|
value: value?.content,
|
|
1567
|
-
onChange: (_v) => onChange({ type: "constant", content: _v }),
|
|
1568
|
-
schema:
|
|
1739
|
+
onChange: (_v) => onChange({ type: "constant", content: _v, schema: constantSchema }),
|
|
1740
|
+
schema: constantSchema || { type: "string" },
|
|
1569
1741
|
readonly,
|
|
1742
|
+
strategies: [...constantProps?.strategies || []],
|
|
1743
|
+
fallbackRenderer: () => /* @__PURE__ */ import_react12.default.createElement(
|
|
1744
|
+
VariableSelector,
|
|
1745
|
+
{
|
|
1746
|
+
style: { width: "100%" },
|
|
1747
|
+
onChange: (_v) => onChange(_v ? { type: "ref", content: _v } : void 0),
|
|
1748
|
+
includeSchema,
|
|
1749
|
+
readonly
|
|
1750
|
+
}
|
|
1751
|
+
),
|
|
1570
1752
|
...constantProps
|
|
1571
1753
|
}
|
|
1572
1754
|
);
|
|
@@ -1579,15 +1761,15 @@ function DynamicValueInput({
|
|
|
1579
1761
|
onChange: (_v) => onChange({ type: "ref", content: _v }),
|
|
1580
1762
|
includeSchema,
|
|
1581
1763
|
readonly,
|
|
1582
|
-
triggerRender: () => /* @__PURE__ */ import_react12.default.createElement(
|
|
1764
|
+
triggerRender: () => /* @__PURE__ */ import_react12.default.createElement(import_semi_ui8.IconButton, { disabled: readonly, size: "small", icon: /* @__PURE__ */ import_react12.default.createElement(import_semi_icons6.IconSetting, { size: "small" }) })
|
|
1583
1765
|
}
|
|
1584
1766
|
);
|
|
1585
|
-
return /* @__PURE__ */ import_react12.default.createElement(UIContainer2, { style }, /* @__PURE__ */ import_react12.default.createElement(UIMain, null, renderMain()), /* @__PURE__ */ import_react12.default.createElement(UITrigger, null, renderTrigger()));
|
|
1767
|
+
return /* @__PURE__ */ import_react12.default.createElement(UIContainer2, { style }, /* @__PURE__ */ import_react12.default.createElement(UIType2, null, renderTypeSelector()), /* @__PURE__ */ import_react12.default.createElement(UIMain, null, renderMain()), /* @__PURE__ */ import_react12.default.createElement(UITrigger, null, renderTrigger()));
|
|
1586
1768
|
}
|
|
1587
1769
|
|
|
1588
1770
|
// src/components/condition-row/index.tsx
|
|
1589
1771
|
var import_react15 = __toESM(require("react"));
|
|
1590
|
-
var
|
|
1772
|
+
var import_semi_ui10 = require("@douyinfe/semi-ui");
|
|
1591
1773
|
|
|
1592
1774
|
// src/components/condition-row/styles.tsx
|
|
1593
1775
|
var import_styled_components4 = __toESM(require("styled-components"));
|
|
@@ -1613,7 +1795,7 @@ var UIValues = import_styled_components4.default.div`
|
|
|
1613
1795
|
|
|
1614
1796
|
// src/components/condition-row/hooks/useRule.ts
|
|
1615
1797
|
var import_react13 = require("react");
|
|
1616
|
-
var
|
|
1798
|
+
var import_editor5 = require("@flowgram.ai/editor");
|
|
1617
1799
|
|
|
1618
1800
|
// src/components/condition-row/constants.ts
|
|
1619
1801
|
var rules = {
|
|
@@ -1737,71 +1919,9 @@ var opConfigs = {
|
|
|
1737
1919
|
}
|
|
1738
1920
|
};
|
|
1739
1921
|
|
|
1740
|
-
// src/utils/format-legacy-refs/index.ts
|
|
1741
|
-
var import_lodash3 = require("lodash");
|
|
1742
|
-
function formatLegacyRefOnSubmit(value) {
|
|
1743
|
-
if ((0, import_lodash3.isObject)(value)) {
|
|
1744
|
-
if (isLegacyFlowRefValueSchema(value)) {
|
|
1745
|
-
return formatLegacyRefToNewRef(value);
|
|
1746
|
-
}
|
|
1747
|
-
return Object.fromEntries(
|
|
1748
|
-
Object.entries(value).map(([key, value2]) => [
|
|
1749
|
-
key,
|
|
1750
|
-
formatLegacyRefOnSubmit(value2)
|
|
1751
|
-
])
|
|
1752
|
-
);
|
|
1753
|
-
}
|
|
1754
|
-
if (Array.isArray(value)) {
|
|
1755
|
-
return value.map(formatLegacyRefOnSubmit);
|
|
1756
|
-
}
|
|
1757
|
-
return value;
|
|
1758
|
-
}
|
|
1759
|
-
function formatLegacyRefOnInit(value) {
|
|
1760
|
-
if ((0, import_lodash3.isObject)(value)) {
|
|
1761
|
-
if (isNewFlowRefValueSchema(value)) {
|
|
1762
|
-
return formatNewRefToLegacyRef(value);
|
|
1763
|
-
}
|
|
1764
|
-
return Object.fromEntries(
|
|
1765
|
-
Object.entries(value).map(([key, value2]) => [
|
|
1766
|
-
key,
|
|
1767
|
-
formatLegacyRefOnInit(value2)
|
|
1768
|
-
])
|
|
1769
|
-
);
|
|
1770
|
-
}
|
|
1771
|
-
if (Array.isArray(value)) {
|
|
1772
|
-
return value.map(formatLegacyRefOnInit);
|
|
1773
|
-
}
|
|
1774
|
-
return value;
|
|
1775
|
-
}
|
|
1776
|
-
function isLegacyFlowRefValueSchema(value) {
|
|
1777
|
-
return (0, import_lodash3.isObject)(value) && Object.keys(value).length === 2 && value.type === "ref" && typeof value.content === "string";
|
|
1778
|
-
}
|
|
1779
|
-
function isNewFlowRefValueSchema(value) {
|
|
1780
|
-
return (0, import_lodash3.isObject)(value) && Object.keys(value).length === 2 && value.type === "ref" && Array.isArray(value.content);
|
|
1781
|
-
}
|
|
1782
|
-
function formatLegacyRefToNewRef(value) {
|
|
1783
|
-
const keyPath = value.content.split(".");
|
|
1784
|
-
if (keyPath[1] === "outputs") {
|
|
1785
|
-
return {
|
|
1786
|
-
type: "ref",
|
|
1787
|
-
content: [`${keyPath[0]}.${keyPath[1]}`, ...keyPath.length > 2 ? keyPath.slice(2) : []]
|
|
1788
|
-
};
|
|
1789
|
-
}
|
|
1790
|
-
return {
|
|
1791
|
-
type: "ref",
|
|
1792
|
-
content: keyPath
|
|
1793
|
-
};
|
|
1794
|
-
}
|
|
1795
|
-
function formatNewRefToLegacyRef(value) {
|
|
1796
|
-
return {
|
|
1797
|
-
type: "ref",
|
|
1798
|
-
content: value.content.join(".")
|
|
1799
|
-
};
|
|
1800
|
-
}
|
|
1801
|
-
|
|
1802
1922
|
// src/components/condition-row/hooks/useRule.ts
|
|
1803
1923
|
function useRule(left) {
|
|
1804
|
-
const available = (0,
|
|
1924
|
+
const available = (0, import_editor5.useScopeAvailable)();
|
|
1805
1925
|
const variable = (0, import_react13.useMemo)(() => {
|
|
1806
1926
|
if (!left) return void 0;
|
|
1807
1927
|
return available.getByKeyPath(left.content);
|
|
@@ -1816,7 +1936,7 @@ function useRule(left) {
|
|
|
1816
1936
|
|
|
1817
1937
|
// src/components/condition-row/hooks/useOp.tsx
|
|
1818
1938
|
var import_react14 = __toESM(require("react"));
|
|
1819
|
-
var
|
|
1939
|
+
var import_semi_ui9 = require("@douyinfe/semi-ui");
|
|
1820
1940
|
var import_semi_icons7 = require("@douyinfe/semi-icons");
|
|
1821
1941
|
function useOp({ rule, op, onChange }) {
|
|
1822
1942
|
const options2 = (0, import_react14.useMemo)(
|
|
@@ -1828,7 +1948,7 @@ function useOp({ rule, op, onChange }) {
|
|
|
1828
1948
|
);
|
|
1829
1949
|
const opConfig = (0, import_react14.useMemo)(() => opConfigs[op], [op]);
|
|
1830
1950
|
const renderOpSelect = () => /* @__PURE__ */ import_react14.default.createElement(
|
|
1831
|
-
|
|
1951
|
+
import_semi_ui9.Select,
|
|
1832
1952
|
{
|
|
1833
1953
|
style: { height: 22 },
|
|
1834
1954
|
size: "small",
|
|
@@ -1837,7 +1957,7 @@ function useOp({ rule, op, onChange }) {
|
|
|
1837
1957
|
onChange: (v) => {
|
|
1838
1958
|
onChange(v);
|
|
1839
1959
|
},
|
|
1840
|
-
triggerRender: ({ value }) => /* @__PURE__ */ import_react14.default.createElement(
|
|
1960
|
+
triggerRender: ({ value }) => /* @__PURE__ */ import_react14.default.createElement(import_semi_ui9.Button, { size: "small", disabled: !rule }, opConfig?.abbreviation || /* @__PURE__ */ import_react14.default.createElement(import_semi_icons7.IconChevronDownStroked, { size: "small" }))
|
|
1841
1961
|
}
|
|
1842
1962
|
);
|
|
1843
1963
|
return { renderOpSelect, opConfig };
|
|
@@ -1879,7 +1999,7 @@ function ConditionRow({ style, value, onChange, readonly }) {
|
|
|
1879
1999
|
onChange: (v) => onChange({ ...value, right: v })
|
|
1880
2000
|
}
|
|
1881
2001
|
) : /* @__PURE__ */ import_react15.default.createElement(
|
|
1882
|
-
|
|
2002
|
+
import_semi_ui10.Input,
|
|
1883
2003
|
{
|
|
1884
2004
|
size: "small",
|
|
1885
2005
|
disabled: true,
|
|
@@ -1891,17 +2011,20 @@ function ConditionRow({ style, value, onChange, readonly }) {
|
|
|
1891
2011
|
|
|
1892
2012
|
// src/components/batch-outputs/index.tsx
|
|
1893
2013
|
var import_react17 = __toESM(require("react"));
|
|
1894
|
-
var
|
|
2014
|
+
var import_semi_ui11 = require("@douyinfe/semi-ui");
|
|
1895
2015
|
var import_semi_icons8 = require("@douyinfe/semi-icons");
|
|
1896
2016
|
|
|
1897
|
-
// src/
|
|
2017
|
+
// src/hooks/use-object-list/index.tsx
|
|
1898
2018
|
var import_react16 = require("react");
|
|
2019
|
+
var import_nanoid = require("nanoid");
|
|
1899
2020
|
var import_lodash4 = require("lodash");
|
|
1900
|
-
var _id2 = 0;
|
|
1901
2021
|
function genId2() {
|
|
1902
|
-
return
|
|
2022
|
+
return (0, import_nanoid.nanoid)();
|
|
1903
2023
|
}
|
|
1904
|
-
function
|
|
2024
|
+
function useObjectList({
|
|
2025
|
+
value,
|
|
2026
|
+
onChange
|
|
2027
|
+
}) {
|
|
1905
2028
|
const [list, setList] = (0, import_react16.useState)([]);
|
|
1906
2029
|
(0, import_react16.useEffect)(() => {
|
|
1907
2030
|
setList((_prevList) => {
|
|
@@ -1911,7 +2034,7 @@ function useList({ value, onChange }) {
|
|
|
1911
2034
|
return _prevList.filter((item) => !item.key || newKeys.includes(item.key)).map((item) => ({
|
|
1912
2035
|
id: item.id,
|
|
1913
2036
|
key: item.key,
|
|
1914
|
-
value: item.key ? value?.[item.key] :
|
|
2037
|
+
value: item.key ? value?.[item.key] : item.value
|
|
1915
2038
|
})).concat(
|
|
1916
2039
|
addKeys.map((_key) => ({
|
|
1917
2040
|
id: genId2(),
|
|
@@ -1929,17 +2052,39 @@ function useList({ value, onChange }) {
|
|
|
1929
2052
|
}
|
|
1930
2053
|
]);
|
|
1931
2054
|
};
|
|
1932
|
-
const
|
|
2055
|
+
const updateValue = (itemId, value2) => {
|
|
2056
|
+
setList((prevList) => {
|
|
2057
|
+
const nextList = prevList.map((_item) => {
|
|
2058
|
+
if (_item.id === itemId) {
|
|
2059
|
+
return {
|
|
2060
|
+
..._item,
|
|
2061
|
+
value: value2
|
|
2062
|
+
};
|
|
2063
|
+
}
|
|
2064
|
+
return _item;
|
|
2065
|
+
});
|
|
2066
|
+
onChange(
|
|
2067
|
+
Object.fromEntries(
|
|
2068
|
+
nextList.filter((item) => item.key).map((item) => [item.key, item.value])
|
|
2069
|
+
)
|
|
2070
|
+
);
|
|
2071
|
+
return nextList;
|
|
2072
|
+
});
|
|
2073
|
+
};
|
|
2074
|
+
const updateKey = (itemId, key) => {
|
|
1933
2075
|
setList((prevList) => {
|
|
1934
2076
|
const nextList = prevList.map((_item) => {
|
|
1935
|
-
if (_item.id ===
|
|
1936
|
-
return
|
|
2077
|
+
if (_item.id === itemId) {
|
|
2078
|
+
return {
|
|
2079
|
+
..._item,
|
|
2080
|
+
key
|
|
2081
|
+
};
|
|
1937
2082
|
}
|
|
1938
2083
|
return _item;
|
|
1939
2084
|
});
|
|
1940
2085
|
onChange(
|
|
1941
2086
|
Object.fromEntries(
|
|
1942
|
-
nextList.filter((
|
|
2087
|
+
nextList.filter((item) => item.key).map((item) => [item.key, item.value])
|
|
1943
2088
|
)
|
|
1944
2089
|
);
|
|
1945
2090
|
return nextList;
|
|
@@ -1956,7 +2101,7 @@ function useList({ value, onChange }) {
|
|
|
1956
2101
|
return nextList;
|
|
1957
2102
|
});
|
|
1958
2103
|
};
|
|
1959
|
-
return { list, add,
|
|
2104
|
+
return { list, add, updateKey, updateValue, remove };
|
|
1960
2105
|
}
|
|
1961
2106
|
|
|
1962
2107
|
// src/components/batch-outputs/styles.tsx
|
|
@@ -1976,15 +2121,15 @@ var UIRow2 = import_styled_components5.default.div`
|
|
|
1976
2121
|
// src/components/batch-outputs/index.tsx
|
|
1977
2122
|
function BatchOutputs(props) {
|
|
1978
2123
|
const { readonly, style } = props;
|
|
1979
|
-
const { list, add,
|
|
2124
|
+
const { list, add, updateKey, updateValue, remove } = useObjectList(props);
|
|
1980
2125
|
return /* @__PURE__ */ import_react17.default.createElement("div", null, /* @__PURE__ */ import_react17.default.createElement(UIRows, { style }, list.map((item) => /* @__PURE__ */ import_react17.default.createElement(UIRow2, { key: item.id }, /* @__PURE__ */ import_react17.default.createElement(
|
|
1981
|
-
|
|
2126
|
+
import_semi_ui11.Input,
|
|
1982
2127
|
{
|
|
1983
2128
|
style: { width: 100 },
|
|
1984
2129
|
disabled: readonly,
|
|
1985
2130
|
size: "small",
|
|
1986
2131
|
value: item.key,
|
|
1987
|
-
onChange: (v) =>
|
|
2132
|
+
onChange: (v) => updateKey(item.id, v)
|
|
1988
2133
|
}
|
|
1989
2134
|
), /* @__PURE__ */ import_react17.default.createElement(
|
|
1990
2135
|
VariableSelector,
|
|
@@ -1992,23 +2137,17 @@ function BatchOutputs(props) {
|
|
|
1992
2137
|
style: { flexGrow: 1 },
|
|
1993
2138
|
readonly,
|
|
1994
2139
|
value: item.value?.content,
|
|
1995
|
-
onChange: (v) =>
|
|
1996
|
-
...item,
|
|
1997
|
-
value: {
|
|
1998
|
-
type: "ref",
|
|
1999
|
-
content: v
|
|
2000
|
-
}
|
|
2001
|
-
})
|
|
2140
|
+
onChange: (v) => updateValue(item.id, { type: "ref", content: v })
|
|
2002
2141
|
}
|
|
2003
2142
|
), /* @__PURE__ */ import_react17.default.createElement(
|
|
2004
|
-
|
|
2143
|
+
import_semi_ui11.Button,
|
|
2005
2144
|
{
|
|
2006
2145
|
disabled: readonly,
|
|
2007
2146
|
icon: /* @__PURE__ */ import_react17.default.createElement(import_semi_icons8.IconDelete, null),
|
|
2008
2147
|
size: "small",
|
|
2009
2148
|
onClick: () => remove(item.id)
|
|
2010
2149
|
}
|
|
2011
|
-
)))), /* @__PURE__ */ import_react17.default.createElement(
|
|
2150
|
+
)))), /* @__PURE__ */ import_react17.default.createElement(import_semi_ui11.Button, { disabled: readonly, icon: /* @__PURE__ */ import_react17.default.createElement(import_semi_icons8.IconPlus, null), size: "small", onClick: add }, "Add"));
|
|
2012
2151
|
}
|
|
2013
2152
|
|
|
2014
2153
|
// src/components/prompt-editor/index.tsx
|
|
@@ -2031,13 +2170,13 @@ var UIContainer4 = import_styled_components6.default.div`
|
|
|
2031
2170
|
// src/components/prompt-editor/extensions/markdown.tsx
|
|
2032
2171
|
var import_react18 = require("react");
|
|
2033
2172
|
var import_react19 = require("@coze-editor/editor/react");
|
|
2034
|
-
var
|
|
2173
|
+
var import_editor6 = require("@coze-editor/editor");
|
|
2035
2174
|
var import_view = require("@codemirror/view");
|
|
2036
2175
|
function MarkdownHighlight() {
|
|
2037
2176
|
const injector = (0, import_react19.useInjector)();
|
|
2038
2177
|
(0, import_react18.useLayoutEffect)(
|
|
2039
2178
|
() => injector.inject([
|
|
2040
|
-
|
|
2179
|
+
import_editor6.astDecorator.whole.of((cursor) => {
|
|
2041
2180
|
if (cursor.name.startsWith("ATXHeading")) {
|
|
2042
2181
|
return {
|
|
2043
2182
|
type: "className",
|
|
@@ -2099,13 +2238,13 @@ var language_support_default = LanguageSupport;
|
|
|
2099
2238
|
// src/components/prompt-editor/extensions/jinja.tsx
|
|
2100
2239
|
var import_react22 = require("react");
|
|
2101
2240
|
var import_react23 = require("@coze-editor/editor/react");
|
|
2102
|
-
var
|
|
2241
|
+
var import_editor7 = require("@coze-editor/editor");
|
|
2103
2242
|
var import_view2 = require("@codemirror/view");
|
|
2104
2243
|
function JinjaHighlight() {
|
|
2105
2244
|
const injector = (0, import_react23.useInjector)();
|
|
2106
2245
|
(0, import_react22.useLayoutEffect)(
|
|
2107
2246
|
() => injector.inject([
|
|
2108
|
-
|
|
2247
|
+
import_editor7.astDecorator.whole.of((cursor) => {
|
|
2109
2248
|
if (cursor.name === "JinjaStatementStart" || cursor.name === "JinjaStatementEnd") {
|
|
2110
2249
|
return {
|
|
2111
2250
|
type: "className",
|
|
@@ -2187,7 +2326,7 @@ var import_react30 = __toESM(require("react"));
|
|
|
2187
2326
|
|
|
2188
2327
|
// src/components/prompt-editor-with-variables/extensions/variable-tree.tsx
|
|
2189
2328
|
var import_react26 = __toESM(require("react"));
|
|
2190
|
-
var
|
|
2329
|
+
var import_semi_ui12 = require("@douyinfe/semi-ui");
|
|
2191
2330
|
var import_react27 = require("@coze-editor/editor/react");
|
|
2192
2331
|
function VariableTree() {
|
|
2193
2332
|
const [posKey, setPosKey] = (0, import_react26.useState)("");
|
|
@@ -2216,14 +2355,14 @@ function VariableTree() {
|
|
|
2216
2355
|
}, [editor, visible]);
|
|
2217
2356
|
const treeData = useVariableTree({});
|
|
2218
2357
|
return /* @__PURE__ */ import_react26.default.createElement(import_react26.default.Fragment, null, /* @__PURE__ */ import_react26.default.createElement(import_react27.Mention, { triggerCharacters: ["{", "{}", "@"], onOpenChange: handleOpenChange }), /* @__PURE__ */ import_react26.default.createElement(
|
|
2219
|
-
|
|
2358
|
+
import_semi_ui12.Popover,
|
|
2220
2359
|
{
|
|
2221
2360
|
visible,
|
|
2222
2361
|
trigger: "custom",
|
|
2223
2362
|
position: "topLeft",
|
|
2224
2363
|
rePosKey: posKey,
|
|
2225
2364
|
content: /* @__PURE__ */ import_react26.default.createElement("div", { style: { width: 300 } }, /* @__PURE__ */ import_react26.default.createElement(
|
|
2226
|
-
|
|
2365
|
+
import_semi_ui12.Tree,
|
|
2227
2366
|
{
|
|
2228
2367
|
treeData,
|
|
2229
2368
|
onSelect: (v) => {
|
|
@@ -2246,15 +2385,15 @@ function VariableTree() {
|
|
|
2246
2385
|
var import_react_dom = __toESM(require("react-dom"));
|
|
2247
2386
|
var import_react28 = __toESM(require("react"));
|
|
2248
2387
|
var import_lodash5 = require("lodash");
|
|
2249
|
-
var
|
|
2250
|
-
var
|
|
2388
|
+
var import_editor8 = require("@flowgram.ai/editor");
|
|
2389
|
+
var import_semi_ui14 = require("@douyinfe/semi-ui");
|
|
2251
2390
|
var import_semi_icons9 = require("@douyinfe/semi-icons");
|
|
2252
2391
|
var import_react29 = require("@coze-editor/editor/react");
|
|
2253
2392
|
var import_view3 = require("@codemirror/view");
|
|
2254
2393
|
|
|
2255
2394
|
// src/components/prompt-editor-with-variables/styles.tsx
|
|
2256
2395
|
var import_styled_components7 = __toESM(require("styled-components"));
|
|
2257
|
-
var
|
|
2396
|
+
var import_semi_ui13 = require("@douyinfe/semi-ui");
|
|
2258
2397
|
var UIRootTitle2 = import_styled_components7.default.div`
|
|
2259
2398
|
margin-right: 4px;
|
|
2260
2399
|
min-width: 20px;
|
|
@@ -2268,7 +2407,7 @@ var UIVarName2 = import_styled_components7.default.div`
|
|
|
2268
2407
|
text-overflow: ellipsis;
|
|
2269
2408
|
white-space: nowrap;
|
|
2270
2409
|
`;
|
|
2271
|
-
var UITag2 = (0, import_styled_components7.default)(
|
|
2410
|
+
var UITag2 = (0, import_styled_components7.default)(import_semi_ui13.Tag)`
|
|
2272
2411
|
display: inline-flex;
|
|
2273
2412
|
align-items: center;
|
|
2274
2413
|
justify-content: flex-start;
|
|
@@ -2282,7 +2421,7 @@ var UITag2 = (0, import_styled_components7.default)(import_semi_ui12.Tag)`
|
|
|
2282
2421
|
margin: 0 5px;
|
|
2283
2422
|
}
|
|
2284
2423
|
`;
|
|
2285
|
-
var
|
|
2424
|
+
var UIPopoverContent2 = import_styled_components7.default.div`
|
|
2286
2425
|
padding: 10px;
|
|
2287
2426
|
display: inline-flex;
|
|
2288
2427
|
align-items: center;
|
|
@@ -2293,7 +2432,7 @@ var UIPopoverContent = import_styled_components7.default.div`
|
|
|
2293
2432
|
var VariableTagWidget = class extends import_view3.WidgetType {
|
|
2294
2433
|
constructor({ keyPath, scope }) {
|
|
2295
2434
|
super();
|
|
2296
|
-
this.toDispose = new
|
|
2435
|
+
this.toDispose = new import_editor8.DisposableCollection();
|
|
2297
2436
|
this.renderIcon = (icon) => {
|
|
2298
2437
|
if (typeof icon === "string") {
|
|
2299
2438
|
return /* @__PURE__ */ import_react28.default.createElement("img", { style: { marginRight: 8 }, width: 12, height: 12, src: icon });
|
|
@@ -2318,9 +2457,9 @@ var VariableTagWidget = class extends import_view3.WidgetType {
|
|
|
2318
2457
|
const rootIcon = this.renderIcon(rootField?.meta.icon);
|
|
2319
2458
|
this.renderReact(
|
|
2320
2459
|
/* @__PURE__ */ import_react28.default.createElement(
|
|
2321
|
-
|
|
2460
|
+
import_semi_ui14.Popover,
|
|
2322
2461
|
{
|
|
2323
|
-
content: /* @__PURE__ */ import_react28.default.createElement(
|
|
2462
|
+
content: /* @__PURE__ */ import_react28.default.createElement(UIPopoverContent2, null, rootIcon, rootTitle, /* @__PURE__ */ import_react28.default.createElement(UIVarName2, null, v?.keyPath.slice(1).join(".")))
|
|
2324
2463
|
},
|
|
2325
2464
|
/* @__PURE__ */ import_react28.default.createElement(UITag2, { prefixIcon: rootIcon }, rootTitle, /* @__PURE__ */ import_react28.default.createElement(UIVarName2, null, v?.key))
|
|
2326
2465
|
)
|
|
@@ -2330,7 +2469,7 @@ var VariableTagWidget = class extends import_view3.WidgetType {
|
|
|
2330
2469
|
const dom = document.createElement("span");
|
|
2331
2470
|
this.rootDOM = dom;
|
|
2332
2471
|
this.toDispose.push(
|
|
2333
|
-
|
|
2472
|
+
import_editor8.Disposable.create(() => {
|
|
2334
2473
|
import_react_dom.default.unmountComponentAtNode(this.rootDOM);
|
|
2335
2474
|
})
|
|
2336
2475
|
);
|
|
@@ -2358,7 +2497,7 @@ var VariableTagWidget = class extends import_view3.WidgetType {
|
|
|
2358
2497
|
};
|
|
2359
2498
|
function VariableTagInject() {
|
|
2360
2499
|
const injector = (0, import_react29.useInjector)();
|
|
2361
|
-
const scope = (0,
|
|
2500
|
+
const scope = (0, import_editor8.useCurrentScope)();
|
|
2362
2501
|
(0, import_react28.useLayoutEffect)(() => {
|
|
2363
2502
|
const atMatcher = new import_view3.MatchDecorator({
|
|
2364
2503
|
regexp: /\{\{([^\}]+)\}\}/g,
|
|
@@ -2404,21 +2543,21 @@ var import_react34 = __toESM(require("react"));
|
|
|
2404
2543
|
|
|
2405
2544
|
// src/components/prompt-editor-with-inputs/extensions/inputs-tree.tsx
|
|
2406
2545
|
var import_react32 = __toESM(require("react"));
|
|
2407
|
-
var
|
|
2546
|
+
var import_semi_ui16 = require("@douyinfe/semi-ui");
|
|
2408
2547
|
var import_react33 = require("@coze-editor/editor/react");
|
|
2409
2548
|
|
|
2410
2549
|
// src/components/prompt-editor-with-inputs/inputs-picker.tsx
|
|
2411
2550
|
var import_react31 = __toESM(require("react"));
|
|
2412
2551
|
var import_lodash6 = require("lodash");
|
|
2413
|
-
var
|
|
2414
|
-
var
|
|
2552
|
+
var import_editor9 = require("@flowgram.ai/editor");
|
|
2553
|
+
var import_semi_ui15 = require("@douyinfe/semi-ui");
|
|
2415
2554
|
function InputsPicker({
|
|
2416
2555
|
inputsValues,
|
|
2417
2556
|
onSelect
|
|
2418
2557
|
}) {
|
|
2419
|
-
const available = (0,
|
|
2558
|
+
const available = (0, import_editor9.useScopeAvailable)();
|
|
2420
2559
|
const getArrayDrilldown = (type, depth = 1) => {
|
|
2421
|
-
if (
|
|
2560
|
+
if (import_editor9.ASTMatch.isArray(type.items)) {
|
|
2422
2561
|
return getArrayDrilldown(type.items, depth + 1);
|
|
2423
2562
|
}
|
|
2424
2563
|
return { type: type.items, depth };
|
|
@@ -2426,12 +2565,12 @@ function InputsPicker({
|
|
|
2426
2565
|
const renderVariable = (variable, keyPath) => {
|
|
2427
2566
|
let type = variable?.type;
|
|
2428
2567
|
let children;
|
|
2429
|
-
if (
|
|
2568
|
+
if (import_editor9.ASTMatch.isObject(type)) {
|
|
2430
2569
|
children = (type.properties || []).map((_property) => renderVariable(_property, [...keyPath, _property.key])).filter(Boolean);
|
|
2431
2570
|
}
|
|
2432
|
-
if (
|
|
2571
|
+
if (import_editor9.ASTMatch.isArray(type)) {
|
|
2433
2572
|
const drilldown = getArrayDrilldown(type);
|
|
2434
|
-
if (
|
|
2573
|
+
if (import_editor9.ASTMatch.isObject(drilldown.type)) {
|
|
2435
2574
|
children = (drilldown.type.properties || []).map(
|
|
2436
2575
|
(_property) => renderVariable(_property, [
|
|
2437
2576
|
...keyPath,
|
|
@@ -2451,7 +2590,7 @@ function InputsPicker({
|
|
|
2451
2590
|
};
|
|
2452
2591
|
const treeData = (0, import_react31.useMemo)(
|
|
2453
2592
|
() => Object.entries(inputsValues).map(([key, value]) => {
|
|
2454
|
-
if (value
|
|
2593
|
+
if (value?.type === "ref") {
|
|
2455
2594
|
const variable = available.getByKeyPath(value.content || []);
|
|
2456
2595
|
if (variable) {
|
|
2457
2596
|
return renderVariable(variable, [key]);
|
|
@@ -2465,7 +2604,7 @@ function InputsPicker({
|
|
|
2465
2604
|
}),
|
|
2466
2605
|
[]
|
|
2467
2606
|
);
|
|
2468
|
-
return /* @__PURE__ */ import_react31.default.createElement(
|
|
2607
|
+
return /* @__PURE__ */ import_react31.default.createElement(import_semi_ui15.Tree, { treeData, onSelect: (v) => onSelect(v) });
|
|
2469
2608
|
}
|
|
2470
2609
|
|
|
2471
2610
|
// src/components/prompt-editor-with-inputs/extensions/inputs-tree.tsx
|
|
@@ -2495,7 +2634,7 @@ function InputsTree({ inputsValues }) {
|
|
|
2495
2634
|
}
|
|
2496
2635
|
}, [editor, visible]);
|
|
2497
2636
|
return /* @__PURE__ */ import_react32.default.createElement(import_react32.default.Fragment, null, /* @__PURE__ */ import_react32.default.createElement(import_react33.Mention, { triggerCharacters: ["{", "{}", "@"], onOpenChange: handleOpenChange }), /* @__PURE__ */ import_react32.default.createElement(
|
|
2498
|
-
|
|
2637
|
+
import_semi_ui16.Popover,
|
|
2499
2638
|
{
|
|
2500
2639
|
visible,
|
|
2501
2640
|
trigger: "custom",
|
|
@@ -2780,19 +2919,21 @@ import_preset_code3.themes.register("light", lightTheme);
|
|
|
2780
2919
|
|
|
2781
2920
|
// src/components/code-editor/language-features.ts
|
|
2782
2921
|
var import_preset_code4 = require("@coze-editor/editor/preset-code");
|
|
2922
|
+
var import_language_typescript = require("@coze-editor/editor/language-typescript");
|
|
2783
2923
|
var import_language_shell = require("@coze-editor/editor/language-shell");
|
|
2784
2924
|
var import_language_python = require("@coze-editor/editor/language-python");
|
|
2785
2925
|
var import_language_json = require("@coze-editor/editor/language-json");
|
|
2786
|
-
var
|
|
2926
|
+
var import_editor10 = require("@coze-editor/editor");
|
|
2787
2927
|
import_preset_code4.languages.register("python", import_language_python.python);
|
|
2928
|
+
import_preset_code4.languages.register("typescript", import_language_typescript.typescript);
|
|
2929
|
+
import_preset_code4.languages.register("shell", import_language_shell.shell);
|
|
2788
2930
|
import_preset_code4.languages.register("json", {
|
|
2789
2931
|
// mixLanguages is used to solve the problem that interpolation also uses parentheses, which causes incorrect highlighting
|
|
2790
|
-
language: (0,
|
|
2932
|
+
language: (0, import_editor10.mixLanguages)({
|
|
2791
2933
|
outerLanguage: import_language_json.json.language
|
|
2792
2934
|
}),
|
|
2793
2935
|
languageService: import_language_json.json.languageService
|
|
2794
2936
|
});
|
|
2795
|
-
import_preset_code4.languages.register("shell", import_language_shell.shell);
|
|
2796
2937
|
|
|
2797
2938
|
// src/components/code-editor/index.tsx
|
|
2798
2939
|
var OriginCodeEditor = (0, import_react36.createRenderer)(import_preset_code5.default, [
|
|
@@ -2848,7 +2989,7 @@ var import_preset_code6 = require("@coze-editor/editor/preset-code");
|
|
|
2848
2989
|
|
|
2849
2990
|
// src/components/json-editor-with-variables/extensions/variable-tree.tsx
|
|
2850
2991
|
var import_react37 = __toESM(require("react"));
|
|
2851
|
-
var
|
|
2992
|
+
var import_semi_ui17 = require("@douyinfe/semi-ui");
|
|
2852
2993
|
var import_react38 = require("@coze-editor/editor/react");
|
|
2853
2994
|
function VariableTree2() {
|
|
2854
2995
|
const [posKey, setPosKey] = (0, import_react37.useState)("");
|
|
@@ -2877,14 +3018,14 @@ function VariableTree2() {
|
|
|
2877
3018
|
}, [editor, visible]);
|
|
2878
3019
|
const treeData = useVariableTree({});
|
|
2879
3020
|
return /* @__PURE__ */ import_react37.default.createElement(import_react37.default.Fragment, null, /* @__PURE__ */ import_react37.default.createElement(import_react38.Mention, { triggerCharacters: ["@"], onOpenChange: handleOpenChange }), /* @__PURE__ */ import_react37.default.createElement(
|
|
2880
|
-
|
|
3021
|
+
import_semi_ui17.Popover,
|
|
2881
3022
|
{
|
|
2882
3023
|
visible,
|
|
2883
3024
|
trigger: "custom",
|
|
2884
3025
|
position: "topLeft",
|
|
2885
3026
|
rePosKey: posKey,
|
|
2886
3027
|
content: /* @__PURE__ */ import_react37.default.createElement("div", { style: { width: 300 } }, /* @__PURE__ */ import_react37.default.createElement(
|
|
2887
|
-
|
|
3028
|
+
import_semi_ui17.Tree,
|
|
2888
3029
|
{
|
|
2889
3030
|
treeData,
|
|
2890
3031
|
onSelect: (v) => {
|
|
@@ -2907,15 +3048,15 @@ function VariableTree2() {
|
|
|
2907
3048
|
var import_react39 = __toESM(require("react"));
|
|
2908
3049
|
var import_client = require("react-dom/client");
|
|
2909
3050
|
var import_lodash7 = require("lodash");
|
|
2910
|
-
var
|
|
2911
|
-
var
|
|
3051
|
+
var import_editor11 = require("@flowgram.ai/editor");
|
|
3052
|
+
var import_semi_ui19 = require("@douyinfe/semi-ui");
|
|
2912
3053
|
var import_semi_icons10 = require("@douyinfe/semi-icons");
|
|
2913
3054
|
var import_react40 = require("@coze-editor/editor/react");
|
|
2914
3055
|
var import_view5 = require("@codemirror/view");
|
|
2915
3056
|
|
|
2916
3057
|
// src/components/json-editor-with-variables/styles.tsx
|
|
2917
3058
|
var import_styled_components8 = __toESM(require("styled-components"));
|
|
2918
|
-
var
|
|
3059
|
+
var import_semi_ui18 = require("@douyinfe/semi-ui");
|
|
2919
3060
|
var UIRootTitle3 = import_styled_components8.default.div`
|
|
2920
3061
|
margin-right: 4px;
|
|
2921
3062
|
min-width: 20px;
|
|
@@ -2929,7 +3070,7 @@ var UIVarName3 = import_styled_components8.default.div`
|
|
|
2929
3070
|
text-overflow: ellipsis;
|
|
2930
3071
|
white-space: nowrap;
|
|
2931
3072
|
`;
|
|
2932
|
-
var UITag3 = (0, import_styled_components8.default)(
|
|
3073
|
+
var UITag3 = (0, import_styled_components8.default)(import_semi_ui18.Tag)`
|
|
2933
3074
|
display: inline-flex;
|
|
2934
3075
|
align-items: center;
|
|
2935
3076
|
justify-content: flex-start;
|
|
@@ -2943,7 +3084,7 @@ var UITag3 = (0, import_styled_components8.default)(import_semi_ui17.Tag)`
|
|
|
2943
3084
|
margin: 0 5px;
|
|
2944
3085
|
}
|
|
2945
3086
|
`;
|
|
2946
|
-
var
|
|
3087
|
+
var UIPopoverContent3 = import_styled_components8.default.div`
|
|
2947
3088
|
padding: 10px;
|
|
2948
3089
|
display: inline-flex;
|
|
2949
3090
|
align-items: center;
|
|
@@ -2954,7 +3095,7 @@ var UIPopoverContent2 = import_styled_components8.default.div`
|
|
|
2954
3095
|
var VariableTagWidget2 = class extends import_view5.WidgetType {
|
|
2955
3096
|
constructor({ keyPath, scope }) {
|
|
2956
3097
|
super();
|
|
2957
|
-
this.toDispose = new
|
|
3098
|
+
this.toDispose = new import_editor11.DisposableCollection();
|
|
2958
3099
|
this.renderIcon = (icon) => {
|
|
2959
3100
|
if (typeof icon === "string") {
|
|
2960
3101
|
return /* @__PURE__ */ import_react39.default.createElement("img", { style: { marginRight: 8 }, width: 12, height: 12, src: icon });
|
|
@@ -2976,9 +3117,9 @@ var VariableTagWidget2 = class extends import_view5.WidgetType {
|
|
|
2976
3117
|
const rootIcon = this.renderIcon(rootField?.meta.icon);
|
|
2977
3118
|
this.root.render(
|
|
2978
3119
|
/* @__PURE__ */ import_react39.default.createElement(
|
|
2979
|
-
|
|
3120
|
+
import_semi_ui19.Popover,
|
|
2980
3121
|
{
|
|
2981
|
-
content: /* @__PURE__ */ import_react39.default.createElement(
|
|
3122
|
+
content: /* @__PURE__ */ import_react39.default.createElement(UIPopoverContent3, null, rootIcon, rootTitle, /* @__PURE__ */ import_react39.default.createElement(UIVarName3, null, v?.keyPath.slice(1).join(".")))
|
|
2982
3123
|
},
|
|
2983
3124
|
/* @__PURE__ */ import_react39.default.createElement(UITag3, { prefixIcon: rootIcon }, rootTitle, /* @__PURE__ */ import_react39.default.createElement(UIVarName3, null, v?.key))
|
|
2984
3125
|
)
|
|
@@ -2988,7 +3129,7 @@ var VariableTagWidget2 = class extends import_view5.WidgetType {
|
|
|
2988
3129
|
const dom = document.createElement("span");
|
|
2989
3130
|
this.root = (0, import_client.createRoot)(dom);
|
|
2990
3131
|
this.toDispose.push(
|
|
2991
|
-
|
|
3132
|
+
import_editor11.Disposable.create(() => {
|
|
2992
3133
|
this.root.unmount();
|
|
2993
3134
|
})
|
|
2994
3135
|
);
|
|
@@ -3016,7 +3157,7 @@ var VariableTagWidget2 = class extends import_view5.WidgetType {
|
|
|
3016
3157
|
};
|
|
3017
3158
|
function VariableTagInject2() {
|
|
3018
3159
|
const injector = (0, import_react40.useInjector)();
|
|
3019
|
-
const scope = (0,
|
|
3160
|
+
const scope = (0, import_editor11.useCurrentScope)();
|
|
3020
3161
|
(0, import_react39.useLayoutEffect)(() => {
|
|
3021
3162
|
const atMatcher = new import_view5.MatchDecorator({
|
|
3022
3163
|
regexp: /\{\{([^\}]+)\}\}/g,
|
|
@@ -3098,30 +3239,88 @@ function JsonEditorWithVariables(props) {
|
|
|
3098
3239
|
);
|
|
3099
3240
|
}
|
|
3100
3241
|
|
|
3242
|
+
// src/components/inputs-values/index.tsx
|
|
3243
|
+
var import_react42 = __toESM(require("react"));
|
|
3244
|
+
var import_semi_ui20 = require("@douyinfe/semi-ui");
|
|
3245
|
+
var import_semi_icons11 = require("@douyinfe/semi-icons");
|
|
3246
|
+
|
|
3247
|
+
// src/components/inputs-values/styles.tsx
|
|
3248
|
+
var import_styled_components9 = __toESM(require("styled-components"));
|
|
3249
|
+
var UIRows2 = import_styled_components9.default.div`
|
|
3250
|
+
display: flex;
|
|
3251
|
+
flex-direction: column;
|
|
3252
|
+
gap: 10px;
|
|
3253
|
+
margin-bottom: 10px;
|
|
3254
|
+
`;
|
|
3255
|
+
var UIRow3 = import_styled_components9.default.div`
|
|
3256
|
+
display: flex;
|
|
3257
|
+
align-items: center;
|
|
3258
|
+
gap: 5px;
|
|
3259
|
+
`;
|
|
3260
|
+
|
|
3261
|
+
// src/components/inputs-values/index.tsx
|
|
3262
|
+
function InputsValues({ value, onChange, style, readonly, constantProps }) {
|
|
3263
|
+
const { list, updateKey, updateValue, remove, add } = useObjectList({
|
|
3264
|
+
value,
|
|
3265
|
+
onChange
|
|
3266
|
+
});
|
|
3267
|
+
return /* @__PURE__ */ import_react42.default.createElement("div", null, /* @__PURE__ */ import_react42.default.createElement(UIRows2, { style }, list.map((item) => /* @__PURE__ */ import_react42.default.createElement(UIRow3, { key: item.id }, /* @__PURE__ */ import_react42.default.createElement(
|
|
3268
|
+
import_semi_ui20.Input,
|
|
3269
|
+
{
|
|
3270
|
+
style: { width: 100, minWidth: 100, maxWidth: 100 },
|
|
3271
|
+
disabled: readonly,
|
|
3272
|
+
size: "small",
|
|
3273
|
+
value: item.key,
|
|
3274
|
+
onChange: (v) => updateKey(item.id, v)
|
|
3275
|
+
}
|
|
3276
|
+
), /* @__PURE__ */ import_react42.default.createElement(
|
|
3277
|
+
DynamicValueInput,
|
|
3278
|
+
{
|
|
3279
|
+
style: { flexGrow: 1 },
|
|
3280
|
+
readonly,
|
|
3281
|
+
value: item.value,
|
|
3282
|
+
onChange: (v) => updateValue(item.id, v),
|
|
3283
|
+
constantProps: {
|
|
3284
|
+
...constantProps,
|
|
3285
|
+
strategies: [...constantProps?.strategies || []]
|
|
3286
|
+
}
|
|
3287
|
+
}
|
|
3288
|
+
), /* @__PURE__ */ import_react42.default.createElement(
|
|
3289
|
+
import_semi_ui20.IconButton,
|
|
3290
|
+
{
|
|
3291
|
+
disabled: readonly,
|
|
3292
|
+
theme: "borderless",
|
|
3293
|
+
icon: /* @__PURE__ */ import_react42.default.createElement(import_semi_icons11.IconDelete, { size: "small" }),
|
|
3294
|
+
size: "small",
|
|
3295
|
+
onClick: () => remove(item.id)
|
|
3296
|
+
}
|
|
3297
|
+
)))), /* @__PURE__ */ import_react42.default.createElement(import_semi_ui20.Button, { disabled: readonly, icon: /* @__PURE__ */ import_react42.default.createElement(import_semi_icons11.IconPlus, null), size: "small", onClick: add }, "Add"));
|
|
3298
|
+
}
|
|
3299
|
+
|
|
3101
3300
|
// src/effects/provide-batch-input/index.ts
|
|
3102
|
-
var
|
|
3103
|
-
var provideBatchInputEffect = (0,
|
|
3301
|
+
var import_editor12 = require("@flowgram.ai/editor");
|
|
3302
|
+
var provideBatchInputEffect = (0, import_editor12.createEffectFromVariableProvider)({
|
|
3104
3303
|
private: true,
|
|
3105
3304
|
parse: (value, ctx) => [
|
|
3106
|
-
|
|
3305
|
+
import_editor12.ASTFactory.createVariableDeclaration({
|
|
3107
3306
|
key: `${ctx.node.id}_locals`,
|
|
3108
3307
|
meta: {
|
|
3109
|
-
title: (0,
|
|
3308
|
+
title: (0, import_editor12.getNodeForm)(ctx.node)?.getValueIn("title"),
|
|
3110
3309
|
icon: ctx.node.getNodeRegistry().info?.icon
|
|
3111
3310
|
},
|
|
3112
|
-
type:
|
|
3311
|
+
type: import_editor12.ASTFactory.createObject({
|
|
3113
3312
|
properties: [
|
|
3114
|
-
|
|
3313
|
+
import_editor12.ASTFactory.createProperty({
|
|
3115
3314
|
key: "item",
|
|
3116
|
-
initializer:
|
|
3117
|
-
enumerateFor:
|
|
3315
|
+
initializer: import_editor12.ASTFactory.createEnumerateExpression({
|
|
3316
|
+
enumerateFor: import_editor12.ASTFactory.createKeyPathExpression({
|
|
3118
3317
|
keyPath: value.content || []
|
|
3119
3318
|
})
|
|
3120
3319
|
})
|
|
3121
3320
|
}),
|
|
3122
|
-
|
|
3321
|
+
import_editor12.ASTFactory.createProperty({
|
|
3123
3322
|
key: "index",
|
|
3124
|
-
type:
|
|
3323
|
+
type: import_editor12.ASTFactory.createNumber()
|
|
3125
3324
|
})
|
|
3126
3325
|
]
|
|
3127
3326
|
})
|
|
@@ -3129,32 +3328,6 @@ var provideBatchInputEffect = (0, import_editor11.createEffectFromVariableProvid
|
|
|
3129
3328
|
]
|
|
3130
3329
|
});
|
|
3131
3330
|
|
|
3132
|
-
// src/effects/provide-batch-outputs/index.ts
|
|
3133
|
-
var import_editor12 = require("@flowgram.ai/editor");
|
|
3134
|
-
var provideBatchOutputsEffect = (0, import_editor12.createEffectFromVariableProvider)({
|
|
3135
|
-
parse: (value, ctx) => [
|
|
3136
|
-
import_editor12.ASTFactory.createVariableDeclaration({
|
|
3137
|
-
key: `${ctx.node.id}`,
|
|
3138
|
-
meta: {
|
|
3139
|
-
title: (0, import_editor12.getNodeForm)(ctx.node)?.getValueIn("title"),
|
|
3140
|
-
icon: ctx.node.getNodeRegistry().info?.icon
|
|
3141
|
-
},
|
|
3142
|
-
type: import_editor12.ASTFactory.createObject({
|
|
3143
|
-
properties: Object.entries(value).map(
|
|
3144
|
-
([_key, value2]) => import_editor12.ASTFactory.createProperty({
|
|
3145
|
-
key: _key,
|
|
3146
|
-
initializer: import_editor12.ASTFactory.createWrapArrayExpression({
|
|
3147
|
-
wrapFor: import_editor12.ASTFactory.createKeyPathExpression({
|
|
3148
|
-
keyPath: value2.content || []
|
|
3149
|
-
})
|
|
3150
|
-
})
|
|
3151
|
-
})
|
|
3152
|
-
)
|
|
3153
|
-
})
|
|
3154
|
-
})
|
|
3155
|
-
]
|
|
3156
|
-
});
|
|
3157
|
-
|
|
3158
3331
|
// src/effects/auto-rename-ref/index.ts
|
|
3159
3332
|
var import_lodash8 = require("lodash");
|
|
3160
3333
|
var import_editor13 = require("@flowgram.ai/editor");
|
|
@@ -3281,7 +3454,7 @@ var syncVariableTitle = [
|
|
|
3281
3454
|
|
|
3282
3455
|
// src/form-plugins/batch-outputs-plugin/index.ts
|
|
3283
3456
|
var import_editor16 = require("@flowgram.ai/editor");
|
|
3284
|
-
var
|
|
3457
|
+
var provideBatchOutputsEffect = (0, import_editor16.createEffectFromVariableProvider)({
|
|
3285
3458
|
parse: (value, ctx) => [
|
|
3286
3459
|
import_editor16.ASTFactory.createVariableDeclaration({
|
|
3287
3460
|
key: `${ctx.node.id}`,
|
|
@@ -3308,7 +3481,7 @@ var createBatchOutputsFormPlugin = (0, import_editor16.defineFormPluginCreator)(
|
|
|
3308
3481
|
name: "batch-outputs-plugin",
|
|
3309
3482
|
onSetupFormMeta({ mergeEffect }, { outputKey }) {
|
|
3310
3483
|
mergeEffect({
|
|
3311
|
-
[outputKey]:
|
|
3484
|
+
[outputKey]: provideBatchOutputsEffect
|
|
3312
3485
|
});
|
|
3313
3486
|
},
|
|
3314
3487
|
onInit(ctx, { outputKey }) {
|
|
@@ -3344,6 +3517,81 @@ var createBatchOutputsFormPlugin = (0, import_editor16.defineFormPluginCreator)(
|
|
|
3344
3517
|
});
|
|
3345
3518
|
}
|
|
3346
3519
|
});
|
|
3520
|
+
|
|
3521
|
+
// src/form-plugins/infer-inputs-plugin/index.ts
|
|
3522
|
+
var import_lodash9 = require("lodash");
|
|
3523
|
+
var import_editor17 = require("@flowgram.ai/editor");
|
|
3524
|
+
var createInferInputsPlugin = (0, import_editor17.defineFormPluginCreator)({
|
|
3525
|
+
onSetupFormMeta({ addFormatOnSubmit }, { sourceKey, targetKey, scope }) {
|
|
3526
|
+
if (!sourceKey || !targetKey) {
|
|
3527
|
+
return;
|
|
3528
|
+
}
|
|
3529
|
+
addFormatOnSubmit((formData, ctx) => {
|
|
3530
|
+
(0, import_lodash9.set)(
|
|
3531
|
+
formData,
|
|
3532
|
+
targetKey,
|
|
3533
|
+
infer(
|
|
3534
|
+
(0, import_lodash9.get)(formData, sourceKey),
|
|
3535
|
+
scope === "private" ? (0, import_editor17.getNodePrivateScope)(ctx.node) : (0, import_editor17.getNodeScope)(ctx.node)
|
|
3536
|
+
)
|
|
3537
|
+
);
|
|
3538
|
+
return formData;
|
|
3539
|
+
});
|
|
3540
|
+
}
|
|
3541
|
+
});
|
|
3542
|
+
function isRef2(value) {
|
|
3543
|
+
return value?.type === "ref" && Array.isArray(value?.content) && typeof value?.content[0] === "string";
|
|
3544
|
+
}
|
|
3545
|
+
function isTemplate2(value) {
|
|
3546
|
+
return value?.type === "template" && typeof value?.content === "string";
|
|
3547
|
+
}
|
|
3548
|
+
function isConstant(value) {
|
|
3549
|
+
return value?.type === "constant" && typeof value?.content !== "undefined";
|
|
3550
|
+
}
|
|
3551
|
+
var infer = (values, scope) => {
|
|
3552
|
+
if (typeof values === "object") {
|
|
3553
|
+
if (isConstant(values)) {
|
|
3554
|
+
if (values?.schema) {
|
|
3555
|
+
return values.schema;
|
|
3556
|
+
}
|
|
3557
|
+
if (typeof values.content === "string") {
|
|
3558
|
+
return {
|
|
3559
|
+
type: "string"
|
|
3560
|
+
};
|
|
3561
|
+
}
|
|
3562
|
+
if (typeof values.content === "number") {
|
|
3563
|
+
return {
|
|
3564
|
+
type: "number"
|
|
3565
|
+
};
|
|
3566
|
+
}
|
|
3567
|
+
if (typeof values.content === "boolean") {
|
|
3568
|
+
return {
|
|
3569
|
+
type: "boolean"
|
|
3570
|
+
};
|
|
3571
|
+
}
|
|
3572
|
+
}
|
|
3573
|
+
if (isRef2(values)) {
|
|
3574
|
+
const variable = scope.available.getByKeyPath(values?.content);
|
|
3575
|
+
const schema = variable?.type ? JsonSchemaUtils.astToSchema(variable?.type) : void 0;
|
|
3576
|
+
return schema;
|
|
3577
|
+
}
|
|
3578
|
+
if (isTemplate2(values)) {
|
|
3579
|
+
return {
|
|
3580
|
+
type: "string"
|
|
3581
|
+
};
|
|
3582
|
+
}
|
|
3583
|
+
return {
|
|
3584
|
+
type: "object",
|
|
3585
|
+
properties: Object.keys(values).reduce((acc, key) => {
|
|
3586
|
+
const schema = infer(values[key], scope);
|
|
3587
|
+
if (schema) {
|
|
3588
|
+
acc[key] = schema;
|
|
3589
|
+
}
|
|
3590
|
+
return acc;
|
|
3591
|
+
}, {})
|
|
3592
|
+
};
|
|
3593
|
+
}
|
|
3594
|
+
};
|
|
3347
3595
|
// Annotate the CommonJS export names for ESM import in node:
|
|
3348
3596
|
0 && (module.exports = {
|
|
3349
3597
|
ArrayIcons,
|
|
@@ -3353,6 +3601,7 @@ var createBatchOutputsFormPlugin = (0, import_editor16.defineFormPluginCreator)(
|
|
|
3353
3601
|
ConditionRow,
|
|
3354
3602
|
ConstantInput,
|
|
3355
3603
|
DynamicValueInput,
|
|
3604
|
+
InputsValues,
|
|
3356
3605
|
JsonEditorWithVariables,
|
|
3357
3606
|
JsonSchemaEditor,
|
|
3358
3607
|
JsonSchemaUtils,
|
|
@@ -3364,6 +3613,7 @@ var createBatchOutputsFormPlugin = (0, import_editor16.defineFormPluginCreator)(
|
|
|
3364
3613
|
VariableTypeIcons,
|
|
3365
3614
|
autoRenameRefEffect,
|
|
3366
3615
|
createBatchOutputsFormPlugin,
|
|
3616
|
+
createInferInputsPlugin,
|
|
3367
3617
|
formatLegacyRefOnInit,
|
|
3368
3618
|
formatLegacyRefOnSubmit,
|
|
3369
3619
|
formatLegacyRefToNewRef,
|