UNPKG

@scayle/storefront-nuxt

Version:

Nuxt integration for the SCAYLE Commerce Engine and Storefront API

72 lines (71 loc) 2.02 kB
/** * Representation of options for formatting currencies. * * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat */ type FormatCurrencyOptions = { /** * The locale to use for formatting. */ locale?: string; /** * The number of fraction digits to use for the currency. */ currencyFractionDigits?: number; /** * The style ('currency' or 'decimal') to use for formatting. Defaults to 'currency'. */ style?: 'currency'; /** * The currency code (e.g., 'EUR', 'USD') to use for formatting. Defaults to the currency of the shop. */ currency?: string; } | { /** * The locale to use for formatting. */ locale?: string; /** * The number of fraction digits to use for the currency. */ currencyFractionDigits?: number; /** * The style to use for formatting. */ style: 'decimal'; }; /** * Representation of options for formatting percentages. * * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat */ interface FormatPercentageOptions { /** * The locale to use for formatting. */ locale?: string; /** * The minimum number of fraction digits to use. */ minimumFractionDigits?: number; /** * The maximum number of fraction digits to use. */ maximumFractionDigits?: number; /** * How to display the sign for the percentage. */ signDisplay?: Intl.NumberFormatOptions['signDisplay']; } /** * Provides currency and percentage formatting helpers. * * It leverages the current shop's locale and currency settings. * * @returns An object containing the formatCurrency and formatPercentage functions. */ export declare function useFormatHelpers(): { formatCurrency: (value: number, options?: FormatCurrencyOptions) => string; formatPercentage: (value: number, options?: FormatPercentageOptions) => string; }; export {};