完全跑通1.0版本
This commit is contained in:
35
frontend/node_modules/element-plus/es/hooks/use-focus-controller/index.d.ts
generated
vendored
Normal file
35
frontend/node_modules/element-plus/es/hooks/use-focus-controller/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
import * as _$vue from "vue";
|
||||
import { MaybeRef, ShallowRef } from "vue";
|
||||
|
||||
//#region ../../packages/hooks/use-focus-controller/index.d.ts
|
||||
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;
|
||||
}
|
||||
declare function useFocusController<T extends {
|
||||
focus: () => void;
|
||||
}>(target: ShallowRef<T | undefined>, {
|
||||
disabled,
|
||||
beforeFocus,
|
||||
afterFocus,
|
||||
beforeBlur,
|
||||
afterBlur
|
||||
}?: UseFocusControllerOptions): {
|
||||
isFocused: _$vue.Ref<boolean, boolean>; /** Avoid using wrapperRef and handleFocus/handleBlur together */
|
||||
wrapperRef: ShallowRef<HTMLElement | undefined, HTMLElement | undefined>;
|
||||
handleFocus: (event: FocusEvent) => void;
|
||||
handleBlur: (event: FocusEvent) => void;
|
||||
};
|
||||
//#endregion
|
||||
export { useFocusController };
|
||||
47
frontend/node_modules/element-plus/es/hooks/use-focus-controller/index.mjs
generated
vendored
Normal file
47
frontend/node_modules/element-plus/es/hooks/use-focus-controller/index.mjs
generated
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
import { isFocusable } from "../../utils/dom/aria.mjs";
|
||||
import { isFunction } from "../../utils/types.mjs";
|
||||
import { useEventListener } from "@vueuse/core";
|
||||
import { getCurrentInstance, ref, shallowRef, unref, watch } from "vue";
|
||||
//#region ../../packages/hooks/use-focus-controller/index.ts
|
||||
function useFocusController(target, { disabled, beforeFocus, afterFocus, beforeBlur, afterBlur } = {}) {
|
||||
const { emit } = getCurrentInstance();
|
||||
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?.();
|
||||
};
|
||||
const handleBlur = (event) => {
|
||||
const cancelBlur = isFunction(beforeBlur) ? beforeBlur(event) : false;
|
||||
if (unref(disabled) || event.relatedTarget && wrapperRef.value?.contains(event.relatedTarget) || cancelBlur) return;
|
||||
isFocused.value = false;
|
||||
emit("blur", event);
|
||||
afterBlur?.();
|
||||
};
|
||||
const handleClick = (event) => {
|
||||
if (unref(disabled) || isFocusable(event.target) || wrapperRef.value?.contains(document.activeElement) && wrapperRef.value !== document.activeElement) return;
|
||||
target.value?.focus();
|
||||
};
|
||||
watch([wrapperRef, () => unref(disabled)], ([el, disabled]) => {
|
||||
if (!el) return;
|
||||
if (disabled) 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,
|
||||
/** Avoid using wrapperRef and handleFocus/handleBlur together */
|
||||
wrapperRef,
|
||||
handleFocus,
|
||||
handleBlur
|
||||
};
|
||||
}
|
||||
//#endregion
|
||||
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
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.mjs","names":[],"sources":["../../../../../packages/hooks/use-focus-controller/index.ts"],"sourcesContent":["import {\n getCurrentInstance,\n onMounted,\n ref,\n shallowRef,\n unref,\n watch,\n} from 'vue'\nimport { useEventListener } from '@vueuse/core'\nimport { isElement, isFocusable, isFunction } from '@element-plus/utils'\n\nimport type { MaybeRef, ShallowRef } from 'vue'\n\ninterface UseFocusControllerOptions {\n disabled?: MaybeRef<boolean>\n /**\n * return true to cancel focus\n * @param event FocusEvent\n */\n beforeFocus?: (event: FocusEvent) => boolean | undefined\n afterFocus?: () => void\n /**\n * return true to cancel blur\n * @param event FocusEvent\n */\n beforeBlur?: (event: FocusEvent) => boolean | undefined\n afterBlur?: () => void\n}\n\nexport function useFocusController<T extends { focus: () => void }>(\n target: ShallowRef<T | undefined>,\n {\n disabled,\n beforeFocus,\n afterFocus,\n beforeBlur,\n afterBlur,\n }: UseFocusControllerOptions = {}\n) {\n const instance = getCurrentInstance()!\n const { emit } = instance\n const wrapperRef = shallowRef<HTMLElement>()\n const isFocused = ref(false)\n\n const handleFocus = (event: FocusEvent) => {\n const cancelFocus = isFunction(beforeFocus) ? beforeFocus(event) : false\n if (unref(disabled) || isFocused.value || cancelFocus) return\n\n isFocused.value = true\n emit('focus', event)\n afterFocus?.()\n }\n\n const handleBlur = (event: FocusEvent) => {\n const cancelBlur = isFunction(beforeBlur) ? beforeBlur(event) : false\n if (\n unref(disabled) ||\n (event.relatedTarget &&\n wrapperRef.value?.contains(event.relatedTarget as Node)) ||\n cancelBlur\n )\n return\n\n isFocused.value = false\n emit('blur', event)\n afterBlur?.()\n }\n\n const handleClick = (event: Event) => {\n if (\n unref(disabled) ||\n isFocusable(event.target as HTMLElement) ||\n (wrapperRef.value?.contains(document.activeElement) &&\n wrapperRef.value !== document.activeElement)\n )\n return\n\n target.value?.focus()\n }\n\n watch([wrapperRef, () => unref(disabled)], ([el, disabled]) => {\n if (!el) return\n if (disabled) {\n el.removeAttribute('tabindex')\n } else {\n el.setAttribute('tabindex', '-1')\n }\n })\n\n useEventListener(wrapperRef, 'focus', handleFocus, true)\n useEventListener(wrapperRef, 'blur', handleBlur, true)\n useEventListener(wrapperRef, 'click', handleClick, true)\n\n // only for test\n if (process.env.NODE_ENV === 'test') {\n onMounted(() => {\n const targetEl = isElement(target.value)\n ? target.value\n : document.querySelector('input,textarea')\n\n if (targetEl) {\n useEventListener(targetEl, 'focus', handleFocus, true)\n useEventListener(targetEl, 'blur', handleBlur, true)\n }\n })\n }\n\n return {\n isFocused,\n /** Avoid using wrapperRef and handleFocus/handleBlur together */\n wrapperRef,\n handleFocus,\n handleBlur,\n }\n}\n"],"mappings":";;;;;AA6BA,SAAgB,mBACd,QACA,EACE,UACA,aACA,YACA,YACA,cAC6B,EAAE,EACjC;CAEA,MAAM,EAAE,SADS,oBACQ;CACzB,MAAM,aAAa,YAAyB;CAC5C,MAAM,YAAY,IAAI,MAAM;CAE5B,MAAM,eAAe,UAAsB;EACzC,MAAM,cAAc,WAAW,YAAY,GAAG,YAAY,MAAM,GAAG;EACnE,IAAI,MAAM,SAAS,IAAI,UAAU,SAAS,aAAa;EAEvD,UAAU,QAAQ;EAClB,KAAK,SAAS,MAAM;EACpB,cAAc;;CAGhB,MAAM,cAAc,UAAsB;EACxC,MAAM,aAAa,WAAW,WAAW,GAAG,WAAW,MAAM,GAAG;EAChE,IACE,MAAM,SAAS,IACd,MAAM,iBACL,WAAW,OAAO,SAAS,MAAM,cAAsB,IACzD,YAEA;EAEF,UAAU,QAAQ;EAClB,KAAK,QAAQ,MAAM;EACnB,aAAa;;CAGf,MAAM,eAAe,UAAiB;EACpC,IACE,MAAM,SAAS,IACf,YAAY,MAAM,OAAsB,IACvC,WAAW,OAAO,SAAS,SAAS,cAAc,IACjD,WAAW,UAAU,SAAS,eAEhC;EAEF,OAAO,OAAO,OAAO;;CAGvB,MAAM,CAAC,kBAAkB,MAAM,SAAS,CAAC,GAAG,CAAC,IAAI,cAAc;EAC7D,IAAI,CAAC,IAAI;EACT,IAAI,UACF,GAAG,gBAAgB,WAAW;OAE9B,GAAG,aAAa,YAAY,KAAK;GAEnC;CAEF,iBAAiB,YAAY,SAAS,aAAa,KAAK;CACxD,iBAAiB,YAAY,QAAQ,YAAY,KAAK;CACtD,iBAAiB,YAAY,SAAS,aAAa,KAAK;CAgBxD,OAAO;EACL;;EAEA;EACA;EACA;EACD"}
|
||||
Reference in New Issue
Block a user