/** * ObjectUI * Copyright (c) 2024-present ObjectStack Inc. * * Licensed under the MIT license found in the LICENSE file. */ /** * `resolveFieldCurrency` now lives in `@object-ui/i18n` (co-located with * `useLocalization`, which supplies the tenant default). This module re-exports * it so the long-standing `@object-ui/fields` import path keeps working for * every field/cell renderer that already depends on it. */ export { resolveFieldCurrency } from '@object-ui/i18n'; /** * The number of fraction digits ISO 4217 gives `currency` — 0 for JPY/KRW/CLP, * 2 for USD/EUR/CNY, 3 for KWD/BHD/OMR/TND — as ICU reports it. * * Returns {@link DEFAULT_FRACTION_DIGITS} when the code is not a currency code * at all: `Intl` throws `RangeError: Invalid currency code` for those, and the * throw must not escape, or a bad code would change the width used by the * callers' own bad-currency fallbacks (objectui#4332 pinned those strings). A * code that is well-formed but unknown to CLDR (e.g. `ZZZ`) does not throw — * ICU answers 2 for anything outside its table, which is the same default. * * Memoized because the currency cell renderer runs once per grid cell: measured * at 24.3us per uncached probe against 0.02us cached (200k iterations, node 22), * so a 500-row grid pays ~12ms per render pass for a value that cannot change. */ export declare function currencyFractionDigits(currency: string): number; /** * The string ICU renders in place of `currency` for a reader in `locale` — `$` * for USD at `en`, `€` for EUR, U+00A5 for JPY — taken from the `currency` part * of the very format the display path already uses. * * This is the ONE channel for the symbol (objectui#4414). It is not an * independent opinion about how a currency should look: it is the same * `Intl.NumberFormat(locale, { style: 'currency', currency })` that * `formatDisplayNumber` formats amounts with, read one part at a time. So a * widget that renders an amount in one mode and a bare symbol in another cannot * disagree with itself — which is exactly what the hand-written * `currency === 'USD' ? '$' : currency` ternary did, showing `JPY` beside a * readonly `¥1,235`. * * Falls back to `currency` itself — the code as given — in the three cases * where ICU cannot answer, because a bare code is a legitimate adornment (it is * what ICU itself returns for KWD/BHD/CHF/ISK, and what * `formatAmount`'s own bad-code branch renders beside it): * * 1. an invalid currency code — `Intl` throws `RangeError: Invalid currency * code`; * 2. a malformed locale tag (`en_US` with an underscore, say) — `Intl` throws * `RangeError: Incorrect locale information provided`. `currencyFractionDigits` * dodged this failure mode by dropping the locale from its probe; this * helper needs the locale, so it catches instead. Neither throw may escape: * this runs during render, so an escaped `RangeError` is a blank widget. * 3. no `currency` part in the output at all — not observed for * `style: 'currency'`, but coalesced rather than asserted. */ export declare function currencySymbol(currency: string, locale: string): string;