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

formik-generator-materialui

v1.0.6

Published

A form generator who use React, Material UI and Formik as dependenties

Downloads

10

Readme

formik-generator-materialui

A form generator who use React, Material UI and Formik as dependencies (an some others). A lot of fields types but feel free to install the minimum of dependencies.

NPM JavaScript Style Guide

ONLINE DEMO !!

https://grachet.github.io/formik-generator-materialui/

Install

npm install --save formik-generator-materialui

Install Dependencies

Required dependencies :

  • react: ^16.8.0
  • react-dom: ^16.8.0
  • formik: ^2.1.0
  • @material-ui/core: ^4.9.0
  • @material-ui/icons: ^4.9.0
  • prop-types: ^15.5.4
npm install --save formik @material-ui/core @material-ui/icons prop-types

Other dependencies (important) :

  • @material-ui/lab: ^4.0.0 (autocomplete)
  • @material-ui/pickers: ^3.2.0 (date)
  • @date-io/moment: ^1.3.0 (date)
  • moment: ^2.24.0 (date)
  • yup: ^0.28.1 (field verification)
  • react-quill: ^2.0.0-beta.1 (RTE)
npm install --save @material-ui/lab @material-ui/pickers yup  react-quill@beta  @date-io/[email protected] moment

Usage FormGenerator

import React, { Component } from 'react'
import {FormGenerator} from "formik-generator-materialui";
import * as Yup from "yup";

function Example {

    const formRef = useRef(null);

    return (
          <div>
            <FormGenerator
              onSubmit={(values) => {
                console.log(values) // {fullname : "john", ...}
              }}
              fields={[
                {
                  title: "Full Name",
                  path: ["fullname"],
                  typeField: "text"
                },
                {...},
              ]}
              formRef={formRef}
              initialValues={{
                fullname: "john"
              }}
              validationSchema={Yup.object().shape({
                fullname: Yup.string().required(),
              })}
              readOnly={false}
              isValidateOnlyOnSubmit={false}
            />
            <button onClick={() => formRef.current.submitForm()} />
        </div>
    )
}

Props List :

  • initialValues: object (reinitialize form on change)
  • fields: array of objects
  • getFields: function with form values who return fields props (replace fields props) : (formValues) => [{},...]
  • onSubmit: func
  • readOnly: bool
  • formRef: object.isRequired (to get form functions)
  • validateOnBlur: bool (less validation, less memory) default true
  • validateOnChange: bool (less validation, less memory) default true
  • validateOnMount: bool (less validation, less memory)
  • onError: func
  • shouldTriggerErrors: func

Usage FormDialogue

import React, { Component } from 'react'
import {FormDialogue} from "formik-generator-materialui";
import * as Yup from "yup";

function Example {

    let [open, setOpen] = useState(false);

    return (
          <div>
            <FormDialogue
            open={open}
            onCancel={() => setOpen(false)}
            onOk={(values) => {
              console.log(values)
            }}
            title={"Your title"}
            text={"Your text here"}
            initialValues={{
                fullname: "john"
            }}
            validationSchema={Yup.object().shape({
                fullname: Yup.string().required(),
            })}
            fields={[
              {
                title: "Full Name",
                path: ["fullname"],
                typeField: "text",
              },
              {...},
            ]}
          />
          <button onClick={() => setOpen(true)}>open<button>
        </div>
    )
}

Props List :

  • onOk: function
  • onCancel: function
  • disableCancelOnOK: bool
  • okText: string
  • title: string
  • maxWidth: 'xs', 'sm', 'md', 'lg', 'xl', false
  • open: bool
  • component: object
  • link: { name: "string", url: "string"})
  • text: string
  • readOnly: bool
  • initialValues: object (reinitialize form on change)
  • fields: array of object
  • validateOnBlur: bool (less validation, less memory) default true
  • validateOnChange: bool (less validation, less memory) default true
  • validateOnMount: bool (less validation, less memory)
  • shouldTriggerErrors: func

Fields Type :

group

  • readOnly: bool
  • hint: string
  • warning: string
  • title: string
  • subfields: array of objects

text

  • path: string (Required)
  • readOnly: bool
  • required: bool
  • hint: string
  • warning: string
  • title: string
  • multiline: bool
  • isLink: bool

displayValue

  • required: bool
  • hint: string
  • warning: string
  • title: string
  • multiline: bool
  • yup: object
  • transformation: function
  • separator: string
  • display: array
  • isLink: bool

select

  • path: string (Required)
  • readOnly: bool
  • required: bool
  • hint: string
  • warning: string
  • title: string
  • choices: array

date

  • path: string (Required)
  • readOnly: bool
  • required: bool
  • hint: string
  • warning: string
  • title: string
  • openTo: string ("year")

richTextEditor

  • path: string (Required)
  • readOnly: bool
  • required: bool
  • hint: string
  • warning: string
  • title: string
  • placeholder: string

switch

  • path: string (Required)
  • readOnly: bool
  • required: bool
  • hint: string
  • warning: string
  • title: string

checkbox

  • path: string (Required)
  • readOnly: bool
  • required: bool
  • hint: string
  • warning: string
  • title: string

arrayObject

  • path: string (Required)
  • readOnly: bool
  • required: bool
  • hint: string
  • warning: string
  • title: string
  • emptyAddText: string
  • noBorder: bool
  • subfields: array of objects
  • withSwap: bool

array

  • path: string (Required)
  • readOnly: bool
  • required: bool
  • hint: string
  • warning: string
  • title: string
  • emptyAddText: string
  • noBorder: bool
  • subfield: object
  • renderRightButton: react component (should be material ui IconButton)
  • withSwap: bool

autocomplete

  • path: string (Required)
  • readOnly: bool
  • required: bool
  • hint: string
  • warning: string
  • title: string
  • freeSolo: bool
  • options: array
  • getOptionLabel: function
  • placeholder: string

asyncAutocomplete

  • path: string (Required)
  • readOnly: bool
  • required: bool
  • hint: string
  • warning: string
  • title: string
  • freeSolo: bool
  • getOptionLabel: function
  • getAsyncOptions: function required
  • placeholder: string

To run in localhost :

  • npm start
  • cd example
  • npm start

To publish to github pages :

  • npm run deploy
  • go to https://grachet.github.io/formik-generator-materialui

To publish to NPM :

  • new version in package.json
  • npm login
  • npm publish

Other

Looking for collaborators to update the tool

License

MIT © grachet