@flowgram.ai/form-materials 0.4.0 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/index.js +792 -423
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.mts +136 -30
- package/dist/index.d.ts +136 -30
- package/dist/index.js +902 -525
- package/dist/index.js.map +1 -1
- package/package.json +6 -5
- package/src/components/batch-outputs/index.tsx +3 -2
- package/src/components/display-flow-value/index.tsx +2 -12
- package/src/components/display-inputs-values/index.tsx +44 -6
- package/src/components/dynamic-value-input/hooks.ts +24 -3
- package/src/components/dynamic-value-input/index.tsx +2 -2
- package/src/components/dynamic-value-input/styles.tsx +14 -4
- package/src/components/index.ts +2 -0
- package/src/components/inputs-values/index.tsx +3 -3
- package/src/components/inputs-values/styles.tsx +1 -1
- package/src/components/inputs-values-tree/hooks/use-child-list.tsx +76 -0
- package/src/components/inputs-values-tree/index.tsx +56 -0
- package/src/components/inputs-values-tree/row.tsx +173 -0
- package/src/components/inputs-values-tree/styles.tsx +128 -0
- package/src/components/inputs-values-tree/types.ts +21 -0
- package/src/components/json-schema-editor/default-value.tsx +1 -3
- package/src/components/json-schema-editor/hooks.tsx +13 -2
- package/src/components/json-schema-editor/index.tsx +17 -57
- package/src/components/json-schema-editor/styles.tsx +12 -55
- package/src/components/json-schema-editor/types.ts +0 -1
- package/src/components/prompt-editor/index.tsx +10 -3
- package/src/effects/auto-rename-ref/index.ts +7 -54
- package/src/form-plugins/infer-inputs-plugin/index.ts +3 -75
- package/src/hooks/use-object-list/index.tsx +34 -6
- package/src/plugins/json-schema-preset/manager.ts +1 -0
- package/src/plugins/json-schema-preset/type-definition/string.tsx +18 -9
- package/src/shared/flow-value/index.ts +6 -0
- package/src/shared/flow-value/schema.ts +38 -0
- package/src/shared/flow-value/utils.ts +201 -0
- package/src/shared/index.ts +1 -0
- package/src/typings/flow-value/index.ts +2 -0
- package/src/components/json-schema-editor/components/blur-input.tsx +0 -27
- package/src/plugins/disable-declaration-plugin/config.json +0 -5
- package/src/plugins/json-schema-preset/config.json +0 -9
- /package/src/components/{inputs-values/components/blur-input.tsx → blur-input/index.tsx} +0 -0
package/dist/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.any().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,24 +1576,32 @@ 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
|
}
|
|
1490
1601
|
`;
|
|
1491
1602
|
|
|
1492
1603
|
// src/components/dynamic-value-input/hooks.ts
|
|
1493
|
-
import { useMemo as useMemo5, useState as useState4 } from "react";
|
|
1604
|
+
import { useEffect as useEffect4, useMemo as useMemo5, useRef as useRef3, useState as useState4 } from "react";
|
|
1494
1605
|
import { useScopeAvailable } from "@flowgram.ai/editor";
|
|
1495
1606
|
function useRefVariable(value) {
|
|
1496
1607
|
const available = useScopeAvailable();
|
|
@@ -1506,8 +1617,25 @@ function useSelectSchema(schemaFromProps, constantProps, value) {
|
|
|
1506
1617
|
if (value?.type === "constant") {
|
|
1507
1618
|
defaultSelectSchema = value?.schema || defaultSelectSchema;
|
|
1508
1619
|
}
|
|
1620
|
+
const changeVersion = useRef3(0);
|
|
1621
|
+
const effectVersion = useRef3(0);
|
|
1509
1622
|
const [selectSchema, setSelectSchema] = useState4(defaultSelectSchema);
|
|
1510
|
-
|
|
1623
|
+
useEffect4(() => {
|
|
1624
|
+
effectVersion.current += 1;
|
|
1625
|
+
if (changeVersion.current === effectVersion.current) {
|
|
1626
|
+
return;
|
|
1627
|
+
}
|
|
1628
|
+
effectVersion.current = changeVersion.current;
|
|
1629
|
+
if (value?.type === "constant" && value?.schema) {
|
|
1630
|
+
setSelectSchema(value?.schema);
|
|
1631
|
+
return;
|
|
1632
|
+
}
|
|
1633
|
+
}, [value]);
|
|
1634
|
+
const setSelectSchemaWithVersionUpdate = (schema) => {
|
|
1635
|
+
setSelectSchema(schema);
|
|
1636
|
+
changeVersion.current += 1;
|
|
1637
|
+
};
|
|
1638
|
+
return [selectSchema, setSelectSchemaWithVersionUpdate];
|
|
1511
1639
|
}
|
|
1512
1640
|
function useIncludeSchema(schemaFromProps) {
|
|
1513
1641
|
const includeSchema = useMemo5(() => {
|
|
@@ -1539,7 +1667,7 @@ function DynamicValueInput({
|
|
|
1539
1667
|
return /* @__PURE__ */ React20.createElement(TypeSelector, { value: schemaFromProps, readonly: true });
|
|
1540
1668
|
}
|
|
1541
1669
|
if (value?.type === "ref") {
|
|
1542
|
-
const schema = refVariable?.type ?
|
|
1670
|
+
const schema = refVariable?.type ? JsonSchemaUtils4.astToSchema(refVariable?.type) : void 0;
|
|
1543
1671
|
return /* @__PURE__ */ React20.createElement(TypeSelector, { value: schema, readonly: true });
|
|
1544
1672
|
}
|
|
1545
1673
|
return /* @__PURE__ */ React20.createElement(
|
|
@@ -1581,15 +1709,14 @@ function DynamicValueInput({
|
|
|
1581
1709
|
}
|
|
1582
1710
|
);
|
|
1583
1711
|
}
|
|
1584
|
-
const
|
|
1712
|
+
const constantSchema2 = schemaFromProps || selectSchema || { type: "string" };
|
|
1585
1713
|
return /* @__PURE__ */ React20.createElement(
|
|
1586
1714
|
ConstantInput,
|
|
1587
1715
|
{
|
|
1588
1716
|
value: value?.content,
|
|
1589
|
-
onChange: (_v) => onChange({ type: "constant", content: _v, schema:
|
|
1590
|
-
schema:
|
|
1717
|
+
onChange: (_v) => onChange({ type: "constant", content: _v, schema: constantSchema2 }),
|
|
1718
|
+
schema: constantSchema2 || { type: "string" },
|
|
1591
1719
|
readonly,
|
|
1592
|
-
strategies: [...constantProps?.strategies || []],
|
|
1593
1720
|
fallbackRenderer: () => /* @__PURE__ */ React20.createElement(
|
|
1594
1721
|
InjectVariableSelector,
|
|
1595
1722
|
{
|
|
@@ -1599,7 +1726,8 @@ function DynamicValueInput({
|
|
|
1599
1726
|
readonly
|
|
1600
1727
|
}
|
|
1601
1728
|
),
|
|
1602
|
-
...constantProps
|
|
1729
|
+
...constantProps,
|
|
1730
|
+
strategies: [...constantProps?.strategies || []]
|
|
1603
1731
|
}
|
|
1604
1732
|
);
|
|
1605
1733
|
};
|
|
@@ -1648,7 +1776,7 @@ var UIValues = styled5.div`
|
|
|
1648
1776
|
|
|
1649
1777
|
// src/components/condition-row/hooks/useRule.ts
|
|
1650
1778
|
import { useMemo as useMemo6 } from "react";
|
|
1651
|
-
import { JsonSchemaUtils as
|
|
1779
|
+
import { JsonSchemaUtils as JsonSchemaUtils5 } from "@flowgram.ai/json-schema";
|
|
1652
1780
|
import { useScopeAvailable as useScopeAvailable2 } from "@flowgram.ai/editor";
|
|
1653
1781
|
|
|
1654
1782
|
// src/components/condition-row/constants.ts
|
|
@@ -1781,7 +1909,7 @@ function useRule(left, userRules) {
|
|
|
1781
1909
|
}, [available, left]);
|
|
1782
1910
|
const rule = useMemo6(() => {
|
|
1783
1911
|
if (!variable) return void 0;
|
|
1784
|
-
const schema =
|
|
1912
|
+
const schema = JsonSchemaUtils5.astToSchema(variable.type, { drilldown: false });
|
|
1785
1913
|
return rules[schema?.type];
|
|
1786
1914
|
}, [variable?.type, rules]);
|
|
1787
1915
|
return { rule };
|
|
@@ -1880,13 +2008,14 @@ function ConditionRow({
|
|
|
1880
2008
|
|
|
1881
2009
|
// src/components/batch-outputs/index.tsx
|
|
1882
2010
|
import React23 from "react";
|
|
2011
|
+
import { I18n as I18n12 } from "@flowgram.ai/editor";
|
|
1883
2012
|
import { Button as Button3, Input as Input5 } from "@douyinfe/semi-ui";
|
|
1884
2013
|
import { IconDelete, IconPlus as IconPlus2 } from "@douyinfe/semi-icons";
|
|
1885
2014
|
|
|
1886
2015
|
// src/hooks/use-object-list/index.tsx
|
|
1887
|
-
import { useEffect as
|
|
2016
|
+
import { useEffect as useEffect5, useRef as useRef4, useState as useState5 } from "react";
|
|
1888
2017
|
import { nanoid } from "nanoid";
|
|
1889
|
-
import { difference as difference2, get, isObject as
|
|
2018
|
+
import { difference as difference2, get, isObject as isObject3, set } from "lodash";
|
|
1890
2019
|
function genId2() {
|
|
1891
2020
|
return nanoid();
|
|
1892
2021
|
}
|
|
@@ -1896,9 +2025,22 @@ function useObjectList({
|
|
|
1896
2025
|
sortIndexKey
|
|
1897
2026
|
}) {
|
|
1898
2027
|
const [list, setList] = useState5([]);
|
|
1899
|
-
|
|
2028
|
+
const effectVersion = useRef4(0);
|
|
2029
|
+
const changeVersion = useRef4(0);
|
|
2030
|
+
const getSortIndex = (value2) => {
|
|
2031
|
+
if (typeof sortIndexKey === "function") {
|
|
2032
|
+
return get(value2, sortIndexKey(value2)) || 0;
|
|
2033
|
+
}
|
|
2034
|
+
return get(value2, sortIndexKey || "") || 0;
|
|
2035
|
+
};
|
|
2036
|
+
useEffect5(() => {
|
|
2037
|
+
effectVersion.current = effectVersion.current + 1;
|
|
2038
|
+
if (effectVersion.current === changeVersion.current) {
|
|
2039
|
+
return;
|
|
2040
|
+
}
|
|
2041
|
+
effectVersion.current = changeVersion.current;
|
|
1900
2042
|
setList((_prevList) => {
|
|
1901
|
-
const newKeys = Object.entries(value || {}).sort((a, b) =>
|
|
2043
|
+
const newKeys = Object.entries(value || {}).sort((a, b) => getSortIndex(a[1]) - getSortIndex(b[1])).map(([key]) => key);
|
|
1902
2044
|
const oldKeys = _prevList.map((item) => item.key).filter(Boolean);
|
|
1903
2045
|
const addKeys = difference2(newKeys, oldKeys);
|
|
1904
2046
|
return _prevList.filter((item) => !item.key || newKeys.includes(item.key)).map((item) => ({
|
|
@@ -1914,15 +2056,17 @@ function useObjectList({
|
|
|
1914
2056
|
);
|
|
1915
2057
|
});
|
|
1916
2058
|
}, [value]);
|
|
1917
|
-
const add = () => {
|
|
2059
|
+
const add = (defaultValue) => {
|
|
1918
2060
|
setList((prevList) => [
|
|
1919
2061
|
...prevList,
|
|
1920
2062
|
{
|
|
1921
|
-
id: genId2()
|
|
2063
|
+
id: genId2(),
|
|
2064
|
+
value: defaultValue
|
|
1922
2065
|
}
|
|
1923
2066
|
]);
|
|
1924
2067
|
};
|
|
1925
2068
|
const updateValue = (itemId, value2) => {
|
|
2069
|
+
changeVersion.current = changeVersion.current + 1;
|
|
1926
2070
|
setList((prevList) => {
|
|
1927
2071
|
const nextList = prevList.map((_item) => {
|
|
1928
2072
|
if (_item.id === itemId) {
|
|
@@ -1936,8 +2080,9 @@ function useObjectList({
|
|
|
1936
2080
|
onChange(
|
|
1937
2081
|
Object.fromEntries(
|
|
1938
2082
|
nextList.filter((item) => item.key).map((item) => [item.key, item.value]).map((_res, idx) => {
|
|
1939
|
-
|
|
1940
|
-
|
|
2083
|
+
const indexKey = typeof sortIndexKey === "function" ? sortIndexKey(_res[1]) : sortIndexKey;
|
|
2084
|
+
if (isObject3(_res[1]) && indexKey) {
|
|
2085
|
+
set(_res[1], indexKey, idx);
|
|
1941
2086
|
}
|
|
1942
2087
|
return _res;
|
|
1943
2088
|
})
|
|
@@ -1947,6 +2092,7 @@ function useObjectList({
|
|
|
1947
2092
|
});
|
|
1948
2093
|
};
|
|
1949
2094
|
const updateKey = (itemId, key) => {
|
|
2095
|
+
changeVersion.current = changeVersion.current + 1;
|
|
1950
2096
|
setList((prevList) => {
|
|
1951
2097
|
const nextList = prevList.map((_item) => {
|
|
1952
2098
|
if (_item.id === itemId) {
|
|
@@ -1966,6 +2112,7 @@ function useObjectList({
|
|
|
1966
2112
|
});
|
|
1967
2113
|
};
|
|
1968
2114
|
const remove = (itemId) => {
|
|
2115
|
+
changeVersion.current = changeVersion.current + 1;
|
|
1969
2116
|
setList((prevList) => {
|
|
1970
2117
|
const nextList = prevList.filter((_item) => _item.id !== itemId);
|
|
1971
2118
|
onChange(
|
|
@@ -2022,11 +2169,11 @@ function BatchOutputs(props) {
|
|
|
2022
2169
|
size: "small",
|
|
2023
2170
|
onClick: () => remove(item.id)
|
|
2024
2171
|
}
|
|
2025
|
-
)))), /* @__PURE__ */ React23.createElement(Button3, { disabled: readonly, icon: /* @__PURE__ */ React23.createElement(IconPlus2, null), size: "small", onClick: add }, "Add"));
|
|
2172
|
+
)))), /* @__PURE__ */ React23.createElement(Button3, { disabled: readonly, icon: /* @__PURE__ */ React23.createElement(IconPlus2, null), size: "small", onClick: () => add() }, I18n12.t("Add")));
|
|
2026
2173
|
}
|
|
2027
2174
|
|
|
2028
2175
|
// src/components/prompt-editor/index.tsx
|
|
2029
|
-
import React24, { useEffect as
|
|
2176
|
+
import React24, { useEffect as useEffect6, useRef as useRef5 } from "react";
|
|
2030
2177
|
import { Renderer, EditorProvider as EditorProvider2, ActiveLinePlaceholder as ActiveLinePlaceholder2 } from "@coze-editor/editor/react";
|
|
2031
2178
|
import preset2 from "@coze-editor/editor/preset-prompt";
|
|
2032
2179
|
|
|
@@ -2168,10 +2315,11 @@ function PromptEditor(props) {
|
|
|
2168
2315
|
style,
|
|
2169
2316
|
hasError,
|
|
2170
2317
|
children,
|
|
2171
|
-
disableMarkdownHighlight
|
|
2318
|
+
disableMarkdownHighlight,
|
|
2319
|
+
options
|
|
2172
2320
|
} = props || {};
|
|
2173
|
-
const editorRef =
|
|
2174
|
-
|
|
2321
|
+
const editorRef = useRef5(null);
|
|
2322
|
+
useEffect6(() => {
|
|
2175
2323
|
if (editorRef.current?.getValue() !== value?.content) {
|
|
2176
2324
|
editorRef.current?.setValue(String(value?.content || ""));
|
|
2177
2325
|
}
|
|
@@ -2187,7 +2335,8 @@ function PromptEditor(props) {
|
|
|
2187
2335
|
options: {
|
|
2188
2336
|
readOnly: readonly,
|
|
2189
2337
|
editable: !readonly,
|
|
2190
|
-
placeholder
|
|
2338
|
+
placeholder,
|
|
2339
|
+
...options
|
|
2191
2340
|
},
|
|
2192
2341
|
onChange: (e) => {
|
|
2193
2342
|
onChange({ type: "template", content: e.value });
|
|
@@ -2200,7 +2349,7 @@ function PromptEditor(props) {
|
|
|
2200
2349
|
import React27 from "react";
|
|
2201
2350
|
|
|
2202
2351
|
// src/components/prompt-editor-with-variables/extensions/variable-tree.tsx
|
|
2203
|
-
import React25, { useEffect as
|
|
2352
|
+
import React25, { useEffect as useEffect7, useState as useState6 } from "react";
|
|
2204
2353
|
import { Popover as Popover2, Tree } from "@douyinfe/semi-ui";
|
|
2205
2354
|
import {
|
|
2206
2355
|
Mention,
|
|
@@ -2228,7 +2377,7 @@ function VariableTree() {
|
|
|
2228
2377
|
setPosition(e.state.selection.main.head);
|
|
2229
2378
|
setVisible(e.value);
|
|
2230
2379
|
}
|
|
2231
|
-
|
|
2380
|
+
useEffect7(() => {
|
|
2232
2381
|
if (!editor) {
|
|
2233
2382
|
return;
|
|
2234
2383
|
}
|
|
@@ -2433,7 +2582,7 @@ function PromptEditorWithVariables(props) {
|
|
|
2433
2582
|
import React30 from "react";
|
|
2434
2583
|
|
|
2435
2584
|
// src/components/prompt-editor-with-inputs/extensions/inputs-tree.tsx
|
|
2436
|
-
import React29, { useEffect as
|
|
2585
|
+
import React29, { useEffect as useEffect8, useState as useState7 } from "react";
|
|
2437
2586
|
import { Popover as Popover4 } from "@douyinfe/semi-ui";
|
|
2438
2587
|
import {
|
|
2439
2588
|
Mention as Mention2,
|
|
@@ -2527,7 +2676,7 @@ function InputsTree({ inputsValues }) {
|
|
|
2527
2676
|
setPosition(e.state.selection.main.head);
|
|
2528
2677
|
setVisible(e.value);
|
|
2529
2678
|
}
|
|
2530
|
-
|
|
2679
|
+
useEffect8(() => {
|
|
2531
2680
|
if (!editor) {
|
|
2532
2681
|
return;
|
|
2533
2682
|
}
|
|
@@ -2569,7 +2718,7 @@ import React33 from "react";
|
|
|
2569
2718
|
import { transformerCreator } from "@coze-editor/editor/preset-code";
|
|
2570
2719
|
|
|
2571
2720
|
// src/components/json-editor-with-variables/extensions/variable-tree.tsx
|
|
2572
|
-
import React31, { useEffect as
|
|
2721
|
+
import React31, { useEffect as useEffect9, useState as useState8 } from "react";
|
|
2573
2722
|
import { Popover as Popover5, Tree as Tree3 } from "@douyinfe/semi-ui";
|
|
2574
2723
|
import {
|
|
2575
2724
|
Mention as Mention3,
|
|
@@ -2597,7 +2746,7 @@ function VariableTree2() {
|
|
|
2597
2746
|
setPosition(e.state.selection.main.head);
|
|
2598
2747
|
setVisible(e.value);
|
|
2599
2748
|
}
|
|
2600
|
-
|
|
2749
|
+
useEffect9(() => {
|
|
2601
2750
|
if (!editor) {
|
|
2602
2751
|
return;
|
|
2603
2752
|
}
|
|
@@ -2836,8 +2985,8 @@ function JsonEditorWithVariables(props) {
|
|
|
2836
2985
|
}
|
|
2837
2986
|
|
|
2838
2987
|
// src/components/inputs-values/index.tsx
|
|
2839
|
-
import
|
|
2840
|
-
import { I18n as
|
|
2988
|
+
import React34 from "react";
|
|
2989
|
+
import { I18n as I18n13 } from "@flowgram.ai/editor";
|
|
2841
2990
|
import { Button as Button4, IconButton as IconButton4 } from "@douyinfe/semi-ui";
|
|
2842
2991
|
import { IconDelete as IconDelete2, IconPlus as IconPlus3 } from "@douyinfe/semi-icons";
|
|
2843
2992
|
|
|
@@ -2851,31 +3000,10 @@ var UIRows2 = styled10.div`
|
|
|
2851
3000
|
`;
|
|
2852
3001
|
var UIRow3 = styled10.div`
|
|
2853
3002
|
display: flex;
|
|
2854
|
-
align-items:
|
|
3003
|
+
align-items: flex-start;
|
|
2855
3004
|
gap: 5px;
|
|
2856
3005
|
`;
|
|
2857
3006
|
|
|
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
3007
|
// src/components/inputs-values/index.tsx
|
|
2880
3008
|
function InputsValues({
|
|
2881
3009
|
value,
|
|
@@ -2891,17 +3019,17 @@ function InputsValues({
|
|
|
2891
3019
|
onChange,
|
|
2892
3020
|
sortIndexKey: "extra.index"
|
|
2893
3021
|
});
|
|
2894
|
-
return /* @__PURE__ */
|
|
2895
|
-
|
|
3022
|
+
return /* @__PURE__ */ React34.createElement("div", null, /* @__PURE__ */ React34.createElement(UIRows2, { style }, list.map((item) => /* @__PURE__ */ React34.createElement(UIRow3, { key: item.id }, /* @__PURE__ */ React34.createElement(
|
|
3023
|
+
BlurInput,
|
|
2896
3024
|
{
|
|
2897
3025
|
style: { width: 100, minWidth: 100, maxWidth: 100 },
|
|
2898
3026
|
disabled: readonly,
|
|
2899
3027
|
size: "small",
|
|
2900
3028
|
value: item.key,
|
|
2901
3029
|
onChange: (v) => updateKey(item.id, v),
|
|
2902
|
-
placeholder:
|
|
3030
|
+
placeholder: I18n13.t("Input Key")
|
|
2903
3031
|
}
|
|
2904
|
-
), /* @__PURE__ */
|
|
3032
|
+
), /* @__PURE__ */ React34.createElement(
|
|
2905
3033
|
InjectDynamicValueInput,
|
|
2906
3034
|
{
|
|
2907
3035
|
style: { flexGrow: 1 },
|
|
@@ -2915,20 +3043,20 @@ function InputsValues({
|
|
|
2915
3043
|
strategies: [...constantProps?.strategies || []]
|
|
2916
3044
|
}
|
|
2917
3045
|
}
|
|
2918
|
-
), /* @__PURE__ */
|
|
3046
|
+
), /* @__PURE__ */ React34.createElement(
|
|
2919
3047
|
IconButton4,
|
|
2920
3048
|
{
|
|
2921
3049
|
disabled: readonly,
|
|
2922
3050
|
theme: "borderless",
|
|
2923
|
-
icon: /* @__PURE__ */
|
|
3051
|
+
icon: /* @__PURE__ */ React34.createElement(IconDelete2, { size: "small" }),
|
|
2924
3052
|
size: "small",
|
|
2925
3053
|
onClick: () => remove(item.id)
|
|
2926
3054
|
}
|
|
2927
|
-
)))), /* @__PURE__ */
|
|
3055
|
+
)))), /* @__PURE__ */ React34.createElement(Button4, { disabled: readonly, icon: /* @__PURE__ */ React34.createElement(IconPlus3, null), size: "small", onClick: () => add() }, I18n13.t("Add")));
|
|
2928
3056
|
}
|
|
2929
3057
|
|
|
2930
3058
|
// src/components/display-schema-tree/index.tsx
|
|
2931
|
-
import
|
|
3059
|
+
import React35 from "react";
|
|
2932
3060
|
|
|
2933
3061
|
// src/components/display-schema-tree/styles.tsx
|
|
2934
3062
|
import styled11, { css as css4 } from "styled-components";
|
|
@@ -3012,7 +3140,7 @@ var TreeItem = styled11.div`
|
|
|
3012
3140
|
|
|
3013
3141
|
// src/components/display-schema-tree/index.tsx
|
|
3014
3142
|
function DisplaySchemaTree(props) {
|
|
3015
|
-
return /* @__PURE__ */
|
|
3143
|
+
return /* @__PURE__ */ React35.createElement(SchemaTree, { ...props });
|
|
3016
3144
|
}
|
|
3017
3145
|
function SchemaTree(props) {
|
|
3018
3146
|
const {
|
|
@@ -3028,18 +3156,18 @@ function SchemaTree(props) {
|
|
|
3028
3156
|
const icon = typeManager?.getDisplayIcon(schema);
|
|
3029
3157
|
let properties = drilldown && config ? config.getTypeSchemaProperties(schema) : {};
|
|
3030
3158
|
const childEntries = Object.entries(properties || {});
|
|
3031
|
-
return /* @__PURE__ */
|
|
3159
|
+
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
3160
|
className: "tree-icon"
|
|
3033
|
-
}), /* @__PURE__ */
|
|
3161
|
+
}), /* @__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
3162
|
}
|
|
3035
3163
|
|
|
3036
3164
|
// src/components/display-outputs/index.tsx
|
|
3037
|
-
import
|
|
3038
|
-
import { JsonSchemaUtils as
|
|
3165
|
+
import React37, { useEffect as useEffect10 } from "react";
|
|
3166
|
+
import { JsonSchemaUtils as JsonSchemaUtils6 } from "@flowgram.ai/json-schema";
|
|
3039
3167
|
import { useCurrentScope as useCurrentScope3, useRefresh } from "@flowgram.ai/editor";
|
|
3040
3168
|
|
|
3041
3169
|
// src/components/display-schema-tag/index.tsx
|
|
3042
|
-
import
|
|
3170
|
+
import React36 from "react";
|
|
3043
3171
|
import { Popover as Popover7 } from "@douyinfe/semi-ui";
|
|
3044
3172
|
|
|
3045
3173
|
// src/components/display-schema-tag/styles.ts
|
|
@@ -3068,14 +3196,14 @@ var TitleSpan = styled12.span`
|
|
|
3068
3196
|
function DisplaySchemaTag({ value = {}, showIconInTree, title, warning }) {
|
|
3069
3197
|
const typeManager = useTypeManager();
|
|
3070
3198
|
const icon = typeManager?.getDisplayIcon(value) || typeManager.getDisplayIcon({ type: "unknown" });
|
|
3071
|
-
return /* @__PURE__ */
|
|
3199
|
+
return /* @__PURE__ */ React36.createElement(
|
|
3072
3200
|
Popover7,
|
|
3073
3201
|
{
|
|
3074
|
-
content: /* @__PURE__ */
|
|
3202
|
+
content: /* @__PURE__ */ React36.createElement(PopoverContent, null, /* @__PURE__ */ React36.createElement(DisplaySchemaTree, { value, typeManager, showIcon: showIconInTree }))
|
|
3075
3203
|
},
|
|
3076
|
-
/* @__PURE__ */
|
|
3204
|
+
/* @__PURE__ */ React36.createElement(StyledTag, { color: warning ? "amber" : "white" }, icon && React36.cloneElement(icon, {
|
|
3077
3205
|
className: "tag-icon"
|
|
3078
|
-
}), title && /* @__PURE__ */
|
|
3206
|
+
}), title && /* @__PURE__ */ React36.createElement(TitleSpan, null, title))
|
|
3079
3207
|
);
|
|
3080
3208
|
}
|
|
3081
3209
|
|
|
@@ -3105,12 +3233,12 @@ function DisplayOutputs({ value, showIconInTree, displayFromScope }) {
|
|
|
3105
3233
|
const properties = displayFromScope ? scope.output.variables?.reduce((acm, curr) => {
|
|
3106
3234
|
acm = {
|
|
3107
3235
|
...acm,
|
|
3108
|
-
...
|
|
3236
|
+
...JsonSchemaUtils6.astToSchema(curr.type)?.properties || {}
|
|
3109
3237
|
};
|
|
3110
3238
|
return acm;
|
|
3111
3239
|
}, {}) : value?.properties || {};
|
|
3112
3240
|
const childEntries = Object.entries(properties || {});
|
|
3113
|
-
return /* @__PURE__ */
|
|
3241
|
+
return /* @__PURE__ */ React37.createElement(DisplayOutputsWrapper, null, childEntries.map(([key, schema]) => /* @__PURE__ */ React37.createElement(
|
|
3114
3242
|
DisplaySchemaTag,
|
|
3115
3243
|
{
|
|
3116
3244
|
key,
|
|
@@ -3123,36 +3251,25 @@ function DisplayOutputs({ value, showIconInTree, displayFromScope }) {
|
|
|
3123
3251
|
}
|
|
3124
3252
|
|
|
3125
3253
|
// src/components/display-flow-value/index.tsx
|
|
3126
|
-
import
|
|
3127
|
-
import { JsonSchemaUtils as
|
|
3254
|
+
import React38, { useMemo as useMemo10 } from "react";
|
|
3255
|
+
import { JsonSchemaUtils as JsonSchemaUtils7 } from "@flowgram.ai/json-schema";
|
|
3128
3256
|
import { useScopeAvailable as useScopeAvailable4 } from "@flowgram.ai/editor";
|
|
3129
3257
|
function DisplayFlowValue({ value, title, showIconInTree }) {
|
|
3130
3258
|
const available = useScopeAvailable4();
|
|
3131
3259
|
const variable = value?.type === "ref" ? available.getByKeyPath(value?.content) : void 0;
|
|
3132
3260
|
const schema = useMemo10(() => {
|
|
3133
3261
|
if (value?.type === "ref") {
|
|
3134
|
-
return
|
|
3262
|
+
return JsonSchemaUtils7.astToSchema(variable?.type);
|
|
3135
3263
|
}
|
|
3136
3264
|
if (value?.type === "template") {
|
|
3137
3265
|
return { type: "string" };
|
|
3138
3266
|
}
|
|
3139
3267
|
if (value?.type === "constant") {
|
|
3140
|
-
|
|
3141
|
-
return value?.schema;
|
|
3142
|
-
}
|
|
3143
|
-
if (typeof value?.content === "string") {
|
|
3144
|
-
return { type: "string" };
|
|
3145
|
-
}
|
|
3146
|
-
if (typeof value?.content === "number") {
|
|
3147
|
-
return { type: "number" };
|
|
3148
|
-
}
|
|
3149
|
-
if (typeof value?.content === "boolean") {
|
|
3150
|
-
return { type: "boolean" };
|
|
3151
|
-
}
|
|
3268
|
+
return FlowValueUtils.inferConstantJsonSchema(value);
|
|
3152
3269
|
}
|
|
3153
3270
|
return { type: "unknown" };
|
|
3154
3271
|
}, [value, variable?.hash]);
|
|
3155
|
-
return /* @__PURE__ */
|
|
3272
|
+
return /* @__PURE__ */ React38.createElement(
|
|
3156
3273
|
DisplaySchemaTag,
|
|
3157
3274
|
{
|
|
3158
3275
|
title,
|
|
@@ -3164,7 +3281,9 @@ function DisplayFlowValue({ value, title, showIconInTree }) {
|
|
|
3164
3281
|
}
|
|
3165
3282
|
|
|
3166
3283
|
// src/components/display-inputs-values/index.tsx
|
|
3167
|
-
import
|
|
3284
|
+
import React39, { useMemo as useMemo11 } from "react";
|
|
3285
|
+
import { isPlainObject as isPlainObject2 } from "lodash";
|
|
3286
|
+
import { useScopeAvailable as useScopeAvailable5 } from "@flowgram.ai/editor";
|
|
3168
3287
|
|
|
3169
3288
|
// src/components/display-inputs-values/styles.ts
|
|
3170
3289
|
import styled14 from "styled-components";
|
|
@@ -3177,30 +3296,58 @@ var DisplayInputsWrapper = styled14.div`
|
|
|
3177
3296
|
// src/components/display-inputs-values/index.tsx
|
|
3178
3297
|
function DisplayInputsValues({ value, showIconInTree }) {
|
|
3179
3298
|
const childEntries = Object.entries(value || {});
|
|
3180
|
-
return /* @__PURE__ */
|
|
3299
|
+
return /* @__PURE__ */ React39.createElement(DisplayInputsWrapper, null, childEntries.map(([key, value2]) => {
|
|
3300
|
+
if (FlowValueUtils.isFlowValue(value2)) {
|
|
3301
|
+
return /* @__PURE__ */ React39.createElement(DisplayFlowValue, { key, title: key, value: value2, showIconInTree });
|
|
3302
|
+
}
|
|
3303
|
+
if (isPlainObject2(value2)) {
|
|
3304
|
+
return /* @__PURE__ */ React39.createElement(
|
|
3305
|
+
DisplayInputsValueAllInTag,
|
|
3306
|
+
{
|
|
3307
|
+
key,
|
|
3308
|
+
title: key,
|
|
3309
|
+
value: value2,
|
|
3310
|
+
showIconInTree
|
|
3311
|
+
}
|
|
3312
|
+
);
|
|
3313
|
+
}
|
|
3314
|
+
return null;
|
|
3315
|
+
}));
|
|
3316
|
+
}
|
|
3317
|
+
function DisplayInputsValueAllInTag({
|
|
3318
|
+
value,
|
|
3319
|
+
title,
|
|
3320
|
+
showIconInTree
|
|
3321
|
+
}) {
|
|
3322
|
+
const available = useScopeAvailable5();
|
|
3323
|
+
const schema = useMemo11(
|
|
3324
|
+
() => FlowValueUtils.inferJsonSchema(value, available.scope),
|
|
3325
|
+
[available.version, value]
|
|
3326
|
+
);
|
|
3327
|
+
return /* @__PURE__ */ React39.createElement(DisplaySchemaTag, { title, value: schema, showIconInTree });
|
|
3181
3328
|
}
|
|
3182
3329
|
|
|
3183
3330
|
// src/components/assign-rows/index.tsx
|
|
3184
|
-
import
|
|
3331
|
+
import React42 from "react";
|
|
3185
3332
|
import { FieldArray } from "@flowgram.ai/editor";
|
|
3186
3333
|
import { Button as Button5 } from "@douyinfe/semi-ui";
|
|
3187
3334
|
import { IconPlus as IconPlus4 } from "@douyinfe/semi-icons";
|
|
3188
3335
|
|
|
3189
3336
|
// src/components/assign-row/index.tsx
|
|
3190
|
-
import
|
|
3337
|
+
import React41 from "react";
|
|
3191
3338
|
import { IconButton as IconButton5 } from "@douyinfe/semi-ui";
|
|
3192
3339
|
import { IconMinus as IconMinus2 } from "@douyinfe/semi-icons";
|
|
3193
3340
|
|
|
3194
3341
|
// src/components/assign-row/components/blur-input.tsx
|
|
3195
|
-
import
|
|
3196
|
-
import
|
|
3197
|
-
function
|
|
3198
|
-
const [value, setValue] =
|
|
3342
|
+
import React40, { useEffect as useEffect11, useState as useState9 } from "react";
|
|
3343
|
+
import Input6 from "@douyinfe/semi-ui/lib/es/input";
|
|
3344
|
+
function BlurInput2(props) {
|
|
3345
|
+
const [value, setValue] = useState9("");
|
|
3199
3346
|
useEffect11(() => {
|
|
3200
3347
|
setValue(props.value);
|
|
3201
3348
|
}, [props.value]);
|
|
3202
|
-
return /* @__PURE__ */
|
|
3203
|
-
|
|
3349
|
+
return /* @__PURE__ */ React40.createElement(
|
|
3350
|
+
Input6,
|
|
3204
3351
|
{
|
|
3205
3352
|
...props,
|
|
3206
3353
|
value,
|
|
@@ -3222,7 +3369,7 @@ function AssignRow(props) {
|
|
|
3222
3369
|
onDelete,
|
|
3223
3370
|
readonly
|
|
3224
3371
|
} = props;
|
|
3225
|
-
return /* @__PURE__ */
|
|
3372
|
+
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
3373
|
InjectVariableSelector,
|
|
3227
3374
|
{
|
|
3228
3375
|
style: { width: "100%", height: 26 },
|
|
@@ -3233,8 +3380,8 @@ function AssignRow(props) {
|
|
|
3233
3380
|
left: { type: "ref", content: v }
|
|
3234
3381
|
})
|
|
3235
3382
|
}
|
|
3236
|
-
) : /* @__PURE__ */
|
|
3237
|
-
|
|
3383
|
+
) : /* @__PURE__ */ React41.createElement(
|
|
3384
|
+
BlurInput2,
|
|
3238
3385
|
{
|
|
3239
3386
|
style: { height: 26 },
|
|
3240
3387
|
size: "small",
|
|
@@ -3245,7 +3392,7 @@ function AssignRow(props) {
|
|
|
3245
3392
|
left: v
|
|
3246
3393
|
})
|
|
3247
3394
|
}
|
|
3248
|
-
)), /* @__PURE__ */
|
|
3395
|
+
)), /* @__PURE__ */ React41.createElement("div", { style: { flexGrow: 1 } }, /* @__PURE__ */ React41.createElement(
|
|
3249
3396
|
InjectDynamicValueInput,
|
|
3250
3397
|
{
|
|
3251
3398
|
readonly,
|
|
@@ -3255,12 +3402,12 @@ function AssignRow(props) {
|
|
|
3255
3402
|
right: v
|
|
3256
3403
|
})
|
|
3257
3404
|
}
|
|
3258
|
-
)), onDelete && /* @__PURE__ */
|
|
3405
|
+
)), onDelete && /* @__PURE__ */ React41.createElement("div", null, /* @__PURE__ */ React41.createElement(
|
|
3259
3406
|
IconButton5,
|
|
3260
3407
|
{
|
|
3261
3408
|
size: "small",
|
|
3262
3409
|
theme: "borderless",
|
|
3263
|
-
icon: /* @__PURE__ */
|
|
3410
|
+
icon: /* @__PURE__ */ React41.createElement(IconMinus2, null),
|
|
3264
3411
|
onClick: () => onDelete?.()
|
|
3265
3412
|
}
|
|
3266
3413
|
)));
|
|
@@ -3269,7 +3416,7 @@ function AssignRow(props) {
|
|
|
3269
3416
|
// src/components/assign-rows/index.tsx
|
|
3270
3417
|
function AssignRows(props) {
|
|
3271
3418
|
const { name, readonly } = props;
|
|
3272
|
-
return /* @__PURE__ */
|
|
3419
|
+
return /* @__PURE__ */ React42.createElement(FieldArray, { name }, ({ field }) => /* @__PURE__ */ React42.createElement(React42.Fragment, null, field.map((childField, index) => /* @__PURE__ */ React42.createElement(
|
|
3273
3420
|
AssignRow,
|
|
3274
3421
|
{
|
|
3275
3422
|
key: childField.key,
|
|
@@ -3280,27 +3427,331 @@ function AssignRows(props) {
|
|
|
3280
3427
|
},
|
|
3281
3428
|
onDelete: () => field.remove(index)
|
|
3282
3429
|
}
|
|
3283
|
-
)), /* @__PURE__ */
|
|
3430
|
+
)), /* @__PURE__ */ React42.createElement("div", { style: { display: "flex", gap: 5 } }, /* @__PURE__ */ React42.createElement(
|
|
3284
3431
|
Button5,
|
|
3285
3432
|
{
|
|
3286
3433
|
size: "small",
|
|
3287
3434
|
theme: "borderless",
|
|
3288
|
-
icon: /* @__PURE__ */
|
|
3435
|
+
icon: /* @__PURE__ */ React42.createElement(IconPlus4, null),
|
|
3289
3436
|
onClick: () => field.append({ operator: "assign" })
|
|
3290
3437
|
},
|
|
3291
3438
|
"Assign"
|
|
3292
|
-
), /* @__PURE__ */
|
|
3439
|
+
), /* @__PURE__ */ React42.createElement(
|
|
3293
3440
|
Button5,
|
|
3294
3441
|
{
|
|
3295
3442
|
size: "small",
|
|
3296
3443
|
theme: "borderless",
|
|
3297
|
-
icon: /* @__PURE__ */
|
|
3444
|
+
icon: /* @__PURE__ */ React42.createElement(IconPlus4, null),
|
|
3298
3445
|
onClick: () => field.append({ operator: "declare" })
|
|
3299
3446
|
},
|
|
3300
3447
|
"Declaration"
|
|
3301
3448
|
))));
|
|
3302
3449
|
}
|
|
3303
3450
|
|
|
3451
|
+
// src/components/inputs-values-tree/index.tsx
|
|
3452
|
+
import React45 from "react";
|
|
3453
|
+
import { I18n as I18n15 } from "@flowgram.ai/editor";
|
|
3454
|
+
import { Button as Button6 } from "@douyinfe/semi-ui";
|
|
3455
|
+
import { IconPlus as IconPlus5 } from "@douyinfe/semi-icons";
|
|
3456
|
+
|
|
3457
|
+
// src/components/inputs-values-tree/styles.tsx
|
|
3458
|
+
import React43 from "react";
|
|
3459
|
+
import styled15, { css as css5 } from "styled-components";
|
|
3460
|
+
import Icon4 from "@douyinfe/semi-icons";
|
|
3461
|
+
var UIContainer5 = styled15.div``;
|
|
3462
|
+
var UIRow4 = styled15.div`
|
|
3463
|
+
display: flex;
|
|
3464
|
+
align-items: flex-start;
|
|
3465
|
+
gap: 5px;
|
|
3466
|
+
`;
|
|
3467
|
+
var UICollapseTrigger2 = styled15.div`
|
|
3468
|
+
cursor: pointer;
|
|
3469
|
+
margin-right: 5px;
|
|
3470
|
+
`;
|
|
3471
|
+
var UITreeItems2 = styled15.div`
|
|
3472
|
+
display: grid;
|
|
3473
|
+
grid-template-columns: auto 1fr;
|
|
3474
|
+
|
|
3475
|
+
${({ $shrink }) => $shrink && css5`
|
|
3476
|
+
padding-left: 3px;
|
|
3477
|
+
margin-top: 10px;
|
|
3478
|
+
`}
|
|
3479
|
+
`;
|
|
3480
|
+
var UITreeItemLeft2 = styled15.div`
|
|
3481
|
+
grid-column: 1;
|
|
3482
|
+
position: relative;
|
|
3483
|
+
width: 16px;
|
|
3484
|
+
|
|
3485
|
+
${({ $showLine, $isLast, $showCollapse }) => {
|
|
3486
|
+
let height = $isLast ? "24px" : "100%";
|
|
3487
|
+
let width = $showCollapse ? "12px" : "30px";
|
|
3488
|
+
return $showLine && css5`
|
|
3489
|
+
&::before {
|
|
3490
|
+
/* 竖线 */
|
|
3491
|
+
content: '';
|
|
3492
|
+
height: ${height};
|
|
3493
|
+
position: absolute;
|
|
3494
|
+
left: -14px;
|
|
3495
|
+
top: -16px;
|
|
3496
|
+
width: 1px;
|
|
3497
|
+
background: #d9d9d9;
|
|
3498
|
+
display: block;
|
|
3499
|
+
}
|
|
3500
|
+
|
|
3501
|
+
&::after {
|
|
3502
|
+
/* 横线 */
|
|
3503
|
+
content: '';
|
|
3504
|
+
position: absolute;
|
|
3505
|
+
left: -14px; // 横线起点和竖线对齐
|
|
3506
|
+
top: 8px; // 跟随你的行高调整
|
|
3507
|
+
width: ${width}; // 横线长度
|
|
3508
|
+
height: 1px;
|
|
3509
|
+
background: #d9d9d9;
|
|
3510
|
+
display: block;
|
|
3511
|
+
}
|
|
3512
|
+
`;
|
|
3513
|
+
}}
|
|
3514
|
+
`;
|
|
3515
|
+
var UITreeItemRight2 = styled15.div`
|
|
3516
|
+
grid-column: 2;
|
|
3517
|
+
margin-bottom: 10px;
|
|
3518
|
+
|
|
3519
|
+
&:last-child {
|
|
3520
|
+
margin-bottom: 0px;
|
|
3521
|
+
}
|
|
3522
|
+
`;
|
|
3523
|
+
var UITreeItemMain2 = styled15.div`
|
|
3524
|
+
display: flex;
|
|
3525
|
+
flex-direction: column;
|
|
3526
|
+
gap: 10px;
|
|
3527
|
+
position: relative;
|
|
3528
|
+
`;
|
|
3529
|
+
var UICollapsible2 = styled15.div`
|
|
3530
|
+
display: none;
|
|
3531
|
+
|
|
3532
|
+
${({ $collapse }) => $collapse && css5`
|
|
3533
|
+
display: block;
|
|
3534
|
+
`}
|
|
3535
|
+
`;
|
|
3536
|
+
var UIActions2 = styled15.div`
|
|
3537
|
+
white-space: nowrap;
|
|
3538
|
+
`;
|
|
3539
|
+
var iconAddChildrenSvg2 = /* @__PURE__ */ React43.createElement(
|
|
3540
|
+
"svg",
|
|
3541
|
+
{
|
|
3542
|
+
className: "icon-icon icon-icon-coz_add_node ",
|
|
3543
|
+
width: "1em",
|
|
3544
|
+
height: "1em",
|
|
3545
|
+
viewBox: "0 0 24 24",
|
|
3546
|
+
fill: "currentColor",
|
|
3547
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
3548
|
+
},
|
|
3549
|
+
/* @__PURE__ */ React43.createElement(
|
|
3550
|
+
"path",
|
|
3551
|
+
{
|
|
3552
|
+
fillRule: "evenodd",
|
|
3553
|
+
clipRule: "evenodd",
|
|
3554
|
+
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"
|
|
3555
|
+
}
|
|
3556
|
+
),
|
|
3557
|
+
/* @__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" })
|
|
3558
|
+
);
|
|
3559
|
+
var IconAddChildren2 = () => /* @__PURE__ */ React43.createElement(Icon4, { size: "small", svg: iconAddChildrenSvg2 });
|
|
3560
|
+
|
|
3561
|
+
// src/components/inputs-values-tree/row.tsx
|
|
3562
|
+
import React44, { useMemo as useMemo13, useState as useState10 } from "react";
|
|
3563
|
+
import { I18n as I18n14 } from "@flowgram.ai/editor";
|
|
3564
|
+
import { IconButton as IconButton6, Input as Input7 } from "@douyinfe/semi-ui";
|
|
3565
|
+
import { IconChevronDown as IconChevronDown2, IconChevronRight as IconChevronRight2, IconDelete as IconDelete3 } from "@douyinfe/semi-icons";
|
|
3566
|
+
|
|
3567
|
+
// src/components/inputs-values-tree/hooks/use-child-list.tsx
|
|
3568
|
+
import { useMemo as useMemo12 } from "react";
|
|
3569
|
+
import { isPlainObject as isPlainObject3 } from "lodash";
|
|
3570
|
+
function useChildList(value, onChange) {
|
|
3571
|
+
const canAddField = useMemo12(() => {
|
|
3572
|
+
if (!isPlainObject3(value)) {
|
|
3573
|
+
return false;
|
|
3574
|
+
}
|
|
3575
|
+
if (FlowValueUtils.isFlowValue(value)) {
|
|
3576
|
+
return FlowValueUtils.isConstant(value) && value?.schema?.type === "object";
|
|
3577
|
+
}
|
|
3578
|
+
return true;
|
|
3579
|
+
}, [value]);
|
|
3580
|
+
const objectListValue = useMemo12(() => {
|
|
3581
|
+
if (isPlainObject3(value)) {
|
|
3582
|
+
if (FlowValueUtils.isFlowValue(value)) {
|
|
3583
|
+
return void 0;
|
|
3584
|
+
}
|
|
3585
|
+
return value;
|
|
3586
|
+
}
|
|
3587
|
+
return void 0;
|
|
3588
|
+
}, [value]);
|
|
3589
|
+
const { list, add, updateKey, updateValue, remove } = useObjectList({
|
|
3590
|
+
value: objectListValue,
|
|
3591
|
+
onChange: (value2) => {
|
|
3592
|
+
onChange?.(value2);
|
|
3593
|
+
},
|
|
3594
|
+
sortIndexKey: (value2) => FlowValueUtils.isFlowValue(value2) ? "extra.index" : ""
|
|
3595
|
+
});
|
|
3596
|
+
const hasChildren = useMemo12(
|
|
3597
|
+
() => canAddField && (list.length > 0 || Object.keys(objectListValue || {}).length > 0),
|
|
3598
|
+
[canAddField, list.length, Object.keys(objectListValue || {}).length]
|
|
3599
|
+
);
|
|
3600
|
+
return {
|
|
3601
|
+
canAddField,
|
|
3602
|
+
hasChildren,
|
|
3603
|
+
list,
|
|
3604
|
+
add,
|
|
3605
|
+
updateKey,
|
|
3606
|
+
updateValue,
|
|
3607
|
+
remove
|
|
3608
|
+
};
|
|
3609
|
+
}
|
|
3610
|
+
|
|
3611
|
+
// src/components/inputs-values-tree/row.tsx
|
|
3612
|
+
var AddObjectChildStrategy = {
|
|
3613
|
+
hit: (schema) => schema.type === "object",
|
|
3614
|
+
Renderer: () => /* @__PURE__ */ React44.createElement(
|
|
3615
|
+
Input7,
|
|
3616
|
+
{
|
|
3617
|
+
size: "small",
|
|
3618
|
+
disabled: true,
|
|
3619
|
+
style: { pointerEvents: "none" },
|
|
3620
|
+
value: I18n14.t("Configure via child fields")
|
|
3621
|
+
}
|
|
3622
|
+
)
|
|
3623
|
+
};
|
|
3624
|
+
function InputValueRow(props) {
|
|
3625
|
+
const {
|
|
3626
|
+
keyName,
|
|
3627
|
+
value,
|
|
3628
|
+
$level = 0,
|
|
3629
|
+
onUpdateKey,
|
|
3630
|
+
onUpdateValue,
|
|
3631
|
+
$isLast,
|
|
3632
|
+
onRemove,
|
|
3633
|
+
constantProps,
|
|
3634
|
+
hasError,
|
|
3635
|
+
readonly
|
|
3636
|
+
} = props;
|
|
3637
|
+
const [collapse, setCollapse] = useState10(false);
|
|
3638
|
+
const { canAddField, hasChildren, list, add, updateKey, updateValue, remove } = useChildList(
|
|
3639
|
+
value,
|
|
3640
|
+
onUpdateValue
|
|
3641
|
+
);
|
|
3642
|
+
const strategies = useMemo13(
|
|
3643
|
+
() => [...hasChildren ? [AddObjectChildStrategy] : [], ...constantProps?.strategies || []],
|
|
3644
|
+
[hasChildren, constantProps?.strategies]
|
|
3645
|
+
);
|
|
3646
|
+
const flowDisplayValue = useMemo13(
|
|
3647
|
+
() => hasChildren ? {
|
|
3648
|
+
type: "constant",
|
|
3649
|
+
schema: { type: "object" }
|
|
3650
|
+
} : value,
|
|
3651
|
+
[hasChildren, value]
|
|
3652
|
+
);
|
|
3653
|
+
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(
|
|
3654
|
+
BlurInput,
|
|
3655
|
+
{
|
|
3656
|
+
style: { width: 100, minWidth: 100, maxWidth: 100 },
|
|
3657
|
+
disabled: readonly,
|
|
3658
|
+
size: "small",
|
|
3659
|
+
value: keyName,
|
|
3660
|
+
onChange: (v) => onUpdateKey?.(v),
|
|
3661
|
+
placeholder: I18n14.t("Input Key")
|
|
3662
|
+
}
|
|
3663
|
+
), /* @__PURE__ */ React44.createElement(
|
|
3664
|
+
InjectDynamicValueInput,
|
|
3665
|
+
{
|
|
3666
|
+
style: { flexGrow: 1 },
|
|
3667
|
+
readonly,
|
|
3668
|
+
value: flowDisplayValue,
|
|
3669
|
+
onChange: (v) => onUpdateValue(v),
|
|
3670
|
+
hasError,
|
|
3671
|
+
constantProps: {
|
|
3672
|
+
...constantProps,
|
|
3673
|
+
strategies
|
|
3674
|
+
}
|
|
3675
|
+
}
|
|
3676
|
+
), /* @__PURE__ */ React44.createElement(UIActions2, null, canAddField && /* @__PURE__ */ React44.createElement(
|
|
3677
|
+
IconButton6,
|
|
3678
|
+
{
|
|
3679
|
+
disabled: readonly,
|
|
3680
|
+
size: "small",
|
|
3681
|
+
theme: "borderless",
|
|
3682
|
+
icon: /* @__PURE__ */ React44.createElement(IconAddChildren2, null),
|
|
3683
|
+
onClick: () => {
|
|
3684
|
+
add();
|
|
3685
|
+
setCollapse(true);
|
|
3686
|
+
}
|
|
3687
|
+
}
|
|
3688
|
+
), /* @__PURE__ */ React44.createElement(
|
|
3689
|
+
IconButton6,
|
|
3690
|
+
{
|
|
3691
|
+
disabled: readonly,
|
|
3692
|
+
theme: "borderless",
|
|
3693
|
+
icon: /* @__PURE__ */ React44.createElement(IconDelete3, { size: "small" }),
|
|
3694
|
+
size: "small",
|
|
3695
|
+
onClick: () => onRemove?.()
|
|
3696
|
+
}
|
|
3697
|
+
)))), hasChildren && /* @__PURE__ */ React44.createElement(UICollapsible2, { $collapse: collapse }, /* @__PURE__ */ React44.createElement(UITreeItems2, { $shrink: true }, list.map((_item, index) => /* @__PURE__ */ React44.createElement(
|
|
3698
|
+
InputValueRow,
|
|
3699
|
+
{
|
|
3700
|
+
readonly,
|
|
3701
|
+
hasError,
|
|
3702
|
+
constantProps,
|
|
3703
|
+
key: _item.id,
|
|
3704
|
+
keyName: _item.key,
|
|
3705
|
+
value: _item.value,
|
|
3706
|
+
$level: $level + 1,
|
|
3707
|
+
onUpdateValue: (_v) => {
|
|
3708
|
+
updateValue(_item.id, _v);
|
|
3709
|
+
},
|
|
3710
|
+
onUpdateKey: (k) => {
|
|
3711
|
+
updateKey(_item.id, k);
|
|
3712
|
+
},
|
|
3713
|
+
onRemove: () => {
|
|
3714
|
+
remove(_item.id);
|
|
3715
|
+
},
|
|
3716
|
+
$isLast: index === list.length - 1
|
|
3717
|
+
}
|
|
3718
|
+
))))));
|
|
3719
|
+
}
|
|
3720
|
+
|
|
3721
|
+
// src/components/inputs-values-tree/index.tsx
|
|
3722
|
+
function InputsValuesTree(props) {
|
|
3723
|
+
const { value, onChange, readonly, hasError, constantProps } = props;
|
|
3724
|
+
const { list, updateKey, updateValue, remove, add } = useObjectList({
|
|
3725
|
+
value,
|
|
3726
|
+
onChange,
|
|
3727
|
+
sortIndexKey: (value2) => FlowValueUtils.isFlowValue(value2) ? "extra.index" : ""
|
|
3728
|
+
});
|
|
3729
|
+
return /* @__PURE__ */ React45.createElement("div", null, /* @__PURE__ */ React45.createElement(UITreeItems2, null, list.map((item) => /* @__PURE__ */ React45.createElement(
|
|
3730
|
+
InputValueRow,
|
|
3731
|
+
{
|
|
3732
|
+
key: item.id,
|
|
3733
|
+
keyName: item.key,
|
|
3734
|
+
value: item.value,
|
|
3735
|
+
onUpdateKey: (key) => updateKey(item.id, key),
|
|
3736
|
+
onUpdateValue: (value2) => updateValue(item.id, value2),
|
|
3737
|
+
onRemove: () => remove(item.id),
|
|
3738
|
+
readonly,
|
|
3739
|
+
hasError,
|
|
3740
|
+
constantProps
|
|
3741
|
+
}
|
|
3742
|
+
))), /* @__PURE__ */ React45.createElement(
|
|
3743
|
+
Button6,
|
|
3744
|
+
{
|
|
3745
|
+
style: { marginTop: 10, marginLeft: 16 },
|
|
3746
|
+
disabled: readonly,
|
|
3747
|
+
icon: /* @__PURE__ */ React45.createElement(IconPlus5, null),
|
|
3748
|
+
size: "small",
|
|
3749
|
+
onClick: add
|
|
3750
|
+
},
|
|
3751
|
+
I18n15.t("Add")
|
|
3752
|
+
));
|
|
3753
|
+
}
|
|
3754
|
+
|
|
3304
3755
|
// src/effects/provide-batch-input/index.ts
|
|
3305
3756
|
import {
|
|
3306
3757
|
ASTFactory,
|
|
@@ -3337,7 +3788,6 @@ var provideBatchInputEffect = createEffectFromVariableProvider({
|
|
|
3337
3788
|
});
|
|
3338
3789
|
|
|
3339
3790
|
// src/effects/auto-rename-ref/index.ts
|
|
3340
|
-
import { isArray, isObject as isObject3, uniq } from "lodash";
|
|
3341
3791
|
import {
|
|
3342
3792
|
DataEvent,
|
|
3343
3793
|
VariableFieldKeyRenameService
|
|
@@ -3364,7 +3814,7 @@ var autoRenameRefEffect = [
|
|
|
3364
3814
|
form.setValueIn(_drilldownName, _v);
|
|
3365
3815
|
}
|
|
3366
3816
|
} else if (_v.type === "template") {
|
|
3367
|
-
const templateKeyPaths = getTemplateKeyPaths(_v);
|
|
3817
|
+
const templateKeyPaths = FlowValueUtils.getTemplateKeyPaths(_v);
|
|
3368
3818
|
let hasMatch = false;
|
|
3369
3819
|
templateKeyPaths.forEach((_keyPath) => {
|
|
3370
3820
|
if (isKeyPathMatch(_keyPath, beforeKeyPath)) {
|
|
@@ -3394,44 +3844,17 @@ var autoRenameRefEffect = [
|
|
|
3394
3844
|
function isKeyPathMatch(keyPath = [], targetKeyPath) {
|
|
3395
3845
|
return targetKeyPath.every((_key, index) => _key === keyPath[index]);
|
|
3396
3846
|
}
|
|
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
3847
|
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;
|
|
3423
|
-
}
|
|
3424
|
-
if (isArray(value)) {
|
|
3425
|
-
value.forEach((_value, idx) => {
|
|
3426
|
-
traverseRef(`${name}[${idx}]`, _value, cb);
|
|
3427
|
-
});
|
|
3428
|
-
return;
|
|
3848
|
+
for (const { value: _v, path } of FlowValueUtils.traverse(value, {
|
|
3849
|
+
includeTypes: ["ref", "template"],
|
|
3850
|
+
path: name
|
|
3851
|
+
})) {
|
|
3852
|
+
cb(path, _v);
|
|
3429
3853
|
}
|
|
3430
|
-
return;
|
|
3431
3854
|
}
|
|
3432
3855
|
|
|
3433
3856
|
// src/effects/provide-json-schema-outputs/index.ts
|
|
3434
|
-
import { JsonSchemaUtils as
|
|
3857
|
+
import { JsonSchemaUtils as JsonSchemaUtils8 } from "@flowgram.ai/json-schema";
|
|
3435
3858
|
import {
|
|
3436
3859
|
ASTFactory as ASTFactory2,
|
|
3437
3860
|
createEffectFromVariableProvider as createEffectFromVariableProvider2,
|
|
@@ -3445,7 +3868,7 @@ var provideJsonSchemaOutputs = createEffectFromVariableProvider2({
|
|
|
3445
3868
|
title: getNodeForm2(ctx.node)?.getValueIn("title") || ctx.node.id,
|
|
3446
3869
|
icon: ctx.node.getNodeRegistry().info?.icon
|
|
3447
3870
|
},
|
|
3448
|
-
type:
|
|
3871
|
+
type: JsonSchemaUtils8.schemaToAST(value)
|
|
3449
3872
|
})
|
|
3450
3873
|
]
|
|
3451
3874
|
});
|
|
@@ -3523,7 +3946,7 @@ var listenRefValueChange = (cb) => [
|
|
|
3523
3946
|
];
|
|
3524
3947
|
|
|
3525
3948
|
// src/effects/listen-ref-schema-change/index.ts
|
|
3526
|
-
import { JsonSchemaUtils as
|
|
3949
|
+
import { JsonSchemaUtils as JsonSchemaUtils9 } from "@flowgram.ai/json-schema";
|
|
3527
3950
|
import {
|
|
3528
3951
|
DataEvent as DataEvent5,
|
|
3529
3952
|
getNodeScope as getNodeScope3
|
|
@@ -3539,7 +3962,7 @@ var listenRefSchemaChange = (cb) => [
|
|
|
3539
3962
|
const disposable = getNodeScope3(context.node).available.trackByKeyPath(
|
|
3540
3963
|
value?.content || [],
|
|
3541
3964
|
(_type) => {
|
|
3542
|
-
cb({ ...params, schema:
|
|
3965
|
+
cb({ ...params, schema: JsonSchemaUtils9.astToSchema(_type) });
|
|
3543
3966
|
},
|
|
3544
3967
|
{
|
|
3545
3968
|
selector: (_v) => _v?.type
|
|
@@ -3629,12 +4052,7 @@ var createBatchOutputsFormPlugin = defineFormPluginCreator({
|
|
|
3629
4052
|
|
|
3630
4053
|
// src/form-plugins/infer-inputs-plugin/index.ts
|
|
3631
4054
|
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";
|
|
4055
|
+
import { defineFormPluginCreator as defineFormPluginCreator2, getNodePrivateScope as getNodePrivateScope3, getNodeScope as getNodeScope5 } from "@flowgram.ai/editor";
|
|
3638
4056
|
var createInferInputsPlugin = defineFormPluginCreator2({
|
|
3639
4057
|
onSetupFormMeta({ addFormatOnSubmit }, { sourceKey, targetKey, scope }) {
|
|
3640
4058
|
if (!sourceKey || !targetKey) {
|
|
@@ -3644,7 +4062,7 @@ var createInferInputsPlugin = defineFormPluginCreator2({
|
|
|
3644
4062
|
set2(
|
|
3645
4063
|
formData,
|
|
3646
4064
|
targetKey,
|
|
3647
|
-
|
|
4065
|
+
FlowValueUtils.inferJsonSchema(
|
|
3648
4066
|
get2(formData, sourceKey),
|
|
3649
4067
|
scope === "private" ? getNodePrivateScope3(ctx.node) : getNodeScope5(ctx.node)
|
|
3650
4068
|
)
|
|
@@ -3653,59 +4071,6 @@ var createInferInputsPlugin = defineFormPluginCreator2({
|
|
|
3653
4071
|
});
|
|
3654
4072
|
}
|
|
3655
4073
|
});
|
|
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
4074
|
|
|
3710
4075
|
// src/form-plugins/infer-assign-plugin/index.ts
|
|
3711
4076
|
import { set as set3, uniqBy } from "lodash";
|
|
@@ -3788,7 +4153,7 @@ function validateFlowValue(value, ctx) {
|
|
|
3788
4153
|
}
|
|
3789
4154
|
}
|
|
3790
4155
|
if (value?.type === "template") {
|
|
3791
|
-
const allRefs =
|
|
4156
|
+
const allRefs = getTemplateKeyPaths(value);
|
|
3792
4157
|
for (const ref of allRefs) {
|
|
3793
4158
|
const variable = getNodeScope7(node).available.getByKeyPath(ref);
|
|
3794
4159
|
if (!variable) {
|
|
@@ -3801,7 +4166,7 @@ function validateFlowValue(value, ctx) {
|
|
|
3801
4166
|
}
|
|
3802
4167
|
return void 0;
|
|
3803
4168
|
}
|
|
3804
|
-
function
|
|
4169
|
+
function getTemplateKeyPaths(value) {
|
|
3805
4170
|
const keyPathReg = /{{(.*?)}}/g;
|
|
3806
4171
|
return uniq2(value.content?.match(keyPathReg) || []).map(
|
|
3807
4172
|
(_keyPath) => _keyPath.slice(2, -2).split(".")
|
|
@@ -3812,24 +4177,28 @@ export {
|
|
|
3812
4177
|
AssignRows,
|
|
3813
4178
|
BatchOutputs,
|
|
3814
4179
|
BatchVariableSelector,
|
|
4180
|
+
BlurInput,
|
|
3815
4181
|
CodeEditor,
|
|
3816
4182
|
CodeEditorMini,
|
|
3817
4183
|
ConditionRow,
|
|
3818
4184
|
ConstantInput,
|
|
3819
4185
|
DisplayFlowValue,
|
|
4186
|
+
DisplayInputsValueAllInTag,
|
|
3820
4187
|
DisplayInputsValues,
|
|
3821
4188
|
DisplayOutputs,
|
|
3822
4189
|
DisplaySchemaTag,
|
|
3823
4190
|
DisplaySchemaTree,
|
|
3824
4191
|
DynamicValueInput,
|
|
4192
|
+
FlowValueUtils,
|
|
3825
4193
|
InjectDynamicValueInput,
|
|
3826
4194
|
InjectTypeSelector,
|
|
3827
4195
|
InjectVariableSelector,
|
|
3828
4196
|
InputsValues,
|
|
4197
|
+
InputsValuesTree,
|
|
3829
4198
|
JsonEditorWithVariables,
|
|
3830
4199
|
JsonSchemaEditor,
|
|
3831
4200
|
JsonSchemaTypePresetProvider,
|
|
3832
|
-
JsonSchemaUtils,
|
|
4201
|
+
JsonSchemaUtils2 as JsonSchemaUtils,
|
|
3833
4202
|
PromptEditor,
|
|
3834
4203
|
PromptEditorWithInputs,
|
|
3835
4204
|
PromptEditorWithVariables,
|