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.

31 lines (30 loc) 759 B
import "../chunk-G2ADBYYC.js"; import { mousedown, selectItem, keydown } from "./index"; import { on, off } from "@opentiny/utils"; const api = ["state", "mousedown", "selectItem"]; const renderless = (props, { onUnmounted, reactive, watch }, { emit }) => { const state = reactive({ hoverValue: "" }); const api2 = { state, mousedown, selectItem: selectItem({ emit, state }), keydown: keydown({ emit, props, state }) }; watch( () => props.isMemoryStorage, (value) => !value && (state.hoverValue = ""), { immediate: true } ); onUnmounted(() => { state.hoverValue = ""; off(document, "keydown", api2.keydown); }); on(document, "keydown", api2.keydown); return api2; }; export { api, renderless };