@flowgram.ai/form-materials 0.2.5 → 0.2.6
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 +413 -190
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.mts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +425 -202
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
- package/src/components/json-schema-editor/default-value.tsx +130 -0
- package/src/components/json-schema-editor/index.tsx +64 -7
- package/src/components/json-schema-editor/styles.tsx +127 -37
- package/src/components/json-schema-editor/types.ts +3 -0
- package/src/components/json-schema-editor/utils.ts +24 -0
- package/src/components/variable-selector/index.tsx +1 -1
package/dist/esm/index.js
CHANGED
|
@@ -614,7 +614,7 @@ var UITreeSelect = styled(TreeSelect)`
|
|
|
614
614
|
// src/components/variable-selector/index.tsx
|
|
615
615
|
var VariableSelector = ({
|
|
616
616
|
value,
|
|
617
|
-
config,
|
|
617
|
+
config = {},
|
|
618
618
|
onChange,
|
|
619
619
|
style,
|
|
620
620
|
readonly = false,
|
|
@@ -723,8 +723,8 @@ function TypeSelector(props) {
|
|
|
723
723
|
}
|
|
724
724
|
|
|
725
725
|
// src/components/json-schema-editor/index.tsx
|
|
726
|
-
import
|
|
727
|
-
import { Button as Button2, Checkbox, IconButton } from "@douyinfe/semi-ui";
|
|
726
|
+
import React9, { useMemo as useMemo5, useState as useState4 } from "react";
|
|
727
|
+
import { Button as Button2, Checkbox, IconButton as IconButton2 } from "@douyinfe/semi-ui";
|
|
728
728
|
import {
|
|
729
729
|
IconExpand,
|
|
730
730
|
IconShrink,
|
|
@@ -776,32 +776,39 @@ var UIProperties = styled2.div`
|
|
|
776
776
|
var UIPropertyLeft = styled2.div`
|
|
777
777
|
grid-column: 1;
|
|
778
778
|
position: relative;
|
|
779
|
+
width: 16px;
|
|
779
780
|
|
|
780
|
-
${({ $showLine, $isLast }) =>
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
781
|
+
${({ $showLine, $isLast, $parentType }) => {
|
|
782
|
+
let height = "100%";
|
|
783
|
+
if ($parentType && $isLast) {
|
|
784
|
+
height = "24px";
|
|
785
|
+
}
|
|
786
|
+
return $showLine && css`
|
|
787
|
+
&::before {
|
|
788
|
+
/* 竖线 */
|
|
789
|
+
content: '';
|
|
790
|
+
height: ${height};
|
|
791
|
+
position: absolute;
|
|
792
|
+
left: -22px;
|
|
793
|
+
top: -16px;
|
|
794
|
+
width: 1px;
|
|
795
|
+
background: #d9d9d9;
|
|
796
|
+
display: block;
|
|
797
|
+
}
|
|
792
798
|
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
799
|
+
&::after {
|
|
800
|
+
/* 横线 */
|
|
801
|
+
content: '';
|
|
802
|
+
position: absolute;
|
|
803
|
+
left: -22px; // 横线起点和竖线对齐
|
|
804
|
+
top: 8px; // 跟随你的行高调整
|
|
805
|
+
width: 18px; // 横线长度
|
|
806
|
+
height: 1px;
|
|
807
|
+
background: #d9d9d9;
|
|
808
|
+
display: block;
|
|
809
|
+
}
|
|
810
|
+
`;
|
|
811
|
+
}}
|
|
805
812
|
`;
|
|
806
813
|
var UIPropertyRight = styled2.div`
|
|
807
814
|
grid-column: 2;
|
|
@@ -815,12 +822,31 @@ var UIPropertyMain = styled2.div`
|
|
|
815
822
|
display: flex;
|
|
816
823
|
flex-direction: column;
|
|
817
824
|
gap: 10px;
|
|
825
|
+
position: relative;
|
|
818
826
|
|
|
819
|
-
${({ $expand }) =>
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
827
|
+
${({ $expand, type, $collapse, $showCollapse }) => {
|
|
828
|
+
const beforeElement = `
|
|
829
|
+
&::before {
|
|
830
|
+
/* \u7AD6\u7EBF */
|
|
831
|
+
content: '';
|
|
832
|
+
height: 100%;
|
|
833
|
+
position: absolute;
|
|
834
|
+
left: -12px;
|
|
835
|
+
top: 18px;
|
|
836
|
+
width: 1px;
|
|
837
|
+
background: #d9d9d9;
|
|
838
|
+
display: block;
|
|
839
|
+
}`;
|
|
840
|
+
return $expand && css`
|
|
841
|
+
background-color: #f5f5f5;
|
|
842
|
+
padding: 10px;
|
|
843
|
+
border-radius: 4px;
|
|
844
|
+
|
|
845
|
+
${$showCollapse && $collapse && (type === "array" || type === "object") && css`
|
|
846
|
+
${beforeElement}
|
|
847
|
+
`}
|
|
848
|
+
`;
|
|
849
|
+
}}
|
|
824
850
|
`;
|
|
825
851
|
var UICollapsible = styled2.div`
|
|
826
852
|
display: none;
|
|
@@ -858,6 +884,43 @@ var iconAddChildrenSvg = /* @__PURE__ */ React5.createElement(
|
|
|
858
884
|
/* @__PURE__ */ React5.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" })
|
|
859
885
|
);
|
|
860
886
|
var IconAddChildren = () => /* @__PURE__ */ React5.createElement(Icon3, { size: "small", svg: iconAddChildrenSvg });
|
|
887
|
+
var DefaultValueWrapper = styled2.div`
|
|
888
|
+
margin: 0;
|
|
889
|
+
`;
|
|
890
|
+
var JSONViewerWrapper = styled2.div`
|
|
891
|
+
padding: 0 0 24px;
|
|
892
|
+
&:first-child {
|
|
893
|
+
margin-top: 0px;
|
|
894
|
+
}
|
|
895
|
+
`;
|
|
896
|
+
var JSONHeader = styled2.div`
|
|
897
|
+
display: flex;
|
|
898
|
+
justify-content: space-between;
|
|
899
|
+
align-items: center;
|
|
900
|
+
background-color: var(--semi-color-fill-0);
|
|
901
|
+
border-radius: 6px 6px 0 0;
|
|
902
|
+
height: 36px;
|
|
903
|
+
padding: 0 8px 0 12px;
|
|
904
|
+
`;
|
|
905
|
+
var JSONHeaderLeft = styled2.div`
|
|
906
|
+
display: flex;
|
|
907
|
+
align-items: center;
|
|
908
|
+
gap: 10px;
|
|
909
|
+
`;
|
|
910
|
+
var JSONHeaderRight = styled2.div`
|
|
911
|
+
display: flex;
|
|
912
|
+
align-items: center;
|
|
913
|
+
gap: 10px;
|
|
914
|
+
`;
|
|
915
|
+
var ConstantInputWrapper = styled2.div`
|
|
916
|
+
flex-grow: 1;
|
|
917
|
+
|
|
918
|
+
& .semi-tree-select,
|
|
919
|
+
& .semi-input-number,
|
|
920
|
+
& .semi-select {
|
|
921
|
+
width: 100%;
|
|
922
|
+
}
|
|
923
|
+
`;
|
|
861
924
|
|
|
862
925
|
// src/components/json-schema-editor/hooks.tsx
|
|
863
926
|
import { useEffect, useMemo as useMemo3, useRef, useState } from "react";
|
|
@@ -976,16 +1039,196 @@ function usePropertiesEdit(value, onChange) {
|
|
|
976
1039
|
};
|
|
977
1040
|
}
|
|
978
1041
|
|
|
1042
|
+
// src/components/json-schema-editor/default-value.tsx
|
|
1043
|
+
import React7, { useRef as useRef2, useState as useState2, useCallback as useCallback2 } from "react";
|
|
1044
|
+
import { IconButton, JsonViewer, Tooltip } from "@douyinfe/semi-ui";
|
|
1045
|
+
import { IconBrackets } from "@douyinfe/semi-icons";
|
|
1046
|
+
|
|
1047
|
+
// src/components/json-schema-editor/utils.ts
|
|
1048
|
+
function getValueType(value) {
|
|
1049
|
+
const type = typeof value;
|
|
1050
|
+
if (type === "string") {
|
|
1051
|
+
return "string";
|
|
1052
|
+
} else if (type === "number") {
|
|
1053
|
+
return Number.isInteger(value) ? "integer" : "number";
|
|
1054
|
+
} else if (type === "boolean") {
|
|
1055
|
+
return "boolean";
|
|
1056
|
+
} else if (type === "object") {
|
|
1057
|
+
if (value === null) {
|
|
1058
|
+
return "other";
|
|
1059
|
+
}
|
|
1060
|
+
return Array.isArray(value) ? "array" : "object";
|
|
1061
|
+
} else {
|
|
1062
|
+
return "other";
|
|
1063
|
+
}
|
|
1064
|
+
}
|
|
1065
|
+
|
|
1066
|
+
// src/components/constant-input/index.tsx
|
|
1067
|
+
import React6, { useMemo as useMemo4 } from "react";
|
|
1068
|
+
import { Input, InputNumber, Select } from "@douyinfe/semi-ui";
|
|
1069
|
+
var defaultStrategies = [
|
|
1070
|
+
{
|
|
1071
|
+
hit: (schema) => schema?.type === "string",
|
|
1072
|
+
Renderer: (props) => /* @__PURE__ */ React6.createElement(Input, { placeholder: "Please Input String", size: "small", disabled: props.readonly, ...props })
|
|
1073
|
+
},
|
|
1074
|
+
{
|
|
1075
|
+
hit: (schema) => schema?.type === "number",
|
|
1076
|
+
Renderer: (props) => /* @__PURE__ */ React6.createElement(
|
|
1077
|
+
InputNumber,
|
|
1078
|
+
{
|
|
1079
|
+
placeholder: "Please Input Number",
|
|
1080
|
+
size: "small",
|
|
1081
|
+
disabled: props.readonly,
|
|
1082
|
+
hideButtons: true,
|
|
1083
|
+
...props
|
|
1084
|
+
}
|
|
1085
|
+
)
|
|
1086
|
+
},
|
|
1087
|
+
{
|
|
1088
|
+
hit: (schema) => schema?.type === "integer",
|
|
1089
|
+
Renderer: (props) => /* @__PURE__ */ React6.createElement(
|
|
1090
|
+
InputNumber,
|
|
1091
|
+
{
|
|
1092
|
+
placeholder: "Please Input Integer",
|
|
1093
|
+
size: "small",
|
|
1094
|
+
disabled: props.readonly,
|
|
1095
|
+
hideButtons: true,
|
|
1096
|
+
precision: 0,
|
|
1097
|
+
...props
|
|
1098
|
+
}
|
|
1099
|
+
)
|
|
1100
|
+
},
|
|
1101
|
+
{
|
|
1102
|
+
hit: (schema) => schema?.type === "boolean",
|
|
1103
|
+
Renderer: (props) => {
|
|
1104
|
+
const { value, onChange, ...rest } = props;
|
|
1105
|
+
return /* @__PURE__ */ React6.createElement(
|
|
1106
|
+
Select,
|
|
1107
|
+
{
|
|
1108
|
+
placeholder: "Please Select Boolean",
|
|
1109
|
+
size: "small",
|
|
1110
|
+
disabled: props.readonly,
|
|
1111
|
+
optionList: [
|
|
1112
|
+
{ label: "True", value: 1 },
|
|
1113
|
+
{ label: "False", value: 0 }
|
|
1114
|
+
],
|
|
1115
|
+
value: value ? 1 : 0,
|
|
1116
|
+
onChange: (value2) => onChange?.(!!value2),
|
|
1117
|
+
...rest
|
|
1118
|
+
}
|
|
1119
|
+
);
|
|
1120
|
+
}
|
|
1121
|
+
}
|
|
1122
|
+
];
|
|
1123
|
+
function ConstantInput(props) {
|
|
1124
|
+
const { value, onChange, schema, strategies: extraStrategies, readonly, ...rest } = props;
|
|
1125
|
+
const strategies = useMemo4(
|
|
1126
|
+
() => [...defaultStrategies, ...extraStrategies || []],
|
|
1127
|
+
[extraStrategies]
|
|
1128
|
+
);
|
|
1129
|
+
const Renderer = useMemo4(() => {
|
|
1130
|
+
const strategy = strategies.find((_strategy) => _strategy.hit(schema));
|
|
1131
|
+
return strategy?.Renderer;
|
|
1132
|
+
}, [strategies, schema]);
|
|
1133
|
+
if (!Renderer) {
|
|
1134
|
+
return /* @__PURE__ */ React6.createElement(Input, { size: "small", disabled: true, placeholder: "Unsupported type" });
|
|
1135
|
+
}
|
|
1136
|
+
return /* @__PURE__ */ React6.createElement(Renderer, { value, onChange, readonly, ...rest });
|
|
1137
|
+
}
|
|
1138
|
+
|
|
1139
|
+
// src/components/json-schema-editor/default-value.tsx
|
|
1140
|
+
function DefaultValue(props) {
|
|
1141
|
+
const { value, schema, type, onChange, placeholder, jsonFormatText } = props;
|
|
1142
|
+
const wrapperRef = useRef2(null);
|
|
1143
|
+
const JsonViewerRef = useRef2(null);
|
|
1144
|
+
const [internalJsonValue, setInternalJsonValue] = useState2(
|
|
1145
|
+
getValueType(value) === "string" ? value : ""
|
|
1146
|
+
);
|
|
1147
|
+
const handleJsonChange = useCallback2((val) => {
|
|
1148
|
+
if (val !== internalJsonValue) {
|
|
1149
|
+
setInternalJsonValue(val);
|
|
1150
|
+
}
|
|
1151
|
+
}, []);
|
|
1152
|
+
const handleEditComplete = useCallback2(() => {
|
|
1153
|
+
onChange(internalJsonValue);
|
|
1154
|
+
requestAnimationFrame(() => {
|
|
1155
|
+
wrapperRef.current?.blur();
|
|
1156
|
+
});
|
|
1157
|
+
setJsonReadOnly(true);
|
|
1158
|
+
}, [internalJsonValue, onChange]);
|
|
1159
|
+
const [jsonReadOnly, setJsonReadOnly] = useState2(true);
|
|
1160
|
+
const handleFormatJson = useCallback2(() => {
|
|
1161
|
+
try {
|
|
1162
|
+
const parsed = JSON.parse(internalJsonValue);
|
|
1163
|
+
const formatted = JSON.stringify(parsed, null, 4);
|
|
1164
|
+
setInternalJsonValue(formatted);
|
|
1165
|
+
onChange(formatted);
|
|
1166
|
+
} catch (error) {
|
|
1167
|
+
console.error("Invalid JSON:", error);
|
|
1168
|
+
}
|
|
1169
|
+
}, [internalJsonValue, onChange]);
|
|
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(
|
|
1171
|
+
IconButton,
|
|
1172
|
+
{
|
|
1173
|
+
icon: /* @__PURE__ */ React7.createElement(IconBrackets, { style: { color: "var(--semi-color-primary)" } }),
|
|
1174
|
+
size: "small",
|
|
1175
|
+
type: "tertiary",
|
|
1176
|
+
theme: "borderless",
|
|
1177
|
+
onClick: handleFormatJson
|
|
1178
|
+
}
|
|
1179
|
+
)))), /* @__PURE__ */ React7.createElement(
|
|
1180
|
+
JSONViewerWrapper,
|
|
1181
|
+
{
|
|
1182
|
+
ref: wrapperRef,
|
|
1183
|
+
tabIndex: -1,
|
|
1184
|
+
onBlur: (e) => {
|
|
1185
|
+
if (wrapperRef.current && !wrapperRef.current?.contains(e.relatedTarget)) {
|
|
1186
|
+
handleEditComplete();
|
|
1187
|
+
}
|
|
1188
|
+
},
|
|
1189
|
+
onClick: (e) => {
|
|
1190
|
+
setJsonReadOnly(false);
|
|
1191
|
+
}
|
|
1192
|
+
},
|
|
1193
|
+
/* @__PURE__ */ React7.createElement(
|
|
1194
|
+
JsonViewer,
|
|
1195
|
+
{
|
|
1196
|
+
ref: JsonViewerRef,
|
|
1197
|
+
value: getValueType(value) === "string" ? value : "",
|
|
1198
|
+
height: 120,
|
|
1199
|
+
width: "100%",
|
|
1200
|
+
showSearch: false,
|
|
1201
|
+
options: {
|
|
1202
|
+
readOnly: jsonReadOnly,
|
|
1203
|
+
formatOptions: { tabSize: 4, insertSpaces: true, eol: "\n" }
|
|
1204
|
+
},
|
|
1205
|
+
style: {
|
|
1206
|
+
padding: 0
|
|
1207
|
+
},
|
|
1208
|
+
onChange: handleJsonChange
|
|
1209
|
+
}
|
|
1210
|
+
)
|
|
1211
|
+
)) : /* @__PURE__ */ React7.createElement(ConstantInputWrapper, null, /* @__PURE__ */ React7.createElement(
|
|
1212
|
+
ConstantInput,
|
|
1213
|
+
{
|
|
1214
|
+
value,
|
|
1215
|
+
onChange: (_v) => onChange(_v),
|
|
1216
|
+
schema: schema || { type: "string" },
|
|
1217
|
+
placeholder: placeholder ?? "Default value if parameter is not provided"
|
|
1218
|
+
}
|
|
1219
|
+
));
|
|
1220
|
+
}
|
|
1221
|
+
|
|
979
1222
|
// src/components/json-schema-editor/components/blur-input.tsx
|
|
980
|
-
import
|
|
981
|
-
import
|
|
1223
|
+
import React8, { useEffect as useEffect2, useState as useState3 } from "react";
|
|
1224
|
+
import Input2 from "@douyinfe/semi-ui/lib/es/input";
|
|
982
1225
|
function BlurInput(props) {
|
|
983
|
-
const [value, setValue] =
|
|
1226
|
+
const [value, setValue] = useState3("");
|
|
984
1227
|
useEffect2(() => {
|
|
985
1228
|
setValue(props.value);
|
|
986
1229
|
}, [props.value]);
|
|
987
|
-
return /* @__PURE__ */
|
|
988
|
-
|
|
1230
|
+
return /* @__PURE__ */ React8.createElement(
|
|
1231
|
+
Input2,
|
|
989
1232
|
{
|
|
990
1233
|
...props,
|
|
991
1234
|
value,
|
|
@@ -1004,12 +1247,13 @@ function JsonSchemaEditor(props) {
|
|
|
1004
1247
|
value,
|
|
1005
1248
|
onChangeProps
|
|
1006
1249
|
);
|
|
1007
|
-
return /* @__PURE__ */
|
|
1250
|
+
return /* @__PURE__ */ React9.createElement(UIContainer, null, /* @__PURE__ */ React9.createElement(UIProperties, null, propertyList.map((_property, index) => /* @__PURE__ */ React9.createElement(
|
|
1008
1251
|
PropertyEdit,
|
|
1009
1252
|
{
|
|
1010
1253
|
key: _property.key,
|
|
1011
1254
|
value: _property,
|
|
1012
1255
|
config,
|
|
1256
|
+
$index: index,
|
|
1013
1257
|
onChange: (_v) => {
|
|
1014
1258
|
onEditProperty(_property.key, _v);
|
|
1015
1259
|
},
|
|
@@ -1017,14 +1261,26 @@ function JsonSchemaEditor(props) {
|
|
|
1017
1261
|
onRemoveProperty(_property.key);
|
|
1018
1262
|
}
|
|
1019
1263
|
}
|
|
1020
|
-
))), /* @__PURE__ */
|
|
1264
|
+
))), /* @__PURE__ */ React9.createElement(Button2, { size: "small", style: { marginTop: 10 }, icon: /* @__PURE__ */ React9.createElement(IconPlus, null), onClick: onAddProperty }, config?.addButtonText ?? "Add"));
|
|
1021
1265
|
}
|
|
1022
1266
|
function PropertyEdit(props) {
|
|
1023
|
-
const {
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1267
|
+
const {
|
|
1268
|
+
value,
|
|
1269
|
+
config,
|
|
1270
|
+
$level = 0,
|
|
1271
|
+
onChange: onChangeProps,
|
|
1272
|
+
onRemove,
|
|
1273
|
+
$index,
|
|
1274
|
+
$isFirst,
|
|
1275
|
+
$isLast,
|
|
1276
|
+
$parentExpand = false,
|
|
1277
|
+
$parentType = "",
|
|
1278
|
+
$showLine
|
|
1279
|
+
} = props;
|
|
1280
|
+
const [expand, setExpand] = useState4(false);
|
|
1281
|
+
const [collapse, setCollapse] = useState4(false);
|
|
1282
|
+
const { name, type, items, default: defaultValue, description, isPropertyRequired } = value || {};
|
|
1283
|
+
const typeSelectorValue = useMemo5(() => ({ type, items }), [type, items]);
|
|
1028
1284
|
const { propertyList, isDrilldownObject, onAddProperty, onRemoveProperty, onEditProperty } = usePropertiesEdit(value, onChangeProps);
|
|
1029
1285
|
const onChange = (key, _value) => {
|
|
1030
1286
|
onChangeProps?.({
|
|
@@ -1033,72 +1289,110 @@ function PropertyEdit(props) {
|
|
|
1033
1289
|
});
|
|
1034
1290
|
};
|
|
1035
1291
|
const showCollapse = isDrilldownObject && propertyList.length > 0;
|
|
1036
|
-
return /* @__PURE__ */
|
|
1037
|
-
|
|
1292
|
+
return /* @__PURE__ */ React9.createElement(React9.Fragment, null, /* @__PURE__ */ React9.createElement(
|
|
1293
|
+
UIPropertyLeft,
|
|
1038
1294
|
{
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1295
|
+
type,
|
|
1296
|
+
$index,
|
|
1297
|
+
$isFirst,
|
|
1298
|
+
$isLast,
|
|
1299
|
+
$showLine,
|
|
1300
|
+
$isExpand: expand,
|
|
1301
|
+
$parentExpand,
|
|
1302
|
+
$parentType
|
|
1303
|
+
},
|
|
1304
|
+
showCollapse && /* @__PURE__ */ React9.createElement(UICollapseTrigger, { onClick: () => setCollapse((_collapse) => !_collapse) }, collapse ? /* @__PURE__ */ React9.createElement(IconChevronDown, { size: "small" }) : /* @__PURE__ */ React9.createElement(IconChevronRight, { size: "small" }))
|
|
1305
|
+
), /* @__PURE__ */ React9.createElement(UIPropertyRight, null, /* @__PURE__ */ React9.createElement(
|
|
1306
|
+
UIPropertyMain,
|
|
1046
1307
|
{
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1308
|
+
$showCollapse: showCollapse,
|
|
1309
|
+
$collapse: collapse,
|
|
1310
|
+
$expand: expand,
|
|
1311
|
+
type
|
|
1312
|
+
},
|
|
1313
|
+
/* @__PURE__ */ React9.createElement(UIRow, null, /* @__PURE__ */ React9.createElement(UIName, null, /* @__PURE__ */ React9.createElement(
|
|
1314
|
+
BlurInput,
|
|
1315
|
+
{
|
|
1316
|
+
placeholder: config?.placeholder ?? "Input Variable Name",
|
|
1317
|
+
size: "small",
|
|
1318
|
+
value: name,
|
|
1319
|
+
onChange: (value2) => onChange("name", value2)
|
|
1053
1320
|
}
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
size: "small",
|
|
1065
|
-
theme: "borderless",
|
|
1066
|
-
icon: expand ? /* @__PURE__ */ React7.createElement(IconShrink, { size: "small" }) : /* @__PURE__ */ React7.createElement(IconExpand, { size: "small" }),
|
|
1067
|
-
onClick: () => setExpand((_expand) => !_expand)
|
|
1068
|
-
}
|
|
1069
|
-
), isDrilldownObject && /* @__PURE__ */ React7.createElement(
|
|
1070
|
-
IconButton,
|
|
1071
|
-
{
|
|
1072
|
-
size: "small",
|
|
1073
|
-
theme: "borderless",
|
|
1074
|
-
icon: /* @__PURE__ */ React7.createElement(IconAddChildren, null),
|
|
1075
|
-
onClick: () => {
|
|
1076
|
-
onAddProperty();
|
|
1077
|
-
setCollapse(true);
|
|
1321
|
+
)), /* @__PURE__ */ React9.createElement(UIType, null, /* @__PURE__ */ React9.createElement(
|
|
1322
|
+
TypeSelector,
|
|
1323
|
+
{
|
|
1324
|
+
value: typeSelectorValue,
|
|
1325
|
+
onChange: (_value) => {
|
|
1326
|
+
onChangeProps?.({
|
|
1327
|
+
...value || {},
|
|
1328
|
+
..._value
|
|
1329
|
+
});
|
|
1330
|
+
}
|
|
1078
1331
|
}
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1332
|
+
)), /* @__PURE__ */ React9.createElement(UIRequired, null, /* @__PURE__ */ React9.createElement(
|
|
1333
|
+
Checkbox,
|
|
1334
|
+
{
|
|
1335
|
+
checked: isPropertyRequired,
|
|
1336
|
+
onChange: (e) => onChange("isPropertyRequired", e.target.checked)
|
|
1337
|
+
}
|
|
1338
|
+
)), /* @__PURE__ */ React9.createElement(UIActions, null, /* @__PURE__ */ React9.createElement(
|
|
1339
|
+
IconButton2,
|
|
1340
|
+
{
|
|
1341
|
+
size: "small",
|
|
1342
|
+
theme: "borderless",
|
|
1343
|
+
icon: expand ? /* @__PURE__ */ React9.createElement(IconShrink, { size: "small" }) : /* @__PURE__ */ React9.createElement(IconExpand, { size: "small" }),
|
|
1344
|
+
onClick: () => {
|
|
1345
|
+
setExpand((_expand) => !_expand);
|
|
1346
|
+
}
|
|
1347
|
+
}
|
|
1348
|
+
), isDrilldownObject && /* @__PURE__ */ React9.createElement(
|
|
1349
|
+
IconButton2,
|
|
1350
|
+
{
|
|
1351
|
+
size: "small",
|
|
1352
|
+
theme: "borderless",
|
|
1353
|
+
icon: /* @__PURE__ */ React9.createElement(IconAddChildren, null),
|
|
1354
|
+
onClick: () => {
|
|
1355
|
+
onAddProperty();
|
|
1356
|
+
setCollapse(true);
|
|
1357
|
+
}
|
|
1358
|
+
}
|
|
1359
|
+
), /* @__PURE__ */ React9.createElement(
|
|
1360
|
+
IconButton2,
|
|
1361
|
+
{
|
|
1362
|
+
size: "small",
|
|
1363
|
+
theme: "borderless",
|
|
1364
|
+
icon: /* @__PURE__ */ React9.createElement(IconMinus, { size: "small" }),
|
|
1365
|
+
onClick: onRemove
|
|
1366
|
+
}
|
|
1367
|
+
))),
|
|
1368
|
+
expand && /* @__PURE__ */ React9.createElement(UIExpandDetail, null, /* @__PURE__ */ React9.createElement(UILabel, null, config?.descTitle ?? "Description"), /* @__PURE__ */ React9.createElement(
|
|
1369
|
+
BlurInput,
|
|
1370
|
+
{
|
|
1371
|
+
size: "small",
|
|
1372
|
+
value: description,
|
|
1373
|
+
onChange: (value2) => onChange("description", value2),
|
|
1374
|
+
placeholder: config?.descPlaceholder ?? "Help LLM to understand the property"
|
|
1375
|
+
}
|
|
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(
|
|
1377
|
+
DefaultValue,
|
|
1378
|
+
{
|
|
1379
|
+
value: defaultValue,
|
|
1380
|
+
schema: value,
|
|
1381
|
+
type,
|
|
1382
|
+
placeholder: config?.defaultValuePlaceholder,
|
|
1383
|
+
jsonFormatText: config?.jsonFormatText,
|
|
1384
|
+
onChange: (value2) => onChange("default", value2)
|
|
1385
|
+
}
|
|
1386
|
+
))))
|
|
1387
|
+
), showCollapse && /* @__PURE__ */ React9.createElement(UICollapsible, { $collapse: collapse }, /* @__PURE__ */ React9.createElement(UIProperties, { $shrink: true }, propertyList.map((_property, index) => /* @__PURE__ */ React9.createElement(
|
|
1097
1388
|
PropertyEdit,
|
|
1098
1389
|
{
|
|
1099
1390
|
key: _property.key,
|
|
1100
1391
|
value: _property,
|
|
1101
1392
|
config,
|
|
1393
|
+
$level: $level + 1,
|
|
1394
|
+
$parentExpand: expand,
|
|
1395
|
+
$parentType: type,
|
|
1102
1396
|
onChange: (_v) => {
|
|
1103
1397
|
onEditProperty(_property.key, _v);
|
|
1104
1398
|
},
|
|
@@ -1106,98 +1400,27 @@ function PropertyEdit(props) {
|
|
|
1106
1400
|
onRemoveProperty(_property.key);
|
|
1107
1401
|
},
|
|
1108
1402
|
$isLast: index === propertyList.length - 1,
|
|
1403
|
+
$isFirst: index === 0,
|
|
1404
|
+
$index: index,
|
|
1109
1405
|
$showLine: true
|
|
1110
1406
|
}
|
|
1111
1407
|
))))));
|
|
1112
1408
|
}
|
|
1113
1409
|
|
|
1114
1410
|
// src/components/batch-variable-selector/index.tsx
|
|
1115
|
-
import
|
|
1411
|
+
import React10 from "react";
|
|
1116
1412
|
import { PrivateScopeProvider } from "@flowgram.ai/editor";
|
|
1117
1413
|
var batchVariableSchema = {
|
|
1118
1414
|
type: "array",
|
|
1119
1415
|
extra: { weak: true }
|
|
1120
1416
|
};
|
|
1121
1417
|
function BatchVariableSelector(props) {
|
|
1122
|
-
return /* @__PURE__ */
|
|
1123
|
-
}
|
|
1124
|
-
|
|
1125
|
-
// src/components/constant-input/index.tsx
|
|
1126
|
-
import React9, { useMemo as useMemo5 } from "react";
|
|
1127
|
-
import { Input as Input2, InputNumber, Select } from "@douyinfe/semi-ui";
|
|
1128
|
-
var defaultStrategies = [
|
|
1129
|
-
{
|
|
1130
|
-
hit: (schema) => schema?.type === "string",
|
|
1131
|
-
Renderer: (props) => /* @__PURE__ */ React9.createElement(Input2, { placeholder: "Please Input String", size: "small", disabled: props.readonly, ...props })
|
|
1132
|
-
},
|
|
1133
|
-
{
|
|
1134
|
-
hit: (schema) => schema?.type === "number",
|
|
1135
|
-
Renderer: (props) => /* @__PURE__ */ React9.createElement(
|
|
1136
|
-
InputNumber,
|
|
1137
|
-
{
|
|
1138
|
-
placeholder: "Please Input Number",
|
|
1139
|
-
size: "small",
|
|
1140
|
-
disabled: props.readonly,
|
|
1141
|
-
hideButtons: true,
|
|
1142
|
-
...props
|
|
1143
|
-
}
|
|
1144
|
-
)
|
|
1145
|
-
},
|
|
1146
|
-
{
|
|
1147
|
-
hit: (schema) => schema?.type === "integer",
|
|
1148
|
-
Renderer: (props) => /* @__PURE__ */ React9.createElement(
|
|
1149
|
-
InputNumber,
|
|
1150
|
-
{
|
|
1151
|
-
placeholder: "Please Input Integer",
|
|
1152
|
-
size: "small",
|
|
1153
|
-
disabled: props.readonly,
|
|
1154
|
-
hideButtons: true,
|
|
1155
|
-
precision: 0,
|
|
1156
|
-
...props
|
|
1157
|
-
}
|
|
1158
|
-
)
|
|
1159
|
-
},
|
|
1160
|
-
{
|
|
1161
|
-
hit: (schema) => schema?.type === "boolean",
|
|
1162
|
-
Renderer: (props) => {
|
|
1163
|
-
const { value, onChange, ...rest } = props;
|
|
1164
|
-
return /* @__PURE__ */ React9.createElement(
|
|
1165
|
-
Select,
|
|
1166
|
-
{
|
|
1167
|
-
placeholder: "Please Select Boolean",
|
|
1168
|
-
size: "small",
|
|
1169
|
-
disabled: props.readonly,
|
|
1170
|
-
optionList: [
|
|
1171
|
-
{ label: "True", value: 1 },
|
|
1172
|
-
{ label: "False", value: 0 }
|
|
1173
|
-
],
|
|
1174
|
-
value: value ? 1 : 0,
|
|
1175
|
-
onChange: (value2) => onChange?.(!!value2),
|
|
1176
|
-
...rest
|
|
1177
|
-
}
|
|
1178
|
-
);
|
|
1179
|
-
}
|
|
1180
|
-
}
|
|
1181
|
-
];
|
|
1182
|
-
function ConstantInput(props) {
|
|
1183
|
-
const { value, onChange, schema, strategies: extraStrategies, readonly, ...rest } = props;
|
|
1184
|
-
const strategies = useMemo5(
|
|
1185
|
-
() => [...defaultStrategies, ...extraStrategies || []],
|
|
1186
|
-
[extraStrategies]
|
|
1187
|
-
);
|
|
1188
|
-
const Renderer = useMemo5(() => {
|
|
1189
|
-
const strategy = strategies.find((_strategy) => _strategy.hit(schema));
|
|
1190
|
-
return strategy?.Renderer;
|
|
1191
|
-
}, [strategies, schema]);
|
|
1192
|
-
if (!Renderer) {
|
|
1193
|
-
return /* @__PURE__ */ React9.createElement(Input2, { size: "small", disabled: true, placeholder: "Unsupported type" });
|
|
1194
|
-
}
|
|
1195
|
-
return /* @__PURE__ */ React9.createElement(Renderer, { value, onChange, readonly, ...rest });
|
|
1418
|
+
return /* @__PURE__ */ React10.createElement(PrivateScopeProvider, null, /* @__PURE__ */ React10.createElement(VariableSelector, { ...props, includeSchema: batchVariableSchema }));
|
|
1196
1419
|
}
|
|
1197
1420
|
|
|
1198
1421
|
// src/components/dynamic-value-input/index.tsx
|
|
1199
|
-
import
|
|
1200
|
-
import { IconButton as
|
|
1422
|
+
import React11, { useMemo as useMemo6 } from "react";
|
|
1423
|
+
import { IconButton as IconButton3 } from "@douyinfe/semi-ui";
|
|
1201
1424
|
import { IconSetting } from "@douyinfe/semi-icons";
|
|
1202
1425
|
|
|
1203
1426
|
// src/components/dynamic-value-input/styles.tsx
|
|
@@ -1235,7 +1458,7 @@ function DynamicValueInput({
|
|
|
1235
1458
|
}, [schema]);
|
|
1236
1459
|
const renderMain = () => {
|
|
1237
1460
|
if (value?.type === "ref") {
|
|
1238
|
-
return /* @__PURE__ */
|
|
1461
|
+
return /* @__PURE__ */ React11.createElement(
|
|
1239
1462
|
VariableSelector,
|
|
1240
1463
|
{
|
|
1241
1464
|
value: value?.content,
|
|
@@ -1245,7 +1468,7 @@ function DynamicValueInput({
|
|
|
1245
1468
|
}
|
|
1246
1469
|
);
|
|
1247
1470
|
}
|
|
1248
|
-
return /* @__PURE__ */
|
|
1471
|
+
return /* @__PURE__ */ React11.createElement(
|
|
1249
1472
|
ConstantInput,
|
|
1250
1473
|
{
|
|
1251
1474
|
value: value?.content,
|
|
@@ -1256,7 +1479,7 @@ function DynamicValueInput({
|
|
|
1256
1479
|
}
|
|
1257
1480
|
);
|
|
1258
1481
|
};
|
|
1259
|
-
const renderTrigger = () => /* @__PURE__ */
|
|
1482
|
+
const renderTrigger = () => /* @__PURE__ */ React11.createElement(
|
|
1260
1483
|
VariableSelector,
|
|
1261
1484
|
{
|
|
1262
1485
|
style: { width: "100%" },
|
|
@@ -1264,14 +1487,14 @@ function DynamicValueInput({
|
|
|
1264
1487
|
onChange: (_v) => onChange({ type: "ref", content: _v }),
|
|
1265
1488
|
includeSchema,
|
|
1266
1489
|
readonly,
|
|
1267
|
-
triggerRender: () => /* @__PURE__ */
|
|
1490
|
+
triggerRender: () => /* @__PURE__ */ React11.createElement(IconButton3, { disabled: readonly, size: "small", icon: /* @__PURE__ */ React11.createElement(IconSetting, { size: "small" }) })
|
|
1268
1491
|
}
|
|
1269
1492
|
);
|
|
1270
|
-
return /* @__PURE__ */
|
|
1493
|
+
return /* @__PURE__ */ React11.createElement(UIContainer2, { style }, /* @__PURE__ */ React11.createElement(UIMain, null, renderMain()), /* @__PURE__ */ React11.createElement(UITrigger, null, renderTrigger()));
|
|
1271
1494
|
}
|
|
1272
1495
|
|
|
1273
1496
|
// src/components/condition-row/index.tsx
|
|
1274
|
-
import
|
|
1497
|
+
import React13, { useMemo as useMemo9 } from "react";
|
|
1275
1498
|
import { Input as Input3 } from "@douyinfe/semi-ui";
|
|
1276
1499
|
|
|
1277
1500
|
// src/components/condition-row/styles.tsx
|
|
@@ -1500,7 +1723,7 @@ function useRule(left) {
|
|
|
1500
1723
|
}
|
|
1501
1724
|
|
|
1502
1725
|
// src/components/condition-row/hooks/useOp.tsx
|
|
1503
|
-
import
|
|
1726
|
+
import React12, { useMemo as useMemo8 } from "react";
|
|
1504
1727
|
import { Button as Button3, Select as Select2 } from "@douyinfe/semi-ui";
|
|
1505
1728
|
import { IconChevronDownStroked as IconChevronDownStroked2 } from "@douyinfe/semi-icons";
|
|
1506
1729
|
function useOp({ rule, op, onChange }) {
|
|
@@ -1512,7 +1735,7 @@ function useOp({ rule, op, onChange }) {
|
|
|
1512
1735
|
[rule]
|
|
1513
1736
|
);
|
|
1514
1737
|
const opConfig = useMemo8(() => opConfigs[op], [op]);
|
|
1515
|
-
const renderOpSelect = () => /* @__PURE__ */
|
|
1738
|
+
const renderOpSelect = () => /* @__PURE__ */ React12.createElement(
|
|
1516
1739
|
Select2,
|
|
1517
1740
|
{
|
|
1518
1741
|
style: { height: 22 },
|
|
@@ -1522,7 +1745,7 @@ function useOp({ rule, op, onChange }) {
|
|
|
1522
1745
|
onChange: (v) => {
|
|
1523
1746
|
onChange(v);
|
|
1524
1747
|
},
|
|
1525
|
-
triggerRender: ({ value }) => /* @__PURE__ */
|
|
1748
|
+
triggerRender: ({ value }) => /* @__PURE__ */ React12.createElement(Button3, { size: "small", disabled: !rule }, opConfig?.abbreviation || /* @__PURE__ */ React12.createElement(IconChevronDownStroked2, { size: "small" }))
|
|
1526
1749
|
}
|
|
1527
1750
|
);
|
|
1528
1751
|
return { renderOpSelect, opConfig };
|
|
@@ -1541,7 +1764,7 @@ function ConditionRow({ style, value, onChange, readonly }) {
|
|
|
1541
1764
|
const targetType = rule?.[operator] || null;
|
|
1542
1765
|
return targetType ? { type: targetType, extra: { weak: true } } : null;
|
|
1543
1766
|
}, [rule, opConfig]);
|
|
1544
|
-
return /* @__PURE__ */
|
|
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(
|
|
1545
1768
|
VariableSelector,
|
|
1546
1769
|
{
|
|
1547
1770
|
readonly,
|
|
@@ -1555,7 +1778,7 @@ function ConditionRow({ style, value, onChange, readonly }) {
|
|
|
1555
1778
|
}
|
|
1556
1779
|
})
|
|
1557
1780
|
}
|
|
1558
|
-
)), /* @__PURE__ */
|
|
1781
|
+
)), /* @__PURE__ */ React13.createElement(UIRight, null, targetSchema ? /* @__PURE__ */ React13.createElement(
|
|
1559
1782
|
DynamicValueInput,
|
|
1560
1783
|
{
|
|
1561
1784
|
readonly: readonly || !rule,
|
|
@@ -1563,7 +1786,7 @@ function ConditionRow({ style, value, onChange, readonly }) {
|
|
|
1563
1786
|
schema: targetSchema,
|
|
1564
1787
|
onChange: (v) => onChange({ ...value, right: v })
|
|
1565
1788
|
}
|
|
1566
|
-
) : /* @__PURE__ */
|
|
1789
|
+
) : /* @__PURE__ */ React13.createElement(Input3, { size: "small", disabled: true, value: opConfig?.rightDisplay || "Empty" }))));
|
|
1567
1790
|
}
|
|
1568
1791
|
|
|
1569
1792
|
// src/effects/provide-batch-input/index.ts
|