Skip to content

Commit

Permalink
Merge 9c549d8 into ce3e8b5
Browse files Browse the repository at this point in the history
  • Loading branch information
tlebreton committed Apr 5, 2024
2 parents ce3e8b5 + 9c549d8 commit 9cc1d5a
Show file tree
Hide file tree
Showing 9 changed files with 311 additions and 545 deletions.
2 changes: 2 additions & 0 deletions README.md
Expand Up @@ -41,6 +41,7 @@ $ npm install intl-tel-input-ng --save / yarn add intl-tel-input-ng
- `labelCssClass`: The CSS class used to style the label associated to the input.
- `required`: Sets the `required` && `aria-required` attributes for the input.
- `[(E164PhoneNumber)]`: Outputs the phone number in E164 format if valid.
- `isMobileOnly`: (true by default) Allow `intl-tel-input` to check the number as a mobile number or not [isMobileOnly](https://github.com/jackocnr/intl-tel-input/issues/1535)

See the [intl-tel-input repository](https://github.com/jackocnr/intl-tel-input) for more documentation.

Expand All @@ -60,6 +61,7 @@ See the [intl-tel-input repository](https://github.com/jackocnr/intl-tel-input)
i18n: { ch: 'Suisse' },
onlyCountries: ['fr', 'ch']
}"
[isMobileOnly]=false
[(E164PhoneNumber)]="E164PhoneNumber"></intl-tel-input>
</form>
```
648 changes: 295 additions & 353 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -36,7 +36,7 @@
"@angular/common": "^17.0.0",
"@angular/core": "^17.0.0",
"@angular/forms": "^17.0.0",
"intl-tel-input": "^19.0.0"
"intl-tel-input": "^21.0.0"
},
"devDependencies": {
"@angular-devkit/build-angular": "^17.0.0",
Expand All @@ -59,7 +59,7 @@
"@typescript-eslint/parser": "6.10.0",
"eslint": "^8.53.0",
"eslint-plugin-rxjs": "^5.0.2",
"intl-tel-input": "^19.0.0",
"intl-tel-input": "^21.0.0",
"jasmine-core": "~5.1.0",
"karma": "~6.4.0",
"karma-chrome-launcher": "~3.2.0",
Expand Down
1 change: 0 additions & 1 deletion src/lib/@types/intl-tel-input/index.d.ts

This file was deleted.

2 changes: 2 additions & 0 deletions src/lib/components/intl-tel-input.component.spec.ts
Expand Up @@ -43,6 +43,7 @@ describe('IntlTelInputComponent', () => {

it('should convert phone number to E164 format', () => {
component.options = {
initialCountry: 'ch',
preferredCountries: ['ch'],
onlyCountries: ['ch', 'fr']
};
Expand All @@ -55,6 +56,7 @@ describe('IntlTelInputComponent', () => {

it('should re-set E164 phone number on countryChange', () => {
component.options = {
initialCountry: 'ch',
preferredCountries: ['ch'],
onlyCountries: ['ch', 'fr']
};
Expand Down
19 changes: 10 additions & 9 deletions src/lib/components/intl-tel-input.component.ts
Expand Up @@ -9,9 +9,7 @@

import { AfterViewInit, Component, ElementRef, EventEmitter, Input, Output, ViewChild } from '@angular/core';
import { ControlContainer, NgForm } from '@angular/forms';
import intlTelInput from 'intl-tel-input';
import { IntlTelInputOptions } from '../model/intl-tel-input-options';
import { IntlTelInput } from "../model/intl-tel-input";
import intlTelInput, {Iti, SomeOptions} from 'intl-tel-input';

@Component({
selector: 'intl-tel-input',
Expand All @@ -26,19 +24,22 @@ export class IntlTelInputComponent implements AfterViewInit {
@Input() label!: string;
@Input() labelCssClass!: string;
@Input() name = 'intl-tel-input-name';
@Input() options: IntlTelInputOptions = {};
@Input() options: SomeOptions = {};
@Input() required!: boolean;
@Input() isMobileOnly: boolean = true;

@Output() private E164PhoneNumberChange = new EventEmitter<string | null>();

@ViewChild('intlTelInput') private _inputElement!: ElementRef;

private _phoneNumber!: string;
private _intlTelInput!: IntlTelInput;
private _intlTelInput!: Iti;

ngAfterViewInit(): void {
const intlTelInputInstance = intlTelInput;
this._intlTelInput = intlTelInputInstance(this._inputElement.nativeElement, this.options);
this._intlTelInput = intlTelInput(this._inputElement.nativeElement, this.options);
}

get intlTelInput(): IntlTelInput {
get intlTelInput(): Iti {
return this._intlTelInput;
}

Expand All @@ -56,7 +57,7 @@ export class IntlTelInputComponent implements AfterViewInit {

i18nizePhoneNumber(): void {
this.E164PhoneNumber = null;
if (this._intlTelInput.isValidNumber()) {
if (this._intlTelInput.isValidNumber(this.isMobileOnly)) {
this.E164PhoneNumber = this._intlTelInput.getNumber();
}
this.E164PhoneNumberChange.emit(this.E164PhoneNumber);
Expand Down
169 changes: 0 additions & 169 deletions src/lib/model/intl-tel-input-options.ts

This file was deleted.

9 changes: 0 additions & 9 deletions src/lib/model/intl-tel-input.ts

This file was deleted.

2 changes: 0 additions & 2 deletions src/public_api.ts
Expand Up @@ -3,6 +3,4 @@
*/

export * from './lib/components/intl-tel-input.component';
export * from './lib/model/intl-tel-input-options';
export * from './lib/model/intl-tel-input';
export * from './lib/intl-tel-input-ng.module';

0 comments on commit 9cc1d5a

Please sign in to comment.