npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-interactive-dynamic-form-generator

v1.0.4

Published

It will generate the interactive form dynamically with validation. all it will take is json model as a input and will give the form output

Downloads

10

Readme

react-interactive-dynamic-form-generator

It will generate the form dynamically with validation. All it will take is json model as a input and will give the simplified json object as a form output. validation object in the configuration is optional(though it must be present as an empty object). It support almost all the input types. also apart from required field validation, it also has special validation for email(type="email"), pan number(type="pan"), only number(type="number"), minlength, maxlength etc. You can even pass your own regular expression as rejex property inside your validation object.

Now you can also pass your own preferred color like buttonBackgroundColor, buttonColor, formBorderColorOnFocus, errorTextColor.

though these are all optional.

NPM JavaScript Style Guide

Install

npm install --save react-interactive-dynamic-form-generator

demo

https://stackblitz.com/edit/react-jdhvjs

How to use

import React, { Component } from "react";

import DynamicFormGenerator from "react-interactive-dynamic-form-generator";

class Example extends Component {
  state = {
    buttonBackgroundColor:'#0000ff',
    buttonColor:'#fff',
    formBorderColorOnFocus:'#0000ff',
    errorTextColor: 'pink',
    formFields: {
      name: {
        elementType: "input",
        elementConfig: {
          type: "text",
          placeholder: "Name"
        },
        value: "",
        validation: {
          required: true,
          error: ""
        },
        valid: false,
        touched: false
      },
      uploadedFile: {
        elementType: "input",
        elementConfig: {
          type: "file",
          placeholder: "upload"
        },
        value: "",
        selectedFileObj: {},
        validation: {
          required: true,
          error: ""
        },
        valid: false,
        touched: false
      },
      ifscCode: {
        elementType: "input",
        elementConfig: {
          type: "text",
          placeholder: "IFSC Code"
        },
        value: "",
        validation: {
          required: true,
          error: "",
          rejex: "^[A-Za-z]{4}[a-zA-Z0-9]{7}$"
        },
        valid: false,
        touched: false
      },

      address: {
        elementType: "textarea",
        elementConfig: {
          type: "text",
          placeholder: "Address"
        },
        value: "",
        validation: {
          required: true,
          error: ""
        },
        valid: false,
        touched: false
      },
      pinCode: {
        elementType: "input",
        elementConfig: {
          type: "text",
          placeholder: "Pin Code"
        },
        value: "",
        validation: {
          required: true,
          minLength: 6,
          maxLength: 6,
          isNumeric: true,
          error: ""
        },
        valid: false,
        touched: false
      },
      accountNumber: {
        elementType: "input",
        elementConfig: {
          type: "text",
          placeholder: "Account Number"
        },
        value: "",
        validation: {
          required: true,
          minLength: 9,
          maxLength: 18,
          isNumeric: true,
          error: ""
        },
        valid: false,
        touched: false
      },
      password: {
        elementType: "password",
        elementConfig: {
          type: "password",
          placeholder: "Passowrd"
        },
        value: "",
        validation: {
          required: true,
          error: ""
        },
        valid: false,
        touched: false
      },
      date: {
        elementType: "date",
        elementConfig: {
          type: "date",
          placeholder: "Date"
        },
        value: "",
        validation: {
          required: true,
          error: ""
        },
        valid: false,
        touched: false
      },
      pan: {
        elementType: "input",
        elementConfig: {
          type: "text",
          placeholder: "PAN No"
        },
        value: "",
        validation: {
          required: true,
          isPan: true,
          error: ""
        },
        valid: false,
        touched: false
      },
      email: {
        elementType: "input",
        elementConfig: {
          type: "email",
          placeholder: "E-Mail"
        },
        value: "",
        validation: {
          required: true,
          isEmail: true,
          error: ""
        },
        valid: false,
        touched: false
      },
      occupation: {
        elementType: "select",
        elementConfig: {
          placeholder: "Occupation",
          options: [
            { value: "Salaried", displayValue: "Salaried" },
            { value: "selfEmployed", displayValue: "Self Employed" }
          ]
        },
        value: "",
        validation: {
          required: true
        },
        valid: false
      },
      gender: {
        elementType: "radio",
        elementConfig: {
          placeholder: "Gender",
          options: [
            { value: "Male", displayValue: "Male" },
            { value: "Female", displayValue: "Female" }
          ]
        },
        value: "",
        validation: {
          required: true
        },
        valid: false
      },
      selectedfruits: {
        elementType: "checkbox",
        elementConfig: {
          placeholder: "Fruit",
          options: [
            { value: "Apple", displayValue: "Apple", checked: false },
            { value: "Banana", displayValue: "Banana", checked: false },
            { value: "Grapes", displayValue: "Grapes", checked: false }
          ]
        },
        value: "",
        selectedCheckbox: [],
        validation: {
          required: true
        },
        valid: false
      }
    }
  };
  formResult = form => {
    console.log(form);
  };
  render() {
    return (
      <DynamicFormGenerator
          formFields={this.state.formFields}
          buttonBackgroundColor = {this.state.buttonBackgroundColor}
          buttonColor = {this.state.buttonColor}
          formBorderColorOnFocus = {this.state.formBorderColorOnFocus}
          errorTextColor = {this.state.errorTextColor}
          onFormSubmit={form => this.formResult(form)}
        />
    );
  }
}

License

GNU General Public License v3.0 © shekharramola