2
0

vnode.d.ts 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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. | number
  23. | null
  24. | undefined
  25. | ScopedSlotReturnArray
  26. interface ScopedSlotReturnArray extends Array<ScopedSlotReturnValue> {}
  27. // Scoped slots are guaranteed to return Array of VNodes starting in 2.6
  28. export type NormalizedScopedSlot = (props: any) => ScopedSlotChildren
  29. export type ScopedSlotChildren = VNode[] | undefined
  30. // Relaxed type compatible with $createElement
  31. export type VNodeChildren =
  32. | VNodeChildrenArrayContents
  33. | [ScopedSlot]
  34. | string
  35. | boolean
  36. | number
  37. | null
  38. | undefined
  39. export interface VNodeChildrenArrayContents
  40. extends Array<VNodeChildren | VNode> {}
  41. export interface VNode {
  42. tag?: string
  43. data?: VNodeData
  44. children?: VNode[]
  45. text?: string
  46. elm?: Node
  47. ns?: string
  48. context?: Vue
  49. key?: string | number | symbol | boolean
  50. componentOptions?: VNodeComponentOptions
  51. componentInstance?: Vue
  52. parent?: VNode
  53. raw?: boolean
  54. isStatic?: boolean
  55. isRootInsert: boolean
  56. isComment: boolean
  57. }
  58. export interface VNodeComponentOptions {
  59. Ctor: typeof Vue
  60. propsData?: object
  61. listeners?: object
  62. children?: VNode[]
  63. tag?: string
  64. }
  65. export type VNodeRef =
  66. | string
  67. | Ref
  68. | ((
  69. ref: Element | ComponentPublicInstance | null,
  70. refs: Record<string, any>
  71. ) => void)
  72. export interface VNodeData {
  73. key?: string | number
  74. slot?: string
  75. scopedSlots?: { [key: string]: ScopedSlot | undefined }
  76. ref?: VNodeRef
  77. refInFor?: boolean
  78. tag?: string
  79. staticClass?: string
  80. class?: any
  81. staticStyle?: { [key: string]: any }
  82. style?: StyleValue
  83. props?: { [key: string]: any }
  84. attrs?: { [key: string]: any }
  85. domProps?: { [key: string]: any }
  86. hook?: { [key: string]: Function }
  87. on?: { [key: string]: Function | Function[] }
  88. nativeOn?: { [key: string]: Function | Function[] }
  89. transition?: object
  90. show?: boolean
  91. inlineTemplate?: {
  92. render: Function
  93. staticRenderFns: Function[]
  94. }
  95. directives?: VNodeDirective[]
  96. keepAlive?: boolean
  97. }
  98. export interface VNodeDirective {
  99. name: string
  100. value?: any
  101. oldValue?: any
  102. expression?: string
  103. arg?: string
  104. oldArg?: string
  105. modifiers?: { [key: string]: boolean }
  106. def?: DirectiveFunction | DirectiveOptions
  107. }