@dnb/eufemia
Version:
DNB Eufemia Design System UI Library
46 lines (45 loc) • 2.1 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(args: {
number: NumberFormatValue;
locale?: string | null;
options?: InternalNumberFormatOptions | null;
}): FormatPartItem[];
export type FormatNumberCoreResult = {
number: string;
parts: 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;
export declare function prepareMinusParts(display: string, parts: FormatPartItem[] | undefined, locale: string | null): FormatNumberCoreResult;
/**
* 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` API.
*/
export declare const formatNumberCore: (number: NumberFormatValue, locale: string | null, options?: InternalNumberFormatOptions, formatter?: PartFormatter | null) => string;
export declare const formatNumberCoreParts: (number: NumberFormatValue, locale: string | null, options?: InternalNumberFormatOptions, formatter?: PartFormatter | null) => FormatNumberCoreResult;