Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-form-blueprint

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-form-blueprint

> Generate input controls from your models

  • 0.1.1
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

react-form-blueprint

Generate input controls from your models

NPM JavaScript Style Guide

Install

npm install --save react-form-blueprint

Usage

import React from 'react';
import { initFormOptions } from 'react-form-blueprint';

interface Person {
  firstName: string;
  age: number;
  dog: {
    color: string;
  };
}
const CustomInput = ({ errorMessage }: { errorMessage: string }) => {
  return (
    <div>
      <input type="radio" />
      <p>{errorMessage}</p>
    </div>
  );
};

const { getFormControls } = initFormOptions({
  customFormControls: {
    radio: {
      input: {
        component: CustomInput,
        presetProps: { errorMessage: 'Error dude!' },
      },
      label: { component: 'label' },
    },
  },
  label: { component: 'label' },
  input: { component: 'input' },
});

const formControls = getFormControls<
  Person,
  'firstName' | 'age' | 'dog.color'
>()({
  firstName: {
    type: 'text',
  },
  age: {
    type: 'number',
  },
  'dog.color': {
    type: 'radio',
  },
});

const App = () => {
  const { firstName, age, dogColor } = formControls;

  return (
    <>
      <div style={{ display: 'flex', flexDirection: 'column' }}>
        <firstName.label>Firstname</firstName.label>
        <firstName.input />
      </div>
      <div style={{ display: 'flex', flexDirection: 'column' }}>
        <age.label>Age</age.label>
        <age.input />
      </div>
      <div style={{ display: 'flex', flexDirection: 'column' }}>
        <dogColor.label>Dog Color</dogColor.label>
        <dogColor.input />
      </div>
    </>
  );
};

export default App;

License

MIT © pffigueiredo

FAQs

Package last updated on 14 Sep 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc