测试
This commit is contained in:
27
frontend/node_modules/element-plus/es/hooks/use-focus-controller/index.d.ts
generated
vendored
Normal file
27
frontend/node_modules/element-plus/es/hooks/use-focus-controller/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
import type { ShallowRef } from 'vue';
|
||||
import type { MaybeRef } from '@vueuse/core';
|
||||
interface UseFocusControllerOptions {
|
||||
disabled?: MaybeRef<boolean>;
|
||||
/**
|
||||
* return true to cancel focus
|
||||
* @param event FocusEvent
|
||||
*/
|
||||
beforeFocus?: (event: FocusEvent) => boolean | undefined;
|
||||
afterFocus?: () => void;
|
||||
/**
|
||||
* return true to cancel blur
|
||||
* @param event FocusEvent
|
||||
*/
|
||||
beforeBlur?: (event: FocusEvent) => boolean | undefined;
|
||||
afterBlur?: () => void;
|
||||
}
|
||||
export declare function useFocusController<T extends {
|
||||
focus: () => void;
|
||||
}>(target: ShallowRef<T | undefined>, { disabled, beforeFocus, afterFocus, beforeBlur, afterBlur, }?: UseFocusControllerOptions): {
|
||||
isFocused: import("vue").Ref<boolean>;
|
||||
/** Avoid using wrapperRef and handleFocus/handleBlur together */
|
||||
wrapperRef: ShallowRef<HTMLElement | undefined>;
|
||||
handleFocus: (event: FocusEvent) => void;
|
||||
handleBlur: (event: FocusEvent) => void;
|
||||
};
|
||||
export {};
|
||||
61
frontend/node_modules/element-plus/es/hooks/use-focus-controller/index.mjs
generated
vendored
Normal file
61
frontend/node_modules/element-plus/es/hooks/use-focus-controller/index.mjs
generated
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
import { getCurrentInstance, shallowRef, ref, unref, watch } from 'vue';
|
||||
import { useEventListener } from '@vueuse/core';
|
||||
import { isFocusable } from '../../utils/dom/aria.mjs';
|
||||
import { isFunction } from '@vue/shared';
|
||||
|
||||
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
|
||||
};
|
||||
}
|
||||
|
||||
export { useFocusController };
|
||||
//# sourceMappingURL=index.mjs.map
|
||||
1
frontend/node_modules/element-plus/es/hooks/use-focus-controller/index.mjs.map
generated
vendored
Normal file
1
frontend/node_modules/element-plus/es/hooks/use-focus-controller/index.mjs.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user