@flowgram.ai/form-materials 0.1.31 → 0.2.0
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/bin/materials.js +21 -5
- package/dist/esm/index.js +453 -50
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.mts +161 -29
- package/dist/index.d.ts +161 -29
- package/dist/index.js +463 -54
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/src/components/batch-variable-selector/config.json +5 -0
- package/src/components/batch-variable-selector/index.tsx +18 -0
- package/src/components/constant-input/config.json +6 -0
- package/src/components/constant-input/index.tsx +81 -0
- package/src/components/constant-input/types.ts +18 -0
- package/src/components/dynamic-value-input/config.json +5 -0
- package/src/components/dynamic-value-input/index.tsx +77 -0
- package/src/components/dynamic-value-input/styles.tsx +19 -0
- package/src/components/index.ts +6 -3
- package/src/components/json-schema-editor/hooks.tsx +33 -22
- package/src/components/type-selector/index.tsx +5 -2
- package/src/components/type-selector/types.ts +4 -18
- package/src/components/variable-selector/config.json +1 -1
- package/src/components/variable-selector/index.tsx +76 -16
- package/src/components/variable-selector/styles.tsx +43 -0
- package/src/components/variable-selector/use-variable-tree.tsx +29 -7
- package/src/effects/index.ts +2 -0
- package/src/effects/provide-batch-input/config.json +5 -0
- package/src/effects/provide-batch-input/index.ts +38 -0
- package/src/effects/provide-batch-outputs/config.json +5 -0
- package/src/effects/provide-batch-outputs/index.ts +34 -0
- package/src/index.ts +3 -0
- package/src/typings/flow-value/config.json +5 -0
- package/src/typings/flow-value/index.ts +27 -0
- package/src/typings/index.ts +1 -0
- package/src/utils/format-legacy-refs/config.json +5 -0
- package/src/utils/format-legacy-refs/index.ts +153 -0
- package/src/utils/format-legacy-refs/readme.md +38 -0
- package/src/utils/index.ts +1 -0
package/dist/index.js
CHANGED
|
@@ -31,16 +31,30 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
31
31
|
var src_exports = {};
|
|
32
32
|
__export(src_exports, {
|
|
33
33
|
ArrayIcons: () => ArrayIcons,
|
|
34
|
+
BatchVariableSelector: () => BatchVariableSelector,
|
|
35
|
+
ConstantInput: () => ConstantInput,
|
|
36
|
+
DynamicValueInput: () => DynamicValueInput,
|
|
34
37
|
JsonSchemaEditor: () => JsonSchemaEditor,
|
|
35
38
|
TypeSelector: () => TypeSelector,
|
|
36
39
|
VariableSelector: () => VariableSelector,
|
|
37
|
-
VariableTypeIcons: () => VariableTypeIcons
|
|
40
|
+
VariableTypeIcons: () => VariableTypeIcons,
|
|
41
|
+
formatLegacyRefOnInit: () => formatLegacyRefOnInit,
|
|
42
|
+
formatLegacyRefOnSubmit: () => formatLegacyRefOnSubmit,
|
|
43
|
+
formatLegacyRefToNewRef: () => formatLegacyRefToNewRef,
|
|
44
|
+
formatNewRefToLegacyRef: () => formatNewRefToLegacyRef,
|
|
45
|
+
getSchemaIcon: () => getSchemaIcon,
|
|
46
|
+
getTypeSelectValue: () => getTypeSelectValue,
|
|
47
|
+
isLegacyFlowRefValueSchema: () => isLegacyFlowRefValueSchema,
|
|
48
|
+
isNewFlowRefValueSchema: () => isNewFlowRefValueSchema,
|
|
49
|
+
parseTypeSelectValue: () => parseTypeSelectValue,
|
|
50
|
+
provideBatchInputEffect: () => provideBatchInputEffect,
|
|
51
|
+
provideBatchOutputsEffect: () => provideBatchOutputsEffect
|
|
38
52
|
});
|
|
39
53
|
module.exports = __toCommonJS(src_exports);
|
|
40
54
|
|
|
41
55
|
// src/components/variable-selector/index.tsx
|
|
42
56
|
var import_react3 = __toESM(require("react"));
|
|
43
|
-
var
|
|
57
|
+
var import_semi_icons2 = require("@douyinfe/semi-icons");
|
|
44
58
|
|
|
45
59
|
// src/components/variable-selector/use-variable-tree.tsx
|
|
46
60
|
var import_react2 = __toESM(require("react"));
|
|
@@ -437,10 +451,11 @@ var options = [
|
|
|
437
451
|
];
|
|
438
452
|
|
|
439
453
|
// src/components/variable-selector/use-variable-tree.tsx
|
|
440
|
-
function useVariableTree() {
|
|
454
|
+
function useVariableTree(params) {
|
|
455
|
+
const { includeSchema, excludeSchema } = params;
|
|
441
456
|
const available = (0, import_editor.useScopeAvailable)();
|
|
442
457
|
const getVariableTypeIcon = (0, import_react2.useCallback)((variable) => {
|
|
443
|
-
if (variable.meta
|
|
458
|
+
if (variable.meta?.icon) {
|
|
444
459
|
if (typeof variable.meta.icon === "string") {
|
|
445
460
|
return /* @__PURE__ */ import_react2.default.createElement("img", { style: { marginRight: 8 }, width: 12, height: 12, src: variable.meta.icon });
|
|
446
461
|
}
|
|
@@ -463,6 +478,9 @@ function useVariableTree() {
|
|
|
463
478
|
}, []);
|
|
464
479
|
const renderVariable = (variable, parentFields = []) => {
|
|
465
480
|
let type = variable?.type;
|
|
481
|
+
if (!type) {
|
|
482
|
+
return null;
|
|
483
|
+
}
|
|
466
484
|
let children;
|
|
467
485
|
if (import_editor.ASTMatch.isObject(type)) {
|
|
468
486
|
children = (type.properties || []).map((_property) => renderVariable(_property, [...parentFields, variable])).filter(Boolean);
|
|
@@ -470,18 +488,70 @@ function useVariableTree() {
|
|
|
470
488
|
return null;
|
|
471
489
|
}
|
|
472
490
|
}
|
|
473
|
-
const
|
|
491
|
+
const keyPath = [...parentFields.map((_field) => _field.key), variable.key];
|
|
492
|
+
const key = keyPath.join(".");
|
|
493
|
+
const isSchemaInclude = includeSchema ? type.isEqualWithJSONSchema(includeSchema) : true;
|
|
494
|
+
const isSchemaExclude = excludeSchema ? type.isEqualWithJSONSchema(excludeSchema) : false;
|
|
495
|
+
const isSchemaMatch = isSchemaInclude && !isSchemaExclude;
|
|
496
|
+
if (!isSchemaMatch && !children?.length) {
|
|
497
|
+
return null;
|
|
498
|
+
}
|
|
474
499
|
return {
|
|
475
|
-
key
|
|
476
|
-
label: variable.meta
|
|
477
|
-
value:
|
|
500
|
+
key,
|
|
501
|
+
label: variable.meta?.title || variable.key,
|
|
502
|
+
value: key,
|
|
503
|
+
keyPath,
|
|
478
504
|
icon: getVariableTypeIcon(variable),
|
|
479
|
-
children
|
|
505
|
+
children,
|
|
506
|
+
disabled: !isSchemaMatch,
|
|
507
|
+
rootMeta: parentFields[0]?.meta
|
|
480
508
|
};
|
|
481
509
|
};
|
|
482
510
|
return [...available.variables.slice(0).reverse()].map((_variable) => renderVariable(_variable)).filter(Boolean);
|
|
483
511
|
}
|
|
484
512
|
|
|
513
|
+
// src/components/variable-selector/styles.tsx
|
|
514
|
+
var import_styled_components = __toESM(require("styled-components"));
|
|
515
|
+
var import_semi_ui2 = require("@douyinfe/semi-ui");
|
|
516
|
+
var UIRootTitle = import_styled_components.default.span`
|
|
517
|
+
margin-right: 4px;
|
|
518
|
+
color: var(--semi-color-text-2);
|
|
519
|
+
`;
|
|
520
|
+
var UITag = (0, import_styled_components.default)(import_semi_ui2.Tag)`
|
|
521
|
+
width: 100%;
|
|
522
|
+
display: flex;
|
|
523
|
+
align-items: center;
|
|
524
|
+
justify-content: flex-start;
|
|
525
|
+
|
|
526
|
+
& .semi-tag-content-center {
|
|
527
|
+
justify-content: flex-start;
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
&.semi-tag {
|
|
531
|
+
margin: 0;
|
|
532
|
+
}
|
|
533
|
+
`;
|
|
534
|
+
var UITreeSelect = (0, import_styled_components.default)(import_semi_ui2.TreeSelect)`
|
|
535
|
+
outline: ${({ $error }) => $error ? "1px solid red" : "none"};
|
|
536
|
+
|
|
537
|
+
height: 22px;
|
|
538
|
+
min-height: 22px;
|
|
539
|
+
line-height: 22px;
|
|
540
|
+
|
|
541
|
+
& .semi-tree-select-selection {
|
|
542
|
+
padding: 0 2px;
|
|
543
|
+
height: 22px;
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
& .semi-tree-select-selection-content {
|
|
547
|
+
width: 100%;
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
& .semi-tree-select-selection-placeholder {
|
|
551
|
+
padding-left: 10px;
|
|
552
|
+
}
|
|
553
|
+
`;
|
|
554
|
+
|
|
485
555
|
// src/components/variable-selector/index.tsx
|
|
486
556
|
var VariableSelector = ({
|
|
487
557
|
value,
|
|
@@ -489,26 +559,70 @@ var VariableSelector = ({
|
|
|
489
559
|
onChange,
|
|
490
560
|
style,
|
|
491
561
|
readonly = false,
|
|
492
|
-
|
|
562
|
+
includeSchema,
|
|
563
|
+
excludeSchema,
|
|
564
|
+
hasError,
|
|
565
|
+
triggerRender
|
|
493
566
|
}) => {
|
|
494
|
-
const treeData = useVariableTree();
|
|
567
|
+
const treeData = useVariableTree({ includeSchema, excludeSchema });
|
|
568
|
+
const treeValue = (0, import_react3.useMemo)(() => {
|
|
569
|
+
if (typeof value === "string") {
|
|
570
|
+
console.warn(
|
|
571
|
+
"The Value of VariableSelector is a string, it should be an ARRAY. \n",
|
|
572
|
+
"Please check the value of VariableSelector \n"
|
|
573
|
+
);
|
|
574
|
+
return value;
|
|
575
|
+
}
|
|
576
|
+
return value?.join(".");
|
|
577
|
+
}, [value]);
|
|
578
|
+
const renderIcon = (icon) => {
|
|
579
|
+
if (typeof icon === "string") {
|
|
580
|
+
return /* @__PURE__ */ import_react3.default.createElement("img", { style: { marginRight: 8 }, width: 12, height: 12, src: icon });
|
|
581
|
+
}
|
|
582
|
+
return icon;
|
|
583
|
+
};
|
|
495
584
|
return /* @__PURE__ */ import_react3.default.createElement(import_react3.default.Fragment, null, /* @__PURE__ */ import_react3.default.createElement(
|
|
496
|
-
|
|
585
|
+
UITreeSelect,
|
|
497
586
|
{
|
|
498
587
|
dropdownMatchSelectWidth: false,
|
|
499
588
|
disabled: readonly,
|
|
500
589
|
treeData,
|
|
501
590
|
size: "small",
|
|
502
|
-
value,
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
},
|
|
591
|
+
value: treeValue,
|
|
592
|
+
clearIcon: null,
|
|
593
|
+
$error: hasError,
|
|
594
|
+
style,
|
|
507
595
|
validateStatus: hasError ? "error" : void 0,
|
|
508
|
-
onChange: (
|
|
509
|
-
onChange(
|
|
596
|
+
onChange: (_, _config) => {
|
|
597
|
+
onChange(_config.keyPath);
|
|
598
|
+
},
|
|
599
|
+
renderSelectedItem: (_option) => {
|
|
600
|
+
if (!_option?.keyPath) {
|
|
601
|
+
return /* @__PURE__ */ import_react3.default.createElement(
|
|
602
|
+
UITag,
|
|
603
|
+
{
|
|
604
|
+
prefixIcon: /* @__PURE__ */ import_react3.default.createElement(import_semi_icons2.IconIssueStroked, null),
|
|
605
|
+
color: "amber",
|
|
606
|
+
closable: !readonly,
|
|
607
|
+
onClose: () => onChange(void 0)
|
|
608
|
+
},
|
|
609
|
+
config?.notFoundContent ?? "Undefined"
|
|
610
|
+
);
|
|
611
|
+
}
|
|
612
|
+
return /* @__PURE__ */ import_react3.default.createElement(
|
|
613
|
+
UITag,
|
|
614
|
+
{
|
|
615
|
+
prefixIcon: renderIcon(_option.rootMeta?.icon || _option?.icon),
|
|
616
|
+
closable: !readonly,
|
|
617
|
+
onClose: () => onChange(void 0)
|
|
618
|
+
},
|
|
619
|
+
/* @__PURE__ */ import_react3.default.createElement(UIRootTitle, null, _option.rootMeta?.title ? `${_option.rootMeta?.title} -` : null),
|
|
620
|
+
_option.label
|
|
621
|
+
);
|
|
510
622
|
},
|
|
511
|
-
showClear:
|
|
623
|
+
showClear: false,
|
|
624
|
+
arrowIcon: value ? null : /* @__PURE__ */ import_react3.default.createElement(import_semi_icons2.IconChevronDownStroked, { size: "small" }),
|
|
625
|
+
triggerRender,
|
|
512
626
|
placeholder: config?.placeholder ?? "Select Variable..."
|
|
513
627
|
}
|
|
514
628
|
));
|
|
@@ -531,13 +645,14 @@ var parseTypeSelectValue = (value) => {
|
|
|
531
645
|
return { type };
|
|
532
646
|
};
|
|
533
647
|
function TypeSelector(props) {
|
|
534
|
-
const { value, onChange } = props;
|
|
648
|
+
const { value, onChange, disabled, style } = props;
|
|
535
649
|
const selectValue = (0, import_react4.useMemo)(() => getTypeSelectValue(value), [value]);
|
|
536
650
|
return /* @__PURE__ */ import_react4.default.createElement(
|
|
537
651
|
import_semi_ui3.Cascader,
|
|
538
652
|
{
|
|
653
|
+
disabled,
|
|
539
654
|
size: "small",
|
|
540
|
-
triggerRender: () => /* @__PURE__ */ import_react4.default.createElement(import_semi_ui3.Button, { size: "small", style
|
|
655
|
+
triggerRender: () => /* @__PURE__ */ import_react4.default.createElement(import_semi_ui3.Button, { size: "small", style }, getSchemaIcon(value)),
|
|
541
656
|
treeData: options,
|
|
542
657
|
value: selectValue,
|
|
543
658
|
leafOnly: true,
|
|
@@ -551,52 +666,52 @@ function TypeSelector(props) {
|
|
|
551
666
|
// src/components/json-schema-editor/index.tsx
|
|
552
667
|
var import_react7 = __toESM(require("react"));
|
|
553
668
|
var import_semi_ui4 = require("@douyinfe/semi-ui");
|
|
554
|
-
var
|
|
669
|
+
var import_semi_icons4 = require("@douyinfe/semi-icons");
|
|
555
670
|
|
|
556
671
|
// src/components/json-schema-editor/styles.tsx
|
|
557
672
|
var import_react5 = __toESM(require("react"));
|
|
558
|
-
var
|
|
559
|
-
var
|
|
560
|
-
var UIContainer =
|
|
673
|
+
var import_styled_components2 = __toESM(require("styled-components"));
|
|
674
|
+
var import_semi_icons3 = __toESM(require("@douyinfe/semi-icons"));
|
|
675
|
+
var UIContainer = import_styled_components2.default.div`
|
|
561
676
|
/* & .semi-input {
|
|
562
677
|
background-color: #fff;
|
|
563
678
|
border-radius: 6px;
|
|
564
679
|
height: 24px;
|
|
565
680
|
} */
|
|
566
681
|
`;
|
|
567
|
-
var UIRow =
|
|
682
|
+
var UIRow = import_styled_components2.default.div`
|
|
568
683
|
display: flex;
|
|
569
684
|
align-items: center;
|
|
570
685
|
gap: 6px;
|
|
571
686
|
`;
|
|
572
|
-
var UICollapseTrigger =
|
|
687
|
+
var UICollapseTrigger = import_styled_components2.default.div`
|
|
573
688
|
cursor: pointer;
|
|
574
689
|
margin-right: 5px;
|
|
575
690
|
`;
|
|
576
|
-
var UIExpandDetail =
|
|
691
|
+
var UIExpandDetail = import_styled_components2.default.div`
|
|
577
692
|
display: flex;
|
|
578
693
|
flex-direction: column;
|
|
579
694
|
`;
|
|
580
|
-
var UILabel =
|
|
695
|
+
var UILabel = import_styled_components2.default.div`
|
|
581
696
|
font-size: 12px;
|
|
582
697
|
color: #999;
|
|
583
698
|
font-weight: 400;
|
|
584
699
|
margin-bottom: 2px;
|
|
585
700
|
`;
|
|
586
|
-
var UIProperties =
|
|
701
|
+
var UIProperties = import_styled_components2.default.div`
|
|
587
702
|
display: grid;
|
|
588
703
|
grid-template-columns: auto 1fr;
|
|
589
704
|
|
|
590
|
-
${({ $shrink }) => $shrink &&
|
|
705
|
+
${({ $shrink }) => $shrink && import_styled_components2.css`
|
|
591
706
|
padding-left: 10px;
|
|
592
707
|
margin-top: 10px;
|
|
593
708
|
`}
|
|
594
709
|
`;
|
|
595
|
-
var UIPropertyLeft =
|
|
710
|
+
var UIPropertyLeft = import_styled_components2.default.div`
|
|
596
711
|
grid-column: 1;
|
|
597
712
|
position: relative;
|
|
598
713
|
|
|
599
|
-
${({ $showLine, $isLast }) => $showLine &&
|
|
714
|
+
${({ $showLine, $isLast }) => $showLine && import_styled_components2.css`
|
|
600
715
|
&::before {
|
|
601
716
|
/* 竖线 */
|
|
602
717
|
content: '';
|
|
@@ -622,7 +737,7 @@ var UIPropertyLeft = import_styled_components.default.div`
|
|
|
622
737
|
}
|
|
623
738
|
`}
|
|
624
739
|
`;
|
|
625
|
-
var UIPropertyRight =
|
|
740
|
+
var UIPropertyRight = import_styled_components2.default.div`
|
|
626
741
|
grid-column: 2;
|
|
627
742
|
margin-bottom: 10px;
|
|
628
743
|
|
|
@@ -630,30 +745,30 @@ var UIPropertyRight = import_styled_components.default.div`
|
|
|
630
745
|
margin-bottom: 0px;
|
|
631
746
|
}
|
|
632
747
|
`;
|
|
633
|
-
var UIPropertyMain =
|
|
748
|
+
var UIPropertyMain = import_styled_components2.default.div`
|
|
634
749
|
display: flex;
|
|
635
750
|
flex-direction: column;
|
|
636
751
|
gap: 10px;
|
|
637
752
|
|
|
638
|
-
${({ $expand }) => $expand &&
|
|
753
|
+
${({ $expand }) => $expand && import_styled_components2.css`
|
|
639
754
|
background-color: #f5f5f5;
|
|
640
755
|
padding: 10px;
|
|
641
756
|
border-radius: 4px;
|
|
642
757
|
`}
|
|
643
758
|
`;
|
|
644
|
-
var UICollapsible =
|
|
759
|
+
var UICollapsible = import_styled_components2.default.div`
|
|
645
760
|
display: none;
|
|
646
761
|
|
|
647
|
-
${({ $collapse }) => $collapse &&
|
|
762
|
+
${({ $collapse }) => $collapse && import_styled_components2.css`
|
|
648
763
|
display: block;
|
|
649
764
|
`}
|
|
650
765
|
`;
|
|
651
|
-
var UIName =
|
|
766
|
+
var UIName = import_styled_components2.default.div`
|
|
652
767
|
flex-grow: 1;
|
|
653
768
|
`;
|
|
654
|
-
var UIType =
|
|
655
|
-
var UIRequired =
|
|
656
|
-
var UIActions =
|
|
769
|
+
var UIType = import_styled_components2.default.div``;
|
|
770
|
+
var UIRequired = import_styled_components2.default.div``;
|
|
771
|
+
var UIActions = import_styled_components2.default.div`
|
|
657
772
|
white-space: nowrap;
|
|
658
773
|
`;
|
|
659
774
|
var iconAddChildrenSvg = /* @__PURE__ */ import_react5.default.createElement(
|
|
@@ -676,7 +791,7 @@ var iconAddChildrenSvg = /* @__PURE__ */ import_react5.default.createElement(
|
|
|
676
791
|
),
|
|
677
792
|
/* @__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" })
|
|
678
793
|
);
|
|
679
|
-
var IconAddChildren = () => /* @__PURE__ */ import_react5.default.createElement(
|
|
794
|
+
var IconAddChildren = () => /* @__PURE__ */ import_react5.default.createElement(import_semi_icons3.default, { size: "small", svg: iconAddChildrenSvg });
|
|
680
795
|
|
|
681
796
|
// src/components/json-schema-editor/hooks.tsx
|
|
682
797
|
var import_react6 = require("react");
|
|
@@ -697,12 +812,16 @@ function usePropertiesEdit(value, onChange) {
|
|
|
697
812
|
const drilldown = (0, import_react6.useMemo)(() => getDrilldownSchema(value), [value, value?.type, value?.items]);
|
|
698
813
|
const isDrilldownObject = drilldown.schema?.type === "object";
|
|
699
814
|
const initPropertyList = (0, import_react6.useMemo)(
|
|
700
|
-
() => isDrilldownObject ? Object.entries(drilldown.schema?.properties || {}).map(
|
|
701
|
-
([name, _value]) => ({
|
|
815
|
+
() => isDrilldownObject ? Object.entries(drilldown.schema?.properties || {}).sort(([, a], [, b]) => (a.extra?.index ?? 0) - (b.extra?.index ?? 0)).map(
|
|
816
|
+
([name, _value], index) => ({
|
|
702
817
|
key: genId(),
|
|
703
818
|
name,
|
|
704
819
|
isPropertyRequired: drilldown.schema?.required?.includes(name) || false,
|
|
705
|
-
..._value
|
|
820
|
+
..._value,
|
|
821
|
+
extra: {
|
|
822
|
+
..._value.extra || {},
|
|
823
|
+
index
|
|
824
|
+
}
|
|
706
825
|
})
|
|
707
826
|
) : [],
|
|
708
827
|
[isDrilldownObject]
|
|
@@ -718,7 +837,7 @@ function usePropertiesEdit(value, onChange) {
|
|
|
718
837
|
nameMap.set(_property.name, _property);
|
|
719
838
|
}
|
|
720
839
|
}
|
|
721
|
-
return Object.entries(drilldown.schema?.properties || {}).map(([name, _value]) => {
|
|
840
|
+
return Object.entries(drilldown.schema?.properties || {}).sort(([, a], [, b]) => (a.extra?.index ?? 0) - (b.extra?.index ?? 0)).map(([name, _value]) => {
|
|
722
841
|
const _property = nameMap.get(name);
|
|
723
842
|
if (_property) {
|
|
724
843
|
return {
|
|
@@ -764,7 +883,10 @@ function usePropertiesEdit(value, onChange) {
|
|
|
764
883
|
});
|
|
765
884
|
};
|
|
766
885
|
const onAddProperty = () => {
|
|
767
|
-
updatePropertyList((_list) => [
|
|
886
|
+
updatePropertyList((_list) => [
|
|
887
|
+
..._list,
|
|
888
|
+
{ key: genId(), name: "", type: "string", extra: { index: _list.length + 1 } }
|
|
889
|
+
]);
|
|
768
890
|
};
|
|
769
891
|
const onRemoveProperty = (key) => {
|
|
770
892
|
updatePropertyList((_list) => _list.filter((_property) => _property.key !== key));
|
|
@@ -808,7 +930,7 @@ function JsonSchemaEditor(props) {
|
|
|
808
930
|
onRemoveProperty(_property.key);
|
|
809
931
|
}
|
|
810
932
|
}
|
|
811
|
-
))), /* @__PURE__ */ import_react7.default.createElement(import_semi_ui4.Button, { size: "small", style: { marginTop: 10 }, icon: /* @__PURE__ */ import_react7.default.createElement(
|
|
933
|
+
))), /* @__PURE__ */ import_react7.default.createElement(import_semi_ui4.Button, { size: "small", style: { marginTop: 10 }, icon: /* @__PURE__ */ import_react7.default.createElement(import_semi_icons4.IconPlus, null), onClick: onAddProperty }, config?.addButtonText ?? "Add"));
|
|
812
934
|
}
|
|
813
935
|
function PropertyEdit(props) {
|
|
814
936
|
const { value, config, onChange: onChangeProps, onRemove, $isLast, $showLine } = props;
|
|
@@ -824,7 +946,7 @@ function PropertyEdit(props) {
|
|
|
824
946
|
});
|
|
825
947
|
};
|
|
826
948
|
const showCollapse = isDrilldownObject && propertyList.length > 0;
|
|
827
|
-
return /* @__PURE__ */ import_react7.default.createElement(import_react7.default.Fragment, null, /* @__PURE__ */ import_react7.default.createElement(UIPropertyLeft, { $isLast, $showLine }, showCollapse && /* @__PURE__ */ import_react7.default.createElement(UICollapseTrigger, { onClick: () => setCollapse((_collapse) => !_collapse) }, collapse ? /* @__PURE__ */ import_react7.default.createElement(
|
|
949
|
+
return /* @__PURE__ */ import_react7.default.createElement(import_react7.default.Fragment, null, /* @__PURE__ */ import_react7.default.createElement(UIPropertyLeft, { $isLast, $showLine }, showCollapse && /* @__PURE__ */ import_react7.default.createElement(UICollapseTrigger, { onClick: () => setCollapse((_collapse) => !_collapse) }, collapse ? /* @__PURE__ */ import_react7.default.createElement(import_semi_icons4.IconChevronDown, { size: "small" }) : /* @__PURE__ */ import_react7.default.createElement(import_semi_icons4.IconChevronRight, { size: "small" }))), /* @__PURE__ */ import_react7.default.createElement(UIPropertyRight, null, /* @__PURE__ */ import_react7.default.createElement(UIPropertyMain, { $expand: expand }, /* @__PURE__ */ import_react7.default.createElement(UIRow, null, /* @__PURE__ */ import_react7.default.createElement(UIName, null, /* @__PURE__ */ import_react7.default.createElement(
|
|
828
950
|
import_semi_ui4.Input,
|
|
829
951
|
{
|
|
830
952
|
placeholder: config?.placeholder ?? "Input Variable Name",
|
|
@@ -854,7 +976,7 @@ function PropertyEdit(props) {
|
|
|
854
976
|
{
|
|
855
977
|
size: "small",
|
|
856
978
|
theme: "borderless",
|
|
857
|
-
icon: expand ? /* @__PURE__ */ import_react7.default.createElement(
|
|
979
|
+
icon: expand ? /* @__PURE__ */ import_react7.default.createElement(import_semi_icons4.IconShrink, { size: "small" }) : /* @__PURE__ */ import_react7.default.createElement(import_semi_icons4.IconExpand, { size: "small" }),
|
|
858
980
|
onClick: () => setExpand((_expand) => !_expand)
|
|
859
981
|
}
|
|
860
982
|
), isDrilldownObject && /* @__PURE__ */ import_react7.default.createElement(
|
|
@@ -873,7 +995,7 @@ function PropertyEdit(props) {
|
|
|
873
995
|
{
|
|
874
996
|
size: "small",
|
|
875
997
|
theme: "borderless",
|
|
876
|
-
icon: /* @__PURE__ */ import_react7.default.createElement(
|
|
998
|
+
icon: /* @__PURE__ */ import_react7.default.createElement(import_semi_icons4.IconMinus, { size: "small" }),
|
|
877
999
|
onClick: onRemove
|
|
878
1000
|
}
|
|
879
1001
|
))), expand && /* @__PURE__ */ import_react7.default.createElement(UIExpandDetail, null, /* @__PURE__ */ import_react7.default.createElement(UILabel, null, config?.descTitle ?? "Description"), /* @__PURE__ */ import_react7.default.createElement(
|
|
@@ -901,12 +1023,299 @@ function PropertyEdit(props) {
|
|
|
901
1023
|
}
|
|
902
1024
|
))))));
|
|
903
1025
|
}
|
|
1026
|
+
|
|
1027
|
+
// src/components/batch-variable-selector/index.tsx
|
|
1028
|
+
var import_react8 = __toESM(require("react"));
|
|
1029
|
+
var import_editor2 = require("@flowgram.ai/editor");
|
|
1030
|
+
var batchVariableSchema = {
|
|
1031
|
+
type: "array",
|
|
1032
|
+
extra: { weak: true }
|
|
1033
|
+
};
|
|
1034
|
+
function BatchVariableSelector(props) {
|
|
1035
|
+
return /* @__PURE__ */ import_react8.default.createElement(import_editor2.PrivateScopeProvider, null, /* @__PURE__ */ import_react8.default.createElement(VariableSelector, { ...props, includeSchema: batchVariableSchema }));
|
|
1036
|
+
}
|
|
1037
|
+
|
|
1038
|
+
// src/components/constant-input/index.tsx
|
|
1039
|
+
var import_react9 = __toESM(require("react"));
|
|
1040
|
+
var import_semi_ui5 = require("@douyinfe/semi-ui");
|
|
1041
|
+
var defaultStrategies = [
|
|
1042
|
+
{
|
|
1043
|
+
hit: (schema) => schema?.type === "string",
|
|
1044
|
+
Renderer: (props) => /* @__PURE__ */ import_react9.default.createElement(import_semi_ui5.Input, { placeholder: "Please Input String", size: "small", disabled: props.readonly, ...props })
|
|
1045
|
+
},
|
|
1046
|
+
{
|
|
1047
|
+
hit: (schema) => schema?.type === "number",
|
|
1048
|
+
Renderer: (props) => /* @__PURE__ */ import_react9.default.createElement(
|
|
1049
|
+
import_semi_ui5.InputNumber,
|
|
1050
|
+
{
|
|
1051
|
+
placeholder: "Please Input Number",
|
|
1052
|
+
size: "small",
|
|
1053
|
+
disabled: props.readonly,
|
|
1054
|
+
hideButtons: true,
|
|
1055
|
+
...props
|
|
1056
|
+
}
|
|
1057
|
+
)
|
|
1058
|
+
},
|
|
1059
|
+
{
|
|
1060
|
+
hit: (schema) => schema?.type === "integer",
|
|
1061
|
+
Renderer: (props) => /* @__PURE__ */ import_react9.default.createElement(
|
|
1062
|
+
import_semi_ui5.InputNumber,
|
|
1063
|
+
{
|
|
1064
|
+
placeholder: "Please Input Integer",
|
|
1065
|
+
size: "small",
|
|
1066
|
+
disabled: props.readonly,
|
|
1067
|
+
hideButtons: true,
|
|
1068
|
+
precision: 0,
|
|
1069
|
+
...props
|
|
1070
|
+
}
|
|
1071
|
+
)
|
|
1072
|
+
},
|
|
1073
|
+
{
|
|
1074
|
+
hit: (schema) => schema?.type === "boolean",
|
|
1075
|
+
Renderer: (props) => {
|
|
1076
|
+
const { value, onChange, ...rest } = props;
|
|
1077
|
+
return /* @__PURE__ */ import_react9.default.createElement(
|
|
1078
|
+
import_semi_ui5.Select,
|
|
1079
|
+
{
|
|
1080
|
+
placeholder: "Please Select Boolean",
|
|
1081
|
+
size: "small",
|
|
1082
|
+
disabled: props.readonly,
|
|
1083
|
+
optionList: [
|
|
1084
|
+
{ label: "True", value: 1 },
|
|
1085
|
+
{ label: "False", value: 0 }
|
|
1086
|
+
],
|
|
1087
|
+
value: value ? 1 : 0,
|
|
1088
|
+
onChange: (value2) => onChange?.(!!value2),
|
|
1089
|
+
...rest
|
|
1090
|
+
}
|
|
1091
|
+
);
|
|
1092
|
+
}
|
|
1093
|
+
}
|
|
1094
|
+
];
|
|
1095
|
+
function ConstantInput(props) {
|
|
1096
|
+
const { value, onChange, schema, strategies: extraStrategies, readonly, ...rest } = props;
|
|
1097
|
+
const strategies = (0, import_react9.useMemo)(
|
|
1098
|
+
() => [...defaultStrategies, ...extraStrategies || []],
|
|
1099
|
+
[extraStrategies]
|
|
1100
|
+
);
|
|
1101
|
+
const Renderer = (0, import_react9.useMemo)(() => {
|
|
1102
|
+
const strategy = strategies.find((_strategy) => _strategy.hit(schema));
|
|
1103
|
+
return strategy?.Renderer;
|
|
1104
|
+
}, [strategies, schema]);
|
|
1105
|
+
if (!Renderer) {
|
|
1106
|
+
return /* @__PURE__ */ import_react9.default.createElement(import_semi_ui5.Input, { size: "small", disabled: true, placeholder: "Unsupported type" });
|
|
1107
|
+
}
|
|
1108
|
+
return /* @__PURE__ */ import_react9.default.createElement(Renderer, { value, onChange, readonly, ...rest });
|
|
1109
|
+
}
|
|
1110
|
+
|
|
1111
|
+
// src/components/dynamic-value-input/index.tsx
|
|
1112
|
+
var import_react10 = __toESM(require("react"));
|
|
1113
|
+
var import_semi_ui6 = require("@douyinfe/semi-ui");
|
|
1114
|
+
var import_semi_icons5 = require("@douyinfe/semi-icons");
|
|
1115
|
+
|
|
1116
|
+
// src/components/dynamic-value-input/styles.tsx
|
|
1117
|
+
var import_styled_components3 = __toESM(require("styled-components"));
|
|
1118
|
+
var UIContainer2 = import_styled_components3.default.div`
|
|
1119
|
+
display: flex;
|
|
1120
|
+
align-items: center;
|
|
1121
|
+
gap: 5px;
|
|
1122
|
+
`;
|
|
1123
|
+
var UIMain = import_styled_components3.default.div`
|
|
1124
|
+
flex-grow: 1;
|
|
1125
|
+
|
|
1126
|
+
& .semi-tree-select,
|
|
1127
|
+
& .semi-input-number,
|
|
1128
|
+
& .semi-select {
|
|
1129
|
+
width: 100%;
|
|
1130
|
+
}
|
|
1131
|
+
`;
|
|
1132
|
+
var UITrigger = import_styled_components3.default.div``;
|
|
1133
|
+
|
|
1134
|
+
// src/components/dynamic-value-input/index.tsx
|
|
1135
|
+
function DynamicValueInput({
|
|
1136
|
+
value,
|
|
1137
|
+
onChange,
|
|
1138
|
+
readonly,
|
|
1139
|
+
style,
|
|
1140
|
+
schema,
|
|
1141
|
+
constantProps
|
|
1142
|
+
}) {
|
|
1143
|
+
const renderMain = () => {
|
|
1144
|
+
if (value?.type === "ref") {
|
|
1145
|
+
return /* @__PURE__ */ import_react10.default.createElement(
|
|
1146
|
+
VariableSelector,
|
|
1147
|
+
{
|
|
1148
|
+
value: value?.content,
|
|
1149
|
+
onChange: (_v) => onChange(_v ? { type: "ref", content: _v } : void 0),
|
|
1150
|
+
includeSchema: schema,
|
|
1151
|
+
readonly
|
|
1152
|
+
}
|
|
1153
|
+
);
|
|
1154
|
+
}
|
|
1155
|
+
return /* @__PURE__ */ import_react10.default.createElement(
|
|
1156
|
+
ConstantInput,
|
|
1157
|
+
{
|
|
1158
|
+
value: value?.content,
|
|
1159
|
+
onChange: (_v) => onChange({ type: "constant", content: _v }),
|
|
1160
|
+
schema: schema || { type: "string" },
|
|
1161
|
+
readonly,
|
|
1162
|
+
...constantProps
|
|
1163
|
+
}
|
|
1164
|
+
);
|
|
1165
|
+
};
|
|
1166
|
+
const renderTrigger = () => /* @__PURE__ */ import_react10.default.createElement(
|
|
1167
|
+
VariableSelector,
|
|
1168
|
+
{
|
|
1169
|
+
style: { width: "100%" },
|
|
1170
|
+
value: value?.type === "ref" ? value?.content : void 0,
|
|
1171
|
+
onChange: (_v) => onChange({ type: "ref", content: _v }),
|
|
1172
|
+
includeSchema: schema,
|
|
1173
|
+
readonly,
|
|
1174
|
+
triggerRender: () => /* @__PURE__ */ import_react10.default.createElement(import_semi_ui6.IconButton, { disabled: readonly, size: "small", icon: /* @__PURE__ */ import_react10.default.createElement(import_semi_icons5.IconSetting, { size: "small" }) })
|
|
1175
|
+
}
|
|
1176
|
+
);
|
|
1177
|
+
return /* @__PURE__ */ import_react10.default.createElement(UIContainer2, { style }, /* @__PURE__ */ import_react10.default.createElement(UIMain, null, renderMain()), /* @__PURE__ */ import_react10.default.createElement(UITrigger, null, renderTrigger()));
|
|
1178
|
+
}
|
|
1179
|
+
|
|
1180
|
+
// src/effects/provide-batch-input/index.ts
|
|
1181
|
+
var import_editor3 = require("@flowgram.ai/editor");
|
|
1182
|
+
var provideBatchInputEffect = (0, import_editor3.createEffectFromVariableProvider)({
|
|
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
|
+
});
|
|
1210
|
+
|
|
1211
|
+
// src/effects/provide-batch-outputs/index.ts
|
|
1212
|
+
var import_editor4 = require("@flowgram.ai/editor");
|
|
1213
|
+
var provideBatchOutputsEffect = (0, import_editor4.createEffectFromVariableProvider)({
|
|
1214
|
+
private: true,
|
|
1215
|
+
parse: (value, ctx) => [
|
|
1216
|
+
import_editor4.ASTFactory.createVariableDeclaration({
|
|
1217
|
+
key: `${ctx.node.id}`,
|
|
1218
|
+
meta: {
|
|
1219
|
+
title: (0, import_editor4.getNodeForm)(ctx.node)?.getValueIn("title"),
|
|
1220
|
+
icon: ctx.node.getNodeRegistry().info?.icon
|
|
1221
|
+
},
|
|
1222
|
+
type: import_editor4.ASTFactory.createObject({
|
|
1223
|
+
properties: Object.entries(value).map(
|
|
1224
|
+
([_key, value2]) => import_editor4.ASTFactory.createProperty({
|
|
1225
|
+
key: _key,
|
|
1226
|
+
initializer: import_editor4.ASTFactory.createWrapArrayExpression({
|
|
1227
|
+
wrapFor: import_editor4.ASTFactory.createKeyPathExpression({
|
|
1228
|
+
keyPath: value2.content || []
|
|
1229
|
+
})
|
|
1230
|
+
})
|
|
1231
|
+
})
|
|
1232
|
+
)
|
|
1233
|
+
})
|
|
1234
|
+
})
|
|
1235
|
+
]
|
|
1236
|
+
});
|
|
1237
|
+
|
|
1238
|
+
// src/utils/format-legacy-refs/index.ts
|
|
1239
|
+
var import_lodash = require("lodash");
|
|
1240
|
+
function formatLegacyRefOnSubmit(value) {
|
|
1241
|
+
if ((0, import_lodash.isObject)(value)) {
|
|
1242
|
+
if (isLegacyFlowRefValueSchema(value)) {
|
|
1243
|
+
return formatLegacyRefToNewRef(value);
|
|
1244
|
+
}
|
|
1245
|
+
return Object.fromEntries(
|
|
1246
|
+
Object.entries(value).map(([key, value2]) => [
|
|
1247
|
+
key,
|
|
1248
|
+
formatLegacyRefOnSubmit(value2)
|
|
1249
|
+
])
|
|
1250
|
+
);
|
|
1251
|
+
}
|
|
1252
|
+
if (Array.isArray(value)) {
|
|
1253
|
+
return value.map(formatLegacyRefOnSubmit);
|
|
1254
|
+
}
|
|
1255
|
+
return value;
|
|
1256
|
+
}
|
|
1257
|
+
function formatLegacyRefOnInit(value) {
|
|
1258
|
+
if ((0, import_lodash.isObject)(value)) {
|
|
1259
|
+
if (isNewFlowRefValueSchema(value)) {
|
|
1260
|
+
return formatNewRefToLegacyRef(value);
|
|
1261
|
+
}
|
|
1262
|
+
return Object.fromEntries(
|
|
1263
|
+
Object.entries(value).map(([key, value2]) => [
|
|
1264
|
+
key,
|
|
1265
|
+
formatLegacyRefOnInit(value2)
|
|
1266
|
+
])
|
|
1267
|
+
);
|
|
1268
|
+
}
|
|
1269
|
+
if (Array.isArray(value)) {
|
|
1270
|
+
return value.map(formatLegacyRefOnInit);
|
|
1271
|
+
}
|
|
1272
|
+
return value;
|
|
1273
|
+
}
|
|
1274
|
+
function isLegacyFlowRefValueSchema(value) {
|
|
1275
|
+
return (0, import_lodash.isObject)(value) && Object.keys(value).length === 2 && value.type === "ref" && typeof value.content === "string";
|
|
1276
|
+
}
|
|
1277
|
+
function isNewFlowRefValueSchema(value) {
|
|
1278
|
+
return (0, import_lodash.isObject)(value) && Object.keys(value).length === 2 && value.type === "ref" && Array.isArray(value.content);
|
|
1279
|
+
}
|
|
1280
|
+
function formatLegacyRefToNewRef(value) {
|
|
1281
|
+
const keyPath = value.content.split(".");
|
|
1282
|
+
if (keyPath[1] === "outputs") {
|
|
1283
|
+
return {
|
|
1284
|
+
type: "ref",
|
|
1285
|
+
content: [`${keyPath[0]}.${keyPath[1]}`, ...keyPath.length > 2 ? keyPath.slice(2) : []]
|
|
1286
|
+
};
|
|
1287
|
+
}
|
|
1288
|
+
return {
|
|
1289
|
+
type: "ref",
|
|
1290
|
+
content: keyPath
|
|
1291
|
+
};
|
|
1292
|
+
}
|
|
1293
|
+
function formatNewRefToLegacyRef(value) {
|
|
1294
|
+
return {
|
|
1295
|
+
type: "ref",
|
|
1296
|
+
content: value.content.join(".")
|
|
1297
|
+
};
|
|
1298
|
+
}
|
|
904
1299
|
// Annotate the CommonJS export names for ESM import in node:
|
|
905
1300
|
0 && (module.exports = {
|
|
906
1301
|
ArrayIcons,
|
|
1302
|
+
BatchVariableSelector,
|
|
1303
|
+
ConstantInput,
|
|
1304
|
+
DynamicValueInput,
|
|
907
1305
|
JsonSchemaEditor,
|
|
908
1306
|
TypeSelector,
|
|
909
1307
|
VariableSelector,
|
|
910
|
-
VariableTypeIcons
|
|
1308
|
+
VariableTypeIcons,
|
|
1309
|
+
formatLegacyRefOnInit,
|
|
1310
|
+
formatLegacyRefOnSubmit,
|
|
1311
|
+
formatLegacyRefToNewRef,
|
|
1312
|
+
formatNewRefToLegacyRef,
|
|
1313
|
+
getSchemaIcon,
|
|
1314
|
+
getTypeSelectValue,
|
|
1315
|
+
isLegacyFlowRefValueSchema,
|
|
1316
|
+
isNewFlowRefValueSchema,
|
|
1317
|
+
parseTypeSelectValue,
|
|
1318
|
+
provideBatchInputEffect,
|
|
1319
|
+
provideBatchOutputsEffect
|
|
911
1320
|
});
|
|
912
1321
|
//# sourceMappingURL=index.js.map
|