UNPKG

@empathyco/x-components

Version:
57 lines (54 loc) 1.59 kB
import { defineComponent, ref } from 'vue'; import { use$x } from '../../../composables/use-_x.js'; import { searchXModule } from '../x-module.js'; /** * A button that when pressed emits the {@link XEventsTypes.UserAcceptedAQuery} * and {@link SearchXEvents.UserClickedPartialQuery} events, expressing the user * intention to set the partial query. * * @public */ var _sfc_main = defineComponent({ name: 'PartialQueryButton', xModule: searchXModule.name, props: { /** * The query property. * * @public */ query: { type: String, required: true, }, }, setup(props) { const $x = use$x(); const partialButtonEl = ref(); /** * Generates the {@link WireMetadata} object omitting the moduleName. * * @returns The {@link WireMetadata} object omitting the moduleName. * @internal */ const createEventMetadata = () => ({ target: partialButtonEl.value, feature: 'partial_result', }); /** * Emits events when the button is clicked. * * @public */ const emitEvents = () => { $x.emit('UserAcceptedAQuery', props.query, createEventMetadata()); $x.emit('UserClickedPartialQuery', props.query, createEventMetadata()); }; return { partialButtonEl, emitEvents, }; }, }); export { _sfc_main as default }; //# sourceMappingURL=partial-query-button.vue2.js.map