This commit is contained in:
2025-09-19 14:25:20 +08:00
parent 269893a435
commit fbf3f77229
24949 changed files with 2839404 additions and 0 deletions

View File

@@ -0,0 +1,8 @@
export declare const usePopperContainerId: () => {
id: import("vue").ComputedRef<string>;
selector: import("vue").ComputedRef<string>;
};
export declare const usePopperContainer: () => {
id: import("vue").ComputedRef<string>;
selector: import("vue").ComputedRef<string>;
};

View File

@@ -0,0 +1,40 @@
import { computed, onBeforeMount } from 'vue';
import { useGetDerivedNamespace } from '../use-namespace/index.mjs';
import { useIdInjection } from '../use-id/index.mjs';
import { isClient } from '@vueuse/core';
const usePopperContainerId = () => {
const namespace = useGetDerivedNamespace();
const idInjection = useIdInjection();
const id = computed(() => {
return `${namespace.value}-popper-container-${idInjection.prefix}`;
});
const selector = computed(() => `#${id.value}`);
return {
id,
selector
};
};
const createContainer = (id) => {
const container = document.createElement("div");
container.id = id;
document.body.appendChild(container);
return container;
};
const usePopperContainer = () => {
const { id, selector } = usePopperContainerId();
onBeforeMount(() => {
if (!isClient)
return;
if (!document.body.querySelector(selector.value)) {
createContainer(id.value);
}
});
return {
id,
selector
};
};
export { usePopperContainer, usePopperContainerId };
//# sourceMappingURL=index.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.mjs","sources":["../../../../../packages/hooks/use-popper-container/index.ts"],"sourcesContent":["import { computed, onBeforeMount } from 'vue'\nimport { isClient } from '@element-plus/utils'\nimport { useGetDerivedNamespace } from '../use-namespace'\nimport { useIdInjection } from '../use-id'\n\nexport const usePopperContainerId = () => {\n const namespace = useGetDerivedNamespace()\n const idInjection = useIdInjection()\n\n const id = computed(() => {\n return `${namespace.value}-popper-container-${idInjection.prefix}`\n })\n const selector = computed(() => `#${id.value}`)\n\n return {\n id,\n selector,\n }\n}\n\nconst createContainer = (id: string) => {\n const container = document.createElement('div')\n container.id = id\n document.body.appendChild(container)\n return container\n}\n\nexport const usePopperContainer = () => {\n const { id, selector } = usePopperContainerId()\n onBeforeMount(() => {\n if (!isClient) return\n\n // This is for bypassing the error that when under testing env, we often encounter\n // document.body.innerHTML = '' situation\n // for this we need to disable the caching since it's not really needed\n if (\n process.env.NODE_ENV === 'test' ||\n !document.body.querySelector(selector.value)\n ) {\n createContainer(id.value)\n }\n })\n\n return {\n id,\n selector,\n }\n}\n"],"names":[],"mappings":";;;;;AAIY,MAAC,oBAAoB,GAAG,MAAM;AAC1C,EAAE,MAAM,SAAS,GAAG,sBAAsB,EAAE,CAAC;AAC7C,EAAE,MAAM,WAAW,GAAG,cAAc,EAAE,CAAC;AACvC,EAAE,MAAM,EAAE,GAAG,QAAQ,CAAC,MAAM;AAC5B,IAAI,OAAO,CAAC,EAAE,SAAS,CAAC,KAAK,CAAC,kBAAkB,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC;AACvE,GAAG,CAAC,CAAC;AACL,EAAE,MAAM,QAAQ,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAClD,EAAE,OAAO;AACT,IAAI,EAAE;AACN,IAAI,QAAQ;AACZ,GAAG,CAAC;AACJ,EAAE;AACF,MAAM,eAAe,GAAG,CAAC,EAAE,KAAK;AAChC,EAAE,MAAM,SAAS,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;AAClD,EAAE,SAAS,CAAC,EAAE,GAAG,EAAE,CAAC;AACpB,EAAE,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;AACvC,EAAE,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC;AACU,MAAC,kBAAkB,GAAG,MAAM;AACxC,EAAE,MAAM,EAAE,EAAE,EAAE,QAAQ,EAAE,GAAG,oBAAoB,EAAE,CAAC;AAClD,EAAE,aAAa,CAAC,MAAM;AACtB,IAAI,IAAI,CAAC,QAAQ;AACjB,MAAM,OAAO;AACb,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;AACtD,MAAM,eAAe,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;AAChC,KAAK;AACL,GAAG,CAAC,CAAC;AACL,EAAE,OAAO;AACT,IAAI,EAAE;AACN,IAAI,QAAQ;AACZ,GAAG,CAAC;AACJ;;;;"}