@bonsae/nrg 0.6.0 → 0.6.2
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.
- package/README.md +5 -5
- package/package.json +14 -75
- package/{build/server → server}/index.cjs +1 -1
- package/{src/core/client → shims}/components.d.ts +2 -0
- package/{src/tsconfig → tsconfig}/client.json +3 -3
- package/types/client.d.ts +37 -0
- package/types/index.d.ts +211 -0
- package/types/server.d.ts +2293 -0
- package/types/vite.d.ts +12 -0
- package/{build/vite → vite}/index.js +95 -0
- package/build/vite/utils.js +0 -56
- package/src/core/client/app.vue +0 -185
- package/src/core/client/components/node-red-config-input.vue +0 -79
- package/src/core/client/components/node-red-editor-input.vue +0 -307
- package/src/core/client/components/node-red-input-label.vue +0 -53
- package/src/core/client/components/node-red-input.vue +0 -93
- package/src/core/client/components/node-red-json-schema-form.vue +0 -444
- package/src/core/client/components/node-red-select-input.vue +0 -108
- package/src/core/client/components/node-red-toggle.vue +0 -115
- package/src/core/client/components/node-red-typed-input.vue +0 -158
- package/src/core/client/index.ts +0 -500
- package/src/core/client/tsconfig.json +0 -18
- package/src/core/constants.ts +0 -18
- package/src/core/errors.ts +0 -9
- package/src/core/server/api/index.ts +0 -1
- package/src/core/server/api/serve-nrg-resources.ts +0 -54
- package/src/core/server/index.ts +0 -190
- package/src/core/server/nodes/config-node.ts +0 -67
- package/src/core/server/nodes/factories.ts +0 -133
- package/src/core/server/nodes/index.ts +0 -5
- package/src/core/server/nodes/io-node.ts +0 -179
- package/src/core/server/nodes/node.ts +0 -259
- package/src/core/server/nodes/types/config-node.ts +0 -28
- package/src/core/server/nodes/types/factories.ts +0 -115
- package/src/core/server/nodes/types/index.ts +0 -4
- package/src/core/server/nodes/types/io-node.ts +0 -40
- package/src/core/server/nodes/types/node.ts +0 -41
- package/src/core/server/nodes/utils.ts +0 -106
- package/src/core/server/schemas/base.ts +0 -66
- package/src/core/server/schemas/index.ts +0 -3
- package/src/core/server/schemas/type.ts +0 -95
- package/src/core/server/schemas/types/index.ts +0 -82
- package/src/core/server/tsconfig.json +0 -17
- package/src/core/server/types/index.ts +0 -220
- package/src/core/server/utils.ts +0 -56
- package/src/core/server/validator.ts +0 -36
- package/src/core/validator.ts +0 -222
- package/src/index.ts +0 -2
- package/src/types.ts +0 -189
- package/src/utils.ts +0 -20
- package/src/vite/async-utils.ts +0 -61
- package/src/vite/client/build.ts +0 -227
- package/src/vite/client/index.ts +0 -1
- package/src/vite/client/plugins/html-generator.ts +0 -75
- package/src/vite/client/plugins/index.ts +0 -5
- package/src/vite/client/plugins/locales-generator.ts +0 -126
- package/src/vite/client/plugins/minifier.ts +0 -23
- package/src/vite/client/plugins/node-definitions-inliner.ts +0 -275
- package/src/vite/client/plugins/static-copy.ts +0 -43
- package/src/vite/defaults.ts +0 -77
- package/src/vite/errors.ts +0 -37
- package/src/vite/index.ts +0 -2
- package/src/vite/logger.ts +0 -94
- package/src/vite/node-red-launcher.ts +0 -344
- package/src/vite/plugin.ts +0 -61
- package/src/vite/plugins/build.ts +0 -85
- package/src/vite/plugins/index.ts +0 -2
- package/src/vite/plugins/server.ts +0 -267
- package/src/vite/server/build.ts +0 -124
- package/src/vite/server/index.ts +0 -1
- package/src/vite/server/plugins/index.ts +0 -3
- package/src/vite/server/plugins/output-wrapper.ts +0 -109
- package/src/vite/server/plugins/package-json-generator.ts +0 -203
- package/src/vite/server/plugins/type-generator.ts +0 -285
- package/src/vite/types.ts +0 -174
- package/src/vite/utils.ts +0 -72
- /package/{build/index.js → index.js} +0 -0
- /package/{build/server → server}/resources/nrg-client.js +0 -0
- /package/{build/server → server}/resources/vue.esm-browser.js +0 -0
- /package/{build/server → server}/resources/vue.esm-browser.prod.js +0 -0
- /package/{src/core/client → shims}/globals.d.ts +0 -0
- /package/{src/core/client → shims}/shims-vue.d.ts +0 -0
- /package/{src/tsconfig → tsconfig}/base.json +0 -0
- /package/{src/tsconfig → tsconfig}/server.json +0 -0
package/types/vite.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
|
|
2
|
+
import type { Plugin } from "vite";
|
|
3
|
+
|
|
4
|
+
export interface NodeRedPluginOptions {
|
|
5
|
+
outDir?: string;
|
|
6
|
+
serverBuildOptions?: Record<string, any>;
|
|
7
|
+
clientBuildOptions?: Record<string, any>;
|
|
8
|
+
nodeRedLauncherOptions?: Record<string, any>;
|
|
9
|
+
extraFilesCopyTargets?: Array<{ src: string; dest: string }>;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export declare function nodeRed(options?: NodeRedPluginOptions): Plugin[];
|
|
@@ -619,6 +619,87 @@ function getNodeTypeExports(filePath) {
|
|
|
619
619
|
}
|
|
620
620
|
return result;
|
|
621
621
|
}
|
|
622
|
+
var SCHEMA_PROP_SEMANTICS = {
|
|
623
|
+
configSchema: "ConfigSchema",
|
|
624
|
+
credentialsSchema: "CredentialsSchema",
|
|
625
|
+
inputSchema: "InputSchema",
|
|
626
|
+
outputsSchema: "OutputsSchema",
|
|
627
|
+
settingsSchema: "SettingsSchema"
|
|
628
|
+
};
|
|
629
|
+
function getSchemaReferences(filePath) {
|
|
630
|
+
const content = fs3.readFileSync(filePath, "utf-8");
|
|
631
|
+
const source = ts.createSourceFile(
|
|
632
|
+
filePath,
|
|
633
|
+
content,
|
|
634
|
+
ts.ScriptTarget.ESNext,
|
|
635
|
+
true
|
|
636
|
+
);
|
|
637
|
+
const importMap = /* @__PURE__ */ new Map();
|
|
638
|
+
for (const stmt of source.statements) {
|
|
639
|
+
if (ts.isImportDeclaration(stmt) && stmt.importClause) {
|
|
640
|
+
const moduleSpecifier = stmt.moduleSpecifier.text;
|
|
641
|
+
const namedBindings = stmt.importClause.namedBindings;
|
|
642
|
+
if (namedBindings && ts.isNamedImports(namedBindings)) {
|
|
643
|
+
for (const el of namedBindings.elements) {
|
|
644
|
+
importMap.set(el.name.text, moduleSpecifier);
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
const schemaRefs = /* @__PURE__ */ new Map();
|
|
650
|
+
function extractIdentifiers(node) {
|
|
651
|
+
if (ts.isIdentifier(node)) return [node.text];
|
|
652
|
+
if (ts.isArrayLiteralExpression(node)) {
|
|
653
|
+
return node.elements.filter(ts.isIdentifier).map((el) => el.text);
|
|
654
|
+
}
|
|
655
|
+
return [];
|
|
656
|
+
}
|
|
657
|
+
for (const stmt of source.statements) {
|
|
658
|
+
if (ts.isClassDeclaration(stmt)) {
|
|
659
|
+
for (const member of stmt.members) {
|
|
660
|
+
if (ts.isPropertyDeclaration(member) && ts.isIdentifier(member.name) && member.name.text in SCHEMA_PROP_SEMANTICS && member.initializer) {
|
|
661
|
+
const ids = extractIdentifiers(member.initializer);
|
|
662
|
+
if (ids.length > 0) {
|
|
663
|
+
schemaRefs.set(member.name.text, ids);
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
if (ts.isExportAssignment(stmt) && stmt.expression && ts.isCallExpression(stmt.expression)) {
|
|
669
|
+
const callee = stmt.expression.expression;
|
|
670
|
+
if (ts.isIdentifier(callee) && (callee.text === "defineIONode" || callee.text === "defineConfigNode")) {
|
|
671
|
+
const arg = stmt.expression.arguments[0];
|
|
672
|
+
if (arg && ts.isObjectLiteralExpression(arg)) {
|
|
673
|
+
for (const prop of arg.properties) {
|
|
674
|
+
if (ts.isPropertyAssignment(prop) && ts.isIdentifier(prop.name) && prop.name.text in SCHEMA_PROP_SEMANTICS) {
|
|
675
|
+
const ids = extractIdentifiers(prop.initializer);
|
|
676
|
+
if (ids.length > 0) {
|
|
677
|
+
schemaRefs.set(prop.name.text, ids);
|
|
678
|
+
}
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
}
|
|
685
|
+
const result = [];
|
|
686
|
+
for (const [propName, identifiers] of schemaRefs) {
|
|
687
|
+
const semanticName = SCHEMA_PROP_SEMANTICS[propName];
|
|
688
|
+
const isArray = identifiers.length > 1;
|
|
689
|
+
for (const identifier of identifiers) {
|
|
690
|
+
const importSource = importMap.get(identifier);
|
|
691
|
+
if (importSource) {
|
|
692
|
+
result.push({
|
|
693
|
+
localName: identifier,
|
|
694
|
+
semanticName: isArray ? identifier : semanticName,
|
|
695
|
+
importSource,
|
|
696
|
+
tupleProp: isArray ? semanticName : void 0
|
|
697
|
+
});
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
return result;
|
|
702
|
+
}
|
|
622
703
|
function buildNodeReexports(srcDir, entryFile) {
|
|
623
704
|
const nodesDir = path3.join(srcDir, "nodes");
|
|
624
705
|
const nodeFiles = collectTsFiles(nodesDir);
|
|
@@ -635,6 +716,20 @@ function buildNodeReexports(srcDir, entryFile) {
|
|
|
635
716
|
).join(", ");
|
|
636
717
|
lines.push(`export type { ${prefixed} } from "${specifier}";`);
|
|
637
718
|
}
|
|
719
|
+
const schemaRefs = getSchemaReferences(file);
|
|
720
|
+
const bySource = /* @__PURE__ */ new Map();
|
|
721
|
+
for (const ref of schemaRefs) {
|
|
722
|
+
const resolvedSource = path3.relative(
|
|
723
|
+
path3.dirname(entryFile),
|
|
724
|
+
path3.resolve(path3.dirname(file), ref.importSource)
|
|
725
|
+
).replace(/\\/g, "/");
|
|
726
|
+
const sourceSpecifier = resolvedSource.startsWith(".") ? resolvedSource : `./${resolvedSource}`;
|
|
727
|
+
if (!bySource.has(sourceSpecifier)) bySource.set(sourceSpecifier, []);
|
|
728
|
+
bySource.get(sourceSpecifier).push(`${ref.localName} as ${ns}${ref.semanticName}`);
|
|
729
|
+
}
|
|
730
|
+
for (const [source, names] of bySource) {
|
|
731
|
+
lines.push(`export { ${names.join(", ")} } from "${source}";`);
|
|
732
|
+
}
|
|
638
733
|
return lines.join("\n");
|
|
639
734
|
}).join("\n");
|
|
640
735
|
}
|
package/build/vite/utils.js
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
// src/vite/utils.ts
|
|
2
|
-
import fs from "fs";
|
|
3
|
-
import path from "path";
|
|
4
|
-
function cleanDir(dir) {
|
|
5
|
-
if (fs.existsSync(dir)) {
|
|
6
|
-
fs.rmSync(dir, { recursive: true });
|
|
7
|
-
}
|
|
8
|
-
fs.mkdirSync(dir, { recursive: true });
|
|
9
|
-
}
|
|
10
|
-
function copyFiles(targets, outDir) {
|
|
11
|
-
for (const { src, dest } of targets) {
|
|
12
|
-
const srcPath = path.resolve(src);
|
|
13
|
-
const destPath = path.join(outDir, dest);
|
|
14
|
-
if (!fs.existsSync(srcPath)) {
|
|
15
|
-
continue;
|
|
16
|
-
}
|
|
17
|
-
const stat = fs.statSync(srcPath);
|
|
18
|
-
if (stat.isDirectory()) {
|
|
19
|
-
fs.cpSync(srcPath, destPath, { recursive: true });
|
|
20
|
-
} else {
|
|
21
|
-
fs.mkdirSync(path.dirname(destPath), { recursive: true });
|
|
22
|
-
fs.copyFileSync(srcPath, destPath);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
function getPackageName() {
|
|
27
|
-
const pkgPath = path.resolve("./package.json");
|
|
28
|
-
if (fs.existsSync(pkgPath)) {
|
|
29
|
-
const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf-8"));
|
|
30
|
-
return pkg.name;
|
|
31
|
-
}
|
|
32
|
-
return "node-red-nodes";
|
|
33
|
-
}
|
|
34
|
-
function mergeOptions(defaults, overrides) {
|
|
35
|
-
if (!overrides) return { ...defaults };
|
|
36
|
-
const result = { ...defaults };
|
|
37
|
-
for (const key of Object.keys(overrides)) {
|
|
38
|
-
const overrideVal = overrides[key];
|
|
39
|
-
const defaultVal = defaults[key];
|
|
40
|
-
if (overrideVal !== void 0 && !Array.isArray(overrideVal) && !Array.isArray(defaultVal) && typeof overrideVal === "object" && typeof defaultVal === "object" && overrideVal !== null && defaultVal !== null) {
|
|
41
|
-
result[key] = mergeOptions(
|
|
42
|
-
defaultVal,
|
|
43
|
-
overrideVal
|
|
44
|
-
);
|
|
45
|
-
} else if (overrideVal !== void 0) {
|
|
46
|
-
result[key] = overrideVal;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
return result;
|
|
50
|
-
}
|
|
51
|
-
export {
|
|
52
|
-
cleanDir,
|
|
53
|
-
copyFiles,
|
|
54
|
-
getPackageName,
|
|
55
|
-
mergeOptions
|
|
56
|
-
};
|
package/src/core/client/app.vue
DELETED
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div
|
|
3
|
-
v-if="features.hasInputSchema || features.hasOutputSchema"
|
|
4
|
-
class="form-row"
|
|
5
|
-
style="display: flex; align-items: center; gap: 12px"
|
|
6
|
-
>
|
|
7
|
-
<NodeRedToggle
|
|
8
|
-
v-if="features.hasInputSchema"
|
|
9
|
-
:model-value="localNode.validateInput"
|
|
10
|
-
label="Validate Input"
|
|
11
|
-
style="flex: 1"
|
|
12
|
-
@update:model-value="localNode.validateInput = $event"
|
|
13
|
-
/>
|
|
14
|
-
<NodeRedToggle
|
|
15
|
-
v-if="features.hasOutputSchema"
|
|
16
|
-
:model-value="localNode.validateOutput"
|
|
17
|
-
label="Validate Output"
|
|
18
|
-
style="flex: 1"
|
|
19
|
-
@update:model-value="localNode.validateOutput = $event"
|
|
20
|
-
/>
|
|
21
|
-
</div>
|
|
22
|
-
<div style="width: 100%; padding-bottom: 12px">
|
|
23
|
-
<NodeRedNodeForm
|
|
24
|
-
:node="localNode"
|
|
25
|
-
:schema="schema"
|
|
26
|
-
:errors="errors"
|
|
27
|
-
style="width: 100%"
|
|
28
|
-
/>
|
|
29
|
-
</div>
|
|
30
|
-
</template>
|
|
31
|
-
|
|
32
|
-
<script lang="ts">
|
|
33
|
-
import jsonpointer from "jsonpointer";
|
|
34
|
-
import { type JSONSchemaType } from "ajv";
|
|
35
|
-
import type { PropType } from "vue";
|
|
36
|
-
import { defineComponent } from "vue";
|
|
37
|
-
import { validator } from "../validator";
|
|
38
|
-
|
|
39
|
-
export default defineComponent({
|
|
40
|
-
name: "NodeRedVueApp",
|
|
41
|
-
props: {
|
|
42
|
-
node: {
|
|
43
|
-
type: Object,
|
|
44
|
-
required: true,
|
|
45
|
-
},
|
|
46
|
-
schema: {
|
|
47
|
-
type: Object as PropType<JSONSchemaType<any>>,
|
|
48
|
-
required: true,
|
|
49
|
-
},
|
|
50
|
-
features: {
|
|
51
|
-
type: Object as PropType<{
|
|
52
|
-
hasInputSchema: boolean;
|
|
53
|
-
hasOutputSchema: boolean;
|
|
54
|
-
}>,
|
|
55
|
-
required: true,
|
|
56
|
-
},
|
|
57
|
-
},
|
|
58
|
-
data() {
|
|
59
|
-
return {
|
|
60
|
-
localNode: this.node,
|
|
61
|
-
errors: {},
|
|
62
|
-
};
|
|
63
|
-
},
|
|
64
|
-
beforeMount() {
|
|
65
|
-
// Normalize array-typed properties to actual arrays. Nodes saved with an
|
|
66
|
-
// older version of the code may have stored array values as comma-separated
|
|
67
|
-
// strings; this ensures validation and future saves always see real arrays.
|
|
68
|
-
if (this.schema?.properties) {
|
|
69
|
-
for (const [prop, propSchema] of Object.entries(this.schema.properties)) {
|
|
70
|
-
if (
|
|
71
|
-
(propSchema as any).type === "array" &&
|
|
72
|
-
!Array.isArray(this.localNode[prop])
|
|
73
|
-
) {
|
|
74
|
-
const val = this.localNode[prop];
|
|
75
|
-
this.localNode[prop] = val
|
|
76
|
-
? String(val).split(",").filter(Boolean)
|
|
77
|
-
: [];
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
// Set __PWD__ for existing password fields before the first validation so
|
|
83
|
-
// the password-skip logic in validate() sees the sentinel value correctly.
|
|
84
|
-
if (this.localNode._def.credentials) {
|
|
85
|
-
Object.keys(this.localNode._def.credentials).forEach((prop) => {
|
|
86
|
-
if (
|
|
87
|
-
this.localNode._def.credentials[prop].type === "password" &&
|
|
88
|
-
this.localNode.credentials[`has_${prop}`]
|
|
89
|
-
) {
|
|
90
|
-
this.localNode.credentials[prop] = "__PWD__";
|
|
91
|
-
}
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
this.validate();
|
|
96
|
-
|
|
97
|
-
if (this.localNode._def.defaults) {
|
|
98
|
-
Object.keys(this.localNode._def.defaults).forEach((prop) => {
|
|
99
|
-
this.$watch(
|
|
100
|
-
() => this.localNode[prop],
|
|
101
|
-
() => {
|
|
102
|
-
this.validate();
|
|
103
|
-
},
|
|
104
|
-
{ deep: true },
|
|
105
|
-
);
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
if (this.localNode._def.credentials) {
|
|
110
|
-
Object.keys(this.localNode._def.credentials).forEach((prop) => {
|
|
111
|
-
this.$watch(
|
|
112
|
-
() => this.localNode.credentials[prop],
|
|
113
|
-
(newVal, oldVal) => {
|
|
114
|
-
this.validate();
|
|
115
|
-
|
|
116
|
-
if (
|
|
117
|
-
this.localNode._def.credentials[prop].type === "password" &&
|
|
118
|
-
newVal !== oldVal
|
|
119
|
-
) {
|
|
120
|
-
this.localNode.credentials[`has_${prop}`] = !!newVal;
|
|
121
|
-
}
|
|
122
|
-
},
|
|
123
|
-
{ deep: true },
|
|
124
|
-
);
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
},
|
|
128
|
-
beforeUnmount() {
|
|
129
|
-
// NOTE: must set credentials prop to undefined to avoid updating it to __PWD__ in the server
|
|
130
|
-
if (this.localNode._def.credentials) {
|
|
131
|
-
Object.keys(this.localNode._def.credentials).forEach((prop) => {
|
|
132
|
-
if (
|
|
133
|
-
this.localNode._def.credentials[prop].type === "password" &&
|
|
134
|
-
this.localNode.credentials?.[`has_${prop}`] &&
|
|
135
|
-
this.localNode.credentials?.[prop] === "__PWD__"
|
|
136
|
-
) {
|
|
137
|
-
this.localNode.credentials[prop] = undefined;
|
|
138
|
-
}
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
|
-
},
|
|
142
|
-
methods: {
|
|
143
|
-
validate() {
|
|
144
|
-
const result = validator.validate(this.localNode, this.schema, {
|
|
145
|
-
cacheKey: `node-schema-${this.node.type}`,
|
|
146
|
-
});
|
|
147
|
-
|
|
148
|
-
if (!result.valid) {
|
|
149
|
-
this.errors = result.errors.reduce((acc, error) => {
|
|
150
|
-
const errorValue = jsonpointer.get(
|
|
151
|
-
this.localNode,
|
|
152
|
-
error.instancePath,
|
|
153
|
-
);
|
|
154
|
-
if (
|
|
155
|
-
error.parentSchema?.format === "password" &&
|
|
156
|
-
errorValue === "__PWD__"
|
|
157
|
-
) {
|
|
158
|
-
return acc;
|
|
159
|
-
} else {
|
|
160
|
-
const key = `node${error.instancePath.replaceAll("/", ".")}`;
|
|
161
|
-
acc[key] = error.message;
|
|
162
|
-
return acc;
|
|
163
|
-
}
|
|
164
|
-
}, {});
|
|
165
|
-
} else {
|
|
166
|
-
this.errors = {};
|
|
167
|
-
}
|
|
168
|
-
},
|
|
169
|
-
},
|
|
170
|
-
});
|
|
171
|
-
</script>
|
|
172
|
-
|
|
173
|
-
<style scoped>
|
|
174
|
-
:deep(.node-red-vue-input-error-message) {
|
|
175
|
-
color: var(--red-ui-text-color-error);
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
:deep(.form-row input[type="text"]),
|
|
179
|
-
:deep(.form-row input[type="number"]),
|
|
180
|
-
:deep(.form-row input[type="password"]) {
|
|
181
|
-
height: 34px;
|
|
182
|
-
padding: 0 8px;
|
|
183
|
-
box-sizing: border-box;
|
|
184
|
-
}
|
|
185
|
-
</style>
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div style="display: flex; flex-direction: column; width: 100%">
|
|
3
|
-
<slot name="label">
|
|
4
|
-
<NodeRedInputLabel
|
|
5
|
-
v-if="label"
|
|
6
|
-
:label="label"
|
|
7
|
-
:icon="icon"
|
|
8
|
-
:required="required"
|
|
9
|
-
/>
|
|
10
|
-
</slot>
|
|
11
|
-
<input :id="inputId" type="text" style="width: 100%" />
|
|
12
|
-
<div v-if="error" class="node-red-vue-input-error-message">
|
|
13
|
-
{{ error }}
|
|
14
|
-
</div>
|
|
15
|
-
</div>
|
|
16
|
-
</template>
|
|
17
|
-
|
|
18
|
-
<script lang="ts">
|
|
19
|
-
import { defineComponent } from "vue";
|
|
20
|
-
import NodeRedInputLabel from "./node-red-input-label.vue";
|
|
21
|
-
export default defineComponent({
|
|
22
|
-
components: { NodeRedInputLabel },
|
|
23
|
-
props: {
|
|
24
|
-
value: {
|
|
25
|
-
type: String,
|
|
26
|
-
default: "",
|
|
27
|
-
},
|
|
28
|
-
type: {
|
|
29
|
-
type: String,
|
|
30
|
-
required: true,
|
|
31
|
-
},
|
|
32
|
-
node: {
|
|
33
|
-
type: Object,
|
|
34
|
-
required: true,
|
|
35
|
-
},
|
|
36
|
-
propName: {
|
|
37
|
-
type: String,
|
|
38
|
-
required: true,
|
|
39
|
-
},
|
|
40
|
-
label: {
|
|
41
|
-
type: String,
|
|
42
|
-
default: "",
|
|
43
|
-
},
|
|
44
|
-
icon: {
|
|
45
|
-
type: String,
|
|
46
|
-
default: "",
|
|
47
|
-
},
|
|
48
|
-
required: {
|
|
49
|
-
type: Boolean,
|
|
50
|
-
default: false,
|
|
51
|
-
},
|
|
52
|
-
error: {
|
|
53
|
-
type: String,
|
|
54
|
-
default: "",
|
|
55
|
-
},
|
|
56
|
-
},
|
|
57
|
-
emits: ["update:value"],
|
|
58
|
-
computed: {
|
|
59
|
-
inputId() {
|
|
60
|
-
return "node-input-" + this.propName;
|
|
61
|
-
},
|
|
62
|
-
},
|
|
63
|
-
mounted() {
|
|
64
|
-
RED.editor.prepareConfigNodeSelect(
|
|
65
|
-
this.node,
|
|
66
|
-
this.propName,
|
|
67
|
-
this.type,
|
|
68
|
-
"node-input",
|
|
69
|
-
);
|
|
70
|
-
|
|
71
|
-
const input = $("#" + this.inputId);
|
|
72
|
-
input.on("change", () => {
|
|
73
|
-
this.$emit("update:value", input.val());
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
input.val(this.value || "_ADD_");
|
|
77
|
-
},
|
|
78
|
-
});
|
|
79
|
-
</script>
|