完全跑通1.0版本
This commit is contained in:
9
frontend/node_modules/element-plus/es/hooks/use-modal/index.d.ts
generated
vendored
Normal file
9
frontend/node_modules/element-plus/es/hooks/use-modal/index.d.ts
generated
vendored
Normal 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 };
|
||||
24
frontend/node_modules/element-plus/es/hooks/use-modal/index.mjs
generated
vendored
Normal file
24
frontend/node_modules/element-plus/es/hooks/use-modal/index.mjs
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
import { EVENT_CODE } from "../../constants/aria.mjs";
|
||||
import { getEventCode } from "../../utils/dom/event.mjs";
|
||||
import { isClient, useEventListener } from "@vueuse/core";
|
||||
import { watch } from "vue";
|
||||
//#region ../../packages/hooks/use-modal/index.ts
|
||||
const modalStack = [];
|
||||
const closeModal = (e) => {
|
||||
if (modalStack.length === 0) return;
|
||||
if (getEventCode(e) === EVENT_CODE.esc) {
|
||||
e.stopPropagation();
|
||||
modalStack[modalStack.length - 1].handleClose();
|
||||
}
|
||||
};
|
||||
const useModal = (instance, visibleRef) => {
|
||||
watch(visibleRef, (val) => {
|
||||
if (val) modalStack.push(instance);
|
||||
else modalStack.splice(modalStack.indexOf(instance), 1);
|
||||
});
|
||||
};
|
||||
if (isClient) useEventListener(document, "keydown", closeModal);
|
||||
//#endregion
|
||||
export { useModal };
|
||||
|
||||
//# sourceMappingURL=index.mjs.map
|
||||
1
frontend/node_modules/element-plus/es/hooks/use-modal/index.mjs.map
generated
vendored
Normal file
1
frontend/node_modules/element-plus/es/hooks/use-modal/index.mjs.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.mjs","names":[],"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;CACvC,IAAI,WAAW,WAAW,GAAG;CAE7B,IADa,aAAa,EAClB,KAAK,WAAW,KAAK;EAC3B,EAAE,iBAAiB;EAEnB,WAD4B,WAAW,SAAS,GACvC,aAAa;;;AAI1B,MAAa,YAAY,UAAyB,eAA6B;CAC7E,MAAM,aAAa,QAAQ;EACzB,IAAI,KACF,WAAW,KAAK,SAAS;OAEzB,WAAW,OAAO,WAAW,QAAQ,SAAS,EAAE,EAAE;GAEpD;;AAGJ,IAAI,UAAU,iBAAiB,UAAU,WAAW,WAAW"}
|
||||
Reference in New Issue
Block a user