@keload/node-red-dxp 1.4.1 → 1.5.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.
@@ -1 +1,176 @@
1
- 'use strict';var solidJs=require('solid-js');function d(e){return Object.prototype.toString.call(e).slice(8,-1)}function m(e){if(d(e)!=="Object")return !1;let r=Object.getPrototypeOf(e);return !!r&&r.constructor===Object&&r===Object.prototype}function x(e){return d(e)==="Symbol"}function O(e,r,s,i){let p={}.propertyIsEnumerable.call(i,r)?"enumerable":"nonenumerable";p==="enumerable"&&(e[r]=s),p==="nonenumerable"&&Object.defineProperty(e,r,{value:s,enumerable:!1,writable:!0,configurable:!0});}function T(e,r,s){if(!m(r))return r;let i={};if(m(e)){let l=Object.getOwnPropertyNames(e),t=Object.getOwnPropertySymbols(e);i=[...l,...t].reduce((n,o)=>{let c=e[o];return (!x(o)&&!Object.getOwnPropertyNames(r).includes(o)||x(o)&&!Object.getOwnPropertySymbols(r).includes(o))&&O(n,o,c,e),n},{});}let p=Object.getOwnPropertyNames(r),f=Object.getOwnPropertySymbols(r);return [...p,...f].reduce((l,t)=>{let n=r[t],o=m(e)?e[t]:void 0;o!==void 0&&m(n)&&(n=T(o,n));let c=n;return O(l,t,c,r),l},i)}function P(e,...r){return r.reduce((s,i)=>T(s,i),e)}function u(e){return e.startsWith("$$")?`#node-config-input-${e.replace("$$","")}`:e.startsWith("$")?`#node-input-${e.replace("$","")}`:e}function B(e,r){let s=u(e),i=document.querySelector(s);if(!i)throw new Error(`Element with id '${e}' not found`);let[p,f]=solidJs.createSignal(r||""),a=()=>{f(i.value);},l=t=>{i.value!==t&&(i.value=t);};return i.addEventListener("input",a),solidJs.onCleanup(()=>{console.log("JE CLEAN"),i.removeEventListener("input",a);}),solidJs.createEffect(()=>{l(p());}),f(i.value||r),[p,f]}var N={};function J(e){return P(N,e)}function j(e){return u(e).split("-input-")[1]}function z(e){function r(t){return e[t]}let s=(t,n,o)=>{let c=(o==null?void 0:o.selected)||r(j(t)),g=u(t),y=n;o!=null&&o.emptyValue&&(y=[{value:"",text:o.emptyValue},...n]),$(g).empty().append(y.map(b=>$("<option>",{value:b.value,text:b.text,selected:b.value===c})));},i=t=>{let n=t;return $(`#node-input-${n}`).val()};function p(t,n){let o=u(t);$(o).text(n);}function f(t){let n=u(t);return $(n)}function a(t,n){let o=u(t);$(o).val(n);}function l(t,n){let c=(Array.isArray(t)?t:[t]).map(u).join(", ");$(c).on("input",()=>{let g=$(c).map(function(){return $(this).val()}).get();n(g);});}return {getInputValue:i,watchInput:l,setText:p,setInputValue:a,jqSelector:f,initSelect:s}}exports.createEditorNode=J;exports.createReactiveField=B;exports.domHelper=z;exports.resolveSelector=u;
1
+ 'use strict';
2
+
3
+ var solidJs = require('solid-js');
4
+
5
+ // node_modules/.pnpm/is-what@5.0.2/node_modules/is-what/dist/getType.js
6
+ function getType(payload) {
7
+ return Object.prototype.toString.call(payload).slice(8, -1);
8
+ }
9
+
10
+ // node_modules/.pnpm/is-what@5.0.2/node_modules/is-what/dist/isPlainObject.js
11
+ function isPlainObject(payload) {
12
+ if (getType(payload) !== "Object")
13
+ return false;
14
+ const prototype = Object.getPrototypeOf(payload);
15
+ return !!prototype && prototype.constructor === Object && prototype === Object.prototype;
16
+ }
17
+
18
+ // node_modules/.pnpm/is-what@5.0.2/node_modules/is-what/dist/isSymbol.js
19
+ function isSymbol(payload) {
20
+ return getType(payload) === "Symbol";
21
+ }
22
+
23
+ // node_modules/.pnpm/merge-anything@6.0.2/node_modules/merge-anything/dist/merge.js
24
+ function assignProp(carry, key, newVal, originalObject) {
25
+ const propType = {}.propertyIsEnumerable.call(originalObject, key) ? "enumerable" : "nonenumerable";
26
+ if (propType === "enumerable")
27
+ carry[key] = newVal;
28
+ if (propType === "nonenumerable") {
29
+ Object.defineProperty(carry, key, {
30
+ value: newVal,
31
+ enumerable: false,
32
+ writable: true,
33
+ configurable: true
34
+ });
35
+ }
36
+ }
37
+ function mergeRecursively(origin, newComer, compareFn) {
38
+ if (!isPlainObject(newComer))
39
+ return newComer;
40
+ let newObject = {};
41
+ if (isPlainObject(origin)) {
42
+ const props2 = Object.getOwnPropertyNames(origin);
43
+ const symbols2 = Object.getOwnPropertySymbols(origin);
44
+ newObject = [...props2, ...symbols2].reduce((carry, key) => {
45
+ const targetVal = origin[key];
46
+ if (!isSymbol(key) && !Object.getOwnPropertyNames(newComer).includes(key) || isSymbol(key) && !Object.getOwnPropertySymbols(newComer).includes(key)) {
47
+ assignProp(carry, key, targetVal, origin);
48
+ }
49
+ return carry;
50
+ }, {});
51
+ }
52
+ const props = Object.getOwnPropertyNames(newComer);
53
+ const symbols = Object.getOwnPropertySymbols(newComer);
54
+ const result = [...props, ...symbols].reduce((carry, key) => {
55
+ let newVal = newComer[key];
56
+ const targetVal = isPlainObject(origin) ? origin[key] : void 0;
57
+ if (targetVal !== void 0 && isPlainObject(newVal)) {
58
+ newVal = mergeRecursively(targetVal, newVal);
59
+ }
60
+ const propToAssign = newVal;
61
+ assignProp(carry, key, propToAssign, newComer);
62
+ return carry;
63
+ }, newObject);
64
+ return result;
65
+ }
66
+ function merge(object, ...otherObjects) {
67
+ return otherObjects.reduce((result, newComer) => {
68
+ return mergeRecursively(result, newComer);
69
+ }, object);
70
+ }
71
+
72
+ // src/editor/utils.ts
73
+ function resolveSelector(inSelector) {
74
+ if (inSelector.startsWith("$$")) {
75
+ return `#node-config-input-${inSelector.replace("$$", "")}`;
76
+ }
77
+ if (inSelector.startsWith("$")) {
78
+ return `#node-input-${inSelector.replace("$", "")}`;
79
+ }
80
+ return inSelector;
81
+ }
82
+ function createReactiveField(selector, defaultValue) {
83
+ const realSelector = resolveSelector(selector);
84
+ const formElement = document.querySelector(realSelector);
85
+ if (!formElement) {
86
+ throw new Error(`Element with id '${selector}' not found`);
87
+ }
88
+ const [fieldValue, setFieldValue] = solidJs.createSignal(defaultValue || "");
89
+ const updateSignal = () => {
90
+ setFieldValue(formElement.value);
91
+ };
92
+ const updateDOM = (newValue) => {
93
+ if (formElement.value !== newValue) {
94
+ formElement.value = newValue;
95
+ }
96
+ };
97
+ formElement.addEventListener("input", updateSignal);
98
+ solidJs.onCleanup(() => {
99
+ console.log("JE CLEAN");
100
+ formElement.removeEventListener("input", updateSignal);
101
+ });
102
+ solidJs.createEffect(() => {
103
+ updateDOM(fieldValue());
104
+ });
105
+ setFieldValue(formElement.value || defaultValue);
106
+ return [fieldValue, setFieldValue];
107
+ }
108
+
109
+ // src/editor/index.ts
110
+ var defaultNodeDef = {};
111
+ function createEditorNode(props) {
112
+ return merge(defaultNodeDef, props);
113
+ }
114
+ function resolveInputKey(selector) {
115
+ const realSelector = resolveSelector(selector);
116
+ return realSelector.split("-input-")[1];
117
+ }
118
+ function domHelper(vm) {
119
+ function getVmInputKey(key) {
120
+ return vm[key];
121
+ }
122
+ const initSelect = (selector, options, params) => {
123
+ const selectedValue = (params == null ? void 0 : params.selected) || getVmInputKey(resolveInputKey(selector));
124
+ const realSelector = resolveSelector(selector);
125
+ let realOptions = options;
126
+ if (params == null ? void 0 : params.emptyValue) {
127
+ realOptions = [{ value: "", text: params.emptyValue }, ...options];
128
+ }
129
+ $(realSelector).empty().append(
130
+ realOptions.map((opt) => {
131
+ return $("<option>", { value: opt.value, text: opt.text, selected: opt.value === selectedValue });
132
+ })
133
+ );
134
+ };
135
+ const getInputValue = (key) => {
136
+ const keyStr = key;
137
+ return $(`#node-input-${keyStr}`).val();
138
+ };
139
+ function setText(selector, text) {
140
+ const realSelector = resolveSelector(selector);
141
+ $(realSelector).text(text);
142
+ }
143
+ function jqSelector(selector) {
144
+ const realSelector = resolveSelector(selector);
145
+ return $(realSelector);
146
+ }
147
+ function setInputValue(selector, val) {
148
+ const realSelector = resolveSelector(selector);
149
+ $(realSelector).val(val);
150
+ }
151
+ function watchInput(selectors, callback) {
152
+ const selectorsArray = Array.isArray(selectors) ? selectors : [selectors];
153
+ const realSelectors = selectorsArray.map(resolveSelector).join(", ");
154
+ $(realSelectors).on("input", () => {
155
+ const values = $(realSelectors).map(function() {
156
+ return $(this).val();
157
+ }).get();
158
+ callback(values);
159
+ });
160
+ }
161
+ return {
162
+ getInputValue,
163
+ watchInput,
164
+ setText,
165
+ setInputValue,
166
+ jqSelector,
167
+ initSelect
168
+ };
169
+ }
170
+
171
+ exports.createEditorNode = createEditorNode;
172
+ exports.createReactiveField = createReactiveField;
173
+ exports.domHelper = domHelper;
174
+ exports.resolveSelector = resolveSelector;
175
+ //# sourceMappingURL=index.cjs.map
176
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../node_modules/.pnpm/is-what@5.0.2/node_modules/is-what/dist/getType.js","../../node_modules/.pnpm/is-what@5.0.2/node_modules/is-what/dist/isPlainObject.js","../../node_modules/.pnpm/is-what@5.0.2/node_modules/is-what/dist/isSymbol.js","../../node_modules/.pnpm/merge-anything@6.0.2/node_modules/merge-anything/dist/merge.js","../../src/editor/utils.ts","../../src/editor/dom.ts","../../src/editor/index.ts"],"names":["props","symbols","createSignal","onCleanup","createEffect"],"mappings":";;;;;AACO,SAAS,QAAQ,OAAS,EAAA;AAC7B,EAAO,OAAA,MAAA,CAAO,UAAU,QAAS,CAAA,IAAA,CAAK,OAAO,CAAE,CAAA,KAAA,CAAM,GAAG,CAAE,CAAA,CAAA;AAC9D;;;ACEO,SAAS,cAAc,OAAS,EAAA;AACnC,EAAI,IAAA,OAAA,CAAQ,OAAO,CAAM,KAAA,QAAA;AACrB,IAAO,OAAA,KAAA;AACX,EAAM,MAAA,SAAA,GAAY,MAAO,CAAA,cAAA,CAAe,OAAO,CAAA;AAC/C,EAAA,OAAO,CAAC,CAAC,SAAA,IAAa,UAAU,WAAgB,KAAA,MAAA,IAAU,cAAc,MAAO,CAAA,SAAA;AACnF;;;ACRO,SAAS,SAAS,OAAS,EAAA;AAC9B,EAAO,OAAA,OAAA,CAAQ,OAAO,CAAM,KAAA,QAAA;AAChC;;;ACFA,SAAS,UAAW,CAAA,K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AA,IACA,aAAA;AAAA,IACA,UAAA;AAAA,IACA;AAAA,GACF;AACF","file":"index.cjs","sourcesContent":["/** Returns the object type of the given payload */\nexport function getType(payload) {\n return Object.prototype.toString.call(payload).slice(8, -1);\n}\n","import { getType } from './getType.js';\n/**\n * Returns whether the payload is a plain JavaScript object (excluding special classes or objects\n * with other prototypes)\n */\nexport function isPlainObject(payload) {\n if (getType(payload) !== 'Object')\n return false;\n const prototype = Object.getPrototypeOf(payload);\n return !!prototype && prototype.constructor === Object && prototype === Object.prototype;\n}\n","import { getType } from './getType.js';\n/** Returns whether the payload is a Symbol */\nexport function isSymbol(payload) {\n return getType(payload) === 'Symbol';\n}\n","import { isPlainObject, isSymbol } from 'is-what';\nimport { concatArrays } from './extensions.js';\nfunction assignProp(carry, key, newVal, originalObject) {\n const propType = {}.propertyIsEnumerable.call(originalObject, key)\n ? 'enumerable'\n : 'nonenumerable';\n if (propType === 'enumerable')\n carry[key] = newVal;\n if (propType === 'nonenumerable') {\n Object.defineProperty(carry, key, {\n value: newVal,\n enumerable: false,\n writable: true,\n configurable: true,\n });\n }\n}\nfunction mergeRecursively(origin, newComer, compareFn) {\n // always return newComer if its not an object\n if (!isPlainObject(newComer))\n return newComer;\n // define newObject to merge all values upon\n let newObject = {};\n if (isPlainObject(origin)) {\n const props = Object.getOwnPropertyNames(origin);\n const symbols = Object.getOwnPropertySymbols(origin);\n newObject = [...props, ...symbols].reduce((carry, key) => {\n const targetVal = origin[key];\n if ((!isSymbol(key) && !Object.getOwnPropertyNames(newComer).includes(key)) ||\n (isSymbol(key) && !Object.getOwnPropertySymbols(newComer).includes(key))) {\n assignProp(carry, key, targetVal, origin);\n }\n return carry;\n }, {});\n }\n // newObject has all properties that newComer hasn't\n const props = Object.getOwnPropertyNames(newComer);\n const symbols = Object.getOwnPropertySymbols(newComer);\n const result = [...props, ...symbols].reduce((carry, key) => {\n // re-define the origin and newComer as targetVal and newVal\n let newVal = newComer[key];\n const targetVal = isPlainObject(origin) ? origin[key] : undefined;\n // When newVal is an object do the merge recursively\n if (targetVal !== undefined && isPlainObject(newVal)) {\n newVal = mergeRecursively(targetVal, newVal, compareFn);\n }\n const propToAssign = compareFn ? compareFn(targetVal, newVal, key) : newVal;\n assignProp(carry, key, propToAssign, newComer);\n return carry;\n }, newObject);\n return result;\n}\n/**\n * Merge anything recursively.\n * Objects get merged, special objects (classes etc.) are re-assigned \"as is\".\n * Basic types overwrite objects or other basic types.\n */\nexport function merge(object, ...otherObjects) {\n return otherObjects.reduce((result, newComer) => {\n return mergeRecursively(result, newComer);\n }, object);\n}\nexport function mergeAndCompare(compareFn, object, ...otherObjects) {\n return otherObjects.reduce((result, newComer) => {\n return mergeRecursively(result, newComer, compareFn);\n }, object);\n}\nexport function mergeAndConcat(object, ...otherObjects) {\n return otherObjects.reduce((result, newComer) => {\n return mergeRecursively(result, newComer, concatArrays);\n }, object);\n}\n// import { Timestamp } from '../test/Timestamp'\n// type T1 = { date: Timestamp }\n// type T2 = [{ b: string[] }, { b: number[] }, { date: Timestamp }]\n// type TestT = Merge<T1, T2>\n// type A1 = { arr: string[] }\n// type A2 = { arr: number[] }\n// type A3 = { arr: boolean[] }\n// type TestA = Merge<A1, [A2, A3]>\n// interface I1 {\n// date: Timestamp\n// }\n// interface I2 {\n// date: Timestamp\n// }\n// const _a: I2 = { date: '' } as unknown as I2\n// type TestI = Merge<I1, [I2]>\n// // ReturnType<(typeof merge)<I1, I2>>\n// const a = merge(_a, [_a])\n// interface Arguments extends Record<string | number | symbol, unknown> {\n// key: string;\n// }\n// const aa1: Arguments = { key: \"value1\" }\n// const aa2: Arguments = { key: \"value2\" }\n// const aa = merge(a1, a2);\n// interface Barguments {\n// key: string\n// }\n// const ba1: Barguments = { key: 'value1' }\n// const ba2: Barguments = { key: 'value2' }\n// const ba = merge(ba1, ba2)\n// interface Carguments {\n// key: string\n// }\n// const ca = merge<Carguments, Carguments[]>({ key: 'value1' }, { key: 'value2' })\n// type P = Pop<Carguments[]>\n","export function resolveSelector(inSelector: string) {\n if (inSelector.startsWith('$$')) {\n return `#node-config-input-${inSelector.replace('$$', '')}`;\n }\n\n if (inSelector.startsWith('$')) {\n return `#node-input-${inSelector.replace('$', '')}`;\n }\n\n return inSelector;\n}\n\nfunction isNodeInput(selector: string) {\n const isShortcut = selector.startsWith('$$') || selector.startsWith('$');\n const isFullSelector = selector.startsWith('#node-config-input') || selector.startsWith('#node-input');\n\n return isShortcut || isFullSelector;\n}\n","import { createEffect, createSignal, onCleanup } from 'solid-js';\nimport { resolveSelector } from './utils';\n\nexport function createReactiveField<T extends HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement>(\n selector: string,\n defaultValue?: string,\n): [() => string, (value: string) => void] {\n const realSelector = resolveSelector(selector);\n\n const formElement = document.querySelector(realSelector) as T;\n\n if (!formElement) {\n throw new Error(`Element with id '${selector}' not found`);\n }\n\n const [fieldValue, setFieldValue] = createSignal(defaultValue || '');\n\n const updateSignal = () => {\n setFieldValue(formElement.value);\n };\n\n const updateDOM = (newValue: string) => {\n if (formElement.value !== newValue) {\n formElement.value = newValue;\n }\n };\n\n formElement.addEventListener('input', updateSignal);\n\n onCleanup(() => {\n console.log('JE CLEAN');\n formElement.removeEventListener('input', updateSignal);\n });\n\n createEffect(() => {\n updateDOM(fieldValue());\n });\n\n setFieldValue(formElement.value || defaultValue);\n\n return [fieldValue, setFieldValue];\n}\n","// @ts-ignore\nimport { merge } from 'merge-anything';\nimport type { EditorNodeDef, EditorNodeInstance, EditorNodeProperties } from 'node-red';\nimport type { EditorDomHelper } from './types';\nimport { resolveSelector } from './utils';\nexport type * from './types';\nexport * from './utils';\nexport * from './dom';\n\nconst defaultNodeDef: Partial<EditorNodeDef> = {};\n\nexport function createEditorNode<\n TProps extends EditorNodeProperties,\n TCreds = undefined,\n TInstProps extends TProps = TProps,\n>(props: Partial<EditorNodeDef<TProps, TCreds, TInstProps>>): EditorNodeDef<TProps, TCreds, TInstProps> {\n return merge(defaultNodeDef, props) as EditorNodeDef<TProps, TCreds, TInstProps>;\n}\n\nfunction resolveInputKey(selector: string) {\n const realSelector = resolveSelector(selector);\n return realSelector.split('-input-')[1];\n}\n\nexport function domHelper<TProps>(vm: EditorNodeInstance) {\n function getVmInputKey(key: string) {\n return vm[key];\n }\n\n const initSelect = (\n selector: string,\n options: Record<string, string>[],\n params?: EditorDomHelper.InitSelectParams,\n ) => {\n const selectedValue = params?.selected || getVmInputKey(resolveInputKey(selector));\n const realSelector = resolveSelector(selector);\n let realOptions = options;\n if (params?.emptyValue) {\n realOptions = [{ value: '', text: params.emptyValue }, ...options];\n }\n $(realSelector)\n .empty()\n .append(\n realOptions.map((opt) => {\n return $('<option>', { value: opt.value, text: opt.text, selected: opt.value === selectedValue });\n }),\n );\n };\n\n const getInputValue = (key: Exclude<keyof TProps, 'inputs'>) => {\n const keyStr = key as string;\n return $(`#node-input-${keyStr}`).val();\n };\n\n function setText(selector: string, text: string) {\n const realSelector = resolveSelector(selector);\n $(realSelector).text(text);\n }\n\n function jqSelector(selector: string) {\n const realSelector = resolveSelector(selector);\n return $(realSelector);\n }\n\n function setInputValue(selector: string, val: string) {\n const realSelector = resolveSelector(selector);\n $(realSelector).val(val);\n }\n\n function watchInput<T = any>(selectors: string | string[], callback: (values: T[]) => void) {\n const selectorsArray = Array.isArray(selectors) ? selectors : [selectors];\n const realSelectors = selectorsArray.map(resolveSelector).join(', ');\n\n $(realSelectors).on('input', () => {\n const values = $(realSelectors)\n .map(function () {\n return $(this).val() as T;\n })\n .get();\n\n callback(values);\n });\n }\n\n return {\n getInputValue,\n watchInput,\n setText,\n setInputValue,\n jqSelector,\n initSelect,\n };\n}\n"]}
@@ -1 +1,171 @@
1
- import {createSignal,onCleanup,createEffect}from'solid-js';function d(e){return Object.prototype.toString.call(e).slice(8,-1)}function m(e){if(d(e)!=="Object")return !1;let r=Object.getPrototypeOf(e);return !!r&&r.constructor===Object&&r===Object.prototype}function x(e){return d(e)==="Symbol"}function O(e,r,s,i){let p={}.propertyIsEnumerable.call(i,r)?"enumerable":"nonenumerable";p==="enumerable"&&(e[r]=s),p==="nonenumerable"&&Object.defineProperty(e,r,{value:s,enumerable:!1,writable:!0,configurable:!0});}function T(e,r,s){if(!m(r))return r;let i={};if(m(e)){let l=Object.getOwnPropertyNames(e),t=Object.getOwnPropertySymbols(e);i=[...l,...t].reduce((n,o)=>{let c=e[o];return (!x(o)&&!Object.getOwnPropertyNames(r).includes(o)||x(o)&&!Object.getOwnPropertySymbols(r).includes(o))&&O(n,o,c,e),n},{});}let p=Object.getOwnPropertyNames(r),f=Object.getOwnPropertySymbols(r);return [...p,...f].reduce((l,t)=>{let n=r[t],o=m(e)?e[t]:void 0;o!==void 0&&m(n)&&(n=T(o,n));let c=n;return O(l,t,c,r),l},i)}function P(e,...r){return r.reduce((s,i)=>T(s,i),e)}function u(e){return e.startsWith("$$")?`#node-config-input-${e.replace("$$","")}`:e.startsWith("$")?`#node-input-${e.replace("$","")}`:e}function B(e,r){let s=u(e),i=document.querySelector(s);if(!i)throw new Error(`Element with id '${e}' not found`);let[p,f]=createSignal(r||""),a=()=>{f(i.value);},l=t=>{i.value!==t&&(i.value=t);};return i.addEventListener("input",a),onCleanup(()=>{console.log("JE CLEAN"),i.removeEventListener("input",a);}),createEffect(()=>{l(p());}),f(i.value||r),[p,f]}var N={};function J(e){return P(N,e)}function j(e){return u(e).split("-input-")[1]}function z(e){function r(t){return e[t]}let s=(t,n,o)=>{let c=(o==null?void 0:o.selected)||r(j(t)),g=u(t),y=n;o!=null&&o.emptyValue&&(y=[{value:"",text:o.emptyValue},...n]),$(g).empty().append(y.map(b=>$("<option>",{value:b.value,text:b.text,selected:b.value===c})));},i=t=>{let n=t;return $(`#node-input-${n}`).val()};function p(t,n){let o=u(t);$(o).text(n);}function f(t){let n=u(t);return $(n)}function a(t,n){let o=u(t);$(o).val(n);}function l(t,n){let c=(Array.isArray(t)?t:[t]).map(u).join(", ");$(c).on("input",()=>{let g=$(c).map(function(){return $(this).val()}).get();n(g);});}return {getInputValue:i,watchInput:l,setText:p,setInputValue:a,jqSelector:f,initSelect:s}}export{J as createEditorNode,B as createReactiveField,z as domHelper,u as resolveSelector};
1
+ import { createSignal, onCleanup, createEffect } from 'solid-js';
2
+
3
+ // node_modules/.pnpm/is-what@5.0.2/node_modules/is-what/dist/getType.js
4
+ function getType(payload) {
5
+ return Object.prototype.toString.call(payload).slice(8, -1);
6
+ }
7
+
8
+ // node_modules/.pnpm/is-what@5.0.2/node_modules/is-what/dist/isPlainObject.js
9
+ function isPlainObject(payload) {
10
+ if (getType(payload) !== "Object")
11
+ return false;
12
+ const prototype = Object.getPrototypeOf(payload);
13
+ return !!prototype && prototype.constructor === Object && prototype === Object.prototype;
14
+ }
15
+
16
+ // node_modules/.pnpm/is-what@5.0.2/node_modules/is-what/dist/isSymbol.js
17
+ function isSymbol(payload) {
18
+ return getType(payload) === "Symbol";
19
+ }
20
+
21
+ // node_modules/.pnpm/merge-anything@6.0.2/node_modules/merge-anything/dist/merge.js
22
+ function assignProp(carry, key, newVal, originalObject) {
23
+ const propType = {}.propertyIsEnumerable.call(originalObject, key) ? "enumerable" : "nonenumerable";
24
+ if (propType === "enumerable")
25
+ carry[key] = newVal;
26
+ if (propType === "nonenumerable") {
27
+ Object.defineProperty(carry, key, {
28
+ value: newVal,
29
+ enumerable: false,
30
+ writable: true,
31
+ configurable: true
32
+ });
33
+ }
34
+ }
35
+ function mergeRecursively(origin, newComer, compareFn) {
36
+ if (!isPlainObject(newComer))
37
+ return newComer;
38
+ let newObject = {};
39
+ if (isPlainObject(origin)) {
40
+ const props2 = Object.getOwnPropertyNames(origin);
41
+ const symbols2 = Object.getOwnPropertySymbols(origin);
42
+ newObject = [...props2, ...symbols2].reduce((carry, key) => {
43
+ const targetVal = origin[key];
44
+ if (!isSymbol(key) && !Object.getOwnPropertyNames(newComer).includes(key) || isSymbol(key) && !Object.getOwnPropertySymbols(newComer).includes(key)) {
45
+ assignProp(carry, key, targetVal, origin);
46
+ }
47
+ return carry;
48
+ }, {});
49
+ }
50
+ const props = Object.getOwnPropertyNames(newComer);
51
+ const symbols = Object.getOwnPropertySymbols(newComer);
52
+ const result = [...props, ...symbols].reduce((carry, key) => {
53
+ let newVal = newComer[key];
54
+ const targetVal = isPlainObject(origin) ? origin[key] : void 0;
55
+ if (targetVal !== void 0 && isPlainObject(newVal)) {
56
+ newVal = mergeRecursively(targetVal, newVal);
57
+ }
58
+ const propToAssign = newVal;
59
+ assignProp(carry, key, propToAssign, newComer);
60
+ return carry;
61
+ }, newObject);
62
+ return result;
63
+ }
64
+ function merge(object, ...otherObjects) {
65
+ return otherObjects.reduce((result, newComer) => {
66
+ return mergeRecursively(result, newComer);
67
+ }, object);
68
+ }
69
+
70
+ // src/editor/utils.ts
71
+ function resolveSelector(inSelector) {
72
+ if (inSelector.startsWith("$$")) {
73
+ return `#node-config-input-${inSelector.replace("$$", "")}`;
74
+ }
75
+ if (inSelector.startsWith("$")) {
76
+ return `#node-input-${inSelector.replace("$", "")}`;
77
+ }
78
+ return inSelector;
79
+ }
80
+ function createReactiveField(selector, defaultValue) {
81
+ const realSelector = resolveSelector(selector);
82
+ const formElement = document.querySelector(realSelector);
83
+ if (!formElement) {
84
+ throw new Error(`Element with id '${selector}' not found`);
85
+ }
86
+ const [fieldValue, setFieldValue] = createSignal(defaultValue || "");
87
+ const updateSignal = () => {
88
+ setFieldValue(formElement.value);
89
+ };
90
+ const updateDOM = (newValue) => {
91
+ if (formElement.value !== newValue) {
92
+ formElement.value = newValue;
93
+ }
94
+ };
95
+ formElement.addEventListener("input", updateSignal);
96
+ onCleanup(() => {
97
+ console.log("JE CLEAN");
98
+ formElement.removeEventListener("input", updateSignal);
99
+ });
100
+ createEffect(() => {
101
+ updateDOM(fieldValue());
102
+ });
103
+ setFieldValue(formElement.value || defaultValue);
104
+ return [fieldValue, setFieldValue];
105
+ }
106
+
107
+ // src/editor/index.ts
108
+ var defaultNodeDef = {};
109
+ function createEditorNode(props) {
110
+ return merge(defaultNodeDef, props);
111
+ }
112
+ function resolveInputKey(selector) {
113
+ const realSelector = resolveSelector(selector);
114
+ return realSelector.split("-input-")[1];
115
+ }
116
+ function domHelper(vm) {
117
+ function getVmInputKey(key) {
118
+ return vm[key];
119
+ }
120
+ const initSelect = (selector, options, params) => {
121
+ const selectedValue = (params == null ? void 0 : params.selected) || getVmInputKey(resolveInputKey(selector));
122
+ const realSelector = resolveSelector(selector);
123
+ let realOptions = options;
124
+ if (params == null ? void 0 : params.emptyValue) {
125
+ realOptions = [{ value: "", text: params.emptyValue }, ...options];
126
+ }
127
+ $(realSelector).empty().append(
128
+ realOptions.map((opt) => {
129
+ return $("<option>", { value: opt.value, text: opt.text, selected: opt.value === selectedValue });
130
+ })
131
+ );
132
+ };
133
+ const getInputValue = (key) => {
134
+ const keyStr = key;
135
+ return $(`#node-input-${keyStr}`).val();
136
+ };
137
+ function setText(selector, text) {
138
+ const realSelector = resolveSelector(selector);
139
+ $(realSelector).text(text);
140
+ }
141
+ function jqSelector(selector) {
142
+ const realSelector = resolveSelector(selector);
143
+ return $(realSelector);
144
+ }
145
+ function setInputValue(selector, val) {
146
+ const realSelector = resolveSelector(selector);
147
+ $(realSelector).val(val);
148
+ }
149
+ function watchInput(selectors, callback) {
150
+ const selectorsArray = Array.isArray(selectors) ? selectors : [selectors];
151
+ const realSelectors = selectorsArray.map(resolveSelector).join(", ");
152
+ $(realSelectors).on("input", () => {
153
+ const values = $(realSelectors).map(function() {
154
+ return $(this).val();
155
+ }).get();
156
+ callback(values);
157
+ });
158
+ }
159
+ return {
160
+ getInputValue,
161
+ watchInput,
162
+ setText,
163
+ setInputValue,
164
+ jqSelector,
165
+ initSelect
166
+ };
167
+ }
168
+
169
+ export { createEditorNode, createReactiveField, domHelper, resolveSelector };
170
+ //# sourceMappingURL=index.js.map
171
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../node_modules/.pnpm/is-what@5.0.2/node_modules/is-what/dist/getType.js","../../node_modules/.pnpm/is-what@5.0.2/node_modules/is-what/dist/isPlainObject.js","../../node_modules/.pnpm/is-what@5.0.2/node_modules/is-what/dist/isSymbol.js","../../node_modules/.pnpm/merge-anything@6.0.2/node_modules/merge-anything/dist/merge.js","../../src/editor/utils.ts","../../src/editor/dom.ts","../../src/editor/index.ts"],"names":["props","symbols"],"mappings":";;;AACO,SAAS,QAAQ,OAAS,EAAA;AAC7B,EAAO,OAAA,MAAA,CAAO,UAAU,QAAS,CAAA,IAAA,CAAK,OAAO,CAAE,CAAA,KAAA,CAAM,GAAG,CAAE,CAAA,CAAA;AAC9D;;;ACEO,SAAS,cAAc,OAAS,EAAA;AACnC,EAAI,IAAA,OAAA,CAAQ,OAAO,CAAM,KAAA,QAAA;AACrB,IAAO,OAAA,KAAA;AACX,EAAM,MAAA,SAAA,GAAY,MAAO,CAAA,cAAA,CAAe,OAAO,CAAA;AAC/C,EAAA,OAAO,CAAC,CAAC,SAAA,IAAa,UAAU,WAAgB,KAAA,MAAA,IAAU,cAAc,MAAO,CAAA,SAAA;AACnF;;;ACRO,SAAS,SAAS,OAAS,EAAA;AAC9B,EAAO,OAAA,OAAA,CAAQ,OAAO,CAAM,KAAA,QAAA;AAChC;;;ACFA,SAAS,UAAW,CAAA,KAAA,EAAO,GAAK,EAAA,MAAA,EAAQ,cAAgB,EAAA;AACpD,EAAM,MAAA,QAAA,GAAW,EAAG,CAAA,oBAAA,CAAqB,KAAK,cAAgB,EAAA,GAAG,IAC3D,YACA,GAAA,eAAA;AACN,EAAA,IAAI,QAAa,KAAA,YAAA;AACb,IAAA,KAAA,CAAM,GAAG,CAAI,GAAA,MAAA;AACjB,EAAA,IAAI,aAAa,eAAiB,EAAA;AAC9B,IAAO,MAAA,CAAA,cAAA,CAAe,OAAO,GAAK,EAAA;AAAA,MAC9B,KAAO,EAAA,MAAA;AAAA,MACP,UAAY,EAAA,KAAA;AAAA,MACZ,QAAU,EAAA,IAAA;AAAA,MACV,YAAc,EAAA;AAAA,KACjB,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,SAAA,aAAA,CAAc,UAAkB,GAAa,EAAA;AACpD,IAAM,MAAA,YAAA,GAAe,gBAAgB,QAAQ,CAAA;AAC7C,IAAE,CAAA,CAAA,YAAY,CAAE,CAAA,GAAA,CAAI,GAAG,CAAA;AAAA;AAGzB,EAAS,SAAA,UAAA,CAAoB,WAA8B,QAAiC,EAAA;AAC1F,IAAA,MAAM,iBAAiB,KAAM,CAAA,OAAA,CAAQ,SAAS,CAAI,GAAA,SAAA,GAAY,CAAC,SAAS,CAAA;AACxE,IAAA,MAAM,gBAAgB,cAAe,CAAA,GAAA,CAAI,eAAe,CAAA,CAAE,KAAK,IAAI,CAAA;AAEnE,IAAA,CAAA,CAAE,aAAa,CAAA,CAAE,EAAG,CAAA,OAAA,EAAS,MAAM;AACjC,MAAA,MAAM,MAAS,GAAA,CAAA,CAAE,aAAa,CAAA,CAC3B,IAAI,WAAY;AACf,QAAO,OAAA,CAAA,CAAE,IAAI,CAAA,CAAE,GAAI,EAAA;AAAA,OACpB,EACA,GAAI,EAAA;AAEP,MAAA,QAAA,CAAS,MAAM,CAAA;AAAA,KAChB,CAAA;AAAA;AAGH,EAAO,OAAA;AAAA,IACL,aAAA;AAAA,IACA,UAAA;AAAA,IACA,OAAA;AAAA,IACA,aAAA;AAAA,IACA,UAAA;AAAA,IACA;AAAA,GACF;AACF","file":"index.js","sourcesContent":["/** Returns the object type of the given payload */\nexport function getType(payload) {\n return Object.prototype.toString.call(payload).slice(8, -1);\n}\n","import { getType } from './getType.js';\n/**\n * Returns whether the payload is a plain JavaScript object (excluding special classes or objects\n * with other prototypes)\n */\nexport function isPlainObject(payload) {\n if (getType(payload) !== 'Object')\n return false;\n const prototype = Object.getPrototypeOf(payload);\n return !!prototype && prototype.constructor === Object && prototype === Object.prototype;\n}\n","import { getType } from './getType.js';\n/** Returns whether the payload is a Symbol */\nexport function isSymbol(payload) {\n return getType(payload) === 'Symbol';\n}\n","import { isPlainObject, isSymbol } from 'is-what';\nimport { concatArrays } from './extensions.js';\nfunction assignProp(carry, key, newVal, originalObject) {\n const propType = {}.propertyIsEnumerable.call(originalObject, key)\n ? 'enumerable'\n : 'nonenumerable';\n if (propType === 'enumerable')\n carry[key] = newVal;\n if (propType === 'nonenumerable') {\n Object.defineProperty(carry, key, {\n value: newVal,\n enumerable: false,\n writable: true,\n configurable: true,\n });\n }\n}\nfunction mergeRecursively(origin, newComer, compareFn) {\n // always return newComer if its not an object\n if (!isPlainObject(newComer))\n return newComer;\n // define newObject to merge all values upon\n let newObject = {};\n if (isPlainObject(origin)) {\n const props = Object.getOwnPropertyNames(origin);\n const symbols = Object.getOwnPropertySymbols(origin);\n newObject = [...props, ...symbols].reduce((carry, key) => {\n const targetVal = origin[key];\n if ((!isSymbol(key) && !Object.getOwnPropertyNames(newComer).includes(key)) ||\n (isSymbol(key) && !Object.getOwnPropertySymbols(newComer).includes(key))) {\n assignProp(carry, key, targetVal, origin);\n }\n return carry;\n }, {});\n }\n // newObject has all properties that newComer hasn't\n const props = Object.getOwnPropertyNames(newComer);\n const symbols = Object.getOwnPropertySymbols(newComer);\n const result = [...props, ...symbols].reduce((carry, key) => {\n // re-define the origin and newComer as targetVal and newVal\n let newVal = newComer[key];\n const targetVal = isPlainObject(origin) ? origin[key] : undefined;\n // When newVal is an object do the merge recursively\n if (targetVal !== undefined && isPlainObject(newVal)) {\n newVal = mergeRecursively(targetVal, newVal, compareFn);\n }\n const propToAssign = compareFn ? compareFn(targetVal, newVal, key) : newVal;\n assignProp(carry, key, propToAssign, newComer);\n return carry;\n }, newObject);\n return result;\n}\n/**\n * Merge anything recursively.\n * Objects get merged, special objects (classes etc.) are re-assigned \"as is\".\n * Basic types overwrite objects or other basic types.\n */\nexport function merge(object, ...otherObjects) {\n return otherObjects.reduce((result, newComer) => {\n return mergeRecursively(result, newComer);\n }, object);\n}\nexport function mergeAndCompare(compareFn, object, ...otherObjects) {\n return otherObjects.reduce((result, newComer) => {\n return mergeRecursively(result, newComer, compareFn);\n }, object);\n}\nexport function mergeAndConcat(object, ...otherObjects) {\n return otherObjects.reduce((result, newComer) => {\n return mergeRecursively(result, newComer, concatArrays);\n }, object);\n}\n// import { Timestamp } from '../test/Timestamp'\n// type T1 = { date: Timestamp }\n// type T2 = [{ b: string[] }, { b: number[] }, { date: Timestamp }]\n// type TestT = Merge<T1, T2>\n// type A1 = { arr: string[] }\n// type A2 = { arr: number[] }\n// type A3 = { arr: boolean[] }\n// type TestA = Merge<A1, [A2, A3]>\n// interface I1 {\n// date: Timestamp\n// }\n// interface I2 {\n// date: Timestamp\n// }\n// const _a: I2 = { date: '' } as unknown as I2\n// type TestI = Merge<I1, [I2]>\n// // ReturnType<(typeof merge)<I1, I2>>\n// const a = merge(_a, [_a])\n// interface Arguments extends Record<string | number | symbol, unknown> {\n// key: string;\n// }\n// const aa1: Arguments = { key: \"value1\" }\n// const aa2: Arguments = { key: \"value2\" }\n// const aa = merge(a1, a2);\n// interface Barguments {\n// key: string\n// }\n// const ba1: Barguments = { key: 'value1' }\n// const ba2: Barguments = { key: 'value2' }\n// const ba = merge(ba1, ba2)\n// interface Carguments {\n// key: string\n// }\n// const ca = merge<Carguments, Carguments[]>({ key: 'value1' }, { key: 'value2' })\n// type P = Pop<Carguments[]>\n","export function resolveSelector(inSelector: string) {\n if (inSelector.startsWith('$$')) {\n return `#node-config-input-${inSelector.replace('$$', '')}`;\n }\n\n if (inSelector.startsWith('$')) {\n return `#node-input-${inSelector.replace('$', '')}`;\n }\n\n return inSelector;\n}\n\nfunction isNodeInput(selector: string) {\n const isShortcut = selector.startsWith('$$') || selector.startsWith('$');\n const isFullSelector = selector.startsWith('#node-config-input') || selector.startsWith('#node-input');\n\n return isShortcut || isFullSelector;\n}\n","import { createEffect, createSignal, onCleanup } from 'solid-js';\nimport { resolveSelector } from './utils';\n\nexport function createReactiveField<T extends HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement>(\n selector: string,\n defaultValue?: string,\n): [() => string, (value: string) => void] {\n const realSelector = resolveSelector(selector);\n\n const formElement = document.querySelector(realSelector) as T;\n\n if (!formElement) {\n throw new Error(`Element with id '${selector}' not found`);\n }\n\n const [fieldValue, setFieldValue] = createSignal(defaultValue || '');\n\n const updateSignal = () => {\n setFieldValue(formElement.value);\n };\n\n const updateDOM = (newValue: string) => {\n if (formElement.value !== newValue) {\n formElement.value = newValue;\n }\n };\n\n formElement.addEventListener('input', updateSignal);\n\n onCleanup(() => {\n console.log('JE CLEAN');\n formElement.removeEventListener('input', updateSignal);\n });\n\n createEffect(() => {\n updateDOM(fieldValue());\n });\n\n setFieldValue(formElement.value || defaultValue);\n\n return [fieldValue, setFieldValue];\n}\n","// @ts-ignore\nimport { merge } from 'merge-anything';\nimport type { EditorNodeDef, EditorNodeInstance, EditorNodeProperties } from 'node-red';\nimport type { EditorDomHelper } from './types';\nimport { resolveSelector } from './utils';\nexport type * from './types';\nexport * from './utils';\nexport * from './dom';\n\nconst defaultNodeDef: Partial<EditorNodeDef> = {};\n\nexport function createEditorNode<\n TProps extends EditorNodeProperties,\n TCreds = undefined,\n TInstProps extends TProps = TProps,\n>(props: Partial<EditorNodeDef<TProps, TCreds, TInstProps>>): EditorNodeDef<TProps, TCreds, TInstProps> {\n return merge(defaultNodeDef, props) as EditorNodeDef<TProps, TCreds, TInstProps>;\n}\n\nfunction resolveInputKey(selector: string) {\n const realSelector = resolveSelector(selector);\n return realSelector.split('-input-')[1];\n}\n\nexport function domHelper<TProps>(vm: EditorNodeInstance) {\n function getVmInputKey(key: string) {\n return vm[key];\n }\n\n const initSelect = (\n selector: string,\n options: Record<string, string>[],\n params?: EditorDomHelper.InitSelectParams,\n ) => {\n const selectedValue = params?.selected || getVmInputKey(resolveInputKey(selector));\n const realSelector = resolveSelector(selector);\n let realOptions = options;\n if (params?.emptyValue) {\n realOptions = [{ value: '', text: params.emptyValue }, ...options];\n }\n $(realSelector)\n .empty()\n .append(\n realOptions.map((opt) => {\n return $('<option>', { value: opt.value, text: opt.text, selected: opt.value === selectedValue });\n }),\n );\n };\n\n const getInputValue = (key: Exclude<keyof TProps, 'inputs'>) => {\n const keyStr = key as string;\n return $(`#node-input-${keyStr}`).val();\n };\n\n function setText(selector: string, text: string) {\n const realSelector = resolveSelector(selector);\n $(realSelector).text(text);\n }\n\n function jqSelector(selector: string) {\n const realSelector = resolveSelector(selector);\n return $(realSelector);\n }\n\n function setInputValue(selector: string, val: string) {\n const realSelector = resolveSelector(selector);\n $(realSelector).val(val);\n }\n\n function watchInput<T = any>(selectors: string | string[], callback: (values: T[]) => void) {\n const selectorsArray = Array.isArray(selectors) ? selectors : [selectors];\n const realSelectors = selectorsArray.map(resolveSelector).join(', ');\n\n $(realSelectors).on('input', () => {\n const values = $(realSelectors)\n .map(function () {\n return $(this).val() as T;\n })\n .get();\n\n callback(values);\n });\n }\n\n return {\n getInputValue,\n watchInput,\n setText,\n setInputValue,\n jqSelector,\n initSelect,\n };\n}\n"]}
package/dist/index.cjs CHANGED
@@ -1 +1,4 @@
1
- 'use strict';
1
+ 'use strict';
2
+
3
+ //# sourceMappingURL=index.cjs.map
4
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.cjs"}
package/dist/index.js CHANGED
@@ -0,0 +1,3 @@
1
+
2
+ //# sourceMappingURL=index.js.map
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@keload/node-red-dxp",
3
- "version": "1.4.1",
3
+ "version": "1.5.0",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -13,7 +13,8 @@
13
13
  "release:test": "pnpm release-it --dry-run",
14
14
  "docs:dev": "vitepress dev docs",
15
15
  "docs:build": "vitepress build docs",
16
- "docs:preview": "vitepress preview docs"
16
+ "docs:preview": "vitepress preview docs",
17
+ "test:unit": "vitest"
17
18
  },
18
19
  "publishConfig": {
19
20
  "access": "public"
@@ -51,7 +52,8 @@
51
52
  "tsup": "8.3.5",
52
53
  "tsx": "4.19.2",
53
54
  "typescript": "5.6.3",
54
- "vitepress": "1.5.0"
55
+ "vitepress": "1.5.0",
56
+ "vitest": "2.1.5"
55
57
  },
56
58
  "dependencies": {
57
59
  "@fullhuman/postcss-purgecss": "^6.0.0",