@flowgram.ai/form-materials 0.1.0-alpha.8 → 0.1.0-alpha.9
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 +111 -148
- package/dist/esm/index.js.map +1 -1
- package/dist/index.js +111 -148
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -405,11 +405,10 @@ var ArrayIcons = {
|
|
|
405
405
|
)
|
|
406
406
|
};
|
|
407
407
|
var getSchemaIcon = (value) => {
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
return ArrayIcons[((_a = value.items) == null ? void 0 : _a.type) || "object"];
|
|
408
|
+
if (value?.type === "array") {
|
|
409
|
+
return ArrayIcons[value.items?.type || "object"];
|
|
411
410
|
}
|
|
412
|
-
return VariableTypeIcons[
|
|
411
|
+
return VariableTypeIcons[value?.type || "object"];
|
|
413
412
|
};
|
|
414
413
|
var labelStyle = { display: "flex", alignItems: "center", gap: 5 };
|
|
415
414
|
var firstUppercase = (str) => str.charAt(0).toUpperCase() + str.slice(1);
|
|
@@ -471,7 +470,7 @@ var JsonSchemaUtils;
|
|
|
471
470
|
return { kind: import_editor.ASTKind.Object, weak: true };
|
|
472
471
|
}
|
|
473
472
|
return import_editor.ASTFactory.createObject({
|
|
474
|
-
properties: Object.entries(jsonSchema.properties || {}).sort((a, b) => ((0, import_lodash.get)(a
|
|
473
|
+
properties: Object.entries(jsonSchema.properties || {}).sort((a, b) => ((0, import_lodash.get)(a?.[1], "extra.index") || 0) - ((0, import_lodash.get)(b?.[1], "extra.index") || 0)).map(([key, _property]) => ({
|
|
475
474
|
key,
|
|
476
475
|
type: schemaToAST(_property),
|
|
477
476
|
meta: { description: _property.description }
|
|
@@ -572,8 +571,7 @@ function useVariableTree(params) {
|
|
|
572
571
|
const { includeSchema, excludeSchema } = params;
|
|
573
572
|
const available = (0, import_editor2.useScopeAvailable)();
|
|
574
573
|
const getVariableTypeIcon = (0, import_react2.useCallback)((variable) => {
|
|
575
|
-
|
|
576
|
-
if ((_a = variable.meta) == null ? void 0 : _a.icon) {
|
|
574
|
+
if (variable.meta?.icon) {
|
|
577
575
|
if (typeof variable.meta.icon === "string") {
|
|
578
576
|
return /* @__PURE__ */ import_react2.default.createElement("img", { style: { marginRight: 8 }, width: 12, height: 12, src: variable.meta.icon });
|
|
579
577
|
}
|
|
@@ -585,25 +583,24 @@ function useVariableTree(params) {
|
|
|
585
583
|
import_semi_ui.Icon,
|
|
586
584
|
{
|
|
587
585
|
size: "small",
|
|
588
|
-
svg: ArrayIcons[
|
|
586
|
+
svg: ArrayIcons[_type.items?.kind.toLowerCase()] || VariableTypeIcons.array
|
|
589
587
|
}
|
|
590
588
|
);
|
|
591
589
|
}
|
|
592
590
|
if (import_editor2.ASTMatch.isCustomType(_type)) {
|
|
593
591
|
return /* @__PURE__ */ import_react2.default.createElement(import_semi_ui.Icon, { size: "small", svg: VariableTypeIcons[_type.typeName.toLowerCase()] });
|
|
594
592
|
}
|
|
595
|
-
return /* @__PURE__ */ import_react2.default.createElement(import_semi_ui.Icon, { size: "small", svg: VariableTypeIcons[
|
|
593
|
+
return /* @__PURE__ */ import_react2.default.createElement(import_semi_ui.Icon, { size: "small", svg: VariableTypeIcons[variable.type?.kind.toLowerCase()] });
|
|
596
594
|
}, []);
|
|
597
595
|
const renderVariable = (variable, parentFields = []) => {
|
|
598
|
-
|
|
599
|
-
let type = variable == null ? void 0 : variable.type;
|
|
596
|
+
let type = variable?.type;
|
|
600
597
|
if (!type) {
|
|
601
598
|
return null;
|
|
602
599
|
}
|
|
603
600
|
let children;
|
|
604
601
|
if (import_editor2.ASTMatch.isObject(type)) {
|
|
605
602
|
children = (type.properties || []).map((_property) => renderVariable(_property, [...parentFields, variable])).filter(Boolean);
|
|
606
|
-
if (!
|
|
603
|
+
if (!children?.length) {
|
|
607
604
|
return null;
|
|
608
605
|
}
|
|
609
606
|
}
|
|
@@ -612,18 +609,18 @@ function useVariableTree(params) {
|
|
|
612
609
|
const isSchemaInclude = includeSchema ? JsonSchemaUtils.isASTMatchSchema(type, includeSchema) : true;
|
|
613
610
|
const isSchemaExclude = excludeSchema ? JsonSchemaUtils.isASTMatchSchema(type, excludeSchema) : false;
|
|
614
611
|
const isSchemaMatch = isSchemaInclude && !isSchemaExclude;
|
|
615
|
-
if (!isSchemaMatch && !
|
|
612
|
+
if (!isSchemaMatch && !children?.length) {
|
|
616
613
|
return null;
|
|
617
614
|
}
|
|
618
615
|
return {
|
|
619
616
|
key,
|
|
620
|
-
label:
|
|
617
|
+
label: variable.meta?.title || variable.key,
|
|
621
618
|
value: key,
|
|
622
619
|
keyPath,
|
|
623
620
|
icon: getVariableTypeIcon(variable),
|
|
624
621
|
children,
|
|
625
622
|
disabled: !isSchemaMatch,
|
|
626
|
-
rootMeta:
|
|
623
|
+
rootMeta: parentFields[0]?.meta
|
|
627
624
|
};
|
|
628
625
|
};
|
|
629
626
|
return [...available.variables.slice(0).reverse()].map((_variable) => renderVariable(_variable)).filter(Boolean);
|
|
@@ -683,7 +680,6 @@ var VariableSelector = ({
|
|
|
683
680
|
hasError,
|
|
684
681
|
triggerRender
|
|
685
682
|
}) => {
|
|
686
|
-
var _a;
|
|
687
683
|
const treeData = useVariableTree({ includeSchema, excludeSchema });
|
|
688
684
|
const treeValue = (0, import_react3.useMemo)(() => {
|
|
689
685
|
if (typeof value === "string") {
|
|
@@ -693,7 +689,7 @@ var VariableSelector = ({
|
|
|
693
689
|
);
|
|
694
690
|
return value;
|
|
695
691
|
}
|
|
696
|
-
return value
|
|
692
|
+
return value?.join(".");
|
|
697
693
|
}, [value]);
|
|
698
694
|
const renderIcon = (icon) => {
|
|
699
695
|
if (typeof icon === "string") {
|
|
@@ -717,8 +713,7 @@ var VariableSelector = ({
|
|
|
717
713
|
onChange(_config.keyPath);
|
|
718
714
|
},
|
|
719
715
|
renderSelectedItem: (_option) => {
|
|
720
|
-
|
|
721
|
-
if (!(_option == null ? void 0 : _option.keyPath)) {
|
|
716
|
+
if (!_option?.keyPath) {
|
|
722
717
|
return /* @__PURE__ */ import_react3.default.createElement(
|
|
723
718
|
UITag,
|
|
724
719
|
{
|
|
@@ -727,24 +722,24 @@ var VariableSelector = ({
|
|
|
727
722
|
closable: !readonly,
|
|
728
723
|
onClose: () => onChange(void 0)
|
|
729
724
|
},
|
|
730
|
-
|
|
725
|
+
config?.notFoundContent ?? "Undefined"
|
|
731
726
|
);
|
|
732
727
|
}
|
|
733
728
|
return /* @__PURE__ */ import_react3.default.createElement(
|
|
734
729
|
UITag,
|
|
735
730
|
{
|
|
736
|
-
prefixIcon: renderIcon(
|
|
731
|
+
prefixIcon: renderIcon(_option.rootMeta?.icon || _option?.icon),
|
|
737
732
|
closable: !readonly,
|
|
738
733
|
onClose: () => onChange(void 0)
|
|
739
734
|
},
|
|
740
|
-
/* @__PURE__ */ import_react3.default.createElement(UIRootTitle, null,
|
|
735
|
+
/* @__PURE__ */ import_react3.default.createElement(UIRootTitle, null, _option.rootMeta?.title ? `${_option.rootMeta?.title} -` : null),
|
|
741
736
|
_option.label
|
|
742
737
|
);
|
|
743
738
|
},
|
|
744
739
|
showClear: false,
|
|
745
740
|
arrowIcon: /* @__PURE__ */ import_react3.default.createElement(import_semi_icons2.IconChevronDownStroked, { size: "small" }),
|
|
746
741
|
triggerRender,
|
|
747
|
-
placeholder:
|
|
742
|
+
placeholder: config?.placeholder ?? "Select Variable..."
|
|
748
743
|
}
|
|
749
744
|
));
|
|
750
745
|
};
|
|
@@ -753,10 +748,10 @@ var VariableSelector = ({
|
|
|
753
748
|
var import_react4 = __toESM(require("react"));
|
|
754
749
|
var import_semi_ui3 = require("@douyinfe/semi-ui");
|
|
755
750
|
var getTypeSelectValue = (value) => {
|
|
756
|
-
if (
|
|
751
|
+
if (value?.type === "array" && value?.items) {
|
|
757
752
|
return [value.type, ...getTypeSelectValue(value.items) || []];
|
|
758
753
|
}
|
|
759
|
-
return
|
|
754
|
+
return value?.type ? [value.type] : void 0;
|
|
760
755
|
};
|
|
761
756
|
var parseTypeSelectValue = (value) => {
|
|
762
757
|
const [type, ...subTypes] = value || [];
|
|
@@ -993,31 +988,21 @@ function getDrilldownSchema(value, path) {
|
|
|
993
988
|
return { schema: value, path };
|
|
994
989
|
}
|
|
995
990
|
function usePropertiesEdit(value, onChange) {
|
|
996
|
-
|
|
997
|
-
const
|
|
998
|
-
const isDrilldownObject = ((_a = drilldown.schema) == null ? void 0 : _a.type) === "object";
|
|
991
|
+
const drilldown = (0, import_react6.useMemo)(() => getDrilldownSchema(value), [value, value?.type, value?.items]);
|
|
992
|
+
const isDrilldownObject = drilldown.schema?.type === "object";
|
|
999
993
|
const initPropertyList = (0, import_react6.useMemo)(
|
|
1000
|
-
() => {
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
key: genId(),
|
|
1010
|
-
name,
|
|
1011
|
-
isPropertyRequired: ((_b = (_a3 = drilldown.schema) == null ? void 0 : _a3.required) == null ? void 0 : _b.includes(name)) || false,
|
|
1012
|
-
..._value,
|
|
1013
|
-
extra: {
|
|
1014
|
-
..._value.extra || {},
|
|
1015
|
-
index
|
|
1016
|
-
}
|
|
1017
|
-
};
|
|
994
|
+
() => isDrilldownObject ? Object.entries(drilldown.schema?.properties || {}).sort(([, a], [, b]) => (a.extra?.index ?? 0) - (b.extra?.index ?? 0)).map(
|
|
995
|
+
([name, _value], index) => ({
|
|
996
|
+
key: genId(),
|
|
997
|
+
name,
|
|
998
|
+
isPropertyRequired: drilldown.schema?.required?.includes(name) || false,
|
|
999
|
+
..._value,
|
|
1000
|
+
extra: {
|
|
1001
|
+
..._value.extra || {},
|
|
1002
|
+
index
|
|
1018
1003
|
}
|
|
1019
|
-
)
|
|
1020
|
-
|
|
1004
|
+
})
|
|
1005
|
+
) : [],
|
|
1021
1006
|
[isDrilldownObject]
|
|
1022
1007
|
);
|
|
1023
1008
|
const [propertyList, setPropertyList] = (0, import_react6.useState)(initPropertyList);
|
|
@@ -1025,31 +1010,26 @@ function usePropertiesEdit(value, onChange) {
|
|
|
1025
1010
|
(0, import_react6.useEffect)(() => {
|
|
1026
1011
|
if (mountRef.current) {
|
|
1027
1012
|
setPropertyList((_list) => {
|
|
1028
|
-
var _a2;
|
|
1029
1013
|
const nameMap = /* @__PURE__ */ new Map();
|
|
1030
1014
|
for (const _property of _list) {
|
|
1031
1015
|
if (_property.name) {
|
|
1032
1016
|
nameMap.set(_property.name, _property);
|
|
1033
1017
|
}
|
|
1034
1018
|
}
|
|
1035
|
-
return Object.entries(
|
|
1036
|
-
var _a3, _b, _c, _d;
|
|
1037
|
-
return ((_b = (_a3 = a.extra) == null ? void 0 : _a3.index) != null ? _b : 0) - ((_d = (_c = b.extra) == null ? void 0 : _c.index) != null ? _d : 0);
|
|
1038
|
-
}).map(([name, _value]) => {
|
|
1039
|
-
var _a3, _b, _c, _d;
|
|
1019
|
+
return Object.entries(drilldown.schema?.properties || {}).sort(([, a], [, b]) => (a.extra?.index ?? 0) - (b.extra?.index ?? 0)).map(([name, _value]) => {
|
|
1040
1020
|
const _property = nameMap.get(name);
|
|
1041
1021
|
if (_property) {
|
|
1042
1022
|
return {
|
|
1043
1023
|
key: _property.key,
|
|
1044
1024
|
name,
|
|
1045
|
-
isPropertyRequired:
|
|
1025
|
+
isPropertyRequired: drilldown.schema?.required?.includes(name) || false,
|
|
1046
1026
|
..._value
|
|
1047
1027
|
};
|
|
1048
1028
|
}
|
|
1049
1029
|
return {
|
|
1050
1030
|
key: genId(),
|
|
1051
1031
|
name,
|
|
1052
|
-
isPropertyRequired:
|
|
1032
|
+
isPropertyRequired: drilldown.schema?.required?.includes(name) || false,
|
|
1053
1033
|
..._value
|
|
1054
1034
|
};
|
|
1055
1035
|
});
|
|
@@ -1077,7 +1057,7 @@ function usePropertiesEdit(value, onChange) {
|
|
|
1077
1057
|
}
|
|
1078
1058
|
drilldownSchema.properties = nextProperties;
|
|
1079
1059
|
drilldownSchema.required = nextRequired;
|
|
1080
|
-
onChange
|
|
1060
|
+
onChange?.(value || {});
|
|
1081
1061
|
return next;
|
|
1082
1062
|
});
|
|
1083
1063
|
};
|
|
@@ -1138,11 +1118,11 @@ var import_react7 = __toESM(require("react"));
|
|
|
1138
1118
|
var import_semi_ui4 = require("@douyinfe/semi-ui");
|
|
1139
1119
|
var defaultStrategies = [
|
|
1140
1120
|
{
|
|
1141
|
-
hit: (schema) =>
|
|
1121
|
+
hit: (schema) => schema?.type === "string",
|
|
1142
1122
|
Renderer: (props) => /* @__PURE__ */ import_react7.default.createElement(import_semi_ui4.Input, { placeholder: "Please Input String", size: "small", disabled: props.readonly, ...props })
|
|
1143
1123
|
},
|
|
1144
1124
|
{
|
|
1145
|
-
hit: (schema) =>
|
|
1125
|
+
hit: (schema) => schema?.type === "number",
|
|
1146
1126
|
Renderer: (props) => /* @__PURE__ */ import_react7.default.createElement(
|
|
1147
1127
|
import_semi_ui4.InputNumber,
|
|
1148
1128
|
{
|
|
@@ -1155,7 +1135,7 @@ var defaultStrategies = [
|
|
|
1155
1135
|
)
|
|
1156
1136
|
},
|
|
1157
1137
|
{
|
|
1158
|
-
hit: (schema) =>
|
|
1138
|
+
hit: (schema) => schema?.type === "integer",
|
|
1159
1139
|
Renderer: (props) => /* @__PURE__ */ import_react7.default.createElement(
|
|
1160
1140
|
import_semi_ui4.InputNumber,
|
|
1161
1141
|
{
|
|
@@ -1169,7 +1149,7 @@ var defaultStrategies = [
|
|
|
1169
1149
|
)
|
|
1170
1150
|
},
|
|
1171
1151
|
{
|
|
1172
|
-
hit: (schema) =>
|
|
1152
|
+
hit: (schema) => schema?.type === "boolean",
|
|
1173
1153
|
Renderer: (props) => {
|
|
1174
1154
|
const { value, onChange, ...rest } = props;
|
|
1175
1155
|
return /* @__PURE__ */ import_react7.default.createElement(
|
|
@@ -1183,7 +1163,7 @@ var defaultStrategies = [
|
|
|
1183
1163
|
{ label: "False", value: 0 }
|
|
1184
1164
|
],
|
|
1185
1165
|
value: value ? 1 : 0,
|
|
1186
|
-
onChange: (value2) => onChange
|
|
1166
|
+
onChange: (value2) => onChange?.(!!value2),
|
|
1187
1167
|
...rest
|
|
1188
1168
|
}
|
|
1189
1169
|
);
|
|
@@ -1198,7 +1178,7 @@ function ConstantInput(props) {
|
|
|
1198
1178
|
);
|
|
1199
1179
|
const Renderer = (0, import_react7.useMemo)(() => {
|
|
1200
1180
|
const strategy = strategies.find((_strategy) => _strategy.hit(schema));
|
|
1201
|
-
return strategy
|
|
1181
|
+
return strategy?.Renderer;
|
|
1202
1182
|
}, [strategies, schema]);
|
|
1203
1183
|
if (!Renderer) {
|
|
1204
1184
|
return /* @__PURE__ */ import_react7.default.createElement(import_semi_ui4.Input, { size: "small", disabled: true, placeholder: "Unsupported type" });
|
|
@@ -1222,8 +1202,7 @@ function DefaultValue(props) {
|
|
|
1222
1202
|
const handleEditComplete = (0, import_react8.useCallback)(() => {
|
|
1223
1203
|
onChange(internalJsonValue);
|
|
1224
1204
|
requestAnimationFrame(() => {
|
|
1225
|
-
|
|
1226
|
-
(_a = wrapperRef.current) == null ? void 0 : _a.blur();
|
|
1205
|
+
wrapperRef.current?.blur();
|
|
1227
1206
|
});
|
|
1228
1207
|
setJsonReadOnly(true);
|
|
1229
1208
|
}, [internalJsonValue, onChange]);
|
|
@@ -1238,7 +1217,7 @@ function DefaultValue(props) {
|
|
|
1238
1217
|
console.error("Invalid JSON:", error);
|
|
1239
1218
|
}
|
|
1240
1219
|
}, [internalJsonValue, onChange]);
|
|
1241
|
-
return type === "object" ? /* @__PURE__ */ import_react8.default.createElement(import_react8.default.Fragment, null, /* @__PURE__ */ import_react8.default.createElement(JSONHeader, null, /* @__PURE__ */ import_react8.default.createElement(JSONHeaderLeft, null, "json"), /* @__PURE__ */ import_react8.default.createElement(JSONHeaderRight, null, /* @__PURE__ */ import_react8.default.createElement(import_semi_ui5.Tooltip, { content: jsonFormatText
|
|
1220
|
+
return type === "object" ? /* @__PURE__ */ import_react8.default.createElement(import_react8.default.Fragment, null, /* @__PURE__ */ import_react8.default.createElement(JSONHeader, null, /* @__PURE__ */ import_react8.default.createElement(JSONHeaderLeft, null, "json"), /* @__PURE__ */ import_react8.default.createElement(JSONHeaderRight, null, /* @__PURE__ */ import_react8.default.createElement(import_semi_ui5.Tooltip, { content: jsonFormatText ?? "Format" }, /* @__PURE__ */ import_react8.default.createElement(
|
|
1242
1221
|
import_semi_ui5.IconButton,
|
|
1243
1222
|
{
|
|
1244
1223
|
icon: /* @__PURE__ */ import_react8.default.createElement(import_semi_icons4.IconBrackets, { style: { color: "var(--semi-color-primary)" } }),
|
|
@@ -1253,8 +1232,7 @@ function DefaultValue(props) {
|
|
|
1253
1232
|
ref: wrapperRef,
|
|
1254
1233
|
tabIndex: -1,
|
|
1255
1234
|
onBlur: (e) => {
|
|
1256
|
-
|
|
1257
|
-
if (wrapperRef.current && !((_a = wrapperRef.current) == null ? void 0 : _a.contains(e.relatedTarget))) {
|
|
1235
|
+
if (wrapperRef.current && !wrapperRef.current?.contains(e.relatedTarget)) {
|
|
1258
1236
|
handleEditComplete();
|
|
1259
1237
|
}
|
|
1260
1238
|
},
|
|
@@ -1286,7 +1264,7 @@ function DefaultValue(props) {
|
|
|
1286
1264
|
value,
|
|
1287
1265
|
onChange: (_v) => onChange(_v),
|
|
1288
1266
|
schema: schema || { type: "string" },
|
|
1289
|
-
placeholder: placeholder
|
|
1267
|
+
placeholder: placeholder ?? "Default value if parameter is not provided"
|
|
1290
1268
|
}
|
|
1291
1269
|
));
|
|
1292
1270
|
}
|
|
@@ -1307,17 +1285,13 @@ function BlurInput(props) {
|
|
|
1307
1285
|
onChange: (value2) => {
|
|
1308
1286
|
setValue(value2);
|
|
1309
1287
|
},
|
|
1310
|
-
onBlur: (e) =>
|
|
1311
|
-
var _a;
|
|
1312
|
-
return (_a = props.onChange) == null ? void 0 : _a.call(props, value, e);
|
|
1313
|
-
}
|
|
1288
|
+
onBlur: (e) => props.onChange?.(value, e)
|
|
1314
1289
|
}
|
|
1315
1290
|
);
|
|
1316
1291
|
}
|
|
1317
1292
|
|
|
1318
1293
|
// src/components/json-schema-editor/index.tsx
|
|
1319
1294
|
function JsonSchemaEditor(props) {
|
|
1320
|
-
var _a;
|
|
1321
1295
|
const { value = { type: "object" }, config = {}, onChange: onChangeProps } = props;
|
|
1322
1296
|
const { propertyList, onAddProperty, onRemoveProperty, onEditProperty } = usePropertiesEdit(
|
|
1323
1297
|
value,
|
|
@@ -1337,10 +1311,9 @@ function JsonSchemaEditor(props) {
|
|
|
1337
1311
|
onRemoveProperty(_property.key);
|
|
1338
1312
|
}
|
|
1339
1313
|
}
|
|
1340
|
-
))), /* @__PURE__ */ import_react10.default.createElement(import_semi_ui6.Button, { size: "small", style: { marginTop: 10 }, icon: /* @__PURE__ */ import_react10.default.createElement(import_semi_icons5.IconPlus, null), onClick: onAddProperty },
|
|
1314
|
+
))), /* @__PURE__ */ import_react10.default.createElement(import_semi_ui6.Button, { size: "small", style: { marginTop: 10 }, icon: /* @__PURE__ */ import_react10.default.createElement(import_semi_icons5.IconPlus, null), onClick: onAddProperty }, config?.addButtonText ?? "Add"));
|
|
1341
1315
|
}
|
|
1342
1316
|
function PropertyEdit(props) {
|
|
1343
|
-
var _a, _b, _c, _d;
|
|
1344
1317
|
const {
|
|
1345
1318
|
value,
|
|
1346
1319
|
config,
|
|
@@ -1360,7 +1333,7 @@ function PropertyEdit(props) {
|
|
|
1360
1333
|
const typeSelectorValue = (0, import_react10.useMemo)(() => ({ type, items }), [type, items]);
|
|
1361
1334
|
const { propertyList, isDrilldownObject, onAddProperty, onRemoveProperty, onEditProperty } = usePropertiesEdit(value, onChangeProps);
|
|
1362
1335
|
const onChange = (key, _value) => {
|
|
1363
|
-
onChangeProps
|
|
1336
|
+
onChangeProps?.({
|
|
1364
1337
|
...value || {},
|
|
1365
1338
|
[key]: _value
|
|
1366
1339
|
});
|
|
@@ -1390,7 +1363,7 @@ function PropertyEdit(props) {
|
|
|
1390
1363
|
/* @__PURE__ */ import_react10.default.createElement(UIRow, null, /* @__PURE__ */ import_react10.default.createElement(UIName, null, /* @__PURE__ */ import_react10.default.createElement(
|
|
1391
1364
|
BlurInput,
|
|
1392
1365
|
{
|
|
1393
|
-
placeholder:
|
|
1366
|
+
placeholder: config?.placeholder ?? "Input Variable Name",
|
|
1394
1367
|
size: "small",
|
|
1395
1368
|
value: name,
|
|
1396
1369
|
onChange: (value2) => onChange("name", value2)
|
|
@@ -1400,7 +1373,7 @@ function PropertyEdit(props) {
|
|
|
1400
1373
|
{
|
|
1401
1374
|
value: typeSelectorValue,
|
|
1402
1375
|
onChange: (_value) => {
|
|
1403
|
-
onChangeProps
|
|
1376
|
+
onChangeProps?.({
|
|
1404
1377
|
...value || {},
|
|
1405
1378
|
..._value
|
|
1406
1379
|
});
|
|
@@ -1442,22 +1415,22 @@ function PropertyEdit(props) {
|
|
|
1442
1415
|
onClick: onRemove
|
|
1443
1416
|
}
|
|
1444
1417
|
))),
|
|
1445
|
-
expand && /* @__PURE__ */ import_react10.default.createElement(UIExpandDetail, null, /* @__PURE__ */ import_react10.default.createElement(UILabel, null,
|
|
1418
|
+
expand && /* @__PURE__ */ import_react10.default.createElement(UIExpandDetail, null, /* @__PURE__ */ import_react10.default.createElement(UILabel, null, config?.descTitle ?? "Description"), /* @__PURE__ */ import_react10.default.createElement(
|
|
1446
1419
|
BlurInput,
|
|
1447
1420
|
{
|
|
1448
1421
|
size: "small",
|
|
1449
1422
|
value: description,
|
|
1450
1423
|
onChange: (value2) => onChange("description", value2),
|
|
1451
|
-
placeholder:
|
|
1424
|
+
placeholder: config?.descPlaceholder ?? "Help LLM to understand the property"
|
|
1452
1425
|
}
|
|
1453
|
-
), $level === 0 && type && type !== "array" && /* @__PURE__ */ import_react10.default.createElement(import_react10.default.Fragment, null, /* @__PURE__ */ import_react10.default.createElement(UILabel, { style: { marginTop: 10 } },
|
|
1426
|
+
), $level === 0 && type && type !== "array" && /* @__PURE__ */ import_react10.default.createElement(import_react10.default.Fragment, null, /* @__PURE__ */ import_react10.default.createElement(UILabel, { style: { marginTop: 10 } }, config?.defaultValueTitle ?? "Default Value"), /* @__PURE__ */ import_react10.default.createElement(DefaultValueWrapper, null, /* @__PURE__ */ import_react10.default.createElement(
|
|
1454
1427
|
DefaultValue,
|
|
1455
1428
|
{
|
|
1456
1429
|
value: defaultValue,
|
|
1457
1430
|
schema: value,
|
|
1458
1431
|
type,
|
|
1459
|
-
placeholder: config
|
|
1460
|
-
jsonFormatText: config
|
|
1432
|
+
placeholder: config?.defaultValuePlaceholder,
|
|
1433
|
+
jsonFormatText: config?.jsonFormatText,
|
|
1461
1434
|
onChange: (value2) => onChange("default", value2)
|
|
1462
1435
|
}
|
|
1463
1436
|
))))
|
|
@@ -1528,17 +1501,17 @@ function DynamicValueInput({
|
|
|
1528
1501
|
constantProps
|
|
1529
1502
|
}) {
|
|
1530
1503
|
const includeSchema = (0, import_react12.useMemo)(() => {
|
|
1531
|
-
if (
|
|
1504
|
+
if (schema?.type === "number") {
|
|
1532
1505
|
return [schema, { type: "integer" }];
|
|
1533
1506
|
}
|
|
1534
1507
|
return schema;
|
|
1535
1508
|
}, [schema]);
|
|
1536
1509
|
const renderMain = () => {
|
|
1537
|
-
if (
|
|
1510
|
+
if (value?.type === "ref") {
|
|
1538
1511
|
return /* @__PURE__ */ import_react12.default.createElement(
|
|
1539
1512
|
VariableSelector,
|
|
1540
1513
|
{
|
|
1541
|
-
value: value
|
|
1514
|
+
value: value?.content,
|
|
1542
1515
|
onChange: (_v) => onChange(_v ? { type: "ref", content: _v } : void 0),
|
|
1543
1516
|
includeSchema,
|
|
1544
1517
|
readonly
|
|
@@ -1548,7 +1521,7 @@ function DynamicValueInput({
|
|
|
1548
1521
|
return /* @__PURE__ */ import_react12.default.createElement(
|
|
1549
1522
|
ConstantInput,
|
|
1550
1523
|
{
|
|
1551
|
-
value: value
|
|
1524
|
+
value: value?.content,
|
|
1552
1525
|
onChange: (_v) => onChange({ type: "constant", content: _v }),
|
|
1553
1526
|
schema: schema || { type: "string" },
|
|
1554
1527
|
readonly,
|
|
@@ -1560,7 +1533,7 @@ function DynamicValueInput({
|
|
|
1560
1533
|
VariableSelector,
|
|
1561
1534
|
{
|
|
1562
1535
|
style: { width: "100%" },
|
|
1563
|
-
value:
|
|
1536
|
+
value: value?.type === "ref" ? value?.content : void 0,
|
|
1564
1537
|
onChange: (_v) => onChange({ type: "ref", content: _v }),
|
|
1565
1538
|
includeSchema,
|
|
1566
1539
|
readonly,
|
|
@@ -1794,8 +1767,8 @@ function useRule(left) {
|
|
|
1794
1767
|
const rule = (0, import_react13.useMemo)(() => {
|
|
1795
1768
|
if (!variable) return void 0;
|
|
1796
1769
|
const schema = JsonSchemaUtils.astToSchema(variable.type, { drilldown: false });
|
|
1797
|
-
return rules[schema
|
|
1798
|
-
}, [variable
|
|
1770
|
+
return rules[schema?.type];
|
|
1771
|
+
}, [variable?.type]);
|
|
1799
1772
|
return { rule };
|
|
1800
1773
|
}
|
|
1801
1774
|
|
|
@@ -1822,7 +1795,7 @@ function useOp({ rule, op, onChange }) {
|
|
|
1822
1795
|
onChange: (v) => {
|
|
1823
1796
|
onChange(v);
|
|
1824
1797
|
},
|
|
1825
|
-
triggerRender: ({ value }) => /* @__PURE__ */ import_react14.default.createElement(import_semi_ui8.Button, { size: "small", disabled: !rule },
|
|
1798
|
+
triggerRender: ({ value }) => /* @__PURE__ */ import_react14.default.createElement(import_semi_ui8.Button, { size: "small", disabled: !rule }, opConfig?.abbreviation || /* @__PURE__ */ import_react14.default.createElement(import_semi_icons7.IconChevronDownStroked, { size: "small" }))
|
|
1826
1799
|
}
|
|
1827
1800
|
);
|
|
1828
1801
|
return { renderOpSelect, opConfig };
|
|
@@ -1838,7 +1811,7 @@ function ConditionRow({ style, value, onChange, readonly }) {
|
|
|
1838
1811
|
onChange: (v) => onChange({ ...value, operator: v })
|
|
1839
1812
|
});
|
|
1840
1813
|
const targetSchema = (0, import_react15.useMemo)(() => {
|
|
1841
|
-
const targetType =
|
|
1814
|
+
const targetType = rule?.[operator] || null;
|
|
1842
1815
|
return targetType ? { type: targetType, extra: { weak: true } } : null;
|
|
1843
1816
|
}, [rule, opConfig]);
|
|
1844
1817
|
return /* @__PURE__ */ import_react15.default.createElement(UIContainer3, { style }, /* @__PURE__ */ import_react15.default.createElement(UIOperator, null, renderOpSelect()), /* @__PURE__ */ import_react15.default.createElement(UIValues, null, /* @__PURE__ */ import_react15.default.createElement(UILeft, null, /* @__PURE__ */ import_react15.default.createElement(
|
|
@@ -1846,7 +1819,7 @@ function ConditionRow({ style, value, onChange, readonly }) {
|
|
|
1846
1819
|
{
|
|
1847
1820
|
readonly,
|
|
1848
1821
|
style: { width: "100%" },
|
|
1849
|
-
value: left
|
|
1822
|
+
value: left?.content,
|
|
1850
1823
|
onChange: (v) => onChange({
|
|
1851
1824
|
...value,
|
|
1852
1825
|
left: {
|
|
@@ -1863,71 +1836,65 @@ function ConditionRow({ style, value, onChange, readonly }) {
|
|
|
1863
1836
|
schema: targetSchema,
|
|
1864
1837
|
onChange: (v) => onChange({ ...value, right: v })
|
|
1865
1838
|
}
|
|
1866
|
-
) : /* @__PURE__ */ import_react15.default.createElement(import_semi_ui9.Input, { size: "small", disabled: true, value:
|
|
1839
|
+
) : /* @__PURE__ */ import_react15.default.createElement(import_semi_ui9.Input, { size: "small", disabled: true, value: opConfig?.rightDisplay || "Empty" }))));
|
|
1867
1840
|
}
|
|
1868
1841
|
|
|
1869
1842
|
// src/effects/provide-batch-input/index.ts
|
|
1870
1843
|
var import_editor5 = require("@flowgram.ai/editor");
|
|
1871
1844
|
var provideBatchInputEffect = (0, import_editor5.createEffectFromVariableProvider)({
|
|
1872
1845
|
private: true,
|
|
1873
|
-
parse: (value, ctx) =>
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
import_editor5.ASTFactory.
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
enumerateFor: import_editor5.ASTFactory.createKeyPathExpression({
|
|
1888
|
-
keyPath: value.content || []
|
|
1889
|
-
})
|
|
1846
|
+
parse: (value, ctx) => [
|
|
1847
|
+
import_editor5.ASTFactory.createVariableDeclaration({
|
|
1848
|
+
key: `${ctx.node.id}_locals`,
|
|
1849
|
+
meta: {
|
|
1850
|
+
title: (0, import_editor5.getNodeForm)(ctx.node)?.getValueIn("title"),
|
|
1851
|
+
icon: ctx.node.getNodeRegistry().info?.icon
|
|
1852
|
+
},
|
|
1853
|
+
type: import_editor5.ASTFactory.createObject({
|
|
1854
|
+
properties: [
|
|
1855
|
+
import_editor5.ASTFactory.createProperty({
|
|
1856
|
+
key: "item",
|
|
1857
|
+
initializer: import_editor5.ASTFactory.createEnumerateExpression({
|
|
1858
|
+
enumerateFor: import_editor5.ASTFactory.createKeyPathExpression({
|
|
1859
|
+
keyPath: value.content || []
|
|
1890
1860
|
})
|
|
1891
|
-
}),
|
|
1892
|
-
import_editor5.ASTFactory.createProperty({
|
|
1893
|
-
key: "index",
|
|
1894
|
-
type: import_editor5.ASTFactory.createNumber()
|
|
1895
1861
|
})
|
|
1896
|
-
|
|
1897
|
-
|
|
1862
|
+
}),
|
|
1863
|
+
import_editor5.ASTFactory.createProperty({
|
|
1864
|
+
key: "index",
|
|
1865
|
+
type: import_editor5.ASTFactory.createNumber()
|
|
1866
|
+
})
|
|
1867
|
+
]
|
|
1898
1868
|
})
|
|
1899
|
-
|
|
1900
|
-
|
|
1869
|
+
})
|
|
1870
|
+
]
|
|
1901
1871
|
});
|
|
1902
1872
|
|
|
1903
1873
|
// src/effects/provide-batch-outputs/index.ts
|
|
1904
1874
|
var import_editor6 = require("@flowgram.ai/editor");
|
|
1905
1875
|
var provideBatchOutputsEffect = (0, import_editor6.createEffectFromVariableProvider)({
|
|
1906
1876
|
private: true,
|
|
1907
|
-
parse: (value, ctx) =>
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
wrapFor: import_editor6.ASTFactory.createKeyPathExpression({
|
|
1922
|
-
keyPath: value2.content || []
|
|
1923
|
-
})
|
|
1877
|
+
parse: (value, ctx) => [
|
|
1878
|
+
import_editor6.ASTFactory.createVariableDeclaration({
|
|
1879
|
+
key: `${ctx.node.id}`,
|
|
1880
|
+
meta: {
|
|
1881
|
+
title: (0, import_editor6.getNodeForm)(ctx.node)?.getValueIn("title"),
|
|
1882
|
+
icon: ctx.node.getNodeRegistry().info?.icon
|
|
1883
|
+
},
|
|
1884
|
+
type: import_editor6.ASTFactory.createObject({
|
|
1885
|
+
properties: Object.entries(value).map(
|
|
1886
|
+
([_key, value2]) => import_editor6.ASTFactory.createProperty({
|
|
1887
|
+
key: _key,
|
|
1888
|
+
initializer: import_editor6.ASTFactory.createWrapArrayExpression({
|
|
1889
|
+
wrapFor: import_editor6.ASTFactory.createKeyPathExpression({
|
|
1890
|
+
keyPath: value2.content || []
|
|
1924
1891
|
})
|
|
1925
1892
|
})
|
|
1926
|
-
)
|
|
1927
|
-
|
|
1893
|
+
})
|
|
1894
|
+
)
|
|
1928
1895
|
})
|
|
1929
|
-
|
|
1930
|
-
|
|
1896
|
+
})
|
|
1897
|
+
]
|
|
1931
1898
|
});
|
|
1932
1899
|
|
|
1933
1900
|
// src/effects/auto-rename-ref/index.ts
|
|
@@ -1949,9 +1916,8 @@ var autoRenameRefEffect = [
|
|
|
1949
1916
|
after.key
|
|
1950
1917
|
];
|
|
1951
1918
|
traverseRef(name, form.getValueIn(name), (_drilldownName, _v) => {
|
|
1952
|
-
var _a;
|
|
1953
1919
|
if (isRefMatch(_v, beforeKeyPath)) {
|
|
1954
|
-
_v.content = [...afterKeyPath, ...(
|
|
1920
|
+
_v.content = [...afterKeyPath, ...(_v.content || [])?.slice(beforeKeyPath.length)];
|
|
1955
1921
|
form.setValueIn(_drilldownName, _v);
|
|
1956
1922
|
}
|
|
1957
1923
|
});
|
|
@@ -1963,13 +1929,10 @@ var autoRenameRefEffect = [
|
|
|
1963
1929
|
}
|
|
1964
1930
|
];
|
|
1965
1931
|
function isRefMatch(value, targetKeyPath) {
|
|
1966
|
-
return targetKeyPath.every((_key, index) =>
|
|
1967
|
-
var _a;
|
|
1968
|
-
return _key === ((_a = value.content) == null ? void 0 : _a[index]);
|
|
1969
|
-
});
|
|
1932
|
+
return targetKeyPath.every((_key, index) => _key === value.content?.[index]);
|
|
1970
1933
|
}
|
|
1971
1934
|
function isRef(value) {
|
|
1972
|
-
return
|
|
1935
|
+
return value?.type === "ref" && Array.isArray(value?.content) && typeof value?.content[0] === "string";
|
|
1973
1936
|
}
|
|
1974
1937
|
function traverseRef(name, value, cb) {
|
|
1975
1938
|
if ((0, import_lodash3.isObject)(value)) {
|