0.0.55 • Published 3 months ago

mj-react-form-builder v0.0.55

Weekly downloads
-
License
MIT
Repository
-
Last release
3 months ago

MJ React Form Builder

mj-react-form-builder is a customizable and reusable form component library built with React, TypeScript, and Tailwind CSS. This package provides a suite of input components, layout components, and utility functions to help developers quickly build forms with validation and consistent styling.

Features

  • Customizable Inputs: Includes various input components like text inputs, multi-select, masked inputs, and more.
  • Form Layouts: Use layout components like FormSection to organize form elements.
  • TypeScript Support: Built with TypeScript for type safety and better development experience.
  • Tailwind CSS: Preconfigured with Tailwind CSS for utility-first styling.
  • React Hook Form Integration: Designed to work seamlessly with react-hook-form for powerful form validation and management.

Installation

You can install the mj-react-form-builder package via npm:

npm install mj-react-form-builder

Or if you are using Yarn:

yarn add mj-react-form-builder

Getting Started

To use the components in your project, import them from mj-react-form-builder:

import React from "react";
import { Form, FormSection, TextInput } from "mj-react-form-builder";
import "./index.css"; // Ensure Tailwind CSS is loaded

const MyForm = () => {
  return (
    <Form>
      <div className="container mx-auto p-4">
        <h1 className="text-2xl font-bold mb-4">My Custom Form</h1>
        <FormSection title="User Information">
          <TextInput name="firstName" label="First Name" required />
          <TextInput name="lastName" label="Last Name" required />
          <TextInput name="email" label="Email" required />
        </FormSection>
      </div>
    </Form>
  );
};

export default MyForm;

Example Components

  • TextInput: A basic text input component with validation.
  • MultiSelectInput: A multi-select dropdown component.
  • FormSection: A layout component to organize form fields into sections.

Available Components

  • Inputs:

    • CheckboxInput
    • ContactArrayInput
    • FileInput
    • MaskedPhoneInput
    • NumberInput
    • MultiSelectInput
    • ResponsiveListItem
    • SelectInput
    • TextInput
    • TextAreaInput
    • ZipCodeInput
    • SelectStateInput
  • Layouts:

    • FormSection
  • Providers:

    • NotifyProvider
    • Form
  • Services:

    • uploadService

Tailwind CSS Setup

Ensure Tailwind CSS is set up in your project. The index.css file should include the following imports to make Tailwind CSS available globally:

@tailwind base;
@tailwind components;
@tailwind utilities;

TypeScript Configuration

If you're expanding the ESLint configuration in a production application, we recommend updating the configuration to enable type-aware lint rules.

Example ESLint Configuration

export default tseslint.config({
  languageOptions: {
    parserOptions: {
      project: ['./tsconfig.node.json', './tsconfig.app.json'],
      tsconfigRootDir: import.meta.dirname,
    },
  },
  settings: { react: { version: '18.3' } },
  plugins: {
    react,
  },
  rules: {
    ...react.configs.recommended.rules,
    ...react.configs['jsx-runtime'].rules,
  },
});

TypeScript Configuration

Your tsconfig.json should be properly set up to handle the library's types and to integrate seamlessly with your project:

{
  "compilerOptions": {
    "target": "esnext",
    "module": "esnext",
    "jsx": "react-jsx",
    "strict": true,
    "moduleResolution": "node",
    "esModuleInterop": true,
    "skipLibCheck": true,
    "forceConsistentCasingInFileNames": true,
    "declaration": true,
    "emitDeclarationOnly": true,
    "outDir": "dist",
    "rootDir": "src"
  },
  "include": ["src"],
  "exclude": ["node_modules", "dist"]
}

Contributing

If you'd like to contribute to mj-react-form-builder, please fork the repository and use a feature branch. Pull requests are warmly welcome.

License

This package is licensed under the MIT License.

Author

Marcos Jimenez


This README.md should give users a clear overview of how to use your mj-react-form-builder package, including installation, basic usage, and configuration tips.

0.0.47

6 months ago

0.0.51

4 months ago

0.0.52

4 months ago

0.0.53

3 months ago

0.0.54

3 months ago

0.0.55

3 months ago

0.0.50

6 months ago

0.0.48

6 months ago

0.0.49

6 months ago

0.0.43

8 months ago

0.0.44

8 months ago

0.0.45

8 months ago

0.0.46

8 months ago

0.0.41

8 months ago

0.0.42

8 months ago

0.0.40

8 months ago

0.0.39

8 months ago

0.0.38

9 months ago

0.0.37

9 months ago

0.0.36

9 months ago

0.0.35

9 months ago

0.0.34

9 months ago

0.0.33

9 months ago

0.0.32

9 months ago

0.0.31

9 months ago

0.0.30

9 months ago

0.0.29

9 months ago

0.0.28

9 months ago

0.0.27

9 months ago

0.0.26

9 months ago

0.0.25

9 months ago

0.0.24

9 months ago

0.0.23

9 months ago

0.0.22

9 months ago

0.0.21

9 months ago

0.0.20

9 months ago

0.0.19

9 months ago

0.0.18

9 months ago

0.0.17

9 months ago

0.0.16

10 months ago

2.0.26

10 months ago

2.0.25

10 months ago

2.0.24

10 months ago

2.0.23

10 months ago

2.0.22

10 months ago

2.0.21

10 months ago

2.0.20

10 months ago

2.0.19

10 months ago

2.0.18

10 months ago

2.0.17

10 months ago

2.0.15

10 months ago

2.0.14

10 months ago

2.0.13

10 months ago

2.0.12

10 months ago

2.0.11

10 months ago

2.0.10

10 months ago

2.0.9

10 months ago

2.0.7

10 months ago

2.0.6

10 months ago

2.0.5

10 months ago

2.0.4

10 months ago

2.0.3

10 months ago

2.0.2

10 months ago

2.0.1

10 months ago

2.0.0

10 months ago

1.0.0

10 months ago