@keload/node-red-dxp 1.24.1 → 1.26.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.
@@ -8,7 +8,7 @@ var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=
8
8
  `),n=r-1;e=[...t.slice(0,n),`... (content truncated to fit terminal)`].join(`
9
9
  `)}return this.#c.write(e),this.#e=this.#b(e,t),this}start(e){if(e&&(this.text=e),this.#f)return this;if(!this.#d){let e=` `.repeat(this.#p)+this.#v(this.#h,` `)+(this.text?`- ${this.text}`:``)+this.#y(this.#g,` `);return e.trim()!==``&&this.#c.write(e+`
10
10
  `),this}return this.isSpinning?this:(this.#o.hideCursor&&pt.hide(this.#c),this.#o.discardStdin&&l.default.stdin.isTTY&&(this.#t=!0,jn.start()),this.render(),this.#l=setInterval(this.render.bind(this),this.interval),this)}stop(){return clearInterval(this.#l),this.#l=void 0,this.#r=0,this.#d&&(this.clear(),this.#o.hideCursor&&pt.show(this.#c)),this.#o.discardStdin&&l.default.stdin.isTTY&&this.#t&&(jn.stop(),this.#t=!1),this}succeed(e){return this.stopAndPersist({symbol:cn,text:e})}fail(e){return this.stopAndPersist({symbol:un,text:e})}warn(e){return this.stopAndPersist({symbol:ln,text:e})}info(e){return this.stopAndPersist({symbol:sn,text:e})}stopAndPersist(e={}){if(this.#f)return this;let t=e.prefixText??this.#h,n=this.#v(t,` `),r=e.symbol??` `,i=e.text??this.text,a=typeof i==`string`?(r?` `:``)+i:``,o=e.suffixText??this.#g,s=this.#y(o,` `),c=n+r+a+s+`
