@flowgram.ai/form-materials 0.3.3 → 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 +431 -505
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.mts +77 -23
- package/dist/index.d.ts +77 -23
- package/dist/index.js +657 -731
- 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/constants.ts +2 -2
- package/src/components/condition-row/hooks/useOp.tsx +13 -9
- package/src/components/condition-row/hooks/useRule.ts +8 -4
- package/src/components/condition-row/index.tsx +27 -10
- package/src/components/condition-row/types.ts +5 -7
- 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 +18 -12
- 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 +9 -7
- package/src/components/variable-selector/index.tsx +9 -5
- 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/plugins/json-schema-preset/type-definition/array.tsx +3 -1
- package/src/plugins/json-schema-preset/type-definition/boolean.tsx +4 -3
- package/src/plugins/json-schema-preset/type-definition/integer.tsx +2 -1
- package/src/plugins/json-schema-preset/type-definition/number.tsx +2 -1
- package/src/plugins/json-schema-preset/type-definition/object.tsx +3 -1
- package/src/plugins/json-schema-preset/type-definition/string.tsx +7 -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,16 +1,105 @@
|
|
|
1
1
|
// src/components/variable-selector/index.tsx
|
|
2
|
-
import
|
|
2
|
+
import React12, { useMemo } from "react";
|
|
3
|
+
import { I18n as I18n7 } from "@flowgram.ai/editor";
|
|
3
4
|
import { Popover } from "@douyinfe/semi-ui";
|
|
4
5
|
import { IconChevronDownStroked, IconIssueStroked } from "@douyinfe/semi-icons";
|
|
5
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
|
+
|
|
6
95
|
// src/components/variable-selector/use-variable-tree.tsx
|
|
7
|
-
import
|
|
96
|
+
import React11, { useCallback } from "react";
|
|
8
97
|
import { JsonSchemaUtils as JsonSchemaUtils2 } from "@flowgram.ai/json-schema";
|
|
9
98
|
import { ASTMatch as ASTMatch2, useAvailableVariables } from "@flowgram.ai/editor";
|
|
10
99
|
import { Icon } from "@douyinfe/semi-ui";
|
|
11
100
|
|
|
12
101
|
// src/plugins/json-schema-preset/index.tsx
|
|
13
|
-
import
|
|
102
|
+
import React10 from "react";
|
|
14
103
|
import {
|
|
15
104
|
JsonSchemaUtils,
|
|
16
105
|
useTypeManager as useOriginTypeManager,
|
|
@@ -21,22 +110,32 @@ import {
|
|
|
21
110
|
import { jsonSchemaTypeManager } from "@flowgram.ai/json-schema";
|
|
22
111
|
|
|
23
112
|
// src/plugins/json-schema-preset/type-definition/string.tsx
|
|
24
|
-
import
|
|
113
|
+
import React2 from "react";
|
|
114
|
+
import { I18n } from "@flowgram.ai/editor";
|
|
25
115
|
import { Input } from "@douyinfe/semi-ui";
|
|
26
116
|
var stringRegistry = {
|
|
27
117
|
type: "string",
|
|
28
|
-
ConstantRenderer: (props) => /* @__PURE__ */
|
|
118
|
+
ConstantRenderer: (props) => /* @__PURE__ */ React2.createElement(
|
|
119
|
+
Input,
|
|
120
|
+
{
|
|
121
|
+
placeholder: I18n.t("Please Input String"),
|
|
122
|
+
size: "small",
|
|
123
|
+
disabled: props.readonly,
|
|
124
|
+
...props
|
|
125
|
+
}
|
|
126
|
+
)
|
|
29
127
|
};
|
|
30
128
|
|
|
31
129
|
// src/plugins/json-schema-preset/type-definition/object.tsx
|
|
32
|
-
import
|
|
130
|
+
import React5 from "react";
|
|
131
|
+
import { I18n as I18n2 } from "@flowgram.ai/editor";
|
|
33
132
|
|
|
34
133
|
// src/components/code-editor-mini/index.tsx
|
|
35
|
-
import
|
|
134
|
+
import React4 from "react";
|
|
36
135
|
import styled from "styled-components";
|
|
37
136
|
|
|
38
137
|
// src/components/code-editor/index.tsx
|
|
39
|
-
import
|
|
138
|
+
import React3, { useEffect, useRef } from "react";
|
|
40
139
|
import {
|
|
41
140
|
ActiveLinePlaceholder,
|
|
42
141
|
createRenderer,
|
|
@@ -357,7 +456,7 @@ function CodeEditor({
|
|
|
357
456
|
editorRef.current?.setValue(String(value || ""));
|
|
358
457
|
}
|
|
359
458
|
}, [value]);
|
|
360
|
-
return /* @__PURE__ */
|
|
459
|
+
return /* @__PURE__ */ React3.createElement(EditorProvider, null, /* @__PURE__ */ React3.createElement(
|
|
361
460
|
OriginCodeEditor,
|
|
362
461
|
{
|
|
363
462
|
defaultValue: value,
|
|
@@ -375,7 +474,7 @@ function CodeEditor({
|
|
|
375
474
|
},
|
|
376
475
|
onChange: (e) => onChange?.(e.value)
|
|
377
476
|
},
|
|
378
|
-
activeLinePlaceholder && /* @__PURE__ */
|
|
477
|
+
activeLinePlaceholder && /* @__PURE__ */ React3.createElement(ActiveLinePlaceholder, null, activeLinePlaceholder),
|
|
379
478
|
children
|
|
380
479
|
));
|
|
381
480
|
}
|
|
@@ -387,7 +486,7 @@ var UIMini = styled.div`
|
|
|
387
486
|
}
|
|
388
487
|
`;
|
|
389
488
|
function CodeEditorMini(props) {
|
|
390
|
-
return /* @__PURE__ */
|
|
489
|
+
return /* @__PURE__ */ React4.createElement(UIMini, null, /* @__PURE__ */ React4.createElement(
|
|
391
490
|
CodeEditor,
|
|
392
491
|
{
|
|
393
492
|
...props,
|
|
@@ -403,27 +502,28 @@ function CodeEditorMini(props) {
|
|
|
403
502
|
// src/plugins/json-schema-preset/type-definition/object.tsx
|
|
404
503
|
var objectRegistry = {
|
|
405
504
|
type: "object",
|
|
406
|
-
ConstantRenderer: (props) => /* @__PURE__ */
|
|
505
|
+
ConstantRenderer: (props) => /* @__PURE__ */ React5.createElement(
|
|
407
506
|
CodeEditorMini,
|
|
408
507
|
{
|
|
409
508
|
value: props.value,
|
|
410
509
|
onChange: (v) => props.onChange?.(v),
|
|
411
510
|
languageId: "json",
|
|
412
|
-
placeholder: "Please Input Object",
|
|
511
|
+
placeholder: I18n2.t("Please Input Object"),
|
|
413
512
|
readonly: props.readonly
|
|
414
513
|
}
|
|
415
514
|
)
|
|
416
515
|
};
|
|
417
516
|
|
|
418
517
|
// src/plugins/json-schema-preset/type-definition/number.tsx
|
|
419
|
-
import
|
|
518
|
+
import React6 from "react";
|
|
519
|
+
import { I18n as I18n3 } from "@flowgram.ai/editor";
|
|
420
520
|
import { InputNumber } from "@douyinfe/semi-ui";
|
|
421
521
|
var numberRegistry = {
|
|
422
522
|
type: "number",
|
|
423
|
-
ConstantRenderer: (props) => /* @__PURE__ */
|
|
523
|
+
ConstantRenderer: (props) => /* @__PURE__ */ React6.createElement(
|
|
424
524
|
InputNumber,
|
|
425
525
|
{
|
|
426
|
-
placeholder: "Please Input Number",
|
|
526
|
+
placeholder: I18n3.t("Please Input Number"),
|
|
427
527
|
size: "small",
|
|
428
528
|
disabled: props.readonly,
|
|
429
529
|
hideButtons: true,
|
|
@@ -433,14 +533,15 @@ var numberRegistry = {
|
|
|
433
533
|
};
|
|
434
534
|
|
|
435
535
|
// src/plugins/json-schema-preset/type-definition/integer.tsx
|
|
436
|
-
import
|
|
536
|
+
import React7 from "react";
|
|
537
|
+
import { I18n as I18n4 } from "@flowgram.ai/editor";
|
|
437
538
|
import { InputNumber as InputNumber2 } from "@douyinfe/semi-ui";
|
|
438
539
|
var integerRegistry = {
|
|
439
540
|
type: "integer",
|
|
440
|
-
ConstantRenderer: (props) => /* @__PURE__ */
|
|
541
|
+
ConstantRenderer: (props) => /* @__PURE__ */ React7.createElement(
|
|
441
542
|
InputNumber2,
|
|
442
543
|
{
|
|
443
|
-
placeholder: "Please Input Integer",
|
|
544
|
+
placeholder: I18n4.t("Please Input Integer"),
|
|
444
545
|
size: "small",
|
|
445
546
|
disabled: props.readonly,
|
|
446
547
|
precision: 0,
|
|
@@ -450,21 +551,22 @@ var integerRegistry = {
|
|
|
450
551
|
};
|
|
451
552
|
|
|
452
553
|
// src/plugins/json-schema-preset/type-definition/boolean.tsx
|
|
453
|
-
import
|
|
554
|
+
import React8 from "react";
|
|
555
|
+
import { I18n as I18n5 } from "@flowgram.ai/editor";
|
|
454
556
|
import { Select } from "@douyinfe/semi-ui";
|
|
455
557
|
var booleanRegistry = {
|
|
456
558
|
type: "boolean",
|
|
457
559
|
ConstantRenderer: (props) => {
|
|
458
560
|
const { value, onChange, ...rest } = props;
|
|
459
|
-
return /* @__PURE__ */
|
|
561
|
+
return /* @__PURE__ */ React8.createElement(
|
|
460
562
|
Select,
|
|
461
563
|
{
|
|
462
|
-
placeholder: "Please Select Boolean",
|
|
564
|
+
placeholder: I18n5.t("Please Select Boolean"),
|
|
463
565
|
size: "small",
|
|
464
566
|
disabled: props.readonly,
|
|
465
567
|
optionList: [
|
|
466
|
-
{ label: "True", value: 1 },
|
|
467
|
-
{ label: "False", value: 0 }
|
|
568
|
+
{ label: I18n5.t("True"), value: 1 },
|
|
569
|
+
{ label: I18n5.t("False"), value: 0 }
|
|
468
570
|
],
|
|
469
571
|
value: value ? 1 : 0,
|
|
470
572
|
onChange: (value2) => onChange?.(!!value2),
|
|
@@ -475,16 +577,17 @@ var booleanRegistry = {
|
|
|
475
577
|
};
|
|
476
578
|
|
|
477
579
|
// src/plugins/json-schema-preset/type-definition/array.tsx
|
|
478
|
-
import
|
|
580
|
+
import React9 from "react";
|
|
581
|
+
import { I18n as I18n6 } from "@flowgram.ai/editor";
|
|
479
582
|
var arrayRegistry = {
|
|
480
583
|
type: "array",
|
|
481
|
-
ConstantRenderer: (props) => /* @__PURE__ */
|
|
584
|
+
ConstantRenderer: (props) => /* @__PURE__ */ React9.createElement(
|
|
482
585
|
CodeEditorMini,
|
|
483
586
|
{
|
|
484
587
|
value: props.value,
|
|
485
588
|
languageId: "json",
|
|
486
589
|
onChange: (v) => props.onChange?.(v),
|
|
487
|
-
placeholder: "Please Input Array",
|
|
590
|
+
placeholder: I18n6.t("Please Input Array"),
|
|
488
591
|
readonly: props.readonly
|
|
489
592
|
}
|
|
490
593
|
)
|
|
@@ -522,7 +625,7 @@ var useTypeManager = () => useOriginTypeManager();
|
|
|
522
625
|
var JsonSchemaTypePresetProvider = ({
|
|
523
626
|
types = [],
|
|
524
627
|
children
|
|
525
|
-
}) => /* @__PURE__ */
|
|
628
|
+
}) => /* @__PURE__ */ React10.createElement(OriginTypePresetProvider, { types: [...jsonSchemaTypePreset, ...types] }, children);
|
|
526
629
|
|
|
527
630
|
// src/plugins/disable-declaration-plugin/create-disable-declaration-plugin.ts
|
|
528
631
|
import {
|
|
@@ -556,12 +659,12 @@ function useVariableTree(params) {
|
|
|
556
659
|
const getVariableTypeIcon = useCallback((variable) => {
|
|
557
660
|
if (variable.meta?.icon) {
|
|
558
661
|
if (typeof variable.meta.icon === "string") {
|
|
559
|
-
return /* @__PURE__ */
|
|
662
|
+
return /* @__PURE__ */ React11.createElement("img", { style: { marginRight: 8 }, width: 12, height: 12, src: variable.meta.icon });
|
|
560
663
|
}
|
|
561
664
|
return variable.meta.icon;
|
|
562
665
|
}
|
|
563
666
|
const schema = JsonSchemaUtils2.astToSchema(variable.type, { drilldownObject: false });
|
|
564
|
-
return /* @__PURE__ */
|
|
667
|
+
return /* @__PURE__ */ React11.createElement(Icon, { size: "small", svg: typeManager.getDisplayIcon(schema || {}) });
|
|
565
668
|
}, []);
|
|
566
669
|
const renderVariable = (variable, parentFields = []) => {
|
|
567
670
|
let type = variable?.type;
|
|
@@ -681,11 +784,11 @@ var VariableSelector = ({
|
|
|
681
784
|
}, [value]);
|
|
682
785
|
const renderIcon = (icon) => {
|
|
683
786
|
if (typeof icon === "string") {
|
|
684
|
-
return /* @__PURE__ */
|
|
787
|
+
return /* @__PURE__ */ React12.createElement("img", { style: { marginRight: 8 }, width: 12, height: 12, src: icon });
|
|
685
788
|
}
|
|
686
789
|
return icon;
|
|
687
790
|
};
|
|
688
|
-
return /* @__PURE__ */
|
|
791
|
+
return /* @__PURE__ */ React12.createElement(React12.Fragment, null, /* @__PURE__ */ React12.createElement(
|
|
689
792
|
UITreeSelect,
|
|
690
793
|
{
|
|
691
794
|
dropdownMatchSelectWidth: false,
|
|
@@ -702,10 +805,10 @@ var VariableSelector = ({
|
|
|
702
805
|
},
|
|
703
806
|
renderSelectedItem: (_option) => {
|
|
704
807
|
if (!_option?.keyPath) {
|
|
705
|
-
return /* @__PURE__ */
|
|
808
|
+
return /* @__PURE__ */ React12.createElement(
|
|
706
809
|
UITag,
|
|
707
810
|
{
|
|
708
|
-
prefixIcon: /* @__PURE__ */
|
|
811
|
+
prefixIcon: /* @__PURE__ */ React12.createElement(IconIssueStroked, null),
|
|
709
812
|
color: "amber",
|
|
710
813
|
closable: !readonly,
|
|
711
814
|
onClose: () => onChange(void 0)
|
|
@@ -714,13 +817,13 @@ var VariableSelector = ({
|
|
|
714
817
|
);
|
|
715
818
|
}
|
|
716
819
|
const rootIcon = renderIcon(_option.rootMeta?.icon || _option?.icon);
|
|
717
|
-
const rootTitle = /* @__PURE__ */
|
|
718
|
-
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(
|
|
719
822
|
Popover,
|
|
720
823
|
{
|
|
721
|
-
content: /* @__PURE__ */
|
|
824
|
+
content: /* @__PURE__ */ React12.createElement(UIPopoverContent, null, rootIcon, rootTitle, /* @__PURE__ */ React12.createElement(UIVarName, null, _option.keyPath.slice(1).join(".")))
|
|
722
825
|
},
|
|
723
|
-
/* @__PURE__ */
|
|
826
|
+
/* @__PURE__ */ React12.createElement(
|
|
724
827
|
UITag,
|
|
725
828
|
{
|
|
726
829
|
prefixIcon: rootIcon,
|
|
@@ -728,23 +831,24 @@ var VariableSelector = ({
|
|
|
728
831
|
onClose: () => onChange(void 0)
|
|
729
832
|
},
|
|
730
833
|
rootTitle,
|
|
731
|
-
!_option.isRoot && /* @__PURE__ */
|
|
834
|
+
!_option.isRoot && /* @__PURE__ */ React12.createElement(UIVarName, { $inSelector: true }, _option.label)
|
|
732
835
|
)
|
|
733
836
|
));
|
|
734
837
|
},
|
|
735
838
|
showClear: false,
|
|
736
|
-
arrowIcon: /* @__PURE__ */
|
|
839
|
+
arrowIcon: /* @__PURE__ */ React12.createElement(IconChevronDownStroked, { size: "small" }),
|
|
737
840
|
triggerRender,
|
|
738
|
-
placeholder: config?.placeholder ?? "Select Variable"
|
|
841
|
+
placeholder: config?.placeholder ?? I18n7.t("Select Variable")
|
|
739
842
|
}
|
|
740
843
|
));
|
|
741
844
|
};
|
|
845
|
+
VariableSelector.renderKey = "variable-selector-render-key";
|
|
846
|
+
var InjectVariableSelector = createInjectMaterial(VariableSelector);
|
|
742
847
|
|
|
743
848
|
// src/components/type-selector/index.tsx
|
|
744
|
-
import
|
|
849
|
+
import React13, { useMemo as useMemo2 } from "react";
|
|
745
850
|
import { Cascader, Icon as Icon2, IconButton } from "@douyinfe/semi-ui";
|
|
746
851
|
var labelStyle = { display: "flex", alignItems: "center", gap: 5 };
|
|
747
|
-
var firstUppercase = (str) => str.charAt(0).toUpperCase() + str.slice(1);
|
|
748
852
|
var getTypeSelectValue = (value) => {
|
|
749
853
|
if (value?.type === "array" && value?.items) {
|
|
750
854
|
return [value.type, ...getTypeSelectValue(value.items) || []];
|
|
@@ -767,10 +871,10 @@ function TypeSelector(props) {
|
|
|
767
871
|
() => typeManager.getTypeRegistriesWithParentType().map((_type) => {
|
|
768
872
|
const isArray2 = _type.type === "array";
|
|
769
873
|
return {
|
|
770
|
-
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),
|
|
771
875
|
value: _type.type,
|
|
772
876
|
children: isArray2 ? typeManager.getTypeRegistriesWithParentType("array").map((_type2) => ({
|
|
773
|
-
label: /* @__PURE__ */
|
|
877
|
+
label: /* @__PURE__ */ React13.createElement("div", { style: labelStyle }, /* @__PURE__ */ React13.createElement(
|
|
774
878
|
Icon2,
|
|
775
879
|
{
|
|
776
880
|
size: "small",
|
|
@@ -779,19 +883,19 @@ function TypeSelector(props) {
|
|
|
779
883
|
items: { type: _type2.type }
|
|
780
884
|
})
|
|
781
885
|
}
|
|
782
|
-
),
|
|
886
|
+
), typeManager.getTypeBySchema(_type2)?.label || _type2.type),
|
|
783
887
|
value: _type2.type
|
|
784
888
|
})) : []
|
|
785
889
|
};
|
|
786
890
|
}),
|
|
787
891
|
[]
|
|
788
892
|
);
|
|
789
|
-
return /* @__PURE__ */
|
|
893
|
+
return /* @__PURE__ */ React13.createElement(
|
|
790
894
|
Cascader,
|
|
791
895
|
{
|
|
792
896
|
disabled: readonly || disabled,
|
|
793
897
|
size: "small",
|
|
794
|
-
triggerRender: () => /* @__PURE__ */
|
|
898
|
+
triggerRender: () => /* @__PURE__ */ React13.createElement(IconButton, { size: "small", style, disabled: readonly || disabled, icon }),
|
|
795
899
|
treeData: options,
|
|
796
900
|
value: selectValue,
|
|
797
901
|
leafOnly: true,
|
|
@@ -801,10 +905,13 @@ function TypeSelector(props) {
|
|
|
801
905
|
}
|
|
802
906
|
);
|
|
803
907
|
}
|
|
908
|
+
TypeSelector.renderKey = "type-selector-render-key";
|
|
909
|
+
var InjectTypeSelector = createInjectMaterial(TypeSelector);
|
|
804
910
|
|
|
805
911
|
// src/components/json-schema-editor/index.tsx
|
|
806
|
-
import
|
|
807
|
-
import {
|
|
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";
|
|
808
915
|
import {
|
|
809
916
|
IconExpand,
|
|
810
917
|
IconShrink,
|
|
@@ -815,7 +922,7 @@ import {
|
|
|
815
922
|
} from "@douyinfe/semi-icons";
|
|
816
923
|
|
|
817
924
|
// src/components/json-schema-editor/styles.tsx
|
|
818
|
-
import
|
|
925
|
+
import React14 from "react";
|
|
819
926
|
import styled3, { css as css2 } from "styled-components";
|
|
820
927
|
import Icon3 from "@douyinfe/semi-icons";
|
|
821
928
|
var UIContainer = styled3.div`
|
|
@@ -943,7 +1050,7 @@ var UIRequired = styled3.div``;
|
|
|
943
1050
|
var UIActions = styled3.div`
|
|
944
1051
|
white-space: nowrap;
|
|
945
1052
|
`;
|
|
946
|
-
var iconAddChildrenSvg = /* @__PURE__ */
|
|
1053
|
+
var iconAddChildrenSvg = /* @__PURE__ */ React14.createElement(
|
|
947
1054
|
"svg",
|
|
948
1055
|
{
|
|
949
1056
|
className: "icon-icon icon-icon-coz_add_node ",
|
|
@@ -953,7 +1060,7 @@ var iconAddChildrenSvg = /* @__PURE__ */ React13.createElement(
|
|
|
953
1060
|
fill: "currentColor",
|
|
954
1061
|
xmlns: "http://www.w3.org/2000/svg"
|
|
955
1062
|
},
|
|
956
|
-
/* @__PURE__ */
|
|
1063
|
+
/* @__PURE__ */ React14.createElement(
|
|
957
1064
|
"path",
|
|
958
1065
|
{
|
|
959
1066
|
fillRule: "evenodd",
|
|
@@ -961,37 +1068,12 @@ var iconAddChildrenSvg = /* @__PURE__ */ React13.createElement(
|
|
|
961
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"
|
|
962
1069
|
}
|
|
963
1070
|
),
|
|
964
|
-
/* @__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" })
|
|
965
1072
|
);
|
|
966
|
-
var IconAddChildren = () => /* @__PURE__ */
|
|
1073
|
+
var IconAddChildren = () => /* @__PURE__ */ React14.createElement(Icon3, { size: "small", svg: iconAddChildrenSvg });
|
|
967
1074
|
var DefaultValueWrapper = styled3.div`
|
|
968
1075
|
margin: 0;
|
|
969
1076
|
`;
|
|
970
|
-
var JSONViewerWrapper = styled3.div`
|
|
971
|
-
padding: 0 0 24px;
|
|
972
|
-
&:first-child {
|
|
973
|
-
margin-top: 0px;
|
|
974
|
-
}
|
|
975
|
-
`;
|
|
976
|
-
var JSONHeader = styled3.div`
|
|
977
|
-
display: flex;
|
|
978
|
-
justify-content: space-between;
|
|
979
|
-
align-items: center;
|
|
980
|
-
background-color: var(--semi-color-fill-0);
|
|
981
|
-
border-radius: 6px 6px 0 0;
|
|
982
|
-
height: 36px;
|
|
983
|
-
padding: 0 8px 0 12px;
|
|
984
|
-
`;
|
|
985
|
-
var JSONHeaderLeft = styled3.div`
|
|
986
|
-
display: flex;
|
|
987
|
-
align-items: center;
|
|
988
|
-
gap: 10px;
|
|
989
|
-
`;
|
|
990
|
-
var JSONHeaderRight = styled3.div`
|
|
991
|
-
display: flex;
|
|
992
|
-
align-items: center;
|
|
993
|
-
gap: 10px;
|
|
994
|
-
`;
|
|
995
1077
|
var ConstantInputWrapper = styled3.div`
|
|
996
1078
|
flex-grow: 1;
|
|
997
1079
|
|
|
@@ -1003,71 +1085,39 @@ var ConstantInputWrapper = styled3.div`
|
|
|
1003
1085
|
`;
|
|
1004
1086
|
|
|
1005
1087
|
// src/components/json-schema-editor/hooks.tsx
|
|
1006
|
-
import { useEffect as useEffect2,
|
|
1007
|
-
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";
|
|
1008
1092
|
var _id = 0;
|
|
1009
1093
|
function genId() {
|
|
1010
1094
|
return _id++;
|
|
1011
1095
|
}
|
|
1012
|
-
function getDrilldownSchema(value, path) {
|
|
1013
|
-
if (!value) {
|
|
1014
|
-
return {};
|
|
1015
|
-
}
|
|
1016
|
-
if (value.type === "array" && value.items) {
|
|
1017
|
-
return getDrilldownSchema(value.items, [...path || [], "items"]);
|
|
1018
|
-
}
|
|
1019
|
-
return { schema: value, path };
|
|
1020
|
-
}
|
|
1021
1096
|
function usePropertiesEdit(value, onChange) {
|
|
1022
|
-
const
|
|
1023
|
-
const
|
|
1024
|
-
const
|
|
1025
|
-
|
|
1026
|
-
([name, _value], index) => ({
|
|
1027
|
-
key: genId(),
|
|
1028
|
-
name,
|
|
1029
|
-
isPropertyRequired: drilldown.schema?.required?.includes(name) || false,
|
|
1030
|
-
..._value,
|
|
1031
|
-
extra: {
|
|
1032
|
-
..._value.extra || {},
|
|
1033
|
-
index
|
|
1034
|
-
}
|
|
1035
|
-
})
|
|
1036
|
-
) : [],
|
|
1037
|
-
[isDrilldownObject]
|
|
1038
|
-
);
|
|
1039
|
-
const [propertyList, setPropertyList] = useState(initPropertyList);
|
|
1040
|
-
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([]);
|
|
1041
1101
|
useEffect2(() => {
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
key: genId(),
|
|
1062
|
-
name,
|
|
1063
|
-
isPropertyRequired: drilldown.schema?.required?.includes(name) || false,
|
|
1064
|
-
..._value
|
|
1065
|
-
};
|
|
1066
|
-
});
|
|
1067
|
-
});
|
|
1068
|
-
}
|
|
1069
|
-
mountRef.current = true;
|
|
1070
|
-
}, [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]);
|
|
1071
1121
|
const updatePropertyList = (updater) => {
|
|
1072
1122
|
setPropertyList((_list) => {
|
|
1073
1123
|
const next = updater(_list);
|
|
@@ -1082,18 +1132,21 @@ function usePropertiesEdit(value, onChange) {
|
|
|
1082
1132
|
nextRequired.push(_property.name);
|
|
1083
1133
|
}
|
|
1084
1134
|
}
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
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
|
+
);
|
|
1092
1145
|
return next;
|
|
1093
1146
|
});
|
|
1094
1147
|
};
|
|
1095
1148
|
const onAddProperty = () => {
|
|
1096
|
-
|
|
1149
|
+
setPropertyList((_list) => [
|
|
1097
1150
|
..._list,
|
|
1098
1151
|
{ key: genId(), name: "", type: "string", extra: { index: _list.length + 1 } }
|
|
1099
1152
|
]);
|
|
@@ -1107,13 +1160,13 @@ function usePropertiesEdit(value, onChange) {
|
|
|
1107
1160
|
);
|
|
1108
1161
|
};
|
|
1109
1162
|
useEffect2(() => {
|
|
1110
|
-
if (!
|
|
1163
|
+
if (!canAddField) {
|
|
1111
1164
|
setPropertyList([]);
|
|
1112
1165
|
}
|
|
1113
|
-
}, [
|
|
1166
|
+
}, [canAddField]);
|
|
1114
1167
|
return {
|
|
1115
1168
|
propertyList,
|
|
1116
|
-
|
|
1169
|
+
canAddField,
|
|
1117
1170
|
onAddProperty,
|
|
1118
1171
|
onRemoveProperty,
|
|
1119
1172
|
onEditProperty
|
|
@@ -1121,36 +1174,16 @@ function usePropertiesEdit(value, onChange) {
|
|
|
1121
1174
|
}
|
|
1122
1175
|
|
|
1123
1176
|
// src/components/json-schema-editor/default-value.tsx
|
|
1124
|
-
import
|
|
1125
|
-
import {
|
|
1126
|
-
import { IconBrackets } from "@douyinfe/semi-icons";
|
|
1127
|
-
|
|
1128
|
-
// src/components/json-schema-editor/utils.ts
|
|
1129
|
-
function getValueType(value) {
|
|
1130
|
-
const type = typeof value;
|
|
1131
|
-
if (type === "string") {
|
|
1132
|
-
return "string";
|
|
1133
|
-
} else if (type === "number") {
|
|
1134
|
-
return Number.isInteger(value) ? "integer" : "number";
|
|
1135
|
-
} else if (type === "boolean") {
|
|
1136
|
-
return "boolean";
|
|
1137
|
-
} else if (type === "object") {
|
|
1138
|
-
if (value === null) {
|
|
1139
|
-
return "other";
|
|
1140
|
-
}
|
|
1141
|
-
return Array.isArray(value) ? "array" : "object";
|
|
1142
|
-
} else {
|
|
1143
|
-
return "other";
|
|
1144
|
-
}
|
|
1145
|
-
}
|
|
1177
|
+
import React16 from "react";
|
|
1178
|
+
import { I18n as I18n8 } from "@flowgram.ai/editor";
|
|
1146
1179
|
|
|
1147
1180
|
// src/components/constant-input/index.tsx
|
|
1148
|
-
import
|
|
1181
|
+
import React15, { useMemo as useMemo3 } from "react";
|
|
1149
1182
|
import { Input as Input2 } from "@douyinfe/semi-ui";
|
|
1150
1183
|
function ConstantInput(props) {
|
|
1151
1184
|
const { value, onChange, schema, strategies, fallbackRenderer, readonly, ...rest } = props;
|
|
1152
1185
|
const typeManager = useTypeManager();
|
|
1153
|
-
const Renderer2 =
|
|
1186
|
+
const Renderer2 = useMemo3(() => {
|
|
1154
1187
|
const strategy = (strategies || []).find((_strategy) => _strategy.hit(schema));
|
|
1155
1188
|
if (!strategy) {
|
|
1156
1189
|
return typeManager.getTypeBySchema(schema)?.ConstantRenderer;
|
|
@@ -1159,110 +1192,41 @@ function ConstantInput(props) {
|
|
|
1159
1192
|
}, [strategies, schema]);
|
|
1160
1193
|
if (!Renderer2) {
|
|
1161
1194
|
if (fallbackRenderer) {
|
|
1162
|
-
return
|
|
1195
|
+
return React15.createElement(fallbackRenderer, {
|
|
1163
1196
|
value,
|
|
1164
1197
|
onChange,
|
|
1165
1198
|
readonly,
|
|
1166
1199
|
...rest
|
|
1167
1200
|
});
|
|
1168
1201
|
}
|
|
1169
|
-
return /* @__PURE__ */
|
|
1202
|
+
return /* @__PURE__ */ React15.createElement(Input2, { size: "small", disabled: true, placeholder: "Unsupported type" });
|
|
1170
1203
|
}
|
|
1171
|
-
return /* @__PURE__ */
|
|
1204
|
+
return /* @__PURE__ */ React15.createElement(Renderer2, { value, onChange, readonly, ...rest });
|
|
1172
1205
|
}
|
|
1173
1206
|
|
|
1174
1207
|
// src/components/json-schema-editor/default-value.tsx
|
|
1175
1208
|
function DefaultValue(props) {
|
|
1176
|
-
const { value, schema,
|
|
1177
|
-
|
|
1178
|
-
const JsonViewerRef = useRef3(null);
|
|
1179
|
-
const [internalJsonValue, setInternalJsonValue] = useState2(
|
|
1180
|
-
getValueType(value) === "string" ? value : ""
|
|
1181
|
-
);
|
|
1182
|
-
const handleJsonChange = useCallback2((val) => {
|
|
1183
|
-
if (val !== internalJsonValue) {
|
|
1184
|
-
setInternalJsonValue(val);
|
|
1185
|
-
}
|
|
1186
|
-
}, []);
|
|
1187
|
-
const handleEditComplete = useCallback2(() => {
|
|
1188
|
-
onChange(internalJsonValue);
|
|
1189
|
-
requestAnimationFrame(() => {
|
|
1190
|
-
wrapperRef.current?.blur();
|
|
1191
|
-
});
|
|
1192
|
-
setJsonReadOnly(true);
|
|
1193
|
-
}, [internalJsonValue, onChange]);
|
|
1194
|
-
const [jsonReadOnly, setJsonReadOnly] = useState2(true);
|
|
1195
|
-
const handleFormatJson = useCallback2(() => {
|
|
1196
|
-
try {
|
|
1197
|
-
const parsed = JSON.parse(internalJsonValue);
|
|
1198
|
-
const formatted = JSON.stringify(parsed, null, 4);
|
|
1199
|
-
setInternalJsonValue(formatted);
|
|
1200
|
-
onChange(formatted);
|
|
1201
|
-
} catch (error) {
|
|
1202
|
-
console.error("Invalid JSON:", error);
|
|
1203
|
-
}
|
|
1204
|
-
}, [internalJsonValue, onChange]);
|
|
1205
|
-
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(
|
|
1206
|
-
IconButton2,
|
|
1207
|
-
{
|
|
1208
|
-
icon: /* @__PURE__ */ React15.createElement(IconBrackets, { style: { color: "var(--semi-color-primary)" } }),
|
|
1209
|
-
size: "small",
|
|
1210
|
-
type: "tertiary",
|
|
1211
|
-
theme: "borderless",
|
|
1212
|
-
onClick: handleFormatJson
|
|
1213
|
-
}
|
|
1214
|
-
)))), /* @__PURE__ */ React15.createElement(
|
|
1215
|
-
JSONViewerWrapper,
|
|
1216
|
-
{
|
|
1217
|
-
ref: wrapperRef,
|
|
1218
|
-
tabIndex: -1,
|
|
1219
|
-
onBlur: (e) => {
|
|
1220
|
-
if (wrapperRef.current && !wrapperRef.current?.contains(e.relatedTarget)) {
|
|
1221
|
-
handleEditComplete();
|
|
1222
|
-
}
|
|
1223
|
-
},
|
|
1224
|
-
onClick: (e) => {
|
|
1225
|
-
setJsonReadOnly(false);
|
|
1226
|
-
}
|
|
1227
|
-
},
|
|
1228
|
-
/* @__PURE__ */ React15.createElement(
|
|
1229
|
-
JsonViewer,
|
|
1230
|
-
{
|
|
1231
|
-
ref: JsonViewerRef,
|
|
1232
|
-
value: getValueType(value) === "string" ? value : "",
|
|
1233
|
-
height: 120,
|
|
1234
|
-
width: "100%",
|
|
1235
|
-
showSearch: false,
|
|
1236
|
-
options: {
|
|
1237
|
-
readOnly: jsonReadOnly,
|
|
1238
|
-
formatOptions: { tabSize: 4, insertSpaces: true, eol: "\n" }
|
|
1239
|
-
},
|
|
1240
|
-
style: {
|
|
1241
|
-
padding: 0
|
|
1242
|
-
},
|
|
1243
|
-
onChange: handleJsonChange
|
|
1244
|
-
}
|
|
1245
|
-
)
|
|
1246
|
-
)) : /* @__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(
|
|
1247
1211
|
ConstantInput,
|
|
1248
1212
|
{
|
|
1249
1213
|
value,
|
|
1250
1214
|
onChange: (_v) => onChange(_v),
|
|
1251
1215
|
schema: schema || { type: "string" },
|
|
1252
|
-
placeholder: placeholder ?? "Default value if parameter is not provided"
|
|
1216
|
+
placeholder: placeholder ?? I18n8.t("Default value if parameter is not provided")
|
|
1253
1217
|
}
|
|
1254
1218
|
));
|
|
1255
1219
|
}
|
|
1256
1220
|
|
|
1257
1221
|
// src/components/json-schema-editor/components/blur-input.tsx
|
|
1258
|
-
import
|
|
1222
|
+
import React17, { useEffect as useEffect3, useState as useState2 } from "react";
|
|
1259
1223
|
import Input3 from "@douyinfe/semi-ui/lib/es/input";
|
|
1260
1224
|
function BlurInput(props) {
|
|
1261
|
-
const [value, setValue] =
|
|
1225
|
+
const [value, setValue] = useState2("");
|
|
1262
1226
|
useEffect3(() => {
|
|
1263
1227
|
setValue(props.value);
|
|
1264
1228
|
}, [props.value]);
|
|
1265
|
-
return /* @__PURE__ */
|
|
1229
|
+
return /* @__PURE__ */ React17.createElement(
|
|
1266
1230
|
Input3,
|
|
1267
1231
|
{
|
|
1268
1232
|
...props,
|
|
@@ -1276,13 +1240,14 @@ function BlurInput(props) {
|
|
|
1276
1240
|
}
|
|
1277
1241
|
|
|
1278
1242
|
// src/components/json-schema-editor/index.tsx
|
|
1243
|
+
var DEFAULT = { type: "object" };
|
|
1279
1244
|
function JsonSchemaEditor(props) {
|
|
1280
|
-
const { value =
|
|
1245
|
+
const { value = DEFAULT, config = {}, onChange: onChangeProps, readonly } = props;
|
|
1281
1246
|
const { propertyList, onAddProperty, onRemoveProperty, onEditProperty } = usePropertiesEdit(
|
|
1282
1247
|
value,
|
|
1283
1248
|
onChangeProps
|
|
1284
1249
|
);
|
|
1285
|
-
return /* @__PURE__ */
|
|
1250
|
+
return /* @__PURE__ */ React18.createElement(UIContainer, { className: props.className }, /* @__PURE__ */ React18.createElement(UIProperties, null, propertyList.map((_property, index) => /* @__PURE__ */ React18.createElement(
|
|
1286
1251
|
PropertyEdit,
|
|
1287
1252
|
{
|
|
1288
1253
|
readonly,
|
|
@@ -1297,16 +1262,16 @@ function JsonSchemaEditor(props) {
|
|
|
1297
1262
|
onRemoveProperty(_property.key);
|
|
1298
1263
|
}
|
|
1299
1264
|
}
|
|
1300
|
-
))), /* @__PURE__ */
|
|
1265
|
+
))), /* @__PURE__ */ React18.createElement(
|
|
1301
1266
|
Button,
|
|
1302
1267
|
{
|
|
1303
1268
|
disabled: readonly,
|
|
1304
1269
|
size: "small",
|
|
1305
1270
|
style: { marginTop: 10, marginLeft: 16 },
|
|
1306
|
-
icon: /* @__PURE__ */
|
|
1271
|
+
icon: /* @__PURE__ */ React18.createElement(IconPlus, null),
|
|
1307
1272
|
onClick: onAddProperty
|
|
1308
1273
|
},
|
|
1309
|
-
config?.addButtonText ?? "Add"
|
|
1274
|
+
config?.addButtonText ?? I18n9.t("Add")
|
|
1310
1275
|
));
|
|
1311
1276
|
}
|
|
1312
1277
|
function PropertyEdit(props) {
|
|
@@ -1324,19 +1289,19 @@ function PropertyEdit(props) {
|
|
|
1324
1289
|
$parentType = "",
|
|
1325
1290
|
$showLine
|
|
1326
1291
|
} = props;
|
|
1327
|
-
const [expand, setExpand] =
|
|
1328
|
-
const [collapse, setCollapse] =
|
|
1292
|
+
const [expand, setExpand] = useState3(false);
|
|
1293
|
+
const [collapse, setCollapse] = useState3(false);
|
|
1329
1294
|
const { name, type, items, default: defaultValue, description, isPropertyRequired } = value || {};
|
|
1330
|
-
const typeSelectorValue =
|
|
1331
|
-
const { propertyList,
|
|
1295
|
+
const typeSelectorValue = useMemo4(() => ({ type, items }), [type, items]);
|
|
1296
|
+
const { propertyList, canAddField, onAddProperty, onRemoveProperty, onEditProperty } = usePropertiesEdit(value, onChangeProps);
|
|
1332
1297
|
const onChange = (key, _value) => {
|
|
1333
1298
|
onChangeProps?.({
|
|
1334
1299
|
...value || {},
|
|
1335
1300
|
[key]: _value
|
|
1336
1301
|
});
|
|
1337
1302
|
};
|
|
1338
|
-
const showCollapse =
|
|
1339
|
-
return /* @__PURE__ */
|
|
1303
|
+
const showCollapse = canAddField && propertyList.length > 0;
|
|
1304
|
+
return /* @__PURE__ */ React18.createElement(React18.Fragment, null, /* @__PURE__ */ React18.createElement(
|
|
1340
1305
|
UIPropertyLeft,
|
|
1341
1306
|
{
|
|
1342
1307
|
type,
|
|
@@ -1348,8 +1313,8 @@ function PropertyEdit(props) {
|
|
|
1348
1313
|
$parentExpand,
|
|
1349
1314
|
$parentType
|
|
1350
1315
|
},
|
|
1351
|
-
showCollapse && /* @__PURE__ */
|
|
1352
|
-
), /* @__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(
|
|
1353
1318
|
UIPropertyMain,
|
|
1354
1319
|
{
|
|
1355
1320
|
$showCollapse: showCollapse,
|
|
@@ -1357,7 +1322,7 @@ function PropertyEdit(props) {
|
|
|
1357
1322
|
$expand: expand,
|
|
1358
1323
|
type
|
|
1359
1324
|
},
|
|
1360
|
-
/* @__PURE__ */
|
|
1325
|
+
/* @__PURE__ */ React18.createElement(UIRow, null, /* @__PURE__ */ React18.createElement(UIName, null, /* @__PURE__ */ React18.createElement(
|
|
1361
1326
|
BlurInput,
|
|
1362
1327
|
{
|
|
1363
1328
|
disabled: readonly,
|
|
@@ -1366,8 +1331,8 @@ function PropertyEdit(props) {
|
|
|
1366
1331
|
value: name,
|
|
1367
1332
|
onChange: (value2) => onChange("name", value2)
|
|
1368
1333
|
}
|
|
1369
|
-
)), /* @__PURE__ */
|
|
1370
|
-
|
|
1334
|
+
)), /* @__PURE__ */ React18.createElement(UIType, null, /* @__PURE__ */ React18.createElement(
|
|
1335
|
+
InjectTypeSelector,
|
|
1371
1336
|
{
|
|
1372
1337
|
value: typeSelectorValue,
|
|
1373
1338
|
readonly,
|
|
@@ -1378,67 +1343,67 @@ function PropertyEdit(props) {
|
|
|
1378
1343
|
});
|
|
1379
1344
|
}
|
|
1380
1345
|
}
|
|
1381
|
-
)), /* @__PURE__ */
|
|
1346
|
+
)), /* @__PURE__ */ React18.createElement(UIRequired, null, /* @__PURE__ */ React18.createElement(
|
|
1382
1347
|
Checkbox,
|
|
1383
1348
|
{
|
|
1384
1349
|
disabled: readonly,
|
|
1385
1350
|
checked: isPropertyRequired,
|
|
1386
1351
|
onChange: (e) => onChange("isPropertyRequired", e.target.checked)
|
|
1387
1352
|
}
|
|
1388
|
-
)), /* @__PURE__ */
|
|
1389
|
-
|
|
1353
|
+
)), /* @__PURE__ */ React18.createElement(UIActions, null, /* @__PURE__ */ React18.createElement(
|
|
1354
|
+
IconButton2,
|
|
1390
1355
|
{
|
|
1391
1356
|
disabled: readonly,
|
|
1392
1357
|
size: "small",
|
|
1393
1358
|
theme: "borderless",
|
|
1394
|
-
icon: expand ? /* @__PURE__ */
|
|
1359
|
+
icon: expand ? /* @__PURE__ */ React18.createElement(IconShrink, { size: "small" }) : /* @__PURE__ */ React18.createElement(IconExpand, { size: "small" }),
|
|
1395
1360
|
onClick: () => {
|
|
1396
1361
|
setExpand((_expand) => !_expand);
|
|
1397
1362
|
}
|
|
1398
1363
|
}
|
|
1399
|
-
),
|
|
1400
|
-
|
|
1364
|
+
), canAddField && /* @__PURE__ */ React18.createElement(
|
|
1365
|
+
IconButton2,
|
|
1401
1366
|
{
|
|
1402
1367
|
disabled: readonly,
|
|
1403
1368
|
size: "small",
|
|
1404
1369
|
theme: "borderless",
|
|
1405
|
-
icon: /* @__PURE__ */
|
|
1370
|
+
icon: /* @__PURE__ */ React18.createElement(IconAddChildren, null),
|
|
1406
1371
|
onClick: () => {
|
|
1407
1372
|
onAddProperty();
|
|
1408
1373
|
setCollapse(true);
|
|
1409
1374
|
}
|
|
1410
1375
|
}
|
|
1411
|
-
), /* @__PURE__ */
|
|
1412
|
-
|
|
1376
|
+
), /* @__PURE__ */ React18.createElement(
|
|
1377
|
+
IconButton2,
|
|
1413
1378
|
{
|
|
1414
1379
|
disabled: readonly,
|
|
1415
1380
|
size: "small",
|
|
1416
1381
|
theme: "borderless",
|
|
1417
|
-
icon: /* @__PURE__ */
|
|
1382
|
+
icon: /* @__PURE__ */ React18.createElement(IconMinus, { size: "small" }),
|
|
1418
1383
|
onClick: onRemove
|
|
1419
1384
|
}
|
|
1420
1385
|
))),
|
|
1421
|
-
expand && /* @__PURE__ */
|
|
1386
|
+
expand && /* @__PURE__ */ React18.createElement(UIExpandDetail, null, /* @__PURE__ */ React18.createElement(UILabel, null, config?.descTitle ?? I18n9.t("Description")), /* @__PURE__ */ React18.createElement(
|
|
1422
1387
|
BlurInput,
|
|
1423
1388
|
{
|
|
1424
1389
|
disabled: readonly,
|
|
1425
1390
|
size: "small",
|
|
1426
1391
|
value: description,
|
|
1427
1392
|
onChange: (value2) => onChange("description", value2),
|
|
1428
|
-
placeholder: config?.descPlaceholder ?? "Help LLM to understand the property"
|
|
1393
|
+
placeholder: config?.descPlaceholder ?? I18n9.t("Help LLM to understand the property")
|
|
1429
1394
|
}
|
|
1430
|
-
), $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(
|
|
1431
1396
|
DefaultValue,
|
|
1432
1397
|
{
|
|
1433
1398
|
value: defaultValue,
|
|
1434
1399
|
schema: value,
|
|
1435
1400
|
type,
|
|
1436
|
-
placeholder: config?.defaultValuePlaceholder,
|
|
1401
|
+
placeholder: config?.defaultValuePlaceholder ?? I18n9.t("Default Value"),
|
|
1437
1402
|
jsonFormatText: config?.jsonFormatText,
|
|
1438
1403
|
onChange: (value2) => onChange("default", value2)
|
|
1439
1404
|
}
|
|
1440
1405
|
))))
|
|
1441
|
-
), showCollapse && /* @__PURE__ */
|
|
1406
|
+
), showCollapse && /* @__PURE__ */ React18.createElement(UICollapsible, { $collapse: collapse }, /* @__PURE__ */ React18.createElement(UIProperties, { $shrink: true }, propertyList.map((_property, index) => /* @__PURE__ */ React18.createElement(
|
|
1442
1407
|
PropertyEdit,
|
|
1443
1408
|
{
|
|
1444
1409
|
readonly,
|
|
@@ -1463,20 +1428,20 @@ function PropertyEdit(props) {
|
|
|
1463
1428
|
}
|
|
1464
1429
|
|
|
1465
1430
|
// src/components/batch-variable-selector/index.tsx
|
|
1466
|
-
import
|
|
1431
|
+
import React19 from "react";
|
|
1467
1432
|
import { PrivateScopeProvider } from "@flowgram.ai/editor";
|
|
1468
1433
|
var batchVariableSchema = {
|
|
1469
1434
|
type: "array",
|
|
1470
1435
|
extra: { weak: true }
|
|
1471
1436
|
};
|
|
1472
1437
|
function BatchVariableSelector(props) {
|
|
1473
|
-
return /* @__PURE__ */
|
|
1438
|
+
return /* @__PURE__ */ React19.createElement(PrivateScopeProvider, null, /* @__PURE__ */ React19.createElement(VariableSelector, { ...props, includeSchema: batchVariableSchema }));
|
|
1474
1439
|
}
|
|
1475
1440
|
|
|
1476
1441
|
// src/components/dynamic-value-input/index.tsx
|
|
1477
|
-
import
|
|
1442
|
+
import React20 from "react";
|
|
1478
1443
|
import { JsonSchemaUtils as JsonSchemaUtils3 } from "@flowgram.ai/json-schema";
|
|
1479
|
-
import { IconButton as
|
|
1444
|
+
import { IconButton as IconButton3 } from "@douyinfe/semi-ui";
|
|
1480
1445
|
import { IconSetting } from "@douyinfe/semi-icons";
|
|
1481
1446
|
|
|
1482
1447
|
// src/components/dynamic-value-input/styles.tsx
|
|
@@ -1525,11 +1490,11 @@ var UITrigger = styled4.div`
|
|
|
1525
1490
|
`;
|
|
1526
1491
|
|
|
1527
1492
|
// src/components/dynamic-value-input/hooks.ts
|
|
1528
|
-
import { useMemo as
|
|
1493
|
+
import { useMemo as useMemo5, useState as useState4 } from "react";
|
|
1529
1494
|
import { useScopeAvailable } from "@flowgram.ai/editor";
|
|
1530
1495
|
function useRefVariable(value) {
|
|
1531
1496
|
const available = useScopeAvailable();
|
|
1532
|
-
const refVariable =
|
|
1497
|
+
const refVariable = useMemo5(() => {
|
|
1533
1498
|
if (value?.type === "ref") {
|
|
1534
1499
|
return available.getByKeyPath(value.content);
|
|
1535
1500
|
}
|
|
@@ -1541,11 +1506,11 @@ function useSelectSchema(schemaFromProps, constantProps, value) {
|
|
|
1541
1506
|
if (value?.type === "constant") {
|
|
1542
1507
|
defaultSelectSchema = value?.schema || defaultSelectSchema;
|
|
1543
1508
|
}
|
|
1544
|
-
const [selectSchema, setSelectSchema] =
|
|
1509
|
+
const [selectSchema, setSelectSchema] = useState4(defaultSelectSchema);
|
|
1545
1510
|
return [selectSchema, setSelectSchema];
|
|
1546
1511
|
}
|
|
1547
1512
|
function useIncludeSchema(schemaFromProps) {
|
|
1548
|
-
const includeSchema =
|
|
1513
|
+
const includeSchema = useMemo5(() => {
|
|
1549
1514
|
if (!schemaFromProps) {
|
|
1550
1515
|
return;
|
|
1551
1516
|
}
|
|
@@ -1571,13 +1536,13 @@ function DynamicValueInput({
|
|
|
1571
1536
|
const includeSchema = useIncludeSchema(schemaFromProps);
|
|
1572
1537
|
const renderTypeSelector = () => {
|
|
1573
1538
|
if (schemaFromProps) {
|
|
1574
|
-
return /* @__PURE__ */
|
|
1539
|
+
return /* @__PURE__ */ React20.createElement(TypeSelector, { value: schemaFromProps, readonly: true });
|
|
1575
1540
|
}
|
|
1576
1541
|
if (value?.type === "ref") {
|
|
1577
1542
|
const schema = refVariable?.type ? JsonSchemaUtils3.astToSchema(refVariable?.type) : void 0;
|
|
1578
|
-
return /* @__PURE__ */
|
|
1543
|
+
return /* @__PURE__ */ React20.createElement(TypeSelector, { value: schema, readonly: true });
|
|
1579
1544
|
}
|
|
1580
|
-
return /* @__PURE__ */
|
|
1545
|
+
return /* @__PURE__ */ React20.createElement(
|
|
1581
1546
|
TypeSelector,
|
|
1582
1547
|
{
|
|
1583
1548
|
value: selectSchema,
|
|
@@ -1605,8 +1570,8 @@ function DynamicValueInput({
|
|
|
1605
1570
|
};
|
|
1606
1571
|
const renderMain = () => {
|
|
1607
1572
|
if (value?.type === "ref") {
|
|
1608
|
-
return /* @__PURE__ */
|
|
1609
|
-
|
|
1573
|
+
return /* @__PURE__ */ React20.createElement(
|
|
1574
|
+
InjectVariableSelector,
|
|
1610
1575
|
{
|
|
1611
1576
|
style: { width: "100%" },
|
|
1612
1577
|
value: value?.content,
|
|
@@ -1617,7 +1582,7 @@ function DynamicValueInput({
|
|
|
1617
1582
|
);
|
|
1618
1583
|
}
|
|
1619
1584
|
const constantSchema = schemaFromProps || selectSchema || { type: "string" };
|
|
1620
|
-
return /* @__PURE__ */
|
|
1585
|
+
return /* @__PURE__ */ React20.createElement(
|
|
1621
1586
|
ConstantInput,
|
|
1622
1587
|
{
|
|
1623
1588
|
value: value?.content,
|
|
@@ -1625,8 +1590,8 @@ function DynamicValueInput({
|
|
|
1625
1590
|
schema: constantSchema || { type: "string" },
|
|
1626
1591
|
readonly,
|
|
1627
1592
|
strategies: [...constantProps?.strategies || []],
|
|
1628
|
-
fallbackRenderer: () => /* @__PURE__ */
|
|
1629
|
-
|
|
1593
|
+
fallbackRenderer: () => /* @__PURE__ */ React20.createElement(
|
|
1594
|
+
InjectVariableSelector,
|
|
1630
1595
|
{
|
|
1631
1596
|
style: { width: "100%" },
|
|
1632
1597
|
onChange: (_v) => onChange(_v ? { type: "ref", content: _v } : void 0),
|
|
@@ -1638,22 +1603,25 @@ function DynamicValueInput({
|
|
|
1638
1603
|
}
|
|
1639
1604
|
);
|
|
1640
1605
|
};
|
|
1641
|
-
const renderTrigger = () => /* @__PURE__ */
|
|
1642
|
-
|
|
1606
|
+
const renderTrigger = () => /* @__PURE__ */ React20.createElement(
|
|
1607
|
+
InjectVariableSelector,
|
|
1643
1608
|
{
|
|
1644
1609
|
style: { width: "100%" },
|
|
1645
1610
|
value: value?.type === "ref" ? value?.content : void 0,
|
|
1646
1611
|
onChange: (_v) => onChange({ type: "ref", content: _v }),
|
|
1647
1612
|
includeSchema,
|
|
1648
1613
|
readonly,
|
|
1649
|
-
triggerRender: () => /* @__PURE__ */
|
|
1614
|
+
triggerRender: () => /* @__PURE__ */ React20.createElement(IconButton3, { disabled: readonly, size: "small", icon: /* @__PURE__ */ React20.createElement(IconSetting, { size: "small" }) })
|
|
1650
1615
|
}
|
|
1651
1616
|
);
|
|
1652
|
-
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()));
|
|
1653
1618
|
}
|
|
1619
|
+
DynamicValueInput.renderKey = "dynamic-value-input-render-key";
|
|
1620
|
+
var InjectDynamicValueInput = createInjectMaterial(DynamicValueInput);
|
|
1654
1621
|
|
|
1655
1622
|
// src/components/condition-row/index.tsx
|
|
1656
|
-
import
|
|
1623
|
+
import React22, { useMemo as useMemo8 } from "react";
|
|
1624
|
+
import { I18n as I18n11 } from "@flowgram.ai/editor";
|
|
1657
1625
|
import { Input as Input4 } from "@douyinfe/semi-ui";
|
|
1658
1626
|
|
|
1659
1627
|
// src/components/condition-row/styles.tsx
|
|
@@ -1679,12 +1647,12 @@ var UIValues = styled5.div`
|
|
|
1679
1647
|
`;
|
|
1680
1648
|
|
|
1681
1649
|
// src/components/condition-row/hooks/useRule.ts
|
|
1682
|
-
import { useMemo as
|
|
1650
|
+
import { useMemo as useMemo6 } from "react";
|
|
1683
1651
|
import { JsonSchemaUtils as JsonSchemaUtils4 } from "@flowgram.ai/json-schema";
|
|
1684
1652
|
import { useScopeAvailable as useScopeAvailable2 } from "@flowgram.ai/editor";
|
|
1685
1653
|
|
|
1686
1654
|
// src/components/condition-row/constants.ts
|
|
1687
|
-
var
|
|
1655
|
+
var defaultRules = {
|
|
1688
1656
|
string: {
|
|
1689
1657
|
["eq" /* EQ */]: "string",
|
|
1690
1658
|
["neq" /* NEQ */]: "string",
|
|
@@ -1740,7 +1708,7 @@ var rules = {
|
|
|
1740
1708
|
["is_not_empty" /* IS_NOT_EMPTY */]: null
|
|
1741
1709
|
}
|
|
1742
1710
|
};
|
|
1743
|
-
var
|
|
1711
|
+
var defaultOpConfigs = {
|
|
1744
1712
|
["eq" /* EQ */]: {
|
|
1745
1713
|
label: "Equal",
|
|
1746
1714
|
abbreviation: "="
|
|
@@ -1804,34 +1772,38 @@ var opConfigs = {
|
|
|
1804
1772
|
};
|
|
1805
1773
|
|
|
1806
1774
|
// src/components/condition-row/hooks/useRule.ts
|
|
1807
|
-
function useRule(left) {
|
|
1775
|
+
function useRule(left, userRules) {
|
|
1808
1776
|
const available = useScopeAvailable2();
|
|
1809
|
-
const
|
|
1777
|
+
const rules = useMemo6(() => ({ ...defaultRules, ...userRules || {} }), [userRules]);
|
|
1778
|
+
const variable = useMemo6(() => {
|
|
1810
1779
|
if (!left) return void 0;
|
|
1811
1780
|
return available.getByKeyPath(left.content);
|
|
1812
1781
|
}, [available, left]);
|
|
1813
|
-
const rule =
|
|
1782
|
+
const rule = useMemo6(() => {
|
|
1814
1783
|
if (!variable) return void 0;
|
|
1815
1784
|
const schema = JsonSchemaUtils4.astToSchema(variable.type, { drilldown: false });
|
|
1816
1785
|
return rules[schema?.type];
|
|
1817
|
-
}, [variable?.type]);
|
|
1786
|
+
}, [variable?.type, rules]);
|
|
1818
1787
|
return { rule };
|
|
1819
1788
|
}
|
|
1820
1789
|
|
|
1821
1790
|
// src/components/condition-row/hooks/useOp.tsx
|
|
1822
|
-
import
|
|
1791
|
+
import React21, { useMemo as useMemo7 } from "react";
|
|
1792
|
+
import { I18n as I18n10 } from "@flowgram.ai/editor";
|
|
1823
1793
|
import { Button as Button2, Select as Select2 } from "@douyinfe/semi-ui";
|
|
1824
1794
|
import { IconChevronDownStroked as IconChevronDownStroked2 } from "@douyinfe/semi-icons";
|
|
1825
|
-
function useOp({ rule, op, onChange, readonly }) {
|
|
1826
|
-
const options =
|
|
1795
|
+
function useOp({ rule, op, onChange, readonly, userOps }) {
|
|
1796
|
+
const options = useMemo7(
|
|
1827
1797
|
() => Object.keys(rule || {}).map((_op) => ({
|
|
1828
|
-
...
|
|
1829
|
-
|
|
1798
|
+
...defaultOpConfigs[_op] || {},
|
|
1799
|
+
...userOps?.[_op] || {},
|
|
1800
|
+
value: _op,
|
|
1801
|
+
label: I18n10.t(userOps?.[_op]?.label || defaultOpConfigs[_op]?.label)
|
|
1830
1802
|
})),
|
|
1831
|
-
[rule]
|
|
1803
|
+
[rule, userOps]
|
|
1832
1804
|
);
|
|
1833
|
-
const opConfig =
|
|
1834
|
-
const renderOpSelect = () => /* @__PURE__ */
|
|
1805
|
+
const opConfig = useMemo7(() => defaultOpConfigs[op], [op]);
|
|
1806
|
+
const renderOpSelect = () => /* @__PURE__ */ React21.createElement(
|
|
1835
1807
|
Select2,
|
|
1836
1808
|
{
|
|
1837
1809
|
style: { height: 22 },
|
|
@@ -1842,28 +1814,39 @@ function useOp({ rule, op, onChange, readonly }) {
|
|
|
1842
1814
|
onChange: (v) => {
|
|
1843
1815
|
onChange(v);
|
|
1844
1816
|
},
|
|
1845
|
-
triggerRender: ({ value }) => /* @__PURE__ */
|
|
1817
|
+
triggerRender: ({ value }) => /* @__PURE__ */ React21.createElement(Button2, { size: "small", disabled: !rule }, opConfig?.abbreviation || /* @__PURE__ */ React21.createElement(IconChevronDownStroked2, { size: "small" }))
|
|
1846
1818
|
}
|
|
1847
1819
|
);
|
|
1848
1820
|
return { renderOpSelect, opConfig };
|
|
1849
1821
|
}
|
|
1850
1822
|
|
|
1851
1823
|
// src/components/condition-row/index.tsx
|
|
1852
|
-
|
|
1824
|
+
var defaultRuleConfig = {
|
|
1825
|
+
ops: {},
|
|
1826
|
+
rules: {}
|
|
1827
|
+
};
|
|
1828
|
+
function ConditionRow({
|
|
1829
|
+
style,
|
|
1830
|
+
value,
|
|
1831
|
+
onChange,
|
|
1832
|
+
readonly,
|
|
1833
|
+
ruleConfig = defaultRuleConfig
|
|
1834
|
+
}) {
|
|
1853
1835
|
const { left, operator, right } = value || {};
|
|
1854
|
-
const { rule } = useRule(left);
|
|
1836
|
+
const { rule } = useRule(left, ruleConfig.rules);
|
|
1855
1837
|
const { renderOpSelect, opConfig } = useOp({
|
|
1856
1838
|
rule,
|
|
1857
1839
|
op: operator,
|
|
1858
1840
|
onChange: (v) => onChange({ ...value, operator: v }),
|
|
1859
|
-
readonly
|
|
1841
|
+
readonly,
|
|
1842
|
+
userOps: ruleConfig.ops
|
|
1860
1843
|
});
|
|
1861
|
-
const targetSchema =
|
|
1862
|
-
const targetType = rule?.[operator] || null;
|
|
1844
|
+
const targetSchema = useMemo8(() => {
|
|
1845
|
+
const targetType = rule?.[operator || ""] || null;
|
|
1863
1846
|
return targetType ? { type: targetType, extra: { weak: true } } : null;
|
|
1864
1847
|
}, [rule, opConfig]);
|
|
1865
|
-
return /* @__PURE__ */
|
|
1866
|
-
|
|
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,
|
|
1867
1850
|
{
|
|
1868
1851
|
readonly,
|
|
1869
1852
|
style: { width: "100%" },
|
|
@@ -1876,34 +1859,34 @@ function ConditionRow({ style, value, onChange, readonly }) {
|
|
|
1876
1859
|
}
|
|
1877
1860
|
})
|
|
1878
1861
|
}
|
|
1879
|
-
)), /* @__PURE__ */
|
|
1880
|
-
|
|
1862
|
+
)), /* @__PURE__ */ React22.createElement(UIRight, null, targetSchema ? /* @__PURE__ */ React22.createElement(
|
|
1863
|
+
InjectDynamicValueInput,
|
|
1881
1864
|
{
|
|
1882
1865
|
readonly: readonly || !rule,
|
|
1883
1866
|
value: right,
|
|
1884
1867
|
schema: targetSchema,
|
|
1885
1868
|
onChange: (v) => onChange({ ...value, right: v })
|
|
1886
1869
|
}
|
|
1887
|
-
) : /* @__PURE__ */
|
|
1870
|
+
) : /* @__PURE__ */ React22.createElement(
|
|
1888
1871
|
Input4,
|
|
1889
1872
|
{
|
|
1890
1873
|
size: "small",
|
|
1891
1874
|
disabled: true,
|
|
1892
1875
|
style: { pointerEvents: "none" },
|
|
1893
|
-
value: opConfig?.rightDisplay || "Empty"
|
|
1876
|
+
value: opConfig?.rightDisplay || I18n11.t("Empty")
|
|
1894
1877
|
}
|
|
1895
1878
|
))));
|
|
1896
1879
|
}
|
|
1897
1880
|
|
|
1898
1881
|
// src/components/batch-outputs/index.tsx
|
|
1899
|
-
import
|
|
1882
|
+
import React23 from "react";
|
|
1900
1883
|
import { Button as Button3, Input as Input5 } from "@douyinfe/semi-ui";
|
|
1901
1884
|
import { IconDelete, IconPlus as IconPlus2 } from "@douyinfe/semi-icons";
|
|
1902
1885
|
|
|
1903
1886
|
// src/hooks/use-object-list/index.tsx
|
|
1904
|
-
import { useEffect as useEffect4, useState as
|
|
1887
|
+
import { useEffect as useEffect4, useState as useState5 } from "react";
|
|
1905
1888
|
import { nanoid } from "nanoid";
|
|
1906
|
-
import { difference, get, isObject, set } from "lodash";
|
|
1889
|
+
import { difference as difference2, get, isObject as isObject2, set } from "lodash";
|
|
1907
1890
|
function genId2() {
|
|
1908
1891
|
return nanoid();
|
|
1909
1892
|
}
|
|
@@ -1912,12 +1895,12 @@ function useObjectList({
|
|
|
1912
1895
|
onChange,
|
|
1913
1896
|
sortIndexKey
|
|
1914
1897
|
}) {
|
|
1915
|
-
const [list, setList] =
|
|
1898
|
+
const [list, setList] = useState5([]);
|
|
1916
1899
|
useEffect4(() => {
|
|
1917
1900
|
setList((_prevList) => {
|
|
1918
1901
|
const newKeys = Object.entries(value || {}).sort((a, b) => get(a[1], sortIndexKey || 0) - get(b[1], sortIndexKey || 0)).map(([key]) => key);
|
|
1919
1902
|
const oldKeys = _prevList.map((item) => item.key).filter(Boolean);
|
|
1920
|
-
const addKeys =
|
|
1903
|
+
const addKeys = difference2(newKeys, oldKeys);
|
|
1921
1904
|
return _prevList.filter((item) => !item.key || newKeys.includes(item.key)).map((item) => ({
|
|
1922
1905
|
id: item.id,
|
|
1923
1906
|
key: item.key,
|
|
@@ -1953,7 +1936,7 @@ function useObjectList({
|
|
|
1953
1936
|
onChange(
|
|
1954
1937
|
Object.fromEntries(
|
|
1955
1938
|
nextList.filter((item) => item.key).map((item) => [item.key, item.value]).map((_res, idx) => {
|
|
1956
|
-
if (
|
|
1939
|
+
if (isObject2(_res[1]) && sortIndexKey) {
|
|
1957
1940
|
set(_res[1], sortIndexKey, idx);
|
|
1958
1941
|
}
|
|
1959
1942
|
return _res;
|
|
@@ -2014,7 +1997,7 @@ var UIRow2 = styled6.div`
|
|
|
2014
1997
|
function BatchOutputs(props) {
|
|
2015
1998
|
const { readonly, style } = props;
|
|
2016
1999
|
const { list, add, updateKey, updateValue, remove } = useObjectList(props);
|
|
2017
|
-
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(
|
|
2018
2001
|
Input5,
|
|
2019
2002
|
{
|
|
2020
2003
|
style: { width: 100 },
|
|
@@ -2023,27 +2006,27 @@ function BatchOutputs(props) {
|
|
|
2023
2006
|
value: item.key,
|
|
2024
2007
|
onChange: (v) => updateKey(item.id, v)
|
|
2025
2008
|
}
|
|
2026
|
-
), /* @__PURE__ */
|
|
2027
|
-
|
|
2009
|
+
), /* @__PURE__ */ React23.createElement(
|
|
2010
|
+
InjectVariableSelector,
|
|
2028
2011
|
{
|
|
2029
2012
|
style: { flexGrow: 1 },
|
|
2030
2013
|
readonly,
|
|
2031
2014
|
value: item.value?.content,
|
|
2032
2015
|
onChange: (v) => updateValue(item.id, { type: "ref", content: v })
|
|
2033
2016
|
}
|
|
2034
|
-
), /* @__PURE__ */
|
|
2017
|
+
), /* @__PURE__ */ React23.createElement(
|
|
2035
2018
|
Button3,
|
|
2036
2019
|
{
|
|
2037
2020
|
disabled: readonly,
|
|
2038
|
-
icon: /* @__PURE__ */
|
|
2021
|
+
icon: /* @__PURE__ */ React23.createElement(IconDelete, null),
|
|
2039
2022
|
size: "small",
|
|
2040
2023
|
onClick: () => remove(item.id)
|
|
2041
2024
|
}
|
|
2042
|
-
)))), /* @__PURE__ */
|
|
2025
|
+
)))), /* @__PURE__ */ React23.createElement(Button3, { disabled: readonly, icon: /* @__PURE__ */ React23.createElement(IconPlus2, null), size: "small", onClick: add }, "Add"));
|
|
2043
2026
|
}
|
|
2044
2027
|
|
|
2045
2028
|
// src/components/prompt-editor/index.tsx
|
|
2046
|
-
import
|
|
2029
|
+
import React24, { useEffect as useEffect5, useRef as useRef2 } from "react";
|
|
2047
2030
|
import { Renderer, EditorProvider as EditorProvider2, ActiveLinePlaceholder as ActiveLinePlaceholder2 } from "@coze-editor/editor/react";
|
|
2048
2031
|
import preset2 from "@coze-editor/editor/preset-prompt";
|
|
2049
2032
|
|
|
@@ -2187,13 +2170,13 @@ function PromptEditor(props) {
|
|
|
2187
2170
|
children,
|
|
2188
2171
|
disableMarkdownHighlight
|
|
2189
2172
|
} = props || {};
|
|
2190
|
-
const editorRef =
|
|
2173
|
+
const editorRef = useRef2(null);
|
|
2191
2174
|
useEffect5(() => {
|
|
2192
2175
|
if (editorRef.current?.getValue() !== value?.content) {
|
|
2193
2176
|
editorRef.current?.setValue(String(value?.content || ""));
|
|
2194
2177
|
}
|
|
2195
2178
|
}, [value]);
|
|
2196
|
-
return /* @__PURE__ */
|
|
2179
|
+
return /* @__PURE__ */ React24.createElement(UIContainer4, { $hasError: hasError, style }, /* @__PURE__ */ React24.createElement(EditorProvider2, null, /* @__PURE__ */ React24.createElement(
|
|
2197
2180
|
Renderer,
|
|
2198
2181
|
{
|
|
2199
2182
|
didMount: (editor) => {
|
|
@@ -2210,14 +2193,14 @@ function PromptEditor(props) {
|
|
|
2210
2193
|
onChange({ type: "template", content: e.value });
|
|
2211
2194
|
}
|
|
2212
2195
|
}
|
|
2213
|
-
), 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));
|
|
2214
2197
|
}
|
|
2215
2198
|
|
|
2216
2199
|
// src/components/prompt-editor-with-variables/index.tsx
|
|
2217
|
-
import
|
|
2200
|
+
import React27 from "react";
|
|
2218
2201
|
|
|
2219
2202
|
// src/components/prompt-editor-with-variables/extensions/variable-tree.tsx
|
|
2220
|
-
import
|
|
2203
|
+
import React25, { useEffect as useEffect6, useState as useState6 } from "react";
|
|
2221
2204
|
import { Popover as Popover2, Tree } from "@douyinfe/semi-ui";
|
|
2222
2205
|
import {
|
|
2223
2206
|
Mention,
|
|
@@ -2226,9 +2209,9 @@ import {
|
|
|
2226
2209
|
PositionMirror
|
|
2227
2210
|
} from "@coze-editor/editor/react";
|
|
2228
2211
|
function VariableTree() {
|
|
2229
|
-
const [posKey, setPosKey] =
|
|
2230
|
-
const [visible, setVisible] =
|
|
2231
|
-
const [position, setPosition] =
|
|
2212
|
+
const [posKey, setPosKey] = useState6("");
|
|
2213
|
+
const [visible, setVisible] = useState6(false);
|
|
2214
|
+
const [position, setPosition] = useState6(-1);
|
|
2232
2215
|
const editor = useEditor();
|
|
2233
2216
|
function insert(variablePath) {
|
|
2234
2217
|
const range = getCurrentMentionReplaceRange(editor.$view.state);
|
|
@@ -2251,14 +2234,14 @@ function VariableTree() {
|
|
|
2251
2234
|
}
|
|
2252
2235
|
}, [editor, visible]);
|
|
2253
2236
|
const treeData = useVariableTree({});
|
|
2254
|
-
return /* @__PURE__ */
|
|
2237
|
+
return /* @__PURE__ */ React25.createElement(React25.Fragment, null, /* @__PURE__ */ React25.createElement(Mention, { triggerCharacters: ["{", "{}", "@"], onOpenChange: handleOpenChange }), /* @__PURE__ */ React25.createElement(
|
|
2255
2238
|
Popover2,
|
|
2256
2239
|
{
|
|
2257
2240
|
visible,
|
|
2258
2241
|
trigger: "custom",
|
|
2259
2242
|
position: "topLeft",
|
|
2260
2243
|
rePosKey: posKey,
|
|
2261
|
-
content: /* @__PURE__ */
|
|
2244
|
+
content: /* @__PURE__ */ React25.createElement("div", { style: { width: 300 } }, /* @__PURE__ */ React25.createElement(
|
|
2262
2245
|
Tree,
|
|
2263
2246
|
{
|
|
2264
2247
|
treeData,
|
|
@@ -2268,7 +2251,7 @@ function VariableTree() {
|
|
|
2268
2251
|
}
|
|
2269
2252
|
))
|
|
2270
2253
|
},
|
|
2271
|
-
/* @__PURE__ */
|
|
2254
|
+
/* @__PURE__ */ React25.createElement(
|
|
2272
2255
|
PositionMirror,
|
|
2273
2256
|
{
|
|
2274
2257
|
position,
|
|
@@ -2280,7 +2263,7 @@ function VariableTree() {
|
|
|
2280
2263
|
|
|
2281
2264
|
// src/components/prompt-editor-with-variables/extensions/variable-tag.tsx
|
|
2282
2265
|
import ReactDOM from "react-dom";
|
|
2283
|
-
import
|
|
2266
|
+
import React26, { useLayoutEffect as useLayoutEffect4 } from "react";
|
|
2284
2267
|
import { isEqual, last } from "lodash";
|
|
2285
2268
|
import {
|
|
2286
2269
|
Disposable,
|
|
@@ -2342,7 +2325,7 @@ var VariableTagWidget = class extends WidgetType {
|
|
|
2342
2325
|
this.toDispose = new DisposableCollection();
|
|
2343
2326
|
this.renderIcon = (icon) => {
|
|
2344
2327
|
if (typeof icon === "string") {
|
|
2345
|
-
return /* @__PURE__ */
|
|
2328
|
+
return /* @__PURE__ */ React26.createElement("img", { style: { marginRight: 8 }, width: 12, height: 12, src: icon });
|
|
2346
2329
|
}
|
|
2347
2330
|
return icon;
|
|
2348
2331
|
};
|
|
@@ -2355,21 +2338,21 @@ var VariableTagWidget = class extends WidgetType {
|
|
|
2355
2338
|
renderVariable(v) {
|
|
2356
2339
|
if (!v) {
|
|
2357
2340
|
this.renderReact(
|
|
2358
|
-
/* @__PURE__ */
|
|
2341
|
+
/* @__PURE__ */ React26.createElement(UITag2, { prefixIcon: /* @__PURE__ */ React26.createElement(IconIssueStroked2, null), color: "amber" }, "Unknown")
|
|
2359
2342
|
);
|
|
2360
2343
|
return;
|
|
2361
2344
|
}
|
|
2362
2345
|
const rootField = last(v.parentFields) || v;
|
|
2363
2346
|
const isRoot = v.parentFields.length === 0;
|
|
2364
|
-
const rootTitle = /* @__PURE__ */
|
|
2347
|
+
const rootTitle = /* @__PURE__ */ React26.createElement(UIRootTitle2, null, rootField?.meta.title ? `${rootField.meta.title} ${isRoot ? "" : "-"} ` : "");
|
|
2365
2348
|
const rootIcon = this.renderIcon(rootField?.meta.icon);
|
|
2366
2349
|
this.renderReact(
|
|
2367
|
-
/* @__PURE__ */
|
|
2350
|
+
/* @__PURE__ */ React26.createElement(
|
|
2368
2351
|
Popover3,
|
|
2369
2352
|
{
|
|
2370
|
-
content: /* @__PURE__ */
|
|
2353
|
+
content: /* @__PURE__ */ React26.createElement(UIPopoverContent2, null, rootIcon, rootTitle, /* @__PURE__ */ React26.createElement(UIVarName2, null, v?.keyPath.slice(1).join(".")))
|
|
2371
2354
|
},
|
|
2372
|
-
/* @__PURE__ */
|
|
2355
|
+
/* @__PURE__ */ React26.createElement(UITag2, { prefixIcon: rootIcon }, rootTitle, !isRoot && /* @__PURE__ */ React26.createElement(UIVarName2, null, v?.key))
|
|
2373
2356
|
)
|
|
2374
2357
|
);
|
|
2375
2358
|
}
|
|
@@ -2443,14 +2426,14 @@ function VariableTagInject() {
|
|
|
2443
2426
|
|
|
2444
2427
|
// src/components/prompt-editor-with-variables/index.tsx
|
|
2445
2428
|
function PromptEditorWithVariables(props) {
|
|
2446
|
-
return /* @__PURE__ */
|
|
2429
|
+
return /* @__PURE__ */ React27.createElement(PromptEditor, { ...props }, /* @__PURE__ */ React27.createElement(VariableTree, null), /* @__PURE__ */ React27.createElement(VariableTagInject, null));
|
|
2447
2430
|
}
|
|
2448
2431
|
|
|
2449
2432
|
// src/components/prompt-editor-with-inputs/index.tsx
|
|
2450
|
-
import
|
|
2433
|
+
import React30 from "react";
|
|
2451
2434
|
|
|
2452
2435
|
// src/components/prompt-editor-with-inputs/extensions/inputs-tree.tsx
|
|
2453
|
-
import
|
|
2436
|
+
import React29, { useEffect as useEffect7, useState as useState7 } from "react";
|
|
2454
2437
|
import { Popover as Popover4 } from "@douyinfe/semi-ui";
|
|
2455
2438
|
import {
|
|
2456
2439
|
Mention as Mention2,
|
|
@@ -2460,7 +2443,7 @@ import {
|
|
|
2460
2443
|
} from "@coze-editor/editor/react";
|
|
2461
2444
|
|
|
2462
2445
|
// src/components/prompt-editor-with-inputs/inputs-picker.tsx
|
|
2463
|
-
import
|
|
2446
|
+
import React28, { useMemo as useMemo9 } from "react";
|
|
2464
2447
|
import { last as last2 } from "lodash";
|
|
2465
2448
|
import {
|
|
2466
2449
|
ASTMatch as ASTMatch3,
|
|
@@ -2504,7 +2487,7 @@ function InputsPicker({
|
|
|
2504
2487
|
children
|
|
2505
2488
|
};
|
|
2506
2489
|
};
|
|
2507
|
-
const treeData =
|
|
2490
|
+
const treeData = useMemo9(
|
|
2508
2491
|
() => Object.entries(inputsValues).map(([key, value]) => {
|
|
2509
2492
|
if (value?.type === "ref") {
|
|
2510
2493
|
const variable = available.getByKeyPath(value.content || []);
|
|
@@ -2520,14 +2503,14 @@ function InputsPicker({
|
|
|
2520
2503
|
}),
|
|
2521
2504
|
[]
|
|
2522
2505
|
);
|
|
2523
|
-
return /* @__PURE__ */
|
|
2506
|
+
return /* @__PURE__ */ React28.createElement(Tree2, { treeData, onSelect: (v) => onSelect(v) });
|
|
2524
2507
|
}
|
|
2525
2508
|
|
|
2526
2509
|
// src/components/prompt-editor-with-inputs/extensions/inputs-tree.tsx
|
|
2527
2510
|
function InputsTree({ inputsValues }) {
|
|
2528
|
-
const [posKey, setPosKey] =
|
|
2529
|
-
const [visible, setVisible] =
|
|
2530
|
-
const [position, setPosition] =
|
|
2511
|
+
const [posKey, setPosKey] = useState7("");
|
|
2512
|
+
const [visible, setVisible] = useState7(false);
|
|
2513
|
+
const [position, setPosition] = useState7(-1);
|
|
2531
2514
|
const editor = useEditor2();
|
|
2532
2515
|
function insert(variablePath) {
|
|
2533
2516
|
const range = getCurrentMentionReplaceRange2(editor.$view.state);
|
|
@@ -2549,14 +2532,14 @@ function InputsTree({ inputsValues }) {
|
|
|
2549
2532
|
return;
|
|
2550
2533
|
}
|
|
2551
2534
|
}, [editor, visible]);
|
|
2552
|
-
return /* @__PURE__ */
|
|
2535
|
+
return /* @__PURE__ */ React29.createElement(React29.Fragment, null, /* @__PURE__ */ React29.createElement(Mention2, { triggerCharacters: ["{", "{}", "@"], onOpenChange: handleOpenChange }), /* @__PURE__ */ React29.createElement(
|
|
2553
2536
|
Popover4,
|
|
2554
2537
|
{
|
|
2555
2538
|
visible,
|
|
2556
2539
|
trigger: "custom",
|
|
2557
2540
|
position: "topLeft",
|
|
2558
2541
|
rePosKey: posKey,
|
|
2559
|
-
content: /* @__PURE__ */
|
|
2542
|
+
content: /* @__PURE__ */ React29.createElement("div", { style: { width: 300 } }, /* @__PURE__ */ React29.createElement(
|
|
2560
2543
|
InputsPicker,
|
|
2561
2544
|
{
|
|
2562
2545
|
inputsValues,
|
|
@@ -2566,7 +2549,7 @@ function InputsTree({ inputsValues }) {
|
|
|
2566
2549
|
}
|
|
2567
2550
|
))
|
|
2568
2551
|
},
|
|
2569
|
-
/* @__PURE__ */
|
|
2552
|
+
/* @__PURE__ */ React29.createElement(
|
|
2570
2553
|
PositionMirror2,
|
|
2571
2554
|
{
|
|
2572
2555
|
position,
|
|
@@ -2578,15 +2561,15 @@ function InputsTree({ inputsValues }) {
|
|
|
2578
2561
|
|
|
2579
2562
|
// src/components/prompt-editor-with-inputs/index.tsx
|
|
2580
2563
|
function PromptEditorWithInputs({ inputsValues, ...restProps }) {
|
|
2581
|
-
return /* @__PURE__ */
|
|
2564
|
+
return /* @__PURE__ */ React30.createElement(PromptEditor, { ...restProps }, /* @__PURE__ */ React30.createElement(InputsTree, { inputsValues }));
|
|
2582
2565
|
}
|
|
2583
2566
|
|
|
2584
2567
|
// src/components/json-editor-with-variables/index.tsx
|
|
2585
|
-
import
|
|
2568
|
+
import React33 from "react";
|
|
2586
2569
|
import { transformerCreator } from "@coze-editor/editor/preset-code";
|
|
2587
2570
|
|
|
2588
2571
|
// src/components/json-editor-with-variables/extensions/variable-tree.tsx
|
|
2589
|
-
import
|
|
2572
|
+
import React31, { useEffect as useEffect8, useState as useState8 } from "react";
|
|
2590
2573
|
import { Popover as Popover5, Tree as Tree3 } from "@douyinfe/semi-ui";
|
|
2591
2574
|
import {
|
|
2592
2575
|
Mention as Mention3,
|
|
@@ -2595,9 +2578,9 @@ import {
|
|
|
2595
2578
|
PositionMirror as PositionMirror3
|
|
2596
2579
|
} from "@coze-editor/editor/react";
|
|
2597
2580
|
function VariableTree2() {
|
|
2598
|
-
const [posKey, setPosKey] =
|
|
2599
|
-
const [visible, setVisible] =
|
|
2600
|
-
const [position, setPosition] =
|
|
2581
|
+
const [posKey, setPosKey] = useState8("");
|
|
2582
|
+
const [visible, setVisible] = useState8(false);
|
|
2583
|
+
const [position, setPosition] = useState8(-1);
|
|
2601
2584
|
const editor = useEditor3();
|
|
2602
2585
|
function insert(variablePath) {
|
|
2603
2586
|
const range = getCurrentMentionReplaceRange3(editor.$view.state);
|
|
@@ -2620,14 +2603,14 @@ function VariableTree2() {
|
|
|
2620
2603
|
}
|
|
2621
2604
|
}, [editor, visible]);
|
|
2622
2605
|
const treeData = useVariableTree({});
|
|
2623
|
-
return /* @__PURE__ */
|
|
2606
|
+
return /* @__PURE__ */ React31.createElement(React31.Fragment, null, /* @__PURE__ */ React31.createElement(Mention3, { triggerCharacters: ["@"], onOpenChange: handleOpenChange }), /* @__PURE__ */ React31.createElement(
|
|
2624
2607
|
Popover5,
|
|
2625
2608
|
{
|
|
2626
2609
|
visible,
|
|
2627
2610
|
trigger: "custom",
|
|
2628
2611
|
position: "topLeft",
|
|
2629
2612
|
rePosKey: posKey,
|
|
2630
|
-
content: /* @__PURE__ */
|
|
2613
|
+
content: /* @__PURE__ */ React31.createElement("div", { style: { width: 300 } }, /* @__PURE__ */ React31.createElement(
|
|
2631
2614
|
Tree3,
|
|
2632
2615
|
{
|
|
2633
2616
|
treeData,
|
|
@@ -2637,7 +2620,7 @@ function VariableTree2() {
|
|
|
2637
2620
|
}
|
|
2638
2621
|
))
|
|
2639
2622
|
},
|
|
2640
|
-
/* @__PURE__ */
|
|
2623
|
+
/* @__PURE__ */ React31.createElement(
|
|
2641
2624
|
PositionMirror3,
|
|
2642
2625
|
{
|
|
2643
2626
|
position,
|
|
@@ -2648,7 +2631,7 @@ function VariableTree2() {
|
|
|
2648
2631
|
}
|
|
2649
2632
|
|
|
2650
2633
|
// src/components/json-editor-with-variables/extensions/variable-tag.tsx
|
|
2651
|
-
import
|
|
2634
|
+
import React32, { useLayoutEffect as useLayoutEffect5 } from "react";
|
|
2652
2635
|
import { createRoot } from "react-dom/client";
|
|
2653
2636
|
import { isEqual as isEqual2, last as last3 } from "lodash";
|
|
2654
2637
|
import {
|
|
@@ -2711,7 +2694,7 @@ var VariableTagWidget2 = class extends WidgetType2 {
|
|
|
2711
2694
|
this.toDispose = new DisposableCollection2();
|
|
2712
2695
|
this.renderIcon = (icon) => {
|
|
2713
2696
|
if (typeof icon === "string") {
|
|
2714
|
-
return /* @__PURE__ */
|
|
2697
|
+
return /* @__PURE__ */ React32.createElement("img", { style: { marginRight: 8 }, width: 12, height: 12, src: icon });
|
|
2715
2698
|
}
|
|
2716
2699
|
return icon;
|
|
2717
2700
|
};
|
|
@@ -2721,20 +2704,20 @@ var VariableTagWidget2 = class extends WidgetType2 {
|
|
|
2721
2704
|
renderVariable(v) {
|
|
2722
2705
|
if (!v) {
|
|
2723
2706
|
this.root.render(
|
|
2724
|
-
/* @__PURE__ */
|
|
2707
|
+
/* @__PURE__ */ React32.createElement(UITag3, { prefixIcon: /* @__PURE__ */ React32.createElement(IconIssueStroked3, null), color: "amber" }, "Unknown")
|
|
2725
2708
|
);
|
|
2726
2709
|
return;
|
|
2727
2710
|
}
|
|
2728
2711
|
const rootField = last3(v.parentFields);
|
|
2729
|
-
const rootTitle = /* @__PURE__ */
|
|
2712
|
+
const rootTitle = /* @__PURE__ */ React32.createElement(UIRootTitle3, null, rootField?.meta.title ? `${rootField.meta.title} -` : "");
|
|
2730
2713
|
const rootIcon = this.renderIcon(rootField?.meta.icon);
|
|
2731
2714
|
this.root.render(
|
|
2732
|
-
/* @__PURE__ */
|
|
2715
|
+
/* @__PURE__ */ React32.createElement(
|
|
2733
2716
|
Popover6,
|
|
2734
2717
|
{
|
|
2735
|
-
content: /* @__PURE__ */
|
|
2718
|
+
content: /* @__PURE__ */ React32.createElement(UIPopoverContent3, null, rootIcon, rootTitle, /* @__PURE__ */ React32.createElement(UIVarName3, null, v?.keyPath.slice(1).join(".")))
|
|
2736
2719
|
},
|
|
2737
|
-
/* @__PURE__ */
|
|
2720
|
+
/* @__PURE__ */ React32.createElement(UITag3, { prefixIcon: rootIcon }, rootTitle, /* @__PURE__ */ React32.createElement(UIVarName3, null, v?.key))
|
|
2738
2721
|
)
|
|
2739
2722
|
);
|
|
2740
2723
|
}
|
|
@@ -2836,7 +2819,7 @@ var transformer = transformerCreator((text) => {
|
|
|
2836
2819
|
return text;
|
|
2837
2820
|
});
|
|
2838
2821
|
function JsonEditorWithVariables(props) {
|
|
2839
|
-
return /* @__PURE__ */
|
|
2822
|
+
return /* @__PURE__ */ React33.createElement(
|
|
2840
2823
|
CodeEditor,
|
|
2841
2824
|
{
|
|
2842
2825
|
languageId: "json",
|
|
@@ -2847,14 +2830,15 @@ function JsonEditorWithVariables(props) {
|
|
|
2847
2830
|
...props.options || {}
|
|
2848
2831
|
}
|
|
2849
2832
|
},
|
|
2850
|
-
/* @__PURE__ */
|
|
2851
|
-
/* @__PURE__ */
|
|
2833
|
+
/* @__PURE__ */ React33.createElement(VariableTree2, null),
|
|
2834
|
+
/* @__PURE__ */ React33.createElement(VariableTagInject2, null)
|
|
2852
2835
|
);
|
|
2853
2836
|
}
|
|
2854
2837
|
|
|
2855
2838
|
// src/components/inputs-values/index.tsx
|
|
2856
|
-
import
|
|
2857
|
-
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";
|
|
2858
2842
|
import { IconDelete as IconDelete2, IconPlus as IconPlus3 } from "@douyinfe/semi-icons";
|
|
2859
2843
|
|
|
2860
2844
|
// src/components/inputs-values/styles.tsx
|
|
@@ -2872,14 +2856,14 @@ var UIRow3 = styled10.div`
|
|
|
2872
2856
|
`;
|
|
2873
2857
|
|
|
2874
2858
|
// src/components/inputs-values/components/blur-input.tsx
|
|
2875
|
-
import
|
|
2859
|
+
import React34, { useEffect as useEffect9, useState as useState9 } from "react";
|
|
2876
2860
|
import Input6 from "@douyinfe/semi-ui/lib/es/input";
|
|
2877
2861
|
function BlurInput2(props) {
|
|
2878
|
-
const [value, setValue] =
|
|
2862
|
+
const [value, setValue] = useState9("");
|
|
2879
2863
|
useEffect9(() => {
|
|
2880
2864
|
setValue(props.value);
|
|
2881
2865
|
}, [props.value]);
|
|
2882
|
-
return /* @__PURE__ */
|
|
2866
|
+
return /* @__PURE__ */ React34.createElement(
|
|
2883
2867
|
Input6,
|
|
2884
2868
|
{
|
|
2885
2869
|
...props,
|
|
@@ -2907,7 +2891,7 @@ function InputsValues({
|
|
|
2907
2891
|
onChange,
|
|
2908
2892
|
sortIndexKey: "extra.index"
|
|
2909
2893
|
});
|
|
2910
|
-
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(
|
|
2911
2895
|
BlurInput2,
|
|
2912
2896
|
{
|
|
2913
2897
|
style: { width: 100, minWidth: 100, maxWidth: 100 },
|
|
@@ -2915,10 +2899,10 @@ function InputsValues({
|
|
|
2915
2899
|
size: "small",
|
|
2916
2900
|
value: item.key,
|
|
2917
2901
|
onChange: (v) => updateKey(item.id, v),
|
|
2918
|
-
placeholder: "Input Key"
|
|
2902
|
+
placeholder: I18n12.t("Input Key")
|
|
2919
2903
|
}
|
|
2920
|
-
), /* @__PURE__ */
|
|
2921
|
-
|
|
2904
|
+
), /* @__PURE__ */ React35.createElement(
|
|
2905
|
+
InjectDynamicValueInput,
|
|
2922
2906
|
{
|
|
2923
2907
|
style: { flexGrow: 1 },
|
|
2924
2908
|
readonly,
|
|
@@ -2931,20 +2915,20 @@ function InputsValues({
|
|
|
2931
2915
|
strategies: [...constantProps?.strategies || []]
|
|
2932
2916
|
}
|
|
2933
2917
|
}
|
|
2934
|
-
), /* @__PURE__ */
|
|
2935
|
-
|
|
2918
|
+
), /* @__PURE__ */ React35.createElement(
|
|
2919
|
+
IconButton4,
|
|
2936
2920
|
{
|
|
2937
2921
|
disabled: readonly,
|
|
2938
2922
|
theme: "borderless",
|
|
2939
|
-
icon: /* @__PURE__ */
|
|
2923
|
+
icon: /* @__PURE__ */ React35.createElement(IconDelete2, { size: "small" }),
|
|
2940
2924
|
size: "small",
|
|
2941
2925
|
onClick: () => remove(item.id)
|
|
2942
2926
|
}
|
|
2943
|
-
)))), /* @__PURE__ */
|
|
2927
|
+
)))), /* @__PURE__ */ React35.createElement(Button4, { disabled: readonly, icon: /* @__PURE__ */ React35.createElement(IconPlus3, null), size: "small", onClick: add }, "Add"));
|
|
2944
2928
|
}
|
|
2945
2929
|
|
|
2946
2930
|
// src/components/display-schema-tree/index.tsx
|
|
2947
|
-
import
|
|
2931
|
+
import React36 from "react";
|
|
2948
2932
|
|
|
2949
2933
|
// src/components/display-schema-tree/styles.tsx
|
|
2950
2934
|
import styled11, { css as css4 } from "styled-components";
|
|
@@ -3028,7 +3012,7 @@ var TreeItem = styled11.div`
|
|
|
3028
3012
|
|
|
3029
3013
|
// src/components/display-schema-tree/index.tsx
|
|
3030
3014
|
function DisplaySchemaTree(props) {
|
|
3031
|
-
return /* @__PURE__ */
|
|
3015
|
+
return /* @__PURE__ */ React36.createElement(SchemaTree, { ...props });
|
|
3032
3016
|
}
|
|
3033
3017
|
function SchemaTree(props) {
|
|
3034
3018
|
const {
|
|
@@ -3044,18 +3028,18 @@ function SchemaTree(props) {
|
|
|
3044
3028
|
const icon = typeManager?.getDisplayIcon(schema);
|
|
3045
3029
|
let properties = drilldown && config ? config.getTypeSchemaProperties(schema) : {};
|
|
3046
3030
|
const childEntries = Object.entries(properties || {});
|
|
3047
|
-
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, {
|
|
3048
3032
|
className: "tree-icon"
|
|
3049
|
-
}), /* @__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);
|
|
3050
3034
|
}
|
|
3051
3035
|
|
|
3052
3036
|
// src/components/display-outputs/index.tsx
|
|
3053
|
-
import
|
|
3037
|
+
import React38, { useEffect as useEffect10 } from "react";
|
|
3054
3038
|
import { JsonSchemaUtils as JsonSchemaUtils5 } from "@flowgram.ai/json-schema";
|
|
3055
3039
|
import { useCurrentScope as useCurrentScope3, useRefresh } from "@flowgram.ai/editor";
|
|
3056
3040
|
|
|
3057
3041
|
// src/components/display-schema-tag/index.tsx
|
|
3058
|
-
import
|
|
3042
|
+
import React37 from "react";
|
|
3059
3043
|
import { Popover as Popover7 } from "@douyinfe/semi-ui";
|
|
3060
3044
|
|
|
3061
3045
|
// src/components/display-schema-tag/styles.ts
|
|
@@ -3084,14 +3068,14 @@ var TitleSpan = styled12.span`
|
|
|
3084
3068
|
function DisplaySchemaTag({ value = {}, showIconInTree, title, warning }) {
|
|
3085
3069
|
const typeManager = useTypeManager();
|
|
3086
3070
|
const icon = typeManager?.getDisplayIcon(value) || typeManager.getDisplayIcon({ type: "unknown" });
|
|
3087
|
-
return /* @__PURE__ */
|
|
3071
|
+
return /* @__PURE__ */ React37.createElement(
|
|
3088
3072
|
Popover7,
|
|
3089
3073
|
{
|
|
3090
|
-
content: /* @__PURE__ */
|
|
3074
|
+
content: /* @__PURE__ */ React37.createElement(PopoverContent, null, /* @__PURE__ */ React37.createElement(DisplaySchemaTree, { value, typeManager, showIcon: showIconInTree }))
|
|
3091
3075
|
},
|
|
3092
|
-
/* @__PURE__ */
|
|
3076
|
+
/* @__PURE__ */ React37.createElement(StyledTag, { color: warning ? "amber" : "white" }, icon && React37.cloneElement(icon, {
|
|
3093
3077
|
className: "tag-icon"
|
|
3094
|
-
}), title && /* @__PURE__ */
|
|
3078
|
+
}), title && /* @__PURE__ */ React37.createElement(TitleSpan, null, title))
|
|
3095
3079
|
);
|
|
3096
3080
|
}
|
|
3097
3081
|
|
|
@@ -3126,7 +3110,7 @@ function DisplayOutputs({ value, showIconInTree, displayFromScope }) {
|
|
|
3126
3110
|
return acm;
|
|
3127
3111
|
}, {}) : value?.properties || {};
|
|
3128
3112
|
const childEntries = Object.entries(properties || {});
|
|
3129
|
-
return /* @__PURE__ */
|
|
3113
|
+
return /* @__PURE__ */ React38.createElement(DisplayOutputsWrapper, null, childEntries.map(([key, schema]) => /* @__PURE__ */ React38.createElement(
|
|
3130
3114
|
DisplaySchemaTag,
|
|
3131
3115
|
{
|
|
3132
3116
|
key,
|
|
@@ -3139,13 +3123,13 @@ function DisplayOutputs({ value, showIconInTree, displayFromScope }) {
|
|
|
3139
3123
|
}
|
|
3140
3124
|
|
|
3141
3125
|
// src/components/display-flow-value/index.tsx
|
|
3142
|
-
import
|
|
3126
|
+
import React39, { useMemo as useMemo10 } from "react";
|
|
3143
3127
|
import { JsonSchemaUtils as JsonSchemaUtils6 } from "@flowgram.ai/json-schema";
|
|
3144
3128
|
import { useScopeAvailable as useScopeAvailable4 } from "@flowgram.ai/editor";
|
|
3145
3129
|
function DisplayFlowValue({ value, title, showIconInTree }) {
|
|
3146
3130
|
const available = useScopeAvailable4();
|
|
3147
3131
|
const variable = value?.type === "ref" ? available.getByKeyPath(value?.content) : void 0;
|
|
3148
|
-
const schema =
|
|
3132
|
+
const schema = useMemo10(() => {
|
|
3149
3133
|
if (value?.type === "ref") {
|
|
3150
3134
|
return JsonSchemaUtils6.astToSchema(variable?.type);
|
|
3151
3135
|
}
|
|
@@ -3168,7 +3152,7 @@ function DisplayFlowValue({ value, title, showIconInTree }) {
|
|
|
3168
3152
|
}
|
|
3169
3153
|
return { type: "unknown" };
|
|
3170
3154
|
}, [value, variable?.hash]);
|
|
3171
|
-
return /* @__PURE__ */
|
|
3155
|
+
return /* @__PURE__ */ React39.createElement(
|
|
3172
3156
|
DisplaySchemaTag,
|
|
3173
3157
|
{
|
|
3174
3158
|
title,
|
|
@@ -3180,7 +3164,7 @@ function DisplayFlowValue({ value, title, showIconInTree }) {
|
|
|
3180
3164
|
}
|
|
3181
3165
|
|
|
3182
3166
|
// src/components/display-inputs-values/index.tsx
|
|
3183
|
-
import
|
|
3167
|
+
import React40 from "react";
|
|
3184
3168
|
|
|
3185
3169
|
// src/components/display-inputs-values/styles.ts
|
|
3186
3170
|
import styled14 from "styled-components";
|
|
@@ -3193,29 +3177,29 @@ var DisplayInputsWrapper = styled14.div`
|
|
|
3193
3177
|
// src/components/display-inputs-values/index.tsx
|
|
3194
3178
|
function DisplayInputsValues({ value, showIconInTree }) {
|
|
3195
3179
|
const childEntries = Object.entries(value || {});
|
|
3196
|
-
return /* @__PURE__ */
|
|
3180
|
+
return /* @__PURE__ */ React40.createElement(DisplayInputsWrapper, null, childEntries.map(([key, value2]) => /* @__PURE__ */ React40.createElement(DisplayFlowValue, { key, title: key, value: value2, showIconInTree })));
|
|
3197
3181
|
}
|
|
3198
3182
|
|
|
3199
3183
|
// src/components/assign-rows/index.tsx
|
|
3200
|
-
import
|
|
3184
|
+
import React43 from "react";
|
|
3201
3185
|
import { FieldArray } from "@flowgram.ai/editor";
|
|
3202
3186
|
import { Button as Button5 } from "@douyinfe/semi-ui";
|
|
3203
3187
|
import { IconPlus as IconPlus4 } from "@douyinfe/semi-icons";
|
|
3204
3188
|
|
|
3205
3189
|
// src/components/assign-row/index.tsx
|
|
3206
|
-
import
|
|
3207
|
-
import { IconButton as
|
|
3190
|
+
import React42 from "react";
|
|
3191
|
+
import { IconButton as IconButton5 } from "@douyinfe/semi-ui";
|
|
3208
3192
|
import { IconMinus as IconMinus2 } from "@douyinfe/semi-icons";
|
|
3209
3193
|
|
|
3210
3194
|
// src/components/assign-row/components/blur-input.tsx
|
|
3211
|
-
import
|
|
3195
|
+
import React41, { useEffect as useEffect11, useState as useState10 } from "react";
|
|
3212
3196
|
import Input7 from "@douyinfe/semi-ui/lib/es/input";
|
|
3213
3197
|
function BlurInput3(props) {
|
|
3214
|
-
const [value, setValue] =
|
|
3198
|
+
const [value, setValue] = useState10("");
|
|
3215
3199
|
useEffect11(() => {
|
|
3216
3200
|
setValue(props.value);
|
|
3217
3201
|
}, [props.value]);
|
|
3218
|
-
return /* @__PURE__ */
|
|
3202
|
+
return /* @__PURE__ */ React41.createElement(
|
|
3219
3203
|
Input7,
|
|
3220
3204
|
{
|
|
3221
3205
|
...props,
|
|
@@ -3238,8 +3222,8 @@ function AssignRow(props) {
|
|
|
3238
3222
|
onDelete,
|
|
3239
3223
|
readonly
|
|
3240
3224
|
} = props;
|
|
3241
|
-
return /* @__PURE__ */
|
|
3242
|
-
|
|
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,
|
|
3243
3227
|
{
|
|
3244
3228
|
style: { width: "100%", height: 26 },
|
|
3245
3229
|
value: value?.left?.content,
|
|
@@ -3249,7 +3233,7 @@ function AssignRow(props) {
|
|
|
3249
3233
|
left: { type: "ref", content: v }
|
|
3250
3234
|
})
|
|
3251
3235
|
}
|
|
3252
|
-
) : /* @__PURE__ */
|
|
3236
|
+
) : /* @__PURE__ */ React42.createElement(
|
|
3253
3237
|
BlurInput3,
|
|
3254
3238
|
{
|
|
3255
3239
|
style: { height: 26 },
|
|
@@ -3261,8 +3245,8 @@ function AssignRow(props) {
|
|
|
3261
3245
|
left: v
|
|
3262
3246
|
})
|
|
3263
3247
|
}
|
|
3264
|
-
)), /* @__PURE__ */
|
|
3265
|
-
|
|
3248
|
+
)), /* @__PURE__ */ React42.createElement("div", { style: { flexGrow: 1 } }, /* @__PURE__ */ React42.createElement(
|
|
3249
|
+
InjectDynamicValueInput,
|
|
3266
3250
|
{
|
|
3267
3251
|
readonly,
|
|
3268
3252
|
value: value?.right,
|
|
@@ -3271,12 +3255,12 @@ function AssignRow(props) {
|
|
|
3271
3255
|
right: v
|
|
3272
3256
|
})
|
|
3273
3257
|
}
|
|
3274
|
-
)), onDelete && /* @__PURE__ */
|
|
3275
|
-
|
|
3258
|
+
)), onDelete && /* @__PURE__ */ React42.createElement("div", null, /* @__PURE__ */ React42.createElement(
|
|
3259
|
+
IconButton5,
|
|
3276
3260
|
{
|
|
3277
3261
|
size: "small",
|
|
3278
3262
|
theme: "borderless",
|
|
3279
|
-
icon: /* @__PURE__ */
|
|
3263
|
+
icon: /* @__PURE__ */ React42.createElement(IconMinus2, null),
|
|
3280
3264
|
onClick: () => onDelete?.()
|
|
3281
3265
|
}
|
|
3282
3266
|
)));
|
|
@@ -3285,7 +3269,7 @@ function AssignRow(props) {
|
|
|
3285
3269
|
// src/components/assign-rows/index.tsx
|
|
3286
3270
|
function AssignRows(props) {
|
|
3287
3271
|
const { name, readonly } = props;
|
|
3288
|
-
return /* @__PURE__ */
|
|
3272
|
+
return /* @__PURE__ */ React43.createElement(FieldArray, { name }, ({ field }) => /* @__PURE__ */ React43.createElement(React43.Fragment, null, field.map((childField, index) => /* @__PURE__ */ React43.createElement(
|
|
3289
3273
|
AssignRow,
|
|
3290
3274
|
{
|
|
3291
3275
|
key: childField.key,
|
|
@@ -3296,21 +3280,21 @@ function AssignRows(props) {
|
|
|
3296
3280
|
},
|
|
3297
3281
|
onDelete: () => field.remove(index)
|
|
3298
3282
|
}
|
|
3299
|
-
)), /* @__PURE__ */
|
|
3283
|
+
)), /* @__PURE__ */ React43.createElement("div", { style: { display: "flex", gap: 5 } }, /* @__PURE__ */ React43.createElement(
|
|
3300
3284
|
Button5,
|
|
3301
3285
|
{
|
|
3302
3286
|
size: "small",
|
|
3303
3287
|
theme: "borderless",
|
|
3304
|
-
icon: /* @__PURE__ */
|
|
3288
|
+
icon: /* @__PURE__ */ React43.createElement(IconPlus4, null),
|
|
3305
3289
|
onClick: () => field.append({ operator: "assign" })
|
|
3306
3290
|
},
|
|
3307
3291
|
"Assign"
|
|
3308
|
-
), /* @__PURE__ */
|
|
3292
|
+
), /* @__PURE__ */ React43.createElement(
|
|
3309
3293
|
Button5,
|
|
3310
3294
|
{
|
|
3311
3295
|
size: "small",
|
|
3312
3296
|
theme: "borderless",
|
|
3313
|
-
icon: /* @__PURE__ */
|
|
3297
|
+
icon: /* @__PURE__ */ React43.createElement(IconPlus4, null),
|
|
3314
3298
|
onClick: () => field.append({ operator: "declare" })
|
|
3315
3299
|
},
|
|
3316
3300
|
"Declaration"
|
|
@@ -3353,7 +3337,7 @@ var provideBatchInputEffect = createEffectFromVariableProvider({
|
|
|
3353
3337
|
});
|
|
3354
3338
|
|
|
3355
3339
|
// src/effects/auto-rename-ref/index.ts
|
|
3356
|
-
import { isArray, isObject as
|
|
3340
|
+
import { isArray, isObject as isObject3, uniq } from "lodash";
|
|
3357
3341
|
import {
|
|
3358
3342
|
DataEvent,
|
|
3359
3343
|
VariableFieldKeyRenameService
|
|
@@ -3423,7 +3407,7 @@ function isTemplate(value) {
|
|
|
3423
3407
|
return value?.type === "template" && typeof value?.content === "string";
|
|
3424
3408
|
}
|
|
3425
3409
|
function traverseRef(name, value, cb) {
|
|
3426
|
-
if (
|
|
3410
|
+
if (isObject3(value)) {
|
|
3427
3411
|
if (isRef(value)) {
|
|
3428
3412
|
cb(name, value);
|
|
3429
3413
|
return;
|
|
@@ -3568,68 +3552,6 @@ var listenRefSchemaChange = (cb) => [
|
|
|
3568
3552
|
}
|
|
3569
3553
|
];
|
|
3570
3554
|
|
|
3571
|
-
// src/shared/format-legacy-refs/index.ts
|
|
3572
|
-
import { isObject as isObject3 } from "lodash";
|
|
3573
|
-
function formatLegacyRefOnSubmit(value) {
|
|
3574
|
-
if (isObject3(value)) {
|
|
3575
|
-
if (isLegacyFlowRefValueSchema(value)) {
|
|
3576
|
-
return formatLegacyRefToNewRef(value);
|
|
3577
|
-
}
|
|
3578
|
-
return Object.fromEntries(
|
|
3579
|
-
Object.entries(value).map(([key, value2]) => [
|
|
3580
|
-
key,
|
|
3581
|
-
formatLegacyRefOnSubmit(value2)
|
|
3582
|
-
])
|
|
3583
|
-
);
|
|
3584
|
-
}
|
|
3585
|
-
if (Array.isArray(value)) {
|
|
3586
|
-
return value.map(formatLegacyRefOnSubmit);
|
|
3587
|
-
}
|
|
3588
|
-
return value;
|
|
3589
|
-
}
|
|
3590
|
-
function formatLegacyRefOnInit(value) {
|
|
3591
|
-
if (isObject3(value)) {
|
|
3592
|
-
if (isNewFlowRefValueSchema(value)) {
|
|
3593
|
-
return formatNewRefToLegacyRef(value);
|
|
3594
|
-
}
|
|
3595
|
-
return Object.fromEntries(
|
|
3596
|
-
Object.entries(value).map(([key, value2]) => [
|
|
3597
|
-
key,
|
|
3598
|
-
formatLegacyRefOnInit(value2)
|
|
3599
|
-
])
|
|
3600
|
-
);
|
|
3601
|
-
}
|
|
3602
|
-
if (Array.isArray(value)) {
|
|
3603
|
-
return value.map(formatLegacyRefOnInit);
|
|
3604
|
-
}
|
|
3605
|
-
return value;
|
|
3606
|
-
}
|
|
3607
|
-
function isLegacyFlowRefValueSchema(value) {
|
|
3608
|
-
return isObject3(value) && Object.keys(value).length === 2 && value.type === "ref" && typeof value.content === "string";
|
|
3609
|
-
}
|
|
3610
|
-
function isNewFlowRefValueSchema(value) {
|
|
3611
|
-
return isObject3(value) && Object.keys(value).length === 2 && value.type === "ref" && Array.isArray(value.content);
|
|
3612
|
-
}
|
|
3613
|
-
function formatLegacyRefToNewRef(value) {
|
|
3614
|
-
const keyPath = value.content.split(".");
|
|
3615
|
-
if (keyPath[1] === "outputs") {
|
|
3616
|
-
return {
|
|
3617
|
-
type: "ref",
|
|
3618
|
-
content: [`${keyPath[0]}.${keyPath[1]}`, ...keyPath.length > 2 ? keyPath.slice(2) : []]
|
|
3619
|
-
};
|
|
3620
|
-
}
|
|
3621
|
-
return {
|
|
3622
|
-
type: "ref",
|
|
3623
|
-
content: keyPath
|
|
3624
|
-
};
|
|
3625
|
-
}
|
|
3626
|
-
function formatNewRefToLegacyRef(value) {
|
|
3627
|
-
return {
|
|
3628
|
-
type: "ref",
|
|
3629
|
-
content: value.content.join(".")
|
|
3630
|
-
};
|
|
3631
|
-
}
|
|
3632
|
-
|
|
3633
3555
|
// src/form-plugins/batch-outputs-plugin/index.ts
|
|
3634
3556
|
import {
|
|
3635
3557
|
ASTFactory as ASTFactory3,
|
|
@@ -3900,6 +3822,9 @@ export {
|
|
|
3900
3822
|
DisplaySchemaTag,
|
|
3901
3823
|
DisplaySchemaTree,
|
|
3902
3824
|
DynamicValueInput,
|
|
3825
|
+
InjectDynamicValueInput,
|
|
3826
|
+
InjectTypeSelector,
|
|
3827
|
+
InjectVariableSelector,
|
|
3903
3828
|
InputsValues,
|
|
3904
3829
|
JsonEditorWithVariables,
|
|
3905
3830
|
JsonSchemaEditor,
|
|
@@ -3915,6 +3840,7 @@ export {
|
|
|
3915
3840
|
createDisableDeclarationPlugin,
|
|
3916
3841
|
createInferAssignPlugin,
|
|
3917
3842
|
createInferInputsPlugin,
|
|
3843
|
+
createInjectMaterial,
|
|
3918
3844
|
createTypePresetPlugin,
|
|
3919
3845
|
formatLegacyRefOnInit,
|
|
3920
3846
|
formatLegacyRefOnSubmit,
|