/** * Copyright (c) 2025 Elara AI Pty Ltd * Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details. */ /** * The B§3 quantity grammar: digits, an optional decimal, an optional * magnitude suffix `k` (×10³) or `m` (×10⁶); the digit-group separator and * any space ignored; the result the number as written — `7.5` is 7.5, as a * quantity's Float field holds it and its cell prints it. A suffix moves the * decimal point in the text, so `1.005k` is 1005 exactly, where multiplying * would leave 1004.9999999999999. It reads the separators of the viewer's * language (#852) — `1,234.5` in English, `1.234,5` in German, `1 234,5` in * French — with ASCII digits. The unit is the column's, never typed — an * integer column uses the same grammar, and refuses a fraction. A number * field takes, key by key, what the grammar reads ({@link typedQuantity}). * * @packageDocumentation */ import type { Formatters } from "@elaraai/east-ui-components"; /** How a language writes a number: its digit-group and decimal separators. */ export type NumberSeparators = Formatters["separators"]; /** * Parse typed text to a number. * * @param text - The typed or pasted text * @param separators - The viewer's language's separators (`Formatters.separators`) * @returns the parsed value; `undefined` for an empty buffer; `null` when unrecognised */ export declare function parseQuantity(text: string, separators: NumberSeparators): number | null | undefined; /** What a number field does with a key, by the text it would hold once the key lands. */ export type QuantityKey = /** The text is a number, or on its way to one — a lone minus, a trailing decimal separator: the key lands. */ { kind: "take"; } /** A magnitude suffix completes a number: the field holds the number it reads, so it steps from there (`1.005k` → 1005). */ | { kind: "read"; n: number; } /** The grammar never reads it. */ | { kind: "refuse"; }; /** * What a number field does with a typed key (B§3) — the grammar decides, not * the field's own format, so a `k`, an `m` and a decimal separator are never * dropped without a word. A fraction in an integer column is taken: the * strip calls it unrecognised and the commit refuses it, where dropping its * point turned `2.5` into 25. * * @param text - The field's text once the key lands at the caret * @param separators - The viewer's language's separators (`Formatters.separators`) * @returns whether the key lands, completes a number the field then holds, or is refused */ export declare function typedQuantity(text: string, separators: NumberSeparators): QuantityKey; /** The bare clipboard / edit form of a number — no grouping, no unit, the * viewer's decimal separator: `1234.5`, `1234,5` in German (#852). */ export declare function formatNumberBare(n: number, words: Formatters): string; //# sourceMappingURL=quantity.d.ts.map