@lbgm/phone-input
Version:
An Angular phone input module
114 lines (113 loc) • 3.5 kB
TypeScript
import { AfterViewInit, ChangeDetectorRef, ElementRef, EventEmitter, OnChanges, OnInit, SimpleChanges } from '@angular/core';
import { T_Country } from './all-countries';
import { AbstractControl, FormGroup } from '@angular/forms';
import * as i0 from "@angular/core";
export { T_Country };
export declare type T_FormFieldControl = {
[key: string]: AbstractControl;
};
export interface PhoneDATA {
country?: string;
dialCode?: string | number;
nationalNumber?: string | number;
number?: string | number;
isValid?: boolean;
}
export declare enum FormControlEvent {
INVALID = "INVALID",
VALID = "VALID"
}
export declare class PhoneInputComponent implements OnInit, AfterViewInit, OnChanges {
el: ElementRef;
private cd;
value?: string;
label?: string;
hasError?: boolean;
hasSuccess?: boolean;
placeholder?: string;
name?: string;
required?: boolean;
defaultCountry?: string;
arrow?: boolean;
listHeight?: number;
allowed?: string[];
group?: FormGroup;
controls?: T_FormFieldControl;
basePhoneArrow?: ElementRef;
inputBase?: ElementRef;
arrowIcon?: ElementRef;
selectPhone?: ElementRef;
phoneEvent: EventEmitter<string>;
phoneData: EventEmitter<PhoneDATA>;
country: EventEmitter<string>;
countries: T_Country[];
openSelect: boolean;
defaultSelected: T_Country;
phone: string;
popupPos: string;
focus: boolean;
constructor(el: ElementRef, cd: ChangeDetectorRef);
/**
* TrackBy for *ngFor
* @param index
* @param item
* @returns
*/
trackByCountry(index: number, country: T_Country): number;
ngOnInit(): void;
ngOnChanges(changes: SimpleChanges): void;
ngDoCheck(): void;
ngAfterViewInit(): void;
/**
* used to send custom Event: usable in case of scroll turning off when popup is under
*/
cev_dash_select(): void;
/**
* filt allowedCountries from props
*/
get allowedCountries(): T_Country[];
get getGroup(): FormGroup;
get getName(): string;
get fieldError(): boolean;
get fieldSuccess(): boolean;
/**
* ToggleSelect
* to open countries list
*/
toggleSelect(): void;
/**
* formatPhoneInput
* used to format Phone Input
* @param val
*/
formatPhoneInput(val: string): T_Country;
/**
* emitPhone
* used to emit phone in internationalFormat
*/
emitPhone(): void;
/**
* emitPhoneData
* Used to emit phoneData as an object
* @returns {}
*/
emitPhoneData(event?: Event): void;
/**
* emitAll
* used to emit all event
*/
emitAll(): void;
/**
* to select any country
* @param country
*/
choose(country: T_Country): void;
/**
* bind on input
* @param event
*/
onPhoneInput(event: Event): void;
focusOn(event: Event): void;
static ɵfac: i0.ɵɵFactoryDeclaration<PhoneInputComponent, never>;
static ɵcmp: i0.ɵɵComponentDeclaration<PhoneInputComponent, "lbgm-phone-input", never, { "value": "value"; "label": "label"; "hasError": "hasError"; "hasSuccess": "hasSuccess"; "placeholder": "placeholder"; "name": "name"; "required": "required"; "defaultCountry": "defaultCountry"; "arrow": "arrow"; "listHeight": "listHeight"; "allowed": "allowed"; "group": "group"; "controls": "controls"; }, { "phoneEvent": "phoneEvent"; "phoneData": "phoneData"; "country": "country"; }, never, ["[arrow]", "[slot]"]>;
}