@bonsae/nrg 0.21.2 → 0.22.0

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.
Files changed (40) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +2 -3
  3. package/package.json +14 -9
  4. package/schemas/labels.schema.json +15 -5
  5. package/server/index.cjs +2 -1358
  6. package/test/client/component/index.js +41 -224
  7. package/test/client/component/setup.js +201 -1475
  8. package/test/client/e2e/config.js +12 -0
  9. package/test/client/e2e/index.js +419 -199
  10. package/test/client/unit/index.js +19 -32
  11. package/test/client/unit/setup.js +28 -21
  12. package/test/server/integration/index.js +2 -26
  13. package/test/server/unit/index.js +2 -184
  14. package/types/client.d.ts +1 -266
  15. package/types/server.d.ts +1 -900
  16. package/types/test-client-component.d.ts +7 -143
  17. package/types/test-client-e2e.d.ts +0 -6
  18. package/types/test-client-unit.d.ts +11 -105
  19. package/types/test-server-integration.d.ts +73 -49
  20. package/types/test-server-unit.d.ts +26 -2
  21. package/types/vite.d.ts +2 -0
  22. package/vite/index.js +378 -150
  23. package/server/resources/nrg-client.js +0 -7493
  24. package/test/client/component/nrg.css +0 -1
  25. package/types/shims/brands.d.ts +0 -32
  26. package/types/shims/client/form/components/node-red-config-input.vue.d.ts +0 -125
  27. package/types/shims/client/form/components/node-red-editor-input.vue.d.ts +0 -124
  28. package/types/shims/client/form/components/node-red-input-label.vue.d.ts +0 -34
  29. package/types/shims/client/form/components/node-red-input.vue.d.ts +0 -123
  30. package/types/shims/client/form/components/node-red-json-schema-form.vue.d.ts +0 -772
  31. package/types/shims/client/form/components/node-red-select-input.vue.d.ts +0 -132
  32. package/types/shims/client/form/components/node-red-toggle.vue.d.ts +0 -36
  33. package/types/shims/client/form/components/node-red-typed-input.vue.d.ts +0 -151
  34. package/types/shims/client/globals.d.ts +0 -320
  35. package/types/shims/client/types.d.ts +0 -227
  36. package/types/shims/components.d.ts +0 -23
  37. package/types/shims/constants.d.ts +0 -4
  38. package/types/shims/schema-options.d.ts +0 -24
  39. package/types/shims/shims-vue.d.ts +0 -5
  40. package/types/shims/typebox.d.ts +0 -10
