@dnb/eufemia
Version:
DNB Eufemia Design System UI Library
40 lines (39 loc) • 1.73 kB
TypeScript
/**
* Core number formatting helpers used by all NumberFormat variants.
*/
import type { NumberFormatValue, FormatPartItem, PartFormatter, InternalNumberFormatOptions } from './types';
/**
* For internal usage.
* Returns an array that contains all the parts of the given number
* `[{ value, type }]`.
*/
export declare function formatToParts({ number, locale, options, }: {
number: NumberFormatValue;
locale?: string | null;
options?: InternalNumberFormatOptions | null;
}): FormatPartItem[];
/**
* Aligns the currency symbol in the output based on the currency display option.
* "norske kroner" ("Norwegian kroner") will be changed to "kroner" if the
* currency display option is set to "name".
*/
export declare function alignCurrencySymbol(output: string | number, currencyDisplay: string | boolean | null | undefined): string;
/**
* When e.g. a currency number is given with a minus,
* this function transforms the minus to be moved before the number
* instead of the symbol.
*
* It only cleans if locale is Norwegian.
* Form `-NOK 1 234` to `NOK -1 234`.
*/
export declare const prepareMinus: (display: string, locale: string | null) => string;
/**
* Enhance VoiceOver support on mobile devices.
* Numbers under 99.999 are read out correctly, but only if we remove the spaces.
*/
export declare const enhanceSR: (value: NumberFormatValue, aria: string, locale: string | null) => string;
/**
* The main number formatter function.
* Calls the browser/Node.js `Intl.NumberFormat` or `Number.toLocaleString` APIs.
*/
export declare const formatNumberCore: (number: NumberFormatValue, locale: string | null, options?: InternalNumberFormatOptions, formatter?: PartFormatter | null) => string;