import { App } from 'vue'; import { ComponentPublicInstance } from 'vue'; import { Ref } from 'vue'; import { Temporal } from 'temporal-polyfill'; /** * What an arithmetic number box may hold while it is typed in: digits, a decimal point, whitespace, * `+ - * / %` and parentheses, plus the given separators, after an optional leading `=` (as a spreadsheet formula * starts). Exponents (`e`, `^`) and any other letter are refused, and so is `=` anywhere but first. * @public */ export declare function arithmeticEntryPattern(separators?: NumberSeparators): RegExp; /** * Configuration for {@link useArithmeticInput}. * @public */ export declare type ArithmeticInputOptions = { /** The model's number. A record may hand it over as text (`"40"`, as a database numeric arrives). */ value: () => unknown; /** Hands the model a new number, or null once the box is emptied */ commit: (value: number | null) => void; /** The box's text for the model's number */ format?: (value: number | null) => string; /** The marks the box writes numbers with; a plain `.` decimal point when omitted */ separators?: () => NumberSeparators; /** The field's decimal places, where it has a fixed number of them; at `0` (as for JPY) a decimal mark is refused */ fractionDigits?: () => number | undefined; /** Rounds a result before it is committed, as to a currency's decimals: `10/3` is `3.33`, as the box shows */ round?: (value: number) => number; /** Commit each well-formed result as it is typed (default), or only once the box settles */ live?: boolean; /** The box's text, when the caller already keeps it (as in `v-model`) */ text?: Ref; /** Whether the box takes arithmetic at all; while false the box's text is left alone. Default true. */ enabled?: () => boolean; /** Select the box's text on focus, so typing replaces it */ selectOnFocus?: boolean; }; /** * Orders two versions by SemVer 2.0.0 precedence: major, minor and patch as numbers, a prerelease * before its release, and prerelease identifiers one by one. Build metadata does not count, so * `1.4.0+a` and `1.4.0+b` compare equal. Text that is not a version comes after every version. * @param a - The first version * @param b - The second version * @returns Negative when `a` comes first, positive when `b` does, zero when neither * @public */ export declare function compareSemver(a: string, b: string): number; /** * What a masked currency amount field may hold while it is typed in: digits and grouping marks, then at most one * decimal point followed by digits. * @param locale - The browser's own when omitted * @public */ export declare function currencyAmountEntryPattern(currencyId: string | undefined, locale?: string): RegExp; /** * The separators a currency amount field writes amounts with: the locale's grouping and decimal marks. * @param locale - The browser's own when omitted * @public */ export declare function currencyAmountSeparators(locale?: string): { group: string; decimal: string; }; /** * Fraction digits for a currency in amount inputs (e.g. JPY → 0). * @public */ export declare function currencyInputFractionDigits(currencyId: string | undefined): number; declare type CurrencyLike = { id?: string | number; symbol?: string; displayText?: string; }; /** * Default keypress handlers for keyboard navigation * @public */ export declare const defaultKeypressHandlers: KeypressHandlers; /** * Evaluate the arithmetic typed into a number box: `12*3+4` is `40`. Supports `+ - * / %` (remainder, as * JavaScript's `%`), parentheses, signed numbers and decimals; nothing else, so no exponents, functions or names. * A leading `=` or `+` is read as a spreadsheet reads it, so `=12*3` and `+12*3` are both `36`. * * The result is rounded to 15 significant digits to shed binary floating-point noise (`0.1*3` is `0.3`, not * `0.30000000000000004`). * * @param text - The box's text * @param separators - The marks the box writes numbers with; a plain `.` decimal point with no grouping when omitted * @returns The number, or null when the text is empty or no well-formed expression (`12*`, `(3`, `5/0`, or a number * written with the separators the other way round, as `1.234,56` in English) * @public */ export declare function evaluateArithmetic(text: string, separators?: NumberSeparators): number | null; /** * Format a currency amount for display (forms, table cells). Uses `Intl` when `currency.id` is a * valid ISO code; otherwise falls back to symbol, display text, or id. * @public */ export declare function formatCurrencyAmount(amount: number | null | undefined, currency: CurrencyLike | undefined): string; /** * Format a numeric amount for display in a currency amount field (no currency symbol). The currency * sets the decimals; the separators are the locale's, as in the table cell. * @param locale - The browser's own when omitted * @public */ export declare function formatCurrencyAmountInput(amount: number | null | undefined, currencyId: string | undefined, locale?: string): string; /** * Render a composite currency value for table cells. * @public */ export declare function formatCurrencyCell(value: unknown): string; /** * The mark that names a currency beside an amount: the symbol `Intl` formats a valid ISO code with, * as {@link formatCurrencyAmount} does; otherwise its symbol, display text, or id. * @public */ export declare function formatCurrencySymbol(currency: CurrencyLike | undefined): string; /** * Render a composite quantity value for table cells. Omits the UOM when it matches `stockUom`. * @public */ export declare function formatQuantityCell(value: unknown): string; /** * Reads a `YYYY-MM-DD` day. Anything that is not a real day written exactly that way reads as no day. * * Not `Temporal.PlainDate.from` alone: it also takes the day out of a date-time, which would show a day * field over a date-time column as a day instead of as the mismatch it is. * @param day - The day, as `YYYY-MM-DD` * @public */ export declare function fromISODate(day: string): Temporal.PlainDate | undefined; /** * Install all utility components * @param _app - Vue app instance * @public */ export declare function install(_app: App): void; /** * Whether an arithmetic number box may hold `text` while it is typed in: what {@link arithmeticEntryPattern} allows, * with each number in it well formed (grouping marks only in the whole part, then at most one decimal mark). * @param fractionDigits - The field's decimal places; at `0` (as for JPY) a decimal mark is refused * @public */ export declare function isArithmeticEntry(text: string, separators?: NumberSeparators, fractionDigits?: number): boolean; /** * Whether a single typed character may go into an arithmetic number box. `=` is one, though only as the box's first * character: check the box's text with {@link arithmeticEntryPattern} where the caret is known. * @public */ export declare function isArithmeticKey(key: string, separators?: NumberSeparators): boolean; /** * Whether the text is a version under SemVer 2.0.0: `1.4.0`, `1.4.0-beta.2`, `1.4.0+build.5`. A `v` * prefix, a missing part (`1.4`) and a leading zero (`01.4.0`) are not. * @param text - The text to check * @public */ export declare function isSemver(text: string): boolean; /** * Whether typing more could still make the text a version: `1.`, `1.4.0-` and the empty text can, * while `v1`, `01` and `1.4-beta` cannot. Every version passes, so a box that refuses any edit failing * this one never stops someone typing a version. * @param text - The text so far * @public */ export declare function isSemverPrefix(text: string): boolean; /** * Keyboard navigation options * @public */ export declare type KeyboardNavigationOptions = { parent?: string | HTMLElement | Readonly>; selectors?: string | HTMLElement | HTMLElement[] | ComponentPublicInstance[] | Readonly> | Readonly> | Readonly>; handlers?: KeypressHandlers; }; /** * Key press handlers * @public */ export declare type KeypressHandlers = { [key: string]: (ev: KeyboardEvent) => any; }; /** * The marks a number box writes numbers with. The decimal mark is read as the decimal point and the group mark is * dropped, so `1.000,5*2` reads as `1000.5*2` with German separators. * @public */ export declare type NumberSeparators = { group?: string; decimal?: string; }; /** * Parse user-entered text in a currency amount field back to a number, read with the separators the * field writes it with. * @param locale - The browser's own when omitted * @public */ export declare function parseCurrencyAmountInput(text: string, locale?: string): number | null; /** * Round a number to a field's decimal places, as a column with a fixed scale holds it: `3.3333333333333` at 2 is * `3.33`. A missing or unusable precision (not a whole number from 0 to 100) leaves the number as it is. * @public */ export declare function roundToPrecision(value: number, precision?: number): number; /** * A number box that takes arithmetic: `12*3+4` is read as `40`, and a leading `=` or `+` as a spreadsheet reads it. * The box holds the typed text while it is edited and settles to the result on blur or Enter; text that is no * expression by then (`12*`) leaves the model at its last number. * * Only an edit writes: a box focused and left as it was commits nothing, so a value is never rewritten (or rounded) * by being looked at. "Edited" means the text differs from what the box last showed or saved. * * An `` binds the returned `inputAttrs` (`v-bind="arithmetic.inputAttrs"`); an attribute written after the bind * overrides it, and a listener written beside it runs as well. A box that is no `` (a contenteditable table * cell), or one that is not always an arithmetic box, drives `begin`, `update`, `settle`, `end` and `accepts` itself. * * @public */ export declare function useArithmeticInput({ value, commit, format, separators, fractionDigits, round, live, text, enabled, selectOnFocus, }: ArithmeticInputOptions): { inputAttrs: { value: string; type: "text"; inputmode: "decimal"; autocomplete: "off"; onFocus: (event: FocusEvent) => void; onInput: (event: Event) => void; onKeydown: (event: KeyboardEvent) => void; onPaste: (event: ClipboardEvent) => void; onBlur: () => void; }; text: Ref; focused: Ref; accepts: (next: string) => boolean; begin: (current?: string) => void; update: (next: string) => void; settle: () => void; end: () => void; rebase: (current: string) => void; syncText: () => void; onFocus: (event: FocusEvent) => void; onInput: (event: Event) => void; onKeydown: (event: KeyboardEvent) => void; onPaste: (event: ClipboardEvent) => void; onBlur: () => void; }; /** * Keyboard navigation composable * @param options - Keyboard navigation options * @public */ export declare function useKeyboardNav(options: KeyboardNavigationOptions[]): void; export { }