@bonsae/nrg 0.18.5 → 0.19.1

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 (37) hide show
  1. package/README.md +2 -2
  2. package/package.json +1 -1
  3. package/server/index.cjs +86 -9
  4. package/server/resources/nrg-client.js +2020 -1987
  5. package/test/client/component/config.js +11 -0
  6. package/test/client/component/index.js +218 -235
  7. package/test/client/component/nrg.css +1 -0
  8. package/test/client/component/setup.js +1549 -140
  9. package/test/client/e2e/index.js +706 -368
  10. package/test/client/unit/index.js +204 -16
  11. package/test/client/unit/setup.js +209 -19
  12. package/test/server/unit/index.js +25 -4
  13. package/tsconfig/core/client.json +1 -1
  14. package/tsconfig/test/client/component.json +1 -1
  15. package/types/client.d.ts +98 -18
  16. package/types/server.d.ts +50 -12
  17. package/types/shims/brands.d.ts +32 -0
  18. package/types/shims/{form → client/form}/components/node-red-editor-input.vue.d.ts +1 -1
  19. package/types/shims/{form → client/form}/components/node-red-json-schema-form.vue.d.ts +21 -2
  20. package/types/shims/{form → client/form}/components/node-red-select-input.vue.d.ts +1 -0
  21. package/types/shims/{form → client/form}/components/node-red-typed-input.vue.d.ts +1 -0
  22. package/types/shims/client/types.d.ts +206 -0
  23. package/types/shims/components.d.ts +8 -8
  24. package/types/shims/constants.d.ts +4 -0
  25. package/types/shims/schema-options.d.ts +23 -10
  26. package/types/shims/typebox.d.ts +2 -2
  27. package/types/test-client-component.d.ts +170 -55
  28. package/types/test-client-e2e.d.ts +50 -0
  29. package/types/test-client-unit.d.ts +86 -22
  30. package/types/test-server-unit.d.ts +3 -1
  31. package/types/vite.d.ts +25 -9
  32. package/vite/index.js +648 -499
  33. /package/types/shims/{form → client/form}/components/node-red-config-input.vue.d.ts +0 -0
  34. /package/types/shims/{form → client/form}/components/node-red-input-label.vue.d.ts +0 -0
  35. /package/types/shims/{form → client/form}/components/node-red-input.vue.d.ts +0 -0
  36. /package/types/shims/{form → client/form}/components/node-red-toggle.vue.d.ts +0 -0
  37. /package/types/shims/{globals.d.ts → client/globals.d.ts} +0 -0
