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

@danderson00/react-forms-material

v0.0.49

Published

Beautiful, ultra simple, stateless, validated forms for use in React function components

Downloads

141

Readme

@danderson00/react-forms-material

Beautiful, ultra simple, stateless, validated forms for use in React function components.

A demo is available at https://danderson00digital.github.io/react-forms-material/.

Installation

yarn add @danderson00/react-forms-material

Usage

import React from 'react'
import { Form, Text, Select, Radio, Checkbox, Submit } from '@danderson00/react-forms-material'

export default ({ onSubmit, initialValues }) => (
  <Form onSubmit={onSubmit} values={initialValues}>
    <Text name="name" label="Name" required minLength="5" maxLength="50" />
    <Text name="description" label="Description" multiline maxLength="100" />
    <Select name="type" label="Type" values={['', 'Widget', 'Component']} required />
    <Radio name="rating" label="Rating" values={[1, 2, 3]} row />
    <Checkbox name="urgent" label="Urgent" />

    <Submit>Submit</Submit>
  </Form>
)

Core Components

Form

All input components must be contained within a Form component.

Props

Name|Type|Description ---|---|--- values|object|Object containing initial values for form elements onSubmit|function(values)|A callback to be executed when the corresponding Submit component is clicked

All other props are passed on to the underlying form element.

Submit

Renders a Material UI Button component that triggers the closest Form component's onSubmit callback.

Props

All props are passed on to the underlying Button component.

Button

A pass through of the Material UI Button component for convenience.

Field Components

Field components are constructed by wrapping a Material UI InputLabel component, a form component and FormHelperText component within a FormControl component, similar to a TextField component.

All field components can be passed the following props:

Name|Type|Description ---|---|--- name|string|Specifies the name of the property to populate with the field value (required) label|string|Text on the field's label value|any|Initial value for the field. The DOM API will generally cast this to a string helperText|string|Specifies the helper text for the field

The following props are passed to the parent FormControl component:

Name|Type|Description ---|---|--- className|string|Class name to apply to the component fullWidth|boolean|Specifies that the field should occupy the full width of its parent variant|string|Corresponds to the variant prop of a FormControl. One of standard, outlined or filled margin|string|Corresponds to the margin prop of a FormControl. One of none, dense or normal. Most fields, except Text default to normal

All other props are passed to the input component, as described below.

Text

Renders a field component with a Material UI Input component as the input component.

Select

Renders a field component with a Material UI Select component as the input component. Options are specified using the props below and are rendered as MenuItem components.

Props

Name|Type|Description ---|---|--- values|array(any)|Specifies the values to use for each option. The DOM API casts these to strings labels|array(string)|Specifies the labels to use for each corresponding option in the values array. If not specified, entries from the values array are used.

Radio

Renders a field component with a Material UI RadioGroup component as the input component. Options are specified using the props below and are rendered as RadioButton components, described in the next section.

Props

Name|Type|Description ---|---|--- values|array(any)|Specifies the values to use for each option. The DOM API casts these to strings labels|array(string)|Specifies the labels to use for each corresponding option in the values array. If not specified, entries from the values array are used

RadioButton

Renders a field component with a Material UI Radio component as the input component.

Checkbox

Renders a field component with a Material UI Checkbox component as the input component.

License

The MIT License (MIT)

Copyright © 2022 Dale Anderson

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.