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
+9
View File
@@ -0,0 +1,9 @@
import { Ref } from "vue";
//#region ../../packages/hooks/use-modal/index.d.ts
type ModalInstance = {
handleClose: () => void;
};
declare const useModal: (instance: ModalInstance, visibleRef: Ref<boolean>) => void;
//#endregion
export { useModal };
+27
View File
@@ -0,0 +1,27 @@
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
const require_runtime = require('../../_virtual/_rolldown/runtime.js');
const require_aria = require('../../constants/aria.js');
const require_event = require('../../utils/dom/event.js');
let _vueuse_core = require("@vueuse/core");
let vue = require("vue");
//#region ../../packages/hooks/use-modal/index.ts
const modalStack = [];
const closeModal = (e) => {
if (modalStack.length === 0) return;
if (require_event.getEventCode(e) === require_aria.EVENT_CODE.esc) {
e.stopPropagation();
modalStack[modalStack.length - 1].handleClose();
}
};
const useModal = (instance, visibleRef) => {
(0, vue.watch)(visibleRef, (val) => {
if (val) modalStack.push(instance);
else modalStack.splice(modalStack.indexOf(instance), 1);
});
};
if (_vueuse_core.isClient) (0, _vueuse_core.useEventListener)(document, "keydown", closeModal);
//#endregion
exports.useModal = useModal;
//# sourceMappingURL=index.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"index.js","names":["getEventCode","EVENT_CODE","isClient"],"sources":["../../../../../packages/hooks/use-modal/index.ts"],"sourcesContent":["import { watch } from 'vue'\nimport { isClient, useEventListener } from '@vueuse/core'\nimport { EVENT_CODE } from '@element-plus/constants'\nimport { getEventCode } from '@element-plus/utils'\n\nimport type { Ref } from 'vue'\n\ntype ModalInstance = {\n handleClose: () => void\n}\n\nconst modalStack: ModalInstance[] = []\n\nconst closeModal = (e: KeyboardEvent) => {\n if (modalStack.length === 0) return\n const code = getEventCode(e)\n if (code === EVENT_CODE.esc) {\n e.stopPropagation()\n const topModal = modalStack[modalStack.length - 1]\n topModal.handleClose()\n }\n}\n\nexport const useModal = (instance: ModalInstance, visibleRef: Ref<boolean>) => {\n watch(visibleRef, (val) => {\n if (val) {\n modalStack.push(instance)\n } else {\n modalStack.splice(modalStack.indexOf(instance), 1)\n }\n })\n}\n\nif (isClient) useEventListener(document, 'keydown', closeModal)\n"],"mappings":";;;;;;;;AAWA,MAAM,aAA8B,EAAE;AAEtC,MAAM,cAAc,MAAqB;AACvC,KAAI,WAAW,WAAW,EAAG;AAE7B,KADaA,2BAAa,EAAE,KACfC,wBAAW,KAAK;AAC3B,IAAE,iBAAiB;AAEnB,EADiB,WAAW,WAAW,SAAS,GACvC,aAAa;;;AAI1B,MAAa,YAAY,UAAyB,eAA6B;AAC7E,gBAAM,aAAa,QAAQ;AACzB,MAAI,IACF,YAAW,KAAK,SAAS;MAEzB,YAAW,OAAO,WAAW,QAAQ,SAAS,EAAE,EAAE;GAEpD;;AAGJ,IAAIC,sBAAU,oCAAiB,UAAU,WAAW,WAAW"}