UNPKG

@esri/calcite-components

Version:

Web Components for Esri's Calcite Design System.

46 lines (45 loc) 2.21 kB
import { NumberStringFormat } from './locale'; export declare class BigDecimal { value: bigint; isNegative: boolean; static DECIMALS: number; static ROUNDED: boolean; static SHIFT: bigint; constructor(input: string | BigDecimal); static _divRound: (dividend: bigint, divisor: bigint) => BigDecimal; static fromBigInt: (bigint: bigint) => BigDecimal; getIntegersAndDecimals(): { integers: string; decimals: string; }; toString(): string; formatToParts(formatter: NumberStringFormat): Intl.NumberFormatPart[]; format(formatter: NumberStringFormat): string; add(n: string): BigDecimal; subtract(n: string): BigDecimal; multiply(n: string): BigDecimal; divide(n: string): BigDecimal; } export declare function isValidNumber(numberString: string): boolean; export declare function parseNumberString(numberString?: string): string; export declare const sanitizeNumberString: (numberString: string) => string; export declare function getBigDecimalAsString(sanitizedValue: string): string; export declare function sanitizeExponentialNumberString(numberString: string, func: (s: string) => string): string; /** * Converts an exponential notation numberString into decimal notation. * BigInt doesn't support exponential notation, so this is required to maintain precision * * @param {string} numberString - pre-validated exponential or decimal number * @returns {string} numberString in decimal notation */ export declare function expandExponentialNumberString(numberString: string): string; /** * Adds localized trailing decimals zero values to the number string. * BigInt conversion to string removes the trailing decimal zero values (Ex: 1.000 is returned as 1). This method helps adding them back. * * @param {string} localizedValue - localized number string value * @param {string} value - current value in the input field * @param {NumberStringFormat} formatter - numberStringFormatter instance to localize the number value * @returns {string} localized number string value */ export declare function addLocalizedTrailingDecimalZeros(localizedValue: string, value: string, formatter: NumberStringFormat): string;