Prompt Title: React Annotator

Created 1 year ago
Votes 0
Views 264 times
0

Prompt Detail:

I have a react component written in typescript and class-based. I want you to rewrite it correctly in react without typescript as a functional component according to version 18 syntax of react. I'll be sharing the large code in smaller chunks for you to understand and then ask for the final result. Here is the types: ``` import * as React from 'react'; import 'antd/lib/button/style/css'; import 'antd/lib/form/style/css'; import 'antd/lib/select/style/css'; interface Props { imageUrl: string; height: number; width: number; types: Array<string>; asyncUpload?: (data: any) => Promise<any>; disableAnnotation?: boolean; defaultType?: string; defaultSceneType?: string; defaultBoxes?: Array<BoundingBox>; showButton?: boolean; sceneTypes?: Array<string>; className?: string; style?: any; mask?: Array<number>; imageName?: string; orientation?: string; orientedPart?: Array<string>; onCheck?: boolean; setOnCheck?: (val: boolean) => void matching?: boolean; onTableUpdate?:(boxes: Array<Object>, imgName: String) => void imageOnOff?: boolean; partWiseDamage?: string; partSegId?: string; uni?: number; guideColor?: string; } interface State { isAnnotating: boolean; showAnnotation: boolean; annotation: string; damage: string; hover: boolean; mouse_down: boolean; uploadIcon: 'upload' | 'check' | 'loading' | 'close'; lock: boolean; uploaded: boolean; x: number; y: number; sceneType: string; hoverEdge?: string; isMovingBox: boolean; } interface BoundingBox { x: number; y: number; w: number; h: number; annotation: string; damage: string; } declare class Box { x: number; y: number; w: number; h: number; hover: boolean; chosen: boolean; lock: boolean; annotation: string; damage: string; constructor(x: number, y: number, w: number, h: number); insideBox(x: number, y: number): boolean; insideInnerBox(x: number, y: number): boolean; getEdgeCursorIsOn(x: number, y: number): string | undefined; getData(): BoundingBox; static fromBoundingBox(data: BoundingBox): Box; moveBoxByDrag(xMovement: number, yMovement: number): void; resizeByDrag(edge: string | undefined, xMovement: number, yMovement: number): void; } export declare class Annotator extends React.Component<Props, State> { private readonly imageCanvas; private readonly image; private canvas?; private ctx?; private lastZoomScale?; private lastX?; private lastY?; private position; private scale; private startX; private startY; private dragX?; private dragY?; private annotatingBox; private chosenBox; private isDrawing; private boxes; private bg; private events; private nextDefaultType?; constructor(props: Props); componentWillReceiveProps(nextProps: Readonly<Props>, nextContext: any): void; componentDidMount(): void; componentWillUnmount(): void; registerEvent: (element: Element | Window, event: string, listener: EventListener) => void; removeEvents: () => void; switchMode: () => void; setEventListeners: () => void; classifyPart: (boxe: Box) => void; onWheel: (e: WheelEvent) => void; onMouseMove: (e: MouseEvent) => void; searchChosenBox: () => Box | undefined; chooseBox: (box: Box, showAnnotation?: boolean) => void; refreshBoxTipPosition: () => void; cancelChosenBox: () => void; getCurrentCoordinate(box: Box): { x: number; y: number; w: number; h: number; }; mouseHoverCheck(mouseX: number, mouseY: number): void; invertTransform(x: number, y: number): { x: number; y: number; }; magnify:(img: string, canvasDiv: string) => void; magnifyer_mode_on_off: () => void getOriginalXY(pageX: number, pageY: number): number[]; moveSmallDistance(pageX: number, pageY: number): boolean; gesturePinchZoom: (event: TouchEvent) => number; doZoom: (zoom: number, x?: number | null, y?: number | null) => void; doMove: (relativeX: number, relativeY: number) => void; annotateMove: (relativeX: number, relativeY: number) => void; dragMove: (relativeX: number, relativeY: number) => void; draw: (timestamp?: number | null) => void; initCanvas: (url: string) => void; getPostData: () => { image: string; height: number; width: number; boxes: BoundingBox[]; }; onUpload: () => void; onDelete: () => void; getDamageList: (part: string) => string[]; render(): JSX.Element; } export {}; ``` Wait for more
avatar
Adarsh
Shared 2 prompts
Created 1 year ago

Leave a Comment

Related Tag Prompts

0
0
props drilling
1 year ago 2023-03-09 03:28:27 anik
0
0
Html para Reac.JS
1 year ago 2023-03-09 23:26:32 Tomás Sarmento
0
0
0
0
React Form Submission.
1 year ago 2023-03-17 13:51:57 nikita
0
2
react error
1 year ago 2023-04-07 11:13:29 tayyeb chaudhary
0
0
React 18: Social Auth
1 year ago 2023-04-17 20:37:06 me
0
0
Changement couleur menu survolé.
1 year ago 2023-07-05 14:20:14 stephane
0
0
React App for screenshot
1 year ago 2023-08-07 11:32:36 Apoorv Gupta
0
0
SSR with React: Pros/Cons
1 year ago 2023-09-04 08:47:46 AK
0
1
React Functional
1 year ago 2023-10-06 13:14:08 Adarsh