index.d.ts 893 B

12345678910111213141516171819202122232425
  1. import type { ShallowRef } from 'vue';
  2. interface UseFocusControllerOptions {
  3. /**
  4. * return true to cancel focus
  5. * @param event FocusEvent
  6. */
  7. beforeFocus?: (event: FocusEvent) => boolean | undefined;
  8. afterFocus?: () => void;
  9. /**
  10. * return true to cancel blur
  11. * @param event FocusEvent
  12. */
  13. beforeBlur?: (event: FocusEvent) => boolean | undefined;
  14. afterBlur?: () => void;
  15. }
  16. export declare function useFocusController<T extends {
  17. focus: () => void;
  18. }>(target: ShallowRef<T | undefined>, { beforeFocus, afterFocus, beforeBlur, afterBlur, }?: UseFocusControllerOptions): {
  19. isFocused: import("vue").Ref<boolean>;
  20. /** Avoid using wrapperRef and handleFocus/handleBlur together */
  21. wrapperRef: ShallowRef<HTMLElement | undefined>;
  22. handleFocus: (event: FocusEvent) => void;
  23. handleBlur: (event: FocusEvent) => void;
  24. };
  25. export {};