@blueking/bkflow-canvas-editor 1.1.0-beta.41 → 1.1.0-beta.42

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.
@@ -0,0 +1,234 @@
1
+ import { defineComponent as A, ref as V, shallowRef as x, computed as C, watch as U, resolveComponent as j, resolveDirective as K, openBlock as l, createBlock as f, createSlots as S, withCtx as y, withDirectives as G, createElementBlock as d, createElementVNode as i, createCommentVNode as v, Fragment as H, renderList as J, toDisplayString as B, unref as Y, createVNode as R, createTextVNode as E } from "vue";
2
+ import { c as _, u as z, i as M, b as Q, d as W, g as X, D as Z, B as ee, R as te, E as ae, _ as oe } from "./index-CrEOdHWn.js";
3
+ import "bkui-vue/lib/message";
4
+ import "bkui-vue/lib/icon";
5
+ import "monaco-editor";
6
+ const se = {
7
+ string: "input",
8
+ text: "input",
9
+ textarea: "textarea",
10
+ int: "input",
11
+ integer: "input",
12
+ number: "input",
13
+ float: "input",
14
+ json: "json",
15
+ object: "json",
16
+ array: "array",
17
+ list: "array",
18
+ select: "select",
19
+ time: "timepicker",
20
+ datetime: "timepicker"
21
+ }, L = (a) => a.replace(/^\$\{(.+)\}$/, "$1"), I = (a) => `\${${L(a)}}`;
22
+ function ne(a, c) {
23
+ const s = I(a.key), o = c ? _(c) : {}, p = a.custom_type ?? o.custom_type ?? se[a.type] ?? "input";
24
+ return {
25
+ ...o,
26
+ key: s,
27
+ name: a.name ?? o.name ?? L(a.key),
28
+ custom_type: p,
29
+ desc: o.desc ?? "",
30
+ index: o.index ?? 0,
31
+ show_type: "show",
32
+ source_info: o.source_info ?? {},
33
+ source_tag: o.source_tag ?? "",
34
+ source_type: o.source_type ?? "custom",
35
+ validation: o.validation ?? "",
36
+ value: a.default ?? o.value,
37
+ meta: {
38
+ ...o.meta ?? {},
39
+ required: a.required ?? o.meta?.required ?? !1
40
+ }
41
+ };
42
+ }
43
+ function le(a, c = {}) {
44
+ if (!a) return {};
45
+ const s = a.constants;
46
+ return s && Object.keys(s).length > 0 ? { ...s } : Array.isArray(a.fields) && a.fields.length > 0 ? a.fields.reduce((o, p) => {
47
+ const n = I(p.key);
48
+ return o[n] = ne(p, c[n]), o;
49
+ }, {}) : {};
50
+ }
51
+ const ie = { class: "global-debug-input" }, re = {
52
+ key: 0,
53
+ class: "global-debug-input__params",
54
+ "data-test": "input-params"
55
+ }, ue = { key: 0 }, de = ["title"], ce = { class: "col-value" }, pe = {
56
+ key: 1,
57
+ class: "global-debug-input__value"
58
+ }, me = {
59
+ key: 1,
60
+ class: "form-params-wrapper"
61
+ }, fe = { class: "sideslider-footer-buttons" }, ye = /* @__PURE__ */ A({
62
+ __name: "index",
63
+ props: {
64
+ show: { type: Boolean },
65
+ schema: {},
66
+ pipelineConstants: { default: () => ({}) },
67
+ initialValues: { default: () => ({}) },
68
+ pending: { type: Boolean, default: !1 },
69
+ readonly: { type: Boolean, default: !1 }
70
+ },
71
+ emits: ["confirm", "close", "update:show"],
72
+ setup(a, { emit: c }) {
73
+ const s = a, o = c, p = z(), n = V({}), b = x([]), m = x([]), g = x(!1), h = V(), k = V(), w = C(() => b.value.filter((e) => M(e))), O = C(() => w.value.length > 0 || m.value.length > 0), F = C(
74
+ () => [...b.value].sort((e, t) => (e.index ?? 0) - (t.index ?? 0)).map((e) => {
75
+ const t = Object.prototype.hasOwnProperty.call(n.value, e.key) ? n.value[e.key] : e.value;
76
+ return {
77
+ key: e.key,
78
+ name: e.name || e.key,
79
+ value: t,
80
+ display: W(t),
81
+ isComplex: Q(t)
82
+ };
83
+ })
84
+ );
85
+ U(
86
+ () => s.show,
87
+ (e) => {
88
+ e && (n.value = _(s.initialValues ?? {}), q());
89
+ }
90
+ );
91
+ const q = async () => {
92
+ const e = le(s.schema, s.pipelineConstants), t = Object.values(e).filter(
93
+ (r) => typeof r == "object" && r !== null && r.show_type === "show"
94
+ );
95
+ if (b.value = t, s.readonly || Object.keys(e).length < 1) {
96
+ m.value = [];
97
+ return;
98
+ }
99
+ g.value = !0;
100
+ try {
101
+ m.value = await X(p, e);
102
+ } catch (r) {
103
+ console.error("Failed to build debug input forms from schema:", r), m.value = [];
104
+ } finally {
105
+ g.value = !1;
106
+ }
107
+ }, N = (e) => {
108
+ n.value = { ...n.value, ..._(e) };
109
+ }, P = async () => {
110
+ const [e, t] = await Promise.all([
111
+ Promise.resolve(
112
+ typeof k.value?.validate == "function" ? k.value.validate() : !0
113
+ ),
114
+ Promise.resolve(typeof h.value?.validate == "function" ? h.value.validate() : !0)
115
+ ]);
116
+ !e || !t || o("confirm", _(n.value));
117
+ }, D = () => {
118
+ o("close"), o("update:show", !1);
119
+ };
120
+ return (e, t) => {
121
+ const r = j("bk-button"), T = j("bk-sideslider"), $ = K("bkloading");
122
+ return l(), f(T, {
123
+ title: "调试参数",
124
+ "is-show": s.show,
125
+ width: 960,
126
+ "quick-close": !0,
127
+ "esc-close": !1,
128
+ onClosed: D
129
+ }, S({
130
+ default: y(() => [
131
+ G((l(), d("div", ie, [
132
+ s.readonly ? (l(), d("table", re, [
133
+ t[2] || (t[2] = i("thead", null, [
134
+ i("tr", null, [
135
+ i("th", { class: "col-name" }, "参数名"),
136
+ i("th", { class: "col-value" }, "参数值")
137
+ ])
138
+ ], -1)),
139
+ i("tbody", null, [
140
+ F.value.length === 0 ? (l(), d("tr", ue, [...t[1] || (t[1] = [
141
+ i("td", {
142
+ class: "global-debug-input__empty",
143
+ colspan: "2"
144
+ }, "暂无参数", -1)
145
+ ])])) : v("", !0),
146
+ (l(!0), d(H, null, J(F.value, (u) => (l(), d("tr", {
147
+ key: u.key,
148
+ "data-test": "input-row"
149
+ }, [
150
+ i("td", {
151
+ class: "col-name",
152
+ title: u.key
153
+ }, B(u.name), 9, de),
154
+ i("td", ce, [
155
+ u.isComplex ? (l(), f(Z, {
156
+ key: 0,
157
+ value: u.value,
158
+ "data-test": "json-viewer"
159
+ }, null, 8, ["value"])) : (l(), d("pre", pe, B(u.display), 1))
160
+ ])
161
+ ]))), 128))
162
+ ])
163
+ ])) : (l(), d("div", me, [
164
+ w.value.length > 0 ? (l(), f(Y(ee), {
165
+ key: 0,
166
+ ref_key: "builtinVariableFormRef",
167
+ ref: k,
168
+ modelValue: n.value,
169
+ "onUpdate:modelValue": t[0] || (t[0] = (u) => n.value = u),
170
+ variables: w.value
171
+ }, null, 8, ["modelValue", "variables"])) : v("", !0),
172
+ m.value.length > 0 ? (l(), f(te, {
173
+ key: 1,
174
+ ref_key: "renderFormRef",
175
+ ref: h,
176
+ scheme: m.value,
177
+ editable: "",
178
+ "form-option": {
179
+ showRequired: !0,
180
+ showGroup: !0,
181
+ showLabel: !1,
182
+ showHook: !1,
183
+ showDesc: !0,
184
+ formEdit: !0
185
+ },
186
+ "form-data": n.value,
187
+ onChange: N
188
+ }, null, 8, ["scheme", "form-data"])) : v("", !0),
189
+ O.value ? v("", !0) : (l(), f(ae, {
190
+ key: 2,
191
+ title: "暂无参数"
192
+ }))
193
+ ]))
194
+ ])), [
195
+ [$, { loading: g.value }]
196
+ ])
197
+ ]),
198
+ _: 2
199
+ }, [
200
+ s.readonly ? void 0 : {
201
+ name: "footer",
202
+ fn: y(() => [
203
+ i("div", fe, [
204
+ R(r, {
205
+ theme: "primary",
206
+ "data-test": "save-and-run",
207
+ loading: s.pending,
208
+ onClick: P
209
+ }, {
210
+ default: y(() => [...t[3] || (t[3] = [
211
+ E(" 保存并执行 ", -1)
212
+ ])]),
213
+ _: 1
214
+ }, 8, ["loading"]),
215
+ R(r, {
216
+ disabled: s.pending,
217
+ onClick: D
218
+ }, {
219
+ default: y(() => [...t[4] || (t[4] = [
220
+ E("取消", -1)
221
+ ])]),
222
+ _: 1
223
+ }, 8, ["disabled"])
224
+ ])
225
+ ]),
226
+ key: "0"
227
+ }
228
+ ]), 1032, ["is-show"]);
229
+ };
230
+ }
231
+ }), ke = /* @__PURE__ */ oe(ye, [["__scopeId", "data-v-01a33593"]]);
232
+ export {
233
+ ke as default
234
+ };