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 🙏

© 2024 – Pkg Stats / Ryan Hefner

uni-form-ng

v2.1.0

Published

Angular forms based on JSON data

Downloads

352

Readme

UniFormNg

This is an Angular 15+ library, that automatically builds and renders highly customizable dynamic forms based on JSON data.

License: MIT

Out of the box, you get:

  • ready to use well-designed forms (Google's Material design);
  • a well-tested and low-coding solution that requires only JSON data;
  • dynamic fields based on Angular reactive forms;
  • full access to the form object for the easy customization;
  • rendering of standard validation errors (required, min, max, ...), which you can simply tweak to your liking;

How to connect?

Run: npm i uni-form-ng

You do NOT need to install "@angular/forms", "@angular/material" or any other dependencies.

Then you need to add a dependency into your Angular Module:

@NgModule({
  imports: [UniFormModule]
})

In main styles file (styles.css) please add:

@import "@angular/material/prebuilt-themes/indigo-pink.css";
@import url("https://fonts.googleapis.com/icon?family=Material+Icons");

How to use?

HTML

<uni-form-ng (formGroupEvent)='handleForm($event)' (submitEvent)='onFormSubmit($event)'>

  <uni-form-group-ng
    [url]="'assets/mocks/group/group.json'"
    [nested]='{countries: {type: "autocomplete", multi: true},
      login: {value: "[email protected]"}, password: {value: "password"}}'
  ></uni-form-group-ng>

  <button type='submit' mat-button [disabled]='!form?.valid'>SUBMIT</button>
</uni-form-ng>

JSON

URL: assets/mocks/group/group.json:

["assets/mocks/dynamic/countries.json","assets/mocks/dynamic/auth.json"]

URL: assets/mocks/dynamic/countries.json:

{"type":"select","key":"countries","label":"Select country / countries","groups":[{"name":"North America","options":[{"label":"Canada","value":"Canada","fields":["assets/mocks/dynamic/canada.json"]},{"label":"USA","value":"USA","fields":["assets/mocks/dynamic/usa.json"]}]}]}

URL: assets/mocks/dynamic/auth.json:

{"type":"checkbox","key":"auth","label":"Check to enable authorization","fields":["assets/mocks/dynamic/login.json","assets/mocks/dynamic/password.json"]}

JS/TS

...
export class Component {

  form;

  handleForm(event) {
    this.form = event;
  }

  onFormSubmit(event) {
    console.log(event.value);
  }
}

Static fields demo

Dynamic fields demo

Custom forms demo

API overview

Selector: uni-form-ng

@Input() clean: boolean - by default is false and newly added dynamic fields will not be removed form Angular reactive form object after switch. If true, then newly added dynamic fields will be removed after switch to another fields.

@Output() formGroupEvent: EventEmitter<FormGroup> - returns a NEW Angular reactive form object every time when a new field was added or removed.

@Output() submitEvent: EventEmitter<FormGroup> - returns an Angular reactive form object when form is submitted.

Selector: uni-form-group-ng

@Input() url: string - the URL link to JSON data with list of fields.

@Input() nested: UniObject<UniFormNested> - the object for nested fields deep configuration.

Selector: uni-form-field-ng

@Input() url: string - the URL link to JSON data for building and rendering form field.

@Input() options: Partial<UniFormField> - the object for the field deep configuration.

@Input() nested: UniObject<UniFormNested> - the object for nested fields deep configuration.

Now I'm looking for new job opportunities. Please, contact me, if you are interested. Thank you! Author's profile