11
- `;return this.stop(),this.#c.write(c),this}};function Nn(e){return new Mn(e)}var Pn=`1.24.0`;function Fn(e){return Object.prototype.toString.call(e).slice(8,-1)}function W(e){if(Fn(e)!==`Object`)return!1;let t=Object.getPrototypeOf(e);return!!t&&t.constructor===Object&&t===Object.prototype}function In(e){return Fn(e)===`Symbol`}function Ln(e,t,n,r){let i={}.propertyIsEnumerable.call(r,t)?`enumerable`:`nonenumerable`;i===`enumerable`&&(e[t]=n),i===`nonenumerable`&&Object.defineProperty(e,t,{value:n,enumerable:!1,writable:!0,configurable:!0})}function Rn(e,t,n){if(!W(t))return t;let r={};if(W(e)){let n=Object.getOwnPropertyNames(e),i=Object.getOwnPropertySymbols(e);r=[...n,...i].reduce((n,r)=>{if(r===`__proto__`)return n;let i=e[r];return(!In(r)&&!Object.getOwnPropertyNames(t).includes(r)||In(r)&&!Object.getOwnPropertySymbols(t).includes(r))&&Ln(n,r,i,e),n},{})}let i=Object.getOwnPropertyNames(t),a=Object.getOwnPropertySymbols(t);return[...i,...a].reduce((r,i)=>{if(i===`__proto__`)return r;let a=t[i],o=W(e)?e[i]:void 0;return o!==void 0&&W(a)&&(a=Rn(o,a,n)),Ln(r,i,n?n(o,a,i):a,t),r},r)}function zn(e,...t){return t.reduce((e,t)=>Rn(e,t),e)}const Bn={builder:{outputDir:`dist`,esbuildControllerOptions:{includeInBundle:[]},tailwind:{forcedClassesInclusion:[]},editor:{webComponents:{formRow:!1}}},watcher:{nodeRed:{enabled:!0,path:`~/.node-red`,url:`http://localhost:1880`}}},G={libCacheDir:`.node-red-dxp`,srcDir:`src`,nodesDirName:`nodes`,localesDirName:`locales`,globalStylesName:`styles`,nodes:{controllerName:`controller`,editor:{dirName:`editor`,htmlName:`index`,stylesName:`styles`,tsName:`index`}}},Vn=`node-red-dxp`,Hn=e=>e.replace(`@`,``).replace(`/`,`-`);function Un(){let e=(0,ee.cosmiconfigSync)(`node-red-dxp`);try{let t=e.search();return zn(Bn,t?t.config:{})}catch(e){throw console.error(`Error while loading configuration`,e),e}}const K=Un(),q=process.cwd(),Wn=JSON.parse((0,m.readFileSync)(`${q}/package.json`,`utf-8`)),J=`${q}/${G.srcDir}`,Gn=`${q}/resources`,Kn=`${q}/resources`,Y=`${J}/${G.nodesDirName}`,qn=`${q}/${G.libCacheDir}`,Jn=`${h.default.resolve(__dirname,`..`)}`,Yn=Hn(Wn.name);function Xn(e=[]){return e.map(e=>{let t=e.path,n=`${t}/${G.nodes.editor.dirName}`,r=t.replace(q,``).slice(1),i=`${r}/${G.nodes.editor.dirName}`,a=(0,g.globSync)(`${n}/${G.nodes.editor.stylesName}.scss`),o=(0,g.globSync)(`${t}/docs.mdx`),s=(0,g.globSync)(`${t}/docs.md`),c=(0,_.dash)(e.name);return{fullEditorPath:n,fullPath:t,name:e.name,pascalName:(0,_.pascal)(e.name),dashName:c,relativeEditorPath:i,relativePath:r,nodeIdentifier:`${Yn}-${c}`,fullControllerPath:`${t}/${G.nodes.controllerName}.ts`,editor:{tsPath:`${n}/${G.nodes.editor.tsName}.ts`,htmlPath:`${n}/${G.nodes.editor.htmlName}.html`,pugPath:`${n}/${G.nodes.editor.htmlName}.pug`,scssFiles:a},doc:{mdxFiles:o,mdFiles:s}}})}function Zn(){let e=(0,g.globSync)(`${Y}/**/*`,{onlyDirectories:!0,deep:1,objectMode:!0}),t=Xn(e),n=t.map(e=>e.name);return{currentDir:q,pathSrcDir:J,pathSrcNodesDir:Y,pathResourcesDir:Gn,additionalResourcesDir:Kn,pathDist:`${q}/${K.builder.outputDir}`,currentPackagedDistPath:Jn,cacheDirFiles:{controllerIndex:`${qn}/controller-index.ts`,editorIndex:`${qn}/editor-index.ts`},pathLibCacheDir:qn,packageName:Wn.name,packageNameSlug:Yn,config:K,resolvedSrcPathsScss:(0,g.globSync)(`${J}/${G.globalStylesName}.scss`,{ignore:[`${Y}/**/*.scss`]}),resolvedNodesPaths:e.map(e=>e.path),resolvedSrcLocalesPaths:(0,g.globSync)(`${J}/${G.localesDirName}/*.json`),redServerPath:(0,g.globSync)(`${J}/red-server.ts`),listNodesFull:t,listNodesFullNames:n}}const X=Zn(),Qn=`${h.default.resolve(__dirname,`..`)}`;function Z(e){m.default.existsSync(e)||m.default.mkdirSync(e,{recursive:!0})}async function Q(e,t){try{await p.default.writeFile(e,t)}catch(e){console.error(`Error writing controller index:`,e)}}async function $n(e){for(let t of e)try{let e=h.default.resolve(t),n=await p.default.stat(e).catch(()=>null);n!=null&&n.isDirectory()&&await p.default.rm(e,{recursive:!0,force:!0})}catch(e){console.error(`Error cleaning path (${t}): ${e}`)}}const er={name:`add-credentials-export`,setup(e){e.onLoad({filter:/controller\.ts$/},async e=>{let t=await p.default.readFile(e.path,`utf8`);return/export\s+const\s+credentials\s*=/.test(t)?{contents:t,loader:`ts`}:{contents:`${t}\nexport const credentials = {};`,loader:`ts`}})}},tr=`${X.currentDir}/package.json`;var nr=class{constructor(e){this.params={minify:!1,...e}}async getControllerIndexContent(){return`
11
+ `;return this.stop(),this.#c.write(c),this}};function Nn(e){return new Mn(e)}var Pn=`1.25.0`;function Fn(e){return Object.prototype.toString.call(e).slice(8,-1)}function W(e){if(Fn(e)!==`Object`)return!1;let t=Object.getPrototypeOf(e);return!!t&&t.constructor===Object&&t===Object.prototype}function In(e){return Fn(e)===`Symbol`}function Ln(e,t,n,r){let i={}.propertyIsEnumerable.call(r,t)?`enumerable`:`nonenumerable`;i===`enumerable`&&(e[t]=n),i===`nonenumerable`&&Object.defineProperty(e,t,{value:n,enumerable:!1,writable:!0,configurable:!0})}function Rn(e,t,n){if(!W(t))return t;let r={};if(W(e)){let n=Object.getOwnPropertyNames(e),i=Object.getOwnPropertySymbols(e);r=[...n,...i].reduce((n,r)=>{if(r===`__proto__`)return n;let i=e[r];return(!In(r)&&!Object.getOwnPropertyNames(t).includes(r)||In(r)&&!Object.getOwnPropertySymbols(t).includes(r))&&Ln(n,r,i,e),n},{})}let i=Object.getOwnPropertyNames(t),a=Object.getOwnPropertySymbols(t);return[...i,...a].reduce((r,i)=>{if(i===`__proto__`)return r;let a=t[i],o=W(e)?e[i]:void 0;return o!==void 0&&W(a)&&(a=Rn(o,a,n)),Ln(r,i,n?n(o,a,i):a,t),r},r)}function zn(e,...t){return t.reduce((e,t)=>Rn(e,t),e)}const Bn={builder:{outputDir:`dist`,esbuildControllerOptions:{includeInBundle:[]},tailwind:{forcedClassesInclusion:[]},editor:{webComponents:{formRow:!1}}},watcher:{nodeRed:{enabled:!0,path:`~/.node-red`,url:`http://localhost:1880`}}},G={libCacheDir:`.node-red-dxp`,srcDir:`src`,nodesDirName:`nodes`,localesDirName:`locales`,globalStylesName:`styles`,nodes:{controllerName:`controller`,editor:{dirName:`editor`,htmlName:`index`,stylesName:`styles`,tsName:`index`}}},Vn=`node-red-dxp`,Hn=e=>e.replace(`@`,``).replace(`/`,`-`);function Un(){let e=(0,ee.cosmiconfigSync)(`node-red-dxp`);try{let t=e.search();return zn(Bn,t?t.config:{})}catch(e){throw console.error(`Error while loading configuration`,e),e}}const K=Un(),q=process.cwd(),Wn=JSON.parse((0,m.readFileSync)(`${q}/package.json`,`utf-8`)),J=`${q}/${G.srcDir}`,Gn=`${q}/resources`,Kn=`${q}/resources`,Y=`${J}/${G.nodesDirName}`,qn=`${q}/${G.libCacheDir}`,Jn=`${h.default.resolve(__dirname,`..`)}`,Yn=Hn(Wn.name);function Xn(e=[]){return e.map(e=>{let t=e.path,n=`${t}/${G.nodes.editor.dirName}`,r=t.replace(q,``).slice(1),i=`${r}/${G.nodes.editor.dirName}`,a=(0,g.globSync)(`${n}/${G.nodes.editor.stylesName}.scss`),o=(0,g.globSync)(`${t}/docs.mdx`),s=(0,g.globSync)(`${t}/docs.md`),c=(0,_.dash)(e.name);return{fullEditorPath:n,fullPath:t,name:e.name,pascalName:(0,_.pascal)(e.name),dashName:c,relativeEditorPath:i,relativePath:r,nodeIdentifier:`${Yn}-${c}`,fullControllerPath:`${t}/${G.nodes.controllerName}.ts`,editor:{tsPath:`${n}/${G.nodes.editor.tsName}.ts`,htmlPath:`${n}/${G.nodes.editor.htmlName}.html`,pugPath:`${n}/${G.nodes.editor.htmlName}.pug`,scssFiles:a},doc:{mdxFiles:o,mdFiles:s}}})}function Zn(){let e=(0,g.globSync)(`${Y}/**/*`,{onlyDirectories:!0,deep:1,objectMode:!0}),t=Xn(e),n=t.map(e=>e.name);return{currentDir:q,pathSrcDir:J,pathSrcNodesDir:Y,pathResourcesDir:Gn,additionalResourcesDir:Kn,pathDist:`${q}/${K.builder.outputDir}`,currentPackagedDistPath:Jn,cacheDirFiles:{controllerIndex:`${qn}/controller-index.ts`,editorIndex:`${qn}/editor-index.ts`},pathLibCacheDir:qn,packageName:Wn.name,packageNameSlug:Yn,config:K,resolvedSrcPathsScss:(0,g.globSync)(`${J}/${G.globalStylesName}.scss`,{ignore:[`${Y}/**/*.scss`]}),resolvedNodesPaths:e.map(e=>e.path),resolvedSrcLocalesPaths:(0,g.globSync)(`${J}/${G.localesDirName}/*.json`),redServerPath:(0,g.globSync)(`${J}/red-server.ts`),listNodesFull:t,listNodesFullNames:n}}const X=Zn(),Qn=`${h.default.resolve(__dirname,`..`)}`;function Z(e){m.default.existsSync(e)||m.default.mkdirSync(e,{recursive:!0})}async function Q(e,t){try{await p.default.writeFile(e,t)}catch(e){console.error(`Error writing controller index:`,e)}}async function $n(e){for(let t of e)try{let e=h.default.resolve(t),n=await p.default.stat(e).catch(()=>null);n!=null&&n.isDirectory()&&await p.default.rm(e,{recursive:!0,force:!0})}catch(e){console.error(`Error cleaning path (${t}): ${e}`)}}const er={name:`add-credentials-export`,setup(e){e.onLoad({filter:/controller\.ts$/},async e=>{let t=await p.default.readFile(e.path,`utf8`);return/export\s+const\s+credentials\s*=/.test(t)?{contents:t,loader:`ts`}:{contents:`${t}\nexport const credentials = {};`,loader:`ts`}})}},tr=`${X.currentDir}/package.json`;var nr=class{constructor(e){this.params={minify:!1,...e}}async getControllerIndexContent(){return`
12
12
  import type { NodeAPI } from 'node-red';
