0.2.1 • Published 10 months ago

@falven/formtext v0.2.1

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

@falven/formtext

FormText is a pure state management library for forms in React. It uses the context API for state management and provides a set of utility hooks for form state, dispatch actions, and more.

Installation

pnpm install @falven/formtext

Usage

Here's a simple example of how to use FormText:

import { FormProvider, useFormContext, useFormValues } from '@falven/formtext';

const MyForm = () => {
  const formState = useFormContext<MyFormValues>();
  const formValues = useFormValues<MyFormValues>('myForm');

  return (
    <div>
      {/* form implementation */}
    </div>
  );
};

const App = () => (
  <FormProvider initialState={...}>
    <MyForm />
  </FormProvider>
);

In this example, we wrap our application with the FormProvider to provide form state to all child components. Then in our form component, we can use various hooks to access and manipulate the form state.

  • useFormContext: Returns the entire form state.
  • useFormValues: Returns the values of a specific form.
  • useFormMeta: Returns the metadata of a specific form.
  • useFormState: Returns both the values and metadata of a specific form.
  • useFormDispatch: Returns the dispatch function for form actions.

API

  • FormProvider: A component that provides form state and dispatch function to its children.

  • useFormContext: Hook that returns the form state.

  • useFormValues: Hook that returns the values of a specific form.

  • useFormMeta: Hook that returns the metadata of a specific form.

  • useFormState: Hook that returns both the values and metadata of a specific form.

  • useFormDispatch: Hook that returns the dispatch function for form actions.

For more details, please refer to the source code.

License

This project is licensed under the MIT License - see the LICENSE.md file for details.

0.2.1

10 months ago

0.2.0

10 months ago

0.1.8

10 months ago

0.1.7

10 months ago

0.1.9

10 months ago

0.1.6

10 months ago

0.1.5

11 months ago

0.1.4

11 months ago

0.1.3

11 months ago

0.1.2

11 months ago

0.1.1

11 months ago

0.1.0

12 months ago

0.0.10

12 months ago

0.0.9

12 months ago

0.0.8

12 months ago

0.0.7

12 months ago

0.0.6

12 months ago

0.0.5

12 months ago

0.0.4

12 months ago

0.0.3

12 months ago

0.0.2

12 months ago

0.0.1

12 months ago