UNPKG

@empathyco/x-components

Version:
52 lines (49 loc) 1.78 kB
import { defineComponent } from 'vue'; import '../../composables/create-use-device.js'; import { use$x } from '../../composables/use-_x.js'; import 'vuex'; import '@vue/devtools-api'; import '../../plugins/devtools/timeline.devtools.js'; import '@empathyco/x-utils'; import 'rxjs/operators'; import 'rxjs'; import '../../plugins/devtools/colors.utils.js'; import '../../plugins/x-bus.js'; import '../../plugins/x-plugin.js'; import '@vueuse/core'; /** * Component that allows to close a modal by emitting * {@link XEventsTypes.UserClickedCloseModal}. * It allows full customization with the 'closing-element' slot and exposes the 'closeModal' * function. * * @public */ var _sfc_main = defineComponent({ name: 'BaseIdModalClose', props: { /** The modalId of the modal that will be closed. */ modalId: { type: String, required: true, }, }, setup(props, { slots }) { const $x = use$x(); /** * Emits the {@link XEventsTypes.UserClickedCloseModal} event with the modalId as payload. * * @param event - The event triggering the function. * @param event.target - Event target. */ function closeModal({ target }) { $x.emit('UserClickedCloseModal', props.modalId, { target: target }); } /* Hack to render through a render-function, the `closing-element` slot or, in its absence, the component itself. It is the alternative for the NoElement antipattern. */ const innerProps = { closeModal }; return (slots['closing-element'] ? () => slots['closing-element']?.(innerProps)[0] : innerProps); }, }); export { _sfc_main as default }; //# sourceMappingURL=base-id-modal-close.vue2.js.map