UNPKG

@i18n-components/input-number

Version:

Web component to format input number based on locale

131 lines (130 loc) 3.19 kB
/** * Class Declaration for InputNumber Webcomponent */ export declare class InputNumber extends HTMLInputElement { /** * HTML tag declaration * @returns string */ static get tag(): string; /** * observe locale and decimaldigits attributes to re-render * @returns Array */ static get observedAttributes(): Array<string>; intl: Intl.NumberFormat; numRegx: RegExp; inputValue: string; /** * Constrctor */ constructor(); /** * get number regex with thosand and decimal separator based on locale * @param {boolean} invertMatch=false * @returns RegExp */ getNumRegx(invertMatch?: boolean, locale?: string): RegExp; /** * current locale * @returns string */ get locale(): string; /** * formatted input value * @returns string */ getFormattedValue({ locale, value, }?: { locale?: string | undefined; value?: string | undefined; }): string; /** * @returns string */ get formattedValue(): string; /** * Number of fraction digits allowed * @returns number */ get fractionDigits(): number; /** * decimal separator for current locale * @returns string */ getDecimalSeparator(locale?: string): string; /** * thousand separator for current locale * @returns string */ getThousandSeparator(locale?: string): string; /** * detect if current input key is valid or not based on locale * @param {string=this.locale} locale * @returns boolean */ isValidInput({ value, locale }?: { value?: string | undefined; locale?: string | undefined; }): boolean; /** * current numeric value * @returns number */ getNumericValue({ locale, value, }?: { locale?: string | undefined; value?: string | undefined; }): number; /** * @returns number */ get numericValue(): number; /** * initialize the Intl.NumberFormat * @returns void */ initializeIntl(): Intl.NumberFormat; /** * Attach events after elements being attached to DOM * @returns void */ connectedCallback(): void; /** * @param {string} name * @param {string} oldValue * @param {string} newValue * @returns void */ attributeChangedCallback(name: string, oldValue: string, newValue: string): void; /** * set the curser at specific position * @param {number} pos * @returns void */ updateCaretPosition(pos: number): void; /** * Attach Events after initialization * @returns void */ attachEvents(): void; /** * @returns void */ onFocus(): void; /** * onchange and onInput event listener callback * @returns void */ onChange(): void; /** * onKeydown event listner callback * @param {KeyboardEvent} e * @returns void */ onKeydown(e: KeyboardEvent): void; /** * * @param {boolean} isBackspace=false * @returns void */ correctCaretPosition(isBackspace?: boolean): void; }