13
13
  ${X.listNodesFull.map(e=>`// @ts-ignore\nimport ${e.pascalName}, {credentials as cred${e.pascalName}} from '${e.fullControllerPath}';`).join(`
14
14
  `)}
@@ -31,17 +31,18 @@ mixin commonLabel(params)
31
31
  - var capitalizedLabel = capitalizeFirst(params.label || '')
32
32
  label(for=params.id)
33
33
  +iconFontAwesome(params.icon)
34
- span(data-i18n=params.label title=capitalizedLabel)= capitalizedLabel
34
+ span(data-i18n=`${params.i18nKey};[title]${params.i18nKey}` title=capitalizedLabel)= capitalizedLabel
35
35
 
36
36
  mixin dxpFormRowInputText(params)
37
37
  - var inputId = generateInputId(params.id, params.isConfig)
38
- .dxp-template-form-row
39
- +commonLabel({label: params.label, icon: params.icon, id: inputId})
38
+ - var i18nKey = params.i18nKey || params.id
39
+ .dxp-template-form-row(class=params.rowClasses)
40
+ +commonLabel({label: params.label, icon: params.icon, id: inputId, i18nKey })
40
41
  .content
41
42
  input(
42
43
  type="text"
43
44
  id=inputId
44
- data-i18n=`[placeholder]${params.label}`
45
+ data-i18n=`[placeholder]${params.id}-placeholder`
45
46
  placeholder=params.placeholder || ''
46
47
  )&attributes(attributes)
