vuestic-ui
Version:
Vue 3 UI Framework
37 lines (36 loc) • 1.26 kB
JavaScript
import { getCurrentInstance } from "vue";
import { u as useCurrentComponentId } from "./useCurrentComponentId.mjs";
const TELEPORT_FROM_ATTR = "data-va-teleported-from";
const TELEPORT_ATTR = "data-va-teleported";
const findTeleportedFrom = (el) => {
if (!el) {
return null;
}
const teleportId = el.getAttribute(TELEPORT_ATTR);
if (teleportId === null) {
return findTeleportedFrom(el.parentElement);
}
return document.querySelector(`[${TELEPORT_FROM_ATTR}="${teleportId}"]`);
};
const useTeleported = () => {
var _a, _b;
const componentId = useCurrentComponentId();
const currentInstance = getCurrentInstance();
const scopedDataV = currentInstance == null ? void 0 : currentInstance.vnode.scopeId;
return {
teleportFromAttrs: {
[TELEPORT_FROM_ATTR]: componentId
},
teleportedAttrs: {
[TELEPORT_ATTR]: componentId,
...scopedDataV ? { [scopedDataV]: "" } : void 0,
...(_b = (_a = currentInstance == null ? void 0 : currentInstance.appContext.config) == null ? void 0 : _a.globalProperties) == null ? void 0 : _b.$vaColorConfig.getAppStylesRootAttribute()
},
findTeleportedFrom
};
};
export {
findTeleportedFrom as f,
useTeleported as u
};
//# sourceMappingURL=useTeleported.mjs.map