import { NumberFormatSection } from './number_format_section'; import type { TextPart, Complex, DimensionedQuantity, CellValue } from '../../treb-base-types/src/index'; /** convert cell value -> date, using the rules above */ export declare const LotusDate: (value: number) => Date; /** convert date (as number, utc millis) -> lotus date value */ export declare const UnlotusDate: (value: number, local?: boolean) => number; /** * unifying date format and number format (really just bolting dates * on the side). dates have only a single section, constant pattern, and * are immutable. */ export declare class NumberFormat { static grouping_regexp: RegExp; static fraction_limits: number[]; /** * this is now exposed so it can be changed, for rendering; some options are * * "i" - regular i, and the default * "𝑖" - mathematical italic small i", U+1D456 * " 𝑖" - the same, with a leading hair space (U+200A) */ static imaginary_character: string; /** * also for complex rendering, the minus sign. there's a unicode * symbol U+2212 which (at least in calibri) is wider than the regular minus * sign/hyphen. I like this but it looks a bit odd if negative numbers are * rendered using the other one. * * "-" - hyphen * "−" - minus */ static minus_character: string; /** * (testing) transformer. this is not rendered or persisted, like magic * decimal it needs to be applied in code. ATM this is only applied in * formatting DQ, but it might turn out to be more universal... * * NOTE that atm this transforms value back into the same type; we don't * cross types (at least for now). perhaps we should support that? that * might mean switching in here and removing the "special" format calls * for complex and DQ. */ transform_value?: (value: CellValue) => CellValue; protected _pattern: string; protected sections: NumberFormatSection[]; protected decimal_zero_regexp: Array; protected cloned: boolean[]; get pattern(): string; /** flag indicates if this is a date format */ get date_format(): boolean; constructor(pattern: string); /** * render text parts to string * FIXME: move */ static FormatPartsAsText(parts: TextPart[], text_width?: number): string; /** for decimal only, set an explicit number of digits */ SetDecimal(digits: number): void; /** * mutate * UPDATE: for fractional formats, increase the denominator digits * (doing something weird with fixed denominators...) */ IncreaseDecimal(): void; /** * mutate * UPDATE: for fractional formats, decrease the denominator digits * (doing something weird with fixed denominators...) */ DecreaseDecimal(): void; /** mutate */ AddGrouping(): void; /** mutate */ RemoveGrouping(): void; /** mutate */ ToggleGrouping(): void; /** * generates a string representation. we use this because we are (now) * allowing mutation of formats; therefore we need to serialize them back * to the basic format. */ toString(): string; /** also temporary? why not switch in here? */ FormatDimensionedQuantity(value: DimensionedQuantity): TextPart[] | string; /** * temporary * * FIXME: merge with FormatParts, use a test to check if it's complex? * OTOH that adds a test to every format which is probably wasteful... * although we can check for 'number' first * */ FormatComplex(value: Complex): TextPart[]; /** * this method composes the format as a set of parts with various * states. it's intended for graphical representation where things * like hidden characters and padding require multiple passes or measurement. */ FormatParts(value: CellValue): TextPart[]; /** * formats a number as text. * * this method will use a single space to replace hidden (leading-underscore) * characters. if a text width is provided, it will use that for padding; * otherwise the padding character (we only allow a single padding character) * is rendered once. * * FIXME: date, string (this is lagging) * UPDATE: unifying, basing this on the text part functionality */ Format(value: CellValue, text_width?: number): string; ZeroPad(text: string, length: number): string; DateFormat(value: number): { parts: TextPart[]; section: NumberFormatSection; }; StringFormat(value: string, section: NumberFormatSection): { parts: TextPart[]; section: NumberFormatSection; }; Round2(value: number, digits: number): number; FormatFraction(value: number, section: NumberFormatSection): string; BaseFormat(value: CellValue): { parts: TextPart[]; section: NumberFormatSection; } | { parts: string[]; section: NumberFormatSection; }; }