UNPKG

ngx-payment-inputs

Version:

A set of Angular Directives to validate and format credit card inputs.

70 lines (69 loc) 2.4 kB
import { ElementRef, OnDestroy, OnInit, Renderer2 } from '@angular/core'; import { AbstractControl, ControlValueAccessor, NgControl } from '@angular/forms'; import { CardTypeService } from '../services/card-type.service'; /** * Directive to format and validate a card expiry date */ export declare class CardExpireDateDirective implements ControlValueAccessor, OnInit, OnDestroy { private _renderer; private _elementRef; private _ngControl; private _cardTypeService; onChange?: (event: any) => void; onTouched?: (event: any) => void; private _rendererTimeout; constructor(_renderer: Renderer2, _elementRef: ElementRef<HTMLInputElement>, _ngControl: NgControl, _cardTypeService: CardTypeService); ngOnInit(): void; ngOnDestroy(): void; /** * get the current html input from element ref * @returns The native element from ref * @private */ get _el(): HTMLInputElement; /** * get the control of the current element ref * @returns return the control of element * @private */ get _control(): AbstractControl; /** * listener the input event from html input element * @param event - the keyboard event */ onCardChanges(event: KeyboardEvent): void; /** * listener the input blur event to update input mask * @param event - the keyboard event */ onCardBlur(event: KeyboardEvent): void; /** * Listener the keydown to check when backspace is pressed * @param event {KeyboardEvent} - The keyboard event */ onKeyDown(event: KeyboardEvent): void; /** * Writes a new value to the element. * @param rawValue - value from input */ writeValue(rawValue: KeyboardEvent): void; /** * Registers a callback function that is called when the control's value changes in the UI. * @param onChange - {fn} */ registerOnChange(onChange: any): void; /** * Registers a callback function that is called by the forms API on initialization to update the form model on blur. * @param onTouched - {fn} */ registerOnTouched(onTouched: any): void; /** * set element ref as disabled * @param isDisabled - set element as disabled */ setDisabledState?(isDisabled: boolean): void; /** * setup input with some attrs for better user experience */ private _setupInput; }