@flowgram.ai/form-materials 0.2.4 → 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/index.js CHANGED
@@ -56,17 +56,17 @@ __export(src_exports, {
56
56
  module.exports = __toCommonJS(src_exports);
57
57
 
58
58
  // src/components/variable-selector/index.tsx
59
- var import_react3 = __toESM(require("react"), 1);
59
+ var import_react3 = __toESM(require("react"));
60
60
  var import_semi_icons2 = require("@douyinfe/semi-icons");
61
61
 
62
62
  // src/components/variable-selector/use-variable-tree.tsx
63
- var import_react2 = __toESM(require("react"), 1);
63
+ var import_react2 = __toESM(require("react"));
64
64
  var import_editor2 = require("@flowgram.ai/editor");
65
65
  var import_semi_ui = require("@douyinfe/semi-ui");
66
66
 
67
67
  // src/components/type-selector/constants.tsx
68
- var import_react = __toESM(require("react"), 1);
69
- var import_semi_icons = __toESM(require("@douyinfe/semi-icons"), 1);
68
+ var import_react = __toESM(require("react"));
69
+ var import_semi_icons = __toESM(require("@douyinfe/semi-icons"));
70
70
  var VariableTypeIcons = {
71
71
  custom: /* @__PURE__ */ import_react.default.createElement(
72
72
  "svg",
@@ -627,7 +627,7 @@ function useVariableTree(params) {
627
627
  }
628
628
 
629
629
  // src/components/variable-selector/styles.tsx
630
- var import_styled_components = __toESM(require("styled-components"), 1);
630
+ var import_styled_components = __toESM(require("styled-components"));
631
631
  var import_semi_ui2 = require("@douyinfe/semi-ui");
632
632
  var UIRootTitle = import_styled_components.default.span`
633
633
  margin-right: 4px;
@@ -671,7 +671,7 @@ var UITreeSelect = (0, import_styled_components.default)(import_semi_ui2.TreeSel
671
671
  // src/components/variable-selector/index.tsx
672
672
  var VariableSelector = ({
673
673
  value,
674
- config,
674
+ config = {},
675
675
  onChange,
676
676
  style,
677
677
  readonly = false,
@@ -745,7 +745,7 @@ var VariableSelector = ({
745
745
  };
746
746
 
747
747
  // src/components/type-selector/index.tsx
748
- var import_react4 = __toESM(require("react"), 1);
748
+ var import_react4 = __toESM(require("react"));
749
749
  var import_semi_ui3 = require("@douyinfe/semi-ui");
750
750
  var getTypeSelectValue = (value) => {
751
751
  if (value?.type === "array" && value?.items) {
@@ -780,14 +780,14 @@ function TypeSelector(props) {
780
780
  }
781
781
 
782
782
  // src/components/json-schema-editor/index.tsx
783
- var import_react8 = __toESM(require("react"), 1);
784
- var import_semi_ui4 = require("@douyinfe/semi-ui");
785
- var import_semi_icons4 = require("@douyinfe/semi-icons");
783
+ var import_react10 = __toESM(require("react"));
784
+ var import_semi_ui6 = require("@douyinfe/semi-ui");
785
+ var import_semi_icons5 = require("@douyinfe/semi-icons");
786
786
 
787
787
  // src/components/json-schema-editor/styles.tsx
788
- var import_react5 = __toESM(require("react"), 1);
789
- var import_styled_components2 = __toESM(require("styled-components"), 1);
790
- var import_semi_icons3 = __toESM(require("@douyinfe/semi-icons"), 1);
788
+ var import_react5 = __toESM(require("react"));
789
+ var import_styled_components2 = __toESM(require("styled-components"));
790
+ var import_semi_icons3 = __toESM(require("@douyinfe/semi-icons"));
791
791
  var UIContainer = import_styled_components2.default.div`
792
792
  /* & .semi-input {
793
793
  background-color: #fff;
@@ -826,32 +826,39 @@ var UIProperties = import_styled_components2.default.div`
826
826
  var UIPropertyLeft = import_styled_components2.default.div`
827
827
  grid-column: 1;
828
828
  position: relative;
829
+ width: 16px;
829
830
 
830
- ${({ $showLine, $isLast }) => $showLine && import_styled_components2.css`
831
- &::before {
832
- /* 竖线 */
833
- content: '';
834
- position: absolute;
835
- left: -22px;
836
- top: -18px;
837
- bottom: ${$isLast ? "12px" : "0px"};
838
- width: 1px;
839
- background: #d9d9d9;
840
- display: block;
841
- }
831
+ ${({ $showLine, $isLast, $parentType }) => {
832
+ let height = "100%";
833
+ if ($parentType && $isLast) {
834
+ height = "24px";
835
+ }
836
+ return $showLine && import_styled_components2.css`
837
+ &::before {
838
+ /* 竖线 */
839
+ content: '';
840
+ height: ${height};
841
+ position: absolute;
842
+ left: -22px;
843
+ top: -16px;
844
+ width: 1px;
845
+ background: #d9d9d9;
846
+ display: block;
847
+ }
842
848
 
843
- &::after {
844
- /* 横线 */
845
- content: '';
846
- position: absolute;
847
- left: -22px; // 横线起点和竖线对齐
848
- top: 12px; // 跟随你的行高调整
849
- width: 22px; // 横线长度
850
- height: 1px;
851
- background: #d9d9d9;
852
- display: block;
853
- }
854
- `}
849
+ &::after {
850
+ /* 横线 */
851
+ content: '';
852
+ position: absolute;
853
+ left: -22px; // 横线起点和竖线对齐
854
+ top: 8px; // 跟随你的行高调整
855
+ width: 18px; // 横线长度
856
+ height: 1px;
857
+ background: #d9d9d9;
858
+ display: block;
859
+ }
860
+ `;
861
+ }}
855
862
  `;
856
863
  var UIPropertyRight = import_styled_components2.default.div`
857
864
  grid-column: 2;
@@ -865,12 +872,31 @@ var UIPropertyMain = import_styled_components2.default.div`
865
872
  display: flex;
866
873
  flex-direction: column;
867
874
  gap: 10px;
875
+ position: relative;
868
876
 
869
- ${({ $expand }) => $expand && import_styled_components2.css`
870
- background-color: #f5f5f5;
871
- padding: 10px;
872
- border-radius: 4px;
873
- `}
877
+ ${({ $expand, type, $collapse, $showCollapse }) => {
878
+ const beforeElement = `
879
+ &::before {
880
+ /* \u7AD6\u7EBF */
881
+ content: '';
882
+ height: 100%;
883
+ position: absolute;
884
+ left: -12px;
885
+ top: 18px;
886
+ width: 1px;
887
+ background: #d9d9d9;
888
+ display: block;
889
+ }`;
890
+ return $expand && import_styled_components2.css`
891
+ background-color: #f5f5f5;
892
+ padding: 10px;
893
+ border-radius: 4px;
894
+
895
+ ${$showCollapse && $collapse && (type === "array" || type === "object") && import_styled_components2.css`
896
+ ${beforeElement}
897
+ `}
898
+ `;
899
+ }}
874
900
  `;
875
901
  var UICollapsible = import_styled_components2.default.div`
876
902
  display: none;
@@ -908,6 +934,43 @@ var iconAddChildrenSvg = /* @__PURE__ */ import_react5.default.createElement(
908
934
  /* @__PURE__ */ import_react5.default.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" })
909
935
  );
910
936
  var IconAddChildren = () => /* @__PURE__ */ import_react5.default.createElement(import_semi_icons3.default, { size: "small", svg: iconAddChildrenSvg });
937
+ var DefaultValueWrapper = import_styled_components2.default.div`
938
+ margin: 0;
939
+ `;
940
+ var JSONViewerWrapper = import_styled_components2.default.div`
941
+ padding: 0 0 24px;
942
+ &:first-child {
943
+ margin-top: 0px;
944
+ }
945
+ `;
946
+ var JSONHeader = import_styled_components2.default.div`
947
+ display: flex;
948
+ justify-content: space-between;
949
+ align-items: center;
950
+ background-color: var(--semi-color-fill-0);
951
+ border-radius: 6px 6px 0 0;
952
+ height: 36px;
953
+ padding: 0 8px 0 12px;
954
+ `;
955
+ var JSONHeaderLeft = import_styled_components2.default.div`
956
+ display: flex;
957
+ align-items: center;
958
+ gap: 10px;
959
+ `;
960
+ var JSONHeaderRight = import_styled_components2.default.div`
961
+ display: flex;
962
+ align-items: center;
963
+ gap: 10px;
964
+ `;
965
+ var ConstantInputWrapper = import_styled_components2.default.div`
966
+ flex-grow: 1;
967
+
968
+ & .semi-tree-select,
969
+ & .semi-input-number,
970
+ & .semi-select {
971
+ width: 100%;
972
+ }
973
+ `;
911
974
 
912
975
  // src/components/json-schema-editor/hooks.tsx
913
976
  var import_react6 = require("react");
@@ -1026,15 +1089,195 @@ function usePropertiesEdit(value, onChange) {
1026
1089
  };
1027
1090
  }
1028
1091
 
1092
+ // src/components/json-schema-editor/default-value.tsx
1093
+ var import_react8 = __toESM(require("react"));
1094
+ var import_semi_ui5 = require("@douyinfe/semi-ui");
1095
+ var import_semi_icons4 = require("@douyinfe/semi-icons");
1096
+
1097
+ // src/components/json-schema-editor/utils.ts
1098
+ function getValueType(value) {
1099
+ const type = typeof value;
1100
+ if (type === "string") {
1101
+ return "string";
1102
+ } else if (type === "number") {
1103
+ return Number.isInteger(value) ? "integer" : "number";
1104
+ } else if (type === "boolean") {
1105
+ return "boolean";
1106
+ } else if (type === "object") {
1107
+ if (value === null) {
1108
+ return "other";
1109
+ }
1110
+ return Array.isArray(value) ? "array" : "object";
1111
+ } else {
1112
+ return "other";
1113
+ }
1114
+ }
1115
+
1116
+ // src/components/constant-input/index.tsx
1117
+ var import_react7 = __toESM(require("react"));
1118
+ var import_semi_ui4 = require("@douyinfe/semi-ui");
1119
+ var defaultStrategies = [
1120
+ {
1121
+ hit: (schema) => schema?.type === "string",
1122
+ Renderer: (props) => /* @__PURE__ */ import_react7.default.createElement(import_semi_ui4.Input, { placeholder: "Please Input String", size: "small", disabled: props.readonly, ...props })
1123
+ },
1124
+ {
1125
+ hit: (schema) => schema?.type === "number",
1126
+ Renderer: (props) => /* @__PURE__ */ import_react7.default.createElement(
1127
+ import_semi_ui4.InputNumber,
1128
+ {
1129
+ placeholder: "Please Input Number",
1130
+ size: "small",
1131
+ disabled: props.readonly,
1132
+ hideButtons: true,
1133
+ ...props
1134
+ }
1135
+ )
1136
+ },
1137
+ {
1138
+ hit: (schema) => schema?.type === "integer",
1139
+ Renderer: (props) => /* @__PURE__ */ import_react7.default.createElement(
1140
+ import_semi_ui4.InputNumber,
1141
+ {
1142
+ placeholder: "Please Input Integer",
1143
+ size: "small",
1144
+ disabled: props.readonly,
1145
+ hideButtons: true,
1146
+ precision: 0,
1147
+ ...props
1148
+ }
1149
+ )
1150
+ },
1151
+ {
1152
+ hit: (schema) => schema?.type === "boolean",
1153
+ Renderer: (props) => {
1154
+ const { value, onChange, ...rest } = props;
1155
+ return /* @__PURE__ */ import_react7.default.createElement(
1156
+ import_semi_ui4.Select,
1157
+ {
1158
+ placeholder: "Please Select Boolean",
1159
+ size: "small",
1160
+ disabled: props.readonly,
1161
+ optionList: [
1162
+ { label: "True", value: 1 },
1163
+ { label: "False", value: 0 }
1164
+ ],
1165
+ value: value ? 1 : 0,
1166
+ onChange: (value2) => onChange?.(!!value2),
1167
+ ...rest
1168
+ }
1169
+ );
1170
+ }
1171
+ }
1172
+ ];
1173
+ function ConstantInput(props) {
1174
+ const { value, onChange, schema, strategies: extraStrategies, readonly, ...rest } = props;
1175
+ const strategies = (0, import_react7.useMemo)(
1176
+ () => [...defaultStrategies, ...extraStrategies || []],
1177
+ [extraStrategies]
1178
+ );
1179
+ const Renderer = (0, import_react7.useMemo)(() => {
1180
+ const strategy = strategies.find((_strategy) => _strategy.hit(schema));
1181
+ return strategy?.Renderer;
1182
+ }, [strategies, schema]);
1183
+ if (!Renderer) {
1184
+ return /* @__PURE__ */ import_react7.default.createElement(import_semi_ui4.Input, { size: "small", disabled: true, placeholder: "Unsupported type" });
1185
+ }
1186
+ return /* @__PURE__ */ import_react7.default.createElement(Renderer, { value, onChange, readonly, ...rest });
1187
+ }
1188
+
1189
+ // src/components/json-schema-editor/default-value.tsx
1190
+ function DefaultValue(props) {
1191
+ const { value, schema, type, onChange, placeholder, jsonFormatText } = props;
1192
+ const wrapperRef = (0, import_react8.useRef)(null);
1193
+ const JsonViewerRef = (0, import_react8.useRef)(null);
1194
+ const [internalJsonValue, setInternalJsonValue] = (0, import_react8.useState)(
1195
+ getValueType(value) === "string" ? value : ""
1196
+ );
1197
+ const handleJsonChange = (0, import_react8.useCallback)((val) => {
1198
+ if (val !== internalJsonValue) {
1199
+ setInternalJsonValue(val);
1200
+ }
1201
+ }, []);
1202
+ const handleEditComplete = (0, import_react8.useCallback)(() => {
1203
+ onChange(internalJsonValue);
1204
+ requestAnimationFrame(() => {
1205
+ wrapperRef.current?.blur();
1206
+ });
1207
+ setJsonReadOnly(true);
1208
+ }, [internalJsonValue, onChange]);
1209
+ const [jsonReadOnly, setJsonReadOnly] = (0, import_react8.useState)(true);
1210
+ const handleFormatJson = (0, import_react8.useCallback)(() => {
1211
+ try {
1212
+ const parsed = JSON.parse(internalJsonValue);
1213
+ const formatted = JSON.stringify(parsed, null, 4);
1214
+ setInternalJsonValue(formatted);
1215
+ onChange(formatted);
1216
+ } catch (error) {
1217
+ console.error("Invalid JSON:", error);
1218
+ }
1219
+ }, [internalJsonValue, onChange]);
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(
1221
+ import_semi_ui5.IconButton,
1222
+ {
1223
+ icon: /* @__PURE__ */ import_react8.default.createElement(import_semi_icons4.IconBrackets, { style: { color: "var(--semi-color-primary)" } }),
1224
+ size: "small",
1225
+ type: "tertiary",
1226
+ theme: "borderless",
1227
+ onClick: handleFormatJson
1228
+ }
1229
+ )))), /* @__PURE__ */ import_react8.default.createElement(
1230
+ JSONViewerWrapper,
1231
+ {
1232
+ ref: wrapperRef,
1233
+ tabIndex: -1,
1234
+ onBlur: (e) => {
1235
+ if (wrapperRef.current && !wrapperRef.current?.contains(e.relatedTarget)) {
1236
+ handleEditComplete();
1237
+ }
1238
+ },
1239
+ onClick: (e) => {
1240
+ setJsonReadOnly(false);
1241
+ }
1242
+ },
1243
+ /* @__PURE__ */ import_react8.default.createElement(
1244
+ import_semi_ui5.JsonViewer,
1245
+ {
1246
+ ref: JsonViewerRef,
1247
+ value: getValueType(value) === "string" ? value : "",
1248
+ height: 120,
1249
+ width: "100%",
1250
+ showSearch: false,
1251
+ options: {
1252
+ readOnly: jsonReadOnly,
1253
+ formatOptions: { tabSize: 4, insertSpaces: true, eol: "\n" }
1254
+ },
1255
+ style: {
1256
+ padding: 0
1257
+ },
1258
+ onChange: handleJsonChange
1259
+ }
1260
+ )
1261
+ )) : /* @__PURE__ */ import_react8.default.createElement(ConstantInputWrapper, null, /* @__PURE__ */ import_react8.default.createElement(
1262
+ ConstantInput,
1263
+ {
1264
+ value,
1265
+ onChange: (_v) => onChange(_v),
1266
+ schema: schema || { type: "string" },
1267
+ placeholder: placeholder ?? "Default value if parameter is not provided"
1268
+ }
1269
+ ));
1270
+ }
1271
+
1029
1272
  // src/components/json-schema-editor/components/blur-input.tsx
