{"version":3,"file":"NameCurrency.cjs","sources":["../../../../src/lib/Name/NameCurrency.tsx"],"sourcesContent":["import {forwardRef, useMemo} from 'react';\nimport classNames from 'classnames';\n\nimport type {DataAttributes, LibraryProps} from '@/internal/LibraryAPI';\nimport {useBrowserLocale} from '@/internal/locale';\nimport type {Locale, CurrencyCodes} from '@/internal/locale';\n\nimport type {Styles} from './types.ts';\nimport classes from './Name.module.css';\n\nexport type Props = DataAttributes &\n    LibraryProps & {\n        /**\n         * Provide a string with a BCP 47 language tag or an Intl.Locale instance,\n         * or an array of such locale identifiers. Defaults to user setting\n         * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DisplayNames/DisplayNames#locales\n         */\n        locale?: Locale;\n        /**\n         * Select the formatting style to use.\n         * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DisplayNames/DisplayNames#style\n         */\n        style?: keyof typeof Styles;\n        /**\n         * Provide a three-letter ISO 4217 currency code\n         * @see https://www.iso.org/iso-4217-currency-codes.html\n         */\n        currencyCode: keyof typeof CurrencyCodes;\n    };\n\nexport const NameCurrency = forwardRef<HTMLDivElement, Props>(\n    ({className, locale: localeProp, currencyCode, style, ...nativeProps}, ref) => {\n        const userLocale = useBrowserLocale();\n        const locale = localeProp ? localeProp : userLocale;\n        const formattedValue = useMemo(\n            () => new Intl.DisplayNames(locale, {type: 'currency', style}).of(currencyCode),\n            [currencyCode, locale, style]\n        );\n\n        return (\n            <span {...nativeProps} className={classNames(classes.name, className)} ref={ref}>\n                {formattedValue}\n            </span>\n        );\n    }\n);\n\nNameCurrency.displayName = 'NameCurrency';\n"],"names":["NameCurrency","forwardRef","className","localeProp","currencyCode","style","nativeProps","ref","userLocale","useBrowserLocale","locale","formattedValue","useMemo","jsx","classNames","classes"],"mappings":"wQA8BaA,EAAeC,EAAAA,WACxB,CAAC,CAAC,UAAAC,EAAW,OAAQC,EAAY,aAAAC,EAAc,MAAAC,EAAO,GAAGC,CAAA,EAAcC,IAAQ,CAC3E,MAAMC,EAAaC,EAAAA,iBAAA,EACbC,EAASP,GAA0BK,EACnCG,EAAiBC,EAAAA,QACnB,IAAM,IAAI,KAAK,aAAaF,EAAQ,CAAC,KAAM,WAAY,MAAAL,CAAA,CAAM,EAAE,GAAGD,CAAY,EAC9E,CAACA,EAAcM,EAAQL,CAAK,CAAA,EAGhC,OACIQ,EAAAA,IAAC,OAAA,CAAM,GAAGP,EAAa,UAAWQ,EAAWC,UAAQ,KAAMb,CAAS,EAAG,IAAAK,EAClE,SAAAI,CAAA,CACL,CAER,CACJ,EAEAX,EAAa,YAAc"}