Giter VIP home page Giter VIP logo

corleon-form-builder's Introduction

corleon-form-builder

an easy to use fully customizable form builder.

Stable Release

Installation

in order to install the form-builder to your react or next app use this commands

  using npm : npm i corleon-form-builder
  using yarn : yarn add corleon-form-builder

Quick start

first things first , in order to use default form-builder or form-generator components. you need to configure the plugins and constraints.

config.ts

import { configuration, Input, CheckBox, RadioGroup, Select } from 'corleon-form-builder';

const builder = configuration({
    plugins: [Input, CheckBox, RadioGroup, Select], // enter at least one plugin to your plugin list 
    constraint: {}, //optional
});

export const { FormBuilder, FormGenerator, FormProvider } = builder;

usage

now that you're exported FormProvider use it in some layout component on your choice

src/layouts/layout.tsx

import { FormProvider } from '@/src/config';
  
function App() {
  <FormProvider>
    //components
  </FormProvider>
}
export default App;

show form-builder

in order to show the default form-builder module you have to create a new component and import FormBuilder in it. in this component you can customize some of the ui but the default module gono render anyway

src/components/AppFormBuilder.tsx

import { FormBuilder } from '@/src/config';
function AppFormBuilder() {
  <div className="w-full max-h-full overflow-y-auto p-4">
    <div className='flex mb-5'>
        <div className="flex gap-2">
           <button onClick={() => { }>"create new field"</button>
           <button onClick={() => { }} >"remove all fields"</button>
        </div>
    </div>
    <FormBuilder />
  </div>
}
export default AppFormBuilder;


update your layout

src/layouts/layout.tsx
import { FormProvider } from '@/src/config';
import AppFormBuilder from '@/src/components/AppFormBuilder'; // add this line
  
function App() {
  <FormProvider>
    <AppFormBuilder/> {/*and this one*/}
  </FormProvider>
}
export default App;

now in order for thing to start working the package provided you a hook with every function you need to create , update, remove or even create a new module (you can have your own FromBuilder , FormGenerator) but first let see some basics of this tool

Create a new Field

src/components/AppFormBuilder.tsx

import { FormBuilder } from '@/src/config';
import { useForm } from 'corleon-form-builder';
function AppFormBuilder() {
  const { createNewField , removeAll } = useForm();//add this tow methods

  <div className="w-full max-h-full overflow-y-auto p-4">
    <div className='flex mb-5'>
        <div className="flex gap-2">
           <button onClick={() => createNewField() /*use it at this point*/ }>"create new field"</button>
           <button onClick={() => removeAll() /*and this*/ }>"remove all fields"</button>
        </div>
    </div>
    <FormBuilder />
  </div>
}
export default AppFormBuilder;

in this state you shuld be able to create a schema of a form for your own at the ui . the logic is so simple but i will create a video of how to work with the default module.

corleon-form-builder's People

Contributors

sina-saberi avatar

Stargazers

omid nami avatar Mohammad Reza Chavoshipor avatar

Watchers

Mohammad Reza Chavoshipor avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.