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

ng-dynamic-components

v0.0.6

Published

Run `npm install ng-dynamic-components --save`

Downloads

4

Readme

Form Controls

Installation

Run npm install ng-dynamic-components --save

Import peer dependencies npm i @angular/flex-layout @angular/material-moment-adapter moment -S

There are seven form controls available:

Text Input

Import Module:

import { TextInputModule } from "ng-dynamic-components";

Form Component HTML:

<dc-text-input
  label="This is a label"
  [formControl]="control"
  idRef="exampleIdentifier"
  [validationMessages]="validationMessages"
></dc-text-input>

Form Component TypeScript:

export class FormComponent implements OnInit {
  public form!: FormGroup;

  public validationMessages = {
    required: "This field is mandatory.",
    maxlength: "Exceeded max length.",
  };

  constructor(private fb: FormBuilder) {}

  ngOnInit(): void {
    this.form = this.fb.group({
      inputText: ["", [Validators.required, Validators.maxLength(10)]],
    });
  }

  public get control(): FormControl {
    return this.form.get("inputText") as FormControl;
  }
}

Input Options:

| Input | Description | Default Value | | ------------------ | ------------------------------------------------------------------------ | ------------- | | idRef | Sets the id for the component | undefined | | label | Sets the label on the component | undefined | | validationMessages | Messages related to validation errors | {} | | readonly | Sets the form element to readonly view | false | | placeholder | Placeholder text | '' | | maxlength | Sets the maximum character length of the UI Input | undefined | | upperCase | Converts all alphabetical character inputs from lowercase to capitalised | false |

Textarea

Import Module:

import { TextareaModule } from "ng-dynamic-components";

Form Component HTML:

<dc-input-textarea
  label="This is a label"
  [formControl]="control"
  idRef="exampleIdentifier"
  [validationMessages]="validationMessages"
></dc-input-textarea>

Form Component TypeScript:

export class FormComponent implements OnInit {
  public form!: FormGroup;

  public validationMessages = {
    required: "This field is mandatory.",
    maxlength: "Exceeded max length.",
  };

  constructor(private fb: FormBuilder) {}

  ngOnInit(): void {
    this.form = this.fb.group({
      textArea: ["", [Validators.required, Validators.maxLength(10)]],
    });
  }

  public get control(): FormControl {
    return this.form.get("textArea") as FormControl;
  }
}

Input Options:

| Input | Description | Default Value | | ------------------ | ------------------------------------------------------------------------ | ------------- | | idRef | Sets the id for the component | undefined | | label | Sets the label on the component | undefined | | validationMessages | Messages related to validation errors | {} | | readonly | Sets the form element to readonly view | false | | placeholder | Placeholder text | '' | | maxlength | Sets the maximum character length of the UI Input | undefined | | upperCase | Converts all alphabetical character inputs from lowercase to capitalised | false |

Select

Import Module:

import { SelectModule } from "ng-dynamic-components";

Form Component HTML:

<dc-select
  label="This is a label"
  [formControl]="control"
  idRef="exampleIdentifier"
  [options]="options"
  [validationMessages]="validationMessages"
></dc-select>

Form Component TypeScript:

export class FormComponent implements OnInit {
  public form!: FormGroup;

  public validationMessages = {
    required: "This field is mandatory.",
    maxlength: "Exceeded max length.",
  };

  public options = [
    {
      value: 1,
      display: "One",
    },
    {
      value: 2,
      display: "Two",
    },
  ];

  constructor(private fb: FormBuilder) {}

  ngOnInit(): void {
    this.form = this.fb.group({
      select: ["", [Validators.required, Validators.maxLength(10)]],
    });
  }

  public get control(): FormControl {
    return this.form.get("select") as FormControl;
  }
}

Input Options:

| Input | Description | Default Value | | ------------------ | -------------------------------------- | ------------- | | idRef | Sets the id for the component | undefined | | label | Sets the label on the component | undefined | | validationMessages | Messages related to validation errors | {} | | readonly | Sets the form element to readonly view | false | | options | Sets the available select options | [] |

Filterable Select

Import Module:

import { FilterableSelectModule } from "ng-dynamic-components";

Form Component HTML:

<dc-filterable-select
  label="This is a label"
  [formControl]="control"
  idRef="exampleIdentifier"
  [validationMessages]="validationMessages"
  [options]="options"
