npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@vanshasomani/generic-form

v0.1.1

Published

Reusable Angular Material Form Component

Readme

@vanshasomani/generic-form

A reusable, configurable Angular form component built using Angular Material. This library allows developers to generate dynamic forms based on a configuration object using @angular/forms and the power of custom components like @vanshasomani/generic-input.

✨ Features

  • Config-driven form rendering
  • Supports all standard Angular Material input types
  • Built-in support for:
    • Validation
    • Custom error messages
    • Checkbox, Radio, Select, Textarea, Password, and more
  • Two-way syncing with external FormControl
  • Designed for clean integration with Angular Material UI
  • Supports multiple input types:
    • text
    • password
    • email
    • textarea
    • select
    • radio
    • checkbox

📦 Installation

npm install @vanshasomani/generic-form @vanshasomani/generic-input

🚀 Usage
1. Import Module (Standalone Component)
No need to create a separate module — GenericForm is a standalone component.

ts
Copy
Edit
import { GenericForm } from '@vanshasomani/generic-form';

@Component({
  standalone: true,
  imports: [GenericForm],
  ...
})
2. Template Usage
html
Copy
Edit
<lib-generic-form
  [config]="formConfig"
  (submitted)="onSubmit($event)"
  (cancelled)="onCancel()"
></lib-generic-form>
3. Define Config in Component
ts
Copy
Edit
import { GenericFormInterface } from '@vanshasomani/generic-form';
import { Validators } from '@angular/forms';

formConfig: GenericFormInterface = {
  fields: [
    {
      type: 'text',
      name: 'firstName',
      label: 'First Name',
      placeholder: 'Enter your first name',
      appearance: 'outline',
      id: 'firstName',
      showRequiredStar: true,
      customValidators: [Validators.required],
      customErrorMessages: {
        required: 'First name is required'
      }
    },
    {
      type: 'email',
      name: 'email',
      label: 'Email',
      placeholder: 'Enter your email',
      appearance: 'outline',
      id: 'email',
      customValidators: [Validators.required, Validators.email]
    },
    {
      type: 'select',
      name: 'gender',
      label: 'Gender',
      placeholder: 'Select gender',
      appearance: 'fill',
      id: 'gender',
      options: [
        { label: 'Male', value: 'M' },
        { label: 'Female', value: 'F' }
      ]
    }
  ],
  submitButtonLabel: 'Register',
  cancelButtonLabel: 'Clear'
};

📤 Outputs
| Output      | Description                             |
| ----------- | --------------------------------------- |
| `submitted` | Emits the form value on valid submit    |
| `cancelled` | Emits when the cancel button is clicked |

🔧 Form Field Configuration
Each field inside fields: GenericInputInterface[] can have:

| Property              | Type                                              | Description                         |                             |
| --------------------- | ------------------------------------------------- | ----------------------------------- | --------------------------- |
| `type`                | `string`                                          | Input type (`text`, `select`, etc.) |                             |
| `name`                | `string`                                          | Form control name                   |                             |
| `label`               | `string`                                          | Label for the field                 |                             |
| `placeholder`         | `string`                                          | Placeholder text                    |                             |
| `id`                  | `string`                                          | HTML id                             |                             |
| `appearance`          | `'outline' \| 'fill'`                             | Angular Material appearance         |                             |
| `showRequiredStar`    | `boolean`                                         | Show `*` for required fields        |                             |
| `disabled`            | `boolean`                                         | Disable input                       |                             |
| `rows`                | `number`                                          | Textarea row size                   |                             |
| `options`             | `{ label: string; value: string }[]`              | For select and radio fields         |                             |
| `value`               | `string`                                          | Default value                       |                             |
| `customValidators`    | \`((control: AbstractControl) => ValidationErrors | null)\[]\`                          | Array of Angular Validators |
| `customErrorMessages` | `{ [key: string]: string }`                       | Custom error messages by error key  |                             |


🧩 Dependencies
This library depends on:

@vanshasomani/generic-input

Angular Material (Button, FormField, Input, Select, etc.)

Angular Forms (Reactive)

Ensure these modules are available in your project.