2
This commit is contained in:
42
normal-admin/node_modules/element-plus/es/utils/dom/event.mjs
generated
vendored
Normal file
42
normal-admin/node_modules/element-plus/es/utils/dom/event.mjs
generated
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
import { isAndroid } from '../browser.mjs';
|
||||
import { EVENT_CODE } from '../../constants/aria.mjs';
|
||||
|
||||
const composeEventHandlers = (theirsHandler, oursHandler, { checkForDefaultPrevented = true } = {}) => {
|
||||
const handleEvent = (event) => {
|
||||
const shouldPrevent = theirsHandler == null ? void 0 : theirsHandler(event);
|
||||
if (checkForDefaultPrevented === false || !shouldPrevent) {
|
||||
return oursHandler == null ? void 0 : oursHandler(event);
|
||||
}
|
||||
};
|
||||
return handleEvent;
|
||||
};
|
||||
const whenMouse = (handler) => {
|
||||
return (e) => e.pointerType === "mouse" ? handler(e) : void 0;
|
||||
};
|
||||
const getEventCode = (event) => {
|
||||
if (event.code && event.code !== "Unidentified")
|
||||
return event.code;
|
||||
const key = getEventKey(event);
|
||||
if (key) {
|
||||
if (Object.values(EVENT_CODE).includes(key))
|
||||
return key;
|
||||
switch (key) {
|
||||
case " ":
|
||||
return EVENT_CODE.space;
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
return "";
|
||||
};
|
||||
const getEventKey = (event) => {
|
||||
let key = event.key && event.key !== "Unidentified" ? event.key : "";
|
||||
if (!key && event.type === "keyup" && isAndroid()) {
|
||||
const target = event.target;
|
||||
key = target.value.charAt(target.selectionStart - 1);
|
||||
}
|
||||
return key;
|
||||
};
|
||||
|
||||
export { composeEventHandlers, getEventCode, getEventKey, whenMouse };
|
||||
//# sourceMappingURL=event.mjs.map
|
||||
Reference in New Issue
Block a user