UNPKG

@uiowa/digit-only

Version:

This package includes two Angular directives. The digitOnly directive only allows numbers in the input box when typing, pasting or drag/dropping. The mask directive checks the input pattern attribute.

35 lines (34 loc) 1.64 kB
import { ElementRef, OnChanges, SimpleChanges } from '@angular/core'; import * as i0 from "@angular/core"; export declare class DigitOnlyDirective implements OnChanges { el: ElementRef; private hasDecimalPoint; private hasNegativeSign; private navigationKeys; decimal: boolean; decimalSeparator: string; allowNegatives: boolean; allowPaste: boolean; negativeSign: string; min: number; max: number; pattern?: string | RegExp; private regex; inputElement: HTMLInputElement; constructor(el: ElementRef); ngOnChanges(changes: SimpleChanges): void; onBeforeInput(e: InputEvent): any; onKeyDown(e: KeyboardEvent): any; onPaste(event: any): void; onDrop(event: DragEvent): void; private pasteData; private insertAtCursor; private triggerEvent; private sanitizeInput; private getNegativeSignRegExp; private isValidDecimal; private getSelection; private forecastValue; static ɵfac: i0.ɵɵFactoryDeclaration<DigitOnlyDirective, never>; static ɵdir: i0.ɵɵDirectiveDeclaration<DigitOnlyDirective, "[digitOnly]", never, { "decimal": { "alias": "decimal"; "required": false; }; "decimalSeparator": { "alias": "decimalSeparator"; "required": false; }; "allowNegatives": { "alias": "allowNegatives"; "required": false; }; "allowPaste": { "alias": "allowPaste"; "required": false; }; "negativeSign": { "alias": "negativeSign"; "required": false; }; "min": { "alias": "min"; "required": false; }; "max": { "alias": "max"; "required": false; }; "pattern": { "alias": "pattern"; "required": false; }; }, {}, never, never, true, never>; }