Giter VIP home page Giter VIP logo

juanjotorres90 / ngx-material-intl-tel-input Goto Github PK

View Code? Open in Web Editor NEW
7.0 4.0 2.0 1.2 MB

Introducing an Angular library designed to streamline the input and validation of international telephone numbers.

Home Page: https://www.npmjs.com/package/ngx-material-intl-tel-input

License: MIT License

TypeScript 57.90% HTML 6.55% SCSS 9.00% JavaScript 0.09% CSS 26.46%
angular angular17 angularmaterial intl-tel-input material ngx phonenumber telephone validation angular18

ngx-material-intl-tel-input's Introduction

All Contributors

npm version npm downloads total npm downloads monthly

NgxMaterialIntlTelInput

https://github.com/juanjotorres90/ngx-material-intl-tel-input

Introducing an Angular library designed to streamline the input and validation of international telephone numbers. Integrates a searchable material select component for convenient country code selection. Moreover, it automatically detects the user's country, dynamically presenting a relevant placeholder for enhanced user experience. With built-in formatting and validation functionalities, this library ensures accuracy and consistency in handling telephone numbers across diverse global contexts.

Check out the Demo

preview

Compatibility:

Validation with google-libphonenumber

ngx-material-intl-tel-input Angular
18.0.0 - 18.0.1 >= 18.0.0
0.0.1 - 17.3.0 >= 17.2.0

Installation

$ npm install ngx-material-intl-tel-input --save

Ensure to include provideAnimations() and provideHttpClient() in the providers array of your main.ts file to initialize your application with animations and auto getting country code capabilities. Refer to the Angular Docs provideAnimations and provideHttpClient for detailed instructions.

Additionally, it's essential to incorporate an Angular Material theme by importing the necessary CSS for styling. Please consult the Angular Material Theming guide for instructions on how to set up the theme.

Usage

Import

Include the NgxMaterialIntlTelInputComponent in the imports array of the standalone component where you intend to utilize it.

imports: [NgxMaterialIntlTelInputComponent];

Example

<form [formGroup]="formGroup">
  <ngx-material-intl-tel-input [fieldControl]="control" [required]="true" [autoIpLookup]="false"> </ngx-material-intl-tel-input>
</form>

Options

Options Type Default Description
fieldControl FormControl FormControl('') Form control required to retrieve the value.
fieldControlName string '' Form control name to assign the control from a FormGroup.
required boolean false Telephone field input required.
disabled boolean false Telephone field input disabled.
autoIpLookup boolean true Sets initial country code based on user's ip.
autoSelectCountry boolean true Enables or disables auto selecting a country on initialization.
autoSelectedCountry CountryISO | string '' Sets the country to be auto selected.
numberValidation boolean true Enables or disables phone number validation.
enableSearch boolean true Enables or disables country search.
includeDialCode boolean false Includes the dial code in the phone number input.
preferredCountries (CountryISO | string)[] [] Shows the specified countries on top of the list.
visibleCountries (CountryISO | string)[] [] Shows only the specified countries.
excludedCountries (CountryISO | string)[] [] Exclude the specified countries from the list.
enablePlaceholder boolean true Input placeholder text for every country national number.
iconMakeCall boolean true Click on phone icon to trigger call action.
initialValue string '' Sets initial telephone number value
textLabels TextLabels {mainLabel: 'Phone number', codePlaceholder: 'Code', searchPlaceholderLabel: 'Search', noEntriesFoundLabel: 'No countries found', nationalNumberLabel: 'Number', hintLabel: 'Select country and type your phone number', invalidNumberError: 'Number is not valid', requiredError: 'This field is required'} Overrides all component text labels

Events

Event Type Default Description
currentValue string '' Emitted when the value of the input changes.

Contribute and develop locally

This workspace has been generated by Nx, Smart Monorepos · Fast CI.

Integrate with editors

Enhance your Nx experience by installing Nx Console for your favorite editor. Nx Console provides an interactive UI to view your projects, run tasks, generate code, and more! Available for VSCode, IntelliJ and comes with a LSP for Vim users.

Prepare dependencies

To start your development once you have cloned this project, you must execute:

  • Using Nodejs:

Node 20.13.1 is required.

npm install
  • Using pnpm:
pnpm install
  • Using bun:
curl -fsSL https://bun.sh/install | bash
bun install

Start the application

Run npx nx serve ngx-material-intl-tel-input to start the development server.

Happy coding! 💻🚀

Build for production

Run npx nx build ngx-material-intl-tel-input-lib to build the library. The build artifacts are stored in the output directory (e.g. dist/ or build/), ready to be deployed.

This project follows conventional commits specification.

Contributors

Thanks goes to these wonderful people:


Juanjo Torres

🎨 💻 📖 🤔 💬 🚇 💡 🚧 👀 ⚠️

Rafa Hernández

💻 🤔 💬 🚇 🚧 👀

This project follows the all-contributors specification. Contributions of any kind are welcome!

ngx-material-intl-tel-input's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

whegar grondig

ngx-material-intl-tel-input's Issues

HI can we remove phone icon

HI can we remove phone icon
<ngx-material-intl-tel-input
[preferredCountries]="['in', 'us', 'nz']"
[enablePlaceholder]="true"
[enableSearch]="true"
cssClass="country-selector"
(countryChanged)="changeCountry($event)"
[fieldControl]="phoneControl"
[initialValue]="''"
[textLabels]="textLabels"
>

Component ID generation collision

I get the following warning message, while retaining full functionality of the component:

NG0912: Component ID generation collision detected. Components '_MatFormField' and '_MatFormField2' with selector 'mat-form-field' generated the same component ID. To fix this, you can change the selector of one of those components or add an extra host attribute to force a different ID. Find more at https://angular.dev/errors/NG0912

Environment:
Angular CLI: 18.0.4
Node: 20.14.0
Package Manager: npm 10.7.0
OS: darwin x64
@angular-devkit/architect 0.1800.4
@angular-devkit/build-angular 18.0.4
@angular-devkit/core 18.0.4
@angular-devkit/schematics 18.0.4
@angular/cdk 17.3.10
@angular/cli 18.0.4
@angular/fire 18.0.1
@angular/material 17.3.10
@angular/ssr 18.0.4
@schematics/angular 18.0.4
rxjs 7.8.1
typescript 5.4.5
zone.js 0.14.4

NgxMaterialIntlTelInputComponent

how to use formControlName so that we can get value of phone no

this.addOrgGroupForm = this.fb.group({
id: [0],
email: ['', [Validators.required]],
phone: new FormControl(''),
});

submitForm() {
  console.log(this.addOrgGroupForm.value);
 }
 <form class="register-form m-4" [formGroup]="addOrgGroupForm" (ngSubmit)="submitForm()">
  <div class="row"> 
          <div class="col-xl-6 col-lg-6 col-md-12 col-sm-12 mb-2">
            <mat-form-field class="example-full-width mb-3" appearance="outline">
              <mat-label> Name</mat-label>
              <input matInput formControlName="name" required>
              @if (addOrgGroupForm.get('name')?.hasError('required')|| addOrgGroupForm.get('name')?.touched) {
                <mat-error >
                  {{displayErrMessage.required}}
                </mat-error>
                }
            </mat-form-field>
          </div>
          <div class="col-xl-6 col-lg-6 col-md-12 col-sm-12 mb-2">
           <ngx-material-intl-tel-input   > </ngx-material-intl-tel-input>
                  </div>
  </div>
 </form>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.