@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.
41 lines (40 loc) • 964 B
JavaScript
import "../../chunk-G2ADBYYC.js";
import { draggable } from "../utils/use-drag";
import { initDom, initState, useEvent } from ".";
const api = ["state", "onSvReady", "bar", "thumb", "wrapper"];
const renderless = (props, hooks, utils) => {
const { onMounted } = hooks;
const { emit } = utils;
const { thumb, bar, wrapper } = initDom(hooks);
const state = initState(props, hooks);
const { onSvReady, onDrag, update } = useEvent({ thumb, bar, wrapper }, state, props, utils);
const api2 = {
state,
onSvReady,
bar,
thumb,
wrapper
};
onMounted(() => {
if (!bar.value || !thumb.value) {
return;
}
const dragConfig = {
drag: (event) => {
onDrag(event);
},
end: (event) => {
onDrag(event);
}
};
draggable(bar.value, dragConfig);
draggable(thumb.value, dragConfig);
emit("hueReady", update);
update();
});
return api2;
};
export {
api,
renderless
};