@@ -1,24 +1,63 @@
1
- // src/test/client/component/setup.ts
2
- import { beforeEach } from "vitest";
3
- import { config } from "vitest-browser-vue";
4
-
5
- // src/test/client/mocks.ts
6
- function createRED() {
7
- return {
8
- _: (key) => key,
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 R, 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 N } 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;
15
+ }
16
+ };
17
+ return e;
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;
25
+ }
26
+ return n.length === r.length;
27
+ }
28
+ function Q(e) {
29
+ var t;
30
+ (t = e.__reset) == null || t.call(e);
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 = {
37
+ element: null,
38
+ open: () => i,
39
+ close: () => i,
40
+ setContent: () => i,
41
+ move: () => {
42
+ }
43
+ };
44
+ return i;
45
+ }, b = {
46
+ _: (i) => i,
9
47
  editor: {
10
- createEditor(options) {
11
- let currentValue = options.value || "";
12
- const session = {
13
- on(_event, _cb) {
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);
14
53
  }
15
54
  };
16
55
  return {
17
- getValue: () => currentValue,
18
- setValue: (val) => {
19
- currentValue = val;
56
+ getValue: () => u,
57
+ setValue: (o) => {
58
+ u = o, (y.change ?? []).forEach((p) => p());
20
59
  },
21
- getSession: () => session,
60
+ getSession: () => I,
22
61
  focus: () => {
23
62
  },
24
63
  destroy: () => {
@@ -31,7 +70,7 @@ function createRED() {
31
70
  },
32
71
  prepareConfigNodeSelect: () => {
33
72
  },
34
- validateNode: () => true
73
+ validateNode: () => !0
35
74
  },
36
75
  tray: {
37
76
  show: () => {
@@ -40,162 +79,1532 @@ function createRED() {
40
79
  }
41
80
  },
42
81
  popover: {
43
- tooltip: () => ({ delete: () => {
44
- }, setAction: () => {
45
- } })
82
+ create: () => h(),
83
+ tooltip: () => {
84
+ const i = {
85
+ element: null,
86
+ open: () => i,
87
+ close: () => i,
88
+ setContent: () => i,
89
+ move: () => {
90
+ },
91
+ delete: () => {
92
+ },
93
+ setAction: () => {
94
+ }
95
+ };
96
+ return i;
97
+ }
46
98
  },
47
99
  nodes: {
48
- registerType: () => {
100
+ registerType(i, u) {
101
+ t.set(i, u);
102
+ },
103
+ getType(i) {
104
+ return t.get(i) ?? null;
105
+ },
106
+ node(i) {
107
+ return e.get(i) ?? null;
108
+ },
109
+ add(i) {
110
+ return e.set(i.id, i), i;
111
+ },
112
+ remove(i) {
113
+ const u = e.get(i);
114
+ return e.delete(i), { links: [], nodes: u ? [u] : [] };
115
+ },
116
+ clear() {
117
+ e.clear();
118
+ },
119
+ // The mock keeps a single registry: eachNode and eachConfig iterate the
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;
124
+ },
125
+ eachConfig(i) {
126
+ for (const u of e.values())
127
+ if (i(u) === !1) break;
49
128
  },
50
- node: () => null,
51
- dirty: () => false
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)
132
+ );
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));
139
+ }
140
+ );
141
+ },
142
+ addLink(i) {
143
+ n.push(i);
144
+ },
145
+ dirty(i) {
146
+ if (i === void 0) return d;
147
+ d = i;
148
+ },
149
+ id() {
150
+ return (++a).toString(16).padStart(16, "0");
151
+ }
52
152
  },
53
153
  events: {
54
- on: () => {
154
+ on(i, u) {
155
+ (r[i] ?? (r[i] = [])).push(u);
55
156
  },
56
- off: () => {
157
+ off(i, u) {
158
+ r[i] && (u ? r[i] = r[i].filter(
159
+ (y) => y !== u
160
+ ) : delete r[i]);
57
161
  },
58
- emit: () => {
162
+ emit(i, ...u) {
163
+ [...r[i] ?? []].forEach((y) => y(...u));
59
164
  }
60
165
  },
61
- settings: {},
62
- notify: () => {
63
- }
166
+ comms: {
167
+ subscribe(i, u) {
168
+ s.push({ topic: i, callback: u });
169
+ },
170
+ unsubscribe(i, u) {
171
+ const y = s.findIndex(
172
+ (I) => I.topic === i && I.callback === u
173
+ );
174
+ y !== -1 && s.splice(y, 1);
175
+ },
176
+ publish(i, u) {
177
+ [...s].filter((y) => Y(y.topic, i)).forEach((y) => y.callback(i, u));
178
+ }
179
+ },
180
+ settings: j(),
181
+ notify: () => ({
182
+ update: () => {
183
+ },
184
+ close: () => {
185
+ }
186
+ })
64
187
  };
188
+ return Object.defineProperty(b, "__reset", {
189
+ enumerable: !1,
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();
195
+ }
196
+ }), b;
65
197
  }
66
- function ensureState(el) {
67
- if (el && !el.__jqState) {
68
- el.__jqState = {
69
- typedInput: { value: "", type: "" },
70
- listeners: {}
71
- };
72
- }
73
- return el ? el.__jqState : { typedInput: { value: "", type: "" }, listeners: {} };
74
- }
75
- function createJQ(el) {
76
- const state = ensureState(el);
77
- const jq = {
78
- 0: el,
79
- length: el ? 1 : 0,
80
- typedInput(action, value) {
81
- if (typeof action === "object") {
82
- state.typedInput = { value: "", type: action.default || "" };
83
- return jq;
84
- }
85
- if (action === "value") {
86
- if (value !== void 0) {
87
- state.typedInput.value = String(value);
88
- if (el) el.setAttribute("value", String(value));
89
- return void 0;
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: {} };
203
+ }
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 = {
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));
218
+ return;
90
219
  }
91
- return state.typedInput.value;
220
+ return t.typedInput.value;
92
221
  }
