|
| 1 | +// special file for minimal import |
| 2 | +import * as React from 'react'; |
| 3 | +import Konva from 'konva/lib/index-types'; |
| 4 | + |
| 5 | +export interface KonvaNodeEvents { |
| 6 | + onMouseOver?(evt: Konva.KonvaEventObject<MouseEvent>): void; |
| 7 | + onMouseMove?(evt: Konva.KonvaEventObject<MouseEvent>): void; |
| 8 | + onMouseOut?(evt: Konva.KonvaEventObject<MouseEvent>): void; |
| 9 | + onMouseEnter?(evt: Konva.KonvaEventObject<MouseEvent>): void; |
| 10 | + onMouseLeave?(evt: Konva.KonvaEventObject<MouseEvent>): void; |
| 11 | + onMouseDown?(evt: Konva.KonvaEventObject<MouseEvent>): void; |
| 12 | + onMouseUp?(evt: Konva.KonvaEventObject<MouseEvent>): void; |
| 13 | + onWheel?(evt: Konva.KonvaEventObject<WheelEvent>): void; |
| 14 | + onClick?(evt: Konva.KonvaEventObject<MouseEvent>): void; |
| 15 | + onDblClick?(evt: Konva.KonvaEventObject<MouseEvent>): void; |
| 16 | + onTouchStart?(evt: Konva.KonvaEventObject<TouchEvent>): void; |
| 17 | + onTouchMove?(evt: Konva.KonvaEventObject<TouchEvent>): void; |
| 18 | + onTouchEnd?(evt: Konva.KonvaEventObject<TouchEvent>): void; |
| 19 | + onTap?(evt: Konva.KonvaEventObject<Event>): void; |
| 20 | + onDblTap?(evt: Konva.KonvaEventObject<Event>): void; |
| 21 | + onDragStart?(evt: Konva.KonvaEventObject<DragEvent>): void; |
| 22 | + onDragMove?(evt: Konva.KonvaEventObject<DragEvent>): void; |
| 23 | + onDragEnd?(evt: Konva.KonvaEventObject<DragEvent>): void; |
| 24 | + onTransform?(evt: Konva.KonvaEventObject<Event>): void; |
| 25 | + onTransformStart?(evt: Konva.KonvaEventObject<Event>): void; |
| 26 | + onTransformEnd?(evt: Konva.KonvaEventObject<Event>): void; |
| 27 | + onContextMenu?(evt: Konva.KonvaEventObject<PointerEvent>): void; |
| 28 | +} |
| 29 | + |
| 30 | +export interface KonvaNodeComponent< |
| 31 | + Node extends Konva.Node, |
| 32 | + Props = Konva.NodeConfig |
| 33 | + // We use React.ClassAttributes to fake the 'ref' attribute. This will ensure |
| 34 | + // consumers get the proper 'Node' type in 'ref' instead of the wrapper |
| 35 | + // component type. |
| 36 | +> extends React.SFC<Props & KonvaNodeEvents & React.ClassAttributes<Node>> { |
| 37 | + getPublicInstance(): Node; |
| 38 | + getNativeNode(): Node; |
| 39 | + // putEventListener(type: string, listener: Function): void; |
| 40 | + // handleEvent(event: Event): void; |
| 41 | +} |
| 42 | + |
| 43 | +export interface StageProps |
| 44 | + extends Konva.NodeConfig, |
| 45 | + KonvaNodeEvents, |
| 46 | + Pick< |
| 47 | + React.HTMLAttributes<HTMLDivElement>, |
| 48 | + 'className' | 'role' | 'style' | 'tabIndex' | 'title' |
| 49 | + > {} |
| 50 | + |
| 51 | +// Stage is the only real class because the others are stubs that only know how |
| 52 | +// to be rendered when they are under stage. Since there is no real backing |
| 53 | +// class and are in reality are a string literal we don't want users to actually |
| 54 | +// try and use them as a type. By defining them as a variable with an interface |
| 55 | +// consumers will not be able to use the values as a type or constructor. |
| 56 | +// The down side to this approach, is that typescript thinks the type is a |
| 57 | +// function, but if the user tries to call it a runtime exception will occur. |
| 58 | + |
| 59 | +export var Stage: KonvaNodeComponent<Konva.Stage, StageProps>; |
| 60 | +export var Layer: KonvaNodeComponent<Konva.Layer, Konva.LayerConfig>; |
| 61 | +export var FastLayer: KonvaNodeComponent<Konva.FastLayer, Konva.LayerConfig>; |
| 62 | +export var Group: KonvaNodeComponent<Konva.Group>; |
| 63 | +export var Label: KonvaNodeComponent<Konva.Label>; |
| 64 | + |
| 65 | +/** Shapes */ |
| 66 | +export var Rect: KonvaNodeComponent<Konva.Rect, Konva.RectConfig>; |
| 67 | +export var Circle: KonvaNodeComponent<Konva.Circle, Konva.CircleConfig>; |
| 68 | +export var Ellipse: KonvaNodeComponent<Konva.Ellipse, Konva.EllipseConfig>; |
| 69 | +export var Wedge: KonvaNodeComponent<Konva.Wedge, Konva.WedgeConfig>; |
| 70 | +export var Transformer: KonvaNodeComponent< |
| 71 | + Konva.Transformer, |
| 72 | + Konva.TransformerConfig |
| 73 | +>; |
| 74 | +export var Line: KonvaNodeComponent<Konva.Line, Konva.LineConfig>; |
| 75 | +export var Sprite: KonvaNodeComponent<Konva.Sprite, Konva.SpriteConfig>; |
| 76 | +export var Image: KonvaNodeComponent<Konva.Image, Konva.ImageConfig>; |
| 77 | +export var Text: KonvaNodeComponent<Konva.Text, Konva.TextConfig>; |
| 78 | +export var TextPath: KonvaNodeComponent<Konva.TextPath, Konva.TextPathConfig>; |
| 79 | +export var Star: KonvaNodeComponent<Konva.Star, Konva.StarConfig>; |
| 80 | +export var Ring: KonvaNodeComponent<Konva.Ring, Konva.RingConfig>; |
| 81 | +export var Arc: KonvaNodeComponent<Konva.Arc, Konva.ArcConfig>; |
| 82 | +export var Tag: KonvaNodeComponent<Konva.Tag, Konva.TagConfig>; |
| 83 | +export var Path: KonvaNodeComponent<Konva.Path, Konva.PathConfig>; |
| 84 | +export var RegularPolygon: KonvaNodeComponent< |
| 85 | + Konva.RegularPolygon, |
| 86 | + Konva.RegularPolygonConfig |
| 87 | +>; |
| 88 | +export var Arrow: KonvaNodeComponent<Konva.Arrow, Konva.ArrowConfig>; |
| 89 | +export var Shape: KonvaNodeComponent<Konva.Shape, Konva.ShapeConfig>; |
| 90 | + |
| 91 | +export var useStrictMode: (useStrictMode: boolean) => void; |
0 commit comments