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

ib-auto-form-bs

v0.0.1

Published

This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 7.2.0.

Downloads

7

Readme

IbAutoFormBs

This library was generated with Angular CLI version 7.2.0.

description

This library basically let you create a dynamic form component using bootstrap from controls (Like registration etc.) Currently as it is, it supports 6 types of form controls:

  • Text input (text, password, email etc.)
  • Select (Also multi select)
  • Radio
  • Checkbox
  • Textarea
  • File

With that being said, it can support any type of control from any other package (Like Angular materials) using customization tools. Forms are being created using a JavaScript Object or a JSON file which contains instructions for the form builder. Different forms for different users can be created on the fly.

Simple usage

You can create a simple working form using IbAutoFormComponent like that: First import IbAutoFormBsModule to your main module:

import {IbAutoFormBsModule} from 'ib-auto-form-bs';

@NgModule({
  ...
  imports: [
    IbAutoFormBsModule.forRoot(),
  ],
  ...
})
export class AppModule { }

Second, add IbAutoFormComponent to your component template:

<ib-dynamic-forms [controlGroups]="controlGroups"></ib-dynamic-forms>

As you can see, we assigned 'controlGroups' property to IbAutoFormComponent 'controlGroups' input. ControlGroups is a list of instructions to create our form. In your component template crate a public property called 'controlGroups' like that:

controlGroups = [
    {
        controls: [
            {
                id: 'firstname',
                title: 'First Name',
                type: 'text'
            }   
        ]       
    }
]

If you will try to run your project on the browser, you should see a text input with 'First Name' label. So what is really going on? What is this structure we are using?

Lets split apart the different parts so we can understand better, from inside to outside:

{
    id: 'firstname',
    title: 'First Name',
    type: 'text'
}   

The above code, as you can imaging, represents a control type, in our case a text input. You can read farther about other properties control can have like validation etc. This control, hypothetically, is part of a list of other controls that make up our form, so we stack them by order on our controls array like so:

controls: [
    // First control
    { 
        id: 'firstname',
        title: 'First Name',
        type: 'text'
    },
    // Second control
    { 
        id: 'lastname',
        title: 'Last Name',
        type: 'text'
    }    
    ...
]   

Ok, maybe that part was pretty clear, but why do we have to put the controls list inside another object which is a part of another list? To answer that lets think of a case where we want to layout our form so that it has different distinct sections. A good example is a feature setup form, which we might have 2 parts , a basic settings and advanced settings. On those cases we would like to divide our form to two main sections (basic and advanced). We call each section like that a ControlGroup. A control group can have properties like title, className etc. In our first example we've used a single controlGroup with no properties:

controlGroups = [
    {
        controls: [
            {
                id: 'firstname',
                title: 'First Name',
                type: 'text'
            }   
        ]       
    }
]

As with controls, custom groups control component can be added instead of the proposed one. control groups can be omitted, so only the controls will be displayed, by setting 'useGroups' to false

<ib-dynamic-forms [controlGroups]="controlGroups" [useGroups]="false"></ib-dynamic-forms>