Skip to content

Commit

Permalink
Merge pull request #286 from pasevin/master
Browse files Browse the repository at this point in the history
v 2.4.0 [id] name change and support for Angular 9
  • Loading branch information
pasevin authored Jun 8, 2020
2 parents 59d8ad3 + 6addf2d commit 986b6ee
Show file tree
Hide file tree
Showing 22 changed files with 17,717 additions and 12,973 deletions.
5 changes: 3 additions & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# Editor configuration, see https://editorconfig.org
# Editor configuration, see http://editorconfig.org
root = true

[*]
charset = utf-8
indent_style = space
indent_style = tab
indent_size = 2
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

Expand Down
6 changes: 6 additions & 0 deletions .jsbeautifyrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"indent_inner_html": true,
"indent_with_tabs": true,
"tab_size": 2,
"wrap_attributes": "force"
}
108 changes: 52 additions & 56 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# International Telephone Input for Angular (NgxIntlTelInput)

[![All Contributors](https://img.shields.io/badge/all_contributors-4-orange.svg?style=flat-square)](#contributors)

[![Build Status](https://travis-ci.org/webcat12345/ngx-intl-tel-input.svg?branch=master)](https://travis-ci.org/webcat12345/ngx-intl-tel-input) [![npm version](https://badge.fury.io/js/ngx-intl-tel-input.svg)](https://badge.fury.io/js/ngx-intl-tel-input) [![npm](https://img.shields.io/npm/dm/localeval.svg)](https://www.npmjs.com/package/ngx-intl-tel-input)
Expand All @@ -18,17 +19,17 @@ An Angular package for entering and validating international telephone numbers.

### Install Dependencies

```$ npm install [email protected] --save```
`$ npm install [email protected] --save`

```$ npm install google-libphonenumber --save```
`$ npm install google-libphonenumber --save`

```$ ng add ngx-bootstrap```
`$ ng add ngx-bootstrap`

### Add Dependency Style

Add *'intl-tel-input'* style file:
Add _'intl-tel-input'_ style file:

```./node_modules/intl-tel-input/build/css/intlTelInput.css```
`./node_modules/intl-tel-input/build/css/intlTelInput.css`

to **angular.json** styles array:

Expand All @@ -45,21 +46,16 @@ to **angular.json** styles array:

### Install This Library

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

## Usage

### Import

Add ```BsDropDownModule``` and ```NgxIntlTelInputModule``` to your module file:
Add `BsDropDownModule` and `NgxIntlTelInputModule` to your module file:

```javascript

imports: [
BsDropdownModule.forRoot(),
NgxIntlTelInputModule,
]

imports: [BsDropdownModule.forRoot(), NgxIntlTelInputModule];
```

## Example
Expand All @@ -69,78 +65,78 @@ Refer to main app in this repository for working example.
Or this [Stackblitz Demo](https://stackblitz.com/edit/ngx-intl-tel-input-demo).

```html

<form #f="ngForm" [formGroup]="phoneForm">
<ngx-intl-tel-input
[cssClass]="'custom'"
[preferredCountries]="[CountryISO.UnitedStates, CountryISO.UnitedKingdom]"
[enableAutoCountrySelect]="false"
[enablePlaceholder]="true"
[searchCountryFlag]="true"
[searchCountryField]="[SearchCountryField.Iso2, SearchCountryField.Name]"
[selectFirstCountry]="false"
[selectedCountryISO]="CountryISO.India"
[maxLength]="15"
[tooltipField]="TooltipLabel.Name"
[phoneValidation]="true"
[id]="my-input-id"
name="phone"
formControlName="phone"></ngx-intl-tel-input>
</form>

<ngx-intl-tel-input
[cssClass]="'custom'"
[preferredCountries]="[CountryISO.UnitedStates, CountryISO.UnitedKingdom]"
[enableAutoCountrySelect]="false"
[enablePlaceholder]="true"
[searchCountryFlag]="true"
[searchCountryField]="[SearchCountryField.Iso2, SearchCountryField.Name]"
[selectFirstCountry]="false"
[selectedCountryISO]="CountryISO.India"
[maxLength]="15"
[tooltipField]="TooltipLabel.Name"
[phoneValidation]="true"
[inputId]="my-input-id"
name="phone"
formControlName="phone"
></ngx-intl-tel-input>
</form>
```

## Options

| Options | Type | Default | Description |
| ------------------------------|------------------------|--------------------|-------------------------------------------------------------------------------------|
| cssClass | ```string``` | ```control-form``` | Bootstrap input css class or your own custom one. |
| preferredCountries | ```<CountryISO>[]``` | ```[]``` | List of countries, which will appear at the top. |
| onlyCountries | ```<CountryISO>[]``` | ```[]``` | List of manually selected countries, which will appear in the dropdown. |
| enableAutoCountrySelect | ```boolean``` | ```false``` | Toggle automatic country (flag) selection based on user input. |
| enablePlaceholder | ```boolean``` | ```true``` | Input placeholder text, which addapts to the country selected. |
| searchCountryFlag | ```boolean``` | ```false``` | Enables input search box for countries in the flag dropdown. |
| searchCountryField | ```<SearchCountryField>[]``` | ```[SearchCountryField.All]``` | Customize which fields to search in, if ```searchCountryFlag``` is enabled. Use ```SearchCountryField``` helper enum. |
| searchCountryPlaceholder | ```string``` | ```'Search Country'``` | Placeholder value for ```searchCountryField``` |
| maxLength | ```number``` | ```None``` | Add character limit.|
| tooltipField | ```<TooltipLabel>``` | ```None``` | Set tooltip on flag hover. Use ```TooltipLabel``` helper enum for label type options. |
| selectFirstCountry | ```boolean``` | ```true``` | Selects first country from ```preferredCountries``` if is set. If not then uses main list. |
| phoneValidation | ```boolean``` | ```true``` | Disable phone validation. |
| id | ```string``` | ```phone``` | Unique ID for input. |
| selectedCountryISO | ```<CountryISO>``` | ```None```| Set specific country on load. |
| separateDialCode | ```boolean``` | ```false``` | Visually separate dialcode into the drop down element. |
| countryChange | ```<Country>``` | ```None``` | Emits country value when the user selects a country from the dropdown. |
| Options | Type | Default | Description |
| ------------------------ | ------------------------ | -------------------------- | ------------------------------------------------------------------------------------------------------------- |
| cssClass | `string` | `control-form` | Bootstrap input css class or your own custom one. |
| preferredCountries | `<CountryISO>[]` | `[]` | List of countries, which will appear at the top. |
| onlyCountries | `<CountryISO>[]` | `[]` | List of manually selected countries, which will appear in the dropdown. |
| enableAutoCountrySelect | `boolean` | `false` | Toggle automatic country (flag) selection based on user input. |
| enablePlaceholder | `boolean` | `true` | Input placeholder text, which addapts to the country selected. |
| searchCountryFlag | `boolean` | `false` | Enables input search box for countries in the flag dropdown. |
| searchCountryField | `<SearchCountryField>[]` | `[SearchCountryField.All]` | Customize which fields to search in, if `searchCountryFlag` is enabled. Use `SearchCountryField` helper enum. |
| searchCountryPlaceholder | `string` | `'Search Country'` | Placeholder value for `searchCountryField` |
| maxLength | `number` | `None` | Add character limit. |
| tooltipField | `<TooltipLabel>` | `None` | Set tooltip on flag hover. Use `TooltipLabel` helper enum for label type options. |
| selectFirstCountry | `boolean` | `true` | Selects first country from `preferredCountries` if is set. If not then uses main list. |
| phoneValidation | `boolean` | `true` | Disable phone validation. |
| inputId | `string` | `phone` | Unique ID for `<input>` element. |
| selectedCountryISO | `<CountryISO>` | `None` | Set specific country on load. |
| separateDialCode | `boolean` | `false` | Visually separate dialcode into the drop down element. |
| countryChange | `<Country>` | `None` | Emits country value when the user selects a country from the dropdown. |

## Supported Formats

Following formats are supported

- NATIONAL // Produces "044 668 18 00"
- INTERNATIONAL // Produces "+41 44 668 18 00"
- E164 // Produces "+41446681800"

## Library Contributions

- Fork repo.
- Update ```./projects/ngx-intl-tel-input```
- Update `./projects/ngx-intl-tel-input`
- Build / test library.
- Update ```./src/app``` with new functionality.
- Update `./src/app` 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```
- 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 localy

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

In your project run:

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

## Contributors

Expand Down
12 changes: 11 additions & 1 deletion angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"aot": true,
"outputPath": "dist/ngx-intl-tel-input-app",
"index": "src/index.html",
"main": "src/main.ts",
Expand Down Expand Up @@ -52,6 +53,10 @@
"type": "initial",
"maximumWarning": "2mb",
"maximumError": "5mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "6kb"
}
]
}
Expand Down Expand Up @@ -148,7 +153,12 @@
"tsConfig": "projects/ngx-intl-tel-input/tsconfig.lib.json",
"project": "projects/ngx-intl-tel-input/ng-package.json"
}
},
, "configurations": {
"production": {
"tsConfig": "projects/ngx-intl-tel-input/tsconfig.lib.prod.json"
}
}
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
Expand Down
Loading

0 comments on commit 986b6ee

Please sign in to comment.