@empathyco/x-components
Version:
Empathy X Components
62 lines (59 loc) • 2.2 kB
JavaScript
import { defineComponent, computed } from 'vue';
import BaseCurrency from '../currency/base-currency.vue.js';
/**
* Component that renders the {@link @empathyco/x-types#Result} current price
* that may or may not be on sale.
*
* @public
*/
var _sfc_main = defineComponent({
components: { BaseCurrency },
props: {
/**
* (Required) The {@link @empathyco/x-types#Result} information.
*
* @public
*/
result: {
type: Object,
required: true,
},
/**
* Format or mask to be defined as string.
* - Use 'i' to define integer numbers.
* - Use 'd' to define decimal numbers. You can define the length of the decimal part. If the
* doesn't include decimals, it is filled with zeros until reach the length defined with 'd's.
* - Integer separator must be defined between the 3rd and the 4th integer 'i' of a group.
* - Decimal separator must be defined between the last 'i' and the first 'd'. It can be more
* than one character.
* - Set whatever you need around the integers and decimals marks.
* - Default mask: 'i.iii,dd' which returns '1.345,67'.
*
* @remarks The number of 'd', which is the maximum decimal length, MUST match with the length
* of decimals provided from the adapter. Otherwise, when the component truncate the decimal
* part, delete significant digits.
*
* @public
*/
format: {
type: String,
},
},
setup(props) {
/**
* Dynamic CSS classes to add to the root element of this component.
*
* @returns A booleans dictionary where each key is the class name to add,
* and the boolean value tells if it should be added or not.
* @internal
*/
const dynamicClasses = computed(() => ({
'x-result-current-price--on-sale': props.result.price?.hasDiscount ?? false,
}));
return {
dynamicClasses,
};
},
});
export { _sfc_main as default };
//# sourceMappingURL=base-result-current-price.vue2.js.map