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

rc-4rm

v0.1.7

Published

React bootstrap forms

Downloads

13

Readme

rc-4rm

Customizable react forms with build-in validation and state managment

Installation

yarn add rc-4rm

or

npm install rc-4rm

Usage

import { SignForm } from "rc-4rm";
...
const handleSubmit = (data) => {
    console.log("handleSubmit, data", data);
    // Send data to server here with AJAX request
    return new Promise((resolve) => {
        setTimeout(resolve, 2000);
    });
};
...
return (
    <div className="App">
        <h1>Sign in</h1>
        <div style={{ maxWidth: "50rem", margin: "0 auto" }}>
            <SignForm handleSubmit={handleSubmit} clearAfter={true} />
        </div>
    </div>
);

API

SignForm

| prop | type | description | | --------------- | ------------------------------------------------------------- | ------------------------------------------------------------------------------------ | | handleSubmit | (data) => void | callback function triggered on onSubmit, sends data object { email, password } | | className | string | class added to bootstrap form classes | | clearAfter | boolean | should form fields be set to empty string after promise resolved | | isConfirmPass | boolean | confirm password input for signing up | | isCheck | boolean | check me out checkbox | | labels | {"email": "Enter email", ...} | object with labels for inputs | | info | {"email": "Should be valid email", ...} | object with information for inputs | | successFeedback | {"email": "Email is valid", ...} | object with success feedback for inputs validation | | errorFeedback | {"email": "Email is invalid", ...} | object with error feedback for inputs validation | | validators | {"email": (value: string) => /\S+@\S+.\S+/.test(value), ...} | object with validator functions for each field |

<SignForm
    handleSubmit={handleSignIn}
    clearAfter={false}
    isConfirmPass={true}
    isCheck={true}
    validators={{
        email: (value: string) => /\S+@\S+\.\S+/.test(value),
        password: (value: string) => value.length > 6,
        isCheckOut: (value: boolean) => value,
    }}
    labels={{
        email: "Enter your email",
        password: "Create a password",
        password2: "Repeat password",
        isCheckOut: "Remember me",
    }}
    info={{
        email: "We'll never share your email with anyone else",
        password:
            "Should contain letters, uppercase letters, numbers and symbols",
        password2: "Enter your password again",
        isCheckOut: "Increase authentication validity time",
    }}
    successFeedback={{
        email: "Email is valid",
        password: "Password is valid",
        password2: "Passwords match",
    }}
    errorFeedback={{
        email: "Email is invalid",
        password: "Password is invalid",
        password2: "Passwords don't match",
        isCheckOut: "You must agree",
    }}
/>

| prop | type | description | | ------------- | ----------------- | ------------------------------------------------------------------------------------ | | handleSubmit | (data) => void | callback function triggered on onSubmit, sends data object { email, password } | | className | string | class added to bootstrap form classes | | clearAfter | boolean | should form fields be set to empty string after promise resolved | | fields | CustomFormField[] | Array describing form fields (type desc below) | | requiredLabel | string | String near field label signifying that field is required. Default is "*" |

CustomFormField

| prop | type | description | | ------------ | ------------------------------ | ------------------------------------------------------ | | id | number | unique id for a field | | type | InputType | html input type | | name | string | unique input type name | | label | string | input label | | validator? | (value: InputValue) => boolean | function to check if input value is correct | | placeholder? | string | input placeholder | | required? | boolean | determines if form can be submitted without this field | | multible? | boolean | select input only, determines multiple options select | | options? | ReactSelectOption[] | array of select options objects |

InputType = text | email | password | select InputValue: string for text inputs, boolean for checkboxes etc.

interface RectSelectOption = {
    label: string;
    value: string;
}

CustomForm usage

<CustomForm
    handleSubmit={handleSubmit}
    fields={CUSTOM_FORM_FIELDS_DATA}
    clearAfter={true}
    className="w-50"
    requiredLabel=" (Required!)"
/>
const CUSTOM_FORM_FIELDS_DATA: CustomFormItem[] = [
    {
        id: 1,
        type: "text",
        name: "username",
        label: "Username",
        validator: (value: string) => value.length > 2,
        placeholder: "Fancy username",
        required: false,
    },
    {
        id: 2,
        type: "text",
        name: "email",
        label: "Email",
        validator: emailValidator,
        placeholder: "Your email",
        required: true,
    },
    {
        id: 3,
        type: "password",
        name: "password",
        label: "Enter password",
        validator: passwordValidator,
        required: true,
    },
    {
        id: 4,
        type: "select",
        name: "languages",
        label: "Your languages",
        validator: (value: any[]) => value.length > 1,
        required: true,
        multiple: true,
        options: [
            {
                value: "en",
                label: "English",
            },
            {
                value: "fr",
                label: "French",
            },
            {
                value: "es",
                label: "Spanish",
            },
        ],
    },
];

LICENSE MIT

Copyright (c) 2022 Alexander Pershin