aiflowy-ui-admin/node_modules/.vite/deps/chunk-6KKRONM6.js

212 lines
6.5 KiB
JavaScript

import {
isClient,
useEventListener
} from "./chunk-FYPMSKES.js";
import {
getCurrentInstance,
nextTick,
ref,
shallowRef,
unref,
watch
} from "./chunk-AAHVYXXY.js";
import {
init_shared_esm_bundler,
isFunction
} from "./chunk-OWZYVOTZ.js";
// ../node_modules/.pnpm/element-plus@2.11.7_vue@3.5.24_typescript@5.9.3_/node_modules/element-plus/es/utils/dom/aria.mjs
var FOCUSABLE_ELEMENT_SELECTORS = `a[href],button:not([disabled]),button:not([hidden]),:not([tabindex="-1"]),input:not([disabled]),input:not([type="hidden"]),select:not([disabled]),textarea:not([disabled])`;
var isHTMLElement = (e) => {
if (typeof Element === "undefined")
return false;
return e instanceof Element;
};
var isVisible = (element) => {
const computed = getComputedStyle(element);
return computed.position === "fixed" ? false : element.offsetParent !== null;
};
var obtainAllFocusableElements = (element) => {
return Array.from(element.querySelectorAll(FOCUSABLE_ELEMENT_SELECTORS)).filter((item) => isFocusable(item) && isVisible(item));
};
var isFocusable = (element) => {
if (element.tabIndex > 0 || element.tabIndex === 0 && element.getAttribute("tabIndex") !== null) {
return true;
}
if (element.tabIndex < 0 || element.hasAttribute("disabled") || element.getAttribute("aria-disabled") === "true") {
return false;
}
switch (element.nodeName) {
case "A": {
return !!element.href && element.rel !== "ignore";
}
case "INPUT": {
return !(element.type === "hidden" || element.type === "file");
}
case "BUTTON":
case "SELECT":
case "TEXTAREA": {
return true;
}
default: {
return false;
}
}
};
var triggerEvent = function(elm, name, ...opts) {
let eventName;
if (name.includes("mouse") || name.includes("click")) {
eventName = "MouseEvents";
} else if (name.includes("key")) {
eventName = "KeyboardEvent";
} else {
eventName = "HTMLEvents";
}
const evt = document.createEvent(eventName);
evt.initEvent(name, ...opts);
elm.dispatchEvent(evt);
return elm;
};
var isLeaf = (el) => !el.getAttribute("aria-owns");
var getSibling = (el, distance, elClass) => {
const { parentNode } = el;
if (!parentNode)
return null;
const siblings = parentNode.querySelectorAll(elClass);
const index = Array.prototype.indexOf.call(siblings, el);
return siblings[index + distance] || null;
};
var focusElement = (el, options) => {
if (!el || !el.focus)
return;
let cleanup = false;
if (isHTMLElement(el) && !isFocusable(el) && !el.getAttribute("tabindex")) {
el.setAttribute("tabindex", "-1");
cleanup = true;
}
el.focus(options);
if (isHTMLElement(el) && cleanup) {
el.removeAttribute("tabindex");
}
};
var focusNode = (el) => {
if (!el)
return;
focusElement(el);
!isLeaf(el) && el.click();
};
// ../node_modules/.pnpm/element-plus@2.11.7_vue@3.5.24_typescript@5.9.3_/node_modules/element-plus/es/hooks/use-focus-controller/index.mjs
init_shared_esm_bundler();
function useFocusController(target, {
disabled,
beforeFocus,
afterFocus,
beforeBlur,
afterBlur
} = {}) {
const instance = getCurrentInstance();
const { emit } = instance;
const wrapperRef = shallowRef();
const isFocused = ref(false);
const handleFocus = (event) => {
const cancelFocus = isFunction(beforeFocus) ? beforeFocus(event) : false;
if (unref(disabled) || isFocused.value || cancelFocus)
return;
isFocused.value = true;
emit("focus", event);
afterFocus == null ? void 0 : afterFocus();
};
const handleBlur = (event) => {
var _a;
const cancelBlur = isFunction(beforeBlur) ? beforeBlur(event) : false;
if (unref(disabled) || event.relatedTarget && ((_a = wrapperRef.value) == null ? void 0 : _a.contains(event.relatedTarget)) || cancelBlur)
return;
isFocused.value = false;
emit("blur", event);
afterBlur == null ? void 0 : afterBlur();
};
const handleClick = (event) => {
var _a, _b;
if (unref(disabled) || isFocusable(event.target) || ((_a = wrapperRef.value) == null ? void 0 : _a.contains(document.activeElement)) && wrapperRef.value !== document.activeElement)
return;
(_b = target.value) == null ? void 0 : _b.focus();
};
watch([wrapperRef, () => unref(disabled)], ([el, disabled2]) => {
if (!el)
return;
if (disabled2) {
el.removeAttribute("tabindex");
} else {
el.setAttribute("tabindex", "-1");
}
});
useEventListener(wrapperRef, "focus", handleFocus, true);
useEventListener(wrapperRef, "blur", handleBlur, true);
useEventListener(wrapperRef, "click", handleClick, true);
return {
isFocused,
wrapperRef,
handleFocus,
handleBlur
};
}
// ../node_modules/.pnpm/element-plus@2.11.7_vue@3.5.24_typescript@5.9.3_/node_modules/element-plus/es/utils/i18n.mjs
var isKorean = (text) => /([\uAC00-\uD7AF\u3130-\u318F])+/gi.test(text);
// ../node_modules/.pnpm/element-plus@2.11.7_vue@3.5.24_typescript@5.9.3_/node_modules/element-plus/es/hooks/use-composition/index.mjs
function useComposition({
afterComposition,
emit
}) {
const isComposing = ref(false);
const handleCompositionStart = (event) => {
emit == null ? void 0 : emit("compositionstart", event);
isComposing.value = true;
};
const handleCompositionUpdate = (event) => {
var _a;
emit == null ? void 0 : emit("compositionupdate", event);
const text = (_a = event.target) == null ? void 0 : _a.value;
const lastCharacter = text[text.length - 1] || "";
isComposing.value = !isKorean(lastCharacter);
};
const handleCompositionEnd = (event) => {
emit == null ? void 0 : emit("compositionend", event);
if (isComposing.value) {
isComposing.value = false;
nextTick(() => afterComposition(event));
}
};
const handleComposition = (event) => {
event.type === "compositionend" ? handleCompositionEnd(event) : handleCompositionUpdate(event);
};
return {
isComposing,
handleComposition,
handleCompositionStart,
handleCompositionUpdate,
handleCompositionEnd
};
}
// ../node_modules/.pnpm/element-plus@2.11.7_vue@3.5.24_typescript@5.9.3_/node_modules/element-plus/es/utils/browser.mjs
var isFirefox = () => isClient && /firefox/i.test(window.navigator.userAgent);
var isAndroid = () => isClient && /android/i.test(window.navigator.userAgent);
export {
isFirefox,
isAndroid,
obtainAllFocusableElements,
isFocusable,
triggerEvent,
isLeaf,
getSibling,
focusElement,
focusNode,
useFocusController,
useComposition
};
//# sourceMappingURL=chunk-6KKRONM6.js.map