wise-form Library
Introduction
wise-form is a comprehensive React library aimed at streamlining the process of form creation and management in React applications. It leverages JSON for form configuration, supporting dynamic form generation with customizable layouts, field ordering, and in-depth validation mechanisms. The library introduces a structured approach with three core models: FieldModel, WrapperModel, and FormModel, alongside the WiseForm component for rendering. This architecture not only simplifies form development but also enhances flexibility by integrating with various UI libraries/frameworks beyond React, such as Preact, Vue, and Svelte.
Core Models
FieldModel: Represents individual form fields, encapsulating details like type, validation, and appearance.
WrapperModel: Acts as a container for grouping fields, capable of holding both
FieldModelinstances and otherWrapperModelcontainers, facilitating complex form structures.FormModel: A reactive model managing the entire form's state, observing changes across its elements for dynamic interaction handling. Its
fieldsproperty can include bothFieldModelandWrapperModelitems, offering a versatile way to construct forms.
These models observe all changes within the form, allowing developers to handle any event seamlessly.
Installation
npm install wise-formUsage
wise-form offers two primary methods for creating and managing forms:
Direct Configuration with WiseForm
WiseFormDefine your form configuration as a JSON object and pass it directly to the WiseForm component using the settings prop:
Advanced Implementation with FormModel
FormModelFor more control and flexibility, instantiate a FormModel and pass it to WiseForm. This approach is ideal for utilizing wise-form with other UI frameworks or for developers seeking detailed management of form behaviors:
Features
Dynamic Form Creation: Easily create forms with a JSON configuration.
Reactive Models: Utilize
FieldModel,WrapperModel, andFormModelfor comprehensive state management and event handling.Compatibility: Implement
wise-formacross multiple UI libraries/frameworks for maximum flexibility.Customizable Layouts: Use template logic for advanced field layout and grouping within your forms.
Last updated