-
-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bump to support intl tel input 21 #54
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,6 +43,7 @@ describe('IntlTelInputComponent', () => { | |
|
||
it('should convert phone number to E164 format', () => { | ||
component.options = { | ||
initialCountry: 'ch', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I suppose we can't do better, uh |
||
preferredCountries: ['ch'], | ||
onlyCountries: ['ch', 'fr'] | ||
}; | ||
|
@@ -55,6 +56,7 @@ describe('IntlTelInputComponent', () => { | |
|
||
it('should re-set E164 phone number on countryChange', () => { | ||
component.options = { | ||
initialCountry: 'ch', | ||
preferredCountries: ['ch'], | ||
onlyCountries: ['ch', 'fr'] | ||
}; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With v21.0.6, tsconfig.json needs to be changed, like this "paths": {
"intl-tel-input": [
"node_modules/intl-tel-input/build/js/intlTelInput"
]
}, and old path must be removed "paths": {
"intl-tel-input": [
"src/lib/@types/intl-tel-input"
]
} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is an error from upstream, will open a PR for discussion. We shouldn't need that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 21.0.8+ fixes this, so not needed (old path must still be cleaned up). You may |
||
|
||
@Component({ | ||
selector: 'intl-tel-input', | ||
|
@@ -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; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should go in a dedicated commit, and tests should be added.Also, I think that it should be |
||
|
||
@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; | ||
} | ||
|
||
|
@@ -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); | ||
|
This file was deleted.
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please reindent and set to
true
as we'll switch tofalse
by default