UNPKG

@empathyco/x-components

Version:
54 lines (51 loc) 1.65 kB
import { defineComponent, ref } from 'vue'; import { use$x } from '../../../composables/use-_x.js'; import { useState } from '../../../composables/use-state.js'; import { searchXModule } from '../x-module.js'; /** * A button that when pressed emits the {@link XEventsTypes.UserAcceptedAQuery} * and {@link XEventsTypes.UserAcceptedSpellcheckQuery} events, expressing the user * intention to set the spellchecked query. * * @public */ var _sfc_main = defineComponent({ name: 'SpellcheckButton', xModule: searchXModule.name, setup() { const $x = use$x(); const el = ref(); /** * The spellcheckedQuery from the search state. * * @public */ const { spellcheckedQuery } = useState('search'); /** * Generates the {@link WireMetadata} object omitting the moduleName. * * @returns The {@link WireMetadata} object omitting the moduleName. * @internal */ const createEventMetadata = () => ({ target: el.value, feature: 'spellcheck', }); /** * Emits events when the button is clicked. * * @public */ const emitEvents = () => { $x.emit('UserAcceptedAQuery', spellcheckedQuery.value, createEventMetadata()); $x.emit('UserAcceptedSpellcheckQuery', spellcheckedQuery.value, createEventMetadata()); }; return { el, spellcheckedQuery, emitEvents, }; }, }); export { _sfc_main as default }; //# sourceMappingURL=spellcheck-button.vue2.js.map