@empathyco/x-components
Version:
Empathy X Components
56 lines (53 loc) • 1.66 kB
JavaScript
import { defineComponent, inject, computed } from 'vue';
import BaseEventButton from '../base-event-button.vue.js';
/**
* Renders a button with a default slot. It receives the result with the data and emits
* {@link XEventsTypes.UserClickedResultAddToCart} to the bus on click mouse event.
*
* @public
*/
var _sfc_main = defineComponent({
components: { BaseEventButton },
props: {
/**
* (Required) The {@link @empathyco/x-types#Result} information.
*
* @public
*/
result: {
type: Object,
required: true,
},
},
setup(props) {
/**
* The list of additional events to be emitted by the component when user clicks the add2cart button.
*
* @internal
*/
const resultAddToCartExtraEvents = inject('resultAddToCartExtraEvents', []);
/**
* The metadata to be injected in the events emitted by the component.
*/
const metadata = inject('resultAddToCartExtraEventsMetadata', {});
/**
* The events to be emitted by the button.
*
* @returns Events {@link XEventsTypes} to emit.
*
* @public
*/
const events = computed(() => {
return resultAddToCartExtraEvents.reduce((acc, event) => {
acc[event] = props.result;
return acc;
}, { UserClickedResultAddToCart: props.result });
});
return {
events,
metadata,
};
},
});
export { _sfc_main as default };
//# sourceMappingURL=base-result-add-to-cart.vue2.js.map