0.5.3 • Published 5 months ago

@appmint/form v0.5.3

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

AppmintForm

npm version npm downloads License: MIT

AppmintForm is a powerful, lightweight, and flexible form builder library for React applications, designed to make it easy to create and manage complex forms with minimal code while maintaining excellent performance and aesthetics.

📚 Documentation

View the comprehensive documentation for detailed information on installation, usage, API reference, examples, and more.

✨ Features

  • JSON Schema Configuration: Define forms using a declarative JSON schema
  • Rich Component Library: Support for 30+ input types and controls
  • Conditional Rendering: Show/hide fields based on form data
  • Built-in Validation: Comprehensive validation using Zod
  • Customizable Layouts: Multiple layout options including tabs, accordions, and more
  • Theming Support: Easily customize the appearance of your forms
  • Performance Optimized: Only updates what has changed, ensuring efficient rendering
  • Extensible: Add custom input components and layouts
  • Multiple Form Instances: Use multiple forms on the same page without state conflicts
  • Custom Components: Create and register custom form elements or override existing ones

🚀 Quick Start

Installation

# Using npm
npm install @appmint/form

# Using yarn
yarn add @appmint/form

# Using pnpm
pnpm add @appmint/form

Basic Usage

import React from 'react';
import { AppmintForm } from '@appmint/form';

const MyForm = () => {
  const schema = {
    type: 'object',
    title: 'User Information',
    properties: {
      name: {
        type: 'string',
        title: 'Name',
        inputRequired: true
      },
      email: {
        type: 'string',
        title: 'Email',
        format: 'email',
        inputRequired: true
      }
    }
  };

  const handleChange = (path, value, data) => {
    console.log('Form data:', data);
  };

  return (
    <AppmintForm 
      schema={schema} 
      onChange={handleChange}
      id="user-form"
    />
  );
};

🎨 Demo Examples

The library includes several demo examples that showcase different features and capabilities:

  • Theme Editor: Customize the appearance of your forms with a powerful theme editor
  • Text Inputs: Various text input types including regular fields, textarea, rich text editor
  • Number Inputs: Different number input options including sliders and ranges
  • Selection Inputs: Various selection controls like dropdowns, checkboxes, and radio buttons
  • Date/Time Inputs: Date pickers, date range pickers, and cron expression editors
  • Special Inputs: Color pickers, file uploads, map location pickers, and more
  • Layout Elements: Different layout options including tabs, accordions, and collapsible sections
  • Advanced Elements: Complex form elements like data views, lookups, and ratings
  • Table Demo: Table component with sorting, filtering, and pagination

Check out the documentation for more details on these demos.

🔌 Custom Components & Multiple Forms

Multiple Form Instances

You can now use multiple form instances on the same page without state conflicts:

import React from 'react';
import { CollectionForm } from '@appmint/form';

const MultipleFormsExample = () => {
  return (
    <div className="grid grid-cols-2 gap-4">
      {/* Each form has its own independent state */}
      <CollectionForm 
        schema={schema1} 
        id="form-1"
        data={data1}
      />
      
      <CollectionForm 
        schema={schema2} 
        id="form-2"
        data={data2}
      />
    </div>
  );
};

Custom Components

Create and register custom form components to extend the library's capabilities:

import React from 'react';
import { CollectionForm, registerCustomComponent } from '@appmint/form';

// Create a custom component
const CustomTextInput = (props) => {
  const { value, change, blur, focus, name, schema } = props;
  
  return (
    <div className="custom-input">
      <input
        type="text"
        value={value || ''}
        onChange={(e) => change(e.target.value)}
        onBlur={(e) => blur(e.target.value)}
        onFocus={focus}
        placeholder={schema.placeholder}
        className="custom-styled-input"
      />
      <div className="helper-text">Custom input component</div>
    </div>
  );
};

// Register your custom component
registerCustomComponent('custom-text', CustomTextInput);

// Use it in your form schema
const schema = {
  type: 'object',
  properties: {
    customField: {
      type: 'string',
      title: 'Custom Field',
      'x-control': 'custom-text'
    }
  }
};

You can also override existing components to customize their appearance and behavior:

// Override the built-in textarea component
registerCustomComponent('textarea', CustomTextareaComponent);

📄 License

AppmintForm is open-source software licensed under the MIT license.

0.3.9

5 months ago

0.3.91

5 months ago

0.3.0

7 months ago

0.2.1

8 months ago

0.2.0

8 months ago

0.3.6

5 months ago

0.5.3

5 months ago

0.3.5

6 months ago

0.3.8

5 months ago

0.3.7

5 months ago

0.4.1

5 months ago

0.3.2

7 months ago

0.2.3

8 months ago

0.2.2

8 months ago

0.5.2

5 months ago

0.3.4

6 months ago

0.2.5

7 months ago

0.5.1

5 months ago

0.4.2

5 months ago

0.3.3

7 months ago

0.2.4

8 months ago

0.1.5

1 year ago

0.1.3

1 year ago

0.1.2

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago