# Informed **Repository Path**: fangminglee/Informed ## Basic Information - **Project Name**: Informed - **Description**: Informed 是用于在 React 应用程序中构建表单的轻量级框架,开箱即用,支持获取和操作值、验证字段、创建自定义输入、多步骤表单、数组字段等 - **Primary Language**: JavaScript - **License**: MIT - **Default Branch**: master - **Homepage**: https://www.oschina.net/p/informed - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 1 - **Created**: 2023-10-11 - **Last Updated**: 2023-10-11 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Informed [![Docs](https://badgen.net/badge/V4/Docs/purple)](https://teslamotors.github.io/informed) [![npmversion](https://img.shields.io/npm/v/informed.svg)](https://www.npmjs.com/package/informed) [![github](https://badgen.net/badge/gihub/main/green?icon=github)](https://github.com/teslamotors/informed) [![Docs](https://badgen.net/badge/V3/Docs/red)](https://61af80ffc6bc460007bf9ec7--joepuzzo-informed.netlify.app/) ## Introduction Say hello to the best React form library you have ever used! Informed is an extensive, simple, and efficient solution for creating basic to complex forms in React. Out of the box you get the ability to grab and manipulate values, validate fields, create custom inputs, multi-step forms, array fields, and much much more! Oh and YES WE USE HOOKS! ## Getting Started ##### Install with npm ``` npm install --save informed ``` #### Live Examples / Docs [![Docs](https://badgen.net/badge/V4/Docs/purple)](https://teslamotors.github.io/informed) [![Docs](https://badgen.net/badge/V3/Docs/red)](https://61af80ffc6bc460007bf9ec7--joepuzzo-informed.netlify.app/) ### What Can it do ? See for yourself. By default it comes with native dom inputs that are controlled by informed. ```jsx import { Form, Input, Select, Checkbox, Relevant, Debug } from 'informed'; const onSubmit = ({ values }) => console.log(values); const ExampleForm = () => (
formState.values.married}> ); ``` ## Creating Your Own Fields But what if you dont want the out of the box stuff?? No problem, see example below! ```jsx import { useForm, useField, Relevant, FormState } from 'informed'; // Step 1. Build your form component --------------------- const Form = ({ children, ...rest }) => { const { formController, render, userProps } = useForm(rest); return render(
{children}
); }; // Step 2. Build your input components -------------------- const Input = props => { const { render, informed, userProps, ref } = useField({ type: 'text', ...props }); const { label, id, ...rest } = userProps; return render( <> ); }; const Checkbox = props => { const { render, informed, userProps, ref } = useField({ type: 'checkbox', ...props }); const { label, id, ...rest } = userProps; return render( <> ); }; const ErrorInput = props => { const { render, informed, userProps, fieldState, ref } = useField({ type: 'text', ...props }); const { label, id, ...rest } = userProps; const { showError } = fieldState; const style = showError ? { border: 'solid 1px red' } : null; return render( <> {showError && {fieldState.error}} ); }; const Select = props => { const { render, informed, userProps, ref } = useField({ type: 'select', ...props }); const { label, id, children, ...rest } = userProps; return render( <> ); }; // Step 3. Build your forms! --------------------------- const onSubmit = ({ values }) => console.log(values); const ExampleForm = () => (
formState.values.married}> ); ```