></dc-filterable-select>

Form Component TypeScript:

export class FormComponent implements OnInit {
  public form!: FormGroup;

  public validationMessages = {
    required: "This field is mandatory.",
  };

  public options = [
    {
      value: 1,
      display: "One",
    },
    {
      value: 2,
      display: "Two",
    },
  ];

  constructor(private fb: FormBuilder) {}

  ngOnInit(): void {
    this.form = this.fb.group({
      filterableSelect: ["", [Validators.required]],
    });
  }

  public get control(): FormControl {
    return this.form.get("filterableSelect") as FormControl;
  }
}

Input Options:

| Input | Description | Default Value | | ------------------ | -------------------------------------- | ------------- | | idRef | Sets the id for the component | undefined | | label | Sets the label on the component | undefined | | validationMessages | Messages related to validation errors | {} | | readonly | Sets the form element to readonly view | false | | options | Sets the available select options | [] |

Checkbox

Import Module:

import { CheckboxModule } from "ng-dynamic-components";

Form Component HTML:

<dc-checkbox
  label="This is a label"
  [formControl]="control"
  idRef="exampleIdentifier"
></dc-checkbox>

Form Component TypeScript:

export class FormComponent implements OnInit {
  public form!: FormGroup;

  constructor(private fb: FormBuilder) {}

  ngOnInit(): void {
    this.form = this.fb.group({
      checkbox: [{ value: true }],
    });
  }

  public get control(): FormControl {
    return this.form.get("checkbox") as FormControl;
  }
}

Input Options:

| Input | Description | Default Value | | ----- | ------------------------------- | ------------- | | idRef | Sets the id for the component | undefined | | label | Sets the label on the component | undefined |

Radio Group

Import Module:

import { RadioGroupModule } from "ng-dynamic-components";

Form Component HTML:

<dc-radio-group
  label="This is a label"
  [options]="options"
  [formControl]="control"
  layout="vertical"
  idRef="exampleIdentifier"
></dc-radio-group>

Form Component TypeScript:

export class FormComponent implements OnInit {
  public form!: FormGroup;

  public options = [
    {
      value: 1,
      display: "One",
    },
    {
      value: 2,
      display: "Two",
    },
  ];

  constructor(private fb: FormBuilder) {}

  ngOnInit(): void {
    this.form = this.fb.group({
      radioGroup: [""],
    });
  }

  public get control(): FormControl {
    return this.form.get("radioGroup") as FormControl;
  }
}

Input Options:

| Input | Description | Default Value | | ------- | --------------------------------------- | ------------- | | idRef | Sets the id for the component | undefined | | label | Sets the label on the component | undefined | | options | Sets the available select options | [] | | layout | Sets the alignment of the radio buttons | horizontal |

Date Picker

Import Module:

import { DatePickerModule } from "ng-dynamic-components";

Form Component HTML:

<dc-date-picker
  label="This is a label"
  [formControl]="control"
  idRef="exampleIdentifier"
  [validationMessages]="validationMessages"
></dc-date-picker>

Form Component TypeScript:

export class FormComponent implements OnInit {
  public form!: FormGroup;

  public validationMessages = {
    required: "This field is mandatory.",
  };

  constructor(private fb: FormBuilder) {}

  ngOnInit(): void {
    this.form = this.fb.group({
      datepicker: ["", [Validators.required]],
    });
  }

  public get control(): FormControl {
    return this.form.get("datepicker") as FormControl;
  }
}

Input Options:

| Input | Description | Default Value | | ------------------ | -------------------------------------- | ------------- | | idRef | Sets the id for the component | undefined | | label | Sets the label on the component | undefined | | validationMessages | Messages related to validation errors | {} | | readonly | Sets the form element to readonly view | false |

Setting the UI Style

Provide the token and the style you want as the value:

import { UI_STYLE } from "ng-dynamic-components";

@NgModule({
    ...
    providers: [
        ...
        { provide: UI_STYLE, useValue: 'material' }
    ]
})

Once the app is initialised the components can be programatically flipped using the FormService:

import { UI_STYLE } from "ng-dynamic-components";

export class AppComponent {
  constructor(private readonly formService: FormService) {
    this.formService.style = "simple";
  }
}

This package supports simple and material component designs.