import { Maybe } from 'yummies/types'; import { parser } from 'yummies/parser'; /** * Placeholder shown when a formatter cannot produce a meaningful value. * * @example * ```ts * const fallback = NO_VALUE; * ``` * * @example * ```ts * format.number(null, { emptyText: NO_VALUE }); * ``` */ declare const NO_VALUE = "\u2013"; /** * Plain ASCII hyphen character. * * @example * ```ts * const separator = HYPHEN; * ``` * * @example * ```ts * `foo${HYPHEN}bar`; * ``` */ declare const HYPHEN = "-"; /** * Infinity symbol used by numeric formatters and UI output. * * @example * ```ts * const label = INFINITY; * ``` * * @example * ```ts * `${INFINITY} items`; * ``` */ declare const INFINITY = "\u221E"; interface NumberFormatSettings { delimiter?: string; /** * digitsOnlyForFloat - Show digits after decimal point only if they are not zeros after converting to number. * Example: "0.00" -> "0", "0.10" -> "0.1", but "0.003" -> "0.003" * * @default true */ digitsOnlyForFloat?: boolean; /** * Text which will be returned if the value is undefined, null, NaN, Infinity or empty string. * Example: "–" will be returned if the value is undefined and emptyText is "–". */ emptyText?: string; /** * Text to append to the end of the formatted number. * Example: if value is 1000 and postfix is "₽", result will be "1 000₽". */ postfix?: string; /** * Fixed number of digits after the decimal point (number.toFixed() method) * If set to false, the truncation is ignored! */ digits?: number | false; /** * Remove trailing zeros from the end of the number * Example: 0.010000000000000000000000000000000000000000000 -> 0.01 */ cutZeros?: boolean; cropDigitsOnly?: boolean; } /** * Formats a numeric value with thousands separators, fractional digit control * and optional postfix text. * * Invalid, empty or unsupported values fall back to `emptyText`. * * @param rawValue Number or numeric string to format. * @param userSettings Formatting overrides merged with `number.defaultSettings`. * @returns Formatted number string or fallback text. * * @example * ```ts * number(12000); // '12 000' * ``` * * @example * ```ts * number(12.5, { digits: 1, postfix: '%' }); // '12.5%' * ``` */ declare const number: { (rawValue: Maybe, userSettings?: Maybe): string; defaultSettings: NumberFormatSettings; }; interface PercentFormatSettings extends Omit { divider?: string; delimiter?: string; symbol?: string; emptyText?: string; } /** * Formats a value as a percent string with configurable decimal precision, * decimal divider and suffix symbol. * * @param value Number or numeric string to format. * @param settings Parser and formatting options. * @returns Formatted percent string or fallback text for invalid values. * * @example * ```ts * percent(12.345); // '12.35%' * ``` * * @example * ```ts * percent(12.345, { divider: ',', symbol: ' pct' }); // '12,35 pct' * ``` */ declare const percent: (value: Maybe, settings?: PercentFormatSettings) => string; /** * Removes all whitespace characters from a string. * * @param value Source string. * @returns String without spaces, tabs and line breaks. * * @example * ```ts * skipSpaces('1 000 000'); // '1000000' * ``` * * @example * ```ts * skipSpaces('a\tb\nc'); // 'abc' * ``` */ declare const skipSpaces: (value: string) => string; /** * ---header-docs-section--- * # yummies/format * * ## Description * * Namespace-style **number, percent, and string** formatting for UI tables, inputs, and charts. * Submodules cover locale-aware numbers, percent parsing/formatting, trimming helpers, and shared * constants so presentation rules stay centralized and tree-shakable behind the package * aggregated **format** export from this entry point. * * ## Usage * * ```ts * import { format } from "yummies/format"; * ``` */ declare const _exports_HYPHEN: typeof HYPHEN; declare const _exports_INFINITY: typeof INFINITY; declare const _exports_NO_VALUE: typeof NO_VALUE; type _exports_NumberFormatSettings = NumberFormatSettings; type _exports_PercentFormatSettings = PercentFormatSettings; declare const _exports_number: typeof number; declare const _exports_percent: typeof percent; declare const _exports_skipSpaces: typeof skipSpaces; declare namespace _exports { export { _exports_HYPHEN as HYPHEN, _exports_INFINITY as INFINITY, _exports_NO_VALUE as NO_VALUE, _exports_number as number, _exports_percent as percent, _exports_skipSpaces as skipSpaces }; export type { _exports_NumberFormatSettings as NumberFormatSettings, _exports_PercentFormatSettings as PercentFormatSettings }; } export { _exports as format };