@abidibo/react-cam-roi 0.2.2 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -2
- package/dist/Components/BoolField/BoolField.module.css +60 -0
- package/dist/Components/Button/Button.module.css +29 -0
- package/dist/Components/EnumField/EnumField.module.css +61 -0
- package/dist/Components/IconButton/IconButton.module.css +20 -0
- package/dist/Components/Loader/Loader.module.css +25 -0
- package/dist/Components/Modal/Modal.module.css +92 -0
- package/dist/Components/NumberField/NumberField.module.css +60 -0
- package/dist/Components/RoiEditor/ColorPicker.module.css +17 -0
- package/dist/Components/RoiEditor/Header.module.css +26 -0
- package/dist/Components/RoiEditor/ParametersModalForm/ParametersModalForm.module.css +5 -0
- package/dist/Components/RoiEditor/RoiEditor.module.css +5 -0
- package/dist/Components/RoiEditor/ShapesList.module.css +71 -0
- package/dist/Components/RoiEditor/Toolbar.module.css +41 -0
- package/dist/Components/RoiEditor/TopBar.module.css +7 -0
- package/dist/Components/TextField/TextField.module.css +61 -0
- package/dist/index.cjs.css +2 -0
- package/dist/index.cjs.css.map +1 -0
- package/dist/index.cjs.js +1582 -0
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.esm.css +2 -0
- package/dist/index.esm.css.map +1 -0
- package/dist/index.esm.js +1576 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/types/Components/BoolField/index.d.ts +5 -0
- package/dist/types/Components/Button/index.d.ts +8 -0
- package/dist/types/Components/EnumField/index.d.ts +10 -0
- package/dist/types/Components/IconButton/index.d.ts +7 -0
- package/dist/types/Components/Loader/index.d.ts +1 -0
- package/dist/types/Components/Modal/index.d.ts +10 -0
- package/dist/types/Components/NumberField/index.d.ts +3 -0
- package/dist/types/Components/RoiEditor/Canvas.d.ts +14 -0
- package/dist/types/Components/RoiEditor/ColorPicker.d.ts +5 -0
- package/dist/types/Components/RoiEditor/Header.d.ts +2 -0
- package/dist/types/Components/RoiEditor/Hooks.d.ts +38 -0
- package/dist/types/Components/RoiEditor/ParameterField.d.ts +9 -0
- package/dist/types/Components/RoiEditor/ParametersModalForm/index.d.ts +17 -0
- package/dist/types/Components/RoiEditor/Polygon.d.ts +18 -0
- package/dist/types/Components/RoiEditor/Polyline.d.ts +28 -0
- package/dist/types/Components/RoiEditor/Rectangle.d.ts +21 -0
- package/dist/types/Components/RoiEditor/RoisInfo.d.ts +2 -0
- package/dist/types/Components/RoiEditor/ShapesList.d.ts +2 -0
- package/dist/types/Components/RoiEditor/Toolbar.d.ts +2 -0
- package/dist/types/Components/RoiEditor/TopBar.d.ts +2 -0
- package/dist/types/Components/RoiEditor/Types.d.ts +128 -0
- package/dist/types/Components/RoiEditor/Utils.d.ts +25 -0
- package/dist/types/Components/RoiEditor/index.d.ts +12 -0
- package/dist/types/Components/RoleField.d.ts +7 -0
- package/dist/types/Components/TextField/index.d.ts +6 -0
- package/dist/types/Components/Typography/index.d.ts +9 -0
- package/dist/types/Icons/AnnotateIcon.d.ts +6 -0
- package/dist/types/Icons/CloseIcon.d.ts +6 -0
- package/dist/types/Icons/CopyIcon.d.ts +6 -0
- package/dist/types/Icons/DeleteIcon.d.ts +6 -0
- package/dist/types/Icons/EditIcon.d.ts +6 -0
- package/dist/types/Icons/PointerIcon.d.ts +6 -0
- package/dist/types/Icons/PolygonIcon.d.ts +6 -0
- package/dist/types/Icons/PolylineIcon.d.ts +6 -0
- package/dist/types/Icons/RectangleIcon.d.ts +6 -0
- package/dist/types/Icons/SaveIcon.d.ts +6 -0
- package/dist/types/Providers/EditorProvider.d.ts +26 -0
- package/dist/types/Providers/UiProvider.d.ts +82 -0
- package/dist/types/Types.d.ts +10 -0
- package/dist/types/Utils/Dispatcher.d.ts +16 -0
- package/dist/types/Utils/index.d.ts +6 -0
- package/dist/types/index.d.ts +4 -0
- package/package.json +17 -6
@@ -0,0 +1,8 @@
|
|
1
|
+
import { PropsWithChildren } from 'react';
|
2
|
+
export type ButtonProps = {
|
3
|
+
onClick: (event: React.MouseEvent) => void;
|
4
|
+
primary?: boolean;
|
5
|
+
disabled?: boolean;
|
6
|
+
};
|
7
|
+
declare const Button: ({ onClick, primary, disabled, children }: PropsWithChildren<ButtonProps>) => import("react/jsx-runtime").JSX.Element;
|
8
|
+
export default Button;
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import { FieldProps } from '../../Types';
|
2
|
+
export type EnumOption<T> = {
|
3
|
+
value: T;
|
4
|
+
label: string;
|
5
|
+
};
|
6
|
+
declare const EnumField: <T extends string | number>({ onChange, value, label, helperText, error, options, disabled, required, multiple }: Omit<FieldProps<T | T[]>, "readOnly"> & {
|
7
|
+
options: EnumOption<T>[];
|
8
|
+
multiple?: boolean;
|
9
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
10
|
+
export default EnumField;
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare const Loader: React.FC;
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import { PropsWithChildren } from 'react';
|
2
|
+
export type ModalProps = {
|
3
|
+
isOpen: boolean;
|
4
|
+
onClose: () => void;
|
5
|
+
title: string;
|
6
|
+
maxWidth: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
7
|
+
onSubmit?: () => void;
|
8
|
+
};
|
9
|
+
declare const Modal: React.FC<PropsWithChildren<ModalProps>>;
|
10
|
+
export default Modal;
|
@@ -0,0 +1,14 @@
|
|
1
|
+
import { Output } from './Types';
|
2
|
+
type CanvasProps = {
|
3
|
+
canvasSize: {
|
4
|
+
width: number;
|
5
|
+
height: number;
|
6
|
+
};
|
7
|
+
imageSize: {
|
8
|
+
width: number;
|
9
|
+
height: number;
|
10
|
+
};
|
11
|
+
initialData?: Output;
|
12
|
+
};
|
13
|
+
declare const Canvas: React.FC<CanvasProps>;
|
14
|
+
export default Canvas;
|
@@ -0,0 +1,38 @@
|
|
1
|
+
import * as fabric from 'fabric';
|
2
|
+
import { Metadata, Output, OutputParameter, Shape, ShapeType } from './Types';
|
3
|
+
export declare const useImageSize: (imageUrl: string) => {
|
4
|
+
imageSize: {
|
5
|
+
width: number;
|
6
|
+
height: number;
|
7
|
+
};
|
8
|
+
isReady: boolean;
|
9
|
+
};
|
10
|
+
export declare const useCanvasSize: (imageUrl: string) => {
|
11
|
+
imageSize: {
|
12
|
+
width: number;
|
13
|
+
height: number;
|
14
|
+
};
|
15
|
+
canvasSize: {
|
16
|
+
width: number;
|
17
|
+
height: number;
|
18
|
+
};
|
19
|
+
wrapperRef: import("react").RefObject<HTMLDivElement>;
|
20
|
+
isReady: boolean;
|
21
|
+
};
|
22
|
+
export declare const initCanvasData: (canvasRef: React.MutableRefObject<fabric.Canvas | null>, imageSize: {
|
23
|
+
width: number;
|
24
|
+
height: number;
|
25
|
+
}, addShapes: (shapes: {
|
26
|
+
id: string;
|
27
|
+
type: ShapeType;
|
28
|
+
shape: Shape;
|
29
|
+
}[]) => void, metadata: Metadata, setMetadata: (v: Metadata) => void, initialData?: Output, enableLogs?: boolean) => void;
|
30
|
+
export declare const useTool: (canvas: fabric.Canvas | null) => void;
|
31
|
+
export declare const useDispatcherEvents: (canvas: fabric.Canvas | null) => void;
|
32
|
+
export declare const useParametersForm: (parameters: OutputParameter[]) => {
|
33
|
+
fields: Record<string, unknown>;
|
34
|
+
setField: <T>(key: string) => (value: T) => void;
|
35
|
+
setFields: import("react").Dispatch<import("react").SetStateAction<Record<string, unknown>>>;
|
36
|
+
errors: Record<string, string>;
|
37
|
+
setErrors: import("react").Dispatch<import("react").SetStateAction<Record<string, string>>>;
|
38
|
+
};
|
@@ -0,0 +1,9 @@
|
|
1
|
+
import { ConfigurationParameter } from './Types';
|
2
|
+
export type ParameterFieldProps<T> = {
|
3
|
+
value: T;
|
4
|
+
onChange: (value: T) => void;
|
5
|
+
parameter: ConfigurationParameter;
|
6
|
+
errors: Record<string, string>;
|
7
|
+
};
|
8
|
+
declare const ParameterField: <T>({ value, onChange, parameter, errors }: ParameterFieldProps<T>) => import("react/jsx-runtime").JSX.Element | null;
|
9
|
+
export default ParameterField;
|
@@ -0,0 +1,17 @@
|
|
1
|
+
import { ConfigurationParameter, OutputParameter, ShapeType } from '../Types';
|
2
|
+
export type ParametersModalFormProps = {
|
3
|
+
onClose: () => void;
|
4
|
+
title: string;
|
5
|
+
parameters: ConfigurationParameter[];
|
6
|
+
data: OutputParameter[];
|
7
|
+
onSubmit: (data: OutputParameter[], properties?: {
|
8
|
+
name: string;
|
9
|
+
role: string;
|
10
|
+
}) => void;
|
11
|
+
shapeType?: ShapeType;
|
12
|
+
shapeName?: string;
|
13
|
+
shapeRole?: string;
|
14
|
+
shapeId?: string;
|
15
|
+
};
|
16
|
+
declare const ParametersModalForm: React.FC<ParametersModalFormProps>;
|
17
|
+
export default ParametersModalForm;
|
@@ -0,0 +1,18 @@
|
|
1
|
+
import * as fabric from 'fabric';
|
2
|
+
import { FabricEvent } from './Types';
|
3
|
+
export declare const handleMouseDownPolygon: (event: FabricEvent, canvas: fabric.Canvas, activeColor: string, setIsDrawing: (v: boolean) => void, points: {
|
4
|
+
x: number;
|
5
|
+
y: number;
|
6
|
+
}[], setPoints: (v: {
|
7
|
+
x: number;
|
8
|
+
y: number;
|
9
|
+
}[]) => void, lines: fabric.Line[], setLines: (v: fabric.Line[]) => void) => void;
|
10
|
+
export declare const handleMouseMovePolygon: (event: FabricEvent, canvas: fabric.Canvas, isDrawing: boolean, lines: fabric.Line[]) => void;
|
11
|
+
export declare const handleDoubleClickPolygon: (editorId: string, canvas: fabric.Canvas, activeColor: string, setIsDrawing: (v: boolean) => void, points: {
|
12
|
+
x: number;
|
13
|
+
y: number;
|
14
|
+
}[], setPoints: (v: {
|
15
|
+
x: number;
|
16
|
+
y: number;
|
17
|
+
}[]) => void, lines: fabric.Line[], setLines: (v: fabric.Line[]) => void) => void;
|
18
|
+
export declare const copyPolygon: (editorId: string, canvas: fabric.Canvas, polygon: fabric.Polygon) => fabric.Polygon;
|
@@ -0,0 +1,28 @@
|
|
1
|
+
import * as fabric from 'fabric';
|
2
|
+
import { FabricEvent } from './Types';
|
3
|
+
export declare const handleMouseDownPolyline: (event: FabricEvent, canvas: fabric.Canvas, activeColor: string, setIsDrawing: (v: boolean) => void, points: {
|
4
|
+
x: number;
|
5
|
+
y: number;
|
6
|
+
}[], setPoints: (v: {
|
7
|
+
x: number;
|
8
|
+
y: number;
|
9
|
+
}[]) => void, lines: fabric.Line[], setLines: (v: fabric.Line[]) => void) => void;
|
10
|
+
export declare const handleMouseMovePolyline: (event: FabricEvent, canvas: fabric.Canvas, isDrawing: boolean, lines: fabric.Line[]) => void;
|
11
|
+
export declare const handleDoubleClickPolyline: (editorId: string, canvas: fabric.Canvas, activeColor: string, setIsDrawing: (v: boolean) => void, points: {
|
12
|
+
x: number;
|
13
|
+
y: number;
|
14
|
+
}[], setPoints: (v: {
|
15
|
+
x: number;
|
16
|
+
y: number;
|
17
|
+
}[]) => void, lines: fabric.Line[], setLines: (v: fabric.Line[]) => void) => void;
|
18
|
+
export declare const copyPolyline: (editorId: string, canvas: fabric.Canvas, polyline: fabric.Polyline) => fabric.Polyline<{
|
19
|
+
top: number;
|
20
|
+
left: number;
|
21
|
+
fill: string;
|
22
|
+
stroke: string | fabric.TFiller | null;
|
23
|
+
strokeWidth: number;
|
24
|
+
selectable: false;
|
25
|
+
hasControls: true;
|
26
|
+
hoverCursor: string;
|
27
|
+
id: string;
|
28
|
+
}, fabric.SerializedPolylineProps, fabric.ObjectEvents>;
|
@@ -0,0 +1,21 @@
|
|
1
|
+
import * as fabric from 'fabric';
|
2
|
+
import { FabricEvent, Shape } from './Types';
|
3
|
+
export declare const handleMouseDownRect: (event: FabricEvent, canvas: fabric.Canvas, activeColor: string, setOriginX: (v: number) => void, setOriginY: (v: number) => void, setShape: (v: Shape) => void, setIsDrawing: (v: boolean) => void) => void;
|
4
|
+
export declare const handleMouseMoveRect: (event: FabricEvent, canvas: fabric.Canvas, originX: number, originY: number, shape: Shape, isDrawing: boolean) => void;
|
5
|
+
export declare const handleMouseUpRect: (editorId: string, canvas: fabric.Canvas, setIsDrawing: (v: boolean) => void, shape: Shape, setShape: (v: Shape | null) => void) => void;
|
6
|
+
export declare const copyRectangle: (editorId: string, canvas: fabric.Canvas, rectangle: fabric.Rect) => fabric.Rect<{
|
7
|
+
left: number;
|
8
|
+
top: number;
|
9
|
+
originX: "left";
|
10
|
+
originY: "top";
|
11
|
+
width: number;
|
12
|
+
height: number;
|
13
|
+
fill: string;
|
14
|
+
stroke: string | fabric.TFiller | null;
|
15
|
+
strokeWidth: number;
|
16
|
+
strokeUniform: true;
|
17
|
+
selectable: false;
|
18
|
+
hasControls: true;
|
19
|
+
hoverCursor: string;
|
20
|
+
id: string;
|
21
|
+
}, fabric.SerializedRectProps, fabric.ObjectEvents>;
|
@@ -0,0 +1,128 @@
|
|
1
|
+
import * as fabric from 'fabric';
|
2
|
+
export declare const enum ToolEnum {
|
3
|
+
Pointer = "pointer",
|
4
|
+
Polyline = "polyline",
|
5
|
+
Polygon = "polygon",
|
6
|
+
Rectangle = "rect"
|
7
|
+
}
|
8
|
+
export type ShapeType = ToolEnum.Polyline | ToolEnum.Polygon | ToolEnum.Rectangle;
|
9
|
+
export type Shape = (fabric.Rect | fabric.Polygon | fabric.Polyline) & {
|
10
|
+
id?: string;
|
11
|
+
};
|
12
|
+
export type Shapes = Record<string, {
|
13
|
+
type: ShapeType;
|
14
|
+
shape: Shape;
|
15
|
+
}>;
|
16
|
+
export type FabricEvent = fabric.TPointerEventInfo<fabric.TPointerEvent>;
|
17
|
+
export type FabricSelectionEvent = Partial<fabric.TEvent> & {
|
18
|
+
selected: fabric.Object[];
|
19
|
+
};
|
20
|
+
export type IAddShape = (id: string, type: ShapeType, shape: Shape) => void;
|
21
|
+
export declare enum DataTypeEnum {
|
22
|
+
Integer = "int",
|
23
|
+
Float = "float",
|
24
|
+
String = "string",
|
25
|
+
Boolean = "bool"
|
26
|
+
}
|
27
|
+
export declare enum OperatorEnum {
|
28
|
+
Lt = "lt",
|
29
|
+
Lte = "lte",
|
30
|
+
Gt = "gt",
|
31
|
+
Gte = "gte",
|
32
|
+
Eq = "eq"
|
33
|
+
}
|
34
|
+
export type ConfigurationParameter = {
|
35
|
+
codename: string;
|
36
|
+
label: string;
|
37
|
+
description: string;
|
38
|
+
unit: string;
|
39
|
+
type: DataTypeEnum;
|
40
|
+
options: {
|
41
|
+
value: number | string;
|
42
|
+
label: string;
|
43
|
+
}[];
|
44
|
+
multiple?: boolean;
|
45
|
+
required: boolean;
|
46
|
+
value: number | string | boolean | string[] | number[] | null;
|
47
|
+
};
|
48
|
+
export type RoiConfiguration = {
|
49
|
+
role: string;
|
50
|
+
label: string;
|
51
|
+
type: Omit<ShapeType, 'pointer'>;
|
52
|
+
multiplicity: {
|
53
|
+
operator: OperatorEnum;
|
54
|
+
threshold: number;
|
55
|
+
};
|
56
|
+
parameters: ConfigurationParameter[];
|
57
|
+
};
|
58
|
+
export type Configuration = {
|
59
|
+
parameters: ConfigurationParameter[];
|
60
|
+
rois: RoiConfiguration[];
|
61
|
+
options?: {
|
62
|
+
hideForbiddenTools?: boolean;
|
63
|
+
description?: string;
|
64
|
+
};
|
65
|
+
};
|
66
|
+
export interface INotify {
|
67
|
+
info: (message: string) => void;
|
68
|
+
warn: (message: string) => void;
|
69
|
+
error: (message: string) => void;
|
70
|
+
success: (message: string) => void;
|
71
|
+
}
|
72
|
+
export type Metadata = {
|
73
|
+
parameters: OutputParameter[];
|
74
|
+
rois: {
|
75
|
+
id: string;
|
76
|
+
parameters: OutputParameter[];
|
77
|
+
name: string;
|
78
|
+
role: string;
|
79
|
+
}[];
|
80
|
+
};
|
81
|
+
export type OutputShapeRect = {
|
82
|
+
top: number;
|
83
|
+
left: number;
|
84
|
+
width: number;
|
85
|
+
height: number;
|
86
|
+
color: string;
|
87
|
+
};
|
88
|
+
export type OutputShapePolyline = {
|
89
|
+
points: {
|
90
|
+
x: number;
|
91
|
+
y: number;
|
92
|
+
}[];
|
93
|
+
top: number;
|
94
|
+
left: number;
|
95
|
+
color: string;
|
96
|
+
};
|
97
|
+
export type OutputShapePolygon = {
|
98
|
+
points: {
|
99
|
+
x: number;
|
100
|
+
y: number;
|
101
|
+
}[];
|
102
|
+
top: number;
|
103
|
+
left: number;
|
104
|
+
color: string;
|
105
|
+
};
|
106
|
+
export interface OutputParameter {
|
107
|
+
codename: string;
|
108
|
+
value: number | string | boolean | string[] | number[] | null;
|
109
|
+
}
|
110
|
+
export interface OutputRoi {
|
111
|
+
parameters: OutputParameter[];
|
112
|
+
type: ShapeType;
|
113
|
+
name: string;
|
114
|
+
role: string;
|
115
|
+
id: string;
|
116
|
+
shape: OutputShapeRect | OutputShapePolyline | OutputShapePolygon;
|
117
|
+
}
|
118
|
+
export interface Output {
|
119
|
+
parameters: OutputParameter[];
|
120
|
+
rois: OutputRoi[];
|
121
|
+
}
|
122
|
+
export declare enum UpdateEventType {
|
123
|
+
AddRoi = "AddRoi",
|
124
|
+
RemoveRoi = "RemoveRoi",
|
125
|
+
UpdateRoi = "UpdateRoi",
|
126
|
+
UpdateRoiParameters = "UpdateRoiParameters",
|
127
|
+
UpdateMainParameters = "UpdateMainParameters"
|
128
|
+
}
|
@@ -0,0 +1,25 @@
|
|
1
|
+
import { Configuration, ConfigurationParameter, INotify, Metadata, Shape, Shapes, ShapeType, ToolEnum } from './Types';
|
2
|
+
export declare const notify: INotify;
|
3
|
+
export declare const enableRois: (configuration: Configuration) => boolean;
|
4
|
+
export declare const enableMainMetadata: (configuration: Configuration) => boolean;
|
5
|
+
export declare const canDrawShape: (configuration: Configuration, shapeType: Omit<ToolEnum, ToolEnum.Pointer>, shapes: Shapes, notify?: INotify, message?: string) => boolean;
|
6
|
+
export declare const validateParametersForm: (parameters: ConfigurationParameter[], fields: Record<string, unknown>, setErrors: (errors: Record<string, string>) => void) => boolean;
|
7
|
+
export declare const validate: (configuration: Configuration, shapes: Shapes, metadata: Metadata, strings: Record<string, string>) => [boolean, string[]];
|
8
|
+
export declare const fabricShapeToOutputShape: (shape: Shape, type: ShapeType, imageSize: {
|
9
|
+
width: number;
|
10
|
+
height: number;
|
11
|
+
}) => {
|
12
|
+
top: number;
|
13
|
+
left: number;
|
14
|
+
width: number;
|
15
|
+
height: number;
|
16
|
+
color: string;
|
17
|
+
points?: undefined;
|
18
|
+
} | {
|
19
|
+
points: any;
|
20
|
+
top: number;
|
21
|
+
left: number;
|
22
|
+
color: string;
|
23
|
+
width?: undefined;
|
24
|
+
height?: undefined;
|
25
|
+
};
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { Configuration, Output } from './Types';
|
3
|
+
export type RoiEditorProps = {
|
4
|
+
imageUrl: string;
|
5
|
+
configuration: Configuration;
|
6
|
+
onSubmit: (data: Output) => void;
|
7
|
+
onUpdate?: (data: Output) => void;
|
8
|
+
initialData?: Output;
|
9
|
+
editorId: string;
|
10
|
+
};
|
11
|
+
declare const RoiEditor: React.FC<RoiEditorProps>;
|
12
|
+
export default RoiEditor;
|
@@ -0,0 +1,7 @@
|
|
1
|
+
import { FieldProps } from '../Types';
|
2
|
+
import { ShapeType } from './RoiEditor/Types';
|
3
|
+
type RoleFieldProps = Omit<FieldProps<string>, 'readonly' | 'label'> & {
|
4
|
+
shapeType: ShapeType;
|
5
|
+
};
|
6
|
+
declare const RoleField: React.FC<RoleFieldProps>;
|
7
|
+
export default RoleField;
|
@@ -0,0 +1,26 @@
|
|
1
|
+
import { PropsWithChildren } from 'react';
|
2
|
+
import { Configuration, Metadata, Shape, Shapes, ShapeType, ToolEnum } from '../Components/RoiEditor/Types';
|
3
|
+
type EditorContextType = {
|
4
|
+
hideForbiddenTools: boolean;
|
5
|
+
activeTool: ToolEnum;
|
6
|
+
setActiveTool: (tool: ToolEnum) => void;
|
7
|
+
activeColor: string;
|
8
|
+
setActiveColor: (color: string) => void;
|
9
|
+
shapes: Shapes;
|
10
|
+
addShape: (id: string, type: ShapeType, shape: Shape) => void;
|
11
|
+
addShapes: (shapes: {
|
12
|
+
id: string;
|
13
|
+
type: ShapeType;
|
14
|
+
shape: Shape;
|
15
|
+
}[]) => void;
|
16
|
+
removeShape: (id: string) => void;
|
17
|
+
configuration: Configuration;
|
18
|
+
metadata: Metadata;
|
19
|
+
setMetadata: (data: Metadata) => void;
|
20
|
+
onSubmit: () => void;
|
21
|
+
editorId: string;
|
22
|
+
};
|
23
|
+
export declare const EditorContext: import("react").Context<EditorContextType | undefined>;
|
24
|
+
export declare function useEditorContext(): EditorContextType;
|
25
|
+
declare const EditorProvider: ({ children, editorId, hideForbiddenTools, activeTool, setActiveTool, activeColor, setActiveColor, shapes, addShape, addShapes, removeShape, configuration, metadata, setMetadata, onSubmit, }: PropsWithChildren<EditorContextType>) => import("react/jsx-runtime").JSX.Element;
|
26
|
+
export default EditorProvider;
|
@@ -0,0 +1,82 @@
|
|
1
|
+
import { PropsWithChildren } from 'react';
|
2
|
+
import Typography from '../Components/Typography';
|
3
|
+
import IconButton from '../Components/IconButton';
|
4
|
+
import DeleteIcon from '../Icons/DeleteIcon';
|
5
|
+
import EditIcon from '../Icons/EditIcon';
|
6
|
+
import { INotify } from '../Components/RoiEditor/Types';
|
7
|
+
import CopyIcon from '../Icons/CopyIcon';
|
8
|
+
import AnnotateIcon from '../Icons/AnnotateIcon';
|
9
|
+
import Modal from '../Components/Modal';
|
10
|
+
import CloseIcon from '../Icons/CloseIcon';
|
11
|
+
import TextField from '../Components/TextField';
|
12
|
+
import NumberField from '../Components/NumberField';
|
13
|
+
import BoolField from '../Components/BoolField';
|
14
|
+
import EnumField from '../Components/EnumField';
|
15
|
+
import Button from '../Components/Button';
|
16
|
+
import SaveIcon from '../Icons/SaveIcon';
|
17
|
+
type UiContextType = {
|
18
|
+
children?: React.ReactNode;
|
19
|
+
enableLogs: boolean;
|
20
|
+
themeMode: 'light' | 'dark';
|
21
|
+
primaryColor: string;
|
22
|
+
primaryFgColor: string;
|
23
|
+
Typography: typeof Typography;
|
24
|
+
IconButton: typeof IconButton;
|
25
|
+
Modal: typeof Modal;
|
26
|
+
DeleteIcon: typeof DeleteIcon;
|
27
|
+
EditIcon: typeof EditIcon;
|
28
|
+
CopyIcon: typeof CopyIcon;
|
29
|
+
AnnotateIcon: typeof AnnotateIcon;
|
30
|
+
SaveIcon: typeof SaveIcon;
|
31
|
+
CloseIcon: typeof CloseIcon;
|
32
|
+
TextField: typeof TextField;
|
33
|
+
NumberField: typeof NumberField;
|
34
|
+
BoolField: typeof BoolField;
|
35
|
+
EnumField: typeof EnumField;
|
36
|
+
Button: typeof Button;
|
37
|
+
pickerColors: string[];
|
38
|
+
notify: INotify;
|
39
|
+
strings: {
|
40
|
+
cancel: string;
|
41
|
+
cannotDrawMorePolygons: string;
|
42
|
+
cannotDrawMorePolylines: string;
|
43
|
+
cannotDrawMoreRectangles: string;
|
44
|
+
id: string;
|
45
|
+
invalidSubmission: string;
|
46
|
+
mainParametersMetadata: string;
|
47
|
+
missingRequiredValuesInMainParameters: string;
|
48
|
+
missingRequiredValuesInShapeParameters: string;
|
49
|
+
roiMultiplicityEqRule: string;
|
50
|
+
roiMultiplicityGtRule: string;
|
51
|
+
roiMultiplicityGteRule: string;
|
52
|
+
roiMultiplicityLtRule: string;
|
53
|
+
roiMultiplicityLteRule: string;
|
54
|
+
roiMultiplicityNoRule: string;
|
55
|
+
name: string;
|
56
|
+
polygon: string;
|
57
|
+
polygonHelpText: string;
|
58
|
+
polyline: string;
|
59
|
+
polylineHelpText: string;
|
60
|
+
rect: string;
|
61
|
+
rectHelpText: string;
|
62
|
+
pointer: string;
|
63
|
+
pointerHelpText: string;
|
64
|
+
roisToBeDrawn: string;
|
65
|
+
role: string;
|
66
|
+
requiredField: string;
|
67
|
+
save: string;
|
68
|
+
shapeParametersMetadata: string;
|
69
|
+
shapesOfRoleShouldBeEqualToThreshold: string;
|
70
|
+
shapesOfRoleShouldBeGreaterThanThreshold: string;
|
71
|
+
shapesOfRoleShouldBeGreaterThanOrEqualToThreshold: string;
|
72
|
+
shapesOfRoleShouldBeLessThanThreshold: string;
|
73
|
+
shapesOfRoleShouldBeLessThanOrEqualToThreshold: string;
|
74
|
+
type: string;
|
75
|
+
};
|
76
|
+
};
|
77
|
+
export declare const DefaultUiContext: UiContextType;
|
78
|
+
export declare const UiContext: import("react").Context<UiContextType>;
|
79
|
+
declare const UiProvider: ({ children, enableLogs, themeMode, primaryColor, primaryFgColor, Typography, Modal, IconButton, DeleteIcon, EditIcon, CopyIcon, AnnotateIcon, SaveIcon, CloseIcon, TextField, NumberField, BoolField, EnumField, Button, pickerColors, notify, strings, }: PropsWithChildren<Partial<Omit<UiContextType, "strings">> & {
|
80
|
+
strings?: Partial<UiContextType["strings"]>;
|
81
|
+
}>) => import("react/jsx-runtime").JSX.Element;
|
82
|
+
export default UiProvider;
|
@@ -0,0 +1,16 @@
|
|
1
|
+
type DispatcherType = {
|
2
|
+
_prefix: string;
|
3
|
+
_listeners: Record<string, Array<unknown>>;
|
4
|
+
evtName: (evtName: string) => string;
|
5
|
+
register: <T>(evtName: string, callback: (evtName: string, params: T) => void, bind?: unknown) => void;
|
6
|
+
unregister: <T>(evtName: string, callback: (evtName: string, params: T) => void) => void;
|
7
|
+
emit: (evtName: string, ...params: unknown[]) => void;
|
8
|
+
};
|
9
|
+
/**
|
10
|
+
* Event Dispatcher
|
11
|
+
*
|
12
|
+
* Implementation of an event dispatcher following the Mediator pattern
|
13
|
+
* @namespace
|
14
|
+
*/
|
15
|
+
declare const Dispatcher: DispatcherType;
|
16
|
+
export default Dispatcher;
|