This commit is contained in:
gr
2026-11-11 14:22:02 +08:00
parent 245618dcdc
commit a62311a8da
64878 changed files with 3747172 additions and 66 deletions
@@ -0,0 +1,13 @@
import * as _$vue from "vue";
//#region ../../packages/hooks/use-popper-container/index.d.ts
declare const usePopperContainerId: () => {
id: _$vue.ComputedRef<string>;
selector: _$vue.ComputedRef<string>;
};
declare const usePopperContainer: () => {
id: _$vue.ComputedRef<string>;
selector: _$vue.ComputedRef<string>;
};
//#endregion
export { usePopperContainer, usePopperContainerId };
@@ -0,0 +1,39 @@
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const require_index = require("../use-namespace/index.js");
const require_index$1 = require("../use-id/index.js");
let vue = require("vue");
let _vueuse_core = require("@vueuse/core");
//#region ../../packages/hooks/use-popper-container/index.ts
const usePopperContainerId = () => {
const namespace = require_index.useGetDerivedNamespace();
const idInjection = require_index$1.useIdInjection();
const id = (0, vue.computed)(() => {
return `${namespace.value}-popper-container-${idInjection.prefix}`;
});
return {
id,
selector: (0, vue.computed)(() => `#${id.value}`)
};
};
const createContainer = (id) => {
const container = document.createElement("div");
container.id = id;
document.body.appendChild(container);
return container;
};
const usePopperContainer = () => {
const { id, selector } = usePopperContainerId();
(0, vue.onBeforeMount)(() => {
if (!_vueuse_core.isClient) return;
if (process.env.NODE_ENV === "test" || !document.body.querySelector(selector.value)) createContainer(id.value);
});
return {
id,
selector
};
};
//#endregion
exports.usePopperContainer = usePopperContainer;
exports.usePopperContainerId = usePopperContainerId;
//# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
{"version":3,"file":"index.js","names":["useGetDerivedNamespace","useIdInjection","computed","isClient"],"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"],"mappings":";;;;;;AAKA,MAAa,6BAA6B;CACxC,MAAM,YAAYA,cAAAA,uBAAuB;CACzC,MAAM,cAAcC,gBAAAA,eAAe;CAEnC,MAAM,MAAA,GAAKC,IAAAA,SAAAA,OAAe;EACxB,OAAO,GAAG,UAAU,MAAM,oBAAoB,YAAY;CAC5D,CAAC;CAGD,OAAO;EACL;EACA,WAAA,GAJeA,IAAAA,SAAAA,OAAe,IAAI,GAAG,OAI9B;CACT;AACF;AAEA,MAAM,mBAAmB,OAAe;CACtC,MAAM,YAAY,SAAS,cAAc,KAAK;CAC9C,UAAU,KAAK;CACf,SAAS,KAAK,YAAY,SAAS;CACnC,OAAO;AACT;AAEA,MAAa,2BAA2B;CACtC,MAAM,EAAE,IAAI,aAAa,qBAAqB;CAC9C,CAAA,GAAA,IAAA,cAAA,OAAoB;EAClB,IAAI,CAACC,aAAAA,UAAU;EAKf,IACE,QAAQ,IAAI,aAAa,UACzB,CAAC,SAAS,KAAK,cAAc,SAAS,KAAK,GAE3C,gBAAgB,GAAG,KAAK;CAE5B,CAAC;CAED,OAAO;EACL;EACA;CACF;AACF"}