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,7 @@
import type { Ref, VNode } from 'vue';
export declare const useTeleport: (contentRenderer: () => VNode, appendToBody: Ref<boolean>) => {
isTeleportVisible: Ref<boolean>;
showTeleport: () => void;
hideTeleport: () => void;
renderTeleport: () => void;
};

View File

@@ -0,0 +1,47 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var vue = require('vue');
var globalNode = require('../../utils/vue/global-node.js');
var core = require('@vueuse/core');
var shared = require('@vue/shared');
const useTeleport = (contentRenderer, appendToBody) => {
const isTeleportVisible = vue.ref(false);
if (!core.isClient) {
return {
isTeleportVisible,
showTeleport: shared.NOOP,
hideTeleport: shared.NOOP,
renderTeleport: shared.NOOP
};
}
let $el = null;
const showTeleport = () => {
isTeleportVisible.value = true;
if ($el !== null)
return;
$el = globalNode.createGlobalNode();
};
const hideTeleport = () => {
isTeleportVisible.value = false;
if ($el !== null) {
globalNode.removeGlobalNode($el);
$el = null;
}
};
const renderTeleport = () => {
return appendToBody.value !== true ? contentRenderer() : isTeleportVisible.value ? [vue.h(vue.Teleport, { to: $el }, contentRenderer())] : void 0;
};
vue.onUnmounted(hideTeleport);
return {
isTeleportVisible,
showTeleport,
hideTeleport,
renderTeleport
};
};
exports.useTeleport = useTeleport;
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sources":["../../../../../packages/hooks/use-teleport/index.ts"],"sourcesContent":["import { Teleport, h, onUnmounted, ref } from 'vue'\nimport {\n NOOP,\n createGlobalNode,\n isClient,\n removeGlobalNode,\n} from '@element-plus/utils'\n\nimport type { Ref, VNode } from 'vue'\n\nexport const useTeleport = (\n contentRenderer: () => VNode,\n appendToBody: Ref<boolean>\n) => {\n const isTeleportVisible = ref(false)\n\n if (!isClient) {\n return {\n isTeleportVisible,\n showTeleport: NOOP,\n hideTeleport: NOOP,\n renderTeleport: NOOP,\n }\n }\n\n let $el: HTMLElement | null = null\n\n const showTeleport = () => {\n isTeleportVisible.value = true\n // this allows the delayed showing strategy since the the content itself could be enterable\n // e.g. el-popper\n if ($el !== null) return\n\n $el = createGlobalNode()\n }\n\n const hideTeleport = () => {\n isTeleportVisible.value = false\n if ($el !== null) {\n removeGlobalNode($el)\n $el = null\n }\n }\n\n const renderTeleport = () => {\n return appendToBody.value !== true\n ? contentRenderer()\n : isTeleportVisible.value\n ? [h(Teleport, { to: $el }, contentRenderer())]\n : undefined\n }\n\n onUnmounted(hideTeleport)\n\n return {\n isTeleportVisible,\n showTeleport,\n hideTeleport,\n renderTeleport,\n }\n}\n"],"names":["ref","isClient","NOOP","createGlobalNode","removeGlobalNode","h","Teleport","onUnmounted"],"mappings":";;;;;;;;;AAOY,MAAC,WAAW,GAAG,CAAC,eAAe,EAAE,YAAY,KAAK;AAC9D,EAAE,MAAM,iBAAiB,GAAGA,OAAG,CAAC,KAAK,CAAC,CAAC;AACvC,EAAE,IAAI,CAACC,aAAQ,EAAE;AACjB,IAAI,OAAO;AACX,MAAM,iBAAiB;AACvB,MAAM,YAAY,EAAEC,WAAI;AACxB,MAAM,YAAY,EAAEA,WAAI;AACxB,MAAM,cAAc,EAAEA,WAAI;AAC1B,KAAK,CAAC;AACN,GAAG;AACH,EAAE,IAAI,GAAG,GAAG,IAAI,CAAC;AACjB,EAAE,MAAM,YAAY,GAAG,MAAM;AAC7B,IAAI,iBAAiB,CAAC,KAAK,GAAG,IAAI,CAAC;AACnC,IAAI,IAAI,GAAG,KAAK,IAAI;AACpB,MAAM,OAAO;AACb,IAAI,GAAG,GAAGC,2BAAgB,EAAE,CAAC;AAC7B,GAAG,CAAC;AACJ,EAAE,MAAM,YAAY,GAAG,MAAM;AAC7B,IAAI,iBAAiB,CAAC,KAAK,GAAG,KAAK,CAAC;AACpC,IAAI,IAAI,GAAG,KAAK,IAAI,EAAE;AACtB,MAAMC,2BAAgB,CAAC,GAAG,CAAC,CAAC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