vnode.d.ts 2.7 KB

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