@@ -1,63 +1,63 @@
1
- import { beforeEach as z } from "vitest";
2
- import { config as O } from "vitest-browser-vue";
3
- import { defineComponent as V, openBlock as l, createElementBlock as c, normalizeClass as N, createCommentVNode as f, renderSlot as w, createTextVNode as D, toDisplayString as T, resolveComponent as g, createBlock as v, createElementVNode as m, shallowRef as q, withDirectives as H, vShow as J, Teleport as K, Fragment as _, renderList as L, createVNode as R } from "vue";
4
- function j() {
5
- const e = {
6
- get(t) {
7
- return e[t];
8
- },
9
- set(t, n) {
10
- return e[t] = n, n;
11
- },
12
- remove(t) {
13
- const n = e[t];
14
- return delete e[t], n;
1
+ import { config as h } from "vitest-browser-vue";
2
+ import { NodeRedJsonSchemaForm as E, NodeRedEditorInput as S, NodeRedSelectInput as I, NodeRedConfigInput as v, NodeRedTypedInput as T, NodeRedInput as k, NodeRedToggle as w, NodeRedInputLabel as M } from "@bonsae/nrg-runtime/internal/client/components";
3
+ import { beforeEach as L } from "vitest";
4
+ function m() {
5
+ const t = {
6
+ get(r) {
7
+ return t[r];
8
+ },
9
+ set(r, s) {
10
+ return t[r] = s, s;
11
+ },
12
+ remove(r) {
13
+ const s = t[r];
14
+ return delete t[r], s;
15
15
  }
16
16
  };
17
- return e;
17
+ return t;
18
18
  }
19
- function Y(e, t) {
20
- if (e === t) return !0;
21
- const n = e.split("/"), r = t.split("/");
22
- for (let s = 0; s < n.length; s++) {
23
- if (n[s] === "#") return !0;
24
- if (s >= r.length || n[s] !== "+" && n[s] !== r[s]) return !1;
19
+ function R(t, r) {
20
+ if (t === r) return !0;
21
+ const s = t.split("/"), n = r.split("/");
22
+ for (let o = 0; o < s.length; o++) {
23
+ if (s[o] === "#") return !0;
24
+ if (o >= n.length || s[o] !== "+" && s[o] !== n[o]) return !1;
25
25
  }
26
- return n.length === r.length;
26
+ return s.length === n.length;
27
27
  }
28
- function Q(e) {
29
- var t;
30
- (t = e.__reset) == null || t.call(e);
28
+ function _(t) {
29
+ var r;
30
+ (r = t.__reset) == null || r.call(t);
31
31
  }
32
- function Z() {
33
- const e = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Map(), n = [], r = {}, s = [];
34
- let d = !1, a = 0;
35
- const h = () => {
36
- const i = {
32
+ function N() {
33
+ const t = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map(), s = [], n = {}, o = [];
34
+ let c = !1, l = 0;
35
+ const b = () => {
36
+ const e = {
37
37
  element: null,
38
- open: () => i,
39
- close: () => i,
40
- setContent: () => i,
38
+ open: () => e,
39
+ close: () => e,
40
+ setContent: () => e,
41
41
  move: () => {
42
42
  }
43
43
  };
44
- return i;
45
- }, b = {
46
- _: (i) => i,
44
+ return e;
45
+ }, y = {
46
+ _: (e) => e,
47
47
  editor: {
48
- createEditor(i) {
49
- let u = (i == null ? void 0 : i.value) || "";
50
- const y = {}, I = {
51
- on(o, p) {
52
- (y[o] ?? (y[o] = [])).push(p);
48
+ createEditor(e) {
49
+ let i = (e == null ? void 0 : e.value) || "";
50
+ const u = {}, f = {
51
+ on(d, p) {
52
+ (u[d] ?? (u[d] = [])).push(p);
53
53
  }
54
54
  };
55
55
  return {
56
- getValue: () => u,
57
- setValue: (o) => {
58
- u = o, (y.change ?? []).forEach((p) => p());
56
+ getValue: () => i,
57
+ setValue: (d) => {
58
+ i = d, (u.change ?? []).forEach((p) => p());
59
59
  },
60
- getSession: () => I,
60
+ getSession: () => f,
61
61
  focus: () => {
62
62
  },
63
63
  destroy: () => {
@@ -79,13 +79,13 @@ function Z() {
79
79
  }
80
80
  },
81
81
  popover: {
82
- create: () => h(),
82
+ create: () => b(),
83
83
  tooltip: () => {
84
- const i = {
84
+ const e = {
85
85
  element: null,
86
- open: () => i,
87
- close: () => i,
88
- setContent: () => i,
86
+ open: () => e,
87
+ close: () => e,
88
+ setContent: () => e,
89
89
  move: () => {
90
90
  },
91
91
  delete: () => {
@@ -93,91 +93,91 @@ function Z() {
93
93
  setAction: () => {
94
94
  }
95
95
  };
96
- return i;
96
+ return e;
97
97
  }
98
98
  },
99
99
  nodes: {
100
- registerType(i, u) {
101
- t.set(i, u);
100
+ registerType(e, i) {
101
+ r.set(e, i);
102
102
  },
103
- getType(i) {
104
- return t.get(i) ?? null;
103
+ getType(e) {
104
+ return r.get(e) ?? null;
105
105
  },
106
- node(i) {
107
- return e.get(i) ?? null;
106
+ node(e) {
107
+ return t.get(e) ?? null;
108
108
  },
109
- add(i) {
110
- return e.set(i.id, i), i;
109
+ add(e) {
110
+ return t.set(e.id, e), e;
111
111
  },
112
- remove(i) {
113
- const u = e.get(i);
114
- return e.delete(i), { links: [], nodes: u ? [u] : [] };
112
+ remove(e) {
113
+ const i = t.get(e);
114
+ return t.delete(e), { links: [], nodes: i ? [i] : [] };
115
115
  },
116
116
  clear() {
117
- e.clear();
117
+ t.clear();
118
118
  },
119
119
  // The mock keeps a single registry: eachNode and eachConfig iterate the
120
120
  // same entries. Register whatever your component expects to find.
121
- eachNode(i) {
122
- for (const u of e.values())
123
- if (i(u) === !1) break;
121
+ eachNode(e) {
122
+ for (const i of t.values())
123
+ if (e(i) === !1) break;
124
124
  },
125
- eachConfig(i) {
126
- for (const u of e.values())
127
- if (i(u) === !1) break;
125
+ eachConfig(e) {
126
+ for (const i of t.values())
127
+ if (e(i) === !1) break;
128
128
  },
129
- filterNodes(i) {
130
- return [...e.values()].filter(
131
- (u) => (i.type === void 0 || u.type === i.type) && (i.z === void 0 || u.z === i.z)
129
+ filterNodes(e) {
130
+ return [...t.values()].filter(
131
+ (i) => (e.type === void 0 || i.type === e.type) && (e.z === void 0 || i.z === e.z)
132
132
  );
133
133
  },
134
- filterLinks(i) {
135
- return n.filter(
136
- (u) => {
137
- var y, I, o, p;
138
- return (i.source === void 0 || u.source === i.source || ((y = u.source) == null ? void 0 : y.id) === ((I = i.source) == null ? void 0 : I.id)) && (i.target === void 0 || u.target === i.target || ((o = u.target) == null ? void 0 : o.id) === ((p = i.target) == null ? void 0 : p.id));
134
+ filterLinks(e) {
135
+ return s.filter(
136
+ (i) => {
137
+ var u, f, d, p;
138
+ return (e.source === void 0 || i.source === e.source || ((u = i.source) == null ? void 0 : u.id) === ((f = e.source) == null ? void 0 : f.id)) && (e.target === void 0 || i.target === e.target || ((d = i.target) == null ? void 0 : d.id) === ((p = e.target) == null ? void 0 : p.id));
139
139
  }
140
140
  );
141
141
  },
142
- addLink(i) {
143
- n.push(i);
142
+ addLink(e) {
143
+ s.push(e);
144
144
  },
145
- dirty(i) {
146
- if (i === void 0) return d;
147
- d = i;
145
+ dirty(e) {
146
+ if (e === void 0) return c;
147
+ c = e;
148
148
  },
149
149
  id() {
150
- return (++a).toString(16).padStart(16, "0");
150
+ return (++l).toString(16).padStart(16, "0");
151
151
  }
152
152
  },
153
153
  events: {
154
- on(i, u) {
155
- (r[i] ?? (r[i] = [])).push(u);
154
+ on(e, i) {
155
+ (n[e] ?? (n[e] = [])).push(i);
156
156
  },
157
- off(i, u) {
158
- r[i] && (u ? r[i] = r[i].filter(
159
- (y) => y !== u
160
- ) : delete r[i]);
157
+ off(e, i) {
158
+ n[e] && (i ? n[e] = n[e].filter(
159
+ (u) => u !== i
160
+ ) : delete n[e]);
161
161
  },
162
- emit(i, ...u) {
163
- [...r[i] ?? []].forEach((y) => y(...u));
162
+ emit(e, ...i) {
163
+ [...n[e] ?? []].forEach((u) => u(...i));
164
164
  }
165
165
  },
166
166
  comms: {
167
- subscribe(i, u) {
168
- s.push({ topic: i, callback: u });
167
+ subscribe(e, i) {
168
+ o.push({ topic: e, callback: i });
169
169
  },
170
- unsubscribe(i, u) {
171
- const y = s.findIndex(
172
- (I) => I.topic === i && I.callback === u
170
+ unsubscribe(e, i) {
171
+ const u = o.findIndex(
172
+ (f) => f.topic === e && f.callback === i
173
173
  );
174
- y !== -1 && s.splice(y, 1);
174
+ u !== -1 && o.splice(u, 1);
175
175
  },
176
- publish(i, u) {
177
- [...s].filter((y) => Y(y.topic, i)).forEach((y) => y.callback(i, u));
176
+ publish(e, i) {
177
+ [...o].filter((u) => R(u.topic, e)).forEach((u) => u.callback(e, i));
178
178
  }
179
179
  },
180
- settings: j(),
180
+ settings: m(),
181
181
  notify: () => ({
182
182
  update: () => {
183
183
  },
@@ -185,1427 +185,153 @@ function Z() {
185
185
  }
186
186
  })
187
187
  };
188
- return Object.defineProperty(b, "__reset", {
188
+ return Object.defineProperty(y, "__reset", {
189
189
  enumerable: !1,
190
190
  value: () => {
191
- e.clear(), t.clear(), n.length = 0;
192
- for (const i of Object.keys(r))
193
- delete r[i];
194
- s.length = 0, d = !1, b.settings = j();
191
+ t.clear(), r.clear(), s.length = 0;
192
+ for (const e of Object.keys(n))
193
+ delete n[e];
194
+ o.length = 0, c = !1, y.settings = m();
195
195
  }
196
- }), b;
196
+ }), y;
197
197
  }
198
- function G(e) {
199
- return e && !e.__jqState && (e.__jqState = {
200
- typedInput: { value: "", type: "" },
201
- listeners: {}
202
- }), e ? e.__jqState : { typedInput: { value: "", type: "" }, listeners: {} };
198
+ function g() {
199
+ return { typedInput: { value: "", type: "" }, listeners: {} };
203
200
  }
204
- function S(e) {
205
- const t = G(e), n = {
206
- 0: e,
207
- length: e ? 1 : 0,
208
- typedInput(r, s) {
209
- if (typeof r == "object")
210
- return t.typedInput = {
201
+ function C(t) {
202
+ return t && !t.__jqState && (t.__jqState = g()), t ? t.__jqState : g();
203
+ }
204
+ function a(t) {
205
+ const r = C(t), s = {
206
+ 0: t,
207
+ length: t ? 1 : 0,
208
+ typedInput(n, o) {
209
+ if (typeof n == "object")
210
+ return r.typedInput = {
211
211
  value: "",
212
- type: r.default || "",
213
- types: r.types
214
- }, n;
215
- if (r === "value") {
216
- if (s !== void 0) {
217
- t.typedInput.value = String(s), e && e.setAttribute("value", String(s));
212
+ type: n.default || "",
213
+ types: n.types
214
+ }, s;
215
+ if (n === "value") {
216
+ if (o !== void 0) {
217
+ r.typedInput.value = String(o), t && t.setAttribute("value", String(o));
218
218
  return;
219
219
  }
220
- return t.typedInput.value;
220
+ return r.typedInput.value;
221
221
  }
222
- if (r === "type") {
223
- if (s !== void 0) {
224
- t.typedInput.type = String(s);
222
+ if (n === "type") {
223
+ if (o !== void 0) {
224
+ r.typedInput.type = String(o);
225
225
  return;
226
226
  }
227
- return t.typedInput.type;
227
+ return r.typedInput.type;
228
228
  }
229
- if (r === "types") {
230
- t.typedInput.types = s;
229
+ if (n === "types") {
230
+ r.typedInput.types = o;
231
231
  return;
232
232
  }
233
- if (r === "validate")
233
+ if (n === "validate")
234
234
  return !0;
235
- if (r === "disable") {
236
- t.typedInput.disabled = s !== !1;
235
+ if (n === "disable") {
236
+ r.typedInput.disabled = o !== !1;
237
237
  return;
238
238
  }
239
- if (r === "enable") {
240
- t.typedInput.disabled = !1;
239
+ if (n === "enable") {
240
+ r.typedInput.disabled = !1;
241
241
  return;
242
242
  }
243
- if (r === "hide") {
244
- t.typedInput.hidden = !0;
243
+ if (n === "hide") {
244
+ r.typedInput.hidden = !0;
245
245
  return;
246
246
  }
247
- if (r === "show") {
248
- t.typedInput.hidden = !1;
247
+ if (n === "show") {
248
+ r.typedInput.hidden = !1;
249
249
  return;
250
250
  }
251
- if (r === "width") {
252
- t.typedInput.width = s;
251
+ if (n === "width") {
252
+ r.typedInput.width = o;
253
253
  return;
254
254
  }
255
- if (r !== "focus")
256
- return n;
255
+ if (n !== "focus")
256
+ return s;
257
257
  },
258
- on(r, s) {
259
- return t.listeners[r] || (t.listeners[r] = []), t.listeners[r].push(s), n;
258
+ on(n, o) {
259
+ return r.listeners[n] || (r.listeners[n] = []), r.listeners[n].push(o), s;
260
260
  },
261
- off(r) {
262
- if (r)
263
- delete t.listeners[r];
261
+ off(n) {
262
+ if (n)
263
+ delete r.listeners[n];
264
264
  else
265
- for (const s of Object.keys(t.listeners))
266
- delete t.listeners[s];
267
- return n;
265
+ for (const o of Object.keys(r.listeners))
266
+ delete r.listeners[o];
267
+ return s;
268
268
  },
269
- val(r) {
270
- return r !== void 0 ? ((e instanceof HTMLInputElement || e instanceof HTMLSelectElement || e instanceof HTMLTextAreaElement) && (e.value = String(r)), n) : e instanceof HTMLInputElement || e instanceof HTMLSelectElement || e instanceof HTMLTextAreaElement ? e.value : "";
269
+ val(n) {
270
+ return n !== void 0 ? ((t instanceof HTMLInputElement || t instanceof HTMLSelectElement || t instanceof HTMLTextAreaElement) && (t.value = String(n)), s) : t instanceof HTMLInputElement || t instanceof HTMLSelectElement || t instanceof HTMLTextAreaElement ? t.value : "";
271
271
  },
272
- find(r) {
273
- return S((e == null ? void 0 : e.querySelector(r)) ?? null);
272
+ find(n) {
273
+ return a((t == null ? void 0 : t.querySelector(n)) ?? null);
274
274
  },
275
- append(r) {
276
- const s = (r == null ? void 0 : r[0]) || r;
277
- return e && s instanceof Element && e.appendChild(s), n;
275
+ append(n) {
276
+ const o = (n == null ? void 0 : n[0]) || n;
277
+ return t && o instanceof Element && t.appendChild(o), s;
278
278
  },
279
- appendTo(r) {
280
- const s = (r == null ? void 0 : r[0]) || r;
281
- return s instanceof Element && e && s.appendChild(e), n;
279
+ appendTo(n) {
280
+ const o = (n == null ? void 0 : n[0]) || n;
281
+ return o instanceof Element && t && o.appendChild(t), s;
282
282
  },
283
- html(r) {
284
- return e && (e.innerHTML = r), n;
283
+ html(n) {
284
+ return t && (t.innerHTML = n), s;
285
285
  },
286
286
  empty() {
287
- return e && (e.innerHTML = ""), n;
287
+ return t && (t.innerHTML = ""), s;
288
288
  },
289
289
  i18n() {
290
- return n;
290
+ return s;
291
291
  },
292
- addClass(r) {
293
- return e == null || e.classList.add(r), n;
292
+ addClass(n) {
293
+ return t == null || t.classList.add(n), s;
294
294
  },
295
- removeClass(r) {
296
- return e == null || e.classList.remove(r), n;
295
+ removeClass(n) {
296
+ return t == null || t.classList.remove(n), s;
297
297
  },
298
- __trigger(r) {
299
- (t.listeners[r] || []).forEach((s) => s());
298
+ __trigger(n) {
299
+ (r.listeners[n] || []).forEach((o) => o());
300
300
  }
301
301
  };
302
- return n;
302
+ return s;
303
303
  }
304
- function X() {
305
- return function(t, n) {
306
- if (typeof t == "string") {
307
- if (t.trim().startsWith("<")) {
308
- const r = document.createElement("template");
309
- r.innerHTML = t.trim();
310
- const s = r.content.firstElementChild;
311
- if (s && n)
312
- for (const [d, a] of Object.entries(n))
313
- d === "html" ? s.innerHTML = String(a) : s.setAttribute(d, String(a));
314
- return S(s);
304
+ function j() {
305
+ return function(r, s) {
306
+ if (typeof r == "string") {
307
+ if (r.trim().startsWith("<")) {
308
+ const n = document.createElement("template");
309
+ n.innerHTML = r.trim();
310
+ const o = n.content.firstElementChild;
311
+ if (o && s)
312
+ for (const [c, l] of Object.entries(s))
313
+ c === "html" ? o.innerHTML = String(l) : o.setAttribute(c, String(l));
314
+ return a(o);
315
315
  }
316
- return S(document.querySelector(t));
316
+ return a(document.querySelector(r));
317
317
  }
318
- return t instanceof Element || t && typeof t == "object" && t.nodeType ? S(t) : S(null);
318
+ return r instanceof Element || r && typeof r == "object" && r.nodeType ? a(r) : a(null);
319
319
  };
320
320
  }
321
- const x = V({
322
- name: "NodeRedInputLabel",
323
- props: {
324
- label: {
325
- type: String,
326
- default: ""
327
- },
328
- icon: {
329
- type: String,
330
- default: ""
331
- },
332
- required: {
333
- type: Boolean,
334
- default: !1
335
- }
336
- },
337
- computed: {
338
- iconClass() {
339
- return this.icon ? `fa ${this.icon.startsWith("fa-") ? this.icon : `fa-${this.icon}`}` : "";
340
- }
341
- }
342
- }), E = (e, t) => {
343
- const n = e.__vccOpts || e;
344
- for (const [r, s] of t)
345
- n[r] = s;
346
- return n;
347
- }, ee = { class: "nrg-label" }, te = {
348
- key: 1,
349
- class: "nrg-required"
350
- };
351
- function ne(e, t, n, r, s, d) {
352
- return l(), c("span", ee, [
353
- e.icon ? (l(), c(
354
- "i",
355
- {
356
- key: 0,
357
- class: N(e.iconClass)
358
- },
359
- null,
360
- 2
361
- /* CLASS */
362
- )) : f("v-if", !0),
363
- w(e.$slots, "default", {}, () => [
364
- D(
365
- T(e.label),
366
- 1
367
- /* TEXT */
368
- )
369
- ], !0),
370
- e.required ? (l(), c("span", te, "*")) : f("v-if", !0)
371
- ]);
372
- }
373
- const k = /* @__PURE__ */ E(x, [["render", ne], ["__scopeId", "data-v-864b02f2"]]), C = "*************", re = V({
374
- components: { NodeRedInputLabel: k },
375
- props: {
376
- modelValue: {
377
- type: [String, Number],
378
- default: void 0
379
- },
380
- value: {
381
- type: [String, Number],
382
- default: ""
383
- },
384
- type: {
385
- type: String,
386
- default: "text"
387
- },
388
- placeholder: {
389
- type: String,
390
- default: ""
391
- },
392
- label: {
393
- type: String,
394
- default: ""
395
- },
396
- icon: {
397
- type: String,
398
- default: ""
399
- },
400
- required: {
401
- type: Boolean,
402
- default: !1
403
- },
404
- error: {
405
- type: String,
406
- default: ""
407
- }
408
- },
409
- emits: ["update:modelValue", "update:value", "input"],
410
- data() {
411
- return {
412
- internalValue: ""
413
- };
414
- },
415
- computed: {
416
- effectiveValue() {
417
- return this.modelValue !== void 0 ? this.modelValue : this.value;
418
- }
419
- },
420
- beforeMount() {
421
- this.internalValue = this.effectiveValue, this.onBlur();
422
- },
423
- methods: {
424
- onInput(e) {
425
- this.internalValue = e.target.value, this.$emit("update:modelValue", this.internalValue), this.$emit("update:value", this.internalValue), this.$emit("input", this.internalValue);
426
- },
427
- onFocus() {
428
- this.type === "password" && this.internalValue === C && (this.internalValue = "");
429
- },
430
- onBlur() {
431
- this.type === "password" && this.effectiveValue === "__PWD__" && (this.internalValue = C);
432
- }
433
- }
434
- }), oe = { style: { display: "flex", "flex-direction": "column", width: "100%" } }, ie = ["type", "value", "placeholder"], se = {
435
- key: 0,
436
- class: "node-red-vue-input-error-message"
437
- };
438
- function ae(e, t, n, r, s, d) {
439
- const a = g("NodeRedInputLabel");
440
- return l(), c("div", oe, [
441
- w(e.$slots, "label", {}, () => [
442
- e.label ? (l(), v(a, {
443
- key: 0,
444
- label: e.label,
445
- icon: e.icon,
446
- required: e.required
447
- }, null, 8, ["label", "icon", "required"])) : f("v-if", !0)
448
- ]),
449
- m("input", {
450
- ref: "inputField",
451
- type: e.type,
452
- value: e.internalValue,
453
- placeholder: e.placeholder,
454
- style: { width: "100%" },
455
- onInput: t[0] || (t[0] = (...h) => e.onInput && e.onInput(...h)),
456
- onFocus: t[1] || (t[1] = (...h) => e.onFocus && e.onFocus(...h)),
457
- onBlur: t[2] || (t[2] = (...h) => e.onBlur && e.onBlur(...h))
458
- }, null, 40, ie),
459
- e.error ? (l(), c(
460
- "div",
461
- se,
462
- T(e.error),
463
- 1
464
- /* TEXT */
465
- )) : f("v-if", !0)
466
- ]);
467
- }
468
- const W = /* @__PURE__ */ E(re, [["render", ae]]), le = [
469
- "msg",
470
- "flow",
471
- "global",
472
- "str",
473
- "num",
474
- "bool",
475
- "json",
476
- "bin",
477
- "re",
478
- "jsonata",
479
- "date",
480
- "env",
481
- "node",
482
- "cred"
483
- ], ue = ["errorPort", "completePort", "statusPort"], de = V({
484
- components: { NodeRedInputLabel: k },
485
- props: {
486
- modelValue: {
487
- type: Object,
488
- default: void 0,
489
- validator: function(e) {
490
- if (e === void 0) return !0;
491
- if (typeof e != "object" || e === null)
492
- return console.warn(
493
- "[WARN] Invalid modelValue for TypedInput. It must be an object."
494
- ), !1;
495
- const t = typeof e.value == "string" && typeof e.type == "string";
496
- return t || console.warn(
497
- "[WARN] Invalid modelValue for TypedInput. It must be an object with 'value' and 'type' properties being strings.",
498
- e
499
- ), t;
500
- }
501
- },
502
- value: {
503
- type: Object,
504
- default: void 0,
505
- validator: function(e) {
506
- if (e === void 0) return !0;
507
- if (typeof e != "object" || e === null)
508
- return console.warn(
509
- "[WARN] Invalid value for TypedInput. It must be an object."
510
- ), !1;
511
- const t = typeof e.value == "string" && typeof e.type == "string";
512
- return t || console.warn(
513
- "[WARN] Invalid value for TypedInput. It must be an object with 'value' and 'type' properties being strings.",
514
- e
515
- ), t;
516
- }
517
- },
518
- types: {
519
- type: Array,
520
- default: () => le
521
- },
522
- label: {
523
- type: String,
524
- default: ""
525
- },
526
- icon: {
527
- type: String,
528
- default: ""
529
- },
530
- required: {
531
- type: Boolean,
532
- default: !1
533
- },
534
- error: {
535
- type: String,
536
- default: ""
537
- }
538
- },
539
- emits: ["update:modelValue", "update:value"],
540
- setup() {
541
- return {
542
- inputWidget: q(null),
543
- mutationObserver: q(null)
544
- };
545
- },
546
- computed: {
547
- effectiveValue() {
548
- return this.modelValue !== void 0 ? this.modelValue : this.value;
549
- },
550
- isProvidedValueTypeValid() {
551
- const e = this.effectiveValue.type;
552
- return this.types.includes(e);
553
- }
554
- },
555
- watch: {
556
- isProvidedValueTypeValid: {
557
- handler(e) {
558
- e || console.warn(
559
- `Validation failed: type (${this.effectiveValue.type}) must be one of the provided types (${this.types}).`
560
- );
561
- },
562
- immediate: !0
563
- },
564
- error(e) {
565
- this.$nextTick(() => {
566
- const t = this.$el.querySelector(
567
- ".red-ui-typedInput-container"
568
- );
569
- t && (e ? t.classList.add("input-error") : t.classList.remove("input-error"));
570
- });
571
- }
572
- },
573
- mounted() {
574
- const e = this.$refs.typedInput;
575
- this.inputWidget = $(e), this.inputWidget.typedInput({
576
- default: this.effectiveValue.type || this.types[0],
577
- types: this.types
578
- }), this.inputWidget.typedInput("value", this.effectiveValue.value || ""), this.inputWidget.typedInput(
579
- "type",
580
- this.effectiveValue.type || this.types[0]
581
- ), this.$nextTick(() => {
582
- const t = new MutationObserver((n) => {
583
- for (const r of n)
584
- r.attributeName === "value" && this.onChange();
585
- });
586
- t.observe(e, {
587
- attributes: !0,
588
- attributeFilter: ["value"]
589
- }), this.mutationObserver = t;
590
- }), this.inputWidget.on("change", () => {
591
- this.onChange();
592
- });
593
- },
594
- beforeUnmount() {
595
- this.mutationObserver && (this.mutationObserver.disconnect(), this.mutationObserver = null);
596
- },
597
- methods: {
598
- onChange() {
599
- const e = this.inputWidget.typedInput("value"), t = this.inputWidget.typedInput("type");
600
- if (this.effectiveValue.value !== e || this.effectiveValue.type !== t) {
601
- const n = { value: e, type: t };
602
- this.$emit("update:modelValue", n), this.$emit("update:value", n);
603
- }
604
- }
605
- }
606
- }), pe = { style: { display: "flex", "flex-direction": "column", width: "100%" } }, ce = {
607
- ref: "typedInput",
608
- type: "text",
609
- class: "node-red-typed-input",
610
- style: { flex: "1", width: "100%" }
611
- }, ye = {
612
- key: 0,
613
- class: "node-red-vue-input-error-message"
614
- };
615
- function fe(e, t, n, r, s, d) {
616
- const a = g("NodeRedInputLabel");
617
- return l(), c("div", pe, [
618
- w(e.$slots, "label", {}, () => [
619
- e.label ? (l(), v(a, {
620
- key: 0,
621
- label: e.label,
622
- icon: e.icon,
623
- required: e.required
624
- }, null, 8, ["label", "icon", "required"])) : f("v-if", !0)
625
- ]),
626
- m(
627
- "input",
628
- ce,
629
- null,
630
- 512
631
- /* NEED_PATCH */
632
- ),
633
- e.error ? (l(), c(
634
- "div",
635
- ye,
636
- T(e.error),
637
- 1
638
- /* TEXT */
639
- )) : f("v-if", !0)
640
- ]);
641
- }
642
- const B = /* @__PURE__ */ E(de, [["render", fe]]), me = V({
643
- components: { NodeRedInputLabel: k },
644
- props: {
645
- modelValue: {
646
- type: String,
647
- default: void 0
648
- },
649
- value: {
650
- type: String,
651
- default: ""
652
- },
653
- type: {
654
- type: String,
655
- required: !0
656
- },
657
- node: {
658
- type: Object,
659
- required: !0
660
- },
661
- propName: {
662
- type: String,
663
- required: !0
664
- },
665
- label: {
666
- type: String,
667
- default: ""
668
- },
669
- icon: {
670
- type: String,
671
- default: ""
672
- },
673
- required: {
674
- type: Boolean,
675
- default: !1
676
- },
677
- error: {
678
- type: String,
679
- default: ""
680
- }
681
- },
682
- emits: ["update:modelValue", "update:value"],
683
- setup() {
684
- return {
685
- jqInput: q(null)
686
- };
687
- },
688
- computed: {
689
- inputId() {
690
- return "node-input-" + this.propName;
691
- },
692
- effectiveValue() {
693
- return this.modelValue !== void 0 ? this.modelValue : this.value;
694
- }
695
- },
696
- mounted() {
697
- RED.editor.prepareConfigNodeSelect(
698
- this.node,
699
- this.propName,
700
- this.type,
701
- "node-input"
702
- );
703
- const e = $("#" + this.inputId);
704
- this.jqInput = e, e.on("change", () => {
705
- const t = e.val(), n = t === "_ADD_" ? "" : t;
706
- this.$emit("update:modelValue", n), this.$emit("update:value", n);
707
- }), e.val(this.effectiveValue || "_ADD_");
708
- },
709
- beforeUnmount() {
710
- this.jqInput && (this.jqInput.off("change"), this.jqInput = null);
711
- }
712
- }), he = { style: { display: "flex", "flex-direction": "column", width: "100%" } }, ge = ["id"], ve = {
713
- key: 0,
714
- class: "node-red-vue-input-error-message"
715
- };
716
- function be(e, t, n, r, s, d) {
717
- const a = g("NodeRedInputLabel");
718
- return l(), c("div", he, [
719
- w(e.$slots, "label", {}, () => [
720
- e.label ? (l(), v(a, {
721
- key: 0,
722
- label: e.label,
723
- icon: e.icon,
724
- required: e.required
725
- }, null, 8, ["label", "icon", "required"])) : f("v-if", !0)
726
- ]),
727
- m("input", {
728
- id: e.inputId,
729
- type: "text",
730
- style: { width: "100%" }
731
- }, null, 8, ge),
732
- e.error ? (l(), c(
733
- "div",
734
- ve,
735
- T(e.error),
736
- 1
737
- /* TEXT */
738
- )) : f("v-if", !0)
739
- ]);
740
- }
741
- const U = /* @__PURE__ */ E(me, [["render", be]]), $e = V({
742
- components: { NodeRedInputLabel: k },
743
- props: {
744
- modelValue: {
745
- type: [String, Array],
746
- default: void 0
747
- },
748
- value: {
749
- type: [String, Array],
750
- default: () => ""
751
- },
752
- options: {
753
- type: Array,
754
- required: !0,
755
- validator: function(e) {
756
- if (!Array.isArray(e))
757
- return console.warn(
758
- "[WARN] Invalid value for 'options' property. It must be an array."
759
- ), !1;
760
- const t = e.every(
761
- (n) => typeof n == "object" && n !== null && typeof n.value == "string" && typeof n.label == "string" && Object.prototype.hasOwnProperty.call(n, "value") && Object.prototype.hasOwnProperty.call(n, "label")
762
- );
763
- return t || console.warn(
764
- "[WARN] Invalid value for 'options' property. Each item must be an object with 'value' and 'label' properties being strings.",
765
- e
766
- ), t;
767
- }
768
- },
769
- multiple: {
770
- type: Boolean,
771
- default: !1
772
- },
773
- label: {
774
- type: String,
775
- default: ""
776
- },
777
- icon: {
778
- type: String,
779
- default: ""
780
- },
781
- required: {
782
- type: Boolean,
783
- default: !1
784
- },
785
- error: {
786
- type: String,
787
- default: ""
788
- }
789
- },
790
- emits: ["update:modelValue", "update:value"],
791
- setup() {
792
- return {
793
- selectWidget: q(null)
794
- };
795
- },
796
- computed: {
797
- effectiveValue() {
798
- return this.modelValue !== void 0 ? this.modelValue : this.value;
799
- }
800
- },
801
- mounted() {
802
- const e = this.$refs.selectInput, t = $(e);
803
- this.selectWidget = t, t.typedInput({
804
- types: [
805
- {
806
- multiple: this.multiple,
807
- options: this.options
808
- }
809
- ]
810
- }), t.typedInput(
811
- "value",
812
- Array.isArray(this.effectiveValue) ? this.effectiveValue.join(",") : this.effectiveValue
813
- ), t.on("change", () => {
814
- var r;
815
- const n = this.multiple ? ((r = t.typedInput("value")) == null ? void 0 : r.split(",").filter(Boolean)) ?? [] : t.typedInput("value");
816
- this.$emit("update:modelValue", n), this.$emit("update:value", n);
817
- });
818
- },
819
- beforeUnmount() {
820
- this.selectWidget && (this.selectWidget.off("change"), this.selectWidget = null);
821
- }
822
- }), Ie = { style: { display: "flex", "flex-direction": "column", width: "100%" } }, Ve = {
823
- ref: "selectInput",
824
- type: "text",
825
- class: "node-input-select",
826
- style: { width: "100%" }
827
- }, Te = {
828
- key: 0,
829
- class: "node-red-vue-input-error-message"
830
- };
831
- function Ee(e, t, n, r, s, d) {
832
- const a = g("NodeRedInputLabel");
833
- return l(), c("div", Ie, [
834
- w(e.$slots, "label", {}, () => [
835
- e.label ? (l(), v(a, {
836
- key: 0,
837
- label: e.label,
838
- icon: e.icon,
839
- required: e.required
840
- }, null, 8, ["label", "icon", "required"])) : f("v-if", !0)
841
- ]),
842
- m(
843
- "input",
844
- Ve,
845
- null,
846
- 512
847
- /* NEED_PATCH */
848
- ),
849
- e.error ? (l(), c(
850
- "div",
851
- Te,
852
- T(e.error),
853
- 1
854
- /* TEXT */
855
- )) : f("v-if", !0)
856
- ]);
857
- }
858
- const M = /* @__PURE__ */ E($e, [["render", Ee]]), we = V({
859
- components: { NodeRedInputLabel: k },
860
- props: {
861
- modelValue: {
862
- type: String,
863
- default: void 0
864
- },
865
- value: {
866
- type: String,
867
- default: ""
868
- },
869
- language: {
870
- type: String,
871
- default: "json",
872
- validator: function(e) {
873
- const t = [
874
- "abap",
875
- "apex",
876
- "azcli",
877
- "bat",
878
- "bicep",
879
- "cameligo",
880
- "clojure",
881
- "coffee",
882
- "cpp",
883
- "csharp",
884
- "csp",
885
- "css",
886
- "cypher",
887
- "dart",
888
- "dockerfile",
889
- "ecl",
890
- "elixir",
891
- "flow9",
892
- "freemarker2",
893
- "fsharp",
894
- "go",
895
- "graphql",
896
- "handlebars",
897
- "hcl",
898
- "html",
899
- "ini",
900
- "java",
901
- "javascript",
902
- "json",
903
- "julia",
904
- "kotlin",
905
- "less",
906
- "lexon",
907
- "liquid",
908
- "lua",
909
- "m3",
910
- "markdown",
911
- "mdx",
912
- "mips",
913
- "msdax",
914
- "mysql",
915
- "objective-c",
916
- "pascal",
917
- "pascaligo",
918
- "perl",
919
- "pgsql",
920
- "php",
921
- "pla",
922
- "postiats",
923
- "powerquery",
924
- "powershell",
925
- "protobuf",
926
- "pub",
927
- "python",
928
- "qsharp",
929
- "r",
930
- "razor",
931
- "redis",
932
- "redshift",
933
- "restructuredtext",
934
- "ruby",
935
- "rust",
936
- "sb",
937
- "scala",
938
- "scheme",
939
- "scss",
940
- "shell",
941
- "solidity",
942
- "sophia",
943
- "sparql",
944
- "sql",
945
- "st",
946
- "swift",
947
- "systemverilog",
948
- "tcl",
949
- "twig",
950
- "typescript",
951
- "typespec",
952
- "vb",
953
- "wgsl",
954
- "xml",
955
- "yaml"
956
- ], n = t.includes(e);
957
- return n || console.warn(
958
- `[WARN]: Invalid value for 'type' property: "${e}". Expected one of: ${t.join(", ")}`
959
- ), n;
960
- }
961
- },
962
- label: {
963
- type: String,
964
- default: ""
965
- },
966
- icon: {
967
- type: String,
968
- default: ""
969
- },
970
- required: {
971
- type: Boolean,
972
- default: !1
973
- },
974
- error: {
975
- type: String,
976
- default: ""
977
- }
978
- },
979
- emits: [
980
- "update:modelValue",
981
- "update:value",
982
- "editor-ready",
983
- "tray-open",
984
- "tray-close"
985
- ],
986
- setup() {
987
- return {
988
- // NOTE: must not be named "editor" — the template's ref="editor" would
989
- // overwrite this with the DOM element on every re-render.
990
- editorInstance: q(null),
991
- expandedEditorTray: q(null)
992
- };
993
- },
994
- data() {
995
- const e = Math.random().toString(36).substring(2, 9);
996
- return {
997
- editorId: "node-red-editor-" + e,
998
- stateId: e,
999
- trayElement: null
1000
- };
1001
- },
1002
- computed: {
1003
- effectiveValue() {
1004
- return this.modelValue !== void 0 ? this.modelValue : this.value;
1005
- }
1006
- },
1007
- mounted() {
1008
- const e = $(this.$refs["expand-button"]);
1009
- RED.popover.tooltip(e, RED._("node-red:common.label.expand")), this.mountEditor(), this.createExpandeEditorTray();
1010
- },
1011
- beforeUnmount() {
1012
- if (this.editorInstance) {
1013
- try {
1014
- this.editorInstance.destroy();
1015
- } catch (e) {
1016
- console.error(`Error destroying editor for ID ${this.editorId}:`, e);
1017
- }
1018
- this.editorInstance = null;
1019
- }
1020
- },
1021
- methods: {
1022
- mountEditor() {
1023
- this.$nextTick(() => {
1024
- const e = this.$refs.container, t = this.$refs.editor;
1025
- if (e && t)
1026
- try {
1027
- const n = e.style.height, r = e.style.width;
1028
- n ? t.style.height = n : t.style.height = "200px", r ? t.style.width = r : t.style.width = "100%", this.createEditorInstance();
1029
- } catch (n) {
1030
- console.error(
1031
- "[NodeRedEditorInput] Error setting initial editor style:",
1032
- n
1033
- ), this.createEditorInstance();
1034
- }
1035
- else
1036
- console.error(
1037
- "[NodeRedEditorInput] Container or Editor div refs not found on mount."
1038
- );
1039
- });
1040
- },
1041
- createEditorInstance() {
1042
- this.editorInstance = RED.editor.createEditor({
1043
- id: this.editorId,
1044
- mode: this.language,
1045
- value: this.effectiveValue
1046
- }), this.editorInstance.getSession().on("change", () => {
1047
- const e = this.editorInstance.getValue();
1048
- e !== this.effectiveValue && (this.$emit("update:modelValue", e), this.$emit("update:value", e));
1049
- }), this.$emit("editor-ready", this.editorInstance);
1050
- },
1051
- createExpandeEditorTray() {
1052
- let e;
1053
- const t = () => {
1054
- setTimeout(() => {
1055
- var r;
1056
- (r = this.editorInstance) == null || r.focus();
1057
- }, 250), RED.tray.close();
1058
- }, n = () => {
1059
- var r;
1060
- e.saveView(), (r = this.editorInstance) == null || r.setValue(e.getValue(), -1), setTimeout(() => {
1061
- var s, d;
1062
- (s = this.editorInstance) == null || s.restoreView(), (d = this.editorInstance) == null || d.focus();
1063
- }, 250), RED.tray.close();
1064
- };
1065
- this.expandedEditorTray = {
1066
- title: "Editor",
1067
- focusElement: !0,
1068
- width: "Infinity",
1069
- buttons: [
1070
- {
1071
- id: "node-dialog-cancel",
1072
- text: RED._("common.label.cancel"),
1073
- click: t
1074
- },
1075
- {
1076
- id: "node-dialog-ok",
1077
- text: RED._("common.label.done"),
1078
- class: "primary",
1079
- click: n
1080
- }
1081
- ],
1082
- open: (r) => {
1083
- const s = $(
1084
- '<form id="dialog-form" class="form-horizontal" autocomplete="off"></form>'
1085
- ).appendTo(r.find(".red-ui-tray-body"));
1086
- s.html(
1087
- '<div id="expanded-editor-input" style="height: 100%"></div>'
1088
- ), e = RED.editor.createEditor({
1089
- id: "expanded-editor-input",
1090
- stateId: this.stateId,
1091
- mode: this.language,
1092
- focus: !0,
1093
- value: this.effectiveValue
1094
- }), s.i18n();
1095
- const d = r.find(".red-ui-tray-body")[0], a = document.createElement("div");
1096
- a.className = "red-ui-tray-footer", d.insertAdjacentElement("afterend", a), this.trayElement = a, this.$emit("tray-open", this.trayElement);
1097
- },
1098
- close: () => {
1099
- this.$emit("tray-close"), this.trayElement && (this.trayElement.remove(), this.trayElement = null), e.destroy();
1100
- }
1101
- };
1102
- },
1103
- onClickExpand() {
1104
- RED.tray.show(this.expandedEditorTray);
1105
- }
1106
- }
1107
- }), ke = {
1108
- ref: "container",
1109
- class: "container"
1110
- }, Se = { class: "editor-wrapper" }, qe = ["id"];
1111
- function Re(e, t, n, r, s, d) {
1112
- const a = g("NodeRedInputLabel");
1113
- return l(), c(
1114
- "div",
1115
- ke,
1116
- [
1117
- w(e.$slots, "label", {}, () => [
1118
- e.label ? (l(), v(a, {
1119
- key: 0,
1120
- label: e.label,
1121
- icon: e.icon,
1122
- required: e.required
1123
- }, null, 8, ["label", "icon", "required"])) : f("v-if", !0)
1124
- ], !0),
1125
- m("div", Se, [
1126
- m(
1127
- "button",
1128
- {
1129
- ref: "expand-button",
1130
- class: "red-ui-button red-ui-button-small expand-button",
1131
- onClick: t[0] || (t[0] = (...h) => e.onClickExpand && e.onClickExpand(...h))
1132
- },
1133
- [...t[1] || (t[1] = [
1134
- m(
1135
- "i",
1136
- { class: "fa fa-expand" },
1137
- null,
1138
- -1
1139
- /* CACHED */
1140
- )
1141
- ])],
1142
- 512
1143
- /* NEED_PATCH */
1144
- ),
1145
- m("div", {
1146
- id: e.editorId,
1147
- ref: "editor"
1148
- }, null, 8, qe)
1149
- ]),
1150
- H(m(
1151
- "div",
1152
- { class: "node-red-vue-input-error-message" },
1153
- T(e.error),
1154
- 513
1155
- /* TEXT, NEED_PATCH */
1156
- ), [
1157
- [J, e.error]
1158
- ]),
1159
- e.trayElement ? (l(), v(K, {
1160
- key: 0,
1161
- to: e.trayElement
1162
- }, [
1163
- w(e.$slots, "tray-footer", {}, void 0, !0)
1164
- ], 8, ["to"])) : f("v-if", !0)
1165
- ],
1166
- 512
1167
- /* NEED_PATCH */
1168
- );
1169
- }
1170
- const F = /* @__PURE__ */ E(we, [["render", Re], ["__scopeId", "data-v-ea93e881"]]), Ne = V({
1171
- name: "NodeRedToggle",
1172
- props: {
1173
- modelValue: {
1174
- type: Boolean,
1175
- default: !1
1176
- },
1177
- label: {
1178
- type: String,
1179
- default: ""
1180
- },
1181
- icon: {
1182
- type: String,
1183
- default: ""
1184
- }
1185
- },
1186
- emits: ["update:modelValue"],
1187
- computed: {
1188
- iconClass() {
1189
- return this.icon ? `fa ${this.icon.startsWith("fa-") ? this.icon : `fa-${this.icon}`}` : "";
1190
- }
1191
- }
1192
- }), _e = { class: "nrg-toggle-wrapper" }, Le = ["checked"], je = {
1193
- key: 0,
1194
- class: "nrg-toggle__label"
1195
- };
1196
- function Ce(e, t, n, r, s, d) {
1197
- return l(), c("div", _e, [
1198
- m(
1199
- "label",
1200
- {
1201
- class: N(["nrg-toggle", { "nrg-toggle--checked": e.modelValue }])
1202
- },
1203
- [
1204
- m("input", {
1205
- type: "checkbox",
1206
- checked: e.modelValue,
1207
- class: "nrg-toggle__input",
1208
- onChange: t[0] || (t[0] = (a) => e.$emit(
1209
- "update:modelValue",
1210
- a.target.checked
1211
- ))
1212
- }, null, 40, Le),
1213
- e.icon || e.label ? (l(), c("span", je, [
1214
- e.icon ? (l(), c(
1215
- "i",
1216
- {
1217
- key: 0,
1218
- class: N(e.iconClass)
1219
- },
1220
- null,
1221
- 2
1222
- /* CLASS */
1223
- )) : f("v-if", !0),
1224
- D(
1225
- " " + T(e.label),
1226
- 1
1227
- /* TEXT */
1228
- )
1229
- ])) : f("v-if", !0),
1230
- t[1] || (t[1] = m(
1231
- "span",
1232
- { class: "nrg-toggle__slider" },
1233
- null,
1234
- -1
1235
- /* CACHED */
1236
- ))
1237
- ],
1238
- 2
1239
- /* CLASS */
1240
- )
1241
- ]);
1242
- }
1243
- const P = /* @__PURE__ */ E(Ne, [["render", Ce], ["__scopeId", "data-v-724dcae4"]]), Ae = /* @__PURE__ */ new Set([
1244
- "id",
1245
- "type",
1246
- "x",
1247
- "y",
1248
- "z",
1249
- "g",
1250
- "wires",
1251
- "credentials",
1252
- "_users",
1253
- "validateInput",
1254
- "validateOutputs",
1255
- "outputs",
1256
- "outputContextModes",
1257
- "outputReturnProperties",
1258
- ...ue
1259
- ]);
1260
- function Oe(e) {
1261
- return e.replace(/([A-Z])/g, " $1").replace(/^./, (t) => t.toUpperCase()).trim();
1262
- }
1263
- function De(e) {
1264
- var t, n;
1265
- return e.type === "object" && !!((t = e.properties) != null && t.value) && !!((n = e.properties) != null && n.type);
1266
- }
1267
- function A(e, t, n, r) {
1268
- var b;
1269
- const s = r || t.title || Oe(e), d = t["x-nrg-form"] ?? {}, a = d.icon || "";
1270
- if (t["x-nrg-node-type"])
1271
- return {
1272
- key: e,
1273
- label: s,
1274
- icon: a,
1275
- inputType: "config",
1276
- required: n,
1277
- configType: t["x-nrg-node-type"]
1278
- };
1279
- if (De(t))
1280
- return {
1281
- key: e,
1282
- label: s,
1283
- icon: a,
1284
- inputType: "typed",
1285
- required: n,
1286
- // serialized schemas carry plain strings; trust them as typed-input type names
1287
- types: d.typedInputTypes
1288
- };
1289
- if (t.type === "array" && ((b = t.items) != null && b.enum))
1290
- return {
1291
- key: e,
1292
- label: s,
1293
- icon: a,
1294
- inputType: "select",
1295
- required: n,
1296
- multiple: !0,
1297
- options: t.items.enum.map((i) => ({
1298
- value: String(i),
1299
- label: String(i)
1300
- }))
1301
- };
1302
- if (t.enum)
1303
- return {
1304
- key: e,
1305
- label: s,
1306
- icon: a,
1307
- inputType: "select",
1308
- required: n,
1309
- multiple: !1,
1310
- options: t.enum.map((i) => ({
1311
- value: String(i),
1312
- label: String(i)
1313
- }))
1314
- };
1315
- if (t.anyOf && t.anyOf.every((i) => i.const !== void 0))
1316
- return {
1317
- key: e,
1318
- label: s,
1319
- icon: a,
1320
- inputType: "select",
1321
- required: n,
1322
- multiple: !1,
1323
- options: t.anyOf.map((i) => ({
1324
- value: String(i.const),
1325
- label: String(i.const)
1326
- }))
1327
- };
1328
- switch (Array.isArray(t.type) ? t.type[0] : t.type) {
1329
- case "boolean":
1330
- return {
1331
- key: e,
1332
- label: s,
1333
- icon: a,
1334
- inputType: "boolean",
1335
- required: n,
1336
- toggle: d.toggle
1337
- };
1338
- case "number":
1339
- case "integer":
1340
- return {
1341
- key: e,
1342
- label: s,
1343
- icon: a,
1344
- inputType: "number",
1345
- required: n,
1346
- htmlType: "number"
1347
- };
1348
- case "array":
1349
- return d.editorLanguage ? {
1350
- key: e,
1351
- label: s,
1352
- icon: a,
1353
- inputType: "editor",
1354
- required: n,
1355
- language: d.editorLanguage
1356
- } : { key: e, label: s, icon: a, inputType: "array-text", required: n };
1357
- case "object":
1358
- return d.editorLanguage ? {
1359
- key: e,
1360
- label: s,
1361
- icon: a,
1362
- inputType: "editor",
1363
- required: n,
1364
- language: d.editorLanguage
1365
- } : {
1366
- key: e,
1367
- label: s,
1368
- icon: a,
1369
- inputType: "text",
1370
- required: n,
1371
- htmlType: "text"
1372
- };
1373
- default:
1374
- return d.editorLanguage ? {
1375
- key: e,
1376
- label: s,
1377
- icon: a,
1378
- inputType: "editor",
1379
- required: n,
1380
- language: d.editorLanguage
1381
- } : {
1382
- key: e,
1383
- label: s,
1384
- icon: a,
1385
- inputType: "text",
1386
- required: n,
1387
- htmlType: t.format === "password" ? "password" : "text"
1388
- };
1389
- }
1390
- }
1391
- const We = V({
1392
- name: "NodeRedJsonSchemaForm",
1393
- components: {
1394
- NodeRedInputLabel: k,
1395
- NodeRedToggle: P,
1396
- NodeRedInput: W,
1397
- NodeRedSelectInput: M,
1398
- NodeRedTypedInput: B,
1399
- NodeRedConfigInput: U,
1400
- NodeRedEditorInput: F
1401
- },
1402
- props: {
1403
- node: {
1404
- type: Object,
1405
- required: !0
1406
- },
1407
- schema: {
1408
- type: Object,
1409
- required: !0
1410
- },
1411
- errors: {
1412
- type: Object,
1413
- default: () => ({})
1414
- }
1415
- },
1416
- computed: {
1417
- configFields() {
1418
- var t;
1419
- if (!((t = this.schema) != null && t.properties)) return [];
1420
- const e = new Set(this.schema.required ?? []);
1421
- return Object.entries(this.schema.properties).filter(([n]) => !Ae.has(n)).map(
1422
- ([n, r]) => A(
1423
- n,
1424
- r,
1425
- e.has(n),
1426
- this.resolveI18n("configs", n)
1427
- )
1428
- );
1429
- },
1430
- credentialFields() {
1431
- var n, r;
1432
- const e = (r = (n = this.schema) == null ? void 0 : n.properties) == null ? void 0 : r.credentials;
1433
- if (!(e != null && e.properties)) return [];
1434
- const t = new Set(e.required ?? []);
1435
- return Object.entries(e.properties).map(([s, d]) => {
1436
- const a = A(
1437
- s,
1438
- d,
1439
- t.has(s),
1440
- this.resolveI18n("credentials", s)
1441
- );
1442
- return a.inputType !== "text" ? {
1443
- ...a,
1444
- inputType: "text",
1445
- htmlType: d.format === "password" ? "password" : "text"
1446
- } : a;
1447
- });
1448
- }
1449
- },
1450
- methods: {
1451
- resolveI18n(e, t) {
1452
- const n = this.$i18n(`${e}.${t}`), r = `${this.node.type}.${e}.${t}`;
1453
- if (n && n !== r && n !== `${e}.${t}`)
1454
- return n;
1455
- }
1456
- }
1457
- }), Be = { key: 1 }, Ue = { key: 2 }, Me = ["checked", "onChange"], Fe = { key: 6 }, Pe = ["value", "onInput"], ze = {
1458
- key: 0,
1459
- class: "node-red-vue-input-error-message"
1460
- };
1461
- function He(e, t, n, r, s, d) {
1462
- const a = g("NodeRedInput"), h = g("NodeRedToggle"), b = g("NodeRedInputLabel"), i = g("NodeRedSelectInput"), u = g("NodeRedTypedInput"), y = g("NodeRedConfigInput"), I = g("NodeRedEditorInput");
1463
- return l(), c("div", null, [
1464
- (l(!0), c(
1465
- _,
1466
- null,
1467
- L(e.configFields, (o) => (l(), c("div", {
1468
- key: o.key,
1469
- class: "form-row"
1470
- }, [
1471
- o.inputType === "text" || o.inputType === "number" ? (l(), v(a, {
1472
- key: 0,
1473
- value: e.node[o.key],
1474
- "onUpdate:value": (p) => e.node[o.key] = p,
1475
- type: o.htmlType,
1476
- label: o.label,
1477
- icon: o.icon,
1478
- required: o.required,
1479
- error: e.errors[`node.${o.key}`]
1480
- }, null, 8, ["value", "onUpdate:value", "type", "label", "icon", "required", "error"])) : o.inputType === "boolean" && o.toggle ? (l(), c("div", Be, [
1481
- R(h, {
1482
- "model-value": e.node[o.key],
1483
- label: o.label,
1484
- icon: o.icon,
1485
- "onUpdate:modelValue": (p) => e.node[o.key] = p
1486
- }, null, 8, ["model-value", "label", "icon", "onUpdate:modelValue"])
1487
- ])) : o.inputType === "boolean" ? (l(), c("div", Ue, [
1488
- R(b, {
1489
- label: o.label,
1490
- icon: o.icon,
1491
- required: o.required
1492
- }, null, 8, ["label", "icon", "required"]),
1493
- m("input", {
1494
- type: "checkbox",
1495
- checked: e.node[o.key],
1496
- style: { width: "auto", margin: "0" },
1497
- onChange: (p) => {
1498
- e.node[o.key] = p.target.checked;
1499
- }
1500
- }, null, 40, Me)
1501
- ])) : o.inputType === "select" ? (l(), v(i, {
1502
- key: 3,
1503
- value: e.node[o.key],
1504
- "onUpdate:value": (p) => e.node[o.key] = p,
1505
- options: o.options,
1506
- multiple: o.multiple,
1507
- label: o.label,
1508
- icon: o.icon,
1509
- required: o.required,
1510
- error: e.errors[`node.${o.key}`]
1511
- }, null, 8, ["value", "onUpdate:value", "options", "multiple", "label", "icon", "required", "error"])) : o.inputType === "typed" ? (l(), v(u, {
1512
- key: 4,
1513
- value: e.node[o.key],
1514
- "onUpdate:value": (p) => e.node[o.key] = p,
1515
- types: o.types,
1516
- label: o.label,
1517
- icon: o.icon,
1518
- required: o.required,
1519
- error: e.errors[`node.${o.key}`]
1520
- }, null, 8, ["value", "onUpdate:value", "types", "label", "icon", "required", "error"])) : o.inputType === "config" ? (l(), v(y, {
1521
- key: 5,
1522
- value: e.node[o.key],
1523
- "onUpdate:value": (p) => e.node[o.key] = p,
1524
- type: o.configType,
1525
- node: e.node,
1526
- "prop-name": o.key,
1527
- label: o.label,
1528
- icon: o.icon,
1529
- required: o.required,
1530
- error: e.errors[`node.${o.key}`]
1531
- }, null, 8, ["value", "onUpdate:value", "type", "node", "prop-name", "label", "icon", "required", "error"])) : o.inputType === "array-text" ? (l(), c("div", Fe, [
1532
- R(b, {
1533
- label: o.label,
1534
- icon: o.icon,
1535
- required: o.required
1536
- }, null, 8, ["label", "icon", "required"]),
1537
- t[0] || (t[0] = m(
1538
- "span",
1539
- { style: { display: "block", "font-size": "11px", color: "var(--red-ui-text-color-disabled, #999)", "margin-bottom": "4px" } },
1540
- " One entry per line ",
1541
- -1
1542
- /* CACHED */
1543
- )),
1544
- m("textarea", {
1545
- value: Array.isArray(e.node[o.key]) ? e.node[o.key].join(`
1546
- `) : e.node[o.key] ?? "",
1547
- rows: "4",
1548
- style: { width: "100%", resize: "vertical", "font-family": "monospace", "font-size": "13px" },
1549
- onInput: (p) => e.node[o.key] = p.target.value.split(`
1550
- `).filter(Boolean)
1551
- }, null, 40, Pe),
1552
- e.errors[`node.${o.key}`] ? (l(), c(
1553
- "span",
1554
- ze,
1555
- T(e.errors[`node.${o.key}`]),
1556
- 1
1557
- /* TEXT */
1558
- )) : f("v-if", !0)
1559
- ])) : o.inputType === "editor" ? (l(), v(I, {
1560
- key: 7,
1561
- value: e.node[o.key],
1562
- "onUpdate:value": (p) => e.node[o.key] = p,
1563
- language: o.language,
1564
- label: o.label,
1565
- icon: o.icon,
1566
- required: o.required,
1567
- error: e.errors[`node.${o.key}`]
1568
- }, null, 8, ["value", "onUpdate:value", "language", "label", "icon", "required", "error"])) : f("v-if", !0)
1569
- ]))),
1570
- 128
1571
- /* KEYED_FRAGMENT */
1572
- )),
1573
- (l(!0), c(
1574
- _,
1575
- null,
1576
- L(e.credentialFields, (o) => (l(), c("div", {
1577
- key: `cred-${o.key}`,
1578
- class: "form-row"
1579
- }, [
1580
- R(a, {
1581
- value: e.node.credentials[o.key],
1582
- "onUpdate:value": (p) => e.node.credentials[o.key] = p,
1583
- type: o.htmlType,
1584
- label: o.label,
1585
- icon: o.icon,
1586
- required: o.required,
1587
- error: e.errors[`node.credentials.${o.key}`]
1588
- }, null, 8, ["value", "onUpdate:value", "type", "label", "icon", "required", "error"])
1589
- ]))),
1590
- 128
1591
- /* KEYED_FRAGMENT */
1592
- ))
1593
- ]);
321
+ function H() {
322
+ window.$ = j(), window.RED = N(), L(() => {
323
+ _(window.RED);
324
+ });
1594
325
  }
1595
- const Je = /* @__PURE__ */ E(We, [["render", He]]);
1596
- O.global.mocks.$i18n = (e) => e;
1597
- O.global.components = {
1598
- NodeRedInputLabel: k,
1599
- NodeRedToggle: P,
1600
- NodeRedInput: W,
1601
- NodeRedTypedInput: B,
1602
- NodeRedConfigInput: U,
1603
- NodeRedSelectInput: M,
1604
- NodeRedEditorInput: F,
1605
- NodeRedJsonSchemaForm: Je
326
+ h.global.mocks.$i18n = (t) => t;
327
+ h.global.components = {
328
+ NodeRedInputLabel: M,
329
+ NodeRedToggle: w,
330
+ NodeRedInput: k,
331
+ NodeRedTypedInput: T,
332
+ NodeRedConfigInput: v,
333
+ NodeRedSelectInput: I,
334
+ NodeRedEditorInput: S,
335
+ NodeRedJsonSchemaForm: E
1606
336
  };
1607
- window.$ = X();
1608
- window.RED = Z();
1609
- z(() => {
1610
- Q(window.RED);
1611
- });
337
+ H();