0.16.11 • Published 2 months ago

material-form-builder v0.16.11

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

Quick Access

introduction

Installation

Dependencies

Material UI (^5.x.x) is available as an npm package.

npm install @mui/material @mui/x-date-pickers @mui/icons-material @emotion/react @emotion/styled dayjs

material-form-builder

npm:

npm install material-form-builder

yarn:

yarn add material-form-builder

basic usage:

import React, { useRef } from 'react'
import { FormBuilder } from 'material-form-builder'

const App = () => {
    const builderRef = useRef(null)
    const getValues = () => {
        const values = builderRef.current?.getValues()
    }
    const clear = () => {
        builderRef.current?.clear()
    }
    return (
        <Fragment>
            <Box>
                <FormBuilder
                    inputs={[
                        {
                            type: 'text',
                            selector: 'person_name',
                            label: 'Name',
                        },
                        {
                            type: 'text',
                            selector: 'person_family',
                            label: 'Family',
                        },
                    ]}
                    ref={builderRef}
                />
            </Box>
            <Box mt={1}>
                <Button color="success" onClick={getValues}>
                    Get
                </Button>
                <Button color="secondary" onClick={setValues}>
                    Set
                </Button>
                <Button color="primary" onClick={clear}>
                    clear
                </Button>
            </Box>
        </Fragment>
    )
}

Component Props:

keydescriptionlink
inputsinputs datausage
refreact ref-

Ref Avilable Methods:

keydescriptionusage
getValuesget value data from form builderusage
setValuesset your data into inputsusage
clearclear all inputs datausage

Get Values Prop

builderRef.current?.getValues() usage:

{
    data: {
        person_name: 'ENTERED VALUE'
        person_family: 'ENTERED VALUE'
    },
    validation: {
        status: boolean,
        inputs: []
    }
}

Set Values Prop

builderRef.current?.setValues() usage:

builderRef.current
    ?.setValues({
        tid: 1,
        person_name: 'john',
        person_family: 'doe',
    })
    .then(() => {
        console.log('all promises were fulfilled !')
    })

The data entered in the inputs will be set and if additional values are received, they will be returned

Clear Prop

builderRef.current?.clear() usage:

builderRef.current?.clear().then(() => {
    console.log('all promises were fulfilled !')
})

Type Of Inputs

typedescriptionusage
texttext inputtext input usage
numbernumber inputnumber input usage
checkboxcheckbox inputcheckbox input usage
passwordpassword inputpassword input usage
autocompleteautocomplete inputautocomplete input usage
mobilemobile inputmobile input usage
otpotp inputotp input usage
maskmask inputmask input usage
datedate inputdate input usage
timetime inputtime input usage
datetimedatetime inputdatetime input usage
filefile inputfile input usage
itemsitems inputitems input usage
customcustom inputcustom input usage

Basic Input Props

keytypedescriptionsample
selectorstring--
defaultValueInput Value Type--
requiredboolean--
visibleboolean--
wrapperfunction--
onChangeValuefunction--
getMutatorfunction--
setMutatorfunction--

License

This project is licensed under the terms of the MIT license.

Sponsoring services

mentasystem.net

back to top

0.16.10

2 months ago

0.16.11

2 months ago

0.16.8

3 months ago

0.16.9

3 months ago

0.16.7

3 months ago

0.16.3

1 year ago

0.16.4

1 year ago

0.16.5

1 year ago

0.16.6

1 year ago

0.16.0

1 year ago

0.16.1

1 year ago

0.16.2

1 year ago

0.15.0

1 year ago

0.14.1

2 years ago

0.15.1

1 year ago

0.14.2

2 years ago

0.15.2

1 year ago

0.15.3

1 year ago

0.14.4

2 years ago

0.12.10

2 years ago

0.12.11

2 years ago

0.10.0

2 years ago

0.12.9

2 years ago

0.9.0

2 years ago

0.12.0

2 years ago

0.8.0

2 years ago

0.14.0

2 years ago

0.12.12

2 years ago

0.12.3

2 years ago

0.12.13

2 years ago

0.12.4

2 years ago

0.12.14

2 years ago

0.12.5

2 years ago

0.7.0

2 years ago

0.6.0

2 years ago

0.5.1

2 years ago

0.4.7

2 years ago

0.4.6

2 years ago

0.4.5

2 years ago