47
48
  if params.isTyped
@@ -51,8 +52,9 @@ mixin dxpFormRowInputText(params)
51
52
 
52
53
  mixin dxpFormRowCheckbox(params)
53
54
  - var inputId = generateInputId(params.id, params.isConfig)
54
- .dxp-template-form-row
55
- +commonLabel({label: params.label, icon: params.icon, id: inputId})
55
+ - var i18nKey = params.i18nKey || params.id
56
+ .dxp-template-form-row(class=params.rowClasses)
57
+ +commonLabel({label: params.label, icon: params.icon, id: inputId, i18nKey })
56
58
  .content
57
59
  .checkbox
58
60
  input(type="checkbox" id=inputId)&attributes(attributes)
@@ -63,8 +65,9 @@ mixin dxpFormRowCheckbox(params)
63
65
 
64
66
  mixin dxpFormRowSelect(params)
65
67
  - var inputId = generateInputId(params.id, params.isConfig)
66
- .dxp-template-form-row
67
- +commonLabel({label: params.label, icon: params.icon, id: inputId})
68
+ - var i18nKey = params.i18nKey || params.id
69
+ .dxp-template-form-row(class=params.rowClasses)
70
+ +commonLabel({label: params.label, icon: params.icon, id: inputId, i18nKey })
68
71
  .content
69
72
  select(id=inputId)&attributes(attributes)
70
73
  if block
@@ -72,8 +75,9 @@ mixin dxpFormRowSelect(params)
72
75
 
73
76
  mixin dxpFormRowSelectConfigNode(params)
74
77
  - var inputId = generateInputId(params.id, params.isConfig)
75
- .dxp-template-form-row
76
- +commonLabel({label: params.label, icon: params.icon, id: inputId})
78
+ - var i18nKey = params.i18nKey || params.id
79
+ .dxp-template-form-row(class=params.rowClasses)
80
+ +commonLabel({label: params.label, icon: params.icon, id: inputId, i18nKey })
77
81
  .content.force-w-full
78
82
  select(id=inputId)&attributes(attributes)
79
83
  if block
@@ -87,8 +91,9 @@ mixin dxpFormTitleSeparator(label)
87
91
  div.flex-1.border-t.border-gray-300
88
92
 
89
93
  mixin dxpHint(params)
90
- - var classState = params.state ? 'hint-' + params.state : ''
91
- - var width = params.fullWidth ? '' : 'max-w-[350px]'
94
+ - var params = params ?? {}
95
+ - var classState = params?.state ? 'hint-' + params.state : ''
96
+ - var width = params?.fullWidth ? '' : 'max-w-[350px]'
92
97
  .hint(class=classState + ' ' + width)
93
98
  +iconFontAwesome(params.icon)(class="mr-1")
94
99
  if block
