Skip to content
This repository has been archived by the owner on Nov 24, 2023. It is now read-only.

Expose types correctly and add support for generic annotations #60

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,17 @@
"description": "react-image-annotation React component",
"author": "Arian Allenson Valdez <[email protected]> (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",
Expand Down
56 changes: 32 additions & 24 deletions src/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ declare module "react-image-annotation" {
id?: number;
};
}
interface IAnnotationProps {
interface IAnnotationProps<T> {
src: string;
alt?: string;
innerRef?: (e: any) => any;
Expand All @@ -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<IAnnotationProps, {}> {}
class Annotation<T> extends React.Component<IAnnotationProps<T>, {}> {}
export default Annotation;
}