@flowgram.ai/form-materials 0.4.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/index.js +723 -401
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.mts +132 -29
- package/dist/index.d.ts +132 -29
- package/dist/index.js +839 -510
- package/dist/index.js.map +1 -1
- package/package.json +6 -5
- package/src/components/batch-outputs/index.tsx +3 -2
- package/src/components/dynamic-value-input/hooks.ts +1 -1
- package/src/components/dynamic-value-input/index.tsx +1 -1
- package/src/components/dynamic-value-input/styles.tsx +14 -4
- package/src/components/index.ts +2 -0
- package/src/components/inputs-values/index.tsx +3 -3
- package/src/components/inputs-values/styles.tsx +1 -1
- package/src/components/inputs-values-tree/hooks/use-child-list.tsx +71 -0
- package/src/components/inputs-values-tree/index.tsx +56 -0
- package/src/components/inputs-values-tree/row.tsx +163 -0
- package/src/components/inputs-values-tree/styles.tsx +128 -0
- package/src/components/inputs-values-tree/types.ts +21 -0
- package/src/components/json-schema-editor/default-value.tsx +1 -3
- package/src/components/json-schema-editor/hooks.tsx +13 -2
- package/src/components/json-schema-editor/index.tsx +17 -57
- package/src/components/json-schema-editor/styles.tsx +12 -55
- package/src/components/json-schema-editor/types.ts +0 -1
- package/src/components/prompt-editor/index.tsx +10 -3
- package/src/effects/auto-rename-ref/index.ts +7 -54
- package/src/form-plugins/infer-inputs-plugin/index.ts +3 -75
- package/src/hooks/use-object-list/index.tsx +34 -6
- package/src/plugins/json-schema-preset/manager.ts +1 -0
- package/src/plugins/json-schema-preset/type-definition/string.tsx +18 -9
- package/src/shared/flow-value/index.ts +6 -0
- package/src/shared/flow-value/schema.ts +38 -0
- package/src/shared/flow-value/utils.ts +201 -0
- package/src/shared/index.ts +1 -0
- package/src/typings/flow-value/index.ts +2 -0
- package/src/components/json-schema-editor/components/blur-input.tsx +0 -27
- package/src/plugins/disable-declaration-plugin/config.json +0 -5
- package/src/plugins/json-schema-preset/config.json +0 -9
- /package/src/components/{inputs-values/components/blur-input.tsx → blur-input/index.tsx} +0 -0
package/dist/esm/index.js
CHANGED
|
@@ -92,16 +92,169 @@ function createInjectMaterial(Component, params) {
|
|
|
92
92
|
return InjectComponent;
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
+
// src/shared/flow-value/utils.ts
|
|
96
|
+
import { isArray, isObject as isObject2, isPlainObject, uniq } from "lodash";
|
|
97
|
+
import { JsonSchemaUtils } from "@flowgram.ai/json-schema";
|
|
98
|
+
|
|
99
|
+
// src/shared/flow-value/schema.ts
|
|
100
|
+
import z from "zod";
|
|
101
|
+
var extraSchema = z.object({
|
|
102
|
+
index: z.number().optional()
|
|
103
|
+
}).optional();
|
|
104
|
+
var constantSchema = z.object({
|
|
105
|
+
type: z.literal("constant"),
|
|
106
|
+
content: z.union([z.string(), z.number(), z.boolean()]).optional(),
|
|
107
|
+
schema: z.any().optional(),
|
|
108
|
+
extra: extraSchema
|
|
109
|
+
});
|
|
110
|
+
var refSchema = z.object({
|
|
111
|
+
type: z.literal("ref"),
|
|
112
|
+
content: z.array(z.string()).optional(),
|
|
113
|
+
extra: extraSchema
|
|
114
|
+
});
|
|
115
|
+
var expressionSchema = z.object({
|
|
116
|
+
type: z.literal("expression"),
|
|
117
|
+
content: z.string().optional(),
|
|
118
|
+
extra: extraSchema
|
|
119
|
+
});
|
|
120
|
+
var templateSchema = z.object({
|
|
121
|
+
type: z.literal("template"),
|
|
122
|
+
content: z.string().optional(),
|
|
123
|
+
extra: extraSchema
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
// src/shared/flow-value/utils.ts
|
|
127
|
+
var FlowValueUtils;
|
|
128
|
+
((FlowValueUtils2) => {
|
|
129
|
+
function isConstant(value) {
|
|
130
|
+
return constantSchema.safeParse(value).success;
|
|
131
|
+
}
|
|
132
|
+
FlowValueUtils2.isConstant = isConstant;
|
|
133
|
+
function isRef(value) {
|
|
134
|
+
return refSchema.safeParse(value).success;
|
|
135
|
+
}
|
|
136
|
+
FlowValueUtils2.isRef = isRef;
|
|
137
|
+
function isExpression(value) {
|
|
138
|
+
return expressionSchema.safeParse(value).success;
|
|
139
|
+
}
|
|
140
|
+
FlowValueUtils2.isExpression = isExpression;
|
|
141
|
+
function isTemplate(value) {
|
|
142
|
+
return templateSchema.safeParse(value).success;
|
|
143
|
+
}
|
|
144
|
+
FlowValueUtils2.isTemplate = isTemplate;
|
|
145
|
+
function isConstantOrRef(value) {
|
|
146
|
+
return isConstant(value) || isRef(value);
|
|
147
|
+
}
|
|
148
|
+
FlowValueUtils2.isConstantOrRef = isConstantOrRef;
|
|
149
|
+
function isFlowValue(value) {
|
|
150
|
+
return isConstant(value) || isRef(value) || isExpression(value) || isTemplate(value);
|
|
151
|
+
}
|
|
152
|
+
FlowValueUtils2.isFlowValue = isFlowValue;
|
|
153
|
+
function* traverse(value, options) {
|
|
154
|
+
const { includeTypes = ["ref", "template"], path = "" } = options;
|
|
155
|
+
if (isPlainObject(value)) {
|
|
156
|
+
if (isRef(value) && includeTypes.includes("ref")) {
|
|
157
|
+
yield { value, path };
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
if (isTemplate(value) && includeTypes.includes("template")) {
|
|
161
|
+
yield { value, path };
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
if (isExpression(value) && includeTypes.includes("expression")) {
|
|
165
|
+
yield { value, path };
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
if (isConstant(value) && includeTypes.includes("constant")) {
|
|
169
|
+
yield { value, path };
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
for (const [_key, _value] of Object.entries(value)) {
|
|
173
|
+
yield* traverse(_value, { ...options, path: `${path}.${_key}` });
|
|
174
|
+
}
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
if (isArray(value)) {
|
|
178
|
+
for (const [_idx, _value] of value.entries()) {
|
|
179
|
+
yield* traverse(_value, { ...options, path: `${path}[${_idx}]` });
|
|
180
|
+
}
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
FlowValueUtils2.traverse = traverse;
|
|
186
|
+
function getTemplateKeyPaths2(value) {
|
|
187
|
+
const keyPathReg = /{{(.*?)}}/g;
|
|
188
|
+
return uniq(value.content?.match(keyPathReg) || []).map(
|
|
189
|
+
(_keyPath) => _keyPath.slice(2, -2).split(".")
|
|
190
|
+
);
|
|
191
|
+
}
|
|
192
|
+
FlowValueUtils2.getTemplateKeyPaths = getTemplateKeyPaths2;
|
|
193
|
+
function inferConstantJsonSchema(value) {
|
|
194
|
+
if (value?.schema) {
|
|
195
|
+
return value.schema;
|
|
196
|
+
}
|
|
197
|
+
if (typeof value.content === "string") {
|
|
198
|
+
return {
|
|
199
|
+
type: "string"
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
if (typeof value.content === "number") {
|
|
203
|
+
return {
|
|
204
|
+
type: "number"
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
if (typeof value.content === "boolean") {
|
|
208
|
+
return {
|
|
209
|
+
type: "boolean"
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
if (isObject2(value.content)) {
|
|
213
|
+
return {
|
|
214
|
+
type: "object"
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
return void 0;
|
|
218
|
+
}
|
|
219
|
+
FlowValueUtils2.inferConstantJsonSchema = inferConstantJsonSchema;
|
|
220
|
+
function inferJsonSchema(values, scope) {
|
|
221
|
+
if (isPlainObject(values)) {
|
|
222
|
+
if (isConstant(values)) {
|
|
223
|
+
return inferConstantJsonSchema(values);
|
|
224
|
+
}
|
|
225
|
+
if (isRef(values)) {
|
|
226
|
+
const variable = scope.available.getByKeyPath(values?.content);
|
|
227
|
+
const schema = variable?.type ? JsonSchemaUtils.astToSchema(variable?.type) : void 0;
|
|
228
|
+
return schema;
|
|
229
|
+
}
|
|
230
|
+
if (isTemplate(values)) {
|
|
231
|
+
return { type: "string" };
|
|
232
|
+
}
|
|
233
|
+
return {
|
|
234
|
+
type: "object",
|
|
235
|
+
properties: Object.keys(values).reduce((acc, key) => {
|
|
236
|
+
const schema = inferJsonSchema(values[key], scope);
|
|
237
|
+
if (schema) {
|
|
238
|
+
acc[key] = schema;
|
|
239
|
+
}
|
|
240
|
+
return acc;
|
|
241
|
+
}, {})
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
FlowValueUtils2.inferJsonSchema = inferJsonSchema;
|
|
246
|
+
})(FlowValueUtils || (FlowValueUtils = {}));
|
|
247
|
+
|
|
95
248
|
// src/components/variable-selector/use-variable-tree.tsx
|
|
96
249
|
import React11, { useCallback } from "react";
|
|
97
|
-
import { JsonSchemaUtils as
|
|
250
|
+
import { JsonSchemaUtils as JsonSchemaUtils3 } from "@flowgram.ai/json-schema";
|
|
98
251
|
import { ASTMatch as ASTMatch2, useAvailableVariables } from "@flowgram.ai/editor";
|
|
99
252
|
import { Icon } from "@douyinfe/semi-ui";
|
|
100
253
|
|
|
101
254
|
// src/plugins/json-schema-preset/index.tsx
|
|
102
255
|
import React10 from "react";
|
|
103
256
|
import {
|
|
104
|
-
JsonSchemaUtils,
|
|
257
|
+
JsonSchemaUtils as JsonSchemaUtils2,
|
|
105
258
|
useTypeManager as useOriginTypeManager,
|
|
106
259
|
TypePresetProvider as OriginTypePresetProvider
|
|
107
260
|
} from "@flowgram.ai/json-schema";
|
|
@@ -112,14 +265,23 @@ import { jsonSchemaTypeManager } from "@flowgram.ai/json-schema";
|
|
|
112
265
|
// src/plugins/json-schema-preset/type-definition/string.tsx
|
|
113
266
|
import React2 from "react";
|
|
114
267
|
import { I18n } from "@flowgram.ai/editor";
|
|
115
|
-
import { Input } from "@douyinfe/semi-ui";
|
|
268
|
+
import { Input, TextArea } from "@douyinfe/semi-ui";
|
|
116
269
|
var stringRegistry = {
|
|
117
270
|
type: "string",
|
|
118
|
-
ConstantRenderer: (props) => /* @__PURE__ */ React2.createElement(
|
|
119
|
-
|
|
271
|
+
ConstantRenderer: (props) => props?.enableMultiLineStr ? /* @__PURE__ */ React2.createElement(
|
|
272
|
+
TextArea,
|
|
120
273
|
{
|
|
274
|
+
autosize: true,
|
|
275
|
+
rows: 1,
|
|
121
276
|
placeholder: I18n.t("Please Input String"),
|
|
277
|
+
disabled: props.readonly,
|
|
278
|
+
...props
|
|
279
|
+
}
|
|
280
|
+
) : /* @__PURE__ */ React2.createElement(
|
|
281
|
+
Input,
|
|
282
|
+
{
|
|
122
283
|
size: "small",
|
|
284
|
+
placeholder: I18n.t("Please Input String"),
|
|
123
285
|
disabled: props.readonly,
|
|
124
286
|
...props
|
|
125
287
|
}
|
|
@@ -663,7 +825,7 @@ function useVariableTree(params) {
|
|
|
663
825
|
}
|
|
664
826
|
return variable.meta.icon;
|
|
665
827
|
}
|
|
666
|
-
const schema =
|
|
828
|
+
const schema = JsonSchemaUtils3.astToSchema(variable.type, { drilldownObject: false });
|
|
667
829
|
return /* @__PURE__ */ React11.createElement(Icon, { size: "small", svg: typeManager.getDisplayIcon(schema || {}) });
|
|
668
830
|
}, []);
|
|
669
831
|
const renderVariable = (variable, parentFields = []) => {
|
|
@@ -677,8 +839,8 @@ function useVariableTree(params) {
|
|
|
677
839
|
}
|
|
678
840
|
const keyPath = [...parentFields.map((_field) => _field.key), variable.key];
|
|
679
841
|
const key = keyPath.join(".");
|
|
680
|
-
const isSchemaInclude = includeSchema ?
|
|
681
|
-
const isSchemaExclude = excludeSchema ?
|
|
842
|
+
const isSchemaInclude = includeSchema ? JsonSchemaUtils3.isASTMatchSchema(type, includeSchema) : true;
|
|
843
|
+
const isSchemaExclude = excludeSchema ? JsonSchemaUtils3.isASTMatchSchema(type, excludeSchema) : false;
|
|
682
844
|
const isCustomSkip = customSkip ? customSkip(variable) : false;
|
|
683
845
|
const isMetaDisabled = variable.meta?.disabled;
|
|
684
846
|
const isSchemaMatch = isSchemaInclude && !isSchemaExclude && !isCustomSkip && !isMetaDisabled;
|
|
@@ -921,8 +1083,29 @@ import {
|
|
|
921
1083
|
IconMinus
|
|
922
1084
|
} from "@douyinfe/semi-icons";
|
|
923
1085
|
|
|
1086
|
+
// src/components/blur-input/index.tsx
|
|
1087
|
+
import React14, { useEffect as useEffect2, useState } from "react";
|
|
1088
|
+
import Input2 from "@douyinfe/semi-ui/lib/es/input";
|
|
1089
|
+
function BlurInput(props) {
|
|
1090
|
+
const [value, setValue] = useState("");
|
|
1091
|
+
useEffect2(() => {
|
|
1092
|
+
setValue(props.value);
|
|
1093
|
+
}, [props.value]);
|
|
1094
|
+
return /* @__PURE__ */ React14.createElement(
|
|
1095
|
+
Input2,
|
|
1096
|
+
{
|
|
1097
|
+
...props,
|
|
1098
|
+
value,
|
|
1099
|
+
onChange: (value2) => {
|
|
1100
|
+
setValue(value2);
|
|
1101
|
+
},
|
|
1102
|
+
onBlur: (e) => props.onChange?.(value, e)
|
|
1103
|
+
}
|
|
1104
|
+
);
|
|
1105
|
+
}
|
|
1106
|
+
|
|
924
1107
|
// src/components/json-schema-editor/styles.tsx
|
|
925
|
-
import
|
|
1108
|
+
import React15 from "react";
|
|
926
1109
|
import styled3, { css as css2 } from "styled-components";
|
|
927
1110
|
import Icon3 from "@douyinfe/semi-icons";
|
|
928
1111
|
var UIContainer = styled3.div`
|
|
@@ -951,32 +1134,30 @@ var UILabel = styled3.div`
|
|
|
951
1134
|
font-weight: 400;
|
|
952
1135
|
margin-bottom: 2px;
|
|
953
1136
|
`;
|
|
954
|
-
var
|
|
1137
|
+
var UITreeItems = styled3.div`
|
|
955
1138
|
display: grid;
|
|
956
1139
|
grid-template-columns: auto 1fr;
|
|
957
1140
|
|
|
958
1141
|
${({ $shrink }) => $shrink && css2`
|
|
959
|
-
padding-left:
|
|
1142
|
+
padding-left: 3px;
|
|
960
1143
|
margin-top: 10px;
|
|
961
1144
|
`}
|
|
962
1145
|
`;
|
|
963
|
-
var
|
|
1146
|
+
var UITreeItemLeft = styled3.div`
|
|
964
1147
|
grid-column: 1;
|
|
965
1148
|
position: relative;
|
|
966
1149
|
width: 16px;
|
|
967
1150
|
|
|
968
|
-
${({ $showLine, $isLast, $
|
|
969
|
-
let height = "100%";
|
|
970
|
-
|
|
971
|
-
height = "24px";
|
|
972
|
-
}
|
|
1151
|
+
${({ $showLine, $isLast, $showCollapse }) => {
|
|
1152
|
+
let height = $isLast ? "24px" : "100%";
|
|
1153
|
+
let width = $showCollapse ? "12px" : "30px";
|
|
973
1154
|
return $showLine && css2`
|
|
974
1155
|
&::before {
|
|
975
1156
|
/* 竖线 */
|
|
976
1157
|
content: '';
|
|
977
1158
|
height: ${height};
|
|
978
1159
|
position: absolute;
|
|
979
|
-
left: -
|
|
1160
|
+
left: -14px;
|
|
980
1161
|
top: -16px;
|
|
981
1162
|
width: 1px;
|
|
982
1163
|
background: #d9d9d9;
|
|
@@ -987,9 +1168,9 @@ var UIPropertyLeft = styled3.div`
|
|
|
987
1168
|
/* 横线 */
|
|
988
1169
|
content: '';
|
|
989
1170
|
position: absolute;
|
|
990
|
-
left: -
|
|
1171
|
+
left: -14px; // 横线起点和竖线对齐
|
|
991
1172
|
top: 8px; // 跟随你的行高调整
|
|
992
|
-
width:
|
|
1173
|
+
width: ${width}; // 横线长度
|
|
993
1174
|
height: 1px;
|
|
994
1175
|
background: #d9d9d9;
|
|
995
1176
|
display: block;
|
|
@@ -997,7 +1178,7 @@ var UIPropertyLeft = styled3.div`
|
|
|
997
1178
|
`;
|
|
998
1179
|
}}
|
|
999
1180
|
`;
|
|
1000
|
-
var
|
|
1181
|
+
var UITreeItemRight = styled3.div`
|
|
1001
1182
|
grid-column: 2;
|
|
1002
1183
|
margin-bottom: 10px;
|
|
1003
1184
|
|
|
@@ -1005,35 +1186,11 @@ var UIPropertyRight = styled3.div`
|
|
|
1005
1186
|
margin-bottom: 0px;
|
|
1006
1187
|
}
|
|
1007
1188
|
`;
|
|
1008
|
-
var
|
|
1189
|
+
var UITreeItemMain = styled3.div`
|
|
1009
1190
|
display: flex;
|
|
1010
1191
|
flex-direction: column;
|
|
1011
1192
|
gap: 10px;
|
|
1012
1193
|
position: relative;
|
|
1013
|
-
|
|
1014
|
-
${({ $expand, type, $collapse, $showCollapse }) => {
|
|
1015
|
-
const beforeElement = `
|
|
1016
|
-
&::before {
|
|
1017
|
-
/* \u7AD6\u7EBF */
|
|
1018
|
-
content: '';
|
|
1019
|
-
height: 100%;
|
|
1020
|
-
position: absolute;
|
|
1021
|
-
left: -12px;
|
|
1022
|
-
top: 18px;
|
|
1023
|
-
width: 1px;
|
|
1024
|
-
background: #d9d9d9;
|
|
1025
|
-
display: block;
|
|
1026
|
-
}`;
|
|
1027
|
-
return $expand && css2`
|
|
1028
|
-
background-color: #f5f5f5;
|
|
1029
|
-
padding: 10px;
|
|
1030
|
-
border-radius: 4px;
|
|
1031
|
-
|
|
1032
|
-
${$showCollapse && $collapse && (type === "array" || type === "object") && css2`
|
|
1033
|
-
${beforeElement}
|
|
1034
|
-
`}
|
|
1035
|
-
`;
|
|
1036
|
-
}}
|
|
1037
1194
|
`;
|
|
1038
1195
|
var UICollapsible = styled3.div`
|
|
1039
1196
|
display: none;
|
|
@@ -1050,7 +1207,7 @@ var UIRequired = styled3.div``;
|
|
|
1050
1207
|
var UIActions = styled3.div`
|
|
1051
1208
|
white-space: nowrap;
|
|
1052
1209
|
`;
|
|
1053
|
-
var iconAddChildrenSvg = /* @__PURE__ */
|
|
1210
|
+
var iconAddChildrenSvg = /* @__PURE__ */ React15.createElement(
|
|
1054
1211
|
"svg",
|
|
1055
1212
|
{
|
|
1056
1213
|
className: "icon-icon icon-icon-coz_add_node ",
|
|
@@ -1060,7 +1217,7 @@ var iconAddChildrenSvg = /* @__PURE__ */ React14.createElement(
|
|
|
1060
1217
|
fill: "currentColor",
|
|
1061
1218
|
xmlns: "http://www.w3.org/2000/svg"
|
|
1062
1219
|
},
|
|
1063
|
-
/* @__PURE__ */
|
|
1220
|
+
/* @__PURE__ */ React15.createElement(
|
|
1064
1221
|
"path",
|
|
1065
1222
|
{
|
|
1066
1223
|
fillRule: "evenodd",
|
|
@@ -1068,9 +1225,9 @@ var iconAddChildrenSvg = /* @__PURE__ */ React14.createElement(
|
|
|
1068
1225
|
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"
|
|
1069
1226
|
}
|
|
1070
1227
|
),
|
|
1071
|
-
/* @__PURE__ */
|
|
1228
|
+
/* @__PURE__ */ React15.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" })
|
|
1072
1229
|
);
|
|
1073
|
-
var IconAddChildren = () => /* @__PURE__ */
|
|
1230
|
+
var IconAddChildren = () => /* @__PURE__ */ React15.createElement(Icon3, { size: "small", svg: iconAddChildrenSvg });
|
|
1074
1231
|
var DefaultValueWrapper = styled3.div`
|
|
1075
1232
|
margin: 0;
|
|
1076
1233
|
`;
|
|
@@ -1085,7 +1242,7 @@ var ConstantInputWrapper = styled3.div`
|
|
|
1085
1242
|
`;
|
|
1086
1243
|
|
|
1087
1244
|
// src/components/json-schema-editor/hooks.tsx
|
|
1088
|
-
import { useEffect as
|
|
1245
|
+
import { useEffect as useEffect3, useRef as useRef2, useState as useState2 } from "react";
|
|
1089
1246
|
import { difference, omit } from "lodash";
|
|
1090
1247
|
import { produce } from "immer";
|
|
1091
1248
|
import { useTypeManager as useTypeManager2 } from "@flowgram.ai/json-schema";
|
|
@@ -1097,8 +1254,15 @@ function usePropertiesEdit(value, onChange) {
|
|
|
1097
1254
|
const typeManager = useTypeManager2();
|
|
1098
1255
|
const drilldownSchema = typeManager.getPropertiesParent(value || {});
|
|
1099
1256
|
const canAddField = typeManager.canAddField(value || {});
|
|
1100
|
-
const [propertyList, setPropertyList] =
|
|
1101
|
-
|
|
1257
|
+
const [propertyList, setPropertyList] = useState2([]);
|
|
1258
|
+
const effectVersion = useRef2(0);
|
|
1259
|
+
const changeVersion = useRef2(0);
|
|
1260
|
+
useEffect3(() => {
|
|
1261
|
+
effectVersion.current = effectVersion.current + 1;
|
|
1262
|
+
if (effectVersion.current === changeVersion.current) {
|
|
1263
|
+
return;
|
|
1264
|
+
}
|
|
1265
|
+
effectVersion.current = changeVersion.current;
|
|
1102
1266
|
setPropertyList((_list) => {
|
|
1103
1267
|
const newNames = Object.entries(drilldownSchema?.properties || {}).sort(([, a], [, b]) => (a.extra?.index ?? 0) - (b.extra?.index ?? 0)).map(([key]) => key);
|
|
1104
1268
|
const oldNames = _list.map((item) => item.name).filter(Boolean);
|
|
@@ -1107,7 +1271,7 @@ function usePropertiesEdit(value, onChange) {
|
|
|
1107
1271
|
key: item.key,
|
|
1108
1272
|
name: item.name,
|
|
1109
1273
|
isPropertyRequired: drilldownSchema?.required?.includes(item.name || "") || false,
|
|
1110
|
-
...item
|
|
1274
|
+
...drilldownSchema?.properties?.[item.name || ""] || item || {}
|
|
1111
1275
|
})).concat(
|
|
1112
1276
|
addNames.map((_name) => ({
|
|
1113
1277
|
key: genId(),
|
|
@@ -1119,6 +1283,7 @@ function usePropertiesEdit(value, onChange) {
|
|
|
1119
1283
|
});
|
|
1120
1284
|
}, [drilldownSchema]);
|
|
1121
1285
|
const updatePropertyList = (updater) => {
|
|
1286
|
+
changeVersion.current = changeVersion.current + 1;
|
|
1122
1287
|
setPropertyList((_list) => {
|
|
1123
1288
|
const next = updater(_list);
|
|
1124
1289
|
const nextProperties = {};
|
|
@@ -1159,7 +1324,7 @@ function usePropertiesEdit(value, onChange) {
|
|
|
1159
1324
|
(_list) => _list.map((_property) => _property.key === key ? nextValue : _property)
|
|
1160
1325
|
);
|
|
1161
1326
|
};
|
|
1162
|
-
|
|
1327
|
+
useEffect3(() => {
|
|
1163
1328
|
if (!canAddField) {
|
|
1164
1329
|
setPropertyList([]);
|
|
1165
1330
|
}
|
|
@@ -1174,12 +1339,12 @@ function usePropertiesEdit(value, onChange) {
|
|
|
1174
1339
|
}
|
|
1175
1340
|
|
|
1176
1341
|
// src/components/json-schema-editor/default-value.tsx
|
|
1177
|
-
import
|
|
1342
|
+
import React17 from "react";
|
|
1178
1343
|
import { I18n as I18n8 } from "@flowgram.ai/editor";
|
|
1179
1344
|
|
|
1180
1345
|
// src/components/constant-input/index.tsx
|
|
1181
|
-
import
|
|
1182
|
-
import { Input as
|
|
1346
|
+
import React16, { useMemo as useMemo3 } from "react";
|
|
1347
|
+
import { Input as Input3 } from "@douyinfe/semi-ui";
|
|
1183
1348
|
function ConstantInput(props) {
|
|
1184
1349
|
const { value, onChange, schema, strategies, fallbackRenderer, readonly, ...rest } = props;
|
|
1185
1350
|
const typeManager = useTypeManager();
|
|
@@ -1192,53 +1357,33 @@ function ConstantInput(props) {
|
|
|
1192
1357
|
}, [strategies, schema]);
|
|
1193
1358
|
if (!Renderer2) {
|
|
1194
1359
|
if (fallbackRenderer) {
|
|
1195
|
-
return
|
|
1360
|
+
return React16.createElement(fallbackRenderer, {
|
|
1196
1361
|
value,
|
|
1197
1362
|
onChange,
|
|
1198
1363
|
readonly,
|
|
1199
1364
|
...rest
|
|
1200
1365
|
});
|
|
1201
1366
|
}
|
|
1202
|
-
return /* @__PURE__ */
|
|
1367
|
+
return /* @__PURE__ */ React16.createElement(Input3, { size: "small", disabled: true, placeholder: "Unsupported type" });
|
|
1203
1368
|
}
|
|
1204
|
-
return /* @__PURE__ */
|
|
1369
|
+
return /* @__PURE__ */ React16.createElement(Renderer2, { value, onChange, readonly, ...rest });
|
|
1205
1370
|
}
|
|
1206
1371
|
|
|
1207
1372
|
// src/components/json-schema-editor/default-value.tsx
|
|
1208
1373
|
function DefaultValue(props) {
|
|
1209
1374
|
const { value, schema, onChange, placeholder } = props;
|
|
1210
|
-
return /* @__PURE__ */
|
|
1375
|
+
return /* @__PURE__ */ React17.createElement(ConstantInputWrapper, null, /* @__PURE__ */ React17.createElement(
|
|
1211
1376
|
ConstantInput,
|
|
1212
1377
|
{
|
|
1213
1378
|
value,
|
|
1214
1379
|
onChange: (_v) => onChange(_v),
|
|
1215
1380
|
schema: schema || { type: "string" },
|
|
1216
|
-
placeholder: placeholder ?? I18n8.t("Default value if parameter is not provided")
|
|
1381
|
+
placeholder: placeholder ?? I18n8.t("Default value if parameter is not provided"),
|
|
1382
|
+
enableMultiLineStr: true
|
|
1217
1383
|
}
|
|
1218
1384
|
));
|
|
1219
1385
|
}
|
|
1220
1386
|
|
|
1221
|
-
// src/components/json-schema-editor/components/blur-input.tsx
|
|
1222
|
-
import React17, { useEffect as useEffect3, useState as useState2 } from "react";
|
|
1223
|
-
import Input3 from "@douyinfe/semi-ui/lib/es/input";
|
|
1224
|
-
function BlurInput(props) {
|
|
1225
|
-
const [value, setValue] = useState2("");
|
|
1226
|
-
useEffect3(() => {
|
|
1227
|
-
setValue(props.value);
|
|
1228
|
-
}, [props.value]);
|
|
1229
|
-
return /* @__PURE__ */ React17.createElement(
|
|
1230
|
-
Input3,
|
|
1231
|
-
{
|
|
1232
|
-
...props,
|
|
1233
|
-
value,
|
|
1234
|
-
onChange: (value2) => {
|
|
1235
|
-
setValue(value2);
|
|
1236
|
-
},
|
|
1237
|
-
onBlur: (e) => props.onChange?.(value, e)
|
|
1238
|
-
}
|
|
1239
|
-
);
|
|
1240
|
-
}
|
|
1241
|
-
|
|
1242
1387
|
// src/components/json-schema-editor/index.tsx
|
|
1243
1388
|
var DEFAULT = { type: "object" };
|
|
1244
1389
|
function JsonSchemaEditor(props) {
|
|
@@ -1247,14 +1392,13 @@ function JsonSchemaEditor(props) {
|
|
|
1247
1392
|
value,
|
|
1248
1393
|
onChangeProps
|
|
1249
1394
|
);
|
|
1250
|
-
return /* @__PURE__ */ React18.createElement(UIContainer, { className: props.className }, /* @__PURE__ */ React18.createElement(
|
|
1395
|
+
return /* @__PURE__ */ React18.createElement(UIContainer, { className: props.className }, /* @__PURE__ */ React18.createElement(UITreeItems, null, propertyList.map((_property) => /* @__PURE__ */ React18.createElement(
|
|
1251
1396
|
PropertyEdit,
|
|
1252
1397
|
{
|
|
1253
1398
|
readonly,
|
|
1254
1399
|
key: _property.key,
|
|
1255
1400
|
value: _property,
|
|
1256
1401
|
config,
|
|
1257
|
-
$index: index,
|
|
1258
1402
|
onChange: (_v) => {
|
|
1259
1403
|
onEditProperty(_property.key, _v);
|
|
1260
1404
|
},
|
|
@@ -1275,20 +1419,7 @@ function JsonSchemaEditor(props) {
|
|
|
1275
1419
|
));
|
|
1276
1420
|
}
|
|
1277
1421
|
function PropertyEdit(props) {
|
|
1278
|
-
const {
|
|
1279
|
-
value,
|
|
1280
|
-
config,
|
|
1281
|
-
readonly,
|
|
1282
|
-
$level = 0,
|
|
1283
|
-
onChange: onChangeProps,
|
|
1284
|
-
onRemove,
|
|
1285
|
-
$index,
|
|
1286
|
-
$isFirst,
|
|
1287
|
-
$isLast,
|
|
1288
|
-
$parentExpand = false,
|
|
1289
|
-
$parentType = "",
|
|
1290
|
-
$showLine
|
|
1291
|
-
} = props;
|
|
1422
|
+
const { value, config, readonly, $level = 0, onChange: onChangeProps, onRemove, $isLast } = props;
|
|
1292
1423
|
const [expand, setExpand] = useState3(false);
|
|
1293
1424
|
const [collapse, setCollapse] = useState3(false);
|
|
1294
1425
|
const { name, type, items, default: defaultValue, description, isPropertyRequired } = value || {};
|
|
@@ -1301,109 +1432,84 @@ function PropertyEdit(props) {
|
|
|
1301
1432
|
});
|
|
1302
1433
|
};
|
|
1303
1434
|
const showCollapse = canAddField && propertyList.length > 0;
|
|
1304
|
-
return /* @__PURE__ */ React18.createElement(React18.Fragment, null, /* @__PURE__ */ React18.createElement(
|
|
1305
|
-
|
|
1306
|
-
{
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
type
|
|
1324
|
-
},
|
|
1325
|
-
/* @__PURE__ */ React18.createElement(UIRow, null, /* @__PURE__ */ React18.createElement(UIName, null, /* @__PURE__ */ React18.createElement(
|
|
1326
|
-
BlurInput,
|
|
1327
|
-
{
|
|
1328
|
-
disabled: readonly,
|
|
1329
|
-
placeholder: config?.placeholder ?? "Input Variable Name",
|
|
1330
|
-
size: "small",
|
|
1331
|
-
value: name,
|
|
1332
|
-
onChange: (value2) => onChange("name", value2)
|
|
1333
|
-
}
|
|
1334
|
-
)), /* @__PURE__ */ React18.createElement(UIType, null, /* @__PURE__ */ React18.createElement(
|
|
1335
|
-
InjectTypeSelector,
|
|
1336
|
-
{
|
|
1337
|
-
value: typeSelectorValue,
|
|
1338
|
-
readonly,
|
|
1339
|
-
onChange: (_value) => {
|
|
1340
|
-
onChangeProps?.({
|
|
1341
|
-
...value || {},
|
|
1342
|
-
..._value
|
|
1343
|
-
});
|
|
1344
|
-
}
|
|
1345
|
-
}
|
|
1346
|
-
)), /* @__PURE__ */ React18.createElement(UIRequired, null, /* @__PURE__ */ React18.createElement(
|
|
1347
|
-
Checkbox,
|
|
1348
|
-
{
|
|
1349
|
-
disabled: readonly,
|
|
1350
|
-
checked: isPropertyRequired,
|
|
1351
|
-
onChange: (e) => onChange("isPropertyRequired", e.target.checked)
|
|
1352
|
-
}
|
|
1353
|
-
)), /* @__PURE__ */ React18.createElement(UIActions, null, /* @__PURE__ */ React18.createElement(
|
|
1354
|
-
IconButton2,
|
|
1355
|
-
{
|
|
1356
|
-
disabled: readonly,
|
|
1357
|
-
size: "small",
|
|
1358
|
-
theme: "borderless",
|
|
1359
|
-
icon: expand ? /* @__PURE__ */ React18.createElement(IconShrink, { size: "small" }) : /* @__PURE__ */ React18.createElement(IconExpand, { size: "small" }),
|
|
1360
|
-
onClick: () => {
|
|
1361
|
-
setExpand((_expand) => !_expand);
|
|
1362
|
-
}
|
|
1363
|
-
}
|
|
1364
|
-
), canAddField && /* @__PURE__ */ React18.createElement(
|
|
1365
|
-
IconButton2,
|
|
1366
|
-
{
|
|
1367
|
-
disabled: readonly,
|
|
1368
|
-
size: "small",
|
|
1369
|
-
theme: "borderless",
|
|
1370
|
-
icon: /* @__PURE__ */ React18.createElement(IconAddChildren, null),
|
|
1371
|
-
onClick: () => {
|
|
1372
|
-
onAddProperty();
|
|
1373
|
-
setCollapse(true);
|
|
1374
|
-
}
|
|
1375
|
-
}
|
|
1376
|
-
), /* @__PURE__ */ React18.createElement(
|
|
1377
|
-
IconButton2,
|
|
1378
|
-
{
|
|
1379
|
-
disabled: readonly,
|
|
1380
|
-
size: "small",
|
|
1381
|
-
theme: "borderless",
|
|
1382
|
-
icon: /* @__PURE__ */ React18.createElement(IconMinus, { size: "small" }),
|
|
1383
|
-
onClick: onRemove
|
|
1435
|
+
return /* @__PURE__ */ React18.createElement(React18.Fragment, null, /* @__PURE__ */ React18.createElement(UITreeItemLeft, { $isLast, $showLine: $level > 0, $showCollapse: showCollapse }, showCollapse && /* @__PURE__ */ React18.createElement(UICollapseTrigger, { onClick: () => setCollapse((_collapse) => !_collapse) }, collapse ? /* @__PURE__ */ React18.createElement(IconChevronDown, { size: "small" }) : /* @__PURE__ */ React18.createElement(IconChevronRight, { size: "small" }))), /* @__PURE__ */ React18.createElement(UITreeItemRight, null, /* @__PURE__ */ React18.createElement(UITreeItemMain, null, /* @__PURE__ */ React18.createElement(UIRow, null, /* @__PURE__ */ React18.createElement(UIName, null, /* @__PURE__ */ React18.createElement(
|
|
1436
|
+
BlurInput,
|
|
1437
|
+
{
|
|
1438
|
+
disabled: readonly,
|
|
1439
|
+
placeholder: config?.placeholder ?? "Input Variable Name",
|
|
1440
|
+
size: "small",
|
|
1441
|
+
value: name,
|
|
1442
|
+
onChange: (value2) => onChange("name", value2)
|
|
1443
|
+
}
|
|
1444
|
+
)), /* @__PURE__ */ React18.createElement(UIType, null, /* @__PURE__ */ React18.createElement(
|
|
1445
|
+
InjectTypeSelector,
|
|
1446
|
+
{
|
|
1447
|
+
value: typeSelectorValue,
|
|
1448
|
+
readonly,
|
|
1449
|
+
onChange: (_value) => {
|
|
1450
|
+
onChangeProps?.({
|
|
1451
|
+
...value || {},
|
|
1452
|
+
..._value
|
|
1453
|
+
});
|
|
1384
1454
|
}
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1455
|
+
}
|
|
1456
|
+
)), /* @__PURE__ */ React18.createElement(UIRequired, null, /* @__PURE__ */ React18.createElement(
|
|
1457
|
+
Checkbox,
|
|
1458
|
+
{
|
|
1459
|
+
disabled: readonly,
|
|
1460
|
+
checked: isPropertyRequired,
|
|
1461
|
+
onChange: (e) => onChange("isPropertyRequired", e.target.checked)
|
|
1462
|
+
}
|
|
1463
|
+
)), /* @__PURE__ */ React18.createElement(UIActions, null, /* @__PURE__ */ React18.createElement(
|
|
1464
|
+
IconButton2,
|
|
1465
|
+
{
|
|
1466
|
+
disabled: readonly,
|
|
1467
|
+
size: "small",
|
|
1468
|
+
theme: "borderless",
|
|
1469
|
+
icon: expand ? /* @__PURE__ */ React18.createElement(IconShrink, { size: "small" }) : /* @__PURE__ */ React18.createElement(IconExpand, { size: "small" }),
|
|
1470
|
+
onClick: () => {
|
|
1471
|
+
setExpand((_expand) => !_expand);
|
|
1394
1472
|
}
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1473
|
+
}
|
|
1474
|
+
), canAddField && /* @__PURE__ */ React18.createElement(
|
|
1475
|
+
IconButton2,
|
|
1476
|
+
{
|
|
1477
|
+
disabled: readonly,
|
|
1478
|
+
size: "small",
|
|
1479
|
+
theme: "borderless",
|
|
1480
|
+
icon: /* @__PURE__ */ React18.createElement(IconAddChildren, null),
|
|
1481
|
+
onClick: () => {
|
|
1482
|
+
onAddProperty();
|
|
1483
|
+
setCollapse(true);
|
|
1404
1484
|
}
|
|
1405
|
-
|
|
1406
|
-
),
|
|
1485
|
+
}
|
|
1486
|
+
), /* @__PURE__ */ React18.createElement(
|
|
1487
|
+
IconButton2,
|
|
1488
|
+
{
|
|
1489
|
+
disabled: readonly,
|
|
1490
|
+
size: "small",
|
|
1491
|
+
theme: "borderless",
|
|
1492
|
+
icon: /* @__PURE__ */ React18.createElement(IconMinus, { size: "small" }),
|
|
1493
|
+
onClick: onRemove
|
|
1494
|
+
}
|
|
1495
|
+
))), expand && /* @__PURE__ */ React18.createElement(UIExpandDetail, null, /* @__PURE__ */ React18.createElement(UILabel, null, config?.descTitle ?? I18n9.t("Description")), /* @__PURE__ */ React18.createElement(
|
|
1496
|
+
BlurInput,
|
|
1497
|
+
{
|
|
1498
|
+
disabled: readonly,
|
|
1499
|
+
size: "small",
|
|
1500
|
+
value: description,
|
|
1501
|
+
onChange: (value2) => onChange("description", value2),
|
|
1502
|
+
placeholder: config?.descPlaceholder ?? I18n9.t("Help LLM to understand the property")
|
|
1503
|
+
}
|
|
1504
|
+
), $level === 0 && /* @__PURE__ */ React18.createElement(React18.Fragment, null, /* @__PURE__ */ React18.createElement(UILabel, { style: { marginTop: 10 } }, config?.defaultValueTitle ?? I18n9.t("Default Value")), /* @__PURE__ */ React18.createElement(DefaultValueWrapper, null, /* @__PURE__ */ React18.createElement(
|
|
1505
|
+
DefaultValue,
|
|
1506
|
+
{
|
|
1507
|
+
value: defaultValue,
|
|
1508
|
+
schema: value,
|
|
1509
|
+
placeholder: config?.defaultValuePlaceholder ?? I18n9.t("Default Value"),
|
|
1510
|
+
onChange: (value2) => onChange("default", value2)
|
|
1511
|
+
}
|
|
1512
|
+
))))), showCollapse && /* @__PURE__ */ React18.createElement(UICollapsible, { $collapse: collapse }, /* @__PURE__ */ React18.createElement(UITreeItems, { $shrink: true }, propertyList.map((_property, index) => /* @__PURE__ */ React18.createElement(
|
|
1407
1513
|
PropertyEdit,
|
|
1408
1514
|
{
|
|
1409
1515
|
readonly,
|
|
@@ -1411,18 +1517,13 @@ function PropertyEdit(props) {
|
|
|
1411
1517
|
value: _property,
|
|
1412
1518
|
config,
|
|
1413
1519
|
$level: $level + 1,
|
|
1414
|
-
$parentExpand: expand,
|
|
1415
|
-
$parentType: type,
|
|
1416
1520
|
onChange: (_v) => {
|
|
1417
1521
|
onEditProperty(_property.key, _v);
|
|
1418
1522
|
},
|
|
1419
1523
|
onRemove: () => {
|
|
1420
1524
|
onRemoveProperty(_property.key);
|
|
1421
1525
|
},
|
|
1422
|
-
$isLast: index === propertyList.length - 1
|
|
1423
|
-
$isFirst: index === 0,
|
|
1424
|
-
$index: index,
|
|
1425
|
-
$showLine: true
|
|
1526
|
+
$isLast: index === propertyList.length - 1
|
|
1426
1527
|
}
|
|
1427
1528
|
))))));
|
|
1428
1529
|
}
|
|
@@ -1440,7 +1541,7 @@ function BatchVariableSelector(props) {
|
|
|
1440
1541
|
|
|
1441
1542
|
// src/components/dynamic-value-input/index.tsx
|
|
1442
1543
|
import React20 from "react";
|
|
1443
|
-
import { JsonSchemaUtils as
|
|
1544
|
+
import { JsonSchemaUtils as JsonSchemaUtils4 } from "@flowgram.ai/json-schema";
|
|
1444
1545
|
import { IconButton as IconButton3 } from "@douyinfe/semi-ui";
|
|
1445
1546
|
import { IconSetting } from "@douyinfe/semi-icons";
|
|
1446
1547
|
|
|
@@ -1460,6 +1561,8 @@ var UIMain = styled4.div`
|
|
|
1460
1561
|
flex-grow: 1;
|
|
1461
1562
|
overflow: hidden;
|
|
1462
1563
|
min-width: 0;
|
|
1564
|
+
border-left: 1px solid var(--semi-color-border);
|
|
1565
|
+
border-right: 1px solid var(--semi-color-border);
|
|
1463
1566
|
|
|
1464
1567
|
& .semi-tree-select,
|
|
1465
1568
|
& .semi-input-number,
|
|
@@ -1473,17 +1576,25 @@ var UIMain = styled4.div`
|
|
|
1473
1576
|
border: none;
|
|
1474
1577
|
border-radius: 0;
|
|
1475
1578
|
}
|
|
1579
|
+
|
|
1580
|
+
& .semi-input-textarea-wrapper {
|
|
1581
|
+
border: none;
|
|
1582
|
+
border-radius: 0;
|
|
1583
|
+
}
|
|
1584
|
+
|
|
1585
|
+
& .semi-input-textarea {
|
|
1586
|
+
padding: 2px 6px;
|
|
1587
|
+
border: none;
|
|
1588
|
+
border-radius: 0;
|
|
1589
|
+
word-break: break-all;
|
|
1590
|
+
}
|
|
1476
1591
|
`;
|
|
1477
1592
|
var UIType2 = styled4.div`
|
|
1478
|
-
border-right: 1px solid #e5e5e5;
|
|
1479
|
-
|
|
1480
1593
|
& .semi-button {
|
|
1481
1594
|
border-radius: 0;
|
|
1482
1595
|
}
|
|
1483
1596
|
`;
|
|
1484
1597
|
var UITrigger = styled4.div`
|
|
1485
|
-
border-left: 1px solid #e5e5e5;
|
|
1486
|
-
|
|
1487
1598
|
& .semi-button {
|
|
1488
1599
|
border-radius: 0;
|
|
1489
1600
|
}
|
|
@@ -1539,7 +1650,7 @@ function DynamicValueInput({
|
|
|
1539
1650
|
return /* @__PURE__ */ React20.createElement(TypeSelector, { value: schemaFromProps, readonly: true });
|
|
1540
1651
|
}
|
|
1541
1652
|
if (value?.type === "ref") {
|
|
1542
|
-
const schema = refVariable?.type ?
|
|
1653
|
+
const schema = refVariable?.type ? JsonSchemaUtils4.astToSchema(refVariable?.type) : void 0;
|
|
1543
1654
|
return /* @__PURE__ */ React20.createElement(TypeSelector, { value: schema, readonly: true });
|
|
1544
1655
|
}
|
|
1545
1656
|
return /* @__PURE__ */ React20.createElement(
|
|
@@ -1581,13 +1692,13 @@ function DynamicValueInput({
|
|
|
1581
1692
|
}
|
|
1582
1693
|
);
|
|
1583
1694
|
}
|
|
1584
|
-
const
|
|
1695
|
+
const constantSchema2 = schemaFromProps || selectSchema || { type: "string" };
|
|
1585
1696
|
return /* @__PURE__ */ React20.createElement(
|
|
1586
1697
|
ConstantInput,
|
|
1587
1698
|
{
|
|
1588
1699
|
value: value?.content,
|
|
1589
|
-
onChange: (_v) => onChange({ type: "constant", content: _v, schema:
|
|
1590
|
-
schema:
|
|
1700
|
+
onChange: (_v) => onChange({ type: "constant", content: _v, schema: constantSchema2 }),
|
|
1701
|
+
schema: constantSchema2 || { type: "string" },
|
|
1591
1702
|
readonly,
|
|
1592
1703
|
strategies: [...constantProps?.strategies || []],
|
|
1593
1704
|
fallbackRenderer: () => /* @__PURE__ */ React20.createElement(
|
|
@@ -1648,7 +1759,7 @@ var UIValues = styled5.div`
|
|
|
1648
1759
|
|
|
1649
1760
|
// src/components/condition-row/hooks/useRule.ts
|
|
1650
1761
|
import { useMemo as useMemo6 } from "react";
|
|
1651
|
-
import { JsonSchemaUtils as
|
|
1762
|
+
import { JsonSchemaUtils as JsonSchemaUtils5 } from "@flowgram.ai/json-schema";
|
|
1652
1763
|
import { useScopeAvailable as useScopeAvailable2 } from "@flowgram.ai/editor";
|
|
1653
1764
|
|
|
1654
1765
|
// src/components/condition-row/constants.ts
|
|
@@ -1781,7 +1892,7 @@ function useRule(left, userRules) {
|
|
|
1781
1892
|
}, [available, left]);
|
|
1782
1893
|
const rule = useMemo6(() => {
|
|
1783
1894
|
if (!variable) return void 0;
|
|
1784
|
-
const schema =
|
|
1895
|
+
const schema = JsonSchemaUtils5.astToSchema(variable.type, { drilldown: false });
|
|
1785
1896
|
return rules[schema?.type];
|
|
1786
1897
|
}, [variable?.type, rules]);
|
|
1787
1898
|
return { rule };
|
|
@@ -1880,13 +1991,14 @@ function ConditionRow({
|
|
|
1880
1991
|
|
|
1881
1992
|
// src/components/batch-outputs/index.tsx
|
|
1882
1993
|
import React23 from "react";
|
|
1994
|
+
import { I18n as I18n12 } from "@flowgram.ai/editor";
|
|
1883
1995
|
import { Button as Button3, Input as Input5 } from "@douyinfe/semi-ui";
|
|
1884
1996
|
import { IconDelete, IconPlus as IconPlus2 } from "@douyinfe/semi-icons";
|
|
1885
1997
|
|
|
1886
1998
|
// src/hooks/use-object-list/index.tsx
|
|
1887
|
-
import { useEffect as useEffect4, useState as useState5 } from "react";
|
|
1999
|
+
import { useEffect as useEffect4, useRef as useRef3, useState as useState5 } from "react";
|
|
1888
2000
|
import { nanoid } from "nanoid";
|
|
1889
|
-
import { difference as difference2, get, isObject as
|
|
2001
|
+
import { difference as difference2, get, isObject as isObject3, set } from "lodash";
|
|
1890
2002
|
function genId2() {
|
|
1891
2003
|
return nanoid();
|
|
1892
2004
|
}
|
|
@@ -1896,9 +2008,22 @@ function useObjectList({
|
|
|
1896
2008
|
sortIndexKey
|
|
1897
2009
|
}) {
|
|
1898
2010
|
const [list, setList] = useState5([]);
|
|
2011
|
+
const effectVersion = useRef3(0);
|
|
2012
|
+
const changeVersion = useRef3(0);
|
|
2013
|
+
const getSortIndex = (value2) => {
|
|
2014
|
+
if (typeof sortIndexKey === "function") {
|
|
2015
|
+
return get(value2, sortIndexKey(value2)) || 0;
|
|
2016
|
+
}
|
|
2017
|
+
return get(value2, sortIndexKey || "") || 0;
|
|
2018
|
+
};
|
|
1899
2019
|
useEffect4(() => {
|
|
2020
|
+
effectVersion.current = effectVersion.current + 1;
|
|
2021
|
+
if (effectVersion.current === changeVersion.current) {
|
|
2022
|
+
return;
|
|
2023
|
+
}
|
|
2024
|
+
effectVersion.current = changeVersion.current;
|
|
1900
2025
|
setList((_prevList) => {
|
|
1901
|
-
const newKeys = Object.entries(value || {}).sort((a, b) =>
|
|
2026
|
+
const newKeys = Object.entries(value || {}).sort((a, b) => getSortIndex(a[1]) - getSortIndex(b[1])).map(([key]) => key);
|
|
1902
2027
|
const oldKeys = _prevList.map((item) => item.key).filter(Boolean);
|
|
1903
2028
|
const addKeys = difference2(newKeys, oldKeys);
|
|
1904
2029
|
return _prevList.filter((item) => !item.key || newKeys.includes(item.key)).map((item) => ({
|
|
@@ -1914,15 +2039,17 @@ function useObjectList({
|
|
|
1914
2039
|
);
|
|
1915
2040
|
});
|
|
1916
2041
|
}, [value]);
|
|
1917
|
-
const add = () => {
|
|
2042
|
+
const add = (defaultValue) => {
|
|
1918
2043
|
setList((prevList) => [
|
|
1919
2044
|
...prevList,
|
|
1920
2045
|
{
|
|
1921
|
-
id: genId2()
|
|
2046
|
+
id: genId2(),
|
|
2047
|
+
value: defaultValue
|
|
1922
2048
|
}
|
|
1923
2049
|
]);
|
|
1924
2050
|
};
|
|
1925
2051
|
const updateValue = (itemId, value2) => {
|
|
2052
|
+
changeVersion.current = changeVersion.current + 1;
|
|
1926
2053
|
setList((prevList) => {
|
|
1927
2054
|
const nextList = prevList.map((_item) => {
|
|
1928
2055
|
if (_item.id === itemId) {
|
|
@@ -1936,8 +2063,9 @@ function useObjectList({
|
|
|
1936
2063
|
onChange(
|
|
1937
2064
|
Object.fromEntries(
|
|
1938
2065
|
nextList.filter((item) => item.key).map((item) => [item.key, item.value]).map((_res, idx) => {
|
|
1939
|
-
|
|
1940
|
-
|
|
2066
|
+
const indexKey = typeof sortIndexKey === "function" ? sortIndexKey(_res[1]) : sortIndexKey;
|
|
2067
|
+
if (isObject3(_res[1]) && indexKey) {
|
|
2068
|
+
set(_res[1], indexKey, idx);
|
|
1941
2069
|
}
|
|
1942
2070
|
return _res;
|
|
1943
2071
|
})
|
|
@@ -1947,6 +2075,7 @@ function useObjectList({
|
|
|
1947
2075
|
});
|
|
1948
2076
|
};
|
|
1949
2077
|
const updateKey = (itemId, key) => {
|
|
2078
|
+
changeVersion.current = changeVersion.current + 1;
|
|
1950
2079
|
setList((prevList) => {
|
|
1951
2080
|
const nextList = prevList.map((_item) => {
|
|
1952
2081
|
if (_item.id === itemId) {
|
|
@@ -1966,6 +2095,7 @@ function useObjectList({
|
|
|
1966
2095
|
});
|
|
1967
2096
|
};
|
|
1968
2097
|
const remove = (itemId) => {
|
|
2098
|
+
changeVersion.current = changeVersion.current + 1;
|
|
1969
2099
|
setList((prevList) => {
|
|
1970
2100
|
const nextList = prevList.filter((_item) => _item.id !== itemId);
|
|
1971
2101
|
onChange(
|
|
@@ -2022,11 +2152,11 @@ function BatchOutputs(props) {
|
|
|
2022
2152
|
size: "small",
|
|
2023
2153
|
onClick: () => remove(item.id)
|
|
2024
2154
|
}
|
|
2025
|
-
)))), /* @__PURE__ */ React23.createElement(Button3, { disabled: readonly, icon: /* @__PURE__ */ React23.createElement(IconPlus2, null), size: "small", onClick: add }, "Add"));
|
|
2155
|
+
)))), /* @__PURE__ */ React23.createElement(Button3, { disabled: readonly, icon: /* @__PURE__ */ React23.createElement(IconPlus2, null), size: "small", onClick: () => add() }, I18n12.t("Add")));
|
|
2026
2156
|
}
|
|
2027
2157
|
|
|
2028
2158
|
// src/components/prompt-editor/index.tsx
|
|
2029
|
-
import React24, { useEffect as useEffect5, useRef as
|
|
2159
|
+
import React24, { useEffect as useEffect5, useRef as useRef4 } from "react";
|
|
2030
2160
|
import { Renderer, EditorProvider as EditorProvider2, ActiveLinePlaceholder as ActiveLinePlaceholder2 } from "@coze-editor/editor/react";
|
|
2031
2161
|
import preset2 from "@coze-editor/editor/preset-prompt";
|
|
2032
2162
|
|
|
@@ -2168,9 +2298,10 @@ function PromptEditor(props) {
|
|
|
2168
2298
|
style,
|
|
2169
2299
|
hasError,
|
|
2170
2300
|
children,
|
|
2171
|
-
disableMarkdownHighlight
|
|
2301
|
+
disableMarkdownHighlight,
|
|
2302
|
+
options
|
|
2172
2303
|
} = props || {};
|
|
2173
|
-
const editorRef =
|
|
2304
|
+
const editorRef = useRef4(null);
|
|
2174
2305
|
useEffect5(() => {
|
|
2175
2306
|
if (editorRef.current?.getValue() !== value?.content) {
|
|
2176
2307
|
editorRef.current?.setValue(String(value?.content || ""));
|
|
@@ -2187,7 +2318,8 @@ function PromptEditor(props) {
|
|
|
2187
2318
|
options: {
|
|
2188
2319
|
readOnly: readonly,
|
|
2189
2320
|
editable: !readonly,
|
|
2190
|
-
placeholder
|
|
2321
|
+
placeholder,
|
|
2322
|
+
...options
|
|
2191
2323
|
},
|
|
2192
2324
|
onChange: (e) => {
|
|
2193
2325
|
onChange({ type: "template", content: e.value });
|
|
@@ -2836,8 +2968,8 @@ function JsonEditorWithVariables(props) {
|
|
|
2836
2968
|
}
|
|
2837
2969
|
|
|
2838
2970
|
// src/components/inputs-values/index.tsx
|
|
2839
|
-
import
|
|
2840
|
-
import { I18n as
|
|
2971
|
+
import React34 from "react";
|
|
2972
|
+
import { I18n as I18n13 } from "@flowgram.ai/editor";
|
|
2841
2973
|
import { Button as Button4, IconButton as IconButton4 } from "@douyinfe/semi-ui";
|
|
2842
2974
|
import { IconDelete as IconDelete2, IconPlus as IconPlus3 } from "@douyinfe/semi-icons";
|
|
2843
2975
|
|
|
@@ -2851,31 +2983,10 @@ var UIRows2 = styled10.div`
|
|
|
2851
2983
|
`;
|
|
2852
2984
|
var UIRow3 = styled10.div`
|
|
2853
2985
|
display: flex;
|
|
2854
|
-
align-items:
|
|
2986
|
+
align-items: flex-start;
|
|
2855
2987
|
gap: 5px;
|
|
2856
2988
|
`;
|
|
2857
2989
|
|
|
2858
|
-
// src/components/inputs-values/components/blur-input.tsx
|
|
2859
|
-
import React34, { useEffect as useEffect9, useState as useState9 } from "react";
|
|
2860
|
-
import Input6 from "@douyinfe/semi-ui/lib/es/input";
|
|
2861
|
-
function BlurInput2(props) {
|
|
2862
|
-
const [value, setValue] = useState9("");
|
|
2863
|
-
useEffect9(() => {
|
|
2864
|
-
setValue(props.value);
|
|
2865
|
-
}, [props.value]);
|
|
2866
|
-
return /* @__PURE__ */ React34.createElement(
|
|
2867
|
-
Input6,
|
|
2868
|
-
{
|
|
2869
|
-
...props,
|
|
2870
|
-
value,
|
|
2871
|
-
onChange: (value2) => {
|
|
2872
|
-
setValue(value2);
|
|
2873
|
-
},
|
|
2874
|
-
onBlur: (e) => props.onChange?.(value, e)
|
|
2875
|
-
}
|
|
2876
|
-
);
|
|
2877
|
-
}
|
|
2878
|
-
|
|
2879
2990
|
// src/components/inputs-values/index.tsx
|
|
2880
2991
|
function InputsValues({
|
|
2881
2992
|
value,
|
|
@@ -2891,17 +3002,17 @@ function InputsValues({
|
|
|
2891
3002
|
onChange,
|
|
2892
3003
|
sortIndexKey: "extra.index"
|
|
2893
3004
|
});
|
|
2894
|
-
return /* @__PURE__ */
|
|
2895
|
-
|
|
3005
|
+
return /* @__PURE__ */ React34.createElement("div", null, /* @__PURE__ */ React34.createElement(UIRows2, { style }, list.map((item) => /* @__PURE__ */ React34.createElement(UIRow3, { key: item.id }, /* @__PURE__ */ React34.createElement(
|
|
3006
|
+
BlurInput,
|
|
2896
3007
|
{
|
|
2897
3008
|
style: { width: 100, minWidth: 100, maxWidth: 100 },
|
|
2898
3009
|
disabled: readonly,
|
|
2899
3010
|
size: "small",
|
|
2900
3011
|
value: item.key,
|
|
2901
3012
|
onChange: (v) => updateKey(item.id, v),
|
|
2902
|
-
placeholder:
|
|
3013
|
+
placeholder: I18n13.t("Input Key")
|
|
2903
3014
|
}
|
|
2904
|
-
), /* @__PURE__ */
|
|
3015
|
+
), /* @__PURE__ */ React34.createElement(
|
|
2905
3016
|
InjectDynamicValueInput,
|
|
2906
3017
|
{
|
|
2907
3018
|
style: { flexGrow: 1 },
|
|
@@ -2915,20 +3026,20 @@ function InputsValues({
|
|
|
2915
3026
|
strategies: [...constantProps?.strategies || []]
|
|
2916
3027
|
}
|
|
2917
3028
|
}
|
|
2918
|
-
), /* @__PURE__ */
|
|
3029
|
+
), /* @__PURE__ */ React34.createElement(
|
|
2919
3030
|
IconButton4,
|
|
2920
3031
|
{
|
|
2921
3032
|
disabled: readonly,
|
|
2922
3033
|
theme: "borderless",
|
|
2923
|
-
icon: /* @__PURE__ */
|
|
3034
|
+
icon: /* @__PURE__ */ React34.createElement(IconDelete2, { size: "small" }),
|
|
2924
3035
|
size: "small",
|
|
2925
3036
|
onClick: () => remove(item.id)
|
|
2926
3037
|
}
|
|
2927
|
-
)))), /* @__PURE__ */
|
|
3038
|
+
)))), /* @__PURE__ */ React34.createElement(Button4, { disabled: readonly, icon: /* @__PURE__ */ React34.createElement(IconPlus3, null), size: "small", onClick: () => add() }, I18n13.t("Add")));
|
|
2928
3039
|
}
|
|
2929
3040
|
|
|
2930
3041
|
// src/components/display-schema-tree/index.tsx
|
|
2931
|
-
import
|
|
3042
|
+
import React35 from "react";
|
|
2932
3043
|
|
|
2933
3044
|
// src/components/display-schema-tree/styles.tsx
|
|
2934
3045
|
import styled11, { css as css4 } from "styled-components";
|
|
@@ -3012,7 +3123,7 @@ var TreeItem = styled11.div`
|
|
|
3012
3123
|
|
|
3013
3124
|
// src/components/display-schema-tree/index.tsx
|
|
3014
3125
|
function DisplaySchemaTree(props) {
|
|
3015
|
-
return /* @__PURE__ */
|
|
3126
|
+
return /* @__PURE__ */ React35.createElement(SchemaTree, { ...props });
|
|
3016
3127
|
}
|
|
3017
3128
|
function SchemaTree(props) {
|
|
3018
3129
|
const {
|
|
@@ -3028,18 +3139,18 @@ function SchemaTree(props) {
|
|
|
3028
3139
|
const icon = typeManager?.getDisplayIcon(schema);
|
|
3029
3140
|
let properties = drilldown && config ? config.getTypeSchemaProperties(schema) : {};
|
|
3030
3141
|
const childEntries = Object.entries(properties || {});
|
|
3031
|
-
return /* @__PURE__ */
|
|
3142
|
+
return /* @__PURE__ */ React35.createElement(TreeItem, { depth, key: parentKey || "root" }, /* @__PURE__ */ React35.createElement(TreeRow, null, depth !== 0 && /* @__PURE__ */ React35.createElement(HorizontalLine, null), showIcon && icon && React35.cloneElement(icon, {
|
|
3032
3143
|
className: "tree-icon"
|
|
3033
|
-
}), /* @__PURE__ */
|
|
3144
|
+
}), /* @__PURE__ */ React35.createElement(TreeTitle, null, parentKey ? /* @__PURE__ */ React35.createElement(React35.Fragment, null, `${parentKey} (`, title, ")") : title)), childEntries?.length ? /* @__PURE__ */ React35.createElement(TreeLevel, null, childEntries.map(([key, value]) => /* @__PURE__ */ React35.createElement(SchemaTree, { key, ...props, parentKey: key, value, depth: depth + 1 }))) : null);
|
|
3034
3145
|
}
|
|
3035
3146
|
|
|
3036
3147
|
// src/components/display-outputs/index.tsx
|
|
3037
|
-
import
|
|
3038
|
-
import { JsonSchemaUtils as
|
|
3148
|
+
import React37, { useEffect as useEffect9 } from "react";
|
|
3149
|
+
import { JsonSchemaUtils as JsonSchemaUtils6 } from "@flowgram.ai/json-schema";
|
|
3039
3150
|
import { useCurrentScope as useCurrentScope3, useRefresh } from "@flowgram.ai/editor";
|
|
3040
3151
|
|
|
3041
3152
|
// src/components/display-schema-tag/index.tsx
|
|
3042
|
-
import
|
|
3153
|
+
import React36 from "react";
|
|
3043
3154
|
import { Popover as Popover7 } from "@douyinfe/semi-ui";
|
|
3044
3155
|
|
|
3045
3156
|
// src/components/display-schema-tag/styles.ts
|
|
@@ -3068,14 +3179,14 @@ var TitleSpan = styled12.span`
|
|
|
3068
3179
|
function DisplaySchemaTag({ value = {}, showIconInTree, title, warning }) {
|
|
3069
3180
|
const typeManager = useTypeManager();
|
|
3070
3181
|
const icon = typeManager?.getDisplayIcon(value) || typeManager.getDisplayIcon({ type: "unknown" });
|
|
3071
|
-
return /* @__PURE__ */
|
|
3182
|
+
return /* @__PURE__ */ React36.createElement(
|
|
3072
3183
|
Popover7,
|
|
3073
3184
|
{
|
|
3074
|
-
content: /* @__PURE__ */
|
|
3185
|
+
content: /* @__PURE__ */ React36.createElement(PopoverContent, null, /* @__PURE__ */ React36.createElement(DisplaySchemaTree, { value, typeManager, showIcon: showIconInTree }))
|
|
3075
3186
|
},
|
|
3076
|
-
/* @__PURE__ */
|
|
3187
|
+
/* @__PURE__ */ React36.createElement(StyledTag, { color: warning ? "amber" : "white" }, icon && React36.cloneElement(icon, {
|
|
3077
3188
|
className: "tag-icon"
|
|
3078
|
-
}), title && /* @__PURE__ */
|
|
3189
|
+
}), title && /* @__PURE__ */ React36.createElement(TitleSpan, null, title))
|
|
3079
3190
|
);
|
|
3080
3191
|
}
|
|
3081
3192
|
|
|
@@ -3091,7 +3202,7 @@ var DisplayOutputsWrapper = styled13.div`
|
|
|
3091
3202
|
function DisplayOutputs({ value, showIconInTree, displayFromScope }) {
|
|
3092
3203
|
const scope = useCurrentScope3();
|
|
3093
3204
|
const refresh = useRefresh();
|
|
3094
|
-
|
|
3205
|
+
useEffect9(() => {
|
|
3095
3206
|
if (!displayFromScope) {
|
|
3096
3207
|
return () => null;
|
|
3097
3208
|
}
|
|
@@ -3105,12 +3216,12 @@ function DisplayOutputs({ value, showIconInTree, displayFromScope }) {
|
|
|
3105
3216
|
const properties = displayFromScope ? scope.output.variables?.reduce((acm, curr) => {
|
|
3106
3217
|
acm = {
|
|
3107
3218
|
...acm,
|
|
3108
|
-
...
|
|
3219
|
+
...JsonSchemaUtils6.astToSchema(curr.type)?.properties || {}
|
|
3109
3220
|
};
|
|
3110
3221
|
return acm;
|
|
3111
3222
|
}, {}) : value?.properties || {};
|
|
3112
3223
|
const childEntries = Object.entries(properties || {});
|
|
3113
|
-
return /* @__PURE__ */
|
|
3224
|
+
return /* @__PURE__ */ React37.createElement(DisplayOutputsWrapper, null, childEntries.map(([key, schema]) => /* @__PURE__ */ React37.createElement(
|
|
3114
3225
|
DisplaySchemaTag,
|
|
3115
3226
|
{
|
|
3116
3227
|
key,
|
|
@@ -3123,15 +3234,15 @@ function DisplayOutputs({ value, showIconInTree, displayFromScope }) {
|
|
|
3123
3234
|
}
|
|
3124
3235
|
|
|
3125
3236
|
// src/components/display-flow-value/index.tsx
|
|
3126
|
-
import
|
|
3127
|
-
import { JsonSchemaUtils as
|
|
3237
|
+
import React38, { useMemo as useMemo10 } from "react";
|
|
3238
|
+
import { JsonSchemaUtils as JsonSchemaUtils7 } from "@flowgram.ai/json-schema";
|
|
3128
3239
|
import { useScopeAvailable as useScopeAvailable4 } from "@flowgram.ai/editor";
|
|
3129
3240
|
function DisplayFlowValue({ value, title, showIconInTree }) {
|
|
3130
3241
|
const available = useScopeAvailable4();
|
|
3131
3242
|
const variable = value?.type === "ref" ? available.getByKeyPath(value?.content) : void 0;
|
|
3132
3243
|
const schema = useMemo10(() => {
|
|
3133
3244
|
if (value?.type === "ref") {
|
|
3134
|
-
return
|
|
3245
|
+
return JsonSchemaUtils7.astToSchema(variable?.type);
|
|
3135
3246
|
}
|
|
3136
3247
|
if (value?.type === "template") {
|
|
3137
3248
|
return { type: "string" };
|
|
@@ -3152,7 +3263,7 @@ function DisplayFlowValue({ value, title, showIconInTree }) {
|
|
|
3152
3263
|
}
|
|
3153
3264
|
return { type: "unknown" };
|
|
3154
3265
|
}, [value, variable?.hash]);
|
|
3155
|
-
return /* @__PURE__ */
|
|
3266
|
+
return /* @__PURE__ */ React38.createElement(
|
|
3156
3267
|
DisplaySchemaTag,
|
|
3157
3268
|
{
|
|
3158
3269
|
title,
|
|
@@ -3164,7 +3275,7 @@ function DisplayFlowValue({ value, title, showIconInTree }) {
|
|
|
3164
3275
|
}
|
|
3165
3276
|
|
|
3166
3277
|
// src/components/display-inputs-values/index.tsx
|
|
3167
|
-
import
|
|
3278
|
+
import React39 from "react";
|
|
3168
3279
|
|
|
3169
3280
|
// src/components/display-inputs-values/styles.ts
|
|
3170
3281
|
import styled14 from "styled-components";
|
|
@@ -3177,30 +3288,30 @@ var DisplayInputsWrapper = styled14.div`
|
|
|
3177
3288
|
// src/components/display-inputs-values/index.tsx
|
|
3178
3289
|
function DisplayInputsValues({ value, showIconInTree }) {
|
|
3179
3290
|
const childEntries = Object.entries(value || {});
|
|
3180
|
-
return /* @__PURE__ */
|
|
3291
|
+
return /* @__PURE__ */ React39.createElement(DisplayInputsWrapper, null, childEntries.map(([key, value2]) => /* @__PURE__ */ React39.createElement(DisplayFlowValue, { key, title: key, value: value2, showIconInTree })));
|
|
3181
3292
|
}
|
|
3182
3293
|
|
|
3183
3294
|
// src/components/assign-rows/index.tsx
|
|
3184
|
-
import
|
|
3295
|
+
import React42 from "react";
|
|
3185
3296
|
import { FieldArray } from "@flowgram.ai/editor";
|
|
3186
3297
|
import { Button as Button5 } from "@douyinfe/semi-ui";
|
|
3187
3298
|
import { IconPlus as IconPlus4 } from "@douyinfe/semi-icons";
|
|
3188
3299
|
|
|
3189
3300
|
// src/components/assign-row/index.tsx
|
|
3190
|
-
import
|
|
3301
|
+
import React41 from "react";
|
|
3191
3302
|
import { IconButton as IconButton5 } from "@douyinfe/semi-ui";
|
|
3192
3303
|
import { IconMinus as IconMinus2 } from "@douyinfe/semi-icons";
|
|
3193
3304
|
|
|
3194
3305
|
// src/components/assign-row/components/blur-input.tsx
|
|
3195
|
-
import
|
|
3196
|
-
import
|
|
3197
|
-
function
|
|
3198
|
-
const [value, setValue] =
|
|
3199
|
-
|
|
3306
|
+
import React40, { useEffect as useEffect10, useState as useState9 } from "react";
|
|
3307
|
+
import Input6 from "@douyinfe/semi-ui/lib/es/input";
|
|
3308
|
+
function BlurInput2(props) {
|
|
3309
|
+
const [value, setValue] = useState9("");
|
|
3310
|
+
useEffect10(() => {
|
|
3200
3311
|
setValue(props.value);
|
|
3201
3312
|
}, [props.value]);
|
|
3202
|
-
return /* @__PURE__ */
|
|
3203
|
-
|
|
3313
|
+
return /* @__PURE__ */ React40.createElement(
|
|
3314
|
+
Input6,
|
|
3204
3315
|
{
|
|
3205
3316
|
...props,
|
|
3206
3317
|
value,
|
|
@@ -3222,7 +3333,7 @@ function AssignRow(props) {
|
|
|
3222
3333
|
onDelete,
|
|
3223
3334
|
readonly
|
|
3224
3335
|
} = props;
|
|
3225
|
-
return /* @__PURE__ */
|
|
3336
|
+
return /* @__PURE__ */ React41.createElement("div", { style: { display: "flex", alignItems: "center", gap: 5 } }, /* @__PURE__ */ React41.createElement("div", { style: { width: 150, minWidth: 150, maxWidth: 150 } }, value?.operator === "assign" ? /* @__PURE__ */ React41.createElement(
|
|
3226
3337
|
InjectVariableSelector,
|
|
3227
3338
|
{
|
|
3228
3339
|
style: { width: "100%", height: 26 },
|
|
@@ -3233,8 +3344,8 @@ function AssignRow(props) {
|
|
|
3233
3344
|
left: { type: "ref", content: v }
|
|
3234
3345
|
})
|
|
3235
3346
|
}
|
|
3236
|
-
) : /* @__PURE__ */
|
|
3237
|
-
|
|
3347
|
+
) : /* @__PURE__ */ React41.createElement(
|
|
3348
|
+
BlurInput2,
|
|
3238
3349
|
{
|
|
3239
3350
|
style: { height: 26 },
|
|
3240
3351
|
size: "small",
|
|
@@ -3245,7 +3356,7 @@ function AssignRow(props) {
|
|
|
3245
3356
|
left: v
|
|
3246
3357
|
})
|
|
3247
3358
|
}
|
|
3248
|
-
)), /* @__PURE__ */
|
|
3359
|
+
)), /* @__PURE__ */ React41.createElement("div", { style: { flexGrow: 1 } }, /* @__PURE__ */ React41.createElement(
|
|
3249
3360
|
InjectDynamicValueInput,
|
|
3250
3361
|
{
|
|
3251
3362
|
readonly,
|
|
@@ -3255,12 +3366,12 @@ function AssignRow(props) {
|
|
|
3255
3366
|
right: v
|
|
3256
3367
|
})
|
|
3257
3368
|
}
|
|
3258
|
-
)), onDelete && /* @__PURE__ */
|
|
3369
|
+
)), onDelete && /* @__PURE__ */ React41.createElement("div", null, /* @__PURE__ */ React41.createElement(
|
|
3259
3370
|
IconButton5,
|
|
3260
3371
|
{
|
|
3261
3372
|
size: "small",
|
|
3262
3373
|
theme: "borderless",
|
|
3263
|
-
icon: /* @__PURE__ */
|
|
3374
|
+
icon: /* @__PURE__ */ React41.createElement(IconMinus2, null),
|
|
3264
3375
|
onClick: () => onDelete?.()
|
|
3265
3376
|
}
|
|
3266
3377
|
)));
|
|
@@ -3269,7 +3380,7 @@ function AssignRow(props) {
|
|
|
3269
3380
|
// src/components/assign-rows/index.tsx
|
|
3270
3381
|
function AssignRows(props) {
|
|
3271
3382
|
const { name, readonly } = props;
|
|
3272
|
-
return /* @__PURE__ */
|
|
3383
|
+
return /* @__PURE__ */ React42.createElement(FieldArray, { name }, ({ field }) => /* @__PURE__ */ React42.createElement(React42.Fragment, null, field.map((childField, index) => /* @__PURE__ */ React42.createElement(
|
|
3273
3384
|
AssignRow,
|
|
3274
3385
|
{
|
|
3275
3386
|
key: childField.key,
|
|
@@ -3280,27 +3391,321 @@ function AssignRows(props) {
|
|
|
3280
3391
|
},
|
|
3281
3392
|
onDelete: () => field.remove(index)
|
|
3282
3393
|
}
|
|
3283
|
-
)), /* @__PURE__ */
|
|
3394
|
+
)), /* @__PURE__ */ React42.createElement("div", { style: { display: "flex", gap: 5 } }, /* @__PURE__ */ React42.createElement(
|
|
3284
3395
|
Button5,
|
|
3285
3396
|
{
|
|
3286
3397
|
size: "small",
|
|
3287
3398
|
theme: "borderless",
|
|
3288
|
-
icon: /* @__PURE__ */
|
|
3399
|
+
icon: /* @__PURE__ */ React42.createElement(IconPlus4, null),
|
|
3289
3400
|
onClick: () => field.append({ operator: "assign" })
|
|
3290
3401
|
},
|
|
3291
3402
|
"Assign"
|
|
3292
|
-
), /* @__PURE__ */
|
|
3403
|
+
), /* @__PURE__ */ React42.createElement(
|
|
3293
3404
|
Button5,
|
|
3294
3405
|
{
|
|
3295
3406
|
size: "small",
|
|
3296
3407
|
theme: "borderless",
|
|
3297
|
-
icon: /* @__PURE__ */
|
|
3408
|
+
icon: /* @__PURE__ */ React42.createElement(IconPlus4, null),
|
|
3298
3409
|
onClick: () => field.append({ operator: "declare" })
|
|
3299
3410
|
},
|
|
3300
3411
|
"Declaration"
|
|
3301
3412
|
))));
|
|
3302
3413
|
}
|
|
3303
3414
|
|
|
3415
|
+
// src/components/inputs-values-tree/index.tsx
|
|
3416
|
+
import React45 from "react";
|
|
3417
|
+
import { I18n as I18n15 } from "@flowgram.ai/editor";
|
|
3418
|
+
import { Button as Button6 } from "@douyinfe/semi-ui";
|
|
3419
|
+
import { IconPlus as IconPlus5 } from "@douyinfe/semi-icons";
|
|
3420
|
+
|
|
3421
|
+
// src/components/inputs-values-tree/styles.tsx
|
|
3422
|
+
import React43 from "react";
|
|
3423
|
+
import styled15, { css as css5 } from "styled-components";
|
|
3424
|
+
import Icon4 from "@douyinfe/semi-icons";
|
|
3425
|
+
var UIContainer5 = styled15.div``;
|
|
3426
|
+
var UIRow4 = styled15.div`
|
|
3427
|
+
display: flex;
|
|
3428
|
+
align-items: flex-start;
|
|
3429
|
+
gap: 5px;
|
|
3430
|
+
`;
|
|
3431
|
+
var UICollapseTrigger2 = styled15.div`
|
|
3432
|
+
cursor: pointer;
|
|
3433
|
+
margin-right: 5px;
|
|
3434
|
+
`;
|
|
3435
|
+
var UITreeItems2 = styled15.div`
|
|
3436
|
+
display: grid;
|
|
3437
|
+
grid-template-columns: auto 1fr;
|
|
3438
|
+
|
|
3439
|
+
${({ $shrink }) => $shrink && css5`
|
|
3440
|
+
padding-left: 3px;
|
|
3441
|
+
margin-top: 10px;
|
|
3442
|
+
`}
|
|
3443
|
+
`;
|
|
3444
|
+
var UITreeItemLeft2 = styled15.div`
|
|
3445
|
+
grid-column: 1;
|
|
3446
|
+
position: relative;
|
|
3447
|
+
width: 16px;
|
|
3448
|
+
|
|
3449
|
+
${({ $showLine, $isLast, $showCollapse }) => {
|
|
3450
|
+
let height = $isLast ? "24px" : "100%";
|
|
3451
|
+
let width = $showCollapse ? "12px" : "30px";
|
|
3452
|
+
return $showLine && css5`
|
|
3453
|
+
&::before {
|
|
3454
|
+
/* 竖线 */
|
|
3455
|
+
content: '';
|
|
3456
|
+
height: ${height};
|
|
3457
|
+
position: absolute;
|
|
3458
|
+
left: -14px;
|
|
3459
|
+
top: -16px;
|
|
3460
|
+
width: 1px;
|
|
3461
|
+
background: #d9d9d9;
|
|
3462
|
+
display: block;
|
|
3463
|
+
}
|
|
3464
|
+
|
|
3465
|
+
&::after {
|
|
3466
|
+
/* 横线 */
|
|
3467
|
+
content: '';
|
|
3468
|
+
position: absolute;
|
|
3469
|
+
left: -14px; // 横线起点和竖线对齐
|
|
3470
|
+
top: 8px; // 跟随你的行高调整
|
|
3471
|
+
width: ${width}; // 横线长度
|
|
3472
|
+
height: 1px;
|
|
3473
|
+
background: #d9d9d9;
|
|
3474
|
+
display: block;
|
|
3475
|
+
}
|
|
3476
|
+
`;
|
|
3477
|
+
}}
|
|
3478
|
+
`;
|
|
3479
|
+
var UITreeItemRight2 = styled15.div`
|
|
3480
|
+
grid-column: 2;
|
|
3481
|
+
margin-bottom: 10px;
|
|
3482
|
+
|
|
3483
|
+
&:last-child {
|
|
3484
|
+
margin-bottom: 0px;
|
|
3485
|
+
}
|
|
3486
|
+
`;
|
|
3487
|
+
var UITreeItemMain2 = styled15.div`
|
|
3488
|
+
display: flex;
|
|
3489
|
+
flex-direction: column;
|
|
3490
|
+
gap: 10px;
|
|
3491
|
+
position: relative;
|
|
3492
|
+
`;
|
|
3493
|
+
var UICollapsible2 = styled15.div`
|
|
3494
|
+
display: none;
|
|
3495
|
+
|
|
3496
|
+
${({ $collapse }) => $collapse && css5`
|
|
3497
|
+
display: block;
|
|
3498
|
+
`}
|
|
3499
|
+
`;
|
|
3500
|
+
var UIActions2 = styled15.div`
|
|
3501
|
+
white-space: nowrap;
|
|
3502
|
+
`;
|
|
3503
|
+
var iconAddChildrenSvg2 = /* @__PURE__ */ React43.createElement(
|
|
3504
|
+
"svg",
|
|
3505
|
+
{
|
|
3506
|
+
className: "icon-icon icon-icon-coz_add_node ",
|
|
3507
|
+
width: "1em",
|
|
3508
|
+
height: "1em",
|
|
3509
|
+
viewBox: "0 0 24 24",
|
|
3510
|
+
fill: "currentColor",
|
|
3511
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
3512
|
+
},
|
|
3513
|
+
/* @__PURE__ */ React43.createElement(
|
|
3514
|
+
"path",
|
|
3515
|
+
{
|
|
3516
|
+
fillRule: "evenodd",
|
|
3517
|
+
clipRule: "evenodd",
|
|
3518
|
+
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"
|
|
3519
|
+
}
|
|
3520
|
+
),
|
|
3521
|
+
/* @__PURE__ */ React43.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" })
|
|
3522
|
+
);
|
|
3523
|
+
var IconAddChildren2 = () => /* @__PURE__ */ React43.createElement(Icon4, { size: "small", svg: iconAddChildrenSvg2 });
|
|
3524
|
+
|
|
3525
|
+
// src/components/inputs-values-tree/row.tsx
|
|
3526
|
+
import React44, { useState as useState10 } from "react";
|
|
3527
|
+
import { I18n as I18n14 } from "@flowgram.ai/editor";
|
|
3528
|
+
import { IconButton as IconButton6, Input as Input7 } from "@douyinfe/semi-ui";
|
|
3529
|
+
import { IconChevronDown as IconChevronDown2, IconChevronRight as IconChevronRight2, IconDelete as IconDelete3 } from "@douyinfe/semi-icons";
|
|
3530
|
+
|
|
3531
|
+
// src/components/inputs-values-tree/hooks/use-child-list.tsx
|
|
3532
|
+
import { useMemo as useMemo11 } from "react";
|
|
3533
|
+
import { isPlainObject as isPlainObject2 } from "lodash";
|
|
3534
|
+
function useChildList(value, onChange) {
|
|
3535
|
+
const canAddField = useMemo11(() => {
|
|
3536
|
+
if (!isPlainObject2(value)) {
|
|
3537
|
+
return false;
|
|
3538
|
+
}
|
|
3539
|
+
if (FlowValueUtils.isFlowValue(value)) {
|
|
3540
|
+
return FlowValueUtils.isConstant(value) && value?.schema?.type === "object";
|
|
3541
|
+
}
|
|
3542
|
+
return true;
|
|
3543
|
+
}, [value]);
|
|
3544
|
+
const objectListValue = useMemo11(() => {
|
|
3545
|
+
if (isPlainObject2(value)) {
|
|
3546
|
+
if (FlowValueUtils.isFlowValue(value)) {
|
|
3547
|
+
return void 0;
|
|
3548
|
+
}
|
|
3549
|
+
return value;
|
|
3550
|
+
}
|
|
3551
|
+
return void 0;
|
|
3552
|
+
}, [value]);
|
|
3553
|
+
console.log("debugger objectListValue", objectListValue);
|
|
3554
|
+
const { list, add, updateKey, updateValue, remove } = useObjectList({
|
|
3555
|
+
value: objectListValue,
|
|
3556
|
+
onChange: (value2) => {
|
|
3557
|
+
onChange?.(value2);
|
|
3558
|
+
},
|
|
3559
|
+
sortIndexKey: (value2) => FlowValueUtils.isFlowValue(value2) ? "extra.index" : ""
|
|
3560
|
+
});
|
|
3561
|
+
return {
|
|
3562
|
+
canAddField,
|
|
3563
|
+
list,
|
|
3564
|
+
add,
|
|
3565
|
+
updateKey,
|
|
3566
|
+
updateValue,
|
|
3567
|
+
remove
|
|
3568
|
+
};
|
|
3569
|
+
}
|
|
3570
|
+
|
|
3571
|
+
// src/components/inputs-values-tree/row.tsx
|
|
3572
|
+
var AddObjectChildStrategy = {
|
|
3573
|
+
hit: (schema) => schema.type === "object",
|
|
3574
|
+
Renderer: () => /* @__PURE__ */ React44.createElement(
|
|
3575
|
+
Input7,
|
|
3576
|
+
{
|
|
3577
|
+
size: "small",
|
|
3578
|
+
disabled: true,
|
|
3579
|
+
style: { pointerEvents: "none" },
|
|
3580
|
+
value: I18n14.t("Configure via child fields")
|
|
3581
|
+
}
|
|
3582
|
+
)
|
|
3583
|
+
};
|
|
3584
|
+
function InputValueRow(props) {
|
|
3585
|
+
const {
|
|
3586
|
+
keyName,
|
|
3587
|
+
value,
|
|
3588
|
+
$level = 0,
|
|
3589
|
+
onUpdateKey,
|
|
3590
|
+
onUpdateValue,
|
|
3591
|
+
$isLast,
|
|
3592
|
+
onRemove,
|
|
3593
|
+
constantProps,
|
|
3594
|
+
hasError,
|
|
3595
|
+
readonly
|
|
3596
|
+
} = props;
|
|
3597
|
+
const [collapse, setCollapse] = useState10(false);
|
|
3598
|
+
const { canAddField, list, add, updateKey, updateValue, remove } = useChildList(
|
|
3599
|
+
value,
|
|
3600
|
+
onUpdateValue
|
|
3601
|
+
);
|
|
3602
|
+
const hasChildren = canAddField && list.length > 0;
|
|
3603
|
+
const flowDisplayValue = hasChildren ? { type: "constant", schema: { type: " object" } } : value;
|
|
3604
|
+
return /* @__PURE__ */ React44.createElement(React44.Fragment, null, /* @__PURE__ */ React44.createElement(UITreeItemLeft2, { $isLast, $showLine: $level > 0, $showCollapse: hasChildren }, hasChildren && /* @__PURE__ */ React44.createElement(UICollapseTrigger2, { onClick: () => setCollapse((_collapse) => !_collapse) }, collapse ? /* @__PURE__ */ React44.createElement(IconChevronDown2, { size: "small" }) : /* @__PURE__ */ React44.createElement(IconChevronRight2, { size: "small" }))), /* @__PURE__ */ React44.createElement(UITreeItemRight2, null, /* @__PURE__ */ React44.createElement(UITreeItemMain2, null, /* @__PURE__ */ React44.createElement(UIRow4, null, /* @__PURE__ */ React44.createElement(
|
|
3605
|
+
BlurInput,
|
|
3606
|
+
{
|
|
3607
|
+
style: { width: 100, minWidth: 100, maxWidth: 100 },
|
|
3608
|
+
disabled: readonly,
|
|
3609
|
+
size: "small",
|
|
3610
|
+
value: keyName,
|
|
3611
|
+
onChange: (v) => onUpdateKey?.(v),
|
|
3612
|
+
placeholder: I18n14.t("Input Key")
|
|
3613
|
+
}
|
|
3614
|
+
), /* @__PURE__ */ React44.createElement(
|
|
3615
|
+
InjectDynamicValueInput,
|
|
3616
|
+
{
|
|
3617
|
+
style: { flexGrow: 1 },
|
|
3618
|
+
readonly,
|
|
3619
|
+
value: flowDisplayValue,
|
|
3620
|
+
onChange: (v) => onUpdateValue(v),
|
|
3621
|
+
hasError,
|
|
3622
|
+
constantProps: {
|
|
3623
|
+
...constantProps,
|
|
3624
|
+
strategies: [
|
|
3625
|
+
...hasChildren ? [AddObjectChildStrategy] : [],
|
|
3626
|
+
...constantProps?.strategies || []
|
|
3627
|
+
]
|
|
3628
|
+
}
|
|
3629
|
+
}
|
|
3630
|
+
), /* @__PURE__ */ React44.createElement(UIActions2, null, canAddField && /* @__PURE__ */ React44.createElement(
|
|
3631
|
+
IconButton6,
|
|
3632
|
+
{
|
|
3633
|
+
disabled: readonly,
|
|
3634
|
+
size: "small",
|
|
3635
|
+
theme: "borderless",
|
|
3636
|
+
icon: /* @__PURE__ */ React44.createElement(IconAddChildren2, null),
|
|
3637
|
+
onClick: () => {
|
|
3638
|
+
add();
|
|
3639
|
+
setCollapse(true);
|
|
3640
|
+
}
|
|
3641
|
+
}
|
|
3642
|
+
), /* @__PURE__ */ React44.createElement(
|
|
3643
|
+
IconButton6,
|
|
3644
|
+
{
|
|
3645
|
+
disabled: readonly,
|
|
3646
|
+
theme: "borderless",
|
|
3647
|
+
icon: /* @__PURE__ */ React44.createElement(IconDelete3, { size: "small" }),
|
|
3648
|
+
size: "small",
|
|
3649
|
+
onClick: () => onRemove?.()
|
|
3650
|
+
}
|
|
3651
|
+
)))), hasChildren && /* @__PURE__ */ React44.createElement(UICollapsible2, { $collapse: collapse }, /* @__PURE__ */ React44.createElement(UITreeItems2, { $shrink: true }, list.map((_item, index) => /* @__PURE__ */ React44.createElement(
|
|
3652
|
+
InputValueRow,
|
|
3653
|
+
{
|
|
3654
|
+
readonly,
|
|
3655
|
+
hasError,
|
|
3656
|
+
constantProps,
|
|
3657
|
+
key: _item.id,
|
|
3658
|
+
keyName: _item.key,
|
|
3659
|
+
value: _item.value,
|
|
3660
|
+
$level: $level + 1,
|
|
3661
|
+
onUpdateValue: (_v) => {
|
|
3662
|
+
updateValue(_item.id, _v);
|
|
3663
|
+
},
|
|
3664
|
+
onUpdateKey: (k) => {
|
|
3665
|
+
updateKey(_item.id, k);
|
|
3666
|
+
},
|
|
3667
|
+
onRemove: () => {
|
|
3668
|
+
remove(_item.id);
|
|
3669
|
+
},
|
|
3670
|
+
$isLast: index === list.length - 1
|
|
3671
|
+
}
|
|
3672
|
+
))))));
|
|
3673
|
+
}
|
|
3674
|
+
|
|
3675
|
+
// src/components/inputs-values-tree/index.tsx
|
|
3676
|
+
function InputsValuesTree(props) {
|
|
3677
|
+
const { value, onChange, readonly, hasError, constantProps } = props;
|
|
3678
|
+
const { list, updateKey, updateValue, remove, add } = useObjectList({
|
|
3679
|
+
value,
|
|
3680
|
+
onChange,
|
|
3681
|
+
sortIndexKey: (value2) => FlowValueUtils.isFlowValue(value2) ? "extra.index" : ""
|
|
3682
|
+
});
|
|
3683
|
+
return /* @__PURE__ */ React45.createElement("div", null, /* @__PURE__ */ React45.createElement(UITreeItems2, null, list.map((item) => /* @__PURE__ */ React45.createElement(
|
|
3684
|
+
InputValueRow,
|
|
3685
|
+
{
|
|
3686
|
+
key: item.id,
|
|
3687
|
+
keyName: item.key,
|
|
3688
|
+
value: item.value,
|
|
3689
|
+
onUpdateKey: (key) => updateKey(item.id, key),
|
|
3690
|
+
onUpdateValue: (value2) => updateValue(item.id, value2),
|
|
3691
|
+
onRemove: () => remove(item.id),
|
|
3692
|
+
readonly,
|
|
3693
|
+
hasError,
|
|
3694
|
+
constantProps
|
|
3695
|
+
}
|
|
3696
|
+
))), /* @__PURE__ */ React45.createElement(
|
|
3697
|
+
Button6,
|
|
3698
|
+
{
|
|
3699
|
+
style: { marginTop: 10, marginLeft: 16 },
|
|
3700
|
+
disabled: readonly,
|
|
3701
|
+
icon: /* @__PURE__ */ React45.createElement(IconPlus5, null),
|
|
3702
|
+
size: "small",
|
|
3703
|
+
onClick: add
|
|
3704
|
+
},
|
|
3705
|
+
I18n15.t("Add")
|
|
3706
|
+
));
|
|
3707
|
+
}
|
|
3708
|
+
|
|
3304
3709
|
// src/effects/provide-batch-input/index.ts
|
|
3305
3710
|
import {
|
|
3306
3711
|
ASTFactory,
|
|
@@ -3337,7 +3742,6 @@ var provideBatchInputEffect = createEffectFromVariableProvider({
|
|
|
3337
3742
|
});
|
|
3338
3743
|
|
|
3339
3744
|
// src/effects/auto-rename-ref/index.ts
|
|
3340
|
-
import { isArray, isObject as isObject3, uniq } from "lodash";
|
|
3341
3745
|
import {
|
|
3342
3746
|
DataEvent,
|
|
3343
3747
|
VariableFieldKeyRenameService
|
|
@@ -3364,7 +3768,7 @@ var autoRenameRefEffect = [
|
|
|
3364
3768
|
form.setValueIn(_drilldownName, _v);
|
|
3365
3769
|
}
|
|
3366
3770
|
} else if (_v.type === "template") {
|
|
3367
|
-
const templateKeyPaths = getTemplateKeyPaths(_v);
|
|
3771
|
+
const templateKeyPaths = FlowValueUtils.getTemplateKeyPaths(_v);
|
|
3368
3772
|
let hasMatch = false;
|
|
3369
3773
|
templateKeyPaths.forEach((_keyPath) => {
|
|
3370
3774
|
if (isKeyPathMatch(_keyPath, beforeKeyPath)) {
|
|
@@ -3394,44 +3798,17 @@ var autoRenameRefEffect = [
|
|
|
3394
3798
|
function isKeyPathMatch(keyPath = [], targetKeyPath) {
|
|
3395
3799
|
return targetKeyPath.every((_key, index) => _key === keyPath[index]);
|
|
3396
3800
|
}
|
|
3397
|
-
function getTemplateKeyPaths(value) {
|
|
3398
|
-
const keyPathReg = /{{(.*?)}}/g;
|
|
3399
|
-
return uniq(value.content?.match(keyPathReg) || []).map(
|
|
3400
|
-
(_keyPath) => _keyPath.slice(2, -2).split(".")
|
|
3401
|
-
);
|
|
3402
|
-
}
|
|
3403
|
-
function isRef(value) {
|
|
3404
|
-
return value?.type === "ref" && Array.isArray(value?.content) && typeof value?.content[0] === "string";
|
|
3405
|
-
}
|
|
3406
|
-
function isTemplate(value) {
|
|
3407
|
-
return value?.type === "template" && typeof value?.content === "string";
|
|
3408
|
-
}
|
|
3409
3801
|
function traverseRef(name, value, cb) {
|
|
3410
|
-
|
|
3411
|
-
|
|
3412
|
-
|
|
3413
|
-
|
|
3414
|
-
|
|
3415
|
-
if (isTemplate(value)) {
|
|
3416
|
-
cb(name, value);
|
|
3417
|
-
return;
|
|
3418
|
-
}
|
|
3419
|
-
Object.entries(value).forEach(([_key, _value]) => {
|
|
3420
|
-
traverseRef(`${name}.${_key}`, _value, cb);
|
|
3421
|
-
});
|
|
3422
|
-
return;
|
|
3802
|
+
for (const { value: _v, path } of FlowValueUtils.traverse(value, {
|
|
3803
|
+
includeTypes: ["ref", "template"],
|
|
3804
|
+
path: name
|
|
3805
|
+
})) {
|
|
3806
|
+
cb(path, _v);
|
|
3423
3807
|
}
|
|
3424
|
-
if (isArray(value)) {
|
|
3425
|
-
value.forEach((_value, idx) => {
|
|
3426
|
-
traverseRef(`${name}[${idx}]`, _value, cb);
|
|
3427
|
-
});
|
|
3428
|
-
return;
|
|
3429
|
-
}
|
|
3430
|
-
return;
|
|
3431
3808
|
}
|
|
3432
3809
|
|
|
3433
3810
|
// src/effects/provide-json-schema-outputs/index.ts
|
|
3434
|
-
import { JsonSchemaUtils as
|
|
3811
|
+
import { JsonSchemaUtils as JsonSchemaUtils8 } from "@flowgram.ai/json-schema";
|
|
3435
3812
|
import {
|
|
3436
3813
|
ASTFactory as ASTFactory2,
|
|
3437
3814
|
createEffectFromVariableProvider as createEffectFromVariableProvider2,
|
|
@@ -3445,7 +3822,7 @@ var provideJsonSchemaOutputs = createEffectFromVariableProvider2({
|
|
|
3445
3822
|
title: getNodeForm2(ctx.node)?.getValueIn("title") || ctx.node.id,
|
|
3446
3823
|
icon: ctx.node.getNodeRegistry().info?.icon
|
|
3447
3824
|
},
|
|
3448
|
-
type:
|
|
3825
|
+
type: JsonSchemaUtils8.schemaToAST(value)
|
|
3449
3826
|
})
|
|
3450
3827
|
]
|
|
3451
3828
|
});
|
|
@@ -3523,7 +3900,7 @@ var listenRefValueChange = (cb) => [
|
|
|
3523
3900
|
];
|
|
3524
3901
|
|
|
3525
3902
|
// src/effects/listen-ref-schema-change/index.ts
|
|
3526
|
-
import { JsonSchemaUtils as
|
|
3903
|
+
import { JsonSchemaUtils as JsonSchemaUtils9 } from "@flowgram.ai/json-schema";
|
|
3527
3904
|
import {
|
|
3528
3905
|
DataEvent as DataEvent5,
|
|
3529
3906
|
getNodeScope as getNodeScope3
|
|
@@ -3539,7 +3916,7 @@ var listenRefSchemaChange = (cb) => [
|
|
|
3539
3916
|
const disposable = getNodeScope3(context.node).available.trackByKeyPath(
|
|
3540
3917
|
value?.content || [],
|
|
3541
3918
|
(_type) => {
|
|
3542
|
-
cb({ ...params, schema:
|
|
3919
|
+
cb({ ...params, schema: JsonSchemaUtils9.astToSchema(_type) });
|
|
3543
3920
|
},
|
|
3544
3921
|
{
|
|
3545
3922
|
selector: (_v) => _v?.type
|
|
@@ -3629,12 +4006,7 @@ var createBatchOutputsFormPlugin = defineFormPluginCreator({
|
|
|
3629
4006
|
|
|
3630
4007
|
// src/form-plugins/infer-inputs-plugin/index.ts
|
|
3631
4008
|
import { get as get2, set as set2 } from "lodash";
|
|
3632
|
-
import {
|
|
3633
|
-
import {
|
|
3634
|
-
defineFormPluginCreator as defineFormPluginCreator2,
|
|
3635
|
-
getNodePrivateScope as getNodePrivateScope3,
|
|
3636
|
-
getNodeScope as getNodeScope5
|
|
3637
|
-
} from "@flowgram.ai/editor";
|
|
4009
|
+
import { defineFormPluginCreator as defineFormPluginCreator2, getNodePrivateScope as getNodePrivateScope3, getNodeScope as getNodeScope5 } from "@flowgram.ai/editor";
|
|
3638
4010
|
var createInferInputsPlugin = defineFormPluginCreator2({
|
|
3639
4011
|
onSetupFormMeta({ addFormatOnSubmit }, { sourceKey, targetKey, scope }) {
|
|
3640
4012
|
if (!sourceKey || !targetKey) {
|
|
@@ -3644,7 +4016,7 @@ var createInferInputsPlugin = defineFormPluginCreator2({
|
|
|
3644
4016
|
set2(
|
|
3645
4017
|
formData,
|
|
3646
4018
|
targetKey,
|
|
3647
|
-
|
|
4019
|
+
FlowValueUtils.inferJsonSchema(
|
|
3648
4020
|
get2(formData, sourceKey),
|
|
3649
4021
|
scope === "private" ? getNodePrivateScope3(ctx.node) : getNodeScope5(ctx.node)
|
|
3650
4022
|
)
|
|
@@ -3653,59 +4025,6 @@ var createInferInputsPlugin = defineFormPluginCreator2({
|
|
|
3653
4025
|
});
|
|
3654
4026
|
}
|
|
3655
4027
|
});
|
|
3656
|
-
function isRef2(value) {
|
|
3657
|
-
return value?.type === "ref" && Array.isArray(value?.content) && typeof value?.content[0] === "string";
|
|
3658
|
-
}
|
|
3659
|
-
function isTemplate2(value) {
|
|
3660
|
-
return value?.type === "template" && typeof value?.content === "string";
|
|
3661
|
-
}
|
|
3662
|
-
function isConstant(value) {
|
|
3663
|
-
return value?.type === "constant" && typeof value?.content !== "undefined";
|
|
3664
|
-
}
|
|
3665
|
-
var infer = (values, scope) => {
|
|
3666
|
-
if (typeof values === "object") {
|
|
3667
|
-
if (isConstant(values)) {
|
|
3668
|
-
if (values?.schema) {
|
|
3669
|
-
return values.schema;
|
|
3670
|
-
}
|
|
3671
|
-
if (typeof values.content === "string") {
|
|
3672
|
-
return {
|
|
3673
|
-
type: "string"
|
|
3674
|
-
};
|
|
3675
|
-
}
|
|
3676
|
-
if (typeof values.content === "number") {
|
|
3677
|
-
return {
|
|
3678
|
-
type: "number"
|
|
3679
|
-
};
|
|
3680
|
-
}
|
|
3681
|
-
if (typeof values.content === "boolean") {
|
|
3682
|
-
return {
|
|
3683
|
-
type: "boolean"
|
|
3684
|
-
};
|
|
3685
|
-
}
|
|
3686
|
-
}
|
|
3687
|
-
if (isRef2(values)) {
|
|
3688
|
-
const variable = scope.available.getByKeyPath(values?.content);
|
|
3689
|
-
const schema = variable?.type ? JsonSchemaUtils9.astToSchema(variable?.type) : void 0;
|
|
3690
|
-
return schema;
|
|
3691
|
-
}
|
|
3692
|
-
if (isTemplate2(values)) {
|
|
3693
|
-
return {
|
|
3694
|
-
type: "string"
|
|
3695
|
-
};
|
|
3696
|
-
}
|
|
3697
|
-
return {
|
|
3698
|
-
type: "object",
|
|
3699
|
-
properties: Object.keys(values).reduce((acc, key) => {
|
|
3700
|
-
const schema = infer(values[key], scope);
|
|
3701
|
-
if (schema) {
|
|
3702
|
-
acc[key] = schema;
|
|
3703
|
-
}
|
|
3704
|
-
return acc;
|
|
3705
|
-
}, {})
|
|
3706
|
-
};
|
|
3707
|
-
}
|
|
3708
|
-
};
|
|
3709
4028
|
|
|
3710
4029
|
// src/form-plugins/infer-assign-plugin/index.ts
|
|
3711
4030
|
import { set as set3, uniqBy } from "lodash";
|
|
@@ -3788,7 +4107,7 @@ function validateFlowValue(value, ctx) {
|
|
|
3788
4107
|
}
|
|
3789
4108
|
}
|
|
3790
4109
|
if (value?.type === "template") {
|
|
3791
|
-
const allRefs =
|
|
4110
|
+
const allRefs = getTemplateKeyPaths(value);
|
|
3792
4111
|
for (const ref of allRefs) {
|
|
3793
4112
|
const variable = getNodeScope7(node).available.getByKeyPath(ref);
|
|
3794
4113
|
if (!variable) {
|
|
@@ -3801,7 +4120,7 @@ function validateFlowValue(value, ctx) {
|
|
|
3801
4120
|
}
|
|
3802
4121
|
return void 0;
|
|
3803
4122
|
}
|
|
3804
|
-
function
|
|
4123
|
+
function getTemplateKeyPaths(value) {
|
|
3805
4124
|
const keyPathReg = /{{(.*?)}}/g;
|
|
3806
4125
|
return uniq2(value.content?.match(keyPathReg) || []).map(
|
|
3807
4126
|
(_keyPath) => _keyPath.slice(2, -2).split(".")
|
|
@@ -3812,6 +4131,7 @@ export {
|
|
|
3812
4131
|
AssignRows,
|
|
3813
4132
|
BatchOutputs,
|
|
3814
4133
|
BatchVariableSelector,
|
|
4134
|
+
BlurInput,
|
|
3815
4135
|
CodeEditor,
|
|
3816
4136
|
CodeEditorMini,
|
|
3817
4137
|
ConditionRow,
|
|
@@ -3822,14 +4142,16 @@ export {
|
|
|
3822
4142
|
DisplaySchemaTag,
|
|
3823
4143
|
DisplaySchemaTree,
|
|
3824
4144
|
DynamicValueInput,
|
|
4145
|
+
FlowValueUtils,
|
|
3825
4146
|
InjectDynamicValueInput,
|
|
3826
4147
|
InjectTypeSelector,
|
|
3827
4148
|
InjectVariableSelector,
|
|
3828
4149
|
InputsValues,
|
|
4150
|
+
InputsValuesTree,
|
|
3829
4151
|
JsonEditorWithVariables,
|
|
3830
4152
|
JsonSchemaEditor,
|
|
3831
4153
|
JsonSchemaTypePresetProvider,
|
|
3832
|
-
JsonSchemaUtils,
|
|
4154
|
+
JsonSchemaUtils2 as JsonSchemaUtils,
|
|
3833
4155
|
PromptEditor,
|
|
3834
4156
|
PromptEditorWithInputs,
|
|
3835
4157
|
PromptEditorWithVariables,
|