feat: initial commit - Phase 1 & 2 core features

This commit is contained in:
hiderfong
2026-04-22 17:07:33 +08:00
commit 1773bda06b
25005 changed files with 6252106 additions and 0 deletions
+15
View 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 };
+55
View File
@@ -0,0 +1,55 @@
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
const require_runtime = 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
@@ -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;AACH,KAAI,gBAAO,QAAQ,CACjB,0BACE,mBACA,gDACD;CAGH,MAAM,KAAK,QAAQ,MAAMA,2BAAa,QAAQ;CAE9C,MAAM,oCAA2B,GAAG,GAAG,UAAU,SAAS,CAAC;CAE3D,IAAI,iBAAiB;CACrB,IAAI,qBAAqB;CACzB,IAAI,YAAY;CAChB,IAAI,UAAU;CAEd,MAAM,gBAAgB;AACpB,MAAI,QAAS;AAEb,YAAU;AACV,mBAAiB;AAGf,OAAI,OAAO,aAAa,YAAa;AACrC,OAAI,sBAAsB,UAAU;AAClC,aAAS,KAAK,MAAM,QAAQ;AAC5B,8BAAY,SAAS,MAAM,UAAU,MAAM;;KAE5C,IAAI;;AAET,gBAAM,UAAU,QAAQ;AACtB,MAAI,CAAC,KAAK;AACR,YAAS;AACT;;AAGF,YAAU;AACV,uBAAqB,CAACC,uBAAS,SAAS,MAAM,UAAU,MAAM;AAC9D,MAAI,oBAAoB;AACtB,eAAY,SAAS,KAAK,MAAM;AAChC,0BAAS,SAAS,MAAM,UAAU,MAAM;;AAE1C,mBAAiBC,iCAAkB,GAAG,UAAU,MAAM;EACtD,MAAM,kBACJ,SAAS,gBAAgB,eAAe,SAAS,KAAK;EACxD,MAAM,gBAAgBC,uBAAS,SAAS,MAAM,YAAY;AAC1D,MACE,iBAAiB,MAChB,mBAAmB,kBAAkB,aACtC,mBAEA,UAAS,KAAK,MAAM,QAAQ,eAAe,eAAe;GAE5D;AACF,+BAAqB,SAAS,CAAC"}