1030
- var import_react7 = __toESM(require("react"), 1);
1031
- var import_input = __toESM(require("@douyinfe/semi-ui/lib/es/input"), 1);
1273
+ var import_react9 = __toESM(require("react"));
1274
+ var import_input = __toESM(require("@douyinfe/semi-ui/lib/es/input"));
1032
1275
  function BlurInput(props) {
1033
- const [value, setValue] = (0, import_react7.useState)("");
1034
- (0, import_react7.useEffect)(() => {
1276
+ const [value, setValue] = (0, import_react9.useState)("");
1277
+ (0, import_react9.useEffect)(() => {
1035
1278
  setValue(props.value);
1036
1279
  }, [props.value]);
1037
- return /* @__PURE__ */ import_react7.default.createElement(
1280
+ return /* @__PURE__ */ import_react9.default.createElement(
1038
1281
  import_input.default,
1039
1282
  {
1040
1283
  ...props,
@@ -1054,12 +1297,13 @@ function JsonSchemaEditor(props) {
1054
1297
  value,
1055
1298
  onChangeProps
1056
1299
  );
1057
- return /* @__PURE__ */ import_react8.default.createElement(UIContainer, null, /* @__PURE__ */ import_react8.default.createElement(UIProperties, null, propertyList.map((_property) => /* @__PURE__ */ import_react8.default.createElement(
1300
+ return /* @__PURE__ */ import_react10.default.createElement(UIContainer, null, /* @__PURE__ */ import_react10.default.createElement(UIProperties, null, propertyList.map((_property, index) => /* @__PURE__ */ import_react10.default.createElement(
1058
1301
  PropertyEdit,
1059
1302
  {
1060
1303
  key: _property.key,
1061
1304
  value: _property,
1062
1305
  config,
1306
+ $index: index,
1063
1307
  onChange: (_v) => {
1064
1308
  onEditProperty(_property.key, _v);
1065
1309
  },
@@ -1067,14 +1311,26 @@ function JsonSchemaEditor(props) {
1067
1311
  onRemoveProperty(_property.key);
1068
1312
  }
1069
1313
  }
1070
- ))), /* @__PURE__ */ import_react8.default.createElement(import_semi_ui4.Button, { size: "small", style: { marginTop: 10 }, icon: /* @__PURE__ */ import_react8.default.createElement(import_semi_icons4.IconPlus, null), onClick: onAddProperty }, config?.addButtonText ?? "Add"));
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"));
1071
1315
  }
1072
1316
  function PropertyEdit(props) {
1073
- const { value, config, onChange: onChangeProps, onRemove, $isLast, $showLine } = props;
1074
- const [expand, setExpand] = (0, import_react8.useState)(false);
1075
- const [collapse, setCollapse] = (0, import_react8.useState)(false);
1076
- const { name, type, items, description, isPropertyRequired } = value || {};
1077
- const typeSelectorValue = (0, import_react8.useMemo)(() => ({ type, items }), [type, items]);
1317
+ const {
1318
+ value,
1319
+ config,
1320
+ $level = 0,
1321
+ onChange: onChangeProps,
1322
+ onRemove,
1323
+ $index,
1324
+ $isFirst,
1325
+ $isLast,
1326
+ $parentExpand = false,
1327
+ $parentType = "",
1328
+ $showLine
1329
+ } = props;
1330
+ const [expand, setExpand] = (0, import_react10.useState)(false);
1331
+ const [collapse, setCollapse] = (0, import_react10.useState)(false);
1332
+ const { name, type, items, default: defaultValue, description, isPropertyRequired } = value || {};
1333
+ const typeSelectorValue = (0, import_react10.useMemo)(() => ({ type, items }), [type, items]);
1078
1334
  const { propertyList, isDrilldownObject, onAddProperty, onRemoveProperty, onEditProperty } = usePropertiesEdit(value, onChangeProps);
1079
1335
  const onChange = (key, _value) => {
1080
1336
  onChangeProps?.({
@@ -1083,72 +1339,110 @@ function PropertyEdit(props) {
1083
1339
  });
1084
1340
  };
1085
1341
  const showCollapse = isDrilldownObject && propertyList.length > 0;
1086
- return /* @__PURE__ */ import_react8.default.createElement(import_react8.default.Fragment, null, /* @__PURE__ */ import_react8.default.createElement(UIPropertyLeft, { $isLast, $showLine }, showCollapse && /* @__PURE__ */ import_react8.default.createElement(UICollapseTrigger, { onClick: () => setCollapse((_collapse) => !_collapse) }, collapse ? /* @__PURE__ */ import_react8.default.createElement(import_semi_icons4.IconChevronDown, { size: "small" }) : /* @__PURE__ */ import_react8.default.createElement(import_semi_icons4.IconChevronRight, { size: "small" }))), /* @__PURE__ */ import_react8.default.createElement(UIPropertyRight, null, /* @__PURE__ */ import_react8.default.createElement(UIPropertyMain, { $expand: expand }, /* @__PURE__ */ import_react8.default.createElement(UIRow, null, /* @__PURE__ */ import_react8.default.createElement(UIName, null, /* @__PURE__ */ import_react8.default.createElement(
1087
- BlurInput,
1342
+ return /* @__PURE__ */ import_react10.default.createElement(import_react10.default.Fragment, null, /* @__PURE__ */ import_react10.default.createElement(
1343
+ UIPropertyLeft,
1088
1344
  {
1089
- placeholder: config?.placeholder ?? "Input Variable Name",
1090
- size: "small",
1091
- value: name,
1092
- onChange: (value2) => onChange("name", value2)
1093
- }
1094
- )), /* @__PURE__ */ import_react8.default.createElement(UIType, null, /* @__PURE__ */ import_react8.default.createElement(
1095
- TypeSelector,
1345
+ type,
1346
+ $index,
1347
+ $isFirst,
1348
+ $isLast,
1349
+ $showLine,
1350
+ $isExpand: expand,
1351
+ $parentExpand,
1352
+ $parentType
1353
+ },
1354
+ showCollapse && /* @__PURE__ */ import_react10.default.createElement(UICollapseTrigger, { onClick: () => setCollapse((_collapse) => !_collapse) }, collapse ? /* @__PURE__ */ import_react10.default.createElement(import_semi_icons5.IconChevronDown, { size: "small" }) : /* @__PURE__ */ import_react10.default.createElement(import_semi_icons5.IconChevronRight, { size: "small" }))
1355
+ ), /* @__PURE__ */ import_react10.default.createElement(UIPropertyRight, null, /* @__PURE__ */ import_react10.default.createElement(
1356
+ UIPropertyMain,
1096
1357
  {
1097
- value: typeSelectorValue,
1098
- onChange: (_value) => {
1099
- onChangeProps?.({
1100
- ...value || {},
1101
- ..._value
1102
- });
1358
+ $showCollapse: showCollapse,
1359
+ $collapse: collapse,
1360
+ $expand: expand,
1361
+ type
1362
+ },
1363
+ /* @__PURE__ */ import_react10.default.createElement(UIRow, null, /* @__PURE__ */ import_react10.default.createElement(UIName, null, /* @__PURE__ */ import_react10.default.createElement(
1364
+ BlurInput,
1365
+ {
1366
+ placeholder: config?.placeholder ?? "Input Variable Name",
1367
+ size: "small",
1368
+ value: name,
1369
+ onChange: (value2) => onChange("name", value2)
1103
1370
  }
1104
- }
1105
- )), /* @__PURE__ */ import_react8.default.createElement(UIRequired, null, /* @__PURE__ */ import_react8.default.createElement(
1106
- import_semi_ui4.Checkbox,
1107
- {
1108
- checked: isPropertyRequired,
1109
- onChange: (e) => onChange("isPropertyRequired", e.target.checked)
1110
- }
1111
- )), /* @__PURE__ */ import_react8.default.createElement(UIActions, null, /* @__PURE__ */ import_react8.default.createElement(
1112
- import_semi_ui4.IconButton,
1113
- {
1114
- size: "small",
1115
- theme: "borderless",
1116
- icon: expand ? /* @__PURE__ */ import_react8.default.createElement(import_semi_icons4.IconShrink, { size: "small" }) : /* @__PURE__ */ import_react8.default.createElement(import_semi_icons4.IconExpand, { size: "small" }),
1117
- onClick: () => setExpand((_expand) => !_expand)
1118
- }
1119
- ), isDrilldownObject && /* @__PURE__ */ import_react8.default.createElement(
1120
- import_semi_ui4.IconButton,
1121
- {
1122
- size: "small",
1123
- theme: "borderless",
1124
- icon: /* @__PURE__ */ import_react8.default.createElement(IconAddChildren, null),
1125
- onClick: () => {
1126
- onAddProperty();
1127
- setCollapse(true);
1371
+ )), /* @__PURE__ */ import_react10.default.createElement(UIType, null, /* @__PURE__ */ import_react10.default.createElement(
1372
+ TypeSelector,
1373
+ {
1374
+ value: typeSelectorValue,
1375
+ onChange: (_value) => {
1376
+ onChangeProps?.({
1377
+ ...value || {},
1378
+ ..._value
1379
+ });
1380
+ }
1128
1381
  }
1129
- }
1130
- ), /* @__PURE__ */ import_react8.default.createElement(
1131
- import_semi_ui4.IconButton,
1132
- {
1133
- size: "small",
1134
- theme: "borderless",
1135
- icon: /* @__PURE__ */ import_react8.default.createElement(import_semi_icons4.IconMinus, { size: "small" }),
1136
- onClick: onRemove
1137
- }
1138
- ))), expand && /* @__PURE__ */ import_react8.default.createElement(UIExpandDetail, null, /* @__PURE__ */ import_react8.default.createElement(UILabel, null, config?.descTitle ?? "Description"), /* @__PURE__ */ import_react8.default.createElement(
1139
- BlurInput,
1140
- {
1141
- size: "small",
1142
- value: description,
1143
- onChange: (value2) => onChange("description", value2),
1144
- placeholder: config?.descPlaceholder ?? "Help LLM to understand the property"
1145
- }
1146
- ))), showCollapse && /* @__PURE__ */ import_react8.default.createElement(UICollapsible, { $collapse: collapse }, /* @__PURE__ */ import_react8.default.createElement(UIProperties, { $shrink: true }, propertyList.map((_property, index) => /* @__PURE__ */ import_react8.default.createElement(
1382
+ )), /* @__PURE__ */ import_react10.default.createElement(UIRequired, null, /* @__PURE__ */ import_react10.default.createElement(
1383
+ import_semi_ui6.Checkbox,
1384
+ {
1385
+ checked: isPropertyRequired,
1386
+ onChange: (e) => onChange("isPropertyRequired", e.target.checked)
1387
+ }
1388
+ )), /* @__PURE__ */ import_react10.default.createElement(UIActions, null, /* @__PURE__ */ import_react10.default.createElement(
1389
+ import_semi_ui6.IconButton,
1390
+ {
1391
+ size: "small",
1392
+ theme: "borderless",
1393
+ icon: expand ? /* @__PURE__ */ import_react10.default.createElement(import_semi_icons5.IconShrink, { size: "small" }) : /* @__PURE__ */ import_react10.default.createElement(import_semi_icons5.IconExpand, { size: "small" }),
1394
+ onClick: () => {
1395
+ setExpand((_expand) => !_expand);
1396
+ }
1397
+ }
1398
+ ), isDrilldownObject && /* @__PURE__ */ import_react10.default.createElement(
1399
+ import_semi_ui6.IconButton,
1400
+ {
1401
+ size: "small",
1402
+ theme: "borderless",
1403
+ icon: /* @__PURE__ */ import_react10.default.createElement(IconAddChildren, null),
1404
+ onClick: () => {
1405
+ onAddProperty();
1406
+ setCollapse(true);
1407
+ }
1408
+ }
1409
+ ), /* @__PURE__ */ import_react10.default.createElement(
1410
+ import_semi_ui6.IconButton,
1411
+ {
1412
+ size: "small",
1413
+ theme: "borderless",
1414
+ icon: /* @__PURE__ */ import_react10.default.createElement(import_semi_icons5.IconMinus, { size: "small" }),
1415
+ onClick: onRemove
1416
+ }
1417
+ ))),
1418
+ expand && /* @__PURE__ */ import_react10.default.createElement(UIExpandDetail, null, /* @__PURE__ */ import_react10.default.createElement(UILabel, null, config?.descTitle ?? "Description"), /* @__PURE__ */ import_react10.default.createElement(
1419
+ BlurInput,
1420
+ {
1421
+ size: "small",
1422
+ value: description,
1423
+ onChange: (value2) => onChange("description", value2),
1424
+ placeholder: config?.descPlaceholder ?? "Help LLM to understand the property"
1425
+ }
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(
1427
+ DefaultValue,
1428
+ {
1429
+ value: defaultValue,
1430
+ schema: value,
1431
+ type,
1432
+ placeholder: config?.defaultValuePlaceholder,
1433
+ jsonFormatText: config?.jsonFormatText,
1434
+ onChange: (value2) => onChange("default", value2)
1435
+ }
1436
+ ))))
1437
+ ), showCollapse && /* @__PURE__ */ import_react10.default.createElement(UICollapsible, { $collapse: collapse }, /* @__PURE__ */ import_react10.default.createElement(UIProperties, { $shrink: true }, propertyList.map((_property, index) => /* @__PURE__ */ import_react10.default.createElement(
1147
1438
  PropertyEdit,
1148
1439
  {
1149
1440
  key: _property.key,
1150
1441
  value: _property,
1151
1442
  config,
1443
+ $level: $level + 1,
1444
+ $parentExpand: expand,
1445
+ $parentType: type,
1152
1446
  onChange: (_v) => {
1153
1447
  onEditProperty(_property.key, _v);
1154
1448
  },
@@ -1156,102 +1450,31 @@ function PropertyEdit(props) {
1156
1450
  onRemoveProperty(_property.key);
1157
1451
  },
1158
1452
  $isLast: index === propertyList.length - 1,
1453
+ $isFirst: index === 0,
1454
+ $index: index,
1159
1455
  $showLine: true
1160
1456
  }
1161
1457
  ))))));
1162
1458
  }
1163
1459
 
1164
1460
  // src/components/batch-variable-selector/index.tsx
1165
- var import_react9 = __toESM(require("react"), 1);
1461
+ var import_react11 = __toESM(require("react"));
1166
1462
  var import_editor3 = require("@flowgram.ai/editor");
1167
1463
  var batchVariableSchema = {
1168
1464
  type: "array",
1169
1465
  extra: { weak: true }
1170
1466
  };
1171
1467
  function BatchVariableSelector(props) {
1172
- return /* @__PURE__ */ import_react9.default.createElement(import_editor3.PrivateScopeProvider, null, /* @__PURE__ */ import_react9.default.createElement(VariableSelector, { ...props, includeSchema: batchVariableSchema }));
1173
- }
1174
-
1175
- // src/components/constant-input/index.tsx
1176
- var import_react10 = __toESM(require("react"), 1);
1177
- var import_semi_ui5 = require("@douyinfe/semi-ui");
1178
- var defaultStrategies = [
1179
- {
1180
- hit: (schema) => schema?.type === "string",
1181
- Renderer: (props) => /* @__PURE__ */ import_react10.default.createElement(import_semi_ui5.Input, { placeholder: "Please Input String", size: "small", disabled: props.readonly, ...props })
1182
- },
1183
- {
1184
- hit: (schema) => schema?.type === "number",
1185
- Renderer: (props) => /* @__PURE__ */ import_react10.default.createElement(
1186
- import_semi_ui5.InputNumber,
1187
- {
1188
- placeholder: "Please Input Number",
1189
- size: "small",
1190
- disabled: props.readonly,
1191
- hideButtons: true,
1192
- ...props
1193
- }
1194
- )
1195
- },
1196
- {
1197
- hit: (schema) => schema?.type === "integer",
1198
- Renderer: (props) => /* @__PURE__ */ import_react10.default.createElement(
1199
- import_semi_ui5.InputNumber,
1200
- {
1201
- placeholder: "Please Input Integer",
1202
- size: "small",
1203
- disabled: props.readonly,
1204
- hideButtons: true,
1205
- precision: 0,
1206
- ...props
1207
- }
1208
- )
1209
- },
1210
- {
1211
- hit: (schema) => schema?.type === "boolean",
1212
- Renderer: (props) => {
1213
- const { value, onChange, ...rest } = props;
1214
- return /* @__PURE__ */ import_react10.default.createElement(
1215
- import_semi_ui5.Select,
1216
- {
1217
- placeholder: "Please Select Boolean",
1218
- size: "small",
1219
- disabled: props.readonly,
1220
- optionList: [
1221
- { label: "True", value: 1 },
1222
- { label: "False", value: 0 }
1223
- ],
1224
- value: value ? 1 : 0,
1225
- onChange: (value2) => onChange?.(!!value2),
1226
- ...rest
1227
- }
1228
- );
1229
- }
1230
- }
1231
- ];
1232
- function ConstantInput(props) {
1233
- const { value, onChange, schema, strategies: extraStrategies, readonly, ...rest } = props;
1234
- const strategies = (0, import_react10.useMemo)(
1235
- () => [...defaultStrategies, ...extraStrategies || []],
1236
- [extraStrategies]
1237
- );
1238
- const Renderer = (0, import_react10.useMemo)(() => {
1239
- const strategy = strategies.find((_strategy) => _strategy.hit(schema));
1240
- return strategy?.Renderer;
1241
- }, [strategies, schema]);
1242
- if (!Renderer) {
1243
- return /* @__PURE__ */ import_react10.default.createElement(import_semi_ui5.Input, { size: "small", disabled: true, placeholder: "Unsupported type" });
1244
- }
1245
- return /* @__PURE__ */ import_react10.default.createElement(Renderer, { value, onChange, readonly, ...rest });
1468
+ return /* @__PURE__ */ import_react11.default.createElement(import_editor3.PrivateScopeProvider, null, /* @__PURE__ */ import_react11.default.createElement(VariableSelector, { ...props, includeSchema: batchVariableSchema }));
1246
1469
  }
1247
1470
 
1248
1471
  // src/components/dynamic-value-input/index.tsx
1249
- var import_react11 = __toESM(require("react"), 1);
1250
- var import_semi_ui6 = require("@douyinfe/semi-ui");
1251
- var import_semi_icons5 = require("@douyinfe/semi-icons");
1472
+ var import_react12 = __toESM(require("react"));
1473
+ var import_semi_ui7 = require("@douyinfe/semi-ui");
1474
+ var import_semi_icons6 = require("@douyinfe/semi-icons");
1252
1475
 
1253
1476
  // src/components/dynamic-value-input/styles.tsx
1254
- var import_styled_components3 = __toESM(require("styled-components"), 1);
1477
+ var import_styled_components3 = __toESM(require("styled-components"));
1255
1478
  var UIContainer2 = import_styled_components3.default.div`
1256
1479
  display: flex;
1257
1480
  align-items: center;
@@ -1277,7 +1500,7 @@ function DynamicValueInput({
1277
1500
  schema,
1278
1501
  constantProps
1279
1502
  }) {
1280
- const includeSchema = (0, import_react11.useMemo)(() => {
1503
+ const includeSchema = (0, import_react12.useMemo)(() => {
1281
1504
  if (schema?.type === "number") {
1282
1505
  return [schema, { type: "integer" }];
1283
1506
  }
@@ -1285,7 +1508,7 @@ function DynamicValueInput({
1285
1508
  }, [schema]);
1286
1509
  const renderMain = () => {
1287
1510
  if (value?.type === "ref") {
1288
- return /* @__PURE__ */ import_react11.default.createElement(
1511
+ return /* @__PURE__ */ import_react12.default.createElement(
1289
1512
  VariableSelector,
1290
1513
  {
1291
1514
  value: value?.content,
@@ -1295,7 +1518,7 @@ function DynamicValueInput({
1295
1518
  }
1296
1519
  );
1297
1520
  }
1298
- return /* @__PURE__ */ import_react11.default.createElement(
1521
+ return /* @__PURE__ */ import_react12.default.createElement(
1299
1522
  ConstantInput,
1300
1523
  {
1301
1524
  value: value?.content,
@@ -1306,7 +1529,7 @@ function DynamicValueInput({
1306
1529
  }
1307
1530
  );
1308
1531
  };
1309
- const renderTrigger = () => /* @__PURE__ */ import_react11.default.createElement(
1532
+ const renderTrigger = () => /* @__PURE__ */ import_react12.default.createElement(
1310
1533
  VariableSelector,
1311
1534
  {
1312
1535
  style: { width: "100%" },
@@ -1314,18 +1537,18 @@ function DynamicValueInput({
1314
1537
  onChange: (_v) => onChange({ type: "ref", content: _v }),
1315
1538
  includeSchema,
1316
1539
  readonly,
1317
- triggerRender: () => /* @__PURE__ */ import_react11.default.createElement(import_semi_ui6.IconButton, { disabled: readonly, size: "small", icon: /* @__PURE__ */ import_react11.default.createElement(import_semi_icons5.IconSetting, { size: "small" }) })
1540
+ triggerRender: () => /* @__PURE__ */ import_react12.default.createElement(import_semi_ui7.IconButton, { disabled: readonly, size: "small", icon: /* @__PURE__ */ import_react12.default.createElement(import_semi_icons6.IconSetting, { size: "small" }) })
1318
1541
  }
1319
1542
  );
1320
- return /* @__PURE__ */ import_react11.default.createElement(UIContainer2, { style }, /* @__PURE__ */ import_react11.default.createElement(UIMain, null, renderMain()), /* @__PURE__ */ import_react11.default.createElement(UITrigger, null, renderTrigger()));
1543
+ return /* @__PURE__ */ import_react12.default.createElement(UIContainer2, { style }, /* @__PURE__ */ import_react12.default.createElement(UIMain, null, renderMain()), /* @__PURE__ */ import_react12.default.createElement(UITrigger, null, renderTrigger()));
1321
1544
  }
1322
1545
 
1323
1546
  // src/components/condition-row/index.tsx
1324
- var import_react14 = __toESM(require("react"), 1);
1325
- var import_semi_ui8 = require("@douyinfe/semi-ui");
1547
+ var import_react15 = __toESM(require("react"));
1548
+ var import_semi_ui9 = require("@douyinfe/semi-ui");
1326
1549
 
1327
1550
  // src/components/condition-row/styles.tsx
1328
- var import_styled_components4 = __toESM(require("styled-components"), 1);
1551
+ var import_styled_components4 = __toESM(require("styled-components"));
1329
1552
  var UIContainer3 = import_styled_components4.default.div`
1330
1553
  display: flex;
1331
1554
  align-items: center;
@@ -1347,7 +1570,7 @@ var UIValues = import_styled_components4.default.div`
1347
1570
  `;
1348
1571
 
1349
1572
  // src/components/condition-row/hooks/useRule.ts
1350
- var import_react12 = require("react");
1573
+ var import_react13 = require("react");
1351
1574
  var import_editor4 = require("@flowgram.ai/editor");
1352
1575
 
1353
1576
  // src/components/condition-row/constants.ts
@@ -1537,11 +1760,11 @@ function formatNewRefToLegacyRef(value) {
1537
1760
  // src/components/condition-row/hooks/useRule.ts
1538
1761
  function useRule(left) {
1539
1762
  const available = (0, import_editor4.useScopeAvailable)();
1540
- const variable = (0, import_react12.useMemo)(() => {
1763
+ const variable = (0, import_react13.useMemo)(() => {
1541
1764
  if (!left) return void 0;
1542
1765
  return available.getByKeyPath(left.content);
1543
1766
  }, [available, left]);
1544
- const rule = (0, import_react12.useMemo)(() => {
1767
+ const rule = (0, import_react13.useMemo)(() => {
1545
1768
  if (!variable) return void 0;
1546
1769
  const schema = JsonSchemaUtils.astToSchema(variable.type, { drilldown: false });
1547
1770
  return rules[schema?.type];
@@ -1550,20 +1773,20 @@ function useRule(left) {
1550
1773
  }
1551
1774
 
1552
1775
  // src/components/condition-row/hooks/useOp.tsx
1553
- var import_react13 = __toESM(require("react"), 1);
1554
- var import_semi_ui7 = require("@douyinfe/semi-ui");
1555
- var import_semi_icons6 = require("@douyinfe/semi-icons");
1776
+ var import_react14 = __toESM(require("react"));
1777
+ var import_semi_ui8 = require("@douyinfe/semi-ui");
1778
+ var import_semi_icons7 = require("@douyinfe/semi-icons");
1556
1779
  function useOp({ rule, op, onChange }) {
1557
- const options2 = (0, import_react13.useMemo)(
1780
+ const options2 = (0, import_react14.useMemo)(
1558
1781
  () => Object.keys(rule || {}).map((_op) => ({
1559
1782
  ...opConfigs[_op] || {},
1560
1783
  value: _op
1561
1784
  })),
1562
1785
  [rule]
1563
1786
  );
1564
- const opConfig = (0, import_react13.useMemo)(() => opConfigs[op], [op]);
1565
- const renderOpSelect = () => /* @__PURE__ */ import_react13.default.createElement(
1566
- import_semi_ui7.Select,
1787
+ const opConfig = (0, import_react14.useMemo)(() => opConfigs[op], [op]);
1788
+ const renderOpSelect = () => /* @__PURE__ */ import_react14.default.createElement(
1789
+ import_semi_ui8.Select,
1567
1790
  {
1568
1791
  style: { height: 22 },
1569
1792
  size: "small",
@@ -1572,7 +1795,7 @@ function useOp({ rule, op, onChange }) {
1572
1795
  onChange: (v) => {
1573
1796
  onChange(v);
1574
1797
  },
1575
- triggerRender: ({ value }) => /* @__PURE__ */ import_react13.default.createElement(import_semi_ui7.Button, { size: "small", disabled: !rule }, opConfig?.abbreviation || /* @__PURE__ */ import_react13.default.createElement(import_semi_icons6.IconChevronDownStroked, { size: "small" }))
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" }))
1576
1799
  }
1577
1800
  );
1578
1801
  return { renderOpSelect, opConfig };
@@ -1587,11 +1810,11 @@ function ConditionRow({ style, value, onChange, readonly }) {
1587
1810
  op: operator,
1588
1811
  onChange: (v) => onChange({ ...value, operator: v })
1589
1812
  });
1590
- const targetSchema = (0, import_react14.useMemo)(() => {
1813
+ const targetSchema = (0, import_react15.useMemo)(() => {
1591
1814
  const targetType = rule?.[operator] || null;
1592
1815
  return targetType ? { type: targetType, extra: { weak: true } } : null;
1593
1816
  }, [rule, opConfig]);
1594
- return /* @__PURE__ */ import_react14.default.createElement(UIContainer3, { style }, /* @__PURE__ */ import_react14.default.createElement(UIOperator, null, renderOpSelect()), /* @__PURE__ */ import_react14.default.createElement(UIValues, null, /* @__PURE__ */ import_react14.default.createElement(UILeft, null, /* @__PURE__ */ import_react14.default.createElement(
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(
1595
1818
  VariableSelector,
1596
1819
  {
1597
1820
  readonly,
@@ -1605,7 +1828,7 @@ function ConditionRow({ style, value, onChange, readonly }) {
1605
1828
  }
1606
1829
  })
1607
1830
  }
1608
- )), /* @__PURE__ */ import_react14.default.createElement(UIRight, null, targetSchema ? /* @__PURE__ */ import_react14.default.createElement(
1831
+ )), /* @__PURE__ */ import_react15.default.createElement(UIRight, null, targetSchema ? /* @__PURE__ */ import_react15.default.createElement(
1609
1832
  DynamicValueInput,
1610
1833
  {
1611
1834
  readonly: readonly || !rule,
@@ -1613,7 +1836,7 @@ function ConditionRow({ style, value, onChange, readonly }) {
1613
1836
  schema: targetSchema,
1614
1837
  onChange: (v) => onChange({ ...value, right: v })
1615
1838
  }
1616
- ) : /* @__PURE__ */ import_react14.default.createElement(import_semi_ui8.Input, { size: "small", disabled: true, value: opConfig?.rightDisplay || "Empty" }))));
1839
+ ) : /* @__PURE__ */ import_react15.default.createElement(import_semi_ui9.Input, { size: "small", disabled: true, value: opConfig?.rightDisplay || "Empty" }))));
1617
1840
  }
1618
1841
 
1619
1842
  // src/effects/provide-batch-input/index.ts