0.0.21 • Published 1 year ago

mj-react-form-builder v0.0.21

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year 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

12 months ago

0.0.51

10 months ago

0.0.52

10 months ago

0.0.53

9 months ago

0.0.54

9 months ago

0.0.55

9 months ago

0.0.50

12 months ago

0.0.48

12 months ago

0.0.49

12 months ago

0.0.43

1 year ago

0.0.44

1 year ago

0.0.45

1 year ago

0.0.46

1 year ago

0.0.41

1 year ago

0.0.42

1 year ago

0.0.40

1 year ago

0.0.39

1 year ago

0.0.38

1 year ago

0.0.37

1 year ago

0.0.36

1 year ago

0.0.35

1 year ago

0.0.34

1 year ago

0.0.33

1 year ago

0.0.32

1 year ago

0.0.31

1 year ago

0.0.30

1 year ago

0.0.29

1 year ago

0.0.28

1 year ago

0.0.27

1 year ago

0.0.26

1 year ago

0.0.25

1 year ago

0.0.24

1 year ago

0.0.23

1 year ago

0.0.22

1 year ago

0.0.21

1 year ago

0.0.20

1 year ago

0.0.19

1 year ago

0.0.18

1 year ago

0.0.17

1 year ago

0.0.16

1 year ago

2.0.26

1 year ago

2.0.25

1 year ago

2.0.24

1 year ago

2.0.23

1 year ago

2.0.22

1 year ago

2.0.21

1 year ago

2.0.20

1 year ago

2.0.19

1 year ago

2.0.18

1 year ago

2.0.17

1 year ago

2.0.15

1 year ago

2.0.14

1 year ago

2.0.13

1 year ago

2.0.12

1 year ago

2.0.11

1 year ago

2.0.10

1 year ago

2.0.9

1 year ago

2.0.7

1 year ago

2.0.6

1 year ago

2.0.5

1 year ago

2.0.4

1 year ago

2.0.3

1 year ago

2.0.2

1 year ago

2.0.1

1 year ago

2.0.0

1 year ago

1.0.0

1 year ago