UNPKG

@empathyco/x-components

Version:
51 lines (48 loc) 1.79 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 open a modal by emitting {@link XEventsTypes.UserClickedOpenModal} * with the modalId as payload. It allows full customization with the 'opening-element' slot and * exposes the 'openModal' function. * * @public */ var _sfc_main = defineComponent({ name: 'BaseIdModalOpen', props: { /** The modalId of the modal that will be opened. */ modalId: { type: String, required: true, }, }, setup(props, { slots }) { const $x = use$x(); /** * Emits the {@link XEventsTypes.UserClickedOpenModal} event with the modalId as payload. * * @param event - The event triggering the function. * @param event.target - Event target. */ function openModal({ target }) { $x.emit('UserClickedOpenModal', props.modalId, { target: target }); } /* Hack to render through a render-function, the `opening-element` slot or, in its absence, the component itself. It is the alternative for the NoElement antipattern. */ const innerProps = { openModal }; return (slots['opening-element'] ? () => slots['opening-element']?.(innerProps)[0] : innerProps); }, }); export { _sfc_main as default }; //# sourceMappingURL=base-id-modal-open.vue2.js.map