sfxcode / formkit-primevue

PrimeVue (v4, v3) support for the FormKit validation Framwork
https://sfxcode.github.io/formkit-primevue
MIT License
110 stars 9 forks source link

Autoimport #56

Closed raizdev closed 3 weeks ago

raizdev commented 3 weeks ago

Im using Vue without nuxt, i was wondering if there is a way to make auto import possible.

Now I have to import all the used components in main.js

app.component('InputText', InputText);
app.component('Checkbox', Checkbox);
app.component('Editor', Editor);
app.component('Textarea', Textarea);
sfxcode commented 3 weeks ago

Hi,

because wrapped PrimeInputs depends on the related PrimeVue input components, they have to registered for using them. Autoimports that scans your code will fail, because they are referenced in the node_modules formkit-primevue package.

I put the composable in the latest version to load all needed inputs at once in the main package folder. So you can use:

  // input components
  const { registerInputs } = usePrimeInputs()
  registerInputs(app)

to import them without much code ...

See in the playground demo:

https://github.com/sfxcode/formkit-primevue/blob/v2.4.16/dev/modules/primevue.ts

Hope that helps for the moment,

Greetings and have a nice coding time,

Tom

raizdev commented 3 weeks ago

That worked! Thankyou :)