diff --git a/docs/.vitepress/components/FormCompositionOptionsApi.vue b/docs/.vitepress/components/FormCompositionOptionsApi.vue deleted file mode 100644 index dcbdc72..0000000 --- a/docs/.vitepress/components/FormCompositionOptionsApi.vue +++ /dev/null @@ -1,26 +0,0 @@ - - - diff --git a/docs/.vitepress/config.js b/docs/.vitepress/config.js new file mode 100644 index 0000000..aefeaf7 --- /dev/null +++ b/docs/.vitepress/config.js @@ -0,0 +1,94 @@ +/* import { UserConfig } from 'vitepress' + */ +const { description } = require('../../package') + +const config = { + title: 'Vue Dynamic Forms', + description, + lang: 'en-US', + themeConfig: { + repo: 'asigloo/vue-dynamic-forms', + logo: '/logo.svg', + editLinks: true, + editLinkText: 'Edit this page', + lastUpdated: 'Last Updated', + nav: [ + { + text: 'Migration Guide', + link: '/v3/guide/migration-guide', + }, + ], + sidebar: { + '/': [ + { + text: 'Guide', + children: [ + { + text: 'Introduction', + link: '/guide/', + }, + { + text: 'Getting Started', + link: '/guide/getting-started', + }, + { + text: 'Usage', + link: '/guide/usage', + }, + { + text: 'Validation', + link: '/guide/validation', + }, + ], + }, + { + text: 'API', + children: [ + { + text: 'Fields', + link: '/guide/api/fields', + }, + { + text: 'Props', + link: '/guide/api/props', + children: [ + { + text: 'Dynamic Form', + link: '/guide/api/props/dynamic-form-props', + }, + { + text: 'Dynamic Input', + link: '/guide/api/props/dynamic-input-props', + }, + ], + }, + { + text: 'Events', + link: '/guide/api/events', + }, + ], + }, + { + text: 'Theming', + children: [ + { + text: 'Basic theming', + link: '/guide/theming/basic', + }, + ], + }, + { + text: 'Advanced', + children: [ + { + text: 'Slots', + link: '/guide/advanced/slots', + }, + ], + }, + ], + }, + }, +} + +module.exports = config diff --git a/docs/.vitepress/config.ts b/docs/.vitepress/config.ts deleted file mode 100644 index 9c5e62d..0000000 --- a/docs/.vitepress/config.ts +++ /dev/null @@ -1,37 +0,0 @@ -const { description } = require('../../package') - -module.exports = { - title: 'Vue Dynamic Forms', - description, - themeConfig: { - repo: 'asigloo/vue-dynamic-forms', - logo: '/logo.svg', - nav: [ - { - text: 'Migration Guide', - link: '/v3/guide/migration-guide', - }, - ], - sidebar: { - '/': [ - { - text: 'Guide', - children: [ - { - text: 'Introduction', - link: '/guide/', - }, - { - text: 'Getting Started', - link: '/guide/getting-started', - }, - { - text: 'Usage', - link: '/guide/usage', - }, - ], - }, - ], - }, - }, -} diff --git a/docs/.vitepress/dist/logo.png b/docs/.vitepress/dist/logo.png new file mode 100644 index 0000000..803b955 Binary files /dev/null and b/docs/.vitepress/dist/logo.png differ diff --git a/docs/.vitepress/dist/logo.svg b/docs/.vitepress/dist/logo.svg new file mode 100644 index 0000000..72fe302 --- /dev/null +++ b/docs/.vitepress/dist/logo.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/docs/.vitepress/theme/components/CheckboxInput.vue b/docs/.vitepress/theme/components/CheckboxInput.vue new file mode 100644 index 0000000..3553c48 --- /dev/null +++ b/docs/.vitepress/theme/components/CheckboxInput.vue @@ -0,0 +1,68 @@ + + + diff --git a/docs/.vitepress/theme/components/Console.vue b/docs/.vitepress/theme/components/Console.vue new file mode 100644 index 0000000..272093f --- /dev/null +++ b/docs/.vitepress/theme/components/Console.vue @@ -0,0 +1,31 @@ + + + diff --git a/docs/.vitepress/theme/components/CustomField.vue b/docs/.vitepress/theme/components/CustomField.vue new file mode 100644 index 0000000..95acf06 --- /dev/null +++ b/docs/.vitepress/theme/components/CustomField.vue @@ -0,0 +1,88 @@ + + + + + diff --git a/docs/.vitepress/theme/components/EmailField.vue b/docs/.vitepress/theme/components/EmailField.vue new file mode 100644 index 0000000..ea9fd19 --- /dev/null +++ b/docs/.vitepress/theme/components/EmailField.vue @@ -0,0 +1,71 @@ + + + diff --git a/docs/.vitepress/theme/components/FormCompositionOptionsApi.vue b/docs/.vitepress/theme/components/FormCompositionOptionsApi.vue new file mode 100644 index 0000000..0be1a17 --- /dev/null +++ b/docs/.vitepress/theme/components/FormCompositionOptionsApi.vue @@ -0,0 +1,58 @@ + + + + + diff --git a/docs/.vitepress/theme/components/NumberField.vue b/docs/.vitepress/theme/components/NumberField.vue new file mode 100644 index 0000000..6fb1f3b --- /dev/null +++ b/docs/.vitepress/theme/components/NumberField.vue @@ -0,0 +1,56 @@ + + + diff --git a/docs/.vitepress/theme/components/PasswordField.vue b/docs/.vitepress/theme/components/PasswordField.vue new file mode 100644 index 0000000..ea8e441 --- /dev/null +++ b/docs/.vitepress/theme/components/PasswordField.vue @@ -0,0 +1,70 @@ + + + diff --git a/docs/.vitepress/theme/components/RadioInput.vue b/docs/.vitepress/theme/components/RadioInput.vue new file mode 100644 index 0000000..4698f16 --- /dev/null +++ b/docs/.vitepress/theme/components/RadioInput.vue @@ -0,0 +1,73 @@ + + + diff --git a/docs/.vitepress/theme/components/SelectField.vue b/docs/.vitepress/theme/components/SelectField.vue new file mode 100644 index 0000000..a9fcecc --- /dev/null +++ b/docs/.vitepress/theme/components/SelectField.vue @@ -0,0 +1,69 @@ + + + diff --git a/docs/.vitepress/theme/components/TextAreaField.vue b/docs/.vitepress/theme/components/TextAreaField.vue new file mode 100644 index 0000000..8045af7 --- /dev/null +++ b/docs/.vitepress/theme/components/TextAreaField.vue @@ -0,0 +1,63 @@ + + + diff --git a/docs/.vitepress/theme/components/TextField.vue b/docs/.vitepress/theme/components/TextField.vue new file mode 100644 index 0000000..1eda025 --- /dev/null +++ b/docs/.vitepress/theme/components/TextField.vue @@ -0,0 +1,55 @@ + + + diff --git a/docs/.vitepress/theme/components/ValidationEmail.vue b/docs/.vitepress/theme/components/ValidationEmail.vue new file mode 100644 index 0000000..8a77f5e --- /dev/null +++ b/docs/.vitepress/theme/components/ValidationEmail.vue @@ -0,0 +1,75 @@ + + + diff --git a/docs/.vitepress/theme/components/ValidationMax.vue b/docs/.vitepress/theme/components/ValidationMax.vue new file mode 100644 index 0000000..5f7b21c --- /dev/null +++ b/docs/.vitepress/theme/components/ValidationMax.vue @@ -0,0 +1,61 @@ + + + diff --git a/docs/.vitepress/theme/components/ValidationMaxLength.vue b/docs/.vitepress/theme/components/ValidationMaxLength.vue new file mode 100644 index 0000000..2770f62 --- /dev/null +++ b/docs/.vitepress/theme/components/ValidationMaxLength.vue @@ -0,0 +1,68 @@ + + + diff --git a/docs/.vitepress/theme/components/ValidationMin.vue b/docs/.vitepress/theme/components/ValidationMin.vue new file mode 100644 index 0000000..bb0d25f --- /dev/null +++ b/docs/.vitepress/theme/components/ValidationMin.vue @@ -0,0 +1,61 @@ + + + diff --git a/docs/.vitepress/theme/components/ValidationMinLength.vue b/docs/.vitepress/theme/components/ValidationMinLength.vue new file mode 100644 index 0000000..12b2a75 --- /dev/null +++ b/docs/.vitepress/theme/components/ValidationMinLength.vue @@ -0,0 +1,65 @@ + + + diff --git a/docs/.vitepress/theme/components/ValidationPattern.vue b/docs/.vitepress/theme/components/ValidationPattern.vue new file mode 100644 index 0000000..bab86be --- /dev/null +++ b/docs/.vitepress/theme/components/ValidationPattern.vue @@ -0,0 +1,77 @@ + + + diff --git a/docs/.vitepress/theme/components/ValidationRequired.vue b/docs/.vitepress/theme/components/ValidationRequired.vue new file mode 100644 index 0000000..f059129 --- /dev/null +++ b/docs/.vitepress/theme/components/ValidationRequired.vue @@ -0,0 +1,75 @@ + + + diff --git a/docs/.vitepress/theme/components/ValidationUrl.vue b/docs/.vitepress/theme/components/ValidationUrl.vue new file mode 100644 index 0000000..25ac2e7 --- /dev/null +++ b/docs/.vitepress/theme/components/ValidationUrl.vue @@ -0,0 +1,75 @@ + + + diff --git a/docs/.vitepress/theme/index.ts b/docs/.vitepress/theme/index.ts index a3a0a23..c4ddde8 100644 --- a/docs/.vitepress/theme/index.ts +++ b/docs/.vitepress/theme/index.ts @@ -1,12 +1,6 @@ import DefaultTheme, { Config } from 'vitepress/theme' -import { createDynamicForms } from '../../../src' - -const modules = import.meta.globEager('../components/**/*.vue') -const components = [] - -for (const path in modules) { - components.push(modules[path].default) -} +import { createDynamicForms } from '/@' +import '../theme/styles/base.scss' const VueDynamicForms = createDynamicForms({ autoValidate: true, @@ -22,9 +16,6 @@ const theme: Config = { ...DefaultTheme, enhanceApp({ app }) { app.use(VueDynamicForms) - components.forEach(component => { - app.component(component.name, component) - }) }, } diff --git a/docs/.vitepress/theme/styles/base.scss b/docs/.vitepress/theme/styles/base.scss new file mode 100644 index 0000000..4ed7521 --- /dev/null +++ b/docs/.vitepress/theme/styles/base.scss @@ -0,0 +1,104 @@ +@tailwind base; +@tailwind components; +@tailwind utilities; + +.nav-bar-title { + @apply flex items-center; +} + +@layer base { + h1 { + @apply text-2xl mt-16 mb-9; + } + h2 { + @apply text-xl mt-9 mb-5; + } + p, + ol, + ul { + @apply my-4 leading-relaxed; + } + + ol, + ul { + @apply pl-4; + } + + ul { + @apply list-disc; + } + + h1, + h2, + h3, + h4, + h5, + h6, + strong, + b { + @apply font-bold; + } + + code { + @apply text-sm; + } +} + +.custom-block { + @apply my-4 py-1 px-6; +} + +.header-anchor { + @apply text-green-400; +} + +a { + @apply text-green-400 font-bold; +} + +.form-group { + @apply flex flex-col mb-4; +} + +.form-label { + @apply w-full mb-2 text-sm font-bold; +} + +.form-control { + @apply border-2 border-gray-300 rounded-lg px-4 py-2; + + &:focus { + @apply outline-none border-green-400; + } + + &--success { + @apply border-green-400 bg-green-50; + } + + &--error { + @apply border-red-400 bg-red-50; + } +} + +.form-hint { + @apply text-sm; +} + +.form-error { + @apply text-red-500; +} + +.checkbox-control, +.radio-control { + @apply mr-4; +} + +.checkbox-label, +.radio-label { + @apply select-none cursor-pointer text-sm; +} + +.checkbox-control:disabled ~ .checkbox-label, +.radio-control:disabled ~ .radio-label { + @apply opacity-50 text-gray-500 cursor-not-allowed pointer-events-none; +} diff --git a/docs/guide/advanced/slots.md b/docs/guide/advanced/slots.md new file mode 100644 index 0000000..0d78ebb --- /dev/null +++ b/docs/guide/advanced/slots.md @@ -0,0 +1,53 @@ +## Custom Field + +Using dynamic scoped slots approach, now is easy to add your own custom fields to the `dynamic-forms` component. + + + +The first step is to add a new `FormField` with `type: 'custom-field'` to your form fields array in the components data: + +```javascript +fields: { + avocado: CustomField({ + label: 'My Avocado field', + }), +}, + +``` + +Inside of the `dynamic-form` component, add a `