@flowgram.ai/form-materials 0.3.4 → 0.3.5
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/index.ts +5 -19
- package/bin/materials.ts +31 -89
- package/bin/project.ts +4 -0
- package/bin/utils/import.ts +127 -0
- package/bin/utils/traverse-file.ts +60 -0
- package/dist/esm/index.js +383 -488
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.mts +64 -6
- package/dist/index.d.ts +64 -6
- package/dist/index.js +625 -730
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
- package/src/components/assign-row/index.tsx +4 -4
- package/src/components/assign-rows/index.tsx +1 -1
- package/src/components/batch-outputs/index.tsx +4 -3
- package/src/components/batch-outputs/types.ts +1 -1
- package/src/components/batch-variable-selector/index.tsx +1 -1
- package/src/components/code-editor-mini/index.tsx +1 -1
- package/src/components/condition-row/hooks/useRule.ts +2 -1
- package/src/components/condition-row/index.tsx +5 -4
- package/src/components/condition-row/types.ts +1 -1
- package/src/components/constant-input/index.tsx +5 -2
- package/src/components/constant-input/types.ts +1 -1
- package/src/components/display-flow-value/index.tsx +2 -2
- package/src/components/display-inputs-values/index.tsx +3 -2
- package/src/components/display-outputs/index.tsx +2 -1
- package/src/components/display-schema-tag/index.tsx +3 -2
- package/src/components/display-schema-tree/index.tsx +2 -1
- package/src/components/dynamic-value-input/hooks.ts +1 -1
- package/src/components/dynamic-value-input/index.tsx +13 -9
- package/src/components/inputs-values/index.tsx +7 -5
- package/src/components/inputs-values/types.ts +3 -3
- package/src/components/json-editor-with-variables/extensions/variable-tree.tsx +1 -1
- package/src/components/json-editor-with-variables/index.tsx +2 -1
- package/src/components/json-schema-editor/default-value.tsx +11 -105
- package/src/components/json-schema-editor/hooks.tsx +53 -94
- package/src/components/json-schema-editor/index.tsx +11 -8
- package/src/components/json-schema-editor/styles.tsx +0 -29
- package/src/components/prompt-editor/types.tsx +1 -1
- package/src/components/prompt-editor-with-inputs/extensions/inputs-tree.tsx +2 -1
- package/src/components/prompt-editor-with-inputs/index.tsx +3 -2
- package/src/components/prompt-editor-with-inputs/inputs-picker.tsx +1 -1
- package/src/components/prompt-editor-with-variables/extensions/variable-tree.tsx +1 -1
- package/src/components/prompt-editor-with-variables/index.tsx +2 -1
- package/src/components/type-selector/index.tsx +7 -3
- package/src/components/variable-selector/index.tsx +7 -4
- package/src/components/variable-selector/use-variable-tree.tsx +1 -1
- package/src/effects/auto-rename-ref/index.ts +1 -1
- package/src/effects/listen-ref-schema-change/index.ts +1 -1
- package/src/effects/listen-ref-value-change/index.ts +1 -1
- package/src/effects/provide-batch-input/index.ts +1 -1
- package/src/form-plugins/batch-outputs-plugin/index.ts +1 -1
- package/src/form-plugins/infer-assign-plugin/index.ts +1 -1
- package/src/form-plugins/infer-inputs-plugin/index.ts +1 -1
- package/src/shared/index.ts +1 -0
- package/src/shared/inject-material/README.md +170 -0
- package/src/shared/inject-material/README.zh.md +174 -0
- package/src/shared/inject-material/index.tsx +87 -0
- package/src/components/assign-row/config.json +0 -11
- package/src/components/assign-rows/config.json +0 -11
- package/src/components/batch-outputs/config.json +0 -13
- package/src/components/batch-variable-selector/config.json +0 -9
- package/src/components/code-editor/config.json +0 -10
- package/src/components/code-editor-mini/config.json +0 -7
- package/src/components/condition-row/config.json +0 -13
- package/src/components/constant-input/config.json +0 -9
- package/src/components/display-flow-value/config.json +0 -8
- package/src/components/display-inputs-values/config.json +0 -9
- package/src/components/display-outputs/config.json +0 -10
- package/src/components/display-schema-tag/config.json +0 -10
- package/src/components/display-schema-tree/config.json +0 -11
- package/src/components/dynamic-value-input/config.json +0 -14
- package/src/components/inputs-values/config.json +0 -13
- package/src/components/json-editor-with-variables/config.json +0 -13
- package/src/components/json-schema-editor/config.json +0 -13
- package/src/components/json-schema-editor/utils.ts +0 -29
- package/src/components/prompt-editor/config.json +0 -9
- package/src/components/prompt-editor-with-inputs/config.json +0 -13
- package/src/components/prompt-editor-with-variables/config.json +0 -13
- package/src/components/type-selector/config.json +0 -9
- package/src/components/variable-selector/config.json +0 -9
- package/src/effects/auto-rename-ref/config.json +0 -5
- package/src/effects/listen-ref-schema-change/config.json +0 -10
- package/src/effects/listen-ref-value-change/config.json +0 -9
- package/src/effects/provide-batch-input/config.json +0 -5
- package/src/effects/provide-json-schema-outputs/config.json +0 -7
- package/src/effects/sync-variable-title/config.json +0 -5
- package/src/effects/validate-when-variable-sync/config.json +0 -5
- package/src/form-plugins/batch-outputs-plugin/config.json +0 -7
- package/src/form-plugins/infer-assign-plugin/config.json +0 -7
- package/src/form-plugins/infer-inputs-plugin/config.json +0 -9
- package/src/hooks/use-object-list/config.json +0 -8
- package/src/shared/format-legacy-refs/config.json +0 -5
- package/src/typings/flow-value/config.json +0 -7
- package/src/validate/validate-flow-value/config.json +0 -7
package/dist/esm/index.js
CHANGED
|
@@ -1,17 +1,105 @@
|
|
|
1
1
|
// src/components/variable-selector/index.tsx
|
|
2
|
-
import
|
|
2
|
+
import React12, { useMemo } from "react";
|
|
3
3
|
import { I18n as I18n7 } from "@flowgram.ai/editor";
|
|
4
4
|
import { Popover } from "@douyinfe/semi-ui";
|
|
5
5
|
import { IconChevronDownStroked, IconIssueStroked } from "@douyinfe/semi-icons";
|
|
6
6
|
|
|
7
|
+
// src/shared/format-legacy-refs/index.ts
|
|
8
|
+
import { isObject } from "lodash";
|
|
9
|
+
function formatLegacyRefOnSubmit(value) {
|
|
10
|
+
if (isObject(value)) {
|
|
11
|
+
if (isLegacyFlowRefValueSchema(value)) {
|
|
12
|
+
return formatLegacyRefToNewRef(value);
|
|
13
|
+
}
|
|
14
|
+
return Object.fromEntries(
|
|
15
|
+
Object.entries(value).map(([key, value2]) => [
|
|
16
|
+
key,
|
|
17
|
+
formatLegacyRefOnSubmit(value2)
|
|
18
|
+
])
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
if (Array.isArray(value)) {
|
|
22
|
+
return value.map(formatLegacyRefOnSubmit);
|
|
23
|
+
}
|
|
24
|
+
return value;
|
|
25
|
+
}
|
|
26
|
+
function formatLegacyRefOnInit(value) {
|
|
27
|
+
if (isObject(value)) {
|
|
28
|
+
if (isNewFlowRefValueSchema(value)) {
|
|
29
|
+
return formatNewRefToLegacyRef(value);
|
|
30
|
+
}
|
|
31
|
+
return Object.fromEntries(
|
|
32
|
+
Object.entries(value).map(([key, value2]) => [
|
|
33
|
+
key,
|
|
34
|
+
formatLegacyRefOnInit(value2)
|
|
35
|
+
])
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
if (Array.isArray(value)) {
|
|
39
|
+
return value.map(formatLegacyRefOnInit);
|
|
40
|
+
}
|
|
41
|
+
return value;
|
|
42
|
+
}
|
|
43
|
+
function isLegacyFlowRefValueSchema(value) {
|
|
44
|
+
return isObject(value) && Object.keys(value).length === 2 && value.type === "ref" && typeof value.content === "string";
|
|
45
|
+
}
|
|
46
|
+
function isNewFlowRefValueSchema(value) {
|
|
47
|
+
return isObject(value) && Object.keys(value).length === 2 && value.type === "ref" && Array.isArray(value.content);
|
|
48
|
+
}
|
|
49
|
+
function formatLegacyRefToNewRef(value) {
|
|
50
|
+
const keyPath = value.content.split(".");
|
|
51
|
+
if (keyPath[1] === "outputs") {
|
|
52
|
+
return {
|
|
53
|
+
type: "ref",
|
|
54
|
+
content: [`${keyPath[0]}.${keyPath[1]}`, ...keyPath.length > 2 ? keyPath.slice(2) : []]
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
return {
|
|
58
|
+
type: "ref",
|
|
59
|
+
content: keyPath
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
function formatNewRefToLegacyRef(value) {
|
|
63
|
+
return {
|
|
64
|
+
type: "ref",
|
|
65
|
+
content: value.content.join(".")
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// src/shared/inject-material/index.tsx
|
|
70
|
+
import React from "react";
|
|
71
|
+
import {
|
|
72
|
+
FlowRendererComponentType,
|
|
73
|
+
FlowRendererRegistry,
|
|
74
|
+
usePlaygroundContainer
|
|
75
|
+
} from "@flowgram.ai/editor";
|
|
76
|
+
function createInjectMaterial(Component, params) {
|
|
77
|
+
const InjectComponent = (props) => {
|
|
78
|
+
const container = usePlaygroundContainer();
|
|
79
|
+
if (!container?.isBound(FlowRendererRegistry)) {
|
|
80
|
+
return React.createElement(Component, { ...props });
|
|
81
|
+
}
|
|
82
|
+
const rendererRegistry = container.get(FlowRendererRegistry);
|
|
83
|
+
const renderKey = params?.renderKey || Component.renderKey || Component.name || "";
|
|
84
|
+
const renderer = rendererRegistry.tryToGetRendererComponent(renderKey);
|
|
85
|
+
if (renderer?.type !== FlowRendererComponentType.REACT) {
|
|
86
|
+
return React.createElement(Component, { ...props });
|
|
87
|
+
}
|
|
88
|
+
return React.createElement(renderer.renderer, {
|
|
89
|
+
...props
|
|
90
|
+
});
|
|
91
|
+
};
|
|
92
|
+
return InjectComponent;
|
|
93
|
+
}
|
|
94
|
+
|
|
7
95
|
// src/components/variable-selector/use-variable-tree.tsx
|
|
8
|
-
import
|
|
96
|
+
import React11, { useCallback } from "react";
|
|
9
97
|
import { JsonSchemaUtils as JsonSchemaUtils2 } from "@flowgram.ai/json-schema";
|
|
10
98
|
import { ASTMatch as ASTMatch2, useAvailableVariables } from "@flowgram.ai/editor";
|
|
11
99
|
import { Icon } from "@douyinfe/semi-ui";
|
|
12
100
|
|
|
13
101
|
// src/plugins/json-schema-preset/index.tsx
|
|
14
|
-
import
|
|
102
|
+
import React10 from "react";
|
|
15
103
|
import {
|
|
16
104
|
JsonSchemaUtils,
|
|
17
105
|
useTypeManager as useOriginTypeManager,
|
|
@@ -22,12 +110,12 @@ import {
|
|
|
22
110
|
import { jsonSchemaTypeManager } from "@flowgram.ai/json-schema";
|
|
23
111
|
|
|
24
112
|
// src/plugins/json-schema-preset/type-definition/string.tsx
|
|
25
|
-
import
|
|
113
|
+
import React2 from "react";
|
|
26
114
|
import { I18n } from "@flowgram.ai/editor";
|
|
27
115
|
import { Input } from "@douyinfe/semi-ui";
|
|
28
116
|
var stringRegistry = {
|
|
29
117
|
type: "string",
|
|
30
|
-
ConstantRenderer: (props) => /* @__PURE__ */
|
|
118
|
+
ConstantRenderer: (props) => /* @__PURE__ */ React2.createElement(
|
|
31
119
|
Input,
|
|
32
120
|
{
|
|
33
121
|
placeholder: I18n.t("Please Input String"),
|
|
@@ -39,15 +127,15 @@ var stringRegistry = {
|
|
|
39
127
|
};
|
|
40
128
|
|
|
41
129
|
// src/plugins/json-schema-preset/type-definition/object.tsx
|
|
42
|
-
import
|
|
130
|
+
import React5 from "react";
|
|
43
131
|
import { I18n as I18n2 } from "@flowgram.ai/editor";
|
|
44
132
|
|
|
45
133
|
// src/components/code-editor-mini/index.tsx
|
|
46
|
-
import
|
|
134
|
+
import React4 from "react";
|
|
47
135
|
import styled from "styled-components";
|
|
48
136
|
|
|
49
137
|
// src/components/code-editor/index.tsx
|
|
50
|
-
import
|
|
138
|
+
import React3, { useEffect, useRef } from "react";
|
|
51
139
|
import {
|
|
52
140
|
ActiveLinePlaceholder,
|
|
53
141
|
createRenderer,
|
|
@@ -368,7 +456,7 @@ function CodeEditor({
|
|
|
368
456
|
editorRef.current?.setValue(String(value || ""));
|
|
369
457
|
}
|
|
370
458
|
}, [value]);
|
|
371
|
-
return /* @__PURE__ */
|
|
459
|
+
return /* @__PURE__ */ React3.createElement(EditorProvider, null, /* @__PURE__ */ React3.createElement(
|
|
372
460
|
OriginCodeEditor,
|
|
373
461
|
{
|
|
374
462
|
defaultValue: value,
|
|
@@ -386,7 +474,7 @@ function CodeEditor({
|
|
|
386
474
|
},
|
|
387
475
|
onChange: (e) => onChange?.(e.value)
|
|
388
476
|
},
|
|
389
|
-
activeLinePlaceholder && /* @__PURE__ */
|
|
477
|
+
activeLinePlaceholder && /* @__PURE__ */ React3.createElement(ActiveLinePlaceholder, null, activeLinePlaceholder),
|
|
390
478
|
children
|
|
391
479
|
));
|
|
392
480
|
}
|
|
@@ -398,7 +486,7 @@ var UIMini = styled.div`
|
|
|
398
486
|
}
|
|
399
487
|
`;
|
|
400
488
|
function CodeEditorMini(props) {
|
|
401
|
-
return /* @__PURE__ */
|
|
489
|
+
return /* @__PURE__ */ React4.createElement(UIMini, null, /* @__PURE__ */ React4.createElement(
|
|
402
490
|
CodeEditor,
|
|
403
491
|
{
|
|
404
492
|
...props,
|
|
@@ -414,7 +502,7 @@ function CodeEditorMini(props) {
|
|
|
414
502
|
// src/plugins/json-schema-preset/type-definition/object.tsx
|
|
415
503
|
var objectRegistry = {
|
|
416
504
|
type: "object",
|
|
417
|
-
ConstantRenderer: (props) => /* @__PURE__ */
|
|
505
|
+
ConstantRenderer: (props) => /* @__PURE__ */ React5.createElement(
|
|
418
506
|
CodeEditorMini,
|
|
419
507
|
{
|
|
420
508
|
value: props.value,
|
|
@@ -427,12 +515,12 @@ var objectRegistry = {
|
|
|
427
515
|
};
|
|
428
516
|
|
|
429
517
|
// src/plugins/json-schema-preset/type-definition/number.tsx
|
|
430
|
-
import
|
|
518
|
+
import React6 from "react";
|
|
431
519
|
import { I18n as I18n3 } from "@flowgram.ai/editor";
|
|
432
520
|
import { InputNumber } from "@douyinfe/semi-ui";
|
|
433
521
|
var numberRegistry = {
|
|
434
522
|
type: "number",
|
|
435
|
-
ConstantRenderer: (props) => /* @__PURE__ */
|
|
523
|
+
ConstantRenderer: (props) => /* @__PURE__ */ React6.createElement(
|
|
436
524
|
InputNumber,
|
|
437
525
|
{
|
|
438
526
|
placeholder: I18n3.t("Please Input Number"),
|
|
@@ -445,12 +533,12 @@ var numberRegistry = {
|
|
|
445
533
|
};
|
|
446
534
|
|
|
447
535
|
// src/plugins/json-schema-preset/type-definition/integer.tsx
|
|
448
|
-
import
|
|
536
|
+
import React7 from "react";
|
|
449
537
|
import { I18n as I18n4 } from "@flowgram.ai/editor";
|
|
450
538
|
import { InputNumber as InputNumber2 } from "@douyinfe/semi-ui";
|
|
451
539
|
var integerRegistry = {
|
|
452
540
|
type: "integer",
|
|
453
|
-
ConstantRenderer: (props) => /* @__PURE__ */
|
|
541
|
+
ConstantRenderer: (props) => /* @__PURE__ */ React7.createElement(
|
|
454
542
|
InputNumber2,
|
|
455
543
|
{
|
|
456
544
|
placeholder: I18n4.t("Please Input Integer"),
|
|
@@ -463,14 +551,14 @@ var integerRegistry = {
|
|
|
463
551
|
};
|
|
464
552
|
|
|
465
553
|
// src/plugins/json-schema-preset/type-definition/boolean.tsx
|
|
466
|
-
import
|
|
554
|
+
import React8 from "react";
|
|
467
555
|
import { I18n as I18n5 } from "@flowgram.ai/editor";
|
|
468
556
|
import { Select } from "@douyinfe/semi-ui";
|
|
469
557
|
var booleanRegistry = {
|
|
470
558
|
type: "boolean",
|
|
471
559
|
ConstantRenderer: (props) => {
|
|
472
560
|
const { value, onChange, ...rest } = props;
|
|
473
|
-
return /* @__PURE__ */
|
|
561
|
+
return /* @__PURE__ */ React8.createElement(
|
|
474
562
|
Select,
|
|
475
563
|
{
|
|
476
564
|
placeholder: I18n5.t("Please Select Boolean"),
|
|
@@ -489,11 +577,11 @@ var booleanRegistry = {
|
|
|
489
577
|
};
|
|
490
578
|
|
|
491
579
|
// src/plugins/json-schema-preset/type-definition/array.tsx
|
|
492
|
-
import
|
|
580
|
+
import React9 from "react";
|
|
493
581
|
import { I18n as I18n6 } from "@flowgram.ai/editor";
|
|
494
582
|
var arrayRegistry = {
|
|
495
583
|
type: "array",
|
|
496
|
-
ConstantRenderer: (props) => /* @__PURE__ */
|
|
584
|
+
ConstantRenderer: (props) => /* @__PURE__ */ React9.createElement(
|
|
497
585
|
CodeEditorMini,
|
|
498
586
|
{
|
|
499
587
|
value: props.value,
|
|
@@ -537,7 +625,7 @@ var useTypeManager = () => useOriginTypeManager();
|
|
|
537
625
|
var JsonSchemaTypePresetProvider = ({
|
|
538
626
|
types = [],
|
|
539
627
|
children
|
|
540
|
-
}) => /* @__PURE__ */
|
|
628
|
+
}) => /* @__PURE__ */ React10.createElement(OriginTypePresetProvider, { types: [...jsonSchemaTypePreset, ...types] }, children);
|
|
541
629
|
|
|
542
630
|
// src/plugins/disable-declaration-plugin/create-disable-declaration-plugin.ts
|
|
543
631
|
import {
|
|
@@ -571,12 +659,12 @@ function useVariableTree(params) {
|
|
|
571
659
|
const getVariableTypeIcon = useCallback((variable) => {
|
|
572
660
|
if (variable.meta?.icon) {
|
|
573
661
|
if (typeof variable.meta.icon === "string") {
|
|
574
|
-
return /* @__PURE__ */
|
|
662
|
+
return /* @__PURE__ */ React11.createElement("img", { style: { marginRight: 8 }, width: 12, height: 12, src: variable.meta.icon });
|
|
575
663
|
}
|
|
576
664
|
return variable.meta.icon;
|
|
577
665
|
}
|
|
578
666
|
const schema = JsonSchemaUtils2.astToSchema(variable.type, { drilldownObject: false });
|
|
579
|
-
return /* @__PURE__ */
|
|
667
|
+
return /* @__PURE__ */ React11.createElement(Icon, { size: "small", svg: typeManager.getDisplayIcon(schema || {}) });
|
|
580
668
|
}, []);
|
|
581
669
|
const renderVariable = (variable, parentFields = []) => {
|
|
582
670
|
let type = variable?.type;
|
|
@@ -696,11 +784,11 @@ var VariableSelector = ({
|
|
|
696
784
|
}, [value]);
|
|
697
785
|
const renderIcon = (icon) => {
|
|
698
786
|
if (typeof icon === "string") {
|
|
699
|
-
return /* @__PURE__ */
|
|
787
|
+
return /* @__PURE__ */ React12.createElement("img", { style: { marginRight: 8 }, width: 12, height: 12, src: icon });
|
|
700
788
|
}
|
|
701
789
|
return icon;
|
|
702
790
|
};
|
|
703
|
-
return /* @__PURE__ */
|
|
791
|
+
return /* @__PURE__ */ React12.createElement(React12.Fragment, null, /* @__PURE__ */ React12.createElement(
|
|
704
792
|
UITreeSelect,
|
|
705
793
|
{
|
|
706
794
|
dropdownMatchSelectWidth: false,
|
|
@@ -717,10 +805,10 @@ var VariableSelector = ({
|
|
|
717
805
|
},
|
|
718
806
|
renderSelectedItem: (_option) => {
|
|
719
807
|
if (!_option?.keyPath) {
|
|
720
|
-
return /* @__PURE__ */
|
|
808
|
+
return /* @__PURE__ */ React12.createElement(
|
|
721
809
|
UITag,
|
|
722
810
|
{
|
|
723
|
-
prefixIcon: /* @__PURE__ */
|
|
811
|
+
prefixIcon: /* @__PURE__ */ React12.createElement(IconIssueStroked, null),
|
|
724
812
|
color: "amber",
|
|
725
813
|
closable: !readonly,
|
|
726
814
|
onClose: () => onChange(void 0)
|
|
@@ -729,13 +817,13 @@ var VariableSelector = ({
|
|
|
729
817
|
);
|
|
730
818
|
}
|
|
731
819
|
const rootIcon = renderIcon(_option.rootMeta?.icon || _option?.icon);
|
|
732
|
-
const rootTitle = /* @__PURE__ */
|
|
733
|
-
return /* @__PURE__ */
|
|
820
|
+
const rootTitle = /* @__PURE__ */ React12.createElement(UIRootTitle, null, _option.rootMeta?.title ? `${_option.rootMeta?.title} ${_option.isRoot ? "" : "-"} ` : null);
|
|
821
|
+
return /* @__PURE__ */ React12.createElement("div", null, /* @__PURE__ */ React12.createElement(
|
|
734
822
|
Popover,
|
|
735
823
|
{
|
|
736
|
-
content: /* @__PURE__ */
|
|
824
|
+
content: /* @__PURE__ */ React12.createElement(UIPopoverContent, null, rootIcon, rootTitle, /* @__PURE__ */ React12.createElement(UIVarName, null, _option.keyPath.slice(1).join(".")))
|
|
737
825
|
},
|
|
738
|
-
/* @__PURE__ */
|
|
826
|
+
/* @__PURE__ */ React12.createElement(
|
|
739
827
|
UITag,
|
|
740
828
|
{
|
|
741
829
|
prefixIcon: rootIcon,
|
|
@@ -743,20 +831,22 @@ var VariableSelector = ({
|
|
|
743
831
|
onClose: () => onChange(void 0)
|
|
744
832
|
},
|
|
745
833
|
rootTitle,
|
|
746
|
-
!_option.isRoot && /* @__PURE__ */
|
|
834
|
+
!_option.isRoot && /* @__PURE__ */ React12.createElement(UIVarName, { $inSelector: true }, _option.label)
|
|
747
835
|
)
|
|
748
836
|
));
|
|
749
837
|
},
|
|
750
838
|
showClear: false,
|
|
751
|
-
arrowIcon: /* @__PURE__ */
|
|
839
|
+
arrowIcon: /* @__PURE__ */ React12.createElement(IconChevronDownStroked, { size: "small" }),
|
|
752
840
|
triggerRender,
|
|
753
841
|
placeholder: config?.placeholder ?? I18n7.t("Select Variable")
|
|
754
842
|
}
|
|
755
843
|
));
|
|
756
844
|
};
|
|
845
|
+
VariableSelector.renderKey = "variable-selector-render-key";
|
|
846
|
+
var InjectVariableSelector = createInjectMaterial(VariableSelector);
|
|
757
847
|
|
|
758
848
|
// src/components/type-selector/index.tsx
|
|
759
|
-
import
|
|
849
|
+
import React13, { useMemo as useMemo2 } from "react";
|
|
760
850
|
import { Cascader, Icon as Icon2, IconButton } from "@douyinfe/semi-ui";
|
|
761
851
|
var labelStyle = { display: "flex", alignItems: "center", gap: 5 };
|
|
762
852
|
var getTypeSelectValue = (value) => {
|
|
@@ -781,10 +871,10 @@ function TypeSelector(props) {
|
|
|
781
871
|
() => typeManager.getTypeRegistriesWithParentType().map((_type) => {
|
|
782
872
|
const isArray2 = _type.type === "array";
|
|
783
873
|
return {
|
|
784
|
-
label: /* @__PURE__ */
|
|
874
|
+
label: /* @__PURE__ */ React13.createElement("div", { style: labelStyle }, /* @__PURE__ */ React13.createElement(Icon2, { size: "small", svg: _type.icon }), typeManager.getTypeBySchema(_type)?.label || _type.type),
|
|
785
875
|
value: _type.type,
|
|
786
876
|
children: isArray2 ? typeManager.getTypeRegistriesWithParentType("array").map((_type2) => ({
|
|
787
|
-
label: /* @__PURE__ */
|
|
877
|
+
label: /* @__PURE__ */ React13.createElement("div", { style: labelStyle }, /* @__PURE__ */ React13.createElement(
|
|
788
878
|
Icon2,
|
|
789
879
|
{
|
|
790
880
|
size: "small",
|
|
@@ -800,12 +890,12 @@ function TypeSelector(props) {
|
|
|
800
890
|
}),
|
|
801
891
|
[]
|
|
802
892
|
);
|
|
803
|
-
return /* @__PURE__ */
|
|
893
|
+
return /* @__PURE__ */ React13.createElement(
|
|
804
894
|
Cascader,
|
|
805
895
|
{
|
|
806
896
|
disabled: readonly || disabled,
|
|
807
897
|
size: "small",
|
|
808
|
-
triggerRender: () => /* @__PURE__ */
|
|
898
|
+
triggerRender: () => /* @__PURE__ */ React13.createElement(IconButton, { size: "small", style, disabled: readonly || disabled, icon }),
|
|
809
899
|
treeData: options,
|
|
810
900
|
value: selectValue,
|
|
811
901
|
leafOnly: true,
|
|
@@ -815,11 +905,13 @@ function TypeSelector(props) {
|
|
|
815
905
|
}
|
|
816
906
|
);
|
|
817
907
|
}
|
|
908
|
+
TypeSelector.renderKey = "type-selector-render-key";
|
|
909
|
+
var InjectTypeSelector = createInjectMaterial(TypeSelector);
|
|
818
910
|
|
|
819
911
|
// src/components/json-schema-editor/index.tsx
|
|
820
|
-
import
|
|
821
|
-
import { I18n as
|
|
822
|
-
import { Button, Checkbox, IconButton as
|
|
912
|
+
import React18, { useMemo as useMemo4, useState as useState3 } from "react";
|
|
913
|
+
import { I18n as I18n9 } from "@flowgram.ai/editor";
|
|
914
|
+
import { Button, Checkbox, IconButton as IconButton2 } from "@douyinfe/semi-ui";
|
|
823
915
|
import {
|
|
824
916
|
IconExpand,
|
|
825
917
|
IconShrink,
|
|
@@ -830,7 +922,7 @@ import {
|
|
|
830
922
|
} from "@douyinfe/semi-icons";
|
|
831
923
|
|
|
832
924
|
// src/components/json-schema-editor/styles.tsx
|
|
833
|
-
import
|
|
925
|
+
import React14 from "react";
|
|
834
926
|
import styled3, { css as css2 } from "styled-components";
|
|
835
927
|
import Icon3 from "@douyinfe/semi-icons";
|
|
836
928
|
var UIContainer = styled3.div`
|
|
@@ -958,7 +1050,7 @@ var UIRequired = styled3.div``;
|
|
|
958
1050
|
var UIActions = styled3.div`
|
|
959
1051
|
white-space: nowrap;
|
|
960
1052
|
`;
|
|
961
|
-
var iconAddChildrenSvg = /* @__PURE__ */
|
|
1053
|
+
var iconAddChildrenSvg = /* @__PURE__ */ React14.createElement(
|
|
962
1054
|
"svg",
|
|
963
1055
|
{
|
|
964
1056
|
className: "icon-icon icon-icon-coz_add_node ",
|
|
@@ -968,7 +1060,7 @@ var iconAddChildrenSvg = /* @__PURE__ */ React13.createElement(
|
|
|
968
1060
|
fill: "currentColor",
|
|
969
1061
|
xmlns: "http://www.w3.org/2000/svg"
|
|
970
1062
|
},
|
|
971
|
-
/* @__PURE__ */
|
|
1063
|
+
/* @__PURE__ */ React14.createElement(
|
|
972
1064
|
"path",
|
|
973
1065
|
{
|
|
974
1066
|
fillRule: "evenodd",
|
|
@@ -976,37 +1068,12 @@ var iconAddChildrenSvg = /* @__PURE__ */ React13.createElement(
|
|
|
976
1068
|
d: "M11 6.49988C11 8.64148 9.50397 10.4337 7.49995 10.8884V15.4998C7.49995 16.0521 7.94767 16.4998 8.49995 16.4998H11.208C11.0742 16.8061 11 17.1443 11 17.4998C11 17.8554 11.0742 18.1936 11.208 18.4998H8.49995C6.8431 18.4998 5.49995 17.1567 5.49995 15.4998V10.8884C3.49599 10.4336 2 8.64145 2 6.49988C2 4.0146 4.01472 1.99988 6.5 1.99988C8.98528 1.99988 11 4.0146 11 6.49988ZM6.5 8.99988C7.88071 8.99988 9 7.88059 9 6.49988C9 5.11917 7.88071 3.99988 6.5 3.99988C5.11929 3.99988 4 5.11917 4 6.49988C4 7.88059 5.11929 8.99988 6.5 8.99988Z"
|
|
977
1069
|
}
|
|
978
1070
|
),
|
|
979
|
-
/* @__PURE__ */
|
|
1071
|
+
/* @__PURE__ */ React14.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" })
|
|
980
1072
|
);
|
|
981
|
-
var IconAddChildren = () => /* @__PURE__ */
|
|
1073
|
+
var IconAddChildren = () => /* @__PURE__ */ React14.createElement(Icon3, { size: "small", svg: iconAddChildrenSvg });
|
|
982
1074
|
var DefaultValueWrapper = styled3.div`
|
|
983
1075
|
margin: 0;
|
|
984
1076
|
`;
|
|
985
|
-
var JSONViewerWrapper = styled3.div`
|
|
986
|
-
padding: 0 0 24px;
|
|
987
|
-
&:first-child {
|
|
988
|
-
margin-top: 0px;
|
|
989
|
-
}
|
|
990
|
-
`;
|
|
991
|
-
var JSONHeader = styled3.div`
|
|
992
|
-
display: flex;
|
|
993
|
-
justify-content: space-between;
|
|
994
|
-
align-items: center;
|
|
995
|
-
background-color: var(--semi-color-fill-0);
|
|
996
|
-
border-radius: 6px 6px 0 0;
|
|
997
|
-
height: 36px;
|
|
998
|
-
padding: 0 8px 0 12px;
|
|
999
|
-
`;
|
|
1000
|
-
var JSONHeaderLeft = styled3.div`
|
|
1001
|
-
display: flex;
|
|
1002
|
-
align-items: center;
|
|
1003
|
-
gap: 10px;
|
|
1004
|
-
`;
|
|
1005
|
-
var JSONHeaderRight = styled3.div`
|
|
1006
|
-
display: flex;
|
|
1007
|
-
align-items: center;
|
|
1008
|
-
gap: 10px;
|
|
1009
|
-
`;
|
|
1010
1077
|
var ConstantInputWrapper = styled3.div`
|
|
1011
1078
|
flex-grow: 1;
|
|
1012
1079
|
|
|
@@ -1018,71 +1085,39 @@ var ConstantInputWrapper = styled3.div`
|
|
|
1018
1085
|
`;
|
|
1019
1086
|
|
|
1020
1087
|
// src/components/json-schema-editor/hooks.tsx
|
|
1021
|
-
import { useEffect as useEffect2,
|
|
1022
|
-
import { omit } from "lodash";
|
|
1088
|
+
import { useEffect as useEffect2, useState } from "react";
|
|
1089
|
+
import { difference, omit } from "lodash";
|
|
1090
|
+
import { produce } from "immer";
|
|
1091
|
+
import { useTypeManager as useTypeManager2 } from "@flowgram.ai/json-schema";
|
|
1023
1092
|
var _id = 0;
|
|
1024
1093
|
function genId() {
|
|
1025
1094
|
return _id++;
|
|
1026
1095
|
}
|
|
1027
|
-
function getDrilldownSchema(value, path) {
|
|
1028
|
-
if (!value) {
|
|
1029
|
-
return {};
|
|
1030
|
-
}
|
|
1031
|
-
if (value.type === "array" && value.items) {
|
|
1032
|
-
return getDrilldownSchema(value.items, [...path || [], "items"]);
|
|
1033
|
-
}
|
|
1034
|
-
return { schema: value, path };
|
|
1035
|
-
}
|
|
1036
1096
|
function usePropertiesEdit(value, onChange) {
|
|
1037
|
-
const
|
|
1038
|
-
const
|
|
1039
|
-
const
|
|
1040
|
-
|
|
1041
|
-
([name, _value], index) => ({
|
|
1042
|
-
key: genId(),
|
|
1043
|
-
name,
|
|
1044
|
-
isPropertyRequired: drilldown.schema?.required?.includes(name) || false,
|
|
1045
|
-
..._value,
|
|
1046
|
-
extra: {
|
|
1047
|
-
..._value.extra || {},
|
|
1048
|
-
index
|
|
1049
|
-
}
|
|
1050
|
-
})
|
|
1051
|
-
) : [],
|
|
1052
|
-
[isDrilldownObject]
|
|
1053
|
-
);
|
|
1054
|
-
const [propertyList, setPropertyList] = useState(initPropertyList);
|
|
1055
|
-
const mountRef = useRef2(false);
|
|
1097
|
+
const typeManager = useTypeManager2();
|
|
1098
|
+
const drilldownSchema = typeManager.getPropertiesParent(value || {});
|
|
1099
|
+
const canAddField = typeManager.canAddField(value || {});
|
|
1100
|
+
const [propertyList, setPropertyList] = useState([]);
|
|
1056
1101
|
useEffect2(() => {
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
key: genId(),
|
|
1077
|
-
name,
|
|
1078
|
-
isPropertyRequired: drilldown.schema?.required?.includes(name) || false,
|
|
1079
|
-
..._value
|
|
1080
|
-
};
|
|
1081
|
-
});
|
|
1082
|
-
});
|
|
1083
|
-
}
|
|
1084
|
-
mountRef.current = true;
|
|
1085
|
-
}, [drilldown.schema]);
|
|
1102
|
+
setPropertyList((_list) => {
|
|
1103
|
+
const newNames = Object.entries(drilldownSchema?.properties || {}).sort(([, a], [, b]) => (a.extra?.index ?? 0) - (b.extra?.index ?? 0)).map(([key]) => key);
|
|
1104
|
+
const oldNames = _list.map((item) => item.name).filter(Boolean);
|
|
1105
|
+
const addNames = difference(newNames, oldNames);
|
|
1106
|
+
return _list.filter((item) => !item.name || newNames.includes(item.name)).map((item) => ({
|
|
1107
|
+
key: item.key,
|
|
1108
|
+
name: item.name,
|
|
1109
|
+
isPropertyRequired: drilldownSchema?.required?.includes(item.name || "") || false,
|
|
1110
|
+
...item
|
|
1111
|
+
})).concat(
|
|
1112
|
+
addNames.map((_name) => ({
|
|
1113
|
+
key: genId(),
|
|
1114
|
+
name: _name,
|
|
1115
|
+
isPropertyRequired: drilldownSchema?.required?.includes(_name) || false,
|
|
1116
|
+
...drilldownSchema?.properties?.[_name] || {}
|
|
1117
|
+
}))
|
|
1118
|
+
);
|
|
1119
|
+
});
|
|
1120
|
+
}, [drilldownSchema]);
|
|
1086
1121
|
const updatePropertyList = (updater) => {
|
|
1087
1122
|
setPropertyList((_list) => {
|
|
1088
1123
|
const next = updater(_list);
|
|
@@ -1097,18 +1132,21 @@ function usePropertiesEdit(value, onChange) {
|
|
|
1097
1132
|
nextRequired.push(_property.name);
|
|
1098
1133
|
}
|
|
1099
1134
|
}
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1135
|
+
onChange?.(
|
|
1136
|
+
produce(value || {}, (draft) => {
|
|
1137
|
+
const propertiesParent = typeManager.getPropertiesParent(draft);
|
|
1138
|
+
if (propertiesParent) {
|
|
1139
|
+
propertiesParent.properties = nextProperties;
|
|
1140
|
+
propertiesParent.required = nextRequired;
|
|
1141
|
+
return;
|
|
1142
|
+
}
|
|
1143
|
+
})
|
|
1144
|
+
);
|
|
1107
1145
|
return next;
|
|
1108
1146
|
});
|
|
1109
1147
|
};
|
|
1110
1148
|
const onAddProperty = () => {
|
|
1111
|
-
|
|
1149
|
+
setPropertyList((_list) => [
|
|
1112
1150
|
..._list,
|
|
1113
1151
|
{ key: genId(), name: "", type: "string", extra: { index: _list.length + 1 } }
|
|
1114
1152
|
]);
|
|
@@ -1122,13 +1160,13 @@ function usePropertiesEdit(value, onChange) {
|
|
|
1122
1160
|
);
|
|
1123
1161
|
};
|
|
1124
1162
|
useEffect2(() => {
|
|
1125
|
-
if (!
|
|
1163
|
+
if (!canAddField) {
|
|
1126
1164
|
setPropertyList([]);
|
|
1127
1165
|
}
|
|
1128
|
-
}, [
|
|
1166
|
+
}, [canAddField]);
|
|
1129
1167
|
return {
|
|
1130
1168
|
propertyList,
|
|
1131
|
-
|
|
1169
|
+
canAddField,
|
|
1132
1170
|
onAddProperty,
|
|
1133
1171
|
onRemoveProperty,
|
|
1134
1172
|
onEditProperty
|
|
@@ -1136,36 +1174,16 @@ function usePropertiesEdit(value, onChange) {
|
|
|
1136
1174
|
}
|
|
1137
1175
|
|
|
1138
1176
|
// src/components/json-schema-editor/default-value.tsx
|
|
1139
|
-
import
|
|
1140
|
-
import {
|
|
1141
|
-
import { IconBrackets } from "@douyinfe/semi-icons";
|
|
1142
|
-
|
|
1143
|
-
// src/components/json-schema-editor/utils.ts
|
|
1144
|
-
function getValueType(value) {
|
|
1145
|
-
const type = typeof value;
|
|
1146
|
-
if (type === "string") {
|
|
1147
|
-
return "string";
|
|
1148
|
-
} else if (type === "number") {
|
|
1149
|
-
return Number.isInteger(value) ? "integer" : "number";
|
|
1150
|
-
} else if (type === "boolean") {
|
|
1151
|
-
return "boolean";
|
|
1152
|
-
} else if (type === "object") {
|
|
1153
|
-
if (value === null) {
|
|
1154
|
-
return "other";
|
|
1155
|
-
}
|
|
1156
|
-
return Array.isArray(value) ? "array" : "object";
|
|
1157
|
-
} else {
|
|
1158
|
-
return "other";
|
|
1159
|
-
}
|
|
1160
|
-
}
|
|
1177
|
+
import React16 from "react";
|
|
1178
|
+
import { I18n as I18n8 } from "@flowgram.ai/editor";
|
|
1161
1179
|
|
|
1162
1180
|
// src/components/constant-input/index.tsx
|
|
1163
|
-
import
|
|
1181
|
+
import React15, { useMemo as useMemo3 } from "react";
|
|
1164
1182
|
import { Input as Input2 } from "@douyinfe/semi-ui";
|
|
1165
1183
|
function ConstantInput(props) {
|
|
1166
1184
|
const { value, onChange, schema, strategies, fallbackRenderer, readonly, ...rest } = props;
|
|
1167
1185
|
const typeManager = useTypeManager();
|
|
1168
|
-
const Renderer2 =
|
|
1186
|
+
const Renderer2 = useMemo3(() => {
|
|
1169
1187
|
const strategy = (strategies || []).find((_strategy) => _strategy.hit(schema));
|
|
1170
1188
|
if (!strategy) {
|
|
1171
1189
|
return typeManager.getTypeBySchema(schema)?.ConstantRenderer;
|
|
@@ -1174,110 +1192,41 @@ function ConstantInput(props) {
|
|
|
1174
1192
|
}, [strategies, schema]);
|
|
1175
1193
|
if (!Renderer2) {
|
|
1176
1194
|
if (fallbackRenderer) {
|
|
1177
|
-
return
|
|
1195
|
+
return React15.createElement(fallbackRenderer, {
|
|
1178
1196
|
value,
|
|
1179
1197
|
onChange,
|
|
1180
1198
|
readonly,
|
|
1181
1199
|
...rest
|
|
1182
1200
|
});
|
|
1183
1201
|
}
|
|
1184
|
-
return /* @__PURE__ */
|
|
1202
|
+
return /* @__PURE__ */ React15.createElement(Input2, { size: "small", disabled: true, placeholder: "Unsupported type" });
|
|
1185
1203
|
}
|
|
1186
|
-
return /* @__PURE__ */
|
|
1204
|
+
return /* @__PURE__ */ React15.createElement(Renderer2, { value, onChange, readonly, ...rest });
|
|
1187
1205
|
}
|
|
1188
1206
|
|
|
1189
1207
|
// src/components/json-schema-editor/default-value.tsx
|
|
1190
1208
|
function DefaultValue(props) {
|
|
1191
|
-
const { value, schema,
|
|
1192
|
-
|
|
1193
|
-
const JsonViewerRef = useRef3(null);
|
|
1194
|
-
const [internalJsonValue, setInternalJsonValue] = useState2(
|
|
1195
|
-
getValueType(value) === "string" ? value : ""
|
|
1196
|
-
);
|
|
1197
|
-
const handleJsonChange = useCallback2((val) => {
|
|
1198
|
-
if (val !== internalJsonValue) {
|
|
1199
|
-
setInternalJsonValue(val);
|
|
1200
|
-
}
|
|
1201
|
-
}, []);
|
|
1202
|
-
const handleEditComplete = useCallback2(() => {
|
|
1203
|
-
onChange(internalJsonValue);
|
|
1204
|
-
requestAnimationFrame(() => {
|
|
1205
|
-
wrapperRef.current?.blur();
|
|
1206
|
-
});
|
|
1207
|
-
setJsonReadOnly(true);
|
|
1208
|
-
}, [internalJsonValue, onChange]);
|
|
1209
|
-
const [jsonReadOnly, setJsonReadOnly] = useState2(true);
|
|
1210
|
-
const handleFormatJson = useCallback2(() => {
|
|
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__ */ React15.createElement(React15.Fragment, null, /* @__PURE__ */ React15.createElement(JSONHeader, null, /* @__PURE__ */ React15.createElement(JSONHeaderLeft, null, "json"), /* @__PURE__ */ React15.createElement(JSONHeaderRight, null, /* @__PURE__ */ React15.createElement(Tooltip, { content: jsonFormatText ?? "Format" }, /* @__PURE__ */ React15.createElement(
|
|
1221
|
-
IconButton2,
|
|
1222
|
-
{
|
|
1223
|
-
icon: /* @__PURE__ */ React15.createElement(IconBrackets, { style: { color: "var(--semi-color-primary)" } }),
|
|
1224
|
-
size: "small",
|
|
1225
|
-
type: "tertiary",
|
|
1226
|
-
theme: "borderless",
|
|
1227
|
-
onClick: handleFormatJson
|
|
1228
|
-
}
|
|
1229
|
-
)))), /* @__PURE__ */ React15.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__ */ React15.createElement(
|
|
1244
|
-
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__ */ React15.createElement(ConstantInputWrapper, null, /* @__PURE__ */ React15.createElement(
|
|
1209
|
+
const { value, schema, onChange, placeholder } = props;
|
|
1210
|
+
return /* @__PURE__ */ React16.createElement(ConstantInputWrapper, null, /* @__PURE__ */ React16.createElement(
|
|
1262
1211
|
ConstantInput,
|
|
1263
1212
|
{
|
|
1264
1213
|
value,
|
|
1265
1214
|
onChange: (_v) => onChange(_v),
|
|
1266
1215
|
schema: schema || { type: "string" },
|
|
1267
|
-
placeholder: placeholder ?? "Default value if parameter is not provided"
|
|
1216
|
+
placeholder: placeholder ?? I18n8.t("Default value if parameter is not provided")
|
|
1268
1217
|
}
|
|
1269
1218
|
));
|
|
1270
1219
|
}
|
|
1271
1220
|
|
|
1272
1221
|
// src/components/json-schema-editor/components/blur-input.tsx
|
|
1273
|
-
import
|
|
1222
|
+
import React17, { useEffect as useEffect3, useState as useState2 } from "react";
|
|
1274
1223
|
import Input3 from "@douyinfe/semi-ui/lib/es/input";
|
|
1275
1224
|
function BlurInput(props) {
|
|
1276
|
-
const [value, setValue] =
|
|
1225
|
+
const [value, setValue] = useState2("");
|
|
1277
1226
|
useEffect3(() => {
|
|
1278
1227
|
setValue(props.value);
|
|
1279
1228
|
}, [props.value]);
|
|
1280
|
-
return /* @__PURE__ */
|
|
1229
|
+
return /* @__PURE__ */ React17.createElement(
|
|
1281
1230
|
Input3,
|
|
1282
1231
|
{
|
|
1283
1232
|
...props,
|
|
@@ -1291,13 +1240,14 @@ function BlurInput(props) {
|
|
|
1291
1240
|
}
|
|
1292
1241
|
|
|
1293
1242
|
// src/components/json-schema-editor/index.tsx
|
|
1243
|
+
var DEFAULT = { type: "object" };
|
|
1294
1244
|
function JsonSchemaEditor(props) {
|
|
1295
|
-
const { value =
|
|
1245
|
+
const { value = DEFAULT, config = {}, onChange: onChangeProps, readonly } = props;
|
|
1296
1246
|
const { propertyList, onAddProperty, onRemoveProperty, onEditProperty } = usePropertiesEdit(
|
|
1297
1247
|
value,
|
|
1298
1248
|
onChangeProps
|
|
1299
1249
|
);
|
|
1300
|
-
return /* @__PURE__ */
|
|
1250
|
+
return /* @__PURE__ */ React18.createElement(UIContainer, { className: props.className }, /* @__PURE__ */ React18.createElement(UIProperties, null, propertyList.map((_property, index) => /* @__PURE__ */ React18.createElement(
|
|
1301
1251
|
PropertyEdit,
|
|
1302
1252
|
{
|
|
1303
1253
|
readonly,
|
|
@@ -1312,16 +1262,16 @@ function JsonSchemaEditor(props) {
|
|
|
1312
1262
|
onRemoveProperty(_property.key);
|
|
1313
1263
|
}
|
|
1314
1264
|
}
|
|
1315
|
-
))), /* @__PURE__ */
|
|
1265
|
+
))), /* @__PURE__ */ React18.createElement(
|
|
1316
1266
|
Button,
|
|
1317
1267
|
{
|
|
1318
1268
|
disabled: readonly,
|
|
1319
1269
|
size: "small",
|
|
1320
1270
|
style: { marginTop: 10, marginLeft: 16 },
|
|
1321
|
-
icon: /* @__PURE__ */
|
|
1271
|
+
icon: /* @__PURE__ */ React18.createElement(IconPlus, null),
|
|
1322
1272
|
onClick: onAddProperty
|
|
1323
1273
|
},
|
|
1324
|
-
config?.addButtonText ?? "Add"
|
|
1274
|
+
config?.addButtonText ?? I18n9.t("Add")
|
|
1325
1275
|
));
|
|
1326
1276
|
}
|
|
1327
1277
|
function PropertyEdit(props) {
|
|
@@ -1339,19 +1289,19 @@ function PropertyEdit(props) {
|
|
|
1339
1289
|
$parentType = "",
|
|
1340
1290
|
$showLine
|
|
1341
1291
|
} = props;
|
|
1342
|
-
const [expand, setExpand] =
|
|
1343
|
-
const [collapse, setCollapse] =
|
|
1292
|
+
const [expand, setExpand] = useState3(false);
|
|
1293
|
+
const [collapse, setCollapse] = useState3(false);
|
|
1344
1294
|
const { name, type, items, default: defaultValue, description, isPropertyRequired } = value || {};
|
|
1345
|
-
const typeSelectorValue =
|
|
1346
|
-
const { propertyList,
|
|
1295
|
+
const typeSelectorValue = useMemo4(() => ({ type, items }), [type, items]);
|
|
1296
|
+
const { propertyList, canAddField, onAddProperty, onRemoveProperty, onEditProperty } = usePropertiesEdit(value, onChangeProps);
|
|
1347
1297
|
const onChange = (key, _value) => {
|
|
1348
1298
|
onChangeProps?.({
|
|
1349
1299
|
...value || {},
|
|
1350
1300
|
[key]: _value
|
|
1351
1301
|
});
|
|
1352
1302
|
};
|
|
1353
|
-
const showCollapse =
|
|
1354
|
-
return /* @__PURE__ */
|
|
1303
|
+
const showCollapse = canAddField && propertyList.length > 0;
|
|
1304
|
+
return /* @__PURE__ */ React18.createElement(React18.Fragment, null, /* @__PURE__ */ React18.createElement(
|
|
1355
1305
|
UIPropertyLeft,
|
|
1356
1306
|
{
|
|
1357
1307
|
type,
|
|
@@ -1363,8 +1313,8 @@ function PropertyEdit(props) {
|
|
|
1363
1313
|
$parentExpand,
|
|
1364
1314
|
$parentType
|
|
1365
1315
|
},
|
|
1366
|
-
showCollapse && /* @__PURE__ */
|
|
1367
|
-
), /* @__PURE__ */
|
|
1316
|
+
showCollapse && /* @__PURE__ */ React18.createElement(UICollapseTrigger, { onClick: () => setCollapse((_collapse) => !_collapse) }, collapse ? /* @__PURE__ */ React18.createElement(IconChevronDown, { size: "small" }) : /* @__PURE__ */ React18.createElement(IconChevronRight, { size: "small" }))
|
|
1317
|
+
), /* @__PURE__ */ React18.createElement(UIPropertyRight, null, /* @__PURE__ */ React18.createElement(
|
|
1368
1318
|
UIPropertyMain,
|
|
1369
1319
|
{
|
|
1370
1320
|
$showCollapse: showCollapse,
|
|
@@ -1372,7 +1322,7 @@ function PropertyEdit(props) {
|
|
|
1372
1322
|
$expand: expand,
|
|
1373
1323
|
type
|
|
1374
1324
|
},
|
|
1375
|
-
/* @__PURE__ */
|
|
1325
|
+
/* @__PURE__ */ React18.createElement(UIRow, null, /* @__PURE__ */ React18.createElement(UIName, null, /* @__PURE__ */ React18.createElement(
|
|
1376
1326
|
BlurInput,
|
|
1377
1327
|
{
|
|
1378
1328
|
disabled: readonly,
|
|
@@ -1381,8 +1331,8 @@ function PropertyEdit(props) {
|
|
|
1381
1331
|
value: name,
|
|
1382
1332
|
onChange: (value2) => onChange("name", value2)
|
|
1383
1333
|
}
|
|
1384
|
-
)), /* @__PURE__ */
|
|
1385
|
-
|
|
1334
|
+
)), /* @__PURE__ */ React18.createElement(UIType, null, /* @__PURE__ */ React18.createElement(
|
|
1335
|
+
InjectTypeSelector,
|
|
1386
1336
|
{
|
|
1387
1337
|
value: typeSelectorValue,
|
|
1388
1338
|
readonly,
|
|
@@ -1393,67 +1343,67 @@ function PropertyEdit(props) {
|
|
|
1393
1343
|
});
|
|
1394
1344
|
}
|
|
1395
1345
|
}
|
|
1396
|
-
)), /* @__PURE__ */
|
|
1346
|
+
)), /* @__PURE__ */ React18.createElement(UIRequired, null, /* @__PURE__ */ React18.createElement(
|
|
1397
1347
|
Checkbox,
|
|
1398
1348
|
{
|
|
1399
1349
|
disabled: readonly,
|
|
1400
1350
|
checked: isPropertyRequired,
|
|
1401
1351
|
onChange: (e) => onChange("isPropertyRequired", e.target.checked)
|
|
1402
1352
|
}
|
|
1403
|
-
)), /* @__PURE__ */
|
|
1404
|
-
|
|
1353
|
+
)), /* @__PURE__ */ React18.createElement(UIActions, null, /* @__PURE__ */ React18.createElement(
|
|
1354
|
+
IconButton2,
|
|
1405
1355
|
{
|
|
1406
1356
|
disabled: readonly,
|
|
1407
1357
|
size: "small",
|
|
1408
1358
|
theme: "borderless",
|
|
1409
|
-
icon: expand ? /* @__PURE__ */
|
|
1359
|
+
icon: expand ? /* @__PURE__ */ React18.createElement(IconShrink, { size: "small" }) : /* @__PURE__ */ React18.createElement(IconExpand, { size: "small" }),
|
|
1410
1360
|
onClick: () => {
|
|
1411
1361
|
setExpand((_expand) => !_expand);
|
|
1412
1362
|
}
|
|
1413
1363
|
}
|
|
1414
|
-
),
|
|
1415
|
-
|
|
1364
|
+
), canAddField && /* @__PURE__ */ React18.createElement(
|
|
1365
|
+
IconButton2,
|
|
1416
1366
|
{
|
|
1417
1367
|
disabled: readonly,
|
|
1418
1368
|
size: "small",
|
|
1419
1369
|
theme: "borderless",
|
|
1420
|
-
icon: /* @__PURE__ */
|
|
1370
|
+
icon: /* @__PURE__ */ React18.createElement(IconAddChildren, null),
|
|
1421
1371
|
onClick: () => {
|
|
1422
1372
|
onAddProperty();
|
|
1423
1373
|
setCollapse(true);
|
|
1424
1374
|
}
|
|
1425
1375
|
}
|
|
1426
|
-
), /* @__PURE__ */
|
|
1427
|
-
|
|
1376
|
+
), /* @__PURE__ */ React18.createElement(
|
|
1377
|
+
IconButton2,
|
|
1428
1378
|
{
|
|
1429
1379
|
disabled: readonly,
|
|
1430
1380
|
size: "small",
|
|
1431
1381
|
theme: "borderless",
|
|
1432
|
-
icon: /* @__PURE__ */
|
|
1382
|
+
icon: /* @__PURE__ */ React18.createElement(IconMinus, { size: "small" }),
|
|
1433
1383
|
onClick: onRemove
|
|
1434
1384
|
}
|
|
1435
1385
|
))),
|
|
1436
|
-
expand && /* @__PURE__ */
|
|
1386
|
+
expand && /* @__PURE__ */ React18.createElement(UIExpandDetail, null, /* @__PURE__ */ React18.createElement(UILabel, null, config?.descTitle ?? I18n9.t("Description")), /* @__PURE__ */ React18.createElement(
|
|
1437
1387
|
BlurInput,
|
|
1438
1388
|
{
|
|
1439
1389
|
disabled: readonly,
|
|
1440
1390
|
size: "small",
|
|
1441
1391
|
value: description,
|
|
1442
1392
|
onChange: (value2) => onChange("description", value2),
|
|
1443
|
-
placeholder: config?.descPlaceholder ??
|
|
1393
|
+
placeholder: config?.descPlaceholder ?? I18n9.t("Help LLM to understand the property")
|
|
1444
1394
|
}
|
|
1445
|
-
), $level === 0 &&
|
|
1395
|
+
), $level === 0 && /* @__PURE__ */ React18.createElement(React18.Fragment, null, /* @__PURE__ */ React18.createElement(UILabel, { style: { marginTop: 10 } }, config?.defaultValueTitle ?? I18n9.t("Default Value")), /* @__PURE__ */ React18.createElement(DefaultValueWrapper, null, /* @__PURE__ */ React18.createElement(
|
|
1446
1396
|
DefaultValue,
|
|
1447
1397
|
{
|
|
1448
1398
|
value: defaultValue,
|
|
1449
1399
|
schema: value,
|
|
1450
1400
|
type,
|
|
1451
|
-
placeholder: config?.defaultValuePlaceholder ??
|
|
1401
|
+
placeholder: config?.defaultValuePlaceholder ?? I18n9.t("Default Value"),
|
|
1452
1402
|
jsonFormatText: config?.jsonFormatText,
|
|
1453
1403
|
onChange: (value2) => onChange("default", value2)
|
|
1454
1404
|
}
|
|
1455
1405
|
))))
|
|
1456
|
-
), showCollapse && /* @__PURE__ */
|
|
1406
|
+
), showCollapse && /* @__PURE__ */ React18.createElement(UICollapsible, { $collapse: collapse }, /* @__PURE__ */ React18.createElement(UIProperties, { $shrink: true }, propertyList.map((_property, index) => /* @__PURE__ */ React18.createElement(
|
|
1457
1407
|
PropertyEdit,
|
|
1458
1408
|
{
|
|
1459
1409
|
readonly,
|
|
@@ -1478,20 +1428,20 @@ function PropertyEdit(props) {
|
|
|
1478
1428
|
}
|
|
1479
1429
|
|
|
1480
1430
|
// src/components/batch-variable-selector/index.tsx
|
|
1481
|
-
import
|
|
1431
|
+
import React19 from "react";
|
|
1482
1432
|
import { PrivateScopeProvider } from "@flowgram.ai/editor";
|
|
1483
1433
|
var batchVariableSchema = {
|
|
1484
1434
|
type: "array",
|
|
1485
1435
|
extra: { weak: true }
|
|
1486
1436
|
};
|
|
1487
1437
|
function BatchVariableSelector(props) {
|
|
1488
|
-
return /* @__PURE__ */
|
|
1438
|
+
return /* @__PURE__ */ React19.createElement(PrivateScopeProvider, null, /* @__PURE__ */ React19.createElement(VariableSelector, { ...props, includeSchema: batchVariableSchema }));
|
|
1489
1439
|
}
|
|
1490
1440
|
|
|
1491
1441
|
// src/components/dynamic-value-input/index.tsx
|
|
1492
|
-
import
|
|
1442
|
+
import React20 from "react";
|
|
1493
1443
|
import { JsonSchemaUtils as JsonSchemaUtils3 } from "@flowgram.ai/json-schema";
|
|
1494
|
-
import { IconButton as
|
|
1444
|
+
import { IconButton as IconButton3 } from "@douyinfe/semi-ui";
|
|
1495
1445
|
import { IconSetting } from "@douyinfe/semi-icons";
|
|
1496
1446
|
|
|
1497
1447
|
// src/components/dynamic-value-input/styles.tsx
|
|
@@ -1540,11 +1490,11 @@ var UITrigger = styled4.div`
|
|
|
1540
1490
|
`;
|
|
1541
1491
|
|
|
1542
1492
|
// src/components/dynamic-value-input/hooks.ts
|
|
1543
|
-
import { useMemo as
|
|
1493
|
+
import { useMemo as useMemo5, useState as useState4 } from "react";
|
|
1544
1494
|
import { useScopeAvailable } from "@flowgram.ai/editor";
|
|
1545
1495
|
function useRefVariable(value) {
|
|
1546
1496
|
const available = useScopeAvailable();
|
|
1547
|
-
const refVariable =
|
|
1497
|
+
const refVariable = useMemo5(() => {
|
|
1548
1498
|
if (value?.type === "ref") {
|
|
1549
1499
|
return available.getByKeyPath(value.content);
|
|
1550
1500
|
}
|
|
@@ -1556,11 +1506,11 @@ function useSelectSchema(schemaFromProps, constantProps, value) {
|
|
|
1556
1506
|
if (value?.type === "constant") {
|
|
1557
1507
|
defaultSelectSchema = value?.schema || defaultSelectSchema;
|
|
1558
1508
|
}
|
|
1559
|
-
const [selectSchema, setSelectSchema] =
|
|
1509
|
+
const [selectSchema, setSelectSchema] = useState4(defaultSelectSchema);
|
|
1560
1510
|
return [selectSchema, setSelectSchema];
|
|
1561
1511
|
}
|
|
1562
1512
|
function useIncludeSchema(schemaFromProps) {
|
|
1563
|
-
const includeSchema =
|
|
1513
|
+
const includeSchema = useMemo5(() => {
|
|
1564
1514
|
if (!schemaFromProps) {
|
|
1565
1515
|
return;
|
|
1566
1516
|
}
|
|
@@ -1586,13 +1536,13 @@ function DynamicValueInput({
|
|
|
1586
1536
|
const includeSchema = useIncludeSchema(schemaFromProps);
|
|
1587
1537
|
const renderTypeSelector = () => {
|
|
1588
1538
|
if (schemaFromProps) {
|
|
1589
|
-
return /* @__PURE__ */
|
|
1539
|
+
return /* @__PURE__ */ React20.createElement(TypeSelector, { value: schemaFromProps, readonly: true });
|
|
1590
1540
|
}
|
|
1591
1541
|
if (value?.type === "ref") {
|
|
1592
1542
|
const schema = refVariable?.type ? JsonSchemaUtils3.astToSchema(refVariable?.type) : void 0;
|
|
1593
|
-
return /* @__PURE__ */
|
|
1543
|
+
return /* @__PURE__ */ React20.createElement(TypeSelector, { value: schema, readonly: true });
|
|
1594
1544
|
}
|
|
1595
|
-
return /* @__PURE__ */
|
|
1545
|
+
return /* @__PURE__ */ React20.createElement(
|
|
1596
1546
|
TypeSelector,
|
|
1597
1547
|
{
|
|
1598
1548
|
value: selectSchema,
|
|
@@ -1620,8 +1570,8 @@ function DynamicValueInput({
|
|
|
1620
1570
|
};
|
|
1621
1571
|
const renderMain = () => {
|
|
1622
1572
|
if (value?.type === "ref") {
|
|
1623
|
-
return /* @__PURE__ */
|
|
1624
|
-
|
|
1573
|
+
return /* @__PURE__ */ React20.createElement(
|
|
1574
|
+
InjectVariableSelector,
|
|
1625
1575
|
{
|
|
1626
1576
|
style: { width: "100%" },
|
|
1627
1577
|
value: value?.content,
|
|
@@ -1632,7 +1582,7 @@ function DynamicValueInput({
|
|
|
1632
1582
|
);
|
|
1633
1583
|
}
|
|
1634
1584
|
const constantSchema = schemaFromProps || selectSchema || { type: "string" };
|
|
1635
|
-
return /* @__PURE__ */
|
|
1585
|
+
return /* @__PURE__ */ React20.createElement(
|
|
1636
1586
|
ConstantInput,
|
|
1637
1587
|
{
|
|
1638
1588
|
value: value?.content,
|
|
@@ -1640,8 +1590,8 @@ function DynamicValueInput({
|
|
|
1640
1590
|
schema: constantSchema || { type: "string" },
|
|
1641
1591
|
readonly,
|
|
1642
1592
|
strategies: [...constantProps?.strategies || []],
|
|
1643
|
-
fallbackRenderer: () => /* @__PURE__ */
|
|
1644
|
-
|
|
1593
|
+
fallbackRenderer: () => /* @__PURE__ */ React20.createElement(
|
|
1594
|
+
InjectVariableSelector,
|
|
1645
1595
|
{
|
|
1646
1596
|
style: { width: "100%" },
|
|
1647
1597
|
onChange: (_v) => onChange(_v ? { type: "ref", content: _v } : void 0),
|
|
@@ -1653,23 +1603,25 @@ function DynamicValueInput({
|
|
|
1653
1603
|
}
|
|
1654
1604
|
);
|
|
1655
1605
|
};
|
|
1656
|
-
const renderTrigger = () => /* @__PURE__ */
|
|
1657
|
-
|
|
1606
|
+
const renderTrigger = () => /* @__PURE__ */ React20.createElement(
|
|
1607
|
+
InjectVariableSelector,
|
|
1658
1608
|
{
|
|
1659
1609
|
style: { width: "100%" },
|
|
1660
1610
|
value: value?.type === "ref" ? value?.content : void 0,
|
|
1661
1611
|
onChange: (_v) => onChange({ type: "ref", content: _v }),
|
|
1662
1612
|
includeSchema,
|
|
1663
1613
|
readonly,
|
|
1664
|
-
triggerRender: () => /* @__PURE__ */
|
|
1614
|
+
triggerRender: () => /* @__PURE__ */ React20.createElement(IconButton3, { disabled: readonly, size: "small", icon: /* @__PURE__ */ React20.createElement(IconSetting, { size: "small" }) })
|
|
1665
1615
|
}
|
|
1666
1616
|
);
|
|
1667
|
-
return /* @__PURE__ */
|
|
1617
|
+
return /* @__PURE__ */ React20.createElement(UIContainer2, { style }, /* @__PURE__ */ React20.createElement(UIType2, null, renderTypeSelector()), /* @__PURE__ */ React20.createElement(UIMain, null, renderMain()), /* @__PURE__ */ React20.createElement(UITrigger, null, renderTrigger()));
|
|
1668
1618
|
}
|
|
1619
|
+
DynamicValueInput.renderKey = "dynamic-value-input-render-key";
|
|
1620
|
+
var InjectDynamicValueInput = createInjectMaterial(DynamicValueInput);
|
|
1669
1621
|
|
|
1670
1622
|
// src/components/condition-row/index.tsx
|
|
1671
|
-
import
|
|
1672
|
-
import { I18n as
|
|
1623
|
+
import React22, { useMemo as useMemo8 } from "react";
|
|
1624
|
+
import { I18n as I18n11 } from "@flowgram.ai/editor";
|
|
1673
1625
|
import { Input as Input4 } from "@douyinfe/semi-ui";
|
|
1674
1626
|
|
|
1675
1627
|
// src/components/condition-row/styles.tsx
|
|
@@ -1695,7 +1647,7 @@ var UIValues = styled5.div`
|
|
|
1695
1647
|
`;
|
|
1696
1648
|
|
|
1697
1649
|
// src/components/condition-row/hooks/useRule.ts
|
|
1698
|
-
import { useMemo as
|
|
1650
|
+
import { useMemo as useMemo6 } from "react";
|
|
1699
1651
|
import { JsonSchemaUtils as JsonSchemaUtils4 } from "@flowgram.ai/json-schema";
|
|
1700
1652
|
import { useScopeAvailable as useScopeAvailable2 } from "@flowgram.ai/editor";
|
|
1701
1653
|
|
|
@@ -1822,12 +1774,12 @@ var defaultOpConfigs = {
|
|
|
1822
1774
|
// src/components/condition-row/hooks/useRule.ts
|
|
1823
1775
|
function useRule(left, userRules) {
|
|
1824
1776
|
const available = useScopeAvailable2();
|
|
1825
|
-
const rules =
|
|
1826
|
-
const variable =
|
|
1777
|
+
const rules = useMemo6(() => ({ ...defaultRules, ...userRules || {} }), [userRules]);
|
|
1778
|
+
const variable = useMemo6(() => {
|
|
1827
1779
|
if (!left) return void 0;
|
|
1828
1780
|
return available.getByKeyPath(left.content);
|
|
1829
1781
|
}, [available, left]);
|
|
1830
|
-
const rule =
|
|
1782
|
+
const rule = useMemo6(() => {
|
|
1831
1783
|
if (!variable) return void 0;
|
|
1832
1784
|
const schema = JsonSchemaUtils4.astToSchema(variable.type, { drilldown: false });
|
|
1833
1785
|
return rules[schema?.type];
|
|
@@ -1836,22 +1788,22 @@ function useRule(left, userRules) {
|
|
|
1836
1788
|
}
|
|
1837
1789
|
|
|
1838
1790
|
// src/components/condition-row/hooks/useOp.tsx
|
|
1839
|
-
import
|
|
1840
|
-
import { I18n as
|
|
1791
|
+
import React21, { useMemo as useMemo7 } from "react";
|
|
1792
|
+
import { I18n as I18n10 } from "@flowgram.ai/editor";
|
|
1841
1793
|
import { Button as Button2, Select as Select2 } from "@douyinfe/semi-ui";
|
|
1842
1794
|
import { IconChevronDownStroked as IconChevronDownStroked2 } from "@douyinfe/semi-icons";
|
|
1843
1795
|
function useOp({ rule, op, onChange, readonly, userOps }) {
|
|
1844
|
-
const options =
|
|
1796
|
+
const options = useMemo7(
|
|
1845
1797
|
() => Object.keys(rule || {}).map((_op) => ({
|
|
1846
1798
|
...defaultOpConfigs[_op] || {},
|
|
1847
1799
|
...userOps?.[_op] || {},
|
|
1848
1800
|
value: _op,
|
|
1849
|
-
label:
|
|
1801
|
+
label: I18n10.t(userOps?.[_op]?.label || defaultOpConfigs[_op]?.label)
|
|
1850
1802
|
})),
|
|
1851
1803
|
[rule, userOps]
|
|
1852
1804
|
);
|
|
1853
|
-
const opConfig =
|
|
1854
|
-
const renderOpSelect = () => /* @__PURE__ */
|
|
1805
|
+
const opConfig = useMemo7(() => defaultOpConfigs[op], [op]);
|
|
1806
|
+
const renderOpSelect = () => /* @__PURE__ */ React21.createElement(
|
|
1855
1807
|
Select2,
|
|
1856
1808
|
{
|
|
1857
1809
|
style: { height: 22 },
|
|
@@ -1862,7 +1814,7 @@ function useOp({ rule, op, onChange, readonly, userOps }) {
|
|
|
1862
1814
|
onChange: (v) => {
|
|
1863
1815
|
onChange(v);
|
|
1864
1816
|
},
|
|
1865
|
-
triggerRender: ({ value }) => /* @__PURE__ */
|
|
1817
|
+
triggerRender: ({ value }) => /* @__PURE__ */ React21.createElement(Button2, { size: "small", disabled: !rule }, opConfig?.abbreviation || /* @__PURE__ */ React21.createElement(IconChevronDownStroked2, { size: "small" }))
|
|
1866
1818
|
}
|
|
1867
1819
|
);
|
|
1868
1820
|
return { renderOpSelect, opConfig };
|
|
@@ -1889,12 +1841,12 @@ function ConditionRow({
|
|
|
1889
1841
|
readonly,
|
|
1890
1842
|
userOps: ruleConfig.ops
|
|
1891
1843
|
});
|
|
1892
|
-
const targetSchema =
|
|
1844
|
+
const targetSchema = useMemo8(() => {
|
|
1893
1845
|
const targetType = rule?.[operator || ""] || null;
|
|
1894
1846
|
return targetType ? { type: targetType, extra: { weak: true } } : null;
|
|
1895
1847
|
}, [rule, opConfig]);
|
|
1896
|
-
return /* @__PURE__ */
|
|
1897
|
-
|
|
1848
|
+
return /* @__PURE__ */ React22.createElement(UIContainer3, { style }, /* @__PURE__ */ React22.createElement(UIOperator, null, renderOpSelect()), /* @__PURE__ */ React22.createElement(UIValues, null, /* @__PURE__ */ React22.createElement(UILeft, null, /* @__PURE__ */ React22.createElement(
|
|
1849
|
+
InjectVariableSelector,
|
|
1898
1850
|
{
|
|
1899
1851
|
readonly,
|
|
1900
1852
|
style: { width: "100%" },
|
|
@@ -1907,34 +1859,34 @@ function ConditionRow({
|
|
|
1907
1859
|
}
|
|
1908
1860
|
})
|
|
1909
1861
|
}
|
|
1910
|
-
)), /* @__PURE__ */
|
|
1911
|
-
|
|
1862
|
+
)), /* @__PURE__ */ React22.createElement(UIRight, null, targetSchema ? /* @__PURE__ */ React22.createElement(
|
|
1863
|
+
InjectDynamicValueInput,
|
|
1912
1864
|
{
|
|
1913
1865
|
readonly: readonly || !rule,
|
|
1914
1866
|
value: right,
|
|
1915
1867
|
schema: targetSchema,
|
|
1916
1868
|
onChange: (v) => onChange({ ...value, right: v })
|
|
1917
1869
|
}
|
|
1918
|
-
) : /* @__PURE__ */
|
|
1870
|
+
) : /* @__PURE__ */ React22.createElement(
|
|
1919
1871
|
Input4,
|
|
1920
1872
|
{
|
|
1921
1873
|
size: "small",
|
|
1922
1874
|
disabled: true,
|
|
1923
1875
|
style: { pointerEvents: "none" },
|
|
1924
|
-
value: opConfig?.rightDisplay ||
|
|
1876
|
+
value: opConfig?.rightDisplay || I18n11.t("Empty")
|
|
1925
1877
|
}
|
|
1926
1878
|
))));
|
|
1927
1879
|
}
|
|
1928
1880
|
|
|
1929
1881
|
// src/components/batch-outputs/index.tsx
|
|
1930
|
-
import
|
|
1882
|
+
import React23 from "react";
|
|
1931
1883
|
import { Button as Button3, Input as Input5 } from "@douyinfe/semi-ui";
|
|
1932
1884
|
import { IconDelete, IconPlus as IconPlus2 } from "@douyinfe/semi-icons";
|
|
1933
1885
|
|
|
1934
1886
|
// src/hooks/use-object-list/index.tsx
|
|
1935
|
-
import { useEffect as useEffect4, useState as
|
|
1887
|
+
import { useEffect as useEffect4, useState as useState5 } from "react";
|
|
1936
1888
|
import { nanoid } from "nanoid";
|
|
1937
|
-
import { difference, get, isObject, set } from "lodash";
|
|
1889
|
+
import { difference as difference2, get, isObject as isObject2, set } from "lodash";
|
|
1938
1890
|
function genId2() {
|
|
1939
1891
|
return nanoid();
|
|
1940
1892
|
}
|
|
@@ -1943,12 +1895,12 @@ function useObjectList({
|
|
|
1943
1895
|
onChange,
|
|
1944
1896
|
sortIndexKey
|
|
1945
1897
|
}) {
|
|
1946
|
-
const [list, setList] =
|
|
1898
|
+
const [list, setList] = useState5([]);
|
|
1947
1899
|
useEffect4(() => {
|
|
1948
1900
|
setList((_prevList) => {
|
|
1949
1901
|
const newKeys = Object.entries(value || {}).sort((a, b) => get(a[1], sortIndexKey || 0) - get(b[1], sortIndexKey || 0)).map(([key]) => key);
|
|
1950
1902
|
const oldKeys = _prevList.map((item) => item.key).filter(Boolean);
|
|
1951
|
-
const addKeys =
|
|
1903
|
+
const addKeys = difference2(newKeys, oldKeys);
|
|
1952
1904
|
return _prevList.filter((item) => !item.key || newKeys.includes(item.key)).map((item) => ({
|
|
1953
1905
|
id: item.id,
|
|
1954
1906
|
key: item.key,
|
|
@@ -1984,7 +1936,7 @@ function useObjectList({
|
|
|
1984
1936
|
onChange(
|
|
1985
1937
|
Object.fromEntries(
|
|
1986
1938
|
nextList.filter((item) => item.key).map((item) => [item.key, item.value]).map((_res, idx) => {
|
|
1987
|
-
if (
|
|
1939
|
+
if (isObject2(_res[1]) && sortIndexKey) {
|
|
1988
1940
|
set(_res[1], sortIndexKey, idx);
|
|
1989
1941
|
}
|
|
1990
1942
|
return _res;
|
|
@@ -2045,7 +1997,7 @@ var UIRow2 = styled6.div`
|
|
|
2045
1997
|
function BatchOutputs(props) {
|
|
2046
1998
|
const { readonly, style } = props;
|
|
2047
1999
|
const { list, add, updateKey, updateValue, remove } = useObjectList(props);
|
|
2048
|
-
return /* @__PURE__ */
|
|
2000
|
+
return /* @__PURE__ */ React23.createElement("div", null, /* @__PURE__ */ React23.createElement(UIRows, { style }, list.map((item) => /* @__PURE__ */ React23.createElement(UIRow2, { key: item.id }, /* @__PURE__ */ React23.createElement(
|
|
2049
2001
|
Input5,
|
|
2050
2002
|
{
|
|
2051
2003
|
style: { width: 100 },
|
|
@@ -2054,27 +2006,27 @@ function BatchOutputs(props) {
|
|
|
2054
2006
|
value: item.key,
|
|
2055
2007
|
onChange: (v) => updateKey(item.id, v)
|
|
2056
2008
|
}
|
|
2057
|
-
), /* @__PURE__ */
|
|
2058
|
-
|
|
2009
|
+
), /* @__PURE__ */ React23.createElement(
|
|
2010
|
+
InjectVariableSelector,
|
|
2059
2011
|
{
|
|
2060
2012
|
style: { flexGrow: 1 },
|
|
2061
2013
|
readonly,
|
|
2062
2014
|
value: item.value?.content,
|
|
2063
2015
|
onChange: (v) => updateValue(item.id, { type: "ref", content: v })
|
|
2064
2016
|
}
|
|
2065
|
-
), /* @__PURE__ */
|
|
2017
|
+
), /* @__PURE__ */ React23.createElement(
|
|
2066
2018
|
Button3,
|
|
2067
2019
|
{
|
|
2068
2020
|
disabled: readonly,
|
|
2069
|
-
icon: /* @__PURE__ */
|
|
2021
|
+
icon: /* @__PURE__ */ React23.createElement(IconDelete, null),
|
|
2070
2022
|
size: "small",
|
|
2071
2023
|
onClick: () => remove(item.id)
|
|
2072
2024
|
}
|
|
2073
|
-
)))), /* @__PURE__ */
|
|
2025
|
+
)))), /* @__PURE__ */ React23.createElement(Button3, { disabled: readonly, icon: /* @__PURE__ */ React23.createElement(IconPlus2, null), size: "small", onClick: add }, "Add"));
|
|
2074
2026
|
}
|
|
2075
2027
|
|
|
2076
2028
|
// src/components/prompt-editor/index.tsx
|
|
2077
|
-
import
|
|
2029
|
+
import React24, { useEffect as useEffect5, useRef as useRef2 } from "react";
|
|
2078
2030
|
import { Renderer, EditorProvider as EditorProvider2, ActiveLinePlaceholder as ActiveLinePlaceholder2 } from "@coze-editor/editor/react";
|
|
2079
2031
|
import preset2 from "@coze-editor/editor/preset-prompt";
|
|
2080
2032
|
|
|
@@ -2218,13 +2170,13 @@ function PromptEditor(props) {
|
|
|
2218
2170
|
children,
|
|
2219
2171
|
disableMarkdownHighlight
|
|
2220
2172
|
} = props || {};
|
|
2221
|
-
const editorRef =
|
|
2173
|
+
const editorRef = useRef2(null);
|
|
2222
2174
|
useEffect5(() => {
|
|
2223
2175
|
if (editorRef.current?.getValue() !== value?.content) {
|
|
2224
2176
|
editorRef.current?.setValue(String(value?.content || ""));
|
|
2225
2177
|
}
|
|
2226
2178
|
}, [value]);
|
|
2227
|
-
return /* @__PURE__ */
|
|
2179
|
+
return /* @__PURE__ */ React24.createElement(UIContainer4, { $hasError: hasError, style }, /* @__PURE__ */ React24.createElement(EditorProvider2, null, /* @__PURE__ */ React24.createElement(
|
|
2228
2180
|
Renderer,
|
|
2229
2181
|
{
|
|
2230
2182
|
didMount: (editor) => {
|
|
@@ -2241,14 +2193,14 @@ function PromptEditor(props) {
|
|
|
2241
2193
|
onChange({ type: "template", content: e.value });
|
|
2242
2194
|
}
|
|
2243
2195
|
}
|
|
2244
|
-
), activeLinePlaceholder && /* @__PURE__ */
|
|
2196
|
+
), activeLinePlaceholder && /* @__PURE__ */ React24.createElement(ActiveLinePlaceholder2, null, activeLinePlaceholder), !disableMarkdownHighlight && /* @__PURE__ */ React24.createElement(markdown_default, null), /* @__PURE__ */ React24.createElement(language_support_default, null), /* @__PURE__ */ React24.createElement(jinja_default, null), children));
|
|
2245
2197
|
}
|
|
2246
2198
|
|
|
2247
2199
|
// src/components/prompt-editor-with-variables/index.tsx
|
|
2248
|
-
import
|
|
2200
|
+
import React27 from "react";
|
|
2249
2201
|
|
|
2250
2202
|
// src/components/prompt-editor-with-variables/extensions/variable-tree.tsx
|
|
2251
|
-
import
|
|
2203
|
+
import React25, { useEffect as useEffect6, useState as useState6 } from "react";
|
|
2252
2204
|
import { Popover as Popover2, Tree } from "@douyinfe/semi-ui";
|
|
2253
2205
|
import {
|
|
2254
2206
|
Mention,
|
|
@@ -2257,9 +2209,9 @@ import {
|
|
|
2257
2209
|
PositionMirror
|
|
2258
2210
|
} from "@coze-editor/editor/react";
|
|
2259
2211
|
function VariableTree() {
|
|
2260
|
-
const [posKey, setPosKey] =
|
|
2261
|
-
const [visible, setVisible] =
|
|
2262
|
-
const [position, setPosition] =
|
|
2212
|
+
const [posKey, setPosKey] = useState6("");
|
|
2213
|
+
const [visible, setVisible] = useState6(false);
|
|
2214
|
+
const [position, setPosition] = useState6(-1);
|
|
2263
2215
|
const editor = useEditor();
|
|
2264
2216
|
function insert(variablePath) {
|
|
2265
2217
|
const range = getCurrentMentionReplaceRange(editor.$view.state);
|
|
@@ -2282,14 +2234,14 @@ function VariableTree() {
|
|
|
2282
2234
|
}
|
|
2283
2235
|
}, [editor, visible]);
|
|
2284
2236
|
const treeData = useVariableTree({});
|
|
2285
|
-
return /* @__PURE__ */
|
|
2237
|
+
return /* @__PURE__ */ React25.createElement(React25.Fragment, null, /* @__PURE__ */ React25.createElement(Mention, { triggerCharacters: ["{", "{}", "@"], onOpenChange: handleOpenChange }), /* @__PURE__ */ React25.createElement(
|
|
2286
2238
|
Popover2,
|
|
2287
2239
|
{
|
|
2288
2240
|
visible,
|
|
2289
2241
|
trigger: "custom",
|
|
2290
2242
|
position: "topLeft",
|
|
2291
2243
|
rePosKey: posKey,
|
|
2292
|
-
content: /* @__PURE__ */
|
|
2244
|
+
content: /* @__PURE__ */ React25.createElement("div", { style: { width: 300 } }, /* @__PURE__ */ React25.createElement(
|
|
2293
2245
|
Tree,
|
|
2294
2246
|
{
|
|
2295
2247
|
treeData,
|
|
@@ -2299,7 +2251,7 @@ function VariableTree() {
|
|
|
2299
2251
|
}
|
|
2300
2252
|
))
|
|
2301
2253
|
},
|
|
2302
|
-
/* @__PURE__ */
|
|
2254
|
+
/* @__PURE__ */ React25.createElement(
|
|
2303
2255
|
PositionMirror,
|
|
2304
2256
|
{
|
|
2305
2257
|
position,
|
|
@@ -2311,7 +2263,7 @@ function VariableTree() {
|
|
|
2311
2263
|
|
|
2312
2264
|
// src/components/prompt-editor-with-variables/extensions/variable-tag.tsx
|
|
2313
2265
|
import ReactDOM from "react-dom";
|
|
2314
|
-
import
|
|
2266
|
+
import React26, { useLayoutEffect as useLayoutEffect4 } from "react";
|
|
2315
2267
|
import { isEqual, last } from "lodash";
|
|
2316
2268
|
import {
|
|
2317
2269
|
Disposable,
|
|
@@ -2373,7 +2325,7 @@ var VariableTagWidget = class extends WidgetType {
|
|
|
2373
2325
|
this.toDispose = new DisposableCollection();
|
|
2374
2326
|
this.renderIcon = (icon) => {
|
|
2375
2327
|
if (typeof icon === "string") {
|
|
2376
|
-
return /* @__PURE__ */
|
|
2328
|
+
return /* @__PURE__ */ React26.createElement("img", { style: { marginRight: 8 }, width: 12, height: 12, src: icon });
|
|
2377
2329
|
}
|
|
2378
2330
|
return icon;
|
|
2379
2331
|
};
|
|
@@ -2386,21 +2338,21 @@ var VariableTagWidget = class extends WidgetType {
|
|
|
2386
2338
|
renderVariable(v) {
|
|
2387
2339
|
if (!v) {
|
|
2388
2340
|
this.renderReact(
|
|
2389
|
-
/* @__PURE__ */
|
|
2341
|
+
/* @__PURE__ */ React26.createElement(UITag2, { prefixIcon: /* @__PURE__ */ React26.createElement(IconIssueStroked2, null), color: "amber" }, "Unknown")
|
|
2390
2342
|
);
|
|
2391
2343
|
return;
|
|
2392
2344
|
}
|
|
2393
2345
|
const rootField = last(v.parentFields) || v;
|
|
2394
2346
|
const isRoot = v.parentFields.length === 0;
|
|
2395
|
-
const rootTitle = /* @__PURE__ */
|
|
2347
|
+
const rootTitle = /* @__PURE__ */ React26.createElement(UIRootTitle2, null, rootField?.meta.title ? `${rootField.meta.title} ${isRoot ? "" : "-"} ` : "");
|
|
2396
2348
|
const rootIcon = this.renderIcon(rootField?.meta.icon);
|
|
2397
2349
|
this.renderReact(
|
|
2398
|
-
/* @__PURE__ */
|
|
2350
|
+
/* @__PURE__ */ React26.createElement(
|
|
2399
2351
|
Popover3,
|
|
2400
2352
|
{
|
|
2401
|
-
content: /* @__PURE__ */
|
|
2353
|
+
content: /* @__PURE__ */ React26.createElement(UIPopoverContent2, null, rootIcon, rootTitle, /* @__PURE__ */ React26.createElement(UIVarName2, null, v?.keyPath.slice(1).join(".")))
|
|
2402
2354
|
},
|
|
2403
|
-
/* @__PURE__ */
|
|
2355
|
+
/* @__PURE__ */ React26.createElement(UITag2, { prefixIcon: rootIcon }, rootTitle, !isRoot && /* @__PURE__ */ React26.createElement(UIVarName2, null, v?.key))
|
|
2404
2356
|
)
|
|
2405
2357
|
);
|
|
2406
2358
|
}
|
|
@@ -2474,14 +2426,14 @@ function VariableTagInject() {
|
|
|
2474
2426
|
|
|
2475
2427
|
// src/components/prompt-editor-with-variables/index.tsx
|
|
2476
2428
|
function PromptEditorWithVariables(props) {
|
|
2477
|
-
return /* @__PURE__ */
|
|
2429
|
+
return /* @__PURE__ */ React27.createElement(PromptEditor, { ...props }, /* @__PURE__ */ React27.createElement(VariableTree, null), /* @__PURE__ */ React27.createElement(VariableTagInject, null));
|
|
2478
2430
|
}
|
|
2479
2431
|
|
|
2480
2432
|
// src/components/prompt-editor-with-inputs/index.tsx
|
|
2481
|
-
import
|
|
2433
|
+
import React30 from "react";
|
|
2482
2434
|
|
|
2483
2435
|
// src/components/prompt-editor-with-inputs/extensions/inputs-tree.tsx
|
|
2484
|
-
import
|
|
2436
|
+
import React29, { useEffect as useEffect7, useState as useState7 } from "react";
|
|
2485
2437
|
import { Popover as Popover4 } from "@douyinfe/semi-ui";
|
|
2486
2438
|
import {
|
|
2487
2439
|
Mention as Mention2,
|
|
@@ -2491,7 +2443,7 @@ import {
|
|
|
2491
2443
|
} from "@coze-editor/editor/react";
|
|
2492
2444
|
|
|
2493
2445
|
// src/components/prompt-editor-with-inputs/inputs-picker.tsx
|
|
2494
|
-
import
|
|
2446
|
+
import React28, { useMemo as useMemo9 } from "react";
|
|
2495
2447
|
import { last as last2 } from "lodash";
|
|
2496
2448
|
import {
|
|
2497
2449
|
ASTMatch as ASTMatch3,
|
|
@@ -2535,7 +2487,7 @@ function InputsPicker({
|
|
|
2535
2487
|
children
|
|
2536
2488
|
};
|
|
2537
2489
|
};
|
|
2538
|
-
const treeData =
|
|
2490
|
+
const treeData = useMemo9(
|
|
2539
2491
|
() => Object.entries(inputsValues).map(([key, value]) => {
|
|
2540
2492
|
if (value?.type === "ref") {
|
|
2541
2493
|
const variable = available.getByKeyPath(value.content || []);
|
|
@@ -2551,14 +2503,14 @@ function InputsPicker({
|
|
|
2551
2503
|
}),
|
|
2552
2504
|
[]
|
|
2553
2505
|
);
|
|
2554
|
-
return /* @__PURE__ */
|
|
2506
|
+
return /* @__PURE__ */ React28.createElement(Tree2, { treeData, onSelect: (v) => onSelect(v) });
|
|
2555
2507
|
}
|
|
2556
2508
|
|
|
2557
2509
|
// src/components/prompt-editor-with-inputs/extensions/inputs-tree.tsx
|
|
2558
2510
|
function InputsTree({ inputsValues }) {
|
|
2559
|
-
const [posKey, setPosKey] =
|
|
2560
|
-
const [visible, setVisible] =
|
|
2561
|
-
const [position, setPosition] =
|
|
2511
|
+
const [posKey, setPosKey] = useState7("");
|
|
2512
|
+
const [visible, setVisible] = useState7(false);
|
|
2513
|
+
const [position, setPosition] = useState7(-1);
|
|
2562
2514
|
const editor = useEditor2();
|
|
2563
2515
|
function insert(variablePath) {
|
|
2564
2516
|
const range = getCurrentMentionReplaceRange2(editor.$view.state);
|
|
@@ -2580,14 +2532,14 @@ function InputsTree({ inputsValues }) {
|
|
|
2580
2532
|
return;
|
|
2581
2533
|
}
|
|
2582
2534
|
}, [editor, visible]);
|
|
2583
|
-
return /* @__PURE__ */
|
|
2535
|
+
return /* @__PURE__ */ React29.createElement(React29.Fragment, null, /* @__PURE__ */ React29.createElement(Mention2, { triggerCharacters: ["{", "{}", "@"], onOpenChange: handleOpenChange }), /* @__PURE__ */ React29.createElement(
|
|
2584
2536
|
Popover4,
|
|
2585
2537
|
{
|
|
2586
2538
|
visible,
|
|
2587
2539
|
trigger: "custom",
|
|
2588
2540
|
position: "topLeft",
|
|
2589
2541
|
rePosKey: posKey,
|
|
2590
|
-
content: /* @__PURE__ */
|
|
2542
|
+
content: /* @__PURE__ */ React29.createElement("div", { style: { width: 300 } }, /* @__PURE__ */ React29.createElement(
|
|
2591
2543
|
InputsPicker,
|
|
2592
2544
|
{
|
|
2593
2545
|
inputsValues,
|
|
@@ -2597,7 +2549,7 @@ function InputsTree({ inputsValues }) {
|
|
|
2597
2549
|
}
|
|
2598
2550
|
))
|
|
2599
2551
|
},
|
|
2600
|
-
/* @__PURE__ */
|
|
2552
|
+
/* @__PURE__ */ React29.createElement(
|
|
2601
2553
|
PositionMirror2,
|
|
2602
2554
|
{
|
|
2603
2555
|
position,
|
|
@@ -2609,15 +2561,15 @@ function InputsTree({ inputsValues }) {
|
|
|
2609
2561
|
|
|
2610
2562
|
// src/components/prompt-editor-with-inputs/index.tsx
|
|
2611
2563
|
function PromptEditorWithInputs({ inputsValues, ...restProps }) {
|
|
2612
|
-
return /* @__PURE__ */
|
|
2564
|
+
return /* @__PURE__ */ React30.createElement(PromptEditor, { ...restProps }, /* @__PURE__ */ React30.createElement(InputsTree, { inputsValues }));
|
|
2613
2565
|
}
|
|
2614
2566
|
|
|
2615
2567
|
// src/components/json-editor-with-variables/index.tsx
|
|
2616
|
-
import
|
|
2568
|
+
import React33 from "react";
|
|
2617
2569
|
import { transformerCreator } from "@coze-editor/editor/preset-code";
|
|
2618
2570
|
|
|
2619
2571
|
// src/components/json-editor-with-variables/extensions/variable-tree.tsx
|
|
2620
|
-
import
|
|
2572
|
+
import React31, { useEffect as useEffect8, useState as useState8 } from "react";
|
|
2621
2573
|
import { Popover as Popover5, Tree as Tree3 } from "@douyinfe/semi-ui";
|
|
2622
2574
|
import {
|
|
2623
2575
|
Mention as Mention3,
|
|
@@ -2626,9 +2578,9 @@ import {
|
|
|
2626
2578
|
PositionMirror as PositionMirror3
|
|
2627
2579
|
} from "@coze-editor/editor/react";
|
|
2628
2580
|
function VariableTree2() {
|
|
2629
|
-
const [posKey, setPosKey] =
|
|
2630
|
-
const [visible, setVisible] =
|
|
2631
|
-
const [position, setPosition] =
|
|
2581
|
+
const [posKey, setPosKey] = useState8("");
|
|
2582
|
+
const [visible, setVisible] = useState8(false);
|
|
2583
|
+
const [position, setPosition] = useState8(-1);
|
|
2632
2584
|
const editor = useEditor3();
|
|
2633
2585
|
function insert(variablePath) {
|
|
2634
2586
|
const range = getCurrentMentionReplaceRange3(editor.$view.state);
|
|
@@ -2651,14 +2603,14 @@ function VariableTree2() {
|
|
|
2651
2603
|
}
|
|
2652
2604
|
}, [editor, visible]);
|
|
2653
2605
|
const treeData = useVariableTree({});
|
|
2654
|
-
return /* @__PURE__ */
|
|
2606
|
+
return /* @__PURE__ */ React31.createElement(React31.Fragment, null, /* @__PURE__ */ React31.createElement(Mention3, { triggerCharacters: ["@"], onOpenChange: handleOpenChange }), /* @__PURE__ */ React31.createElement(
|
|
2655
2607
|
Popover5,
|
|
2656
2608
|
{
|
|
2657
2609
|
visible,
|
|
2658
2610
|
trigger: "custom",
|
|
2659
2611
|
position: "topLeft",
|
|
2660
2612
|
rePosKey: posKey,
|
|
2661
|
-
content: /* @__PURE__ */
|
|
2613
|
+
content: /* @__PURE__ */ React31.createElement("div", { style: { width: 300 } }, /* @__PURE__ */ React31.createElement(
|
|
2662
2614
|
Tree3,
|
|
2663
2615
|
{
|
|
2664
2616
|
treeData,
|
|
@@ -2668,7 +2620,7 @@ function VariableTree2() {
|
|
|
2668
2620
|
}
|
|
2669
2621
|
))
|
|
2670
2622
|
},
|
|
2671
|
-
/* @__PURE__ */
|
|
2623
|
+
/* @__PURE__ */ React31.createElement(
|
|
2672
2624
|
PositionMirror3,
|
|
2673
2625
|
{
|
|
2674
2626
|
position,
|
|
@@ -2679,7 +2631,7 @@ function VariableTree2() {
|
|
|
2679
2631
|
}
|
|
2680
2632
|
|
|
2681
2633
|
// src/components/json-editor-with-variables/extensions/variable-tag.tsx
|
|
2682
|
-
import
|
|
2634
|
+
import React32, { useLayoutEffect as useLayoutEffect5 } from "react";
|
|
2683
2635
|
import { createRoot } from "react-dom/client";
|
|
2684
2636
|
import { isEqual as isEqual2, last as last3 } from "lodash";
|
|
2685
2637
|
import {
|
|
@@ -2742,7 +2694,7 @@ var VariableTagWidget2 = class extends WidgetType2 {
|
|
|
2742
2694
|
this.toDispose = new DisposableCollection2();
|
|
2743
2695
|
this.renderIcon = (icon) => {
|
|
2744
2696
|
if (typeof icon === "string") {
|
|
2745
|
-
return /* @__PURE__ */
|
|
2697
|
+
return /* @__PURE__ */ React32.createElement("img", { style: { marginRight: 8 }, width: 12, height: 12, src: icon });
|
|
2746
2698
|
}
|
|
2747
2699
|
return icon;
|
|
2748
2700
|
};
|
|
@@ -2752,20 +2704,20 @@ var VariableTagWidget2 = class extends WidgetType2 {
|
|
|
2752
2704
|
renderVariable(v) {
|
|
2753
2705
|
if (!v) {
|
|
2754
2706
|
this.root.render(
|
|
2755
|
-
/* @__PURE__ */
|
|
2707
|
+
/* @__PURE__ */ React32.createElement(UITag3, { prefixIcon: /* @__PURE__ */ React32.createElement(IconIssueStroked3, null), color: "amber" }, "Unknown")
|
|
2756
2708
|
);
|
|
2757
2709
|
return;
|
|
2758
2710
|
}
|
|
2759
2711
|
const rootField = last3(v.parentFields);
|
|
2760
|
-
const rootTitle = /* @__PURE__ */
|
|
2712
|
+
const rootTitle = /* @__PURE__ */ React32.createElement(UIRootTitle3, null, rootField?.meta.title ? `${rootField.meta.title} -` : "");
|
|
2761
2713
|
const rootIcon = this.renderIcon(rootField?.meta.icon);
|
|
2762
2714
|
this.root.render(
|
|
2763
|
-
/* @__PURE__ */
|
|
2715
|
+
/* @__PURE__ */ React32.createElement(
|
|
2764
2716
|
Popover6,
|
|
2765
2717
|
{
|
|
2766
|
-
content: /* @__PURE__ */
|
|
2718
|
+
content: /* @__PURE__ */ React32.createElement(UIPopoverContent3, null, rootIcon, rootTitle, /* @__PURE__ */ React32.createElement(UIVarName3, null, v?.keyPath.slice(1).join(".")))
|
|
2767
2719
|
},
|
|
2768
|
-
/* @__PURE__ */
|
|
2720
|
+
/* @__PURE__ */ React32.createElement(UITag3, { prefixIcon: rootIcon }, rootTitle, /* @__PURE__ */ React32.createElement(UIVarName3, null, v?.key))
|
|
2769
2721
|
)
|
|
2770
2722
|
);
|
|
2771
2723
|
}
|
|
@@ -2867,7 +2819,7 @@ var transformer = transformerCreator((text) => {
|
|
|
2867
2819
|
return text;
|
|
2868
2820
|
});
|
|
2869
2821
|
function JsonEditorWithVariables(props) {
|
|
2870
|
-
return /* @__PURE__ */
|
|
2822
|
+
return /* @__PURE__ */ React33.createElement(
|
|
2871
2823
|
CodeEditor,
|
|
2872
2824
|
{
|
|
2873
2825
|
languageId: "json",
|
|
@@ -2878,14 +2830,15 @@ function JsonEditorWithVariables(props) {
|
|
|
2878
2830
|
...props.options || {}
|
|
2879
2831
|
}
|
|
2880
2832
|
},
|
|
2881
|
-
/* @__PURE__ */
|
|
2882
|
-
/* @__PURE__ */
|
|
2833
|
+
/* @__PURE__ */ React33.createElement(VariableTree2, null),
|
|
2834
|
+
/* @__PURE__ */ React33.createElement(VariableTagInject2, null)
|
|
2883
2835
|
);
|
|
2884
2836
|
}
|
|
2885
2837
|
|
|
2886
2838
|
// src/components/inputs-values/index.tsx
|
|
2887
|
-
import
|
|
2888
|
-
import {
|
|
2839
|
+
import React35 from "react";
|
|
2840
|
+
import { I18n as I18n12 } from "@flowgram.ai/editor";
|
|
2841
|
+
import { Button as Button4, IconButton as IconButton4 } from "@douyinfe/semi-ui";
|
|
2889
2842
|
import { IconDelete as IconDelete2, IconPlus as IconPlus3 } from "@douyinfe/semi-icons";
|
|
2890
2843
|
|
|
2891
2844
|
// src/components/inputs-values/styles.tsx
|
|
@@ -2903,14 +2856,14 @@ var UIRow3 = styled10.div`
|
|
|
2903
2856
|
`;
|
|
2904
2857
|
|
|
2905
2858
|
// src/components/inputs-values/components/blur-input.tsx
|
|
2906
|
-
import
|
|
2859
|
+
import React34, { useEffect as useEffect9, useState as useState9 } from "react";
|
|
2907
2860
|
import Input6 from "@douyinfe/semi-ui/lib/es/input";
|
|
2908
2861
|
function BlurInput2(props) {
|
|
2909
|
-
const [value, setValue] =
|
|
2862
|
+
const [value, setValue] = useState9("");
|
|
2910
2863
|
useEffect9(() => {
|
|
2911
2864
|
setValue(props.value);
|
|
2912
2865
|
}, [props.value]);
|
|
2913
|
-
return /* @__PURE__ */
|
|
2866
|
+
return /* @__PURE__ */ React34.createElement(
|
|
2914
2867
|
Input6,
|
|
2915
2868
|
{
|
|
2916
2869
|
...props,
|
|
@@ -2938,7 +2891,7 @@ function InputsValues({
|
|
|
2938
2891
|
onChange,
|
|
2939
2892
|
sortIndexKey: "extra.index"
|
|
2940
2893
|
});
|
|
2941
|
-
return /* @__PURE__ */
|
|
2894
|
+
return /* @__PURE__ */ React35.createElement("div", null, /* @__PURE__ */ React35.createElement(UIRows2, { style }, list.map((item) => /* @__PURE__ */ React35.createElement(UIRow3, { key: item.id }, /* @__PURE__ */ React35.createElement(
|
|
2942
2895
|
BlurInput2,
|
|
2943
2896
|
{
|
|
2944
2897
|
style: { width: 100, minWidth: 100, maxWidth: 100 },
|
|
@@ -2946,10 +2899,10 @@ function InputsValues({
|
|
|
2946
2899
|
size: "small",
|
|
2947
2900
|
value: item.key,
|
|
2948
2901
|
onChange: (v) => updateKey(item.id, v),
|
|
2949
|
-
placeholder: "Input Key"
|
|
2902
|
+
placeholder: I18n12.t("Input Key")
|
|
2950
2903
|
}
|
|
2951
|
-
), /* @__PURE__ */
|
|
2952
|
-
|
|
2904
|
+
), /* @__PURE__ */ React35.createElement(
|
|
2905
|
+
InjectDynamicValueInput,
|
|
2953
2906
|
{
|
|
2954
2907
|
style: { flexGrow: 1 },
|
|
2955
2908
|
readonly,
|
|
@@ -2962,20 +2915,20 @@ function InputsValues({
|
|
|
2962
2915
|
strategies: [...constantProps?.strategies || []]
|
|
2963
2916
|
}
|
|
2964
2917
|
}
|
|
2965
|
-
), /* @__PURE__ */
|
|
2966
|
-
|
|
2918
|
+
), /* @__PURE__ */ React35.createElement(
|
|
2919
|
+
IconButton4,
|
|
2967
2920
|
{
|
|
2968
2921
|
disabled: readonly,
|
|
2969
2922
|
theme: "borderless",
|
|
2970
|
-
icon: /* @__PURE__ */
|
|
2923
|
+
icon: /* @__PURE__ */ React35.createElement(IconDelete2, { size: "small" }),
|
|
2971
2924
|
size: "small",
|
|
2972
2925
|
onClick: () => remove(item.id)
|
|
2973
2926
|
}
|
|
2974
|
-
)))), /* @__PURE__ */
|
|
2927
|
+
)))), /* @__PURE__ */ React35.createElement(Button4, { disabled: readonly, icon: /* @__PURE__ */ React35.createElement(IconPlus3, null), size: "small", onClick: add }, "Add"));
|
|
2975
2928
|
}
|
|
2976
2929
|
|
|
2977
2930
|
// src/components/display-schema-tree/index.tsx
|
|
2978
|
-
import
|
|
2931
|
+
import React36 from "react";
|
|
2979
2932
|
|
|
2980
2933
|
// src/components/display-schema-tree/styles.tsx
|
|
2981
2934
|
import styled11, { css as css4 } from "styled-components";
|
|
@@ -3059,7 +3012,7 @@ var TreeItem = styled11.div`
|
|
|
3059
3012
|
|
|
3060
3013
|
// src/components/display-schema-tree/index.tsx
|
|
3061
3014
|
function DisplaySchemaTree(props) {
|
|
3062
|
-
return /* @__PURE__ */
|
|
3015
|
+
return /* @__PURE__ */ React36.createElement(SchemaTree, { ...props });
|
|
3063
3016
|
}
|
|
3064
3017
|
function SchemaTree(props) {
|
|
3065
3018
|
const {
|
|
@@ -3075,18 +3028,18 @@ function SchemaTree(props) {
|
|
|
3075
3028
|
const icon = typeManager?.getDisplayIcon(schema);
|
|
3076
3029
|
let properties = drilldown && config ? config.getTypeSchemaProperties(schema) : {};
|
|
3077
3030
|
const childEntries = Object.entries(properties || {});
|
|
3078
|
-
return /* @__PURE__ */
|
|
3031
|
+
return /* @__PURE__ */ React36.createElement(TreeItem, { depth, key: parentKey || "root" }, /* @__PURE__ */ React36.createElement(TreeRow, null, depth !== 0 && /* @__PURE__ */ React36.createElement(HorizontalLine, null), showIcon && icon && React36.cloneElement(icon, {
|
|
3079
3032
|
className: "tree-icon"
|
|
3080
|
-
}), /* @__PURE__ */
|
|
3033
|
+
}), /* @__PURE__ */ React36.createElement(TreeTitle, null, parentKey ? /* @__PURE__ */ React36.createElement(React36.Fragment, null, `${parentKey} (`, title, ")") : title)), childEntries?.length ? /* @__PURE__ */ React36.createElement(TreeLevel, null, childEntries.map(([key, value]) => /* @__PURE__ */ React36.createElement(SchemaTree, { key, ...props, parentKey: key, value, depth: depth + 1 }))) : null);
|
|
3081
3034
|
}
|
|
3082
3035
|
|
|
3083
3036
|
// src/components/display-outputs/index.tsx
|
|
3084
|
-
import
|
|
3037
|
+
import React38, { useEffect as useEffect10 } from "react";
|
|
3085
3038
|
import { JsonSchemaUtils as JsonSchemaUtils5 } from "@flowgram.ai/json-schema";
|
|
3086
3039
|
import { useCurrentScope as useCurrentScope3, useRefresh } from "@flowgram.ai/editor";
|
|
3087
3040
|
|
|
3088
3041
|
// src/components/display-schema-tag/index.tsx
|
|
3089
|
-
import
|
|
3042
|
+
import React37 from "react";
|
|
3090
3043
|
import { Popover as Popover7 } from "@douyinfe/semi-ui";
|
|
3091
3044
|
|
|
3092
3045
|
// src/components/display-schema-tag/styles.ts
|
|
@@ -3115,14 +3068,14 @@ var TitleSpan = styled12.span`
|
|
|
3115
3068
|
function DisplaySchemaTag({ value = {}, showIconInTree, title, warning }) {
|
|
3116
3069
|
const typeManager = useTypeManager();
|
|
3117
3070
|
const icon = typeManager?.getDisplayIcon(value) || typeManager.getDisplayIcon({ type: "unknown" });
|
|
3118
|
-
return /* @__PURE__ */
|
|
3071
|
+
return /* @__PURE__ */ React37.createElement(
|
|
3119
3072
|
Popover7,
|
|
3120
3073
|
{
|
|
3121
|
-
content: /* @__PURE__ */
|
|
3074
|
+
content: /* @__PURE__ */ React37.createElement(PopoverContent, null, /* @__PURE__ */ React37.createElement(DisplaySchemaTree, { value, typeManager, showIcon: showIconInTree }))
|
|
3122
3075
|
},
|
|
3123
|
-
/* @__PURE__ */
|
|
3076
|
+
/* @__PURE__ */ React37.createElement(StyledTag, { color: warning ? "amber" : "white" }, icon && React37.cloneElement(icon, {
|
|
3124
3077
|
className: "tag-icon"
|
|
3125
|
-
}), title && /* @__PURE__ */
|
|
3078
|
+
}), title && /* @__PURE__ */ React37.createElement(TitleSpan, null, title))
|
|
3126
3079
|
);
|
|
3127
3080
|
}
|
|
3128
3081
|
|
|
@@ -3157,7 +3110,7 @@ function DisplayOutputs({ value, showIconInTree, displayFromScope }) {
|
|
|
3157
3110
|
return acm;
|
|
3158
3111
|
}, {}) : value?.properties || {};
|
|
3159
3112
|
const childEntries = Object.entries(properties || {});
|
|
3160
|
-
return /* @__PURE__ */
|
|
3113
|
+
return /* @__PURE__ */ React38.createElement(DisplayOutputsWrapper, null, childEntries.map(([key, schema]) => /* @__PURE__ */ React38.createElement(
|
|
3161
3114
|
DisplaySchemaTag,
|
|
3162
3115
|
{
|
|
3163
3116
|
key,
|
|
@@ -3170,13 +3123,13 @@ function DisplayOutputs({ value, showIconInTree, displayFromScope }) {
|
|
|
3170
3123
|
}
|
|
3171
3124
|
|
|
3172
3125
|
// src/components/display-flow-value/index.tsx
|
|
3173
|
-
import
|
|
3126
|
+
import React39, { useMemo as useMemo10 } from "react";
|
|
3174
3127
|
import { JsonSchemaUtils as JsonSchemaUtils6 } from "@flowgram.ai/json-schema";
|
|
3175
3128
|
import { useScopeAvailable as useScopeAvailable4 } from "@flowgram.ai/editor";
|
|
3176
3129
|
function DisplayFlowValue({ value, title, showIconInTree }) {
|
|
3177
3130
|
const available = useScopeAvailable4();
|
|
3178
3131
|
const variable = value?.type === "ref" ? available.getByKeyPath(value?.content) : void 0;
|
|
3179
|
-
const schema =
|
|
3132
|
+
const schema = useMemo10(() => {
|
|
3180
3133
|
if (value?.type === "ref") {
|
|
3181
3134
|
return JsonSchemaUtils6.astToSchema(variable?.type);
|
|
3182
3135
|
}
|
|
@@ -3199,7 +3152,7 @@ function DisplayFlowValue({ value, title, showIconInTree }) {
|
|
|
3199
3152
|
}
|
|
3200
3153
|
return { type: "unknown" };
|
|
3201
3154
|
}, [value, variable?.hash]);
|
|
3202
|
-
return /* @__PURE__ */
|
|
3155
|
+
return /* @__PURE__ */ React39.createElement(
|
|
3203
3156
|
DisplaySchemaTag,
|
|
3204
3157
|
{
|
|
3205
3158
|
title,
|
|
@@ -3211,7 +3164,7 @@ function DisplayFlowValue({ value, title, showIconInTree }) {
|
|
|
3211
3164
|
}
|
|
3212
3165
|
|
|
3213
3166
|
// src/components/display-inputs-values/index.tsx
|
|
3214
|
-
import
|
|
3167
|
+
import React40 from "react";
|
|
3215
3168
|
|
|
3216
3169
|
// src/components/display-inputs-values/styles.ts
|
|
3217
3170
|
import styled14 from "styled-components";
|
|
@@ -3224,29 +3177,29 @@ var DisplayInputsWrapper = styled14.div`
|
|
|
3224
3177
|
// src/components/display-inputs-values/index.tsx
|
|
3225
3178
|
function DisplayInputsValues({ value, showIconInTree }) {
|
|
3226
3179
|
const childEntries = Object.entries(value || {});
|
|
3227
|
-
return /* @__PURE__ */
|
|
3180
|
+
return /* @__PURE__ */ React40.createElement(DisplayInputsWrapper, null, childEntries.map(([key, value2]) => /* @__PURE__ */ React40.createElement(DisplayFlowValue, { key, title: key, value: value2, showIconInTree })));
|
|
3228
3181
|
}
|
|
3229
3182
|
|
|
3230
3183
|
// src/components/assign-rows/index.tsx
|
|
3231
|
-
import
|
|
3184
|
+
import React43 from "react";
|
|
3232
3185
|
import { FieldArray } from "@flowgram.ai/editor";
|
|
3233
3186
|
import { Button as Button5 } from "@douyinfe/semi-ui";
|
|
3234
3187
|
import { IconPlus as IconPlus4 } from "@douyinfe/semi-icons";
|
|
3235
3188
|
|
|
3236
3189
|
// src/components/assign-row/index.tsx
|
|
3237
|
-
import
|
|
3238
|
-
import { IconButton as
|
|
3190
|
+
import React42 from "react";
|
|
3191
|
+
import { IconButton as IconButton5 } from "@douyinfe/semi-ui";
|
|
3239
3192
|
import { IconMinus as IconMinus2 } from "@douyinfe/semi-icons";
|
|
3240
3193
|
|
|
3241
3194
|
// src/components/assign-row/components/blur-input.tsx
|
|
3242
|
-
import
|
|
3195
|
+
import React41, { useEffect as useEffect11, useState as useState10 } from "react";
|
|
3243
3196
|
import Input7 from "@douyinfe/semi-ui/lib/es/input";
|
|
3244
3197
|
function BlurInput3(props) {
|
|
3245
|
-
const [value, setValue] =
|
|
3198
|
+
const [value, setValue] = useState10("");
|
|
3246
3199
|
useEffect11(() => {
|
|
3247
3200
|
setValue(props.value);
|
|
3248
3201
|
}, [props.value]);
|
|
3249
|
-
return /* @__PURE__ */
|
|
3202
|
+
return /* @__PURE__ */ React41.createElement(
|
|
3250
3203
|
Input7,
|
|
3251
3204
|
{
|
|
3252
3205
|
...props,
|
|
@@ -3269,8 +3222,8 @@ function AssignRow(props) {
|
|
|
3269
3222
|
onDelete,
|
|
3270
3223
|
readonly
|
|
3271
3224
|
} = props;
|
|
3272
|
-
return /* @__PURE__ */
|
|
3273
|
-
|
|
3225
|
+
return /* @__PURE__ */ React42.createElement("div", { style: { display: "flex", alignItems: "center", gap: 5 } }, /* @__PURE__ */ React42.createElement("div", { style: { width: 150, minWidth: 150, maxWidth: 150 } }, value?.operator === "assign" ? /* @__PURE__ */ React42.createElement(
|
|
3226
|
+
InjectVariableSelector,
|
|
3274
3227
|
{
|
|
3275
3228
|
style: { width: "100%", height: 26 },
|
|
3276
3229
|
value: value?.left?.content,
|
|
@@ -3280,7 +3233,7 @@ function AssignRow(props) {
|
|
|
3280
3233
|
left: { type: "ref", content: v }
|
|
3281
3234
|
})
|
|
3282
3235
|
}
|
|
3283
|
-
) : /* @__PURE__ */
|
|
3236
|
+
) : /* @__PURE__ */ React42.createElement(
|
|
3284
3237
|
BlurInput3,
|
|
3285
3238
|
{
|
|
3286
3239
|
style: { height: 26 },
|
|
@@ -3292,8 +3245,8 @@ function AssignRow(props) {
|
|
|
3292
3245
|
left: v
|
|
3293
3246
|
})
|
|
3294
3247
|
}
|
|
3295
|
-
)), /* @__PURE__ */
|
|
3296
|
-
|
|
3248
|
+
)), /* @__PURE__ */ React42.createElement("div", { style: { flexGrow: 1 } }, /* @__PURE__ */ React42.createElement(
|
|
3249
|
+
InjectDynamicValueInput,
|
|
3297
3250
|
{
|
|
3298
3251
|
readonly,
|
|
3299
3252
|
value: value?.right,
|
|
@@ -3302,12 +3255,12 @@ function AssignRow(props) {
|
|
|
3302
3255
|
right: v
|
|
3303
3256
|
})
|
|
3304
3257
|
}
|
|
3305
|
-
)), onDelete && /* @__PURE__ */
|
|
3306
|
-
|
|
3258
|
+
)), onDelete && /* @__PURE__ */ React42.createElement("div", null, /* @__PURE__ */ React42.createElement(
|
|
3259
|
+
IconButton5,
|
|
3307
3260
|
{
|
|
3308
3261
|
size: "small",
|
|
3309
3262
|
theme: "borderless",
|
|
3310
|
-
icon: /* @__PURE__ */
|
|
3263
|
+
icon: /* @__PURE__ */ React42.createElement(IconMinus2, null),
|
|
3311
3264
|
onClick: () => onDelete?.()
|
|
3312
3265
|
}
|
|
3313
3266
|
)));
|
|
@@ -3316,7 +3269,7 @@ function AssignRow(props) {
|
|
|
3316
3269
|
// src/components/assign-rows/index.tsx
|
|
3317
3270
|
function AssignRows(props) {
|
|
3318
3271
|
const { name, readonly } = props;
|
|
3319
|
-
return /* @__PURE__ */
|
|
3272
|
+
return /* @__PURE__ */ React43.createElement(FieldArray, { name }, ({ field }) => /* @__PURE__ */ React43.createElement(React43.Fragment, null, field.map((childField, index) => /* @__PURE__ */ React43.createElement(
|
|
3320
3273
|
AssignRow,
|
|
3321
3274
|
{
|
|
3322
3275
|
key: childField.key,
|
|
@@ -3327,21 +3280,21 @@ function AssignRows(props) {
|
|
|
3327
3280
|
},
|
|
3328
3281
|
onDelete: () => field.remove(index)
|
|
3329
3282
|
}
|
|
3330
|
-
)), /* @__PURE__ */
|
|
3283
|
+
)), /* @__PURE__ */ React43.createElement("div", { style: { display: "flex", gap: 5 } }, /* @__PURE__ */ React43.createElement(
|
|
3331
3284
|
Button5,
|
|
3332
3285
|
{
|
|
3333
3286
|
size: "small",
|
|
3334
3287
|
theme: "borderless",
|
|
3335
|
-
icon: /* @__PURE__ */
|
|
3288
|
+
icon: /* @__PURE__ */ React43.createElement(IconPlus4, null),
|
|
3336
3289
|
onClick: () => field.append({ operator: "assign" })
|
|
3337
3290
|
},
|
|
3338
3291
|
"Assign"
|
|
3339
|
-
), /* @__PURE__ */
|
|
3292
|
+
), /* @__PURE__ */ React43.createElement(
|
|
3340
3293
|
Button5,
|
|
3341
3294
|
{
|
|
3342
3295
|
size: "small",
|
|
3343
3296
|
theme: "borderless",
|
|
3344
|
-
icon: /* @__PURE__ */
|
|
3297
|
+
icon: /* @__PURE__ */ React43.createElement(IconPlus4, null),
|
|
3345
3298
|
onClick: () => field.append({ operator: "declare" })
|
|
3346
3299
|
},
|
|
3347
3300
|
"Declaration"
|
|
@@ -3384,7 +3337,7 @@ var provideBatchInputEffect = createEffectFromVariableProvider({
|
|
|
3384
3337
|
});
|
|
3385
3338
|
|
|
3386
3339
|
// src/effects/auto-rename-ref/index.ts
|
|
3387
|
-
import { isArray, isObject as
|
|
3340
|
+
import { isArray, isObject as isObject3, uniq } from "lodash";
|
|
3388
3341
|
import {
|
|
3389
3342
|
DataEvent,
|
|
3390
3343
|
VariableFieldKeyRenameService
|
|
@@ -3454,7 +3407,7 @@ function isTemplate(value) {
|
|
|
3454
3407
|
return value?.type === "template" && typeof value?.content === "string";
|
|
3455
3408
|
}
|
|
3456
3409
|
function traverseRef(name, value, cb) {
|
|
3457
|
-
if (
|
|
3410
|
+
if (isObject3(value)) {
|
|
3458
3411
|
if (isRef(value)) {
|
|
3459
3412
|
cb(name, value);
|
|
3460
3413
|
return;
|
|
@@ -3599,68 +3552,6 @@ var listenRefSchemaChange = (cb) => [
|
|
|
3599
3552
|
}
|
|
3600
3553
|
];
|
|
3601
3554
|
|
|
3602
|
-
// src/shared/format-legacy-refs/index.ts
|
|
3603
|
-
import { isObject as isObject3 } from "lodash";
|
|
3604
|
-
function formatLegacyRefOnSubmit(value) {
|
|
3605
|
-
if (isObject3(value)) {
|
|
3606
|
-
if (isLegacyFlowRefValueSchema(value)) {
|
|
3607
|
-
return formatLegacyRefToNewRef(value);
|
|
3608
|
-
}
|
|
3609
|
-
return Object.fromEntries(
|
|
3610
|
-
Object.entries(value).map(([key, value2]) => [
|
|
3611
|
-
key,
|
|
3612
|
-
formatLegacyRefOnSubmit(value2)
|
|
3613
|
-
])
|
|
3614
|
-
);
|
|
3615
|
-
}
|
|
3616
|
-
if (Array.isArray(value)) {
|
|
3617
|
-
return value.map(formatLegacyRefOnSubmit);
|
|
3618
|
-
}
|
|
3619
|
-
return value;
|
|
3620
|
-
}
|
|
3621
|
-
function formatLegacyRefOnInit(value) {
|
|
3622
|
-
if (isObject3(value)) {
|
|
3623
|
-
if (isNewFlowRefValueSchema(value)) {
|
|
3624
|
-
return formatNewRefToLegacyRef(value);
|
|
3625
|
-
}
|
|
3626
|
-
return Object.fromEntries(
|
|
3627
|
-
Object.entries(value).map(([key, value2]) => [
|
|
3628
|
-
key,
|
|
3629
|
-
formatLegacyRefOnInit(value2)
|
|
3630
|
-
])
|
|
3631
|
-
);
|
|
3632
|
-
}
|
|
3633
|
-
if (Array.isArray(value)) {
|
|
3634
|
-
return value.map(formatLegacyRefOnInit);
|
|
3635
|
-
}
|
|
3636
|
-
return value;
|
|
3637
|
-
}
|
|
3638
|
-
function isLegacyFlowRefValueSchema(value) {
|
|
3639
|
-
return isObject3(value) && Object.keys(value).length === 2 && value.type === "ref" && typeof value.content === "string";
|
|
3640
|
-
}
|
|
3641
|
-
function isNewFlowRefValueSchema(value) {
|
|
3642
|
-
return isObject3(value) && Object.keys(value).length === 2 && value.type === "ref" && Array.isArray(value.content);
|
|
3643
|
-
}
|
|
3644
|
-
function formatLegacyRefToNewRef(value) {
|
|
3645
|
-
const keyPath = value.content.split(".");
|
|
3646
|
-
if (keyPath[1] === "outputs") {
|
|
3647
|
-
return {
|
|
3648
|
-
type: "ref",
|
|
3649
|
-
content: [`${keyPath[0]}.${keyPath[1]}`, ...keyPath.length > 2 ? keyPath.slice(2) : []]
|
|
3650
|
-
};
|
|
3651
|
-
}
|
|
3652
|
-
return {
|
|
3653
|
-
type: "ref",
|
|
3654
|
-
content: keyPath
|
|
3655
|
-
};
|
|
3656
|
-
}
|
|
3657
|
-
function formatNewRefToLegacyRef(value) {
|
|
3658
|
-
return {
|
|
3659
|
-
type: "ref",
|
|
3660
|
-
content: value.content.join(".")
|
|
3661
|
-
};
|
|
3662
|
-
}
|
|
3663
|
-
|
|
3664
3555
|
// src/form-plugins/batch-outputs-plugin/index.ts
|
|
3665
3556
|
import {
|
|
3666
3557
|
ASTFactory as ASTFactory3,
|
|
@@ -3931,6 +3822,9 @@ export {
|
|
|
3931
3822
|
DisplaySchemaTag,
|
|
3932
3823
|
DisplaySchemaTree,
|
|
3933
3824
|
DynamicValueInput,
|
|
3825
|
+
InjectDynamicValueInput,
|
|
3826
|
+
InjectTypeSelector,
|
|
3827
|
+
InjectVariableSelector,
|
|
3934
3828
|
InputsValues,
|
|
3935
3829
|
JsonEditorWithVariables,
|
|
3936
3830
|
JsonSchemaEditor,
|
|
@@ -3946,6 +3840,7 @@ export {
|
|
|
3946
3840
|
createDisableDeclarationPlugin,
|
|
3947
3841
|
createInferAssignPlugin,
|
|
3948
3842
|
createInferInputsPlugin,
|
|
3843
|
+
createInjectMaterial,
|
|
3949
3844
|
createTypePresetPlugin,
|
|
3950
3845
|
formatLegacyRefOnInit,
|
|
3951
3846
|
formatLegacyRefOnSubmit,
|