vnode.d.ts 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. import { Vue } from './vue'
  2. import { DirectiveFunction, DirectiveOptions } from './options'
  3. import { Ref } from './v3-generated'
  4. import { ComponentPublicInstance } from './v3-component-public-instance'
  5. /**
  6. * For extending allowed non-declared props on components in TSX
  7. */
  8. export interface ComponentCustomProps {}
  9. /**
  10. * Default allowed non-declared props on component in TSX
  11. */
  12. export interface AllowedComponentProps {
  13. class?: unknown
  14. style?: unknown
  15. }
  16. export type ScopedSlot = (props: any) => ScopedSlotReturnValue
  17. type ScopedSlotReturnValue =
  18. | VNode
  19. | string
  20. | boolean
  21. | null
  22. | undefined
  23. | ScopedSlotReturnArray
  24. interface ScopedSlotReturnArray extends Array<ScopedSlotReturnValue> {}
  25. // Scoped slots are guaranteed to return Array of VNodes starting in 2.6
  26. export type NormalizedScopedSlot = (props: any) => ScopedSlotChildren
  27. export type ScopedSlotChildren = VNode[] | undefined
  28. // Relaxed type compatible with $createElement
  29. export type VNodeChildren =
  30. | VNodeChildrenArrayContents
  31. | [ScopedSlot]
  32. | string
  33. | boolean
  34. | null
  35. | undefined
  36. export interface VNodeChildrenArrayContents
  37. extends Array<VNodeChildren | VNode> {}
  38. export interface VNode {
  39. tag?: string
  40. data?: VNodeData
  41. children?: VNode[]
  42. text?: string
  43. elm?: Node
  44. ns?: string
  45. context?: Vue
  46. key?: string | number | symbol | boolean
  47. componentOptions?: VNodeComponentOptions
  48. componentInstance?: Vue
  49. parent?: VNode
  50. raw?: boolean
  51. isStatic?: boolean
  52. isRootInsert: boolean
  53. isComment: boolean
  54. }
  55. export interface VNodeComponentOptions {
  56. Ctor: typeof Vue
  57. propsData?: object
  58. listeners?: object
  59. children?: VNode[]
  60. tag?: string
  61. }
  62. export type VNodeRef =
  63. | string
  64. | Ref
  65. | ((
  66. ref: Element | ComponentPublicInstance | null,
  67. refs: Record<string, any>
  68. ) => void)
  69. export interface VNodeData {
  70. key?: string | number
  71. slot?: string
  72. scopedSlots?: { [key: string]: ScopedSlot | undefined }
  73. ref?: VNodeRef
  74. refInFor?: boolean
  75. tag?: string
  76. staticClass?: string
  77. class?: any
  78. staticStyle?: { [key: string]: any }
  79. style?: string | object[] | object
  80. props?: { [key: string]: any }
  81. attrs?: { [key: string]: any }
  82. domProps?: { [key: string]: any }
  83. hook?: { [key: string]: Function }
  84. on?: { [key: string]: Function | Function[] }
  85. nativeOn?: { [key: string]: Function | Function[] }
  86. transition?: object
  87. show?: boolean
  88. inlineTemplate?: {
  89. render: Function
  90. staticRenderFns: Function[]
  91. }
  92. directives?: VNodeDirective[]
  93. keepAlive?: boolean
  94. }
  95. export interface VNodeDirective {
  96. name: string
  97. value?: any
  98. oldValue?: any
  99. expression?: string
  100. arg?: string
  101. oldArg?: string
  102. modifiers?: { [key: string]: boolean }
  103. def?: DirectiveFunction | DirectiveOptions
  104. }