OpenVue based FormKit Inputs for using FormKit with the OpenVue UI Framework (openvue).
Main focus of this project is to provide configuration based forms with validation.
In addition, you can use the same pattern for data output from schema using FormOutputs.
Actual OpenVue Version of the main branch is 1.0.0.
This package replaces the former PrimeVue based @sfxcode/formkit-primevue. It uses the open source OpenVue components (openvue, @openvue/themes, @openvue/openicons) instead of PrimeVue.
Migrating from @sfxcode/formkit-primevue to @sfxcode/formkit-openvue:
-
Replace the package and the UI framework
pnpm remove @sfxcode/formkit-primevue primevue @primeuix/themes primeicons pnpm add @sfxcode/formkit-openvue openvue @openvue/themes @openvue/openicons
-
Update the imports (including
/components,/composablesand the scss file)// before import { primeInputs, primeOutputs } from '@sfxcode/formkit-primevue' // after import { formInputs, formOutputs } from '@sfxcode/formkit-openvue'
-
Rename the input and output types in your schemas: the
primeprefix is nowformPrimeVue OpenVue type: 'primeInputText'type: 'formInputText'type: 'primeSelect'type: 'formSelect'type: 'primeOutputText'type: 'formOutputText'primeInputs,primeOutputsformInputs,formOutputsusePrimeInputs()useFormInputs()PrimeInputText(component)FormInputText(component)A search and replace of
primefollowed by an uppercase letter (prime[A-Z]->form,Prime[A-Z]->Form) covers most of it. -
Replace PrimeVue with OpenVue in your app setup: use the
openvuecomponents, themes and@openvue/openicons(instead of PrimeIcons) and register them as you did with PrimeVue. -
Update custom CSS: selectors like
[data-type="primeCheckbox"]become[data-type="formCheckbox"].
Also rename the i18n keys formkit.prime.true / formkit.prime.false to formkit.form.true / formkit.form.false. If you use useInputEditor, its data fields prime, prime_key and prime_value are now form, form_key and form_value. The stylesheet is now formkit-openvue.scss (update imports of dist/sass/formkit-primevue.scss). Not changed: the p-formkit wrapper class.
Install the latest release of @sfxcode/formkit-openvue together with OpenVue:
pnpm add @sfxcode/formkit-openvue openvue @openvue/themes @openvue/openicons
# or: npm install ... / yarn add ...Set up OpenVue, FormKit and the form inputs in your main.ts:
import Aura from '@openvue/themes/aura'
import { defaultConfig, plugin } from '@formkit/vue'
import { formInputs, useFormInputs } from '@sfxcode/formkit-openvue'
import OpenVue from 'openvue/config'
import { createApp } from 'vue'
import App from './App.vue'
import '@openvue/openicons/openicons.css'
import '@sfxcode/formkit-openvue/dist/style.css'
const app = createApp(App)
// OpenVue with theme
app.use(OpenVue, { theme: { preset: Aura } })
// register the OpenVue components used by the form inputs
const { registerInputs } = useFormInputs()
registerInputs(app)
// FormKit with the OpenVue inputs
app.use(plugin, defaultConfig({ inputs: formInputs }))
app.mount('#app')Use the inputs in a FormKit schema (or as <FormKit type="formInputText" ... />):
<script setup lang="ts">
import { ref } from 'vue'
const data = ref({ email: '' })
const schema = [
{ $formkit: 'formInputText', name: 'email', label: 'Email', validation: 'required|email' },
{ $formkit: 'formCheckbox', name: 'newsletter', label: 'Subscribe to the newsletter' },
]
</script>
<template>
<FormKit v-model="data" type="form">
<FormKitSchema :schema="schema" :data="data" />
</FormKit>
</template>See Usage for outputs, i18n and more configuration.
Add formkit.config.ts
import { defaultConfig, plugin } from '@formkit/vue'
import { formInputs } from '@sfxcode/formkit-openvue'
app.use(plugin, defaultConfig({
locales: { de, en },
// Define the active locale
locale: 'en',
inputs: formInputs,
}))or if using also the output part
import { defaultConfig, plugin } from '@formkit/vue'
import { formInputs, formOutputs } from '@sfxcode/formkit-openvue'
app.use(plugin, defaultConfig({
locales: { de, en },
// Define the active locale
locale: 'en',
inputs: { ...formInputs, ...formOutputs },
}))Important: output elements depends on vue-i18n to style numbers, dates, ...
Prefixing of the OpenVue component names is not supported.
useFormKitSchema provide functions to simplify the usage of elements, components, lists, ...
useInputEditorSchema provide functions for a component schema generation builder
Basic styling is provided with the formkit-openvue.scss file or the corresponding css file in the package.
Features:
- Width of all text and dropdown elements is set to 100%
- Error Color by variable (--formkit-error-color)
- Some margins, font sizes ...
You can use it or take it as base for your own styling.
- Styling outerClas, innerClass .... is provided by FormKit
- All inputs, outputs are wrapped in a div with a p-formkit class
- Most of the OpenVue Input Components have access to class / styles attributes
- PT and PTOptions are available (pass-through API of OpenVue components)
- Styling and PT demo available
- Grid Demo of the provided grid styling (col-[1-12])
Some samples for common tasks are available
- Repeater Use Repeater composable for using repeating values in your schema
- Input Editor Edit FormKit schema on the based on a provided composable
- Form Editor Basic demo as starter to create Forms visually
- AutoComplete
- CascadeSelect
- Checkbox
- ColorPicker
- DatePicker
- Editor (HTML Editor - if you register the editor component, make sure to import quill)
- InputMask
- InputNumber
- InputOtp
- InputText
- Knob
- Listbox
- MultiSelect
- Password
- RadioButton
- Rating
- Repeater (not an OpenVue component, but provided as helper for repeating groups of inputs)
- Select
- SelectButton
- Slider
- Textarea
- ToggleButton
- ToggleSwitch
- TreeSelect
