UNPKG

auto-form-builder

Version:

๐Ÿงฑ Vue Auto Form Builder with schema-based generation, themes, validation and localization.

121 lines (93 loc) โ€ข 2.65 kB
# ๐Ÿงฑ vue-auto-form-builder [![npm](https://img.shields.io/npm/v/auto-form-builder)](https://www.npmjs.com/package/auto-form-builder) A smart and fully customizable Vue 3 component to auto-generate forms using a simple JSON schema. Supports **RTL**, **Dark Mode**, **themes**, **sections**, **validation**, **i18n**, and more โ€” all out of the box โšก๏ธ --- ## โœจ Features - ๐Ÿ“„ Build forms instantly from a schema - ๐Ÿง‘โ€๐ŸŽจ Fully customizable styling via `themeConfig` - ๐Ÿงฉ Supports all common field types: text, number, password, file, switch, checkbox, radio, textarea, select, etc. - ๐Ÿ“ฆ Section-based grouping (with `section` titles) - โœ… Built-in validation (required, min, max, pattern) - ๐ŸŒ Multi-language support (EN / AR auto-detect) - ๐ŸŒ“ Auto dark mode support via `prefers-color-scheme` - ๐Ÿ”— Optional `submitUrl` to POST form data automatically - ๐Ÿงช Works perfectly with Tailwind / Bootstrap - ๐Ÿ’ก JSON output ready-to-use - ๐Ÿชถ Lightweight and dependency-free --- ## ๐Ÿ“ฆ Installation ```bash npm install auto-form-builder ``` --- ## ๐Ÿš€ Usage ```ts import { AutoForm } from "auto-form-builder"; ``` ```vue <AutoForm :schema="formSchema" @submit="handleSubmit" /> ``` --- ## ๐Ÿ“˜ Schema Example ```ts const formSchema = [ { section: "ู…ุนู„ูˆู…ุงุช ุฃุณุงุณูŠุฉ", fields: [ { name: "name", label: "ุงู„ุงุณู…", type: "text", required: true }, { name: "email", label: "ุงู„ุจุฑูŠุฏ ุงู„ุฅู„ูƒุชุฑูˆู†ูŠ", type: "email", required: true, }, { name: "gender", label: "ุงู„ุฌู†ุณ", type: "radio", options: ["ุฐูƒุฑ", "ุฃู†ุซู‰"], }, ], }, { section: "ุชูุงุตูŠู„ ุฅุถุงููŠุฉ", fields: [ { name: "dob", label: "ุชุงุฑูŠุฎ ุงู„ู…ูŠู„ุงุฏ", type: "date" }, { name: "resume", label: "ุงู„ุณูŠุฑุฉ ุงู„ุฐุงุชูŠุฉ", type: "file" }, ], }, ]; ``` --- ## ๐ŸŽจ Theme Configuration (optional) ```ts <AutoForm :schema="formSchema" :theme-config="{ input: 'bg-gray-100 rounded border p-2', label: 'text-gray-700 font-semibold', submitButton: 'bg-blue-600 text-white py-2 px-4 rounded' }" /> ``` --- ## ๐Ÿ“ Project Structure ``` vue-auto-form-builder/ โ”œโ”€โ”€ src/ โ”‚ โ”œโ”€โ”€ components/AutoForm.vue โ”‚ โ”œโ”€โ”€ utils/schemaParser.ts โ”œโ”€โ”€ package.json โ”œโ”€โ”€ README.md โ””โ”€โ”€ tsconfig.json ``` --- ## ๐Ÿ› ๏ธ Build & Publish ```bash npm run build npm publish ``` --- ## ๐Ÿ“œ License [LICENSE](License)