All Projects â†’ VoliJS â†’ Nestedlink

VoliJS / Nestedlink

Licence: mit
Callback-free React forms with painless validation.

Programming Languages

javascript
184084 projects - #8 most used programming language
typescript
32286 projects

Projects that are alternatives of or similar to Nestedlink

Ionic Forms And Validations
📝 Ionic Tutorial - Learn to use Forms and Validations in Ionic Angular apps. Get a FREE Ionic 5 Forms Starter App and learn to handle simple and custom validations. Includes complete ionic forms tutorial!
Stars: ✭ 155 (-20.1%)
Mutual labels:  forms
Ruyi
äș€äș’ćŒèĄšć•èźŸèźĄć™š
Stars: ✭ 167 (-13.92%)
Mutual labels:  forms
React Redux Form
Create forms easily in React with Redux.
Stars: ✭ 2,099 (+981.96%)
Mutual labels:  forms
Input
📋 Wrapper component for controlled inputs
Stars: ✭ 158 (-18.56%)
Mutual labels:  forms
Evolutility Ui Jquery
Model-driven Web UI for CRUD using REST or localStorage.
Stars: ✭ 164 (-15.46%)
Mutual labels:  forms
React Serial Forms
A lightweight and extendable SSR-friendly form library (for React).
Stars: ✭ 172 (-11.34%)
Mutual labels:  forms
Niui
Lightweight, feature-rich, accessible front-end library
Stars: ✭ 152 (-21.65%)
Mutual labels:  forms
Redux Form
A Higher Order Component using react-redux to keep form state in a Redux store
Stars: ✭ 12,597 (+6393.3%)
Mutual labels:  forms
Paginglibrary Sample
An open source app that is refactored to demo Paging Library from Android Jetpack
Stars: ✭ 165 (-14.95%)
Mutual labels:  data-binding
Composable Form
Build type-safe composable forms in Elm
Stars: ✭ 179 (-7.73%)
Mutual labels:  forms
Formiz
🐜 React forms with ease! Composable, headless & with built-in multi steps
Stars: ✭ 159 (-18.04%)
Mutual labels:  forms
Mvvmarchitecture
An example Android app using Retrofit, Room, LiveData, RxJava2, Paging, Koin and the MVVM pattern with the databinding
Stars: ✭ 160 (-17.53%)
Mutual labels:  data-binding
React Apollo Form
Build React forms based on GraphQL APIs.
Stars: ✭ 178 (-8.25%)
Mutual labels:  forms
Core
The Form Tools Core.
Stars: ✭ 156 (-19.59%)
Mutual labels:  forms
Ember One Way Controls
Native one way input
Stars: ✭ 184 (-5.15%)
Mutual labels:  forms
Ngx Formly
JSON powered / Dynamic forms for Angular
Stars: ✭ 2,109 (+987.11%)
Mutual labels:  forms
Liform React
Generate forms from JSON Schema to use with React (& redux-form)
Stars: ✭ 167 (-13.92%)
Mutual labels:  forms
React Widgets
Polished, feature rich, accessible form inputs built with React
Stars: ✭ 2,236 (+1052.58%)
Mutual labels:  forms
React Form
⚛ Hooks for managing form state and validation in React
Stars: ✭ 2,270 (+1070.1%)
Mutual labels:  forms
Observable Slim
Observable Slim is a singleton that utilizes ES6 Proxies to observe changes made to an object and any nested children of that object. It is intended to assist with state management and one-way data binding.
Stars: ✭ 178 (-8.25%)
Mutual labels:  data-binding

logo

Painless React forms, validation, and state management

NestedLink is useState React Hook on steroids providing an elegant callback-free solution for complex forms with input validation and making the React state a perfect state container. It's lightweight (6.5K minified) and designed to be used with both JS and TypeScript.

The Link is the object representing the writable reference to the member of the component's state encapsulating the value, function to update the value, and the validation error. Link class has a set of methods to perform useful transformations, such as $link.props generating the pair of standard { value, onChange } props.

NestedLink dramatically improves your React project's modularity and code readability.

