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,6 @@
import type { Ref } from 'vue';
type ModalInstance = {
handleClose: () => void;
};
export declare const useModal: (instance: ModalInstance, visibleRef: Ref<boolean>) => void;
export {};

32
node_modules/element-plus/lib/hooks/use-modal/index.js generated vendored Normal file
View File

@@ -0,0 +1,32 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var vue = require('vue');
var core = require('@vueuse/core');
var aria = require('../../constants/aria.js');
const modalStack = [];
const closeModal = (e) => {
if (modalStack.length === 0)
return;
if (e.code === aria.EVENT_CODE.esc) {
e.stopPropagation();
const topModal = modalStack[modalStack.length - 1];
topModal.handleClose();
}
};
const useModal = (instance, visibleRef) => {
vue.watch(visibleRef, (val) => {
if (val) {
modalStack.push(instance);
} else {
modalStack.splice(modalStack.indexOf(instance), 1);
}
});
};
if (core.isClient)
core.useEventListener(document, "keydown", closeModal);
exports.useModal = useModal;
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","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'\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 if (e.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"],"names":["EVENT_CODE","watch","isClient","useEventListener"],"mappings":";;;;;;;;AAGA,MAAM,UAAU,GAAG,EAAE,CAAC;AACtB,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK;AAC1B,EAAE,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC;AAC7B,IAAI,OAAO;AACX,EAAE,IAAI,CAAC,CAAC,IAAI,KAAKA,eAAU,CAAC,GAAG,EAAE;AACjC,IAAI,CAAC,CAAC,eAAe,EAAE,CAAC;AACxB,IAAI,MAAM,QAAQ,GAAG,UAAU,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AACvD,IAAI,QAAQ,CAAC,WAAW,EAAE,CAAC;AAC3B,GAAG;AACH,CAAC,CAAC;AACU,MAAC,QAAQ,GAAG,CAAC,QAAQ,EAAE,UAAU,KAAK;AAClD,EAAEC,SAAK,CAAC,UAAU,EAAE,CAAC,GAAG,KAAK;AAC7B,IAAI,IAAI,GAAG,EAAE;AACb,MAAM,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AAChC,KAAK,MAAM;AACX,MAAM,UAAU,CAAC,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;AACzD,KAAK;AACL,GAAG,CAAC,CAAC;AACL,EAAE;AACF,IAAIC,aAAQ;AACZ,EAAEC,qBAAgB,CAAC,QAAQ,EAAE,SAAS,EAAE,UAAU,CAAC;;;;"}