pagamio-frontend-commons-lib
Version:
Pagamio library for Frontend reusable components like the form engine and table container
38 lines (37 loc) • 1.48 kB
TypeScript
import { type ClassValue } from 'clsx';
export declare function cn(...inputs: ClassValue[]): string;
/**
* Formats a number as currency using en-US locale standards.
*
* @param {number} price - The numeric value to format as currency
* @param {string} [currency="ZAR"] - ISO 4217 currency code (default: "ZAR")
* @param {number} [minimumFractionDigits=2] - Minimum fraction digits (default: 2)
* @param {number} [maximumFractionDigits] - Optional maximum fraction digits
* @param {string} [displaySymbol] - Optional custom symbol to display instead of ISO code
* @returns {string} Formatted currency string
*
* @example
* // Basic usage with ZAR (South African Rand)
* formatPrice(1234.56); // Returns "ZAR 1,234.56"
*
* @example
* // USD with 2 decimal places
* formatPrice(1234.56, "USD"); // Returns "$1,234.56"
*
* @example
* // Euro with standard formatting
* formatPrice(1234.56, "EUR"); // Returns "€1,234.56"
*
* @example
* // Custom display symbol for ZAR
* formatPrice(1234.56, "ZAR", 2, undefined, "R"); // Returns "R 1,234.56"
*
* @example
* // Custom decimal places (clamping)
* formatPrice(1234.5678, "GBP", 2, 3); // Returns "£1,234.568"
*
* @example
* // Fallback behavior with invalid currency
* formatPrice(1234.56, "XYZ"); // Returns "XYZ 1,234.56"
*/
export declare const formatPrice: (price: number, currency?: string, minimumFractionDigits?: number, maximumFractionDigits?: number, displaySymbol?: string) => string;