@@ -1 +1 @@
1
- require(`../../src-BNoPX5QG.cjs`);const e=e=>{if(!e||e.length===0)return``;let t=e.toLowerCase();return t.substring(0,1).toUpperCase()+t.substring(1,t.length)},t=(t,n)=>{var r;let i=(r=t==null?void 0:t.replace(/([A-Z])+/g,e).split(/(?=[A-Z])|[\.\-\s_]/).map(e=>e.toLowerCase()))==null?[]:r;if(i.length===0)return``;if(i.length===1)return i[0];let a=i.reduce((e,t)=>`${e}_${t.toLowerCase()}`);return(n==null?void 0:n.splitOnNumber)===!1?a:a.replace(/([A-Za-z]{1}[0-9]{1})/,e=>`${e[0]}_${e[1]}`)};function n(e){let t=e.startsWith(`$`),n=e.startsWith(`$$`),r=e.startsWith(`#node-config-input`)||e.startsWith(`#node-input`);return{isNodeIdShortcut:t,isNodeConfigIdShortcut:n,isFullSelector:r,value:t||n||r}}function r(e){let t=n(e);return t.isNodeConfigIdShortcut?`#node-config-input-${e.replace(`$$`,``)}`:t.isNodeIdShortcut?`#node-input-${e.replace(`$`,``)}`:e}function i(e,t,n){t.forEach(t=>{let r=document.querySelector(t);r&&n.forEach(t=>r.classList[e](t))})}function a(e,t){i(`remove`,e,t)}function o(e,t){i(`add`,e,t)}function s(e){return r(e).split(`-input-`)[1]}function c(e,t,n){let i=r(e),a=t;n!=null&&n.emptyValue&&(a=[{value:``,text:n.emptyValue},...t]),$(i).empty().append(a.map(e=>$(`<option>`,{value:e.value,text:e.text,selected:e.value===(n==null?void 0:n.selected)})))}function l(e,t,n={additionalEvents:[]}){let i=(Array.isArray(e)?e:[e]).map(r).join(`, `),a=[`input`,...n.additionalEvents];$(i).on(a.join(` `),()=>{t($(i).map(function(){return $(this).val()}).get())})}function u(e,t){let n=r(e);$(n).val(t)}function d(e,t){let n=r(e);$(n).text(t)}function f(e){let t=r(e);return $(t)}function p(e){let t=r(e);return document.querySelector(t).checked}function m(e){let t={};return document.querySelectorAll(`[id^="node-input-${e}-"]`).forEach(n=>{let r=n,i=r.id.replace(`node-input-${e}-`,``);r.type===`checkbox`?t[i]=r.checked:t[i]=r.value}),t}function h(e,t){t&&Object.entries(t).forEach(([t,n])=>{let r=document.querySelector(`#node-input-${e}-${t}`);r&&(r.type===`checkbox`?r.checked=!!n:r.value=String(n))})}function g(e){let n=`#tabs-content-${e.targetId}`,r=RED.tabs.create({id:e.targetId,onchange:e=>{$(n).children().addClass(`hidden`),$(`#${e.id}`).removeClass(`hidden`)}});(e.tabsLabel||[]).forEach(e=>{r.addTab({id:`tab-${t(e)}`,label:e})}),r.activateTab(`tab-${t(e.initialTab)}`)}exports.addClassesOnSelectors=o,exports.getFormValues=m,exports.handleAddRemoveClassesOnSelectors=i,exports.initSelect=c,exports.initTabs=g,exports.isCheckboxChecked=p,exports.isNodeInput=n,exports.jqSelector=f,exports.removeClassesOnSelectors=a,exports.resolveInputKey=s,exports.resolveSelector=r,exports.setFormValues=h,exports.setInputValue=u,exports.setText=d,exports.watchInput=l;
1
+ require(`../../src-BNoPX5QG.cjs`);const e=e=>{if(!e||e.length===0)return``;let t=e.toLowerCase();return t.substring(0,1).toUpperCase()+t.substring(1,t.length)},t=(t,n)=>{var r;let i=(r=t==null?void 0:t.replace(/([A-Z])+/g,e).split(/(?=[A-Z])|[\.\-\s_]/).map(e=>e.toLowerCase()))==null?[]:r;if(i.length===0)return``;if(i.length===1)return i[0];let a=i.reduce((e,t)=>`${e}_${t.toLowerCase()}`);return(n==null?void 0:n.splitOnNumber)===!1?a:a.replace(/([A-Za-z]{1}[0-9]{1})/,e=>`${e[0]}_${e[1]}`)};function n(e){let t=e.startsWith(`$`),n=e.startsWith(`$$`),r=e.startsWith(`#node-config-input`)||e.startsWith(`#node-input`);return{isNodeIdShortcut:t,isNodeConfigIdShortcut:n,isFullSelector:r,value:t||n||r}}function r(e){let t=n(e);return t.isNodeConfigIdShortcut?`#node-config-input-${e.replace(`$$`,``)}`:t.isNodeIdShortcut?`#node-input-${e.replace(`$`,``)}`:e}function i(e,t,n){t.forEach(t=>{let r=document.querySelector(t);r&&n.forEach(t=>r.classList[e](t))})}function a(e,t){i(`remove`,e,t)}function o(e,t){i(`add`,e,t)}function s(e){return r(e).split(`-input-`)[1]}function c(e,t,n){let i=r(e),a=t;n!=null&&n.emptyValue&&(a=[{value:``,text:n.emptyValue},...t]),$(i).empty().append(a.map(e=>$(`<option>`,{value:e.value,text:e.text,selected:e.value===(n==null?void 0:n.selected)})))}function l(e){p(e.selector).typedInput({types:e.types,typeField:r(`${e.selector}Type`)})}function u(e,t,n={additionalEvents:[]}){let i=(Array.isArray(e)?e:[e]).map(r).join(`, `),a=[`input`,...n.additionalEvents];$(i).on(a.join(` `),()=>{t($(i).map(function(){return $(this).val()}).get())})}function d(e,t){let n=r(e);$(n).val(t)}function f(e,t){let n=r(e);$(n).text(t)}function p(e){let t=r(e);return $(t)}function m(e){let t=r(e);return document.querySelector(t).checked}function h(e){let t={};return document.querySelectorAll(`[id^="node-input-${e}-"]`).forEach(n=>{let r=n,i=r.id.replace(`node-input-${e}-`,``);r.type===`checkbox`?t[i]=r.checked:t[i]=r.value}),t}function g(e,t){t&&Object.entries(t).forEach(([t,n])=>{let r=document.querySelector(`#node-input-${e}-${t}`);r&&(r.type===`checkbox`?r.checked=!!n:r.value=String(n))})}function _(e){let n=`#tabs-content-${e.targetId}`,r=RED.tabs.create({id:e.targetId,onchange:e=>{$(n).children().addClass(`hidden`),$(`#${e.id}`).removeClass(`hidden`)}});(e.tabsLabel||[]).forEach(e=>{r.addTab({id:`tab-${t(e)}`,label:e})}),r.activateTab(`tab-${t(e.initialTab)}`)}exports.addClassesOnSelectors=o,exports.applyTypedInput=l,exports.getFormValues=h,exports.handleAddRemoveClassesOnSelectors=i,exports.initSelect=c,exports.initTabs=_,exports.isCheckboxChecked=m,exports.isNodeInput=n,exports.jqSelector=p,exports.removeClassesOnSelectors=a,exports.resolveInputKey=s,exports.resolveSelector=r,exports.setFormValues=g,exports.setInputValue=d,exports.setText=f,exports.watchInput=u;
@@ -1,5 +1,6 @@
1
1
  import { t as EditorDomHelper } from "../../types-B5Bh_DR_.cjs";
