🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

formkit-builder

Package Overview
Dependencies
Maintainers
1
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

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

0.4.4
latest
npm
Version published
Weekly downloads
0
-100%
Maintainers
1
Weekly downloads
 
Created
Source

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.

Keywords

Experience

FAQs

Package last updated on 19 Jul 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts