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

@gruppoanthea/dynamic-form

v1.0.5-alpha.2

Published

Angular Dynamic Form Generator

Readme

Dynamic Form

Angular Dynamic form Creator

Getting Started

Install library:

$ npm install --save @gruppoanthea/dynamic-form  

add DynamicFormModule to app.module.ts

import {NgModule} from '@angular/core';    
...  
import {AppComponent} from './app.component';    
import {DynamicFormModule} from '@gruppoanthea/dynamic-form';
    
@NgModule({    
  declarations: [AppComponent],    
  imports: [    
    ...    
    DynamicFormModule.forRoot()  
     // or DynamicFormModule.forChild() for lazy loaded modules ,    
  ],    
  providers: [],    
  bootstrap: [AppComponent],    
})    
export class AppModule {    
}  

and call it in app.component.ts:

import {Component, ViewChild} from '@angular/core';    
import {FieldConfig, DynamicFormComponent} from '@gruppoanthea/dynamic-form';    
    
@Component({    
  selector: 'app-root',    
  template: `    
    <div class="form">  
       <dynamic-form [fields]="regConfig" (submit)="submit($event)"></dynamic-form>    
    </div> `,    
  styles: []    
})    
export class AppComponent {    
  regConfig: FieldConfig[] = [];    
  @ViewChild(DynamicFormComponent) form: DynamicFormComponent;    
  constructor() {    
     window.fetch('assets/form.json', {method: 'GET'})    
       .then(res => res.json())    
       .then(res => this.regConfig = res);  
  }    
  submit(value: any) {    
     console.log(value);    
  }  
}  

Form Schema

the form schema can be imported locally or from Backend.
schema structure:

export interface Validator {    
  name: string;    
  validationParams?: any;    
  validationFunction?: any;    
  message: string;    
}    
export interface FieldConfig {    
  name: string;    
  type: string;    
  label?: string;    
  inputType?: string;    
  options?: string[];    
  collections?: any;    
  value?: any;    
  validations?: Validator[];    
  events?: any[];    
}  

example:

[
  {
    "type": "input", // required
    "name": "name",  // required
    "label": "Username",
    "inputType": "text",
    "value": "Andrea",
    "validations": [
      {
        "name": "required",
        "message": "Name Required"
      },
      {
        "name": "custom",
        "message": "This is a custom validator"
      }
    ]
  }
]  

Add Custom Field Component

you can add a custom component to populate your form. your component MUST extends the "BaseFieldComponent" that have field and group default variables. you had to add [formGroup] = "group" attribute to the firs tag of your component in the field variable you have all form field's data.

custom-component.ts

import { Component, OnInit, Input } from '@angular/core';    
import { FormControl } from '@angular/forms';    
    
@Component({    
  selector: 'app-custom-component',    
  template: `  
  <div [formGroup]="group">    
    <label>{{field.label}}: </label>    
    <input [formControlName]="field.name" [placeholder]="field.label" [type]="field.inputType">    
    <ng-container *ngFor="let validation of field.validations;" ngProjectAs="div">    
       <div *ngIf="group.get(field.name).hasError(validation.name)">{{validation.message}}</div>    
    </ng-container>  
 </div>  
  `,    
})    
export class CustomFieldComponent extends BaseFieldComponent implements OnInit {
	ngOnInit() {}
}  

in order to add custom components in form schema you need to
add it to DynamicFormModule:

...   
import {CustomFieldComponent} from '@gruppoanthea/dynamic-form';

const customComponents = {    
  'custom': CustomFieldComponent    
};    
  
@NgModule({    
  declarations: [  
  ...  
  CustomFieldComponent  
  ],    
  ...     
  imports: [    
    DynamicFormModule.forRoot({customComponents}),    
  ]  
})    
export class AppModule {    
}  

Add Custom Validator

create custom validators with createAsyncValidator function
in order to add custom validators in form schema you need to add it to ValidatorMapper Singleton:

...   
import {createAsyncValidator} from '@gruppoanthea/dynamic-form';    
    
 ...   
  const customValidators = {    
    'custom': createAsyncValidator('custom', fieldValue => /^ciao$/.test(fieldValue))    
  };    
@NgModule({    
  declarations: [  
  ...  
  CustomFieldComponent  
  ],    
  ...     
  imports: [    
      DynamicFormModule.forRoot({customComponents, customValidators}),    
   ]  
})    
export class AppModule {    
}  

custom Components and Validators can be used in form schema.

See also