index.d.ts 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  1. import * as vue from "vue";
  2. import { ShallowRef } from "vue";
  3. import { MaybeRef } from "@vueuse/core";
  4. //#region ../../packages/hooks/use-focus-controller/index.d.ts
  5. interface UseFocusControllerOptions {
  6. disabled?: MaybeRef<boolean>;
  7. /**
  8. * return true to cancel focus
  9. * @param event FocusEvent
  10. */
  11. beforeFocus?: (event: FocusEvent) => boolean | undefined;
  12. afterFocus?: () => void;
  13. /**
  14. * return true to cancel blur
  15. * @param event FocusEvent
  16. */
  17. beforeBlur?: (event: FocusEvent) => boolean | undefined;
  18. afterBlur?: () => void;
  19. }
  20. declare function useFocusController<T extends {
  21. focus: () => void;
  22. }>(target: ShallowRef<T | undefined>, {
  23. disabled,
  24. beforeFocus,
  25. afterFocus,
  26. beforeBlur,
  27. afterBlur
  28. }?: UseFocusControllerOptions): {
  29. isFocused: vue.Ref<boolean>; /** Avoid using wrapperRef and handleFocus/handleBlur together */
  30. wrapperRef: ShallowRef<HTMLElement | undefined>;
  31. handleFocus: (event: FocusEvent) => void;
  32. handleBlur: (event: FocusEvent) => void;
  33. };
  34. //#endregion
  35. export { useFocusController };