teleport.mjs 885 B

12345678910111213141516171819202122232425
  1. // Utilities
  2. import { computed, warn } from 'vue';
  3. import { IN_BROWSER } from "../util/index.mjs"; // Types
  4. export function useTeleport(target) {
  5. const teleportTarget = computed(() => {
  6. const _target = target.value;
  7. if (_target === true || !IN_BROWSER) return undefined;
  8. const targetElement = _target === false ? document.body : typeof _target === 'string' ? document.querySelector(_target) : _target;
  9. if (targetElement == null) {
  10. warn(`Unable to locate target ${_target}`);
  11. return undefined;
  12. }
  13. let container = targetElement.querySelector(':scope > .v-overlay-container');
  14. if (!container) {
  15. container = document.createElement('div');
  16. container.className = 'v-overlay-container';
  17. targetElement.appendChild(container);
  18. }
  19. return container;
  20. });
  21. return {
  22. teleportTarget
  23. };
  24. }
  25. //# sourceMappingURL=teleport.mjs.map