2
2
  import "../../index-DKhJ6JZE.cjs";
3
+ import { EditorWidgetTypedInputType, EditorWidgetTypedInputTypeDefinition } from "node-red";
3
4
 
4
5
  //#region src/editor/dom.d.ts
5
6
 
@@ -113,6 +114,25 @@ declare function resolveInputKey(selector: string): string;
113
114
  * initSelect('$select-id', [{ value: '1', text: 'Option 1' }], { emptyValue: 'Select an option', selected: '1' });
114
115
  */
115
116
  declare function initSelect(selector: string, options: Record<string, string>[], params?: EditorDomHelper.InitSelectParams): void;
117
+ /**
118
+ * Applies a typed input widget to a DOM element.
119
+ *
120
+ * @param params - Configuration object for the typed input
121
+ * @param params.selector - CSS selector of the input element to enhance
122
+ * @param params.types - Array of available input types or type definitions
123
+ *
124
+ * @example
125
+ * ```typescript
126
+ * applyTypedInput({
127
+ * selector: '$myInput',
128
+ * types: ['str', 'num', 'bool']
129
+ * });
130
+ * ```
131
+ */
132
+ declare function applyTypedInput(params: {
133
+ selector: string;
134
+ types: (EditorWidgetTypedInputType | EditorWidgetTypedInputTypeDefinition)[];
135
+ }): void;
116
136
  /**
117
137
  * Watches for changes on input elements and triggers a callback with the updated values.
118
138
  *
@@ -275,4 +295,4 @@ type InitTabsParams = {
275
295
  */
276
296
  declare function initTabs(params: InitTabsParams): void;
277
297
  //#endregion
278
- export { addClassesOnSelectors, getFormValues, handleAddRemoveClassesOnSelectors, initSelect, initTabs, isCheckboxChecked, isNodeInput, jqSelector, removeClassesOnSelectors, resolveInputKey, resolveSelector, setFormValues, setInputValue, setText, watchInput };
298
+ export { addClassesOnSelectors, applyTypedInput, getFormValues, handleAddRemoveClassesOnSelectors, initSelect, initTabs, isCheckboxChecked, isNodeInput, jqSelector, removeClassesOnSelectors, resolveInputKey, resolveSelector, setFormValues, setInputValue, setText, watchInput };
@@ -1,5 +1,6 @@
1
1
  import { t as EditorDomHelper } from "../../types-BSEMgzWV.js";
2
2
  import "../../index-BhYSgW2V.js";
