UNPKG

@empathyco/x-components

Version:
53 lines (50 loc) 1.58 kB
import { defineComponent, inject, computed } from 'vue'; var _sfc_main = defineComponent({ props: { /** * Numeric value to be formatted. * * @remarks Pass the value with 'v-bind:value' (or ':value' shortcut) instead of plain string. * @remarks Be careful using numbers under Number.MAX_SAFE_INTEGER to avoid unexpected errors. * * @public */ value: { type: Number, required: true, }, /** * The ISO 4217 currency value. If not specified we use snippetConfig.currency * * @public */ currency: String, /** * The currency format possibilities from Intl.NumberFormatOptions. * Allows customization of decimal places, grouping, etc. * Note: 'currency' and 'style' options are managed internally. * * @public */ format: { type: Object, default: () => ({}), }, }, setup(props) { const snippetConfig = inject('snippetConfig'); const currencyText = computed(() => { const currency = props.currency ?? snippetConfig?.currency ?? 'EUR'; return Intl.NumberFormat(snippetConfig?.uiLang, { style: 'currency', ...props.format, currency, }).format(props.value); }); return { currencyText, }; }, }); export { _sfc_main as default }; //# sourceMappingURL=base-currency.vue2.js.map