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

jsx-dynamic-form

v0.1.2

Published

<br>

Downloads

5

Readme

React + Bootstrap powered popup form component

Popup visuals

Example Usage

import React from 'react';
import ReactDOM from 'react-dom';
import DynamicForm from 'jsx-dynamic-form';
import data from './data';

import './index.css';

function onConfirmCallback(data) {
  console.log(data);
};

function onCancelCallback() {
  console.log('cancelled');
};

function onDeleteCallback() {
  console.log('deleted');
}

ReactDOM.render(
  <DynamicForm
  definition={data.definition}
  data={data.data}
  onConfirmCallback={onConfirmCallback}
  onCancelCallback={onCancelCallback}
  onDeleteCallback={onDeleteCallback}/>, document.getElementById('root'));

Example Form Definition

const definition = {
    title: 'Enter your information',
    overlay: true,
    confirmButtonText: 'Confirm',
    cancelButtonText: 'Cancel',
    isOpen: true,
    fields: [{
        type: 'TextInput',
        name: 'UserName',
        label: 'Your name',
        required: true
    }, {
        type: 'Dropdown',
        name: 'EmploymentStatus',
        label: 'Employment Status',
        options: [
            {
                display: 'Employed',
                value: 'Employed'
            }, {
                display: 'Unemployed',
                value: 'Unemployed'
            }, {
                display: 'Self-employed',
                value: 'SelfEmployed'
            }
        ],
        value: 'Employed',
        required: true
    }, {
        type: 'TextArea',
        name: 'Notes',
        label: 'Notes',
        value: '',
        placeholder: 'Any additional comments'
    }]
};

const data = {  
    UserName: 'John Doe'
};

export default {
    definition,
    data,
}

Definition file explained

In the usual circumstances the definition file will not contain any data, just the static form definition. The data is located here just for demonstrational purposes, showing how data prepopulation can be used with the popup. The matching between provided data vs form definition element is based on the "name" property of the definition field.

Supported definition properties

| Attribute | Default Value | Description | Required | | --------- | ------------- | ----------- | -------- | | title | '' | Popup header title | true | | overlay | true | Whether an overlay is added to the page | false | | isOpen | false | Whether the popup is visible | false | | confirmButtonText | | The text displayed on the button | true | | cancelButtonText | | The text displayed on the button. If none is provided, the button will not be rendered | false | | deleteButtonText | | The text displayed on the button. If none is provided, the button will not be rendered | false | | fields | [] | The fields which will be displayed in the form. If none are provided, no fields will be rendered, just the buttons | false |

Supported field properties and types

  • TextInput
  • NumberInput
  • TextArea
  • FreeText
  • Dropdown

| Attribute | Default Value | Description | Required | | --------- | ------------- | ----------- |-----------| | type | | One of the 5 types mentioned | true | | name | | Unique name for internal use. The data returned after confirmation is mapped with those names| true | | label | | The label for the form control | false | | required | | Whether the component can have empty value when confirming the whole form | false | | placeholder | | Placeholder text for the form component | false |

Dropdown options

| Attribute | Default Value | Description | Required | | --------- | ------------- | ----------- | -------- | | displayName | | How the end user sees the option | true | | value | | What is the actual value for the option | true |

Built-in validation

There is a basic validation at the moment: if a field is marked as required and is empty - the form cannot be submitted.

Form validation