3
+ import { EditorWidgetTypedInputType, EditorWidgetTypedInputTypeDefinition } from "node-red";
3
4
 
4
5
  //#region src/editor/dom.d.ts
5
6
 
@@ -113,6 +114,25 @@ declare function resolveInputKey(selector: string): string;
113
114
  * initSelect('$select-id', [{ value: '1', text: 'Option 1' }], { emptyValue: 'Select an option', selected: '1' });
114
115
  */
115
116
  declare function initSelect(selector: string, options: Record<string, string>[], params?: EditorDomHelper.InitSelectParams): void;
117
+ /**
118
+ * Applies a typed input widget to a DOM element.
119
+ *
120
+ * @param params - Configuration object for the typed input
121
+ * @param params.selector - CSS selector of the input element to enhance
122
+ * @param params.types - Array of available input types or type definitions
123
+ *
124
+ * @example
125
+ * ```typescript
126
+ * applyTypedInput({
127
+ * selector: '$myInput',
128
+ * types: ['str', 'num', 'bool']
129
+ * });
130
+ * ```
131
+ */
132
+ declare function applyTypedInput(params: {
133
+ selector: string;
134
+ types: (EditorWidgetTypedInputType | EditorWidgetTypedInputTypeDefinition)[];
135
+ }): void;
116
136
  /**
117
137
  * Watches for changes on input elements and triggers a callback with the updated values.
118
138
  *
@@ -275,4 +295,4 @@ type InitTabsParams = {
275
295
  */
276
296
  declare function initTabs(params: InitTabsParams): void;
277
297
  //#endregion