import { useLink } from 'valuelink'
import { MyInput } from './controls.jsx'

const coolState = { some : { name : '' } };
const MyCoolComponent = () => {
    // Digging through the object to get a link to the `coolState.some.name`
    const $name = useLink( coolState ).at( 'some' ).at( 'name' )
    
    // applying the validation rules
    $name.check( x => x.length > 0, 'Name is required' ),
         .check( x => x.length > 2, 'Name is too short' );
         .check( x => x.length < 20, 'Name is too long' );

    return (
        <MyInput $value={$name} />
    )
}

// controls.jsx
import * as React from 'react'

// Custom form field with validation taking the link to the `value`
const MyInput = ({ $value }) => (
    <div>
        <input {...$value.props} className={ $value.error ? 'error' : '' } />
        <span>{ $value.error || '' }</span>
    </div>
)

Features

IMPORTANT! Version 2.x is not entirely backwards compatible with 1.x, see the release notes at the bottom.

  • Callback-free form controls binding to the component state.
  • Complete separation of the validation logic from the markup.
  • Easy handling of nested objects and arrays in the component state.
  • Complete support for the React Hooks API and functional components.
  • Pricise TypeScript typings.

Reference implementation of 'linked' UI controls (optional linked-controls npm package):

  • Standard tags: <Input />, <TextArea />, <Select />,
  • Custom tags: <Radio />, <Checkbox />, <NumberInput />
  • Validator functions: isNumber, isEmail, isRequred.

Tutorials

The rationale behind the design and a high-level overview of how amazing NestedLink is: React Hooks, form validation, and complex state

The series of 5-minute tutorials (with React.Component):

API Reference

Linked Controls Reference

Examples(sources)

How to

Use it in your project

There are no side dependencies except react as peer dependency. Installation:

npm install valuelink --save-dev

Usage with React Hooks (check out the React Hooks starting boilerplate).

import React from 'react'
import { useLink } from 'valuelink'
...
// Instead of const [ name, setName ] = useState('')
const $name = useLink('');

Usage with React Component.

import React from 'react'
// Instead of React.Component...
import { LinkedComponent } from 'valuelink'
...
// In a render, do
const $name = this.$at('name');
// Or, to link all the state members at once...
const state$ = this.state$();

Refer to the databinding examples and the manual for the typical data binding scenarios.

Create your own data bound controls

Use linked-controls project as the starting boilerplate for your components.

Create the binding to the custom state container

NestedLink is an abstraction of the data binding independent on both the particular control and the state container. The default binding implemented in the library is for the standard React state. It's fairly easy to create your own.

You need to subclass React.Component and make your own $at and state$ methods. You can either use Link.value inside to create links dynamically, or extend the Link as it's done in /valuelink/src/component.ts.

Start hacking

design

It's a very simple library written with TypeScript, there's no any magic inside (except some scary type annotations). If you want to play with the examples, fix the bug, or whatever:

yarn - installs the dependencies.

yarn build - compiles everything including examples.

Release Notes

2.0

  • IMPORTANT: Repository is converted to the monorepository based on yarn worspaces.
  • IMPORTANT: valuelink/tags.jsx is moved to the dedicated package linked-controls.
  • Complete support of new React Hooks API.
    • useLink() to create the state link.
    • useIO() to perform promised IO on mount.
    • useLocalStorage() to persist links to the local storage (loaded on mount, saved on unmount).
  • $-notation for the link variables.
  • New React.Component API (this.linkAt -> this.$at, this.linkAll -> this.state$)
  • Group operations Link.getValues(), Link.setValues(), Link.getErrors()

v1.6

React Hooks support.

  • useLink( initValue ) - create linked state.
  • setLinks({ lnk1, lnk2, ... }, json ) - bulk set link values from an object.
  • linksValues({ lnk1, lnk2, ... }) - extract values object from links.
  • linksErrors({ lnk1, lnk2, ... }) - extract errors object from links.

v1.5

  • <input {...link.props} /> can be used to bind the link to any of the standard controls expecting value and onChange props.

usedby

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].