@flowgram.ai/form-materials 0.2.0 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/index.js +544 -107
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.mts +130 -39
- package/dist/index.d.ts +130 -39
- package/dist/index.js +544 -107
- package/dist/index.js.map +1 -1
- package/package.json +5 -4
- package/src/components/batch-variable-selector/index.tsx +3 -2
- package/src/components/condition-row/config.json +5 -0
- package/src/components/condition-row/constants.ts +123 -0
- package/src/components/condition-row/hooks/useOp.tsx +45 -0
- package/src/components/condition-row/hooks/useRule.ts +26 -0
- package/src/components/condition-row/index.tsx +71 -0
- package/src/components/condition-row/styles.tsx +25 -0
- package/src/components/condition-row/types.ts +37 -0
- package/src/components/constant-input/config.json +1 -1
- package/src/components/constant-input/types.ts +3 -3
- package/src/components/dynamic-value-input/index.tsx +13 -5
- package/src/components/index.ts +1 -0
- package/src/components/json-schema-editor/components/blur-input.tsx +22 -0
- package/src/components/json-schema-editor/config.json +1 -1
- package/src/components/json-schema-editor/hooks.tsx +2 -2
- package/src/components/json-schema-editor/index.tsx +7 -6
- package/src/components/json-schema-editor/types.ts +3 -3
- package/src/components/type-selector/config.json +1 -1
- package/src/components/type-selector/constants.tsx +2 -2
- package/src/components/type-selector/index.tsx +6 -6
- package/src/components/variable-selector/config.json +1 -1
- package/src/components/variable-selector/index.tsx +4 -4
- package/src/components/variable-selector/use-variable-tree.tsx +11 -5
- package/src/effects/auto-rename-ref/config.json +5 -0
- package/src/effects/auto-rename-ref/index.ts +104 -0
- package/src/effects/index.ts +1 -0
- package/src/typings/index.ts +1 -0
- package/src/typings/json-schema/config.json +5 -0
- package/src/typings/json-schema/index.ts +31 -0
- package/src/utils/index.ts +1 -0
- package/src/utils/json-schema/config.json +5 -0
- package/src/utils/json-schema/index.ts +161 -0
- package/src/components/type-selector/types.ts +0 -5
package/dist/index.js
CHANGED
|
@@ -32,12 +32,15 @@ var src_exports = {};
|
|
|
32
32
|
__export(src_exports, {
|
|
33
33
|
ArrayIcons: () => ArrayIcons,
|
|
34
34
|
BatchVariableSelector: () => BatchVariableSelector,
|
|
35
|
+
ConditionRow: () => ConditionRow,
|
|
35
36
|
ConstantInput: () => ConstantInput,
|
|
36
37
|
DynamicValueInput: () => DynamicValueInput,
|
|
37
38
|
JsonSchemaEditor: () => JsonSchemaEditor,
|
|
39
|
+
JsonSchemaUtils: () => JsonSchemaUtils,
|
|
38
40
|
TypeSelector: () => TypeSelector,
|
|
39
41
|
VariableSelector: () => VariableSelector,
|
|
40
42
|
VariableTypeIcons: () => VariableTypeIcons,
|
|
43
|
+
autoRenameRefEffect: () => autoRenameRefEffect,
|
|
41
44
|
formatLegacyRefOnInit: () => formatLegacyRefOnInit,
|
|
42
45
|
formatLegacyRefOnSubmit: () => formatLegacyRefOnSubmit,
|
|
43
46
|
formatLegacyRefToNewRef: () => formatLegacyRefToNewRef,
|
|
@@ -58,7 +61,7 @@ var import_semi_icons2 = require("@douyinfe/semi-icons");
|
|
|
58
61
|
|
|
59
62
|
// src/components/variable-selector/use-variable-tree.tsx
|
|
60
63
|
var import_react2 = __toESM(require("react"));
|
|
61
|
-
var
|
|
64
|
+
var import_editor2 = require("@flowgram.ai/editor");
|
|
62
65
|
var import_semi_ui = require("@douyinfe/semi-ui");
|
|
63
66
|
|
|
64
67
|
// src/components/type-selector/constants.tsx
|
|
@@ -450,10 +453,123 @@ var options = [
|
|
|
450
453
|
}
|
|
451
454
|
];
|
|
452
455
|
|
|
456
|
+
// src/utils/json-schema/index.ts
|
|
457
|
+
var import_lodash = require("lodash");
|
|
458
|
+
var import_editor = require("@flowgram.ai/editor");
|
|
459
|
+
var JsonSchemaUtils;
|
|
460
|
+
((JsonSchemaUtils2) => {
|
|
461
|
+
function schemaToAST(jsonSchema) {
|
|
462
|
+
const { type, extra } = jsonSchema || {};
|
|
463
|
+
const { weak = false } = extra || {};
|
|
464
|
+
if (!type) {
|
|
465
|
+
return void 0;
|
|
466
|
+
}
|
|
467
|
+
switch (type) {
|
|
468
|
+
case "object":
|
|
469
|
+
if (weak) {
|
|
470
|
+
return { kind: import_editor.ASTKind.Object, weak: true };
|
|
471
|
+
}
|
|
472
|
+
return import_editor.ASTFactory.createObject({
|
|
473
|
+
properties: Object.entries(jsonSchema.properties || {}).sort((a, b) => ((0, import_lodash.get)(a?.[1], "extra.index") || 0) - ((0, import_lodash.get)(b?.[1], "extra.index") || 0)).map(([key, _property]) => ({
|
|
474
|
+
key,
|
|
475
|
+
type: schemaToAST(_property),
|
|
476
|
+
meta: { description: _property.description }
|
|
477
|
+
}))
|
|
478
|
+
});
|
|
479
|
+
case "array":
|
|
480
|
+
if (weak) {
|
|
481
|
+
return { kind: import_editor.ASTKind.Array, weak: true };
|
|
482
|
+
}
|
|
483
|
+
return import_editor.ASTFactory.createArray({
|
|
484
|
+
items: schemaToAST(jsonSchema.items)
|
|
485
|
+
});
|
|
486
|
+
case "map":
|
|
487
|
+
if (weak) {
|
|
488
|
+
return { kind: import_editor.ASTKind.Map, weak: true };
|
|
489
|
+
}
|
|
490
|
+
return import_editor.ASTFactory.createMap({
|
|
491
|
+
valueType: schemaToAST(jsonSchema.additionalProperties)
|
|
492
|
+
});
|
|
493
|
+
case "string":
|
|
494
|
+
return import_editor.ASTFactory.createString();
|
|
495
|
+
case "number":
|
|
496
|
+
return import_editor.ASTFactory.createNumber();
|
|
497
|
+
case "boolean":
|
|
498
|
+
return import_editor.ASTFactory.createBoolean();
|
|
499
|
+
case "integer":
|
|
500
|
+
return import_editor.ASTFactory.createInteger();
|
|
501
|
+
default:
|
|
502
|
+
return import_editor.ASTFactory.createCustomType({ typeName: type });
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
JsonSchemaUtils2.schemaToAST = schemaToAST;
|
|
506
|
+
function astToSchema(typeAST, options2) {
|
|
507
|
+
const { drilldown = true } = options2 || {};
|
|
508
|
+
if (import_editor.ASTMatch.isString(typeAST)) {
|
|
509
|
+
return {
|
|
510
|
+
type: "string"
|
|
511
|
+
};
|
|
512
|
+
}
|
|
513
|
+
if (import_editor.ASTMatch.isBoolean(typeAST)) {
|
|
514
|
+
return {
|
|
515
|
+
type: "boolean"
|
|
516
|
+
};
|
|
517
|
+
}
|
|
518
|
+
if (import_editor.ASTMatch.isNumber(typeAST)) {
|
|
519
|
+
return {
|
|
520
|
+
type: "number"
|
|
521
|
+
};
|
|
522
|
+
}
|
|
523
|
+
if (import_editor.ASTMatch.isInteger(typeAST)) {
|
|
524
|
+
return {
|
|
525
|
+
type: "integer"
|
|
526
|
+
};
|
|
527
|
+
}
|
|
528
|
+
if (import_editor.ASTMatch.isObject(typeAST)) {
|
|
529
|
+
return {
|
|
530
|
+
type: "object",
|
|
531
|
+
properties: drilldown ? Object.fromEntries(
|
|
532
|
+
Object.entries(typeAST.properties).map(([key, value]) => [key, astToSchema(value)])
|
|
533
|
+
) : {}
|
|
534
|
+
};
|
|
535
|
+
}
|
|
536
|
+
if (import_editor.ASTMatch.isArray(typeAST)) {
|
|
537
|
+
return {
|
|
538
|
+
type: "array",
|
|
539
|
+
items: drilldown ? astToSchema(typeAST.items) : void 0
|
|
540
|
+
};
|
|
541
|
+
}
|
|
542
|
+
if (import_editor.ASTMatch.isMap(typeAST)) {
|
|
543
|
+
return {
|
|
544
|
+
type: "map",
|
|
545
|
+
items: drilldown ? astToSchema(typeAST.valueType) : void 0
|
|
546
|
+
};
|
|
547
|
+
}
|
|
548
|
+
if (import_editor.ASTMatch.isCustomType(typeAST)) {
|
|
549
|
+
return {
|
|
550
|
+
type: typeAST.typeName
|
|
551
|
+
};
|
|
552
|
+
}
|
|
553
|
+
return void 0;
|
|
554
|
+
}
|
|
555
|
+
JsonSchemaUtils2.astToSchema = astToSchema;
|
|
556
|
+
function isASTMatchSchema(typeAST, schema) {
|
|
557
|
+
if (Array.isArray(schema)) {
|
|
558
|
+
return typeAST.isTypeEqual(
|
|
559
|
+
import_editor.ASTFactory.createUnion({
|
|
560
|
+
types: schema.map((_schema) => schemaToAST(_schema)).filter(Boolean)
|
|
561
|
+
})
|
|
562
|
+
);
|
|
563
|
+
}
|
|
564
|
+
return typeAST.isTypeEqual(schemaToAST(schema));
|
|
565
|
+
}
|
|
566
|
+
JsonSchemaUtils2.isASTMatchSchema = isASTMatchSchema;
|
|
567
|
+
})(JsonSchemaUtils || (JsonSchemaUtils = {}));
|
|
568
|
+
|
|
453
569
|
// src/components/variable-selector/use-variable-tree.tsx
|
|
454
570
|
function useVariableTree(params) {
|
|
455
571
|
const { includeSchema, excludeSchema } = params;
|
|
456
|
-
const available = (0,
|
|
572
|
+
const available = (0, import_editor2.useScopeAvailable)();
|
|
457
573
|
const getVariableTypeIcon = (0, import_react2.useCallback)((variable) => {
|
|
458
574
|
if (variable.meta?.icon) {
|
|
459
575
|
if (typeof variable.meta.icon === "string") {
|
|
@@ -462,7 +578,7 @@ function useVariableTree(params) {
|
|
|
462
578
|
return variable.meta.icon;
|
|
463
579
|
}
|
|
464
580
|
const _type = variable.type;
|
|
465
|
-
if (
|
|
581
|
+
if (import_editor2.ASTMatch.isArray(_type)) {
|
|
466
582
|
return /* @__PURE__ */ import_react2.default.createElement(
|
|
467
583
|
import_semi_ui.Icon,
|
|
468
584
|
{
|
|
@@ -471,7 +587,7 @@ function useVariableTree(params) {
|
|
|
471
587
|
}
|
|
472
588
|
);
|
|
473
589
|
}
|
|
474
|
-
if (
|
|
590
|
+
if (import_editor2.ASTMatch.isCustomType(_type)) {
|
|
475
591
|
return /* @__PURE__ */ import_react2.default.createElement(import_semi_ui.Icon, { size: "small", svg: VariableTypeIcons[_type.typeName.toLowerCase()] });
|
|
476
592
|
}
|
|
477
593
|
return /* @__PURE__ */ import_react2.default.createElement(import_semi_ui.Icon, { size: "small", svg: VariableTypeIcons[variable.type?.kind.toLowerCase()] });
|
|
@@ -482,7 +598,7 @@ function useVariableTree(params) {
|
|
|
482
598
|
return null;
|
|
483
599
|
}
|
|
484
600
|
let children;
|
|
485
|
-
if (
|
|
601
|
+
if (import_editor2.ASTMatch.isObject(type)) {
|
|
486
602
|
children = (type.properties || []).map((_property) => renderVariable(_property, [...parentFields, variable])).filter(Boolean);
|
|
487
603
|
if (!children?.length) {
|
|
488
604
|
return null;
|
|
@@ -490,8 +606,8 @@ function useVariableTree(params) {
|
|
|
490
606
|
}
|
|
491
607
|
const keyPath = [...parentFields.map((_field) => _field.key), variable.key];
|
|
492
608
|
const key = keyPath.join(".");
|
|
493
|
-
const isSchemaInclude = includeSchema ?
|
|
494
|
-
const isSchemaExclude = excludeSchema ?
|
|
609
|
+
const isSchemaInclude = includeSchema ? JsonSchemaUtils.isASTMatchSchema(type, includeSchema) : true;
|
|
610
|
+
const isSchemaExclude = excludeSchema ? JsonSchemaUtils.isASTMatchSchema(type, excludeSchema) : false;
|
|
495
611
|
const isSchemaMatch = isSchemaInclude && !isSchemaExclude;
|
|
496
612
|
if (!isSchemaMatch && !children?.length) {
|
|
497
613
|
return null;
|
|
@@ -621,7 +737,7 @@ var VariableSelector = ({
|
|
|
621
737
|
);
|
|
622
738
|
},
|
|
623
739
|
showClear: false,
|
|
624
|
-
arrowIcon:
|
|
740
|
+
arrowIcon: /* @__PURE__ */ import_react3.default.createElement(import_semi_icons2.IconChevronDownStroked, { size: "small" }),
|
|
625
741
|
triggerRender,
|
|
626
742
|
placeholder: config?.placeholder ?? "Select Variable..."
|
|
627
743
|
}
|
|
@@ -664,7 +780,7 @@ function TypeSelector(props) {
|
|
|
664
780
|
}
|
|
665
781
|
|
|
666
782
|
// src/components/json-schema-editor/index.tsx
|
|
667
|
-
var
|
|
783
|
+
var import_react8 = __toESM(require("react"));
|
|
668
784
|
var import_semi_ui4 = require("@douyinfe/semi-ui");
|
|
669
785
|
var import_semi_icons4 = require("@douyinfe/semi-icons");
|
|
670
786
|
|
|
@@ -910,6 +1026,27 @@ function usePropertiesEdit(value, onChange) {
|
|
|
910
1026
|
};
|
|
911
1027
|
}
|
|
912
1028
|
|
|
1029
|
+
// src/components/json-schema-editor/components/blur-input.tsx
|
|
1030
|
+
var import_react7 = __toESM(require("react"));
|
|
1031
|
+
var import_input = __toESM(require("@douyinfe/semi-ui/lib/es/input"));
|
|
1032
|
+
function BlurInput(props) {
|
|
1033
|
+
const [value, setValue] = (0, import_react7.useState)("");
|
|
1034
|
+
(0, import_react7.useEffect)(() => {
|
|
1035
|
+
setValue(props.value);
|
|
1036
|
+
}, [props.value]);
|
|
1037
|
+
return /* @__PURE__ */ import_react7.default.createElement(
|
|
1038
|
+
import_input.default,
|
|
1039
|
+
{
|
|
1040
|
+
...props,
|
|
1041
|
+
value,
|
|
1042
|
+
onChange: (value2) => {
|
|
1043
|
+
setValue(value2);
|
|
1044
|
+
},
|
|
1045
|
+
onBlur: (e) => props.onChange?.(value, e)
|
|
1046
|
+
}
|
|
1047
|
+
);
|
|
1048
|
+
}
|
|
1049
|
+
|
|
913
1050
|
// src/components/json-schema-editor/index.tsx
|
|
914
1051
|
function JsonSchemaEditor(props) {
|
|
915
1052
|
const { value = { type: "object" }, config = {}, onChange: onChangeProps } = props;
|
|
@@ -917,7 +1054,7 @@ function JsonSchemaEditor(props) {
|
|
|
917
1054
|
value,
|
|
918
1055
|
onChangeProps
|
|
919
1056
|
);
|
|
920
|
-
return /* @__PURE__ */
|
|
1057
|
+
return /* @__PURE__ */ import_react8.default.createElement(UIContainer, null, /* @__PURE__ */ import_react8.default.createElement(UIProperties, null, propertyList.map((_property) => /* @__PURE__ */ import_react8.default.createElement(
|
|
921
1058
|
PropertyEdit,
|
|
922
1059
|
{
|
|
923
1060
|
key: _property.key,
|
|
@@ -930,14 +1067,14 @@ function JsonSchemaEditor(props) {
|
|
|
930
1067
|
onRemoveProperty(_property.key);
|
|
931
1068
|
}
|
|
932
1069
|
}
|
|
933
|
-
))), /* @__PURE__ */
|
|
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"));
|
|
934
1071
|
}
|
|
935
1072
|
function PropertyEdit(props) {
|
|
936
1073
|
const { value, config, onChange: onChangeProps, onRemove, $isLast, $showLine } = props;
|
|
937
|
-
const [expand, setExpand] = (0,
|
|
938
|
-
const [collapse, setCollapse] = (0,
|
|
1074
|
+
const [expand, setExpand] = (0, import_react8.useState)(false);
|
|
1075
|
+
const [collapse, setCollapse] = (0, import_react8.useState)(false);
|
|
939
1076
|
const { name, type, items, description, isPropertyRequired } = value || {};
|
|
940
|
-
const typeSelectorValue = (0,
|
|
1077
|
+
const typeSelectorValue = (0, import_react8.useMemo)(() => ({ type, items }), [type, items]);
|
|
941
1078
|
const { propertyList, isDrilldownObject, onAddProperty, onRemoveProperty, onEditProperty } = usePropertiesEdit(value, onChangeProps);
|
|
942
1079
|
const onChange = (key, _value) => {
|
|
943
1080
|
onChangeProps?.({
|
|
@@ -946,15 +1083,15 @@ function PropertyEdit(props) {
|
|
|
946
1083
|
});
|
|
947
1084
|
};
|
|
948
1085
|
const showCollapse = isDrilldownObject && propertyList.length > 0;
|
|
949
|
-
return /* @__PURE__ */
|
|
950
|
-
|
|
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,
|
|
951
1088
|
{
|
|
952
1089
|
placeholder: config?.placeholder ?? "Input Variable Name",
|
|
953
1090
|
size: "small",
|
|
954
1091
|
value: name,
|
|
955
1092
|
onChange: (value2) => onChange("name", value2)
|
|
956
1093
|
}
|
|
957
|
-
)), /* @__PURE__ */
|
|
1094
|
+
)), /* @__PURE__ */ import_react8.default.createElement(UIType, null, /* @__PURE__ */ import_react8.default.createElement(
|
|
958
1095
|
TypeSelector,
|
|
959
1096
|
{
|
|
960
1097
|
value: typeSelectorValue,
|
|
@@ -965,48 +1102,48 @@ function PropertyEdit(props) {
|
|
|
965
1102
|
});
|
|
966
1103
|
}
|
|
967
1104
|
}
|
|
968
|
-
)), /* @__PURE__ */
|
|
1105
|
+
)), /* @__PURE__ */ import_react8.default.createElement(UIRequired, null, /* @__PURE__ */ import_react8.default.createElement(
|
|
969
1106
|
import_semi_ui4.Checkbox,
|
|
970
1107
|
{
|
|
971
1108
|
checked: isPropertyRequired,
|
|
972
1109
|
onChange: (e) => onChange("isPropertyRequired", e.target.checked)
|
|
973
1110
|
}
|
|
974
|
-
)), /* @__PURE__ */
|
|
1111
|
+
)), /* @__PURE__ */ import_react8.default.createElement(UIActions, null, /* @__PURE__ */ import_react8.default.createElement(
|
|
975
1112
|
import_semi_ui4.IconButton,
|
|
976
1113
|
{
|
|
977
1114
|
size: "small",
|
|
978
1115
|
theme: "borderless",
|
|
979
|
-
icon: expand ? /* @__PURE__ */
|
|
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" }),
|
|
980
1117
|
onClick: () => setExpand((_expand) => !_expand)
|
|
981
1118
|
}
|
|
982
|
-
), isDrilldownObject && /* @__PURE__ */
|
|
1119
|
+
), isDrilldownObject && /* @__PURE__ */ import_react8.default.createElement(
|
|
983
1120
|
import_semi_ui4.IconButton,
|
|
984
1121
|
{
|
|
985
1122
|
size: "small",
|
|
986
1123
|
theme: "borderless",
|
|
987
|
-
icon: /* @__PURE__ */
|
|
1124
|
+
icon: /* @__PURE__ */ import_react8.default.createElement(IconAddChildren, null),
|
|
988
1125
|
onClick: () => {
|
|
989
1126
|
onAddProperty();
|
|
990
1127
|
setCollapse(true);
|
|
991
1128
|
}
|
|
992
1129
|
}
|
|
993
|
-
), /* @__PURE__ */
|
|
1130
|
+
), /* @__PURE__ */ import_react8.default.createElement(
|
|
994
1131
|
import_semi_ui4.IconButton,
|
|
995
1132
|
{
|
|
996
1133
|
size: "small",
|
|
997
1134
|
theme: "borderless",
|
|
998
|
-
icon: /* @__PURE__ */
|
|
1135
|
+
icon: /* @__PURE__ */ import_react8.default.createElement(import_semi_icons4.IconMinus, { size: "small" }),
|
|
999
1136
|
onClick: onRemove
|
|
1000
1137
|
}
|
|
1001
|
-
))), expand && /* @__PURE__ */
|
|
1002
|
-
|
|
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,
|
|
1003
1140
|
{
|
|
1004
1141
|
size: "small",
|
|
1005
1142
|
value: description,
|
|
1006
1143
|
onChange: (value2) => onChange("description", value2),
|
|
1007
1144
|
placeholder: config?.descPlaceholder ?? "Help LLM to understand the property"
|
|
1008
1145
|
}
|
|
1009
|
-
))), showCollapse && /* @__PURE__ */
|
|
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(
|
|
1010
1147
|
PropertyEdit,
|
|
1011
1148
|
{
|
|
1012
1149
|
key: _property.key,
|
|
@@ -1025,27 +1162,27 @@ function PropertyEdit(props) {
|
|
|
1025
1162
|
}
|
|
1026
1163
|
|
|
1027
1164
|
// src/components/batch-variable-selector/index.tsx
|
|
1028
|
-
var
|
|
1029
|
-
var
|
|
1165
|
+
var import_react9 = __toESM(require("react"));
|
|
1166
|
+
var import_editor3 = require("@flowgram.ai/editor");
|
|
1030
1167
|
var batchVariableSchema = {
|
|
1031
1168
|
type: "array",
|
|
1032
1169
|
extra: { weak: true }
|
|
1033
1170
|
};
|
|
1034
1171
|
function BatchVariableSelector(props) {
|
|
1035
|
-
return /* @__PURE__ */
|
|
1172
|
+
return /* @__PURE__ */ import_react9.default.createElement(import_editor3.PrivateScopeProvider, null, /* @__PURE__ */ import_react9.default.createElement(VariableSelector, { ...props, includeSchema: batchVariableSchema }));
|
|
1036
1173
|
}
|
|
1037
1174
|
|
|
1038
1175
|
// src/components/constant-input/index.tsx
|
|
1039
|
-
var
|
|
1176
|
+
var import_react10 = __toESM(require("react"));
|
|
1040
1177
|
var import_semi_ui5 = require("@douyinfe/semi-ui");
|
|
1041
1178
|
var defaultStrategies = [
|
|
1042
1179
|
{
|
|
1043
1180
|
hit: (schema) => schema?.type === "string",
|
|
1044
|
-
Renderer: (props) => /* @__PURE__ */
|
|
1181
|
+
Renderer: (props) => /* @__PURE__ */ import_react10.default.createElement(import_semi_ui5.Input, { placeholder: "Please Input String", size: "small", disabled: props.readonly, ...props })
|
|
1045
1182
|
},
|
|
1046
1183
|
{
|
|
1047
1184
|
hit: (schema) => schema?.type === "number",
|
|
1048
|
-
Renderer: (props) => /* @__PURE__ */
|
|
1185
|
+
Renderer: (props) => /* @__PURE__ */ import_react10.default.createElement(
|
|
1049
1186
|
import_semi_ui5.InputNumber,
|
|
1050
1187
|
{
|
|
1051
1188
|
placeholder: "Please Input Number",
|
|
@@ -1058,7 +1195,7 @@ var defaultStrategies = [
|
|
|
1058
1195
|
},
|
|
1059
1196
|
{
|
|
1060
1197
|
hit: (schema) => schema?.type === "integer",
|
|
1061
|
-
Renderer: (props) => /* @__PURE__ */
|
|
1198
|
+
Renderer: (props) => /* @__PURE__ */ import_react10.default.createElement(
|
|
1062
1199
|
import_semi_ui5.InputNumber,
|
|
1063
1200
|
{
|
|
1064
1201
|
placeholder: "Please Input Integer",
|
|
@@ -1074,7 +1211,7 @@ var defaultStrategies = [
|
|
|
1074
1211
|
hit: (schema) => schema?.type === "boolean",
|
|
1075
1212
|
Renderer: (props) => {
|
|
1076
1213
|
const { value, onChange, ...rest } = props;
|
|
1077
|
-
return /* @__PURE__ */
|
|
1214
|
+
return /* @__PURE__ */ import_react10.default.createElement(
|
|
1078
1215
|
import_semi_ui5.Select,
|
|
1079
1216
|
{
|
|
1080
1217
|
placeholder: "Please Select Boolean",
|
|
@@ -1094,22 +1231,22 @@ var defaultStrategies = [
|
|
|
1094
1231
|
];
|
|
1095
1232
|
function ConstantInput(props) {
|
|
1096
1233
|
const { value, onChange, schema, strategies: extraStrategies, readonly, ...rest } = props;
|
|
1097
|
-
const strategies = (0,
|
|
1234
|
+
const strategies = (0, import_react10.useMemo)(
|
|
1098
1235
|
() => [...defaultStrategies, ...extraStrategies || []],
|
|
1099
1236
|
[extraStrategies]
|
|
1100
1237
|
);
|
|
1101
|
-
const Renderer = (0,
|
|
1238
|
+
const Renderer = (0, import_react10.useMemo)(() => {
|
|
1102
1239
|
const strategy = strategies.find((_strategy) => _strategy.hit(schema));
|
|
1103
1240
|
return strategy?.Renderer;
|
|
1104
1241
|
}, [strategies, schema]);
|
|
1105
1242
|
if (!Renderer) {
|
|
1106
|
-
return /* @__PURE__ */
|
|
1243
|
+
return /* @__PURE__ */ import_react10.default.createElement(import_semi_ui5.Input, { size: "small", disabled: true, placeholder: "Unsupported type" });
|
|
1107
1244
|
}
|
|
1108
|
-
return /* @__PURE__ */
|
|
1245
|
+
return /* @__PURE__ */ import_react10.default.createElement(Renderer, { value, onChange, readonly, ...rest });
|
|
1109
1246
|
}
|
|
1110
1247
|
|
|
1111
1248
|
// src/components/dynamic-value-input/index.tsx
|
|
1112
|
-
var
|
|
1249
|
+
var import_react11 = __toESM(require("react"));
|
|
1113
1250
|
var import_semi_ui6 = require("@douyinfe/semi-ui");
|
|
1114
1251
|
var import_semi_icons5 = require("@douyinfe/semi-icons");
|
|
1115
1252
|
|
|
@@ -1140,19 +1277,25 @@ function DynamicValueInput({
|
|
|
1140
1277
|
schema,
|
|
1141
1278
|
constantProps
|
|
1142
1279
|
}) {
|
|
1280
|
+
const includeSchema = (0, import_react11.useMemo)(() => {
|
|
1281
|
+
if (schema?.type === "number") {
|
|
1282
|
+
return [schema, { type: "integer" }];
|
|
1283
|
+
}
|
|
1284
|
+
return schema;
|
|
1285
|
+
}, [schema]);
|
|
1143
1286
|
const renderMain = () => {
|
|
1144
1287
|
if (value?.type === "ref") {
|
|
1145
|
-
return /* @__PURE__ */
|
|
1288
|
+
return /* @__PURE__ */ import_react11.default.createElement(
|
|
1146
1289
|
VariableSelector,
|
|
1147
1290
|
{
|
|
1148
1291
|
value: value?.content,
|
|
1149
1292
|
onChange: (_v) => onChange(_v ? { type: "ref", content: _v } : void 0),
|
|
1150
|
-
includeSchema
|
|
1293
|
+
includeSchema,
|
|
1151
1294
|
readonly
|
|
1152
1295
|
}
|
|
1153
1296
|
);
|
|
1154
1297
|
}
|
|
1155
|
-
return /* @__PURE__ */
|
|
1298
|
+
return /* @__PURE__ */ import_react11.default.createElement(
|
|
1156
1299
|
ConstantInput,
|
|
1157
1300
|
{
|
|
1158
1301
|
value: value?.content,
|
|
@@ -1163,82 +1306,176 @@ function DynamicValueInput({
|
|
|
1163
1306
|
}
|
|
1164
1307
|
);
|
|
1165
1308
|
};
|
|
1166
|
-
const renderTrigger = () => /* @__PURE__ */
|
|
1309
|
+
const renderTrigger = () => /* @__PURE__ */ import_react11.default.createElement(
|
|
1167
1310
|
VariableSelector,
|
|
1168
1311
|
{
|
|
1169
1312
|
style: { width: "100%" },
|
|
1170
1313
|
value: value?.type === "ref" ? value?.content : void 0,
|
|
1171
1314
|
onChange: (_v) => onChange({ type: "ref", content: _v }),
|
|
1172
|
-
includeSchema
|
|
1315
|
+
includeSchema,
|
|
1173
1316
|
readonly,
|
|
1174
|
-
triggerRender: () => /* @__PURE__ */
|
|
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" }) })
|
|
1175
1318
|
}
|
|
1176
1319
|
);
|
|
1177
|
-
return /* @__PURE__ */
|
|
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()));
|
|
1178
1321
|
}
|
|
1179
1322
|
|
|
1180
|
-
// src/
|
|
1181
|
-
var
|
|
1182
|
-
var
|
|
1183
|
-
private: true,
|
|
1184
|
-
parse: (value, ctx) => [
|
|
1185
|
-
import_editor3.ASTFactory.createVariableDeclaration({
|
|
1186
|
-
key: `${ctx.node.id}_locals`,
|
|
1187
|
-
meta: {
|
|
1188
|
-
title: (0, import_editor3.getNodeForm)(ctx.node)?.getValueIn("title"),
|
|
1189
|
-
icon: ctx.node.getNodeRegistry().info?.icon
|
|
1190
|
-
},
|
|
1191
|
-
type: import_editor3.ASTFactory.createObject({
|
|
1192
|
-
properties: [
|
|
1193
|
-
import_editor3.ASTFactory.createProperty({
|
|
1194
|
-
key: "item",
|
|
1195
|
-
initializer: import_editor3.ASTFactory.createEnumerateExpression({
|
|
1196
|
-
enumerateFor: import_editor3.ASTFactory.createKeyPathExpression({
|
|
1197
|
-
keyPath: value.content || []
|
|
1198
|
-
})
|
|
1199
|
-
})
|
|
1200
|
-
}),
|
|
1201
|
-
import_editor3.ASTFactory.createProperty({
|
|
1202
|
-
key: "index",
|
|
1203
|
-
type: import_editor3.ASTFactory.createNumber()
|
|
1204
|
-
})
|
|
1205
|
-
]
|
|
1206
|
-
})
|
|
1207
|
-
})
|
|
1208
|
-
]
|
|
1209
|
-
});
|
|
1323
|
+
// src/components/condition-row/index.tsx
|
|
1324
|
+
var import_react14 = __toESM(require("react"));
|
|
1325
|
+
var import_semi_ui8 = require("@douyinfe/semi-ui");
|
|
1210
1326
|
|
|
1211
|
-
// src/
|
|
1327
|
+
// src/components/condition-row/styles.tsx
|
|
1328
|
+
var import_styled_components4 = __toESM(require("styled-components"));
|
|
1329
|
+
var UIContainer3 = import_styled_components4.default.div`
|
|
1330
|
+
display: flex;
|
|
1331
|
+
align-items: center;
|
|
1332
|
+
gap: 4px;
|
|
1333
|
+
`;
|
|
1334
|
+
var UIOperator = import_styled_components4.default.div``;
|
|
1335
|
+
var UILeft = import_styled_components4.default.div`
|
|
1336
|
+
width: 100%;
|
|
1337
|
+
`;
|
|
1338
|
+
var UIRight = import_styled_components4.default.div`
|
|
1339
|
+
width: 100%;
|
|
1340
|
+
`;
|
|
1341
|
+
var UIValues = import_styled_components4.default.div`
|
|
1342
|
+
flex-grow: 1;
|
|
1343
|
+
display: flex;
|
|
1344
|
+
flex-direction: column;
|
|
1345
|
+
align-items: center;
|
|
1346
|
+
gap: 4px;
|
|
1347
|
+
`;
|
|
1348
|
+
|
|
1349
|
+
// src/components/condition-row/hooks/useRule.ts
|
|
1350
|
+
var import_react12 = require("react");
|
|
1212
1351
|
var import_editor4 = require("@flowgram.ai/editor");
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1352
|
+
|
|
1353
|
+
// src/components/condition-row/constants.ts
|
|
1354
|
+
var rules = {
|
|
1355
|
+
string: {
|
|
1356
|
+
["eq" /* EQ */]: "string",
|
|
1357
|
+
["neq" /* NEQ */]: "string",
|
|
1358
|
+
["contains" /* CONTAINS */]: "string",
|
|
1359
|
+
["not_contains" /* NOT_CONTAINS */]: "string",
|
|
1360
|
+
["in" /* IN */]: "array",
|
|
1361
|
+
["nin" /* NIN */]: "array",
|
|
1362
|
+
["is_empty" /* IS_EMPTY */]: "string",
|
|
1363
|
+
["is_not_empty" /* IS_NOT_EMPTY */]: "string"
|
|
1364
|
+
},
|
|
1365
|
+
number: {
|
|
1366
|
+
["eq" /* EQ */]: "number",
|
|
1367
|
+
["neq" /* NEQ */]: "number",
|
|
1368
|
+
["gt" /* GT */]: "number",
|
|
1369
|
+
["gte" /* GTE */]: "number",
|
|
1370
|
+
["lt" /* LT */]: "number",
|
|
1371
|
+
["lte" /* LTE */]: "number",
|
|
1372
|
+
["in" /* IN */]: "array",
|
|
1373
|
+
["nin" /* NIN */]: "array",
|
|
1374
|
+
["is_empty" /* IS_EMPTY */]: null,
|
|
1375
|
+
["is_not_empty" /* IS_NOT_EMPTY */]: null
|
|
1376
|
+
},
|
|
1377
|
+
integer: {
|
|
1378
|
+
["eq" /* EQ */]: "number",
|
|
1379
|
+
["neq" /* NEQ */]: "number",
|
|
1380
|
+
["gt" /* GT */]: "number",
|
|
1381
|
+
["gte" /* GTE */]: "number",
|
|
1382
|
+
["lt" /* LT */]: "number",
|
|
1383
|
+
["lte" /* LTE */]: "number",
|
|
1384
|
+
["in" /* IN */]: "array",
|
|
1385
|
+
["nin" /* NIN */]: "array",
|
|
1386
|
+
["is_empty" /* IS_EMPTY */]: null,
|
|
1387
|
+
["is_not_empty" /* IS_NOT_EMPTY */]: null
|
|
1388
|
+
},
|
|
1389
|
+
boolean: {
|
|
1390
|
+
["eq" /* EQ */]: "boolean",
|
|
1391
|
+
["neq" /* NEQ */]: "boolean",
|
|
1392
|
+
["is_true" /* IS_TRUE */]: null,
|
|
1393
|
+
["is_false" /* IS_FALSE */]: null,
|
|
1394
|
+
["in" /* IN */]: "array",
|
|
1395
|
+
["nin" /* NIN */]: "array",
|
|
1396
|
+
["is_empty" /* IS_EMPTY */]: null,
|
|
1397
|
+
["is_not_empty" /* IS_NOT_EMPTY */]: null
|
|
1398
|
+
},
|
|
1399
|
+
object: {
|
|
1400
|
+
["is_empty" /* IS_EMPTY */]: null,
|
|
1401
|
+
["is_not_empty" /* IS_NOT_EMPTY */]: null
|
|
1402
|
+
},
|
|
1403
|
+
array: {
|
|
1404
|
+
["is_empty" /* IS_EMPTY */]: null,
|
|
1405
|
+
["is_not_empty" /* IS_NOT_EMPTY */]: null
|
|
1406
|
+
},
|
|
1407
|
+
map: {
|
|
1408
|
+
["is_empty" /* IS_EMPTY */]: null,
|
|
1409
|
+
["is_not_empty" /* IS_NOT_EMPTY */]: null
|
|
1410
|
+
}
|
|
1411
|
+
};
|
|
1412
|
+
var opConfigs = {
|
|
1413
|
+
["eq" /* EQ */]: {
|
|
1414
|
+
label: "Equal",
|
|
1415
|
+
abbreviation: "="
|
|
1416
|
+
},
|
|
1417
|
+
["neq" /* NEQ */]: {
|
|
1418
|
+
label: "Not Equal",
|
|
1419
|
+
abbreviation: "\u2260"
|
|
1420
|
+
},
|
|
1421
|
+
["gt" /* GT */]: {
|
|
1422
|
+
label: "Greater Than",
|
|
1423
|
+
abbreviation: ">"
|
|
1424
|
+
},
|
|
1425
|
+
["gte" /* GTE */]: {
|
|
1426
|
+
label: "Greater Than or Equal",
|
|
1427
|
+
abbreviation: ">="
|
|
1428
|
+
},
|
|
1429
|
+
["lt" /* LT */]: {
|
|
1430
|
+
label: "Less Than",
|
|
1431
|
+
abbreviation: "<"
|
|
1432
|
+
},
|
|
1433
|
+
["lte" /* LTE */]: {
|
|
1434
|
+
label: "Less Than or Equal",
|
|
1435
|
+
abbreviation: "<="
|
|
1436
|
+
},
|
|
1437
|
+
["in" /* IN */]: {
|
|
1438
|
+
label: "In",
|
|
1439
|
+
abbreviation: "\u2208"
|
|
1440
|
+
},
|
|
1441
|
+
["nin" /* NIN */]: {
|
|
1442
|
+
label: "Not In",
|
|
1443
|
+
abbreviation: "\u2209"
|
|
1444
|
+
},
|
|
1445
|
+
["contains" /* CONTAINS */]: {
|
|
1446
|
+
label: "Contains",
|
|
1447
|
+
abbreviation: "\u2287"
|
|
1448
|
+
},
|
|
1449
|
+
["not_contains" /* NOT_CONTAINS */]: {
|
|
1450
|
+
label: "Not Contains",
|
|
1451
|
+
abbreviation: "\u2289"
|
|
1452
|
+
},
|
|
1453
|
+
["is_empty" /* IS_EMPTY */]: {
|
|
1454
|
+
label: "Is Empty",
|
|
1455
|
+
abbreviation: "=",
|
|
1456
|
+
rightDisplay: "Empty"
|
|
1457
|
+
},
|
|
1458
|
+
["is_not_empty" /* IS_NOT_EMPTY */]: {
|
|
1459
|
+
label: "Is Not Empty",
|
|
1460
|
+
abbreviation: "\u2260",
|
|
1461
|
+
rightDisplay: "Empty"
|
|
1462
|
+
},
|
|
1463
|
+
["is_true" /* IS_TRUE */]: {
|
|
1464
|
+
label: "Is True",
|
|
1465
|
+
abbreviation: "=",
|
|
1466
|
+
rightDisplay: "True"
|
|
1467
|
+
},
|
|
1468
|
+
["is_false" /* IS_FALSE */]: {
|
|
1469
|
+
label: "Is False",
|
|
1470
|
+
abbreviation: "=",
|
|
1471
|
+
rightDisplay: "False"
|
|
1472
|
+
}
|
|
1473
|
+
};
|
|
1237
1474
|
|
|
1238
1475
|
// src/utils/format-legacy-refs/index.ts
|
|
1239
|
-
var
|
|
1476
|
+
var import_lodash2 = require("lodash");
|
|
1240
1477
|
function formatLegacyRefOnSubmit(value) {
|
|
1241
|
-
if ((0,
|
|
1478
|
+
if ((0, import_lodash2.isObject)(value)) {
|
|
1242
1479
|
if (isLegacyFlowRefValueSchema(value)) {
|
|
1243
1480
|
return formatLegacyRefToNewRef(value);
|
|
1244
1481
|
}
|
|
@@ -1255,7 +1492,7 @@ function formatLegacyRefOnSubmit(value) {
|
|
|
1255
1492
|
return value;
|
|
1256
1493
|
}
|
|
1257
1494
|
function formatLegacyRefOnInit(value) {
|
|
1258
|
-
if ((0,
|
|
1495
|
+
if ((0, import_lodash2.isObject)(value)) {
|
|
1259
1496
|
if (isNewFlowRefValueSchema(value)) {
|
|
1260
1497
|
return formatNewRefToLegacyRef(value);
|
|
1261
1498
|
}
|
|
@@ -1272,10 +1509,10 @@ function formatLegacyRefOnInit(value) {
|
|
|
1272
1509
|
return value;
|
|
1273
1510
|
}
|
|
1274
1511
|
function isLegacyFlowRefValueSchema(value) {
|
|
1275
|
-
return (0,
|
|
1512
|
+
return (0, import_lodash2.isObject)(value) && Object.keys(value).length === 2 && value.type === "ref" && typeof value.content === "string";
|
|
1276
1513
|
}
|
|
1277
1514
|
function isNewFlowRefValueSchema(value) {
|
|
1278
|
-
return (0,
|
|
1515
|
+
return (0, import_lodash2.isObject)(value) && Object.keys(value).length === 2 && value.type === "ref" && Array.isArray(value.content);
|
|
1279
1516
|
}
|
|
1280
1517
|
function formatLegacyRefToNewRef(value) {
|
|
1281
1518
|
const keyPath = value.content.split(".");
|
|
@@ -1296,16 +1533,216 @@ function formatNewRefToLegacyRef(value) {
|
|
|
1296
1533
|
content: value.content.join(".")
|
|
1297
1534
|
};
|
|
1298
1535
|
}
|
|
1536
|
+
|
|
1537
|
+
// src/components/condition-row/hooks/useRule.ts
|
|
1538
|
+
function useRule(left) {
|
|
1539
|
+
const available = (0, import_editor4.useScopeAvailable)();
|
|
1540
|
+
const variable = (0, import_react12.useMemo)(() => {
|
|
1541
|
+
if (!left) return void 0;
|
|
1542
|
+
return available.getByKeyPath(left.content);
|
|
1543
|
+
}, [available, left]);
|
|
1544
|
+
const rule = (0, import_react12.useMemo)(() => {
|
|
1545
|
+
if (!variable) return void 0;
|
|
1546
|
+
const schema = JsonSchemaUtils.astToSchema(variable.type, { drilldown: false });
|
|
1547
|
+
return rules[schema?.type];
|
|
1548
|
+
}, [variable?.type]);
|
|
1549
|
+
return { rule };
|
|
1550
|
+
}
|
|
1551
|
+
|
|
1552
|
+
// src/components/condition-row/hooks/useOp.tsx
|
|
1553
|
+
var import_react13 = __toESM(require("react"));
|
|
1554
|
+
var import_semi_ui7 = require("@douyinfe/semi-ui");
|
|
1555
|
+
var import_semi_icons6 = require("@douyinfe/semi-icons");
|
|
1556
|
+
function useOp({ rule, op, onChange }) {
|
|
1557
|
+
const options2 = (0, import_react13.useMemo)(
|
|
1558
|
+
() => Object.keys(rule || {}).map((_op) => ({
|
|
1559
|
+
...opConfigs[_op] || {},
|
|
1560
|
+
value: _op
|
|
1561
|
+
})),
|
|
1562
|
+
[rule]
|
|
1563
|
+
);
|
|
1564
|
+
const opConfig = (0, import_react13.useMemo)(() => opConfigs[op], [op]);
|
|
1565
|
+
const renderOpSelect = () => /* @__PURE__ */ import_react13.default.createElement(
|
|
1566
|
+
import_semi_ui7.Select,
|
|
1567
|
+
{
|
|
1568
|
+
style: { height: 22 },
|
|
1569
|
+
size: "small",
|
|
1570
|
+
value: op,
|
|
1571
|
+
optionList: options2,
|
|
1572
|
+
onChange: (v) => {
|
|
1573
|
+
onChange(v);
|
|
1574
|
+
},
|
|
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" }))
|
|
1576
|
+
}
|
|
1577
|
+
);
|
|
1578
|
+
return { renderOpSelect, opConfig };
|
|
1579
|
+
}
|
|
1580
|
+
|
|
1581
|
+
// src/components/condition-row/index.tsx
|
|
1582
|
+
function ConditionRow({ style, value, onChange, readonly }) {
|
|
1583
|
+
const { left, operator, right } = value || {};
|
|
1584
|
+
const { rule } = useRule(left);
|
|
1585
|
+
const { renderOpSelect, opConfig } = useOp({
|
|
1586
|
+
rule,
|
|
1587
|
+
op: operator,
|
|
1588
|
+
onChange: (v) => onChange({ ...value, operator: v })
|
|
1589
|
+
});
|
|
1590
|
+
const targetSchema = (0, import_react14.useMemo)(() => {
|
|
1591
|
+
const targetType = rule?.[operator] || null;
|
|
1592
|
+
return targetType ? { type: targetType, extra: { weak: true } } : null;
|
|
1593
|
+
}, [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(
|
|
1595
|
+
VariableSelector,
|
|
1596
|
+
{
|
|
1597
|
+
readonly,
|
|
1598
|
+
style: { width: "100%" },
|
|
1599
|
+
value: left?.content,
|
|
1600
|
+
onChange: (v) => onChange({
|
|
1601
|
+
...value,
|
|
1602
|
+
left: {
|
|
1603
|
+
type: "ref",
|
|
1604
|
+
content: v
|
|
1605
|
+
}
|
|
1606
|
+
})
|
|
1607
|
+
}
|
|
1608
|
+
)), /* @__PURE__ */ import_react14.default.createElement(UIRight, null, targetSchema ? /* @__PURE__ */ import_react14.default.createElement(
|
|
1609
|
+
DynamicValueInput,
|
|
1610
|
+
{
|
|
1611
|
+
readonly: readonly || !rule,
|
|
1612
|
+
value: right,
|
|
1613
|
+
schema: targetSchema,
|
|
1614
|
+
onChange: (v) => onChange({ ...value, right: v })
|
|
1615
|
+
}
|
|
1616
|
+
) : /* @__PURE__ */ import_react14.default.createElement(import_semi_ui8.Input, { size: "small", disabled: true, value: opConfig?.rightDisplay || "Empty" }))));
|
|
1617
|
+
}
|
|
1618
|
+
|
|
1619
|
+
// src/effects/provide-batch-input/index.ts
|
|
1620
|
+
var import_editor5 = require("@flowgram.ai/editor");
|
|
1621
|
+
var provideBatchInputEffect = (0, import_editor5.createEffectFromVariableProvider)({
|
|
1622
|
+
private: true,
|
|
1623
|
+
parse: (value, ctx) => [
|
|
1624
|
+
import_editor5.ASTFactory.createVariableDeclaration({
|
|
1625
|
+
key: `${ctx.node.id}_locals`,
|
|
1626
|
+
meta: {
|
|
1627
|
+
title: (0, import_editor5.getNodeForm)(ctx.node)?.getValueIn("title"),
|
|
1628
|
+
icon: ctx.node.getNodeRegistry().info?.icon
|
|
1629
|
+
},
|
|
1630
|
+
type: import_editor5.ASTFactory.createObject({
|
|
1631
|
+
properties: [
|
|
1632
|
+
import_editor5.ASTFactory.createProperty({
|
|
1633
|
+
key: "item",
|
|
1634
|
+
initializer: import_editor5.ASTFactory.createEnumerateExpression({
|
|
1635
|
+
enumerateFor: import_editor5.ASTFactory.createKeyPathExpression({
|
|
1636
|
+
keyPath: value.content || []
|
|
1637
|
+
})
|
|
1638
|
+
})
|
|
1639
|
+
}),
|
|
1640
|
+
import_editor5.ASTFactory.createProperty({
|
|
1641
|
+
key: "index",
|
|
1642
|
+
type: import_editor5.ASTFactory.createNumber()
|
|
1643
|
+
})
|
|
1644
|
+
]
|
|
1645
|
+
})
|
|
1646
|
+
})
|
|
1647
|
+
]
|
|
1648
|
+
});
|
|
1649
|
+
|
|
1650
|
+
// src/effects/provide-batch-outputs/index.ts
|
|
1651
|
+
var import_editor6 = require("@flowgram.ai/editor");
|
|
1652
|
+
var provideBatchOutputsEffect = (0, import_editor6.createEffectFromVariableProvider)({
|
|
1653
|
+
private: true,
|
|
1654
|
+
parse: (value, ctx) => [
|
|
1655
|
+
import_editor6.ASTFactory.createVariableDeclaration({
|
|
1656
|
+
key: `${ctx.node.id}`,
|
|
1657
|
+
meta: {
|
|
1658
|
+
title: (0, import_editor6.getNodeForm)(ctx.node)?.getValueIn("title"),
|
|
1659
|
+
icon: ctx.node.getNodeRegistry().info?.icon
|
|
1660
|
+
},
|
|
1661
|
+
type: import_editor6.ASTFactory.createObject({
|
|
1662
|
+
properties: Object.entries(value).map(
|
|
1663
|
+
([_key, value2]) => import_editor6.ASTFactory.createProperty({
|
|
1664
|
+
key: _key,
|
|
1665
|
+
initializer: import_editor6.ASTFactory.createWrapArrayExpression({
|
|
1666
|
+
wrapFor: import_editor6.ASTFactory.createKeyPathExpression({
|
|
1667
|
+
keyPath: value2.content || []
|
|
1668
|
+
})
|
|
1669
|
+
})
|
|
1670
|
+
})
|
|
1671
|
+
)
|
|
1672
|
+
})
|
|
1673
|
+
})
|
|
1674
|
+
]
|
|
1675
|
+
});
|
|
1676
|
+
|
|
1677
|
+
// src/effects/auto-rename-ref/index.ts
|
|
1678
|
+
var import_lodash3 = require("lodash");
|
|
1679
|
+
var import_editor7 = require("@flowgram.ai/editor");
|
|
1680
|
+
var autoRenameRefEffect = [
|
|
1681
|
+
{
|
|
1682
|
+
event: import_editor7.DataEvent.onValueInit,
|
|
1683
|
+
effect: (params) => {
|
|
1684
|
+
const { context, form, name } = params;
|
|
1685
|
+
const renameService = context.node.getService(import_editor7.VariableFieldKeyRenameService);
|
|
1686
|
+
const disposable = renameService.onRename(({ before, after }) => {
|
|
1687
|
+
const beforeKeyPath = [
|
|
1688
|
+
...before.parentFields.map((_field) => _field.key).reverse(),
|
|
1689
|
+
before.key
|
|
1690
|
+
];
|
|
1691
|
+
const afterKeyPath = [
|
|
1692
|
+
...after.parentFields.map((_field) => _field.key).reverse(),
|
|
1693
|
+
after.key
|
|
1694
|
+
];
|
|
1695
|
+
traverseRef(name, form.getValueIn(name), (_drilldownName, _v) => {
|
|
1696
|
+
if (isRefMatch(_v, beforeKeyPath)) {
|
|
1697
|
+
_v.content = [...afterKeyPath, ...(_v.content || [])?.slice(beforeKeyPath.length)];
|
|
1698
|
+
form.setValueIn(_drilldownName, _v);
|
|
1699
|
+
}
|
|
1700
|
+
});
|
|
1701
|
+
});
|
|
1702
|
+
return () => {
|
|
1703
|
+
disposable.dispose();
|
|
1704
|
+
};
|
|
1705
|
+
}
|
|
1706
|
+
}
|
|
1707
|
+
];
|
|
1708
|
+
function isRefMatch(value, targetKeyPath) {
|
|
1709
|
+
return targetKeyPath.every((_key, index) => _key === value.content?.[index]);
|
|
1710
|
+
}
|
|
1711
|
+
function isRef(value) {
|
|
1712
|
+
return value?.type === "ref" && Array.isArray(value?.content) && typeof value?.content[0] === "string";
|
|
1713
|
+
}
|
|
1714
|
+
function traverseRef(name, value, cb) {
|
|
1715
|
+
if ((0, import_lodash3.isObject)(value)) {
|
|
1716
|
+
if (isRef(value)) {
|
|
1717
|
+
cb(name, value);
|
|
1718
|
+
return;
|
|
1719
|
+
}
|
|
1720
|
+
Object.entries(value).forEach(([_key, _value]) => {
|
|
1721
|
+
traverseRef(`${name}.${_key}`, _value, cb);
|
|
1722
|
+
});
|
|
1723
|
+
return;
|
|
1724
|
+
}
|
|
1725
|
+
if ((0, import_lodash3.isArray)(value)) {
|
|
1726
|
+
value.forEach((_value, idx) => {
|
|
1727
|
+
traverseRef(`${name}[${idx}]`, _value, cb);
|
|
1728
|
+
});
|
|
1729
|
+
return;
|
|
1730
|
+
}
|
|
1731
|
+
return;
|
|
1732
|
+
}
|
|
1299
1733
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1300
1734
|
0 && (module.exports = {
|
|
1301
1735
|
ArrayIcons,
|
|
1302
1736
|
BatchVariableSelector,
|
|
1737
|
+
ConditionRow,
|
|
1303
1738
|
ConstantInput,
|
|
1304
1739
|
DynamicValueInput,
|
|
1305
1740
|
JsonSchemaEditor,
|
|
1741
|
+
JsonSchemaUtils,
|
|
1306
1742
|
TypeSelector,
|
|
1307
1743
|
VariableSelector,
|
|
1308
1744
|
VariableTypeIcons,
|
|
1745
|
+
autoRenameRefEffect,
|
|
1309
1746
|
formatLegacyRefOnInit,
|
|
1310
1747
|
formatLegacyRefOnSubmit,
|
|
1311
1748
|
formatLegacyRefToNewRef,
|