formkit-builder

formkit-builder is a powerful Vue component package designed to streamline form creation and API interaction in Vue.js projects. With formkit-builder, developers can easily generate dynamic forms for data creation and updating, simplifying the process of
1,467
Install
npm install formkit-builder
Latest Version:0.4.4
Vue:3
License:ISC
Last Updated:Jul 19, 2023
Links: npm
Maintainer: ahmeddarwish

Sure! Here's a template for a README file for your Formkit Builder npm package:

Formkit Builder

Formkit Builder is a Vue 3 package that provides a wrapper around Formkit forms, offering advanced features such as seamless loading handling, error management, and API calls. It simplifies the process of creating ready-to-use forms by allowing you to pass a sections object, submit handler, and form options.

Features

  • Wraps Formkit forms in a more advanced form component
  • Handles loading state during form submission
  • Manages errors and displays them in the form
  • Supports API calls for form submission
  • Built with Vue 3 and Formkit

Installation

To install Formkit Builder, you need to have Vue 3 and Formkit installed in your project.

npm install formkit-builder

or

yarn add formkit-builder

Usage

Data Create Form

<script setup lang="ts">
// import { DataCreateForm } from './components';
import { FormKitSection, FormKitError, FormKitOptions, FormSubmitHandler } from './types'

const errorHandler: Record<string, FormKitError> = {
  unique_constraint_roles_role_name_key: {
    roleName: 'unique_constraint_roles_role_name_key'
  }
}
const redirectRoute: string = 'roles_list'
const sections: FormKitSection[] = [
  {
    roleInfo: [
      {
        $formkit: 'text',
        outerClass: 'col-4',
        name: 'roleName',
        label: 'roleNameLabel',
        placeholder: 'roleNamePlaceholder',
        validation: 'required|length:3'
      },
      {
        $formkit: 'textarea',
        outerClass: 'col-8',
        name: 'roleDescription',
        label: 'roleDescriptionLabel',
        placeholder: 'roleDescriptionPlaceholder',
        validation: ''
      }
    ]
  }
]
const options: FormKitOptions = {
  title: 'role_create',
  allowBulkDelete: true
}
const submitHandler: FormSubmitHandler<any, any, any> = {
  submit: (req: any) => {
    console.log(req)
    return new Promise(async (resolve) => {
      resolve(null)
    })
  },
  errorHandler,
  redirectRoute
}
</script>

<template>
  <data-create-form :sections="sections" :submitHandler="submitHandler" :options="options" />
</template>

Data Update Form

<script setup lang="ts">
import type { FormKitSection, FormKitError, FormKitOptions, FormSubmitHandler, FormFindDataHandler } from '@/types'
import type { RoleUpdateRequest, RoleUpdateResponse, RoleFindRequest, RoleFindResponse } from '@/api/ApiTypes';
import apiClient from '@/api/ApiMock';
import { useI18n } from 'vue-i18n';

const { t } = useI18n()
const errorHandler: Record<string, FormKitError> = {
  'unique_constraint_roles_role_name_key': {
    roleName: 'unique_constraint_roles_role_name_key'
  }
}
const redirectRoute: string = 'list'
const sections: FormKitSection[] = [
  {
    roleInfo: [
      {
        $formkit: 'text',
        outerClass: "col-4",
        name: 'roleName',
        label: t('roleNameLabel'),
        placeholder: t('roleNamePlaceholder'),
        validation: 'required|length:3',

      },
      {
        $formkit: 'textarea',
        outerClass: "col-8",
        name: 'roleDescription',
        label: t('roleDescriptionLabel'),
        placeholder: t('roleDescriptionPlaceholder'),
        validation: '',
      },
    ],
  },
]
const options: FormKitOptions = {
  title: "role_Update",
  allowBulkDelete: false,
}
const submitHandler: FormSubmitHandler<RoleUpdateRequest, RoleUpdateRequest, RoleUpdateResponse> = {
  submit: apiClient.roleUpdateWithGlobalErr,
  errorHandler,
  redirectRoute,
}
const findDataHandler: FormFindDataHandler<RoleFindRequest, RoleFindResponse, any> = {
  findData: apiClient.roleFind,
  findRequerPropertyName: 'roleId',
}

</script>

<template>
  <data-update-form :sections="sections" :findDataHandler="findDataHandler" :submitHandler="submitHandler"
    :options="options" />
</template>

Documentation

For detailed usage instructions and documentation, please visit the Formkit Builder Documentation.

Contributing

Contributions are welcome! If you encounter any issues or have suggestions for improvements, please open an issue on the GitHub repository.

License

This package is open source and available under the MIT License.

Acknowledgements

Formkit Builder is built upon the excellent Formkit library developed by Author's Name. We would like to extend our gratitude to the Formkit team for their amazing work.


Feel free to customize the template to fit your package and add more details as needed. Include sections such as Installation, Usage, Documentation, Contributing, License, and Acknowledgements to provide comprehensive information about your package.

Related Packages

simple-vue-validator

lightweight yet flexible validation lib for vue.js

96,321 289
vue-restify

rest API requests

1,112 0
eom-form

vue.js schema based form generator

652 3
vue-youtube

YouTube IFrame Player API wrapper

629,279 333
vue-youtube-vue-3

YouTube IFrame Player API wrapper

18,009 333

Version History

Version Released Vue License
0.4.4 ^3.3.4 ISC
0.4.3 ^3.3.4 ISC
0.4.2 ^3.3.4 ISC
0.4.1 ^3.3.4 ISC
0.4.0 ^3.3.4 ISC