完全跑通1.0版本
This commit is contained in:
15
frontend/node_modules/element-plus/lib/hooks/use-lockscreen/index.d.ts
generated
vendored
Normal file
15
frontend/node_modules/element-plus/lib/hooks/use-lockscreen/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
import { UseNamespaceReturn } from "../use-namespace/index.js";
|
||||
import { Ref } from "vue";
|
||||
|
||||
//#region ../../packages/hooks/use-lockscreen/index.d.ts
|
||||
type UseLockScreenOptions = {
|
||||
ns?: UseNamespaceReturn;
|
||||
};
|
||||
/**
|
||||
* Hook that monitoring the ref value to lock or unlock the screen.
|
||||
* When the trigger became true, it assumes modal is now opened and vice versa.
|
||||
* @param trigger {Ref<boolean>}
|
||||
*/
|
||||
declare const useLockscreen: (trigger: Ref<boolean>, options?: UseLockScreenOptions) => void;
|
||||
//#endregion
|
||||
export { UseLockScreenOptions, useLockscreen };
|
||||
54
frontend/node_modules/element-plus/lib/hooks/use-lockscreen/index.js
generated
vendored
Normal file
54
frontend/node_modules/element-plus/lib/hooks/use-lockscreen/index.js
generated
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
||||
require("../../_virtual/_rolldown/runtime.js");
|
||||
const require_error = require("../../utils/error.js");
|
||||
const require_style = require("../../utils/dom/style.js");
|
||||
const require_scroll = require("../../utils/dom/scroll.js");
|
||||
const require_index = require("../use-namespace/index.js");
|
||||
let vue = require("vue");
|
||||
//#region ../../packages/hooks/use-lockscreen/index.ts
|
||||
/**
|
||||
* Hook that monitoring the ref value to lock or unlock the screen.
|
||||
* When the trigger became true, it assumes modal is now opened and vice versa.
|
||||
* @param trigger {Ref<boolean>}
|
||||
*/
|
||||
const useLockscreen = (trigger, options = {}) => {
|
||||
if (!(0, vue.isRef)(trigger)) require_error.throwError("[useLockscreen]", "You need to pass a ref param to this function");
|
||||
const ns = options.ns || require_index.useNamespace("popup");
|
||||
const hiddenCls = (0, vue.computed)(() => ns.bm("parent", "hidden"));
|
||||
let scrollBarWidth = 0;
|
||||
let withoutHiddenClass = false;
|
||||
let bodyWidth = "0";
|
||||
let cleaned = false;
|
||||
const cleanup = () => {
|
||||
if (cleaned) return;
|
||||
cleaned = true;
|
||||
setTimeout(() => {
|
||||
if (typeof document === "undefined") return;
|
||||
if (withoutHiddenClass && document) {
|
||||
document.body.style.width = bodyWidth;
|
||||
require_style.removeClass(document.body, hiddenCls.value);
|
||||
}
|
||||
}, 200);
|
||||
};
|
||||
(0, vue.watch)(trigger, (val) => {
|
||||
if (!val) {
|
||||
cleanup();
|
||||
return;
|
||||
}
|
||||
cleaned = false;
|
||||
withoutHiddenClass = !require_style.hasClass(document.body, hiddenCls.value);
|
||||
if (withoutHiddenClass) {
|
||||
bodyWidth = document.body.style.width;
|
||||
require_style.addClass(document.body, hiddenCls.value);
|
||||
}
|
||||
scrollBarWidth = require_scroll.getScrollBarWidth(ns.namespace.value);
|
||||
const bodyHasOverflow = document.documentElement.clientHeight < document.body.scrollHeight;
|
||||
const bodyOverflowY = require_style.getStyle(document.body, "overflowY");
|
||||
if (scrollBarWidth > 0 && (bodyHasOverflow || bodyOverflowY === "scroll") && withoutHiddenClass) document.body.style.width = `calc(100% - ${scrollBarWidth}px)`;
|
||||
});
|
||||
(0, vue.onScopeDispose)(() => cleanup());
|
||||
};
|
||||
//#endregion
|
||||
exports.useLockscreen = useLockscreen;
|
||||
|
||||
//# sourceMappingURL=index.js.map
|
||||
1
frontend/node_modules/element-plus/lib/hooks/use-lockscreen/index.js.map
generated
vendored
Normal file
1
frontend/node_modules/element-plus/lib/hooks/use-lockscreen/index.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","names":["useNamespace","hasClass","getScrollBarWidth","getStyle"],"sources":["../../../../../packages/hooks/use-lockscreen/index.ts"],"sourcesContent":["import { computed, isRef, onScopeDispose, watch } from 'vue'\nimport {\n addClass,\n getScrollBarWidth,\n getStyle,\n hasClass,\n removeClass,\n throwError,\n} from '@element-plus/utils'\nimport { useNamespace } from '../use-namespace'\n\nimport type { Ref } from 'vue'\nimport type { UseNamespaceReturn } from '../use-namespace'\n\nexport type UseLockScreenOptions = {\n ns?: UseNamespaceReturn\n // shouldLock?: MaybeRef<boolean>\n}\n\n/**\n * Hook that monitoring the ref value to lock or unlock the screen.\n * When the trigger became true, it assumes modal is now opened and vice versa.\n * @param trigger {Ref<boolean>}\n */\nexport const useLockscreen = (\n trigger: Ref<boolean>,\n options: UseLockScreenOptions = {}\n) => {\n if (!isRef(trigger)) {\n throwError(\n '[useLockscreen]',\n 'You need to pass a ref param to this function'\n )\n }\n\n const ns = options.ns || useNamespace('popup')\n\n const hiddenCls = computed(() => ns.bm('parent', 'hidden'))\n\n let scrollBarWidth = 0\n let withoutHiddenClass = false\n let bodyWidth = '0'\n let cleaned = false\n\n const cleanup = () => {\n if (cleaned) return\n\n cleaned = true\n setTimeout(() => {\n // When the test case is running, the context environment simulated by jsdom may have been destroyed,\n // and the document does not exist at this time.\n if (typeof document === 'undefined') return\n if (withoutHiddenClass && document) {\n document.body.style.width = bodyWidth\n removeClass(document.body, hiddenCls.value)\n }\n }, 200)\n }\n watch(trigger, (val) => {\n if (!val) {\n cleanup()\n return\n }\n\n cleaned = false\n withoutHiddenClass = !hasClass(document.body, hiddenCls.value)\n if (withoutHiddenClass) {\n bodyWidth = document.body.style.width\n addClass(document.body, hiddenCls.value)\n }\n scrollBarWidth = getScrollBarWidth(ns.namespace.value)\n const bodyHasOverflow =\n document.documentElement.clientHeight < document.body.scrollHeight\n const bodyOverflowY = getStyle(document.body, 'overflowY')\n if (\n scrollBarWidth > 0 &&\n (bodyHasOverflow || bodyOverflowY === 'scroll') &&\n withoutHiddenClass\n ) {\n document.body.style.width = `calc(100% - ${scrollBarWidth}px)`\n }\n })\n onScopeDispose(() => cleanup())\n}\n"],"mappings":";;;;;;;;;;;;;AAwBA,MAAa,iBACX,SACA,UAAgC,EAAE,KAC/B;CACH,IAAI,EAAA,GAAA,IAAA,OAAO,QAAQ,EACjB,cAAA,WACE,mBACA,gDACD;CAGH,MAAM,KAAK,QAAQ,MAAMA,cAAAA,aAAa,QAAQ;CAE9C,MAAM,aAAA,GAAA,IAAA,gBAA2B,GAAG,GAAG,UAAU,SAAS,CAAC;CAE3D,IAAI,iBAAiB;CACrB,IAAI,qBAAqB;CACzB,IAAI,YAAY;CAChB,IAAI,UAAU;CAEd,MAAM,gBAAgB;EACpB,IAAI,SAAS;EAEb,UAAU;EACV,iBAAiB;GAGf,IAAI,OAAO,aAAa,aAAa;GACrC,IAAI,sBAAsB,UAAU;IAClC,SAAS,KAAK,MAAM,QAAQ;IAC5B,cAAA,YAAY,SAAS,MAAM,UAAU,MAAM;;KAE5C,IAAI;;CAET,CAAA,GAAA,IAAA,OAAM,UAAU,QAAQ;EACtB,IAAI,CAAC,KAAK;GACR,SAAS;GACT;;EAGF,UAAU;EACV,qBAAqB,CAACC,cAAAA,SAAS,SAAS,MAAM,UAAU,MAAM;EAC9D,IAAI,oBAAoB;GACtB,YAAY,SAAS,KAAK,MAAM;GAChC,cAAA,SAAS,SAAS,MAAM,UAAU,MAAM;;EAE1C,iBAAiBC,eAAAA,kBAAkB,GAAG,UAAU,MAAM;EACtD,MAAM,kBACJ,SAAS,gBAAgB,eAAe,SAAS,KAAK;EACxD,MAAM,gBAAgBC,cAAAA,SAAS,SAAS,MAAM,YAAY;EAC1D,IACE,iBAAiB,MAChB,mBAAmB,kBAAkB,aACtC,oBAEA,SAAS,KAAK,MAAM,QAAQ,eAAe,eAAe;GAE5D;CACF,CAAA,GAAA,IAAA,sBAAqB,SAAS,CAAC"}
|
||||
Reference in New Issue
Block a user