You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
1.2 KiB

1 month ago
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', { value: true });
  3. var vue = require('vue');
  4. var index = require('../use-namespace/index.js');
  5. var index$1 = require('../use-id/index.js');
  6. var core = require('@vueuse/core');
  7. const usePopperContainerId = () => {
  8. const namespace = index.useGetDerivedNamespace();
  9. const idInjection = index$1.useIdInjection();
  10. const id = vue.computed(() => {
  11. return `${namespace.value}-popper-container-${idInjection.prefix}`;
  12. });
  13. const selector = vue.computed(() => `#${id.value}`);
  14. return {
  15. id,
  16. selector
  17. };
  18. };
  19. const createContainer = (id) => {
  20. const container = document.createElement("div");
  21. container.id = id;
  22. document.body.appendChild(container);
  23. return container;
  24. };
  25. const usePopperContainer = () => {
  26. const { id, selector } = usePopperContainerId();
  27. vue.onBeforeMount(() => {
  28. if (!core.isClient)
  29. return;
  30. if (process.env.NODE_ENV === "test" || !document.body.querySelector(selector.value)) {
  31. createContainer(id.value);
  32. }
  33. });
  34. return {
  35. id,
  36. selector
  37. };
  38. };
  39. exports.usePopperContainer = usePopperContainer;
  40. exports.usePopperContainerId = usePopperContainerId;
  41. //# sourceMappingURL=index.js.map