@flowgram.ai/form-materials 0.3.4 → 0.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/index.ts +5 -19
- package/bin/materials.ts +31 -89
- package/bin/project.ts +4 -0
- package/bin/utils/import.ts +127 -0
- package/bin/utils/traverse-file.ts +60 -0
- package/dist/esm/index.js +383 -488
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.mts +64 -6
- package/dist/index.d.ts +64 -6
- package/dist/index.js +625 -730
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
- package/src/components/assign-row/index.tsx +4 -4
- package/src/components/assign-rows/index.tsx +1 -1
- package/src/components/batch-outputs/index.tsx +4 -3
- package/src/components/batch-outputs/types.ts +1 -1
- package/src/components/batch-variable-selector/index.tsx +1 -1
- package/src/components/code-editor-mini/index.tsx +1 -1
- package/src/components/condition-row/hooks/useRule.ts +2 -1
- package/src/components/condition-row/index.tsx +5 -4
- package/src/components/condition-row/types.ts +1 -1
- package/src/components/constant-input/index.tsx +5 -2
- package/src/components/constant-input/types.ts +1 -1
- package/src/components/display-flow-value/index.tsx +2 -2
- package/src/components/display-inputs-values/index.tsx +3 -2
- package/src/components/display-outputs/index.tsx +2 -1
- package/src/components/display-schema-tag/index.tsx +3 -2
- package/src/components/display-schema-tree/index.tsx +2 -1
- package/src/components/dynamic-value-input/hooks.ts +1 -1
- package/src/components/dynamic-value-input/index.tsx +13 -9
- package/src/components/inputs-values/index.tsx +7 -5
- package/src/components/inputs-values/types.ts +3 -3
- package/src/components/json-editor-with-variables/extensions/variable-tree.tsx +1 -1
- package/src/components/json-editor-with-variables/index.tsx +2 -1
- package/src/components/json-schema-editor/default-value.tsx +11 -105
- package/src/components/json-schema-editor/hooks.tsx +53 -94
- package/src/components/json-schema-editor/index.tsx +11 -8
- package/src/components/json-schema-editor/styles.tsx +0 -29
- package/src/components/prompt-editor/types.tsx +1 -1
- package/src/components/prompt-editor-with-inputs/extensions/inputs-tree.tsx +2 -1
- package/src/components/prompt-editor-with-inputs/index.tsx +3 -2
- package/src/components/prompt-editor-with-inputs/inputs-picker.tsx +1 -1
- package/src/components/prompt-editor-with-variables/extensions/variable-tree.tsx +1 -1
- package/src/components/prompt-editor-with-variables/index.tsx +2 -1
- package/src/components/type-selector/index.tsx +7 -3
- package/src/components/variable-selector/index.tsx +7 -4
- package/src/components/variable-selector/use-variable-tree.tsx +1 -1
- package/src/effects/auto-rename-ref/index.ts +1 -1
- package/src/effects/listen-ref-schema-change/index.ts +1 -1
- package/src/effects/listen-ref-value-change/index.ts +1 -1
- package/src/effects/provide-batch-input/index.ts +1 -1
- package/src/form-plugins/batch-outputs-plugin/index.ts +1 -1
- package/src/form-plugins/infer-assign-plugin/index.ts +1 -1
- package/src/form-plugins/infer-inputs-plugin/index.ts +1 -1
- package/src/shared/index.ts +1 -0
- package/src/shared/inject-material/README.md +170 -0
- package/src/shared/inject-material/README.zh.md +174 -0
- package/src/shared/inject-material/index.tsx +87 -0
- package/src/components/assign-row/config.json +0 -11
- package/src/components/assign-rows/config.json +0 -11
- package/src/components/batch-outputs/config.json +0 -13
- package/src/components/batch-variable-selector/config.json +0 -9
- package/src/components/code-editor/config.json +0 -10
- package/src/components/code-editor-mini/config.json +0 -7
- package/src/components/condition-row/config.json +0 -13
- package/src/components/constant-input/config.json +0 -9
- package/src/components/display-flow-value/config.json +0 -8
- package/src/components/display-inputs-values/config.json +0 -9
- package/src/components/display-outputs/config.json +0 -10
- package/src/components/display-schema-tag/config.json +0 -10
- package/src/components/display-schema-tree/config.json +0 -11
- package/src/components/dynamic-value-input/config.json +0 -14
- package/src/components/inputs-values/config.json +0 -13
- package/src/components/json-editor-with-variables/config.json +0 -13
- package/src/components/json-schema-editor/config.json +0 -13
- package/src/components/json-schema-editor/utils.ts +0 -29
- package/src/components/prompt-editor/config.json +0 -9
- package/src/components/prompt-editor-with-inputs/config.json +0 -13
- package/src/components/prompt-editor-with-variables/config.json +0 -13
- package/src/components/type-selector/config.json +0 -9
- package/src/components/variable-selector/config.json +0 -9
- package/src/effects/auto-rename-ref/config.json +0 -5
- package/src/effects/listen-ref-schema-change/config.json +0 -10
- package/src/effects/listen-ref-value-change/config.json +0 -9
- package/src/effects/provide-batch-input/config.json +0 -5
- package/src/effects/provide-json-schema-outputs/config.json +0 -7
- package/src/effects/sync-variable-title/config.json +0 -5
- package/src/effects/validate-when-variable-sync/config.json +0 -5
- package/src/form-plugins/batch-outputs-plugin/config.json +0 -7
- package/src/form-plugins/infer-assign-plugin/config.json +0 -7
- package/src/form-plugins/infer-inputs-plugin/config.json +0 -9
- package/src/hooks/use-object-list/config.json +0 -8
- package/src/shared/format-legacy-refs/config.json +0 -5
- package/src/typings/flow-value/config.json +0 -7
- package/src/validate/validate-flow-value/config.json +0 -7
package/dist/index.js
CHANGED
|
@@ -44,6 +44,9 @@ __export(src_exports, {
|
|
|
44
44
|
DisplaySchemaTag: () => DisplaySchemaTag,
|
|
45
45
|
DisplaySchemaTree: () => DisplaySchemaTree,
|
|
46
46
|
DynamicValueInput: () => DynamicValueInput,
|
|
47
|
+
InjectDynamicValueInput: () => InjectDynamicValueInput,
|
|
48
|
+
InjectTypeSelector: () => InjectTypeSelector,
|
|
49
|
+
InjectVariableSelector: () => InjectVariableSelector,
|
|
47
50
|
InputsValues: () => InputsValues,
|
|
48
51
|
JsonEditorWithVariables: () => JsonEditorWithVariables,
|
|
49
52
|
JsonSchemaEditor: () => JsonSchemaEditor,
|
|
@@ -59,6 +62,7 @@ __export(src_exports, {
|
|
|
59
62
|
createDisableDeclarationPlugin: () => createDisableDeclarationPlugin,
|
|
60
63
|
createInferAssignPlugin: () => createInferAssignPlugin,
|
|
61
64
|
createInferInputsPlugin: () => createInferInputsPlugin,
|
|
65
|
+
createInjectMaterial: () => createInjectMaterial,
|
|
62
66
|
createTypePresetPlugin: () => createTypePresetPlugin,
|
|
63
67
|
formatLegacyRefOnInit: () => formatLegacyRefOnInit,
|
|
64
68
|
formatLegacyRefOnSubmit: () => formatLegacyRefOnSubmit,
|
|
@@ -86,34 +90,118 @@ var getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${_
|
|
|
86
90
|
var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
|
|
87
91
|
|
|
88
92
|
// src/components/variable-selector/index.tsx
|
|
89
|
-
var
|
|
90
|
-
var
|
|
93
|
+
var import_react13 = __toESM(require("react"));
|
|
94
|
+
var import_editor12 = require("@flowgram.ai/editor");
|
|
91
95
|
var import_semi_ui7 = require("@douyinfe/semi-ui");
|
|
92
96
|
var import_semi_icons = require("@douyinfe/semi-icons");
|
|
93
97
|
|
|
98
|
+
// src/shared/format-legacy-refs/index.ts
|
|
99
|
+
var import_lodash = require("lodash");
|
|
100
|
+
function formatLegacyRefOnSubmit(value) {
|
|
101
|
+
if ((0, import_lodash.isObject)(value)) {
|
|
102
|
+
if (isLegacyFlowRefValueSchema(value)) {
|
|
103
|
+
return formatLegacyRefToNewRef(value);
|
|
104
|
+
}
|
|
105
|
+
return Object.fromEntries(
|
|
106
|
+
Object.entries(value).map(([key, value2]) => [
|
|
107
|
+
key,
|
|
108
|
+
formatLegacyRefOnSubmit(value2)
|
|
109
|
+
])
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
if (Array.isArray(value)) {
|
|
113
|
+
return value.map(formatLegacyRefOnSubmit);
|
|
114
|
+
}
|
|
115
|
+
return value;
|
|
116
|
+
}
|
|
117
|
+
function formatLegacyRefOnInit(value) {
|
|
118
|
+
if ((0, import_lodash.isObject)(value)) {
|
|
119
|
+
if (isNewFlowRefValueSchema(value)) {
|
|
120
|
+
return formatNewRefToLegacyRef(value);
|
|
121
|
+
}
|
|
122
|
+
return Object.fromEntries(
|
|
123
|
+
Object.entries(value).map(([key, value2]) => [
|
|
124
|
+
key,
|
|
125
|
+
formatLegacyRefOnInit(value2)
|
|
126
|
+
])
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
if (Array.isArray(value)) {
|
|
130
|
+
return value.map(formatLegacyRefOnInit);
|
|
131
|
+
}
|
|
132
|
+
return value;
|
|
133
|
+
}
|
|
134
|
+
function isLegacyFlowRefValueSchema(value) {
|
|
135
|
+
return (0, import_lodash.isObject)(value) && Object.keys(value).length === 2 && value.type === "ref" && typeof value.content === "string";
|
|
136
|
+
}
|
|
137
|
+
function isNewFlowRefValueSchema(value) {
|
|
138
|
+
return (0, import_lodash.isObject)(value) && Object.keys(value).length === 2 && value.type === "ref" && Array.isArray(value.content);
|
|
139
|
+
}
|
|
140
|
+
function formatLegacyRefToNewRef(value) {
|
|
141
|
+
const keyPath = value.content.split(".");
|
|
142
|
+
if (keyPath[1] === "outputs") {
|
|
143
|
+
return {
|
|
144
|
+
type: "ref",
|
|
145
|
+
content: [`${keyPath[0]}.${keyPath[1]}`, ...keyPath.length > 2 ? keyPath.slice(2) : []]
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
return {
|
|
149
|
+
type: "ref",
|
|
150
|
+
content: keyPath
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
function formatNewRefToLegacyRef(value) {
|
|
154
|
+
return {
|
|
155
|
+
type: "ref",
|
|
156
|
+
content: value.content.join(".")
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// src/shared/inject-material/index.tsx
|
|
161
|
+
var import_react = __toESM(require("react"));
|
|
162
|
+
var import_editor = require("@flowgram.ai/editor");
|
|
163
|
+
function createInjectMaterial(Component, params) {
|
|
164
|
+
const InjectComponent = (props) => {
|
|
165
|
+
const container = (0, import_editor.usePlaygroundContainer)();
|
|
166
|
+
if (!container?.isBound(import_editor.FlowRendererRegistry)) {
|
|
167
|
+
return import_react.default.createElement(Component, { ...props });
|
|
168
|
+
}
|
|
169
|
+
const rendererRegistry = container.get(import_editor.FlowRendererRegistry);
|
|
170
|
+
const renderKey = params?.renderKey || Component.renderKey || Component.name || "";
|
|
171
|
+
const renderer = rendererRegistry.tryToGetRendererComponent(renderKey);
|
|
172
|
+
if (renderer?.type !== import_editor.FlowRendererComponentType.REACT) {
|
|
173
|
+
return import_react.default.createElement(Component, { ...props });
|
|
174
|
+
}
|
|
175
|
+
return import_react.default.createElement(renderer.renderer, {
|
|
176
|
+
...props
|
|
177
|
+
});
|
|
178
|
+
};
|
|
179
|
+
return InjectComponent;
|
|
180
|
+
}
|
|
181
|
+
|
|
94
182
|
// src/components/variable-selector/use-variable-tree.tsx
|
|
95
|
-
var
|
|
183
|
+
var import_react12 = __toESM(require("react"));
|
|
96
184
|
var import_json_schema4 = require("@flowgram.ai/json-schema");
|
|
97
|
-
var
|
|
185
|
+
var import_editor11 = require("@flowgram.ai/editor");
|
|
98
186
|
var import_semi_ui5 = require("@douyinfe/semi-ui");
|
|
99
187
|
|
|
100
188
|
// src/plugins/json-schema-preset/index.tsx
|
|
101
|
-
var
|
|
189
|
+
var import_react11 = __toESM(require("react"));
|
|
102
190
|
var import_json_schema3 = require("@flowgram.ai/json-schema");
|
|
103
191
|
|
|
104
192
|
// src/plugins/json-schema-preset/type-definition/index.tsx
|
|
105
193
|
var import_json_schema = require("@flowgram.ai/json-schema");
|
|
106
194
|
|
|
107
195
|
// src/plugins/json-schema-preset/type-definition/string.tsx
|
|
108
|
-
var
|
|
109
|
-
var
|
|
196
|
+
var import_react2 = __toESM(require("react"));
|
|
197
|
+
var import_editor2 = require("@flowgram.ai/editor");
|
|
110
198
|
var import_semi_ui = require("@douyinfe/semi-ui");
|
|
111
199
|
var stringRegistry = {
|
|
112
200
|
type: "string",
|
|
113
|
-
ConstantRenderer: (props) => /* @__PURE__ */
|
|
201
|
+
ConstantRenderer: (props) => /* @__PURE__ */ import_react2.default.createElement(
|
|
114
202
|
import_semi_ui.Input,
|
|
115
203
|
{
|
|
116
|
-
placeholder:
|
|
204
|
+
placeholder: import_editor2.I18n.t("Please Input String"),
|
|
117
205
|
size: "small",
|
|
118
206
|
disabled: props.readonly,
|
|
119
207
|
...props
|
|
@@ -122,16 +210,16 @@ var stringRegistry = {
|
|
|
122
210
|
};
|
|
123
211
|
|
|
124
212
|
// src/plugins/json-schema-preset/type-definition/object.tsx
|
|
125
|
-
var
|
|
126
|
-
var
|
|
213
|
+
var import_react6 = __toESM(require("react"));
|
|
214
|
+
var import_editor4 = require("@flowgram.ai/editor");
|
|
127
215
|
|
|
128
216
|
// src/components/code-editor-mini/index.tsx
|
|
129
|
-
var
|
|
217
|
+
var import_react5 = __toESM(require("react"));
|
|
130
218
|
var import_styled_components = __toESM(require("styled-components"));
|
|
131
219
|
|
|
132
220
|
// src/components/code-editor/index.tsx
|
|
133
|
-
var
|
|
134
|
-
var
|
|
221
|
+
var import_react3 = __toESM(require("react"));
|
|
222
|
+
var import_react4 = require("@coze-editor/editor/react");
|
|
135
223
|
var import_preset_code5 = __toESM(require("@coze-editor/editor/preset-code"));
|
|
136
224
|
var import_view = require("@codemirror/view");
|
|
137
225
|
|
|
@@ -158,13 +246,13 @@ var import_language_typescript = require("@coze-editor/editor/language-typescrip
|
|
|
158
246
|
var import_language_shell = require("@coze-editor/editor/language-shell");
|
|
159
247
|
var import_language_python = require("@coze-editor/editor/language-python");
|
|
160
248
|
var import_language_json = require("@coze-editor/editor/language-json");
|
|
161
|
-
var
|
|
249
|
+
var import_editor3 = require("@coze-editor/editor");
|
|
162
250
|
import_preset_code.languages.register("python", import_language_python.python);
|
|
163
251
|
import_preset_code.languages.register("shell", import_language_shell.shell);
|
|
164
252
|
import_preset_code.languages.register("typescript", import_language_typescript.typescript);
|
|
165
253
|
import_preset_code.languages.register("json", {
|
|
166
254
|
// mixLanguages is used to solve the problem that interpolation also uses parentheses, which causes incorrect highlighting
|
|
167
|
-
language: (0,
|
|
255
|
+
language: (0, import_editor3.mixLanguages)({
|
|
168
256
|
outerLanguage: import_language_json.json.language
|
|
169
257
|
}),
|
|
170
258
|
languageService: import_language_json.json.languageService
|
|
@@ -418,7 +506,7 @@ import_preset_code4.themes.register("dark", darkTheme);
|
|
|
418
506
|
import_preset_code4.themes.register("light", lightTheme);
|
|
419
507
|
|
|
420
508
|
// src/components/code-editor/index.tsx
|
|
421
|
-
var OriginCodeEditor = (0,
|
|
509
|
+
var OriginCodeEditor = (0, import_react4.createRenderer)(import_preset_code5.default, [
|
|
422
510
|
import_view.EditorView.theme({
|
|
423
511
|
"&.cm-focused": {
|
|
424
512
|
outline: "none"
|
|
@@ -436,18 +524,18 @@ function CodeEditor({
|
|
|
436
524
|
options,
|
|
437
525
|
readonly
|
|
438
526
|
}) {
|
|
439
|
-
const editorRef = (0,
|
|
440
|
-
(0,
|
|
527
|
+
const editorRef = (0, import_react3.useRef)(null);
|
|
528
|
+
(0, import_react3.useEffect)(() => {
|
|
441
529
|
if (languageId === "typescript") {
|
|
442
530
|
initTsWorker();
|
|
443
531
|
}
|
|
444
532
|
}, [languageId]);
|
|
445
|
-
(0,
|
|
533
|
+
(0, import_react3.useEffect)(() => {
|
|
446
534
|
if (editorRef.current?.getValue() !== value) {
|
|
447
535
|
editorRef.current?.setValue(String(value || ""));
|
|
448
536
|
}
|
|
449
537
|
}, [value]);
|
|
450
|
-
return /* @__PURE__ */
|
|
538
|
+
return /* @__PURE__ */ import_react3.default.createElement(import_react4.EditorProvider, null, /* @__PURE__ */ import_react3.default.createElement(
|
|
451
539
|
OriginCodeEditor,
|
|
452
540
|
{
|
|
453
541
|
defaultValue: value,
|
|
@@ -465,7 +553,7 @@ function CodeEditor({
|
|
|
465
553
|
},
|
|
466
554
|
onChange: (e) => onChange?.(e.value)
|
|
467
555
|
},
|
|
468
|
-
activeLinePlaceholder && /* @__PURE__ */
|
|
556
|
+
activeLinePlaceholder && /* @__PURE__ */ import_react3.default.createElement(import_react4.ActiveLinePlaceholder, null, activeLinePlaceholder),
|
|
469
557
|
children
|
|
470
558
|
));
|
|
471
559
|
}
|
|
@@ -477,7 +565,7 @@ var UIMini = import_styled_components.default.div`
|
|
|
477
565
|
}
|
|
478
566
|
`;
|
|
479
567
|
function CodeEditorMini(props) {
|
|
480
|
-
return /* @__PURE__ */
|
|
568
|
+
return /* @__PURE__ */ import_react5.default.createElement(UIMini, null, /* @__PURE__ */ import_react5.default.createElement(
|
|
481
569
|
CodeEditor,
|
|
482
570
|
{
|
|
483
571
|
...props,
|
|
@@ -493,28 +581,28 @@ function CodeEditorMini(props) {
|
|
|
493
581
|
// src/plugins/json-schema-preset/type-definition/object.tsx
|
|
494
582
|
var objectRegistry = {
|
|
495
583
|
type: "object",
|
|
496
|
-
ConstantRenderer: (props) => /* @__PURE__ */
|
|
584
|
+
ConstantRenderer: (props) => /* @__PURE__ */ import_react6.default.createElement(
|
|
497
585
|
CodeEditorMini,
|
|
498
586
|
{
|
|
499
587
|
value: props.value,
|
|
500
588
|
onChange: (v) => props.onChange?.(v),
|
|
501
589
|
languageId: "json",
|
|
502
|
-
placeholder:
|
|
590
|
+
placeholder: import_editor4.I18n.t("Please Input Object"),
|
|
503
591
|
readonly: props.readonly
|
|
504
592
|
}
|
|
505
593
|
)
|
|
506
594
|
};
|
|
507
595
|
|
|
508
596
|
// src/plugins/json-schema-preset/type-definition/number.tsx
|
|
509
|
-
var
|
|
510
|
-
var
|
|
597
|
+
var import_react7 = __toESM(require("react"));
|
|
598
|
+
var import_editor5 = require("@flowgram.ai/editor");
|
|
511
599
|
var import_semi_ui2 = require("@douyinfe/semi-ui");
|
|
512
600
|
var numberRegistry = {
|
|
513
601
|
type: "number",
|
|
514
|
-
ConstantRenderer: (props) => /* @__PURE__ */
|
|
602
|
+
ConstantRenderer: (props) => /* @__PURE__ */ import_react7.default.createElement(
|
|
515
603
|
import_semi_ui2.InputNumber,
|
|
516
604
|
{
|
|
517
|
-
placeholder:
|
|
605
|
+
placeholder: import_editor5.I18n.t("Please Input Number"),
|
|
518
606
|
size: "small",
|
|
519
607
|
disabled: props.readonly,
|
|
520
608
|
hideButtons: true,
|
|
@@ -524,15 +612,15 @@ var numberRegistry = {
|
|
|
524
612
|
};
|
|
525
613
|
|
|
526
614
|
// src/plugins/json-schema-preset/type-definition/integer.tsx
|
|
527
|
-
var
|
|
528
|
-
var
|
|
615
|
+
var import_react8 = __toESM(require("react"));
|
|
616
|
+
var import_editor6 = require("@flowgram.ai/editor");
|
|
529
617
|
var import_semi_ui3 = require("@douyinfe/semi-ui");
|
|
530
618
|
var integerRegistry = {
|
|
531
619
|
type: "integer",
|
|
532
|
-
ConstantRenderer: (props) => /* @__PURE__ */
|
|
620
|
+
ConstantRenderer: (props) => /* @__PURE__ */ import_react8.default.createElement(
|
|
533
621
|
import_semi_ui3.InputNumber,
|
|
534
622
|
{
|
|
535
|
-
placeholder:
|
|
623
|
+
placeholder: import_editor6.I18n.t("Please Input Integer"),
|
|
536
624
|
size: "small",
|
|
537
625
|
disabled: props.readonly,
|
|
538
626
|
precision: 0,
|
|
@@ -542,22 +630,22 @@ var integerRegistry = {
|
|
|
542
630
|
};
|
|
543
631
|
|
|
544
632
|
// src/plugins/json-schema-preset/type-definition/boolean.tsx
|
|
545
|
-
var
|
|
546
|
-
var
|
|
633
|
+
var import_react9 = __toESM(require("react"));
|
|
634
|
+
var import_editor7 = require("@flowgram.ai/editor");
|
|
547
635
|
var import_semi_ui4 = require("@douyinfe/semi-ui");
|
|
548
636
|
var booleanRegistry = {
|
|
549
637
|
type: "boolean",
|
|
550
638
|
ConstantRenderer: (props) => {
|
|
551
639
|
const { value, onChange, ...rest } = props;
|
|
552
|
-
return /* @__PURE__ */
|
|
640
|
+
return /* @__PURE__ */ import_react9.default.createElement(
|
|
553
641
|
import_semi_ui4.Select,
|
|
554
642
|
{
|
|
555
|
-
placeholder:
|
|
643
|
+
placeholder: import_editor7.I18n.t("Please Select Boolean"),
|
|
556
644
|
size: "small",
|
|
557
645
|
disabled: props.readonly,
|
|
558
646
|
optionList: [
|
|
559
|
-
{ label:
|
|
560
|
-
{ label:
|
|
647
|
+
{ label: import_editor7.I18n.t("True"), value: 1 },
|
|
648
|
+
{ label: import_editor7.I18n.t("False"), value: 0 }
|
|
561
649
|
],
|
|
562
650
|
value: value ? 1 : 0,
|
|
563
651
|
onChange: (value2) => onChange?.(!!value2),
|
|
@@ -568,17 +656,17 @@ var booleanRegistry = {
|
|
|
568
656
|
};
|
|
569
657
|
|
|
570
658
|
// src/plugins/json-schema-preset/type-definition/array.tsx
|
|
571
|
-
var
|
|
572
|
-
var
|
|
659
|
+
var import_react10 = __toESM(require("react"));
|
|
660
|
+
var import_editor8 = require("@flowgram.ai/editor");
|
|
573
661
|
var arrayRegistry = {
|
|
574
662
|
type: "array",
|
|
575
|
-
ConstantRenderer: (props) => /* @__PURE__ */
|
|
663
|
+
ConstantRenderer: (props) => /* @__PURE__ */ import_react10.default.createElement(
|
|
576
664
|
CodeEditorMini,
|
|
577
665
|
{
|
|
578
666
|
value: props.value,
|
|
579
667
|
languageId: "json",
|
|
580
668
|
onChange: (v) => props.onChange?.(v),
|
|
581
|
-
placeholder:
|
|
669
|
+
placeholder: import_editor8.I18n.t("Please Input Array"),
|
|
582
670
|
readonly: props.readonly
|
|
583
671
|
}
|
|
584
672
|
)
|
|
@@ -597,8 +685,8 @@ jsonSchemaTypePreset.forEach((_type) => import_json_schema.jsonSchemaTypeManager
|
|
|
597
685
|
|
|
598
686
|
// src/plugins/json-schema-preset/create-type-preset-plugin.tsx
|
|
599
687
|
var import_json_schema2 = require("@flowgram.ai/json-schema");
|
|
600
|
-
var
|
|
601
|
-
var createTypePresetPlugin = (0,
|
|
688
|
+
var import_editor9 = require("@flowgram.ai/editor");
|
|
689
|
+
var createTypePresetPlugin = (0, import_editor9.definePluginCreator)({
|
|
602
690
|
onInit(ctx, opts) {
|
|
603
691
|
const typeManager = ctx.get(import_json_schema2.BaseTypeManager);
|
|
604
692
|
jsonSchemaTypePreset.forEach((_type) => typeManager.register(_type));
|
|
@@ -613,15 +701,15 @@ var useTypeManager = () => (0, import_json_schema3.useTypeManager)();
|
|
|
613
701
|
var JsonSchemaTypePresetProvider = ({
|
|
614
702
|
types = [],
|
|
615
703
|
children
|
|
616
|
-
}) => /* @__PURE__ */
|
|
704
|
+
}) => /* @__PURE__ */ import_react11.default.createElement(import_json_schema3.TypePresetProvider, { types: [...jsonSchemaTypePreset, ...types] }, children);
|
|
617
705
|
|
|
618
706
|
// src/plugins/disable-declaration-plugin/create-disable-declaration-plugin.ts
|
|
619
|
-
var
|
|
620
|
-
var createDisableDeclarationPlugin = (0,
|
|
707
|
+
var import_editor10 = require("@flowgram.ai/editor");
|
|
708
|
+
var createDisableDeclarationPlugin = (0, import_editor10.definePluginCreator)({
|
|
621
709
|
onInit(ctx) {
|
|
622
|
-
const variableEngine = ctx.get(
|
|
710
|
+
const variableEngine = ctx.get(import_editor10.VariableEngine);
|
|
623
711
|
const handleEvent = (action) => {
|
|
624
|
-
if (
|
|
712
|
+
if (import_editor10.ASTMatch.isVariableDeclaration(action.ast)) {
|
|
625
713
|
if (!action.ast.meta?.disabled) {
|
|
626
714
|
action.ast.updateMeta({
|
|
627
715
|
...action.ast.meta || {},
|
|
@@ -639,16 +727,16 @@ var createDisableDeclarationPlugin = (0, import_editor9.definePluginCreator)({
|
|
|
639
727
|
function useVariableTree(params) {
|
|
640
728
|
const { includeSchema, excludeSchema, customSkip } = params;
|
|
641
729
|
const typeManager = useTypeManager();
|
|
642
|
-
const variables = (0,
|
|
643
|
-
const getVariableTypeIcon = (0,
|
|
730
|
+
const variables = (0, import_editor11.useAvailableVariables)();
|
|
731
|
+
const getVariableTypeIcon = (0, import_react12.useCallback)((variable) => {
|
|
644
732
|
if (variable.meta?.icon) {
|
|
645
733
|
if (typeof variable.meta.icon === "string") {
|
|
646
|
-
return /* @__PURE__ */
|
|
734
|
+
return /* @__PURE__ */ import_react12.default.createElement("img", { style: { marginRight: 8 }, width: 12, height: 12, src: variable.meta.icon });
|
|
647
735
|
}
|
|
648
736
|
return variable.meta.icon;
|
|
649
737
|
}
|
|
650
738
|
const schema = import_json_schema4.JsonSchemaUtils.astToSchema(variable.type, { drilldownObject: false });
|
|
651
|
-
return /* @__PURE__ */
|
|
739
|
+
return /* @__PURE__ */ import_react12.default.createElement(import_semi_ui5.Icon, { size: "small", svg: typeManager.getDisplayIcon(schema || {}) });
|
|
652
740
|
}, []);
|
|
653
741
|
const renderVariable = (variable, parentFields = []) => {
|
|
654
742
|
let type = variable?.type;
|
|
@@ -656,7 +744,7 @@ function useVariableTree(params) {
|
|
|
656
744
|
return null;
|
|
657
745
|
}
|
|
658
746
|
let children;
|
|
659
|
-
if (
|
|
747
|
+
if (import_editor11.ASTMatch.isObject(type)) {
|
|
660
748
|
children = (type.properties || []).map((_property) => renderVariable(_property, [...parentFields, variable])).filter(Boolean);
|
|
661
749
|
}
|
|
662
750
|
const keyPath = [...parentFields.map((_field) => _field.key), variable.key];
|
|
@@ -756,7 +844,7 @@ var VariableSelector = ({
|
|
|
756
844
|
triggerRender
|
|
757
845
|
}) => {
|
|
758
846
|
const treeData = useVariableTree({ includeSchema, excludeSchema });
|
|
759
|
-
const treeValue = (0,
|
|
847
|
+
const treeValue = (0, import_react13.useMemo)(() => {
|
|
760
848
|
if (typeof value === "string") {
|
|
761
849
|
console.warn(
|
|
762
850
|
"The Value of VariableSelector is a string, it should be an ARRAY. \n",
|
|
@@ -768,11 +856,11 @@ var VariableSelector = ({
|
|
|
768
856
|
}, [value]);
|
|
769
857
|
const renderIcon = (icon) => {
|
|
770
858
|
if (typeof icon === "string") {
|
|
771
|
-
return /* @__PURE__ */
|
|
859
|
+
return /* @__PURE__ */ import_react13.default.createElement("img", { style: { marginRight: 8 }, width: 12, height: 12, src: icon });
|
|
772
860
|
}
|
|
773
861
|
return icon;
|
|
774
862
|
};
|
|
775
|
-
return /* @__PURE__ */
|
|
863
|
+
return /* @__PURE__ */ import_react13.default.createElement(import_react13.default.Fragment, null, /* @__PURE__ */ import_react13.default.createElement(
|
|
776
864
|
UITreeSelect,
|
|
777
865
|
{
|
|
778
866
|
dropdownMatchSelectWidth: false,
|
|
@@ -789,10 +877,10 @@ var VariableSelector = ({
|
|
|
789
877
|
},
|
|
790
878
|
renderSelectedItem: (_option) => {
|
|
791
879
|
if (!_option?.keyPath) {
|
|
792
|
-
return /* @__PURE__ */
|
|
880
|
+
return /* @__PURE__ */ import_react13.default.createElement(
|
|
793
881
|
UITag,
|
|
794
882
|
{
|
|
795
|
-
prefixIcon: /* @__PURE__ */
|
|
883
|
+
prefixIcon: /* @__PURE__ */ import_react13.default.createElement(import_semi_icons.IconIssueStroked, null),
|
|
796
884
|
color: "amber",
|
|
797
885
|
closable: !readonly,
|
|
798
886
|
onClose: () => onChange(void 0)
|
|
@@ -801,13 +889,13 @@ var VariableSelector = ({
|
|
|
801
889
|
);
|
|
802
890
|
}
|
|
803
891
|
const rootIcon = renderIcon(_option.rootMeta?.icon || _option?.icon);
|
|
804
|
-
const rootTitle = /* @__PURE__ */
|
|
805
|
-
return /* @__PURE__ */
|
|
892
|
+
const rootTitle = /* @__PURE__ */ import_react13.default.createElement(UIRootTitle, null, _option.rootMeta?.title ? `${_option.rootMeta?.title} ${_option.isRoot ? "" : "-"} ` : null);
|
|
893
|
+
return /* @__PURE__ */ import_react13.default.createElement("div", null, /* @__PURE__ */ import_react13.default.createElement(
|
|
806
894
|
import_semi_ui7.Popover,
|
|
807
895
|
{
|
|
808
|
-
content: /* @__PURE__ */
|
|
896
|
+
content: /* @__PURE__ */ import_react13.default.createElement(UIPopoverContent, null, rootIcon, rootTitle, /* @__PURE__ */ import_react13.default.createElement(UIVarName, null, _option.keyPath.slice(1).join(".")))
|
|
809
897
|
},
|
|
810
|
-
/* @__PURE__ */
|
|
898
|
+
/* @__PURE__ */ import_react13.default.createElement(
|
|
811
899
|
UITag,
|
|
812
900
|
{
|
|
813
901
|
prefixIcon: rootIcon,
|
|
@@ -815,20 +903,22 @@ var VariableSelector = ({
|
|
|
815
903
|
onClose: () => onChange(void 0)
|
|
816
904
|
},
|
|
817
905
|
rootTitle,
|
|
818
|
-
!_option.isRoot && /* @__PURE__ */
|
|
906
|
+
!_option.isRoot && /* @__PURE__ */ import_react13.default.createElement(UIVarName, { $inSelector: true }, _option.label)
|
|
819
907
|
)
|
|
820
908
|
));
|
|
821
909
|
},
|
|
822
910
|
showClear: false,
|
|
823
|
-
arrowIcon: /* @__PURE__ */
|
|
911
|
+
arrowIcon: /* @__PURE__ */ import_react13.default.createElement(import_semi_icons.IconChevronDownStroked, { size: "small" }),
|
|
824
912
|
triggerRender,
|
|
825
|
-
placeholder: config?.placeholder ??
|
|
913
|
+
placeholder: config?.placeholder ?? import_editor12.I18n.t("Select Variable")
|
|
826
914
|
}
|
|
827
915
|
));
|
|
828
916
|
};
|
|
917
|
+
VariableSelector.renderKey = "variable-selector-render-key";
|
|
918
|
+
var InjectVariableSelector = createInjectMaterial(VariableSelector);
|
|
829
919
|
|
|
830
920
|
// src/components/type-selector/index.tsx
|
|
831
|
-
var
|
|
921
|
+
var import_react14 = __toESM(require("react"));
|
|
832
922
|
var import_semi_ui8 = require("@douyinfe/semi-ui");
|
|
833
923
|
var labelStyle = { display: "flex", alignItems: "center", gap: 5 };
|
|
834
924
|
var getTypeSelectValue = (value) => {
|
|
@@ -846,17 +936,17 @@ var parseTypeSelectValue = (value) => {
|
|
|
846
936
|
};
|
|
847
937
|
function TypeSelector(props) {
|
|
848
938
|
const { value, onChange, readonly, disabled, style } = props;
|
|
849
|
-
const selectValue = (0,
|
|
939
|
+
const selectValue = (0, import_react14.useMemo)(() => getTypeSelectValue(value), [value]);
|
|
850
940
|
const typeManager = useTypeManager();
|
|
851
941
|
const icon = typeManager.getDisplayIcon(value || {});
|
|
852
|
-
const options = (0,
|
|
942
|
+
const options = (0, import_react14.useMemo)(
|
|
853
943
|
() => typeManager.getTypeRegistriesWithParentType().map((_type) => {
|
|
854
944
|
const isArray2 = _type.type === "array";
|
|
855
945
|
return {
|
|
856
|
-
label: /* @__PURE__ */
|
|
946
|
+
label: /* @__PURE__ */ import_react14.default.createElement("div", { style: labelStyle }, /* @__PURE__ */ import_react14.default.createElement(import_semi_ui8.Icon, { size: "small", svg: _type.icon }), typeManager.getTypeBySchema(_type)?.label || _type.type),
|
|
857
947
|
value: _type.type,
|
|
858
948
|
children: isArray2 ? typeManager.getTypeRegistriesWithParentType("array").map((_type2) => ({
|
|
859
|
-
label: /* @__PURE__ */
|
|
949
|
+
label: /* @__PURE__ */ import_react14.default.createElement("div", { style: labelStyle }, /* @__PURE__ */ import_react14.default.createElement(
|
|
860
950
|
import_semi_ui8.Icon,
|
|
861
951
|
{
|
|
862
952
|
size: "small",
|
|
@@ -872,12 +962,12 @@ function TypeSelector(props) {
|
|
|
872
962
|
}),
|
|
873
963
|
[]
|
|
874
964
|
);
|
|
875
|
-
return /* @__PURE__ */
|
|
965
|
+
return /* @__PURE__ */ import_react14.default.createElement(
|
|
876
966
|
import_semi_ui8.Cascader,
|
|
877
967
|
{
|
|
878
968
|
disabled: readonly || disabled,
|
|
879
969
|
size: "small",
|
|
880
|
-
triggerRender: () => /* @__PURE__ */
|
|
970
|
+
triggerRender: () => /* @__PURE__ */ import_react14.default.createElement(import_semi_ui8.IconButton, { size: "small", style, disabled: readonly || disabled, icon }),
|
|
881
971
|
treeData: options,
|
|
882
972
|
value: selectValue,
|
|
883
973
|
leafOnly: true,
|
|
@@ -887,15 +977,17 @@ function TypeSelector(props) {
|
|
|
887
977
|
}
|
|
888
978
|
);
|
|
889
979
|
}
|
|
980
|
+
TypeSelector.renderKey = "type-selector-render-key";
|
|
981
|
+
var InjectTypeSelector = createInjectMaterial(TypeSelector);
|
|
890
982
|
|
|
891
983
|
// src/components/json-schema-editor/index.tsx
|
|
892
|
-
var
|
|
893
|
-
var
|
|
894
|
-
var
|
|
895
|
-
var
|
|
984
|
+
var import_react20 = __toESM(require("react"));
|
|
985
|
+
var import_editor14 = require("@flowgram.ai/editor");
|
|
986
|
+
var import_semi_ui10 = require("@douyinfe/semi-ui");
|
|
987
|
+
var import_semi_icons3 = require("@douyinfe/semi-icons");
|
|
896
988
|
|
|
897
989
|
// src/components/json-schema-editor/styles.tsx
|
|
898
|
-
var
|
|
990
|
+
var import_react15 = __toESM(require("react"));
|
|
899
991
|
var import_styled_components3 = __toESM(require("styled-components"));
|
|
900
992
|
var import_semi_icons2 = __toESM(require("@douyinfe/semi-icons"));
|
|
901
993
|
var UIContainer = import_styled_components3.default.div`
|
|
@@ -1023,7 +1115,7 @@ var UIRequired = import_styled_components3.default.div``;
|
|
|
1023
1115
|
var UIActions = import_styled_components3.default.div`
|
|
1024
1116
|
white-space: nowrap;
|
|
1025
1117
|
`;
|
|
1026
|
-
var iconAddChildrenSvg = /* @__PURE__ */
|
|
1118
|
+
var iconAddChildrenSvg = /* @__PURE__ */ import_react15.default.createElement(
|
|
1027
1119
|
"svg",
|
|
1028
1120
|
{
|
|
1029
1121
|
className: "icon-icon icon-icon-coz_add_node ",
|
|
@@ -1033,7 +1125,7 @@ var iconAddChildrenSvg = /* @__PURE__ */ import_react14.default.createElement(
|
|
|
1033
1125
|
fill: "currentColor",
|
|
1034
1126
|
xmlns: "http://www.w3.org/2000/svg"
|
|
1035
1127
|
},
|
|
1036
|
-
/* @__PURE__ */
|
|
1128
|
+
/* @__PURE__ */ import_react15.default.createElement(
|
|
1037
1129
|
"path",
|
|
1038
1130
|
{
|
|
1039
1131
|
fillRule: "evenodd",
|
|
@@ -1041,37 +1133,12 @@ var iconAddChildrenSvg = /* @__PURE__ */ import_react14.default.createElement(
|
|
|
1041
1133
|
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"
|
|
1042
1134
|
}
|
|
1043
1135
|
),
|
|
1044
|
-
/* @__PURE__ */
|
|
1136
|
+
/* @__PURE__ */ import_react15.default.createElement("path", { d: "M17.5 12.4999C18.0523 12.4999 18.5 12.9476 18.5 13.4999V16.4999H21.5C22.0523 16.4999 22.5 16.9476 22.5 17.4999C22.5 18.0522 22.0523 18.4999 21.5 18.4999H18.5V21.4999C18.5 22.0522 18.0523 22.4999 17.5 22.4999C16.9477 22.4999 16.5 22.0522 16.5 21.4999V18.4999H13.5C12.9477 18.4999 12.5 18.0522 12.5 17.4999C12.5 16.9476 12.9477 16.4999 13.5 16.4999H16.5V13.4999C16.5 12.9476 16.9477 12.4999 17.5 12.4999Z" })
|
|
1045
1137
|
);
|
|
1046
|
-
var IconAddChildren = () => /* @__PURE__ */
|
|
1138
|
+
var IconAddChildren = () => /* @__PURE__ */ import_react15.default.createElement(import_semi_icons2.default, { size: "small", svg: iconAddChildrenSvg });
|
|
1047
1139
|
var DefaultValueWrapper = import_styled_components3.default.div`
|
|
1048
1140
|
margin: 0;
|
|
1049
1141
|
`;
|
|
1050
|
-
var JSONViewerWrapper = import_styled_components3.default.div`
|
|
1051
|
-
padding: 0 0 24px;
|
|
1052
|
-
&:first-child {
|
|
1053
|
-
margin-top: 0px;
|
|
1054
|
-
}
|
|
1055
|
-
`;
|
|
1056
|
-
var JSONHeader = import_styled_components3.default.div`
|
|
1057
|
-
display: flex;
|
|
1058
|
-
justify-content: space-between;
|
|
1059
|
-
align-items: center;
|
|
1060
|
-
background-color: var(--semi-color-fill-0);
|
|
1061
|
-
border-radius: 6px 6px 0 0;
|
|
1062
|
-
height: 36px;
|
|
1063
|
-
padding: 0 8px 0 12px;
|
|
1064
|
-
`;
|
|
1065
|
-
var JSONHeaderLeft = import_styled_components3.default.div`
|
|
1066
|
-
display: flex;
|
|
1067
|
-
align-items: center;
|
|
1068
|
-
gap: 10px;
|
|
1069
|
-
`;
|
|
1070
|
-
var JSONHeaderRight = import_styled_components3.default.div`
|
|
1071
|
-
display: flex;
|
|
1072
|
-
align-items: center;
|
|
1073
|
-
gap: 10px;
|
|
1074
|
-
`;
|
|
1075
1142
|
var ConstantInputWrapper = import_styled_components3.default.div`
|
|
1076
1143
|
flex-grow: 1;
|
|
1077
1144
|
|
|
@@ -1083,71 +1150,39 @@ var ConstantInputWrapper = import_styled_components3.default.div`
|
|
|
1083
1150
|
`;
|
|
1084
1151
|
|
|
1085
1152
|
// src/components/json-schema-editor/hooks.tsx
|
|
1086
|
-
var
|
|
1087
|
-
var
|
|
1153
|
+
var import_react16 = require("react");
|
|
1154
|
+
var import_lodash2 = require("lodash");
|
|
1155
|
+
var import_immer = require("immer");
|
|
1156
|
+
var import_json_schema5 = require("@flowgram.ai/json-schema");
|
|
1088
1157
|
var _id = 0;
|
|
1089
1158
|
function genId() {
|
|
1090
1159
|
return _id++;
|
|
1091
1160
|
}
|
|
1092
|
-
function getDrilldownSchema(value, path) {
|
|
1093
|
-
if (!value) {
|
|
1094
|
-
return {};
|
|
1095
|
-
}
|
|
1096
|
-
if (value.type === "array" && value.items) {
|
|
1097
|
-
return getDrilldownSchema(value.items, [...path || [], "items"]);
|
|
1098
|
-
}
|
|
1099
|
-
return { schema: value, path };
|
|
1100
|
-
}
|
|
1101
1161
|
function usePropertiesEdit(value, onChange) {
|
|
1102
|
-
const
|
|
1103
|
-
const
|
|
1104
|
-
const
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
if (_property.name) {
|
|
1127
|
-
nameMap.set(_property.name, _property);
|
|
1128
|
-
}
|
|
1129
|
-
}
|
|
1130
|
-
return Object.entries(drilldown.schema?.properties || {}).sort(([, a], [, b]) => (a.extra?.index ?? 0) - (b.extra?.index ?? 0)).map(([name, _value]) => {
|
|
1131
|
-
const _property = nameMap.get(name);
|
|
1132
|
-
if (_property) {
|
|
1133
|
-
return {
|
|
1134
|
-
key: _property.key,
|
|
1135
|
-
name,
|
|
1136
|
-
isPropertyRequired: drilldown.schema?.required?.includes(name) || false,
|
|
1137
|
-
..._value
|
|
1138
|
-
};
|
|
1139
|
-
}
|
|
1140
|
-
return {
|
|
1141
|
-
key: genId(),
|
|
1142
|
-
name,
|
|
1143
|
-
isPropertyRequired: drilldown.schema?.required?.includes(name) || false,
|
|
1144
|
-
..._value
|
|
1145
|
-
};
|
|
1146
|
-
});
|
|
1147
|
-
});
|
|
1148
|
-
}
|
|
1149
|
-
mountRef.current = true;
|
|
1150
|
-
}, [drilldown.schema]);
|
|
1162
|
+
const typeManager = (0, import_json_schema5.useTypeManager)();
|
|
1163
|
+
const drilldownSchema = typeManager.getPropertiesParent(value || {});
|
|
1164
|
+
const canAddField = typeManager.canAddField(value || {});
|
|
1165
|
+
const [propertyList, setPropertyList] = (0, import_react16.useState)([]);
|
|
1166
|
+
(0, import_react16.useEffect)(() => {
|
|
1167
|
+
setPropertyList((_list) => {
|
|
1168
|
+
const newNames = Object.entries(drilldownSchema?.properties || {}).sort(([, a], [, b]) => (a.extra?.index ?? 0) - (b.extra?.index ?? 0)).map(([key]) => key);
|
|
1169
|
+
const oldNames = _list.map((item) => item.name).filter(Boolean);
|
|
1170
|
+
const addNames = (0, import_lodash2.difference)(newNames, oldNames);
|
|
1171
|
+
return _list.filter((item) => !item.name || newNames.includes(item.name)).map((item) => ({
|
|
1172
|
+
key: item.key,
|
|
1173
|
+
name: item.name,
|
|
1174
|
+
isPropertyRequired: drilldownSchema?.required?.includes(item.name || "") || false,
|
|
1175
|
+
...item
|
|
1176
|
+
})).concat(
|
|
1177
|
+
addNames.map((_name) => ({
|
|
1178
|
+
key: genId(),
|
|
1179
|
+
name: _name,
|
|
1180
|
+
isPropertyRequired: drilldownSchema?.required?.includes(_name) || false,
|
|
1181
|
+
...drilldownSchema?.properties?.[_name] || {}
|
|
1182
|
+
}))
|
|
1183
|
+
);
|
|
1184
|
+
});
|
|
1185
|
+
}, [drilldownSchema]);
|
|
1151
1186
|
const updatePropertyList = (updater) => {
|
|
1152
1187
|
setPropertyList((_list) => {
|
|
1153
1188
|
const next = updater(_list);
|
|
@@ -1157,23 +1192,26 @@ function usePropertiesEdit(value, onChange) {
|
|
|
1157
1192
|
if (!_property.name) {
|
|
1158
1193
|
continue;
|
|
1159
1194
|
}
|
|
1160
|
-
nextProperties[_property.name] = (0,
|
|
1195
|
+
nextProperties[_property.name] = (0, import_lodash2.omit)(_property, ["key", "name", "isPropertyRequired"]);
|
|
1161
1196
|
if (_property.isPropertyRequired) {
|
|
1162
1197
|
nextRequired.push(_property.name);
|
|
1163
1198
|
}
|
|
1164
1199
|
}
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1200
|
+
onChange?.(
|
|
1201
|
+
(0, import_immer.produce)(value || {}, (draft) => {
|
|
1202
|
+
const propertiesParent = typeManager.getPropertiesParent(draft);
|
|
1203
|
+
if (propertiesParent) {
|
|
1204
|
+
propertiesParent.properties = nextProperties;
|
|
1205
|
+
propertiesParent.required = nextRequired;
|
|
1206
|
+
return;
|
|
1207
|
+
}
|
|
1208
|
+
})
|
|
1209
|
+
);
|
|
1172
1210
|
return next;
|
|
1173
1211
|
});
|
|
1174
1212
|
};
|
|
1175
1213
|
const onAddProperty = () => {
|
|
1176
|
-
|
|
1214
|
+
setPropertyList((_list) => [
|
|
1177
1215
|
..._list,
|
|
1178
1216
|
{ key: genId(), name: "", type: "string", extra: { index: _list.length + 1 } }
|
|
1179
1217
|
]);
|
|
@@ -1186,14 +1224,14 @@ function usePropertiesEdit(value, onChange) {
|
|
|
1186
1224
|
(_list) => _list.map((_property) => _property.key === key ? nextValue : _property)
|
|
1187
1225
|
);
|
|
1188
1226
|
};
|
|
1189
|
-
(0,
|
|
1190
|
-
if (!
|
|
1227
|
+
(0, import_react16.useEffect)(() => {
|
|
1228
|
+
if (!canAddField) {
|
|
1191
1229
|
setPropertyList([]);
|
|
1192
1230
|
}
|
|
1193
|
-
}, [
|
|
1231
|
+
}, [canAddField]);
|
|
1194
1232
|
return {
|
|
1195
1233
|
propertyList,
|
|
1196
|
-
|
|
1234
|
+
canAddField,
|
|
1197
1235
|
onAddProperty,
|
|
1198
1236
|
onRemoveProperty,
|
|
1199
1237
|
onEditProperty
|
|
@@ -1201,36 +1239,16 @@ function usePropertiesEdit(value, onChange) {
|
|
|
1201
1239
|
}
|
|
1202
1240
|
|
|
1203
1241
|
// src/components/json-schema-editor/default-value.tsx
|
|
1204
|
-
var
|
|
1205
|
-
var
|
|
1206
|
-
var import_semi_icons3 = require("@douyinfe/semi-icons");
|
|
1207
|
-
|
|
1208
|
-
// src/components/json-schema-editor/utils.ts
|
|
1209
|
-
function getValueType(value) {
|
|
1210
|
-
const type = typeof value;
|
|
1211
|
-
if (type === "string") {
|
|
1212
|
-
return "string";
|
|
1213
|
-
} else if (type === "number") {
|
|
1214
|
-
return Number.isInteger(value) ? "integer" : "number";
|
|
1215
|
-
} else if (type === "boolean") {
|
|
1216
|
-
return "boolean";
|
|
1217
|
-
} else if (type === "object") {
|
|
1218
|
-
if (value === null) {
|
|
1219
|
-
return "other";
|
|
1220
|
-
}
|
|
1221
|
-
return Array.isArray(value) ? "array" : "object";
|
|
1222
|
-
} else {
|
|
1223
|
-
return "other";
|
|
1224
|
-
}
|
|
1225
|
-
}
|
|
1242
|
+
var import_react18 = __toESM(require("react"));
|
|
1243
|
+
var import_editor13 = require("@flowgram.ai/editor");
|
|
1226
1244
|
|
|
1227
1245
|
// src/components/constant-input/index.tsx
|
|
1228
|
-
var
|
|
1246
|
+
var import_react17 = __toESM(require("react"));
|
|
1229
1247
|
var import_semi_ui9 = require("@douyinfe/semi-ui");
|
|
1230
1248
|
function ConstantInput(props) {
|
|
1231
1249
|
const { value, onChange, schema, strategies, fallbackRenderer, readonly, ...rest } = props;
|
|
1232
1250
|
const typeManager = useTypeManager();
|
|
1233
|
-
const Renderer2 = (0,
|
|
1251
|
+
const Renderer2 = (0, import_react17.useMemo)(() => {
|
|
1234
1252
|
const strategy = (strategies || []).find((_strategy) => _strategy.hit(schema));
|
|
1235
1253
|
if (!strategy) {
|
|
1236
1254
|
return typeManager.getTypeBySchema(schema)?.ConstantRenderer;
|
|
@@ -1239,110 +1257,41 @@ function ConstantInput(props) {
|
|
|
1239
1257
|
}, [strategies, schema]);
|
|
1240
1258
|
if (!Renderer2) {
|
|
1241
1259
|
if (fallbackRenderer) {
|
|
1242
|
-
return
|
|
1260
|
+
return import_react17.default.createElement(fallbackRenderer, {
|
|
1243
1261
|
value,
|
|
1244
1262
|
onChange,
|
|
1245
1263
|
readonly,
|
|
1246
1264
|
...rest
|
|
1247
1265
|
});
|
|
1248
1266
|
}
|
|
1249
|
-
return /* @__PURE__ */
|
|
1267
|
+
return /* @__PURE__ */ import_react17.default.createElement(import_semi_ui9.Input, { size: "small", disabled: true, placeholder: "Unsupported type" });
|
|
1250
1268
|
}
|
|
1251
|
-
return /* @__PURE__ */
|
|
1269
|
+
return /* @__PURE__ */ import_react17.default.createElement(Renderer2, { value, onChange, readonly, ...rest });
|
|
1252
1270
|
}
|
|
1253
1271
|
|
|
1254
1272
|
// src/components/json-schema-editor/default-value.tsx
|
|
1255
1273
|
function DefaultValue(props) {
|
|
1256
|
-
const { value, schema,
|
|
1257
|
-
|
|
1258
|
-
const JsonViewerRef = (0, import_react17.useRef)(null);
|
|
1259
|
-
const [internalJsonValue, setInternalJsonValue] = (0, import_react17.useState)(
|
|
1260
|
-
getValueType(value) === "string" ? value : ""
|
|
1261
|
-
);
|
|
1262
|
-
const handleJsonChange = (0, import_react17.useCallback)((val) => {
|
|
1263
|
-
if (val !== internalJsonValue) {
|
|
1264
|
-
setInternalJsonValue(val);
|
|
1265
|
-
}
|
|
1266
|
-
}, []);
|
|
1267
|
-
const handleEditComplete = (0, import_react17.useCallback)(() => {
|
|
1268
|
-
onChange(internalJsonValue);
|
|
1269
|
-
requestAnimationFrame(() => {
|
|
1270
|
-
wrapperRef.current?.blur();
|
|
1271
|
-
});
|
|
1272
|
-
setJsonReadOnly(true);
|
|
1273
|
-
}, [internalJsonValue, onChange]);
|
|
1274
|
-
const [jsonReadOnly, setJsonReadOnly] = (0, import_react17.useState)(true);
|
|
1275
|
-
const handleFormatJson = (0, import_react17.useCallback)(() => {
|
|
1276
|
-
try {
|
|
1277
|
-
const parsed = JSON.parse(internalJsonValue);
|
|
1278
|
-
const formatted = JSON.stringify(parsed, null, 4);
|
|
1279
|
-
setInternalJsonValue(formatted);
|
|
1280
|
-
onChange(formatted);
|
|
1281
|
-
} catch (error) {
|
|
1282
|
-
console.error("Invalid JSON:", error);
|
|
1283
|
-
}
|
|
1284
|
-
}, [internalJsonValue, onChange]);
|
|
1285
|
-
return type === "object" ? /* @__PURE__ */ import_react17.default.createElement(import_react17.default.Fragment, null, /* @__PURE__ */ import_react17.default.createElement(JSONHeader, null, /* @__PURE__ */ import_react17.default.createElement(JSONHeaderLeft, null, "json"), /* @__PURE__ */ import_react17.default.createElement(JSONHeaderRight, null, /* @__PURE__ */ import_react17.default.createElement(import_semi_ui10.Tooltip, { content: jsonFormatText ?? "Format" }, /* @__PURE__ */ import_react17.default.createElement(
|
|
1286
|
-
import_semi_ui10.IconButton,
|
|
1287
|
-
{
|
|
1288
|
-
icon: /* @__PURE__ */ import_react17.default.createElement(import_semi_icons3.IconBrackets, { style: { color: "var(--semi-color-primary)" } }),
|
|
1289
|
-
size: "small",
|
|
1290
|
-
type: "tertiary",
|
|
1291
|
-
theme: "borderless",
|
|
1292
|
-
onClick: handleFormatJson
|
|
1293
|
-
}
|
|
1294
|
-
)))), /* @__PURE__ */ import_react17.default.createElement(
|
|
1295
|
-
JSONViewerWrapper,
|
|
1296
|
-
{
|
|
1297
|
-
ref: wrapperRef,
|
|
1298
|
-
tabIndex: -1,
|
|
1299
|
-
onBlur: (e) => {
|
|
1300
|
-
if (wrapperRef.current && !wrapperRef.current?.contains(e.relatedTarget)) {
|
|
1301
|
-
handleEditComplete();
|
|
1302
|
-
}
|
|
1303
|
-
},
|
|
1304
|
-
onClick: (e) => {
|
|
1305
|
-
setJsonReadOnly(false);
|
|
1306
|
-
}
|
|
1307
|
-
},
|
|
1308
|
-
/* @__PURE__ */ import_react17.default.createElement(
|
|
1309
|
-
import_semi_ui10.JsonViewer,
|
|
1310
|
-
{
|
|
1311
|
-
ref: JsonViewerRef,
|
|
1312
|
-
value: getValueType(value) === "string" ? value : "",
|
|
1313
|
-
height: 120,
|
|
1314
|
-
width: "100%",
|
|
1315
|
-
showSearch: false,
|
|
1316
|
-
options: {
|
|
1317
|
-
readOnly: jsonReadOnly,
|
|
1318
|
-
formatOptions: { tabSize: 4, insertSpaces: true, eol: "\n" }
|
|
1319
|
-
},
|
|
1320
|
-
style: {
|
|
1321
|
-
padding: 0
|
|
1322
|
-
},
|
|
1323
|
-
onChange: handleJsonChange
|
|
1324
|
-
}
|
|
1325
|
-
)
|
|
1326
|
-
)) : /* @__PURE__ */ import_react17.default.createElement(ConstantInputWrapper, null, /* @__PURE__ */ import_react17.default.createElement(
|
|
1274
|
+
const { value, schema, onChange, placeholder } = props;
|
|
1275
|
+
return /* @__PURE__ */ import_react18.default.createElement(ConstantInputWrapper, null, /* @__PURE__ */ import_react18.default.createElement(
|
|
1327
1276
|
ConstantInput,
|
|
1328
1277
|
{
|
|
1329
1278
|
value,
|
|
1330
1279
|
onChange: (_v) => onChange(_v),
|
|
1331
1280
|
schema: schema || { type: "string" },
|
|
1332
|
-
placeholder: placeholder ?? "Default value if parameter is not provided"
|
|
1281
|
+
placeholder: placeholder ?? import_editor13.I18n.t("Default value if parameter is not provided")
|
|
1333
1282
|
}
|
|
1334
1283
|
));
|
|
1335
1284
|
}
|
|
1336
1285
|
|
|
1337
1286
|
// src/components/json-schema-editor/components/blur-input.tsx
|
|
1338
|
-
var
|
|
1287
|
+
var import_react19 = __toESM(require("react"));
|
|
1339
1288
|
var import_input = __toESM(require("@douyinfe/semi-ui/lib/es/input"));
|
|
1340
1289
|
function BlurInput(props) {
|
|
1341
|
-
const [value, setValue] = (0,
|
|
1342
|
-
(0,
|
|
1290
|
+
const [value, setValue] = (0, import_react19.useState)("");
|
|
1291
|
+
(0, import_react19.useEffect)(() => {
|
|
1343
1292
|
setValue(props.value);
|
|
1344
1293
|
}, [props.value]);
|
|
1345
|
-
return /* @__PURE__ */
|
|
1294
|
+
return /* @__PURE__ */ import_react19.default.createElement(
|
|
1346
1295
|
import_input.default,
|
|
1347
1296
|
{
|
|
1348
1297
|
...props,
|
|
@@ -1356,13 +1305,14 @@ function BlurInput(props) {
|
|
|
1356
1305
|
}
|
|
1357
1306
|
|
|
1358
1307
|
// src/components/json-schema-editor/index.tsx
|
|
1308
|
+
var DEFAULT = { type: "object" };
|
|
1359
1309
|
function JsonSchemaEditor(props) {
|
|
1360
|
-
const { value =
|
|
1310
|
+
const { value = DEFAULT, config = {}, onChange: onChangeProps, readonly } = props;
|
|
1361
1311
|
const { propertyList, onAddProperty, onRemoveProperty, onEditProperty } = usePropertiesEdit(
|
|
1362
1312
|
value,
|
|
1363
1313
|
onChangeProps
|
|
1364
1314
|
);
|
|
1365
|
-
return /* @__PURE__ */
|
|
1315
|
+
return /* @__PURE__ */ import_react20.default.createElement(UIContainer, { className: props.className }, /* @__PURE__ */ import_react20.default.createElement(UIProperties, null, propertyList.map((_property, index) => /* @__PURE__ */ import_react20.default.createElement(
|
|
1366
1316
|
PropertyEdit,
|
|
1367
1317
|
{
|
|
1368
1318
|
readonly,
|
|
@@ -1377,16 +1327,16 @@ function JsonSchemaEditor(props) {
|
|
|
1377
1327
|
onRemoveProperty(_property.key);
|
|
1378
1328
|
}
|
|
1379
1329
|
}
|
|
1380
|
-
))), /* @__PURE__ */
|
|
1381
|
-
|
|
1330
|
+
))), /* @__PURE__ */ import_react20.default.createElement(
|
|
1331
|
+
import_semi_ui10.Button,
|
|
1382
1332
|
{
|
|
1383
1333
|
disabled: readonly,
|
|
1384
1334
|
size: "small",
|
|
1385
1335
|
style: { marginTop: 10, marginLeft: 16 },
|
|
1386
|
-
icon: /* @__PURE__ */
|
|
1336
|
+
icon: /* @__PURE__ */ import_react20.default.createElement(import_semi_icons3.IconPlus, null),
|
|
1387
1337
|
onClick: onAddProperty
|
|
1388
1338
|
},
|
|
1389
|
-
config?.addButtonText ?? "Add"
|
|
1339
|
+
config?.addButtonText ?? import_editor14.I18n.t("Add")
|
|
1390
1340
|
));
|
|
1391
1341
|
}
|
|
1392
1342
|
function PropertyEdit(props) {
|
|
@@ -1404,19 +1354,19 @@ function PropertyEdit(props) {
|
|
|
1404
1354
|
$parentType = "",
|
|
1405
1355
|
$showLine
|
|
1406
1356
|
} = props;
|
|
1407
|
-
const [expand, setExpand] = (0,
|
|
1408
|
-
const [collapse, setCollapse] = (0,
|
|
1357
|
+
const [expand, setExpand] = (0, import_react20.useState)(false);
|
|
1358
|
+
const [collapse, setCollapse] = (0, import_react20.useState)(false);
|
|
1409
1359
|
const { name, type, items, default: defaultValue, description, isPropertyRequired } = value || {};
|
|
1410
|
-
const typeSelectorValue = (0,
|
|
1411
|
-
const { propertyList,
|
|
1360
|
+
const typeSelectorValue = (0, import_react20.useMemo)(() => ({ type, items }), [type, items]);
|
|
1361
|
+
const { propertyList, canAddField, onAddProperty, onRemoveProperty, onEditProperty } = usePropertiesEdit(value, onChangeProps);
|
|
1412
1362
|
const onChange = (key, _value) => {
|
|
1413
1363
|
onChangeProps?.({
|
|
1414
1364
|
...value || {},
|
|
1415
1365
|
[key]: _value
|
|
1416
1366
|
});
|
|
1417
1367
|
};
|
|
1418
|
-
const showCollapse =
|
|
1419
|
-
return /* @__PURE__ */
|
|
1368
|
+
const showCollapse = canAddField && propertyList.length > 0;
|
|
1369
|
+
return /* @__PURE__ */ import_react20.default.createElement(import_react20.default.Fragment, null, /* @__PURE__ */ import_react20.default.createElement(
|
|
1420
1370
|
UIPropertyLeft,
|
|
1421
1371
|
{
|
|
1422
1372
|
type,
|
|
@@ -1428,8 +1378,8 @@ function PropertyEdit(props) {
|
|
|
1428
1378
|
$parentExpand,
|
|
1429
1379
|
$parentType
|
|
1430
1380
|
},
|
|
1431
|
-
showCollapse && /* @__PURE__ */
|
|
1432
|
-
), /* @__PURE__ */
|
|
1381
|
+
showCollapse && /* @__PURE__ */ import_react20.default.createElement(UICollapseTrigger, { onClick: () => setCollapse((_collapse) => !_collapse) }, collapse ? /* @__PURE__ */ import_react20.default.createElement(import_semi_icons3.IconChevronDown, { size: "small" }) : /* @__PURE__ */ import_react20.default.createElement(import_semi_icons3.IconChevronRight, { size: "small" }))
|
|
1382
|
+
), /* @__PURE__ */ import_react20.default.createElement(UIPropertyRight, null, /* @__PURE__ */ import_react20.default.createElement(
|
|
1433
1383
|
UIPropertyMain,
|
|
1434
1384
|
{
|
|
1435
1385
|
$showCollapse: showCollapse,
|
|
@@ -1437,7 +1387,7 @@ function PropertyEdit(props) {
|
|
|
1437
1387
|
$expand: expand,
|
|
1438
1388
|
type
|
|
1439
1389
|
},
|
|
1440
|
-
/* @__PURE__ */
|
|
1390
|
+
/* @__PURE__ */ import_react20.default.createElement(UIRow, null, /* @__PURE__ */ import_react20.default.createElement(UIName, null, /* @__PURE__ */ import_react20.default.createElement(
|
|
1441
1391
|
BlurInput,
|
|
1442
1392
|
{
|
|
1443
1393
|
disabled: readonly,
|
|
@@ -1446,8 +1396,8 @@ function PropertyEdit(props) {
|
|
|
1446
1396
|
value: name,
|
|
1447
1397
|
onChange: (value2) => onChange("name", value2)
|
|
1448
1398
|
}
|
|
1449
|
-
)), /* @__PURE__ */
|
|
1450
|
-
|
|
1399
|
+
)), /* @__PURE__ */ import_react20.default.createElement(UIType, null, /* @__PURE__ */ import_react20.default.createElement(
|
|
1400
|
+
InjectTypeSelector,
|
|
1451
1401
|
{
|
|
1452
1402
|
value: typeSelectorValue,
|
|
1453
1403
|
readonly,
|
|
@@ -1458,67 +1408,67 @@ function PropertyEdit(props) {
|
|
|
1458
1408
|
});
|
|
1459
1409
|
}
|
|
1460
1410
|
}
|
|
1461
|
-
)), /* @__PURE__ */
|
|
1462
|
-
|
|
1411
|
+
)), /* @__PURE__ */ import_react20.default.createElement(UIRequired, null, /* @__PURE__ */ import_react20.default.createElement(
|
|
1412
|
+
import_semi_ui10.Checkbox,
|
|
1463
1413
|
{
|
|
1464
1414
|
disabled: readonly,
|
|
1465
1415
|
checked: isPropertyRequired,
|
|
1466
1416
|
onChange: (e) => onChange("isPropertyRequired", e.target.checked)
|
|
1467
1417
|
}
|
|
1468
|
-
)), /* @__PURE__ */
|
|
1469
|
-
|
|
1418
|
+
)), /* @__PURE__ */ import_react20.default.createElement(UIActions, null, /* @__PURE__ */ import_react20.default.createElement(
|
|
1419
|
+
import_semi_ui10.IconButton,
|
|
1470
1420
|
{
|
|
1471
1421
|
disabled: readonly,
|
|
1472
1422
|
size: "small",
|
|
1473
1423
|
theme: "borderless",
|
|
1474
|
-
icon: expand ? /* @__PURE__ */
|
|
1424
|
+
icon: expand ? /* @__PURE__ */ import_react20.default.createElement(import_semi_icons3.IconShrink, { size: "small" }) : /* @__PURE__ */ import_react20.default.createElement(import_semi_icons3.IconExpand, { size: "small" }),
|
|
1475
1425
|
onClick: () => {
|
|
1476
1426
|
setExpand((_expand) => !_expand);
|
|
1477
1427
|
}
|
|
1478
1428
|
}
|
|
1479
|
-
),
|
|
1480
|
-
|
|
1429
|
+
), canAddField && /* @__PURE__ */ import_react20.default.createElement(
|
|
1430
|
+
import_semi_ui10.IconButton,
|
|
1481
1431
|
{
|
|
1482
1432
|
disabled: readonly,
|
|
1483
1433
|
size: "small",
|
|
1484
1434
|
theme: "borderless",
|
|
1485
|
-
icon: /* @__PURE__ */
|
|
1435
|
+
icon: /* @__PURE__ */ import_react20.default.createElement(IconAddChildren, null),
|
|
1486
1436
|
onClick: () => {
|
|
1487
1437
|
onAddProperty();
|
|
1488
1438
|
setCollapse(true);
|
|
1489
1439
|
}
|
|
1490
1440
|
}
|
|
1491
|
-
), /* @__PURE__ */
|
|
1492
|
-
|
|
1441
|
+
), /* @__PURE__ */ import_react20.default.createElement(
|
|
1442
|
+
import_semi_ui10.IconButton,
|
|
1493
1443
|
{
|
|
1494
1444
|
disabled: readonly,
|
|
1495
1445
|
size: "small",
|
|
1496
1446
|
theme: "borderless",
|
|
1497
|
-
icon: /* @__PURE__ */
|
|
1447
|
+
icon: /* @__PURE__ */ import_react20.default.createElement(import_semi_icons3.IconMinus, { size: "small" }),
|
|
1498
1448
|
onClick: onRemove
|
|
1499
1449
|
}
|
|
1500
1450
|
))),
|
|
1501
|
-
expand && /* @__PURE__ */
|
|
1451
|
+
expand && /* @__PURE__ */ import_react20.default.createElement(UIExpandDetail, null, /* @__PURE__ */ import_react20.default.createElement(UILabel, null, config?.descTitle ?? import_editor14.I18n.t("Description")), /* @__PURE__ */ import_react20.default.createElement(
|
|
1502
1452
|
BlurInput,
|
|
1503
1453
|
{
|
|
1504
1454
|
disabled: readonly,
|
|
1505
1455
|
size: "small",
|
|
1506
1456
|
value: description,
|
|
1507
1457
|
onChange: (value2) => onChange("description", value2),
|
|
1508
|
-
placeholder: config?.descPlaceholder ??
|
|
1458
|
+
placeholder: config?.descPlaceholder ?? import_editor14.I18n.t("Help LLM to understand the property")
|
|
1509
1459
|
}
|
|
1510
|
-
), $level === 0 &&
|
|
1460
|
+
), $level === 0 && /* @__PURE__ */ import_react20.default.createElement(import_react20.default.Fragment, null, /* @__PURE__ */ import_react20.default.createElement(UILabel, { style: { marginTop: 10 } }, config?.defaultValueTitle ?? import_editor14.I18n.t("Default Value")), /* @__PURE__ */ import_react20.default.createElement(DefaultValueWrapper, null, /* @__PURE__ */ import_react20.default.createElement(
|
|
1511
1461
|
DefaultValue,
|
|
1512
1462
|
{
|
|
1513
1463
|
value: defaultValue,
|
|
1514
1464
|
schema: value,
|
|
1515
1465
|
type,
|
|
1516
|
-
placeholder: config?.defaultValuePlaceholder ??
|
|
1466
|
+
placeholder: config?.defaultValuePlaceholder ?? import_editor14.I18n.t("Default Value"),
|
|
1517
1467
|
jsonFormatText: config?.jsonFormatText,
|
|
1518
1468
|
onChange: (value2) => onChange("default", value2)
|
|
1519
1469
|
}
|
|
1520
1470
|
))))
|
|
1521
|
-
), showCollapse && /* @__PURE__ */
|
|
1471
|
+
), showCollapse && /* @__PURE__ */ import_react20.default.createElement(UICollapsible, { $collapse: collapse }, /* @__PURE__ */ import_react20.default.createElement(UIProperties, { $shrink: true }, propertyList.map((_property, index) => /* @__PURE__ */ import_react20.default.createElement(
|
|
1522
1472
|
PropertyEdit,
|
|
1523
1473
|
{
|
|
1524
1474
|
readonly,
|
|
@@ -1543,21 +1493,21 @@ function PropertyEdit(props) {
|
|
|
1543
1493
|
}
|
|
1544
1494
|
|
|
1545
1495
|
// src/components/batch-variable-selector/index.tsx
|
|
1546
|
-
var
|
|
1547
|
-
var
|
|
1496
|
+
var import_react21 = __toESM(require("react"));
|
|
1497
|
+
var import_editor15 = require("@flowgram.ai/editor");
|
|
1548
1498
|
var batchVariableSchema = {
|
|
1549
1499
|
type: "array",
|
|
1550
1500
|
extra: { weak: true }
|
|
1551
1501
|
};
|
|
1552
1502
|
function BatchVariableSelector(props) {
|
|
1553
|
-
return /* @__PURE__ */
|
|
1503
|
+
return /* @__PURE__ */ import_react21.default.createElement(import_editor15.PrivateScopeProvider, null, /* @__PURE__ */ import_react21.default.createElement(VariableSelector, { ...props, includeSchema: batchVariableSchema }));
|
|
1554
1504
|
}
|
|
1555
1505
|
|
|
1556
1506
|
// src/components/dynamic-value-input/index.tsx
|
|
1557
|
-
var
|
|
1558
|
-
var
|
|
1559
|
-
var
|
|
1560
|
-
var
|
|
1507
|
+
var import_react23 = __toESM(require("react"));
|
|
1508
|
+
var import_json_schema6 = require("@flowgram.ai/json-schema");
|
|
1509
|
+
var import_semi_ui11 = require("@douyinfe/semi-ui");
|
|
1510
|
+
var import_semi_icons4 = require("@douyinfe/semi-icons");
|
|
1561
1511
|
|
|
1562
1512
|
// src/components/dynamic-value-input/styles.tsx
|
|
1563
1513
|
var import_styled_components4 = __toESM(require("styled-components"));
|
|
@@ -1605,11 +1555,11 @@ var UITrigger = import_styled_components4.default.div`
|
|
|
1605
1555
|
`;
|
|
1606
1556
|
|
|
1607
1557
|
// src/components/dynamic-value-input/hooks.ts
|
|
1608
|
-
var
|
|
1609
|
-
var
|
|
1558
|
+
var import_react22 = require("react");
|
|
1559
|
+
var import_editor16 = require("@flowgram.ai/editor");
|
|
1610
1560
|
function useRefVariable(value) {
|
|
1611
|
-
const available = (0,
|
|
1612
|
-
const refVariable = (0,
|
|
1561
|
+
const available = (0, import_editor16.useScopeAvailable)();
|
|
1562
|
+
const refVariable = (0, import_react22.useMemo)(() => {
|
|
1613
1563
|
if (value?.type === "ref") {
|
|
1614
1564
|
return available.getByKeyPath(value.content);
|
|
1615
1565
|
}
|
|
@@ -1621,11 +1571,11 @@ function useSelectSchema(schemaFromProps, constantProps, value) {
|
|
|
1621
1571
|
if (value?.type === "constant") {
|
|
1622
1572
|
defaultSelectSchema = value?.schema || defaultSelectSchema;
|
|
1623
1573
|
}
|
|
1624
|
-
const [selectSchema, setSelectSchema] = (0,
|
|
1574
|
+
const [selectSchema, setSelectSchema] = (0, import_react22.useState)(defaultSelectSchema);
|
|
1625
1575
|
return [selectSchema, setSelectSchema];
|
|
1626
1576
|
}
|
|
1627
1577
|
function useIncludeSchema(schemaFromProps) {
|
|
1628
|
-
const includeSchema = (0,
|
|
1578
|
+
const includeSchema = (0, import_react22.useMemo)(() => {
|
|
1629
1579
|
if (!schemaFromProps) {
|
|
1630
1580
|
return;
|
|
1631
1581
|
}
|
|
@@ -1651,13 +1601,13 @@ function DynamicValueInput({
|
|
|
1651
1601
|
const includeSchema = useIncludeSchema(schemaFromProps);
|
|
1652
1602
|
const renderTypeSelector = () => {
|
|
1653
1603
|
if (schemaFromProps) {
|
|
1654
|
-
return /* @__PURE__ */
|
|
1604
|
+
return /* @__PURE__ */ import_react23.default.createElement(TypeSelector, { value: schemaFromProps, readonly: true });
|
|
1655
1605
|
}
|
|
1656
1606
|
if (value?.type === "ref") {
|
|
1657
|
-
const schema = refVariable?.type ?
|
|
1658
|
-
return /* @__PURE__ */
|
|
1607
|
+
const schema = refVariable?.type ? import_json_schema6.JsonSchemaUtils.astToSchema(refVariable?.type) : void 0;
|
|
1608
|
+
return /* @__PURE__ */ import_react23.default.createElement(TypeSelector, { value: schema, readonly: true });
|
|
1659
1609
|
}
|
|
1660
|
-
return /* @__PURE__ */
|
|
1610
|
+
return /* @__PURE__ */ import_react23.default.createElement(
|
|
1661
1611
|
TypeSelector,
|
|
1662
1612
|
{
|
|
1663
1613
|
value: selectSchema,
|
|
@@ -1685,8 +1635,8 @@ function DynamicValueInput({
|
|
|
1685
1635
|
};
|
|
1686
1636
|
const renderMain = () => {
|
|
1687
1637
|
if (value?.type === "ref") {
|
|
1688
|
-
return /* @__PURE__ */
|
|
1689
|
-
|
|
1638
|
+
return /* @__PURE__ */ import_react23.default.createElement(
|
|
1639
|
+
InjectVariableSelector,
|
|
1690
1640
|
{
|
|
1691
1641
|
style: { width: "100%" },
|
|
1692
1642
|
value: value?.content,
|
|
@@ -1697,7 +1647,7 @@ function DynamicValueInput({
|
|
|
1697
1647
|
);
|
|
1698
1648
|
}
|
|
1699
1649
|
const constantSchema = schemaFromProps || selectSchema || { type: "string" };
|
|
1700
|
-
return /* @__PURE__ */
|
|
1650
|
+
return /* @__PURE__ */ import_react23.default.createElement(
|
|
1701
1651
|
ConstantInput,
|
|
1702
1652
|
{
|
|
1703
1653
|
value: value?.content,
|
|
@@ -1705,8 +1655,8 @@ function DynamicValueInput({
|
|
|
1705
1655
|
schema: constantSchema || { type: "string" },
|
|
1706
1656
|
readonly,
|
|
1707
1657
|
strategies: [...constantProps?.strategies || []],
|
|
1708
|
-
fallbackRenderer: () => /* @__PURE__ */
|
|
1709
|
-
|
|
1658
|
+
fallbackRenderer: () => /* @__PURE__ */ import_react23.default.createElement(
|
|
1659
|
+
InjectVariableSelector,
|
|
1710
1660
|
{
|
|
1711
1661
|
style: { width: "100%" },
|
|
1712
1662
|
onChange: (_v) => onChange(_v ? { type: "ref", content: _v } : void 0),
|
|
@@ -1718,24 +1668,26 @@ function DynamicValueInput({
|
|
|
1718
1668
|
}
|
|
1719
1669
|
);
|
|
1720
1670
|
};
|
|
1721
|
-
const renderTrigger = () => /* @__PURE__ */
|
|
1722
|
-
|
|
1671
|
+
const renderTrigger = () => /* @__PURE__ */ import_react23.default.createElement(
|
|
1672
|
+
InjectVariableSelector,
|
|
1723
1673
|
{
|
|
1724
1674
|
style: { width: "100%" },
|
|
1725
1675
|
value: value?.type === "ref" ? value?.content : void 0,
|
|
1726
1676
|
onChange: (_v) => onChange({ type: "ref", content: _v }),
|
|
1727
1677
|
includeSchema,
|
|
1728
1678
|
readonly,
|
|
1729
|
-
triggerRender: () => /* @__PURE__ */
|
|
1679
|
+
triggerRender: () => /* @__PURE__ */ import_react23.default.createElement(import_semi_ui11.IconButton, { disabled: readonly, size: "small", icon: /* @__PURE__ */ import_react23.default.createElement(import_semi_icons4.IconSetting, { size: "small" }) })
|
|
1730
1680
|
}
|
|
1731
1681
|
);
|
|
1732
|
-
return /* @__PURE__ */
|
|
1682
|
+
return /* @__PURE__ */ import_react23.default.createElement(UIContainer2, { style }, /* @__PURE__ */ import_react23.default.createElement(UIType2, null, renderTypeSelector()), /* @__PURE__ */ import_react23.default.createElement(UIMain, null, renderMain()), /* @__PURE__ */ import_react23.default.createElement(UITrigger, null, renderTrigger()));
|
|
1733
1683
|
}
|
|
1684
|
+
DynamicValueInput.renderKey = "dynamic-value-input-render-key";
|
|
1685
|
+
var InjectDynamicValueInput = createInjectMaterial(DynamicValueInput);
|
|
1734
1686
|
|
|
1735
1687
|
// src/components/condition-row/index.tsx
|
|
1736
|
-
var
|
|
1737
|
-
var
|
|
1738
|
-
var
|
|
1688
|
+
var import_react26 = __toESM(require("react"));
|
|
1689
|
+
var import_editor19 = require("@flowgram.ai/editor");
|
|
1690
|
+
var import_semi_ui13 = require("@douyinfe/semi-ui");
|
|
1739
1691
|
|
|
1740
1692
|
// src/components/condition-row/styles.tsx
|
|
1741
1693
|
var import_styled_components5 = __toESM(require("styled-components"));
|
|
@@ -1760,9 +1712,9 @@ var UIValues = import_styled_components5.default.div`
|
|
|
1760
1712
|
`;
|
|
1761
1713
|
|
|
1762
1714
|
// src/components/condition-row/hooks/useRule.ts
|
|
1763
|
-
var
|
|
1764
|
-
var
|
|
1765
|
-
var
|
|
1715
|
+
var import_react24 = require("react");
|
|
1716
|
+
var import_json_schema7 = require("@flowgram.ai/json-schema");
|
|
1717
|
+
var import_editor17 = require("@flowgram.ai/editor");
|
|
1766
1718
|
|
|
1767
1719
|
// src/components/condition-row/constants.ts
|
|
1768
1720
|
var defaultRules = {
|
|
@@ -1886,38 +1838,38 @@ var defaultOpConfigs = {
|
|
|
1886
1838
|
|
|
1887
1839
|
// src/components/condition-row/hooks/useRule.ts
|
|
1888
1840
|
function useRule(left, userRules) {
|
|
1889
|
-
const available = (0,
|
|
1890
|
-
const rules = (0,
|
|
1891
|
-
const variable = (0,
|
|
1841
|
+
const available = (0, import_editor17.useScopeAvailable)();
|
|
1842
|
+
const rules = (0, import_react24.useMemo)(() => ({ ...defaultRules, ...userRules || {} }), [userRules]);
|
|
1843
|
+
const variable = (0, import_react24.useMemo)(() => {
|
|
1892
1844
|
if (!left) return void 0;
|
|
1893
1845
|
return available.getByKeyPath(left.content);
|
|
1894
1846
|
}, [available, left]);
|
|
1895
|
-
const rule = (0,
|
|
1847
|
+
const rule = (0, import_react24.useMemo)(() => {
|
|
1896
1848
|
if (!variable) return void 0;
|
|
1897
|
-
const schema =
|
|
1849
|
+
const schema = import_json_schema7.JsonSchemaUtils.astToSchema(variable.type, { drilldown: false });
|
|
1898
1850
|
return rules[schema?.type];
|
|
1899
1851
|
}, [variable?.type, rules]);
|
|
1900
1852
|
return { rule };
|
|
1901
1853
|
}
|
|
1902
1854
|
|
|
1903
1855
|
// src/components/condition-row/hooks/useOp.tsx
|
|
1904
|
-
var
|
|
1905
|
-
var
|
|
1906
|
-
var
|
|
1907
|
-
var
|
|
1856
|
+
var import_react25 = __toESM(require("react"));
|
|
1857
|
+
var import_editor18 = require("@flowgram.ai/editor");
|
|
1858
|
+
var import_semi_ui12 = require("@douyinfe/semi-ui");
|
|
1859
|
+
var import_semi_icons5 = require("@douyinfe/semi-icons");
|
|
1908
1860
|
function useOp({ rule, op, onChange, readonly, userOps }) {
|
|
1909
|
-
const options = (0,
|
|
1861
|
+
const options = (0, import_react25.useMemo)(
|
|
1910
1862
|
() => Object.keys(rule || {}).map((_op) => ({
|
|
1911
1863
|
...defaultOpConfigs[_op] || {},
|
|
1912
1864
|
...userOps?.[_op] || {},
|
|
1913
1865
|
value: _op,
|
|
1914
|
-
label:
|
|
1866
|
+
label: import_editor18.I18n.t(userOps?.[_op]?.label || defaultOpConfigs[_op]?.label)
|
|
1915
1867
|
})),
|
|
1916
1868
|
[rule, userOps]
|
|
1917
1869
|
);
|
|
1918
|
-
const opConfig = (0,
|
|
1919
|
-
const renderOpSelect = () => /* @__PURE__ */
|
|
1920
|
-
|
|
1870
|
+
const opConfig = (0, import_react25.useMemo)(() => defaultOpConfigs[op], [op]);
|
|
1871
|
+
const renderOpSelect = () => /* @__PURE__ */ import_react25.default.createElement(
|
|
1872
|
+
import_semi_ui12.Select,
|
|
1921
1873
|
{
|
|
1922
1874
|
style: { height: 22 },
|
|
1923
1875
|
disabled: readonly,
|
|
@@ -1927,7 +1879,7 @@ function useOp({ rule, op, onChange, readonly, userOps }) {
|
|
|
1927
1879
|
onChange: (v) => {
|
|
1928
1880
|
onChange(v);
|
|
1929
1881
|
},
|
|
1930
|
-
triggerRender: ({ value }) => /* @__PURE__ */
|
|
1882
|
+
triggerRender: ({ value }) => /* @__PURE__ */ import_react25.default.createElement(import_semi_ui12.Button, { size: "small", disabled: !rule }, opConfig?.abbreviation || /* @__PURE__ */ import_react25.default.createElement(import_semi_icons5.IconChevronDownStroked, { size: "small" }))
|
|
1931
1883
|
}
|
|
1932
1884
|
);
|
|
1933
1885
|
return { renderOpSelect, opConfig };
|
|
@@ -1954,12 +1906,12 @@ function ConditionRow({
|
|
|
1954
1906
|
readonly,
|
|
1955
1907
|
userOps: ruleConfig.ops
|
|
1956
1908
|
});
|
|
1957
|
-
const targetSchema = (0,
|
|
1909
|
+
const targetSchema = (0, import_react26.useMemo)(() => {
|
|
1958
1910
|
const targetType = rule?.[operator || ""] || null;
|
|
1959
1911
|
return targetType ? { type: targetType, extra: { weak: true } } : null;
|
|
1960
1912
|
}, [rule, opConfig]);
|
|
1961
|
-
return /* @__PURE__ */
|
|
1962
|
-
|
|
1913
|
+
return /* @__PURE__ */ import_react26.default.createElement(UIContainer3, { style }, /* @__PURE__ */ import_react26.default.createElement(UIOperator, null, renderOpSelect()), /* @__PURE__ */ import_react26.default.createElement(UIValues, null, /* @__PURE__ */ import_react26.default.createElement(UILeft, null, /* @__PURE__ */ import_react26.default.createElement(
|
|
1914
|
+
InjectVariableSelector,
|
|
1963
1915
|
{
|
|
1964
1916
|
readonly,
|
|
1965
1917
|
style: { width: "100%" },
|
|
@@ -1972,34 +1924,34 @@ function ConditionRow({
|
|
|
1972
1924
|
}
|
|
1973
1925
|
})
|
|
1974
1926
|
}
|
|
1975
|
-
)), /* @__PURE__ */
|
|
1976
|
-
|
|
1927
|
+
)), /* @__PURE__ */ import_react26.default.createElement(UIRight, null, targetSchema ? /* @__PURE__ */ import_react26.default.createElement(
|
|
1928
|
+
InjectDynamicValueInput,
|
|
1977
1929
|
{
|
|
1978
1930
|
readonly: readonly || !rule,
|
|
1979
1931
|
value: right,
|
|
1980
1932
|
schema: targetSchema,
|
|
1981
1933
|
onChange: (v) => onChange({ ...value, right: v })
|
|
1982
1934
|
}
|
|
1983
|
-
) : /* @__PURE__ */
|
|
1984
|
-
|
|
1935
|
+
) : /* @__PURE__ */ import_react26.default.createElement(
|
|
1936
|
+
import_semi_ui13.Input,
|
|
1985
1937
|
{
|
|
1986
1938
|
size: "small",
|
|
1987
1939
|
disabled: true,
|
|
1988
1940
|
style: { pointerEvents: "none" },
|
|
1989
|
-
value: opConfig?.rightDisplay ||
|
|
1941
|
+
value: opConfig?.rightDisplay || import_editor19.I18n.t("Empty")
|
|
1990
1942
|
}
|
|
1991
1943
|
))));
|
|
1992
1944
|
}
|
|
1993
1945
|
|
|
1994
1946
|
// src/components/batch-outputs/index.tsx
|
|
1995
|
-
var
|
|
1996
|
-
var
|
|
1997
|
-
var
|
|
1947
|
+
var import_react28 = __toESM(require("react"));
|
|
1948
|
+
var import_semi_ui14 = require("@douyinfe/semi-ui");
|
|
1949
|
+
var import_semi_icons6 = require("@douyinfe/semi-icons");
|
|
1998
1950
|
|
|
1999
1951
|
// src/hooks/use-object-list/index.tsx
|
|
2000
|
-
var
|
|
1952
|
+
var import_react27 = require("react");
|
|
2001
1953
|
var import_nanoid = require("nanoid");
|
|
2002
|
-
var
|
|
1954
|
+
var import_lodash3 = require("lodash");
|
|
2003
1955
|
function genId2() {
|
|
2004
1956
|
return (0, import_nanoid.nanoid)();
|
|
2005
1957
|
}
|
|
@@ -2008,12 +1960,12 @@ function useObjectList({
|
|
|
2008
1960
|
onChange,
|
|
2009
1961
|
sortIndexKey
|
|
2010
1962
|
}) {
|
|
2011
|
-
const [list, setList] = (0,
|
|
2012
|
-
(0,
|
|
1963
|
+
const [list, setList] = (0, import_react27.useState)([]);
|
|
1964
|
+
(0, import_react27.useEffect)(() => {
|
|
2013
1965
|
setList((_prevList) => {
|
|
2014
|
-
const newKeys = Object.entries(value || {}).sort((a, b) => (0,
|
|
1966
|
+
const newKeys = Object.entries(value || {}).sort((a, b) => (0, import_lodash3.get)(a[1], sortIndexKey || 0) - (0, import_lodash3.get)(b[1], sortIndexKey || 0)).map(([key]) => key);
|
|
2015
1967
|
const oldKeys = _prevList.map((item) => item.key).filter(Boolean);
|
|
2016
|
-
const addKeys = (0,
|
|
1968
|
+
const addKeys = (0, import_lodash3.difference)(newKeys, oldKeys);
|
|
2017
1969
|
return _prevList.filter((item) => !item.key || newKeys.includes(item.key)).map((item) => ({
|
|
2018
1970
|
id: item.id,
|
|
2019
1971
|
key: item.key,
|
|
@@ -2049,8 +2001,8 @@ function useObjectList({
|
|
|
2049
2001
|
onChange(
|
|
2050
2002
|
Object.fromEntries(
|
|
2051
2003
|
nextList.filter((item) => item.key).map((item) => [item.key, item.value]).map((_res, idx) => {
|
|
2052
|
-
if ((0,
|
|
2053
|
-
(0,
|
|
2004
|
+
if ((0, import_lodash3.isObject)(_res[1]) && sortIndexKey) {
|
|
2005
|
+
(0, import_lodash3.set)(_res[1], sortIndexKey, idx);
|
|
2054
2006
|
}
|
|
2055
2007
|
return _res;
|
|
2056
2008
|
})
|
|
@@ -2110,8 +2062,8 @@ var UIRow2 = import_styled_components6.default.div`
|
|
|
2110
2062
|
function BatchOutputs(props) {
|
|
2111
2063
|
const { readonly, style } = props;
|
|
2112
2064
|
const { list, add, updateKey, updateValue, remove } = useObjectList(props);
|
|
2113
|
-
return /* @__PURE__ */
|
|
2114
|
-
|
|
2065
|
+
return /* @__PURE__ */ import_react28.default.createElement("div", null, /* @__PURE__ */ import_react28.default.createElement(UIRows, { style }, list.map((item) => /* @__PURE__ */ import_react28.default.createElement(UIRow2, { key: item.id }, /* @__PURE__ */ import_react28.default.createElement(
|
|
2066
|
+
import_semi_ui14.Input,
|
|
2115
2067
|
{
|
|
2116
2068
|
style: { width: 100 },
|
|
2117
2069
|
disabled: readonly,
|
|
@@ -2119,28 +2071,28 @@ function BatchOutputs(props) {
|
|
|
2119
2071
|
value: item.key,
|
|
2120
2072
|
onChange: (v) => updateKey(item.id, v)
|
|
2121
2073
|
}
|
|
2122
|
-
), /* @__PURE__ */
|
|
2123
|
-
|
|
2074
|
+
), /* @__PURE__ */ import_react28.default.createElement(
|
|
2075
|
+
InjectVariableSelector,
|
|
2124
2076
|
{
|
|
2125
2077
|
style: { flexGrow: 1 },
|
|
2126
2078
|
readonly,
|
|
2127
2079
|
value: item.value?.content,
|
|
2128
2080
|
onChange: (v) => updateValue(item.id, { type: "ref", content: v })
|
|
2129
2081
|
}
|
|
2130
|
-
), /* @__PURE__ */
|
|
2131
|
-
|
|
2082
|
+
), /* @__PURE__ */ import_react28.default.createElement(
|
|
2083
|
+
import_semi_ui14.Button,
|
|
2132
2084
|
{
|
|
2133
2085
|
disabled: readonly,
|
|
2134
|
-
icon: /* @__PURE__ */
|
|
2086
|
+
icon: /* @__PURE__ */ import_react28.default.createElement(import_semi_icons6.IconDelete, null),
|
|
2135
2087
|
size: "small",
|
|
2136
2088
|
onClick: () => remove(item.id)
|
|
2137
2089
|
}
|
|
2138
|
-
)))), /* @__PURE__ */
|
|
2090
|
+
)))), /* @__PURE__ */ import_react28.default.createElement(import_semi_ui14.Button, { disabled: readonly, icon: /* @__PURE__ */ import_react28.default.createElement(import_semi_icons6.IconPlus, null), size: "small", onClick: add }, "Add"));
|
|
2139
2091
|
}
|
|
2140
2092
|
|
|
2141
2093
|
// src/components/prompt-editor/index.tsx
|
|
2142
|
-
var
|
|
2143
|
-
var
|
|
2094
|
+
var import_react35 = __toESM(require("react"));
|
|
2095
|
+
var import_react36 = require("@coze-editor/editor/react");
|
|
2144
2096
|
var import_preset_prompt2 = __toESM(require("@coze-editor/editor/preset-prompt"));
|
|
2145
2097
|
|
|
2146
2098
|
// src/components/prompt-editor/styles.tsx
|
|
@@ -2156,15 +2108,15 @@ var UIContainer4 = import_styled_components7.default.div`
|
|
|
2156
2108
|
`;
|
|
2157
2109
|
|
|
2158
2110
|
// src/components/prompt-editor/extensions/markdown.tsx
|
|
2159
|
-
var
|
|
2160
|
-
var
|
|
2161
|
-
var
|
|
2111
|
+
var import_react29 = require("react");
|
|
2112
|
+
var import_react30 = require("@coze-editor/editor/react");
|
|
2113
|
+
var import_editor20 = require("@coze-editor/editor");
|
|
2162
2114
|
var import_view2 = require("@codemirror/view");
|
|
2163
2115
|
function MarkdownHighlight() {
|
|
2164
|
-
const injector = (0,
|
|
2165
|
-
(0,
|
|
2116
|
+
const injector = (0, import_react30.useInjector)();
|
|
2117
|
+
(0, import_react29.useLayoutEffect)(
|
|
2166
2118
|
() => injector.inject([
|
|
2167
|
-
|
|
2119
|
+
import_editor20.astDecorator.whole.of((cursor) => {
|
|
2168
2120
|
if (cursor.name.startsWith("ATXHeading")) {
|
|
2169
2121
|
return {
|
|
2170
2122
|
type: "className",
|
|
@@ -2213,26 +2165,26 @@ function MarkdownHighlight() {
|
|
|
2213
2165
|
var markdown_default = MarkdownHighlight;
|
|
2214
2166
|
|
|
2215
2167
|
// src/components/prompt-editor/extensions/language-support.tsx
|
|
2216
|
-
var
|
|
2217
|
-
var
|
|
2168
|
+
var import_react31 = require("react");
|
|
2169
|
+
var import_react32 = require("@coze-editor/editor/react");
|
|
2218
2170
|
var import_preset_prompt = require("@coze-editor/editor/preset-prompt");
|
|
2219
2171
|
function LanguageSupport() {
|
|
2220
|
-
const injector = (0,
|
|
2221
|
-
(0,
|
|
2172
|
+
const injector = (0, import_react32.useInjector)();
|
|
2173
|
+
(0, import_react31.useLayoutEffect)(() => injector.inject([import_preset_prompt.languageSupport]), [injector]);
|
|
2222
2174
|
return null;
|
|
2223
2175
|
}
|
|
2224
2176
|
var language_support_default = LanguageSupport;
|
|
2225
2177
|
|
|
2226
2178
|
// src/components/prompt-editor/extensions/jinja.tsx
|
|
2227
|
-
var
|
|
2228
|
-
var
|
|
2229
|
-
var
|
|
2179
|
+
var import_react33 = require("react");
|
|
2180
|
+
var import_react34 = require("@coze-editor/editor/react");
|
|
2181
|
+
var import_editor21 = require("@coze-editor/editor");
|
|
2230
2182
|
var import_view3 = require("@codemirror/view");
|
|
2231
2183
|
function JinjaHighlight() {
|
|
2232
|
-
const injector = (0,
|
|
2233
|
-
(0,
|
|
2184
|
+
const injector = (0, import_react34.useInjector)();
|
|
2185
|
+
(0, import_react33.useLayoutEffect)(
|
|
2234
2186
|
() => injector.inject([
|
|
2235
|
-
|
|
2187
|
+
import_editor21.astDecorator.whole.of((cursor) => {
|
|
2236
2188
|
if (cursor.name === "JinjaStatementStart" || cursor.name === "JinjaStatementEnd") {
|
|
2237
2189
|
return {
|
|
2238
2190
|
type: "className",
|
|
@@ -2283,14 +2235,14 @@ function PromptEditor(props) {
|
|
|
2283
2235
|
children,
|
|
2284
2236
|
disableMarkdownHighlight
|
|
2285
2237
|
} = props || {};
|
|
2286
|
-
const editorRef = (0,
|
|
2287
|
-
(0,
|
|
2238
|
+
const editorRef = (0, import_react35.useRef)(null);
|
|
2239
|
+
(0, import_react35.useEffect)(() => {
|
|
2288
2240
|
if (editorRef.current?.getValue() !== value?.content) {
|
|
2289
2241
|
editorRef.current?.setValue(String(value?.content || ""));
|
|
2290
2242
|
}
|
|
2291
2243
|
}, [value]);
|
|
2292
|
-
return /* @__PURE__ */
|
|
2293
|
-
|
|
2244
|
+
return /* @__PURE__ */ import_react35.default.createElement(UIContainer4, { $hasError: hasError, style }, /* @__PURE__ */ import_react35.default.createElement(import_react36.EditorProvider, null, /* @__PURE__ */ import_react35.default.createElement(
|
|
2245
|
+
import_react36.Renderer,
|
|
2294
2246
|
{
|
|
2295
2247
|
didMount: (editor) => {
|
|
2296
2248
|
editorRef.current = editor;
|
|
@@ -2306,23 +2258,23 @@ function PromptEditor(props) {
|
|
|
2306
2258
|
onChange({ type: "template", content: e.value });
|
|
2307
2259
|
}
|
|
2308
2260
|
}
|
|
2309
|
-
), activeLinePlaceholder && /* @__PURE__ */
|
|
2261
|
+
), activeLinePlaceholder && /* @__PURE__ */ import_react35.default.createElement(import_react36.ActiveLinePlaceholder, null, activeLinePlaceholder), !disableMarkdownHighlight && /* @__PURE__ */ import_react35.default.createElement(markdown_default, null), /* @__PURE__ */ import_react35.default.createElement(language_support_default, null), /* @__PURE__ */ import_react35.default.createElement(jinja_default, null), children));
|
|
2310
2262
|
}
|
|
2311
2263
|
|
|
2312
2264
|
// src/components/prompt-editor-with-variables/index.tsx
|
|
2313
|
-
var
|
|
2265
|
+
var import_react41 = __toESM(require("react"));
|
|
2314
2266
|
|
|
2315
2267
|
// src/components/prompt-editor-with-variables/extensions/variable-tree.tsx
|
|
2316
|
-
var
|
|
2317
|
-
var
|
|
2318
|
-
var
|
|
2268
|
+
var import_react37 = __toESM(require("react"));
|
|
2269
|
+
var import_semi_ui15 = require("@douyinfe/semi-ui");
|
|
2270
|
+
var import_react38 = require("@coze-editor/editor/react");
|
|
2319
2271
|
function VariableTree() {
|
|
2320
|
-
const [posKey, setPosKey] = (0,
|
|
2321
|
-
const [visible, setVisible] = (0,
|
|
2322
|
-
const [position, setPosition] = (0,
|
|
2323
|
-
const editor = (0,
|
|
2272
|
+
const [posKey, setPosKey] = (0, import_react37.useState)("");
|
|
2273
|
+
const [visible, setVisible] = (0, import_react37.useState)(false);
|
|
2274
|
+
const [position, setPosition] = (0, import_react37.useState)(-1);
|
|
2275
|
+
const editor = (0, import_react38.useEditor)();
|
|
2324
2276
|
function insert(variablePath) {
|
|
2325
|
-
const range = (0,
|
|
2277
|
+
const range = (0, import_react38.getCurrentMentionReplaceRange)(editor.$view.state);
|
|
2326
2278
|
if (!range) {
|
|
2327
2279
|
return;
|
|
2328
2280
|
}
|
|
@@ -2336,21 +2288,21 @@ function VariableTree() {
|
|
|
2336
2288
|
setPosition(e.state.selection.main.head);
|
|
2337
2289
|
setVisible(e.value);
|
|
2338
2290
|
}
|
|
2339
|
-
(0,
|
|
2291
|
+
(0, import_react37.useEffect)(() => {
|
|
2340
2292
|
if (!editor) {
|
|
2341
2293
|
return;
|
|
2342
2294
|
}
|
|
2343
2295
|
}, [editor, visible]);
|
|
2344
2296
|
const treeData = useVariableTree({});
|
|
2345
|
-
return /* @__PURE__ */
|
|
2346
|
-
|
|
2297
|
+
return /* @__PURE__ */ import_react37.default.createElement(import_react37.default.Fragment, null, /* @__PURE__ */ import_react37.default.createElement(import_react38.Mention, { triggerCharacters: ["{", "{}", "@"], onOpenChange: handleOpenChange }), /* @__PURE__ */ import_react37.default.createElement(
|
|
2298
|
+
import_semi_ui15.Popover,
|
|
2347
2299
|
{
|
|
2348
2300
|
visible,
|
|
2349
2301
|
trigger: "custom",
|
|
2350
2302
|
position: "topLeft",
|
|
2351
2303
|
rePosKey: posKey,
|
|
2352
|
-
content: /* @__PURE__ */
|
|
2353
|
-
|
|
2304
|
+
content: /* @__PURE__ */ import_react37.default.createElement("div", { style: { width: 300 } }, /* @__PURE__ */ import_react37.default.createElement(
|
|
2305
|
+
import_semi_ui15.Tree,
|
|
2354
2306
|
{
|
|
2355
2307
|
treeData,
|
|
2356
2308
|
onSelect: (v) => {
|
|
@@ -2359,8 +2311,8 @@ function VariableTree() {
|
|
|
2359
2311
|
}
|
|
2360
2312
|
))
|
|
2361
2313
|
},
|
|
2362
|
-
/* @__PURE__ */
|
|
2363
|
-
|
|
2314
|
+
/* @__PURE__ */ import_react37.default.createElement(
|
|
2315
|
+
import_react38.PositionMirror,
|
|
2364
2316
|
{
|
|
2365
2317
|
position,
|
|
2366
2318
|
onChange: () => setPosKey(String(Math.random()))
|
|
@@ -2371,17 +2323,17 @@ function VariableTree() {
|
|
|
2371
2323
|
|
|
2372
2324
|
// src/components/prompt-editor-with-variables/extensions/variable-tag.tsx
|
|
2373
2325
|
var import_react_dom = __toESM(require("react-dom"));
|
|
2374
|
-
var
|
|
2375
|
-
var
|
|
2376
|
-
var
|
|
2377
|
-
var
|
|
2378
|
-
var
|
|
2379
|
-
var
|
|
2326
|
+
var import_react39 = __toESM(require("react"));
|
|
2327
|
+
var import_lodash4 = require("lodash");
|
|
2328
|
+
var import_editor22 = require("@flowgram.ai/editor");
|
|
2329
|
+
var import_semi_ui17 = require("@douyinfe/semi-ui");
|
|
2330
|
+
var import_semi_icons7 = require("@douyinfe/semi-icons");
|
|
2331
|
+
var import_react40 = require("@coze-editor/editor/react");
|
|
2380
2332
|
var import_view4 = require("@codemirror/view");
|
|
2381
2333
|
|
|
2382
2334
|
// src/components/prompt-editor-with-variables/styles.tsx
|
|
2383
2335
|
var import_styled_components8 = __toESM(require("styled-components"));
|
|
2384
|
-
var
|
|
2336
|
+
var import_semi_ui16 = require("@douyinfe/semi-ui");
|
|
2385
2337
|
var UIRootTitle2 = import_styled_components8.default.div`
|
|
2386
2338
|
margin-right: 4px;
|
|
2387
2339
|
min-width: 20px;
|
|
@@ -2395,7 +2347,7 @@ var UIVarName2 = import_styled_components8.default.div`
|
|
|
2395
2347
|
text-overflow: ellipsis;
|
|
2396
2348
|
white-space: nowrap;
|
|
2397
2349
|
`;
|
|
2398
|
-
var UITag2 = (0, import_styled_components8.default)(
|
|
2350
|
+
var UITag2 = (0, import_styled_components8.default)(import_semi_ui16.Tag)`
|
|
2399
2351
|
display: inline-flex;
|
|
2400
2352
|
align-items: center;
|
|
2401
2353
|
justify-content: flex-start;
|
|
@@ -2420,10 +2372,10 @@ var UIPopoverContent2 = import_styled_components8.default.div`
|
|
|
2420
2372
|
var VariableTagWidget = class extends import_view4.WidgetType {
|
|
2421
2373
|
constructor({ keyPath, scope }) {
|
|
2422
2374
|
super();
|
|
2423
|
-
this.toDispose = new
|
|
2375
|
+
this.toDispose = new import_editor22.DisposableCollection();
|
|
2424
2376
|
this.renderIcon = (icon) => {
|
|
2425
2377
|
if (typeof icon === "string") {
|
|
2426
|
-
return /* @__PURE__ */
|
|
2378
|
+
return /* @__PURE__ */ import_react39.default.createElement("img", { style: { marginRight: 8 }, width: 12, height: 12, src: icon });
|
|
2427
2379
|
}
|
|
2428
2380
|
return icon;
|
|
2429
2381
|
};
|
|
@@ -2436,21 +2388,21 @@ var VariableTagWidget = class extends import_view4.WidgetType {
|
|
|
2436
2388
|
renderVariable(v) {
|
|
2437
2389
|
if (!v) {
|
|
2438
2390
|
this.renderReact(
|
|
2439
|
-
/* @__PURE__ */
|
|
2391
|
+
/* @__PURE__ */ import_react39.default.createElement(UITag2, { prefixIcon: /* @__PURE__ */ import_react39.default.createElement(import_semi_icons7.IconIssueStroked, null), color: "amber" }, "Unknown")
|
|
2440
2392
|
);
|
|
2441
2393
|
return;
|
|
2442
2394
|
}
|
|
2443
|
-
const rootField = (0,
|
|
2395
|
+
const rootField = (0, import_lodash4.last)(v.parentFields) || v;
|
|
2444
2396
|
const isRoot = v.parentFields.length === 0;
|
|
2445
|
-
const rootTitle = /* @__PURE__ */
|
|
2397
|
+
const rootTitle = /* @__PURE__ */ import_react39.default.createElement(UIRootTitle2, null, rootField?.meta.title ? `${rootField.meta.title} ${isRoot ? "" : "-"} ` : "");
|
|
2446
2398
|
const rootIcon = this.renderIcon(rootField?.meta.icon);
|
|
2447
2399
|
this.renderReact(
|
|
2448
|
-
/* @__PURE__ */
|
|
2449
|
-
|
|
2400
|
+
/* @__PURE__ */ import_react39.default.createElement(
|
|
2401
|
+
import_semi_ui17.Popover,
|
|
2450
2402
|
{
|
|
2451
|
-
content: /* @__PURE__ */
|
|
2403
|
+
content: /* @__PURE__ */ import_react39.default.createElement(UIPopoverContent2, null, rootIcon, rootTitle, /* @__PURE__ */ import_react39.default.createElement(UIVarName2, null, v?.keyPath.slice(1).join(".")))
|
|
2452
2404
|
},
|
|
2453
|
-
/* @__PURE__ */
|
|
2405
|
+
/* @__PURE__ */ import_react39.default.createElement(UITag2, { prefixIcon: rootIcon }, rootTitle, !isRoot && /* @__PURE__ */ import_react39.default.createElement(UIVarName2, null, v?.key))
|
|
2454
2406
|
)
|
|
2455
2407
|
);
|
|
2456
2408
|
}
|
|
@@ -2458,7 +2410,7 @@ var VariableTagWidget = class extends import_view4.WidgetType {
|
|
|
2458
2410
|
const dom = document.createElement("span");
|
|
2459
2411
|
this.rootDOM = dom;
|
|
2460
2412
|
this.toDispose.push(
|
|
2461
|
-
|
|
2413
|
+
import_editor22.Disposable.create(() => {
|
|
2462
2414
|
import_react_dom.default.unmountComponentAtNode(this.rootDOM);
|
|
2463
2415
|
})
|
|
2464
2416
|
);
|
|
@@ -2475,7 +2427,7 @@ var VariableTagWidget = class extends import_view4.WidgetType {
|
|
|
2475
2427
|
return dom;
|
|
2476
2428
|
}
|
|
2477
2429
|
eq(other) {
|
|
2478
|
-
return (0,
|
|
2430
|
+
return (0, import_lodash4.isEqual)(this.keyPath, other.keyPath);
|
|
2479
2431
|
}
|
|
2480
2432
|
ignoreEvent() {
|
|
2481
2433
|
return false;
|
|
@@ -2485,9 +2437,9 @@ var VariableTagWidget = class extends import_view4.WidgetType {
|
|
|
2485
2437
|
}
|
|
2486
2438
|
};
|
|
2487
2439
|
function VariableTagInject() {
|
|
2488
|
-
const injector = (0,
|
|
2489
|
-
const scope = (0,
|
|
2490
|
-
(0,
|
|
2440
|
+
const injector = (0, import_react40.useInjector)();
|
|
2441
|
+
const scope = (0, import_editor22.useCurrentScope)();
|
|
2442
|
+
(0, import_react39.useLayoutEffect)(() => {
|
|
2491
2443
|
const atMatcher = new import_view4.MatchDecorator({
|
|
2492
2444
|
regexp: /\{\{([^\}]+)\}\}/g,
|
|
2493
2445
|
decoration: (match) => import_view4.Decoration.replace({
|
|
@@ -2524,29 +2476,29 @@ function VariableTagInject() {
|
|
|
2524
2476
|
|
|
2525
2477
|
// src/components/prompt-editor-with-variables/index.tsx
|
|
2526
2478
|
function PromptEditorWithVariables(props) {
|
|
2527
|
-
return /* @__PURE__ */
|
|
2479
|
+
return /* @__PURE__ */ import_react41.default.createElement(PromptEditor, { ...props }, /* @__PURE__ */ import_react41.default.createElement(VariableTree, null), /* @__PURE__ */ import_react41.default.createElement(VariableTagInject, null));
|
|
2528
2480
|
}
|
|
2529
2481
|
|
|
2530
2482
|
// src/components/prompt-editor-with-inputs/index.tsx
|
|
2531
|
-
var
|
|
2483
|
+
var import_react45 = __toESM(require("react"));
|
|
2532
2484
|
|
|
2533
2485
|
// src/components/prompt-editor-with-inputs/extensions/inputs-tree.tsx
|
|
2534
|
-
var
|
|
2535
|
-
var
|
|
2536
|
-
var
|
|
2486
|
+
var import_react43 = __toESM(require("react"));
|
|
2487
|
+
var import_semi_ui19 = require("@douyinfe/semi-ui");
|
|
2488
|
+
var import_react44 = require("@coze-editor/editor/react");
|
|
2537
2489
|
|
|
2538
2490
|
// src/components/prompt-editor-with-inputs/inputs-picker.tsx
|
|
2539
|
-
var
|
|
2540
|
-
var
|
|
2541
|
-
var
|
|
2542
|
-
var
|
|
2491
|
+
var import_react42 = __toESM(require("react"));
|
|
2492
|
+
var import_lodash5 = require("lodash");
|
|
2493
|
+
var import_editor23 = require("@flowgram.ai/editor");
|
|
2494
|
+
var import_semi_ui18 = require("@douyinfe/semi-ui");
|
|
2543
2495
|
function InputsPicker({
|
|
2544
2496
|
inputsValues,
|
|
2545
2497
|
onSelect
|
|
2546
2498
|
}) {
|
|
2547
|
-
const available = (0,
|
|
2499
|
+
const available = (0, import_editor23.useScopeAvailable)();
|
|
2548
2500
|
const getArrayDrilldown = (type, depth = 1) => {
|
|
2549
|
-
if (
|
|
2501
|
+
if (import_editor23.ASTMatch.isArray(type.items)) {
|
|
2550
2502
|
return getArrayDrilldown(type.items, depth + 1);
|
|
2551
2503
|
}
|
|
2552
2504
|
return { type: type.items, depth };
|
|
@@ -2554,12 +2506,12 @@ function InputsPicker({
|
|
|
2554
2506
|
const renderVariable = (variable, keyPath) => {
|
|
2555
2507
|
let type = variable?.type;
|
|
2556
2508
|
let children;
|
|
2557
|
-
if (
|
|
2509
|
+
if (import_editor23.ASTMatch.isObject(type)) {
|
|
2558
2510
|
children = (type.properties || []).map((_property) => renderVariable(_property, [...keyPath, _property.key])).filter(Boolean);
|
|
2559
2511
|
}
|
|
2560
|
-
if (
|
|
2512
|
+
if (import_editor23.ASTMatch.isArray(type)) {
|
|
2561
2513
|
const drilldown = getArrayDrilldown(type);
|
|
2562
|
-
if (
|
|
2514
|
+
if (import_editor23.ASTMatch.isObject(drilldown.type)) {
|
|
2563
2515
|
children = (drilldown.type.properties || []).map(
|
|
2564
2516
|
(_property) => renderVariable(_property, [
|
|
2565
2517
|
...keyPath,
|
|
@@ -2572,12 +2524,12 @@ function InputsPicker({
|
|
|
2572
2524
|
const key = keyPath.map((_key, idx) => _key === "[0]" || idx === 0 ? _key : `.${_key}`).join("");
|
|
2573
2525
|
return {
|
|
2574
2526
|
key,
|
|
2575
|
-
label: (0,
|
|
2527
|
+
label: (0, import_lodash5.last)(keyPath),
|
|
2576
2528
|
value: key,
|
|
2577
2529
|
children
|
|
2578
2530
|
};
|
|
2579
2531
|
};
|
|
2580
|
-
const treeData = (0,
|
|
2532
|
+
const treeData = (0, import_react42.useMemo)(
|
|
2581
2533
|
() => Object.entries(inputsValues).map(([key, value]) => {
|
|
2582
2534
|
if (value?.type === "ref") {
|
|
2583
2535
|
const variable = available.getByKeyPath(value.content || []);
|
|
@@ -2593,17 +2545,17 @@ function InputsPicker({
|
|
|
2593
2545
|
}),
|
|
2594
2546
|
[]
|
|
2595
2547
|
);
|
|
2596
|
-
return /* @__PURE__ */
|
|
2548
|
+
return /* @__PURE__ */ import_react42.default.createElement(import_semi_ui18.Tree, { treeData, onSelect: (v) => onSelect(v) });
|
|
2597
2549
|
}
|
|
2598
2550
|
|
|
2599
2551
|
// src/components/prompt-editor-with-inputs/extensions/inputs-tree.tsx
|
|
2600
2552
|
function InputsTree({ inputsValues }) {
|
|
2601
|
-
const [posKey, setPosKey] = (0,
|
|
2602
|
-
const [visible, setVisible] = (0,
|
|
2603
|
-
const [position, setPosition] = (0,
|
|
2604
|
-
const editor = (0,
|
|
2553
|
+
const [posKey, setPosKey] = (0, import_react43.useState)("");
|
|
2554
|
+
const [visible, setVisible] = (0, import_react43.useState)(false);
|
|
2555
|
+
const [position, setPosition] = (0, import_react43.useState)(-1);
|
|
2556
|
+
const editor = (0, import_react44.useEditor)();
|
|
2605
2557
|
function insert(variablePath) {
|
|
2606
|
-
const range = (0,
|
|
2558
|
+
const range = (0, import_react44.getCurrentMentionReplaceRange)(editor.$view.state);
|
|
2607
2559
|
if (!range) {
|
|
2608
2560
|
return;
|
|
2609
2561
|
}
|
|
@@ -2617,19 +2569,19 @@ function InputsTree({ inputsValues }) {
|
|
|
2617
2569
|
setPosition(e.state.selection.main.head);
|
|
2618
2570
|
setVisible(e.value);
|
|
2619
2571
|
}
|
|
2620
|
-
(0,
|
|
2572
|
+
(0, import_react43.useEffect)(() => {
|
|
2621
2573
|
if (!editor) {
|
|
2622
2574
|
return;
|
|
2623
2575
|
}
|
|
2624
2576
|
}, [editor, visible]);
|
|
2625
|
-
return /* @__PURE__ */
|
|
2626
|
-
|
|
2577
|
+
return /* @__PURE__ */ import_react43.default.createElement(import_react43.default.Fragment, null, /* @__PURE__ */ import_react43.default.createElement(import_react44.Mention, { triggerCharacters: ["{", "{}", "@"], onOpenChange: handleOpenChange }), /* @__PURE__ */ import_react43.default.createElement(
|
|
2578
|
+
import_semi_ui19.Popover,
|
|
2627
2579
|
{
|
|
2628
2580
|
visible,
|
|
2629
2581
|
trigger: "custom",
|
|
2630
2582
|
position: "topLeft",
|
|
2631
2583
|
rePosKey: posKey,
|
|
2632
|
-
content: /* @__PURE__ */
|
|
2584
|
+
content: /* @__PURE__ */ import_react43.default.createElement("div", { style: { width: 300 } }, /* @__PURE__ */ import_react43.default.createElement(
|
|
2633
2585
|
InputsPicker,
|
|
2634
2586
|
{
|
|
2635
2587
|
inputsValues,
|
|
@@ -2639,8 +2591,8 @@ function InputsTree({ inputsValues }) {
|
|
|
2639
2591
|
}
|
|
2640
2592
|
))
|
|
2641
2593
|
},
|
|
2642
|
-
/* @__PURE__ */
|
|
2643
|
-
|
|
2594
|
+
/* @__PURE__ */ import_react43.default.createElement(
|
|
2595
|
+
import_react44.PositionMirror,
|
|
2644
2596
|
{
|
|
2645
2597
|
position,
|
|
2646
2598
|
onChange: () => setPosKey(String(Math.random()))
|
|
@@ -2651,24 +2603,24 @@ function InputsTree({ inputsValues }) {
|
|
|
2651
2603
|
|
|
2652
2604
|
// src/components/prompt-editor-with-inputs/index.tsx
|
|
2653
2605
|
function PromptEditorWithInputs({ inputsValues, ...restProps }) {
|
|
2654
|
-
return /* @__PURE__ */
|
|
2606
|
+
return /* @__PURE__ */ import_react45.default.createElement(PromptEditor, { ...restProps }, /* @__PURE__ */ import_react45.default.createElement(InputsTree, { inputsValues }));
|
|
2655
2607
|
}
|
|
2656
2608
|
|
|
2657
2609
|
// src/components/json-editor-with-variables/index.tsx
|
|
2658
|
-
var
|
|
2610
|
+
var import_react50 = __toESM(require("react"));
|
|
2659
2611
|
var import_preset_code6 = require("@coze-editor/editor/preset-code");
|
|
2660
2612
|
|
|
2661
2613
|
// src/components/json-editor-with-variables/extensions/variable-tree.tsx
|
|
2662
|
-
var
|
|
2663
|
-
var
|
|
2664
|
-
var
|
|
2614
|
+
var import_react46 = __toESM(require("react"));
|
|
2615
|
+
var import_semi_ui20 = require("@douyinfe/semi-ui");
|
|
2616
|
+
var import_react47 = require("@coze-editor/editor/react");
|
|
2665
2617
|
function VariableTree2() {
|
|
2666
|
-
const [posKey, setPosKey] = (0,
|
|
2667
|
-
const [visible, setVisible] = (0,
|
|
2668
|
-
const [position, setPosition] = (0,
|
|
2669
|
-
const editor = (0,
|
|
2618
|
+
const [posKey, setPosKey] = (0, import_react46.useState)("");
|
|
2619
|
+
const [visible, setVisible] = (0, import_react46.useState)(false);
|
|
2620
|
+
const [position, setPosition] = (0, import_react46.useState)(-1);
|
|
2621
|
+
const editor = (0, import_react47.useEditor)();
|
|
2670
2622
|
function insert(variablePath) {
|
|
2671
|
-
const range = (0,
|
|
2623
|
+
const range = (0, import_react47.getCurrentMentionReplaceRange)(editor.$view.state);
|
|
2672
2624
|
if (!range) {
|
|
2673
2625
|
return;
|
|
2674
2626
|
}
|
|
@@ -2682,21 +2634,21 @@ function VariableTree2() {
|
|
|
2682
2634
|
setPosition(e.state.selection.main.head);
|
|
2683
2635
|
setVisible(e.value);
|
|
2684
2636
|
}
|
|
2685
|
-
(0,
|
|
2637
|
+
(0, import_react46.useEffect)(() => {
|
|
2686
2638
|
if (!editor) {
|
|
2687
2639
|
return;
|
|
2688
2640
|
}
|
|
2689
2641
|
}, [editor, visible]);
|
|
2690
2642
|
const treeData = useVariableTree({});
|
|
2691
|
-
return /* @__PURE__ */
|
|
2692
|
-
|
|
2643
|
+
return /* @__PURE__ */ import_react46.default.createElement(import_react46.default.Fragment, null, /* @__PURE__ */ import_react46.default.createElement(import_react47.Mention, { triggerCharacters: ["@"], onOpenChange: handleOpenChange }), /* @__PURE__ */ import_react46.default.createElement(
|
|
2644
|
+
import_semi_ui20.Popover,
|
|
2693
2645
|
{
|
|
2694
2646
|
visible,
|
|
2695
2647
|
trigger: "custom",
|
|
2696
2648
|
position: "topLeft",
|
|
2697
2649
|
rePosKey: posKey,
|
|
2698
|
-
content: /* @__PURE__ */
|
|
2699
|
-
|
|
2650
|
+
content: /* @__PURE__ */ import_react46.default.createElement("div", { style: { width: 300 } }, /* @__PURE__ */ import_react46.default.createElement(
|
|
2651
|
+
import_semi_ui20.Tree,
|
|
2700
2652
|
{
|
|
2701
2653
|
treeData,
|
|
2702
2654
|
onSelect: (v) => {
|
|
@@ -2705,8 +2657,8 @@ function VariableTree2() {
|
|
|
2705
2657
|
}
|
|
2706
2658
|
))
|
|
2707
2659
|
},
|
|
2708
|
-
/* @__PURE__ */
|
|
2709
|
-
|
|
2660
|
+
/* @__PURE__ */ import_react46.default.createElement(
|
|
2661
|
+
import_react47.PositionMirror,
|
|
2710
2662
|
{
|
|
2711
2663
|
position,
|
|
2712
2664
|
onChange: () => setPosKey(String(Math.random()))
|
|
@@ -2716,18 +2668,18 @@ function VariableTree2() {
|
|
|
2716
2668
|
}
|
|
2717
2669
|
|
|
2718
2670
|
// src/components/json-editor-with-variables/extensions/variable-tag.tsx
|
|
2719
|
-
var
|
|
2671
|
+
var import_react48 = __toESM(require("react"));
|
|
2720
2672
|
var import_client = require("react-dom/client");
|
|
2721
|
-
var
|
|
2722
|
-
var
|
|
2723
|
-
var
|
|
2724
|
-
var
|
|
2725
|
-
var
|
|
2673
|
+
var import_lodash6 = require("lodash");
|
|
2674
|
+
var import_editor24 = require("@flowgram.ai/editor");
|
|
2675
|
+
var import_semi_ui22 = require("@douyinfe/semi-ui");
|
|
2676
|
+
var import_semi_icons8 = require("@douyinfe/semi-icons");
|
|
2677
|
+
var import_react49 = require("@coze-editor/editor/react");
|
|
2726
2678
|
var import_view5 = require("@codemirror/view");
|
|
2727
2679
|
|
|
2728
2680
|
// src/components/json-editor-with-variables/styles.tsx
|
|
2729
2681
|
var import_styled_components9 = __toESM(require("styled-components"));
|
|
2730
|
-
var
|
|
2682
|
+
var import_semi_ui21 = require("@douyinfe/semi-ui");
|
|
2731
2683
|
var UIRootTitle3 = import_styled_components9.default.div`
|
|
2732
2684
|
margin-right: 4px;
|
|
2733
2685
|
min-width: 20px;
|
|
@@ -2741,7 +2693,7 @@ var UIVarName3 = import_styled_components9.default.div`
|
|
|
2741
2693
|
text-overflow: ellipsis;
|
|
2742
2694
|
white-space: nowrap;
|
|
2743
2695
|
`;
|
|
2744
|
-
var UITag3 = (0, import_styled_components9.default)(
|
|
2696
|
+
var UITag3 = (0, import_styled_components9.default)(import_semi_ui21.Tag)`
|
|
2745
2697
|
display: inline-flex;
|
|
2746
2698
|
align-items: center;
|
|
2747
2699
|
justify-content: flex-start;
|
|
@@ -2766,10 +2718,10 @@ var UIPopoverContent3 = import_styled_components9.default.div`
|
|
|
2766
2718
|
var VariableTagWidget2 = class extends import_view5.WidgetType {
|
|
2767
2719
|
constructor({ keyPath, scope }) {
|
|
2768
2720
|
super();
|
|
2769
|
-
this.toDispose = new
|
|
2721
|
+
this.toDispose = new import_editor24.DisposableCollection();
|
|
2770
2722
|
this.renderIcon = (icon) => {
|
|
2771
2723
|
if (typeof icon === "string") {
|
|
2772
|
-
return /* @__PURE__ */
|
|
2724
|
+
return /* @__PURE__ */ import_react48.default.createElement("img", { style: { marginRight: 8 }, width: 12, height: 12, src: icon });
|
|
2773
2725
|
}
|
|
2774
2726
|
return icon;
|
|
2775
2727
|
};
|
|
@@ -2779,20 +2731,20 @@ var VariableTagWidget2 = class extends import_view5.WidgetType {
|
|
|
2779
2731
|
renderVariable(v) {
|
|
2780
2732
|
if (!v) {
|
|
2781
2733
|
this.root.render(
|
|
2782
|
-
/* @__PURE__ */
|
|
2734
|
+
/* @__PURE__ */ import_react48.default.createElement(UITag3, { prefixIcon: /* @__PURE__ */ import_react48.default.createElement(import_semi_icons8.IconIssueStroked, null), color: "amber" }, "Unknown")
|
|
2783
2735
|
);
|
|
2784
2736
|
return;
|
|
2785
2737
|
}
|
|
2786
|
-
const rootField = (0,
|
|
2787
|
-
const rootTitle = /* @__PURE__ */
|
|
2738
|
+
const rootField = (0, import_lodash6.last)(v.parentFields);
|
|
2739
|
+
const rootTitle = /* @__PURE__ */ import_react48.default.createElement(UIRootTitle3, null, rootField?.meta.title ? `${rootField.meta.title} -` : "");
|
|
2788
2740
|
const rootIcon = this.renderIcon(rootField?.meta.icon);
|
|
2789
2741
|
this.root.render(
|
|
2790
|
-
/* @__PURE__ */
|
|
2791
|
-
|
|
2742
|
+
/* @__PURE__ */ import_react48.default.createElement(
|
|
2743
|
+
import_semi_ui22.Popover,
|
|
2792
2744
|
{
|
|
2793
|
-
content: /* @__PURE__ */
|
|
2745
|
+
content: /* @__PURE__ */ import_react48.default.createElement(UIPopoverContent3, null, rootIcon, rootTitle, /* @__PURE__ */ import_react48.default.createElement(UIVarName3, null, v?.keyPath.slice(1).join(".")))
|
|
2794
2746
|
},
|
|
2795
|
-
/* @__PURE__ */
|
|
2747
|
+
/* @__PURE__ */ import_react48.default.createElement(UITag3, { prefixIcon: rootIcon }, rootTitle, /* @__PURE__ */ import_react48.default.createElement(UIVarName3, null, v?.key))
|
|
2796
2748
|
)
|
|
2797
2749
|
);
|
|
2798
2750
|
}
|
|
@@ -2800,7 +2752,7 @@ var VariableTagWidget2 = class extends import_view5.WidgetType {
|
|
|
2800
2752
|
const dom = document.createElement("span");
|
|
2801
2753
|
this.root = (0, import_client.createRoot)(dom);
|
|
2802
2754
|
this.toDispose.push(
|
|
2803
|
-
|
|
2755
|
+
import_editor24.Disposable.create(() => {
|
|
2804
2756
|
this.root.unmount();
|
|
2805
2757
|
})
|
|
2806
2758
|
);
|
|
@@ -2817,7 +2769,7 @@ var VariableTagWidget2 = class extends import_view5.WidgetType {
|
|
|
2817
2769
|
return dom;
|
|
2818
2770
|
}
|
|
2819
2771
|
eq(other) {
|
|
2820
|
-
return (0,
|
|
2772
|
+
return (0, import_lodash6.isEqual)(this.keyPath, other.keyPath);
|
|
2821
2773
|
}
|
|
2822
2774
|
ignoreEvent() {
|
|
2823
2775
|
return false;
|
|
@@ -2827,9 +2779,9 @@ var VariableTagWidget2 = class extends import_view5.WidgetType {
|
|
|
2827
2779
|
}
|
|
2828
2780
|
};
|
|
2829
2781
|
function VariableTagInject2() {
|
|
2830
|
-
const injector = (0,
|
|
2831
|
-
const scope = (0,
|
|
2832
|
-
(0,
|
|
2782
|
+
const injector = (0, import_react49.useInjector)();
|
|
2783
|
+
const scope = (0, import_editor24.useCurrentScope)();
|
|
2784
|
+
(0, import_react48.useLayoutEffect)(() => {
|
|
2833
2785
|
const atMatcher = new import_view5.MatchDecorator({
|
|
2834
2786
|
regexp: /\{\{([^\}]+)\}\}/g,
|
|
2835
2787
|
decoration: (match) => import_view5.Decoration.replace({
|
|
@@ -2894,7 +2846,7 @@ var transformer = (0, import_preset_code6.transformerCreator)((text) => {
|
|
|
2894
2846
|
return text;
|
|
2895
2847
|
});
|
|
2896
2848
|
function JsonEditorWithVariables(props) {
|
|
2897
|
-
return /* @__PURE__ */
|
|
2849
|
+
return /* @__PURE__ */ import_react50.default.createElement(
|
|
2898
2850
|
CodeEditor,
|
|
2899
2851
|
{
|
|
2900
2852
|
languageId: "json",
|
|
@@ -2905,15 +2857,16 @@ function JsonEditorWithVariables(props) {
|
|
|
2905
2857
|
...props.options || {}
|
|
2906
2858
|
}
|
|
2907
2859
|
},
|
|
2908
|
-
/* @__PURE__ */
|
|
2909
|
-
/* @__PURE__ */
|
|
2860
|
+
/* @__PURE__ */ import_react50.default.createElement(VariableTree2, null),
|
|
2861
|
+
/* @__PURE__ */ import_react50.default.createElement(VariableTagInject2, null)
|
|
2910
2862
|
);
|
|
2911
2863
|
}
|
|
2912
2864
|
|
|
2913
2865
|
// src/components/inputs-values/index.tsx
|
|
2914
|
-
var
|
|
2915
|
-
var
|
|
2916
|
-
var
|
|
2866
|
+
var import_react52 = __toESM(require("react"));
|
|
2867
|
+
var import_editor25 = require("@flowgram.ai/editor");
|
|
2868
|
+
var import_semi_ui23 = require("@douyinfe/semi-ui");
|
|
2869
|
+
var import_semi_icons9 = require("@douyinfe/semi-icons");
|
|
2917
2870
|
|
|
2918
2871
|
// src/components/inputs-values/styles.tsx
|
|
2919
2872
|
var import_styled_components10 = __toESM(require("styled-components"));
|
|
@@ -2930,14 +2883,14 @@ var UIRow3 = import_styled_components10.default.div`
|
|
|
2930
2883
|
`;
|
|
2931
2884
|
|
|
2932
2885
|
// src/components/inputs-values/components/blur-input.tsx
|
|
2933
|
-
var
|
|
2886
|
+
var import_react51 = __toESM(require("react"));
|
|
2934
2887
|
var import_input2 = __toESM(require("@douyinfe/semi-ui/lib/es/input"));
|
|
2935
2888
|
function BlurInput2(props) {
|
|
2936
|
-
const [value, setValue] = (0,
|
|
2937
|
-
(0,
|
|
2889
|
+
const [value, setValue] = (0, import_react51.useState)("");
|
|
2890
|
+
(0, import_react51.useEffect)(() => {
|
|
2938
2891
|
setValue(props.value);
|
|
2939
2892
|
}, [props.value]);
|
|
2940
|
-
return /* @__PURE__ */
|
|
2893
|
+
return /* @__PURE__ */ import_react51.default.createElement(
|
|
2941
2894
|
import_input2.default,
|
|
2942
2895
|
{
|
|
2943
2896
|
...props,
|
|
@@ -2965,7 +2918,7 @@ function InputsValues({
|
|
|
2965
2918
|
onChange,
|
|
2966
2919
|
sortIndexKey: "extra.index"
|
|
2967
2920
|
});
|
|
2968
|
-
return /* @__PURE__ */
|
|
2921
|
+
return /* @__PURE__ */ import_react52.default.createElement("div", null, /* @__PURE__ */ import_react52.default.createElement(UIRows2, { style }, list.map((item) => /* @__PURE__ */ import_react52.default.createElement(UIRow3, { key: item.id }, /* @__PURE__ */ import_react52.default.createElement(
|
|
2969
2922
|
BlurInput2,
|
|
2970
2923
|
{
|
|
2971
2924
|
style: { width: 100, minWidth: 100, maxWidth: 100 },
|
|
@@ -2973,10 +2926,10 @@ function InputsValues({
|
|
|
2973
2926
|
size: "small",
|
|
2974
2927
|
value: item.key,
|
|
2975
2928
|
onChange: (v) => updateKey(item.id, v),
|
|
2976
|
-
placeholder: "Input Key"
|
|
2929
|
+
placeholder: import_editor25.I18n.t("Input Key")
|
|
2977
2930
|
}
|
|
2978
|
-
), /* @__PURE__ */
|
|
2979
|
-
|
|
2931
|
+
), /* @__PURE__ */ import_react52.default.createElement(
|
|
2932
|
+
InjectDynamicValueInput,
|
|
2980
2933
|
{
|
|
2981
2934
|
style: { flexGrow: 1 },
|
|
2982
2935
|
readonly,
|
|
@@ -2989,20 +2942,20 @@ function InputsValues({
|
|
|
2989
2942
|
strategies: [...constantProps?.strategies || []]
|
|
2990
2943
|
}
|
|
2991
2944
|
}
|
|
2992
|
-
), /* @__PURE__ */
|
|
2993
|
-
|
|
2945
|
+
), /* @__PURE__ */ import_react52.default.createElement(
|
|
2946
|
+
import_semi_ui23.IconButton,
|
|
2994
2947
|
{
|
|
2995
2948
|
disabled: readonly,
|
|
2996
2949
|
theme: "borderless",
|
|
2997
|
-
icon: /* @__PURE__ */
|
|
2950
|
+
icon: /* @__PURE__ */ import_react52.default.createElement(import_semi_icons9.IconDelete, { size: "small" }),
|
|
2998
2951
|
size: "small",
|
|
2999
2952
|
onClick: () => remove(item.id)
|
|
3000
2953
|
}
|
|
3001
|
-
)))), /* @__PURE__ */
|
|
2954
|
+
)))), /* @__PURE__ */ import_react52.default.createElement(import_semi_ui23.Button, { disabled: readonly, icon: /* @__PURE__ */ import_react52.default.createElement(import_semi_icons9.IconPlus, null), size: "small", onClick: add }, "Add"));
|
|
3002
2955
|
}
|
|
3003
2956
|
|
|
3004
2957
|
// src/components/display-schema-tree/index.tsx
|
|
3005
|
-
var
|
|
2958
|
+
var import_react53 = __toESM(require("react"));
|
|
3006
2959
|
|
|
3007
2960
|
// src/components/display-schema-tree/styles.tsx
|
|
3008
2961
|
var import_styled_components11 = __toESM(require("styled-components"));
|
|
@@ -3086,7 +3039,7 @@ var TreeItem = import_styled_components11.default.div`
|
|
|
3086
3039
|
|
|
3087
3040
|
// src/components/display-schema-tree/index.tsx
|
|
3088
3041
|
function DisplaySchemaTree(props) {
|
|
3089
|
-
return /* @__PURE__ */
|
|
3042
|
+
return /* @__PURE__ */ import_react53.default.createElement(SchemaTree, { ...props });
|
|
3090
3043
|
}
|
|
3091
3044
|
function SchemaTree(props) {
|
|
3092
3045
|
const {
|
|
@@ -3102,27 +3055,27 @@ function SchemaTree(props) {
|
|
|
3102
3055
|
const icon = typeManager?.getDisplayIcon(schema);
|
|
3103
3056
|
let properties = drilldown && config ? config.getTypeSchemaProperties(schema) : {};
|
|
3104
3057
|
const childEntries = Object.entries(properties || {});
|
|
3105
|
-
return /* @__PURE__ */
|
|
3058
|
+
return /* @__PURE__ */ import_react53.default.createElement(TreeItem, { depth, key: parentKey || "root" }, /* @__PURE__ */ import_react53.default.createElement(TreeRow, null, depth !== 0 && /* @__PURE__ */ import_react53.default.createElement(HorizontalLine, null), showIcon && icon && import_react53.default.cloneElement(icon, {
|
|
3106
3059
|
className: "tree-icon"
|
|
3107
|
-
}), /* @__PURE__ */
|
|
3060
|
+
}), /* @__PURE__ */ import_react53.default.createElement(TreeTitle, null, parentKey ? /* @__PURE__ */ import_react53.default.createElement(import_react53.default.Fragment, null, `${parentKey} (`, title, ")") : title)), childEntries?.length ? /* @__PURE__ */ import_react53.default.createElement(TreeLevel, null, childEntries.map(([key, value]) => /* @__PURE__ */ import_react53.default.createElement(SchemaTree, { key, ...props, parentKey: key, value, depth: depth + 1 }))) : null);
|
|
3108
3061
|
}
|
|
3109
3062
|
|
|
3110
3063
|
// src/components/display-outputs/index.tsx
|
|
3111
|
-
var
|
|
3112
|
-
var
|
|
3113
|
-
var
|
|
3064
|
+
var import_react55 = __toESM(require("react"));
|
|
3065
|
+
var import_json_schema8 = require("@flowgram.ai/json-schema");
|
|
3066
|
+
var import_editor26 = require("@flowgram.ai/editor");
|
|
3114
3067
|
|
|
3115
3068
|
// src/components/display-schema-tag/index.tsx
|
|
3116
|
-
var
|
|
3117
|
-
var
|
|
3069
|
+
var import_react54 = __toESM(require("react"));
|
|
3070
|
+
var import_semi_ui25 = require("@douyinfe/semi-ui");
|
|
3118
3071
|
|
|
3119
3072
|
// src/components/display-schema-tag/styles.ts
|
|
3120
3073
|
var import_styled_components12 = __toESM(require("styled-components"));
|
|
3121
|
-
var
|
|
3074
|
+
var import_semi_ui24 = require("@douyinfe/semi-ui");
|
|
3122
3075
|
var PopoverContent = import_styled_components12.default.div`
|
|
3123
3076
|
padding: 10px;
|
|
3124
3077
|
`;
|
|
3125
|
-
var StyledTag = (0, import_styled_components12.default)(
|
|
3078
|
+
var StyledTag = (0, import_styled_components12.default)(import_semi_ui24.Tag)`
|
|
3126
3079
|
padding: 4px;
|
|
3127
3080
|
|
|
3128
3081
|
.tag-icon {
|
|
@@ -3142,14 +3095,14 @@ var TitleSpan = import_styled_components12.default.span`
|
|
|
3142
3095
|
function DisplaySchemaTag({ value = {}, showIconInTree, title, warning }) {
|
|
3143
3096
|
const typeManager = useTypeManager();
|
|
3144
3097
|
const icon = typeManager?.getDisplayIcon(value) || typeManager.getDisplayIcon({ type: "unknown" });
|
|
3145
|
-
return /* @__PURE__ */
|
|
3146
|
-
|
|
3098
|
+
return /* @__PURE__ */ import_react54.default.createElement(
|
|
3099
|
+
import_semi_ui25.Popover,
|
|
3147
3100
|
{
|
|
3148
|
-
content: /* @__PURE__ */
|
|
3101
|
+
content: /* @__PURE__ */ import_react54.default.createElement(PopoverContent, null, /* @__PURE__ */ import_react54.default.createElement(DisplaySchemaTree, { value, typeManager, showIcon: showIconInTree }))
|
|
3149
3102
|
},
|
|
3150
|
-
/* @__PURE__ */
|
|
3103
|
+
/* @__PURE__ */ import_react54.default.createElement(StyledTag, { color: warning ? "amber" : "white" }, icon && import_react54.default.cloneElement(icon, {
|
|
3151
3104
|
className: "tag-icon"
|
|
3152
|
-
}), title && /* @__PURE__ */
|
|
3105
|
+
}), title && /* @__PURE__ */ import_react54.default.createElement(TitleSpan, null, title))
|
|
3153
3106
|
);
|
|
3154
3107
|
}
|
|
3155
3108
|
|
|
@@ -3163,9 +3116,9 @@ var DisplayOutputsWrapper = import_styled_components13.default.div`
|
|
|
3163
3116
|
|
|
3164
3117
|
// src/components/display-outputs/index.tsx
|
|
3165
3118
|
function DisplayOutputs({ value, showIconInTree, displayFromScope }) {
|
|
3166
|
-
const scope = (0,
|
|
3167
|
-
const refresh = (0,
|
|
3168
|
-
(0,
|
|
3119
|
+
const scope = (0, import_editor26.useCurrentScope)();
|
|
3120
|
+
const refresh = (0, import_editor26.useRefresh)();
|
|
3121
|
+
(0, import_react55.useEffect)(() => {
|
|
3169
3122
|
if (!displayFromScope) {
|
|
3170
3123
|
return () => null;
|
|
3171
3124
|
}
|
|
@@ -3179,12 +3132,12 @@ function DisplayOutputs({ value, showIconInTree, displayFromScope }) {
|
|
|
3179
3132
|
const properties = displayFromScope ? scope.output.variables?.reduce((acm, curr) => {
|
|
3180
3133
|
acm = {
|
|
3181
3134
|
...acm,
|
|
3182
|
-
...
|
|
3135
|
+
...import_json_schema8.JsonSchemaUtils.astToSchema(curr.type)?.properties || {}
|
|
3183
3136
|
};
|
|
3184
3137
|
return acm;
|
|
3185
3138
|
}, {}) : value?.properties || {};
|
|
3186
3139
|
const childEntries = Object.entries(properties || {});
|
|
3187
|
-
return /* @__PURE__ */
|
|
3140
|
+
return /* @__PURE__ */ import_react55.default.createElement(DisplayOutputsWrapper, null, childEntries.map(([key, schema]) => /* @__PURE__ */ import_react55.default.createElement(
|
|
3188
3141
|
DisplaySchemaTag,
|
|
3189
3142
|
{
|
|
3190
3143
|
key,
|
|
@@ -3197,15 +3150,15 @@ function DisplayOutputs({ value, showIconInTree, displayFromScope }) {
|
|
|
3197
3150
|
}
|
|
3198
3151
|
|
|
3199
3152
|
// src/components/display-flow-value/index.tsx
|
|
3200
|
-
var
|
|
3201
|
-
var
|
|
3202
|
-
var
|
|
3153
|
+
var import_react56 = __toESM(require("react"));
|
|
3154
|
+
var import_json_schema9 = require("@flowgram.ai/json-schema");
|
|
3155
|
+
var import_editor27 = require("@flowgram.ai/editor");
|
|
3203
3156
|
function DisplayFlowValue({ value, title, showIconInTree }) {
|
|
3204
|
-
const available = (0,
|
|
3157
|
+
const available = (0, import_editor27.useScopeAvailable)();
|
|
3205
3158
|
const variable = value?.type === "ref" ? available.getByKeyPath(value?.content) : void 0;
|
|
3206
|
-
const schema = (0,
|
|
3159
|
+
const schema = (0, import_react56.useMemo)(() => {
|
|
3207
3160
|
if (value?.type === "ref") {
|
|
3208
|
-
return
|
|
3161
|
+
return import_json_schema9.JsonSchemaUtils.astToSchema(variable?.type);
|
|
3209
3162
|
}
|
|
3210
3163
|
if (value?.type === "template") {
|
|
3211
3164
|
return { type: "string" };
|
|
@@ -3226,7 +3179,7 @@ function DisplayFlowValue({ value, title, showIconInTree }) {
|
|
|
3226
3179
|
}
|
|
3227
3180
|
return { type: "unknown" };
|
|
3228
3181
|
}, [value, variable?.hash]);
|
|
3229
|
-
return /* @__PURE__ */
|
|
3182
|
+
return /* @__PURE__ */ import_react56.default.createElement(
|
|
3230
3183
|
DisplaySchemaTag,
|
|
3231
3184
|
{
|
|
3232
3185
|
title,
|
|
@@ -3238,7 +3191,7 @@ function DisplayFlowValue({ value, title, showIconInTree }) {
|
|
|
3238
3191
|
}
|
|
3239
3192
|
|
|
3240
3193
|
// src/components/display-inputs-values/index.tsx
|
|
3241
|
-
var
|
|
3194
|
+
var import_react57 = __toESM(require("react"));
|
|
3242
3195
|
|
|
3243
3196
|
// src/components/display-inputs-values/styles.ts
|
|
3244
3197
|
var import_styled_components14 = __toESM(require("styled-components"));
|
|
@@ -3251,29 +3204,29 @@ var DisplayInputsWrapper = import_styled_components14.default.div`
|
|
|
3251
3204
|
// src/components/display-inputs-values/index.tsx
|
|
3252
3205
|
function DisplayInputsValues({ value, showIconInTree }) {
|
|
3253
3206
|
const childEntries = Object.entries(value || {});
|
|
3254
|
-
return /* @__PURE__ */
|
|
3207
|
+
return /* @__PURE__ */ import_react57.default.createElement(DisplayInputsWrapper, null, childEntries.map(([key, value2]) => /* @__PURE__ */ import_react57.default.createElement(DisplayFlowValue, { key, title: key, value: value2, showIconInTree })));
|
|
3255
3208
|
}
|
|
3256
3209
|
|
|
3257
3210
|
// src/components/assign-rows/index.tsx
|
|
3258
|
-
var
|
|
3259
|
-
var
|
|
3260
|
-
var import_semi_ui28 = require("@douyinfe/semi-ui");
|
|
3261
|
-
var import_semi_icons12 = require("@douyinfe/semi-icons");
|
|
3262
|
-
|
|
3263
|
-
// src/components/assign-row/index.tsx
|
|
3264
|
-
var import_react58 = __toESM(require("react"));
|
|
3211
|
+
var import_react60 = __toESM(require("react"));
|
|
3212
|
+
var import_editor28 = require("@flowgram.ai/editor");
|
|
3265
3213
|
var import_semi_ui27 = require("@douyinfe/semi-ui");
|
|
3266
3214
|
var import_semi_icons11 = require("@douyinfe/semi-icons");
|
|
3267
3215
|
|
|
3216
|
+
// src/components/assign-row/index.tsx
|
|
3217
|
+
var import_react59 = __toESM(require("react"));
|
|
3218
|
+
var import_semi_ui26 = require("@douyinfe/semi-ui");
|
|
3219
|
+
var import_semi_icons10 = require("@douyinfe/semi-icons");
|
|
3220
|
+
|
|
3268
3221
|
// src/components/assign-row/components/blur-input.tsx
|
|
3269
|
-
var
|
|
3222
|
+
var import_react58 = __toESM(require("react"));
|
|
3270
3223
|
var import_input3 = __toESM(require("@douyinfe/semi-ui/lib/es/input"));
|
|
3271
3224
|
function BlurInput3(props) {
|
|
3272
|
-
const [value, setValue] = (0,
|
|
3273
|
-
(0,
|
|
3225
|
+
const [value, setValue] = (0, import_react58.useState)("");
|
|
3226
|
+
(0, import_react58.useEffect)(() => {
|
|
3274
3227
|
setValue(props.value);
|
|
3275
3228
|
}, [props.value]);
|
|
3276
|
-
return /* @__PURE__ */
|
|
3229
|
+
return /* @__PURE__ */ import_react58.default.createElement(
|
|
3277
3230
|
import_input3.default,
|
|
3278
3231
|
{
|
|
3279
3232
|
...props,
|
|
@@ -3296,8 +3249,8 @@ function AssignRow(props) {
|
|
|
3296
3249
|
onDelete,
|
|
3297
3250
|
readonly
|
|
3298
3251
|
} = props;
|
|
3299
|
-
return /* @__PURE__ */
|
|
3300
|
-
|
|
3252
|
+
return /* @__PURE__ */ import_react59.default.createElement("div", { style: { display: "flex", alignItems: "center", gap: 5 } }, /* @__PURE__ */ import_react59.default.createElement("div", { style: { width: 150, minWidth: 150, maxWidth: 150 } }, value?.operator === "assign" ? /* @__PURE__ */ import_react59.default.createElement(
|
|
3253
|
+
InjectVariableSelector,
|
|
3301
3254
|
{
|
|
3302
3255
|
style: { width: "100%", height: 26 },
|
|
3303
3256
|
value: value?.left?.content,
|
|
@@ -3307,7 +3260,7 @@ function AssignRow(props) {
|
|
|
3307
3260
|
left: { type: "ref", content: v }
|
|
3308
3261
|
})
|
|
3309
3262
|
}
|
|
3310
|
-
) : /* @__PURE__ */
|
|
3263
|
+
) : /* @__PURE__ */ import_react59.default.createElement(
|
|
3311
3264
|
BlurInput3,
|
|
3312
3265
|
{
|
|
3313
3266
|
style: { height: 26 },
|
|
@@ -3319,8 +3272,8 @@ function AssignRow(props) {
|
|
|
3319
3272
|
left: v
|
|
3320
3273
|
})
|
|
3321
3274
|
}
|
|
3322
|
-
)), /* @__PURE__ */
|
|
3323
|
-
|
|
3275
|
+
)), /* @__PURE__ */ import_react59.default.createElement("div", { style: { flexGrow: 1 } }, /* @__PURE__ */ import_react59.default.createElement(
|
|
3276
|
+
InjectDynamicValueInput,
|
|
3324
3277
|
{
|
|
3325
3278
|
readonly,
|
|
3326
3279
|
value: value?.right,
|
|
@@ -3329,12 +3282,12 @@ function AssignRow(props) {
|
|
|
3329
3282
|
right: v
|
|
3330
3283
|
})
|
|
3331
3284
|
}
|
|
3332
|
-
)), onDelete && /* @__PURE__ */
|
|
3333
|
-
|
|
3285
|
+
)), onDelete && /* @__PURE__ */ import_react59.default.createElement("div", null, /* @__PURE__ */ import_react59.default.createElement(
|
|
3286
|
+
import_semi_ui26.IconButton,
|
|
3334
3287
|
{
|
|
3335
3288
|
size: "small",
|
|
3336
3289
|
theme: "borderless",
|
|
3337
|
-
icon: /* @__PURE__ */
|
|
3290
|
+
icon: /* @__PURE__ */ import_react59.default.createElement(import_semi_icons10.IconMinus, null),
|
|
3338
3291
|
onClick: () => onDelete?.()
|
|
3339
3292
|
}
|
|
3340
3293
|
)));
|
|
@@ -3343,7 +3296,7 @@ function AssignRow(props) {
|
|
|
3343
3296
|
// src/components/assign-rows/index.tsx
|
|
3344
3297
|
function AssignRows(props) {
|
|
3345
3298
|
const { name, readonly } = props;
|
|
3346
|
-
return /* @__PURE__ */
|
|
3299
|
+
return /* @__PURE__ */ import_react60.default.createElement(import_editor28.FieldArray, { name }, ({ field }) => /* @__PURE__ */ import_react60.default.createElement(import_react60.default.Fragment, null, field.map((childField, index) => /* @__PURE__ */ import_react60.default.createElement(
|
|
3347
3300
|
AssignRow,
|
|
3348
3301
|
{
|
|
3349
3302
|
key: childField.key,
|
|
@@ -3354,21 +3307,21 @@ function AssignRows(props) {
|
|
|
3354
3307
|
},
|
|
3355
3308
|
onDelete: () => field.remove(index)
|
|
3356
3309
|
}
|
|
3357
|
-
)), /* @__PURE__ */
|
|
3358
|
-
|
|
3310
|
+
)), /* @__PURE__ */ import_react60.default.createElement("div", { style: { display: "flex", gap: 5 } }, /* @__PURE__ */ import_react60.default.createElement(
|
|
3311
|
+
import_semi_ui27.Button,
|
|
3359
3312
|
{
|
|
3360
3313
|
size: "small",
|
|
3361
3314
|
theme: "borderless",
|
|
3362
|
-
icon: /* @__PURE__ */
|
|
3315
|
+
icon: /* @__PURE__ */ import_react60.default.createElement(import_semi_icons11.IconPlus, null),
|
|
3363
3316
|
onClick: () => field.append({ operator: "assign" })
|
|
3364
3317
|
},
|
|
3365
3318
|
"Assign"
|
|
3366
|
-
), /* @__PURE__ */
|
|
3367
|
-
|
|
3319
|
+
), /* @__PURE__ */ import_react60.default.createElement(
|
|
3320
|
+
import_semi_ui27.Button,
|
|
3368
3321
|
{
|
|
3369
3322
|
size: "small",
|
|
3370
3323
|
theme: "borderless",
|
|
3371
|
-
icon: /* @__PURE__ */
|
|
3324
|
+
icon: /* @__PURE__ */ import_react60.default.createElement(import_semi_icons11.IconPlus, null),
|
|
3372
3325
|
onClick: () => field.append({ operator: "declare" })
|
|
3373
3326
|
},
|
|
3374
3327
|
"Declaration"
|
|
@@ -3376,29 +3329,29 @@ function AssignRows(props) {
|
|
|
3376
3329
|
}
|
|
3377
3330
|
|
|
3378
3331
|
// src/effects/provide-batch-input/index.ts
|
|
3379
|
-
var
|
|
3380
|
-
var provideBatchInputEffect = (0,
|
|
3332
|
+
var import_editor29 = require("@flowgram.ai/editor");
|
|
3333
|
+
var provideBatchInputEffect = (0, import_editor29.createEffectFromVariableProvider)({
|
|
3381
3334
|
private: true,
|
|
3382
3335
|
parse: (value, ctx) => [
|
|
3383
|
-
|
|
3336
|
+
import_editor29.ASTFactory.createVariableDeclaration({
|
|
3384
3337
|
key: `${ctx.node.id}_locals`,
|
|
3385
3338
|
meta: {
|
|
3386
|
-
title: (0,
|
|
3339
|
+
title: (0, import_editor29.getNodeForm)(ctx.node)?.getValueIn("title"),
|
|
3387
3340
|
icon: ctx.node.getNodeRegistry().info?.icon
|
|
3388
3341
|
},
|
|
3389
|
-
type:
|
|
3342
|
+
type: import_editor29.ASTFactory.createObject({
|
|
3390
3343
|
properties: [
|
|
3391
|
-
|
|
3344
|
+
import_editor29.ASTFactory.createProperty({
|
|
3392
3345
|
key: "item",
|
|
3393
|
-
initializer:
|
|
3394
|
-
enumerateFor:
|
|
3346
|
+
initializer: import_editor29.ASTFactory.createEnumerateExpression({
|
|
3347
|
+
enumerateFor: import_editor29.ASTFactory.createKeyPathExpression({
|
|
3395
3348
|
keyPath: value.content || []
|
|
3396
3349
|
})
|
|
3397
3350
|
})
|
|
3398
3351
|
}),
|
|
3399
|
-
|
|
3352
|
+
import_editor29.ASTFactory.createProperty({
|
|
3400
3353
|
key: "index",
|
|
3401
|
-
type:
|
|
3354
|
+
type: import_editor29.ASTFactory.createNumber()
|
|
3402
3355
|
})
|
|
3403
3356
|
]
|
|
3404
3357
|
})
|
|
@@ -3407,14 +3360,14 @@ var provideBatchInputEffect = (0, import_editor26.createEffectFromVariableProvid
|
|
|
3407
3360
|
});
|
|
3408
3361
|
|
|
3409
3362
|
// src/effects/auto-rename-ref/index.ts
|
|
3410
|
-
var
|
|
3411
|
-
var
|
|
3363
|
+
var import_lodash7 = require("lodash");
|
|
3364
|
+
var import_editor30 = require("@flowgram.ai/editor");
|
|
3412
3365
|
var autoRenameRefEffect = [
|
|
3413
3366
|
{
|
|
3414
|
-
event:
|
|
3367
|
+
event: import_editor30.DataEvent.onValueInit,
|
|
3415
3368
|
effect: (params) => {
|
|
3416
3369
|
const { context, form, name } = params;
|
|
3417
|
-
const renameService = context.node.getService(
|
|
3370
|
+
const renameService = context.node.getService(import_editor30.VariableFieldKeyRenameService);
|
|
3418
3371
|
const disposable = renameService.onRename(({ before, after }) => {
|
|
3419
3372
|
const beforeKeyPath = [
|
|
3420
3373
|
...before.parentFields.map((_field) => _field.key).reverse(),
|
|
@@ -3463,7 +3416,7 @@ function isKeyPathMatch(keyPath = [], targetKeyPath) {
|
|
|
3463
3416
|
}
|
|
3464
3417
|
function getTemplateKeyPaths(value) {
|
|
3465
3418
|
const keyPathReg = /{{(.*?)}}/g;
|
|
3466
|
-
return (0,
|
|
3419
|
+
return (0, import_lodash7.uniq)(value.content?.match(keyPathReg) || []).map(
|
|
3467
3420
|
(_keyPath) => _keyPath.slice(2, -2).split(".")
|
|
3468
3421
|
);
|
|
3469
3422
|
}
|
|
@@ -3474,7 +3427,7 @@ function isTemplate(value) {
|
|
|
3474
3427
|
return value?.type === "template" && typeof value?.content === "string";
|
|
3475
3428
|
}
|
|
3476
3429
|
function traverseRef(name, value, cb) {
|
|
3477
|
-
if ((0,
|
|
3430
|
+
if ((0, import_lodash7.isObject)(value)) {
|
|
3478
3431
|
if (isRef(value)) {
|
|
3479
3432
|
cb(name, value);
|
|
3480
3433
|
return;
|
|
@@ -3488,7 +3441,7 @@ function traverseRef(name, value, cb) {
|
|
|
3488
3441
|
});
|
|
3489
3442
|
return;
|
|
3490
3443
|
}
|
|
3491
|
-
if ((0,
|
|
3444
|
+
if ((0, import_lodash7.isArray)(value)) {
|
|
3492
3445
|
value.forEach((_value, idx) => {
|
|
3493
3446
|
traverseRef(`${name}[${idx}]`, _value, cb);
|
|
3494
3447
|
});
|
|
@@ -3498,28 +3451,28 @@ function traverseRef(name, value, cb) {
|
|
|
3498
3451
|
}
|
|
3499
3452
|
|
|
3500
3453
|
// src/effects/provide-json-schema-outputs/index.ts
|
|
3501
|
-
var
|
|
3502
|
-
var
|
|
3503
|
-
var provideJsonSchemaOutputs = (0,
|
|
3454
|
+
var import_json_schema10 = require("@flowgram.ai/json-schema");
|
|
3455
|
+
var import_editor31 = require("@flowgram.ai/editor");
|
|
3456
|
+
var provideJsonSchemaOutputs = (0, import_editor31.createEffectFromVariableProvider)({
|
|
3504
3457
|
parse: (value, ctx) => [
|
|
3505
|
-
|
|
3458
|
+
import_editor31.ASTFactory.createVariableDeclaration({
|
|
3506
3459
|
key: `${ctx.node.id}`,
|
|
3507
3460
|
meta: {
|
|
3508
|
-
title: (0,
|
|
3461
|
+
title: (0, import_editor31.getNodeForm)(ctx.node)?.getValueIn("title") || ctx.node.id,
|
|
3509
3462
|
icon: ctx.node.getNodeRegistry().info?.icon
|
|
3510
3463
|
},
|
|
3511
|
-
type:
|
|
3464
|
+
type: import_json_schema10.JsonSchemaUtils.schemaToAST(value)
|
|
3512
3465
|
})
|
|
3513
3466
|
]
|
|
3514
3467
|
});
|
|
3515
3468
|
|
|
3516
3469
|
// src/effects/sync-variable-title/index.ts
|
|
3517
|
-
var
|
|
3470
|
+
var import_editor32 = require("@flowgram.ai/editor");
|
|
3518
3471
|
var syncVariableTitle = [
|
|
3519
3472
|
{
|
|
3520
|
-
event:
|
|
3473
|
+
event: import_editor32.DataEvent.onValueChange,
|
|
3521
3474
|
effect: ({ value, context }) => {
|
|
3522
|
-
context.node.getData(
|
|
3475
|
+
context.node.getData(import_editor32.FlowNodeVariableData).allScopes.forEach((_scope) => {
|
|
3523
3476
|
_scope.output.variables.forEach((_var) => {
|
|
3524
3477
|
_var.updateMeta({
|
|
3525
3478
|
..._var.meta || {},
|
|
@@ -3533,17 +3486,17 @@ var syncVariableTitle = [
|
|
|
3533
3486
|
];
|
|
3534
3487
|
|
|
3535
3488
|
// src/effects/validate-when-variable-sync/index.ts
|
|
3536
|
-
var
|
|
3537
|
-
var
|
|
3489
|
+
var import_lodash8 = require("lodash");
|
|
3490
|
+
var import_editor33 = require("@flowgram.ai/editor");
|
|
3538
3491
|
var validateWhenVariableSync = ({
|
|
3539
3492
|
scope
|
|
3540
3493
|
} = {}) => [
|
|
3541
3494
|
{
|
|
3542
|
-
event:
|
|
3495
|
+
event: import_editor33.DataEvent.onValueInit,
|
|
3543
3496
|
effect: ({ context, form }) => {
|
|
3544
|
-
const nodeScope = scope === "private" ? (0,
|
|
3497
|
+
const nodeScope = scope === "private" ? (0, import_editor33.getNodePrivateScope)(context.node) : (0, import_editor33.getNodeScope)(context.node);
|
|
3545
3498
|
const disposable = nodeScope.available.onListOrAnyVarChange(() => {
|
|
3546
|
-
if (!(0,
|
|
3499
|
+
if (!(0, import_lodash8.isEmpty)(form.state.errors)) {
|
|
3547
3500
|
form.validate();
|
|
3548
3501
|
}
|
|
3549
3502
|
});
|
|
@@ -3553,16 +3506,16 @@ var validateWhenVariableSync = ({
|
|
|
3553
3506
|
];
|
|
3554
3507
|
|
|
3555
3508
|
// src/effects/listen-ref-value-change/index.ts
|
|
3556
|
-
var
|
|
3509
|
+
var import_editor34 = require("@flowgram.ai/editor");
|
|
3557
3510
|
var listenRefValueChange = (cb) => [
|
|
3558
3511
|
{
|
|
3559
|
-
event:
|
|
3512
|
+
event: import_editor34.DataEvent.onValueInitOrChange,
|
|
3560
3513
|
effect: (params) => {
|
|
3561
3514
|
const { context, value } = params;
|
|
3562
3515
|
if (value?.type !== "ref") {
|
|
3563
3516
|
return () => null;
|
|
3564
3517
|
}
|
|
3565
|
-
const disposable = (0,
|
|
3518
|
+
const disposable = (0, import_editor34.getNodeScope)(context.node).available.trackByKeyPath(
|
|
3566
3519
|
value?.content || [],
|
|
3567
3520
|
(v) => {
|
|
3568
3521
|
cb({ ...params, variable: v });
|
|
@@ -3576,20 +3529,20 @@ var listenRefValueChange = (cb) => [
|
|
|
3576
3529
|
];
|
|
3577
3530
|
|
|
3578
3531
|
// src/effects/listen-ref-schema-change/index.ts
|
|
3579
|
-
var
|
|
3580
|
-
var
|
|
3532
|
+
var import_json_schema11 = require("@flowgram.ai/json-schema");
|
|
3533
|
+
var import_editor35 = require("@flowgram.ai/editor");
|
|
3581
3534
|
var listenRefSchemaChange = (cb) => [
|
|
3582
3535
|
{
|
|
3583
|
-
event:
|
|
3536
|
+
event: import_editor35.DataEvent.onValueInitOrChange,
|
|
3584
3537
|
effect: (params) => {
|
|
3585
3538
|
const { context, value } = params;
|
|
3586
3539
|
if (value?.type !== "ref") {
|
|
3587
3540
|
return () => null;
|
|
3588
3541
|
}
|
|
3589
|
-
const disposable = (0,
|
|
3542
|
+
const disposable = (0, import_editor35.getNodeScope)(context.node).available.trackByKeyPath(
|
|
3590
3543
|
value?.content || [],
|
|
3591
3544
|
(_type) => {
|
|
3592
|
-
cb({ ...params, schema:
|
|
3545
|
+
cb({ ...params, schema: import_json_schema11.JsonSchemaUtils.astToSchema(_type) });
|
|
3593
3546
|
},
|
|
3594
3547
|
{
|
|
3595
3548
|
selector: (_v) => _v?.type
|
|
@@ -3602,84 +3555,22 @@ var listenRefSchemaChange = (cb) => [
|
|
|
3602
3555
|
}
|
|
3603
3556
|
];
|
|
3604
3557
|
|
|
3605
|
-
// src/shared/format-legacy-refs/index.ts
|
|
3606
|
-
var import_lodash8 = require("lodash");
|
|
3607
|
-
function formatLegacyRefOnSubmit(value) {
|
|
3608
|
-
if ((0, import_lodash8.isObject)(value)) {
|
|
3609
|
-
if (isLegacyFlowRefValueSchema(value)) {
|
|
3610
|
-
return formatLegacyRefToNewRef(value);
|
|
3611
|
-
}
|
|
3612
|
-
return Object.fromEntries(
|
|
3613
|
-
Object.entries(value).map(([key, value2]) => [
|
|
3614
|
-
key,
|
|
3615
|
-
formatLegacyRefOnSubmit(value2)
|
|
3616
|
-
])
|
|
3617
|
-
);
|
|
3618
|
-
}
|
|
3619
|
-
if (Array.isArray(value)) {
|
|
3620
|
-
return value.map(formatLegacyRefOnSubmit);
|
|
3621
|
-
}
|
|
3622
|
-
return value;
|
|
3623
|
-
}
|
|
3624
|
-
function formatLegacyRefOnInit(value) {
|
|
3625
|
-
if ((0, import_lodash8.isObject)(value)) {
|
|
3626
|
-
if (isNewFlowRefValueSchema(value)) {
|
|
3627
|
-
return formatNewRefToLegacyRef(value);
|
|
3628
|
-
}
|
|
3629
|
-
return Object.fromEntries(
|
|
3630
|
-
Object.entries(value).map(([key, value2]) => [
|
|
3631
|
-
key,
|
|
3632
|
-
formatLegacyRefOnInit(value2)
|
|
3633
|
-
])
|
|
3634
|
-
);
|
|
3635
|
-
}
|
|
3636
|
-
if (Array.isArray(value)) {
|
|
3637
|
-
return value.map(formatLegacyRefOnInit);
|
|
3638
|
-
}
|
|
3639
|
-
return value;
|
|
3640
|
-
}
|
|
3641
|
-
function isLegacyFlowRefValueSchema(value) {
|
|
3642
|
-
return (0, import_lodash8.isObject)(value) && Object.keys(value).length === 2 && value.type === "ref" && typeof value.content === "string";
|
|
3643
|
-
}
|
|
3644
|
-
function isNewFlowRefValueSchema(value) {
|
|
3645
|
-
return (0, import_lodash8.isObject)(value) && Object.keys(value).length === 2 && value.type === "ref" && Array.isArray(value.content);
|
|
3646
|
-
}
|
|
3647
|
-
function formatLegacyRefToNewRef(value) {
|
|
3648
|
-
const keyPath = value.content.split(".");
|
|
3649
|
-
if (keyPath[1] === "outputs") {
|
|
3650
|
-
return {
|
|
3651
|
-
type: "ref",
|
|
3652
|
-
content: [`${keyPath[0]}.${keyPath[1]}`, ...keyPath.length > 2 ? keyPath.slice(2) : []]
|
|
3653
|
-
};
|
|
3654
|
-
}
|
|
3655
|
-
return {
|
|
3656
|
-
type: "ref",
|
|
3657
|
-
content: keyPath
|
|
3658
|
-
};
|
|
3659
|
-
}
|
|
3660
|
-
function formatNewRefToLegacyRef(value) {
|
|
3661
|
-
return {
|
|
3662
|
-
type: "ref",
|
|
3663
|
-
content: value.content.join(".")
|
|
3664
|
-
};
|
|
3665
|
-
}
|
|
3666
|
-
|
|
3667
3558
|
// src/form-plugins/batch-outputs-plugin/index.ts
|
|
3668
|
-
var
|
|
3669
|
-
var provideBatchOutputsEffect = (0,
|
|
3559
|
+
var import_editor36 = require("@flowgram.ai/editor");
|
|
3560
|
+
var provideBatchOutputsEffect = (0, import_editor36.createEffectFromVariableProvider)({
|
|
3670
3561
|
parse: (value, ctx) => [
|
|
3671
|
-
|
|
3562
|
+
import_editor36.ASTFactory.createVariableDeclaration({
|
|
3672
3563
|
key: `${ctx.node.id}`,
|
|
3673
3564
|
meta: {
|
|
3674
|
-
title: (0,
|
|
3565
|
+
title: (0, import_editor36.getNodeForm)(ctx.node)?.getValueIn("title"),
|
|
3675
3566
|
icon: ctx.node.getNodeRegistry().info?.icon
|
|
3676
3567
|
},
|
|
3677
|
-
type:
|
|
3568
|
+
type: import_editor36.ASTFactory.createObject({
|
|
3678
3569
|
properties: Object.entries(value).map(
|
|
3679
|
-
([_key, value2]) =>
|
|
3570
|
+
([_key, value2]) => import_editor36.ASTFactory.createProperty({
|
|
3680
3571
|
key: _key,
|
|
3681
|
-
initializer:
|
|
3682
|
-
wrapFor:
|
|
3572
|
+
initializer: import_editor36.ASTFactory.createWrapArrayExpression({
|
|
3573
|
+
wrapFor: import_editor36.ASTFactory.createKeyPathExpression({
|
|
3683
3574
|
keyPath: value2?.content || []
|
|
3684
3575
|
})
|
|
3685
3576
|
})
|
|
@@ -3689,7 +3580,7 @@ var provideBatchOutputsEffect = (0, import_editor33.createEffectFromVariableProv
|
|
|
3689
3580
|
})
|
|
3690
3581
|
]
|
|
3691
3582
|
});
|
|
3692
|
-
var createBatchOutputsFormPlugin = (0,
|
|
3583
|
+
var createBatchOutputsFormPlugin = (0, import_editor36.defineFormPluginCreator)({
|
|
3693
3584
|
name: "batch-outputs-plugin",
|
|
3694
3585
|
onSetupFormMeta({ mergeEffect }, { outputKey }) {
|
|
3695
3586
|
mergeEffect({
|
|
@@ -3697,7 +3588,7 @@ var createBatchOutputsFormPlugin = (0, import_editor33.defineFormPluginCreator)(
|
|
|
3697
3588
|
});
|
|
3698
3589
|
},
|
|
3699
3590
|
onInit(ctx, { outputKey }) {
|
|
3700
|
-
const chainTransformService = ctx.node.getService(
|
|
3591
|
+
const chainTransformService = ctx.node.getService(import_editor36.ScopeChainTransformService);
|
|
3701
3592
|
const batchNodeType = ctx.node.flowNodeType;
|
|
3702
3593
|
const transformerId = `${batchNodeType}-outputs`;
|
|
3703
3594
|
if (chainTransformService.hasTransformer(transformerId)) {
|
|
@@ -3707,21 +3598,21 @@ var createBatchOutputsFormPlugin = (0, import_editor33.defineFormPluginCreator)(
|
|
|
3707
3598
|
transformCovers: (covers, ctx2) => {
|
|
3708
3599
|
const node = ctx2.scope.meta?.node;
|
|
3709
3600
|
if (node?.parent?.flowNodeType === batchNodeType) {
|
|
3710
|
-
return [...covers, (0,
|
|
3601
|
+
return [...covers, (0, import_editor36.getNodeScope)(node.parent)];
|
|
3711
3602
|
}
|
|
3712
3603
|
return covers;
|
|
3713
3604
|
},
|
|
3714
3605
|
transformDeps(scopes, ctx2) {
|
|
3715
3606
|
const scopeMeta = ctx2.scope.meta;
|
|
3716
|
-
if (scopeMeta?.type ===
|
|
3607
|
+
if (scopeMeta?.type === import_editor36.FlowNodeScopeType.private) {
|
|
3717
3608
|
return scopes;
|
|
3718
3609
|
}
|
|
3719
3610
|
const node = scopeMeta?.node;
|
|
3720
3611
|
if (node?.flowNodeType === batchNodeType) {
|
|
3721
3612
|
const childBlocks = node.blocks;
|
|
3722
3613
|
return [
|
|
3723
|
-
(0,
|
|
3724
|
-
...childBlocks.map((_childBlock) => (0,
|
|
3614
|
+
(0, import_editor36.getNodePrivateScope)(node),
|
|
3615
|
+
...childBlocks.map((_childBlock) => (0, import_editor36.getNodeScope)(_childBlock))
|
|
3725
3616
|
];
|
|
3726
3617
|
}
|
|
3727
3618
|
return scopes;
|
|
@@ -3732,9 +3623,9 @@ var createBatchOutputsFormPlugin = (0, import_editor33.defineFormPluginCreator)(
|
|
|
3732
3623
|
|
|
3733
3624
|
// src/form-plugins/infer-inputs-plugin/index.ts
|
|
3734
3625
|
var import_lodash9 = require("lodash");
|
|
3735
|
-
var
|
|
3736
|
-
var
|
|
3737
|
-
var createInferInputsPlugin = (0,
|
|
3626
|
+
var import_json_schema12 = require("@flowgram.ai/json-schema");
|
|
3627
|
+
var import_editor37 = require("@flowgram.ai/editor");
|
|
3628
|
+
var createInferInputsPlugin = (0, import_editor37.defineFormPluginCreator)({
|
|
3738
3629
|
onSetupFormMeta({ addFormatOnSubmit }, { sourceKey, targetKey, scope }) {
|
|
3739
3630
|
if (!sourceKey || !targetKey) {
|
|
3740
3631
|
return;
|
|
@@ -3745,7 +3636,7 @@ var createInferInputsPlugin = (0, import_editor34.defineFormPluginCreator)({
|
|
|
3745
3636
|
targetKey,
|
|
3746
3637
|
infer(
|
|
3747
3638
|
(0, import_lodash9.get)(formData, sourceKey),
|
|
3748
|
-
scope === "private" ? (0,
|
|
3639
|
+
scope === "private" ? (0, import_editor37.getNodePrivateScope)(ctx.node) : (0, import_editor37.getNodeScope)(ctx.node)
|
|
3749
3640
|
)
|
|
3750
3641
|
);
|
|
3751
3642
|
return formData;
|
|
@@ -3785,7 +3676,7 @@ var infer = (values, scope) => {
|
|
|
3785
3676
|
}
|
|
3786
3677
|
if (isRef2(values)) {
|
|
3787
3678
|
const variable = scope.available.getByKeyPath(values?.content);
|
|
3788
|
-
const schema = variable?.type ?
|
|
3679
|
+
const schema = variable?.type ? import_json_schema12.JsonSchemaUtils.astToSchema(variable?.type) : void 0;
|
|
3789
3680
|
return schema;
|
|
3790
3681
|
}
|
|
3791
3682
|
if (isTemplate2(values)) {
|
|
@@ -3808,33 +3699,33 @@ var infer = (values, scope) => {
|
|
|
3808
3699
|
|
|
3809
3700
|
// src/form-plugins/infer-assign-plugin/index.ts
|
|
3810
3701
|
var import_lodash10 = require("lodash");
|
|
3811
|
-
var
|
|
3812
|
-
var
|
|
3813
|
-
var createInferAssignPlugin = (0,
|
|
3702
|
+
var import_json_schema13 = require("@flowgram.ai/json-schema");
|
|
3703
|
+
var import_editor38 = require("@flowgram.ai/editor");
|
|
3704
|
+
var createInferAssignPlugin = (0, import_editor38.defineFormPluginCreator)({
|
|
3814
3705
|
onSetupFormMeta({ addFormatOnSubmit, mergeEffect }, { assignKey, outputKey }) {
|
|
3815
3706
|
if (!assignKey || !outputKey) {
|
|
3816
3707
|
return;
|
|
3817
3708
|
}
|
|
3818
3709
|
mergeEffect({
|
|
3819
|
-
[assignKey]: (0,
|
|
3710
|
+
[assignKey]: (0, import_editor38.createEffectFromVariableProvider)({
|
|
3820
3711
|
parse: (value, ctx) => {
|
|
3821
3712
|
const declareRows = (0, import_lodash10.uniqBy)(
|
|
3822
3713
|
value.filter((_v) => _v.operator === "declare" && _v.left && _v.right),
|
|
3823
3714
|
"left"
|
|
3824
3715
|
);
|
|
3825
3716
|
return [
|
|
3826
|
-
|
|
3717
|
+
import_editor38.ASTFactory.createVariableDeclaration({
|
|
3827
3718
|
key: `${ctx.node.id}`,
|
|
3828
3719
|
meta: {
|
|
3829
|
-
title: (0,
|
|
3720
|
+
title: (0, import_editor38.getNodeForm)(ctx.node)?.getValueIn("title"),
|
|
3830
3721
|
icon: ctx.node.getNodeRegistry().info?.icon
|
|
3831
3722
|
},
|
|
3832
|
-
type:
|
|
3723
|
+
type: import_editor38.ASTFactory.createObject({
|
|
3833
3724
|
properties: declareRows.map(
|
|
3834
|
-
(_v) =>
|
|
3725
|
+
(_v) => import_editor38.ASTFactory.createProperty({
|
|
3835
3726
|
key: _v.left,
|
|
3836
|
-
type: _v.right?.type === "constant" ?
|
|
3837
|
-
initializer: _v.right?.type === "ref" ?
|
|
3727
|
+
type: _v.right?.type === "constant" ? import_json_schema13.JsonSchemaUtils.schemaToAST(_v.right?.schema || {}) : void 0,
|
|
3728
|
+
initializer: _v.right?.type === "ref" ? import_editor38.ASTFactory.createKeyPathExpression({
|
|
3838
3729
|
keyPath: _v.right?.content || []
|
|
3839
3730
|
}) : {}
|
|
3840
3731
|
})
|
|
@@ -3849,7 +3740,7 @@ var createInferAssignPlugin = (0, import_editor35.defineFormPluginCreator)({
|
|
|
3849
3740
|
(0, import_lodash10.set)(
|
|
3850
3741
|
formData,
|
|
3851
3742
|
outputKey,
|
|
3852
|
-
|
|
3743
|
+
import_json_schema13.JsonSchemaUtils.astToSchema((0, import_editor38.getNodeScope)(ctx.node).output.variables?.[0]?.type)
|
|
3853
3744
|
);
|
|
3854
3745
|
return formData;
|
|
3855
3746
|
});
|
|
@@ -3858,7 +3749,7 @@ var createInferAssignPlugin = (0, import_editor35.defineFormPluginCreator)({
|
|
|
3858
3749
|
|
|
3859
3750
|
// src/validate/validate-flow-value/index.tsx
|
|
3860
3751
|
var import_lodash11 = require("lodash");
|
|
3861
|
-
var
|
|
3752
|
+
var import_editor39 = require("@flowgram.ai/editor");
|
|
3862
3753
|
function validateFlowValue(value, ctx) {
|
|
3863
3754
|
const { node, required, errorMessages } = ctx;
|
|
3864
3755
|
const {
|
|
@@ -3867,15 +3758,15 @@ function validateFlowValue(value, ctx) {
|
|
|
3867
3758
|
} = errorMessages || {};
|
|
3868
3759
|
if (required && ((0, import_lodash11.isNil)(value) || (0, import_lodash11.isNil)(value?.content) || value?.content === "")) {
|
|
3869
3760
|
return {
|
|
3870
|
-
level:
|
|
3761
|
+
level: import_editor39.FeedbackLevel.Error,
|
|
3871
3762
|
message: requiredMessage
|
|
3872
3763
|
};
|
|
3873
3764
|
}
|
|
3874
3765
|
if (value?.type === "ref") {
|
|
3875
|
-
const variable = (0,
|
|
3766
|
+
const variable = (0, import_editor39.getNodeScope)(node).available.getByKeyPath(value?.content || []);
|
|
3876
3767
|
if (!variable) {
|
|
3877
3768
|
return {
|
|
3878
|
-
level:
|
|
3769
|
+
level: import_editor39.FeedbackLevel.Error,
|
|
3879
3770
|
message: unknownVariableMessage
|
|
3880
3771
|
};
|
|
3881
3772
|
}
|
|
@@ -3883,10 +3774,10 @@ function validateFlowValue(value, ctx) {
|
|
|
3883
3774
|
if (value?.type === "template") {
|
|
3884
3775
|
const allRefs = getTemplateKeyPaths2(value);
|
|
3885
3776
|
for (const ref of allRefs) {
|
|
3886
|
-
const variable = (0,
|
|
3777
|
+
const variable = (0, import_editor39.getNodeScope)(node).available.getByKeyPath(ref);
|
|
3887
3778
|
if (!variable) {
|
|
3888
3779
|
return {
|
|
3889
|
-
level:
|
|
3780
|
+
level: import_editor39.FeedbackLevel.Error,
|
|
3890
3781
|
message: unknownVariableMessage
|
|
3891
3782
|
};
|
|
3892
3783
|
}
|
|
@@ -3916,6 +3807,9 @@ function getTemplateKeyPaths2(value) {
|
|
|
3916
3807
|
DisplaySchemaTag,
|
|
3917
3808
|
DisplaySchemaTree,
|
|
3918
3809
|
DynamicValueInput,
|
|
3810
|
+
InjectDynamicValueInput,
|
|
3811
|
+
InjectTypeSelector,
|
|
3812
|
+
InjectVariableSelector,
|
|
3919
3813
|
InputsValues,
|
|
3920
3814
|
JsonEditorWithVariables,
|
|
3921
3815
|
JsonSchemaEditor,
|
|
@@ -3931,6 +3825,7 @@ function getTemplateKeyPaths2(value) {
|
|
|
3931
3825
|
createDisableDeclarationPlugin,
|
|
3932
3826
|
createInferAssignPlugin,
|
|
3933
3827
|
createInferInputsPlugin,
|
|
3828
|
+
createInjectMaterial,
|
|
3934
3829
|
createTypePresetPlugin,
|
|
3935
3830
|
formatLegacyRefOnInit,
|
|
3936
3831
|
formatLegacyRefOnSubmit,
|