完全跑通1.0版本
This commit is contained in:
6
frontend/node_modules/element-plus/es/directives/click-outside/index.d.ts
generated
vendored
Normal file
6
frontend/node_modules/element-plus/es/directives/click-outside/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
import { ObjectDirective } from "vue";
|
||||
|
||||
//#region ../../packages/directives/click-outside/index.d.ts
|
||||
declare const ClickOutside: ObjectDirective<HTMLElement, any>;
|
||||
//#endregion
|
||||
export { ClickOutside as default };
|
||||
59
frontend/node_modules/element-plus/es/directives/click-outside/index.mjs
generated
vendored
Normal file
59
frontend/node_modules/element-plus/es/directives/click-outside/index.mjs
generated
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
import { isClient } from "../../utils/browser.mjs";
|
||||
import { isArray, isElement } from "../../utils/types.mjs";
|
||||
//#region ../../packages/directives/click-outside/index.ts
|
||||
const nodeList = /* @__PURE__ */ new Map();
|
||||
if (isClient) {
|
||||
let startClick;
|
||||
document.addEventListener("mousedown", (e) => startClick = e);
|
||||
document.addEventListener("mouseup", (e) => {
|
||||
if (startClick) {
|
||||
for (const handlers of nodeList.values()) for (const { documentHandler } of handlers) documentHandler(e, startClick);
|
||||
startClick = void 0;
|
||||
}
|
||||
});
|
||||
}
|
||||
function createDocumentHandler(el, binding) {
|
||||
let excludes = [];
|
||||
if (isArray(binding.arg)) excludes = binding.arg;
|
||||
else if (isElement(binding.arg)) excludes.push(binding.arg);
|
||||
return function(mouseup, mousedown) {
|
||||
const popperRef = binding.instance.popperRef;
|
||||
const mouseUpTarget = mouseup.target;
|
||||
const mouseDownTarget = mousedown?.target;
|
||||
const isBound = !binding || !binding.instance;
|
||||
const isTargetExists = !mouseUpTarget || !mouseDownTarget;
|
||||
const isContainedByEl = el.contains(mouseUpTarget) || el.contains(mouseDownTarget);
|
||||
const isSelf = el === mouseUpTarget;
|
||||
const isTargetExcluded = excludes.length && excludes.some((item) => item?.contains(mouseUpTarget)) || excludes.length && excludes.includes(mouseDownTarget);
|
||||
const isContainedByPopper = popperRef && (popperRef.contains(mouseUpTarget) || popperRef.contains(mouseDownTarget));
|
||||
if (isBound || isTargetExists || isContainedByEl || isSelf || isTargetExcluded || isContainedByPopper) return;
|
||||
binding.value(mouseup, mousedown);
|
||||
};
|
||||
}
|
||||
const ClickOutside = {
|
||||
beforeMount(el, binding) {
|
||||
if (!nodeList.has(el)) nodeList.set(el, []);
|
||||
nodeList.get(el).push({
|
||||
documentHandler: createDocumentHandler(el, binding),
|
||||
bindingFn: binding.value
|
||||
});
|
||||
},
|
||||
updated(el, binding) {
|
||||
if (!nodeList.has(el)) nodeList.set(el, []);
|
||||
const handlers = nodeList.get(el);
|
||||
const oldHandlerIndex = handlers.findIndex((item) => item.bindingFn === binding.oldValue);
|
||||
const newHandler = {
|
||||
documentHandler: createDocumentHandler(el, binding),
|
||||
bindingFn: binding.value
|
||||
};
|
||||
if (oldHandlerIndex >= 0) handlers.splice(oldHandlerIndex, 1, newHandler);
|
||||
else handlers.push(newHandler);
|
||||
},
|
||||
unmounted(el) {
|
||||
nodeList.delete(el);
|
||||
}
|
||||
};
|
||||
//#endregion
|
||||
export { ClickOutside as default };
|
||||
|
||||
//# sourceMappingURL=index.mjs.map
|
||||
1
frontend/node_modules/element-plus/es/directives/click-outside/index.mjs.map
generated
vendored
Normal file
1
frontend/node_modules/element-plus/es/directives/click-outside/index.mjs.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.mjs","names":[],"sources":["../../../../../packages/directives/click-outside/index.ts"],"sourcesContent":["import { isArray, isClient, isElement } from '@element-plus/utils'\n\nimport type {\n ComponentPublicInstance,\n DirectiveBinding,\n ObjectDirective,\n} from 'vue'\n\ntype DocumentHandler = <T extends MouseEvent>(mouseup: T, mousedown: T) => void\ntype FlushList = Map<\n HTMLElement,\n {\n documentHandler: DocumentHandler\n bindingFn: (...args: unknown[]) => unknown\n }[]\n>\n\nconst nodeList: FlushList = new Map()\n\nif (isClient) {\n let startClick: MouseEvent | undefined\n document.addEventListener('mousedown', (e: MouseEvent) => (startClick = e))\n document.addEventListener('mouseup', (e: MouseEvent) => {\n if (startClick) {\n for (const handlers of nodeList.values()) {\n for (const { documentHandler } of handlers) {\n documentHandler(e as MouseEvent, startClick)\n }\n }\n startClick = undefined\n }\n })\n}\n\nfunction createDocumentHandler(\n el: HTMLElement,\n binding: DirectiveBinding\n): DocumentHandler {\n let excludes: HTMLElement[] = []\n if (isArray(binding.arg)) {\n excludes = binding.arg\n } else if (isElement(binding.arg)) {\n // due to current implementation on binding type is wrong the type casting is necessary here\n excludes.push(binding.arg as unknown as HTMLElement)\n }\n return function (mouseup, mousedown) {\n const popperRef = (\n binding.instance as ComponentPublicInstance<{\n popperRef: HTMLElement\n }>\n ).popperRef\n const mouseUpTarget = mouseup.target as Node\n const mouseDownTarget = mousedown?.target as Node\n const isBound = !binding || !binding.instance\n const isTargetExists = !mouseUpTarget || !mouseDownTarget\n const isContainedByEl =\n el.contains(mouseUpTarget) || el.contains(mouseDownTarget)\n const isSelf = el === mouseUpTarget\n\n const isTargetExcluded =\n (excludes.length &&\n excludes.some((item) => item?.contains(mouseUpTarget))) ||\n (excludes.length && excludes.includes(mouseDownTarget as HTMLElement))\n const isContainedByPopper =\n popperRef &&\n (popperRef.contains(mouseUpTarget) || popperRef.contains(mouseDownTarget))\n if (\n isBound ||\n isTargetExists ||\n isContainedByEl ||\n isSelf ||\n isTargetExcluded ||\n isContainedByPopper\n ) {\n return\n }\n binding.value(mouseup, mousedown)\n }\n}\n\nconst ClickOutside: ObjectDirective<HTMLElement, any> = {\n beforeMount(el, binding) {\n // there could be multiple handlers on the element\n if (!nodeList.has(el)) {\n nodeList.set(el, [])\n }\n\n nodeList.get(el)!.push({\n documentHandler: createDocumentHandler(el, binding),\n bindingFn: binding.value,\n })\n },\n updated(el, binding) {\n if (!nodeList.has(el)) {\n nodeList.set(el, [])\n }\n\n const handlers = nodeList.get(el)!\n const oldHandlerIndex = handlers.findIndex(\n (item) => item.bindingFn === binding.oldValue\n )\n const newHandler = {\n documentHandler: createDocumentHandler(el, binding),\n bindingFn: binding.value,\n }\n\n if (oldHandlerIndex >= 0) {\n // replace the old handler to the new handler\n handlers.splice(oldHandlerIndex, 1, newHandler)\n } else {\n handlers.push(newHandler)\n }\n },\n unmounted(el) {\n // remove all listeners when a component unmounted\n nodeList.delete(el)\n },\n}\n\nexport default ClickOutside\n"],"mappings":";;;AAiBA,MAAM,2BAAsB,IAAI,KAAK;AAErC,IAAI,UAAU;CACZ,IAAI;CACJ,SAAS,iBAAiB,cAAc,MAAmB,aAAa,EAAG;CAC3E,SAAS,iBAAiB,YAAY,MAAkB;EACtD,IAAI,YAAY;GACd,KAAK,MAAM,YAAY,SAAS,QAAQ,EACtC,KAAK,MAAM,EAAE,qBAAqB,UAChC,gBAAgB,GAAiB,WAAW;GAGhD,aAAa,KAAA;;GAEf;;AAGJ,SAAS,sBACP,IACA,SACiB;CACjB,IAAI,WAA0B,EAAE;CAChC,IAAI,QAAQ,QAAQ,IAAI,EACtB,WAAW,QAAQ;MACd,IAAI,UAAU,QAAQ,IAAI,EAE/B,SAAS,KAAK,QAAQ,IAA8B;CAEtD,OAAO,SAAU,SAAS,WAAW;EACnC,MAAM,YACJ,QAAQ,SAGR;EACF,MAAM,gBAAgB,QAAQ;EAC9B,MAAM,kBAAkB,WAAW;EACnC,MAAM,UAAU,CAAC,WAAW,CAAC,QAAQ;EACrC,MAAM,iBAAiB,CAAC,iBAAiB,CAAC;EAC1C,MAAM,kBACJ,GAAG,SAAS,cAAc,IAAI,GAAG,SAAS,gBAAgB;EAC5D,MAAM,SAAS,OAAO;EAEtB,MAAM,mBACH,SAAS,UACR,SAAS,MAAM,SAAS,MAAM,SAAS,cAAc,CAAC,IACvD,SAAS,UAAU,SAAS,SAAS,gBAA+B;EACvE,MAAM,sBACJ,cACC,UAAU,SAAS,cAAc,IAAI,UAAU,SAAS,gBAAgB;EAC3E,IACE,WACA,kBACA,mBACA,UACA,oBACA,qBAEA;EAEF,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