UNPKG

13.4 kBTypeScriptView Raw
1declare namespace preact {
2 interface ComponentProps {
3 children?:JSX.Element[];
4 key?:string;
5 }
6
7 interface DangerouslySetInnerHTML {
8 __html: string;
9 }
10
11 interface PreactHTMLAttributes {
12 dangerouslySetInnerHTML?:DangerouslySetInnerHTML;
13 key?:string;
14 ref?:(el?: Element) => void;
15 }
16
17 interface VNode {
18 nodeName:ComponentConstructor<any, any>|string;
19 attributes:{[name:string]:any};
20 children:VNode[];
21 key:string;
22 }
23
24 interface ComponentLifecycle<PropsType, StateType> {
25 componentWillMount?():void;
26
27 componentDidMount?():void;
28
29 componentWillUnmount?():void;
30
31 componentDidUnmount?():void;
32
33 componentWillReceiveProps?(props:PropsType):void;
34
35 shouldComponentUpdate?(props:PropsType):boolean;
36
37 componentWillUpdate?():void;
38
39 componentDidUpdate?():void;
40 }
41
42 interface ComponentConstructor<PropsType, StateType> {
43 new (props?:PropsType):Component<PropsType, StateType>;
44 }
45
46 abstract class Component<PropsType, StateType> implements ComponentLifecycle<PropsType, StateType> {
47 constructor(props?:PropsType);
48
49 state:StateType;
50 props:PropsType & ComponentProps;
51 base:HTMLElement;
52
53 linkState:(name:string) => void;
54
55 setState(state:StateType, opts?:any):void;
56
57 abstract render(props:PropsType & ComponentProps, state:any):JSX.Element;
58 }
59
60 function h<PropsType>(node:ComponentConstructor<PropsType, any>, params:PropsType, ...children:(JSX.Element|JSX.Element[]|string)[]):JSX.Element;
61 function h(node:string, params:JSX.HTMLAttributes&JSX.SVGAttributes&{[propName: string]: any}, ...children:(JSX.Element|JSX.Element[]|string)[]):JSX.Element;
62
63 function render(node:JSX.Element, parent:Element, merge?:boolean):Element;
64
65 function rerender():void;
66
67 function cloneElement(element:JSX.Element, props:any):JSX.Element;
68
69 var options:{
70 syncComponentUpdates?:boolean;
71 debounceRendering?:(render:() => void) => void;
72 vnode?:(vnode:VNode) => void;
73 event?:(event:Event) => Event;
74 };
75}
76
77declare module "preact" {
78 export = preact;
79}
80
81declare module "preact/devtools" {
82 // Empty. This module initializes the React Developer Tools integration
83 // when imported.
84}
85
86declare namespace JSX {
87 interface Element extends preact.VNode {
88
89 }
90
91 interface ElementClass extends preact.Component<any, any> {
92
93 }
94
95 interface ElementAttributesProperty {
96 props:any;
97 }
98
99 interface SVGAttributes {
100 clipPath?:string;
101 cx?:number | string;
102 cy?:number | string;
103 d?:string;
104 dx?:number | string;
105 dy?:number | string;
106 fill?:string;
107 fillOpacity?:number | string;
108 fontFamily?:string;
109 fontSize?:number | string;
110 fx?:number | string;
111 fy?:number | string;
112 gradientTransform?:string;
113 gradientUnits?:string;
114 markerEnd?:string;
115 markerMid?:string;
116 markerStart?:string;
117 offset?:number | string;
118 opacity?:number | string;
119 patternContentUnits?:string;
120 patternUnits?:string;
121 points?:string;
122 preserveAspectRatio?:string;
123 r?:number | string;
124 rx?:number | string;
125 ry?:number | string;
126 spreadMethod?:string;
127 stopColor?:string;
128 stopOpacity?:number | string;
129 stroke?:string;
130 strokeDasharray?:string;
131 strokeLinecap?:string;
132 strokeMiterlimit?:string;
133 strokeOpacity?:number | string;
134 strokeWidth?:number | string;
135 textAnchor?:string;
136 transform?:string;
137 version?:string;
138 viewBox?:string;
139 x1?:number | string;
140 x2?:number | string;
141 x?:number | string;
142 xlinkActuate?:string;
143 xlinkArcrole?:string;
144 xlinkHref?:string;
145 xlinkRole?:string;
146 xlinkShow?:string;
147 xlinkTitle?:string;
148 xlinkType?:string;
149 xmlBase?:string;
150 xmlLang?:string;
151 xmlSpace?:string;
152 y1?:number | string;
153 y2?:number | string;
154 y?:number | string;
155 }
156
157 interface PathAttributes {
158 d:string;
159 }
160
161 interface EventHandler<E extends Event> {
162 (event:E):void;
163 }
164
165 type ClipboardEventHandler = EventHandler<ClipboardEvent>;
166 type CompositionEventHandler = EventHandler<CompositionEvent>;
167 type DragEventHandler = EventHandler<DragEvent>;
168 type FocusEventHandler = EventHandler<FocusEvent>;
169 type KeyboardEventHandler = EventHandler<KeyboardEvent>;
170 type MouseEventHandler = EventHandler<MouseEvent>;
171 type TouchEventHandler = EventHandler<TouchEvent>;
172 type UIEventHandler = EventHandler<UIEvent>;
173 type WheelEventHandler = EventHandler<WheelEvent>;
174 type AnimationEventHandler = EventHandler<AnimationEvent>;
175 type TransitionEventHandler = EventHandler<TransitionEvent>;
176
177 type GenericEventHandler = EventHandler<Event>;
178
179 interface DOMAttributed {
180 // Clipboard Events
181 onCopy?:ClipboardEventHandler;
182 onCut?:ClipboardEventHandler;
183 onPaste?:ClipboardEventHandler;
184
185 // Composition Events
186 onCompositionEnd?:CompositionEventHandler;
187 onCompositionStart?:CompositionEventHandler;
188 onCompositionUpdate?:CompositionEventHandler;
189
190 // Focus Events
191 onFocus?:FocusEventHandler;
192 onBlur?:FocusEventHandler;
193
194 // Form Events
195 onChange?:GenericEventHandler;
196 onInput?:GenericEventHandler;
197 onSubmit?:GenericEventHandler;
198
199 // Keyboard Events
200 onKeyDown?:KeyboardEventHandler;
201 onKeyPress?:KeyboardEventHandler;
202 onKeyUp?:KeyboardEventHandler;
203
204 // Media Events
205 onAbort?:GenericEventHandler;
206 onCanPlay?:GenericEventHandler;
207 onCanPlayThrough?:GenericEventHandler;
208 onDurationChange?:GenericEventHandler;
209 onEmptied?:GenericEventHandler;
210 onEncrypted?:GenericEventHandler;
211 onEnded?:GenericEventHandler;
212 onLoadedData?:GenericEventHandler;
213 onLoadedMetadata?:GenericEventHandler;
214 onLoadStart?:GenericEventHandler;
215 onPause?:GenericEventHandler;
216 onPlay?:GenericEventHandler;
217 onPlaying?:GenericEventHandler;
218 onProgress?:GenericEventHandler;
219 onRateChange?:GenericEventHandler;
220 onSeeked?:GenericEventHandler;
221 onSeeking?:GenericEventHandler;
222 onStalled?:GenericEventHandler;
223 onSuspend?:GenericEventHandler;
224 onTimeUpdate?:GenericEventHandler;
225 onVolumeChange?:GenericEventHandler;
226 onWaiting?:GenericEventHandler;
227
228 // MouseEvents
229 onClick?:MouseEventHandler;
230 onContextMenu?:MouseEventHandler;
231 onDoubleClick?:MouseEventHandler;
232 onDrag?:DragEventHandler;
233 onDragEnd?:DragEventHandler;
234 onDragEnter?:DragEventHandler;
235 onDragExit?:DragEventHandler;
236 onDragLeave?:DragEventHandler;
237 onDragOver?:DragEventHandler;
238 onDragStart?:DragEventHandler;
239 onDrop?:DragEventHandler;
240 onMouseDown?:MouseEventHandler;
241 onMouseEnter?:MouseEventHandler;
242 onMouseLeave?:MouseEventHandler;
243 onMouseMove?:MouseEventHandler;
244 onMouseOut?:MouseEventHandler;
245 onMouseOver?:MouseEventHandler;
246 onMouseUp?:MouseEventHandler;
247
248 // Selection Events
249 onSelect?:GenericEventHandler;
250
251 // Touch Events
252 onTouchCancel?:TouchEventHandler;
253 onTouchEnd?:TouchEventHandler;
254 onTouchMove?:TouchEventHandler;
255 onTouchStart?:TouchEventHandler;
256
257 // UI Events
258 onScroll?:UIEventHandler;
259
260 // Wheel Events
261 onWheel?:WheelEventHandler;
262
263 // Animation Events
264 onAnimationStart?:AnimationEventHandler;
265 onAnimationEnd?:AnimationEventHandler;
266 onAnimationIteration?:AnimationEventHandler;
267
268 // Transition Events
269 onTransitionEnd?:TransitionEventHandler;
270 }
271
272 interface HTMLAttributes extends preact.PreactHTMLAttributes, DOMAttributed {
273 // Standard HTML Attributes
274 accept?:string;
275 acceptCharset?:string;
276 accessKey?:string;
277 action?:string;
278 allowFullScreen?:boolean;
279 allowTransparency?:boolean;
280 alt?:string;
281 async?:boolean;
282 autocomplete?:string;
283 autofocus?:boolean;
284 autoPlay?:boolean;
285 capture?:boolean;
286 cellPadding?:number | string;
287 cellSpacing?:number | string;
288 charSet?:string;
289 challenge?:string;
290 checked?:boolean;
291 class?:string | { [key:string]: boolean };
292 className?:string | { [key:string]: boolean };
293 cols?:number;
294 colSpan?:number;
295 content?:string;
296 contentEditable?:boolean;
297 contextMenu?:string;
298 controls?:boolean;
299 coords?:string;
300 crossOrigin?:string;
301 data?:string;
302 dateTime?:string;
303 default?:boolean;
304 defer?:boolean;
305 dir?:string;
306 disabled?:boolean;
307 download?:any;
308 draggable?:boolean;
309 encType?:string;
310 form?:string;
311 formAction?:string;
312 formEncType?:string;
313 formMethod?:string;
314 formNoValidate?:boolean;
315 formTarget?:string;
316 frameBorder?:number | string;
317 headers?:string;
318 height?:number | string;
319 hidden?:boolean;
320 high?:number;
321 href?:string;
322 hrefLang?:string;
323 for?:string;
324 httpEquiv?:string;
325 icon?:string;
326 id?:string;
327 inputMode?:string;
328 integrity?:string;
329 is?:string;
330 keyParams?:string;
331 keyType?:string;
332 kind?:string;
333 label?:string;
334 lang?:string;
335 list?:string;
336 loop?:boolean;
337 low?:number;
338 manifest?:string;
339 marginHeight?:number;
340 marginWidth?:number;
341 max?:number | string;
342 maxLength?:number;
343 media?:string;
344 mediaGroup?:string;
345 method?:string;
346 min?:number | string;
347 minLength?:number;
348 multiple?:boolean;
349 muted?:boolean;
350 name?:string;
351 noValidate?:boolean;
352 open?:boolean;
353 optimum?:number;
354 pattern?:string;
355 placeholder?:string;
356 poster?:string;
357 preload?:string;
358 radioGroup?:string;
359 readOnly?:boolean;
360 rel?:string;
361 required?:boolean;
362 role?:string;
363 rows?:number;
364 rowSpan?:number;
365 sandbox?:string;
366 scope?:string;
367 scoped?:boolean;
368 scrolling?:string;
369 seamless?:boolean;
370 selected?:boolean;
371 shape?:string;
372 size?:number;
373 sizes?:string;
374 span?:number;
375 spellCheck?:boolean;
376 src?:string;
377 srcset?:string;
378 srcDoc?:string;
379 srcLang?:string;
380 srcSet?:string;
381 start?:number;
382 step?:number | string;
383 style?:any;
384 summary?:string;
385 tabIndex?:number;
386 target?:string;
387 title?:string;
388 type?:string;
389 useMap?:string;
390 value?:string | string[];
391 width?:number | string;
392 wmode?:string;
393 wrap?:string;
394
395 // RDFa Attributes
396 about?:string;
397 datatype?:string;
398 inlist?:any;
399 prefix?:string;
400 property?:string;
401 resource?:string;
402 typeof?:string;
403 vocab?:string;
404 }
405
406 interface IntrinsicElements {
407 // HTML
408 a:HTMLAttributes;
409 abbr:HTMLAttributes;
410 address:HTMLAttributes;
411 area:HTMLAttributes;
412 article:HTMLAttributes;
413 aside:HTMLAttributes;
414 audio:HTMLAttributes;
415 b:HTMLAttributes;
416 base:HTMLAttributes;
417 bdi:HTMLAttributes;
418 bdo:HTMLAttributes;
419 big:HTMLAttributes;
420 blockquote:HTMLAttributes;
421 body:HTMLAttributes;
422 br:HTMLAttributes;
423 button:HTMLAttributes;
424 canvas:HTMLAttributes;
425 caption:HTMLAttributes;
426 cite:HTMLAttributes;
427 code:HTMLAttributes;
428 col:HTMLAttributes;
429 colgroup:HTMLAttributes;
430 data:HTMLAttributes;
431 datalist:HTMLAttributes;
432 dd:HTMLAttributes;
433 del:HTMLAttributes;
434 details:HTMLAttributes;
435 dfn:HTMLAttributes;
436 dialog:HTMLAttributes;
437 div:HTMLAttributes;
438 dl:HTMLAttributes;
439 dt:HTMLAttributes;
440 em:HTMLAttributes;
441 embed:HTMLAttributes;
442 fieldset:HTMLAttributes;
443 figcaption:HTMLAttributes;
444 figure:HTMLAttributes;
445 footer:HTMLAttributes;
446 form:HTMLAttributes;
447 h1:HTMLAttributes;
448 h2:HTMLAttributes;
449 h3:HTMLAttributes;
450 h4:HTMLAttributes;
451 h5:HTMLAttributes;
452 h6:HTMLAttributes;
453 head:HTMLAttributes;
454 header:HTMLAttributes;
455 hr:HTMLAttributes;
456 html:HTMLAttributes;
457 i:HTMLAttributes;
458 iframe:HTMLAttributes;
459 img:HTMLAttributes;
460 input:HTMLAttributes;
461 ins:HTMLAttributes;
462 kbd:HTMLAttributes;
463 keygen:HTMLAttributes;
464 label:HTMLAttributes;
465 legend:HTMLAttributes;
466 li:HTMLAttributes;
467 link:HTMLAttributes;
468 main:HTMLAttributes;
469 map:HTMLAttributes;
470 mark:HTMLAttributes;
471 menu:HTMLAttributes;
472 menuitem:HTMLAttributes;
473 meta:HTMLAttributes;
474 meter:HTMLAttributes;
475 nav:HTMLAttributes;
476 noscript:HTMLAttributes;
477 object:HTMLAttributes;
478 ol:HTMLAttributes;
479 optgroup:HTMLAttributes;
480 option:HTMLAttributes;
481 output:HTMLAttributes;
482 p:HTMLAttributes;
483 param:HTMLAttributes;
484 picture:HTMLAttributes;
485 pre:HTMLAttributes;
486 progress:HTMLAttributes;
487 q:HTMLAttributes;
488 rp:HTMLAttributes;
489 rt:HTMLAttributes;
490 ruby:HTMLAttributes;
491 s:HTMLAttributes;
492 samp:HTMLAttributes;
493 script:HTMLAttributes;
494 section:HTMLAttributes;
495 select:HTMLAttributes;
496 small:HTMLAttributes;
497 source:HTMLAttributes;
498 span:HTMLAttributes;
499 strong:HTMLAttributes;
500 style:HTMLAttributes;
501 sub:HTMLAttributes;
502 summary:HTMLAttributes;
503 sup:HTMLAttributes;
504 table:HTMLAttributes;
505 tbody:HTMLAttributes;
506 td:HTMLAttributes;
507 textarea:HTMLAttributes;
508 tfoot:HTMLAttributes;
509 th:HTMLAttributes;
510 thead:HTMLAttributes;
511 time:HTMLAttributes;
512 title:HTMLAttributes;
513 tr:HTMLAttributes;
514 track:HTMLAttributes;
515 u:HTMLAttributes;
516 ul:HTMLAttributes;
517 "var":HTMLAttributes;
518 video:HTMLAttributes;
519 wbr:HTMLAttributes;
520
521 //SVG
522 svg:SVGAttributes;
523
524 circle:SVGAttributes;
525 clipPath:SVGAttributes;
526 defs:SVGAttributes;
527 ellipse:SVGAttributes;
528 feBlend:SVGAttributes;
529 feColorMatrix:SVGAttributes;
530 feComponentTransfer:SVGAttributes;
531 feComposite:SVGAttributes;
532 feConvolveMatrix:SVGAttributes;
533 feDiffuseLighting:SVGAttributes;
534 feDisplacementMap:SVGAttributes;
535 feFlood:SVGAttributes;
536 feGaussianBlur:SVGAttributes;
537 feImage:SVGAttributes;
538 feMerge:SVGAttributes;
539 feMergeNode:SVGAttributes;
540 feMorphology:SVGAttributes;
541 feOffset:SVGAttributes;
542 feSpecularLighting:SVGAttributes;
543 feTile:SVGAttributes;
544 feTurbulence:SVGAttributes;
545 filter:SVGAttributes;
546 foreignObject:SVGAttributes;
547 g:SVGAttributes;
548 image:SVGAttributes;
549 line:SVGAttributes;
550 linearGradient:SVGAttributes;
551 marker:SVGAttributes;
552 mask:SVGAttributes;
553 path:SVGAttributes;
554 pattern:SVGAttributes;
555 polygon:SVGAttributes;
556 polyline:SVGAttributes;
557 radialGradient:SVGAttributes;
558 rect:SVGAttributes;
559 stop:SVGAttributes;
560 symbol:SVGAttributes;
561 text:SVGAttributes;
562 tspan:SVGAttributes;
563 use:SVGAttributes;
564 }
565}
\No newline at end of file