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

lac-mat-tel-input

v3.0.0

Published

An Angular Material package for entering and validating international telephone numbers.

Downloads

1,002

Readme

Lacuna International Telephone Input for Angular Material (LacMatTelInput)

An Angular Material package for entering and validating international telephone numbers.

This is a partial rewrite of [tanansatpal's ngx-mat-intl-tel-input] (https://github.com/tanansatpal/ngx-mat-intl-tel-input) which was the best angular material component I could find for this purpose but I felt that the structure of the component needded too many changes.

Main features:

  • Country Selector with flag
  • Auto formatting when user types phone
  • Applies max length according with the country selected
  • Output is formatted (digits only coming soon)
  • Phone validator for Reactive Forms
  • Automatically sets country when user pastes phone with the country's dial code

Supports:

  • Angular 9
  • Angular Material 9
  • ReactiveFormsModule
  • FormsModule
  • Validation with libphonenumber-js

Installation

Install Dependencies

$ npm install libphonenumber-js --save

Install This Library

$ npm install lac-mat-tel-input --save

Usage

Import

Add LacMatTelInputModule to your module file:


imports: [
    LacMatTelInputModule,
  ]

Example

You can find a complete Stackblitz sample here.


<form [formGroup]="form">
	<mat-form-field>
		<mat-label>Phone</mat-label>
		<lac-mat-country-selector matPrefix [selectorFor]="input"></lac-mat-country-selector>
		<lac-mat-tel-input #input formControlName="phone"></lac-mat-tel-input>
		<mat-error *ngIf="form.controls['phone']?.errors?.invalidPhone">Invalid phone</mat-error>
    </mat-form-field>
</form>

<form [formGroup]="form">
	<mat-form-field>
		<mat-label>Phone</mat-label>
		<lac-mat-country-selector matPrefix [selectorFor]="input"
			[preferredCountries]="['us', 'gb']"
			[onlyCountries]="['us', 'gb', 'es']"
			[showDialCode]="false"
			[disableSearch]="false"
			searchPlaceholder="Search..."
			(change)="onCountryChange($event)">
		</lac-mat-country-selector>
		<lac-mat-tel-input #input formControlName="phone">
		</lac-mat-tel-input>
    </mat-form-field>
</form>

Options

| Options | Type | Default | Description | | ------------------------------|------------------------|--------------------|-------------------------------------------------------------------------------------| | preferredCountries | string[] | [] | List of country abbreviations, which will appear at the top. | | onlyCountries | string[] | [] | List of manually selected country abbreviations, which will appear in the dropdown. | | showDialCode | boolean | false | Shows the country's dial code next to the flag | | disableSearch | boolean | false | Whether to disable the search bar to help filter down the list of countries | | searchPlaceholder | string | null | The placeholder to display in the search bar | | internationalFormat | boolean | false | By default, phone numbers will be formated using the AsYouType formatter. However, if you wish to use INTERNATIONAL format set this to true |

Library Contributions

  • Fork repo.
  • Go to ./projects/lac-mat-tel-input
  • Update ./src/lib with new functionality.
  • Update README.md
  • Pull request.

Helpful commands

  • Build lib: $ npm run build_lib
  • Copy license and readme files: $ npm run copy-files
  • Create package: $ npm run npm_pack
  • Build lib and create package: $ npm run package

Use locally

After building and creating package, you can use it locally too.

In your project run:

$ npm install --save {{path to your local '*.tgz' package file}}