93
- if (action === "type") {
94
- if (value !== void 0) {
95
- state.typedInput.type = String(value);
96
- return void 0;
222
+ if (r === "type") {
223
+ if (s !== void 0) {
224
+ t.typedInput.type = String(s);
225
+ return;
97
226
  }
98
- return state.typedInput.type;
227
+ return t.typedInput.type;
99
228
  }
100
- return jq;
101
- },
102
- on(event, cb) {
103
- if (!state.listeners[event]) state.listeners[event] = [];
104
- state.listeners[event].push(cb);
105
- return jq;
106
- },
107
- off(event) {
108
- if (event) {
109
- delete state.listeners[event];
110
- } else {
111
- for (const key of Object.keys(state.listeners)) {
112
- delete state.listeners[key];
113
- }
229
+ if (r === "types") {
230
+ t.typedInput.types = s;
231
+ return;
114
232
  }
115
- return jq;
116
- },
117
- val(value) {
118
- if (value !== void 0) {
119
- if (el instanceof HTMLInputElement || el instanceof HTMLSelectElement || el instanceof HTMLTextAreaElement) {
120
- el.value = String(value);
121
- }
122
- return jq;
233
+ if (r === "validate")
234
+ return !0;
235
+ if (r === "disable") {
236
+ t.typedInput.disabled = s !== !1;
237
+ return;
238
+ }
239
+ if (r === "enable") {
240
+ t.typedInput.disabled = !1;
241
+ return;
242
+ }
243
+ if (r === "hide") {
244
+ t.typedInput.hidden = !0;
245
+ return;
123
246
  }
124
- if (el instanceof HTMLInputElement || el instanceof HTMLSelectElement || el instanceof HTMLTextAreaElement) {
125
- return el.value;
247
+ if (r === "show") {
248
+ t.typedInput.hidden = !1;
249
+ return;
126
250
  }
127
- return "";
251
+ if (r === "width") {
252
+ t.typedInput.width = s;
253
+ return;
254
+ }
255
+ if (r !== "focus")
256
+ return n;
257
+ },
258
+ on(r, s) {
259
+ return t.listeners[r] || (t.listeners[r] = []), t.listeners[r].push(s), n;
260
+ },
261
+ off(r) {
262
+ if (r)
263
+ delete t.listeners[r];
264
+ else
265
+ for (const s of Object.keys(t.listeners))
266
+ delete t.listeners[s];
267
+ return n;
128
268
  },
129
- find(selector) {
130
- return createJQ(el?.querySelector(selector) ?? null);
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 : "";
131
271
  },
132
- append(child) {
133
- const childEl = child?.[0] || child;
134
- if (el && childEl instanceof Element) el.appendChild(childEl);
135
- return jq;
272
+ find(r) {
273
+ return S((e == null ? void 0 : e.querySelector(r)) ?? null);
136
274
  },
137
- appendTo(target) {
138
- const t = target?.[0] || target;
139
- if (t instanceof Element && el) t.appendChild(el);
140
- return jq;
275
+ append(r) {
276
+ const s = (r == null ? void 0 : r[0]) || r;
277
+ return e && s instanceof Element && e.appendChild(s), n;
141
278
  },
142
- html(content) {
143
- if (el) el.innerHTML = content;
144
- return jq;
279
+ appendTo(r) {
280
+ const s = (r == null ? void 0 : r[0]) || r;
281
+ return s instanceof Element && e && s.appendChild(e), n;
282
+ },
283
+ html(r) {
284
+ return e && (e.innerHTML = r), n;
145
285
  },
146
286
  empty() {
147
- if (el) el.innerHTML = "";
148
- return jq;
287
+ return e && (e.innerHTML = ""), n;
149
288
  },
150
289
  i18n() {
151
- return jq;
290
+ return n;
152
291
  },
153
- addClass(cls) {
154
- el?.classList.add(cls);
155
- return jq;
292
+ addClass(r) {
293
+ return e == null || e.classList.add(r), n;
156
294
  },
157
- removeClass(cls) {
158
- el?.classList.remove(cls);
159
- return jq;
295
+ removeClass(r) {
296
+ return e == null || e.classList.remove(r), n;
160
297
  },
161
- __trigger(event) {
162
- (state.listeners[event] || []).forEach((cb) => cb());
298
+ __trigger(r) {
299
+ (t.listeners[r] || []).forEach((s) => s());
163
300
  }
164
301
  };
165
- return jq;
166
- }
167
- function createJQuery() {
168
- return function $(selector, attrs) {
169
- if (typeof selector === "string") {
170
- if (selector.trim().startsWith("<")) {
171
- const tpl = document.createElement("template");
172
- tpl.innerHTML = selector.trim();
173
- const el = tpl.content.firstElementChild;
174
- if (el && attrs) {
175
- for (const [key, value] of Object.entries(attrs)) {
176
- if (key === "html") {
177
- el.innerHTML = String(value);
178
- } else {
179
- el.setAttribute(key, String(value));
180
- }
181
- }
182
- }
183
- return createJQ(el);
302
+ return n;
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);
184
315
  }
185
- return createJQ(document.querySelector(selector));
316
+ return S(document.querySelector(t));
186
317
  }
187
- if (selector instanceof Element) return createJQ(selector);
188
- if (selector && typeof selector === "object" && selector.nodeType)
189
- return createJQ(selector);
190
- return createJQ(null);
318
+ return t instanceof Element || t && typeof t == "object" && t.nodeType ? S(t) : S(null);
191
319
  };
192
320
  }
193
-
194
- // src/test/client/component/setup.ts
195
- config.global.mocks.$i18n = (key) => key;
196
- var RED = createRED();
197
- window.$ = createJQuery();
198
- window.RED = RED;
199
- beforeEach(() => {
200
- RED.settings = {};
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: R(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 F = /* @__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 Ne(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 M = /* @__PURE__ */ E(we, [["render", Ne], ["__scopeId", "data-v-ea93e881"]]), Re = 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: R(["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: R(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(Re, [["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
+ "validateOutput",
1255
+ "outputs",
1256
+ "returnProperty",
1257
+ ...ue
1258
+ ]);
1259
+ function Oe(e) {
1260
+ return e.replace(/([A-Z])/g, " $1").replace(/^./, (t) => t.toUpperCase()).trim();
1261
+ }
1262
+ function De(e) {
1263
+ var t, n;
1264
+ return e.type === "object" && !!((t = e.properties) != null && t.value) && !!((n = e.properties) != null && n.type);
1265
+ }
1266
+ function A(e, t, n, r) {
1267
+ var b;
1268
+ const s = r || t.title || Oe(e), d = t["x-nrg-form"] ?? {}, a = d.icon || "";
1269
+ if (t["x-nrg-node-type"])
1270
+ return {
1271
+ key: e,
1272
+ label: s,
1273
+ icon: a,
1274
+ inputType: "config",
1275
+ required: n,
1276
+ configType: t["x-nrg-node-type"]
1277
+ };
1278
+ if (De(t))
1279
+ return {
1280
+ key: e,
1281
+ label: s,
1282
+ icon: a,
1283
+ inputType: "typed",
1284
+ required: n,
1285
+ // serialized schemas carry plain strings; trust them as typed-input type names
1286
+ types: d.typedInputTypes
1287
+ };
1288
+ if (t.type === "array" && ((b = t.items) != null && b.enum))
1289
+ return {
1290
+ key: e,
1291
+ label: s,
1292
+ icon: a,
1293
+ inputType: "select",
1294
+ required: n,
1295
+ multiple: !0,
1296
+ options: t.items.enum.map((i) => ({
1297
+ value: String(i),
1298
+ label: String(i)
1299
+ }))
1300
+ };
1301
+ if (t.enum)
1302
+ return {
1303
+ key: e,
1304
+ label: s,
1305
+ icon: a,
1306
+ inputType: "select",
1307
+ required: n,
1308
+ multiple: !1,
1309
+ options: t.enum.map((i) => ({
1310
+ value: String(i),
1311
+ label: String(i)
1312
+ }))
1313
+ };
1314
+ if (t.anyOf && t.anyOf.every((i) => i.const !== void 0))
1315
+ return {
1316
+ key: e,
1317
+ label: s,
1318
+ icon: a,
1319
+ inputType: "select",
1320
+ required: n,
1321
+ multiple: !1,
1322
+ options: t.anyOf.map((i) => ({
1323
+ value: String(i.const),
1324
+ label: String(i.const)
1325
+ }))
1326
+ };
1327
+ switch (Array.isArray(t.type) ? t.type[0] : t.type) {
1328
+ case "boolean":
1329
+ return {
1330
+ key: e,
1331
+ label: s,
1332
+ icon: a,
1333
+ inputType: "boolean",
1334
+ required: n,
1335
+ toggle: d.toggle
1336
+ };
1337
+ case "number":
1338
+ case "integer":
1339
+ return {
1340
+ key: e,
1341
+ label: s,
1342
+ icon: a,
1343
+ inputType: "number",
1344
+ required: n,
1345
+ htmlType: "number"
1346
+ };
1347
+ case "array":
1348
+ return d.editorLanguage ? {
1349
+ key: e,
1350
+ label: s,
1351
+ icon: a,
1352
+ inputType: "editor",
1353
+ required: n,
1354
+ language: d.editorLanguage
1355
+ } : { key: e, label: s, icon: a, inputType: "array-text", required: n };
1356
+ case "object":
1357
+ return d.editorLanguage ? {
1358
+ key: e,
1359
+ label: s,
1360
+ icon: a,
1361
+ inputType: "editor",
1362
+ required: n,
1363
+ language: d.editorLanguage
1364
+ } : {
1365
+ key: e,
1366
+ label: s,
1367
+ icon: a,
1368
+ inputType: "text",
1369
+ required: n,
1370
+ htmlType: "text"
1371
+ };
1372
+ default:
1373
+ return d.editorLanguage ? {
1374
+ key: e,
1375
+ label: s,
1376
+ icon: a,
1377
+ inputType: "editor",
1378
+ required: n,
1379
+ language: d.editorLanguage
1380
+ } : {
1381
+ key: e,
1382
+ label: s,
1383
+ icon: a,
1384
+ inputType: "text",
1385
+ required: n,
1386
+ htmlType: t.format === "password" ? "password" : "text"
1387
+ };
1388
+ }
1389
+ }
1390
+ const We = V({
1391
+ name: "NodeRedJsonSchemaForm",
1392
+ components: {
1393
+ NodeRedInputLabel: k,
1394
+ NodeRedToggle: P,
1395
+ NodeRedInput: W,
1396
+ NodeRedSelectInput: F,
1397
+ NodeRedTypedInput: B,
1398
+ NodeRedConfigInput: U,
1399
+ NodeRedEditorInput: M
1400
+ },
1401
+ props: {
1402
+ node: {
1403
+ type: Object,
1404
+ required: !0
1405
+ },
1406
+ schema: {
1407
+ type: Object,
1408
+ required: !0
1409
+ },
1410
+ errors: {
1411
+ type: Object,
1412
+ default: () => ({})
1413
+ }
1414
+ },
1415
+ computed: {
1416
+ configFields() {
1417
+ var t;
1418
+ if (!((t = this.schema) != null && t.properties)) return [];
1419
+ const e = new Set(this.schema.required ?? []);
1420
+ return Object.entries(this.schema.properties).filter(([n]) => !Ae.has(n)).map(
1421
+ ([n, r]) => A(
1422
+ n,
1423
+ r,
1424
+ e.has(n),
1425
+ this.resolveI18n("configs", n)
1426
+ )
1427
+ );
1428
+ },
1429
+ credentialFields() {
1430
+ var n, r;
1431
+ const e = (r = (n = this.schema) == null ? void 0 : n.properties) == null ? void 0 : r.credentials;
1432
+ if (!(e != null && e.properties)) return [];
1433
+ const t = new Set(e.required ?? []);
1434
+ return Object.entries(e.properties).map(([s, d]) => {
1435
+ const a = A(
1436
+ s,
1437
+ d,
1438
+ t.has(s),
1439
+ this.resolveI18n("credentials", s)
1440
+ );
1441
+ return a.inputType !== "text" ? {
1442
+ ...a,
1443
+ inputType: "text",
1444
+ htmlType: d.format === "password" ? "password" : "text"
1445
+ } : a;
1446
+ });
1447
+ }
1448
+ },
1449
+ methods: {
1450
+ resolveI18n(e, t) {
1451
+ const n = this.$i18n(`${e}.${t}`), r = `${this.node.type}.${e}.${t}`;
1452
+ if (n && n !== r && n !== `${e}.${t}`)
1453
+ return n;
1454
+ }
1455
+ }
1456
+ }), Be = { key: 1 }, Ue = { key: 2 }, Fe = ["checked", "onChange"], Me = { key: 6 }, Pe = ["value", "onInput"], ze = {
1457
+ key: 0,
1458
+ class: "node-red-vue-input-error-message"
1459
+ };
1460
+ function He(e, t, n, r, s, d) {
1461
+ const a = g("NodeRedInput"), h = g("NodeRedToggle"), b = g("NodeRedInputLabel"), i = g("NodeRedSelectInput"), u = g("NodeRedTypedInput"), y = g("NodeRedConfigInput"), I = g("NodeRedEditorInput");
1462
+ return l(), c("div", null, [
1463
+ (l(!0), c(
1464
+ _,
1465
+ null,
1466
+ L(e.configFields, (o) => (l(), c("div", {
1467
+ key: o.key,
1468
+ class: "form-row"
1469
+ }, [
1470
+ o.inputType === "text" || o.inputType === "number" ? (l(), v(a, {
1471
+ key: 0,
1472
+ value: e.node[o.key],
1473
+ "onUpdate:value": (p) => e.node[o.key] = p,
1474
+ type: o.htmlType,
1475
+ label: o.label,
1476
+ icon: o.icon,
1477
+ required: o.required,
1478
+ error: e.errors[`node.${o.key}`]
1479
+ }, null, 8, ["value", "onUpdate:value", "type", "label", "icon", "required", "error"])) : o.inputType === "boolean" && o.toggle ? (l(), c("div", Be, [
1480
+ N(h, {
1481
+ "model-value": e.node[o.key],
1482
+ label: o.label,
1483
+ icon: o.icon,
1484
+ "onUpdate:modelValue": (p) => e.node[o.key] = p
1485
+ }, null, 8, ["model-value", "label", "icon", "onUpdate:modelValue"])
1486
+ ])) : o.inputType === "boolean" ? (l(), c("div", Ue, [
1487
+ N(b, {
1488
+ label: o.label,
1489
+ icon: o.icon,
1490
+ required: o.required
1491
+ }, null, 8, ["label", "icon", "required"]),
1492
+ m("input", {
1493
+ type: "checkbox",
1494
+ checked: e.node[o.key],
1495
+ style: { width: "auto", margin: "0" },
1496
+ onChange: (p) => {
1497
+ e.node[o.key] = p.target.checked;
1498
+ }
1499
+ }, null, 40, Fe)
1500
+ ])) : o.inputType === "select" ? (l(), v(i, {
1501
+ key: 3,
1502
+ value: e.node[o.key],
1503
+ "onUpdate:value": (p) => e.node[o.key] = p,
1504
+ options: o.options,
1505
+ multiple: o.multiple,
1506
+ label: o.label,
1507
+ icon: o.icon,
1508
+ required: o.required,
1509
+ error: e.errors[`node.${o.key}`]
1510
+ }, null, 8, ["value", "onUpdate:value", "options", "multiple", "label", "icon", "required", "error"])) : o.inputType === "typed" ? (l(), v(u, {
1511
+ key: 4,
1512
+ value: e.node[o.key],
1513
+ "onUpdate:value": (p) => e.node[o.key] = p,
1514
+ types: o.types,
1515
+ label: o.label,
1516
+ icon: o.icon,
1517
+ required: o.required,
1518
+ error: e.errors[`node.${o.key}`]
1519
+ }, null, 8, ["value", "onUpdate:value", "types", "label", "icon", "required", "error"])) : o.inputType === "config" ? (l(), v(y, {
1520
+ key: 5,
1521
+ value: e.node[o.key],
1522
+ "onUpdate:value": (p) => e.node[o.key] = p,
1523
+ type: o.configType,
1524
+ node: e.node,
1525
+ "prop-name": o.key,
1526
+ label: o.label,
1527
+ icon: o.icon,
1528
+ required: o.required,
1529
+ error: e.errors[`node.${o.key}`]
1530
+ }, null, 8, ["value", "onUpdate:value", "type", "node", "prop-name", "label", "icon", "required", "error"])) : o.inputType === "array-text" ? (l(), c("div", Me, [
1531
+ N(b, {
1532
+ label: o.label,
1533
+ icon: o.icon,
1534
+ required: o.required
1535
+ }, null, 8, ["label", "icon", "required"]),
1536
+ t[0] || (t[0] = m(
1537
+ "span",
1538
+ { style: { display: "block", "font-size": "11px", color: "var(--red-ui-text-color-disabled, #999)", "margin-bottom": "4px" } },
1539
+ " One entry per line ",
1540
+ -1
1541
+ /* CACHED */
1542
+ )),
1543
+ m("textarea", {
1544
+ value: Array.isArray(e.node[o.key]) ? e.node[o.key].join(`
1545
+ `) : e.node[o.key] ?? "",
1546
+ rows: "4",
1547
+ style: { width: "100%", resize: "vertical", "font-family": "monospace", "font-size": "13px" },
1548
+ onInput: (p) => e.node[o.key] = p.target.value.split(`
1549
+ `).filter(Boolean)
1550
+ }, null, 40, Pe),
1551
+ e.errors[`node.${o.key}`] ? (l(), c(
1552
+ "span",
1553
+ ze,
1554
+ T(e.errors[`node.${o.key}`]),
1555
+ 1
1556
+ /* TEXT */
1557
+ )) : f("v-if", !0)
1558
+ ])) : o.inputType === "editor" ? (l(), v(I, {
1559
+ key: 7,
1560
+ value: e.node[o.key],
1561
+ "onUpdate:value": (p) => e.node[o.key] = p,
1562
+ language: o.language,
1563
+ label: o.label,
1564
+ icon: o.icon,
1565
+ required: o.required,
1566
+ error: e.errors[`node.${o.key}`]
1567
+ }, null, 8, ["value", "onUpdate:value", "language", "label", "icon", "required", "error"])) : f("v-if", !0)
1568
+ ]))),
1569
+ 128
1570
+ /* KEYED_FRAGMENT */
1571
+ )),
1572
+ (l(!0), c(
1573
+ _,
1574
+ null,
1575
+ L(e.credentialFields, (o) => (l(), c("div", {
1576
+ key: `cred-${o.key}`,
1577
+ class: "form-row"
1578
+ }, [
1579
+ N(a, {
1580
+ value: e.node.credentials[o.key],
1581
+ "onUpdate:value": (p) => e.node.credentials[o.key] = p,
1582
+ type: o.htmlType,
1583
+ label: o.label,
1584
+ icon: o.icon,
1585
+ required: o.required,
1586
+ error: e.errors[`node.credentials.${o.key}`]
1587
+ }, null, 8, ["value", "onUpdate:value", "type", "label", "icon", "required", "error"])
1588
+ ]))),
1589
+ 128
1590
+ /* KEYED_FRAGMENT */
1591
+ ))
1592
+ ]);
1593
+ }
1594
+ const Je = /* @__PURE__ */ E(We, [["render", He]]);
1595
+ O.global.mocks.$i18n = (e) => e;
1596
+ O.global.components = {
1597
+ NodeRedInputLabel: k,
1598
+ NodeRedToggle: P,
1599
+ NodeRedInput: W,
1600
+ NodeRedTypedInput: B,
1601
+ NodeRedConfigInput: U,
1602
+ NodeRedSelectInput: F,
1603
+ NodeRedEditorInput: M,
1604
+ NodeRedJsonSchemaForm: Je
1605
+ };
1606
+ window.$ = X();
1607
+ window.RED = Z();
1608
+ z(() => {
1609
+ Q(window.RED);
201
1610
  });