@flowgram.ai/form-materials 0.2.30 → 0.2.32
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/dist/esm/index.js +4 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.ts +553 -0
- package/dist/index.js +3697 -0
- package/dist/index.js.map +1 -0
- package/package.json +5 -5
- package/src/components/condition-row/hooks/useOp.tsx +3 -1
- package/src/components/condition-row/index.tsx +1 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,3697 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/index.ts
|
|
31
|
+
var src_exports = {};
|
|
32
|
+
__export(src_exports, {
|
|
33
|
+
ArrayIcons: () => ArrayIcons,
|
|
34
|
+
BatchOutputs: () => BatchOutputs,
|
|
35
|
+
BatchVariableSelector: () => BatchVariableSelector,
|
|
36
|
+
CodeEditor: () => CodeEditor,
|
|
37
|
+
ConditionRow: () => ConditionRow,
|
|
38
|
+
ConstantInput: () => ConstantInput,
|
|
39
|
+
DynamicValueInput: () => DynamicValueInput,
|
|
40
|
+
InputsValues: () => InputsValues,
|
|
41
|
+
JsonEditorWithVariables: () => JsonEditorWithVariables,
|
|
42
|
+
JsonSchemaEditor: () => JsonSchemaEditor,
|
|
43
|
+
JsonSchemaUtils: () => JsonSchemaUtils,
|
|
44
|
+
PromptEditor: () => PromptEditor,
|
|
45
|
+
PromptEditorWithInputs: () => PromptEditorWithInputs,
|
|
46
|
+
PromptEditorWithVariables: () => PromptEditorWithVariables,
|
|
47
|
+
TypeSelector: () => TypeSelector,
|
|
48
|
+
VariableSelector: () => VariableSelector,
|
|
49
|
+
VariableTypeIcons: () => VariableTypeIcons,
|
|
50
|
+
autoRenameRefEffect: () => autoRenameRefEffect,
|
|
51
|
+
createBatchOutputsFormPlugin: () => createBatchOutputsFormPlugin,
|
|
52
|
+
createInferInputsPlugin: () => createInferInputsPlugin,
|
|
53
|
+
formatLegacyRefOnInit: () => formatLegacyRefOnInit,
|
|
54
|
+
formatLegacyRefOnSubmit: () => formatLegacyRefOnSubmit,
|
|
55
|
+
formatLegacyRefToNewRef: () => formatLegacyRefToNewRef,
|
|
56
|
+
formatNewRefToLegacyRef: () => formatNewRefToLegacyRef,
|
|
57
|
+
getSchemaIcon: () => getSchemaIcon,
|
|
58
|
+
getTypeSelectValue: () => getTypeSelectValue,
|
|
59
|
+
isLegacyFlowRefValueSchema: () => isLegacyFlowRefValueSchema,
|
|
60
|
+
isNewFlowRefValueSchema: () => isNewFlowRefValueSchema,
|
|
61
|
+
parseTypeSelectValue: () => parseTypeSelectValue,
|
|
62
|
+
provideBatchInputEffect: () => provideBatchInputEffect,
|
|
63
|
+
provideBatchOutputsEffect: () => provideBatchOutputsEffect,
|
|
64
|
+
provideJsonSchemaOutputs: () => provideJsonSchemaOutputs,
|
|
65
|
+
syncVariableTitle: () => syncVariableTitle,
|
|
66
|
+
useVariableTree: () => useVariableTree
|
|
67
|
+
});
|
|
68
|
+
module.exports = __toCommonJS(src_exports);
|
|
69
|
+
|
|
70
|
+
// ../../../common/temp/node_modules/.pnpm/tsup@8.3.5_typescript@5.8.3/node_modules/tsup/assets/cjs_shims.js
|
|
71
|
+
var getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.src || new URL("main.js", document.baseURI).href;
|
|
72
|
+
var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
|
|
73
|
+
|
|
74
|
+
// src/components/variable-selector/index.tsx
|
|
75
|
+
var import_react3 = __toESM(require("react"));
|
|
76
|
+
var import_semi_ui3 = require("@douyinfe/semi-ui");
|
|
77
|
+
var import_semi_icons2 = require("@douyinfe/semi-icons");
|
|
78
|
+
|
|
79
|
+
// src/components/variable-selector/use-variable-tree.tsx
|
|
80
|
+
var import_react2 = __toESM(require("react"));
|
|
81
|
+
var import_editor2 = require("@flowgram.ai/editor");
|
|
82
|
+
var import_semi_ui = require("@douyinfe/semi-ui");
|
|
83
|
+
|
|
84
|
+
// src/components/type-selector/constants.tsx
|
|
85
|
+
var import_react = __toESM(require("react"));
|
|
86
|
+
var import_semi_icons = __toESM(require("@douyinfe/semi-icons"));
|
|
87
|
+
var VariableTypeIcons = {
|
|
88
|
+
custom: /* @__PURE__ */ import_react.default.createElement(
|
|
89
|
+
"svg",
|
|
90
|
+
{
|
|
91
|
+
viewBox: "0 0 24 24",
|
|
92
|
+
fill: "none",
|
|
93
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
94
|
+
width: "1em",
|
|
95
|
+
height: "1em",
|
|
96
|
+
focusable: "false",
|
|
97
|
+
"aria-hidden": "true"
|
|
98
|
+
},
|
|
99
|
+
/* @__PURE__ */ import_react.default.createElement(
|
|
100
|
+
"path",
|
|
101
|
+
{
|
|
102
|
+
fillRule: "evenodd",
|
|
103
|
+
clipRule: "evenodd",
|
|
104
|
+
d: "M5.1 18L4.5032 20.1702C4.24999 21.0909 4.94281 22 5.89773 22C6.54881 22 7.11964 21.565 7.29227 20.9372L8.1 18H12.1L11.5032 20.1702C11.25 21.0909 11.9428 22 12.8977 22C13.5488 22 14.1196 21.565 14.2923 20.9372L15.1 18H19.5C20.3284 18 21 17.3284 21 16.5C21 15.6716 20.3284 15 19.5 15H15.925L17.575 9H20.5C21.3284 9 22 8.32843 22 7.5C22 6.67157 21.3284 6 20.5 6H18.4L18.9968 3.8298C19.25 2.90906 18.5572 2 17.6023 2C16.9512 2 16.3804 2.43504 16.2077 3.06281L15.4 6H11.4L11.9968 3.8298C12.25 2.90906 11.5572 2 10.6023 2C9.95119 2 9.38036 2.43504 9.20773 3.06281L8.4 6H4.5C3.67157 6 3 6.67157 3 7.5C3 8.32843 3.67157 9 4.5 9H7.575L5.925 15H3.5C2.67157 15 2 15.6716 2 16.5C2 17.3284 2.67157 18 3.5 18H5.1ZM8.925 15L10.575 9H14.575L12.925 15H8.925Z",
|
|
105
|
+
fill: "currentColor"
|
|
106
|
+
}
|
|
107
|
+
)
|
|
108
|
+
),
|
|
109
|
+
object: /* @__PURE__ */ import_react.default.createElement(
|
|
110
|
+
"svg",
|
|
111
|
+
{
|
|
112
|
+
width: "1em",
|
|
113
|
+
height: "1em",
|
|
114
|
+
viewBox: "0 0 16 16",
|
|
115
|
+
fill: "none",
|
|
116
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
117
|
+
},
|
|
118
|
+
/* @__PURE__ */ import_react.default.createElement(
|
|
119
|
+
"path",
|
|
120
|
+
{
|
|
121
|
+
d: "M5.33893 1.5835C5.66613 1.5835 5.93137 1.88142 5.93137 2.20862C5.93137 2.53582 5.66613 2.76838 5.33893 2.76838H4.9099C4.34717 2.76838 4.08062 3.07557 4.08062 3.71921V6.58633C4.08062 7.30996 3.80723 7.84734 3.26798 8.19105C3.11426 8.28902 3.10884 8.55273 3.26068 8.65359C3.80476 9.01503 4.08062 9.53994 4.08062 10.2434V13.1251C4.08062 13.7395 4.34717 14.0613 4.9099 14.0613H5.33893C5.66613 14.0613 5.93137 14.3435 5.93137 14.6707C5.93137 14.9979 5.66613 15.2462 5.33893 15.2462H4.64335C3.99177 15.2462 3.48828 15.0268 3.13287 14.6172C2.80708 14.2369 2.64419 13.7103 2.64419 13.0666V10.3165C2.64419 9.8923 2.55534 9.58511 2.37764 9.39494C2.26816 9.27135 1.80618 9.17938 1.38154 9.11602C1.02726 9.06315 0.759057 8.76744 0.765747 8.4093C0.772379 8.0543 1.03439 7.7566 1.38545 7.70346C1.80778 7.63952 2.26906 7.54968 2.37764 7.43477C2.55534 7.22997 2.64419 6.92278 2.64419 6.51319V3.77772C2.64419 3.11945 2.80708 2.59284 3.13287 2.21251C3.48828 1.78829 3.99177 1.5835 4.64335 1.5835H5.33893Z",
|
|
122
|
+
fill: "currentColor"
|
|
123
|
+
}
|
|
124
|
+
),
|
|
125
|
+
/* @__PURE__ */ import_react.default.createElement(
|
|
126
|
+
"path",
|
|
127
|
+
{
|
|
128
|
+
d: "M10.962 15.2463C10.6348 15.2463 10.3696 14.9483 10.3696 14.6211C10.3696 14.2939 10.6348 14.0614 10.962 14.0614H11.391C11.9538 14.0614 12.2203 13.7542 12.2203 13.1105V10.2434C12.2203 9.51979 12.4937 8.98241 13.033 8.6387C13.1867 8.54073 13.1921 8.27703 13.0403 8.17616C12.4962 7.81472 12.2203 7.28982 12.2203 6.58638V3.70463C12.2203 3.09024 11.9538 2.76842 11.391 2.76842L10.962 2.76842C10.6348 2.76842 10.3696 2.48627 10.3696 2.15907C10.3696 1.83188 10.6348 1.58354 10.962 1.58354L11.6576 1.58354C12.3092 1.58354 12.8127 1.80296 13.1681 2.21255C13.4939 2.59289 13.6568 3.1195 13.6568 3.76314V6.51324C13.6568 6.93745 13.7456 7.24464 13.9233 7.43481C14.03 7.5553 14.4328 7.64858 14.8186 7.71393C15.1718 7.77376 15.4401 8.06977 15.4334 8.42791C15.4268 8.78291 15.1646 9.08018 14.814 9.13633C14.4306 9.19774 14.0291 9.28303 13.9233 9.39499C13.7456 9.59978 13.6568 9.90697 13.6568 10.3166V13.052C13.6568 13.7103 13.4939 14.2369 13.1681 14.6172C12.8127 15.0415 12.3092 15.2463 11.6576 15.2463H10.962Z",
|
|
129
|
+
fill: "currentColor"
|
|
130
|
+
}
|
|
131
|
+
)
|
|
132
|
+
),
|
|
133
|
+
boolean: /* @__PURE__ */ import_react.default.createElement(
|
|
134
|
+
"svg",
|
|
135
|
+
{
|
|
136
|
+
width: "1em",
|
|
137
|
+
height: "1em",
|
|
138
|
+
viewBox: "0 0 16 16",
|
|
139
|
+
fill: "none",
|
|
140
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
141
|
+
},
|
|
142
|
+
/* @__PURE__ */ import_react.default.createElement(
|
|
143
|
+
"path",
|
|
144
|
+
{
|
|
145
|
+
fillRule: "evenodd",
|
|
146
|
+
clipRule: "evenodd",
|
|
147
|
+
d: "M10.668 4.66683H5.33463C3.49369 4.66683 2.0013 6.15921 2.0013 8.00016C2.0013 9.84111 3.49369 11.3335 5.33463 11.3335H10.668C12.5089 11.3335 14.0013 9.84111 14.0013 8.00016C14.0013 6.15921 12.5089 4.66683 10.668 4.66683ZM5.33463 3.3335C2.75731 3.3335 0.667969 5.42283 0.667969 8.00016C0.667969 10.5775 2.75731 12.6668 5.33463 12.6668H10.668C13.2453 12.6668 15.3346 10.5775 15.3346 8.00016C15.3346 5.42283 13.2453 3.3335 10.668 3.3335H5.33463Z",
|
|
148
|
+
fill: "currentColor"
|
|
149
|
+
}
|
|
150
|
+
),
|
|
151
|
+
/* @__PURE__ */ import_react.default.createElement(
|
|
152
|
+
"path",
|
|
153
|
+
{
|
|
154
|
+
fillRule: "evenodd",
|
|
155
|
+
clipRule: "evenodd",
|
|
156
|
+
d: "M8.66797 8.00016C8.66797 6.89559 9.5634 6.00016 10.668 6.00016C11.7725 6.00016 12.668 6.89559 12.668 8.00016C12.668 9.10473 11.7725 10.0002 10.668 10.0002C9.5634 10.0002 8.66797 9.10473 8.66797 8.00016ZM10.668 7.3335C10.2998 7.3335 10.0013 7.63197 10.0013 8.00016C10.0013 8.36835 10.2998 8.66683 10.668 8.66683C11.0362 8.66683 11.3346 8.36835 11.3346 8.00016C11.3346 7.63197 11.0362 7.3335 10.668 7.3335Z",
|
|
157
|
+
fill: "currentColor"
|
|
158
|
+
}
|
|
159
|
+
)
|
|
160
|
+
),
|
|
161
|
+
string: /* @__PURE__ */ import_react.default.createElement(
|
|
162
|
+
"svg",
|
|
163
|
+
{
|
|
164
|
+
width: "1em",
|
|
165
|
+
height: "1em",
|
|
166
|
+
viewBox: "0 0 16 16",
|
|
167
|
+
fill: "none",
|
|
168
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
169
|
+
},
|
|
170
|
+
/* @__PURE__ */ import_react.default.createElement(
|
|
171
|
+
"path",
|
|
172
|
+
{
|
|
173
|
+
d: "M9.3342 3.33321C8.96601 3.33321 8.66753 3.63169 8.66753 3.99988C8.66753 4.36807 8.96601 4.66655 9.3342 4.66655H14.6675C15.0357 4.66655 15.3342 4.36807 15.3342 3.99988C15.3342 3.63169 15.0357 3.33321 14.6675 3.33321H9.3342Z",
|
|
174
|
+
fill: "currentColor"
|
|
175
|
+
}
|
|
176
|
+
),
|
|
177
|
+
/* @__PURE__ */ import_react.default.createElement(
|
|
178
|
+
"path",
|
|
179
|
+
{
|
|
180
|
+
d: "M10.0009 7.99988C10.0009 7.63169 10.2993 7.33321 10.6675 7.33321H14.6675C15.0357 7.33321 15.3342 7.63169 15.3342 7.99988C15.3342 8.36807 15.0357 8.66655 14.6675 8.66655H10.6675C10.2993 8.66655 10.0009 8.36807 10.0009 7.99988Z",
|
|
181
|
+
fill: "currentColor"
|
|
182
|
+
}
|
|
183
|
+
),
|
|
184
|
+
/* @__PURE__ */ import_react.default.createElement(
|
|
185
|
+
"path",
|
|
186
|
+
{
|
|
187
|
+
d: "M12.0009 11.3332C11.6327 11.3332 11.3342 11.6317 11.3342 11.9999C11.3342 12.3681 11.6327 12.6665 12.0009 12.6665H14.6675C15.0357 12.6665 15.3342 12.3681 15.3342 11.9999C15.3342 11.6317 15.0357 11.3332 14.6675 11.3332H12.0009Z",
|
|
188
|
+
fill: "currentColor"
|
|
189
|
+
}
|
|
190
|
+
),
|
|
191
|
+
/* @__PURE__ */ import_react.default.createElement(
|
|
192
|
+
"path",
|
|
193
|
+
{
|
|
194
|
+
d: "M9.86659 14.1482L8.23444 10.1844H3.18136C3.13868 10.1844 3.09685 10.1808 3.05616 10.1738L1.66589 14.1129C1.53049 14.4965 1.10971 14.6978 0.726058 14.5624C0.342408 14.427 0.141166 14.0062 0.276572 13.6225L4.37566 2.00848C4.71323 1.05202 6.05321 1.01763 6.4394 1.95552L11.2289 13.5872C11.3838 13.9634 11.2044 14.394 10.8282 14.5489C10.452 14.7038 10.0215 14.5244 9.86659 14.1482ZM5.44412 3.40791L3.57241 8.71109H7.62778L5.44412 3.40791Z",
|
|
195
|
+
fill: "currentColor"
|
|
196
|
+
}
|
|
197
|
+
)
|
|
198
|
+
),
|
|
199
|
+
integer: /* @__PURE__ */ import_react.default.createElement(
|
|
200
|
+
"svg",
|
|
201
|
+
{
|
|
202
|
+
width: "1em",
|
|
203
|
+
height: "1em",
|
|
204
|
+
viewBox: "0 0 16 16",
|
|
205
|
+
fill: "none",
|
|
206
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
207
|
+
},
|
|
208
|
+
/* @__PURE__ */ import_react.default.createElement(
|
|
209
|
+
"path",
|
|
210
|
+
{
|
|
211
|
+
d: "M15.132 11.4601C15.644 11.0121 15.9 10.3921 15.9 9.60007C15.9 8.60807 15.5 7.93607 14.7 7.58407C15.412 7.23207 15.768 6.62407 15.768 5.76007C15.768 5.05607 15.536 4.48007 15.072 4.03207C14.608 3.59207 14.012 3.37207 13.284 3.37207C12.588 3.37207 12.008 3.58007 11.544 3.99607C11.064 4.42007 10.808 4.98807 10.776 5.70007H12C12.064 4.88407 12.492 4.47607 13.284 4.47607C14.124 4.47607 14.544 4.91607 14.544 5.79607C14.544 6.66007 14.112 7.09207 13.248 7.09207H13.044V8.16007H13.248C14.2 8.16007 14.676 8.62807 14.676 9.56407C14.676 10.5081 14.212 10.9801 13.284 10.9801C12.9 10.9801 12.584 10.8761 12.336 10.6681C12.064 10.4441 11.916 10.1161 11.892 9.68407H10.668C10.692 10.4761 10.964 11.0841 11.484 11.5081C11.948 11.8921 12.548 12.0841 13.284 12.0841C14.036 12.0841 14.652 11.8761 15.132 11.4601Z",
|
|
212
|
+
fill: "currentColor"
|
|
213
|
+
}
|
|
214
|
+
),
|
|
215
|
+
/* @__PURE__ */ import_react.default.createElement(
|
|
216
|
+
"path",
|
|
217
|
+
{
|
|
218
|
+
d: "M4.46875 12.0003V10.9083L7.75675 6.91228C8.06075 6.54428 8.21275 6.16428 8.21275 5.77228C8.21275 4.90828 7.79675 4.47628 6.96475 4.47628C6.60475 4.47628 6.31275 4.57628 6.08875 4.77628C5.83275 5.00828 5.70475 5.34828 5.70475 5.79628H4.48075C4.48075 5.07628 4.71275 4.49228 5.17675 4.04428C5.64075 3.60428 6.23675 3.38428 6.96475 3.38428C7.70075 3.38428 8.29675 3.60028 8.75275 4.03228C9.20875 4.47228 9.43675 5.05628 9.43675 5.78428C9.43675 6.13628 9.36875 6.45628 9.23275 6.74428C9.12075 6.97628 8.92075 7.27228 8.63275 7.63228L5.95675 10.9083H9.43675V12.0003H4.46875Z",
|
|
219
|
+
fill: "currentColor"
|
|
220
|
+
}
|
|
221
|
+
),
|
|
222
|
+
/* @__PURE__ */ import_react.default.createElement(
|
|
223
|
+
"path",
|
|
224
|
+
{
|
|
225
|
+
d: "M1.668 12.0001V4.78805L0 6.25205V4.89605L1.668 3.45605H2.892V12.0001H1.668Z",
|
|
226
|
+
fill: "currentColor"
|
|
227
|
+
}
|
|
228
|
+
)
|
|
229
|
+
),
|
|
230
|
+
number: /* @__PURE__ */ import_react.default.createElement(
|
|
231
|
+
"svg",
|
|
232
|
+
{
|
|
233
|
+
width: "1em",
|
|
234
|
+
height: "1em",
|
|
235
|
+
viewBox: "0 0 16 16",
|
|
236
|
+
fill: "none",
|
|
237
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
238
|
+
},
|
|
239
|
+
/* @__PURE__ */ import_react.default.createElement(
|
|
240
|
+
"path",
|
|
241
|
+
{
|
|
242
|
+
d: "M3.44151 5.3068C3.44151 3.83404 4.71542 2.64014 6.18818 2.64014C7.66094 2.64014 8.93484 3.83404 8.93484 5.3068V10.6135C8.93484 12.0862 7.66094 13.2801 6.18818 13.2801C4.71542 13.2801 3.44151 12.0862 3.44151 10.6135V5.3068ZM7.60151 5.3068C7.60151 4.57042 6.92456 3.97347 6.18818 3.97347C5.4518 3.97347 4.77484 4.57042 4.77484 5.3068V10.6135C4.77484 11.3498 5.4518 11.9468 6.18818 11.9468C6.92456 11.9468 7.60151 11.3498 7.60151 10.6135V5.3068Z",
|
|
243
|
+
fill: "currentColor"
|
|
244
|
+
}
|
|
245
|
+
),
|
|
246
|
+
/* @__PURE__ */ import_react.default.createElement(
|
|
247
|
+
"path",
|
|
248
|
+
{
|
|
249
|
+
d: "M12.9882 2.64014C11.5154 2.64014 10.2415 3.83404 10.2415 5.3068V10.6135C10.2415 12.0862 11.5154 13.2801 12.9882 13.2801C14.4609 13.2801 15.7348 12.0862 15.7348 10.6135V5.3068C15.7348 3.83404 14.4609 2.64014 12.9882 2.64014ZM14.4015 10.6135C14.4015 11.3498 13.7246 11.9468 12.9882 11.9468C12.2518 11.9468 11.5748 11.3498 11.5748 10.6135V5.3068C11.5748 4.57042 12.2518 3.97347 12.9882 3.97347C13.7246 3.97347 14.4015 4.57042 14.4015 5.3068V10.6135Z",
|
|
250
|
+
fill: "currentColor"
|
|
251
|
+
}
|
|
252
|
+
),
|
|
253
|
+
/* @__PURE__ */ import_react.default.createElement(
|
|
254
|
+
"path",
|
|
255
|
+
{
|
|
256
|
+
d: "M1.21484 13.2001C1.76713 13.2001 2.21484 12.7524 2.21484 12.2001C2.21484 11.6479 1.76713 11.2001 1.21484 11.2001C0.662559 11.2001 0.214844 11.6479 0.214844 12.2001C0.214844 12.7524 0.662559 13.2001 1.21484 13.2001Z",
|
|
257
|
+
fill: "currentColor"
|
|
258
|
+
}
|
|
259
|
+
)
|
|
260
|
+
),
|
|
261
|
+
array: /* @__PURE__ */ import_react.default.createElement(
|
|
262
|
+
"svg",
|
|
263
|
+
{
|
|
264
|
+
width: "1em",
|
|
265
|
+
height: "1em",
|
|
266
|
+
viewBox: "0 0 16 16",
|
|
267
|
+
fill: "none",
|
|
268
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
269
|
+
},
|
|
270
|
+
/* @__PURE__ */ import_react.default.createElement(
|
|
271
|
+
"path",
|
|
272
|
+
{
|
|
273
|
+
d: "M5.23759 1.00342H2.00391V14.997H5.23759V13.6251H3.35127V2.37534H5.23759V1.00342Z",
|
|
274
|
+
fill: "currentColor"
|
|
275
|
+
}
|
|
276
|
+
),
|
|
277
|
+
/* @__PURE__ */ import_react.default.createElement(
|
|
278
|
+
"path",
|
|
279
|
+
{
|
|
280
|
+
d: "M10.7624 1.00342H13.9961V14.997H10.7624V13.6251H12.6487V2.37534H10.7624V1.00342Z",
|
|
281
|
+
fill: "currentColor"
|
|
282
|
+
}
|
|
283
|
+
)
|
|
284
|
+
),
|
|
285
|
+
stream: /* @__PURE__ */ import_react.default.createElement(
|
|
286
|
+
"svg",
|
|
287
|
+
{
|
|
288
|
+
viewBox: "0 0 1024 1024",
|
|
289
|
+
version: "1.1",
|
|
290
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
291
|
+
width: "1em",
|
|
292
|
+
height: "1em"
|
|
293
|
+
},
|
|
294
|
+
/* @__PURE__ */ import_react.default.createElement(
|
|
295
|
+
"path",
|
|
296
|
+
{
|
|
297
|
+
d: "M879.674 544.51l-158.254-0.221c-8.534 2.287-17.305-2.776-19.588-11.307l-23.862-75.877-74.742 350.891c0 0-1.523 18.507-11.518 18.507s-26.9 0.281-26.9 0.281c-8.259 2.213-16.748-2.687-18.961-10.949l-92.741-457.648-70.305 330.634c-2.261 8.291-11.94 15.206-20.385 12.986l-24.876 0.339c-8.723 2.293-17.685-2.789-20.023-11.349L270.629 544.51 143.993 544.51c-8.831 0-15.993-7.159-15.993-15.993l0-31.986c0-8.831 7.162-15.993 15.993-15.993l157.429-0.516c9.565-0.304 17.685 0.788 20.023 9.351l24.386 76.092 68.642-358.907c0 0 3.4-10.894 14.397-10.894 10.994 0 34.107-0.448 34.107-0.448 8.262-2.213 16.751 2.687 18.965 10.949l91.912 454.126 67.948-326.182c2.213-8.262 8.707-15.161 16.965-12.948l27.316-0.333c8.531-2.287 17.301 2.776 19.588 11.31l46.665 148.4 127.337 0c8.835 0 15.993 7.162 15.993 15.993l0 31.986C895.667 537.352 888.508 544.51 879.674 544.51z",
|
|
298
|
+
fill: "currentColor"
|
|
299
|
+
}
|
|
300
|
+
)
|
|
301
|
+
),
|
|
302
|
+
map: /* @__PURE__ */ import_react.default.createElement(
|
|
303
|
+
"svg",
|
|
304
|
+
{
|
|
305
|
+
viewBox: "0 0 1024 1024",
|
|
306
|
+
version: "1.1",
|
|
307
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
308
|
+
width: "1em",
|
|
309
|
+
height: "1em"
|
|
310
|
+
},
|
|
311
|
+
/* @__PURE__ */ import_react.default.createElement(
|
|
312
|
+
"path",
|
|
313
|
+
{
|
|
314
|
+
d: "M877.860571 938.642286h-645.851428c-27.574857 0-54.052571-11.337143-73.508572-31.744a110.957714 110.957714 0 0 1-30.500571-76.8V193.828571c0-28.745143 10.971429-56.32 30.500571-76.726857a101.888 101.888 0 0 1 73.508572-31.817143h574.171428c27.501714 0 53.979429 11.337143 73.508572 31.744 19.529143 20.333714 30.500571 48.054857 30.500571 76.8v522.020572a34.157714 34.157714 0 0 1-6.948571 22.820571c-37.156571 19.382857-57.636571 39.350857-57.636572 72.630857 0 39.716571 19.894857 50.029714 57.636572 72.777143a34.816 34.816 0 0 1-8.045714 49.298286 32.256 32.256 0 0 1-17.334858 5.193143z m-32.256-254.537143V193.828571a40.228571 40.228571 0 0 0-39.497142-41.179428H232.009143a40.301714 40.301714 0 0 0-39.497143 41.252571V699.245714c17.773714-9.874286 37.449143-14.994286 57.417143-14.921143h595.675428v-0.073142z m-595.675428 187.245714h566.198857c-22.893714-11.190857-27.940571-39.497143-28.013714-59.977143 0-20.260571 3.218286-43.885714 28.013714-59.904h-566.125714c-31.670857 0-57.417143 26.843429-57.417143 59.977143 0 33.060571 25.746286 59.904 57.344 59.904z",
|
|
315
|
+
fill: "currentColor"
|
|
316
|
+
}
|
|
317
|
+
),
|
|
318
|
+
/* @__PURE__ */ import_react.default.createElement(
|
|
319
|
+
"path",
|
|
320
|
+
{
|
|
321
|
+
d: "M320 128m32.036571 0l-0.073142 0q32.036571 0 32.036571 32.036571l0 511.926858q0 32.036571-32.036571 32.036571l0.073142 0q-32.036571 0-32.036571-32.036571l0-511.926858q0-32.036571 32.036571-32.036571Z",
|
|
322
|
+
fill: "currentColor"
|
|
323
|
+
}
|
|
324
|
+
)
|
|
325
|
+
)
|
|
326
|
+
};
|
|
327
|
+
var ArrayIcons = {
|
|
328
|
+
object: /* @__PURE__ */ import_react.default.createElement(
|
|
329
|
+
"svg",
|
|
330
|
+
{
|
|
331
|
+
width: "1em",
|
|
332
|
+
height: "1em",
|
|
333
|
+
viewBox: "0 0 16 16",
|
|
334
|
+
fill: "none",
|
|
335
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
336
|
+
},
|
|
337
|
+
/* @__PURE__ */ import_react.default.createElement(
|
|
338
|
+
"path",
|
|
339
|
+
{
|
|
340
|
+
fillRule: "evenodd",
|
|
341
|
+
clipRule: "evenodd",
|
|
342
|
+
d: "M0 1.58105H3.6139V2.87326H1.36702V13.1264H3.6139V14.4186H0V1.58105ZM3.41656 13.3264V13.3266H1.17155V13.3264H3.41656ZM0.197344 14.2186H0.199219V1.78125H3.41656V1.78105H0.197344V14.2186ZM12.3861 1.58105H16V14.4186H12.3861V13.1264H14.633V2.87326H12.3861V1.58105ZM12.5834 2.67326V1.78105H15.8027V1.78125H12.5853V2.67326H12.5834ZM12.5853 13.3266V14.2186H12.5834V13.3264H14.8303V2.67345H14.8322V13.3266H12.5853ZM3.82031 5.9091C3.82031 5.18535 4.40703 4.59863 5.13078 4.59863C5.85453 4.59863 6.44124 5.18535 6.44124 5.9091C6.44124 6.56485 5.9596 7.1081 5.33078 7.2044V8.70018H5.32877C5.32982 8.75093 5.33078 8.80912 5.33078 8.87034V9.72111C5.33078 10.0195 5.57268 10.2614 5.87109 10.2614H6.24124C6.55613 10.2614 6.8114 10.5167 6.8114 10.8316C6.8114 11.1465 6.55613 11.4017 6.24124 11.4017H5.87109C4.94291 11.4017 4.19047 10.6493 4.19047 9.72111V6.82186C3.96158 6.58607 3.82031 6.26397 3.82031 5.9091ZM7.33679 5.9091C7.33679 5.59421 7.59205 5.33894 7.90694 5.33894H11.6085C11.9234 5.33894 12.1786 5.59421 12.1786 5.9091C12.1786 6.22399 11.9234 6.47925 11.6085 6.47925H7.90694C7.59205 6.47925 7.33679 6.22399 7.33679 5.9091ZM7.33679 9.86846C7.33679 9.55357 7.59205 9.2983 7.90694 9.2983H11.6085C11.9234 9.2983 12.1786 9.55357 12.1786 9.86846C12.1786 10.1833 11.9234 10.4386 11.6085 10.4386H7.90694C7.59205 10.4386 7.33679 10.1833 7.33679 9.86846Z",
|
|
343
|
+
fill: "currentColor"
|
|
344
|
+
}
|
|
345
|
+
)
|
|
346
|
+
),
|
|
347
|
+
boolean: /* @__PURE__ */ import_react.default.createElement(
|
|
348
|
+
"svg",
|
|
349
|
+
{
|
|
350
|
+
width: "1em",
|
|
351
|
+
height: "1em",
|
|
352
|
+
viewBox: "0 0 16 16",
|
|
353
|
+
fill: "none",
|
|
354
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
355
|
+
},
|
|
356
|
+
/* @__PURE__ */ import_react.default.createElement(
|
|
357
|
+
"path",
|
|
358
|
+
{
|
|
359
|
+
fillRule: "evenodd",
|
|
360
|
+
clipRule: "evenodd",
|
|
361
|
+
d: "M0 1.58105H3.6139V2.87326H1.36702V13.1264H3.6139V14.4186H0V1.58105ZM3.41656 13.3264V13.3266H1.17155V13.3264H3.41656ZM0.197344 14.2186H0.199219V1.78125H3.41656V1.78105H0.197344V14.2186ZM12.3861 1.58105H16V14.4186H12.3861V13.1264H14.633V2.87326H12.3861V1.58105ZM12.5834 2.67326V1.78105H15.8027V1.78125H12.5853V2.67326H12.5834ZM12.5853 13.3266V14.2186H12.5834V13.3264H14.8303V2.67345H14.8322V13.3266H12.5853ZM2.75 7.99993C2.75 6.14518 4.25358 4.6416 6.10833 4.6416H9.775C11.6298 4.6416 13.1333 6.14518 13.1333 7.99993C13.1333 9.85469 11.6298 11.3583 9.775 11.3583H6.10833C4.25358 11.3583 2.75 9.85469 2.75 7.99993ZM6.10833 5.85827C4.92552 5.85827 3.96667 6.81713 3.96667 7.99993C3.96667 9.18274 4.92552 10.1416 6.10833 10.1416H9.775C10.9578 10.1416 11.9167 9.18274 11.9167 7.99993C11.9167 6.81713 10.9578 5.85827 9.775 5.85827H6.10833ZM8.25 7.99993C8.25 7.1577 8.93277 6.47493 9.775 6.47493C10.6172 6.47493 11.3 7.1577 11.3 7.99993C11.3 8.84217 10.6172 9.52493 9.775 9.52493C8.93277 9.52493 8.25 8.84217 8.25 7.99993ZM9.775 7.6916C9.60471 7.6916 9.46667 7.82965 9.46667 7.99993C9.46667 8.17022 9.60471 8.30827 9.775 8.30827C9.94529 8.30827 10.0833 8.17022 10.0833 7.99993C10.0833 7.82965 9.94529 7.6916 9.775 7.6916Z",
|
|
362
|
+
fill: "currentColor"
|
|
363
|
+
}
|
|
364
|
+
)
|
|
365
|
+
),
|
|
366
|
+
string: /* @__PURE__ */ import_react.default.createElement(
|
|
367
|
+
"svg",
|
|
368
|
+
{
|
|
369
|
+
width: "1em",
|
|
370
|
+
height: "1em",
|
|
371
|
+
viewBox: "0 0 16 16",
|
|
372
|
+
fill: "none",
|
|
373
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
374
|
+
},
|
|
375
|
+
/* @__PURE__ */ import_react.default.createElement(
|
|
376
|
+
"path",
|
|
377
|
+
{
|
|
378
|
+
fillRule: "evenodd",
|
|
379
|
+
clipRule: "evenodd",
|
|
380
|
+
d: "M0 1.58105H3.6139V2.87326H1.36702V13.1264H3.6139V14.4186H0V1.58105ZM3.41656 13.3264V13.3266H1.17155V13.3264H3.41656ZM0.197344 14.2186H0.199219V1.78125H3.41656V1.78105H0.197344V14.2186ZM12.3861 1.58105H16V14.4186H12.3861V13.1264H14.633V2.87326H12.3861V1.58105ZM12.5834 2.67326V1.78105H15.8027V1.78125H12.5853V2.67326H12.5834ZM12.5853 13.3266V14.2186H12.5834V13.3264H14.8303V2.67345H14.8322V13.3266H12.5853ZM5.23701 4.07158C5.50364 3.3161 6.56205 3.28894 6.86709 4.02974L10 11.6383C10.1329 11.9609 9.979 12.3302 9.65631 12.4631C9.33363 12.596 8.96434 12.4421 8.83147 12.1194L7.8021 9.61951H4.61903L3.7474 12.0891C3.63126 12.4182 3.27034 12.5908 2.94127 12.4747C2.6122 12.3585 2.43958 11.9976 2.55573 11.6685L5.23701 4.07158ZM6.08814 5.45704L5.06505 8.35579H7.28174L6.08814 5.45704ZM8.81938 6.07534C8.81938 5.75166 9.08177 5.48926 9.40545 5.48926H12.8941C13.2178 5.48926 13.4802 5.75166 13.4802 6.07534C13.4802 6.39902 13.2178 6.66142 12.8941 6.66142H9.40545C9.08177 6.66142 8.81938 6.39902 8.81938 6.07534ZM10.2668 9.69181C10.2668 9.36812 10.5292 9.10573 10.8529 9.10573H12.8941C13.2178 9.10573 13.4802 9.36812 13.4802 9.69181C13.4802 10.0155 13.2178 10.2779 12.8941 10.2779H10.8529C10.5292 10.2779 10.2668 10.0155 10.2668 9.69181Z",
|
|
381
|
+
fill: "currentColor"
|
|
382
|
+
}
|
|
383
|
+
)
|
|
384
|
+
),
|
|
385
|
+
integer: /* @__PURE__ */ import_react.default.createElement(
|
|
386
|
+
"svg",
|
|
387
|
+
{
|
|
388
|
+
width: "1em",
|
|
389
|
+
height: "1em",
|
|
390
|
+
viewBox: "0 0 16 16",
|
|
391
|
+
fill: "none",
|
|
392
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
393
|
+
},
|
|
394
|
+
/* @__PURE__ */ import_react.default.createElement(
|
|
395
|
+
"path",
|
|
396
|
+
{
|
|
397
|
+
fillRule: "evenodd",
|
|
398
|
+
clipRule: "evenodd",
|
|
399
|
+
d: "M0 1.58105H3.6139V2.87326H1.36702V13.1264H3.6139V14.4186H0V1.58105ZM3.41656 13.3264V13.3266H1.17155V13.3264H3.41656ZM0.197344 14.2186H0.199219V1.78125H3.41656V1.78105H0.197344V14.2186ZM12.3861 1.58105H16V14.4186H12.3861V13.1264H14.633V2.87326H12.3861V1.58105ZM12.5834 2.67326V1.78105H15.8027V1.78125H12.5853V2.67326H12.5834ZM12.5853 13.3266V14.2186H12.5834V13.3264H14.8303V2.67345H14.8322V13.3266H12.5853ZM10.3614 5.22374C10.7161 4.90585 11.1581 4.75 11.6762 4.75C12.2173 4.75 12.6723 4.91467 13.0281 5.25207L13.0291 5.253C13.3852 5.59688 13.561 6.03946 13.561 6.56767C13.561 6.89 13.4945 7.17448 13.3539 7.41445C13.2572 7.57972 13.1279 7.71948 12.9685 7.83428C13.1575 7.95643 13.3099 8.11182 13.4225 8.30109C13.5793 8.5644 13.6531 8.88311 13.6531 9.24936C13.6531 9.83787 13.4612 10.3151 13.0656 10.6612C12.6982 10.9795 12.2305 11.1341 11.6762 11.1341C11.1356 11.1341 10.6805 10.9925 10.324 10.6977C9.92124 10.3691 9.71723 9.90026 9.69942 9.31256L9.69473 9.15802H10.846L10.8539 9.2997C10.8689 9.5698 10.9591 9.75553 11.1096 9.87941L11.1106 9.88027C11.2519 9.99882 11.4365 10.0631 11.6762 10.0631C11.9765 10.0631 12.1743 9.98692 12.2984 9.86071C12.4229 9.73404 12.4984 9.53136 12.4984 9.22422C12.4984 8.92116 12.4215 8.72127 12.2939 8.59581C12.1658 8.46989 11.961 8.39373 11.6511 8.39373H11.3586V7.34788H11.6511C11.9297 7.34788 12.111 7.27834 12.2238 7.16555C12.3366 7.05276 12.4062 6.87138 12.4062 6.59281C12.4062 6.30696 12.3378 6.12041 12.2277 6.00501C12.1188 5.89092 11.9446 5.82098 11.6762 5.82098C11.4248 5.82098 11.2539 5.88537 11.1407 5.99325C11.0268 6.10185 10.9497 6.27522 10.9291 6.5375L10.9183 6.67577H9.76788L9.77492 6.51904C9.79886 5.98644 9.99237 5.54989 10.3614 5.22374ZM5.91032 5.26037C6.26612 4.92297 6.72112 4.7583 7.26219 4.7583C7.80751 4.7583 8.26297 4.91938 8.61401 5.25194L8.61501 5.25289C8.96719 5.59272 9.13852 6.04185 9.13852 6.58435C9.13852 6.84997 9.08709 7.09565 8.9817 7.31883L8.98114 7.31999C8.89563 7.49712 8.74775 7.71415 8.54418 7.96862L8.54322 7.96981L6.87446 10.0127H9.13852V11.0753H5.36909V10.1089L7.69946 7.27679C7.89456 7.04062 7.98374 6.80773 7.98374 6.57597C7.98374 6.29602 7.91626 6.11385 7.8078 6.00122C7.70036 5.88964 7.52811 5.8209 7.26219 5.8209C7.04017 5.8209 6.87439 5.88173 6.75075 5.99193C6.61227 6.11766 6.53226 6.30918 6.53226 6.59273V6.74273H5.37747V6.59273C5.37747 6.05443 5.55248 5.60586 5.90934 5.2613L5.91032 5.26037ZM3.50907 4.80865H4.56964V11.0754H3.41486V6.2201L2.25 7.24249V5.89561L3.50907 4.80865Z",
|
|
400
|
+
fill: "currentColor"
|
|
401
|
+
}
|
|
402
|
+
)
|
|
403
|
+
),
|
|
404
|
+
number: /* @__PURE__ */ import_react.default.createElement(
|
|
405
|
+
"svg",
|
|
406
|
+
{
|
|
407
|
+
width: "1em",
|
|
408
|
+
height: "1em",
|
|
409
|
+
viewBox: "0 0 16 16",
|
|
410
|
+
fill: "none",
|
|
411
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
412
|
+
},
|
|
413
|
+
/* @__PURE__ */ import_react.default.createElement(
|
|
414
|
+
"path",
|
|
415
|
+
{
|
|
416
|
+
fillRule: "evenodd",
|
|
417
|
+
clipRule: "evenodd",
|
|
418
|
+
d: "M3.6139 1.58154H0V14.4191H3.6139V13.1269H1.36702V2.87375H3.6139V1.58154ZM3.41656 13.3271V13.3269H1.17155V13.3271H3.41656ZM0.199219 14.2191H0.197344V1.78154H3.41656V1.78174H0.199219V14.2191ZM16 1.58154H12.3861V2.87375H14.633V13.1269H12.3861V14.4191H16V1.58154ZM12.5834 1.78154V2.67375H12.5853V1.78174H15.8027V1.78154H12.5834ZM12.5853 14.2191V13.3271H14.8322V2.67394H14.8303V13.3269H12.5834V14.2191H12.5853ZM6.86771 4.5C5.87019 4.5 5.00104 5.30767 5.00104 6.31667V9.63333C5.00104 10.6423 5.87019 11.45 6.86771 11.45C7.86523 11.45 8.73438 10.6423 8.73438 9.63333V6.31667C8.73438 5.30767 7.86523 4.5 6.86771 4.5ZM11.1177 4.5C10.1202 4.5 9.25104 5.30767 9.25104 6.31667V9.63333C9.25104 10.6423 10.1202 11.45 11.1177 11.45C12.1152 11.45 12.9844 10.6423 12.9844 9.63333V6.31667C12.9844 5.30767 12.1152 4.5 11.1177 4.5ZM6.13438 6.31667C6.13438 5.9503 6.47884 5.63333 6.86771 5.63333C7.25657 5.63333 7.60104 5.9503 7.60104 6.31667V9.63333C7.60104 9.9997 7.25657 10.3167 6.86771 10.3167C6.47884 10.3167 6.13438 9.9997 6.13438 9.63333V6.31667ZM10.3844 6.31667C10.3844 5.9503 10.7288 5.63333 11.1177 5.63333C11.5066 5.63333 11.851 5.9503 11.851 6.31667V9.63333C11.851 9.9997 11.5066 10.3167 11.1177 10.3167C10.7288 10.3167 10.3844 9.9997 10.3844 9.63333V6.31667ZM3.75938 9.85C3.33135 9.85 2.98438 10.197 2.98438 10.625C2.98438 11.053 3.33135 11.4 3.75938 11.4C4.1874 11.4 4.53438 11.053 4.53438 10.625C4.53438 10.197 4.1874 9.85 3.75938 9.85Z",
|
|
419
|
+
fill: "currentColor"
|
|
420
|
+
}
|
|
421
|
+
)
|
|
422
|
+
)
|
|
423
|
+
};
|
|
424
|
+
var getSchemaIcon = (value) => {
|
|
425
|
+
if (value?.type === "array") {
|
|
426
|
+
return ArrayIcons[value.items?.type || "object"];
|
|
427
|
+
}
|
|
428
|
+
return VariableTypeIcons[value?.type || "object"];
|
|
429
|
+
};
|
|
430
|
+
var labelStyle = { display: "flex", alignItems: "center", gap: 5 };
|
|
431
|
+
var firstUppercase = (str) => str.charAt(0).toUpperCase() + str.slice(1);
|
|
432
|
+
var baseOptions = [
|
|
433
|
+
{
|
|
434
|
+
label: /* @__PURE__ */ import_react.default.createElement("div", { style: labelStyle }, /* @__PURE__ */ import_react.default.createElement(import_semi_icons.default, { size: "small", svg: getSchemaIcon({ type: "string" }) }), firstUppercase("string")),
|
|
435
|
+
value: "string"
|
|
436
|
+
},
|
|
437
|
+
{
|
|
438
|
+
label: /* @__PURE__ */ import_react.default.createElement("div", { style: labelStyle }, /* @__PURE__ */ import_react.default.createElement(import_semi_icons.default, { size: "small", svg: getSchemaIcon({ type: "integer" }) }), firstUppercase("integer")),
|
|
439
|
+
value: "integer"
|
|
440
|
+
},
|
|
441
|
+
{
|
|
442
|
+
label: /* @__PURE__ */ import_react.default.createElement("div", { style: labelStyle }, /* @__PURE__ */ import_react.default.createElement(import_semi_icons.default, { size: "small", svg: getSchemaIcon({ type: "number" }) }), firstUppercase("number")),
|
|
443
|
+
value: "number"
|
|
444
|
+
},
|
|
445
|
+
{
|
|
446
|
+
label: /* @__PURE__ */ import_react.default.createElement("div", { style: labelStyle }, /* @__PURE__ */ import_react.default.createElement(import_semi_icons.default, { size: "small", svg: getSchemaIcon({ type: "boolean" }) }), firstUppercase("boolean")),
|
|
447
|
+
value: "boolean"
|
|
448
|
+
},
|
|
449
|
+
{
|
|
450
|
+
label: /* @__PURE__ */ import_react.default.createElement("div", { style: labelStyle }, /* @__PURE__ */ import_react.default.createElement(import_semi_icons.default, { size: "small", svg: getSchemaIcon({ type: "object" }) }), firstUppercase("object")),
|
|
451
|
+
value: "object"
|
|
452
|
+
}
|
|
453
|
+
];
|
|
454
|
+
var options = [
|
|
455
|
+
...baseOptions,
|
|
456
|
+
{
|
|
457
|
+
label: /* @__PURE__ */ import_react.default.createElement("div", { style: labelStyle }, /* @__PURE__ */ import_react.default.createElement(import_semi_icons.default, { size: "small", svg: getSchemaIcon({ type: "array" }) }), firstUppercase("array")),
|
|
458
|
+
value: "array",
|
|
459
|
+
children: baseOptions.map((_opt) => ({
|
|
460
|
+
..._opt,
|
|
461
|
+
value: `${_opt.value}`,
|
|
462
|
+
label: /* @__PURE__ */ import_react.default.createElement("div", { style: labelStyle }, /* @__PURE__ */ import_react.default.createElement(
|
|
463
|
+
import_semi_icons.default,
|
|
464
|
+
{
|
|
465
|
+
size: "small",
|
|
466
|
+
svg: getSchemaIcon({ type: "array", items: { type: _opt.value } })
|
|
467
|
+
}
|
|
468
|
+
), firstUppercase(_opt.value))
|
|
469
|
+
}))
|
|
470
|
+
}
|
|
471
|
+
];
|
|
472
|
+
|
|
473
|
+
// src/utils/json-schema/index.ts
|
|
474
|
+
var import_lodash = require("lodash");
|
|
475
|
+
var import_editor = require("@flowgram.ai/editor");
|
|
476
|
+
var JsonSchemaUtils;
|
|
477
|
+
((JsonSchemaUtils2) => {
|
|
478
|
+
function schemaToAST(jsonSchema) {
|
|
479
|
+
const { type, extra } = jsonSchema || {};
|
|
480
|
+
const { weak = false } = extra || {};
|
|
481
|
+
if (!type) {
|
|
482
|
+
return void 0;
|
|
483
|
+
}
|
|
484
|
+
switch (type) {
|
|
485
|
+
case "object":
|
|
486
|
+
if (weak) {
|
|
487
|
+
return { kind: import_editor.ASTKind.Object, weak: true };
|
|
488
|
+
}
|
|
489
|
+
return import_editor.ASTFactory.createObject({
|
|
490
|
+
properties: Object.entries(jsonSchema.properties || {}).sort((a, b) => ((0, import_lodash.get)(a?.[1], "extra.index") || 0) - ((0, import_lodash.get)(b?.[1], "extra.index") || 0)).map(([key, _property]) => ({
|
|
491
|
+
key,
|
|
492
|
+
type: schemaToAST(_property),
|
|
493
|
+
meta: {
|
|
494
|
+
title: _property.title,
|
|
495
|
+
description: _property.description
|
|
496
|
+
}
|
|
497
|
+
}))
|
|
498
|
+
});
|
|
499
|
+
case "array":
|
|
500
|
+
if (weak) {
|
|
501
|
+
return { kind: import_editor.ASTKind.Array, weak: true };
|
|
502
|
+
}
|
|
503
|
+
return import_editor.ASTFactory.createArray({
|
|
504
|
+
items: schemaToAST(jsonSchema.items)
|
|
505
|
+
});
|
|
506
|
+
case "map":
|
|
507
|
+
if (weak) {
|
|
508
|
+
return { kind: import_editor.ASTKind.Map, weak: true };
|
|
509
|
+
}
|
|
510
|
+
return import_editor.ASTFactory.createMap({
|
|
511
|
+
valueType: schemaToAST(jsonSchema.additionalProperties)
|
|
512
|
+
});
|
|
513
|
+
case "string":
|
|
514
|
+
return import_editor.ASTFactory.createString();
|
|
515
|
+
case "number":
|
|
516
|
+
return import_editor.ASTFactory.createNumber();
|
|
517
|
+
case "boolean":
|
|
518
|
+
return import_editor.ASTFactory.createBoolean();
|
|
519
|
+
case "integer":
|
|
520
|
+
return import_editor.ASTFactory.createInteger();
|
|
521
|
+
default:
|
|
522
|
+
return import_editor.ASTFactory.createCustomType({ typeName: type });
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
JsonSchemaUtils2.schemaToAST = schemaToAST;
|
|
526
|
+
function astToSchema(typeAST, options2) {
|
|
527
|
+
const { drilldown = true } = options2 || {};
|
|
528
|
+
if (import_editor.ASTMatch.isString(typeAST)) {
|
|
529
|
+
return {
|
|
530
|
+
type: "string"
|
|
531
|
+
};
|
|
532
|
+
}
|
|
533
|
+
if (import_editor.ASTMatch.isBoolean(typeAST)) {
|
|
534
|
+
return {
|
|
535
|
+
type: "boolean"
|
|
536
|
+
};
|
|
537
|
+
}
|
|
538
|
+
if (import_editor.ASTMatch.isNumber(typeAST)) {
|
|
539
|
+
return {
|
|
540
|
+
type: "number"
|
|
541
|
+
};
|
|
542
|
+
}
|
|
543
|
+
if (import_editor.ASTMatch.isInteger(typeAST)) {
|
|
544
|
+
return {
|
|
545
|
+
type: "integer"
|
|
546
|
+
};
|
|
547
|
+
}
|
|
548
|
+
if (import_editor.ASTMatch.isObject(typeAST)) {
|
|
549
|
+
return {
|
|
550
|
+
type: "object",
|
|
551
|
+
properties: drilldown ? Object.fromEntries(
|
|
552
|
+
typeAST.properties.map((property) => {
|
|
553
|
+
const schema = astToSchema(property.type);
|
|
554
|
+
if (property.meta?.title && schema) {
|
|
555
|
+
schema.title = property.meta.title;
|
|
556
|
+
}
|
|
557
|
+
if (property.meta?.description && schema) {
|
|
558
|
+
schema.description = property.meta.description;
|
|
559
|
+
}
|
|
560
|
+
return [property.key, schema];
|
|
561
|
+
})
|
|
562
|
+
) : {}
|
|
563
|
+
};
|
|
564
|
+
}
|
|
565
|
+
if (import_editor.ASTMatch.isArray(typeAST)) {
|
|
566
|
+
return {
|
|
567
|
+
type: "array",
|
|
568
|
+
items: drilldown ? astToSchema(typeAST.items) : void 0
|
|
569
|
+
};
|
|
570
|
+
}
|
|
571
|
+
if (import_editor.ASTMatch.isMap(typeAST)) {
|
|
572
|
+
return {
|
|
573
|
+
type: "map",
|
|
574
|
+
items: drilldown ? astToSchema(typeAST.valueType) : void 0
|
|
575
|
+
};
|
|
576
|
+
}
|
|
577
|
+
if (import_editor.ASTMatch.isCustomType(typeAST)) {
|
|
578
|
+
return {
|
|
579
|
+
type: typeAST.typeName
|
|
580
|
+
};
|
|
581
|
+
}
|
|
582
|
+
return void 0;
|
|
583
|
+
}
|
|
584
|
+
JsonSchemaUtils2.astToSchema = astToSchema;
|
|
585
|
+
function isASTMatchSchema(typeAST, schema) {
|
|
586
|
+
if (Array.isArray(schema)) {
|
|
587
|
+
return typeAST.isTypeEqual(
|
|
588
|
+
import_editor.ASTFactory.createUnion({
|
|
589
|
+
types: schema.map((_schema) => schemaToAST(_schema)).filter(Boolean)
|
|
590
|
+
})
|
|
591
|
+
);
|
|
592
|
+
}
|
|
593
|
+
return typeAST.isTypeEqual(schemaToAST(schema));
|
|
594
|
+
}
|
|
595
|
+
JsonSchemaUtils2.isASTMatchSchema = isASTMatchSchema;
|
|
596
|
+
})(JsonSchemaUtils || (JsonSchemaUtils = {}));
|
|
597
|
+
|
|
598
|
+
// src/components/variable-selector/use-variable-tree.tsx
|
|
599
|
+
function useVariableTree(params) {
|
|
600
|
+
const { includeSchema, excludeSchema, customSkip } = params;
|
|
601
|
+
const variables = (0, import_editor2.useAvailableVariables)();
|
|
602
|
+
const getVariableTypeIcon = (0, import_react2.useCallback)((variable) => {
|
|
603
|
+
if (variable.meta?.icon) {
|
|
604
|
+
if (typeof variable.meta.icon === "string") {
|
|
605
|
+
return /* @__PURE__ */ import_react2.default.createElement("img", { style: { marginRight: 8 }, width: 12, height: 12, src: variable.meta.icon });
|
|
606
|
+
}
|
|
607
|
+
return variable.meta.icon;
|
|
608
|
+
}
|
|
609
|
+
const _type = variable.type;
|
|
610
|
+
if (import_editor2.ASTMatch.isArray(_type)) {
|
|
611
|
+
return /* @__PURE__ */ import_react2.default.createElement(
|
|
612
|
+
import_semi_ui.Icon,
|
|
613
|
+
{
|
|
614
|
+
size: "small",
|
|
615
|
+
svg: ArrayIcons[_type.items?.kind.toLowerCase()] || VariableTypeIcons.array
|
|
616
|
+
}
|
|
617
|
+
);
|
|
618
|
+
}
|
|
619
|
+
if (import_editor2.ASTMatch.isCustomType(_type)) {
|
|
620
|
+
return /* @__PURE__ */ import_react2.default.createElement(import_semi_ui.Icon, { size: "small", svg: VariableTypeIcons[_type.typeName.toLowerCase()] });
|
|
621
|
+
}
|
|
622
|
+
return /* @__PURE__ */ import_react2.default.createElement(import_semi_ui.Icon, { size: "small", svg: VariableTypeIcons[variable.type?.kind.toLowerCase()] });
|
|
623
|
+
}, []);
|
|
624
|
+
const renderVariable = (variable, parentFields = []) => {
|
|
625
|
+
let type = variable?.type;
|
|
626
|
+
if (!type) {
|
|
627
|
+
return null;
|
|
628
|
+
}
|
|
629
|
+
let children;
|
|
630
|
+
if (import_editor2.ASTMatch.isObject(type)) {
|
|
631
|
+
children = (type.properties || []).map((_property) => renderVariable(_property, [...parentFields, variable])).filter(Boolean);
|
|
632
|
+
}
|
|
633
|
+
const keyPath = [...parentFields.map((_field) => _field.key), variable.key];
|
|
634
|
+
const key = keyPath.join(".");
|
|
635
|
+
const isSchemaInclude = includeSchema ? JsonSchemaUtils.isASTMatchSchema(type, includeSchema) : true;
|
|
636
|
+
const isSchemaExclude = excludeSchema ? JsonSchemaUtils.isASTMatchSchema(type, excludeSchema) : false;
|
|
637
|
+
const isCustomSkip = customSkip ? customSkip(variable) : false;
|
|
638
|
+
const isSchemaMatch = isSchemaInclude && !isSchemaExclude && !isCustomSkip;
|
|
639
|
+
if (!isSchemaMatch && !children?.length) {
|
|
640
|
+
return null;
|
|
641
|
+
}
|
|
642
|
+
return {
|
|
643
|
+
key,
|
|
644
|
+
label: variable.meta?.title || variable.key,
|
|
645
|
+
value: key,
|
|
646
|
+
keyPath,
|
|
647
|
+
icon: getVariableTypeIcon(variable),
|
|
648
|
+
children,
|
|
649
|
+
disabled: !isSchemaMatch,
|
|
650
|
+
rootMeta: parentFields[0]?.meta || variable.meta,
|
|
651
|
+
isRoot: !parentFields?.length
|
|
652
|
+
};
|
|
653
|
+
};
|
|
654
|
+
return [...variables.slice(0).reverse()].map((_variable) => renderVariable(_variable)).filter(Boolean);
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
// src/components/variable-selector/styles.tsx
|
|
658
|
+
var import_styled_components = __toESM(require("styled-components"));
|
|
659
|
+
var import_semi_ui2 = require("@douyinfe/semi-ui");
|
|
660
|
+
var UIRootTitle = import_styled_components.default.div`
|
|
661
|
+
margin-right: 4px;
|
|
662
|
+
min-width: 20px;
|
|
663
|
+
overflow: hidden;
|
|
664
|
+
text-overflow: ellipsis;
|
|
665
|
+
white-space: nowrap;
|
|
666
|
+
color: var(--semi-color-text-2);
|
|
667
|
+
`;
|
|
668
|
+
var UIVarName = import_styled_components.default.div`
|
|
669
|
+
overflow: hidden;
|
|
670
|
+
text-overflow: ellipsis;
|
|
671
|
+
white-space: nowrap;
|
|
672
|
+
|
|
673
|
+
${({ $inSelector }) => $inSelector && import_styled_components.css`
|
|
674
|
+
min-width: 50%;
|
|
675
|
+
`}
|
|
676
|
+
`;
|
|
677
|
+
var UITag = (0, import_styled_components.default)(import_semi_ui2.Tag)`
|
|
678
|
+
width: 100%;
|
|
679
|
+
display: flex;
|
|
680
|
+
align-items: center;
|
|
681
|
+
justify-content: flex-start;
|
|
682
|
+
|
|
683
|
+
& .semi-tag-content-center {
|
|
684
|
+
justify-content: flex-start;
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
&.semi-tag {
|
|
688
|
+
margin: 0;
|
|
689
|
+
height: 22px;
|
|
690
|
+
}
|
|
691
|
+
`;
|
|
692
|
+
var UITreeSelect = (0, import_styled_components.default)(import_semi_ui2.TreeSelect)`
|
|
693
|
+
outline: ${({ $error }) => $error ? "1px solid red" : "none"};
|
|
694
|
+
|
|
695
|
+
& .semi-tree-select-selection {
|
|
696
|
+
padding: 0px;
|
|
697
|
+
height: 22px;
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
& .semi-tree-select-selection-content {
|
|
701
|
+
width: 100%;
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
& .semi-tree-select-selection-placeholder {
|
|
705
|
+
padding-left: 10px;
|
|
706
|
+
}
|
|
707
|
+
`;
|
|
708
|
+
var UIPopoverContent = import_styled_components.default.div`
|
|
709
|
+
padding: 10px;
|
|
710
|
+
display: inline-flex;
|
|
711
|
+
align-items: center;
|
|
712
|
+
justify-content: flex-start;
|
|
713
|
+
white-space: nowrap;
|
|
714
|
+
`;
|
|
715
|
+
|
|
716
|
+
// src/components/variable-selector/index.tsx
|
|
717
|
+
var VariableSelector = ({
|
|
718
|
+
value,
|
|
719
|
+
config = {},
|
|
720
|
+
onChange,
|
|
721
|
+
style,
|
|
722
|
+
readonly = false,
|
|
723
|
+
includeSchema,
|
|
724
|
+
excludeSchema,
|
|
725
|
+
hasError,
|
|
726
|
+
triggerRender
|
|
727
|
+
}) => {
|
|
728
|
+
const treeData = useVariableTree({ includeSchema, excludeSchema });
|
|
729
|
+
const treeValue = (0, import_react3.useMemo)(() => {
|
|
730
|
+
if (typeof value === "string") {
|
|
731
|
+
console.warn(
|
|
732
|
+
"The Value of VariableSelector is a string, it should be an ARRAY. \n",
|
|
733
|
+
"Please check the value of VariableSelector \n"
|
|
734
|
+
);
|
|
735
|
+
return value;
|
|
736
|
+
}
|
|
737
|
+
return value?.join(".");
|
|
738
|
+
}, [value]);
|
|
739
|
+
const renderIcon = (icon) => {
|
|
740
|
+
if (typeof icon === "string") {
|
|
741
|
+
return /* @__PURE__ */ import_react3.default.createElement("img", { style: { marginRight: 8 }, width: 12, height: 12, src: icon });
|
|
742
|
+
}
|
|
743
|
+
return icon;
|
|
744
|
+
};
|
|
745
|
+
return /* @__PURE__ */ import_react3.default.createElement(import_react3.default.Fragment, null, /* @__PURE__ */ import_react3.default.createElement(
|
|
746
|
+
UITreeSelect,
|
|
747
|
+
{
|
|
748
|
+
dropdownMatchSelectWidth: false,
|
|
749
|
+
disabled: readonly,
|
|
750
|
+
treeData,
|
|
751
|
+
size: "small",
|
|
752
|
+
value: treeValue,
|
|
753
|
+
clearIcon: null,
|
|
754
|
+
$error: hasError,
|
|
755
|
+
style,
|
|
756
|
+
validateStatus: hasError ? "error" : void 0,
|
|
757
|
+
onChange: (_, _config) => {
|
|
758
|
+
onChange(_config.keyPath);
|
|
759
|
+
},
|
|
760
|
+
renderSelectedItem: (_option) => {
|
|
761
|
+
if (!_option?.keyPath) {
|
|
762
|
+
return /* @__PURE__ */ import_react3.default.createElement(
|
|
763
|
+
UITag,
|
|
764
|
+
{
|
|
765
|
+
prefixIcon: /* @__PURE__ */ import_react3.default.createElement(import_semi_icons2.IconIssueStroked, null),
|
|
766
|
+
color: "amber",
|
|
767
|
+
closable: !readonly,
|
|
768
|
+
onClose: () => onChange(void 0)
|
|
769
|
+
},
|
|
770
|
+
config?.notFoundContent ?? "Undefined"
|
|
771
|
+
);
|
|
772
|
+
}
|
|
773
|
+
const rootIcon = renderIcon(_option.rootMeta?.icon || _option?.icon);
|
|
774
|
+
const rootTitle = /* @__PURE__ */ import_react3.default.createElement(UIRootTitle, null, _option.rootMeta?.title ? `${_option.rootMeta?.title} ${_option.isRoot ? "" : "-"} ` : null);
|
|
775
|
+
return /* @__PURE__ */ import_react3.default.createElement("div", null, /* @__PURE__ */ import_react3.default.createElement(
|
|
776
|
+
import_semi_ui3.Popover,
|
|
777
|
+
{
|
|
778
|
+
content: /* @__PURE__ */ import_react3.default.createElement(UIPopoverContent, null, rootIcon, rootTitle, /* @__PURE__ */ import_react3.default.createElement(UIVarName, null, _option.keyPath.slice(1).join(".")))
|
|
779
|
+
},
|
|
780
|
+
/* @__PURE__ */ import_react3.default.createElement(
|
|
781
|
+
UITag,
|
|
782
|
+
{
|
|
783
|
+
prefixIcon: rootIcon,
|
|
784
|
+
closable: !readonly,
|
|
785
|
+
onClose: () => onChange(void 0)
|
|
786
|
+
},
|
|
787
|
+
rootTitle,
|
|
788
|
+
!_option.isRoot && /* @__PURE__ */ import_react3.default.createElement(UIVarName, { $inSelector: true }, _option.label)
|
|
789
|
+
)
|
|
790
|
+
));
|
|
791
|
+
},
|
|
792
|
+
showClear: false,
|
|
793
|
+
arrowIcon: /* @__PURE__ */ import_react3.default.createElement(import_semi_icons2.IconChevronDownStroked, { size: "small" }),
|
|
794
|
+
triggerRender,
|
|
795
|
+
placeholder: config?.placeholder ?? "Select Variable..."
|
|
796
|
+
}
|
|
797
|
+
));
|
|
798
|
+
};
|
|
799
|
+
|
|
800
|
+
// src/components/type-selector/index.tsx
|
|
801
|
+
var import_react4 = __toESM(require("react"));
|
|
802
|
+
var import_semi_ui4 = require("@douyinfe/semi-ui");
|
|
803
|
+
var getTypeSelectValue = (value) => {
|
|
804
|
+
if (value?.type === "array" && value?.items) {
|
|
805
|
+
return [value.type, ...getTypeSelectValue(value.items) || []];
|
|
806
|
+
}
|
|
807
|
+
return value?.type ? [value.type] : void 0;
|
|
808
|
+
};
|
|
809
|
+
var parseTypeSelectValue = (value) => {
|
|
810
|
+
const [type, ...subTypes] = value || [];
|
|
811
|
+
if (type === "array") {
|
|
812
|
+
return { type: "array", items: parseTypeSelectValue(subTypes) };
|
|
813
|
+
}
|
|
814
|
+
return { type };
|
|
815
|
+
};
|
|
816
|
+
function TypeSelector(props) {
|
|
817
|
+
const { value, onChange, readonly, disabled, style } = props;
|
|
818
|
+
const selectValue = (0, import_react4.useMemo)(() => getTypeSelectValue(value), [value]);
|
|
819
|
+
return /* @__PURE__ */ import_react4.default.createElement(
|
|
820
|
+
import_semi_ui4.Cascader,
|
|
821
|
+
{
|
|
822
|
+
disabled: readonly || disabled,
|
|
823
|
+
size: "small",
|
|
824
|
+
triggerRender: () => /* @__PURE__ */ import_react4.default.createElement(
|
|
825
|
+
import_semi_ui4.IconButton,
|
|
826
|
+
{
|
|
827
|
+
size: "small",
|
|
828
|
+
style,
|
|
829
|
+
disabled: readonly || disabled,
|
|
830
|
+
icon: getSchemaIcon(value)
|
|
831
|
+
}
|
|
832
|
+
),
|
|
833
|
+
treeData: options,
|
|
834
|
+
value: selectValue,
|
|
835
|
+
leafOnly: true,
|
|
836
|
+
onChange: (value2) => {
|
|
837
|
+
onChange?.(parseTypeSelectValue(value2));
|
|
838
|
+
}
|
|
839
|
+
}
|
|
840
|
+
);
|
|
841
|
+
}
|
|
842
|
+
|
|
843
|
+
// src/components/json-schema-editor/index.tsx
|
|
844
|
+
var import_react10 = __toESM(require("react"));
|
|
845
|
+
var import_semi_ui7 = require("@douyinfe/semi-ui");
|
|
846
|
+
var import_semi_icons5 = require("@douyinfe/semi-icons");
|
|
847
|
+
|
|
848
|
+
// src/components/json-schema-editor/styles.tsx
|
|
849
|
+
var import_react5 = __toESM(require("react"));
|
|
850
|
+
var import_styled_components2 = __toESM(require("styled-components"));
|
|
851
|
+
var import_semi_icons3 = __toESM(require("@douyinfe/semi-icons"));
|
|
852
|
+
var UIContainer = import_styled_components2.default.div`
|
|
853
|
+
/* & .semi-input {
|
|
854
|
+
background-color: #fff;
|
|
855
|
+
border-radius: 6px;
|
|
856
|
+
height: 24px;
|
|
857
|
+
} */
|
|
858
|
+
`;
|
|
859
|
+
var UIRow = import_styled_components2.default.div`
|
|
860
|
+
display: flex;
|
|
861
|
+
align-items: center;
|
|
862
|
+
gap: 6px;
|
|
863
|
+
`;
|
|
864
|
+
var UICollapseTrigger = import_styled_components2.default.div`
|
|
865
|
+
cursor: pointer;
|
|
866
|
+
margin-right: 5px;
|
|
867
|
+
`;
|
|
868
|
+
var UIExpandDetail = import_styled_components2.default.div`
|
|
869
|
+
display: flex;
|
|
870
|
+
flex-direction: column;
|
|
871
|
+
`;
|
|
872
|
+
var UILabel = import_styled_components2.default.div`
|
|
873
|
+
font-size: 12px;
|
|
874
|
+
color: #999;
|
|
875
|
+
font-weight: 400;
|
|
876
|
+
margin-bottom: 2px;
|
|
877
|
+
`;
|
|
878
|
+
var UIProperties = import_styled_components2.default.div`
|
|
879
|
+
display: grid;
|
|
880
|
+
grid-template-columns: auto 1fr;
|
|
881
|
+
|
|
882
|
+
${({ $shrink }) => $shrink && import_styled_components2.css`
|
|
883
|
+
padding-left: 10px;
|
|
884
|
+
margin-top: 10px;
|
|
885
|
+
`}
|
|
886
|
+
`;
|
|
887
|
+
var UIPropertyLeft = import_styled_components2.default.div`
|
|
888
|
+
grid-column: 1;
|
|
889
|
+
position: relative;
|
|
890
|
+
width: 16px;
|
|
891
|
+
|
|
892
|
+
${({ $showLine, $isLast, $parentType }) => {
|
|
893
|
+
let height = "100%";
|
|
894
|
+
if ($parentType && $isLast) {
|
|
895
|
+
height = "24px";
|
|
896
|
+
}
|
|
897
|
+
return $showLine && import_styled_components2.css`
|
|
898
|
+
&::before {
|
|
899
|
+
/* 竖线 */
|
|
900
|
+
content: '';
|
|
901
|
+
height: ${height};
|
|
902
|
+
position: absolute;
|
|
903
|
+
left: -22px;
|
|
904
|
+
top: -16px;
|
|
905
|
+
width: 1px;
|
|
906
|
+
background: #d9d9d9;
|
|
907
|
+
display: block;
|
|
908
|
+
}
|
|
909
|
+
|
|
910
|
+
&::after {
|
|
911
|
+
/* 横线 */
|
|
912
|
+
content: '';
|
|
913
|
+
position: absolute;
|
|
914
|
+
left: -22px; // 横线起点和竖线对齐
|
|
915
|
+
top: 8px; // 跟随你的行高调整
|
|
916
|
+
width: 18px; // 横线长度
|
|
917
|
+
height: 1px;
|
|
918
|
+
background: #d9d9d9;
|
|
919
|
+
display: block;
|
|
920
|
+
}
|
|
921
|
+
`;
|
|
922
|
+
}}
|
|
923
|
+
`;
|
|
924
|
+
var UIPropertyRight = import_styled_components2.default.div`
|
|
925
|
+
grid-column: 2;
|
|
926
|
+
margin-bottom: 10px;
|
|
927
|
+
|
|
928
|
+
&:last-child {
|
|
929
|
+
margin-bottom: 0px;
|
|
930
|
+
}
|
|
931
|
+
`;
|
|
932
|
+
var UIPropertyMain = import_styled_components2.default.div`
|
|
933
|
+
display: flex;
|
|
934
|
+
flex-direction: column;
|
|
935
|
+
gap: 10px;
|
|
936
|
+
position: relative;
|
|
937
|
+
|
|
938
|
+
${({ $expand, type, $collapse, $showCollapse }) => {
|
|
939
|
+
const beforeElement = `
|
|
940
|
+
&::before {
|
|
941
|
+
/* \u7AD6\u7EBF */
|
|
942
|
+
content: '';
|
|
943
|
+
height: 100%;
|
|
944
|
+
position: absolute;
|
|
945
|
+
left: -12px;
|
|
946
|
+
top: 18px;
|
|
947
|
+
width: 1px;
|
|
948
|
+
background: #d9d9d9;
|
|
949
|
+
display: block;
|
|
950
|
+
}`;
|
|
951
|
+
return $expand && import_styled_components2.css`
|
|
952
|
+
background-color: #f5f5f5;
|
|
953
|
+
padding: 10px;
|
|
954
|
+
border-radius: 4px;
|
|
955
|
+
|
|
956
|
+
${$showCollapse && $collapse && (type === "array" || type === "object") && import_styled_components2.css`
|
|
957
|
+
${beforeElement}
|
|
958
|
+
`}
|
|
959
|
+
`;
|
|
960
|
+
}}
|
|
961
|
+
`;
|
|
962
|
+
var UICollapsible = import_styled_components2.default.div`
|
|
963
|
+
display: none;
|
|
964
|
+
|
|
965
|
+
${({ $collapse }) => $collapse && import_styled_components2.css`
|
|
966
|
+
display: block;
|
|
967
|
+
`}
|
|
968
|
+
`;
|
|
969
|
+
var UIName = import_styled_components2.default.div`
|
|
970
|
+
flex-grow: 1;
|
|
971
|
+
`;
|
|
972
|
+
var UIType = import_styled_components2.default.div``;
|
|
973
|
+
var UIRequired = import_styled_components2.default.div``;
|
|
974
|
+
var UIActions = import_styled_components2.default.div`
|
|
975
|
+
white-space: nowrap;
|
|
976
|
+
`;
|
|
977
|
+
var iconAddChildrenSvg = /* @__PURE__ */ import_react5.default.createElement(
|
|
978
|
+
"svg",
|
|
979
|
+
{
|
|
980
|
+
className: "icon-icon icon-icon-coz_add_node ",
|
|
981
|
+
width: "1em",
|
|
982
|
+
height: "1em",
|
|
983
|
+
viewBox: "0 0 24 24",
|
|
984
|
+
fill: "currentColor",
|
|
985
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
986
|
+
},
|
|
987
|
+
/* @__PURE__ */ import_react5.default.createElement(
|
|
988
|
+
"path",
|
|
989
|
+
{
|
|
990
|
+
fillRule: "evenodd",
|
|
991
|
+
clipRule: "evenodd",
|
|
992
|
+
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"
|
|
993
|
+
}
|
|
994
|
+
),
|
|
995
|
+
/* @__PURE__ */ import_react5.default.createElement("path", { d: "M17.5 12.4999C18.0523 12.4999 18.5 12.9476 18.5 13.4999V16.4999H21.5C22.0523 16.4999 22.5 16.9476 22.5 17.4999C22.5 18.0522 22.0523 18.4999 21.5 18.4999H18.5V21.4999C18.5 22.0522 18.0523 22.4999 17.5 22.4999C16.9477 22.4999 16.5 22.0522 16.5 21.4999V18.4999H13.5C12.9477 18.4999 12.5 18.0522 12.5 17.4999C12.5 16.9476 12.9477 16.4999 13.5 16.4999H16.5V13.4999C16.5 12.9476 16.9477 12.4999 17.5 12.4999Z" })
|
|
996
|
+
);
|
|
997
|
+
var IconAddChildren = () => /* @__PURE__ */ import_react5.default.createElement(import_semi_icons3.default, { size: "small", svg: iconAddChildrenSvg });
|
|
998
|
+
var DefaultValueWrapper = import_styled_components2.default.div`
|
|
999
|
+
margin: 0;
|
|
1000
|
+
`;
|
|
1001
|
+
var JSONViewerWrapper = import_styled_components2.default.div`
|
|
1002
|
+
padding: 0 0 24px;
|
|
1003
|
+
&:first-child {
|
|
1004
|
+
margin-top: 0px;
|
|
1005
|
+
}
|
|
1006
|
+
`;
|
|
1007
|
+
var JSONHeader = import_styled_components2.default.div`
|
|
1008
|
+
display: flex;
|
|
1009
|
+
justify-content: space-between;
|
|
1010
|
+
align-items: center;
|
|
1011
|
+
background-color: var(--semi-color-fill-0);
|
|
1012
|
+
border-radius: 6px 6px 0 0;
|
|
1013
|
+
height: 36px;
|
|
1014
|
+
padding: 0 8px 0 12px;
|
|
1015
|
+
`;
|
|
1016
|
+
var JSONHeaderLeft = import_styled_components2.default.div`
|
|
1017
|
+
display: flex;
|
|
1018
|
+
align-items: center;
|
|
1019
|
+
gap: 10px;
|
|
1020
|
+
`;
|
|
1021
|
+
var JSONHeaderRight = import_styled_components2.default.div`
|
|
1022
|
+
display: flex;
|
|
1023
|
+
align-items: center;
|
|
1024
|
+
gap: 10px;
|
|
1025
|
+
`;
|
|
1026
|
+
var ConstantInputWrapper = import_styled_components2.default.div`
|
|
1027
|
+
flex-grow: 1;
|
|
1028
|
+
|
|
1029
|
+
& .semi-tree-select,
|
|
1030
|
+
& .semi-input-number,
|
|
1031
|
+
& .semi-select {
|
|
1032
|
+
width: 100%;
|
|
1033
|
+
}
|
|
1034
|
+
`;
|
|
1035
|
+
|
|
1036
|
+
// src/components/json-schema-editor/hooks.tsx
|
|
1037
|
+
var import_react6 = require("react");
|
|
1038
|
+
var import_lodash2 = require("lodash");
|
|
1039
|
+
var _id = 0;
|
|
1040
|
+
function genId() {
|
|
1041
|
+
return _id++;
|
|
1042
|
+
}
|
|
1043
|
+
function getDrilldownSchema(value, path) {
|
|
1044
|
+
if (!value) {
|
|
1045
|
+
return {};
|
|
1046
|
+
}
|
|
1047
|
+
if (value.type === "array" && value.items) {
|
|
1048
|
+
return getDrilldownSchema(value.items, [...path || [], "items"]);
|
|
1049
|
+
}
|
|
1050
|
+
return { schema: value, path };
|
|
1051
|
+
}
|
|
1052
|
+
function usePropertiesEdit(value, onChange) {
|
|
1053
|
+
const drilldown = (0, import_react6.useMemo)(() => getDrilldownSchema(value), [value, value?.type, value?.items]);
|
|
1054
|
+
const isDrilldownObject = drilldown.schema?.type === "object";
|
|
1055
|
+
const initPropertyList = (0, import_react6.useMemo)(
|
|
1056
|
+
() => isDrilldownObject ? Object.entries(drilldown.schema?.properties || {}).sort(([, a], [, b]) => (a.extra?.index ?? 0) - (b.extra?.index ?? 0)).map(
|
|
1057
|
+
([name, _value], index) => ({
|
|
1058
|
+
key: genId(),
|
|
1059
|
+
name,
|
|
1060
|
+
isPropertyRequired: drilldown.schema?.required?.includes(name) || false,
|
|
1061
|
+
..._value,
|
|
1062
|
+
extra: {
|
|
1063
|
+
..._value.extra || {},
|
|
1064
|
+
index
|
|
1065
|
+
}
|
|
1066
|
+
})
|
|
1067
|
+
) : [],
|
|
1068
|
+
[isDrilldownObject]
|
|
1069
|
+
);
|
|
1070
|
+
const [propertyList, setPropertyList] = (0, import_react6.useState)(initPropertyList);
|
|
1071
|
+
const mountRef = (0, import_react6.useRef)(false);
|
|
1072
|
+
(0, import_react6.useEffect)(() => {
|
|
1073
|
+
if (mountRef.current) {
|
|
1074
|
+
setPropertyList((_list) => {
|
|
1075
|
+
const nameMap = /* @__PURE__ */ new Map();
|
|
1076
|
+
for (const _property of _list) {
|
|
1077
|
+
if (_property.name) {
|
|
1078
|
+
nameMap.set(_property.name, _property);
|
|
1079
|
+
}
|
|
1080
|
+
}
|
|
1081
|
+
return Object.entries(drilldown.schema?.properties || {}).sort(([, a], [, b]) => (a.extra?.index ?? 0) - (b.extra?.index ?? 0)).map(([name, _value]) => {
|
|
1082
|
+
const _property = nameMap.get(name);
|
|
1083
|
+
if (_property) {
|
|
1084
|
+
return {
|
|
1085
|
+
key: _property.key,
|
|
1086
|
+
name,
|
|
1087
|
+
isPropertyRequired: drilldown.schema?.required?.includes(name) || false,
|
|
1088
|
+
..._value
|
|
1089
|
+
};
|
|
1090
|
+
}
|
|
1091
|
+
return {
|
|
1092
|
+
key: genId(),
|
|
1093
|
+
name,
|
|
1094
|
+
isPropertyRequired: drilldown.schema?.required?.includes(name) || false,
|
|
1095
|
+
..._value
|
|
1096
|
+
};
|
|
1097
|
+
});
|
|
1098
|
+
});
|
|
1099
|
+
}
|
|
1100
|
+
mountRef.current = true;
|
|
1101
|
+
}, [drilldown.schema]);
|
|
1102
|
+
const updatePropertyList = (updater) => {
|
|
1103
|
+
setPropertyList((_list) => {
|
|
1104
|
+
const next = updater(_list);
|
|
1105
|
+
const nextProperties = {};
|
|
1106
|
+
const nextRequired = [];
|
|
1107
|
+
for (const _property of next) {
|
|
1108
|
+
if (!_property.name) {
|
|
1109
|
+
continue;
|
|
1110
|
+
}
|
|
1111
|
+
nextProperties[_property.name] = (0, import_lodash2.omit)(_property, ["key", "name", "isPropertyRequired"]);
|
|
1112
|
+
if (_property.isPropertyRequired) {
|
|
1113
|
+
nextRequired.push(_property.name);
|
|
1114
|
+
}
|
|
1115
|
+
}
|
|
1116
|
+
let drilldownSchema = value || {};
|
|
1117
|
+
if (drilldown.path) {
|
|
1118
|
+
drilldownSchema = drilldown.path.reduce((acc, key) => acc[key], value || {});
|
|
1119
|
+
}
|
|
1120
|
+
drilldownSchema.properties = nextProperties;
|
|
1121
|
+
drilldownSchema.required = nextRequired;
|
|
1122
|
+
onChange?.(value || {});
|
|
1123
|
+
return next;
|
|
1124
|
+
});
|
|
1125
|
+
};
|
|
1126
|
+
const onAddProperty = () => {
|
|
1127
|
+
updatePropertyList((_list) => [
|
|
1128
|
+
..._list,
|
|
1129
|
+
{ key: genId(), name: "", type: "string", extra: { index: _list.length + 1 } }
|
|
1130
|
+
]);
|
|
1131
|
+
};
|
|
1132
|
+
const onRemoveProperty = (key) => {
|
|
1133
|
+
updatePropertyList((_list) => _list.filter((_property) => _property.key !== key));
|
|
1134
|
+
};
|
|
1135
|
+
const onEditProperty = (key, nextValue) => {
|
|
1136
|
+
updatePropertyList(
|
|
1137
|
+
(_list) => _list.map((_property) => _property.key === key ? nextValue : _property)
|
|
1138
|
+
);
|
|
1139
|
+
};
|
|
1140
|
+
(0, import_react6.useEffect)(() => {
|
|
1141
|
+
if (!isDrilldownObject) {
|
|
1142
|
+
setPropertyList([]);
|
|
1143
|
+
}
|
|
1144
|
+
}, [isDrilldownObject]);
|
|
1145
|
+
return {
|
|
1146
|
+
propertyList,
|
|
1147
|
+
isDrilldownObject,
|
|
1148
|
+
onAddProperty,
|
|
1149
|
+
onRemoveProperty,
|
|
1150
|
+
onEditProperty
|
|
1151
|
+
};
|
|
1152
|
+
}
|
|
1153
|
+
|
|
1154
|
+
// src/components/json-schema-editor/default-value.tsx
|
|
1155
|
+
var import_react8 = __toESM(require("react"));
|
|
1156
|
+
var import_semi_ui6 = require("@douyinfe/semi-ui");
|
|
1157
|
+
var import_semi_icons4 = require("@douyinfe/semi-icons");
|
|
1158
|
+
|
|
1159
|
+
// src/components/json-schema-editor/utils.ts
|
|
1160
|
+
function getValueType(value) {
|
|
1161
|
+
const type = typeof value;
|
|
1162
|
+
if (type === "string") {
|
|
1163
|
+
return "string";
|
|
1164
|
+
} else if (type === "number") {
|
|
1165
|
+
return Number.isInteger(value) ? "integer" : "number";
|
|
1166
|
+
} else if (type === "boolean") {
|
|
1167
|
+
return "boolean";
|
|
1168
|
+
} else if (type === "object") {
|
|
1169
|
+
if (value === null) {
|
|
1170
|
+
return "other";
|
|
1171
|
+
}
|
|
1172
|
+
return Array.isArray(value) ? "array" : "object";
|
|
1173
|
+
} else {
|
|
1174
|
+
return "other";
|
|
1175
|
+
}
|
|
1176
|
+
}
|
|
1177
|
+
|
|
1178
|
+
// src/components/constant-input/index.tsx
|
|
1179
|
+
var import_react7 = __toESM(require("react"));
|
|
1180
|
+
var import_semi_ui5 = require("@douyinfe/semi-ui");
|
|
1181
|
+
var defaultStrategies = [
|
|
1182
|
+
{
|
|
1183
|
+
hit: (schema) => schema?.type === "string",
|
|
1184
|
+
Renderer: (props) => /* @__PURE__ */ import_react7.default.createElement(import_semi_ui5.Input, { placeholder: "Please Input String", size: "small", disabled: props.readonly, ...props })
|
|
1185
|
+
},
|
|
1186
|
+
{
|
|
1187
|
+
hit: (schema) => schema?.type === "number",
|
|
1188
|
+
Renderer: (props) => /* @__PURE__ */ import_react7.default.createElement(
|
|
1189
|
+
import_semi_ui5.InputNumber,
|
|
1190
|
+
{
|
|
1191
|
+
placeholder: "Please Input Number",
|
|
1192
|
+
size: "small",
|
|
1193
|
+
disabled: props.readonly,
|
|
1194
|
+
hideButtons: true,
|
|
1195
|
+
...props
|
|
1196
|
+
}
|
|
1197
|
+
)
|
|
1198
|
+
},
|
|
1199
|
+
{
|
|
1200
|
+
hit: (schema) => schema?.type === "integer",
|
|
1201
|
+
Renderer: (props) => /* @__PURE__ */ import_react7.default.createElement(
|
|
1202
|
+
import_semi_ui5.InputNumber,
|
|
1203
|
+
{
|
|
1204
|
+
placeholder: "Please Input Integer",
|
|
1205
|
+
size: "small",
|
|
1206
|
+
disabled: props.readonly,
|
|
1207
|
+
hideButtons: true,
|
|
1208
|
+
precision: 0,
|
|
1209
|
+
...props
|
|
1210
|
+
}
|
|
1211
|
+
)
|
|
1212
|
+
},
|
|
1213
|
+
{
|
|
1214
|
+
hit: (schema) => schema?.type === "boolean",
|
|
1215
|
+
Renderer: (props) => {
|
|
1216
|
+
const { value, onChange, ...rest } = props;
|
|
1217
|
+
return /* @__PURE__ */ import_react7.default.createElement(
|
|
1218
|
+
import_semi_ui5.Select,
|
|
1219
|
+
{
|
|
1220
|
+
placeholder: "Please Select Boolean",
|
|
1221
|
+
size: "small",
|
|
1222
|
+
disabled: props.readonly,
|
|
1223
|
+
optionList: [
|
|
1224
|
+
{ label: "True", value: 1 },
|
|
1225
|
+
{ label: "False", value: 0 }
|
|
1226
|
+
],
|
|
1227
|
+
value: value ? 1 : 0,
|
|
1228
|
+
onChange: (value2) => onChange?.(!!value2),
|
|
1229
|
+
...rest
|
|
1230
|
+
}
|
|
1231
|
+
);
|
|
1232
|
+
}
|
|
1233
|
+
}
|
|
1234
|
+
];
|
|
1235
|
+
function ConstantInput(props) {
|
|
1236
|
+
const {
|
|
1237
|
+
value,
|
|
1238
|
+
onChange,
|
|
1239
|
+
schema,
|
|
1240
|
+
strategies: extraStrategies,
|
|
1241
|
+
fallbackRenderer,
|
|
1242
|
+
readonly,
|
|
1243
|
+
...rest
|
|
1244
|
+
} = props;
|
|
1245
|
+
const strategies = (0, import_react7.useMemo)(
|
|
1246
|
+
// user's extraStrategies first
|
|
1247
|
+
() => [...extraStrategies || [], ...defaultStrategies],
|
|
1248
|
+
[extraStrategies]
|
|
1249
|
+
);
|
|
1250
|
+
const Renderer2 = (0, import_react7.useMemo)(() => {
|
|
1251
|
+
const strategy = strategies.find((_strategy) => _strategy.hit(schema));
|
|
1252
|
+
return strategy?.Renderer;
|
|
1253
|
+
}, [strategies, schema]);
|
|
1254
|
+
if (!Renderer2) {
|
|
1255
|
+
if (fallbackRenderer) {
|
|
1256
|
+
return import_react7.default.createElement(fallbackRenderer, {
|
|
1257
|
+
value,
|
|
1258
|
+
onChange,
|
|
1259
|
+
readonly,
|
|
1260
|
+
...rest
|
|
1261
|
+
});
|
|
1262
|
+
}
|
|
1263
|
+
return /* @__PURE__ */ import_react7.default.createElement(import_semi_ui5.Input, { size: "small", disabled: true, placeholder: "Unsupported type" });
|
|
1264
|
+
}
|
|
1265
|
+
return /* @__PURE__ */ import_react7.default.createElement(Renderer2, { value, onChange, readonly, ...rest });
|
|
1266
|
+
}
|
|
1267
|
+
|
|
1268
|
+
// src/components/json-schema-editor/default-value.tsx
|
|
1269
|
+
function DefaultValue(props) {
|
|
1270
|
+
const { value, schema, type, onChange, placeholder, jsonFormatText } = props;
|
|
1271
|
+
const wrapperRef = (0, import_react8.useRef)(null);
|
|
1272
|
+
const JsonViewerRef = (0, import_react8.useRef)(null);
|
|
1273
|
+
const [internalJsonValue, setInternalJsonValue] = (0, import_react8.useState)(
|
|
1274
|
+
getValueType(value) === "string" ? value : ""
|
|
1275
|
+
);
|
|
1276
|
+
const handleJsonChange = (0, import_react8.useCallback)((val) => {
|
|
1277
|
+
if (val !== internalJsonValue) {
|
|
1278
|
+
setInternalJsonValue(val);
|
|
1279
|
+
}
|
|
1280
|
+
}, []);
|
|
1281
|
+
const handleEditComplete = (0, import_react8.useCallback)(() => {
|
|
1282
|
+
onChange(internalJsonValue);
|
|
1283
|
+
requestAnimationFrame(() => {
|
|
1284
|
+
wrapperRef.current?.blur();
|
|
1285
|
+
});
|
|
1286
|
+
setJsonReadOnly(true);
|
|
1287
|
+
}, [internalJsonValue, onChange]);
|
|
1288
|
+
const [jsonReadOnly, setJsonReadOnly] = (0, import_react8.useState)(true);
|
|
1289
|
+
const handleFormatJson = (0, import_react8.useCallback)(() => {
|
|
1290
|
+
try {
|
|
1291
|
+
const parsed = JSON.parse(internalJsonValue);
|
|
1292
|
+
const formatted = JSON.stringify(parsed, null, 4);
|
|
1293
|
+
setInternalJsonValue(formatted);
|
|
1294
|
+
onChange(formatted);
|
|
1295
|
+
} catch (error) {
|
|
1296
|
+
console.error("Invalid JSON:", error);
|
|
1297
|
+
}
|
|
1298
|
+
}, [internalJsonValue, onChange]);
|
|
1299
|
+
return type === "object" ? /* @__PURE__ */ import_react8.default.createElement(import_react8.default.Fragment, null, /* @__PURE__ */ import_react8.default.createElement(JSONHeader, null, /* @__PURE__ */ import_react8.default.createElement(JSONHeaderLeft, null, "json"), /* @__PURE__ */ import_react8.default.createElement(JSONHeaderRight, null, /* @__PURE__ */ import_react8.default.createElement(import_semi_ui6.Tooltip, { content: jsonFormatText ?? "Format" }, /* @__PURE__ */ import_react8.default.createElement(
|
|
1300
|
+
import_semi_ui6.IconButton,
|
|
1301
|
+
{
|
|
1302
|
+
icon: /* @__PURE__ */ import_react8.default.createElement(import_semi_icons4.IconBrackets, { style: { color: "var(--semi-color-primary)" } }),
|
|
1303
|
+
size: "small",
|
|
1304
|
+
type: "tertiary",
|
|
1305
|
+
theme: "borderless",
|
|
1306
|
+
onClick: handleFormatJson
|
|
1307
|
+
}
|
|
1308
|
+
)))), /* @__PURE__ */ import_react8.default.createElement(
|
|
1309
|
+
JSONViewerWrapper,
|
|
1310
|
+
{
|
|
1311
|
+
ref: wrapperRef,
|
|
1312
|
+
tabIndex: -1,
|
|
1313
|
+
onBlur: (e) => {
|
|
1314
|
+
if (wrapperRef.current && !wrapperRef.current?.contains(e.relatedTarget)) {
|
|
1315
|
+
handleEditComplete();
|
|
1316
|
+
}
|
|
1317
|
+
},
|
|
1318
|
+
onClick: (e) => {
|
|
1319
|
+
setJsonReadOnly(false);
|
|
1320
|
+
}
|
|
1321
|
+
},
|
|
1322
|
+
/* @__PURE__ */ import_react8.default.createElement(
|
|
1323
|
+
import_semi_ui6.JsonViewer,
|
|
1324
|
+
{
|
|
1325
|
+
ref: JsonViewerRef,
|
|
1326
|
+
value: getValueType(value) === "string" ? value : "",
|
|
1327
|
+
height: 120,
|
|
1328
|
+
width: "100%",
|
|
1329
|
+
showSearch: false,
|
|
1330
|
+
options: {
|
|
1331
|
+
readOnly: jsonReadOnly,
|
|
1332
|
+
formatOptions: { tabSize: 4, insertSpaces: true, eol: "\n" }
|
|
1333
|
+
},
|
|
1334
|
+
style: {
|
|
1335
|
+
padding: 0
|
|
1336
|
+
},
|
|
1337
|
+
onChange: handleJsonChange
|
|
1338
|
+
}
|
|
1339
|
+
)
|
|
1340
|
+
)) : /* @__PURE__ */ import_react8.default.createElement(ConstantInputWrapper, null, /* @__PURE__ */ import_react8.default.createElement(
|
|
1341
|
+
ConstantInput,
|
|
1342
|
+
{
|
|
1343
|
+
value,
|
|
1344
|
+
onChange: (_v) => onChange(_v),
|
|
1345
|
+
schema: schema || { type: "string" },
|
|
1346
|
+
placeholder: placeholder ?? "Default value if parameter is not provided"
|
|
1347
|
+
}
|
|
1348
|
+
));
|
|
1349
|
+
}
|
|
1350
|
+
|
|
1351
|
+
// src/components/json-schema-editor/components/blur-input.tsx
|
|
1352
|
+
var import_react9 = __toESM(require("react"));
|
|
1353
|
+
var import_input = __toESM(require("@douyinfe/semi-ui/lib/es/input"));
|
|
1354
|
+
function BlurInput(props) {
|
|
1355
|
+
const [value, setValue] = (0, import_react9.useState)("");
|
|
1356
|
+
(0, import_react9.useEffect)(() => {
|
|
1357
|
+
setValue(props.value);
|
|
1358
|
+
}, [props.value]);
|
|
1359
|
+
return /* @__PURE__ */ import_react9.default.createElement(
|
|
1360
|
+
import_input.default,
|
|
1361
|
+
{
|
|
1362
|
+
...props,
|
|
1363
|
+
value,
|
|
1364
|
+
onChange: (value2) => {
|
|
1365
|
+
setValue(value2);
|
|
1366
|
+
},
|
|
1367
|
+
onBlur: (e) => props.onChange?.(value, e)
|
|
1368
|
+
}
|
|
1369
|
+
);
|
|
1370
|
+
}
|
|
1371
|
+
|
|
1372
|
+
// src/components/json-schema-editor/index.tsx
|
|
1373
|
+
function JsonSchemaEditor(props) {
|
|
1374
|
+
const { value = { type: "object" }, config = {}, onChange: onChangeProps, readonly } = props;
|
|
1375
|
+
const { propertyList, onAddProperty, onRemoveProperty, onEditProperty } = usePropertiesEdit(
|
|
1376
|
+
value,
|
|
1377
|
+
onChangeProps
|
|
1378
|
+
);
|
|
1379
|
+
return /* @__PURE__ */ import_react10.default.createElement(UIContainer, { className: props.className }, /* @__PURE__ */ import_react10.default.createElement(UIProperties, null, propertyList.map((_property, index) => /* @__PURE__ */ import_react10.default.createElement(
|
|
1380
|
+
PropertyEdit,
|
|
1381
|
+
{
|
|
1382
|
+
readonly,
|
|
1383
|
+
key: _property.key,
|
|
1384
|
+
value: _property,
|
|
1385
|
+
config,
|
|
1386
|
+
$index: index,
|
|
1387
|
+
onChange: (_v) => {
|
|
1388
|
+
onEditProperty(_property.key, _v);
|
|
1389
|
+
},
|
|
1390
|
+
onRemove: () => {
|
|
1391
|
+
onRemoveProperty(_property.key);
|
|
1392
|
+
}
|
|
1393
|
+
}
|
|
1394
|
+
))), /* @__PURE__ */ import_react10.default.createElement(
|
|
1395
|
+
import_semi_ui7.Button,
|
|
1396
|
+
{
|
|
1397
|
+
disabled: readonly,
|
|
1398
|
+
size: "small",
|
|
1399
|
+
style: { marginTop: 10, marginLeft: 16 },
|
|
1400
|
+
icon: /* @__PURE__ */ import_react10.default.createElement(import_semi_icons5.IconPlus, null),
|
|
1401
|
+
onClick: onAddProperty
|
|
1402
|
+
},
|
|
1403
|
+
config?.addButtonText ?? "Add"
|
|
1404
|
+
));
|
|
1405
|
+
}
|
|
1406
|
+
function PropertyEdit(props) {
|
|
1407
|
+
const {
|
|
1408
|
+
value,
|
|
1409
|
+
config,
|
|
1410
|
+
readonly,
|
|
1411
|
+
$level = 0,
|
|
1412
|
+
onChange: onChangeProps,
|
|
1413
|
+
onRemove,
|
|
1414
|
+
$index,
|
|
1415
|
+
$isFirst,
|
|
1416
|
+
$isLast,
|
|
1417
|
+
$parentExpand = false,
|
|
1418
|
+
$parentType = "",
|
|
1419
|
+
$showLine
|
|
1420
|
+
} = props;
|
|
1421
|
+
const [expand, setExpand] = (0, import_react10.useState)(false);
|
|
1422
|
+
const [collapse, setCollapse] = (0, import_react10.useState)(false);
|
|
1423
|
+
const { name, type, items, default: defaultValue, description, isPropertyRequired } = value || {};
|
|
1424
|
+
const typeSelectorValue = (0, import_react10.useMemo)(() => ({ type, items }), [type, items]);
|
|
1425
|
+
const { propertyList, isDrilldownObject, onAddProperty, onRemoveProperty, onEditProperty } = usePropertiesEdit(value, onChangeProps);
|
|
1426
|
+
const onChange = (key, _value) => {
|
|
1427
|
+
onChangeProps?.({
|
|
1428
|
+
...value || {},
|
|
1429
|
+
[key]: _value
|
|
1430
|
+
});
|
|
1431
|
+
};
|
|
1432
|
+
const showCollapse = isDrilldownObject && propertyList.length > 0;
|
|
1433
|
+
return /* @__PURE__ */ import_react10.default.createElement(import_react10.default.Fragment, null, /* @__PURE__ */ import_react10.default.createElement(
|
|
1434
|
+
UIPropertyLeft,
|
|
1435
|
+
{
|
|
1436
|
+
type,
|
|
1437
|
+
$index,
|
|
1438
|
+
$isFirst,
|
|
1439
|
+
$isLast,
|
|
1440
|
+
$showLine,
|
|
1441
|
+
$isExpand: expand,
|
|
1442
|
+
$parentExpand,
|
|
1443
|
+
$parentType
|
|
1444
|
+
},
|
|
1445
|
+
showCollapse && /* @__PURE__ */ import_react10.default.createElement(UICollapseTrigger, { onClick: () => setCollapse((_collapse) => !_collapse) }, collapse ? /* @__PURE__ */ import_react10.default.createElement(import_semi_icons5.IconChevronDown, { size: "small" }) : /* @__PURE__ */ import_react10.default.createElement(import_semi_icons5.IconChevronRight, { size: "small" }))
|
|
1446
|
+
), /* @__PURE__ */ import_react10.default.createElement(UIPropertyRight, null, /* @__PURE__ */ import_react10.default.createElement(
|
|
1447
|
+
UIPropertyMain,
|
|
1448
|
+
{
|
|
1449
|
+
$showCollapse: showCollapse,
|
|
1450
|
+
$collapse: collapse,
|
|
1451
|
+
$expand: expand,
|
|
1452
|
+
type
|
|
1453
|
+
},
|
|
1454
|
+
/* @__PURE__ */ import_react10.default.createElement(UIRow, null, /* @__PURE__ */ import_react10.default.createElement(UIName, null, /* @__PURE__ */ import_react10.default.createElement(
|
|
1455
|
+
BlurInput,
|
|
1456
|
+
{
|
|
1457
|
+
disabled: readonly,
|
|
1458
|
+
placeholder: config?.placeholder ?? "Input Variable Name",
|
|
1459
|
+
size: "small",
|
|
1460
|
+
value: name,
|
|
1461
|
+
onChange: (value2) => onChange("name", value2)
|
|
1462
|
+
}
|
|
1463
|
+
)), /* @__PURE__ */ import_react10.default.createElement(UIType, null, /* @__PURE__ */ import_react10.default.createElement(
|
|
1464
|
+
TypeSelector,
|
|
1465
|
+
{
|
|
1466
|
+
value: typeSelectorValue,
|
|
1467
|
+
readonly,
|
|
1468
|
+
onChange: (_value) => {
|
|
1469
|
+
onChangeProps?.({
|
|
1470
|
+
...value || {},
|
|
1471
|
+
..._value
|
|
1472
|
+
});
|
|
1473
|
+
}
|
|
1474
|
+
}
|
|
1475
|
+
)), /* @__PURE__ */ import_react10.default.createElement(UIRequired, null, /* @__PURE__ */ import_react10.default.createElement(
|
|
1476
|
+
import_semi_ui7.Checkbox,
|
|
1477
|
+
{
|
|
1478
|
+
disabled: readonly,
|
|
1479
|
+
checked: isPropertyRequired,
|
|
1480
|
+
onChange: (e) => onChange("isPropertyRequired", e.target.checked)
|
|
1481
|
+
}
|
|
1482
|
+
)), /* @__PURE__ */ import_react10.default.createElement(UIActions, null, /* @__PURE__ */ import_react10.default.createElement(
|
|
1483
|
+
import_semi_ui7.IconButton,
|
|
1484
|
+
{
|
|
1485
|
+
disabled: readonly,
|
|
1486
|
+
size: "small",
|
|
1487
|
+
theme: "borderless",
|
|
1488
|
+
icon: expand ? /* @__PURE__ */ import_react10.default.createElement(import_semi_icons5.IconShrink, { size: "small" }) : /* @__PURE__ */ import_react10.default.createElement(import_semi_icons5.IconExpand, { size: "small" }),
|
|
1489
|
+
onClick: () => {
|
|
1490
|
+
setExpand((_expand) => !_expand);
|
|
1491
|
+
}
|
|
1492
|
+
}
|
|
1493
|
+
), isDrilldownObject && /* @__PURE__ */ import_react10.default.createElement(
|
|
1494
|
+
import_semi_ui7.IconButton,
|
|
1495
|
+
{
|
|
1496
|
+
disabled: readonly,
|
|
1497
|
+
size: "small",
|
|
1498
|
+
theme: "borderless",
|
|
1499
|
+
icon: /* @__PURE__ */ import_react10.default.createElement(IconAddChildren, null),
|
|
1500
|
+
onClick: () => {
|
|
1501
|
+
onAddProperty();
|
|
1502
|
+
setCollapse(true);
|
|
1503
|
+
}
|
|
1504
|
+
}
|
|
1505
|
+
), /* @__PURE__ */ import_react10.default.createElement(
|
|
1506
|
+
import_semi_ui7.IconButton,
|
|
1507
|
+
{
|
|
1508
|
+
disabled: readonly,
|
|
1509
|
+
size: "small",
|
|
1510
|
+
theme: "borderless",
|
|
1511
|
+
icon: /* @__PURE__ */ import_react10.default.createElement(import_semi_icons5.IconMinus, { size: "small" }),
|
|
1512
|
+
onClick: onRemove
|
|
1513
|
+
}
|
|
1514
|
+
))),
|
|
1515
|
+
expand && /* @__PURE__ */ import_react10.default.createElement(UIExpandDetail, null, /* @__PURE__ */ import_react10.default.createElement(UILabel, null, config?.descTitle ?? "Description"), /* @__PURE__ */ import_react10.default.createElement(
|
|
1516
|
+
BlurInput,
|
|
1517
|
+
{
|
|
1518
|
+
disabled: readonly,
|
|
1519
|
+
size: "small",
|
|
1520
|
+
value: description,
|
|
1521
|
+
onChange: (value2) => onChange("description", value2),
|
|
1522
|
+
placeholder: config?.descPlaceholder ?? "Help LLM to understand the property"
|
|
1523
|
+
}
|
|
1524
|
+
), $level === 0 && type && type !== "array" && /* @__PURE__ */ import_react10.default.createElement(import_react10.default.Fragment, null, /* @__PURE__ */ import_react10.default.createElement(UILabel, { style: { marginTop: 10 } }, config?.defaultValueTitle ?? "Default Value"), /* @__PURE__ */ import_react10.default.createElement(DefaultValueWrapper, null, /* @__PURE__ */ import_react10.default.createElement(
|
|
1525
|
+
DefaultValue,
|
|
1526
|
+
{
|
|
1527
|
+
value: defaultValue,
|
|
1528
|
+
schema: value,
|
|
1529
|
+
type,
|
|
1530
|
+
placeholder: config?.defaultValuePlaceholder,
|
|
1531
|
+
jsonFormatText: config?.jsonFormatText,
|
|
1532
|
+
onChange: (value2) => onChange("default", value2)
|
|
1533
|
+
}
|
|
1534
|
+
))))
|
|
1535
|
+
), showCollapse && /* @__PURE__ */ import_react10.default.createElement(UICollapsible, { $collapse: collapse }, /* @__PURE__ */ import_react10.default.createElement(UIProperties, { $shrink: true }, propertyList.map((_property, index) => /* @__PURE__ */ import_react10.default.createElement(
|
|
1536
|
+
PropertyEdit,
|
|
1537
|
+
{
|
|
1538
|
+
readonly,
|
|
1539
|
+
key: _property.key,
|
|
1540
|
+
value: _property,
|
|
1541
|
+
config,
|
|
1542
|
+
$level: $level + 1,
|
|
1543
|
+
$parentExpand: expand,
|
|
1544
|
+
$parentType: type,
|
|
1545
|
+
onChange: (_v) => {
|
|
1546
|
+
onEditProperty(_property.key, _v);
|
|
1547
|
+
},
|
|
1548
|
+
onRemove: () => {
|
|
1549
|
+
onRemoveProperty(_property.key);
|
|
1550
|
+
},
|
|
1551
|
+
$isLast: index === propertyList.length - 1,
|
|
1552
|
+
$isFirst: index === 0,
|
|
1553
|
+
$index: index,
|
|
1554
|
+
$showLine: true
|
|
1555
|
+
}
|
|
1556
|
+
))))));
|
|
1557
|
+
}
|
|
1558
|
+
|
|
1559
|
+
// src/components/batch-variable-selector/index.tsx
|
|
1560
|
+
var import_react11 = __toESM(require("react"));
|
|
1561
|
+
var import_editor3 = require("@flowgram.ai/editor");
|
|
1562
|
+
var batchVariableSchema = {
|
|
1563
|
+
type: "array",
|
|
1564
|
+
extra: { weak: true }
|
|
1565
|
+
};
|
|
1566
|
+
function BatchVariableSelector(props) {
|
|
1567
|
+
return /* @__PURE__ */ import_react11.default.createElement(import_editor3.PrivateScopeProvider, null, /* @__PURE__ */ import_react11.default.createElement(VariableSelector, { ...props, includeSchema: batchVariableSchema }));
|
|
1568
|
+
}
|
|
1569
|
+
|
|
1570
|
+
// src/components/dynamic-value-input/index.tsx
|
|
1571
|
+
var import_react12 = __toESM(require("react"));
|
|
1572
|
+
var import_editor4 = require("@flowgram.ai/editor");
|
|
1573
|
+
var import_semi_ui8 = require("@douyinfe/semi-ui");
|
|
1574
|
+
var import_semi_icons6 = require("@douyinfe/semi-icons");
|
|
1575
|
+
|
|
1576
|
+
// src/utils/format-legacy-refs/index.ts
|
|
1577
|
+
var import_lodash3 = require("lodash");
|
|
1578
|
+
function formatLegacyRefOnSubmit(value) {
|
|
1579
|
+
if ((0, import_lodash3.isObject)(value)) {
|
|
1580
|
+
if (isLegacyFlowRefValueSchema(value)) {
|
|
1581
|
+
return formatLegacyRefToNewRef(value);
|
|
1582
|
+
}
|
|
1583
|
+
return Object.fromEntries(
|
|
1584
|
+
Object.entries(value).map(([key, value2]) => [
|
|
1585
|
+
key,
|
|
1586
|
+
formatLegacyRefOnSubmit(value2)
|
|
1587
|
+
])
|
|
1588
|
+
);
|
|
1589
|
+
}
|
|
1590
|
+
if (Array.isArray(value)) {
|
|
1591
|
+
return value.map(formatLegacyRefOnSubmit);
|
|
1592
|
+
}
|
|
1593
|
+
return value;
|
|
1594
|
+
}
|
|
1595
|
+
function formatLegacyRefOnInit(value) {
|
|
1596
|
+
if ((0, import_lodash3.isObject)(value)) {
|
|
1597
|
+
if (isNewFlowRefValueSchema(value)) {
|
|
1598
|
+
return formatNewRefToLegacyRef(value);
|
|
1599
|
+
}
|
|
1600
|
+
return Object.fromEntries(
|
|
1601
|
+
Object.entries(value).map(([key, value2]) => [
|
|
1602
|
+
key,
|
|
1603
|
+
formatLegacyRefOnInit(value2)
|
|
1604
|
+
])
|
|
1605
|
+
);
|
|
1606
|
+
}
|
|
1607
|
+
if (Array.isArray(value)) {
|
|
1608
|
+
return value.map(formatLegacyRefOnInit);
|
|
1609
|
+
}
|
|
1610
|
+
return value;
|
|
1611
|
+
}
|
|
1612
|
+
function isLegacyFlowRefValueSchema(value) {
|
|
1613
|
+
return (0, import_lodash3.isObject)(value) && Object.keys(value).length === 2 && value.type === "ref" && typeof value.content === "string";
|
|
1614
|
+
}
|
|
1615
|
+
function isNewFlowRefValueSchema(value) {
|
|
1616
|
+
return (0, import_lodash3.isObject)(value) && Object.keys(value).length === 2 && value.type === "ref" && Array.isArray(value.content);
|
|
1617
|
+
}
|
|
1618
|
+
function formatLegacyRefToNewRef(value) {
|
|
1619
|
+
const keyPath = value.content.split(".");
|
|
1620
|
+
if (keyPath[1] === "outputs") {
|
|
1621
|
+
return {
|
|
1622
|
+
type: "ref",
|
|
1623
|
+
content: [`${keyPath[0]}.${keyPath[1]}`, ...keyPath.length > 2 ? keyPath.slice(2) : []]
|
|
1624
|
+
};
|
|
1625
|
+
}
|
|
1626
|
+
return {
|
|
1627
|
+
type: "ref",
|
|
1628
|
+
content: keyPath
|
|
1629
|
+
};
|
|
1630
|
+
}
|
|
1631
|
+
function formatNewRefToLegacyRef(value) {
|
|
1632
|
+
return {
|
|
1633
|
+
type: "ref",
|
|
1634
|
+
content: value.content.join(".")
|
|
1635
|
+
};
|
|
1636
|
+
}
|
|
1637
|
+
|
|
1638
|
+
// src/components/dynamic-value-input/styles.tsx
|
|
1639
|
+
var import_styled_components3 = __toESM(require("styled-components"));
|
|
1640
|
+
var UIContainer2 = import_styled_components3.default.div`
|
|
1641
|
+
display: flex;
|
|
1642
|
+
align-items: center;
|
|
1643
|
+
border-radius: 4px;
|
|
1644
|
+
border: 1px solid var(--semi-color-border);
|
|
1645
|
+
|
|
1646
|
+
overflow: hidden;
|
|
1647
|
+
|
|
1648
|
+
background-color: var(--semi-color-fill-0);
|
|
1649
|
+
`;
|
|
1650
|
+
var UIMain = import_styled_components3.default.div`
|
|
1651
|
+
flex-grow: 1;
|
|
1652
|
+
overflow: hidden;
|
|
1653
|
+
min-width: 0;
|
|
1654
|
+
|
|
1655
|
+
& .semi-tree-select,
|
|
1656
|
+
& .semi-input-number,
|
|
1657
|
+
& .semi-select {
|
|
1658
|
+
width: 100%;
|
|
1659
|
+
border: none;
|
|
1660
|
+
border-radius: 0;
|
|
1661
|
+
}
|
|
1662
|
+
|
|
1663
|
+
& .semi-input-wrapper {
|
|
1664
|
+
border: none;
|
|
1665
|
+
border-radius: 0;
|
|
1666
|
+
}
|
|
1667
|
+
`;
|
|
1668
|
+
var UIType2 = import_styled_components3.default.div`
|
|
1669
|
+
border-right: 1px solid #e5e5e5;
|
|
1670
|
+
|
|
1671
|
+
& .semi-button {
|
|
1672
|
+
border-radius: 0;
|
|
1673
|
+
}
|
|
1674
|
+
`;
|
|
1675
|
+
var UITrigger = import_styled_components3.default.div`
|
|
1676
|
+
border-left: 1px solid #e5e5e5;
|
|
1677
|
+
|
|
1678
|
+
& .semi-button {
|
|
1679
|
+
border-radius: 0;
|
|
1680
|
+
}
|
|
1681
|
+
`;
|
|
1682
|
+
|
|
1683
|
+
// src/components/dynamic-value-input/index.tsx
|
|
1684
|
+
function DynamicValueInput({
|
|
1685
|
+
value,
|
|
1686
|
+
onChange,
|
|
1687
|
+
readonly,
|
|
1688
|
+
style,
|
|
1689
|
+
schema: schemaFromProps,
|
|
1690
|
+
constantProps
|
|
1691
|
+
}) {
|
|
1692
|
+
const available = (0, import_editor4.useScopeAvailable)();
|
|
1693
|
+
const refVariable = (0, import_react12.useMemo)(() => {
|
|
1694
|
+
if (value?.type === "ref") {
|
|
1695
|
+
return available.getByKeyPath(value.content);
|
|
1696
|
+
}
|
|
1697
|
+
}, [value, available]);
|
|
1698
|
+
const [selectSchema, setSelectSchema] = (0, import_react12.useState)(
|
|
1699
|
+
schemaFromProps || constantProps?.schema || { type: "string" }
|
|
1700
|
+
);
|
|
1701
|
+
const renderTypeSelector = () => {
|
|
1702
|
+
if (schemaFromProps) {
|
|
1703
|
+
return /* @__PURE__ */ import_react12.default.createElement(TypeSelector, { value: schemaFromProps, readonly: true });
|
|
1704
|
+
}
|
|
1705
|
+
if (value?.type === "ref") {
|
|
1706
|
+
const schema = refVariable?.type ? JsonSchemaUtils.astToSchema(refVariable?.type) : void 0;
|
|
1707
|
+
return /* @__PURE__ */ import_react12.default.createElement(TypeSelector, { value: schema, readonly: true });
|
|
1708
|
+
}
|
|
1709
|
+
return /* @__PURE__ */ import_react12.default.createElement(
|
|
1710
|
+
TypeSelector,
|
|
1711
|
+
{
|
|
1712
|
+
value: selectSchema,
|
|
1713
|
+
onChange: (_v) => setSelectSchema(_v || { type: "string" }),
|
|
1714
|
+
readonly
|
|
1715
|
+
}
|
|
1716
|
+
);
|
|
1717
|
+
};
|
|
1718
|
+
const includeSchema = (0, import_react12.useMemo)(() => {
|
|
1719
|
+
if (!schemaFromProps) {
|
|
1720
|
+
return;
|
|
1721
|
+
}
|
|
1722
|
+
if (schemaFromProps?.type === "number") {
|
|
1723
|
+
return [schemaFromProps, { type: "integer" }];
|
|
1724
|
+
}
|
|
1725
|
+
return { ...schemaFromProps, extra: { ...schemaFromProps?.extra, weak: true } };
|
|
1726
|
+
}, [schemaFromProps]);
|
|
1727
|
+
const renderMain = () => {
|
|
1728
|
+
if (value?.type === "ref") {
|
|
1729
|
+
return /* @__PURE__ */ import_react12.default.createElement(
|
|
1730
|
+
VariableSelector,
|
|
1731
|
+
{
|
|
1732
|
+
style: { width: "100%" },
|
|
1733
|
+
value: value?.content,
|
|
1734
|
+
onChange: (_v) => onChange(_v ? { type: "ref", content: _v } : void 0),
|
|
1735
|
+
includeSchema,
|
|
1736
|
+
readonly
|
|
1737
|
+
}
|
|
1738
|
+
);
|
|
1739
|
+
}
|
|
1740
|
+
const constantSchema = schemaFromProps || selectSchema || { type: "string" };
|
|
1741
|
+
return /* @__PURE__ */ import_react12.default.createElement(
|
|
1742
|
+
ConstantInput,
|
|
1743
|
+
{
|
|
1744
|
+
value: value?.content,
|
|
1745
|
+
onChange: (_v) => onChange({ type: "constant", content: _v, schema: constantSchema }),
|
|
1746
|
+
schema: constantSchema || { type: "string" },
|
|
1747
|
+
readonly,
|
|
1748
|
+
strategies: [...constantProps?.strategies || []],
|
|
1749
|
+
fallbackRenderer: () => /* @__PURE__ */ import_react12.default.createElement(
|
|
1750
|
+
VariableSelector,
|
|
1751
|
+
{
|
|
1752
|
+
style: { width: "100%" },
|
|
1753
|
+
onChange: (_v) => onChange(_v ? { type: "ref", content: _v } : void 0),
|
|
1754
|
+
includeSchema,
|
|
1755
|
+
readonly
|
|
1756
|
+
}
|
|
1757
|
+
),
|
|
1758
|
+
...constantProps
|
|
1759
|
+
}
|
|
1760
|
+
);
|
|
1761
|
+
};
|
|
1762
|
+
const renderTrigger = () => /* @__PURE__ */ import_react12.default.createElement(
|
|
1763
|
+
VariableSelector,
|
|
1764
|
+
{
|
|
1765
|
+
style: { width: "100%" },
|
|
1766
|
+
value: value?.type === "ref" ? value?.content : void 0,
|
|
1767
|
+
onChange: (_v) => onChange({ type: "ref", content: _v }),
|
|
1768
|
+
includeSchema,
|
|
1769
|
+
readonly,
|
|
1770
|
+
triggerRender: () => /* @__PURE__ */ import_react12.default.createElement(import_semi_ui8.IconButton, { disabled: readonly, size: "small", icon: /* @__PURE__ */ import_react12.default.createElement(import_semi_icons6.IconSetting, { size: "small" }) })
|
|
1771
|
+
}
|
|
1772
|
+
);
|
|
1773
|
+
return /* @__PURE__ */ import_react12.default.createElement(UIContainer2, { style }, /* @__PURE__ */ import_react12.default.createElement(UIType2, null, renderTypeSelector()), /* @__PURE__ */ import_react12.default.createElement(UIMain, null, renderMain()), /* @__PURE__ */ import_react12.default.createElement(UITrigger, null, renderTrigger()));
|
|
1774
|
+
}
|
|
1775
|
+
|
|
1776
|
+
// src/components/condition-row/index.tsx
|
|
1777
|
+
var import_react15 = __toESM(require("react"));
|
|
1778
|
+
var import_semi_ui10 = require("@douyinfe/semi-ui");
|
|
1779
|
+
|
|
1780
|
+
// src/components/condition-row/styles.tsx
|
|
1781
|
+
var import_styled_components4 = __toESM(require("styled-components"));
|
|
1782
|
+
var UIContainer3 = import_styled_components4.default.div`
|
|
1783
|
+
display: flex;
|
|
1784
|
+
align-items: center;
|
|
1785
|
+
gap: 4px;
|
|
1786
|
+
`;
|
|
1787
|
+
var UIOperator = import_styled_components4.default.div``;
|
|
1788
|
+
var UILeft = import_styled_components4.default.div`
|
|
1789
|
+
width: 100%;
|
|
1790
|
+
`;
|
|
1791
|
+
var UIRight = import_styled_components4.default.div`
|
|
1792
|
+
width: 100%;
|
|
1793
|
+
`;
|
|
1794
|
+
var UIValues = import_styled_components4.default.div`
|
|
1795
|
+
flex-grow: 1;
|
|
1796
|
+
display: flex;
|
|
1797
|
+
flex-direction: column;
|
|
1798
|
+
align-items: center;
|
|
1799
|
+
gap: 4px;
|
|
1800
|
+
`;
|
|
1801
|
+
|
|
1802
|
+
// src/components/condition-row/hooks/useRule.ts
|
|
1803
|
+
var import_react13 = require("react");
|
|
1804
|
+
var import_editor5 = require("@flowgram.ai/editor");
|
|
1805
|
+
|
|
1806
|
+
// src/components/condition-row/constants.ts
|
|
1807
|
+
var rules = {
|
|
1808
|
+
string: {
|
|
1809
|
+
["eq" /* EQ */]: "string",
|
|
1810
|
+
["neq" /* NEQ */]: "string",
|
|
1811
|
+
["contains" /* CONTAINS */]: "string",
|
|
1812
|
+
["not_contains" /* NOT_CONTAINS */]: "string",
|
|
1813
|
+
["in" /* IN */]: "array",
|
|
1814
|
+
["nin" /* NIN */]: "array",
|
|
1815
|
+
["is_empty" /* IS_EMPTY */]: null,
|
|
1816
|
+
["is_not_empty" /* IS_NOT_EMPTY */]: null
|
|
1817
|
+
},
|
|
1818
|
+
number: {
|
|
1819
|
+
["eq" /* EQ */]: "number",
|
|
1820
|
+
["neq" /* NEQ */]: "number",
|
|
1821
|
+
["gt" /* GT */]: "number",
|
|
1822
|
+
["gte" /* GTE */]: "number",
|
|
1823
|
+
["lt" /* LT */]: "number",
|
|
1824
|
+
["lte" /* LTE */]: "number",
|
|
1825
|
+
["in" /* IN */]: "array",
|
|
1826
|
+
["nin" /* NIN */]: "array"
|
|
1827
|
+
},
|
|
1828
|
+
integer: {
|
|
1829
|
+
["eq" /* EQ */]: "number",
|
|
1830
|
+
["neq" /* NEQ */]: "number",
|
|
1831
|
+
["gt" /* GT */]: "number",
|
|
1832
|
+
["gte" /* GTE */]: "number",
|
|
1833
|
+
["lt" /* LT */]: "number",
|
|
1834
|
+
["lte" /* LTE */]: "number",
|
|
1835
|
+
["in" /* IN */]: "array",
|
|
1836
|
+
["nin" /* NIN */]: "array"
|
|
1837
|
+
},
|
|
1838
|
+
boolean: {
|
|
1839
|
+
["eq" /* EQ */]: "boolean",
|
|
1840
|
+
["neq" /* NEQ */]: "boolean",
|
|
1841
|
+
["is_true" /* IS_TRUE */]: null,
|
|
1842
|
+
["is_false" /* IS_FALSE */]: null,
|
|
1843
|
+
["in" /* IN */]: "array",
|
|
1844
|
+
["nin" /* NIN */]: "array"
|
|
1845
|
+
},
|
|
1846
|
+
object: {
|
|
1847
|
+
["is_empty" /* IS_EMPTY */]: null,
|
|
1848
|
+
["is_not_empty" /* IS_NOT_EMPTY */]: null
|
|
1849
|
+
},
|
|
1850
|
+
array: {
|
|
1851
|
+
["is_empty" /* IS_EMPTY */]: null,
|
|
1852
|
+
["is_not_empty" /* IS_NOT_EMPTY */]: null
|
|
1853
|
+
},
|
|
1854
|
+
map: {
|
|
1855
|
+
["is_empty" /* IS_EMPTY */]: null,
|
|
1856
|
+
["is_not_empty" /* IS_NOT_EMPTY */]: null
|
|
1857
|
+
}
|
|
1858
|
+
};
|
|
1859
|
+
var opConfigs = {
|
|
1860
|
+
["eq" /* EQ */]: {
|
|
1861
|
+
label: "Equal",
|
|
1862
|
+
abbreviation: "="
|
|
1863
|
+
},
|
|
1864
|
+
["neq" /* NEQ */]: {
|
|
1865
|
+
label: "Not Equal",
|
|
1866
|
+
abbreviation: "\u2260"
|
|
1867
|
+
},
|
|
1868
|
+
["gt" /* GT */]: {
|
|
1869
|
+
label: "Greater Than",
|
|
1870
|
+
abbreviation: ">"
|
|
1871
|
+
},
|
|
1872
|
+
["gte" /* GTE */]: {
|
|
1873
|
+
label: "Greater Than or Equal",
|
|
1874
|
+
abbreviation: ">="
|
|
1875
|
+
},
|
|
1876
|
+
["lt" /* LT */]: {
|
|
1877
|
+
label: "Less Than",
|
|
1878
|
+
abbreviation: "<"
|
|
1879
|
+
},
|
|
1880
|
+
["lte" /* LTE */]: {
|
|
1881
|
+
label: "Less Than or Equal",
|
|
1882
|
+
abbreviation: "<="
|
|
1883
|
+
},
|
|
1884
|
+
["in" /* IN */]: {
|
|
1885
|
+
label: "In",
|
|
1886
|
+
abbreviation: "\u2208"
|
|
1887
|
+
},
|
|
1888
|
+
["nin" /* NIN */]: {
|
|
1889
|
+
label: "Not In",
|
|
1890
|
+
abbreviation: "\u2209"
|
|
1891
|
+
},
|
|
1892
|
+
["contains" /* CONTAINS */]: {
|
|
1893
|
+
label: "Contains",
|
|
1894
|
+
abbreviation: "\u2287"
|
|
1895
|
+
},
|
|
1896
|
+
["not_contains" /* NOT_CONTAINS */]: {
|
|
1897
|
+
label: "Not Contains",
|
|
1898
|
+
abbreviation: "\u2289"
|
|
1899
|
+
},
|
|
1900
|
+
["is_empty" /* IS_EMPTY */]: {
|
|
1901
|
+
label: "Is Empty",
|
|
1902
|
+
abbreviation: "=",
|
|
1903
|
+
rightDisplay: "Empty"
|
|
1904
|
+
},
|
|
1905
|
+
["is_not_empty" /* IS_NOT_EMPTY */]: {
|
|
1906
|
+
label: "Is Not Empty",
|
|
1907
|
+
abbreviation: "\u2260",
|
|
1908
|
+
rightDisplay: "Empty"
|
|
1909
|
+
},
|
|
1910
|
+
["is_true" /* IS_TRUE */]: {
|
|
1911
|
+
label: "Is True",
|
|
1912
|
+
abbreviation: "=",
|
|
1913
|
+
rightDisplay: "True"
|
|
1914
|
+
},
|
|
1915
|
+
["is_false" /* IS_FALSE */]: {
|
|
1916
|
+
label: "Is False",
|
|
1917
|
+
abbreviation: "=",
|
|
1918
|
+
rightDisplay: "False"
|
|
1919
|
+
}
|
|
1920
|
+
};
|
|
1921
|
+
|
|
1922
|
+
// src/components/condition-row/hooks/useRule.ts
|
|
1923
|
+
function useRule(left) {
|
|
1924
|
+
const available = (0, import_editor5.useScopeAvailable)();
|
|
1925
|
+
const variable = (0, import_react13.useMemo)(() => {
|
|
1926
|
+
if (!left) return void 0;
|
|
1927
|
+
return available.getByKeyPath(left.content);
|
|
1928
|
+
}, [available, left]);
|
|
1929
|
+
const rule = (0, import_react13.useMemo)(() => {
|
|
1930
|
+
if (!variable) return void 0;
|
|
1931
|
+
const schema = JsonSchemaUtils.astToSchema(variable.type, { drilldown: false });
|
|
1932
|
+
return rules[schema?.type];
|
|
1933
|
+
}, [variable?.type]);
|
|
1934
|
+
return { rule };
|
|
1935
|
+
}
|
|
1936
|
+
|
|
1937
|
+
// src/components/condition-row/hooks/useOp.tsx
|
|
1938
|
+
var import_react14 = __toESM(require("react"));
|
|
1939
|
+
var import_semi_ui9 = require("@douyinfe/semi-ui");
|
|
1940
|
+
var import_semi_icons7 = require("@douyinfe/semi-icons");
|
|
1941
|
+
function useOp({ rule, op, onChange, readonly }) {
|
|
1942
|
+
const options2 = (0, import_react14.useMemo)(
|
|
1943
|
+
() => Object.keys(rule || {}).map((_op) => ({
|
|
1944
|
+
...opConfigs[_op] || {},
|
|
1945
|
+
value: _op
|
|
1946
|
+
})),
|
|
1947
|
+
[rule]
|
|
1948
|
+
);
|
|
1949
|
+
const opConfig = (0, import_react14.useMemo)(() => opConfigs[op], [op]);
|
|
1950
|
+
const renderOpSelect = () => /* @__PURE__ */ import_react14.default.createElement(
|
|
1951
|
+
import_semi_ui9.Select,
|
|
1952
|
+
{
|
|
1953
|
+
style: { height: 22 },
|
|
1954
|
+
disabled: readonly,
|
|
1955
|
+
size: "small",
|
|
1956
|
+
value: op,
|
|
1957
|
+
optionList: options2,
|
|
1958
|
+
onChange: (v) => {
|
|
1959
|
+
onChange(v);
|
|
1960
|
+
},
|
|
1961
|
+
triggerRender: ({ value }) => /* @__PURE__ */ import_react14.default.createElement(import_semi_ui9.Button, { size: "small", disabled: !rule }, opConfig?.abbreviation || /* @__PURE__ */ import_react14.default.createElement(import_semi_icons7.IconChevronDownStroked, { size: "small" }))
|
|
1962
|
+
}
|
|
1963
|
+
);
|
|
1964
|
+
return { renderOpSelect, opConfig };
|
|
1965
|
+
}
|
|
1966
|
+
|
|
1967
|
+
// src/components/condition-row/index.tsx
|
|
1968
|
+
function ConditionRow({ style, value, onChange, readonly }) {
|
|
1969
|
+
const { left, operator, right } = value || {};
|
|
1970
|
+
const { rule } = useRule(left);
|
|
1971
|
+
const { renderOpSelect, opConfig } = useOp({
|
|
1972
|
+
rule,
|
|
1973
|
+
op: operator,
|
|
1974
|
+
onChange: (v) => onChange({ ...value, operator: v }),
|
|
1975
|
+
readonly
|
|
1976
|
+
});
|
|
1977
|
+
const targetSchema = (0, import_react15.useMemo)(() => {
|
|
1978
|
+
const targetType = rule?.[operator] || null;
|
|
1979
|
+
return targetType ? { type: targetType, extra: { weak: true } } : null;
|
|
1980
|
+
}, [rule, opConfig]);
|
|
1981
|
+
return /* @__PURE__ */ import_react15.default.createElement(UIContainer3, { style }, /* @__PURE__ */ import_react15.default.createElement(UIOperator, null, renderOpSelect()), /* @__PURE__ */ import_react15.default.createElement(UIValues, null, /* @__PURE__ */ import_react15.default.createElement(UILeft, null, /* @__PURE__ */ import_react15.default.createElement(
|
|
1982
|
+
VariableSelector,
|
|
1983
|
+
{
|
|
1984
|
+
readonly,
|
|
1985
|
+
style: { width: "100%" },
|
|
1986
|
+
value: left?.content,
|
|
1987
|
+
onChange: (v) => onChange({
|
|
1988
|
+
...value,
|
|
1989
|
+
left: {
|
|
1990
|
+
type: "ref",
|
|
1991
|
+
content: v
|
|
1992
|
+
}
|
|
1993
|
+
})
|
|
1994
|
+
}
|
|
1995
|
+
)), /* @__PURE__ */ import_react15.default.createElement(UIRight, null, targetSchema ? /* @__PURE__ */ import_react15.default.createElement(
|
|
1996
|
+
DynamicValueInput,
|
|
1997
|
+
{
|
|
1998
|
+
readonly: readonly || !rule,
|
|
1999
|
+
value: right,
|
|
2000
|
+
schema: targetSchema,
|
|
2001
|
+
onChange: (v) => onChange({ ...value, right: v })
|
|
2002
|
+
}
|
|
2003
|
+
) : /* @__PURE__ */ import_react15.default.createElement(
|
|
2004
|
+
import_semi_ui10.Input,
|
|
2005
|
+
{
|
|
2006
|
+
size: "small",
|
|
2007
|
+
disabled: true,
|
|
2008
|
+
style: { pointerEvents: "none" },
|
|
2009
|
+
value: opConfig?.rightDisplay || "Empty"
|
|
2010
|
+
}
|
|
2011
|
+
))));
|
|
2012
|
+
}
|
|
2013
|
+
|
|
2014
|
+
// src/components/batch-outputs/index.tsx
|
|
2015
|
+
var import_react17 = __toESM(require("react"));
|
|
2016
|
+
var import_semi_ui11 = require("@douyinfe/semi-ui");
|
|
2017
|
+
var import_semi_icons8 = require("@douyinfe/semi-icons");
|
|
2018
|
+
|
|
2019
|
+
// src/hooks/use-object-list/index.tsx
|
|
2020
|
+
var import_react16 = require("react");
|
|
2021
|
+
var import_nanoid = require("nanoid");
|
|
2022
|
+
var import_lodash4 = require("lodash");
|
|
2023
|
+
function genId2() {
|
|
2024
|
+
return (0, import_nanoid.nanoid)();
|
|
2025
|
+
}
|
|
2026
|
+
function useObjectList({
|
|
2027
|
+
value,
|
|
2028
|
+
onChange,
|
|
2029
|
+
sortIndexKey
|
|
2030
|
+
}) {
|
|
2031
|
+
const [list, setList] = (0, import_react16.useState)([]);
|
|
2032
|
+
(0, import_react16.useEffect)(() => {
|
|
2033
|
+
setList((_prevList) => {
|
|
2034
|
+
const newKeys = Object.entries(value || {}).sort((a, b) => (0, import_lodash4.get)(a[1], sortIndexKey || 0) - (0, import_lodash4.get)(b[1], sortIndexKey || 0)).map(([key]) => key);
|
|
2035
|
+
const oldKeys = _prevList.map((item) => item.key).filter(Boolean);
|
|
2036
|
+
const addKeys = (0, import_lodash4.difference)(newKeys, oldKeys);
|
|
2037
|
+
return _prevList.filter((item) => !item.key || newKeys.includes(item.key)).map((item) => ({
|
|
2038
|
+
id: item.id,
|
|
2039
|
+
key: item.key,
|
|
2040
|
+
value: item.key ? value?.[item.key] : item.value
|
|
2041
|
+
})).concat(
|
|
2042
|
+
addKeys.map((_key) => ({
|
|
2043
|
+
id: genId2(),
|
|
2044
|
+
key: _key,
|
|
2045
|
+
value: value?.[_key]
|
|
2046
|
+
}))
|
|
2047
|
+
);
|
|
2048
|
+
});
|
|
2049
|
+
}, [value]);
|
|
2050
|
+
const add = () => {
|
|
2051
|
+
setList((prevList) => [
|
|
2052
|
+
...prevList,
|
|
2053
|
+
{
|
|
2054
|
+
id: genId2()
|
|
2055
|
+
}
|
|
2056
|
+
]);
|
|
2057
|
+
};
|
|
2058
|
+
const updateValue = (itemId, value2) => {
|
|
2059
|
+
setList((prevList) => {
|
|
2060
|
+
const nextList = prevList.map((_item) => {
|
|
2061
|
+
if (_item.id === itemId) {
|
|
2062
|
+
return {
|
|
2063
|
+
..._item,
|
|
2064
|
+
value: value2
|
|
2065
|
+
};
|
|
2066
|
+
}
|
|
2067
|
+
return _item;
|
|
2068
|
+
});
|
|
2069
|
+
onChange(
|
|
2070
|
+
Object.fromEntries(
|
|
2071
|
+
nextList.filter((item) => item.key).map((item) => [item.key, item.value]).map((_res, idx) => {
|
|
2072
|
+
if ((0, import_lodash4.isObject)(_res[1]) && sortIndexKey) {
|
|
2073
|
+
(0, import_lodash4.set)(_res[1], sortIndexKey, idx);
|
|
2074
|
+
}
|
|
2075
|
+
return _res;
|
|
2076
|
+
})
|
|
2077
|
+
)
|
|
2078
|
+
);
|
|
2079
|
+
return nextList;
|
|
2080
|
+
});
|
|
2081
|
+
};
|
|
2082
|
+
const updateKey = (itemId, key) => {
|
|
2083
|
+
setList((prevList) => {
|
|
2084
|
+
const nextList = prevList.map((_item) => {
|
|
2085
|
+
if (_item.id === itemId) {
|
|
2086
|
+
return {
|
|
2087
|
+
..._item,
|
|
2088
|
+
key
|
|
2089
|
+
};
|
|
2090
|
+
}
|
|
2091
|
+
return _item;
|
|
2092
|
+
});
|
|
2093
|
+
onChange(
|
|
2094
|
+
Object.fromEntries(
|
|
2095
|
+
nextList.filter((item) => item.key).map((item) => [item.key, item.value])
|
|
2096
|
+
)
|
|
2097
|
+
);
|
|
2098
|
+
return nextList;
|
|
2099
|
+
});
|
|
2100
|
+
};
|
|
2101
|
+
const remove = (itemId) => {
|
|
2102
|
+
setList((prevList) => {
|
|
2103
|
+
const nextList = prevList.filter((_item) => _item.id !== itemId);
|
|
2104
|
+
onChange(
|
|
2105
|
+
Object.fromEntries(
|
|
2106
|
+
nextList.filter((item) => item.key).map((item) => [item.key, item.value])
|
|
2107
|
+
)
|
|
2108
|
+
);
|
|
2109
|
+
return nextList;
|
|
2110
|
+
});
|
|
2111
|
+
};
|
|
2112
|
+
return { list, add, updateKey, updateValue, remove };
|
|
2113
|
+
}
|
|
2114
|
+
|
|
2115
|
+
// src/components/batch-outputs/styles.tsx
|
|
2116
|
+
var import_styled_components5 = __toESM(require("styled-components"));
|
|
2117
|
+
var UIRows = import_styled_components5.default.div`
|
|
2118
|
+
display: flex;
|
|
2119
|
+
flex-direction: column;
|
|
2120
|
+
gap: 10px;
|
|
2121
|
+
margin-bottom: 10px;
|
|
2122
|
+
`;
|
|
2123
|
+
var UIRow2 = import_styled_components5.default.div`
|
|
2124
|
+
display: flex;
|
|
2125
|
+
align-items: center;
|
|
2126
|
+
gap: 5px;
|
|
2127
|
+
`;
|
|
2128
|
+
|
|
2129
|
+
// src/components/batch-outputs/index.tsx
|
|
2130
|
+
function BatchOutputs(props) {
|
|
2131
|
+
const { readonly, style } = props;
|
|
2132
|
+
const { list, add, updateKey, updateValue, remove } = useObjectList(props);
|
|
2133
|
+
return /* @__PURE__ */ import_react17.default.createElement("div", null, /* @__PURE__ */ import_react17.default.createElement(UIRows, { style }, list.map((item) => /* @__PURE__ */ import_react17.default.createElement(UIRow2, { key: item.id }, /* @__PURE__ */ import_react17.default.createElement(
|
|
2134
|
+
import_semi_ui11.Input,
|
|
2135
|
+
{
|
|
2136
|
+
style: { width: 100 },
|
|
2137
|
+
disabled: readonly,
|
|
2138
|
+
size: "small",
|
|
2139
|
+
value: item.key,
|
|
2140
|
+
onChange: (v) => updateKey(item.id, v)
|
|
2141
|
+
}
|
|
2142
|
+
), /* @__PURE__ */ import_react17.default.createElement(
|
|
2143
|
+
VariableSelector,
|
|
2144
|
+
{
|
|
2145
|
+
style: { flexGrow: 1 },
|
|
2146
|
+
readonly,
|
|
2147
|
+
value: item.value?.content,
|
|
2148
|
+
onChange: (v) => updateValue(item.id, { type: "ref", content: v })
|
|
2149
|
+
}
|
|
2150
|
+
), /* @__PURE__ */ import_react17.default.createElement(
|
|
2151
|
+
import_semi_ui11.Button,
|
|
2152
|
+
{
|
|
2153
|
+
disabled: readonly,
|
|
2154
|
+
icon: /* @__PURE__ */ import_react17.default.createElement(import_semi_icons8.IconDelete, null),
|
|
2155
|
+
size: "small",
|
|
2156
|
+
onClick: () => remove(item.id)
|
|
2157
|
+
}
|
|
2158
|
+
)))), /* @__PURE__ */ import_react17.default.createElement(import_semi_ui11.Button, { disabled: readonly, icon: /* @__PURE__ */ import_react17.default.createElement(import_semi_icons8.IconPlus, null), size: "small", onClick: add }, "Add"));
|
|
2159
|
+
}
|
|
2160
|
+
|
|
2161
|
+
// src/components/prompt-editor/index.tsx
|
|
2162
|
+
var import_react24 = __toESM(require("react"));
|
|
2163
|
+
var import_react25 = require("@coze-editor/editor/react");
|
|
2164
|
+
var import_preset_prompt2 = __toESM(require("@coze-editor/editor/preset-prompt"));
|
|
2165
|
+
|
|
2166
|
+
// src/components/prompt-editor/styles.tsx
|
|
2167
|
+
var import_styled_components6 = __toESM(require("styled-components"));
|
|
2168
|
+
var UIContainer4 = import_styled_components6.default.div`
|
|
2169
|
+
background-color: var(--semi-color-fill-0);
|
|
2170
|
+
padding-left: 10px;
|
|
2171
|
+
padding-right: 6px;
|
|
2172
|
+
|
|
2173
|
+
${({ $hasError }) => $hasError && import_styled_components6.css`
|
|
2174
|
+
border: 1px solid var(--semi-color-danger-6);
|
|
2175
|
+
`}
|
|
2176
|
+
`;
|
|
2177
|
+
|
|
2178
|
+
// src/components/prompt-editor/extensions/markdown.tsx
|
|
2179
|
+
var import_react18 = require("react");
|
|
2180
|
+
var import_react19 = require("@coze-editor/editor/react");
|
|
2181
|
+
var import_editor6 = require("@coze-editor/editor");
|
|
2182
|
+
var import_view = require("@codemirror/view");
|
|
2183
|
+
function MarkdownHighlight() {
|
|
2184
|
+
const injector = (0, import_react19.useInjector)();
|
|
2185
|
+
(0, import_react18.useLayoutEffect)(
|
|
2186
|
+
() => injector.inject([
|
|
2187
|
+
import_editor6.astDecorator.whole.of((cursor) => {
|
|
2188
|
+
if (cursor.name.startsWith("ATXHeading")) {
|
|
2189
|
+
return {
|
|
2190
|
+
type: "className",
|
|
2191
|
+
className: "heading"
|
|
2192
|
+
};
|
|
2193
|
+
}
|
|
2194
|
+
if (cursor.name === "Emphasis") {
|
|
2195
|
+
return {
|
|
2196
|
+
type: "className",
|
|
2197
|
+
className: "emphasis"
|
|
2198
|
+
};
|
|
2199
|
+
}
|
|
2200
|
+
if (cursor.name === "StrongEmphasis") {
|
|
2201
|
+
return {
|
|
2202
|
+
type: "className",
|
|
2203
|
+
className: "strong-emphasis"
|
|
2204
|
+
};
|
|
2205
|
+
}
|
|
2206
|
+
if (cursor.name === "ListMark" || cursor.name === "QuoteMark") {
|
|
2207
|
+
return {
|
|
2208
|
+
type: "className",
|
|
2209
|
+
className: "mark"
|
|
2210
|
+
};
|
|
2211
|
+
}
|
|
2212
|
+
}),
|
|
2213
|
+
import_view.EditorView.theme({
|
|
2214
|
+
".heading": {
|
|
2215
|
+
color: "#00818C",
|
|
2216
|
+
fontWeight: "bold"
|
|
2217
|
+
},
|
|
2218
|
+
".emphasis": {
|
|
2219
|
+
fontStyle: "italic"
|
|
2220
|
+
},
|
|
2221
|
+
".strong-emphasis": {
|
|
2222
|
+
fontWeight: "bold"
|
|
2223
|
+
},
|
|
2224
|
+
".mark": {
|
|
2225
|
+
color: "#4E40E5"
|
|
2226
|
+
}
|
|
2227
|
+
})
|
|
2228
|
+
]),
|
|
2229
|
+
[injector]
|
|
2230
|
+
);
|
|
2231
|
+
return null;
|
|
2232
|
+
}
|
|
2233
|
+
var markdown_default = MarkdownHighlight;
|
|
2234
|
+
|
|
2235
|
+
// src/components/prompt-editor/extensions/language-support.tsx
|
|
2236
|
+
var import_react20 = require("react");
|
|
2237
|
+
var import_react21 = require("@coze-editor/editor/react");
|
|
2238
|
+
var import_preset_prompt = require("@coze-editor/editor/preset-prompt");
|
|
2239
|
+
function LanguageSupport() {
|
|
2240
|
+
const injector = (0, import_react21.useInjector)();
|
|
2241
|
+
(0, import_react20.useLayoutEffect)(() => injector.inject([import_preset_prompt.languageSupport]), [injector]);
|
|
2242
|
+
return null;
|
|
2243
|
+
}
|
|
2244
|
+
var language_support_default = LanguageSupport;
|
|
2245
|
+
|
|
2246
|
+
// src/components/prompt-editor/extensions/jinja.tsx
|
|
2247
|
+
var import_react22 = require("react");
|
|
2248
|
+
var import_react23 = require("@coze-editor/editor/react");
|
|
2249
|
+
var import_editor7 = require("@coze-editor/editor");
|
|
2250
|
+
var import_view2 = require("@codemirror/view");
|
|
2251
|
+
function JinjaHighlight() {
|
|
2252
|
+
const injector = (0, import_react23.useInjector)();
|
|
2253
|
+
(0, import_react22.useLayoutEffect)(
|
|
2254
|
+
() => injector.inject([
|
|
2255
|
+
import_editor7.astDecorator.whole.of((cursor) => {
|
|
2256
|
+
if (cursor.name === "JinjaStatementStart" || cursor.name === "JinjaStatementEnd") {
|
|
2257
|
+
return {
|
|
2258
|
+
type: "className",
|
|
2259
|
+
className: "jinja-statement-bracket"
|
|
2260
|
+
};
|
|
2261
|
+
}
|
|
2262
|
+
if (cursor.name === "JinjaComment") {
|
|
2263
|
+
return {
|
|
2264
|
+
type: "className",
|
|
2265
|
+
className: "jinja-comment"
|
|
2266
|
+
};
|
|
2267
|
+
}
|
|
2268
|
+
if (cursor.name === "JinjaExpression") {
|
|
2269
|
+
return {
|
|
2270
|
+
type: "className",
|
|
2271
|
+
className: "jinja-expression"
|
|
2272
|
+
};
|
|
2273
|
+
}
|
|
2274
|
+
}),
|
|
2275
|
+
import_view2.EditorView.theme({
|
|
2276
|
+
".jinja-statement-bracket": {
|
|
2277
|
+
color: "#D1009D"
|
|
2278
|
+
},
|
|
2279
|
+
".jinja-comment": {
|
|
2280
|
+
color: "#0607094D"
|
|
2281
|
+
},
|
|
2282
|
+
".jinja-expression": {
|
|
2283
|
+
color: "#4E40E5"
|
|
2284
|
+
}
|
|
2285
|
+
})
|
|
2286
|
+
]),
|
|
2287
|
+
[injector]
|
|
2288
|
+
);
|
|
2289
|
+
return null;
|
|
2290
|
+
}
|
|
2291
|
+
var jinja_default = JinjaHighlight;
|
|
2292
|
+
|
|
2293
|
+
// src/components/prompt-editor/index.tsx
|
|
2294
|
+
function PromptEditor(props) {
|
|
2295
|
+
const {
|
|
2296
|
+
value,
|
|
2297
|
+
onChange,
|
|
2298
|
+
readonly,
|
|
2299
|
+
placeholder,
|
|
2300
|
+
activeLinePlaceholder,
|
|
2301
|
+
style,
|
|
2302
|
+
hasError,
|
|
2303
|
+
children,
|
|
2304
|
+
disableMarkdownHighlight
|
|
2305
|
+
} = props || {};
|
|
2306
|
+
const editorRef = (0, import_react24.useRef)(null);
|
|
2307
|
+
(0, import_react24.useEffect)(() => {
|
|
2308
|
+
if (editorRef.current?.getValue() !== value?.content) {
|
|
2309
|
+
editorRef.current?.setValue(String(value?.content || ""));
|
|
2310
|
+
}
|
|
2311
|
+
}, [value]);
|
|
2312
|
+
return /* @__PURE__ */ import_react24.default.createElement(UIContainer4, { $hasError: hasError, style }, /* @__PURE__ */ import_react24.default.createElement(import_react25.EditorProvider, null, /* @__PURE__ */ import_react24.default.createElement(
|
|
2313
|
+
import_react25.Renderer,
|
|
2314
|
+
{
|
|
2315
|
+
didMount: (editor) => {
|
|
2316
|
+
editorRef.current = editor;
|
|
2317
|
+
},
|
|
2318
|
+
plugins: import_preset_prompt2.default,
|
|
2319
|
+
defaultValue: String(value?.content),
|
|
2320
|
+
options: {
|
|
2321
|
+
readOnly: readonly,
|
|
2322
|
+
editable: !readonly,
|
|
2323
|
+
placeholder
|
|
2324
|
+
},
|
|
2325
|
+
onChange: (e) => {
|
|
2326
|
+
onChange({ type: "template", content: e.value });
|
|
2327
|
+
}
|
|
2328
|
+
}
|
|
2329
|
+
), activeLinePlaceholder && /* @__PURE__ */ import_react24.default.createElement(import_react25.ActiveLinePlaceholder, null, activeLinePlaceholder), !disableMarkdownHighlight && /* @__PURE__ */ import_react24.default.createElement(markdown_default, null), /* @__PURE__ */ import_react24.default.createElement(language_support_default, null), /* @__PURE__ */ import_react24.default.createElement(jinja_default, null), children));
|
|
2330
|
+
}
|
|
2331
|
+
|
|
2332
|
+
// src/components/prompt-editor-with-variables/index.tsx
|
|
2333
|
+
var import_react30 = __toESM(require("react"));
|
|
2334
|
+
|
|
2335
|
+
// src/components/prompt-editor-with-variables/extensions/variable-tree.tsx
|
|
2336
|
+
var import_react26 = __toESM(require("react"));
|
|
2337
|
+
var import_semi_ui12 = require("@douyinfe/semi-ui");
|
|
2338
|
+
var import_react27 = require("@coze-editor/editor/react");
|
|
2339
|
+
function VariableTree() {
|
|
2340
|
+
const [posKey, setPosKey] = (0, import_react26.useState)("");
|
|
2341
|
+
const [visible, setVisible] = (0, import_react26.useState)(false);
|
|
2342
|
+
const [position, setPosition] = (0, import_react26.useState)(-1);
|
|
2343
|
+
const editor = (0, import_react27.useEditor)();
|
|
2344
|
+
function insert(variablePath) {
|
|
2345
|
+
const range = (0, import_react27.getCurrentMentionReplaceRange)(editor.$view.state);
|
|
2346
|
+
if (!range) {
|
|
2347
|
+
return;
|
|
2348
|
+
}
|
|
2349
|
+
editor.replaceText({
|
|
2350
|
+
...range,
|
|
2351
|
+
text: "{{" + variablePath + "}}"
|
|
2352
|
+
});
|
|
2353
|
+
setVisible(false);
|
|
2354
|
+
}
|
|
2355
|
+
function handleOpenChange(e) {
|
|
2356
|
+
setPosition(e.state.selection.main.head);
|
|
2357
|
+
setVisible(e.value);
|
|
2358
|
+
}
|
|
2359
|
+
(0, import_react26.useEffect)(() => {
|
|
2360
|
+
if (!editor) {
|
|
2361
|
+
return;
|
|
2362
|
+
}
|
|
2363
|
+
}, [editor, visible]);
|
|
2364
|
+
const treeData = useVariableTree({});
|
|
2365
|
+
return /* @__PURE__ */ import_react26.default.createElement(import_react26.default.Fragment, null, /* @__PURE__ */ import_react26.default.createElement(import_react27.Mention, { triggerCharacters: ["{", "{}", "@"], onOpenChange: handleOpenChange }), /* @__PURE__ */ import_react26.default.createElement(
|
|
2366
|
+
import_semi_ui12.Popover,
|
|
2367
|
+
{
|
|
2368
|
+
visible,
|
|
2369
|
+
trigger: "custom",
|
|
2370
|
+
position: "topLeft",
|
|
2371
|
+
rePosKey: posKey,
|
|
2372
|
+
content: /* @__PURE__ */ import_react26.default.createElement("div", { style: { width: 300 } }, /* @__PURE__ */ import_react26.default.createElement(
|
|
2373
|
+
import_semi_ui12.Tree,
|
|
2374
|
+
{
|
|
2375
|
+
treeData,
|
|
2376
|
+
onSelect: (v) => {
|
|
2377
|
+
insert(v);
|
|
2378
|
+
}
|
|
2379
|
+
}
|
|
2380
|
+
))
|
|
2381
|
+
},
|
|
2382
|
+
/* @__PURE__ */ import_react26.default.createElement(
|
|
2383
|
+
import_react27.PositionMirror,
|
|
2384
|
+
{
|
|
2385
|
+
position,
|
|
2386
|
+
onChange: () => setPosKey(String(Math.random()))
|
|
2387
|
+
}
|
|
2388
|
+
)
|
|
2389
|
+
));
|
|
2390
|
+
}
|
|
2391
|
+
|
|
2392
|
+
// src/components/prompt-editor-with-variables/extensions/variable-tag.tsx
|
|
2393
|
+
var import_react_dom = __toESM(require("react-dom"));
|
|
2394
|
+
var import_react28 = __toESM(require("react"));
|
|
2395
|
+
var import_lodash5 = require("lodash");
|
|
2396
|
+
var import_editor8 = require("@flowgram.ai/editor");
|
|
2397
|
+
var import_semi_ui14 = require("@douyinfe/semi-ui");
|
|
2398
|
+
var import_semi_icons9 = require("@douyinfe/semi-icons");
|
|
2399
|
+
var import_react29 = require("@coze-editor/editor/react");
|
|
2400
|
+
var import_view3 = require("@codemirror/view");
|
|
2401
|
+
|
|
2402
|
+
// src/components/prompt-editor-with-variables/styles.tsx
|
|
2403
|
+
var import_styled_components7 = __toESM(require("styled-components"));
|
|
2404
|
+
var import_semi_ui13 = require("@douyinfe/semi-ui");
|
|
2405
|
+
var UIRootTitle2 = import_styled_components7.default.div`
|
|
2406
|
+
margin-right: 4px;
|
|
2407
|
+
min-width: 20px;
|
|
2408
|
+
overflow: hidden;
|
|
2409
|
+
text-overflow: ellipsis;
|
|
2410
|
+
white-space: nowrap;
|
|
2411
|
+
color: var(--semi-color-text-2);
|
|
2412
|
+
`;
|
|
2413
|
+
var UIVarName2 = import_styled_components7.default.div`
|
|
2414
|
+
overflow: hidden;
|
|
2415
|
+
text-overflow: ellipsis;
|
|
2416
|
+
white-space: nowrap;
|
|
2417
|
+
`;
|
|
2418
|
+
var UITag2 = (0, import_styled_components7.default)(import_semi_ui13.Tag)`
|
|
2419
|
+
display: inline-flex;
|
|
2420
|
+
align-items: center;
|
|
2421
|
+
justify-content: flex-start;
|
|
2422
|
+
max-width: 300px;
|
|
2423
|
+
|
|
2424
|
+
& .semi-tag-content-center {
|
|
2425
|
+
justify-content: flex-start;
|
|
2426
|
+
}
|
|
2427
|
+
|
|
2428
|
+
&.semi-tag {
|
|
2429
|
+
margin: 0 5px;
|
|
2430
|
+
}
|
|
2431
|
+
`;
|
|
2432
|
+
var UIPopoverContent2 = import_styled_components7.default.div`
|
|
2433
|
+
padding: 10px;
|
|
2434
|
+
display: inline-flex;
|
|
2435
|
+
align-items: center;
|
|
2436
|
+
justify-content: flex-start;
|
|
2437
|
+
`;
|
|
2438
|
+
|
|
2439
|
+
// src/components/prompt-editor-with-variables/extensions/variable-tag.tsx
|
|
2440
|
+
var VariableTagWidget = class extends import_view3.WidgetType {
|
|
2441
|
+
constructor({ keyPath, scope }) {
|
|
2442
|
+
super();
|
|
2443
|
+
this.toDispose = new import_editor8.DisposableCollection();
|
|
2444
|
+
this.renderIcon = (icon) => {
|
|
2445
|
+
if (typeof icon === "string") {
|
|
2446
|
+
return /* @__PURE__ */ import_react28.default.createElement("img", { style: { marginRight: 8 }, width: 12, height: 12, src: icon });
|
|
2447
|
+
}
|
|
2448
|
+
return icon;
|
|
2449
|
+
};
|
|
2450
|
+
this.keyPath = keyPath;
|
|
2451
|
+
this.scope = scope;
|
|
2452
|
+
}
|
|
2453
|
+
renderReact(jsx) {
|
|
2454
|
+
import_react_dom.default.render(jsx, this.rootDOM);
|
|
2455
|
+
}
|
|
2456
|
+
renderVariable(v) {
|
|
2457
|
+
if (!v) {
|
|
2458
|
+
this.renderReact(
|
|
2459
|
+
/* @__PURE__ */ import_react28.default.createElement(UITag2, { prefixIcon: /* @__PURE__ */ import_react28.default.createElement(import_semi_icons9.IconIssueStroked, null), color: "amber" }, "Unknown")
|
|
2460
|
+
);
|
|
2461
|
+
return;
|
|
2462
|
+
}
|
|
2463
|
+
const rootField = (0, import_lodash5.last)(v.parentFields) || v;
|
|
2464
|
+
const isRoot = v.parentFields.length === 0;
|
|
2465
|
+
const rootTitle = /* @__PURE__ */ import_react28.default.createElement(UIRootTitle2, null, rootField?.meta.title ? `${rootField.meta.title} ${isRoot ? "" : "-"} ` : "");
|
|
2466
|
+
const rootIcon = this.renderIcon(rootField?.meta.icon);
|
|
2467
|
+
this.renderReact(
|
|
2468
|
+
/* @__PURE__ */ import_react28.default.createElement(
|
|
2469
|
+
import_semi_ui14.Popover,
|
|
2470
|
+
{
|
|
2471
|
+
content: /* @__PURE__ */ import_react28.default.createElement(UIPopoverContent2, null, rootIcon, rootTitle, /* @__PURE__ */ import_react28.default.createElement(UIVarName2, null, v?.keyPath.slice(1).join(".")))
|
|
2472
|
+
},
|
|
2473
|
+
/* @__PURE__ */ import_react28.default.createElement(UITag2, { prefixIcon: rootIcon }, rootTitle, !isRoot && /* @__PURE__ */ import_react28.default.createElement(UIVarName2, null, v?.key))
|
|
2474
|
+
)
|
|
2475
|
+
);
|
|
2476
|
+
}
|
|
2477
|
+
toDOM(view) {
|
|
2478
|
+
const dom = document.createElement("span");
|
|
2479
|
+
this.rootDOM = dom;
|
|
2480
|
+
this.toDispose.push(
|
|
2481
|
+
import_editor8.Disposable.create(() => {
|
|
2482
|
+
import_react_dom.default.unmountComponentAtNode(this.rootDOM);
|
|
2483
|
+
})
|
|
2484
|
+
);
|
|
2485
|
+
this.toDispose.push(
|
|
2486
|
+
this.scope.available.trackByKeyPath(
|
|
2487
|
+
this.keyPath,
|
|
2488
|
+
(v) => {
|
|
2489
|
+
this.renderVariable(v);
|
|
2490
|
+
},
|
|
2491
|
+
{ triggerOnInit: false }
|
|
2492
|
+
)
|
|
2493
|
+
);
|
|
2494
|
+
this.renderVariable(this.scope.available.getByKeyPath(this.keyPath));
|
|
2495
|
+
return dom;
|
|
2496
|
+
}
|
|
2497
|
+
eq(other) {
|
|
2498
|
+
return (0, import_lodash5.isEqual)(this.keyPath, other.keyPath);
|
|
2499
|
+
}
|
|
2500
|
+
ignoreEvent() {
|
|
2501
|
+
return false;
|
|
2502
|
+
}
|
|
2503
|
+
destroy(dom) {
|
|
2504
|
+
this.toDispose.dispose();
|
|
2505
|
+
}
|
|
2506
|
+
};
|
|
2507
|
+
function VariableTagInject() {
|
|
2508
|
+
const injector = (0, import_react29.useInjector)();
|
|
2509
|
+
const scope = (0, import_editor8.useCurrentScope)();
|
|
2510
|
+
(0, import_react28.useLayoutEffect)(() => {
|
|
2511
|
+
const atMatcher = new import_view3.MatchDecorator({
|
|
2512
|
+
regexp: /\{\{([^\}]+)\}\}/g,
|
|
2513
|
+
decoration: (match) => import_view3.Decoration.replace({
|
|
2514
|
+
widget: new VariableTagWidget({
|
|
2515
|
+
keyPath: match[1]?.split(".") ?? [],
|
|
2516
|
+
scope
|
|
2517
|
+
})
|
|
2518
|
+
})
|
|
2519
|
+
});
|
|
2520
|
+
return injector.inject([
|
|
2521
|
+
import_view3.ViewPlugin.fromClass(
|
|
2522
|
+
class {
|
|
2523
|
+
constructor(view) {
|
|
2524
|
+
this.view = view;
|
|
2525
|
+
this.decorations = atMatcher.createDeco(view);
|
|
2526
|
+
}
|
|
2527
|
+
update() {
|
|
2528
|
+
this.decorations = atMatcher.createDeco(this.view);
|
|
2529
|
+
}
|
|
2530
|
+
},
|
|
2531
|
+
{
|
|
2532
|
+
decorations: (p) => p.decorations,
|
|
2533
|
+
provide(p) {
|
|
2534
|
+
return import_view3.EditorView.atomicRanges.of(
|
|
2535
|
+
(view) => view.plugin(p)?.decorations ?? import_view3.Decoration.none
|
|
2536
|
+
);
|
|
2537
|
+
}
|
|
2538
|
+
}
|
|
2539
|
+
)
|
|
2540
|
+
]);
|
|
2541
|
+
}, [injector]);
|
|
2542
|
+
return null;
|
|
2543
|
+
}
|
|
2544
|
+
|
|
2545
|
+
// src/components/prompt-editor-with-variables/index.tsx
|
|
2546
|
+
function PromptEditorWithVariables(props) {
|
|
2547
|
+
return /* @__PURE__ */ import_react30.default.createElement(PromptEditor, { ...props }, /* @__PURE__ */ import_react30.default.createElement(VariableTree, null), /* @__PURE__ */ import_react30.default.createElement(VariableTagInject, null));
|
|
2548
|
+
}
|
|
2549
|
+
|
|
2550
|
+
// src/components/prompt-editor-with-inputs/index.tsx
|
|
2551
|
+
var import_react34 = __toESM(require("react"));
|
|
2552
|
+
|
|
2553
|
+
// src/components/prompt-editor-with-inputs/extensions/inputs-tree.tsx
|
|
2554
|
+
var import_react32 = __toESM(require("react"));
|
|
2555
|
+
var import_semi_ui16 = require("@douyinfe/semi-ui");
|
|
2556
|
+
var import_react33 = require("@coze-editor/editor/react");
|
|
2557
|
+
|
|
2558
|
+
// src/components/prompt-editor-with-inputs/inputs-picker.tsx
|
|
2559
|
+
var import_react31 = __toESM(require("react"));
|
|
2560
|
+
var import_lodash6 = require("lodash");
|
|
2561
|
+
var import_editor9 = require("@flowgram.ai/editor");
|
|
2562
|
+
var import_semi_ui15 = require("@douyinfe/semi-ui");
|
|
2563
|
+
function InputsPicker({
|
|
2564
|
+
inputsValues,
|
|
2565
|
+
onSelect
|
|
2566
|
+
}) {
|
|
2567
|
+
const available = (0, import_editor9.useScopeAvailable)();
|
|
2568
|
+
const getArrayDrilldown = (type, depth = 1) => {
|
|
2569
|
+
if (import_editor9.ASTMatch.isArray(type.items)) {
|
|
2570
|
+
return getArrayDrilldown(type.items, depth + 1);
|
|
2571
|
+
}
|
|
2572
|
+
return { type: type.items, depth };
|
|
2573
|
+
};
|
|
2574
|
+
const renderVariable = (variable, keyPath) => {
|
|
2575
|
+
let type = variable?.type;
|
|
2576
|
+
let children;
|
|
2577
|
+
if (import_editor9.ASTMatch.isObject(type)) {
|
|
2578
|
+
children = (type.properties || []).map((_property) => renderVariable(_property, [...keyPath, _property.key])).filter(Boolean);
|
|
2579
|
+
}
|
|
2580
|
+
if (import_editor9.ASTMatch.isArray(type)) {
|
|
2581
|
+
const drilldown = getArrayDrilldown(type);
|
|
2582
|
+
if (import_editor9.ASTMatch.isObject(drilldown.type)) {
|
|
2583
|
+
children = (drilldown.type.properties || []).map(
|
|
2584
|
+
(_property) => renderVariable(_property, [
|
|
2585
|
+
...keyPath,
|
|
2586
|
+
...new Array(drilldown.depth).fill("[0]"),
|
|
2587
|
+
_property.key
|
|
2588
|
+
])
|
|
2589
|
+
).filter(Boolean);
|
|
2590
|
+
}
|
|
2591
|
+
}
|
|
2592
|
+
const key = keyPath.map((_key, idx) => _key === "[0]" || idx === 0 ? _key : `.${_key}`).join("");
|
|
2593
|
+
return {
|
|
2594
|
+
key,
|
|
2595
|
+
label: (0, import_lodash6.last)(keyPath),
|
|
2596
|
+
value: key,
|
|
2597
|
+
children
|
|
2598
|
+
};
|
|
2599
|
+
};
|
|
2600
|
+
const treeData = (0, import_react31.useMemo)(
|
|
2601
|
+
() => Object.entries(inputsValues).map(([key, value]) => {
|
|
2602
|
+
if (value?.type === "ref") {
|
|
2603
|
+
const variable = available.getByKeyPath(value.content || []);
|
|
2604
|
+
if (variable) {
|
|
2605
|
+
return renderVariable(variable, [key]);
|
|
2606
|
+
}
|
|
2607
|
+
}
|
|
2608
|
+
return {
|
|
2609
|
+
key,
|
|
2610
|
+
value: key,
|
|
2611
|
+
label: key
|
|
2612
|
+
};
|
|
2613
|
+
}),
|
|
2614
|
+
[]
|
|
2615
|
+
);
|
|
2616
|
+
return /* @__PURE__ */ import_react31.default.createElement(import_semi_ui15.Tree, { treeData, onSelect: (v) => onSelect(v) });
|
|
2617
|
+
}
|
|
2618
|
+
|
|
2619
|
+
// src/components/prompt-editor-with-inputs/extensions/inputs-tree.tsx
|
|
2620
|
+
function InputsTree({ inputsValues }) {
|
|
2621
|
+
const [posKey, setPosKey] = (0, import_react32.useState)("");
|
|
2622
|
+
const [visible, setVisible] = (0, import_react32.useState)(false);
|
|
2623
|
+
const [position, setPosition] = (0, import_react32.useState)(-1);
|
|
2624
|
+
const editor = (0, import_react33.useEditor)();
|
|
2625
|
+
function insert(variablePath) {
|
|
2626
|
+
const range = (0, import_react33.getCurrentMentionReplaceRange)(editor.$view.state);
|
|
2627
|
+
if (!range) {
|
|
2628
|
+
return;
|
|
2629
|
+
}
|
|
2630
|
+
editor.replaceText({
|
|
2631
|
+
...range,
|
|
2632
|
+
text: "{{" + variablePath + "}}"
|
|
2633
|
+
});
|
|
2634
|
+
setVisible(false);
|
|
2635
|
+
}
|
|
2636
|
+
function handleOpenChange(e) {
|
|
2637
|
+
setPosition(e.state.selection.main.head);
|
|
2638
|
+
setVisible(e.value);
|
|
2639
|
+
}
|
|
2640
|
+
(0, import_react32.useEffect)(() => {
|
|
2641
|
+
if (!editor) {
|
|
2642
|
+
return;
|
|
2643
|
+
}
|
|
2644
|
+
}, [editor, visible]);
|
|
2645
|
+
return /* @__PURE__ */ import_react32.default.createElement(import_react32.default.Fragment, null, /* @__PURE__ */ import_react32.default.createElement(import_react33.Mention, { triggerCharacters: ["{", "{}", "@"], onOpenChange: handleOpenChange }), /* @__PURE__ */ import_react32.default.createElement(
|
|
2646
|
+
import_semi_ui16.Popover,
|
|
2647
|
+
{
|
|
2648
|
+
visible,
|
|
2649
|
+
trigger: "custom",
|
|
2650
|
+
position: "topLeft",
|
|
2651
|
+
rePosKey: posKey,
|
|
2652
|
+
content: /* @__PURE__ */ import_react32.default.createElement("div", { style: { width: 300 } }, /* @__PURE__ */ import_react32.default.createElement(
|
|
2653
|
+
InputsPicker,
|
|
2654
|
+
{
|
|
2655
|
+
inputsValues,
|
|
2656
|
+
onSelect: (v) => {
|
|
2657
|
+
insert(v);
|
|
2658
|
+
}
|
|
2659
|
+
}
|
|
2660
|
+
))
|
|
2661
|
+
},
|
|
2662
|
+
/* @__PURE__ */ import_react32.default.createElement(
|
|
2663
|
+
import_react33.PositionMirror,
|
|
2664
|
+
{
|
|
2665
|
+
position,
|
|
2666
|
+
onChange: () => setPosKey(String(Math.random()))
|
|
2667
|
+
}
|
|
2668
|
+
)
|
|
2669
|
+
));
|
|
2670
|
+
}
|
|
2671
|
+
|
|
2672
|
+
// src/components/prompt-editor-with-inputs/index.tsx
|
|
2673
|
+
function PromptEditorWithInputs({ inputsValues, ...restProps }) {
|
|
2674
|
+
return /* @__PURE__ */ import_react34.default.createElement(PromptEditor, { ...restProps }, /* @__PURE__ */ import_react34.default.createElement(InputsTree, { inputsValues }));
|
|
2675
|
+
}
|
|
2676
|
+
|
|
2677
|
+
// src/components/code-editor/index.tsx
|
|
2678
|
+
var import_react35 = __toESM(require("react"));
|
|
2679
|
+
var import_react36 = require("@coze-editor/editor/react");
|
|
2680
|
+
var import_preset_code5 = __toESM(require("@coze-editor/editor/preset-code"));
|
|
2681
|
+
var import_view4 = require("@codemirror/view");
|
|
2682
|
+
|
|
2683
|
+
// src/components/code-editor/utils.ts
|
|
2684
|
+
function getSuffixByLanguageId(languageId) {
|
|
2685
|
+
if (languageId === "python") {
|
|
2686
|
+
return ".py";
|
|
2687
|
+
}
|
|
2688
|
+
if (languageId === "typescript") {
|
|
2689
|
+
return ".ts";
|
|
2690
|
+
}
|
|
2691
|
+
if (languageId === "shell") {
|
|
2692
|
+
return ".sh";
|
|
2693
|
+
}
|
|
2694
|
+
if (languageId === "json") {
|
|
2695
|
+
return ".json";
|
|
2696
|
+
}
|
|
2697
|
+
return "";
|
|
2698
|
+
}
|
|
2699
|
+
|
|
2700
|
+
// src/components/code-editor/language-features.ts
|
|
2701
|
+
var import_preset_code = require("@coze-editor/editor/preset-code");
|
|
2702
|
+
var import_language_typescript = require("@coze-editor/editor/language-typescript");
|
|
2703
|
+
var import_language_shell = require("@coze-editor/editor/language-shell");
|
|
2704
|
+
var import_language_python = require("@coze-editor/editor/language-python");
|
|
2705
|
+
var import_language_json = require("@coze-editor/editor/language-json");
|
|
2706
|
+
var import_editor10 = require("@coze-editor/editor");
|
|
2707
|
+
import_preset_code.languages.register("python", import_language_python.python);
|
|
2708
|
+
import_preset_code.languages.register("shell", import_language_shell.shell);
|
|
2709
|
+
import_preset_code.languages.register("typescript", import_language_typescript.typescript);
|
|
2710
|
+
import_preset_code.languages.register("json", {
|
|
2711
|
+
// mixLanguages is used to solve the problem that interpolation also uses parentheses, which causes incorrect highlighting
|
|
2712
|
+
language: (0, import_editor10.mixLanguages)({
|
|
2713
|
+
outerLanguage: import_language_json.json.language
|
|
2714
|
+
}),
|
|
2715
|
+
languageService: import_language_json.json.languageService
|
|
2716
|
+
});
|
|
2717
|
+
var tsWorkerInit = false;
|
|
2718
|
+
var initTsWorker = () => {
|
|
2719
|
+
if (tsWorkerInit) {
|
|
2720
|
+
return;
|
|
2721
|
+
}
|
|
2722
|
+
tsWorkerInit = true;
|
|
2723
|
+
const tsWorker = new Worker(
|
|
2724
|
+
new URL(`@coze-editor/editor/language-typescript/worker`, importMetaUrl),
|
|
2725
|
+
{ type: "module" }
|
|
2726
|
+
);
|
|
2727
|
+
import_language_typescript.typescript.languageService.initialize(tsWorker, {
|
|
2728
|
+
compilerOptions: {
|
|
2729
|
+
// eliminate Promise error
|
|
2730
|
+
lib: ["es2015", "dom"],
|
|
2731
|
+
noImplicitAny: false
|
|
2732
|
+
}
|
|
2733
|
+
});
|
|
2734
|
+
};
|
|
2735
|
+
|
|
2736
|
+
// src/components/code-editor/theme/index.ts
|
|
2737
|
+
var import_preset_code4 = require("@coze-editor/editor/preset-code");
|
|
2738
|
+
|
|
2739
|
+
// src/components/code-editor/theme/light.ts
|
|
2740
|
+
var import_preset_code2 = require("@coze-editor/editor/preset-code");
|
|
2741
|
+
var colors = {
|
|
2742
|
+
background: "#F7F7FC",
|
|
2743
|
+
// syntax
|
|
2744
|
+
comment: "#000A298A",
|
|
2745
|
+
key: "#00818C",
|
|
2746
|
+
string: "#D1009D",
|
|
2747
|
+
number: "#C74200",
|
|
2748
|
+
boolean: "#2B57D9",
|
|
2749
|
+
null: "#2B57D9",
|
|
2750
|
+
separator: "#0F1529D1"
|
|
2751
|
+
};
|
|
2752
|
+
var lightTheme = (0, import_preset_code2.createTheme)({
|
|
2753
|
+
variant: "light",
|
|
2754
|
+
settings: {
|
|
2755
|
+
background: "#fff",
|
|
2756
|
+
foreground: "#000",
|
|
2757
|
+
caret: "#000",
|
|
2758
|
+
selection: "#d9d9d9",
|
|
2759
|
+
gutterBackground: "#f0f0f0",
|
|
2760
|
+
gutterForeground: "#666",
|
|
2761
|
+
gutterBorderColor: "transparent",
|
|
2762
|
+
gutterBorderWidth: 0,
|
|
2763
|
+
lineHighlight: "#f0f0f0",
|
|
2764
|
+
bracketColors: ["#FFD700", "#DD99FF", "#78B0FF"],
|
|
2765
|
+
tooltip: {
|
|
2766
|
+
backgroundColor: "#f0f0f0",
|
|
2767
|
+
color: "#000",
|
|
2768
|
+
border: "1px solid #ccc"
|
|
2769
|
+
},
|
|
2770
|
+
link: {
|
|
2771
|
+
color: "#007bff"
|
|
2772
|
+
},
|
|
2773
|
+
completionItemHover: {
|
|
2774
|
+
backgroundColor: "#f0f0f0"
|
|
2775
|
+
},
|
|
2776
|
+
completionItemSelected: {
|
|
2777
|
+
backgroundColor: "#e0e0e0"
|
|
2778
|
+
},
|
|
2779
|
+
completionItemIcon: {
|
|
2780
|
+
color: "#333"
|
|
2781
|
+
},
|
|
2782
|
+
completionItemLabel: {
|
|
2783
|
+
color: "#333"
|
|
2784
|
+
},
|
|
2785
|
+
completionItemInfo: {
|
|
2786
|
+
color: "#333"
|
|
2787
|
+
},
|
|
2788
|
+
completionItemDetail: {
|
|
2789
|
+
color: "#666"
|
|
2790
|
+
}
|
|
2791
|
+
},
|
|
2792
|
+
styles: [
|
|
2793
|
+
// JSON
|
|
2794
|
+
{
|
|
2795
|
+
tag: import_preset_code2.tags.comment,
|
|
2796
|
+
color: colors.comment
|
|
2797
|
+
},
|
|
2798
|
+
{
|
|
2799
|
+
tag: [import_preset_code2.tags.propertyName],
|
|
2800
|
+
color: colors.key
|
|
2801
|
+
},
|
|
2802
|
+
{
|
|
2803
|
+
tag: [import_preset_code2.tags.string],
|
|
2804
|
+
color: colors.string
|
|
2805
|
+
},
|
|
2806
|
+
{
|
|
2807
|
+
tag: [import_preset_code2.tags.number],
|
|
2808
|
+
color: colors.number
|
|
2809
|
+
},
|
|
2810
|
+
{
|
|
2811
|
+
tag: [import_preset_code2.tags.bool],
|
|
2812
|
+
color: colors.boolean
|
|
2813
|
+
},
|
|
2814
|
+
{
|
|
2815
|
+
tag: [import_preset_code2.tags.null],
|
|
2816
|
+
color: colors.null
|
|
2817
|
+
},
|
|
2818
|
+
{
|
|
2819
|
+
tag: [import_preset_code2.tags.separator],
|
|
2820
|
+
color: colors.separator
|
|
2821
|
+
},
|
|
2822
|
+
// markdown
|
|
2823
|
+
{
|
|
2824
|
+
tag: [import_preset_code2.tags.heading],
|
|
2825
|
+
color: "#3e76ef"
|
|
2826
|
+
},
|
|
2827
|
+
{
|
|
2828
|
+
tag: [import_preset_code2.tags.processingInstruction],
|
|
2829
|
+
color: "#3e76ef"
|
|
2830
|
+
},
|
|
2831
|
+
// shell
|
|
2832
|
+
// curl
|
|
2833
|
+
{
|
|
2834
|
+
tag: [import_preset_code2.tags.standard(import_preset_code2.tags.variableName)],
|
|
2835
|
+
color: "#00804A"
|
|
2836
|
+
},
|
|
2837
|
+
// -X
|
|
2838
|
+
{
|
|
2839
|
+
tag: [import_preset_code2.tags.attributeName],
|
|
2840
|
+
color: "#C74200"
|
|
2841
|
+
},
|
|
2842
|
+
// url in string (includes quotes), e.g. "https://..."
|
|
2843
|
+
{
|
|
2844
|
+
tag: [import_preset_code2.tags.special(import_preset_code2.tags.string)],
|
|
2845
|
+
color: "#2B57D9"
|
|
2846
|
+
}
|
|
2847
|
+
]
|
|
2848
|
+
});
|
|
2849
|
+
|
|
2850
|
+
// src/components/code-editor/theme/dark.ts
|
|
2851
|
+
var import_preset_code3 = require("@coze-editor/editor/preset-code");
|
|
2852
|
+
var colors2 = {
|
|
2853
|
+
background: "#151B27",
|
|
2854
|
+
// syntax
|
|
2855
|
+
comment: "#FFFFFF63",
|
|
2856
|
+
key: "#39E5D7",
|
|
2857
|
+
string: "#FF94D2",
|
|
2858
|
+
number: "#FF9933",
|
|
2859
|
+
boolean: "#78B0FF",
|
|
2860
|
+
null: "#78B0FF",
|
|
2861
|
+
separator: "#FFFFFFC9"
|
|
2862
|
+
};
|
|
2863
|
+
var darkTheme = (0, import_preset_code3.createTheme)({
|
|
2864
|
+
variant: "dark",
|
|
2865
|
+
settings: {
|
|
2866
|
+
background: colors2.background,
|
|
2867
|
+
foreground: "#fff",
|
|
2868
|
+
caret: "#AEAFAD",
|
|
2869
|
+
selection: "#d9d9d942",
|
|
2870
|
+
gutterBackground: colors2.background,
|
|
2871
|
+
gutterForeground: "#FFFFFF63",
|
|
2872
|
+
gutterBorderColor: "transparent",
|
|
2873
|
+
gutterBorderWidth: 0,
|
|
2874
|
+
lineHighlight: "#272e3d36",
|
|
2875
|
+
bracketColors: ["#FFEF61", "#DD99FF", "#78B0FF"],
|
|
2876
|
+
tooltip: {
|
|
2877
|
+
backgroundColor: "#363D4D",
|
|
2878
|
+
color: "#fff",
|
|
2879
|
+
border: "none"
|
|
2880
|
+
},
|
|
2881
|
+
link: {
|
|
2882
|
+
color: "#4daafc"
|
|
2883
|
+
},
|
|
2884
|
+
completionItemHover: {
|
|
2885
|
+
backgroundColor: "#FFFFFF0F"
|
|
2886
|
+
},
|
|
2887
|
+
completionItemSelected: {
|
|
2888
|
+
backgroundColor: "#FFFFFF17"
|
|
2889
|
+
},
|
|
2890
|
+
completionItemIcon: {
|
|
2891
|
+
color: "#FFFFFFC9"
|
|
2892
|
+
},
|
|
2893
|
+
completionItemLabel: {
|
|
2894
|
+
color: "#FFFFFFC9"
|
|
2895
|
+
},
|
|
2896
|
+
completionItemInfo: {
|
|
2897
|
+
color: "#FFFFFFC9"
|
|
2898
|
+
},
|
|
2899
|
+
completionItemDetail: {
|
|
2900
|
+
color: "#FFFFFF63"
|
|
2901
|
+
}
|
|
2902
|
+
},
|
|
2903
|
+
styles: [
|
|
2904
|
+
// json
|
|
2905
|
+
{
|
|
2906
|
+
tag: import_preset_code3.tags.comment,
|
|
2907
|
+
color: colors2.comment
|
|
2908
|
+
},
|
|
2909
|
+
{
|
|
2910
|
+
tag: [import_preset_code3.tags.propertyName],
|
|
2911
|
+
color: colors2.key
|
|
2912
|
+
},
|
|
2913
|
+
{
|
|
2914
|
+
tag: [import_preset_code3.tags.string],
|
|
2915
|
+
color: colors2.string
|
|
2916
|
+
},
|
|
2917
|
+
{
|
|
2918
|
+
tag: [import_preset_code3.tags.number],
|
|
2919
|
+
color: colors2.number
|
|
2920
|
+
},
|
|
2921
|
+
{
|
|
2922
|
+
tag: [import_preset_code3.tags.bool],
|
|
2923
|
+
color: colors2.boolean
|
|
2924
|
+
},
|
|
2925
|
+
{
|
|
2926
|
+
tag: [import_preset_code3.tags.null],
|
|
2927
|
+
color: colors2.null
|
|
2928
|
+
},
|
|
2929
|
+
{
|
|
2930
|
+
tag: [import_preset_code3.tags.separator],
|
|
2931
|
+
color: colors2.separator
|
|
2932
|
+
},
|
|
2933
|
+
// markdown
|
|
2934
|
+
{
|
|
2935
|
+
tag: [import_preset_code3.tags.heading],
|
|
2936
|
+
color: "#6b6bff"
|
|
2937
|
+
},
|
|
2938
|
+
{
|
|
2939
|
+
tag: [import_preset_code3.tags.processingInstruction],
|
|
2940
|
+
color: "#6b6bff"
|
|
2941
|
+
},
|
|
2942
|
+
// shell
|
|
2943
|
+
// curl
|
|
2944
|
+
{
|
|
2945
|
+
tag: [import_preset_code3.tags.standard(import_preset_code3.tags.variableName)],
|
|
2946
|
+
color: "#3BEB84"
|
|
2947
|
+
},
|
|
2948
|
+
// -X
|
|
2949
|
+
{
|
|
2950
|
+
tag: [import_preset_code3.tags.attributeName],
|
|
2951
|
+
color: "#FF9933"
|
|
2952
|
+
},
|
|
2953
|
+
// url in string (includes quotes), e.g. "https://..."
|
|
2954
|
+
{
|
|
2955
|
+
tag: [import_preset_code3.tags.special(import_preset_code3.tags.string)],
|
|
2956
|
+
color: "#78B0FF"
|
|
2957
|
+
}
|
|
2958
|
+
]
|
|
2959
|
+
});
|
|
2960
|
+
|
|
2961
|
+
// src/components/code-editor/theme/index.ts
|
|
2962
|
+
import_preset_code4.themes.register("dark", darkTheme);
|
|
2963
|
+
import_preset_code4.themes.register("light", lightTheme);
|
|
2964
|
+
|
|
2965
|
+
// src/components/code-editor/index.tsx
|
|
2966
|
+
var OriginCodeEditor = (0, import_react36.createRenderer)(import_preset_code5.default, [
|
|
2967
|
+
import_view4.EditorView.theme({
|
|
2968
|
+
"&.cm-focused": {
|
|
2969
|
+
outline: "none"
|
|
2970
|
+
}
|
|
2971
|
+
})
|
|
2972
|
+
]);
|
|
2973
|
+
function CodeEditor({
|
|
2974
|
+
value,
|
|
2975
|
+
onChange,
|
|
2976
|
+
languageId = "python",
|
|
2977
|
+
theme = "light",
|
|
2978
|
+
children,
|
|
2979
|
+
placeholder,
|
|
2980
|
+
activeLinePlaceholder,
|
|
2981
|
+
options: options2,
|
|
2982
|
+
readonly
|
|
2983
|
+
}) {
|
|
2984
|
+
const editorRef = (0, import_react35.useRef)(null);
|
|
2985
|
+
(0, import_react35.useEffect)(() => {
|
|
2986
|
+
if (languageId === "typescript") {
|
|
2987
|
+
initTsWorker();
|
|
2988
|
+
}
|
|
2989
|
+
}, [languageId]);
|
|
2990
|
+
(0, import_react35.useEffect)(() => {
|
|
2991
|
+
if (editorRef.current?.getValue() !== value) {
|
|
2992
|
+
editorRef.current?.setValue(String(value || ""));
|
|
2993
|
+
}
|
|
2994
|
+
}, [value]);
|
|
2995
|
+
return /* @__PURE__ */ import_react35.default.createElement(import_react36.EditorProvider, null, /* @__PURE__ */ import_react35.default.createElement(
|
|
2996
|
+
OriginCodeEditor,
|
|
2997
|
+
{
|
|
2998
|
+
defaultValue: value,
|
|
2999
|
+
options: {
|
|
3000
|
+
uri: `file:///untitled${getSuffixByLanguageId(languageId)}`,
|
|
3001
|
+
languageId,
|
|
3002
|
+
theme,
|
|
3003
|
+
placeholder,
|
|
3004
|
+
readOnly: readonly,
|
|
3005
|
+
editable: !readonly,
|
|
3006
|
+
...options2 || {}
|
|
3007
|
+
},
|
|
3008
|
+
didMount: (editor) => {
|
|
3009
|
+
editorRef.current = editor;
|
|
3010
|
+
},
|
|
3011
|
+
onChange: (e) => onChange?.(e.value)
|
|
3012
|
+
},
|
|
3013
|
+
activeLinePlaceholder && /* @__PURE__ */ import_react35.default.createElement(import_react36.ActiveLinePlaceholder, null, activeLinePlaceholder),
|
|
3014
|
+
children
|
|
3015
|
+
));
|
|
3016
|
+
}
|
|
3017
|
+
|
|
3018
|
+
// src/components/json-editor-with-variables/index.tsx
|
|
3019
|
+
var import_react41 = __toESM(require("react"));
|
|
3020
|
+
var import_preset_code6 = require("@coze-editor/editor/preset-code");
|
|
3021
|
+
|
|
3022
|
+
// src/components/json-editor-with-variables/extensions/variable-tree.tsx
|
|
3023
|
+
var import_react37 = __toESM(require("react"));
|
|
3024
|
+
var import_semi_ui17 = require("@douyinfe/semi-ui");
|
|
3025
|
+
var import_react38 = require("@coze-editor/editor/react");
|
|
3026
|
+
function VariableTree2() {
|
|
3027
|
+
const [posKey, setPosKey] = (0, import_react37.useState)("");
|
|
3028
|
+
const [visible, setVisible] = (0, import_react37.useState)(false);
|
|
3029
|
+
const [position, setPosition] = (0, import_react37.useState)(-1);
|
|
3030
|
+
const editor = (0, import_react38.useEditor)();
|
|
3031
|
+
function insert(variablePath) {
|
|
3032
|
+
const range = (0, import_react38.getCurrentMentionReplaceRange)(editor.$view.state);
|
|
3033
|
+
if (!range) {
|
|
3034
|
+
return;
|
|
3035
|
+
}
|
|
3036
|
+
editor.replaceText({
|
|
3037
|
+
...range,
|
|
3038
|
+
text: "{{" + variablePath + "}}"
|
|
3039
|
+
});
|
|
3040
|
+
setVisible(false);
|
|
3041
|
+
}
|
|
3042
|
+
function handleOpenChange(e) {
|
|
3043
|
+
setPosition(e.state.selection.main.head);
|
|
3044
|
+
setVisible(e.value);
|
|
3045
|
+
}
|
|
3046
|
+
(0, import_react37.useEffect)(() => {
|
|
3047
|
+
if (!editor) {
|
|
3048
|
+
return;
|
|
3049
|
+
}
|
|
3050
|
+
}, [editor, visible]);
|
|
3051
|
+
const treeData = useVariableTree({});
|
|
3052
|
+
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(
|
|
3053
|
+
import_semi_ui17.Popover,
|
|
3054
|
+
{
|
|
3055
|
+
visible,
|
|
3056
|
+
trigger: "custom",
|
|
3057
|
+
position: "topLeft",
|
|
3058
|
+
rePosKey: posKey,
|
|
3059
|
+
content: /* @__PURE__ */ import_react37.default.createElement("div", { style: { width: 300 } }, /* @__PURE__ */ import_react37.default.createElement(
|
|
3060
|
+
import_semi_ui17.Tree,
|
|
3061
|
+
{
|
|
3062
|
+
treeData,
|
|
3063
|
+
onSelect: (v) => {
|
|
3064
|
+
insert(v);
|
|
3065
|
+
}
|
|
3066
|
+
}
|
|
3067
|
+
))
|
|
3068
|
+
},
|
|
3069
|
+
/* @__PURE__ */ import_react37.default.createElement(
|
|
3070
|
+
import_react38.PositionMirror,
|
|
3071
|
+
{
|
|
3072
|
+
position,
|
|
3073
|
+
onChange: () => setPosKey(String(Math.random()))
|
|
3074
|
+
}
|
|
3075
|
+
)
|
|
3076
|
+
));
|
|
3077
|
+
}
|
|
3078
|
+
|
|
3079
|
+
// src/components/json-editor-with-variables/extensions/variable-tag.tsx
|
|
3080
|
+
var import_react39 = __toESM(require("react"));
|
|
3081
|
+
var import_client = require("react-dom/client");
|
|
3082
|
+
var import_lodash7 = require("lodash");
|
|
3083
|
+
var import_editor11 = require("@flowgram.ai/editor");
|
|
3084
|
+
var import_semi_ui19 = require("@douyinfe/semi-ui");
|
|
3085
|
+
var import_semi_icons10 = require("@douyinfe/semi-icons");
|
|
3086
|
+
var import_react40 = require("@coze-editor/editor/react");
|
|
3087
|
+
var import_view5 = require("@codemirror/view");
|
|
3088
|
+
|
|
3089
|
+
// src/components/json-editor-with-variables/styles.tsx
|
|
3090
|
+
var import_styled_components8 = __toESM(require("styled-components"));
|
|
3091
|
+
var import_semi_ui18 = require("@douyinfe/semi-ui");
|
|
3092
|
+
var UIRootTitle3 = import_styled_components8.default.div`
|
|
3093
|
+
margin-right: 4px;
|
|
3094
|
+
min-width: 20px;
|
|
3095
|
+
overflow: hidden;
|
|
3096
|
+
text-overflow: ellipsis;
|
|
3097
|
+
white-space: nowrap;
|
|
3098
|
+
color: var(--semi-color-text-2);
|
|
3099
|
+
`;
|
|
3100
|
+
var UIVarName3 = import_styled_components8.default.div`
|
|
3101
|
+
overflow: hidden;
|
|
3102
|
+
text-overflow: ellipsis;
|
|
3103
|
+
white-space: nowrap;
|
|
3104
|
+
`;
|
|
3105
|
+
var UITag3 = (0, import_styled_components8.default)(import_semi_ui18.Tag)`
|
|
3106
|
+
display: inline-flex;
|
|
3107
|
+
align-items: center;
|
|
3108
|
+
justify-content: flex-start;
|
|
3109
|
+
max-width: 300px;
|
|
3110
|
+
|
|
3111
|
+
& .semi-tag-content-center {
|
|
3112
|
+
justify-content: flex-start;
|
|
3113
|
+
}
|
|
3114
|
+
|
|
3115
|
+
&.semi-tag {
|
|
3116
|
+
margin: 0 5px;
|
|
3117
|
+
}
|
|
3118
|
+
`;
|
|
3119
|
+
var UIPopoverContent3 = import_styled_components8.default.div`
|
|
3120
|
+
padding: 10px;
|
|
3121
|
+
display: inline-flex;
|
|
3122
|
+
align-items: center;
|
|
3123
|
+
justify-content: flex-start;
|
|
3124
|
+
`;
|
|
3125
|
+
|
|
3126
|
+
// src/components/json-editor-with-variables/extensions/variable-tag.tsx
|
|
3127
|
+
var VariableTagWidget2 = class extends import_view5.WidgetType {
|
|
3128
|
+
constructor({ keyPath, scope }) {
|
|
3129
|
+
super();
|
|
3130
|
+
this.toDispose = new import_editor11.DisposableCollection();
|
|
3131
|
+
this.renderIcon = (icon) => {
|
|
3132
|
+
if (typeof icon === "string") {
|
|
3133
|
+
return /* @__PURE__ */ import_react39.default.createElement("img", { style: { marginRight: 8 }, width: 12, height: 12, src: icon });
|
|
3134
|
+
}
|
|
3135
|
+
return icon;
|
|
3136
|
+
};
|
|
3137
|
+
this.keyPath = keyPath;
|
|
3138
|
+
this.scope = scope;
|
|
3139
|
+
}
|
|
3140
|
+
renderVariable(v) {
|
|
3141
|
+
if (!v) {
|
|
3142
|
+
this.root.render(
|
|
3143
|
+
/* @__PURE__ */ import_react39.default.createElement(UITag3, { prefixIcon: /* @__PURE__ */ import_react39.default.createElement(import_semi_icons10.IconIssueStroked, null), color: "amber" }, "Unknown")
|
|
3144
|
+
);
|
|
3145
|
+
return;
|
|
3146
|
+
}
|
|
3147
|
+
const rootField = (0, import_lodash7.last)(v.parentFields);
|
|
3148
|
+
const rootTitle = /* @__PURE__ */ import_react39.default.createElement(UIRootTitle3, null, rootField?.meta.title ? `${rootField.meta.title} -` : "");
|
|
3149
|
+
const rootIcon = this.renderIcon(rootField?.meta.icon);
|
|
3150
|
+
this.root.render(
|
|
3151
|
+
/* @__PURE__ */ import_react39.default.createElement(
|
|
3152
|
+
import_semi_ui19.Popover,
|
|
3153
|
+
{
|
|
3154
|
+
content: /* @__PURE__ */ import_react39.default.createElement(UIPopoverContent3, null, rootIcon, rootTitle, /* @__PURE__ */ import_react39.default.createElement(UIVarName3, null, v?.keyPath.slice(1).join(".")))
|
|
3155
|
+
},
|
|
3156
|
+
/* @__PURE__ */ import_react39.default.createElement(UITag3, { prefixIcon: rootIcon }, rootTitle, /* @__PURE__ */ import_react39.default.createElement(UIVarName3, null, v?.key))
|
|
3157
|
+
)
|
|
3158
|
+
);
|
|
3159
|
+
}
|
|
3160
|
+
toDOM(view) {
|
|
3161
|
+
const dom = document.createElement("span");
|
|
3162
|
+
this.root = (0, import_client.createRoot)(dom);
|
|
3163
|
+
this.toDispose.push(
|
|
3164
|
+
import_editor11.Disposable.create(() => {
|
|
3165
|
+
this.root.unmount();
|
|
3166
|
+
})
|
|
3167
|
+
);
|
|
3168
|
+
this.toDispose.push(
|
|
3169
|
+
this.scope.available.trackByKeyPath(
|
|
3170
|
+
this.keyPath,
|
|
3171
|
+
(v) => {
|
|
3172
|
+
this.renderVariable(v);
|
|
3173
|
+
},
|
|
3174
|
+
{ triggerOnInit: false }
|
|
3175
|
+
)
|
|
3176
|
+
);
|
|
3177
|
+
this.renderVariable(this.scope.available.getByKeyPath(this.keyPath));
|
|
3178
|
+
return dom;
|
|
3179
|
+
}
|
|
3180
|
+
eq(other) {
|
|
3181
|
+
return (0, import_lodash7.isEqual)(this.keyPath, other.keyPath);
|
|
3182
|
+
}
|
|
3183
|
+
ignoreEvent() {
|
|
3184
|
+
return false;
|
|
3185
|
+
}
|
|
3186
|
+
destroy(dom) {
|
|
3187
|
+
this.toDispose.dispose();
|
|
3188
|
+
}
|
|
3189
|
+
};
|
|
3190
|
+
function VariableTagInject2() {
|
|
3191
|
+
const injector = (0, import_react40.useInjector)();
|
|
3192
|
+
const scope = (0, import_editor11.useCurrentScope)();
|
|
3193
|
+
(0, import_react39.useLayoutEffect)(() => {
|
|
3194
|
+
const atMatcher = new import_view5.MatchDecorator({
|
|
3195
|
+
regexp: /\{\{([^\}]+)\}\}/g,
|
|
3196
|
+
decoration: (match) => import_view5.Decoration.replace({
|
|
3197
|
+
widget: new VariableTagWidget2({
|
|
3198
|
+
keyPath: match[1]?.split(".") ?? [],
|
|
3199
|
+
scope
|
|
3200
|
+
})
|
|
3201
|
+
})
|
|
3202
|
+
});
|
|
3203
|
+
return injector.inject([
|
|
3204
|
+
import_view5.ViewPlugin.fromClass(
|
|
3205
|
+
class {
|
|
3206
|
+
constructor(view) {
|
|
3207
|
+
this.view = view;
|
|
3208
|
+
this.decorations = atMatcher.createDeco(view);
|
|
3209
|
+
}
|
|
3210
|
+
update() {
|
|
3211
|
+
this.decorations = atMatcher.createDeco(this.view);
|
|
3212
|
+
}
|
|
3213
|
+
},
|
|
3214
|
+
{
|
|
3215
|
+
decorations: (p) => p.decorations,
|
|
3216
|
+
provide(p) {
|
|
3217
|
+
return import_view5.EditorView.atomicRanges.of(
|
|
3218
|
+
(view) => view.plugin(p)?.decorations ?? import_view5.Decoration.none
|
|
3219
|
+
);
|
|
3220
|
+
}
|
|
3221
|
+
}
|
|
3222
|
+
)
|
|
3223
|
+
]);
|
|
3224
|
+
}, [injector]);
|
|
3225
|
+
return null;
|
|
3226
|
+
}
|
|
3227
|
+
|
|
3228
|
+
// src/components/json-editor-with-variables/index.tsx
|
|
3229
|
+
function findAllMatches(inputString, regex) {
|
|
3230
|
+
const globalRegex = new RegExp(
|
|
3231
|
+
regex,
|
|
3232
|
+
regex.flags.includes("g") ? regex.flags : regex.flags + "g"
|
|
3233
|
+
);
|
|
3234
|
+
let match;
|
|
3235
|
+
const matches = [];
|
|
3236
|
+
while ((match = globalRegex.exec(inputString)) !== null) {
|
|
3237
|
+
if (match.index === globalRegex.lastIndex) {
|
|
3238
|
+
globalRegex.lastIndex++;
|
|
3239
|
+
}
|
|
3240
|
+
matches.push({
|
|
3241
|
+
match: match[0],
|
|
3242
|
+
range: [match.index, match.index + match[0].length]
|
|
3243
|
+
});
|
|
3244
|
+
}
|
|
3245
|
+
return matches;
|
|
3246
|
+
}
|
|
3247
|
+
var transformer = (0, import_preset_code6.transformerCreator)((text) => {
|
|
3248
|
+
const originalSource = text.toString();
|
|
3249
|
+
const matches = findAllMatches(originalSource, /\{\{([^\}]*)\}\}/g);
|
|
3250
|
+
if (matches.length > 0) {
|
|
3251
|
+
matches.forEach(({ range }) => {
|
|
3252
|
+
text.replaceRange(range[0], range[1], "null");
|
|
3253
|
+
});
|
|
3254
|
+
}
|
|
3255
|
+
return text;
|
|
3256
|
+
});
|
|
3257
|
+
function JsonEditorWithVariables(props) {
|
|
3258
|
+
return /* @__PURE__ */ import_react41.default.createElement(
|
|
3259
|
+
CodeEditor,
|
|
3260
|
+
{
|
|
3261
|
+
languageId: "json",
|
|
3262
|
+
activeLinePlaceholder: "Press '@' to Select variable",
|
|
3263
|
+
...props,
|
|
3264
|
+
options: {
|
|
3265
|
+
transformer,
|
|
3266
|
+
...props.options || {}
|
|
3267
|
+
}
|
|
3268
|
+
},
|
|
3269
|
+
/* @__PURE__ */ import_react41.default.createElement(VariableTree2, null),
|
|
3270
|
+
/* @__PURE__ */ import_react41.default.createElement(VariableTagInject2, null)
|
|
3271
|
+
);
|
|
3272
|
+
}
|
|
3273
|
+
|
|
3274
|
+
// src/components/inputs-values/index.tsx
|
|
3275
|
+
var import_react43 = __toESM(require("react"));
|
|
3276
|
+
var import_semi_ui20 = require("@douyinfe/semi-ui");
|
|
3277
|
+
var import_semi_icons11 = require("@douyinfe/semi-icons");
|
|
3278
|
+
|
|
3279
|
+
// src/components/inputs-values/styles.tsx
|
|
3280
|
+
var import_styled_components9 = __toESM(require("styled-components"));
|
|
3281
|
+
var UIRows2 = import_styled_components9.default.div`
|
|
3282
|
+
display: flex;
|
|
3283
|
+
flex-direction: column;
|
|
3284
|
+
gap: 10px;
|
|
3285
|
+
margin-bottom: 10px;
|
|
3286
|
+
`;
|
|
3287
|
+
var UIRow3 = import_styled_components9.default.div`
|
|
3288
|
+
display: flex;
|
|
3289
|
+
align-items: center;
|
|
3290
|
+
gap: 5px;
|
|
3291
|
+
`;
|
|
3292
|
+
|
|
3293
|
+
// src/components/inputs-values/components/blur-input.tsx
|
|
3294
|
+
var import_react42 = __toESM(require("react"));
|
|
3295
|
+
var import_input2 = __toESM(require("@douyinfe/semi-ui/lib/es/input"));
|
|
3296
|
+
function BlurInput2(props) {
|
|
3297
|
+
const [value, setValue] = (0, import_react42.useState)("");
|
|
3298
|
+
(0, import_react42.useEffect)(() => {
|
|
3299
|
+
setValue(props.value);
|
|
3300
|
+
}, [props.value]);
|
|
3301
|
+
return /* @__PURE__ */ import_react42.default.createElement(
|
|
3302
|
+
import_input2.default,
|
|
3303
|
+
{
|
|
3304
|
+
...props,
|
|
3305
|
+
value,
|
|
3306
|
+
onChange: (value2) => {
|
|
3307
|
+
setValue(value2);
|
|
3308
|
+
},
|
|
3309
|
+
onBlur: (e) => props.onChange?.(value, e)
|
|
3310
|
+
}
|
|
3311
|
+
);
|
|
3312
|
+
}
|
|
3313
|
+
|
|
3314
|
+
// src/components/inputs-values/index.tsx
|
|
3315
|
+
function InputsValues({
|
|
3316
|
+
value,
|
|
3317
|
+
onChange,
|
|
3318
|
+
style,
|
|
3319
|
+
readonly,
|
|
3320
|
+
constantProps,
|
|
3321
|
+
schema,
|
|
3322
|
+
hasError
|
|
3323
|
+
}) {
|
|
3324
|
+
const { list, updateKey, updateValue, remove, add } = useObjectList({
|
|
3325
|
+
value,
|
|
3326
|
+
onChange,
|
|
3327
|
+
sortIndexKey: "extra.index"
|
|
3328
|
+
});
|
|
3329
|
+
return /* @__PURE__ */ import_react43.default.createElement("div", null, /* @__PURE__ */ import_react43.default.createElement(UIRows2, { style }, list.map((item) => /* @__PURE__ */ import_react43.default.createElement(UIRow3, { key: item.id }, /* @__PURE__ */ import_react43.default.createElement(
|
|
3330
|
+
BlurInput2,
|
|
3331
|
+
{
|
|
3332
|
+
style: { width: 100, minWidth: 100, maxWidth: 100 },
|
|
3333
|
+
disabled: readonly,
|
|
3334
|
+
size: "small",
|
|
3335
|
+
value: item.key,
|
|
3336
|
+
onChange: (v) => updateKey(item.id, v),
|
|
3337
|
+
placeholder: "Input Key"
|
|
3338
|
+
}
|
|
3339
|
+
), /* @__PURE__ */ import_react43.default.createElement(
|
|
3340
|
+
DynamicValueInput,
|
|
3341
|
+
{
|
|
3342
|
+
style: { flexGrow: 1 },
|
|
3343
|
+
readonly,
|
|
3344
|
+
value: item.value,
|
|
3345
|
+
onChange: (v) => updateValue(item.id, v),
|
|
3346
|
+
schema,
|
|
3347
|
+
hasError,
|
|
3348
|
+
constantProps: {
|
|
3349
|
+
...constantProps,
|
|
3350
|
+
strategies: [...constantProps?.strategies || []]
|
|
3351
|
+
}
|
|
3352
|
+
}
|
|
3353
|
+
), /* @__PURE__ */ import_react43.default.createElement(
|
|
3354
|
+
import_semi_ui20.IconButton,
|
|
3355
|
+
{
|
|
3356
|
+
disabled: readonly,
|
|
3357
|
+
theme: "borderless",
|
|
3358
|
+
icon: /* @__PURE__ */ import_react43.default.createElement(import_semi_icons11.IconDelete, { size: "small" }),
|
|
3359
|
+
size: "small",
|
|
3360
|
+
onClick: () => remove(item.id)
|
|
3361
|
+
}
|
|
3362
|
+
)))), /* @__PURE__ */ import_react43.default.createElement(import_semi_ui20.Button, { disabled: readonly, icon: /* @__PURE__ */ import_react43.default.createElement(import_semi_icons11.IconPlus, null), size: "small", onClick: add }, "Add"));
|
|
3363
|
+
}
|
|
3364
|
+
|
|
3365
|
+
// src/effects/provide-batch-input/index.ts
|
|
3366
|
+
var import_editor12 = require("@flowgram.ai/editor");
|
|
3367
|
+
var provideBatchInputEffect = (0, import_editor12.createEffectFromVariableProvider)({
|
|
3368
|
+
private: true,
|
|
3369
|
+
parse: (value, ctx) => [
|
|
3370
|
+
import_editor12.ASTFactory.createVariableDeclaration({
|
|
3371
|
+
key: `${ctx.node.id}_locals`,
|
|
3372
|
+
meta: {
|
|
3373
|
+
title: (0, import_editor12.getNodeForm)(ctx.node)?.getValueIn("title"),
|
|
3374
|
+
icon: ctx.node.getNodeRegistry().info?.icon
|
|
3375
|
+
},
|
|
3376
|
+
type: import_editor12.ASTFactory.createObject({
|
|
3377
|
+
properties: [
|
|
3378
|
+
import_editor12.ASTFactory.createProperty({
|
|
3379
|
+
key: "item",
|
|
3380
|
+
initializer: import_editor12.ASTFactory.createEnumerateExpression({
|
|
3381
|
+
enumerateFor: import_editor12.ASTFactory.createKeyPathExpression({
|
|
3382
|
+
keyPath: value.content || []
|
|
3383
|
+
})
|
|
3384
|
+
})
|
|
3385
|
+
}),
|
|
3386
|
+
import_editor12.ASTFactory.createProperty({
|
|
3387
|
+
key: "index",
|
|
3388
|
+
type: import_editor12.ASTFactory.createNumber()
|
|
3389
|
+
})
|
|
3390
|
+
]
|
|
3391
|
+
})
|
|
3392
|
+
})
|
|
3393
|
+
]
|
|
3394
|
+
});
|
|
3395
|
+
|
|
3396
|
+
// src/effects/auto-rename-ref/index.ts
|
|
3397
|
+
var import_lodash8 = require("lodash");
|
|
3398
|
+
var import_editor13 = require("@flowgram.ai/editor");
|
|
3399
|
+
var autoRenameRefEffect = [
|
|
3400
|
+
{
|
|
3401
|
+
event: import_editor13.DataEvent.onValueInit,
|
|
3402
|
+
effect: (params) => {
|
|
3403
|
+
const { context, form, name } = params;
|
|
3404
|
+
const renameService = context.node.getService(import_editor13.VariableFieldKeyRenameService);
|
|
3405
|
+
const disposable = renameService.onRename(({ before, after }) => {
|
|
3406
|
+
const beforeKeyPath = [
|
|
3407
|
+
...before.parentFields.map((_field) => _field.key).reverse(),
|
|
3408
|
+
before.key
|
|
3409
|
+
];
|
|
3410
|
+
const afterKeyPath = [
|
|
3411
|
+
...after.parentFields.map((_field) => _field.key).reverse(),
|
|
3412
|
+
after.key
|
|
3413
|
+
];
|
|
3414
|
+
traverseRef(name, form.getValueIn(name), (_drilldownName, _v) => {
|
|
3415
|
+
if (_v.type === "ref") {
|
|
3416
|
+
if (isKeyPathMatch(_v.content, beforeKeyPath)) {
|
|
3417
|
+
_v.content = [...afterKeyPath, ...(_v.content || [])?.slice(beforeKeyPath.length)];
|
|
3418
|
+
form.setValueIn(_drilldownName, _v);
|
|
3419
|
+
}
|
|
3420
|
+
} else if (_v.type === "template") {
|
|
3421
|
+
const templateKeyPaths = getTemplateKeyPaths(_v);
|
|
3422
|
+
let hasMatch = false;
|
|
3423
|
+
templateKeyPaths.forEach((_keyPath) => {
|
|
3424
|
+
if (isKeyPathMatch(_keyPath, beforeKeyPath)) {
|
|
3425
|
+
hasMatch = true;
|
|
3426
|
+
const nextKeyPath = [
|
|
3427
|
+
...afterKeyPath,
|
|
3428
|
+
...(_keyPath || [])?.slice(beforeKeyPath.length)
|
|
3429
|
+
];
|
|
3430
|
+
_v.content = _v.content?.replace(
|
|
3431
|
+
`{{${_keyPath.join(".")}}`,
|
|
3432
|
+
`{{${nextKeyPath.join(".")}}`
|
|
3433
|
+
);
|
|
3434
|
+
}
|
|
3435
|
+
});
|
|
3436
|
+
if (hasMatch) {
|
|
3437
|
+
form.setValueIn(_drilldownName, { ..._v });
|
|
3438
|
+
}
|
|
3439
|
+
}
|
|
3440
|
+
});
|
|
3441
|
+
});
|
|
3442
|
+
return () => {
|
|
3443
|
+
disposable.dispose();
|
|
3444
|
+
};
|
|
3445
|
+
}
|
|
3446
|
+
}
|
|
3447
|
+
];
|
|
3448
|
+
function isKeyPathMatch(keyPath = [], targetKeyPath) {
|
|
3449
|
+
return targetKeyPath.every((_key, index) => _key === keyPath[index]);
|
|
3450
|
+
}
|
|
3451
|
+
function getTemplateKeyPaths(value) {
|
|
3452
|
+
const keyPathReg = /{{(.*?)}}/g;
|
|
3453
|
+
return (0, import_lodash8.uniq)(value.content?.match(keyPathReg) || []).map(
|
|
3454
|
+
(_keyPath) => _keyPath.slice(2, -2).split(".")
|
|
3455
|
+
);
|
|
3456
|
+
}
|
|
3457
|
+
function isRef(value) {
|
|
3458
|
+
return value?.type === "ref" && Array.isArray(value?.content) && typeof value?.content[0] === "string";
|
|
3459
|
+
}
|
|
3460
|
+
function isTemplate(value) {
|
|
3461
|
+
return value?.type === "template" && typeof value?.content === "string";
|
|
3462
|
+
}
|
|
3463
|
+
function traverseRef(name, value, cb) {
|
|
3464
|
+
if ((0, import_lodash8.isObject)(value)) {
|
|
3465
|
+
if (isRef(value)) {
|
|
3466
|
+
cb(name, value);
|
|
3467
|
+
return;
|
|
3468
|
+
}
|
|
3469
|
+
if (isTemplate(value)) {
|
|
3470
|
+
cb(name, value);
|
|
3471
|
+
return;
|
|
3472
|
+
}
|
|
3473
|
+
Object.entries(value).forEach(([_key, _value]) => {
|
|
3474
|
+
traverseRef(`${name}.${_key}`, _value, cb);
|
|
3475
|
+
});
|
|
3476
|
+
return;
|
|
3477
|
+
}
|
|
3478
|
+
if ((0, import_lodash8.isArray)(value)) {
|
|
3479
|
+
value.forEach((_value, idx) => {
|
|
3480
|
+
traverseRef(`${name}[${idx}]`, _value, cb);
|
|
3481
|
+
});
|
|
3482
|
+
return;
|
|
3483
|
+
}
|
|
3484
|
+
return;
|
|
3485
|
+
}
|
|
3486
|
+
|
|
3487
|
+
// src/effects/provide-json-schema-outputs/index.ts
|
|
3488
|
+
var import_editor14 = require("@flowgram.ai/editor");
|
|
3489
|
+
var provideJsonSchemaOutputs = (0, import_editor14.createEffectFromVariableProvider)({
|
|
3490
|
+
parse: (value, ctx) => [
|
|
3491
|
+
import_editor14.ASTFactory.createVariableDeclaration({
|
|
3492
|
+
key: `${ctx.node.id}`,
|
|
3493
|
+
meta: {
|
|
3494
|
+
title: (0, import_editor14.getNodeForm)(ctx.node)?.getValueIn("title") || ctx.node.id,
|
|
3495
|
+
icon: ctx.node.getNodeRegistry().info?.icon
|
|
3496
|
+
},
|
|
3497
|
+
type: JsonSchemaUtils.schemaToAST(value)
|
|
3498
|
+
})
|
|
3499
|
+
]
|
|
3500
|
+
});
|
|
3501
|
+
|
|
3502
|
+
// src/effects/sync-variable-title/index.ts
|
|
3503
|
+
var import_editor15 = require("@flowgram.ai/editor");
|
|
3504
|
+
var syncVariableTitle = [
|
|
3505
|
+
{
|
|
3506
|
+
event: import_editor15.DataEvent.onValueChange,
|
|
3507
|
+
effect: ({ value, context }) => {
|
|
3508
|
+
context.node.getData(import_editor15.FlowNodeVariableData).allScopes.forEach((_scope) => {
|
|
3509
|
+
_scope.output.variables.forEach((_var) => {
|
|
3510
|
+
_var.updateMeta({
|
|
3511
|
+
title: value || context.node.id,
|
|
3512
|
+
icon: context.node.getNodeRegistry().info?.icon
|
|
3513
|
+
});
|
|
3514
|
+
});
|
|
3515
|
+
});
|
|
3516
|
+
}
|
|
3517
|
+
}
|
|
3518
|
+
];
|
|
3519
|
+
|
|
3520
|
+
// src/form-plugins/batch-outputs-plugin/index.ts
|
|
3521
|
+
var import_editor16 = require("@flowgram.ai/editor");
|
|
3522
|
+
var provideBatchOutputsEffect = (0, import_editor16.createEffectFromVariableProvider)({
|
|
3523
|
+
parse: (value, ctx) => [
|
|
3524
|
+
import_editor16.ASTFactory.createVariableDeclaration({
|
|
3525
|
+
key: `${ctx.node.id}`,
|
|
3526
|
+
meta: {
|
|
3527
|
+
title: (0, import_editor16.getNodeForm)(ctx.node)?.getValueIn("title"),
|
|
3528
|
+
icon: ctx.node.getNodeRegistry().info?.icon
|
|
3529
|
+
},
|
|
3530
|
+
type: import_editor16.ASTFactory.createObject({
|
|
3531
|
+
properties: Object.entries(value).map(
|
|
3532
|
+
([_key, value2]) => import_editor16.ASTFactory.createProperty({
|
|
3533
|
+
key: _key,
|
|
3534
|
+
initializer: import_editor16.ASTFactory.createWrapArrayExpression({
|
|
3535
|
+
wrapFor: import_editor16.ASTFactory.createKeyPathExpression({
|
|
3536
|
+
keyPath: value2?.content || []
|
|
3537
|
+
})
|
|
3538
|
+
})
|
|
3539
|
+
})
|
|
3540
|
+
)
|
|
3541
|
+
})
|
|
3542
|
+
})
|
|
3543
|
+
]
|
|
3544
|
+
});
|
|
3545
|
+
var createBatchOutputsFormPlugin = (0, import_editor16.defineFormPluginCreator)({
|
|
3546
|
+
name: "batch-outputs-plugin",
|
|
3547
|
+
onSetupFormMeta({ mergeEffect }, { outputKey }) {
|
|
3548
|
+
mergeEffect({
|
|
3549
|
+
[outputKey]: provideBatchOutputsEffect
|
|
3550
|
+
});
|
|
3551
|
+
},
|
|
3552
|
+
onInit(ctx, { outputKey }) {
|
|
3553
|
+
const chainTransformService = ctx.node.getService(import_editor16.ScopeChainTransformService);
|
|
3554
|
+
const batchNodeType = ctx.node.flowNodeType;
|
|
3555
|
+
const transformerId = `${batchNodeType}-outputs`;
|
|
3556
|
+
if (chainTransformService.hasTransformer(transformerId)) {
|
|
3557
|
+
return;
|
|
3558
|
+
}
|
|
3559
|
+
chainTransformService.registerTransformer(transformerId, {
|
|
3560
|
+
transformCovers: (covers, ctx2) => {
|
|
3561
|
+
const node = ctx2.scope.meta?.node;
|
|
3562
|
+
if (node?.parent?.flowNodeType === batchNodeType) {
|
|
3563
|
+
return [...covers, (0, import_editor16.getNodeScope)(node.parent)];
|
|
3564
|
+
}
|
|
3565
|
+
return covers;
|
|
3566
|
+
},
|
|
3567
|
+
transformDeps(scopes, ctx2) {
|
|
3568
|
+
const scopeMeta = ctx2.scope.meta;
|
|
3569
|
+
if (scopeMeta?.type === import_editor16.FlowNodeScopeType.private) {
|
|
3570
|
+
return scopes;
|
|
3571
|
+
}
|
|
3572
|
+
const node = scopeMeta?.node;
|
|
3573
|
+
if (node?.flowNodeType === batchNodeType) {
|
|
3574
|
+
const childBlocks = node.blocks;
|
|
3575
|
+
return [
|
|
3576
|
+
(0, import_editor16.getNodePrivateScope)(node),
|
|
3577
|
+
...childBlocks.map((_childBlock) => (0, import_editor16.getNodeScope)(_childBlock))
|
|
3578
|
+
];
|
|
3579
|
+
}
|
|
3580
|
+
return scopes;
|
|
3581
|
+
}
|
|
3582
|
+
});
|
|
3583
|
+
}
|
|
3584
|
+
});
|
|
3585
|
+
|
|
3586
|
+
// src/form-plugins/infer-inputs-plugin/index.ts
|
|
3587
|
+
var import_lodash9 = require("lodash");
|
|
3588
|
+
var import_editor17 = require("@flowgram.ai/editor");
|
|
3589
|
+
var createInferInputsPlugin = (0, import_editor17.defineFormPluginCreator)({
|
|
3590
|
+
onSetupFormMeta({ addFormatOnSubmit }, { sourceKey, targetKey, scope }) {
|
|
3591
|
+
if (!sourceKey || !targetKey) {
|
|
3592
|
+
return;
|
|
3593
|
+
}
|
|
3594
|
+
addFormatOnSubmit((formData, ctx) => {
|
|
3595
|
+
(0, import_lodash9.set)(
|
|
3596
|
+
formData,
|
|
3597
|
+
targetKey,
|
|
3598
|
+
infer(
|
|
3599
|
+
(0, import_lodash9.get)(formData, sourceKey),
|
|
3600
|
+
scope === "private" ? (0, import_editor17.getNodePrivateScope)(ctx.node) : (0, import_editor17.getNodeScope)(ctx.node)
|
|
3601
|
+
)
|
|
3602
|
+
);
|
|
3603
|
+
return formData;
|
|
3604
|
+
});
|
|
3605
|
+
}
|
|
3606
|
+
});
|
|
3607
|
+
function isRef2(value) {
|
|
3608
|
+
return value?.type === "ref" && Array.isArray(value?.content) && typeof value?.content[0] === "string";
|
|
3609
|
+
}
|
|
3610
|
+
function isTemplate2(value) {
|
|
3611
|
+
return value?.type === "template" && typeof value?.content === "string";
|
|
3612
|
+
}
|
|
3613
|
+
function isConstant(value) {
|
|
3614
|
+
return value?.type === "constant" && typeof value?.content !== "undefined";
|
|
3615
|
+
}
|
|
3616
|
+
var infer = (values, scope) => {
|
|
3617
|
+
if (typeof values === "object") {
|
|
3618
|
+
if (isConstant(values)) {
|
|
3619
|
+
if (values?.schema) {
|
|
3620
|
+
return values.schema;
|
|
3621
|
+
}
|
|
3622
|
+
if (typeof values.content === "string") {
|
|
3623
|
+
return {
|
|
3624
|
+
type: "string"
|
|
3625
|
+
};
|
|
3626
|
+
}
|
|
3627
|
+
if (typeof values.content === "number") {
|
|
3628
|
+
return {
|
|
3629
|
+
type: "number"
|
|
3630
|
+
};
|
|
3631
|
+
}
|
|
3632
|
+
if (typeof values.content === "boolean") {
|
|
3633
|
+
return {
|
|
3634
|
+
type: "boolean"
|
|
3635
|
+
};
|
|
3636
|
+
}
|
|
3637
|
+
}
|
|
3638
|
+
if (isRef2(values)) {
|
|
3639
|
+
const variable = scope.available.getByKeyPath(values?.content);
|
|
3640
|
+
const schema = variable?.type ? JsonSchemaUtils.astToSchema(variable?.type) : void 0;
|
|
3641
|
+
return schema;
|
|
3642
|
+
}
|
|
3643
|
+
if (isTemplate2(values)) {
|
|
3644
|
+
return {
|
|
3645
|
+
type: "string"
|
|
3646
|
+
};
|
|
3647
|
+
}
|
|
3648
|
+
return {
|
|
3649
|
+
type: "object",
|
|
3650
|
+
properties: Object.keys(values).reduce((acc, key) => {
|
|
3651
|
+
const schema = infer(values[key], scope);
|
|
3652
|
+
if (schema) {
|
|
3653
|
+
acc[key] = schema;
|
|
3654
|
+
}
|
|
3655
|
+
return acc;
|
|
3656
|
+
}, {})
|
|
3657
|
+
};
|
|
3658
|
+
}
|
|
3659
|
+
};
|
|
3660
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
3661
|
+
0 && (module.exports = {
|
|
3662
|
+
ArrayIcons,
|
|
3663
|
+
BatchOutputs,
|
|
3664
|
+
BatchVariableSelector,
|
|
3665
|
+
CodeEditor,
|
|
3666
|
+
ConditionRow,
|
|
3667
|
+
ConstantInput,
|
|
3668
|
+
DynamicValueInput,
|
|
3669
|
+
InputsValues,
|
|
3670
|
+
JsonEditorWithVariables,
|
|
3671
|
+
JsonSchemaEditor,
|
|
3672
|
+
JsonSchemaUtils,
|
|
3673
|
+
PromptEditor,
|
|
3674
|
+
PromptEditorWithInputs,
|
|
3675
|
+
PromptEditorWithVariables,
|
|
3676
|
+
TypeSelector,
|
|
3677
|
+
VariableSelector,
|
|
3678
|
+
VariableTypeIcons,
|
|
3679
|
+
autoRenameRefEffect,
|
|
3680
|
+
createBatchOutputsFormPlugin,
|
|
3681
|
+
createInferInputsPlugin,
|
|
3682
|
+
formatLegacyRefOnInit,
|
|
3683
|
+
formatLegacyRefOnSubmit,
|
|
3684
|
+
formatLegacyRefToNewRef,
|
|
3685
|
+
formatNewRefToLegacyRef,
|
|
3686
|
+
getSchemaIcon,
|
|
3687
|
+
getTypeSelectValue,
|
|
3688
|
+
isLegacyFlowRefValueSchema,
|
|
3689
|
+
isNewFlowRefValueSchema,
|
|
3690
|
+
parseTypeSelectValue,
|
|
3691
|
+
provideBatchInputEffect,
|
|
3692
|
+
provideBatchOutputsEffect,
|
|
3693
|
+
provideJsonSchemaOutputs,
|
|
3694
|
+
syncVariableTitle,
|
|
3695
|
+
useVariableTree
|
|
3696
|
+
});
|
|
3697
|
+
//# sourceMappingURL=index.js.map
|