278
- export { addClassesOnSelectors, getFormValues, handleAddRemoveClassesOnSelectors, initSelect, initTabs, isCheckboxChecked, isNodeInput, jqSelector, removeClassesOnSelectors, resolveInputKey, resolveSelector, setFormValues, setInputValue, setText, watchInput };
298
+ export { addClassesOnSelectors, applyTypedInput, getFormValues, handleAddRemoveClassesOnSelectors, initSelect, initTabs, isCheckboxChecked, isNodeInput, jqSelector, removeClassesOnSelectors, resolveInputKey, resolveSelector, setFormValues, setInputValue, setText, watchInput };
@@ -1 +1 @@
1
- import"../../src-DvBS17xd.js";const e=e=>{if(!e||e.length===0)return``;let t=e.toLowerCase();return t.substring(0,1).toUpperCase()+t.substring(1,t.length)},t=(t,n)=>{var r;let i=(r=t==null?void 0:t.replace(/([A-Z])+/g,e).split(/(?=[A-Z])|[\.\-\s_]/).map(e=>e.toLowerCase()))==null?[]:r;if(i.length===0)return``;if(i.length===1)return i[0];let a=i.reduce((e,t)=>`${e}_${t.toLowerCase()}`);return(n==null?void 0:n.splitOnNumber)===!1?a:a.replace(/([A-Za-z]{1}[0-9]{1})/,e=>`${e[0]}_${e[1]}`)};function n(e){let t=e.startsWith(`$`),n=e.startsWith(`$$`),r=e.startsWith(`#node-config-input`)||e.startsWith(`#node-input`);return{isNodeIdShortcut:t,isNodeConfigIdShortcut:n,isFullSelector:r,value:t||n||r}}function r(e){let t=n(e);return t.isNodeConfigIdShortcut?`#node-config-input-${e.replace(`$$`,``)}`:t.isNodeIdShortcut?`#node-input-${e.replace(`$`,``)}`:e}function i(e,t,n){t.forEach(t=>{let r=document.querySelector(t);r&&n.forEach(t=>r.classList[e](t))})}function a(e,t){i(`remove`,e,t)}function o(e,t){i(`add`,e,t)}function s(e){return r(e).split(`-input-`)[1]}function c(e,t,n){let i=r(e),a=t;n!=null&&n.emptyValue&&(a=[{value:``,text:n.emptyValue},...t]),$(i).empty().append(a.map(e=>$(`<option>`,{value:e.value,text:e.text,selected:e.value===(n==null?void 0:n.selected)})))}function l(e,t,n={additionalEvents:[]}){let i=(Array.isArray(e)?e:[e]).map(r).join(`, `),a=[`input`,...n.additionalEvents];$(i).on(a.join(` `),()=>{t($(i).map(function(){return $(this).val()}).get())})}function u(e,t){let n=r(e);$(n).val(t)}function d(e,t){let n=r(e);$(n).text(t)}function f(e){let t=r(e);return $(t)}function p(e){let t=r(e);return document.querySelector(t).checked}function m(e){let t={};return document.querySelectorAll(`[id^="node-input-${e}-"]`).forEach(n=>{let r=n,i=r.id.replace(`node-input-${e}-`,``);r.type===`checkbox`?t[i]=r.checked:t[i]=r.value}),t}function h(e,t){t&&Object.entries(t).forEach(([t,n])=>{let r=document.querySelector(`#node-input-${e}-${t}`);r&&(r.type===`checkbox`?r.checked=!!n:r.value=String(n))})}function g(e){let n=`#tabs-content-${e.targetId}`,r=RED.tabs.create({id:e.targetId,onchange:e=>{$(n).children().addClass(`hidden`),$(`#${e.id}`).removeClass(`hidden`)}});(e.tabsLabel||[]).forEach(e=>{r.addTab({id:`tab-${t(e)}`,label:e})}),r.activateTab(`tab-${t(e.initialTab)}`)}export{o as addClassesOnSelectors,m as getFormValues,i as handleAddRemoveClassesOnSelectors,c as initSelect,g as initTabs,p as isCheckboxChecked,n as isNodeInput,f as jqSelector,a as removeClassesOnSelectors,s as resolveInputKey,r as resolveSelector,h as setFormValues,u as setInputValue,d as setText,l as watchInput};
1
+ import"../../src-DvBS17xd.js";const e=e=>{if(!e||e.length===0)return``;let t=e.toLowerCase();return t.substring(0,1).toUpperCase()+t.substring(1,t.length)},t=(t,n)=>{var r;let i=(r=t==null?void 0:t.replace(/([A-Z])+/g,e).split(/(?=[A-Z])|[\.\-\s_]/).map(e=>e.toLowerCase()))==null?[]:r;if(i.length===0)return``;if(i.length===1)return i[0];let a=i.reduce((e,t)=>`${e}_${t.toLowerCase()}`);return(n==null?void 0:n.splitOnNumber)===!1?a:a.replace(/([A-Za-z]{1}[0-9]{1})/,e=>`${e[0]}_${e[1]}`)};function n(e){let t=e.startsWith(`$`),n=e.startsWith(`$$`),r=e.startsWith(`#node-config-input`)||e.startsWith(`#node-input`);return{isNodeIdShortcut:t,isNodeConfigIdShortcut:n,isFullSelector:r,value:t||n||r}}function r(e){let t=n(e);return t.isNodeConfigIdShortcut?`#node-config-input-${e.replace(`$$`,``)}`:t.isNodeIdShortcut?`#node-input-${e.replace(`$`,``)}`:e}function i(e,t,n){t.forEach(t=>{let r=document.querySelector(t);r&&n.forEach(t=>r.classList[e](t))})}function a(e,t){i(`remove`,e,t)}function o(e,t){i(`add`,e,t)}function s(e){return r(e).split(`-input-`)[1]}function c(e,t,n){let i=r(e),a=t;n!=null&&n.emptyValue&&(a=[{value:``,text:n.emptyValue},...t]),$(i).empty().append(a.map(e=>$(`<option>`,{value:e.value,text:e.text,selected:e.value===(n==null?void 0:n.selected)})))}function l(e){p(e.selector).typedInput({types:e.types,typeField:r(`${e.selector}Type`)})}function u(e,t,n={additionalEvents:[]}){let i=(Array.isArray(e)?e:[e]).map(r).join(`, `),a=[`input`,...n.additionalEvents];$(i).on(a.join(` `),()=>{t($(i).map(function(){return $(this).val()}).get())})}function d(e,t){let n=r(e);$(n).val(t)}function f(e,t){let n=r(e);$(n).text(t)}function p(e){let t=r(e);return $(t)}function m(e){let t=r(e);return document.querySelector(t).checked}function h(e){let t={};return document.querySelectorAll(`[id^="node-input-${e}-"]`).forEach(n=>{let r=n,i=r.id.replace(`node-input-${e}-`,``);r.type===`checkbox`?t[i]=r.checked:t[i]=r.value}),t}function g(e,t){t&&Object.entries(t).forEach(([t,n])=>{let r=document.querySelector(`#node-input-${e}-${t}`);r&&(r.type===`checkbox`?r.checked=!!n:r.value=String(n))})}function _(e){let n=`#tabs-content-${e.targetId}`,r=RED.tabs.create({id:e.targetId,onchange:e=>{$(n).children().addClass(`hidden`),$(`#${e.id}`).removeClass(`hidden`)}});(e.tabsLabel||[]).forEach(e=>{r.addTab({id:`tab-${t(e)}`,label:e})}),r.activateTab(`tab-${t(e.initialTab)}`)}export{o as addClassesOnSelectors,l as applyTypedInput,h as getFormValues,i as handleAddRemoveClassesOnSelectors,c as initSelect,_ as initTabs,m as isCheckboxChecked,n as isNodeInput,p as jqSelector,a as removeClassesOnSelectors,s as resolveInputKey,r as resolveSelector,g as setFormValues,d as setInputValue,f as setText,u as watchInput};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@keload/node-red-dxp",
3
- "version": "1.24.1",
3
+ "version": "1.26.0",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "scripts": {