jsx.d.ts 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763
  1. // This code is based on https://github.com/wonderful-panda/vue-tsx-support
  2. // published under the MIT license.
  3. // Copyright by @wonderful-panda
  4. //
  5. // which is in turn based on the react definition in DefinitelyTyped
  6. // published under the MIT license.
  7. // Repository: https://github.com/DefinitelyTyped/DefinitelyTyped
  8. // Path in the repository: types/react/v15/index.d.ts
  9. //
  10. // Copyrights of original definition are:
  11. // Asana <https://asana.com>
  12. // AssureSign <http://www.assuresign.com>
  13. // Microsoft <https://microsoft.com>
  14. // John Reilly <https://github.com/johnnyreilly/>
  15. // Benoit Benezech <https://github.com/bbenezech>
  16. // Patricio Zavolinsky <https://github.com/pzavolinsky>
  17. // Digiguru <https://github.com/digiguru>
  18. // Eric Anderson <https://github.com/ericanderson>
  19. // Albert Kurniawan <https://github.com/morcerf>
  20. // Tanguy Krotoff <https://github.com/tkrotoff>
  21. // Dovydas Navickas <https://github.com/DovydasNavickas>
  22. // Stéphane Goetz <https://github.com/onigoetz>
  23. interface HTMLAttributes {
  24. class?: any
  25. style?: string | { [key: string]: string | number }
  26. accesskey?: string
  27. contenteditable?: boolean
  28. contextmenu?: string
  29. dir?: string
  30. disabled?: boolean
  31. draggable?: boolean
  32. hidden?: boolean
  33. id?: string
  34. lang?: string
  35. spellcheck?: boolean
  36. tabindex?: number
  37. title?: string
  38. role?: string
  39. }
  40. interface AnchorHTMLAttributes extends HTMLAttributes {
  41. download?: any
  42. href?: string
  43. hreflang?: string
  44. media?: string
  45. rel?: string
  46. target?: string
  47. }
  48. interface AreaHTMLAttributes extends HTMLAttributes {
  49. alt?: string
  50. coord?: string
  51. download?: any
  52. href?: string
  53. hreflang?: string
  54. media?: string
  55. rel?: string
  56. shape?: string
  57. target?: string
  58. }
  59. interface AudioHTMLAttributes extends MediaHTMLAttributes {}
  60. interface BaseHTMLAttributes extends HTMLAttributes {
  61. href?: string
  62. target?: string
  63. }
  64. interface BlockquoteHTMLAttributes extends HTMLAttributes {
  65. cite?: string
  66. }
  67. interface ButtonHTMLAttributes extends HTMLAttributes {
  68. autofocus?: boolean
  69. disabled?: boolean
  70. form?: string
  71. formaction?: string
  72. formenctype?: string
  73. formmethod?: string
  74. formnovalidate?: boolean
  75. formtarget?: string
  76. name?: string
  77. type?: string
  78. value?: string | string[] | number
  79. }
  80. interface CanvasHTMLAttributes extends HTMLAttributes {
  81. height?: number | string
  82. width?: number | string
  83. }
  84. interface ColHTMLAttributes extends HTMLAttributes {
  85. span?: number
  86. }
  87. interface ColgroupHTMLAttributes extends ColHTMLAttributes {}
  88. interface DetailsHTMLAttributes extends HTMLAttributes {
  89. open?: boolean
  90. }
  91. interface DelHTMLAttributes extends HTMLAttributes {
  92. cite?: string
  93. datetime?: string
  94. }
  95. interface EmbedHTMLAttributes extends HTMLAttributes {
  96. height?: number | string
  97. src?: string
  98. type?: string
  99. width?: number | string
  100. }
  101. interface FieldsetHTMLAttributes extends HTMLAttributes {
  102. disabled?: boolean
  103. form?: string
  104. name?: string
  105. }
  106. interface FormHTMLAttributes extends HTMLAttributes {
  107. acceptcharset?: string
  108. action?: string
  109. autocomplete?: string
  110. enctype?: string
  111. method?: string
  112. name?: string
  113. novalidate?: boolean
  114. target?: string
  115. }
  116. interface HtmlHTMLAttributes extends HTMLAttributes {
  117. manifest?: string
  118. }
  119. interface IframeHTMLAttributes extends HTMLAttributes {
  120. allowfullscreen?: boolean
  121. allowtransparency?: boolean
  122. frameborder?: number | string
  123. height?: number | string
  124. marginheight?: number
  125. marginwidth?: number
  126. name?: string
  127. sandbox?: string
  128. scrolling?: string
  129. seamless?: boolean
  130. src?: string
  131. srcdoc?: string
  132. width?: number | string
  133. }
  134. interface ImgHTMLAttributes extends HTMLAttributes {
  135. alt?: string
  136. height?: number | string
  137. sizes?: string
  138. src?: string
  139. srcset?: string
  140. usemap?: string
  141. width?: number | string
  142. }
  143. interface InsHTMLAttributes extends HTMLAttributes {
  144. cite?: string
  145. datetime?: string
  146. }
  147. interface InputHTMLAttributes extends HTMLAttributes {
  148. accept?: string
  149. alt?: string
  150. autocomplete?: string
  151. autofocus?: boolean
  152. capture?: boolean // https://www.w3.org/tr/html-media-capture/#the-capture-attribute
  153. checked?: boolean
  154. crossorigin?: string
  155. disabled?: boolean
  156. form?: string
  157. formaction?: string
  158. formenctype?: string
  159. formmethod?: string
  160. formnovalidate?: boolean
  161. formtarget?: string
  162. height?: number | string
  163. list?: string
  164. max?: number | string
  165. maxlength?: number
  166. min?: number | string
  167. minlength?: number
  168. multiple?: boolean
  169. name?: string
  170. pattern?: string
  171. placeholder?: string
  172. readonly?: boolean
  173. required?: boolean
  174. size?: number
  175. src?: string
  176. step?: number | string
  177. type?: string
  178. value?: string | string[] | number
  179. width?: number | string
  180. }
  181. interface KeygenHTMLAttributes extends HTMLAttributes {
  182. autofocus?: boolean
  183. challenge?: string
  184. disabled?: boolean
  185. form?: string
  186. keytype?: string
  187. keyparams?: string
  188. name?: string
  189. }
  190. interface LabelHTMLAttributes extends HTMLAttributes {
  191. form?: string
  192. htmlfor?: string
  193. }
  194. interface LiHTMLAttributes extends HTMLAttributes {
  195. value?: string | string[] | number
  196. }
  197. interface LinkHTMLAttributes extends HTMLAttributes {
  198. href?: string
  199. hreflang?: string
  200. integrity?: string
  201. media?: string
  202. rel?: string
  203. sizes?: string
  204. type?: string
  205. }
  206. interface MapHTMLAttributes extends HTMLAttributes {
  207. name?: string
  208. }
  209. interface MenuHTMLAttributes extends HTMLAttributes {
  210. type?: string
  211. }
  212. interface MediaHTMLAttributes extends HTMLAttributes {
  213. autoplay?: boolean
  214. controls?: boolean
  215. crossorigin?: string
  216. loop?: boolean
  217. mediagroup?: string
  218. muted?: boolean
  219. preload?: string
  220. src?: string
  221. }
  222. interface MetaHTMLAttributes extends HTMLAttributes {
  223. charset?: string
  224. content?: string
  225. httpequiv?: string
  226. name?: string
  227. }
  228. interface MeterHTMLAttributes extends HTMLAttributes {
  229. form?: string
  230. high?: number
  231. low?: number
  232. max?: number | string
  233. min?: number | string
  234. optimum?: number
  235. value?: string | string[] | number
  236. }
  237. interface QuoteHTMLAttributes extends HTMLAttributes {
  238. cite?: string
  239. }
  240. interface ObjectHTMLAttributes extends HTMLAttributes {
  241. classid?: string
  242. data?: string
  243. form?: string
  244. height?: number | string
  245. name?: string
  246. type?: string
  247. usemap?: string
  248. width?: number | string
  249. wmode?: string
  250. }
  251. interface OlHTMLAttributes extends HTMLAttributes {
  252. reversed?: boolean
  253. start?: number
  254. }
  255. interface OptgroupHTMLAttributes extends HTMLAttributes {
  256. disabled?: boolean
  257. label?: string
  258. }
  259. interface OptionHTMLAttributes extends HTMLAttributes {
  260. disabled?: boolean
  261. label?: string
  262. selected?: boolean
  263. value?: string | string[] | number
  264. }
  265. interface OutputHTMLAttributes extends HTMLAttributes {
  266. form?: string
  267. htmlfor?: string
  268. name?: string
  269. }
  270. interface ParamHTMLAttributes extends HTMLAttributes {
  271. name?: string
  272. value?: string | string[] | number
  273. }
  274. interface ProgressHTMLAttributes extends HTMLAttributes {
  275. max?: number | string
  276. value?: string | string[] | number
  277. }
  278. interface ScriptHTMLAttributes extends HTMLAttributes {
  279. async?: boolean
  280. charset?: string
  281. crossorigin?: string
  282. defer?: boolean
  283. integrity?: string
  284. nonce?: string
  285. src?: string
  286. type?: string
  287. }
  288. interface SelectHTMLAttributes extends HTMLAttributes {
  289. autofocus?: boolean
  290. disabled?: boolean
  291. form?: string
  292. multiple?: boolean
  293. name?: string
  294. required?: boolean
  295. size?: number
  296. value?: string | string[] | number
  297. }
  298. interface SourceHTMLAttributes extends HTMLAttributes {
  299. media?: string
  300. sizes?: string
  301. src?: string
  302. srcset?: string
  303. type?: string
  304. }
  305. interface StyleHTMLAttributes extends HTMLAttributes {
  306. media?: string
  307. nonce?: string
  308. scoped?: boolean
  309. type?: string
  310. }
  311. interface TableHTMLAttributes extends HTMLAttributes {
  312. cellpadding?: number | string
  313. cellspacing?: number | string
  314. summary?: string
  315. }
  316. interface TextareaHTMLAttributes extends HTMLAttributes {
  317. autocomplete?: string
  318. autofocus?: boolean
  319. cols?: number
  320. dirname?: string
  321. disabled?: boolean
  322. form?: string
  323. maxlength?: number
  324. minlength?: number
  325. name?: string
  326. placeholder?: string
  327. readonly?: boolean
  328. required?: boolean
  329. rows?: number
  330. value?: string | string[] | number
  331. wrap?: string
  332. }
  333. interface TdHTMLAttributes extends HTMLAttributes {
  334. colspan?: number
  335. headers?: string
  336. rowspan?: number
  337. }
  338. interface ThHTMLAttributes extends HTMLAttributes {
  339. colspan?: number
  340. headers?: string
  341. rowspan?: number
  342. scope?: string
  343. }
  344. interface TimeHTMLAttributes extends HTMLAttributes {
  345. datetime?: string
  346. }
  347. interface TrackHTMLAttributes extends HTMLAttributes {
  348. default?: boolean
  349. kind?: string
  350. label?: string
  351. src?: string
  352. srclang?: string
  353. }
  354. interface VideoHTMLAttributes extends MediaHTMLAttributes {
  355. height?: number | string
  356. playsinline?: boolean
  357. poster?: string
  358. width?: number | string
  359. }
  360. interface AllHTMLAttributes extends HTMLAttributes {
  361. accept?: string
  362. acceptcharset?: string
  363. action?: boolean
  364. allowfullscreen?: boolean
  365. allowtransparency?: boolean
  366. alt?: string
  367. async?: boolean
  368. autocomplete?: string
  369. autofocus?: boolean
  370. autoplay?: boolean
  371. capture?: boolean // https://www.w3.org/tr/html-media-capture/#the-capture-attribute
  372. cellpadding?: number | string
  373. cellspacing?: number | string
  374. challenge?: string
  375. charset?: string
  376. checked?: boolean
  377. cite?: string
  378. classid?: string
  379. cols?: number
  380. colspan?: number
  381. content?: string
  382. controls?: boolean
  383. coord?: string
  384. crossorigin?: string
  385. data?: string
  386. datetime?: string
  387. default?: boolean
  388. defer?: boolean
  389. dirname?: string
  390. disabled?: boolean
  391. download?: any
  392. enctype?: string
  393. form?: string
  394. formaction?: string
  395. formenctype?: string
  396. formmethod?: string
  397. formnovalidate?: boolean
  398. formtarget?: string
  399. frameborder?: number | string
  400. headers?: string
  401. height?: number | string
  402. high?: number
  403. href?: string
  404. hreflang?: string
  405. htmlfor?: string
  406. httpequiv?: string
  407. integrity?: string
  408. keyparams?: string
  409. keytype?: string
  410. kind?: string
  411. label?: string
  412. list?: string
  413. loop?: boolean
  414. low?: number
  415. manifest?: string
  416. marginheight?: number
  417. marginwidth?: number
  418. max?: number | string
  419. maxlength?: number
  420. media?: string
  421. mediagroup?: string
  422. method?: string
  423. min?: number | string
  424. minlength?: number
  425. multiple?: boolean
  426. muted?: boolean
  427. name?: string
  428. nonce?: string
  429. novalidate?: boolean
  430. open?: boolean
  431. optimum?: number
  432. pattern?: string
  433. placeholder?: string
  434. playsinline?: boolean
  435. poster?: string
  436. preload?: string
  437. readonly?: boolean
  438. rel?: string
  439. required?: boolean
  440. reversed?: boolean
  441. rows?: number
  442. rowspan?: number
  443. sandbox?: string
  444. scope?: string
  445. scoped?: boolean
  446. scrolling?: string
  447. seamless?: boolean
  448. selected?: boolean
  449. shape?: string
  450. size?: number
  451. sizes?: string
  452. span?: number
  453. src?: string
  454. srcdoc?: string
  455. srclang?: string
  456. srcset?: string
  457. start?: number
  458. step?: number | string
  459. summary?: string
  460. target?: string
  461. type?: string
  462. usemap?: string
  463. value?: string | string[] | number
  464. width?: number | string
  465. wmode?: string
  466. wrap?: string
  467. }
  468. interface IntrinsicElementAttributes {
  469. a: AnchorHTMLAttributes
  470. abbr: HTMLAttributes
  471. address: HTMLAttributes
  472. area: AreaHTMLAttributes
  473. article: HTMLAttributes
  474. aside: HTMLAttributes
  475. audio: AudioHTMLAttributes
  476. b: HTMLAttributes
  477. base: BaseHTMLAttributes
  478. bdi: HTMLAttributes
  479. bdo: HTMLAttributes
  480. big: HTMLAttributes
  481. blockquote: BlockquoteHTMLAttributes
  482. body: HTMLAttributes
  483. br: HTMLAttributes
  484. button: ButtonHTMLAttributes
  485. canvas: CanvasHTMLAttributes
  486. caption: HTMLAttributes
  487. cite: HTMLAttributes
  488. code: HTMLAttributes
  489. col: ColHTMLAttributes
  490. colgroup: ColgroupHTMLAttributes
  491. data: HTMLAttributes
  492. datalist: HTMLAttributes
  493. dd: HTMLAttributes
  494. del: DelHTMLAttributes
  495. details: DetailsHTMLAttributes
  496. dfn: HTMLAttributes
  497. dialog: HTMLAttributes
  498. div: HTMLAttributes
  499. dl: HTMLAttributes
  500. dt: HTMLAttributes
  501. em: HTMLAttributes
  502. embed: EmbedHTMLAttributes
  503. fieldset: FieldsetHTMLAttributes
  504. figcaption: HTMLAttributes
  505. figure: HTMLAttributes
  506. footer: HTMLAttributes
  507. form: FormHTMLAttributes
  508. h1: HTMLAttributes
  509. h2: HTMLAttributes
  510. h3: HTMLAttributes
  511. h4: HTMLAttributes
  512. h5: HTMLAttributes
  513. h6: HTMLAttributes
  514. head: HTMLAttributes
  515. header: HTMLAttributes
  516. hgroup: HTMLAttributes
  517. hr: HTMLAttributes
  518. html: HtmlHTMLAttributes
  519. i: HTMLAttributes
  520. iframe: IframeHTMLAttributes
  521. img: ImgHTMLAttributes
  522. input: InputHTMLAttributes
  523. ins: InsHTMLAttributes
  524. kbd: HTMLAttributes
  525. keygen: KeygenHTMLAttributes
  526. label: LabelHTMLAttributes
  527. legend: HTMLAttributes
  528. li: LiHTMLAttributes
  529. link: LinkHTMLAttributes
  530. main: HTMLAttributes
  531. map: MapHTMLAttributes
  532. mark: HTMLAttributes
  533. menu: MenuHTMLAttributes
  534. menuitem: HTMLAttributes
  535. meta: MetaHTMLAttributes
  536. meter: MeterHTMLAttributes
  537. nav: HTMLAttributes
  538. noscript: HTMLAttributes
  539. object: ObjectHTMLAttributes
  540. ol: OlHTMLAttributes
  541. optgroup: OptgroupHTMLAttributes
  542. option: OptionHTMLAttributes
  543. output: OutputHTMLAttributes
  544. p: HTMLAttributes
  545. param: ParamHTMLAttributes
  546. picture: HTMLAttributes
  547. pre: HTMLAttributes
  548. progress: ProgressHTMLAttributes
  549. q: QuoteHTMLAttributes
  550. rp: HTMLAttributes
  551. rt: HTMLAttributes
  552. ruby: HTMLAttributes
  553. s: HTMLAttributes
  554. samp: HTMLAttributes
  555. script: ScriptHTMLAttributes
  556. section: HTMLAttributes
  557. select: SelectHTMLAttributes
  558. small: HTMLAttributes
  559. source: SourceHTMLAttributes
  560. span: HTMLAttributes
  561. strong: HTMLAttributes
  562. style: StyleHTMLAttributes
  563. sub: HTMLAttributes
  564. summary: HTMLAttributes
  565. sup: HTMLAttributes
  566. table: TableHTMLAttributes
  567. tbody: HTMLAttributes
  568. td: TdHTMLAttributes
  569. textarea: TextareaHTMLAttributes
  570. tfoot: HTMLAttributes
  571. th: ThHTMLAttributes
  572. thead: HTMLAttributes
  573. time: TimeHTMLAttributes
  574. title: HTMLAttributes
  575. tr: HTMLAttributes
  576. track: TrackHTMLAttributes
  577. u: HTMLAttributes
  578. ul: HTMLAttributes
  579. var: HTMLAttributes
  580. video: VideoHTMLAttributes
  581. wbr: HTMLAttributes
  582. }
  583. interface Events {
  584. // clipboard events
  585. onCopy: ClipboardEvent
  586. onCut: ClipboardEvent
  587. onPaste: ClipboardEvent
  588. // composition events
  589. onCompositionend: CompositionEvent
  590. onCompositionstart: CompositionEvent
  591. onCompositionupdate: CompositionEvent
  592. // drag drop events
  593. onDrag: DragEvent
  594. onDragend: DragEvent
  595. onDragenter: DragEvent
  596. onDragexit: DragEvent
  597. onDragleave: DragEvent
  598. onDragover: DragEvent
  599. onDragstart: DragEvent
  600. onDrop: DragEvent
  601. // focus events
  602. onFocus: FocusEvent
  603. onBlur: FocusEvent
  604. // form events
  605. onChange: Event
  606. onInput: Event
  607. onReset: Event
  608. onSubmit: Event
  609. onInvalid: Event
  610. // image events
  611. onLoad: Event
  612. onError: Event
  613. // keyboard events
  614. onKeydown: KeyboardEvent
  615. onKeypress: KeyboardEvent
  616. onKeyup: KeyboardEvent
  617. // mouse events
  618. onClick: MouseEvent
  619. onContextmenu: MouseEvent
  620. onDblclick: MouseEvent
  621. onMousedown: MouseEvent
  622. onMouseenter: MouseEvent
  623. onMouseleave: MouseEvent
  624. onMousemove: MouseEvent
  625. onMouseout: MouseEvent
  626. onMouseover: MouseEvent
  627. onMouseup: MouseEvent
  628. // media events
  629. onAbort: Event
  630. onCanplay: Event
  631. onCanplaythrough: Event
  632. onDurationchange: Event
  633. onEmptied: Event
  634. onEncrypted: Event
  635. onEnded: Event
  636. onLoadeddata: Event
  637. onLoadedmetadata: Event
  638. onLoadstart: Event
  639. onPause: Event
  640. onPlay: Event
  641. onPlaying: Event
  642. onProgress: Event
  643. onRatechange: Event
  644. onSeeked: Event
  645. onSeeking: Event
  646. onStalled: Event
  647. onSuspend: Event
  648. onTimeupdate: Event
  649. onVolumechange: Event
  650. onWaiting: Event
  651. // selection events
  652. onSelect: Event
  653. // UI events
  654. onScroll: UIEvent
  655. // touch events
  656. onTouchcancel: TouchEvent
  657. onTouchend: TouchEvent
  658. onTouchmove: TouchEvent
  659. onTouchstart: TouchEvent
  660. // wheel events
  661. onWheel: WheelEvent
  662. // animation events
  663. onAnimationstart: AnimationEvent
  664. onAnimationend: AnimationEvent
  665. onAnimationiteration: AnimationEvent
  666. // transition events
  667. onTransitionend: TransitionEvent
  668. onTransitionstart: TransitionEvent
  669. }
  670. type StringKeyOf<T> = Extract<keyof T, string>
  671. type EventHandlers<E> = {
  672. [K in StringKeyOf<E>]?: E[K] extends Function ? E[K] : (payload: E[K]) => void
  673. }
  674. type ElementAttrs<T> = T & EventHandlers<Events>
  675. type NativeElements = {
  676. [K in StringKeyOf<IntrinsicElementAttributes>]: ElementAttrs<
  677. IntrinsicElementAttributes[K]
  678. >
  679. }
  680. declare namespace JSX {
  681. interface Element {}
  682. interface ElementClass {
  683. $props: {}
  684. }
  685. interface ElementAttributesProperty {
  686. $props: {}
  687. }
  688. interface IntrinsicElements extends NativeElements {
  689. // allow arbitrary elements
  690. [name: string]: any
  691. }
  692. }