v3-directive.d.ts 850 B

1234567891011121314151617181920212223242526272829
  1. import type { VNodeDirective, VNode } from './vnode'
  2. export type DirectiveModifiers = Record<string, boolean>
  3. export interface DirectiveBinding<V> extends Readonly<VNodeDirective> {
  4. readonly modifiers: DirectiveModifiers
  5. readonly value: V
  6. readonly oldValue: V | null
  7. }
  8. export type DirectiveHook<T = any, Prev = VNode | null, V = any> = (
  9. el: T,
  10. binding: DirectiveBinding<V>,
  11. vnode: VNode,
  12. prevVNode: Prev
  13. ) => void
  14. export interface ObjectDirective<T = any, V = any> {
  15. bind?: DirectiveHook<T, any, V>
  16. inserted?: DirectiveHook<T, any, V>
  17. update?: DirectiveHook<T, any, V>
  18. componentUpdated?: DirectiveHook<T, any, V>
  19. unbind?: DirectiveHook<T, any, V>
  20. }
  21. export type FunctionDirective<T = any, V = any> = DirectiveHook<T, any, V>
  22. export type Directive<T = any, V = any> =
  23. | ObjectDirective<T, V>
  24. | FunctionDirective<T, V>