@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/esm/index.js
CHANGED
|
@@ -348,11 +348,10 @@ var ArrayIcons = {
|
|
|
348
348
|
)
|
|
349
349
|
};
|
|
350
350
|
var getSchemaIcon = (value) => {
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
return ArrayIcons[((_a = value.items) == null ? void 0 : _a.type) || "object"];
|
|
351
|
+
if (value?.type === "array") {
|
|
352
|
+
return ArrayIcons[value.items?.type || "object"];
|
|
354
353
|
}
|
|
355
|
-
return VariableTypeIcons[
|
|
354
|
+
return VariableTypeIcons[value?.type || "object"];
|
|
356
355
|
};
|
|
357
356
|
var labelStyle = { display: "flex", alignItems: "center", gap: 5 };
|
|
358
357
|
var firstUppercase = (str) => str.charAt(0).toUpperCase() + str.slice(1);
|
|
@@ -414,7 +413,7 @@ var JsonSchemaUtils;
|
|
|
414
413
|
return { kind: ASTKind.Object, weak: true };
|
|
415
414
|
}
|
|
416
415
|
return ASTFactory.createObject({
|
|
417
|
-
properties: Object.entries(jsonSchema.properties || {}).sort((a, b) => (get(a
|
|
416
|
+
properties: Object.entries(jsonSchema.properties || {}).sort((a, b) => (get(a?.[1], "extra.index") || 0) - (get(b?.[1], "extra.index") || 0)).map(([key, _property]) => ({
|
|
418
417
|
key,
|
|
419
418
|
type: schemaToAST(_property),
|
|
420
419
|
meta: { description: _property.description }
|
|
@@ -515,8 +514,7 @@ function useVariableTree(params) {
|
|
|
515
514
|
const { includeSchema, excludeSchema } = params;
|
|
516
515
|
const available = useScopeAvailable();
|
|
517
516
|
const getVariableTypeIcon = useCallback((variable) => {
|
|
518
|
-
|
|
519
|
-
if ((_a = variable.meta) == null ? void 0 : _a.icon) {
|
|
517
|
+
if (variable.meta?.icon) {
|
|
520
518
|
if (typeof variable.meta.icon === "string") {
|
|
521
519
|
return /* @__PURE__ */ React2.createElement("img", { style: { marginRight: 8 }, width: 12, height: 12, src: variable.meta.icon });
|
|
522
520
|
}
|
|
@@ -528,25 +526,24 @@ function useVariableTree(params) {
|
|
|
528
526
|
Icon2,
|
|
529
527
|
{
|
|
530
528
|
size: "small",
|
|
531
|
-
svg: ArrayIcons[
|
|
529
|
+
svg: ArrayIcons[_type.items?.kind.toLowerCase()] || VariableTypeIcons.array
|
|
532
530
|
}
|
|
533
531
|
);
|
|
534
532
|
}
|
|
535
533
|
if (ASTMatch2.isCustomType(_type)) {
|
|
536
534
|
return /* @__PURE__ */ React2.createElement(Icon2, { size: "small", svg: VariableTypeIcons[_type.typeName.toLowerCase()] });
|
|
537
535
|
}
|
|
538
|
-
return /* @__PURE__ */ React2.createElement(Icon2, { size: "small", svg: VariableTypeIcons[
|
|
536
|
+
return /* @__PURE__ */ React2.createElement(Icon2, { size: "small", svg: VariableTypeIcons[variable.type?.kind.toLowerCase()] });
|
|
539
537
|
}, []);
|
|
540
538
|
const renderVariable = (variable, parentFields = []) => {
|
|
541
|
-
|
|
542
|
-
let type = variable == null ? void 0 : variable.type;
|
|
539
|
+
let type = variable?.type;
|
|
543
540
|
if (!type) {
|
|
544
541
|
return null;
|
|
545
542
|
}
|
|
546
543
|
let children;
|
|
547
544
|
if (ASTMatch2.isObject(type)) {
|
|
548
545
|
children = (type.properties || []).map((_property) => renderVariable(_property, [...parentFields, variable])).filter(Boolean);
|
|
549
|
-
if (!
|
|
546
|
+
if (!children?.length) {
|
|
550
547
|
return null;
|
|
551
548
|
}
|
|
552
549
|
}
|
|
@@ -555,18 +552,18 @@ function useVariableTree(params) {
|
|
|
555
552
|
const isSchemaInclude = includeSchema ? JsonSchemaUtils.isASTMatchSchema(type, includeSchema) : true;
|
|
556
553
|
const isSchemaExclude = excludeSchema ? JsonSchemaUtils.isASTMatchSchema(type, excludeSchema) : false;
|
|
557
554
|
const isSchemaMatch = isSchemaInclude && !isSchemaExclude;
|
|
558
|
-
if (!isSchemaMatch && !
|
|
555
|
+
if (!isSchemaMatch && !children?.length) {
|
|
559
556
|
return null;
|
|
560
557
|
}
|
|
561
558
|
return {
|
|
562
559
|
key,
|
|
563
|
-
label:
|
|
560
|
+
label: variable.meta?.title || variable.key,
|
|
564
561
|
value: key,
|
|
565
562
|
keyPath,
|
|
566
563
|
icon: getVariableTypeIcon(variable),
|
|
567
564
|
children,
|
|
568
565
|
disabled: !isSchemaMatch,
|
|
569
|
-
rootMeta:
|
|
566
|
+
rootMeta: parentFields[0]?.meta
|
|
570
567
|
};
|
|
571
568
|
};
|
|
572
569
|
return [...available.variables.slice(0).reverse()].map((_variable) => renderVariable(_variable)).filter(Boolean);
|
|
@@ -626,7 +623,6 @@ var VariableSelector = ({
|
|
|
626
623
|
hasError,
|
|
627
624
|
triggerRender
|
|
628
625
|
}) => {
|
|
629
|
-
var _a;
|
|
630
626
|
const treeData = useVariableTree({ includeSchema, excludeSchema });
|
|
631
627
|
const treeValue = useMemo(() => {
|
|
632
628
|
if (typeof value === "string") {
|
|
@@ -636,7 +632,7 @@ var VariableSelector = ({
|
|
|
636
632
|
);
|
|
637
633
|
return value;
|
|
638
634
|
}
|
|
639
|
-
return value
|
|
635
|
+
return value?.join(".");
|
|
640
636
|
}, [value]);
|
|
641
637
|
const renderIcon = (icon) => {
|
|
642
638
|
if (typeof icon === "string") {
|
|
@@ -660,8 +656,7 @@ var VariableSelector = ({
|
|
|
660
656
|
onChange(_config.keyPath);
|
|
661
657
|
},
|
|
662
658
|
renderSelectedItem: (_option) => {
|
|
663
|
-
|
|
664
|
-
if (!(_option == null ? void 0 : _option.keyPath)) {
|
|
659
|
+
if (!_option?.keyPath) {
|
|
665
660
|
return /* @__PURE__ */ React3.createElement(
|
|
666
661
|
UITag,
|
|
667
662
|
{
|
|
@@ -670,24 +665,24 @@ var VariableSelector = ({
|
|
|
670
665
|
closable: !readonly,
|
|
671
666
|
onClose: () => onChange(void 0)
|
|
672
667
|
},
|
|
673
|
-
|
|
668
|
+
config?.notFoundContent ?? "Undefined"
|
|
674
669
|
);
|
|
675
670
|
}
|
|
676
671
|
return /* @__PURE__ */ React3.createElement(
|
|
677
672
|
UITag,
|
|
678
673
|
{
|
|
679
|
-
prefixIcon: renderIcon(
|
|
674
|
+
prefixIcon: renderIcon(_option.rootMeta?.icon || _option?.icon),
|
|
680
675
|
closable: !readonly,
|
|
681
676
|
onClose: () => onChange(void 0)
|
|
682
677
|
},
|
|
683
|
-
/* @__PURE__ */ React3.createElement(UIRootTitle, null,
|
|
678
|
+
/* @__PURE__ */ React3.createElement(UIRootTitle, null, _option.rootMeta?.title ? `${_option.rootMeta?.title} -` : null),
|
|
684
679
|
_option.label
|
|
685
680
|
);
|
|
686
681
|
},
|
|
687
682
|
showClear: false,
|
|
688
683
|
arrowIcon: /* @__PURE__ */ React3.createElement(IconChevronDownStroked, { size: "small" }),
|
|
689
684
|
triggerRender,
|
|
690
|
-
placeholder:
|
|
685
|
+
placeholder: config?.placeholder ?? "Select Variable..."
|
|
691
686
|
}
|
|
692
687
|
));
|
|
693
688
|
};
|
|
@@ -696,10 +691,10 @@ var VariableSelector = ({
|
|
|
696
691
|
import React4, { useMemo as useMemo2 } from "react";
|
|
697
692
|
import { Button, Cascader } from "@douyinfe/semi-ui";
|
|
698
693
|
var getTypeSelectValue = (value) => {
|
|
699
|
-
if (
|
|
694
|
+
if (value?.type === "array" && value?.items) {
|
|
700
695
|
return [value.type, ...getTypeSelectValue(value.items) || []];
|
|
701
696
|
}
|
|
702
|
-
return
|
|
697
|
+
return value?.type ? [value.type] : void 0;
|
|
703
698
|
};
|
|
704
699
|
var parseTypeSelectValue = (value) => {
|
|
705
700
|
const [type, ...subTypes] = value || [];
|
|
@@ -943,31 +938,21 @@ function getDrilldownSchema(value, path) {
|
|
|
943
938
|
return { schema: value, path };
|
|
944
939
|
}
|
|
945
940
|
function usePropertiesEdit(value, onChange) {
|
|
946
|
-
|
|
947
|
-
const
|
|
948
|
-
const isDrilldownObject = ((_a = drilldown.schema) == null ? void 0 : _a.type) === "object";
|
|
941
|
+
const drilldown = useMemo3(() => getDrilldownSchema(value), [value, value?.type, value?.items]);
|
|
942
|
+
const isDrilldownObject = drilldown.schema?.type === "object";
|
|
949
943
|
const initPropertyList = useMemo3(
|
|
950
|
-
() => {
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
key: genId(),
|
|
960
|
-
name,
|
|
961
|
-
isPropertyRequired: ((_b = (_a3 = drilldown.schema) == null ? void 0 : _a3.required) == null ? void 0 : _b.includes(name)) || false,
|
|
962
|
-
..._value,
|
|
963
|
-
extra: {
|
|
964
|
-
..._value.extra || {},
|
|
965
|
-
index
|
|
966
|
-
}
|
|
967
|
-
};
|
|
944
|
+
() => isDrilldownObject ? Object.entries(drilldown.schema?.properties || {}).sort(([, a], [, b]) => (a.extra?.index ?? 0) - (b.extra?.index ?? 0)).map(
|
|
945
|
+
([name, _value], index) => ({
|
|
946
|
+
key: genId(),
|
|
947
|
+
name,
|
|
948
|
+
isPropertyRequired: drilldown.schema?.required?.includes(name) || false,
|
|
949
|
+
..._value,
|
|
950
|
+
extra: {
|
|
951
|
+
..._value.extra || {},
|
|
952
|
+
index
|
|
968
953
|
}
|
|
969
|
-
)
|
|
970
|
-
|
|
954
|
+
})
|
|
955
|
+
) : [],
|
|
971
956
|
[isDrilldownObject]
|
|
972
957
|
);
|
|
973
958
|
const [propertyList, setPropertyList] = useState(initPropertyList);
|
|
@@ -975,31 +960,26 @@ function usePropertiesEdit(value, onChange) {
|
|
|
975
960
|
useEffect(() => {
|
|
976
961
|
if (mountRef.current) {
|
|
977
962
|
setPropertyList((_list) => {
|
|
978
|
-
var _a2;
|
|
979
963
|
const nameMap = /* @__PURE__ */ new Map();
|
|
980
964
|
for (const _property of _list) {
|
|
981
965
|
if (_property.name) {
|
|
982
966
|
nameMap.set(_property.name, _property);
|
|
983
967
|
}
|
|
984
968
|
}
|
|
985
|
-
return Object.entries(
|
|
986
|
-
var _a3, _b, _c, _d;
|
|
987
|
-
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);
|
|
988
|
-
}).map(([name, _value]) => {
|
|
989
|
-
var _a3, _b, _c, _d;
|
|
969
|
+
return Object.entries(drilldown.schema?.properties || {}).sort(([, a], [, b]) => (a.extra?.index ?? 0) - (b.extra?.index ?? 0)).map(([name, _value]) => {
|
|
990
970
|
const _property = nameMap.get(name);
|
|
991
971
|
if (_property) {
|
|
992
972
|
return {
|
|
993
973
|
key: _property.key,
|
|
994
974
|
name,
|
|
995
|
-
isPropertyRequired:
|
|
975
|
+
isPropertyRequired: drilldown.schema?.required?.includes(name) || false,
|
|
996
976
|
..._value
|
|
997
977
|
};
|
|
998
978
|
}
|
|
999
979
|
return {
|
|
1000
980
|
key: genId(),
|
|
1001
981
|
name,
|
|
1002
|
-
isPropertyRequired:
|
|
982
|
+
isPropertyRequired: drilldown.schema?.required?.includes(name) || false,
|
|
1003
983
|
..._value
|
|
1004
984
|
};
|
|
1005
985
|
});
|
|
@@ -1027,7 +1007,7 @@ function usePropertiesEdit(value, onChange) {
|
|
|
1027
1007
|
}
|
|
1028
1008
|
drilldownSchema.properties = nextProperties;
|
|
1029
1009
|
drilldownSchema.required = nextRequired;
|
|
1030
|
-
onChange
|
|
1010
|
+
onChange?.(value || {});
|
|
1031
1011
|
return next;
|
|
1032
1012
|
});
|
|
1033
1013
|
};
|
|
@@ -1088,11 +1068,11 @@ import React6, { useMemo as useMemo4 } from "react";
|
|
|
1088
1068
|
import { Input, InputNumber, Select } from "@douyinfe/semi-ui";
|
|
1089
1069
|
var defaultStrategies = [
|
|
1090
1070
|
{
|
|
1091
|
-
hit: (schema) =>
|
|
1071
|
+
hit: (schema) => schema?.type === "string",
|
|
1092
1072
|
Renderer: (props) => /* @__PURE__ */ React6.createElement(Input, { placeholder: "Please Input String", size: "small", disabled: props.readonly, ...props })
|
|
1093
1073
|
},
|
|
1094
1074
|
{
|
|
1095
|
-
hit: (schema) =>
|
|
1075
|
+
hit: (schema) => schema?.type === "number",
|
|
1096
1076
|
Renderer: (props) => /* @__PURE__ */ React6.createElement(
|
|
1097
1077
|
InputNumber,
|
|
1098
1078
|
{
|
|
@@ -1105,7 +1085,7 @@ var defaultStrategies = [
|
|
|
1105
1085
|
)
|
|
1106
1086
|
},
|
|
1107
1087
|
{
|
|
1108
|
-
hit: (schema) =>
|
|
1088
|
+
hit: (schema) => schema?.type === "integer",
|
|
1109
1089
|
Renderer: (props) => /* @__PURE__ */ React6.createElement(
|
|
1110
1090
|
InputNumber,
|
|
1111
1091
|
{
|
|
@@ -1119,7 +1099,7 @@ var defaultStrategies = [
|
|
|
1119
1099
|
)
|
|
1120
1100
|
},
|
|
1121
1101
|
{
|
|
1122
|
-
hit: (schema) =>
|
|
1102
|
+
hit: (schema) => schema?.type === "boolean",
|
|
1123
1103
|
Renderer: (props) => {
|
|
1124
1104
|
const { value, onChange, ...rest } = props;
|
|
1125
1105
|
return /* @__PURE__ */ React6.createElement(
|
|
@@ -1133,7 +1113,7 @@ var defaultStrategies = [
|
|
|
1133
1113
|
{ label: "False", value: 0 }
|
|
1134
1114
|
],
|
|
1135
1115
|
value: value ? 1 : 0,
|
|
1136
|
-
onChange: (value2) => onChange
|
|
1116
|
+
onChange: (value2) => onChange?.(!!value2),
|
|
1137
1117
|
...rest
|
|
1138
1118
|
}
|
|
1139
1119
|
);
|
|
@@ -1148,7 +1128,7 @@ function ConstantInput(props) {
|
|
|
1148
1128
|
);
|
|
1149
1129
|
const Renderer = useMemo4(() => {
|
|
1150
1130
|
const strategy = strategies.find((_strategy) => _strategy.hit(schema));
|
|
1151
|
-
return strategy
|
|
1131
|
+
return strategy?.Renderer;
|
|
1152
1132
|
}, [strategies, schema]);
|
|
1153
1133
|
if (!Renderer) {
|
|
1154
1134
|
return /* @__PURE__ */ React6.createElement(Input, { size: "small", disabled: true, placeholder: "Unsupported type" });
|
|
@@ -1172,8 +1152,7 @@ function DefaultValue(props) {
|
|
|
1172
1152
|
const handleEditComplete = useCallback2(() => {
|
|
1173
1153
|
onChange(internalJsonValue);
|
|
1174
1154
|
requestAnimationFrame(() => {
|
|
1175
|
-
|
|
1176
|
-
(_a = wrapperRef.current) == null ? void 0 : _a.blur();
|
|
1155
|
+
wrapperRef.current?.blur();
|
|
1177
1156
|
});
|
|
1178
1157
|
setJsonReadOnly(true);
|
|
1179
1158
|
}, [internalJsonValue, onChange]);
|
|
@@ -1188,7 +1167,7 @@ function DefaultValue(props) {
|
|
|
1188
1167
|
console.error("Invalid JSON:", error);
|
|
1189
1168
|
}
|
|
1190
1169
|
}, [internalJsonValue, onChange]);
|
|
1191
|
-
return type === "object" ? /* @__PURE__ */ React7.createElement(React7.Fragment, null, /* @__PURE__ */ React7.createElement(JSONHeader, null, /* @__PURE__ */ React7.createElement(JSONHeaderLeft, null, "json"), /* @__PURE__ */ React7.createElement(JSONHeaderRight, null, /* @__PURE__ */ React7.createElement(Tooltip, { content: jsonFormatText
|
|
1170
|
+
return type === "object" ? /* @__PURE__ */ React7.createElement(React7.Fragment, null, /* @__PURE__ */ React7.createElement(JSONHeader, null, /* @__PURE__ */ React7.createElement(JSONHeaderLeft, null, "json"), /* @__PURE__ */ React7.createElement(JSONHeaderRight, null, /* @__PURE__ */ React7.createElement(Tooltip, { content: jsonFormatText ?? "Format" }, /* @__PURE__ */ React7.createElement(
|
|
1192
1171
|
IconButton,
|
|
1193
1172
|
{
|
|
1194
1173
|
icon: /* @__PURE__ */ React7.createElement(IconBrackets, { style: { color: "var(--semi-color-primary)" } }),
|
|
@@ -1203,8 +1182,7 @@ function DefaultValue(props) {
|
|
|
1203
1182
|
ref: wrapperRef,
|
|
1204
1183
|
tabIndex: -1,
|
|
1205
1184
|
onBlur: (e) => {
|
|
1206
|
-
|
|
1207
|
-
if (wrapperRef.current && !((_a = wrapperRef.current) == null ? void 0 : _a.contains(e.relatedTarget))) {
|
|
1185
|
+
if (wrapperRef.current && !wrapperRef.current?.contains(e.relatedTarget)) {
|
|
1208
1186
|
handleEditComplete();
|
|
1209
1187
|
}
|
|
1210
1188
|
},
|
|
@@ -1236,7 +1214,7 @@ function DefaultValue(props) {
|
|
|
1236
1214
|
value,
|
|
1237
1215
|
onChange: (_v) => onChange(_v),
|
|
1238
1216
|
schema: schema || { type: "string" },
|
|
1239
|
-
placeholder: placeholder
|
|
1217
|
+
placeholder: placeholder ?? "Default value if parameter is not provided"
|
|
1240
1218
|
}
|
|
1241
1219
|
));
|
|
1242
1220
|
}
|
|
@@ -1257,17 +1235,13 @@ function BlurInput(props) {
|
|
|
1257
1235
|
onChange: (value2) => {
|
|
1258
1236
|
setValue(value2);
|
|
1259
1237
|
},
|
|
1260
|
-
onBlur: (e) =>
|
|
1261
|
-
var _a;
|
|
1262
|
-
return (_a = props.onChange) == null ? void 0 : _a.call(props, value, e);
|
|
1263
|
-
}
|
|
1238
|
+
onBlur: (e) => props.onChange?.(value, e)
|
|
1264
1239
|
}
|
|
1265
1240
|
);
|
|
1266
1241
|
}
|
|
1267
1242
|
|
|
1268
1243
|
// src/components/json-schema-editor/index.tsx
|
|
1269
1244
|
function JsonSchemaEditor(props) {
|
|
1270
|
-
var _a;
|
|
1271
1245
|
const { value = { type: "object" }, config = {}, onChange: onChangeProps } = props;
|
|
1272
1246
|
const { propertyList, onAddProperty, onRemoveProperty, onEditProperty } = usePropertiesEdit(
|
|
1273
1247
|
value,
|
|
@@ -1287,10 +1261,9 @@ function JsonSchemaEditor(props) {
|
|
|
1287
1261
|
onRemoveProperty(_property.key);
|
|
1288
1262
|
}
|
|
1289
1263
|
}
|
|
1290
|
-
))), /* @__PURE__ */ React9.createElement(Button2, { size: "small", style: { marginTop: 10 }, icon: /* @__PURE__ */ React9.createElement(IconPlus, null), onClick: onAddProperty },
|
|
1264
|
+
))), /* @__PURE__ */ React9.createElement(Button2, { size: "small", style: { marginTop: 10 }, icon: /* @__PURE__ */ React9.createElement(IconPlus, null), onClick: onAddProperty }, config?.addButtonText ?? "Add"));
|
|
1291
1265
|
}
|
|
1292
1266
|
function PropertyEdit(props) {
|
|
1293
|
-
var _a, _b, _c, _d;
|
|
1294
1267
|
const {
|
|
1295
1268
|
value,
|
|
1296
1269
|
config,
|
|
@@ -1310,7 +1283,7 @@ function PropertyEdit(props) {
|
|
|
1310
1283
|
const typeSelectorValue = useMemo5(() => ({ type, items }), [type, items]);
|
|
1311
1284
|
const { propertyList, isDrilldownObject, onAddProperty, onRemoveProperty, onEditProperty } = usePropertiesEdit(value, onChangeProps);
|
|
1312
1285
|
const onChange = (key, _value) => {
|
|
1313
|
-
onChangeProps
|
|
1286
|
+
onChangeProps?.({
|
|
1314
1287
|
...value || {},
|
|
1315
1288
|
[key]: _value
|
|
1316
1289
|
});
|
|
@@ -1340,7 +1313,7 @@ function PropertyEdit(props) {
|
|
|
1340
1313
|
/* @__PURE__ */ React9.createElement(UIRow, null, /* @__PURE__ */ React9.createElement(UIName, null, /* @__PURE__ */ React9.createElement(
|
|
1341
1314
|
BlurInput,
|
|
1342
1315
|
{
|
|
1343
|
-
placeholder:
|
|
1316
|
+
placeholder: config?.placeholder ?? "Input Variable Name",
|
|
1344
1317
|
size: "small",
|
|
1345
1318
|
value: name,
|
|
1346
1319
|
onChange: (value2) => onChange("name", value2)
|
|
@@ -1350,7 +1323,7 @@ function PropertyEdit(props) {
|
|
|
1350
1323
|
{
|
|
1351
1324
|
value: typeSelectorValue,
|
|
1352
1325
|
onChange: (_value) => {
|
|
1353
|
-
onChangeProps
|
|
1326
|
+
onChangeProps?.({
|
|
1354
1327
|
...value || {},
|
|
1355
1328
|
..._value
|
|
1356
1329
|
});
|
|
@@ -1392,22 +1365,22 @@ function PropertyEdit(props) {
|
|
|
1392
1365
|
onClick: onRemove
|
|
1393
1366
|
}
|
|
1394
1367
|
))),
|
|
1395
|
-
expand && /* @__PURE__ */ React9.createElement(UIExpandDetail, null, /* @__PURE__ */ React9.createElement(UILabel, null,
|
|
1368
|
+
expand && /* @__PURE__ */ React9.createElement(UIExpandDetail, null, /* @__PURE__ */ React9.createElement(UILabel, null, config?.descTitle ?? "Description"), /* @__PURE__ */ React9.createElement(
|
|
1396
1369
|
BlurInput,
|
|
1397
1370
|
{
|
|
1398
1371
|
size: "small",
|
|
1399
1372
|
value: description,
|
|
1400
1373
|
onChange: (value2) => onChange("description", value2),
|
|
1401
|
-
placeholder:
|
|
1374
|
+
placeholder: config?.descPlaceholder ?? "Help LLM to understand the property"
|
|
1402
1375
|
}
|
|
1403
|
-
), $level === 0 && type && type !== "array" && /* @__PURE__ */ React9.createElement(React9.Fragment, null, /* @__PURE__ */ React9.createElement(UILabel, { style: { marginTop: 10 } },
|
|
1376
|
+
), $level === 0 && type && type !== "array" && /* @__PURE__ */ React9.createElement(React9.Fragment, null, /* @__PURE__ */ React9.createElement(UILabel, { style: { marginTop: 10 } }, config?.defaultValueTitle ?? "Default Value"), /* @__PURE__ */ React9.createElement(DefaultValueWrapper, null, /* @__PURE__ */ React9.createElement(
|
|
1404
1377
|
DefaultValue,
|
|
1405
1378
|
{
|
|
1406
1379
|
value: defaultValue,
|
|
1407
1380
|
schema: value,
|
|
1408
1381
|
type,
|
|
1409
|
-
placeholder: config
|
|
1410
|
-
jsonFormatText: config
|
|
1382
|
+
placeholder: config?.defaultValuePlaceholder,
|
|
1383
|
+
jsonFormatText: config?.jsonFormatText,
|
|
1411
1384
|
onChange: (value2) => onChange("default", value2)
|
|
1412
1385
|
}
|
|
1413
1386
|
))))
|
|
@@ -1478,17 +1451,17 @@ function DynamicValueInput({
|
|
|
1478
1451
|
constantProps
|
|
1479
1452
|
}) {
|
|
1480
1453
|
const includeSchema = useMemo6(() => {
|
|
1481
|
-
if (
|
|
1454
|
+
if (schema?.type === "number") {
|
|
1482
1455
|
return [schema, { type: "integer" }];
|
|
1483
1456
|
}
|
|
1484
1457
|
return schema;
|
|
1485
1458
|
}, [schema]);
|
|
1486
1459
|
const renderMain = () => {
|
|
1487
|
-
if (
|
|
1460
|
+
if (value?.type === "ref") {
|
|
1488
1461
|
return /* @__PURE__ */ React11.createElement(
|
|
1489
1462
|
VariableSelector,
|
|
1490
1463
|
{
|
|
1491
|
-
value: value
|
|
1464
|
+
value: value?.content,
|
|
1492
1465
|
onChange: (_v) => onChange(_v ? { type: "ref", content: _v } : void 0),
|
|
1493
1466
|
includeSchema,
|
|
1494
1467
|
readonly
|
|
@@ -1498,7 +1471,7 @@ function DynamicValueInput({
|
|
|
1498
1471
|
return /* @__PURE__ */ React11.createElement(
|
|
1499
1472
|
ConstantInput,
|
|
1500
1473
|
{
|
|
1501
|
-
value: value
|
|
1474
|
+
value: value?.content,
|
|
1502
1475
|
onChange: (_v) => onChange({ type: "constant", content: _v }),
|
|
1503
1476
|
schema: schema || { type: "string" },
|
|
1504
1477
|
readonly,
|
|
@@ -1510,7 +1483,7 @@ function DynamicValueInput({
|
|
|
1510
1483
|
VariableSelector,
|
|
1511
1484
|
{
|
|
1512
1485
|
style: { width: "100%" },
|
|
1513
|
-
value:
|
|
1486
|
+
value: value?.type === "ref" ? value?.content : void 0,
|
|
1514
1487
|
onChange: (_v) => onChange({ type: "ref", content: _v }),
|
|
1515
1488
|
includeSchema,
|
|
1516
1489
|
readonly,
|
|
@@ -1744,8 +1717,8 @@ function useRule(left) {
|
|
|
1744
1717
|
const rule = useMemo7(() => {
|
|
1745
1718
|
if (!variable) return void 0;
|
|
1746
1719
|
const schema = JsonSchemaUtils.astToSchema(variable.type, { drilldown: false });
|
|
1747
|
-
return rules[schema
|
|
1748
|
-
}, [variable
|
|
1720
|
+
return rules[schema?.type];
|
|
1721
|
+
}, [variable?.type]);
|
|
1749
1722
|
return { rule };
|
|
1750
1723
|
}
|
|
1751
1724
|
|
|
@@ -1772,7 +1745,7 @@ function useOp({ rule, op, onChange }) {
|
|
|
1772
1745
|
onChange: (v) => {
|
|
1773
1746
|
onChange(v);
|
|
1774
1747
|
},
|
|
1775
|
-
triggerRender: ({ value }) => /* @__PURE__ */ React12.createElement(Button3, { size: "small", disabled: !rule },
|
|
1748
|
+
triggerRender: ({ value }) => /* @__PURE__ */ React12.createElement(Button3, { size: "small", disabled: !rule }, opConfig?.abbreviation || /* @__PURE__ */ React12.createElement(IconChevronDownStroked2, { size: "small" }))
|
|
1776
1749
|
}
|
|
1777
1750
|
);
|
|
1778
1751
|
return { renderOpSelect, opConfig };
|
|
@@ -1788,7 +1761,7 @@ function ConditionRow({ style, value, onChange, readonly }) {
|
|
|
1788
1761
|
onChange: (v) => onChange({ ...value, operator: v })
|
|
1789
1762
|
});
|
|
1790
1763
|
const targetSchema = useMemo9(() => {
|
|
1791
|
-
const targetType =
|
|
1764
|
+
const targetType = rule?.[operator] || null;
|
|
1792
1765
|
return targetType ? { type: targetType, extra: { weak: true } } : null;
|
|
1793
1766
|
}, [rule, opConfig]);
|
|
1794
1767
|
return /* @__PURE__ */ React13.createElement(UIContainer3, { style }, /* @__PURE__ */ React13.createElement(UIOperator, null, renderOpSelect()), /* @__PURE__ */ React13.createElement(UIValues, null, /* @__PURE__ */ React13.createElement(UILeft, null, /* @__PURE__ */ React13.createElement(
|
|
@@ -1796,7 +1769,7 @@ function ConditionRow({ style, value, onChange, readonly }) {
|
|
|
1796
1769
|
{
|
|
1797
1770
|
readonly,
|
|
1798
1771
|
style: { width: "100%" },
|
|
1799
|
-
value: left
|
|
1772
|
+
value: left?.content,
|
|
1800
1773
|
onChange: (v) => onChange({
|
|
1801
1774
|
...value,
|
|
1802
1775
|
left: {
|
|
@@ -1813,7 +1786,7 @@ function ConditionRow({ style, value, onChange, readonly }) {
|
|
|
1813
1786
|
schema: targetSchema,
|
|
1814
1787
|
onChange: (v) => onChange({ ...value, right: v })
|
|
1815
1788
|
}
|
|
1816
|
-
) : /* @__PURE__ */ React13.createElement(Input3, { size: "small", disabled: true, value:
|
|
1789
|
+
) : /* @__PURE__ */ React13.createElement(Input3, { size: "small", disabled: true, value: opConfig?.rightDisplay || "Empty" }))));
|
|
1817
1790
|
}
|
|
1818
1791
|
|
|
1819
1792
|
// src/effects/provide-batch-input/index.ts
|
|
@@ -1824,34 +1797,31 @@ import {
|
|
|
1824
1797
|
} from "@flowgram.ai/editor";
|
|
1825
1798
|
var provideBatchInputEffect = createEffectFromVariableProvider({
|
|
1826
1799
|
private: true,
|
|
1827
|
-
parse: (value, ctx) =>
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
ASTFactory2.
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
enumerateFor: ASTFactory2.createKeyPathExpression({
|
|
1842
|
-
keyPath: value.content || []
|
|
1843
|
-
})
|
|
1800
|
+
parse: (value, ctx) => [
|
|
1801
|
+
ASTFactory2.createVariableDeclaration({
|
|
1802
|
+
key: `${ctx.node.id}_locals`,
|
|
1803
|
+
meta: {
|
|
1804
|
+
title: getNodeForm(ctx.node)?.getValueIn("title"),
|
|
1805
|
+
icon: ctx.node.getNodeRegistry().info?.icon
|
|
1806
|
+
},
|
|
1807
|
+
type: ASTFactory2.createObject({
|
|
1808
|
+
properties: [
|
|
1809
|
+
ASTFactory2.createProperty({
|
|
1810
|
+
key: "item",
|
|
1811
|
+
initializer: ASTFactory2.createEnumerateExpression({
|
|
1812
|
+
enumerateFor: ASTFactory2.createKeyPathExpression({
|
|
1813
|
+
keyPath: value.content || []
|
|
1844
1814
|
})
|
|
1845
|
-
}),
|
|
1846
|
-
ASTFactory2.createProperty({
|
|
1847
|
-
key: "index",
|
|
1848
|
-
type: ASTFactory2.createNumber()
|
|
1849
1815
|
})
|
|
1850
|
-
|
|
1851
|
-
|
|
1816
|
+
}),
|
|
1817
|
+
ASTFactory2.createProperty({
|
|
1818
|
+
key: "index",
|
|
1819
|
+
type: ASTFactory2.createNumber()
|
|
1820
|
+
})
|
|
1821
|
+
]
|
|
1852
1822
|
})
|
|
1853
|
-
|
|
1854
|
-
|
|
1823
|
+
})
|
|
1824
|
+
]
|
|
1855
1825
|
});
|
|
1856
1826
|
|
|
1857
1827
|
// src/effects/provide-batch-outputs/index.ts
|
|
@@ -1862,30 +1832,27 @@ import {
|
|
|
1862
1832
|
} from "@flowgram.ai/editor";
|
|
1863
1833
|
var provideBatchOutputsEffect = createEffectFromVariableProvider2({
|
|
1864
1834
|
private: true,
|
|
1865
|
-
parse: (value, ctx) =>
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
wrapFor: ASTFactory3.createKeyPathExpression({
|
|
1880
|
-
keyPath: value2.content || []
|
|
1881
|
-
})
|
|
1835
|
+
parse: (value, ctx) => [
|
|
1836
|
+
ASTFactory3.createVariableDeclaration({
|
|
1837
|
+
key: `${ctx.node.id}`,
|
|
1838
|
+
meta: {
|
|
1839
|
+
title: getNodeForm2(ctx.node)?.getValueIn("title"),
|
|
1840
|
+
icon: ctx.node.getNodeRegistry().info?.icon
|
|
1841
|
+
},
|
|
1842
|
+
type: ASTFactory3.createObject({
|
|
1843
|
+
properties: Object.entries(value).map(
|
|
1844
|
+
([_key, value2]) => ASTFactory3.createProperty({
|
|
1845
|
+
key: _key,
|
|
1846
|
+
initializer: ASTFactory3.createWrapArrayExpression({
|
|
1847
|
+
wrapFor: ASTFactory3.createKeyPathExpression({
|
|
1848
|
+
keyPath: value2.content || []
|
|
1882
1849
|
})
|
|
1883
1850
|
})
|
|
1884
|
-
)
|
|
1885
|
-
|
|
1851
|
+
})
|
|
1852
|
+
)
|
|
1886
1853
|
})
|
|
1887
|
-
|
|
1888
|
-
|
|
1854
|
+
})
|
|
1855
|
+
]
|
|
1889
1856
|
});
|
|
1890
1857
|
|
|
1891
1858
|
// src/effects/auto-rename-ref/index.ts
|
|
@@ -1910,9 +1877,8 @@ var autoRenameRefEffect = [
|
|
|
1910
1877
|
after.key
|
|
1911
1878
|
];
|
|
1912
1879
|
traverseRef(name, form.getValueIn(name), (_drilldownName, _v) => {
|
|
1913
|
-
var _a;
|
|
1914
1880
|
if (isRefMatch(_v, beforeKeyPath)) {
|
|
1915
|
-
_v.content = [...afterKeyPath, ...(
|
|
1881
|
+
_v.content = [...afterKeyPath, ...(_v.content || [])?.slice(beforeKeyPath.length)];
|
|
1916
1882
|
form.setValueIn(_drilldownName, _v);
|
|
1917
1883
|
}
|
|
1918
1884
|
});
|
|
@@ -1924,13 +1890,10 @@ var autoRenameRefEffect = [
|
|
|
1924
1890
|
}
|
|
1925
1891
|
];
|
|
1926
1892
|
function isRefMatch(value, targetKeyPath) {
|
|
1927
|
-
return targetKeyPath.every((_key, index) =>
|
|
1928
|
-
var _a;
|
|
1929
|
-
return _key === ((_a = value.content) == null ? void 0 : _a[index]);
|
|
1930
|
-
});
|
|
1893
|
+
return targetKeyPath.every((_key, index) => _key === value.content?.[index]);
|
|
1931
1894
|
}
|
|
1932
1895
|
function isRef(value) {
|
|
1933
|
-
return
|
|
1896
|
+
return value?.type === "ref" && Array.isArray(value?.content) && typeof value?.content[0] === "string";
|
|
1934
1897
|
}
|
|
1935
1898
|
function traverseRef(name, value, cb) {
|
|
1936
1899
|
if (isObject2(value)) {
|