All Projects โ†’ psaia โ†’ React Serial Forms

psaia / React Serial Forms

A lightweight and extendable SSR-friendly form library (for React).

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to React Serial Forms

Falcon
A high-performance web server for Ruby, supporting HTTP/1, HTTP/2 and TLS.
Stars: โœญ 2,058 (+1096.51%)
Mutual labels:  async
Kitsu
๐ŸฆŠ A simple, lightweight & framework agnostic JSON:API client
Stars: โœญ 166 (-3.49%)
Mutual labels:  async
Riptide
Client-side response routing for Spring
Stars: โœญ 169 (-1.74%)
Mutual labels:  async
Bfj
MOVED TO GITLAB
Stars: โœญ 164 (-4.65%)
Mutual labels:  async
React Use Wizard
๐Ÿง™ A React wizard (stepper) builder without the hassle, powered by hooks.
Stars: โœญ 162 (-5.81%)
Mutual labels:  async
Hitchcock
The Master of Suspense ๐Ÿฟ
Stars: โœญ 167 (-2.91%)
Mutual labels:  async
Fastapi Crudrouter
A dynamic FastAPI router that automatically creates CRUD routes for your models
Stars: โœญ 159 (-7.56%)
Mutual labels:  async
Netdev
Asynchronous multi-vendor library for interacting with network devices
Stars: โœญ 172 (+0%)
Mutual labels:  async
Message Bus
Go simple async message bus
Stars: โœญ 166 (-3.49%)
Mutual labels:  async
Redux Promise Middleware
Enables simple, yet robust handling of async action creators in Redux
Stars: โœญ 2,001 (+1063.37%)
Mutual labels:  async
Evolutility Ui Jquery
Model-driven Web UI for CRUD using REST or localStorage.
Stars: โœญ 164 (-4.65%)
Mutual labels:  forms
Await To Js
Async await wrapper for easy error handling without try-catch
Stars: โœญ 2,223 (+1192.44%)
Mutual labels:  async
Ruyi
ไบคไบ’ๅผ่กจๅ•่ฎพ่ฎกๅ™จ
Stars: โœญ 167 (-2.91%)
Mutual labels:  forms
Metasync
Asynchronous Programming Library for JavaScript & Node.js
Stars: โœญ 164 (-4.65%)
Mutual labels:  async
Thenextquant
Asynchronous driven quantitative trading framework.
Stars: โœญ 172 (+0%)
Mutual labels:  async
Minicoro
Single header asymmetric stackful cross-platform coroutine library in pure C.
Stars: โœญ 164 (-4.65%)
Mutual labels:  async
Gol
gol is a high performance async log kit for golang
Stars: โœญ 166 (-3.49%)
Mutual labels:  async
Smol
A small and fast async runtime for Rust
Stars: โœญ 2,206 (+1182.56%)
Mutual labels:  async
Pulsar4s
Idiomatic, typesafe, and reactive Scala client for Apache Pulsar
Stars: โœญ 172 (+0%)
Mutual labels:  async
Liform React
Generate forms from JSON Schema to use with React (& redux-form)
Stars: โœญ 167 (-2.91%)
Mutual labels:  forms

React Serial Forms v3

Note: Version 3 has been rebuilt from the ground up and is incompatible with prior major versions.

