diff --git a/package.json b/package.json index a5bcdef..c262e56 100644 --- a/package.json +++ b/package.json @@ -4,14 +4,17 @@ "description": "react-image-annotation React component", "author": "Arian Allenson Valdez (http://arianv.com/)", "main": "lib/index.js", + "types": "src/types/index.d.ts", "module": "es/index.js", "files": [ "css", "es", "lib", - "umd" + "umd", + "src/types/index.d.ts" ], "scripts": { + "prepare": "nwb build-react-component", "build": "nwb build-react-component", "deploy": "gh-pages -d demo/dist", "clean": "nwb clean-module && nwb clean-demo", diff --git a/src/types/index.d.ts b/src/types/index.d.ts index 026db11..15b3890 100644 --- a/src/types/index.d.ts +++ b/src/types/index.d.ts @@ -35,7 +35,7 @@ declare module "react-image-annotation" { id?: number; }; } - interface IAnnotationProps { + interface IAnnotationProps { src: string; alt?: string; innerRef?: (e: any) => any; @@ -44,45 +44,53 @@ declare module "react-image-annotation" { onMouseMove?: (e: React.MouseEvent) => any; onClick?: (e: React.MouseEvent) => any; - annotations: IAnnotation[]; + annotations: T[]; type?: string; selectors?: ISelector[]; - value: IAnnotation | {}; + value: T | {}; onChange?: (e: any) => any; onSubmit?: (e: any) => any; - activeAnnotationComparator?: (annotation: IAnnotation) => boolean; - activeAnnotations?: IAnnotation[]; + activeAnnotationComparator?: (annotation: T) => boolean; + activeAnnotations?: T[]; disableAnnotation?: boolean; disableSelector?: boolean; - renderSelector?: ( - { annotation, active }: { annotation: IAnnotation; active: boolean } - ) => any; + renderSelector?: ({ + annotation, + active, + }: { + annotation: T; + active: boolean; + }) => any; disableEditor?: boolean; - renderEditor?: ( - { - annotation, - onChange, - onSubmit - }: { - annotation: IAnnotation; - onChange: (annotation: IAnnotation | {}) => any; - onSubmit: (e?: any) => any; - } - ) => any; + renderEditor?: ({ + annotation, + onChange, + onSubmit, + }: { + annotation: T; + onChange: (annotation: T | {}) => any; + onSubmit: (e?: any) => any; + }) => any; - renderHighlight?: ( - { annotation, active }: { annotation: IAnnotation; active: boolean } - ) => any; - renderContent?: ({ annotation }: { annotation: IAnnotation }) => any; + renderHighlight?: ({ + key, + annotation, + active, + }: { + key: string; + annotation: T; + active: boolean; + }) => any; + renderContent?: ({ annotation }: { annotation: T }) => any; disableOverlay?: boolean; renderOverlay?: () => any; allowTouch: boolean; } - class Annotation extends React.Component {} + class Annotation extends React.Component, {}> {} export default Annotation; }