测试
This commit is contained in:
11
frontend/node_modules/element-plus/lib/hooks/use-lockscreen/index.d.ts
generated
vendored
Normal file
11
frontend/node_modules/element-plus/lib/hooks/use-lockscreen/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
import type { Ref } from 'vue';
|
||||
import type { UseNamespaceReturn } from '../use-namespace';
|
||||
export 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>}
|
||||
*/
|
||||
export declare const useLockscreen: (trigger: Ref<boolean>, options?: UseLockScreenOptions) => void;
|
||||
55
frontend/node_modules/element-plus/lib/hooks/use-lockscreen/index.js
generated
vendored
Normal file
55
frontend/node_modules/element-plus/lib/hooks/use-lockscreen/index.js
generated
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
var vue = require('vue');
|
||||
var index = require('../use-namespace/index.js');
|
||||
var error = require('../../utils/error.js');
|
||||
var core = require('@vueuse/core');
|
||||
var style = require('../../utils/dom/style.js');
|
||||
var scroll = require('../../utils/dom/scroll.js');
|
||||
|
||||
const useLockscreen = (trigger, options = {}) => {
|
||||
if (!vue.isRef(trigger)) {
|
||||
error.throwError("[useLockscreen]", "You need to pass a ref param to this function");
|
||||
}
|
||||
const ns = options.ns || index.useNamespace("popup");
|
||||
const hiddenCls = vue.computed(() => ns.bm("parent", "hidden"));
|
||||
if (!core.isClient || style.hasClass(document.body, hiddenCls.value)) {
|
||||
return;
|
||||
}
|
||||
let scrollBarWidth = 0;
|
||||
let withoutHiddenClass = false;
|
||||
let bodyWidth = "0";
|
||||
const cleanup = () => {
|
||||
setTimeout(() => {
|
||||
if (typeof document === "undefined")
|
||||
return;
|
||||
if (withoutHiddenClass && document) {
|
||||
document.body.style.width = bodyWidth;
|
||||
style.removeClass(document.body, hiddenCls.value);
|
||||
}
|
||||
}, 200);
|
||||
};
|
||||
vue.watch(trigger, (val) => {
|
||||
if (!val) {
|
||||
cleanup();
|
||||
return;
|
||||
}
|
||||
withoutHiddenClass = !style.hasClass(document.body, hiddenCls.value);
|
||||
if (withoutHiddenClass) {
|
||||
bodyWidth = document.body.style.width;
|
||||
style.addClass(document.body, hiddenCls.value);
|
||||
}
|
||||
scrollBarWidth = scroll.getScrollBarWidth(ns.namespace.value);
|
||||
const bodyHasOverflow = document.documentElement.clientHeight < document.body.scrollHeight;
|
||||
const bodyOverflowY = style.getStyle(document.body, "overflowY");
|
||||
if (scrollBarWidth > 0 && (bodyHasOverflow || bodyOverflowY === "scroll") && withoutHiddenClass) {
|
||||
document.body.style.width = `calc(100% - ${scrollBarWidth}px)`;
|
||||
}
|
||||
});
|
||||
vue.onScopeDispose(() => cleanup());
|
||||
};
|
||||
|
||||
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","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 isClient,\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 if (!isClient || hasClass(document.body, hiddenCls.value)) {\n return\n }\n\n let scrollBarWidth = 0\n let withoutHiddenClass = false\n let bodyWidth = '0'\n\n const cleanup = () => {\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 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"],"names":["isRef","throwError","useNamespace","computed","isClient","hasClass","removeClass","watch","addClass","getScrollBarWidth","getStyle","onScopeDispose"],"mappings":";;;;;;;;;;;AAWY,MAAC,aAAa,GAAG,CAAC,OAAO,EAAE,OAAO,GAAG,EAAE,KAAK;AACxD,EAAE,IAAI,CAACA,SAAK,CAAC,OAAO,CAAC,EAAE;AACvB,IAAIC,gBAAU,CAAC,iBAAiB,EAAE,+CAA+C,CAAC,CAAC;AACnF,GAAG;AACH,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,EAAE,IAAIC,kBAAY,CAAC,OAAO,CAAC,CAAC;AACjD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