UNPKG

@ecomplus/storefront-components

Version:
49 lines (40 loc) 837 B
import { i19zipCode } from '@ecomplus/i18n' import { $ecomConfig, i18n } from '@ecomplus/utils' import CleaveInput from 'vue-cleave-component' const countryCode = $ecomConfig.get('country_code') export default { name: 'InputZipCode', components: { CleaveInput }, props: { value: { type: [String, Number], required: true } }, computed: { placeholder () { return i18n(i19zipCode) }, pattern () { if (countryCode === 'BR') { return '[\\d]{5}-[\\d]{3}' } return null }, localValue: { get () { return this.value }, set (value) { this.$emit('input', value) } }, cleaveOptions () { return countryCode === 'BR' ? { blocks: [5, 3], delimiter: '-' } : { blocks: [30] } } } }