UNPKG

@nestledjs/forms

Version:

A flexible React form library supporting both declarative and imperative usage patterns with TypeScript support

54 lines (53 loc) 2.08 kB
import { CurrencyCode, CurrencyConfig } from '../form-types'; export declare const CURRENCY_CONFIGS: Record<CurrencyCode, CurrencyConfig>; /** * Get currency configuration by code */ export declare function getCurrencyConfig(code: CurrencyCode): CurrencyConfig; /** * Get all available currencies as options for select fields */ export declare function getCurrencyOptions(): { value: CurrencyCode; label: string; }[]; /** * Get popular currencies as options (most commonly used globally) */ export declare function getPopularCurrencyOptions(): { value: CurrencyCode; label: string; }[]; /** * Format a number as currency based on currency configuration */ export declare function formatCurrency(value: number | string | null | undefined, config: CurrencyConfig, options?: { showSymbol?: boolean; showCode?: boolean; includeDecimals?: boolean; }): string; /** * Parse a formatted currency string back to a number */ export declare function parseCurrency(value: string, config: CurrencyConfig): number | null; /** * Get the appropriate step value for HTML input based on currency */ export declare function getCurrencyStep(config: CurrencyConfig): string; /** * Resolve the final currency configuration from options */ export declare function resolveCurrencyConfig(currency?: CurrencyCode | 'custom', customCurrency?: Partial<CurrencyConfig>): CurrencyConfig; /** * Validate if a currency code is supported */ export declare function isSupportedCurrency(code: string): code is CurrencyCode; /** * Convert between currencies (requires exchange rates - this is a placeholder) * In a real application, you would integrate with a currency API */ export declare function convertCurrency(amount: number, fromCurrency: CurrencyCode, toCurrency: CurrencyCode, exchangeRates?: Record<string, number>): number; /** * Format currency for display in different contexts */ export declare function formatCurrencyForDisplay(value: number | string | null | undefined, currency: CurrencyCode, context?: 'input' | 'display' | 'compact'): string;