angular-cc-library
Version:
angular credit card library
104 lines (96 loc) • 4 kB
TypeScript
import { AbstractControl, ValidationErrors } from '@angular/forms';
import { BehaviorSubject } from 'rxjs';
import * as i0 from '@angular/core';
declare class CreditCardValidators {
static validateCCNumber(control: AbstractControl): ValidationErrors | null;
static validateExpDate(control: AbstractControl): ValidationErrors | null;
}
interface CardDefinition {
type: string;
patterns: number[];
format: RegExp;
length: number[];
cvvLength: number[];
luhn: boolean;
}
declare class CreditCard {
static cards(): CardDefinition[];
static cardFromNumber(num: string): CardDefinition;
static restrictNumeric(e: KeyboardEvent): boolean;
static hasTextSelected(target: HTMLInputElement): boolean;
static cardType(num: string): string;
static formatCardNumber(num: string): string;
static safeVal(value: string, target: HTMLInputElement, updateValue: (value: string) => void): number;
static isCardNumber(key: number, target: HTMLInputElement): boolean;
static restrictExpiry(key: number, target: HTMLInputElement): boolean;
static replaceFullWidthChars(str: string): string;
static formatExpiry(expiry: string): string;
static restrictCvc(key: number, target: HTMLInputElement): boolean;
static luhnCheck(num: string): boolean;
}
declare class CreditCardFormatDirective {
private el;
private target;
private control;
private cards;
resolvedScheme$: BehaviorSubject<string>;
/**
* Updates the value to target element, or FormControl if exists.
* @param value New input value.
*/
private updateValue;
onKeypress(e: KeyboardEvent): void;
onKeydown(e: KeyboardEvent): void;
onKeyup(): void;
onPaste(): void;
onChange(): void;
onInput(): void;
private formatCardNumber;
private formatBackCardNumber;
private setCardType;
private reFormatCardNumber;
static ɵfac: i0.ɵɵFactoryDeclaration<CreditCardFormatDirective, never>;
static ɵdir: i0.ɵɵDirectiveDeclaration<CreditCardFormatDirective, "[ccNumber]", ["ccNumber"], {}, {}, never, never, true, never>;
}
declare class CvcFormatDirective {
private el;
private target;
private control;
/**
* Updates the value to target element, or FormControl if exists.
* @param value New input value.
*/
private updateValue;
onKeypress(e: KeyboardEvent): void;
reformatCvc(): void;
static ɵfac: i0.ɵɵFactoryDeclaration<CvcFormatDirective, never>;
static ɵdir: i0.ɵɵDirectiveDeclaration<CvcFormatDirective, "[ccCVC]", never, {}, {}, never, never, true, never>;
}
declare class ExpiryFormatDirective {
private el;
private target;
private control;
/**
* Updates the value to target element, or FormControl if exists.
* @param value New input value.
*/
private updateValue;
onKeypress(e: KeyboardEvent): boolean;
onKeydown(e: KeyboardEvent): void;
onChange(): void;
onInput(): void;
private formatExpiry;
private formatForwardSlashAndSpace;
private formatForwardExpiry;
private formatBackExpiry;
private reformatExpiry;
static ɵfac: i0.ɵɵFactoryDeclaration<ExpiryFormatDirective, never>;
static ɵdir: i0.ɵɵDirectiveDeclaration<ExpiryFormatDirective, "[ccExp]", never, {}, {}, never, never, true, never>;
}
declare class CreditCardDirectivesModule {
static ɵfac: i0.ɵɵFactoryDeclaration<CreditCardDirectivesModule, never>;
static ɵmod: i0.ɵɵNgModuleDeclaration<CreditCardDirectivesModule, never, [typeof CreditCardFormatDirective, typeof ExpiryFormatDirective, typeof CvcFormatDirective], [typeof CreditCardFormatDirective, typeof ExpiryFormatDirective, typeof CvcFormatDirective]>;
static ɵinj: i0.ɵɵInjectorDeclaration<CreditCardDirectivesModule>;
}
export { CreditCard, CreditCardDirectivesModule, CreditCardFormatDirective, CreditCardValidators, CvcFormatDirective, ExpiryFormatDirective };
export type { CardDefinition };