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-dynamic-form

v1.0.1

Published

A Simple But yet highly Dynamic Form with React and Bootstrap

Downloads

16

Readme

react-dynamic-form

A Simple But yet highly Dynamic Form with React and Bootstrap

Example

Usage

a.Install

npm install react-dynamic-form --save

b.Import Module

To use react-bootstrap-table in your react app, you should import it first. With a module bundler like webpack that supports either CommonJS or ES2015 modules, use as you would anything else. You can include source maps on your build system to debug on development. Don't forget to Uglify on production.

// in ECMAScript 6
import DynamicForm from "react-dynamic-form";

// or in ECMAScript 5
var DynamicForm = require('react-dynamic-form');
<DynamicForm
    config={this.state.formConfig}
    controls={
        <button type="button" className="btn btn-default">
            <span className="glyphicon glyphicon-redo"/>&nbsp;Cancel
        </button>
    }
    ref={(form) => {
        this.boundForm = form;
    }}
    onSaveClicked={this.onSaveClicked.bind(this)}
/>

Reading the data; This returns an object or false in case the Form has errors

 onSaveClicked() {
        console.log("SAve Clicked...");
        let data = this.boundForm.getData();
        if (data) {
            console.log("Data>>>", data);
        } else {
            console.log("Data Contains Errors...");
        }
    }

Setting Data is as Simple

 let id = Math.floor((Math.random() * 1000) + 1);
        let data = {
            id: id,
            username: "newName",
            level: "staff",
            creator: "Foo barz",
            creationDate: "2017-01-26"
        };
        this.boundForm.setData(data);

Sample Form Config data

var formConfig = {
             fields: [
                 {
                     name: "id",
                     title: "ID",
                     type: "text",
                     isRequired: true
                 },
                 {
                     name: "username",
                     title: "User Name",
                     type: "text",
                     isRequired: true,
                     showOnForm: false
                 },
                 {
                     name: "level",
                     title: "Level",
                     type: "select",
                     data: [{name: "super", title: "Super"}, {name: "admin", title: "Admin"}, {name: "staff", title: "Staff"}],
                     isRequired: true
                 },
                 {
                     name: "creator",
                     title: "Creator",
                     type: "text",
                     isRequired: true
                 },
                 {
                     name: "creationDate",
                     title: "Created Date",
                     type: "date",
                     isRequired: true
                 }
             ],
             primaryKey: "id"
         };

Development

react-dynamic-form dependencies on react 0.14.x and Bootstrap 3 written by ES6 and uses webpack for building and bundling.

You can use the following commands to prepare development

$ git clone https://github.com/ekastimo/react-dynamic-form.git
$ cd react-dynamic-form
$ npm install

Use npm to build the react-dynamic-form

$ npm run dev  #for development
$ npm run dev  #to bulid the library
$ npm run demo  #to bulid the demo, go to localhost:8000

| Atribute | M/O | Default | Description | |------------|-----|-----------|--------------------------------------------------------------| | name | M | - | This is the name of the item, similar to html name attribute | | title | M | | The lebel | | type | M | | Type of editor component, eg text,number,date,datetime | | isRequired | M | false | Self explanatory | | data | O | undefined | Array of name,title objects used in case type is select | | value | O | undefined | The initial Value | | pattern | O | true | Regex pattern to be used for Validation | | showOnForm | O | true | A value of false would hide this item from the view |