@flowgram.ai/form-materials 0.3.3 → 0.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/index.ts +5 -19
- package/bin/materials.ts +31 -89
- package/bin/project.ts +4 -0
- package/bin/utils/import.ts +127 -0
- package/bin/utils/traverse-file.ts +60 -0
- package/dist/esm/index.js +431 -505
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.mts +77 -23
- package/dist/index.d.ts +77 -23
- package/dist/index.js +657 -731
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
- package/src/components/assign-row/index.tsx +4 -4
- package/src/components/assign-rows/index.tsx +1 -1
- package/src/components/batch-outputs/index.tsx +4 -3
- package/src/components/batch-outputs/types.ts +1 -1
- package/src/components/batch-variable-selector/index.tsx +1 -1
- package/src/components/code-editor-mini/index.tsx +1 -1
- package/src/components/condition-row/constants.ts +2 -2
- package/src/components/condition-row/hooks/useOp.tsx +13 -9
- package/src/components/condition-row/hooks/useRule.ts +8 -4
- package/src/components/condition-row/index.tsx +27 -10
- package/src/components/condition-row/types.ts +5 -7
- package/src/components/constant-input/index.tsx +5 -2
- package/src/components/constant-input/types.ts +1 -1
- package/src/components/display-flow-value/index.tsx +2 -2
- package/src/components/display-inputs-values/index.tsx +3 -2
- package/src/components/display-outputs/index.tsx +2 -1
- package/src/components/display-schema-tag/index.tsx +3 -2
- package/src/components/display-schema-tree/index.tsx +2 -1
- package/src/components/dynamic-value-input/hooks.ts +1 -1
- package/src/components/dynamic-value-input/index.tsx +13 -9
- package/src/components/inputs-values/index.tsx +7 -5
- package/src/components/inputs-values/types.ts +3 -3
- package/src/components/json-editor-with-variables/extensions/variable-tree.tsx +1 -1
- package/src/components/json-editor-with-variables/index.tsx +2 -1
- package/src/components/json-schema-editor/default-value.tsx +11 -105
- package/src/components/json-schema-editor/hooks.tsx +53 -94
- package/src/components/json-schema-editor/index.tsx +18 -12
- package/src/components/json-schema-editor/styles.tsx +0 -29
- package/src/components/prompt-editor/types.tsx +1 -1
- package/src/components/prompt-editor-with-inputs/extensions/inputs-tree.tsx +2 -1
- package/src/components/prompt-editor-with-inputs/index.tsx +3 -2
- package/src/components/prompt-editor-with-inputs/inputs-picker.tsx +1 -1
- package/src/components/prompt-editor-with-variables/extensions/variable-tree.tsx +1 -1
- package/src/components/prompt-editor-with-variables/index.tsx +2 -1
- package/src/components/type-selector/index.tsx +9 -7
- package/src/components/variable-selector/index.tsx +9 -5
- package/src/components/variable-selector/use-variable-tree.tsx +1 -1
- package/src/effects/auto-rename-ref/index.ts +1 -1
- package/src/effects/listen-ref-schema-change/index.ts +1 -1
- package/src/effects/listen-ref-value-change/index.ts +1 -1
- package/src/effects/provide-batch-input/index.ts +1 -1
- package/src/form-plugins/batch-outputs-plugin/index.ts +1 -1
- package/src/form-plugins/infer-assign-plugin/index.ts +1 -1
- package/src/form-plugins/infer-inputs-plugin/index.ts +1 -1
- package/src/plugins/json-schema-preset/type-definition/array.tsx +3 -1
- package/src/plugins/json-schema-preset/type-definition/boolean.tsx +4 -3
- package/src/plugins/json-schema-preset/type-definition/integer.tsx +2 -1
- package/src/plugins/json-schema-preset/type-definition/number.tsx +2 -1
- package/src/plugins/json-schema-preset/type-definition/object.tsx +3 -1
- package/src/plugins/json-schema-preset/type-definition/string.tsx +7 -1
- package/src/shared/index.ts +1 -0
- package/src/shared/inject-material/README.md +170 -0
- package/src/shared/inject-material/README.zh.md +174 -0
- package/src/shared/inject-material/index.tsx +87 -0
- package/src/components/assign-row/config.json +0 -11
- package/src/components/assign-rows/config.json +0 -11
- package/src/components/batch-outputs/config.json +0 -13
- package/src/components/batch-variable-selector/config.json +0 -9
- package/src/components/code-editor/config.json +0 -10
- package/src/components/code-editor-mini/config.json +0 -7
- package/src/components/condition-row/config.json +0 -13
- package/src/components/constant-input/config.json +0 -9
- package/src/components/display-flow-value/config.json +0 -8
- package/src/components/display-inputs-values/config.json +0 -9
- package/src/components/display-outputs/config.json +0 -10
- package/src/components/display-schema-tag/config.json +0 -10
- package/src/components/display-schema-tree/config.json +0 -11
- package/src/components/dynamic-value-input/config.json +0 -14
- package/src/components/inputs-values/config.json +0 -13
- package/src/components/json-editor-with-variables/config.json +0 -13
- package/src/components/json-schema-editor/config.json +0 -13
- package/src/components/json-schema-editor/utils.ts +0 -29
- package/src/components/prompt-editor/config.json +0 -9
- package/src/components/prompt-editor-with-inputs/config.json +0 -13
- package/src/components/prompt-editor-with-variables/config.json +0 -13
- package/src/components/type-selector/config.json +0 -9
- package/src/components/variable-selector/config.json +0 -9
- package/src/effects/auto-rename-ref/config.json +0 -5
- package/src/effects/listen-ref-schema-change/config.json +0 -10
- package/src/effects/listen-ref-value-change/config.json +0 -9
- package/src/effects/provide-batch-input/config.json +0 -5
- package/src/effects/provide-json-schema-outputs/config.json +0 -7
- package/src/effects/sync-variable-title/config.json +0 -5
- package/src/effects/validate-when-variable-sync/config.json +0 -5
- package/src/form-plugins/batch-outputs-plugin/config.json +0 -7
- package/src/form-plugins/infer-assign-plugin/config.json +0 -7
- package/src/form-plugins/infer-inputs-plugin/config.json +0 -9
- package/src/hooks/use-object-list/config.json +0 -8
- package/src/shared/format-legacy-refs/config.json +0 -5
- package/src/typings/flow-value/config.json +0 -7
- package/src/validate/validate-flow-value/config.json +0 -7
package/dist/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,41 +90,136 @@ 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
|
|
93
|
+
var import_react13 = __toESM(require("react"));
|
|
94
|
+
var import_editor12 = require("@flowgram.ai/editor");
|
|
90
95
|
var import_semi_ui7 = require("@douyinfe/semi-ui");
|
|
91
96
|
var import_semi_icons = require("@douyinfe/semi-icons");
|
|
92
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
|
+
|
|
93
182
|
// src/components/variable-selector/use-variable-tree.tsx
|
|
94
|
-
var
|
|
183
|
+
var import_react12 = __toESM(require("react"));
|
|
95
184
|
var import_json_schema4 = require("@flowgram.ai/json-schema");
|
|
96
|
-
var
|
|
185
|
+
var import_editor11 = require("@flowgram.ai/editor");
|
|
97
186
|
var import_semi_ui5 = require("@douyinfe/semi-ui");
|
|
98
187
|
|
|
99
188
|
// src/plugins/json-schema-preset/index.tsx
|
|
100
|
-
var
|
|
189
|
+
var import_react11 = __toESM(require("react"));
|
|
101
190
|
var import_json_schema3 = require("@flowgram.ai/json-schema");
|
|
102
191
|
|
|
103
192
|
// src/plugins/json-schema-preset/type-definition/index.tsx
|
|
104
193
|
var import_json_schema = require("@flowgram.ai/json-schema");
|
|
105
194
|
|
|
106
195
|
// src/plugins/json-schema-preset/type-definition/string.tsx
|
|
107
|
-
var
|
|
196
|
+
var import_react2 = __toESM(require("react"));
|
|
197
|
+
var import_editor2 = require("@flowgram.ai/editor");
|
|
108
198
|
var import_semi_ui = require("@douyinfe/semi-ui");
|
|
109
199
|
var stringRegistry = {
|
|
110
200
|
type: "string",
|
|
111
|
-
ConstantRenderer: (props) => /* @__PURE__ */
|
|
201
|
+
ConstantRenderer: (props) => /* @__PURE__ */ import_react2.default.createElement(
|
|
202
|
+
import_semi_ui.Input,
|
|
203
|
+
{
|
|
204
|
+
placeholder: import_editor2.I18n.t("Please Input String"),
|
|
205
|
+
size: "small",
|
|
206
|
+
disabled: props.readonly,
|
|
207
|
+
...props
|
|
208
|
+
}
|
|
209
|
+
)
|
|
112
210
|
};
|
|
113
211
|
|
|
114
212
|
// src/plugins/json-schema-preset/type-definition/object.tsx
|
|
115
|
-
var
|
|
213
|
+
var import_react6 = __toESM(require("react"));
|
|
214
|
+
var import_editor4 = require("@flowgram.ai/editor");
|
|
116
215
|
|
|
117
216
|
// src/components/code-editor-mini/index.tsx
|
|
118
|
-
var
|
|
217
|
+
var import_react5 = __toESM(require("react"));
|
|
119
218
|
var import_styled_components = __toESM(require("styled-components"));
|
|
120
219
|
|
|
121
220
|
// src/components/code-editor/index.tsx
|
|
122
|
-
var
|
|
123
|
-
var
|
|
221
|
+
var import_react3 = __toESM(require("react"));
|
|
222
|
+
var import_react4 = require("@coze-editor/editor/react");
|
|
124
223
|
var import_preset_code5 = __toESM(require("@coze-editor/editor/preset-code"));
|
|
125
224
|
var import_view = require("@codemirror/view");
|
|
126
225
|
|
|
@@ -147,13 +246,13 @@ var import_language_typescript = require("@coze-editor/editor/language-typescrip
|
|
|
147
246
|
var import_language_shell = require("@coze-editor/editor/language-shell");
|
|
148
247
|
var import_language_python = require("@coze-editor/editor/language-python");
|
|
149
248
|
var import_language_json = require("@coze-editor/editor/language-json");
|
|
150
|
-
var
|
|
249
|
+
var import_editor3 = require("@coze-editor/editor");
|
|
151
250
|
import_preset_code.languages.register("python", import_language_python.python);
|
|
152
251
|
import_preset_code.languages.register("shell", import_language_shell.shell);
|
|
153
252
|
import_preset_code.languages.register("typescript", import_language_typescript.typescript);
|
|
154
253
|
import_preset_code.languages.register("json", {
|
|
155
254
|
// mixLanguages is used to solve the problem that interpolation also uses parentheses, which causes incorrect highlighting
|
|
156
|
-
language: (0,
|
|
255
|
+
language: (0, import_editor3.mixLanguages)({
|
|
157
256
|
outerLanguage: import_language_json.json.language
|
|
158
257
|
}),
|
|
159
258
|
languageService: import_language_json.json.languageService
|
|
@@ -407,7 +506,7 @@ import_preset_code4.themes.register("dark", darkTheme);
|
|
|
407
506
|
import_preset_code4.themes.register("light", lightTheme);
|
|
408
507
|
|
|
409
508
|
// src/components/code-editor/index.tsx
|
|
410
|
-
var OriginCodeEditor = (0,
|
|
509
|
+
var OriginCodeEditor = (0, import_react4.createRenderer)(import_preset_code5.default, [
|
|
411
510
|
import_view.EditorView.theme({
|
|
412
511
|
"&.cm-focused": {
|
|
413
512
|
outline: "none"
|
|
@@ -425,18 +524,18 @@ function CodeEditor({
|
|
|
425
524
|
options,
|
|
426
525
|
readonly
|
|
427
526
|
}) {
|
|
428
|
-
const editorRef = (0,
|
|
429
|
-
(0,
|
|
527
|
+
const editorRef = (0, import_react3.useRef)(null);
|
|
528
|
+
(0, import_react3.useEffect)(() => {
|
|
430
529
|
if (languageId === "typescript") {
|
|
431
530
|
initTsWorker();
|
|
432
531
|
}
|
|
433
532
|
}, [languageId]);
|
|
434
|
-
(0,
|
|
533
|
+
(0, import_react3.useEffect)(() => {
|
|
435
534
|
if (editorRef.current?.getValue() !== value) {
|
|
436
535
|
editorRef.current?.setValue(String(value || ""));
|
|
437
536
|
}
|
|
438
537
|
}, [value]);
|
|
439
|
-
return /* @__PURE__ */
|
|
538
|
+
return /* @__PURE__ */ import_react3.default.createElement(import_react4.EditorProvider, null, /* @__PURE__ */ import_react3.default.createElement(
|
|
440
539
|
OriginCodeEditor,
|
|
441
540
|
{
|
|
442
541
|
defaultValue: value,
|
|
@@ -454,7 +553,7 @@ function CodeEditor({
|
|
|
454
553
|
},
|
|
455
554
|
onChange: (e) => onChange?.(e.value)
|
|
456
555
|
},
|
|
457
|
-
activeLinePlaceholder && /* @__PURE__ */
|
|
556
|
+
activeLinePlaceholder && /* @__PURE__ */ import_react3.default.createElement(import_react4.ActiveLinePlaceholder, null, activeLinePlaceholder),
|
|
458
557
|
children
|
|
459
558
|
));
|
|
460
559
|
}
|
|
@@ -466,7 +565,7 @@ var UIMini = import_styled_components.default.div`
|
|
|
466
565
|
}
|
|
467
566
|
`;
|
|
468
567
|
function CodeEditorMini(props) {
|
|
469
|
-
return /* @__PURE__ */
|
|
568
|
+
return /* @__PURE__ */ import_react5.default.createElement(UIMini, null, /* @__PURE__ */ import_react5.default.createElement(
|
|
470
569
|
CodeEditor,
|
|
471
570
|
{
|
|
472
571
|
...props,
|
|
@@ -482,27 +581,28 @@ function CodeEditorMini(props) {
|
|
|
482
581
|
// src/plugins/json-schema-preset/type-definition/object.tsx
|
|
483
582
|
var objectRegistry = {
|
|
484
583
|
type: "object",
|
|
485
|
-
ConstantRenderer: (props) => /* @__PURE__ */
|
|
584
|
+
ConstantRenderer: (props) => /* @__PURE__ */ import_react6.default.createElement(
|
|
486
585
|
CodeEditorMini,
|
|
487
586
|
{
|
|
488
587
|
value: props.value,
|
|
489
588
|
onChange: (v) => props.onChange?.(v),
|
|
490
589
|
languageId: "json",
|
|
491
|
-
placeholder: "Please Input Object",
|
|
590
|
+
placeholder: import_editor4.I18n.t("Please Input Object"),
|
|
492
591
|
readonly: props.readonly
|
|
493
592
|
}
|
|
494
593
|
)
|
|
495
594
|
};
|
|
496
595
|
|
|
497
596
|
// src/plugins/json-schema-preset/type-definition/number.tsx
|
|
498
|
-
var
|
|
597
|
+
var import_react7 = __toESM(require("react"));
|
|
598
|
+
var import_editor5 = require("@flowgram.ai/editor");
|
|
499
599
|
var import_semi_ui2 = require("@douyinfe/semi-ui");
|
|
500
600
|
var numberRegistry = {
|
|
501
601
|
type: "number",
|
|
502
|
-
ConstantRenderer: (props) => /* @__PURE__ */
|
|
602
|
+
ConstantRenderer: (props) => /* @__PURE__ */ import_react7.default.createElement(
|
|
503
603
|
import_semi_ui2.InputNumber,
|
|
504
604
|
{
|
|
505
|
-
placeholder: "Please Input Number",
|
|
605
|
+
placeholder: import_editor5.I18n.t("Please Input Number"),
|
|
506
606
|
size: "small",
|
|
507
607
|
disabled: props.readonly,
|
|
508
608
|
hideButtons: true,
|
|
@@ -512,14 +612,15 @@ var numberRegistry = {
|
|
|
512
612
|
};
|
|
513
613
|
|
|
514
614
|
// src/plugins/json-schema-preset/type-definition/integer.tsx
|
|
515
|
-
var
|
|
615
|
+
var import_react8 = __toESM(require("react"));
|
|
616
|
+
var import_editor6 = require("@flowgram.ai/editor");
|
|
516
617
|
var import_semi_ui3 = require("@douyinfe/semi-ui");
|
|
517
618
|
var integerRegistry = {
|
|
518
619
|
type: "integer",
|
|
519
|
-
ConstantRenderer: (props) => /* @__PURE__ */
|
|
620
|
+
ConstantRenderer: (props) => /* @__PURE__ */ import_react8.default.createElement(
|
|
520
621
|
import_semi_ui3.InputNumber,
|
|
521
622
|
{
|
|
522
|
-
placeholder: "Please Input Integer",
|
|
623
|
+
placeholder: import_editor6.I18n.t("Please Input Integer"),
|
|
523
624
|
size: "small",
|
|
524
625
|
disabled: props.readonly,
|
|
525
626
|
precision: 0,
|
|
@@ -529,21 +630,22 @@ var integerRegistry = {
|
|
|
529
630
|
};
|
|
530
631
|
|
|
531
632
|
// src/plugins/json-schema-preset/type-definition/boolean.tsx
|
|
532
|
-
var
|
|
633
|
+
var import_react9 = __toESM(require("react"));
|
|
634
|
+
var import_editor7 = require("@flowgram.ai/editor");
|
|
533
635
|
var import_semi_ui4 = require("@douyinfe/semi-ui");
|
|
534
636
|
var booleanRegistry = {
|
|
535
637
|
type: "boolean",
|
|
536
638
|
ConstantRenderer: (props) => {
|
|
537
639
|
const { value, onChange, ...rest } = props;
|
|
538
|
-
return /* @__PURE__ */
|
|
640
|
+
return /* @__PURE__ */ import_react9.default.createElement(
|
|
539
641
|
import_semi_ui4.Select,
|
|
540
642
|
{
|
|
541
|
-
placeholder: "Please Select Boolean",
|
|
643
|
+
placeholder: import_editor7.I18n.t("Please Select Boolean"),
|
|
542
644
|
size: "small",
|
|
543
645
|
disabled: props.readonly,
|
|
544
646
|
optionList: [
|
|
545
|
-
{ label: "True", value: 1 },
|
|
546
|
-
{ label: "False", value: 0 }
|
|
647
|
+
{ label: import_editor7.I18n.t("True"), value: 1 },
|
|
648
|
+
{ label: import_editor7.I18n.t("False"), value: 0 }
|
|
547
649
|
],
|
|
548
650
|
value: value ? 1 : 0,
|
|
549
651
|
onChange: (value2) => onChange?.(!!value2),
|
|
@@ -554,16 +656,17 @@ var booleanRegistry = {
|
|
|
554
656
|
};
|
|
555
657
|
|
|
556
658
|
// src/plugins/json-schema-preset/type-definition/array.tsx
|
|
557
|
-
var
|
|
659
|
+
var import_react10 = __toESM(require("react"));
|
|
660
|
+
var import_editor8 = require("@flowgram.ai/editor");
|
|
558
661
|
var arrayRegistry = {
|
|
559
662
|
type: "array",
|
|
560
|
-
ConstantRenderer: (props) => /* @__PURE__ */
|
|
663
|
+
ConstantRenderer: (props) => /* @__PURE__ */ import_react10.default.createElement(
|
|
561
664
|
CodeEditorMini,
|
|
562
665
|
{
|
|
563
666
|
value: props.value,
|
|
564
667
|
languageId: "json",
|
|
565
668
|
onChange: (v) => props.onChange?.(v),
|
|
566
|
-
placeholder: "Please Input Array",
|
|
669
|
+
placeholder: import_editor8.I18n.t("Please Input Array"),
|
|
567
670
|
readonly: props.readonly
|
|
568
671
|
}
|
|
569
672
|
)
|
|
@@ -582,8 +685,8 @@ jsonSchemaTypePreset.forEach((_type) => import_json_schema.jsonSchemaTypeManager
|
|
|
582
685
|
|
|
583
686
|
// src/plugins/json-schema-preset/create-type-preset-plugin.tsx
|
|
584
687
|
var import_json_schema2 = require("@flowgram.ai/json-schema");
|
|
585
|
-
var
|
|
586
|
-
var createTypePresetPlugin = (0,
|
|
688
|
+
var import_editor9 = require("@flowgram.ai/editor");
|
|
689
|
+
var createTypePresetPlugin = (0, import_editor9.definePluginCreator)({
|
|
587
690
|
onInit(ctx, opts) {
|
|
588
691
|
const typeManager = ctx.get(import_json_schema2.BaseTypeManager);
|
|
589
692
|
jsonSchemaTypePreset.forEach((_type) => typeManager.register(_type));
|
|
@@ -598,15 +701,15 @@ var useTypeManager = () => (0, import_json_schema3.useTypeManager)();
|
|
|
598
701
|
var JsonSchemaTypePresetProvider = ({
|
|
599
702
|
types = [],
|
|
600
703
|
children
|
|
601
|
-
}) => /* @__PURE__ */
|
|
704
|
+
}) => /* @__PURE__ */ import_react11.default.createElement(import_json_schema3.TypePresetProvider, { types: [...jsonSchemaTypePreset, ...types] }, children);
|
|
602
705
|
|
|
603
706
|
// src/plugins/disable-declaration-plugin/create-disable-declaration-plugin.ts
|
|
604
|
-
var
|
|
605
|
-
var createDisableDeclarationPlugin = (0,
|
|
707
|
+
var import_editor10 = require("@flowgram.ai/editor");
|
|
708
|
+
var createDisableDeclarationPlugin = (0, import_editor10.definePluginCreator)({
|
|
606
709
|
onInit(ctx) {
|
|
607
|
-
const variableEngine = ctx.get(
|
|
710
|
+
const variableEngine = ctx.get(import_editor10.VariableEngine);
|
|
608
711
|
const handleEvent = (action) => {
|
|
609
|
-
if (
|
|
712
|
+
if (import_editor10.ASTMatch.isVariableDeclaration(action.ast)) {
|
|
610
713
|
if (!action.ast.meta?.disabled) {
|
|
611
714
|
action.ast.updateMeta({
|
|
612
715
|
...action.ast.meta || {},
|
|
@@ -624,16 +727,16 @@ var createDisableDeclarationPlugin = (0, import_editor3.definePluginCreator)({
|
|
|
624
727
|
function useVariableTree(params) {
|
|
625
728
|
const { includeSchema, excludeSchema, customSkip } = params;
|
|
626
729
|
const typeManager = useTypeManager();
|
|
627
|
-
const variables = (0,
|
|
628
|
-
const getVariableTypeIcon = (0,
|
|
730
|
+
const variables = (0, import_editor11.useAvailableVariables)();
|
|
731
|
+
const getVariableTypeIcon = (0, import_react12.useCallback)((variable) => {
|
|
629
732
|
if (variable.meta?.icon) {
|
|
630
733
|
if (typeof variable.meta.icon === "string") {
|
|
631
|
-
return /* @__PURE__ */
|
|
734
|
+
return /* @__PURE__ */ import_react12.default.createElement("img", { style: { marginRight: 8 }, width: 12, height: 12, src: variable.meta.icon });
|
|
632
735
|
}
|
|
633
736
|
return variable.meta.icon;
|
|
634
737
|
}
|
|
635
738
|
const schema = import_json_schema4.JsonSchemaUtils.astToSchema(variable.type, { drilldownObject: false });
|
|
636
|
-
return /* @__PURE__ */
|
|
739
|
+
return /* @__PURE__ */ import_react12.default.createElement(import_semi_ui5.Icon, { size: "small", svg: typeManager.getDisplayIcon(schema || {}) });
|
|
637
740
|
}, []);
|
|
638
741
|
const renderVariable = (variable, parentFields = []) => {
|
|
639
742
|
let type = variable?.type;
|
|
@@ -641,7 +744,7 @@ function useVariableTree(params) {
|
|
|
641
744
|
return null;
|
|
642
745
|
}
|
|
643
746
|
let children;
|
|
644
|
-
if (
|
|
747
|
+
if (import_editor11.ASTMatch.isObject(type)) {
|
|
645
748
|
children = (type.properties || []).map((_property) => renderVariable(_property, [...parentFields, variable])).filter(Boolean);
|
|
646
749
|
}
|
|
647
750
|
const keyPath = [...parentFields.map((_field) => _field.key), variable.key];
|
|
@@ -741,7 +844,7 @@ var VariableSelector = ({
|
|
|
741
844
|
triggerRender
|
|
742
845
|
}) => {
|
|
743
846
|
const treeData = useVariableTree({ includeSchema, excludeSchema });
|
|
744
|
-
const treeValue = (0,
|
|
847
|
+
const treeValue = (0, import_react13.useMemo)(() => {
|
|
745
848
|
if (typeof value === "string") {
|
|
746
849
|
console.warn(
|
|
747
850
|
"The Value of VariableSelector is a string, it should be an ARRAY. \n",
|
|
@@ -753,11 +856,11 @@ var VariableSelector = ({
|
|
|
753
856
|
}, [value]);
|
|
754
857
|
const renderIcon = (icon) => {
|
|
755
858
|
if (typeof icon === "string") {
|
|
756
|
-
return /* @__PURE__ */
|
|
859
|
+
return /* @__PURE__ */ import_react13.default.createElement("img", { style: { marginRight: 8 }, width: 12, height: 12, src: icon });
|
|
757
860
|
}
|
|
758
861
|
return icon;
|
|
759
862
|
};
|
|
760
|
-
return /* @__PURE__ */
|
|
863
|
+
return /* @__PURE__ */ import_react13.default.createElement(import_react13.default.Fragment, null, /* @__PURE__ */ import_react13.default.createElement(
|
|
761
864
|
UITreeSelect,
|
|
762
865
|
{
|
|
763
866
|
dropdownMatchSelectWidth: false,
|
|
@@ -774,10 +877,10 @@ var VariableSelector = ({
|
|
|
774
877
|
},
|
|
775
878
|
renderSelectedItem: (_option) => {
|
|
776
879
|
if (!_option?.keyPath) {
|
|
777
|
-
return /* @__PURE__ */
|
|
880
|
+
return /* @__PURE__ */ import_react13.default.createElement(
|
|
778
881
|
UITag,
|
|
779
882
|
{
|
|
780
|
-
prefixIcon: /* @__PURE__ */
|
|
883
|
+
prefixIcon: /* @__PURE__ */ import_react13.default.createElement(import_semi_icons.IconIssueStroked, null),
|
|
781
884
|
color: "amber",
|
|
782
885
|
closable: !readonly,
|
|
783
886
|
onClose: () => onChange(void 0)
|
|
@@ -786,13 +889,13 @@ var VariableSelector = ({
|
|
|
786
889
|
);
|
|
787
890
|
}
|
|
788
891
|
const rootIcon = renderIcon(_option.rootMeta?.icon || _option?.icon);
|
|
789
|
-
const rootTitle = /* @__PURE__ */
|
|
790
|
-
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(
|
|
791
894
|
import_semi_ui7.Popover,
|
|
792
895
|
{
|
|
793
|
-
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(".")))
|
|
794
897
|
},
|
|
795
|
-
/* @__PURE__ */
|
|
898
|
+
/* @__PURE__ */ import_react13.default.createElement(
|
|
796
899
|
UITag,
|
|
797
900
|
{
|
|
798
901
|
prefixIcon: rootIcon,
|
|
@@ -800,23 +903,24 @@ var VariableSelector = ({
|
|
|
800
903
|
onClose: () => onChange(void 0)
|
|
801
904
|
},
|
|
802
905
|
rootTitle,
|
|
803
|
-
!_option.isRoot && /* @__PURE__ */
|
|
906
|
+
!_option.isRoot && /* @__PURE__ */ import_react13.default.createElement(UIVarName, { $inSelector: true }, _option.label)
|
|
804
907
|
)
|
|
805
908
|
));
|
|
806
909
|
},
|
|
807
910
|
showClear: false,
|
|
808
|
-
arrowIcon: /* @__PURE__ */
|
|
911
|
+
arrowIcon: /* @__PURE__ */ import_react13.default.createElement(import_semi_icons.IconChevronDownStroked, { size: "small" }),
|
|
809
912
|
triggerRender,
|
|
810
|
-
placeholder: config?.placeholder ?? "Select Variable"
|
|
913
|
+
placeholder: config?.placeholder ?? import_editor12.I18n.t("Select Variable")
|
|
811
914
|
}
|
|
812
915
|
));
|
|
813
916
|
};
|
|
917
|
+
VariableSelector.renderKey = "variable-selector-render-key";
|
|
918
|
+
var InjectVariableSelector = createInjectMaterial(VariableSelector);
|
|
814
919
|
|
|
815
920
|
// src/components/type-selector/index.tsx
|
|
816
|
-
var
|
|
921
|
+
var import_react14 = __toESM(require("react"));
|
|
817
922
|
var import_semi_ui8 = require("@douyinfe/semi-ui");
|
|
818
923
|
var labelStyle = { display: "flex", alignItems: "center", gap: 5 };
|
|
819
|
-
var firstUppercase = (str) => str.charAt(0).toUpperCase() + str.slice(1);
|
|
820
924
|
var getTypeSelectValue = (value) => {
|
|
821
925
|
if (value?.type === "array" && value?.items) {
|
|
822
926
|
return [value.type, ...getTypeSelectValue(value.items) || []];
|
|
@@ -832,17 +936,17 @@ var parseTypeSelectValue = (value) => {
|
|
|
832
936
|
};
|
|
833
937
|
function TypeSelector(props) {
|
|
834
938
|
const { value, onChange, readonly, disabled, style } = props;
|
|
835
|
-
const selectValue = (0,
|
|
939
|
+
const selectValue = (0, import_react14.useMemo)(() => getTypeSelectValue(value), [value]);
|
|
836
940
|
const typeManager = useTypeManager();
|
|
837
941
|
const icon = typeManager.getDisplayIcon(value || {});
|
|
838
|
-
const options = (0,
|
|
942
|
+
const options = (0, import_react14.useMemo)(
|
|
839
943
|
() => typeManager.getTypeRegistriesWithParentType().map((_type) => {
|
|
840
944
|
const isArray2 = _type.type === "array";
|
|
841
945
|
return {
|
|
842
|
-
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),
|
|
843
947
|
value: _type.type,
|
|
844
948
|
children: isArray2 ? typeManager.getTypeRegistriesWithParentType("array").map((_type2) => ({
|
|
845
|
-
label: /* @__PURE__ */
|
|
949
|
+
label: /* @__PURE__ */ import_react14.default.createElement("div", { style: labelStyle }, /* @__PURE__ */ import_react14.default.createElement(
|
|
846
950
|
import_semi_ui8.Icon,
|
|
847
951
|
{
|
|
848
952
|
size: "small",
|
|
@@ -851,19 +955,19 @@ function TypeSelector(props) {
|
|
|
851
955
|
items: { type: _type2.type }
|
|
852
956
|
})
|
|
853
957
|
}
|
|
854
|
-
),
|
|
958
|
+
), typeManager.getTypeBySchema(_type2)?.label || _type2.type),
|
|
855
959
|
value: _type2.type
|
|
856
960
|
})) : []
|
|
857
961
|
};
|
|
858
962
|
}),
|
|
859
963
|
[]
|
|
860
964
|
);
|
|
861
|
-
return /* @__PURE__ */
|
|
965
|
+
return /* @__PURE__ */ import_react14.default.createElement(
|
|
862
966
|
import_semi_ui8.Cascader,
|
|
863
967
|
{
|
|
864
968
|
disabled: readonly || disabled,
|
|
865
969
|
size: "small",
|
|
866
|
-
triggerRender: () => /* @__PURE__ */
|
|
970
|
+
triggerRender: () => /* @__PURE__ */ import_react14.default.createElement(import_semi_ui8.IconButton, { size: "small", style, disabled: readonly || disabled, icon }),
|
|
867
971
|
treeData: options,
|
|
868
972
|
value: selectValue,
|
|
869
973
|
leafOnly: true,
|
|
@@ -873,14 +977,17 @@ function TypeSelector(props) {
|
|
|
873
977
|
}
|
|
874
978
|
);
|
|
875
979
|
}
|
|
980
|
+
TypeSelector.renderKey = "type-selector-render-key";
|
|
981
|
+
var InjectTypeSelector = createInjectMaterial(TypeSelector);
|
|
876
982
|
|
|
877
983
|
// src/components/json-schema-editor/index.tsx
|
|
878
|
-
var
|
|
879
|
-
var
|
|
880
|
-
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");
|
|
881
988
|
|
|
882
989
|
// src/components/json-schema-editor/styles.tsx
|
|
883
|
-
var
|
|
990
|
+
var import_react15 = __toESM(require("react"));
|
|
884
991
|
var import_styled_components3 = __toESM(require("styled-components"));
|
|
885
992
|
var import_semi_icons2 = __toESM(require("@douyinfe/semi-icons"));
|
|
886
993
|
var UIContainer = import_styled_components3.default.div`
|
|
@@ -1008,7 +1115,7 @@ var UIRequired = import_styled_components3.default.div``;
|
|
|
1008
1115
|
var UIActions = import_styled_components3.default.div`
|
|
1009
1116
|
white-space: nowrap;
|
|
1010
1117
|
`;
|
|
1011
|
-
var iconAddChildrenSvg = /* @__PURE__ */
|
|
1118
|
+
var iconAddChildrenSvg = /* @__PURE__ */ import_react15.default.createElement(
|
|
1012
1119
|
"svg",
|
|
1013
1120
|
{
|
|
1014
1121
|
className: "icon-icon icon-icon-coz_add_node ",
|
|
@@ -1018,7 +1125,7 @@ var iconAddChildrenSvg = /* @__PURE__ */ import_react14.default.createElement(
|
|
|
1018
1125
|
fill: "currentColor",
|
|
1019
1126
|
xmlns: "http://www.w3.org/2000/svg"
|
|
1020
1127
|
},
|
|
1021
|
-
/* @__PURE__ */
|
|
1128
|
+
/* @__PURE__ */ import_react15.default.createElement(
|
|
1022
1129
|
"path",
|
|
1023
1130
|
{
|
|
1024
1131
|
fillRule: "evenodd",
|
|
@@ -1026,37 +1133,12 @@ var iconAddChildrenSvg = /* @__PURE__ */ import_react14.default.createElement(
|
|
|
1026
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"
|
|
1027
1134
|
}
|
|
1028
1135
|
),
|
|
1029
|
-
/* @__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" })
|
|
1030
1137
|
);
|
|
1031
|
-
var IconAddChildren = () => /* @__PURE__ */
|
|
1138
|
+
var IconAddChildren = () => /* @__PURE__ */ import_react15.default.createElement(import_semi_icons2.default, { size: "small", svg: iconAddChildrenSvg });
|
|
1032
1139
|
var DefaultValueWrapper = import_styled_components3.default.div`
|
|
1033
1140
|
margin: 0;
|
|
1034
1141
|
`;
|
|
1035
|
-
var JSONViewerWrapper = import_styled_components3.default.div`
|
|
1036
|
-
padding: 0 0 24px;
|
|
1037
|
-
&:first-child {
|
|
1038
|
-
margin-top: 0px;
|
|
1039
|
-
}
|
|
1040
|
-
`;
|
|
1041
|
-
var JSONHeader = import_styled_components3.default.div`
|
|
1042
|
-
display: flex;
|
|
1043
|
-
justify-content: space-between;
|
|
1044
|
-
align-items: center;
|
|
1045
|
-
background-color: var(--semi-color-fill-0);
|
|
1046
|
-
border-radius: 6px 6px 0 0;
|
|
1047
|
-
height: 36px;
|
|
1048
|
-
padding: 0 8px 0 12px;
|
|
1049
|
-
`;
|
|
1050
|
-
var JSONHeaderLeft = import_styled_components3.default.div`
|
|
1051
|
-
display: flex;
|
|
1052
|
-
align-items: center;
|
|
1053
|
-
gap: 10px;
|
|
1054
|
-
`;
|
|
1055
|
-
var JSONHeaderRight = import_styled_components3.default.div`
|
|
1056
|
-
display: flex;
|
|
1057
|
-
align-items: center;
|
|
1058
|
-
gap: 10px;
|
|
1059
|
-
`;
|
|
1060
1142
|
var ConstantInputWrapper = import_styled_components3.default.div`
|
|
1061
1143
|
flex-grow: 1;
|
|
1062
1144
|
|
|
@@ -1068,71 +1150,39 @@ var ConstantInputWrapper = import_styled_components3.default.div`
|
|
|
1068
1150
|
`;
|
|
1069
1151
|
|
|
1070
1152
|
// src/components/json-schema-editor/hooks.tsx
|
|
1071
|
-
var
|
|
1072
|
-
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");
|
|
1073
1157
|
var _id = 0;
|
|
1074
1158
|
function genId() {
|
|
1075
1159
|
return _id++;
|
|
1076
1160
|
}
|
|
1077
|
-
function getDrilldownSchema(value, path) {
|
|
1078
|
-
if (!value) {
|
|
1079
|
-
return {};
|
|
1080
|
-
}
|
|
1081
|
-
if (value.type === "array" && value.items) {
|
|
1082
|
-
return getDrilldownSchema(value.items, [...path || [], "items"]);
|
|
1083
|
-
}
|
|
1084
|
-
return { schema: value, path };
|
|
1085
|
-
}
|
|
1086
1161
|
function usePropertiesEdit(value, onChange) {
|
|
1087
|
-
const
|
|
1088
|
-
const
|
|
1089
|
-
const
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
if (_property.name) {
|
|
1112
|
-
nameMap.set(_property.name, _property);
|
|
1113
|
-
}
|
|
1114
|
-
}
|
|
1115
|
-
return Object.entries(drilldown.schema?.properties || {}).sort(([, a], [, b]) => (a.extra?.index ?? 0) - (b.extra?.index ?? 0)).map(([name, _value]) => {
|
|
1116
|
-
const _property = nameMap.get(name);
|
|
1117
|
-
if (_property) {
|
|
1118
|
-
return {
|
|
1119
|
-
key: _property.key,
|
|
1120
|
-
name,
|
|
1121
|
-
isPropertyRequired: drilldown.schema?.required?.includes(name) || false,
|
|
1122
|
-
..._value
|
|
1123
|
-
};
|
|
1124
|
-
}
|
|
1125
|
-
return {
|
|
1126
|
-
key: genId(),
|
|
1127
|
-
name,
|
|
1128
|
-
isPropertyRequired: drilldown.schema?.required?.includes(name) || false,
|
|
1129
|
-
..._value
|
|
1130
|
-
};
|
|
1131
|
-
});
|
|
1132
|
-
});
|
|
1133
|
-
}
|
|
1134
|
-
mountRef.current = true;
|
|
1135
|
-
}, [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]);
|
|
1136
1186
|
const updatePropertyList = (updater) => {
|
|
1137
1187
|
setPropertyList((_list) => {
|
|
1138
1188
|
const next = updater(_list);
|
|
@@ -1142,23 +1192,26 @@ function usePropertiesEdit(value, onChange) {
|
|
|
1142
1192
|
if (!_property.name) {
|
|
1143
1193
|
continue;
|
|
1144
1194
|
}
|
|
1145
|
-
nextProperties[_property.name] = (0,
|
|
1195
|
+
nextProperties[_property.name] = (0, import_lodash2.omit)(_property, ["key", "name", "isPropertyRequired"]);
|
|
1146
1196
|
if (_property.isPropertyRequired) {
|
|
1147
1197
|
nextRequired.push(_property.name);
|
|
1148
1198
|
}
|
|
1149
1199
|
}
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
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
|
+
);
|
|
1157
1210
|
return next;
|
|
1158
1211
|
});
|
|
1159
1212
|
};
|
|
1160
1213
|
const onAddProperty = () => {
|
|
1161
|
-
|
|
1214
|
+
setPropertyList((_list) => [
|
|
1162
1215
|
..._list,
|
|
1163
1216
|
{ key: genId(), name: "", type: "string", extra: { index: _list.length + 1 } }
|
|
1164
1217
|
]);
|
|
@@ -1171,14 +1224,14 @@ function usePropertiesEdit(value, onChange) {
|
|
|
1171
1224
|
(_list) => _list.map((_property) => _property.key === key ? nextValue : _property)
|
|
1172
1225
|
);
|
|
1173
1226
|
};
|
|
1174
|
-
(0,
|
|
1175
|
-
if (!
|
|
1227
|
+
(0, import_react16.useEffect)(() => {
|
|
1228
|
+
if (!canAddField) {
|
|
1176
1229
|
setPropertyList([]);
|
|
1177
1230
|
}
|
|
1178
|
-
}, [
|
|
1231
|
+
}, [canAddField]);
|
|
1179
1232
|
return {
|
|
1180
1233
|
propertyList,
|
|
1181
|
-
|
|
1234
|
+
canAddField,
|
|
1182
1235
|
onAddProperty,
|
|
1183
1236
|
onRemoveProperty,
|
|
1184
1237
|
onEditProperty
|
|
@@ -1186,36 +1239,16 @@ function usePropertiesEdit(value, onChange) {
|
|
|
1186
1239
|
}
|
|
1187
1240
|
|
|
1188
1241
|
// src/components/json-schema-editor/default-value.tsx
|
|
1189
|
-
var
|
|
1190
|
-
var
|
|
1191
|
-
var import_semi_icons3 = require("@douyinfe/semi-icons");
|
|
1192
|
-
|
|
1193
|
-
// src/components/json-schema-editor/utils.ts
|
|
1194
|
-
function getValueType(value) {
|
|
1195
|
-
const type = typeof value;
|
|
1196
|
-
if (type === "string") {
|
|
1197
|
-
return "string";
|
|
1198
|
-
} else if (type === "number") {
|
|
1199
|
-
return Number.isInteger(value) ? "integer" : "number";
|
|
1200
|
-
} else if (type === "boolean") {
|
|
1201
|
-
return "boolean";
|
|
1202
|
-
} else if (type === "object") {
|
|
1203
|
-
if (value === null) {
|
|
1204
|
-
return "other";
|
|
1205
|
-
}
|
|
1206
|
-
return Array.isArray(value) ? "array" : "object";
|
|
1207
|
-
} else {
|
|
1208
|
-
return "other";
|
|
1209
|
-
}
|
|
1210
|
-
}
|
|
1242
|
+
var import_react18 = __toESM(require("react"));
|
|
1243
|
+
var import_editor13 = require("@flowgram.ai/editor");
|
|
1211
1244
|
|
|
1212
1245
|
// src/components/constant-input/index.tsx
|
|
1213
|
-
var
|
|
1246
|
+
var import_react17 = __toESM(require("react"));
|
|
1214
1247
|
var import_semi_ui9 = require("@douyinfe/semi-ui");
|
|
1215
1248
|
function ConstantInput(props) {
|
|
1216
1249
|
const { value, onChange, schema, strategies, fallbackRenderer, readonly, ...rest } = props;
|
|
1217
1250
|
const typeManager = useTypeManager();
|
|
1218
|
-
const Renderer2 = (0,
|
|
1251
|
+
const Renderer2 = (0, import_react17.useMemo)(() => {
|
|
1219
1252
|
const strategy = (strategies || []).find((_strategy) => _strategy.hit(schema));
|
|
1220
1253
|
if (!strategy) {
|
|
1221
1254
|
return typeManager.getTypeBySchema(schema)?.ConstantRenderer;
|
|
@@ -1224,110 +1257,41 @@ function ConstantInput(props) {
|
|
|
1224
1257
|
}, [strategies, schema]);
|
|
1225
1258
|
if (!Renderer2) {
|
|
1226
1259
|
if (fallbackRenderer) {
|
|
1227
|
-
return
|
|
1260
|
+
return import_react17.default.createElement(fallbackRenderer, {
|
|
1228
1261
|
value,
|
|
1229
1262
|
onChange,
|
|
1230
1263
|
readonly,
|
|
1231
1264
|
...rest
|
|
1232
1265
|
});
|
|
1233
1266
|
}
|
|
1234
|
-
return /* @__PURE__ */
|
|
1267
|
+
return /* @__PURE__ */ import_react17.default.createElement(import_semi_ui9.Input, { size: "small", disabled: true, placeholder: "Unsupported type" });
|
|
1235
1268
|
}
|
|
1236
|
-
return /* @__PURE__ */
|
|
1269
|
+
return /* @__PURE__ */ import_react17.default.createElement(Renderer2, { value, onChange, readonly, ...rest });
|
|
1237
1270
|
}
|
|
1238
1271
|
|
|
1239
1272
|
// src/components/json-schema-editor/default-value.tsx
|
|
1240
1273
|
function DefaultValue(props) {
|
|
1241
|
-
const { value, schema,
|
|
1242
|
-
|
|
1243
|
-
const JsonViewerRef = (0, import_react17.useRef)(null);
|
|
1244
|
-
const [internalJsonValue, setInternalJsonValue] = (0, import_react17.useState)(
|
|
1245
|
-
getValueType(value) === "string" ? value : ""
|
|
1246
|
-
);
|
|
1247
|
-
const handleJsonChange = (0, import_react17.useCallback)((val) => {
|
|
1248
|
-
if (val !== internalJsonValue) {
|
|
1249
|
-
setInternalJsonValue(val);
|
|
1250
|
-
}
|
|
1251
|
-
}, []);
|
|
1252
|
-
const handleEditComplete = (0, import_react17.useCallback)(() => {
|
|
1253
|
-
onChange(internalJsonValue);
|
|
1254
|
-
requestAnimationFrame(() => {
|
|
1255
|
-
wrapperRef.current?.blur();
|
|
1256
|
-
});
|
|
1257
|
-
setJsonReadOnly(true);
|
|
1258
|
-
}, [internalJsonValue, onChange]);
|
|
1259
|
-
const [jsonReadOnly, setJsonReadOnly] = (0, import_react17.useState)(true);
|
|
1260
|
-
const handleFormatJson = (0, import_react17.useCallback)(() => {
|
|
1261
|
-
try {
|
|
1262
|
-
const parsed = JSON.parse(internalJsonValue);
|
|
1263
|
-
const formatted = JSON.stringify(parsed, null, 4);
|
|
1264
|
-
setInternalJsonValue(formatted);
|
|
1265
|
-
onChange(formatted);
|
|
1266
|
-
} catch (error) {
|
|
1267
|
-
console.error("Invalid JSON:", error);
|
|
1268
|
-
}
|
|
1269
|
-
}, [internalJsonValue, onChange]);
|
|
1270
|
-
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(
|
|
1271
|
-
import_semi_ui10.IconButton,
|
|
1272
|
-
{
|
|
1273
|
-
icon: /* @__PURE__ */ import_react17.default.createElement(import_semi_icons3.IconBrackets, { style: { color: "var(--semi-color-primary)" } }),
|
|
1274
|
-
size: "small",
|
|
1275
|
-
type: "tertiary",
|
|
1276
|
-
theme: "borderless",
|
|
1277
|
-
onClick: handleFormatJson
|
|
1278
|
-
}
|
|
1279
|
-
)))), /* @__PURE__ */ import_react17.default.createElement(
|
|
1280
|
-
JSONViewerWrapper,
|
|
1281
|
-
{
|
|
1282
|
-
ref: wrapperRef,
|
|
1283
|
-
tabIndex: -1,
|
|
1284
|
-
onBlur: (e) => {
|
|
1285
|
-
if (wrapperRef.current && !wrapperRef.current?.contains(e.relatedTarget)) {
|
|
1286
|
-
handleEditComplete();
|
|
1287
|
-
}
|
|
1288
|
-
},
|
|
1289
|
-
onClick: (e) => {
|
|
1290
|
-
setJsonReadOnly(false);
|
|
1291
|
-
}
|
|
1292
|
-
},
|
|
1293
|
-
/* @__PURE__ */ import_react17.default.createElement(
|
|
1294
|
-
import_semi_ui10.JsonViewer,
|
|
1295
|
-
{
|
|
1296
|
-
ref: JsonViewerRef,
|
|
1297
|
-
value: getValueType(value) === "string" ? value : "",
|
|
1298
|
-
height: 120,
|
|
1299
|
-
width: "100%",
|
|
1300
|
-
showSearch: false,
|
|
1301
|
-
options: {
|
|
1302
|
-
readOnly: jsonReadOnly,
|
|
1303
|
-
formatOptions: { tabSize: 4, insertSpaces: true, eol: "\n" }
|
|
1304
|
-
},
|
|
1305
|
-
style: {
|
|
1306
|
-
padding: 0
|
|
1307
|
-
},
|
|
1308
|
-
onChange: handleJsonChange
|
|
1309
|
-
}
|
|
1310
|
-
)
|
|
1311
|
-
)) : /* @__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(
|
|
1312
1276
|
ConstantInput,
|
|
1313
1277
|
{
|
|
1314
1278
|
value,
|
|
1315
1279
|
onChange: (_v) => onChange(_v),
|
|
1316
1280
|
schema: schema || { type: "string" },
|
|
1317
|
-
placeholder: placeholder ?? "Default value if parameter is not provided"
|
|
1281
|
+
placeholder: placeholder ?? import_editor13.I18n.t("Default value if parameter is not provided")
|
|
1318
1282
|
}
|
|
1319
1283
|
));
|
|
1320
1284
|
}
|
|
1321
1285
|
|
|
1322
1286
|
// src/components/json-schema-editor/components/blur-input.tsx
|
|
1323
|
-
var
|
|
1287
|
+
var import_react19 = __toESM(require("react"));
|
|
1324
1288
|
var import_input = __toESM(require("@douyinfe/semi-ui/lib/es/input"));
|
|
1325
1289
|
function BlurInput(props) {
|
|
1326
|
-
const [value, setValue] = (0,
|
|
1327
|
-
(0,
|
|
1290
|
+
const [value, setValue] = (0, import_react19.useState)("");
|
|
1291
|
+
(0, import_react19.useEffect)(() => {
|
|
1328
1292
|
setValue(props.value);
|
|
1329
1293
|
}, [props.value]);
|
|
1330
|
-
return /* @__PURE__ */
|
|
1294
|
+
return /* @__PURE__ */ import_react19.default.createElement(
|
|
1331
1295
|
import_input.default,
|
|
1332
1296
|
{
|
|
1333
1297
|
...props,
|
|
@@ -1341,13 +1305,14 @@ function BlurInput(props) {
|
|
|
1341
1305
|
}
|
|
1342
1306
|
|
|
1343
1307
|
// src/components/json-schema-editor/index.tsx
|
|
1308
|
+
var DEFAULT = { type: "object" };
|
|
1344
1309
|
function JsonSchemaEditor(props) {
|
|
1345
|
-
const { value =
|
|
1310
|
+
const { value = DEFAULT, config = {}, onChange: onChangeProps, readonly } = props;
|
|
1346
1311
|
const { propertyList, onAddProperty, onRemoveProperty, onEditProperty } = usePropertiesEdit(
|
|
1347
1312
|
value,
|
|
1348
1313
|
onChangeProps
|
|
1349
1314
|
);
|
|
1350
|
-
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(
|
|
1351
1316
|
PropertyEdit,
|
|
1352
1317
|
{
|
|
1353
1318
|
readonly,
|
|
@@ -1362,16 +1327,16 @@ function JsonSchemaEditor(props) {
|
|
|
1362
1327
|
onRemoveProperty(_property.key);
|
|
1363
1328
|
}
|
|
1364
1329
|
}
|
|
1365
|
-
))), /* @__PURE__ */
|
|
1366
|
-
|
|
1330
|
+
))), /* @__PURE__ */ import_react20.default.createElement(
|
|
1331
|
+
import_semi_ui10.Button,
|
|
1367
1332
|
{
|
|
1368
1333
|
disabled: readonly,
|
|
1369
1334
|
size: "small",
|
|
1370
1335
|
style: { marginTop: 10, marginLeft: 16 },
|
|
1371
|
-
icon: /* @__PURE__ */
|
|
1336
|
+
icon: /* @__PURE__ */ import_react20.default.createElement(import_semi_icons3.IconPlus, null),
|
|
1372
1337
|
onClick: onAddProperty
|
|
1373
1338
|
},
|
|
1374
|
-
config?.addButtonText ?? "Add"
|
|
1339
|
+
config?.addButtonText ?? import_editor14.I18n.t("Add")
|
|
1375
1340
|
));
|
|
1376
1341
|
}
|
|
1377
1342
|
function PropertyEdit(props) {
|
|
@@ -1389,19 +1354,19 @@ function PropertyEdit(props) {
|
|
|
1389
1354
|
$parentType = "",
|
|
1390
1355
|
$showLine
|
|
1391
1356
|
} = props;
|
|
1392
|
-
const [expand, setExpand] = (0,
|
|
1393
|
-
const [collapse, setCollapse] = (0,
|
|
1357
|
+
const [expand, setExpand] = (0, import_react20.useState)(false);
|
|
1358
|
+
const [collapse, setCollapse] = (0, import_react20.useState)(false);
|
|
1394
1359
|
const { name, type, items, default: defaultValue, description, isPropertyRequired } = value || {};
|
|
1395
|
-
const typeSelectorValue = (0,
|
|
1396
|
-
const { propertyList,
|
|
1360
|
+
const typeSelectorValue = (0, import_react20.useMemo)(() => ({ type, items }), [type, items]);
|
|
1361
|
+
const { propertyList, canAddField, onAddProperty, onRemoveProperty, onEditProperty } = usePropertiesEdit(value, onChangeProps);
|
|
1397
1362
|
const onChange = (key, _value) => {
|
|
1398
1363
|
onChangeProps?.({
|
|
1399
1364
|
...value || {},
|
|
1400
1365
|
[key]: _value
|
|
1401
1366
|
});
|
|
1402
1367
|
};
|
|
1403
|
-
const showCollapse =
|
|
1404
|
-
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(
|
|
1405
1370
|
UIPropertyLeft,
|
|
1406
1371
|
{
|
|
1407
1372
|
type,
|
|
@@ -1413,8 +1378,8 @@ function PropertyEdit(props) {
|
|
|
1413
1378
|
$parentExpand,
|
|
1414
1379
|
$parentType
|
|
1415
1380
|
},
|
|
1416
|
-
showCollapse && /* @__PURE__ */
|
|
1417
|
-
), /* @__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(
|
|
1418
1383
|
UIPropertyMain,
|
|
1419
1384
|
{
|
|
1420
1385
|
$showCollapse: showCollapse,
|
|
@@ -1422,7 +1387,7 @@ function PropertyEdit(props) {
|
|
|
1422
1387
|
$expand: expand,
|
|
1423
1388
|
type
|
|
1424
1389
|
},
|
|
1425
|
-
/* @__PURE__ */
|
|
1390
|
+
/* @__PURE__ */ import_react20.default.createElement(UIRow, null, /* @__PURE__ */ import_react20.default.createElement(UIName, null, /* @__PURE__ */ import_react20.default.createElement(
|
|
1426
1391
|
BlurInput,
|
|
1427
1392
|
{
|
|
1428
1393
|
disabled: readonly,
|
|
@@ -1431,8 +1396,8 @@ function PropertyEdit(props) {
|
|
|
1431
1396
|
value: name,
|
|
1432
1397
|
onChange: (value2) => onChange("name", value2)
|
|
1433
1398
|
}
|
|
1434
|
-
)), /* @__PURE__ */
|
|
1435
|
-
|
|
1399
|
+
)), /* @__PURE__ */ import_react20.default.createElement(UIType, null, /* @__PURE__ */ import_react20.default.createElement(
|
|
1400
|
+
InjectTypeSelector,
|
|
1436
1401
|
{
|
|
1437
1402
|
value: typeSelectorValue,
|
|
1438
1403
|
readonly,
|
|
@@ -1443,67 +1408,67 @@ function PropertyEdit(props) {
|
|
|
1443
1408
|
});
|
|
1444
1409
|
}
|
|
1445
1410
|
}
|
|
1446
|
-
)), /* @__PURE__ */
|
|
1447
|
-
|
|
1411
|
+
)), /* @__PURE__ */ import_react20.default.createElement(UIRequired, null, /* @__PURE__ */ import_react20.default.createElement(
|
|
1412
|
+
import_semi_ui10.Checkbox,
|
|
1448
1413
|
{
|
|
1449
1414
|
disabled: readonly,
|
|
1450
1415
|
checked: isPropertyRequired,
|
|
1451
1416
|
onChange: (e) => onChange("isPropertyRequired", e.target.checked)
|
|
1452
1417
|
}
|
|
1453
|
-
)), /* @__PURE__ */
|
|
1454
|
-
|
|
1418
|
+
)), /* @__PURE__ */ import_react20.default.createElement(UIActions, null, /* @__PURE__ */ import_react20.default.createElement(
|
|
1419
|
+
import_semi_ui10.IconButton,
|
|
1455
1420
|
{
|
|
1456
1421
|
disabled: readonly,
|
|
1457
1422
|
size: "small",
|
|
1458
1423
|
theme: "borderless",
|
|
1459
|
-
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" }),
|
|
1460
1425
|
onClick: () => {
|
|
1461
1426
|
setExpand((_expand) => !_expand);
|
|
1462
1427
|
}
|
|
1463
1428
|
}
|
|
1464
|
-
),
|
|
1465
|
-
|
|
1429
|
+
), canAddField && /* @__PURE__ */ import_react20.default.createElement(
|
|
1430
|
+
import_semi_ui10.IconButton,
|
|
1466
1431
|
{
|
|
1467
1432
|
disabled: readonly,
|
|
1468
1433
|
size: "small",
|
|
1469
1434
|
theme: "borderless",
|
|
1470
|
-
icon: /* @__PURE__ */
|
|
1435
|
+
icon: /* @__PURE__ */ import_react20.default.createElement(IconAddChildren, null),
|
|
1471
1436
|
onClick: () => {
|
|
1472
1437
|
onAddProperty();
|
|
1473
1438
|
setCollapse(true);
|
|
1474
1439
|
}
|
|
1475
1440
|
}
|
|
1476
|
-
), /* @__PURE__ */
|
|
1477
|
-
|
|
1441
|
+
), /* @__PURE__ */ import_react20.default.createElement(
|
|
1442
|
+
import_semi_ui10.IconButton,
|
|
1478
1443
|
{
|
|
1479
1444
|
disabled: readonly,
|
|
1480
1445
|
size: "small",
|
|
1481
1446
|
theme: "borderless",
|
|
1482
|
-
icon: /* @__PURE__ */
|
|
1447
|
+
icon: /* @__PURE__ */ import_react20.default.createElement(import_semi_icons3.IconMinus, { size: "small" }),
|
|
1483
1448
|
onClick: onRemove
|
|
1484
1449
|
}
|
|
1485
1450
|
))),
|
|
1486
|
-
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(
|
|
1487
1452
|
BlurInput,
|
|
1488
1453
|
{
|
|
1489
1454
|
disabled: readonly,
|
|
1490
1455
|
size: "small",
|
|
1491
1456
|
value: description,
|
|
1492
1457
|
onChange: (value2) => onChange("description", value2),
|
|
1493
|
-
placeholder: config?.descPlaceholder ?? "Help LLM to understand the property"
|
|
1458
|
+
placeholder: config?.descPlaceholder ?? import_editor14.I18n.t("Help LLM to understand the property")
|
|
1494
1459
|
}
|
|
1495
|
-
), $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(
|
|
1496
1461
|
DefaultValue,
|
|
1497
1462
|
{
|
|
1498
1463
|
value: defaultValue,
|
|
1499
1464
|
schema: value,
|
|
1500
1465
|
type,
|
|
1501
|
-
placeholder: config?.defaultValuePlaceholder,
|
|
1466
|
+
placeholder: config?.defaultValuePlaceholder ?? import_editor14.I18n.t("Default Value"),
|
|
1502
1467
|
jsonFormatText: config?.jsonFormatText,
|
|
1503
1468
|
onChange: (value2) => onChange("default", value2)
|
|
1504
1469
|
}
|
|
1505
1470
|
))))
|
|
1506
|
-
), 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(
|
|
1507
1472
|
PropertyEdit,
|
|
1508
1473
|
{
|
|
1509
1474
|
readonly,
|
|
@@ -1528,21 +1493,21 @@ function PropertyEdit(props) {
|
|
|
1528
1493
|
}
|
|
1529
1494
|
|
|
1530
1495
|
// src/components/batch-variable-selector/index.tsx
|
|
1531
|
-
var
|
|
1532
|
-
var
|
|
1496
|
+
var import_react21 = __toESM(require("react"));
|
|
1497
|
+
var import_editor15 = require("@flowgram.ai/editor");
|
|
1533
1498
|
var batchVariableSchema = {
|
|
1534
1499
|
type: "array",
|
|
1535
1500
|
extra: { weak: true }
|
|
1536
1501
|
};
|
|
1537
1502
|
function BatchVariableSelector(props) {
|
|
1538
|
-
return /* @__PURE__ */
|
|
1503
|
+
return /* @__PURE__ */ import_react21.default.createElement(import_editor15.PrivateScopeProvider, null, /* @__PURE__ */ import_react21.default.createElement(VariableSelector, { ...props, includeSchema: batchVariableSchema }));
|
|
1539
1504
|
}
|
|
1540
1505
|
|
|
1541
1506
|
// src/components/dynamic-value-input/index.tsx
|
|
1542
|
-
var
|
|
1543
|
-
var
|
|
1544
|
-
var
|
|
1545
|
-
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");
|
|
1546
1511
|
|
|
1547
1512
|
// src/components/dynamic-value-input/styles.tsx
|
|
1548
1513
|
var import_styled_components4 = __toESM(require("styled-components"));
|
|
@@ -1590,11 +1555,11 @@ var UITrigger = import_styled_components4.default.div`
|
|
|
1590
1555
|
`;
|
|
1591
1556
|
|
|
1592
1557
|
// src/components/dynamic-value-input/hooks.ts
|
|
1593
|
-
var
|
|
1594
|
-
var
|
|
1558
|
+
var import_react22 = require("react");
|
|
1559
|
+
var import_editor16 = require("@flowgram.ai/editor");
|
|
1595
1560
|
function useRefVariable(value) {
|
|
1596
|
-
const available = (0,
|
|
1597
|
-
const refVariable = (0,
|
|
1561
|
+
const available = (0, import_editor16.useScopeAvailable)();
|
|
1562
|
+
const refVariable = (0, import_react22.useMemo)(() => {
|
|
1598
1563
|
if (value?.type === "ref") {
|
|
1599
1564
|
return available.getByKeyPath(value.content);
|
|
1600
1565
|
}
|
|
@@ -1606,11 +1571,11 @@ function useSelectSchema(schemaFromProps, constantProps, value) {
|
|
|
1606
1571
|
if (value?.type === "constant") {
|
|
1607
1572
|
defaultSelectSchema = value?.schema || defaultSelectSchema;
|
|
1608
1573
|
}
|
|
1609
|
-
const [selectSchema, setSelectSchema] = (0,
|
|
1574
|
+
const [selectSchema, setSelectSchema] = (0, import_react22.useState)(defaultSelectSchema);
|
|
1610
1575
|
return [selectSchema, setSelectSchema];
|
|
1611
1576
|
}
|
|
1612
1577
|
function useIncludeSchema(schemaFromProps) {
|
|
1613
|
-
const includeSchema = (0,
|
|
1578
|
+
const includeSchema = (0, import_react22.useMemo)(() => {
|
|
1614
1579
|
if (!schemaFromProps) {
|
|
1615
1580
|
return;
|
|
1616
1581
|
}
|
|
@@ -1636,13 +1601,13 @@ function DynamicValueInput({
|
|
|
1636
1601
|
const includeSchema = useIncludeSchema(schemaFromProps);
|
|
1637
1602
|
const renderTypeSelector = () => {
|
|
1638
1603
|
if (schemaFromProps) {
|
|
1639
|
-
return /* @__PURE__ */
|
|
1604
|
+
return /* @__PURE__ */ import_react23.default.createElement(TypeSelector, { value: schemaFromProps, readonly: true });
|
|
1640
1605
|
}
|
|
1641
1606
|
if (value?.type === "ref") {
|
|
1642
|
-
const schema = refVariable?.type ?
|
|
1643
|
-
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 });
|
|
1644
1609
|
}
|
|
1645
|
-
return /* @__PURE__ */
|
|
1610
|
+
return /* @__PURE__ */ import_react23.default.createElement(
|
|
1646
1611
|
TypeSelector,
|
|
1647
1612
|
{
|
|
1648
1613
|
value: selectSchema,
|
|
@@ -1670,8 +1635,8 @@ function DynamicValueInput({
|
|
|
1670
1635
|
};
|
|
1671
1636
|
const renderMain = () => {
|
|
1672
1637
|
if (value?.type === "ref") {
|
|
1673
|
-
return /* @__PURE__ */
|
|
1674
|
-
|
|
1638
|
+
return /* @__PURE__ */ import_react23.default.createElement(
|
|
1639
|
+
InjectVariableSelector,
|
|
1675
1640
|
{
|
|
1676
1641
|
style: { width: "100%" },
|
|
1677
1642
|
value: value?.content,
|
|
@@ -1682,7 +1647,7 @@ function DynamicValueInput({
|
|
|
1682
1647
|
);
|
|
1683
1648
|
}
|
|
1684
1649
|
const constantSchema = schemaFromProps || selectSchema || { type: "string" };
|
|
1685
|
-
return /* @__PURE__ */
|
|
1650
|
+
return /* @__PURE__ */ import_react23.default.createElement(
|
|
1686
1651
|
ConstantInput,
|
|
1687
1652
|
{
|
|
1688
1653
|
value: value?.content,
|
|
@@ -1690,8 +1655,8 @@ function DynamicValueInput({
|
|
|
1690
1655
|
schema: constantSchema || { type: "string" },
|
|
1691
1656
|
readonly,
|
|
1692
1657
|
strategies: [...constantProps?.strategies || []],
|
|
1693
|
-
fallbackRenderer: () => /* @__PURE__ */
|
|
1694
|
-
|
|
1658
|
+
fallbackRenderer: () => /* @__PURE__ */ import_react23.default.createElement(
|
|
1659
|
+
InjectVariableSelector,
|
|
1695
1660
|
{
|
|
1696
1661
|
style: { width: "100%" },
|
|
1697
1662
|
onChange: (_v) => onChange(_v ? { type: "ref", content: _v } : void 0),
|
|
@@ -1703,23 +1668,26 @@ function DynamicValueInput({
|
|
|
1703
1668
|
}
|
|
1704
1669
|
);
|
|
1705
1670
|
};
|
|
1706
|
-
const renderTrigger = () => /* @__PURE__ */
|
|
1707
|
-
|
|
1671
|
+
const renderTrigger = () => /* @__PURE__ */ import_react23.default.createElement(
|
|
1672
|
+
InjectVariableSelector,
|
|
1708
1673
|
{
|
|
1709
1674
|
style: { width: "100%" },
|
|
1710
1675
|
value: value?.type === "ref" ? value?.content : void 0,
|
|
1711
1676
|
onChange: (_v) => onChange({ type: "ref", content: _v }),
|
|
1712
1677
|
includeSchema,
|
|
1713
1678
|
readonly,
|
|
1714
|
-
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" }) })
|
|
1715
1680
|
}
|
|
1716
1681
|
);
|
|
1717
|
-
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()));
|
|
1718
1683
|
}
|
|
1684
|
+
DynamicValueInput.renderKey = "dynamic-value-input-render-key";
|
|
1685
|
+
var InjectDynamicValueInput = createInjectMaterial(DynamicValueInput);
|
|
1719
1686
|
|
|
1720
1687
|
// src/components/condition-row/index.tsx
|
|
1721
|
-
var
|
|
1722
|
-
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");
|
|
1723
1691
|
|
|
1724
1692
|
// src/components/condition-row/styles.tsx
|
|
1725
1693
|
var import_styled_components5 = __toESM(require("styled-components"));
|
|
@@ -1744,12 +1712,12 @@ var UIValues = import_styled_components5.default.div`
|
|
|
1744
1712
|
`;
|
|
1745
1713
|
|
|
1746
1714
|
// src/components/condition-row/hooks/useRule.ts
|
|
1747
|
-
var
|
|
1748
|
-
var
|
|
1749
|
-
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");
|
|
1750
1718
|
|
|
1751
1719
|
// src/components/condition-row/constants.ts
|
|
1752
|
-
var
|
|
1720
|
+
var defaultRules = {
|
|
1753
1721
|
string: {
|
|
1754
1722
|
["eq" /* EQ */]: "string",
|
|
1755
1723
|
["neq" /* NEQ */]: "string",
|
|
@@ -1805,7 +1773,7 @@ var rules = {
|
|
|
1805
1773
|
["is_not_empty" /* IS_NOT_EMPTY */]: null
|
|
1806
1774
|
}
|
|
1807
1775
|
};
|
|
1808
|
-
var
|
|
1776
|
+
var defaultOpConfigs = {
|
|
1809
1777
|
["eq" /* EQ */]: {
|
|
1810
1778
|
label: "Equal",
|
|
1811
1779
|
abbreviation: "="
|
|
@@ -1869,35 +1837,39 @@ var opConfigs = {
|
|
|
1869
1837
|
};
|
|
1870
1838
|
|
|
1871
1839
|
// src/components/condition-row/hooks/useRule.ts
|
|
1872
|
-
function useRule(left) {
|
|
1873
|
-
const available = (0,
|
|
1874
|
-
const
|
|
1840
|
+
function useRule(left, userRules) {
|
|
1841
|
+
const available = (0, import_editor17.useScopeAvailable)();
|
|
1842
|
+
const rules = (0, import_react24.useMemo)(() => ({ ...defaultRules, ...userRules || {} }), [userRules]);
|
|
1843
|
+
const variable = (0, import_react24.useMemo)(() => {
|
|
1875
1844
|
if (!left) return void 0;
|
|
1876
1845
|
return available.getByKeyPath(left.content);
|
|
1877
1846
|
}, [available, left]);
|
|
1878
|
-
const rule = (0,
|
|
1847
|
+
const rule = (0, import_react24.useMemo)(() => {
|
|
1879
1848
|
if (!variable) return void 0;
|
|
1880
|
-
const schema =
|
|
1849
|
+
const schema = import_json_schema7.JsonSchemaUtils.astToSchema(variable.type, { drilldown: false });
|
|
1881
1850
|
return rules[schema?.type];
|
|
1882
|
-
}, [variable?.type]);
|
|
1851
|
+
}, [variable?.type, rules]);
|
|
1883
1852
|
return { rule };
|
|
1884
1853
|
}
|
|
1885
1854
|
|
|
1886
1855
|
// src/components/condition-row/hooks/useOp.tsx
|
|
1887
|
-
var
|
|
1888
|
-
var
|
|
1889
|
-
var
|
|
1890
|
-
|
|
1891
|
-
|
|
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");
|
|
1860
|
+
function useOp({ rule, op, onChange, readonly, userOps }) {
|
|
1861
|
+
const options = (0, import_react25.useMemo)(
|
|
1892
1862
|
() => Object.keys(rule || {}).map((_op) => ({
|
|
1893
|
-
...
|
|
1894
|
-
|
|
1863
|
+
...defaultOpConfigs[_op] || {},
|
|
1864
|
+
...userOps?.[_op] || {},
|
|
1865
|
+
value: _op,
|
|
1866
|
+
label: import_editor18.I18n.t(userOps?.[_op]?.label || defaultOpConfigs[_op]?.label)
|
|
1895
1867
|
})),
|
|
1896
|
-
[rule]
|
|
1868
|
+
[rule, userOps]
|
|
1897
1869
|
);
|
|
1898
|
-
const opConfig = (0,
|
|
1899
|
-
const renderOpSelect = () => /* @__PURE__ */
|
|
1900
|
-
|
|
1870
|
+
const opConfig = (0, import_react25.useMemo)(() => defaultOpConfigs[op], [op]);
|
|
1871
|
+
const renderOpSelect = () => /* @__PURE__ */ import_react25.default.createElement(
|
|
1872
|
+
import_semi_ui12.Select,
|
|
1901
1873
|
{
|
|
1902
1874
|
style: { height: 22 },
|
|
1903
1875
|
disabled: readonly,
|
|
@@ -1907,28 +1879,39 @@ function useOp({ rule, op, onChange, readonly }) {
|
|
|
1907
1879
|
onChange: (v) => {
|
|
1908
1880
|
onChange(v);
|
|
1909
1881
|
},
|
|
1910
|
-
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" }))
|
|
1911
1883
|
}
|
|
1912
1884
|
);
|
|
1913
1885
|
return { renderOpSelect, opConfig };
|
|
1914
1886
|
}
|
|
1915
1887
|
|
|
1916
1888
|
// src/components/condition-row/index.tsx
|
|
1917
|
-
|
|
1889
|
+
var defaultRuleConfig = {
|
|
1890
|
+
ops: {},
|
|
1891
|
+
rules: {}
|
|
1892
|
+
};
|
|
1893
|
+
function ConditionRow({
|
|
1894
|
+
style,
|
|
1895
|
+
value,
|
|
1896
|
+
onChange,
|
|
1897
|
+
readonly,
|
|
1898
|
+
ruleConfig = defaultRuleConfig
|
|
1899
|
+
}) {
|
|
1918
1900
|
const { left, operator, right } = value || {};
|
|
1919
|
-
const { rule } = useRule(left);
|
|
1901
|
+
const { rule } = useRule(left, ruleConfig.rules);
|
|
1920
1902
|
const { renderOpSelect, opConfig } = useOp({
|
|
1921
1903
|
rule,
|
|
1922
1904
|
op: operator,
|
|
1923
1905
|
onChange: (v) => onChange({ ...value, operator: v }),
|
|
1924
|
-
readonly
|
|
1906
|
+
readonly,
|
|
1907
|
+
userOps: ruleConfig.ops
|
|
1925
1908
|
});
|
|
1926
|
-
const targetSchema = (0,
|
|
1927
|
-
const targetType = rule?.[operator] || null;
|
|
1909
|
+
const targetSchema = (0, import_react26.useMemo)(() => {
|
|
1910
|
+
const targetType = rule?.[operator || ""] || null;
|
|
1928
1911
|
return targetType ? { type: targetType, extra: { weak: true } } : null;
|
|
1929
1912
|
}, [rule, opConfig]);
|
|
1930
|
-
return /* @__PURE__ */
|
|
1931
|
-
|
|
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,
|
|
1932
1915
|
{
|
|
1933
1916
|
readonly,
|
|
1934
1917
|
style: { width: "100%" },
|
|
@@ -1941,34 +1924,34 @@ function ConditionRow({ style, value, onChange, readonly }) {
|
|
|
1941
1924
|
}
|
|
1942
1925
|
})
|
|
1943
1926
|
}
|
|
1944
|
-
)), /* @__PURE__ */
|
|
1945
|
-
|
|
1927
|
+
)), /* @__PURE__ */ import_react26.default.createElement(UIRight, null, targetSchema ? /* @__PURE__ */ import_react26.default.createElement(
|
|
1928
|
+
InjectDynamicValueInput,
|
|
1946
1929
|
{
|
|
1947
1930
|
readonly: readonly || !rule,
|
|
1948
1931
|
value: right,
|
|
1949
1932
|
schema: targetSchema,
|
|
1950
1933
|
onChange: (v) => onChange({ ...value, right: v })
|
|
1951
1934
|
}
|
|
1952
|
-
) : /* @__PURE__ */
|
|
1953
|
-
|
|
1935
|
+
) : /* @__PURE__ */ import_react26.default.createElement(
|
|
1936
|
+
import_semi_ui13.Input,
|
|
1954
1937
|
{
|
|
1955
1938
|
size: "small",
|
|
1956
1939
|
disabled: true,
|
|
1957
1940
|
style: { pointerEvents: "none" },
|
|
1958
|
-
value: opConfig?.rightDisplay || "Empty"
|
|
1941
|
+
value: opConfig?.rightDisplay || import_editor19.I18n.t("Empty")
|
|
1959
1942
|
}
|
|
1960
1943
|
))));
|
|
1961
1944
|
}
|
|
1962
1945
|
|
|
1963
1946
|
// src/components/batch-outputs/index.tsx
|
|
1964
|
-
var
|
|
1965
|
-
var
|
|
1966
|
-
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");
|
|
1967
1950
|
|
|
1968
1951
|
// src/hooks/use-object-list/index.tsx
|
|
1969
|
-
var
|
|
1952
|
+
var import_react27 = require("react");
|
|
1970
1953
|
var import_nanoid = require("nanoid");
|
|
1971
|
-
var
|
|
1954
|
+
var import_lodash3 = require("lodash");
|
|
1972
1955
|
function genId2() {
|
|
1973
1956
|
return (0, import_nanoid.nanoid)();
|
|
1974
1957
|
}
|
|
@@ -1977,12 +1960,12 @@ function useObjectList({
|
|
|
1977
1960
|
onChange,
|
|
1978
1961
|
sortIndexKey
|
|
1979
1962
|
}) {
|
|
1980
|
-
const [list, setList] = (0,
|
|
1981
|
-
(0,
|
|
1963
|
+
const [list, setList] = (0, import_react27.useState)([]);
|
|
1964
|
+
(0, import_react27.useEffect)(() => {
|
|
1982
1965
|
setList((_prevList) => {
|
|
1983
|
-
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);
|
|
1984
1967
|
const oldKeys = _prevList.map((item) => item.key).filter(Boolean);
|
|
1985
|
-
const addKeys = (0,
|
|
1968
|
+
const addKeys = (0, import_lodash3.difference)(newKeys, oldKeys);
|
|
1986
1969
|
return _prevList.filter((item) => !item.key || newKeys.includes(item.key)).map((item) => ({
|
|
1987
1970
|
id: item.id,
|
|
1988
1971
|
key: item.key,
|
|
@@ -2018,8 +2001,8 @@ function useObjectList({
|
|
|
2018
2001
|
onChange(
|
|
2019
2002
|
Object.fromEntries(
|
|
2020
2003
|
nextList.filter((item) => item.key).map((item) => [item.key, item.value]).map((_res, idx) => {
|
|
2021
|
-
if ((0,
|
|
2022
|
-
(0,
|
|
2004
|
+
if ((0, import_lodash3.isObject)(_res[1]) && sortIndexKey) {
|
|
2005
|
+
(0, import_lodash3.set)(_res[1], sortIndexKey, idx);
|
|
2023
2006
|
}
|
|
2024
2007
|
return _res;
|
|
2025
2008
|
})
|
|
@@ -2079,8 +2062,8 @@ var UIRow2 = import_styled_components6.default.div`
|
|
|
2079
2062
|
function BatchOutputs(props) {
|
|
2080
2063
|
const { readonly, style } = props;
|
|
2081
2064
|
const { list, add, updateKey, updateValue, remove } = useObjectList(props);
|
|
2082
|
-
return /* @__PURE__ */
|
|
2083
|
-
|
|
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,
|
|
2084
2067
|
{
|
|
2085
2068
|
style: { width: 100 },
|
|
2086
2069
|
disabled: readonly,
|
|
@@ -2088,28 +2071,28 @@ function BatchOutputs(props) {
|
|
|
2088
2071
|
value: item.key,
|
|
2089
2072
|
onChange: (v) => updateKey(item.id, v)
|
|
2090
2073
|
}
|
|
2091
|
-
), /* @__PURE__ */
|
|
2092
|
-
|
|
2074
|
+
), /* @__PURE__ */ import_react28.default.createElement(
|
|
2075
|
+
InjectVariableSelector,
|
|
2093
2076
|
{
|
|
2094
2077
|
style: { flexGrow: 1 },
|
|
2095
2078
|
readonly,
|
|
2096
2079
|
value: item.value?.content,
|
|
2097
2080
|
onChange: (v) => updateValue(item.id, { type: "ref", content: v })
|
|
2098
2081
|
}
|
|
2099
|
-
), /* @__PURE__ */
|
|
2100
|
-
|
|
2082
|
+
), /* @__PURE__ */ import_react28.default.createElement(
|
|
2083
|
+
import_semi_ui14.Button,
|
|
2101
2084
|
{
|
|
2102
2085
|
disabled: readonly,
|
|
2103
|
-
icon: /* @__PURE__ */
|
|
2086
|
+
icon: /* @__PURE__ */ import_react28.default.createElement(import_semi_icons6.IconDelete, null),
|
|
2104
2087
|
size: "small",
|
|
2105
2088
|
onClick: () => remove(item.id)
|
|
2106
2089
|
}
|
|
2107
|
-
)))), /* @__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"));
|
|
2108
2091
|
}
|
|
2109
2092
|
|
|
2110
2093
|
// src/components/prompt-editor/index.tsx
|
|
2111
|
-
var
|
|
2112
|
-
var
|
|
2094
|
+
var import_react35 = __toESM(require("react"));
|
|
2095
|
+
var import_react36 = require("@coze-editor/editor/react");
|
|
2113
2096
|
var import_preset_prompt2 = __toESM(require("@coze-editor/editor/preset-prompt"));
|
|
2114
2097
|
|
|
2115
2098
|
// src/components/prompt-editor/styles.tsx
|
|
@@ -2125,15 +2108,15 @@ var UIContainer4 = import_styled_components7.default.div`
|
|
|
2125
2108
|
`;
|
|
2126
2109
|
|
|
2127
2110
|
// src/components/prompt-editor/extensions/markdown.tsx
|
|
2128
|
-
var
|
|
2129
|
-
var
|
|
2130
|
-
var
|
|
2111
|
+
var import_react29 = require("react");
|
|
2112
|
+
var import_react30 = require("@coze-editor/editor/react");
|
|
2113
|
+
var import_editor20 = require("@coze-editor/editor");
|
|
2131
2114
|
var import_view2 = require("@codemirror/view");
|
|
2132
2115
|
function MarkdownHighlight() {
|
|
2133
|
-
const injector = (0,
|
|
2134
|
-
(0,
|
|
2116
|
+
const injector = (0, import_react30.useInjector)();
|
|
2117
|
+
(0, import_react29.useLayoutEffect)(
|
|
2135
2118
|
() => injector.inject([
|
|
2136
|
-
|
|
2119
|
+
import_editor20.astDecorator.whole.of((cursor) => {
|
|
2137
2120
|
if (cursor.name.startsWith("ATXHeading")) {
|
|
2138
2121
|
return {
|
|
2139
2122
|
type: "className",
|
|
@@ -2182,26 +2165,26 @@ function MarkdownHighlight() {
|
|
|
2182
2165
|
var markdown_default = MarkdownHighlight;
|
|
2183
2166
|
|
|
2184
2167
|
// src/components/prompt-editor/extensions/language-support.tsx
|
|
2185
|
-
var
|
|
2186
|
-
var
|
|
2168
|
+
var import_react31 = require("react");
|
|
2169
|
+
var import_react32 = require("@coze-editor/editor/react");
|
|
2187
2170
|
var import_preset_prompt = require("@coze-editor/editor/preset-prompt");
|
|
2188
2171
|
function LanguageSupport() {
|
|
2189
|
-
const injector = (0,
|
|
2190
|
-
(0,
|
|
2172
|
+
const injector = (0, import_react32.useInjector)();
|
|
2173
|
+
(0, import_react31.useLayoutEffect)(() => injector.inject([import_preset_prompt.languageSupport]), [injector]);
|
|
2191
2174
|
return null;
|
|
2192
2175
|
}
|
|
2193
2176
|
var language_support_default = LanguageSupport;
|
|
2194
2177
|
|
|
2195
2178
|
// src/components/prompt-editor/extensions/jinja.tsx
|
|
2196
|
-
var
|
|
2197
|
-
var
|
|
2198
|
-
var
|
|
2179
|
+
var import_react33 = require("react");
|
|
2180
|
+
var import_react34 = require("@coze-editor/editor/react");
|
|
2181
|
+
var import_editor21 = require("@coze-editor/editor");
|
|
2199
2182
|
var import_view3 = require("@codemirror/view");
|
|
2200
2183
|
function JinjaHighlight() {
|
|
2201
|
-
const injector = (0,
|
|
2202
|
-
(0,
|
|
2184
|
+
const injector = (0, import_react34.useInjector)();
|
|
2185
|
+
(0, import_react33.useLayoutEffect)(
|
|
2203
2186
|
() => injector.inject([
|
|
2204
|
-
|
|
2187
|
+
import_editor21.astDecorator.whole.of((cursor) => {
|
|
2205
2188
|
if (cursor.name === "JinjaStatementStart" || cursor.name === "JinjaStatementEnd") {
|
|
2206
2189
|
return {
|
|
2207
2190
|
type: "className",
|
|
@@ -2252,14 +2235,14 @@ function PromptEditor(props) {
|
|
|
2252
2235
|
children,
|
|
2253
2236
|
disableMarkdownHighlight
|
|
2254
2237
|
} = props || {};
|
|
2255
|
-
const editorRef = (0,
|
|
2256
|
-
(0,
|
|
2238
|
+
const editorRef = (0, import_react35.useRef)(null);
|
|
2239
|
+
(0, import_react35.useEffect)(() => {
|
|
2257
2240
|
if (editorRef.current?.getValue() !== value?.content) {
|
|
2258
2241
|
editorRef.current?.setValue(String(value?.content || ""));
|
|
2259
2242
|
}
|
|
2260
2243
|
}, [value]);
|
|
2261
|
-
return /* @__PURE__ */
|
|
2262
|
-
|
|
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,
|
|
2263
2246
|
{
|
|
2264
2247
|
didMount: (editor) => {
|
|
2265
2248
|
editorRef.current = editor;
|
|
@@ -2275,23 +2258,23 @@ function PromptEditor(props) {
|
|
|
2275
2258
|
onChange({ type: "template", content: e.value });
|
|
2276
2259
|
}
|
|
2277
2260
|
}
|
|
2278
|
-
), 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));
|
|
2279
2262
|
}
|
|
2280
2263
|
|
|
2281
2264
|
// src/components/prompt-editor-with-variables/index.tsx
|
|
2282
|
-
var
|
|
2265
|
+
var import_react41 = __toESM(require("react"));
|
|
2283
2266
|
|
|
2284
2267
|
// src/components/prompt-editor-with-variables/extensions/variable-tree.tsx
|
|
2285
|
-
var
|
|
2286
|
-
var
|
|
2287
|
-
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");
|
|
2288
2271
|
function VariableTree() {
|
|
2289
|
-
const [posKey, setPosKey] = (0,
|
|
2290
|
-
const [visible, setVisible] = (0,
|
|
2291
|
-
const [position, setPosition] = (0,
|
|
2292
|
-
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)();
|
|
2293
2276
|
function insert(variablePath) {
|
|
2294
|
-
const range = (0,
|
|
2277
|
+
const range = (0, import_react38.getCurrentMentionReplaceRange)(editor.$view.state);
|
|
2295
2278
|
if (!range) {
|
|
2296
2279
|
return;
|
|
2297
2280
|
}
|
|
@@ -2305,21 +2288,21 @@ function VariableTree() {
|
|
|
2305
2288
|
setPosition(e.state.selection.main.head);
|
|
2306
2289
|
setVisible(e.value);
|
|
2307
2290
|
}
|
|
2308
|
-
(0,
|
|
2291
|
+
(0, import_react37.useEffect)(() => {
|
|
2309
2292
|
if (!editor) {
|
|
2310
2293
|
return;
|
|
2311
2294
|
}
|
|
2312
2295
|
}, [editor, visible]);
|
|
2313
2296
|
const treeData = useVariableTree({});
|
|
2314
|
-
return /* @__PURE__ */
|
|
2315
|
-
|
|
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,
|
|
2316
2299
|
{
|
|
2317
2300
|
visible,
|
|
2318
2301
|
trigger: "custom",
|
|
2319
2302
|
position: "topLeft",
|
|
2320
2303
|
rePosKey: posKey,
|
|
2321
|
-
content: /* @__PURE__ */
|
|
2322
|
-
|
|
2304
|
+
content: /* @__PURE__ */ import_react37.default.createElement("div", { style: { width: 300 } }, /* @__PURE__ */ import_react37.default.createElement(
|
|
2305
|
+
import_semi_ui15.Tree,
|
|
2323
2306
|
{
|
|
2324
2307
|
treeData,
|
|
2325
2308
|
onSelect: (v) => {
|
|
@@ -2328,8 +2311,8 @@ function VariableTree() {
|
|
|
2328
2311
|
}
|
|
2329
2312
|
))
|
|
2330
2313
|
},
|
|
2331
|
-
/* @__PURE__ */
|
|
2332
|
-
|
|
2314
|
+
/* @__PURE__ */ import_react37.default.createElement(
|
|
2315
|
+
import_react38.PositionMirror,
|
|
2333
2316
|
{
|
|
2334
2317
|
position,
|
|
2335
2318
|
onChange: () => setPosKey(String(Math.random()))
|
|
@@ -2340,17 +2323,17 @@ function VariableTree() {
|
|
|
2340
2323
|
|
|
2341
2324
|
// src/components/prompt-editor-with-variables/extensions/variable-tag.tsx
|
|
2342
2325
|
var import_react_dom = __toESM(require("react-dom"));
|
|
2343
|
-
var
|
|
2344
|
-
var
|
|
2345
|
-
var
|
|
2346
|
-
var
|
|
2347
|
-
var
|
|
2348
|
-
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");
|
|
2349
2332
|
var import_view4 = require("@codemirror/view");
|
|
2350
2333
|
|
|
2351
2334
|
// src/components/prompt-editor-with-variables/styles.tsx
|
|
2352
2335
|
var import_styled_components8 = __toESM(require("styled-components"));
|
|
2353
|
-
var
|
|
2336
|
+
var import_semi_ui16 = require("@douyinfe/semi-ui");
|
|
2354
2337
|
var UIRootTitle2 = import_styled_components8.default.div`
|
|
2355
2338
|
margin-right: 4px;
|
|
2356
2339
|
min-width: 20px;
|
|
@@ -2364,7 +2347,7 @@ var UIVarName2 = import_styled_components8.default.div`
|
|
|
2364
2347
|
text-overflow: ellipsis;
|
|
2365
2348
|
white-space: nowrap;
|
|
2366
2349
|
`;
|
|
2367
|
-
var UITag2 = (0, import_styled_components8.default)(
|
|
2350
|
+
var UITag2 = (0, import_styled_components8.default)(import_semi_ui16.Tag)`
|
|
2368
2351
|
display: inline-flex;
|
|
2369
2352
|
align-items: center;
|
|
2370
2353
|
justify-content: flex-start;
|
|
@@ -2389,10 +2372,10 @@ var UIPopoverContent2 = import_styled_components8.default.div`
|
|
|
2389
2372
|
var VariableTagWidget = class extends import_view4.WidgetType {
|
|
2390
2373
|
constructor({ keyPath, scope }) {
|
|
2391
2374
|
super();
|
|
2392
|
-
this.toDispose = new
|
|
2375
|
+
this.toDispose = new import_editor22.DisposableCollection();
|
|
2393
2376
|
this.renderIcon = (icon) => {
|
|
2394
2377
|
if (typeof icon === "string") {
|
|
2395
|
-
return /* @__PURE__ */
|
|
2378
|
+
return /* @__PURE__ */ import_react39.default.createElement("img", { style: { marginRight: 8 }, width: 12, height: 12, src: icon });
|
|
2396
2379
|
}
|
|
2397
2380
|
return icon;
|
|
2398
2381
|
};
|
|
@@ -2405,21 +2388,21 @@ var VariableTagWidget = class extends import_view4.WidgetType {
|
|
|
2405
2388
|
renderVariable(v) {
|
|
2406
2389
|
if (!v) {
|
|
2407
2390
|
this.renderReact(
|
|
2408
|
-
/* @__PURE__ */
|
|
2391
|
+
/* @__PURE__ */ import_react39.default.createElement(UITag2, { prefixIcon: /* @__PURE__ */ import_react39.default.createElement(import_semi_icons7.IconIssueStroked, null), color: "amber" }, "Unknown")
|
|
2409
2392
|
);
|
|
2410
2393
|
return;
|
|
2411
2394
|
}
|
|
2412
|
-
const rootField = (0,
|
|
2395
|
+
const rootField = (0, import_lodash4.last)(v.parentFields) || v;
|
|
2413
2396
|
const isRoot = v.parentFields.length === 0;
|
|
2414
|
-
const rootTitle = /* @__PURE__ */
|
|
2397
|
+
const rootTitle = /* @__PURE__ */ import_react39.default.createElement(UIRootTitle2, null, rootField?.meta.title ? `${rootField.meta.title} ${isRoot ? "" : "-"} ` : "");
|
|
2415
2398
|
const rootIcon = this.renderIcon(rootField?.meta.icon);
|
|
2416
2399
|
this.renderReact(
|
|
2417
|
-
/* @__PURE__ */
|
|
2418
|
-
|
|
2400
|
+
/* @__PURE__ */ import_react39.default.createElement(
|
|
2401
|
+
import_semi_ui17.Popover,
|
|
2419
2402
|
{
|
|
2420
|
-
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(".")))
|
|
2421
2404
|
},
|
|
2422
|
-
/* @__PURE__ */
|
|
2405
|
+
/* @__PURE__ */ import_react39.default.createElement(UITag2, { prefixIcon: rootIcon }, rootTitle, !isRoot && /* @__PURE__ */ import_react39.default.createElement(UIVarName2, null, v?.key))
|
|
2423
2406
|
)
|
|
2424
2407
|
);
|
|
2425
2408
|
}
|
|
@@ -2427,7 +2410,7 @@ var VariableTagWidget = class extends import_view4.WidgetType {
|
|
|
2427
2410
|
const dom = document.createElement("span");
|
|
2428
2411
|
this.rootDOM = dom;
|
|
2429
2412
|
this.toDispose.push(
|
|
2430
|
-
|
|
2413
|
+
import_editor22.Disposable.create(() => {
|
|
2431
2414
|
import_react_dom.default.unmountComponentAtNode(this.rootDOM);
|
|
2432
2415
|
})
|
|
2433
2416
|
);
|
|
@@ -2444,7 +2427,7 @@ var VariableTagWidget = class extends import_view4.WidgetType {
|
|
|
2444
2427
|
return dom;
|
|
2445
2428
|
}
|
|
2446
2429
|
eq(other) {
|
|
2447
|
-
return (0,
|
|
2430
|
+
return (0, import_lodash4.isEqual)(this.keyPath, other.keyPath);
|
|
2448
2431
|
}
|
|
2449
2432
|
ignoreEvent() {
|
|
2450
2433
|
return false;
|
|
@@ -2454,9 +2437,9 @@ var VariableTagWidget = class extends import_view4.WidgetType {
|
|
|
2454
2437
|
}
|
|
2455
2438
|
};
|
|
2456
2439
|
function VariableTagInject() {
|
|
2457
|
-
const injector = (0,
|
|
2458
|
-
const scope = (0,
|
|
2459
|
-
(0,
|
|
2440
|
+
const injector = (0, import_react40.useInjector)();
|
|
2441
|
+
const scope = (0, import_editor22.useCurrentScope)();
|
|
2442
|
+
(0, import_react39.useLayoutEffect)(() => {
|
|
2460
2443
|
const atMatcher = new import_view4.MatchDecorator({
|
|
2461
2444
|
regexp: /\{\{([^\}]+)\}\}/g,
|
|
2462
2445
|
decoration: (match) => import_view4.Decoration.replace({
|
|
@@ -2493,29 +2476,29 @@ function VariableTagInject() {
|
|
|
2493
2476
|
|
|
2494
2477
|
// src/components/prompt-editor-with-variables/index.tsx
|
|
2495
2478
|
function PromptEditorWithVariables(props) {
|
|
2496
|
-
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));
|
|
2497
2480
|
}
|
|
2498
2481
|
|
|
2499
2482
|
// src/components/prompt-editor-with-inputs/index.tsx
|
|
2500
|
-
var
|
|
2483
|
+
var import_react45 = __toESM(require("react"));
|
|
2501
2484
|
|
|
2502
2485
|
// src/components/prompt-editor-with-inputs/extensions/inputs-tree.tsx
|
|
2503
|
-
var
|
|
2504
|
-
var
|
|
2505
|
-
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");
|
|
2506
2489
|
|
|
2507
2490
|
// src/components/prompt-editor-with-inputs/inputs-picker.tsx
|
|
2508
|
-
var
|
|
2509
|
-
var
|
|
2510
|
-
var
|
|
2511
|
-
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");
|
|
2512
2495
|
function InputsPicker({
|
|
2513
2496
|
inputsValues,
|
|
2514
2497
|
onSelect
|
|
2515
2498
|
}) {
|
|
2516
|
-
const available = (0,
|
|
2499
|
+
const available = (0, import_editor23.useScopeAvailable)();
|
|
2517
2500
|
const getArrayDrilldown = (type, depth = 1) => {
|
|
2518
|
-
if (
|
|
2501
|
+
if (import_editor23.ASTMatch.isArray(type.items)) {
|
|
2519
2502
|
return getArrayDrilldown(type.items, depth + 1);
|
|
2520
2503
|
}
|
|
2521
2504
|
return { type: type.items, depth };
|
|
@@ -2523,12 +2506,12 @@ function InputsPicker({
|
|
|
2523
2506
|
const renderVariable = (variable, keyPath) => {
|
|
2524
2507
|
let type = variable?.type;
|
|
2525
2508
|
let children;
|
|
2526
|
-
if (
|
|
2509
|
+
if (import_editor23.ASTMatch.isObject(type)) {
|
|
2527
2510
|
children = (type.properties || []).map((_property) => renderVariable(_property, [...keyPath, _property.key])).filter(Boolean);
|
|
2528
2511
|
}
|
|
2529
|
-
if (
|
|
2512
|
+
if (import_editor23.ASTMatch.isArray(type)) {
|
|
2530
2513
|
const drilldown = getArrayDrilldown(type);
|
|
2531
|
-
if (
|
|
2514
|
+
if (import_editor23.ASTMatch.isObject(drilldown.type)) {
|
|
2532
2515
|
children = (drilldown.type.properties || []).map(
|
|
2533
2516
|
(_property) => renderVariable(_property, [
|
|
2534
2517
|
...keyPath,
|
|
@@ -2541,12 +2524,12 @@ function InputsPicker({
|
|
|
2541
2524
|
const key = keyPath.map((_key, idx) => _key === "[0]" || idx === 0 ? _key : `.${_key}`).join("");
|
|
2542
2525
|
return {
|
|
2543
2526
|
key,
|
|
2544
|
-
label: (0,
|
|
2527
|
+
label: (0, import_lodash5.last)(keyPath),
|
|
2545
2528
|
value: key,
|
|
2546
2529
|
children
|
|
2547
2530
|
};
|
|
2548
2531
|
};
|
|
2549
|
-
const treeData = (0,
|
|
2532
|
+
const treeData = (0, import_react42.useMemo)(
|
|
2550
2533
|
() => Object.entries(inputsValues).map(([key, value]) => {
|
|
2551
2534
|
if (value?.type === "ref") {
|
|
2552
2535
|
const variable = available.getByKeyPath(value.content || []);
|
|
@@ -2562,17 +2545,17 @@ function InputsPicker({
|
|
|
2562
2545
|
}),
|
|
2563
2546
|
[]
|
|
2564
2547
|
);
|
|
2565
|
-
return /* @__PURE__ */
|
|
2548
|
+
return /* @__PURE__ */ import_react42.default.createElement(import_semi_ui18.Tree, { treeData, onSelect: (v) => onSelect(v) });
|
|
2566
2549
|
}
|
|
2567
2550
|
|
|
2568
2551
|
// src/components/prompt-editor-with-inputs/extensions/inputs-tree.tsx
|
|
2569
2552
|
function InputsTree({ inputsValues }) {
|
|
2570
|
-
const [posKey, setPosKey] = (0,
|
|
2571
|
-
const [visible, setVisible] = (0,
|
|
2572
|
-
const [position, setPosition] = (0,
|
|
2573
|
-
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)();
|
|
2574
2557
|
function insert(variablePath) {
|
|
2575
|
-
const range = (0,
|
|
2558
|
+
const range = (0, import_react44.getCurrentMentionReplaceRange)(editor.$view.state);
|
|
2576
2559
|
if (!range) {
|
|
2577
2560
|
return;
|
|
2578
2561
|
}
|
|
@@ -2586,19 +2569,19 @@ function InputsTree({ inputsValues }) {
|
|
|
2586
2569
|
setPosition(e.state.selection.main.head);
|
|
2587
2570
|
setVisible(e.value);
|
|
2588
2571
|
}
|
|
2589
|
-
(0,
|
|
2572
|
+
(0, import_react43.useEffect)(() => {
|
|
2590
2573
|
if (!editor) {
|
|
2591
2574
|
return;
|
|
2592
2575
|
}
|
|
2593
2576
|
}, [editor, visible]);
|
|
2594
|
-
return /* @__PURE__ */
|
|
2595
|
-
|
|
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,
|
|
2596
2579
|
{
|
|
2597
2580
|
visible,
|
|
2598
2581
|
trigger: "custom",
|
|
2599
2582
|
position: "topLeft",
|
|
2600
2583
|
rePosKey: posKey,
|
|
2601
|
-
content: /* @__PURE__ */
|
|
2584
|
+
content: /* @__PURE__ */ import_react43.default.createElement("div", { style: { width: 300 } }, /* @__PURE__ */ import_react43.default.createElement(
|
|
2602
2585
|
InputsPicker,
|
|
2603
2586
|
{
|
|
2604
2587
|
inputsValues,
|
|
@@ -2608,8 +2591,8 @@ function InputsTree({ inputsValues }) {
|
|
|
2608
2591
|
}
|
|
2609
2592
|
))
|
|
2610
2593
|
},
|
|
2611
|
-
/* @__PURE__ */
|
|
2612
|
-
|
|
2594
|
+
/* @__PURE__ */ import_react43.default.createElement(
|
|
2595
|
+
import_react44.PositionMirror,
|
|
2613
2596
|
{
|
|
2614
2597
|
position,
|
|
2615
2598
|
onChange: () => setPosKey(String(Math.random()))
|
|
@@ -2620,24 +2603,24 @@ function InputsTree({ inputsValues }) {
|
|
|
2620
2603
|
|
|
2621
2604
|
// src/components/prompt-editor-with-inputs/index.tsx
|
|
2622
2605
|
function PromptEditorWithInputs({ inputsValues, ...restProps }) {
|
|
2623
|
-
return /* @__PURE__ */
|
|
2606
|
+
return /* @__PURE__ */ import_react45.default.createElement(PromptEditor, { ...restProps }, /* @__PURE__ */ import_react45.default.createElement(InputsTree, { inputsValues }));
|
|
2624
2607
|
}
|
|
2625
2608
|
|
|
2626
2609
|
// src/components/json-editor-with-variables/index.tsx
|
|
2627
|
-
var
|
|
2610
|
+
var import_react50 = __toESM(require("react"));
|
|
2628
2611
|
var import_preset_code6 = require("@coze-editor/editor/preset-code");
|
|
2629
2612
|
|
|
2630
2613
|
// src/components/json-editor-with-variables/extensions/variable-tree.tsx
|
|
2631
|
-
var
|
|
2632
|
-
var
|
|
2633
|
-
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");
|
|
2634
2617
|
function VariableTree2() {
|
|
2635
|
-
const [posKey, setPosKey] = (0,
|
|
2636
|
-
const [visible, setVisible] = (0,
|
|
2637
|
-
const [position, setPosition] = (0,
|
|
2638
|
-
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)();
|
|
2639
2622
|
function insert(variablePath) {
|
|
2640
|
-
const range = (0,
|
|
2623
|
+
const range = (0, import_react47.getCurrentMentionReplaceRange)(editor.$view.state);
|
|
2641
2624
|
if (!range) {
|
|
2642
2625
|
return;
|
|
2643
2626
|
}
|
|
@@ -2651,21 +2634,21 @@ function VariableTree2() {
|
|
|
2651
2634
|
setPosition(e.state.selection.main.head);
|
|
2652
2635
|
setVisible(e.value);
|
|
2653
2636
|
}
|
|
2654
|
-
(0,
|
|
2637
|
+
(0, import_react46.useEffect)(() => {
|
|
2655
2638
|
if (!editor) {
|
|
2656
2639
|
return;
|
|
2657
2640
|
}
|
|
2658
2641
|
}, [editor, visible]);
|
|
2659
2642
|
const treeData = useVariableTree({});
|
|
2660
|
-
return /* @__PURE__ */
|
|
2661
|
-
|
|
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,
|
|
2662
2645
|
{
|
|
2663
2646
|
visible,
|
|
2664
2647
|
trigger: "custom",
|
|
2665
2648
|
position: "topLeft",
|
|
2666
2649
|
rePosKey: posKey,
|
|
2667
|
-
content: /* @__PURE__ */
|
|
2668
|
-
|
|
2650
|
+
content: /* @__PURE__ */ import_react46.default.createElement("div", { style: { width: 300 } }, /* @__PURE__ */ import_react46.default.createElement(
|
|
2651
|
+
import_semi_ui20.Tree,
|
|
2669
2652
|
{
|
|
2670
2653
|
treeData,
|
|
2671
2654
|
onSelect: (v) => {
|
|
@@ -2674,8 +2657,8 @@ function VariableTree2() {
|
|
|
2674
2657
|
}
|
|
2675
2658
|
))
|
|
2676
2659
|
},
|
|
2677
|
-
/* @__PURE__ */
|
|
2678
|
-
|
|
2660
|
+
/* @__PURE__ */ import_react46.default.createElement(
|
|
2661
|
+
import_react47.PositionMirror,
|
|
2679
2662
|
{
|
|
2680
2663
|
position,
|
|
2681
2664
|
onChange: () => setPosKey(String(Math.random()))
|
|
@@ -2685,18 +2668,18 @@ function VariableTree2() {
|
|
|
2685
2668
|
}
|
|
2686
2669
|
|
|
2687
2670
|
// src/components/json-editor-with-variables/extensions/variable-tag.tsx
|
|
2688
|
-
var
|
|
2671
|
+
var import_react48 = __toESM(require("react"));
|
|
2689
2672
|
var import_client = require("react-dom/client");
|
|
2690
|
-
var
|
|
2691
|
-
var
|
|
2692
|
-
var
|
|
2693
|
-
var
|
|
2694
|
-
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");
|
|
2695
2678
|
var import_view5 = require("@codemirror/view");
|
|
2696
2679
|
|
|
2697
2680
|
// src/components/json-editor-with-variables/styles.tsx
|
|
2698
2681
|
var import_styled_components9 = __toESM(require("styled-components"));
|
|
2699
|
-
var
|
|
2682
|
+
var import_semi_ui21 = require("@douyinfe/semi-ui");
|
|
2700
2683
|
var UIRootTitle3 = import_styled_components9.default.div`
|
|
2701
2684
|
margin-right: 4px;
|
|
2702
2685
|
min-width: 20px;
|
|
@@ -2710,7 +2693,7 @@ var UIVarName3 = import_styled_components9.default.div`
|
|
|
2710
2693
|
text-overflow: ellipsis;
|
|
2711
2694
|
white-space: nowrap;
|
|
2712
2695
|
`;
|
|
2713
|
-
var UITag3 = (0, import_styled_components9.default)(
|
|
2696
|
+
var UITag3 = (0, import_styled_components9.default)(import_semi_ui21.Tag)`
|
|
2714
2697
|
display: inline-flex;
|
|
2715
2698
|
align-items: center;
|
|
2716
2699
|
justify-content: flex-start;
|
|
@@ -2735,10 +2718,10 @@ var UIPopoverContent3 = import_styled_components9.default.div`
|
|
|
2735
2718
|
var VariableTagWidget2 = class extends import_view5.WidgetType {
|
|
2736
2719
|
constructor({ keyPath, scope }) {
|
|
2737
2720
|
super();
|
|
2738
|
-
this.toDispose = new
|
|
2721
|
+
this.toDispose = new import_editor24.DisposableCollection();
|
|
2739
2722
|
this.renderIcon = (icon) => {
|
|
2740
2723
|
if (typeof icon === "string") {
|
|
2741
|
-
return /* @__PURE__ */
|
|
2724
|
+
return /* @__PURE__ */ import_react48.default.createElement("img", { style: { marginRight: 8 }, width: 12, height: 12, src: icon });
|
|
2742
2725
|
}
|
|
2743
2726
|
return icon;
|
|
2744
2727
|
};
|
|
@@ -2748,20 +2731,20 @@ var VariableTagWidget2 = class extends import_view5.WidgetType {
|
|
|
2748
2731
|
renderVariable(v) {
|
|
2749
2732
|
if (!v) {
|
|
2750
2733
|
this.root.render(
|
|
2751
|
-
/* @__PURE__ */
|
|
2734
|
+
/* @__PURE__ */ import_react48.default.createElement(UITag3, { prefixIcon: /* @__PURE__ */ import_react48.default.createElement(import_semi_icons8.IconIssueStroked, null), color: "amber" }, "Unknown")
|
|
2752
2735
|
);
|
|
2753
2736
|
return;
|
|
2754
2737
|
}
|
|
2755
|
-
const rootField = (0,
|
|
2756
|
-
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} -` : "");
|
|
2757
2740
|
const rootIcon = this.renderIcon(rootField?.meta.icon);
|
|
2758
2741
|
this.root.render(
|
|
2759
|
-
/* @__PURE__ */
|
|
2760
|
-
|
|
2742
|
+
/* @__PURE__ */ import_react48.default.createElement(
|
|
2743
|
+
import_semi_ui22.Popover,
|
|
2761
2744
|
{
|
|
2762
|
-
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(".")))
|
|
2763
2746
|
},
|
|
2764
|
-
/* @__PURE__ */
|
|
2747
|
+
/* @__PURE__ */ import_react48.default.createElement(UITag3, { prefixIcon: rootIcon }, rootTitle, /* @__PURE__ */ import_react48.default.createElement(UIVarName3, null, v?.key))
|
|
2765
2748
|
)
|
|
2766
2749
|
);
|
|
2767
2750
|
}
|
|
@@ -2769,7 +2752,7 @@ var VariableTagWidget2 = class extends import_view5.WidgetType {
|
|
|
2769
2752
|
const dom = document.createElement("span");
|
|
2770
2753
|
this.root = (0, import_client.createRoot)(dom);
|
|
2771
2754
|
this.toDispose.push(
|
|
2772
|
-
|
|
2755
|
+
import_editor24.Disposable.create(() => {
|
|
2773
2756
|
this.root.unmount();
|
|
2774
2757
|
})
|
|
2775
2758
|
);
|
|
@@ -2786,7 +2769,7 @@ var VariableTagWidget2 = class extends import_view5.WidgetType {
|
|
|
2786
2769
|
return dom;
|
|
2787
2770
|
}
|
|
2788
2771
|
eq(other) {
|
|
2789
|
-
return (0,
|
|
2772
|
+
return (0, import_lodash6.isEqual)(this.keyPath, other.keyPath);
|
|
2790
2773
|
}
|
|
2791
2774
|
ignoreEvent() {
|
|
2792
2775
|
return false;
|
|
@@ -2796,9 +2779,9 @@ var VariableTagWidget2 = class extends import_view5.WidgetType {
|
|
|
2796
2779
|
}
|
|
2797
2780
|
};
|
|
2798
2781
|
function VariableTagInject2() {
|
|
2799
|
-
const injector = (0,
|
|
2800
|
-
const scope = (0,
|
|
2801
|
-
(0,
|
|
2782
|
+
const injector = (0, import_react49.useInjector)();
|
|
2783
|
+
const scope = (0, import_editor24.useCurrentScope)();
|
|
2784
|
+
(0, import_react48.useLayoutEffect)(() => {
|
|
2802
2785
|
const atMatcher = new import_view5.MatchDecorator({
|
|
2803
2786
|
regexp: /\{\{([^\}]+)\}\}/g,
|
|
2804
2787
|
decoration: (match) => import_view5.Decoration.replace({
|
|
@@ -2863,7 +2846,7 @@ var transformer = (0, import_preset_code6.transformerCreator)((text) => {
|
|
|
2863
2846
|
return text;
|
|
2864
2847
|
});
|
|
2865
2848
|
function JsonEditorWithVariables(props) {
|
|
2866
|
-
return /* @__PURE__ */
|
|
2849
|
+
return /* @__PURE__ */ import_react50.default.createElement(
|
|
2867
2850
|
CodeEditor,
|
|
2868
2851
|
{
|
|
2869
2852
|
languageId: "json",
|
|
@@ -2874,15 +2857,16 @@ function JsonEditorWithVariables(props) {
|
|
|
2874
2857
|
...props.options || {}
|
|
2875
2858
|
}
|
|
2876
2859
|
},
|
|
2877
|
-
/* @__PURE__ */
|
|
2878
|
-
/* @__PURE__ */
|
|
2860
|
+
/* @__PURE__ */ import_react50.default.createElement(VariableTree2, null),
|
|
2861
|
+
/* @__PURE__ */ import_react50.default.createElement(VariableTagInject2, null)
|
|
2879
2862
|
);
|
|
2880
2863
|
}
|
|
2881
2864
|
|
|
2882
2865
|
// src/components/inputs-values/index.tsx
|
|
2883
|
-
var
|
|
2884
|
-
var
|
|
2885
|
-
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");
|
|
2886
2870
|
|
|
2887
2871
|
// src/components/inputs-values/styles.tsx
|
|
2888
2872
|
var import_styled_components10 = __toESM(require("styled-components"));
|
|
@@ -2899,14 +2883,14 @@ var UIRow3 = import_styled_components10.default.div`
|
|
|
2899
2883
|
`;
|
|
2900
2884
|
|
|
2901
2885
|
// src/components/inputs-values/components/blur-input.tsx
|
|
2902
|
-
var
|
|
2886
|
+
var import_react51 = __toESM(require("react"));
|
|
2903
2887
|
var import_input2 = __toESM(require("@douyinfe/semi-ui/lib/es/input"));
|
|
2904
2888
|
function BlurInput2(props) {
|
|
2905
|
-
const [value, setValue] = (0,
|
|
2906
|
-
(0,
|
|
2889
|
+
const [value, setValue] = (0, import_react51.useState)("");
|
|
2890
|
+
(0, import_react51.useEffect)(() => {
|
|
2907
2891
|
setValue(props.value);
|
|
2908
2892
|
}, [props.value]);
|
|
2909
|
-
return /* @__PURE__ */
|
|
2893
|
+
return /* @__PURE__ */ import_react51.default.createElement(
|
|
2910
2894
|
import_input2.default,
|
|
2911
2895
|
{
|
|
2912
2896
|
...props,
|
|
@@ -2934,7 +2918,7 @@ function InputsValues({
|
|
|
2934
2918
|
onChange,
|
|
2935
2919
|
sortIndexKey: "extra.index"
|
|
2936
2920
|
});
|
|
2937
|
-
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(
|
|
2938
2922
|
BlurInput2,
|
|
2939
2923
|
{
|
|
2940
2924
|
style: { width: 100, minWidth: 100, maxWidth: 100 },
|
|
@@ -2942,10 +2926,10 @@ function InputsValues({
|
|
|
2942
2926
|
size: "small",
|
|
2943
2927
|
value: item.key,
|
|
2944
2928
|
onChange: (v) => updateKey(item.id, v),
|
|
2945
|
-
placeholder: "Input Key"
|
|
2929
|
+
placeholder: import_editor25.I18n.t("Input Key")
|
|
2946
2930
|
}
|
|
2947
|
-
), /* @__PURE__ */
|
|
2948
|
-
|
|
2931
|
+
), /* @__PURE__ */ import_react52.default.createElement(
|
|
2932
|
+
InjectDynamicValueInput,
|
|
2949
2933
|
{
|
|
2950
2934
|
style: { flexGrow: 1 },
|
|
2951
2935
|
readonly,
|
|
@@ -2958,20 +2942,20 @@ function InputsValues({
|
|
|
2958
2942
|
strategies: [...constantProps?.strategies || []]
|
|
2959
2943
|
}
|
|
2960
2944
|
}
|
|
2961
|
-
), /* @__PURE__ */
|
|
2962
|
-
|
|
2945
|
+
), /* @__PURE__ */ import_react52.default.createElement(
|
|
2946
|
+
import_semi_ui23.IconButton,
|
|
2963
2947
|
{
|
|
2964
2948
|
disabled: readonly,
|
|
2965
2949
|
theme: "borderless",
|
|
2966
|
-
icon: /* @__PURE__ */
|
|
2950
|
+
icon: /* @__PURE__ */ import_react52.default.createElement(import_semi_icons9.IconDelete, { size: "small" }),
|
|
2967
2951
|
size: "small",
|
|
2968
2952
|
onClick: () => remove(item.id)
|
|
2969
2953
|
}
|
|
2970
|
-
)))), /* @__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"));
|
|
2971
2955
|
}
|
|
2972
2956
|
|
|
2973
2957
|
// src/components/display-schema-tree/index.tsx
|
|
2974
|
-
var
|
|
2958
|
+
var import_react53 = __toESM(require("react"));
|
|
2975
2959
|
|
|
2976
2960
|
// src/components/display-schema-tree/styles.tsx
|
|
2977
2961
|
var import_styled_components11 = __toESM(require("styled-components"));
|
|
@@ -3055,7 +3039,7 @@ var TreeItem = import_styled_components11.default.div`
|
|
|
3055
3039
|
|
|
3056
3040
|
// src/components/display-schema-tree/index.tsx
|
|
3057
3041
|
function DisplaySchemaTree(props) {
|
|
3058
|
-
return /* @__PURE__ */
|
|
3042
|
+
return /* @__PURE__ */ import_react53.default.createElement(SchemaTree, { ...props });
|
|
3059
3043
|
}
|
|
3060
3044
|
function SchemaTree(props) {
|
|
3061
3045
|
const {
|
|
@@ -3071,27 +3055,27 @@ function SchemaTree(props) {
|
|
|
3071
3055
|
const icon = typeManager?.getDisplayIcon(schema);
|
|
3072
3056
|
let properties = drilldown && config ? config.getTypeSchemaProperties(schema) : {};
|
|
3073
3057
|
const childEntries = Object.entries(properties || {});
|
|
3074
|
-
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, {
|
|
3075
3059
|
className: "tree-icon"
|
|
3076
|
-
}), /* @__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);
|
|
3077
3061
|
}
|
|
3078
3062
|
|
|
3079
3063
|
// src/components/display-outputs/index.tsx
|
|
3080
|
-
var
|
|
3081
|
-
var
|
|
3082
|
-
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");
|
|
3083
3067
|
|
|
3084
3068
|
// src/components/display-schema-tag/index.tsx
|
|
3085
|
-
var
|
|
3086
|
-
var
|
|
3069
|
+
var import_react54 = __toESM(require("react"));
|
|
3070
|
+
var import_semi_ui25 = require("@douyinfe/semi-ui");
|
|
3087
3071
|
|
|
3088
3072
|
// src/components/display-schema-tag/styles.ts
|
|
3089
3073
|
var import_styled_components12 = __toESM(require("styled-components"));
|
|
3090
|
-
var
|
|
3074
|
+
var import_semi_ui24 = require("@douyinfe/semi-ui");
|
|
3091
3075
|
var PopoverContent = import_styled_components12.default.div`
|
|
3092
3076
|
padding: 10px;
|
|
3093
3077
|
`;
|
|
3094
|
-
var StyledTag = (0, import_styled_components12.default)(
|
|
3078
|
+
var StyledTag = (0, import_styled_components12.default)(import_semi_ui24.Tag)`
|
|
3095
3079
|
padding: 4px;
|
|
3096
3080
|
|
|
3097
3081
|
.tag-icon {
|
|
@@ -3111,14 +3095,14 @@ var TitleSpan = import_styled_components12.default.span`
|
|
|
3111
3095
|
function DisplaySchemaTag({ value = {}, showIconInTree, title, warning }) {
|
|
3112
3096
|
const typeManager = useTypeManager();
|
|
3113
3097
|
const icon = typeManager?.getDisplayIcon(value) || typeManager.getDisplayIcon({ type: "unknown" });
|
|
3114
|
-
return /* @__PURE__ */
|
|
3115
|
-
|
|
3098
|
+
return /* @__PURE__ */ import_react54.default.createElement(
|
|
3099
|
+
import_semi_ui25.Popover,
|
|
3116
3100
|
{
|
|
3117
|
-
content: /* @__PURE__ */
|
|
3101
|
+
content: /* @__PURE__ */ import_react54.default.createElement(PopoverContent, null, /* @__PURE__ */ import_react54.default.createElement(DisplaySchemaTree, { value, typeManager, showIcon: showIconInTree }))
|
|
3118
3102
|
},
|
|
3119
|
-
/* @__PURE__ */
|
|
3103
|
+
/* @__PURE__ */ import_react54.default.createElement(StyledTag, { color: warning ? "amber" : "white" }, icon && import_react54.default.cloneElement(icon, {
|
|
3120
3104
|
className: "tag-icon"
|
|
3121
|
-
}), title && /* @__PURE__ */
|
|
3105
|
+
}), title && /* @__PURE__ */ import_react54.default.createElement(TitleSpan, null, title))
|
|
3122
3106
|
);
|
|
3123
3107
|
}
|
|
3124
3108
|
|
|
@@ -3132,9 +3116,9 @@ var DisplayOutputsWrapper = import_styled_components13.default.div`
|
|
|
3132
3116
|
|
|
3133
3117
|
// src/components/display-outputs/index.tsx
|
|
3134
3118
|
function DisplayOutputs({ value, showIconInTree, displayFromScope }) {
|
|
3135
|
-
const scope = (0,
|
|
3136
|
-
const refresh = (0,
|
|
3137
|
-
(0,
|
|
3119
|
+
const scope = (0, import_editor26.useCurrentScope)();
|
|
3120
|
+
const refresh = (0, import_editor26.useRefresh)();
|
|
3121
|
+
(0, import_react55.useEffect)(() => {
|
|
3138
3122
|
if (!displayFromScope) {
|
|
3139
3123
|
return () => null;
|
|
3140
3124
|
}
|
|
@@ -3148,12 +3132,12 @@ function DisplayOutputs({ value, showIconInTree, displayFromScope }) {
|
|
|
3148
3132
|
const properties = displayFromScope ? scope.output.variables?.reduce((acm, curr) => {
|
|
3149
3133
|
acm = {
|
|
3150
3134
|
...acm,
|
|
3151
|
-
...
|
|
3135
|
+
...import_json_schema8.JsonSchemaUtils.astToSchema(curr.type)?.properties || {}
|
|
3152
3136
|
};
|
|
3153
3137
|
return acm;
|
|
3154
3138
|
}, {}) : value?.properties || {};
|
|
3155
3139
|
const childEntries = Object.entries(properties || {});
|
|
3156
|
-
return /* @__PURE__ */
|
|
3140
|
+
return /* @__PURE__ */ import_react55.default.createElement(DisplayOutputsWrapper, null, childEntries.map(([key, schema]) => /* @__PURE__ */ import_react55.default.createElement(
|
|
3157
3141
|
DisplaySchemaTag,
|
|
3158
3142
|
{
|
|
3159
3143
|
key,
|
|
@@ -3166,15 +3150,15 @@ function DisplayOutputs({ value, showIconInTree, displayFromScope }) {
|
|
|
3166
3150
|
}
|
|
3167
3151
|
|
|
3168
3152
|
// src/components/display-flow-value/index.tsx
|
|
3169
|
-
var
|
|
3170
|
-
var
|
|
3171
|
-
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");
|
|
3172
3156
|
function DisplayFlowValue({ value, title, showIconInTree }) {
|
|
3173
|
-
const available = (0,
|
|
3157
|
+
const available = (0, import_editor27.useScopeAvailable)();
|
|
3174
3158
|
const variable = value?.type === "ref" ? available.getByKeyPath(value?.content) : void 0;
|
|
3175
|
-
const schema = (0,
|
|
3159
|
+
const schema = (0, import_react56.useMemo)(() => {
|
|
3176
3160
|
if (value?.type === "ref") {
|
|
3177
|
-
return
|
|
3161
|
+
return import_json_schema9.JsonSchemaUtils.astToSchema(variable?.type);
|
|
3178
3162
|
}
|
|
3179
3163
|
if (value?.type === "template") {
|
|
3180
3164
|
return { type: "string" };
|
|
@@ -3195,7 +3179,7 @@ function DisplayFlowValue({ value, title, showIconInTree }) {
|
|
|
3195
3179
|
}
|
|
3196
3180
|
return { type: "unknown" };
|
|
3197
3181
|
}, [value, variable?.hash]);
|
|
3198
|
-
return /* @__PURE__ */
|
|
3182
|
+
return /* @__PURE__ */ import_react56.default.createElement(
|
|
3199
3183
|
DisplaySchemaTag,
|
|
3200
3184
|
{
|
|
3201
3185
|
title,
|
|
@@ -3207,7 +3191,7 @@ function DisplayFlowValue({ value, title, showIconInTree }) {
|
|
|
3207
3191
|
}
|
|
3208
3192
|
|
|
3209
3193
|
// src/components/display-inputs-values/index.tsx
|
|
3210
|
-
var
|
|
3194
|
+
var import_react57 = __toESM(require("react"));
|
|
3211
3195
|
|
|
3212
3196
|
// src/components/display-inputs-values/styles.ts
|
|
3213
3197
|
var import_styled_components14 = __toESM(require("styled-components"));
|
|
@@ -3220,29 +3204,29 @@ var DisplayInputsWrapper = import_styled_components14.default.div`
|
|
|
3220
3204
|
// src/components/display-inputs-values/index.tsx
|
|
3221
3205
|
function DisplayInputsValues({ value, showIconInTree }) {
|
|
3222
3206
|
const childEntries = Object.entries(value || {});
|
|
3223
|
-
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 })));
|
|
3224
3208
|
}
|
|
3225
3209
|
|
|
3226
3210
|
// src/components/assign-rows/index.tsx
|
|
3227
|
-
var
|
|
3228
|
-
var
|
|
3229
|
-
var import_semi_ui28 = require("@douyinfe/semi-ui");
|
|
3230
|
-
var import_semi_icons12 = require("@douyinfe/semi-icons");
|
|
3231
|
-
|
|
3232
|
-
// src/components/assign-row/index.tsx
|
|
3233
|
-
var import_react58 = __toESM(require("react"));
|
|
3211
|
+
var import_react60 = __toESM(require("react"));
|
|
3212
|
+
var import_editor28 = require("@flowgram.ai/editor");
|
|
3234
3213
|
var import_semi_ui27 = require("@douyinfe/semi-ui");
|
|
3235
3214
|
var import_semi_icons11 = require("@douyinfe/semi-icons");
|
|
3236
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
|
+
|
|
3237
3221
|
// src/components/assign-row/components/blur-input.tsx
|
|
3238
|
-
var
|
|
3222
|
+
var import_react58 = __toESM(require("react"));
|
|
3239
3223
|
var import_input3 = __toESM(require("@douyinfe/semi-ui/lib/es/input"));
|
|
3240
3224
|
function BlurInput3(props) {
|
|
3241
|
-
const [value, setValue] = (0,
|
|
3242
|
-
(0,
|
|
3225
|
+
const [value, setValue] = (0, import_react58.useState)("");
|
|
3226
|
+
(0, import_react58.useEffect)(() => {
|
|
3243
3227
|
setValue(props.value);
|
|
3244
3228
|
}, [props.value]);
|
|
3245
|
-
return /* @__PURE__ */
|
|
3229
|
+
return /* @__PURE__ */ import_react58.default.createElement(
|
|
3246
3230
|
import_input3.default,
|
|
3247
3231
|
{
|
|
3248
3232
|
...props,
|
|
@@ -3265,8 +3249,8 @@ function AssignRow(props) {
|
|
|
3265
3249
|
onDelete,
|
|
3266
3250
|
readonly
|
|
3267
3251
|
} = props;
|
|
3268
|
-
return /* @__PURE__ */
|
|
3269
|
-
|
|
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,
|
|
3270
3254
|
{
|
|
3271
3255
|
style: { width: "100%", height: 26 },
|
|
3272
3256
|
value: value?.left?.content,
|
|
@@ -3276,7 +3260,7 @@ function AssignRow(props) {
|
|
|
3276
3260
|
left: { type: "ref", content: v }
|
|
3277
3261
|
})
|
|
3278
3262
|
}
|
|
3279
|
-
) : /* @__PURE__ */
|
|
3263
|
+
) : /* @__PURE__ */ import_react59.default.createElement(
|
|
3280
3264
|
BlurInput3,
|
|
3281
3265
|
{
|
|
3282
3266
|
style: { height: 26 },
|
|
@@ -3288,8 +3272,8 @@ function AssignRow(props) {
|
|
|
3288
3272
|
left: v
|
|
3289
3273
|
})
|
|
3290
3274
|
}
|
|
3291
|
-
)), /* @__PURE__ */
|
|
3292
|
-
|
|
3275
|
+
)), /* @__PURE__ */ import_react59.default.createElement("div", { style: { flexGrow: 1 } }, /* @__PURE__ */ import_react59.default.createElement(
|
|
3276
|
+
InjectDynamicValueInput,
|
|
3293
3277
|
{
|
|
3294
3278
|
readonly,
|
|
3295
3279
|
value: value?.right,
|
|
@@ -3298,12 +3282,12 @@ function AssignRow(props) {
|
|
|
3298
3282
|
right: v
|
|
3299
3283
|
})
|
|
3300
3284
|
}
|
|
3301
|
-
)), onDelete && /* @__PURE__ */
|
|
3302
|
-
|
|
3285
|
+
)), onDelete && /* @__PURE__ */ import_react59.default.createElement("div", null, /* @__PURE__ */ import_react59.default.createElement(
|
|
3286
|
+
import_semi_ui26.IconButton,
|
|
3303
3287
|
{
|
|
3304
3288
|
size: "small",
|
|
3305
3289
|
theme: "borderless",
|
|
3306
|
-
icon: /* @__PURE__ */
|
|
3290
|
+
icon: /* @__PURE__ */ import_react59.default.createElement(import_semi_icons10.IconMinus, null),
|
|
3307
3291
|
onClick: () => onDelete?.()
|
|
3308
3292
|
}
|
|
3309
3293
|
)));
|
|
@@ -3312,7 +3296,7 @@ function AssignRow(props) {
|
|
|
3312
3296
|
// src/components/assign-rows/index.tsx
|
|
3313
3297
|
function AssignRows(props) {
|
|
3314
3298
|
const { name, readonly } = props;
|
|
3315
|
-
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(
|
|
3316
3300
|
AssignRow,
|
|
3317
3301
|
{
|
|
3318
3302
|
key: childField.key,
|
|
@@ -3323,21 +3307,21 @@ function AssignRows(props) {
|
|
|
3323
3307
|
},
|
|
3324
3308
|
onDelete: () => field.remove(index)
|
|
3325
3309
|
}
|
|
3326
|
-
)), /* @__PURE__ */
|
|
3327
|
-
|
|
3310
|
+
)), /* @__PURE__ */ import_react60.default.createElement("div", { style: { display: "flex", gap: 5 } }, /* @__PURE__ */ import_react60.default.createElement(
|
|
3311
|
+
import_semi_ui27.Button,
|
|
3328
3312
|
{
|
|
3329
3313
|
size: "small",
|
|
3330
3314
|
theme: "borderless",
|
|
3331
|
-
icon: /* @__PURE__ */
|
|
3315
|
+
icon: /* @__PURE__ */ import_react60.default.createElement(import_semi_icons11.IconPlus, null),
|
|
3332
3316
|
onClick: () => field.append({ operator: "assign" })
|
|
3333
3317
|
},
|
|
3334
3318
|
"Assign"
|
|
3335
|
-
), /* @__PURE__ */
|
|
3336
|
-
|
|
3319
|
+
), /* @__PURE__ */ import_react60.default.createElement(
|
|
3320
|
+
import_semi_ui27.Button,
|
|
3337
3321
|
{
|
|
3338
3322
|
size: "small",
|
|
3339
3323
|
theme: "borderless",
|
|
3340
|
-
icon: /* @__PURE__ */
|
|
3324
|
+
icon: /* @__PURE__ */ import_react60.default.createElement(import_semi_icons11.IconPlus, null),
|
|
3341
3325
|
onClick: () => field.append({ operator: "declare" })
|
|
3342
3326
|
},
|
|
3343
3327
|
"Declaration"
|
|
@@ -3345,29 +3329,29 @@ function AssignRows(props) {
|
|
|
3345
3329
|
}
|
|
3346
3330
|
|
|
3347
3331
|
// src/effects/provide-batch-input/index.ts
|
|
3348
|
-
var
|
|
3349
|
-
var provideBatchInputEffect = (0,
|
|
3332
|
+
var import_editor29 = require("@flowgram.ai/editor");
|
|
3333
|
+
var provideBatchInputEffect = (0, import_editor29.createEffectFromVariableProvider)({
|
|
3350
3334
|
private: true,
|
|
3351
3335
|
parse: (value, ctx) => [
|
|
3352
|
-
|
|
3336
|
+
import_editor29.ASTFactory.createVariableDeclaration({
|
|
3353
3337
|
key: `${ctx.node.id}_locals`,
|
|
3354
3338
|
meta: {
|
|
3355
|
-
title: (0,
|
|
3339
|
+
title: (0, import_editor29.getNodeForm)(ctx.node)?.getValueIn("title"),
|
|
3356
3340
|
icon: ctx.node.getNodeRegistry().info?.icon
|
|
3357
3341
|
},
|
|
3358
|
-
type:
|
|
3342
|
+
type: import_editor29.ASTFactory.createObject({
|
|
3359
3343
|
properties: [
|
|
3360
|
-
|
|
3344
|
+
import_editor29.ASTFactory.createProperty({
|
|
3361
3345
|
key: "item",
|
|
3362
|
-
initializer:
|
|
3363
|
-
enumerateFor:
|
|
3346
|
+
initializer: import_editor29.ASTFactory.createEnumerateExpression({
|
|
3347
|
+
enumerateFor: import_editor29.ASTFactory.createKeyPathExpression({
|
|
3364
3348
|
keyPath: value.content || []
|
|
3365
3349
|
})
|
|
3366
3350
|
})
|
|
3367
3351
|
}),
|
|
3368
|
-
|
|
3352
|
+
import_editor29.ASTFactory.createProperty({
|
|
3369
3353
|
key: "index",
|
|
3370
|
-
type:
|
|
3354
|
+
type: import_editor29.ASTFactory.createNumber()
|
|
3371
3355
|
})
|
|
3372
3356
|
]
|
|
3373
3357
|
})
|
|
@@ -3376,14 +3360,14 @@ var provideBatchInputEffect = (0, import_editor16.createEffectFromVariableProvid
|
|
|
3376
3360
|
});
|
|
3377
3361
|
|
|
3378
3362
|
// src/effects/auto-rename-ref/index.ts
|
|
3379
|
-
var
|
|
3380
|
-
var
|
|
3363
|
+
var import_lodash7 = require("lodash");
|
|
3364
|
+
var import_editor30 = require("@flowgram.ai/editor");
|
|
3381
3365
|
var autoRenameRefEffect = [
|
|
3382
3366
|
{
|
|
3383
|
-
event:
|
|
3367
|
+
event: import_editor30.DataEvent.onValueInit,
|
|
3384
3368
|
effect: (params) => {
|
|
3385
3369
|
const { context, form, name } = params;
|
|
3386
|
-
const renameService = context.node.getService(
|
|
3370
|
+
const renameService = context.node.getService(import_editor30.VariableFieldKeyRenameService);
|
|
3387
3371
|
const disposable = renameService.onRename(({ before, after }) => {
|
|
3388
3372
|
const beforeKeyPath = [
|
|
3389
3373
|
...before.parentFields.map((_field) => _field.key).reverse(),
|
|
@@ -3432,7 +3416,7 @@ function isKeyPathMatch(keyPath = [], targetKeyPath) {
|
|
|
3432
3416
|
}
|
|
3433
3417
|
function getTemplateKeyPaths(value) {
|
|
3434
3418
|
const keyPathReg = /{{(.*?)}}/g;
|
|
3435
|
-
return (0,
|
|
3419
|
+
return (0, import_lodash7.uniq)(value.content?.match(keyPathReg) || []).map(
|
|
3436
3420
|
(_keyPath) => _keyPath.slice(2, -2).split(".")
|
|
3437
3421
|
);
|
|
3438
3422
|
}
|
|
@@ -3443,7 +3427,7 @@ function isTemplate(value) {
|
|
|
3443
3427
|
return value?.type === "template" && typeof value?.content === "string";
|
|
3444
3428
|
}
|
|
3445
3429
|
function traverseRef(name, value, cb) {
|
|
3446
|
-
if ((0,
|
|
3430
|
+
if ((0, import_lodash7.isObject)(value)) {
|
|
3447
3431
|
if (isRef(value)) {
|
|
3448
3432
|
cb(name, value);
|
|
3449
3433
|
return;
|
|
@@ -3457,7 +3441,7 @@ function traverseRef(name, value, cb) {
|
|
|
3457
3441
|
});
|
|
3458
3442
|
return;
|
|
3459
3443
|
}
|
|
3460
|
-
if ((0,
|
|
3444
|
+
if ((0, import_lodash7.isArray)(value)) {
|
|
3461
3445
|
value.forEach((_value, idx) => {
|
|
3462
3446
|
traverseRef(`${name}[${idx}]`, _value, cb);
|
|
3463
3447
|
});
|
|
@@ -3467,28 +3451,28 @@ function traverseRef(name, value, cb) {
|
|
|
3467
3451
|
}
|
|
3468
3452
|
|
|
3469
3453
|
// src/effects/provide-json-schema-outputs/index.ts
|
|
3470
|
-
var
|
|
3471
|
-
var
|
|
3472
|
-
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)({
|
|
3473
3457
|
parse: (value, ctx) => [
|
|
3474
|
-
|
|
3458
|
+
import_editor31.ASTFactory.createVariableDeclaration({
|
|
3475
3459
|
key: `${ctx.node.id}`,
|
|
3476
3460
|
meta: {
|
|
3477
|
-
title: (0,
|
|
3461
|
+
title: (0, import_editor31.getNodeForm)(ctx.node)?.getValueIn("title") || ctx.node.id,
|
|
3478
3462
|
icon: ctx.node.getNodeRegistry().info?.icon
|
|
3479
3463
|
},
|
|
3480
|
-
type:
|
|
3464
|
+
type: import_json_schema10.JsonSchemaUtils.schemaToAST(value)
|
|
3481
3465
|
})
|
|
3482
3466
|
]
|
|
3483
3467
|
});
|
|
3484
3468
|
|
|
3485
3469
|
// src/effects/sync-variable-title/index.ts
|
|
3486
|
-
var
|
|
3470
|
+
var import_editor32 = require("@flowgram.ai/editor");
|
|
3487
3471
|
var syncVariableTitle = [
|
|
3488
3472
|
{
|
|
3489
|
-
event:
|
|
3473
|
+
event: import_editor32.DataEvent.onValueChange,
|
|
3490
3474
|
effect: ({ value, context }) => {
|
|
3491
|
-
context.node.getData(
|
|
3475
|
+
context.node.getData(import_editor32.FlowNodeVariableData).allScopes.forEach((_scope) => {
|
|
3492
3476
|
_scope.output.variables.forEach((_var) => {
|
|
3493
3477
|
_var.updateMeta({
|
|
3494
3478
|
..._var.meta || {},
|
|
@@ -3502,17 +3486,17 @@ var syncVariableTitle = [
|
|
|
3502
3486
|
];
|
|
3503
3487
|
|
|
3504
3488
|
// src/effects/validate-when-variable-sync/index.ts
|
|
3505
|
-
var
|
|
3506
|
-
var
|
|
3489
|
+
var import_lodash8 = require("lodash");
|
|
3490
|
+
var import_editor33 = require("@flowgram.ai/editor");
|
|
3507
3491
|
var validateWhenVariableSync = ({
|
|
3508
3492
|
scope
|
|
3509
3493
|
} = {}) => [
|
|
3510
3494
|
{
|
|
3511
|
-
event:
|
|
3495
|
+
event: import_editor33.DataEvent.onValueInit,
|
|
3512
3496
|
effect: ({ context, form }) => {
|
|
3513
|
-
const nodeScope = scope === "private" ? (0,
|
|
3497
|
+
const nodeScope = scope === "private" ? (0, import_editor33.getNodePrivateScope)(context.node) : (0, import_editor33.getNodeScope)(context.node);
|
|
3514
3498
|
const disposable = nodeScope.available.onListOrAnyVarChange(() => {
|
|
3515
|
-
if (!(0,
|
|
3499
|
+
if (!(0, import_lodash8.isEmpty)(form.state.errors)) {
|
|
3516
3500
|
form.validate();
|
|
3517
3501
|
}
|
|
3518
3502
|
});
|
|
@@ -3522,16 +3506,16 @@ var validateWhenVariableSync = ({
|
|
|
3522
3506
|
];
|
|
3523
3507
|
|
|
3524
3508
|
// src/effects/listen-ref-value-change/index.ts
|
|
3525
|
-
var
|
|
3509
|
+
var import_editor34 = require("@flowgram.ai/editor");
|
|
3526
3510
|
var listenRefValueChange = (cb) => [
|
|
3527
3511
|
{
|
|
3528
|
-
event:
|
|
3512
|
+
event: import_editor34.DataEvent.onValueInitOrChange,
|
|
3529
3513
|
effect: (params) => {
|
|
3530
3514
|
const { context, value } = params;
|
|
3531
3515
|
if (value?.type !== "ref") {
|
|
3532
3516
|
return () => null;
|
|
3533
3517
|
}
|
|
3534
|
-
const disposable = (0,
|
|
3518
|
+
const disposable = (0, import_editor34.getNodeScope)(context.node).available.trackByKeyPath(
|
|
3535
3519
|
value?.content || [],
|
|
3536
3520
|
(v) => {
|
|
3537
3521
|
cb({ ...params, variable: v });
|
|
@@ -3545,20 +3529,20 @@ var listenRefValueChange = (cb) => [
|
|
|
3545
3529
|
];
|
|
3546
3530
|
|
|
3547
3531
|
// src/effects/listen-ref-schema-change/index.ts
|
|
3548
|
-
var
|
|
3549
|
-
var
|
|
3532
|
+
var import_json_schema11 = require("@flowgram.ai/json-schema");
|
|
3533
|
+
var import_editor35 = require("@flowgram.ai/editor");
|
|
3550
3534
|
var listenRefSchemaChange = (cb) => [
|
|
3551
3535
|
{
|
|
3552
|
-
event:
|
|
3536
|
+
event: import_editor35.DataEvent.onValueInitOrChange,
|
|
3553
3537
|
effect: (params) => {
|
|
3554
3538
|
const { context, value } = params;
|
|
3555
3539
|
if (value?.type !== "ref") {
|
|
3556
3540
|
return () => null;
|
|
3557
3541
|
}
|
|
3558
|
-
const disposable = (0,
|
|
3542
|
+
const disposable = (0, import_editor35.getNodeScope)(context.node).available.trackByKeyPath(
|
|
3559
3543
|
value?.content || [],
|
|
3560
3544
|
(_type) => {
|
|
3561
|
-
cb({ ...params, schema:
|
|
3545
|
+
cb({ ...params, schema: import_json_schema11.JsonSchemaUtils.astToSchema(_type) });
|
|
3562
3546
|
},
|
|
3563
3547
|
{
|
|
3564
3548
|
selector: (_v) => _v?.type
|
|
@@ -3571,84 +3555,22 @@ var listenRefSchemaChange = (cb) => [
|
|
|
3571
3555
|
}
|
|
3572
3556
|
];
|
|
3573
3557
|
|
|
3574
|
-
// src/shared/format-legacy-refs/index.ts
|
|
3575
|
-
var import_lodash8 = require("lodash");
|
|
3576
|
-
function formatLegacyRefOnSubmit(value) {
|
|
3577
|
-
if ((0, import_lodash8.isObject)(value)) {
|
|
3578
|
-
if (isLegacyFlowRefValueSchema(value)) {
|
|
3579
|
-
return formatLegacyRefToNewRef(value);
|
|
3580
|
-
}
|
|
3581
|
-
return Object.fromEntries(
|
|
3582
|
-
Object.entries(value).map(([key, value2]) => [
|
|
3583
|
-
key,
|
|
3584
|
-
formatLegacyRefOnSubmit(value2)
|
|
3585
|
-
])
|
|
3586
|
-
);
|
|
3587
|
-
}
|
|
3588
|
-
if (Array.isArray(value)) {
|
|
3589
|
-
return value.map(formatLegacyRefOnSubmit);
|
|
3590
|
-
}
|
|
3591
|
-
return value;
|
|
3592
|
-
}
|
|
3593
|
-
function formatLegacyRefOnInit(value) {
|
|
3594
|
-
if ((0, import_lodash8.isObject)(value)) {
|
|
3595
|
-
if (isNewFlowRefValueSchema(value)) {
|
|
3596
|
-
return formatNewRefToLegacyRef(value);
|
|
3597
|
-
}
|
|
3598
|
-
return Object.fromEntries(
|
|
3599
|
-
Object.entries(value).map(([key, value2]) => [
|
|
3600
|
-
key,
|
|
3601
|
-
formatLegacyRefOnInit(value2)
|
|
3602
|
-
])
|
|
3603
|
-
);
|
|
3604
|
-
}
|
|
3605
|
-
if (Array.isArray(value)) {
|
|
3606
|
-
return value.map(formatLegacyRefOnInit);
|
|
3607
|
-
}
|
|
3608
|
-
return value;
|
|
3609
|
-
}
|
|
3610
|
-
function isLegacyFlowRefValueSchema(value) {
|
|
3611
|
-
return (0, import_lodash8.isObject)(value) && Object.keys(value).length === 2 && value.type === "ref" && typeof value.content === "string";
|
|
3612
|
-
}
|
|
3613
|
-
function isNewFlowRefValueSchema(value) {
|
|
3614
|
-
return (0, import_lodash8.isObject)(value) && Object.keys(value).length === 2 && value.type === "ref" && Array.isArray(value.content);
|
|
3615
|
-
}
|
|
3616
|
-
function formatLegacyRefToNewRef(value) {
|
|
3617
|
-
const keyPath = value.content.split(".");
|
|
3618
|
-
if (keyPath[1] === "outputs") {
|
|
3619
|
-
return {
|
|
3620
|
-
type: "ref",
|
|
3621
|
-
content: [`${keyPath[0]}.${keyPath[1]}`, ...keyPath.length > 2 ? keyPath.slice(2) : []]
|
|
3622
|
-
};
|
|
3623
|
-
}
|
|
3624
|
-
return {
|
|
3625
|
-
type: "ref",
|
|
3626
|
-
content: keyPath
|
|
3627
|
-
};
|
|
3628
|
-
}
|
|
3629
|
-
function formatNewRefToLegacyRef(value) {
|
|
3630
|
-
return {
|
|
3631
|
-
type: "ref",
|
|
3632
|
-
content: value.content.join(".")
|
|
3633
|
-
};
|
|
3634
|
-
}
|
|
3635
|
-
|
|
3636
3558
|
// src/form-plugins/batch-outputs-plugin/index.ts
|
|
3637
|
-
var
|
|
3638
|
-
var provideBatchOutputsEffect = (0,
|
|
3559
|
+
var import_editor36 = require("@flowgram.ai/editor");
|
|
3560
|
+
var provideBatchOutputsEffect = (0, import_editor36.createEffectFromVariableProvider)({
|
|
3639
3561
|
parse: (value, ctx) => [
|
|
3640
|
-
|
|
3562
|
+
import_editor36.ASTFactory.createVariableDeclaration({
|
|
3641
3563
|
key: `${ctx.node.id}`,
|
|
3642
3564
|
meta: {
|
|
3643
|
-
title: (0,
|
|
3565
|
+
title: (0, import_editor36.getNodeForm)(ctx.node)?.getValueIn("title"),
|
|
3644
3566
|
icon: ctx.node.getNodeRegistry().info?.icon
|
|
3645
3567
|
},
|
|
3646
|
-
type:
|
|
3568
|
+
type: import_editor36.ASTFactory.createObject({
|
|
3647
3569
|
properties: Object.entries(value).map(
|
|
3648
|
-
([_key, value2]) =>
|
|
3570
|
+
([_key, value2]) => import_editor36.ASTFactory.createProperty({
|
|
3649
3571
|
key: _key,
|
|
3650
|
-
initializer:
|
|
3651
|
-
wrapFor:
|
|
3572
|
+
initializer: import_editor36.ASTFactory.createWrapArrayExpression({
|
|
3573
|
+
wrapFor: import_editor36.ASTFactory.createKeyPathExpression({
|
|
3652
3574
|
keyPath: value2?.content || []
|
|
3653
3575
|
})
|
|
3654
3576
|
})
|
|
@@ -3658,7 +3580,7 @@ var provideBatchOutputsEffect = (0, import_editor23.createEffectFromVariableProv
|
|
|
3658
3580
|
})
|
|
3659
3581
|
]
|
|
3660
3582
|
});
|
|
3661
|
-
var createBatchOutputsFormPlugin = (0,
|
|
3583
|
+
var createBatchOutputsFormPlugin = (0, import_editor36.defineFormPluginCreator)({
|
|
3662
3584
|
name: "batch-outputs-plugin",
|
|
3663
3585
|
onSetupFormMeta({ mergeEffect }, { outputKey }) {
|
|
3664
3586
|
mergeEffect({
|
|
@@ -3666,7 +3588,7 @@ var createBatchOutputsFormPlugin = (0, import_editor23.defineFormPluginCreator)(
|
|
|
3666
3588
|
});
|
|
3667
3589
|
},
|
|
3668
3590
|
onInit(ctx, { outputKey }) {
|
|
3669
|
-
const chainTransformService = ctx.node.getService(
|
|
3591
|
+
const chainTransformService = ctx.node.getService(import_editor36.ScopeChainTransformService);
|
|
3670
3592
|
const batchNodeType = ctx.node.flowNodeType;
|
|
3671
3593
|
const transformerId = `${batchNodeType}-outputs`;
|
|
3672
3594
|
if (chainTransformService.hasTransformer(transformerId)) {
|
|
@@ -3676,21 +3598,21 @@ var createBatchOutputsFormPlugin = (0, import_editor23.defineFormPluginCreator)(
|
|
|
3676
3598
|
transformCovers: (covers, ctx2) => {
|
|
3677
3599
|
const node = ctx2.scope.meta?.node;
|
|
3678
3600
|
if (node?.parent?.flowNodeType === batchNodeType) {
|
|
3679
|
-
return [...covers, (0,
|
|
3601
|
+
return [...covers, (0, import_editor36.getNodeScope)(node.parent)];
|
|
3680
3602
|
}
|
|
3681
3603
|
return covers;
|
|
3682
3604
|
},
|
|
3683
3605
|
transformDeps(scopes, ctx2) {
|
|
3684
3606
|
const scopeMeta = ctx2.scope.meta;
|
|
3685
|
-
if (scopeMeta?.type ===
|
|
3607
|
+
if (scopeMeta?.type === import_editor36.FlowNodeScopeType.private) {
|
|
3686
3608
|
return scopes;
|
|
3687
3609
|
}
|
|
3688
3610
|
const node = scopeMeta?.node;
|
|
3689
3611
|
if (node?.flowNodeType === batchNodeType) {
|
|
3690
3612
|
const childBlocks = node.blocks;
|
|
3691
3613
|
return [
|
|
3692
|
-
(0,
|
|
3693
|
-
...childBlocks.map((_childBlock) => (0,
|
|
3614
|
+
(0, import_editor36.getNodePrivateScope)(node),
|
|
3615
|
+
...childBlocks.map((_childBlock) => (0, import_editor36.getNodeScope)(_childBlock))
|
|
3694
3616
|
];
|
|
3695
3617
|
}
|
|
3696
3618
|
return scopes;
|
|
@@ -3701,9 +3623,9 @@ var createBatchOutputsFormPlugin = (0, import_editor23.defineFormPluginCreator)(
|
|
|
3701
3623
|
|
|
3702
3624
|
// src/form-plugins/infer-inputs-plugin/index.ts
|
|
3703
3625
|
var import_lodash9 = require("lodash");
|
|
3704
|
-
var
|
|
3705
|
-
var
|
|
3706
|
-
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)({
|
|
3707
3629
|
onSetupFormMeta({ addFormatOnSubmit }, { sourceKey, targetKey, scope }) {
|
|
3708
3630
|
if (!sourceKey || !targetKey) {
|
|
3709
3631
|
return;
|
|
@@ -3714,7 +3636,7 @@ var createInferInputsPlugin = (0, import_editor24.defineFormPluginCreator)({
|
|
|
3714
3636
|
targetKey,
|
|
3715
3637
|
infer(
|
|
3716
3638
|
(0, import_lodash9.get)(formData, sourceKey),
|
|
3717
|
-
scope === "private" ? (0,
|
|
3639
|
+
scope === "private" ? (0, import_editor37.getNodePrivateScope)(ctx.node) : (0, import_editor37.getNodeScope)(ctx.node)
|
|
3718
3640
|
)
|
|
3719
3641
|
);
|
|
3720
3642
|
return formData;
|
|
@@ -3754,7 +3676,7 @@ var infer = (values, scope) => {
|
|
|
3754
3676
|
}
|
|
3755
3677
|
if (isRef2(values)) {
|
|
3756
3678
|
const variable = scope.available.getByKeyPath(values?.content);
|
|
3757
|
-
const schema = variable?.type ?
|
|
3679
|
+
const schema = variable?.type ? import_json_schema12.JsonSchemaUtils.astToSchema(variable?.type) : void 0;
|
|
3758
3680
|
return schema;
|
|
3759
3681
|
}
|
|
3760
3682
|
if (isTemplate2(values)) {
|
|
@@ -3777,33 +3699,33 @@ var infer = (values, scope) => {
|
|
|
3777
3699
|
|
|
3778
3700
|
// src/form-plugins/infer-assign-plugin/index.ts
|
|
3779
3701
|
var import_lodash10 = require("lodash");
|
|
3780
|
-
var
|
|
3781
|
-
var
|
|
3782
|
-
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)({
|
|
3783
3705
|
onSetupFormMeta({ addFormatOnSubmit, mergeEffect }, { assignKey, outputKey }) {
|
|
3784
3706
|
if (!assignKey || !outputKey) {
|
|
3785
3707
|
return;
|
|
3786
3708
|
}
|
|
3787
3709
|
mergeEffect({
|
|
3788
|
-
[assignKey]: (0,
|
|
3710
|
+
[assignKey]: (0, import_editor38.createEffectFromVariableProvider)({
|
|
3789
3711
|
parse: (value, ctx) => {
|
|
3790
3712
|
const declareRows = (0, import_lodash10.uniqBy)(
|
|
3791
3713
|
value.filter((_v) => _v.operator === "declare" && _v.left && _v.right),
|
|
3792
3714
|
"left"
|
|
3793
3715
|
);
|
|
3794
3716
|
return [
|
|
3795
|
-
|
|
3717
|
+
import_editor38.ASTFactory.createVariableDeclaration({
|
|
3796
3718
|
key: `${ctx.node.id}`,
|
|
3797
3719
|
meta: {
|
|
3798
|
-
title: (0,
|
|
3720
|
+
title: (0, import_editor38.getNodeForm)(ctx.node)?.getValueIn("title"),
|
|
3799
3721
|
icon: ctx.node.getNodeRegistry().info?.icon
|
|
3800
3722
|
},
|
|
3801
|
-
type:
|
|
3723
|
+
type: import_editor38.ASTFactory.createObject({
|
|
3802
3724
|
properties: declareRows.map(
|
|
3803
|
-
(_v) =>
|
|
3725
|
+
(_v) => import_editor38.ASTFactory.createProperty({
|
|
3804
3726
|
key: _v.left,
|
|
3805
|
-
type: _v.right?.type === "constant" ?
|
|
3806
|
-
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({
|
|
3807
3729
|
keyPath: _v.right?.content || []
|
|
3808
3730
|
}) : {}
|
|
3809
3731
|
})
|
|
@@ -3818,7 +3740,7 @@ var createInferAssignPlugin = (0, import_editor25.defineFormPluginCreator)({
|
|
|
3818
3740
|
(0, import_lodash10.set)(
|
|
3819
3741
|
formData,
|
|
3820
3742
|
outputKey,
|
|
3821
|
-
|
|
3743
|
+
import_json_schema13.JsonSchemaUtils.astToSchema((0, import_editor38.getNodeScope)(ctx.node).output.variables?.[0]?.type)
|
|
3822
3744
|
);
|
|
3823
3745
|
return formData;
|
|
3824
3746
|
});
|
|
@@ -3827,7 +3749,7 @@ var createInferAssignPlugin = (0, import_editor25.defineFormPluginCreator)({
|
|
|
3827
3749
|
|
|
3828
3750
|
// src/validate/validate-flow-value/index.tsx
|
|
3829
3751
|
var import_lodash11 = require("lodash");
|
|
3830
|
-
var
|
|
3752
|
+
var import_editor39 = require("@flowgram.ai/editor");
|
|
3831
3753
|
function validateFlowValue(value, ctx) {
|
|
3832
3754
|
const { node, required, errorMessages } = ctx;
|
|
3833
3755
|
const {
|
|
@@ -3836,15 +3758,15 @@ function validateFlowValue(value, ctx) {
|
|
|
3836
3758
|
} = errorMessages || {};
|
|
3837
3759
|
if (required && ((0, import_lodash11.isNil)(value) || (0, import_lodash11.isNil)(value?.content) || value?.content === "")) {
|
|
3838
3760
|
return {
|
|
3839
|
-
level:
|
|
3761
|
+
level: import_editor39.FeedbackLevel.Error,
|
|
3840
3762
|
message: requiredMessage
|
|
3841
3763
|
};
|
|
3842
3764
|
}
|
|
3843
3765
|
if (value?.type === "ref") {
|
|
3844
|
-
const variable = (0,
|
|
3766
|
+
const variable = (0, import_editor39.getNodeScope)(node).available.getByKeyPath(value?.content || []);
|
|
3845
3767
|
if (!variable) {
|
|
3846
3768
|
return {
|
|
3847
|
-
level:
|
|
3769
|
+
level: import_editor39.FeedbackLevel.Error,
|
|
3848
3770
|
message: unknownVariableMessage
|
|
3849
3771
|
};
|
|
3850
3772
|
}
|
|
@@ -3852,10 +3774,10 @@ function validateFlowValue(value, ctx) {
|
|
|
3852
3774
|
if (value?.type === "template") {
|
|
3853
3775
|
const allRefs = getTemplateKeyPaths2(value);
|
|
3854
3776
|
for (const ref of allRefs) {
|
|
3855
|
-
const variable = (0,
|
|
3777
|
+
const variable = (0, import_editor39.getNodeScope)(node).available.getByKeyPath(ref);
|
|
3856
3778
|
if (!variable) {
|
|
3857
3779
|
return {
|
|
3858
|
-
level:
|
|
3780
|
+
level: import_editor39.FeedbackLevel.Error,
|
|
3859
3781
|
message: unknownVariableMessage
|
|
3860
3782
|
};
|
|
3861
3783
|
}
|
|
@@ -3885,6 +3807,9 @@ function getTemplateKeyPaths2(value) {
|
|
|
3885
3807
|
DisplaySchemaTag,
|
|
3886
3808
|
DisplaySchemaTree,
|
|
3887
3809
|
DynamicValueInput,
|
|
3810
|
+
InjectDynamicValueInput,
|
|
3811
|
+
InjectTypeSelector,
|
|
3812
|
+
InjectVariableSelector,
|
|
3888
3813
|
InputsValues,
|
|
3889
3814
|
JsonEditorWithVariables,
|
|
3890
3815
|
JsonSchemaEditor,
|
|
@@ -3900,6 +3825,7 @@ function getTemplateKeyPaths2(value) {
|
|
|
3900
3825
|
createDisableDeclarationPlugin,
|
|
3901
3826
|
createInferAssignPlugin,
|
|
3902
3827
|
createInferInputsPlugin,
|
|
3828
|
+
createInjectMaterial,
|
|
3903
3829
|
createTypePresetPlugin,
|
|
3904
3830
|
formatLegacyRefOnInit,
|
|
3905
3831
|
formatLegacyRefOnSubmit,
|