Comments (6)
Thanks for the feedback @pi0! We'll make these changes soon.
from formkit.
@pi0 — I refactored most of the module in this most recent push — including using resolvePath
and reducing the templating significantly. It now only has 2 simple template outputs. Honestly I would love to get rid of the template all together, but as far as I can tell there is no way to pass functions and other non serializable data to a nuxt plugin from a nuxt module using addPlugin
(or is there?).
FormKit uses lots of user-defined functions in its configuration (like plugin functions for example) — so as far as I know, I still need to use the template to "manually" write those import
statements (is my assumption true?)
from formkit.
Amazing work @justin-schroeder ! Added two comments to 0cbfab5 hopefully solving template issue.
from formkit.
@pi0 — ok, played around with the nuxt.options.alias
a bit to try and fully remove the template — but I've fallen short. I need to import a named import (import { defaultConfig } from '@fomrkit/core'
) based on the module option option.defaultConfig
. So for example, the final template output could be 1 of 3 variations:
1. No configFile or detected config file provided:
import { defineNuxtPlugin } from '#app'
import { plugin, defaultConfig } from '@formkit/vue'
export default defineNuxtPlugin((nuxtApp) => {
nuxtApp.vueApp.use(plugin, defaultConfig)
})
2. formkit.config.(ts|mjs|js)
exists and defaultConfig
is true
(default)
import { defineNuxtPlugin } from '#app'
import { plugin, defaultConfig } from '@formkit/vue'
import config from './path/to/formkit.config.ts'
export default defineNuxtPlugin((nuxtApp) => {
nuxtApp.vueApp.use(plugin, defaultConfig(config))
})
3. formkit.config.(ts|mjs|js)
is false
and defaultConfig
is false
In this case they provide the entire config setup, so we don’t import defaultConfig
at all:
import { defineNuxtPlugin } from '#app'
import { plugin } from '@formkit/vue'
import config from './path/to/formkit.config.ts'
export default defineNuxtPlugin((nuxtApp) => {
nuxtApp.vueApp.use(plugin, config)
})
If I understand correctly, I can alias import config from '#formkit-config'
to be the path to formkit.config.ts
file which solves 1 import question, but doesn't solve the variability of the named import { defaultConfig } from '@formkit/vue'
. If users dont want the defaultConfig
I dont want to import it since it includes a lot of default weight people may not want to absorb.
Is this a use case for keeping the template around, or are there other paths forward?
from formkit.
We can think of some ideas to alias config to an empty alias (like #empty
) but we could also use a dynamic import template from the module:
addTemplate({
filename: '#fromkit-config'
getContents: () => { /* dynamic logic to generate exportstatement */ return 'export default ...' }
})
This way we can still avoid lodash template in plugin while having full control over logic using a template for config.
from formkit.
We've been able to remove the lodash templates in the latest release. Closing this one!
from formkit.
Related Issues (20)
- datetime-local field with initial value resets itself in firefox after the entry of a 0
- FormKit datepicker component: enter key submits the form and display the calendar popup
- `childRemoved` event not triggered for type list HOT 1
- setting Buddist locale breaks datepicker HOT 2
- Changing `datepicker` value makes it to autofocus on Safari
- Pro Inputs - Potential Memory Leak Issue HOT 1
- blur() doesn't remove focused attributes such as highlighted border and text inputs remain focused.
- icon-click does not trigger on keyboard action
- When using Schema, fields rendered within a `children` slot of a custom component don't have access to `$value.xxx`
- Form nodes not retrievable via getNode() or useFormKitNodeById() after component re-render on locale change.
- Support for extra units for the Unit Input
- Autocomplete input - selected option is not reactive with selection-appearance=text
- tailwind classes not apply on formkit
- Dropdown truncation issues
- Ability to create compound units from the Unit Input
- Datepicker disabled-days + validation removes validation message
- Inconsistent paste behavior in taglist field
- Nested repeater causes recursive updates HOT 5
- After Update to Vue 3.5.x FormKitSchema cleanup on unmount throws Exception HOT 17
- Min decimals prop not working correctly with currency and unit inputs. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from formkit.