54 lines
1.6 KiB
JavaScript
54 lines
1.6 KiB
JavaScript
const require_rolldown_runtime = require('../rolldown-runtime.cjs');
|
|
const vue = require_rolldown_runtime.__toESM(require("vue"));
|
|
const __vueuse_core = require_rolldown_runtime.__toESM(require("@vueuse/core"));
|
|
|
|
//#region src/shared/useForwardExpose.ts
|
|
function useForwardExpose() {
|
|
const instance = (0, vue.getCurrentInstance)();
|
|
const currentRef = (0, vue.ref)();
|
|
const currentElement = (0, vue.computed)(() => {
|
|
return ["#text", "#comment"].includes(currentRef.value?.$el.nodeName) ? currentRef.value?.$el.nextElementSibling : (0, __vueuse_core.unrefElement)(currentRef);
|
|
});
|
|
const localExpose = Object.assign({}, instance.exposed);
|
|
const ret = {};
|
|
for (const key in instance.props) Object.defineProperty(ret, key, {
|
|
enumerable: true,
|
|
configurable: true,
|
|
get: () => instance.props[key]
|
|
});
|
|
if (Object.keys(localExpose).length > 0) for (const key in localExpose) Object.defineProperty(ret, key, {
|
|
enumerable: true,
|
|
configurable: true,
|
|
get: () => localExpose[key]
|
|
});
|
|
Object.defineProperty(ret, "$el", {
|
|
enumerable: true,
|
|
configurable: true,
|
|
get: () => instance.vnode.el
|
|
});
|
|
instance.exposed = ret;
|
|
function forwardRef(ref$1) {
|
|
currentRef.value = ref$1;
|
|
if (!ref$1) return;
|
|
Object.defineProperty(ret, "$el", {
|
|
enumerable: true,
|
|
configurable: true,
|
|
get: () => ref$1 instanceof Element ? ref$1 : ref$1.$el
|
|
});
|
|
instance.exposed = ret;
|
|
}
|
|
return {
|
|
forwardRef,
|
|
currentRef,
|
|
currentElement
|
|
};
|
|
}
|
|
|
|
//#endregion
|
|
Object.defineProperty(exports, 'useForwardExpose', {
|
|
enumerable: true,
|
|
get: function () {
|
|
return useForwardExpose;
|
|
}
|
|
});
|
|
//# sourceMappingURL=useForwardExpose.cjs.map
|