UNPKG

@opentiny/vue-renderless

Version:

An enterprise-class UI component library, support both Vue.js 2 and Vue.js 3, as well as PC and mobile.

33 lines (32 loc) 1.05 kB
import "../chunk-G2ADBYYC.js"; import { doDestroy, show, hide, popoverShow, popoverHide, handleClear, handleDocumentClick, togglePanel } from "./index"; import { on, off } from "@opentiny/utils"; const api = ["state", "doDestroy", "show", "hide", "popoverShow", "popoverHide", "handleClear", "togglePanel"]; const renderless = (props, { reactive, onMounted, onBeforeUnmount }, { vm, emit }) => { const state = reactive({ visible: false }); const api2 = {}; Object.assign(api2, { state, show: show({ state }), hide: hide({ state }), togglePanel: togglePanel({ props, state }), popoverShow: popoverShow({ state, emit }), popoverHide: popoverHide({ state, emit }), handleClear: handleClear({ emit }), doDestroy: doDestroy({ vm }), handleDocumentClick: handleDocumentClick({ vm, state }) }); onMounted(() => { on(document, "click", api2.handleDocumentClick); }); onBeforeUnmount(() => { off(document, "click", api2.handleDocumentClick); }); return api2; }; export { api, renderless };