Serial Forms is optimized to be mostly unopinionated, fast, and extendible. This module is useful for complex or large applications with a variety of form input components.

  • First-class citizen TypeScript module
  • React hooks interface
  • Simple async-capable validation protocol
  • Simple input masking protocol
  • SSR Friendly
  • Light weight
  • Great form utility belt for the major frameworks - Relay, Apollo, Redux, etc.
                   โ–ฒ                โ–ฒ
                   โ”‚                โ”‚
                   โ”‚                โ”‚
                Values     Validation Results
                   โ”‚                โ”‚
                   โ”‚                โ”‚
                   โ”‚                โ”‚

 โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“
 โ”ƒ                                                     โ”ƒ
 โ”ƒ                                                     โ”ƒ
 โ”ƒ                    Form Instance                    โ”ƒ
 โ”ƒ                                                     โ”ƒ
 โ”ƒ                                                     โ”ƒ
 โ”—โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”›

           โ–ฒ                โ”‚              โ”‚
           โ”‚                โ”‚              โ”‚
           โ”‚                โ”‚              โ”‚
    Input Mutations    Validation     Input State
           โ”‚                โ”‚              โ”‚
           โ”‚                โ”‚              โ”‚
           โ”‚                โ–ผ              โ–ผ

               โ”Œ โ”€ โ”€ โ”€ โ”€ โ”€ โ”€ โ”€ โ”€ โ”€ โ”€ โ”
                โ”Œ โ”€ โ”€ โ”€ โ”€ โ”€ โ”€ โ”€ โ”€ โ”€ โ”€ โ”
               โ”‚  โ”Œ โ”€ โ”€ โ”€ โ”€ โ”€ โ”€ โ”€ โ”€ โ”€ โ”€ โ”
                โ”‚
               โ””  โ”‚   Input Instance    โ”‚
                โ”” โ”€
                  โ”” โ”€ โ”€ โ”€ โ”€ โ”€ โ”€ โ”€ โ”€ โ”€ โ”€ โ”˜

Installation

npm i --save react-serial-forms

Usage

Better documentation is coming soon. See the example below for API implementation.

import React from "react";
import FormErrors from "react-serial-forms/lib/components/FormErrors";
import Input from "react-serial-forms/lib/components/inputs/Input";
import useForm from "react-serial-forms/lib/hooks/use-form";
import { validations } from "react-serial-forms/lib/validation";
import phoneMask from "react-serial-forms/lib/masks/phone";

function MyComponent() {
  const [form, saving, onSubmit] = useForm(

    // Set the initial values for the inputs used in the form.
    {
      name: "",
      cellPhone: ""
    },

    // Handle the form submission. values => { cellPhone: ..., name: ... }
    async values => {
      const remoteErrors = await makeRemoteRequestWithValues(values);
      // Do stuff with errors from the server perhaps.
    }
  );

  if (saving) {
    return <p>Form is saving.</p>
  }

  return (
    <form onSubmit={onSubmit}>
      <Input
        type="text"
        name="name"
        label="Your Name"
        form={form}
        placeholder="John Doe"
        validations={[validations.required("Your name is required.")]}
      />
      <Input
        type="text"
        name="cellPhone"
        label="Your Phone Number"
        mask={phoneMask}
        form={form}
        placeholder="555-555-5555"
        validations={[validations.phone("A valid phone number is required.")]}
      />
    </form>
  );
}

Using a custom component

import React from "react";
import Textarea from "../custom-inputs/Textarea"; // Assume you have your own.
import { BaseInputProps } from "react-serial-forms/lib/types";
import Form from "react-serial-forms/lib/form";
import Errors from "react-serial-forms/lib/components/FormErrors";
import useInput from "react-serial-forms/lib/hooks/use-input";

export interface Props extends BaseInputProps<Form> {
  bold: boolean;
  italic: boolean;
  underline: boolean;
  ol: boolean;
  ul: boolean;
}

export default function Wysiwyg(props: Props) {
  const [id, dirty, currentValue, errors, onChange] = useInput({
    name: props.name,
    getValueFromEvent: val => val,
    defaultValue: "",
    form: props.form,
    validations: props.validations
  });

  return (
    <div className="input-wrapper">
      {props.label ? <label htmlFor={id}>{props.label}</label> : null}
      <Textarea
        onChange={onChange}
        value={currentValue}
        bold={props.bold}
        italic={props.italic}
        underline={props.underline}
        ol={props.ol}
        ul={props.ul}
      />
      {props.helper ? (
        <small
          className="helper-text"
          dangerouslySetInnerHTML={{ __html: props.helper }}
        />
      ) : null}
      <Errors errors={dirty ? errors : []} />
    </div>
  );
}

Now you can use this component simply by importing it:

...
  <Wysiwyg
    type="text"
    name="description"
    bold={true}
    italic={false}
    ol={true}
    underline={false}
    ul={false}
    form={form}
    validations={[validations.required("A description is required.")]}
  />
...
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].