@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.
28 lines (27 loc) • 742 B
JavaScript
import "../chunk-G2ADBYYC.js";
import { setActiveNames, handleItemClick } from "./index";
const api = ["state"];
const renderless = (props, { reactive, watch }, { parent, emit, constants }) => {
const eventName = constants.EVENT_NAME.CollapseItemClick;
const state = reactive({
activeNames: []
});
const api2 = {
state,
setActiveNames: setActiveNames({ emit, props, state })
};
api2.handleItemClick = handleItemClick({ api: api2, props, state });
watch(
() => props.modelValue,
(value) => {
state.activeNames = value || value === 0 ? [].concat(value) : [];
},
{ immediate: true, deep: true }
);
parent.$on(eventName, api2.handleItemClick);
return api2;
};
export {
api,
renderless
};