diff --git a/nodes/icons/ui_dynamic_form.svg b/nodes/icons/ui_dynamic_form.svg new file mode 100644 index 0000000..92fe836 --- /dev/null +++ b/nodes/icons/ui_dynamic_form.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/nodes/ui-dynamic-form.html b/nodes/ui-dynamic-form.html index ee6a9b1..dd362e6 100644 --- a/nodes/ui-dynamic-form.html +++ b/nodes/ui-dynamic-form.html @@ -40,7 +40,7 @@ outputLabels: function (index) { return this.options[index].label; }, - icon: 'file.svg', + icon: 'ui_dynamic_form.svg', label: function () { return this.name || 'dynamic-form'; }, diff --git a/package-lock.json b/package-lock.json index 03b6a2b..d1efb06 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,6 +9,8 @@ "version": "1.0.24", "license": "Apache-2.0", "dependencies": { + "@formkit/themes": "^1.6.5", + "@formkit/vue": "^1.6.5", "to-title-case": "^1.0.0", "vue": "^3.3.8", "vuex": "^4.1.0" @@ -462,6 +464,119 @@ "node": "^12.22.0 || ^14.17.0 || >=16.0.0" } }, + "node_modules/@formkit/core": { + "version": "1.6.5", + "resolved": "https://registry.npmjs.org/@formkit/core/-/core-1.6.5.tgz", + "integrity": "sha512-LLq8+vLd9ddPYA0NkyvnKycN4ESU8Wqcl9TrllPyU/axduJunSIJMZz4LHzlwK8G26b0pQNegXF/hXaj4wbmng==", + "dependencies": { + "@formkit/utils": "1.6.5" + } + }, + "node_modules/@formkit/dev": { + "version": "1.6.5", + "resolved": "https://registry.npmjs.org/@formkit/dev/-/dev-1.6.5.tgz", + "integrity": "sha512-dg62HTehLPi9lLBShixr9AoYgIv13gpxTZgiHEvf1UZz2HQq0Lcp63d0a+XT/tQ2HTz2ewLUGeXSN9dUVkYFSg==", + "dependencies": { + "@formkit/core": "1.6.5", + "@formkit/utils": "1.6.5" + } + }, + "node_modules/@formkit/i18n": { + "version": "1.6.5", + "resolved": "https://registry.npmjs.org/@formkit/i18n/-/i18n-1.6.5.tgz", + "integrity": "sha512-mM1UKGSa0Mdd8a8AAF+6BCNFnf8gUD1nOzU6dJ9UoPE8M/qA+hmcPR3PJm39p6e3OaT5O0Gn/J6JxgccPyWmGA==", + "dependencies": { + "@formkit/core": "1.6.5", + "@formkit/utils": "1.6.5", + "@formkit/validation": "1.6.5" + } + }, + "node_modules/@formkit/inputs": { + "version": "1.6.5", + "resolved": "https://registry.npmjs.org/@formkit/inputs/-/inputs-1.6.5.tgz", + "integrity": "sha512-mHLMF0JMFZL/JC6NYrG4xaIdi7lUNE+tdC+QMipBdhobUhND0EJSpO6QNPGF6OLd9Zm9MDgqAzNXEtc05/nvow==", + "dependencies": { + "@formkit/core": "1.6.5", + "@formkit/utils": "1.6.5" + } + }, + "node_modules/@formkit/observer": { + "version": "1.6.5", + "resolved": "https://registry.npmjs.org/@formkit/observer/-/observer-1.6.5.tgz", + "integrity": "sha512-3Vh2Pj6tHX3wosbNm5VvwVVlTI5Zq0FT3dl/+DAuaCG84abpTLoc3O0C2pmbQcDaJ4aCuxu3+tBmhY9J7qFXMQ==", + "dependencies": { + "@formkit/core": "1.6.5", + "@formkit/utils": "1.6.5" + } + }, + "node_modules/@formkit/rules": { + "version": "1.6.5", + "resolved": "https://registry.npmjs.org/@formkit/rules/-/rules-1.6.5.tgz", + "integrity": "sha512-j9ylAibBvNx+3tEAkYzl2HjQwDzWV2mRPmFH7GTAmtxijFiktPS8HTU9H88H/x2stkYk9S13/MMeqDgZnc3VrQ==", + "dependencies": { + "@formkit/core": "1.6.5", + "@formkit/utils": "1.6.5", + "@formkit/validation": "1.6.5" + } + }, + "node_modules/@formkit/themes": { + "version": "1.6.5", + "resolved": "https://registry.npmjs.org/@formkit/themes/-/themes-1.6.5.tgz", + "integrity": "sha512-C+ANzH6qw4zS7niv+RamJAqpASOPfrZvMURVj5HQcT1XlcYB7ULvA9UmDW/AKOqP/OGf/OL6WvOzA7B16UkiiA==", + "dependencies": { + "@formkit/core": "1.6.5" + }, + "peerDependencies": { + "tailwindcss": "^3.2.0", + "unocss": "0.x.x", + "windicss": "^3.0.0" + }, + "peerDependenciesMeta": { + "tailwindcss": { + "optional": true + }, + "unocss": { + "optional": true + }, + "windicss": { + "optional": true + } + } + }, + "node_modules/@formkit/utils": { + "version": "1.6.5", + "resolved": "https://registry.npmjs.org/@formkit/utils/-/utils-1.6.5.tgz", + "integrity": "sha512-fohOg344tqFujHlEwvyHzzH5YiOBgecuOPkg7r7QObUrsH8gP1N8Rp9CHZlafxZ1zAEHZY2nTNx0VVQBkVmJbA==" + }, + "node_modules/@formkit/validation": { + "version": "1.6.5", + "resolved": "https://registry.npmjs.org/@formkit/validation/-/validation-1.6.5.tgz", + "integrity": "sha512-mnU+F6uXsNlczbU7QOq6QfsafSYNmMF9zvOpk4ravn9mba0IDXRhkPgU/+VFpcF/EEiXmqQql3pqQ7Vqv2wVbg==", + "dependencies": { + "@formkit/core": "1.6.5", + "@formkit/observer": "1.6.5", + "@formkit/utils": "1.6.5" + } + }, + "node_modules/@formkit/vue": { + "version": "1.6.5", + "resolved": "https://registry.npmjs.org/@formkit/vue/-/vue-1.6.5.tgz", + "integrity": "sha512-D5W8JfhFJXUXm8RX0OfPbPZt3Ds68iqxSrvbvmyabae2cBlGl8sqhMEuc48FptnsGOYqYXOhG+CPni+uE72Whw==", + "dependencies": { + "@formkit/core": "1.6.5", + "@formkit/dev": "1.6.5", + "@formkit/i18n": "1.6.5", + "@formkit/inputs": "1.6.5", + "@formkit/observer": "1.6.5", + "@formkit/rules": "1.6.5", + "@formkit/themes": "1.6.5", + "@formkit/utils": "1.6.5", + "@formkit/validation": "1.6.5" + }, + "peerDependencies": { + "vue": "^3.4.0" + } + }, "node_modules/@humanwhocodes/config-array": { "version": "0.11.14", "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.14.tgz", diff --git a/package.json b/package.json index c19519d..1801d5a 100644 --- a/package.json +++ b/package.json @@ -54,6 +54,8 @@ "lint:package:fix": "sort-package-json 'package.json'" }, "dependencies": { + "@formkit/themes": "^1.6.5", + "@formkit/vue": "^1.6.5", "to-title-case": "^1.0.0", "vue": "^3.3.8", "vuex": "^4.1.0" diff --git a/ui/components/UIDynamicForm.vue b/ui/components/UIDynamicForm.vue index db39282..5da4d77 100644 --- a/ui/components/UIDynamicForm.vue +++ b/ui/components/UIDynamicForm.vue @@ -6,13 +6,13 @@ + v-if="createComponent(field).innerText" + :is="createComponent(field).type" + v-bind="createComponent(field).props" + > + {{ createComponent(field).innerText }} + + @@ -34,8 +34,11 @@ - diff --git a/ui/main.js b/ui/main.js index ce6a9fe..ecacb3b 100644 --- a/ui/main.js +++ b/ui/main.js @@ -3,8 +3,8 @@ * * This file is useful for testing your component in isolation from Node-RED. */ -import { createApp } from 'vue' +import { createApp } from 'vue'; +import { plugin, defaultConfig } from '@formkit/vue'; +import UIDynamicForm from './components/UIDynamicForm.vue'; -import UIDynamicForm from './components/UIDynamicForm.vue' - -createApp(UIDynamicForm).mount('#app') +createApp(UIDynamicForm).use(plugin, defaultConfig).mount('#app'); diff --git a/ui/stylesheets/ui-dynamic-form.css b/ui/stylesheets/ui-dynamic-form.css index d7cb064..421fe8d 100644 --- a/ui/stylesheets/ui-dynamic-form.css +++ b/ui/stylesheets/ui-dynamic-form.css @@ -1,44 +1,62 @@ .dynamic-form-wrapper { - padding: 10px; - margin: 10px; - border: 1px solid black; + padding: 10px; + margin: 10px; + border: 1px solid black; } .dynamic-form-class { - color: green; - font-weight: bold; + color: green; + font-weight: bold; } h1 { - margin-bottom: 10px; + margin-bottom: 10px; } h2 { - margin-top: 1.5rem; - margin-bottom: 0.75rem; + margin-top: 1.5rem; + margin-bottom: 0.75rem; } h3 { - margin-top: 1rem; + margin-top: 1rem; } p { - margin-bottom: 5px; + margin-bottom: 5px; } ul li { - list-style-type: circle; - list-style-position: inside; - margin-left: 15px; + list-style-type: circle; + list-style-position: inside; + margin-left: 15px; } pre { - padding: 12px; - margin: 12px; - background-color: #eee; + padding: 12px; + margin: 12px; + background-color: #eee; } code { - font-size: 0.825rem; - color: #ae0000; + font-size: 0.825rem; + color: #ae0000; +} + +.ui-dynamic-form-wrapper { + --fk-color-primary: rgb(var(--v-theme-primary)) !important; + --fk-color-border: rgb(var(--v-theme-group-outline)); /* Does not work somehow */ + --fk-bg-input: rgb(var(--v-theme-group-background)); + --fk-color-input: rgb(var(--v-theme-on-group-background)); + --fk-color-help: rgb(var(--v-theme-on-group-background)); + --fk-color-border-focus: rgb(var(--v-theme-primary)); +} + +.reset-background { + --fk-bg-input: rgb(var(--does-not-exist, #000)); + /* i dont know why this works but it works */ +} + +.custom-fieldset { + max-width: none !important; }