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

@jvlsoft/ngx-dynamic-form

v1.2.1

Published

The `ngx-dynamic-form` is a library that works in Angular 16 with Bootstrap 5 to generate forms in a simple and dynamic way.

Downloads

505

Readme

ngx-dynamic-form

The ngx-dynamic-form is a library that works in Angular 16 with Bootstrap 5 to generate forms in a simple and dynamic way.

Installation

To install the library, run:

yarn add @jvlsoft/ngx-dynamic-form

Then add the following styles:

@import "~bootstrap/dist/css/bootstrap.min.css";
@import '~bootstrap-icons/font/bootstrap-icons.css';
@import "~@ng-select/ng-select/themes/default.theme.css";

Note: Make sure your project has routing, otherwise the library won't work

Usage

Here's a basic example of how to use the library in your Angular project:

import { DynamicFormComponent, FormInputComponent } from '@jvlsoft/ngx-dynamic-form';

@NgModule({
  imports: [
    DynamicFormComponent,
    // other imports
  ],
})
export class AppModule { }

In your component:

import { Component } from '@angular/core';

@Component({
  selector: 'app-dynamic-form',
  template: `<ngx-dynamic-form [config]="inputsConfig" [onlyFields]="false" title="User" [hasPrefix]="false"
        [saveButton]="false" [canGoBack]="false"></ngx-dynamic-form>`,
})
export class DynamicFormComponent {
  formConfig = [
    {
      type: FormInputComponent,
      name: 'username',
      class: 'col-lg-4 col-md-6 col-sm-12',
      helperText: 'Insert your username',
      label: 'Username',
      placeholder: 'John',
      validation: [Validators.required],
    },
    {
      type: FormInputComponent,
      name: 'email',
      class: 'col-lg-4 col-md-6 col-sm-12',
      helperText: 'Insert your company email',
      label: 'Email',
      placeholder: 'email@dominium',
      validation: [Validators.required],
    },
    // Other fields...
  ];
}

image

API

IFieldConfig

| Attribute | Type | Description | |-----------------|-------------------------------|-----------------------------------------------------------------------------------------------| | type | Type<IField> | Type of HTML field. | | name | string | Field name, this name will be the FormControlName. Example: 'name', 'email', etc. | | class | string | Class to apply to the field. Example: col-lg-4. | | label | string | Component label. | | helperText | string | Text to display below the field. | | fieldType | string | HTML type attribute of the field. Example: 'text', 'password', 'email', 'submit', etc. | | placeholder | string | Field placeholder. | | style | object | Style to apply to the field. Example: { "background-color": "#fff" }. | | order | number | Fields order. Field with order 1 goes first that with order 2. | | disabled | boolean | If the field will be disabled. | | readonly | boolean | If the field is readonly. | | value | any | Default value. | | options | IFieldOptions | Object with other options, this gives the possibility to add other functionalities. | | component | ComponentRef<any> | Represents a component created by a ComponentFactory. Provides access to the component instance and related objects, and provides the means of destroying the instance. | | validation | ValidatorFn[] | Array of ValidatorFn. | | asyncValidators | AsyncValidatorFn | AsyncValidatorFn[] | It accepts an AsyncValidatorFn or AsyncValidatorFn[] for async validator in reactive forms. | | updateOn | 'change' | 'blur' | 'submit'| The event name for control to update upon. |

IInputConfig

| Attribute | Type | Description | |------------|---------|--------------------------------------| | staticText | string | A text to display above the field. | | min | number | min attribute of html input tag. | | step | number | step attribute of html input tag. | | validStyle | boolean | If is true show the valid style. |

ICheckboxConfig

| Attribute | Type | Description | |----------------|---------|--------------------------------------| | firstLabel | string | Checkbox first label. | | lastLabel | string | Checkbox last label. | | hasLabelMargin | boolean | Is true if the label has a left margin. |

IRadioConfig

| Attribute | Type | Description | |-----------|---------|--------------------------------------| | class | string | Class to apply to options. | | options | any[] | Radio options. | | checked | any | The checked element. |

ISelectConfig

| Attribute | Type | Description | |-----------------|-------------------------------------------|-----------------------------------------------------------------------------------------------| | itemService | IFieldService | Service to get the items from the database. | | dynamic | boolean | Used for scrolling, searching on the server, and handling complex functions. If the data is simple, set dynamic to false. | | loading | boolean | Indicates if the component is in a loading state. | | autoLoadItems | boolean | If true, items will be automatically loaded. | | multiple | boolean | If true, multiple items can be selected. | | clearable | boolean | If true, the selected item can be cleared. | | searchable | boolean | If true, the select component will be searchable. | | filter | { [key: string]: string | string[] | number | number[] | boolean } | Filter to use on the service search query. | | items | [...[], ...any] | Items to be displayed in the select component. | | bindLabel | string | The property to bind as the label for each item. | | bindValue | string | The property to bind as the value for each item. | | groupBy | string | The property to group items by. | | limit | number | The maximum number of items per query. | | maxSelectedItems| number | The maximum number of items that can be selected. | | method | (query: any, skip: number, limit: number) => Observable<IRows> | The method to fetch rows, returning an observable. | | onChange | EventEmitter<any> | Event emitter for change events. | | transformData | (data: any) => any[] | Function to transform the data before displaying it. |

ITextAreaConfig

| Attribute | Type | Description | |-----------|--------|--------------------------| | rows | number | Textarea rows number. |