@abidibo/react-cam-roi 0.0.7 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +588 -29
- package/dist/Components/BoolField/BoolField.module.css +60 -0
- package/dist/Components/BoolField/index.d.ts +5 -0
- package/dist/Components/BoolField/index.js +13 -0
- package/dist/Components/Button/Button.module.css +27 -0
- package/dist/Components/Button/index.d.ts +8 -0
- package/dist/Components/Button/index.js +15 -0
- package/dist/Components/EnumField/EnumField.module.css +61 -0
- package/dist/Components/EnumField/index.d.ts +10 -0
- package/dist/Components/EnumField/index.js +16 -0
- package/dist/Components/IconButton/IconButton.module.css +8 -3
- package/dist/Components/IconButton/index.d.ts +1 -0
- package/dist/Components/IconButton/index.js +3 -3
- package/dist/Components/Modal/Modal.module.css +92 -0
- package/dist/Components/Modal/index.d.ts +10 -0
- package/dist/Components/Modal/index.js +16 -0
- package/dist/Components/NumberField/NumberField.module.css +60 -0
- package/dist/Components/NumberField/index.d.ts +3 -0
- package/dist/Components/NumberField/index.js +13 -0
- package/dist/Components/RoiEditor/Canvas.d.ts +2 -0
- package/dist/Components/RoiEditor/Canvas.js +21 -11
- package/dist/Components/RoiEditor/Hooks.d.ts +16 -4
- package/dist/Components/RoiEditor/Hooks.js +148 -21
- package/dist/Components/RoiEditor/ParameterField.d.ts +9 -0
- package/dist/Components/RoiEditor/ParameterField.js +27 -0
- package/dist/Components/RoiEditor/ParametersModalForm/ParametersModalForm.module.css +5 -0
- package/dist/Components/RoiEditor/ParametersModalForm/index.d.ts +10 -0
- package/dist/Components/RoiEditor/ParametersModalForm/index.js +31 -0
- package/dist/Components/RoiEditor/Polygon.d.ts +3 -2
- package/dist/Components/RoiEditor/Polygon.js +18 -0
- package/dist/Components/RoiEditor/Polyline.d.ts +12 -1
- package/dist/Components/RoiEditor/Polyline.js +18 -0
- package/dist/Components/RoiEditor/Rectangle.d.ts +17 -1
- package/dist/Components/RoiEditor/Rectangle.js +23 -1
- package/dist/Components/RoiEditor/ShapesList.d.ts +2 -0
- package/dist/Components/RoiEditor/ShapesList.js +47 -0
- package/dist/Components/RoiEditor/ShapesList.module.css +36 -0
- package/dist/Components/RoiEditor/Toolbar.js +20 -6
- package/dist/Components/RoiEditor/Toolbar.module.css +40 -0
- package/dist/Components/RoiEditor/Types.d.ts +97 -1
- package/dist/Components/RoiEditor/Types.js +15 -1
- package/dist/Components/RoiEditor/Utils.d.ts +22 -0
- package/dist/Components/RoiEditor/Utils.js +143 -0
- package/dist/Components/RoiEditor/index.d.ts +4 -0
- package/dist/Components/RoiEditor/index.js +44 -7
- package/dist/Components/TextField/TextField.module.css +61 -0
- package/dist/Components/TextField/index.d.ts +6 -0
- package/dist/Components/TextField/index.js +13 -0
- package/dist/Components/Typography/index.d.ts +4 -0
- package/dist/Components/Typography/index.js +3 -2
- package/dist/Icons/AnnotateIcon.d.ts +6 -0
- package/dist/Icons/AnnotateIcon.js +5 -0
- package/dist/Icons/CloseIcon.d.ts +6 -0
- package/dist/Icons/CloseIcon.js +5 -0
- package/dist/Icons/CopyIcon.d.ts +6 -0
- package/dist/Icons/CopyIcon.js +5 -0
- package/dist/Icons/SaveIcon.d.ts +6 -0
- package/dist/Icons/SaveIcon.js +5 -0
- package/dist/Providers/EditorProvider.d.ts +12 -2
- package/dist/Providers/EditorProvider.js +16 -2
- package/dist/Providers/UiProvider.d.ts +44 -2
- package/dist/Providers/UiProvider.js +55 -2
- package/dist/Types.d.ts +10 -0
- package/dist/Types.js +1 -0
- package/dist/Utils/index.d.ts +1 -1
- package/dist/Utils/index.js +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/package.json +13 -4
- package/dist/Components/RoiEditor/Metadata.d.ts +0 -2
- package/dist/Components/RoiEditor/Metadata.js +0 -31
- package/dist/Components/RoiEditor/Metadata.module.css +0 -34
package/README.md
CHANGED
@@ -2,32 +2,251 @@
|
|
2
2
|
|
3
3
|
> Still in development!
|
4
4
|
|
5
|
-
This is a react component which lets you draw regions of interest (ROI) over images, manage metadata and import/export everything.
|
5
|
+
This is a react component which lets you draw regions of interest (ROI) over images, manage metadata and import/export everything.
|
6
|
+
Metadata are dynamic information that can be attached to the whole image and/or to each ROI. The number of drawable ROIs can also be configured.
|
7
|
+
|
8
|
+
![Screenshot](./react-cam-roi.png)
|
9
|
+
|
10
|
+
It provides one component: `RoiEditor` and one provider: `UiProvider`. The editor lets you draw regions of interest over a given image (url). Each ROI can have dynamic metadata attached.
|
11
|
+
|
12
|
+
Export and import functionality is also provided.
|
13
|
+
|
14
|
+
Features:
|
15
|
+
|
16
|
+
- Autosizing of the editor: the canvas resizes to the size of the image, but it's also responsive, so if the container width is smaller, then the canvas is resized accordingly keeping the aspect ratio.
|
17
|
+
(the size is adjusted on load, after will remain the same even if changing viewport size)
|
18
|
+
- Draw polylines, polygons and rectangles, change dimensions and rotate them.
|
19
|
+
- Support for number of drawable ROIs, defining a rule for each type.
|
20
|
+
- Support for dynamic metadata information attached to each shape and the whole image (with validation included).
|
21
|
+
- Import and export shapes and metadata in json format.
|
22
|
+
- Highly customizable: shape colors, custom components and css classes.
|
6
23
|
|
7
24
|
## Installation
|
8
25
|
|
9
|
-
```
|
10
|
-
npm install react-cam-roi
|
26
|
+
``` bash
|
27
|
+
npm install @abidibo/react-cam-roi
|
11
28
|
```
|
12
29
|
|
13
30
|
## Usage
|
14
31
|
|
15
|
-
|
32
|
+
```ts
|
33
|
+
import { RoiEditor, UiProvider, Types } from '@abidibo/react-cam-roi'
|
34
|
+
import { Typography, IconButton, Delete } from '@mui/material'
|
35
|
+
|
36
|
+
const MyComponent: React.FC = () => {
|
37
|
+
const themMode = 'light'
|
38
|
+
const config = {} // see below
|
39
|
+
|
40
|
+
const handleSubmit = (data: Types.Output) => console.log(data)
|
41
|
+
|
42
|
+
return (
|
43
|
+
<UiProvider themeMode={themeMode} IconButton={IconButton} Typography={Typography} DeleteIcon={() => <Delete />}>
|
44
|
+
<RoiEditor imageUrl={'https://placecats.com/800/600'} configuration={config} onSubmit={handleSubmit} />
|
45
|
+
</UiProvider>
|
46
|
+
)
|
47
|
+
}
|
48
|
+
```
|
49
|
+
|
50
|
+
The `RoiEditor` props and the `Output` interface used both in import and export:
|
51
|
+
|
52
|
+
``` ts
|
53
|
+
export type RoiEditorProps = {
|
54
|
+
// the url of the image we want to annotate
|
55
|
+
imageUrl: string
|
56
|
+
configuration: Configuration
|
57
|
+
onSubmit: (data: Output) => void
|
58
|
+
initialData?: Output
|
59
|
+
}
|
60
|
+
|
61
|
+
export const enum ToolEnum {
|
62
|
+
Pointer = 'pointer',
|
63
|
+
Polyline = 'polyline',
|
64
|
+
Polygon = 'polygon',
|
65
|
+
Rectangle = 'rect',
|
66
|
+
}
|
67
|
+
|
68
|
+
export type ShapeType = ToolEnum.Polyline | ToolEnum.Polygon | ToolEnum.Rectangle
|
69
|
+
|
70
|
+
export type OutputShapeRect = {
|
71
|
+
top: number
|
72
|
+
left: number
|
73
|
+
width: number
|
74
|
+
height: number
|
75
|
+
color: string
|
76
|
+
}
|
77
|
+
|
78
|
+
export type OutputShapePolyline = {
|
79
|
+
points: { x: number; y: number }[]
|
80
|
+
top: number
|
81
|
+
left: number
|
82
|
+
color: string
|
83
|
+
}
|
84
|
+
|
85
|
+
export type OutputShapePolygon = {
|
86
|
+
points: { x: number; y: number }[]
|
87
|
+
top: number
|
88
|
+
left: number
|
89
|
+
color: string
|
90
|
+
}
|
91
|
+
|
92
|
+
|
93
|
+
export interface OutputParameter {
|
94
|
+
codename: string
|
95
|
+
value: number | string | boolean | string[] | number[] | null
|
96
|
+
}
|
97
|
+
|
98
|
+
export interface OutputRoi {
|
99
|
+
parameters: OutputParameter[]
|
100
|
+
type: ShapeType
|
101
|
+
shape: OutputShapeRect | OutputShapePolyline | OutputShapePolygon
|
102
|
+
}
|
103
|
+
export interface Output {
|
104
|
+
parameters: OutputParameter[]
|
105
|
+
rois: OutputRoi[]
|
106
|
+
}
|
107
|
+
```
|
108
|
+
|
109
|
+
Take a look at the `UiProvider` allowed props (below) to see all the customization options.
|
110
|
+
|
111
|
+
## Configuration
|
112
|
+
|
113
|
+
The configuration prop defines which kind and how many ROIs can be drawn, along with metadata information. Here the types definitions and an example:
|
114
|
+
|
115
|
+
```ts
|
116
|
+
// All types can be imported:
|
117
|
+
// import { Types } from '@abidibo/react-cam-roi'
|
118
|
+
// const { ToolEnum, ShapeType, DataTypeEnum, OperatorEnum, ConfigurationParameter, RoiConfiguration, Configuration } = Types
|
119
|
+
|
120
|
+
// The drawable shapes plus the Pointer tool
|
121
|
+
export const enum ToolEnum {
|
122
|
+
Pointer = 'pointer',
|
123
|
+
Polyline = 'polyline',
|
124
|
+
Polygon = 'polygon',
|
125
|
+
Rectangle = 'rect',
|
126
|
+
}
|
127
|
+
|
128
|
+
// Allowed shape types
|
129
|
+
export type ShapeType = ToolEnum.Polyline | ToolEnum.Polygon | ToolEnum.Rectangle
|
130
|
+
|
131
|
+
// Data types allowed for metadata values
|
132
|
+
export enum DataTypeEnum {
|
133
|
+
Integer = 'int',
|
134
|
+
Float = 'float',
|
135
|
+
String = 'string',
|
136
|
+
Boolean = 'bool',
|
137
|
+
}
|
138
|
+
|
139
|
+
// Operators allowed for multiplicity (control how many shapes should/can be drawn)
|
140
|
+
export enum OperatorEnum {
|
141
|
+
Lt = 'lt',
|
142
|
+
Lte = 'lte',
|
143
|
+
Gt = 'gt',
|
144
|
+
Gte = 'gte',
|
145
|
+
Eq = 'eq',
|
146
|
+
}
|
147
|
+
|
148
|
+
// Definition of a metadata parameter
|
149
|
+
export type ConfigurationParameter = {
|
150
|
+
codename: string // unique
|
151
|
+
label: string // label of the parameter
|
152
|
+
description: string // helper text
|
153
|
+
unit: string // postponed to the label
|
154
|
+
type: DataTypeEnum // value type
|
155
|
+
options: { value: number | string | boolean; label: string }[] // if filled the component will be a dropdown
|
156
|
+
multiple?: boolean // for multiple selection
|
157
|
+
required: boolean // required parameter
|
158
|
+
value: number | string | boolean | string[] | number[] | null // default value
|
159
|
+
}
|
16
160
|
|
17
|
-
|
161
|
+
// Configuration of ROIs
|
162
|
+
export type RoiConfiguration = {
|
163
|
+
role: string // for our use case
|
164
|
+
type: Omit<ShapeType, 'pointer'> // shape type
|
165
|
+
multiplicity: { // how many ROIs of this type can be drawn
|
166
|
+
operator: OperatorEnum
|
167
|
+
threshold: number
|
168
|
+
}
|
169
|
+
parameters: ConfigurationParameter[] // ROIs parameters for this shape type
|
170
|
+
}
|
171
|
+
|
172
|
+
// Whole configuration
|
173
|
+
export type Configuration = {
|
174
|
+
parameters: ConfigurationParameter[]
|
175
|
+
rois: RoiConfiguration[]
|
176
|
+
options: {
|
177
|
+
hideForbiddenTools?: boolean // hide tools controllers for shapes that cannot be drawn
|
178
|
+
description?: string // optional initial text shown in the editor
|
179
|
+
}
|
180
|
+
}
|
181
|
+
|
182
|
+
// Example
|
183
|
+
export const configuration: Configuration = {
|
184
|
+
parameters: [
|
185
|
+
{
|
186
|
+
codename: 'analytics_1', // internal code
|
187
|
+
label: 'Analytics param 1', // to be shown in interface
|
188
|
+
description: 'This is some descriptive text', // tooltip
|
189
|
+
unit: 's', // unit
|
190
|
+
type: DataTypeEnum.Integer, // int, float, string, bool
|
191
|
+
options: [
|
192
|
+
// if filled -> enum of types type
|
193
|
+
{
|
194
|
+
value: 7,
|
195
|
+
label: 'Seven',
|
196
|
+
},
|
197
|
+
{
|
198
|
+
value: 10,
|
199
|
+
label: 'Ten',
|
200
|
+
},
|
201
|
+
],
|
202
|
+
required: true, // true | false,
|
203
|
+
value: 10, // default value
|
204
|
+
},
|
205
|
+
],
|
206
|
+
rois: [
|
207
|
+
{
|
208
|
+
role: 'invasion_area', // analytics role, do not show in interface
|
209
|
+
type: ToolEnum.Polygon,
|
210
|
+
multiplicity: {
|
211
|
+
// how many rois of this type can/should be created
|
212
|
+
operator: OperatorEnum.Lt, // lt | lte | gt | gte | eq
|
213
|
+
threshold: 2,
|
214
|
+
},
|
215
|
+
parameters: [
|
216
|
+
{
|
217
|
+
codename: 'threshold', // internal code
|
218
|
+
label: 'Alert threshold', // to be shown in interface
|
219
|
+
description: 'Threshold used for triggering alarms', // tooltip
|
220
|
+
unit: '%', // unit
|
221
|
+
type: DataTypeEnum.Integer, // int, float, string, bool
|
222
|
+
options: [],
|
223
|
+
required: true, // true / false,
|
224
|
+
value: null, // default value
|
225
|
+
},
|
226
|
+
],
|
227
|
+
},
|
228
|
+
],
|
229
|
+
options?: {
|
230
|
+
hideForbiddenTools?: boolean,
|
231
|
+
description?: string,
|
232
|
+
}
|
233
|
+
}
|
234
|
+
```
|
235
|
+
|
236
|
+
## UiProvider and Customization
|
18
237
|
|
19
238
|
You can customize many aspects of this library by using the `UiProvider`.
|
20
239
|
|
21
|
-
- You can customize both the styles and the components
|
240
|
+
- You can customize both the styles and the components used in this library. The library provides default components with an interface almost compatible witu mui components (maybe you'll need to wrap some of them).
|
22
241
|
- You can override them by using the `UiProvider`. But you can also use the default ones and just add your styling.
|
23
|
-
- You can pass a theme mode which is used by the default components to determine the color scheme. It is also used to define custom classes you can use for styling.
|
242
|
+
- You can pass a theme mode which is used by the default components to determine the color scheme. It is also used to define custom classes you can use for styling.
|
24
243
|
- You can define a primary color which is used for color or background of active elements.
|
25
|
-
- You can define custom strings used here and there.
|
244
|
+
- You can define custom strings used here and there (some strings require one or more placeholders).
|
26
245
|
- You can enable logs in the console by setting the `enableLogs` option to `true`.
|
27
246
|
|
28
247
|
``` tsx
|
29
|
-
import { UiProvider, RoiEditor } from 'react-cam-roi'
|
30
248
|
import IconButton from '@mui/material/IconButton'
|
249
|
+
import { UiProvider, RoiEditor } from 'react-cam-roi'
|
31
250
|
|
32
251
|
const MyView: React.FC = () => {
|
33
252
|
return (
|
@@ -40,19 +259,54 @@ const MyView: React.FC = () => {
|
|
40
259
|
|
41
260
|
### UiProvider
|
42
261
|
|
43
|
-
|
262
|
+
Props and types are defined later in this document.
|
263
|
+
|
264
|
+
```ts
|
44
265
|
type UiContextType = {
|
45
266
|
children?: React.ReactNode
|
46
|
-
enableLogs: boolean
|
47
|
-
themeMode: 'light' | 'dark'
|
48
|
-
primaryColor: string
|
49
|
-
Typography: React.FC<TypographyProps>
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
SelectIcon: React.FC<SelectIconProps>
|
54
|
-
|
267
|
+
enableLogs: boolean // enable console logs
|
268
|
+
themeMode: 'light' | 'dark' // themeMode for internal components
|
269
|
+
primaryColor: string // primary color for internal components
|
270
|
+
Typography: React.FC<TypographyProps> // component used to surround text
|
271
|
+
Modal: React.FC<ModalProps> // modal dialog component (it displays metadata forms)
|
272
|
+
IconButton: React.FC<IconButtonProps> // wrapper for icon buttons
|
273
|
+
DeleteIcon: React.FC<DeleteIconProps> // delete icon
|
274
|
+
SelectIcon: React.FC<SelectIconProps> // select icon
|
275
|
+
CopyIcon: typeof CopyIcon // copy icon (clone a shape)
|
276
|
+
AnnotateIcon: typeof AnnotateIcon // annotate icon (open metadata form)
|
277
|
+
CloseIcon: typeof CloseIcon // close icon
|
278
|
+
SaveIcon: typeof SaveIcon // save icon
|
279
|
+
TextField: typeof TextField // field used for text input
|
280
|
+
NumberField: typeof NumberField // field used for number input
|
281
|
+
BoolField: typeof BoolField // field used for boolean input
|
282
|
+
EnumField: typeof EnumField // field used for enum input (options filled in parameter definition)
|
283
|
+
Button: typeof Button // button
|
284
|
+
notify: INotify // function used to display notifications
|
285
|
+
strings: { // strings used here and there
|
286
|
+
cancel: string
|
287
|
+
cannotDrawMorePolygons: string
|
288
|
+
cannotDrawMorePolylines: string
|
289
|
+
cannotDrawMoreRectangles: string
|
55
290
|
id: string
|
291
|
+
invalidSubmission: string
|
292
|
+
mainParametersMetadata: string
|
293
|
+
missingRequiredValuesInMainParameters: string
|
294
|
+
missingRequiredValuesInShapeParameters: string // with {id} placeholder
|
295
|
+
polygon: string
|
296
|
+
polygonHelpText: string
|
297
|
+
polyline: string
|
298
|
+
polylineHelpText: string
|
299
|
+
rect: string
|
300
|
+
rectHelpText: string
|
301
|
+
pointer: string
|
302
|
+
pointerHelpText: string
|
303
|
+
requiredField: string
|
304
|
+
save: string
|
305
|
+
shapesOfTypeShouldBeEqualToThreshold: string // with {type} and {threshold} placeholders
|
306
|
+
shapesOfTypeShouldBeGreaterThanThreshold: string // with {type} and {threshold} placeholders
|
307
|
+
shapesOfTypeShouldBeGreaterThanOrEqualToThreshold: string // with {type} and {threshold} placeholders
|
308
|
+
shapesOfTypeShouldBeLessThanThreshold: string // with {type} and {threshold} placeholders
|
309
|
+
shapesOfTypeShouldBeLessThanOrEqualToThreshold: string // with {type} and {threshold} placeholders
|
56
310
|
type: string
|
57
311
|
}
|
58
312
|
}
|
@@ -66,22 +320,59 @@ Here comes the list of components you can override using the `UiProvider`.
|
|
66
320
|
|
67
321
|
##### Interface
|
68
322
|
|
69
|
-
```
|
323
|
+
```ts
|
70
324
|
type LoaderProps = {}
|
71
325
|
```
|
72
326
|
|
73
327
|
##### Classes
|
328
|
+
|
74
329
|
- `react-cam-roi-loader`
|
75
330
|
- `react-cam-roi-loader-light`
|
76
331
|
- `react-cam-roi-loader-dark`
|
77
332
|
|
333
|
+
#### Modal
|
334
|
+
|
335
|
+
##### Interface
|
336
|
+
|
337
|
+
```ts
|
338
|
+
type ModalProps = {
|
339
|
+
children?: React.ReactNode
|
340
|
+
title: string
|
341
|
+
onClose: () => void
|
342
|
+
isOpen: boolean
|
343
|
+
maxWidth: 'xs' | 'sm' | 'md' | 'lg'
|
344
|
+
}
|
345
|
+
```
|
346
|
+
|
347
|
+
##### Classes
|
348
|
+
|
349
|
+
- `react-cam-roi-modal`
|
350
|
+
- `react-cam-roi-modal-light`
|
351
|
+
- `react-cam-roi-modal-dark`
|
352
|
+
- `react-cam-roi-modal-overlay`
|
353
|
+
- `react-cam-roi-modal-overlay-light`
|
354
|
+
- `react-cam-roi-modal-overlay-dark`
|
355
|
+
- `react-cam-roi-modal-header`
|
356
|
+
- `react-cam-roi-modal-header-light`
|
357
|
+
- `react-cam-roi-modal-header-dark`
|
358
|
+
- `react-cam-roi-modal-title`
|
359
|
+
- `react-cam-roi-modal-title-light`
|
360
|
+
- `react-cam-roi-modal-title-dark`
|
361
|
+
- `react-cam-roi-modal-footer`
|
362
|
+
- `react-cam-roi-modal-footer-light`
|
363
|
+
- `react-cam-roi-modal-footer-dark`
|
364
|
+
|
78
365
|
#### Typography
|
79
366
|
|
80
367
|
##### Interface
|
81
368
|
|
82
|
-
```
|
369
|
+
```ts
|
83
370
|
type TypographyProps = {
|
84
371
|
children?: React.ReactNode
|
372
|
+
variant?: any // compatible with mui
|
373
|
+
component?: any // compatible with mui
|
374
|
+
className?: string
|
375
|
+
style?: React.CSSProperties
|
85
376
|
}
|
86
377
|
```
|
87
378
|
|
@@ -89,18 +380,26 @@ type TypographyProps = {
|
|
89
380
|
|
90
381
|
##### Interface
|
91
382
|
|
92
|
-
```
|
383
|
+
```ts
|
93
384
|
type IconButtonProps = {
|
94
385
|
children?: React.ReactNode
|
386
|
+
disabled?: boolean
|
95
387
|
onClick?: (event: React.MouseEvent) => void
|
96
388
|
}
|
97
389
|
```
|
98
390
|
|
391
|
+
##### Classes
|
392
|
+
|
393
|
+
- `react-cam-roi-icon-button`
|
394
|
+
- `react-cam-roi-icon-button-light`
|
395
|
+
- `react-cam-roi-icon-button-dark`
|
396
|
+
- `react-cam-roi-icon-button-disabled`
|
397
|
+
|
99
398
|
#### DeleteIcon
|
100
399
|
|
101
400
|
##### Interface
|
102
401
|
|
103
|
-
```
|
402
|
+
```ts
|
104
403
|
type DeleteIconProps = {
|
105
404
|
color?: string
|
106
405
|
style?: React.CSSProperties
|
@@ -111,7 +410,7 @@ type DeleteIconProps = {
|
|
111
410
|
|
112
411
|
##### Interface
|
113
412
|
|
114
|
-
```
|
413
|
+
```ts
|
115
414
|
type EditIconProps = {
|
116
415
|
color?: string
|
117
416
|
style?: React.CSSProperties
|
@@ -122,13 +421,220 @@ type EditIconProps = {
|
|
122
421
|
|
123
422
|
##### Interface
|
124
423
|
|
125
|
-
```
|
424
|
+
```ts
|
126
425
|
type SelectIconProps = {
|
127
426
|
color?: string
|
128
427
|
style?: React.CSSProperties
|
129
428
|
}
|
130
429
|
```
|
131
430
|
|
431
|
+
#### CopyIcon
|
432
|
+
|
433
|
+
##### Interface
|
434
|
+
|
435
|
+
```ts
|
436
|
+
type CopyIconProps = {
|
437
|
+
color?: string
|
438
|
+
style?: React.CSSProperties
|
439
|
+
}
|
440
|
+
```
|
441
|
+
|
442
|
+
#### AnnotateIcon
|
443
|
+
|
444
|
+
##### Interface
|
445
|
+
|
446
|
+
```ts
|
447
|
+
type AnnotateIconProps = {
|
448
|
+
color?: string
|
449
|
+
style?: React.CSSProperties
|
450
|
+
}
|
451
|
+
```
|
452
|
+
#### SaveIcon
|
453
|
+
|
454
|
+
##### Interface
|
455
|
+
|
456
|
+
```ts
|
457
|
+
type SaveIconProps = {
|
458
|
+
color?: string
|
459
|
+
style?: React.CSSProperties
|
460
|
+
}
|
461
|
+
```
|
462
|
+
|
463
|
+
#### TextField
|
464
|
+
|
465
|
+
##### Interface
|
466
|
+
|
467
|
+
```ts
|
468
|
+
type TextFieldProps = {
|
469
|
+
type?: 'text' | 'email' | 'password'
|
470
|
+
onChange: (value: string) => void
|
471
|
+
value: string
|
472
|
+
label: string
|
473
|
+
helperText?: string
|
474
|
+
error?: boolean
|
475
|
+
required?: boolean
|
476
|
+
readOnly?: boolean
|
477
|
+
disabled?: boolean
|
478
|
+
}
|
479
|
+
```
|
480
|
+
|
481
|
+
##### Classes
|
482
|
+
|
483
|
+
|
484
|
+
- `react-cam-roi-text-field-wrapper`
|
485
|
+
- `react-cam-roi-text-field-wrapper-light`
|
486
|
+
- `react-cam-roi-text-field-wrapper-dark`
|
487
|
+
- `react-cam-roi-text-field`
|
488
|
+
- `react-cam-roi-text-field--light`
|
489
|
+
- `react-cam-roi-text-field--dark`
|
490
|
+
- `react-cam-roi-text-field--error`
|
491
|
+
- `react-cam-roi-text-field-label`
|
492
|
+
- `react-cam-roi-text-field-label-light`
|
493
|
+
- `react-cam-roi-text-field-label-dark`
|
494
|
+
- `react-cam-roi-text-field-label-error`
|
495
|
+
- `react-cam-roi-text-field-helper-text`
|
496
|
+
- `react-cam-roi-text-field-helper-text-light`
|
497
|
+
- `react-cam-roi-text-field-helper-text-dark`
|
498
|
+
- `react-cam-roi-text-field-helper-text-error`
|
499
|
+
|
500
|
+
#### NumberField
|
501
|
+
|
502
|
+
##### Interface
|
503
|
+
|
504
|
+
```ts
|
505
|
+
type NumberFieldProps = {
|
506
|
+
onChange: (value: number) => void
|
507
|
+
value: number
|
508
|
+
label: string
|
509
|
+
helperText?: string
|
510
|
+
error?: boolean
|
511
|
+
required?: boolean
|
512
|
+
readOnly?: boolean
|
513
|
+
disabled?: boolean
|
514
|
+
}
|
515
|
+
```
|
516
|
+
|
517
|
+
##### Classes
|
518
|
+
|
519
|
+
- `react-cam-roi-number-field-wrapper`
|
520
|
+
- `react-cam-roi-number-field-wrapper-light`
|
521
|
+
- `react-cam-roi-number-field-wrapper-dark`
|
522
|
+
- `react-cam-roi-number-field`
|
523
|
+
- `react-cam-roi-number-field--light`
|
524
|
+
- `react-cam-roi-number-field--dark`
|
525
|
+
- `react-cam-roi-number-field--error`
|
526
|
+
- `react-cam-roi-number-field-label`
|
527
|
+
- `react-cam-roi-number-field-label-light`
|
528
|
+
- `react-cam-roi-number-field-label-dark`
|
529
|
+
- `react-cam-roi-number-field-label-error`
|
530
|
+
- `react-cam-roi-number-field-helper-text`
|
531
|
+
- `react-cam-roi-number-field-helper-text-light`
|
532
|
+
- `react-cam-roi-number-field-helper-text-dark`
|
533
|
+
- `react-cam-roi-number-field-helper-text-error`
|
534
|
+
|
535
|
+
#### BoolField
|
536
|
+
|
537
|
+
##### Interface
|
538
|
+
|
539
|
+
```ts
|
540
|
+
type BoolFieldProps = {
|
541
|
+
onChange: (value: boolean) => void
|
542
|
+
value: boolean
|
543
|
+
label: string
|
544
|
+
helperText?: string
|
545
|
+
error?: boolean
|
546
|
+
required?: boolean
|
547
|
+
readOnly?: boolean
|
548
|
+
disabled?: boolean
|
549
|
+
}
|
550
|
+
```
|
551
|
+
|
552
|
+
##### Classes
|
553
|
+
|
554
|
+
- `react-cam-roi-bool-field-wrapper`
|
555
|
+
- `react-cam-roi-bool-field-wrapper-light`
|
556
|
+
- `react-cam-roi-bool-field-wrapper-dark`
|
557
|
+
- `react-cam-roi-bool-field`
|
558
|
+
- `react-cam-roi-bool-field--light`
|
559
|
+
- `react-cam-roi-bool-field--dark`
|
560
|
+
- `react-cam-roi-bool-field--error`
|
561
|
+
- `react-cam-roi-bool-field-label`
|
562
|
+
- `react-cam-roi-bool-field-label-light`
|
563
|
+
- `react-cam-roi-bool-field-label-dark`
|
564
|
+
- `react-cam-roi-bool-field-label-error`
|
565
|
+
- `react-cam-roi-bool-field-helper-text`
|
566
|
+
- `react-cam-roi-bool-field-helper-text-light`
|
567
|
+
- `react-cam-roi-bool-field-helper-text-dark`
|
568
|
+
- `react-cam-roi-bool-field-helper-text-error`
|
569
|
+
|
570
|
+
#### EnumField
|
571
|
+
|
572
|
+
##### Interface
|
573
|
+
|
574
|
+
```ts
|
575
|
+
type EnumFieldProps = {
|
576
|
+
onChange: (value: string | number | (string | number)[]) => void
|
577
|
+
value: string | number | (string | number)[]
|
578
|
+
label: string
|
579
|
+
helperText?: string
|
580
|
+
error?: boolean
|
581
|
+
required?: boolean
|
582
|
+
multiple?: boolean
|
583
|
+
disabled?: boolean
|
584
|
+
}
|
585
|
+
```
|
586
|
+
|
587
|
+
##### Classes
|
588
|
+
|
589
|
+
- `react-cam-roi-enum-field-wrapper`
|
590
|
+
- `react-cam-roi-enum-field-wrapper-light`
|
591
|
+
- `react-cam-roi-enum-field-wrapper-dark`
|
592
|
+
- `react-cam-roi-enum-field`
|
593
|
+
- `react-cam-roi-enum-field--light`
|
594
|
+
- `react-cam-roi-enum-field--dark`
|
595
|
+
- `react-cam-roi-enum-field--error`
|
596
|
+
- `react-cam-roi-enum-field-label`
|
597
|
+
- `react-cam-roi-enum-field-label-light`
|
598
|
+
- `react-cam-roi-enum-field-label-dark`
|
599
|
+
- `react-cam-roi-enum-field-label-error`
|
600
|
+
- `react-cam-roi-enum-field-helper-text`
|
601
|
+
- `react-cam-roi-enum-field-helper-text-light`
|
602
|
+
- `react-cam-roi-enum-field-helper-text-dark`
|
603
|
+
- `react-cam-roi-enum-field-helper-text-error`
|
604
|
+
|
605
|
+
|
606
|
+
#### Button
|
607
|
+
|
608
|
+
##### Interface
|
609
|
+
|
610
|
+
```ts
|
611
|
+
type ButtonProps = {
|
612
|
+
onClick: (event: React.MouseEvent) => void
|
613
|
+
primary?: boolean
|
614
|
+
disabled?: boolean
|
615
|
+
}
|
616
|
+
```
|
617
|
+
|
618
|
+
##### Classes
|
619
|
+
|
620
|
+
- `react-cam-roi-button`
|
621
|
+
- `react-cam-roi-button-light`
|
622
|
+
- `react-cam-roi-button-dark`
|
623
|
+
- `react-cam-roi-button-disabled`
|
624
|
+
- `react-cam-roi-button-disabled-light`
|
625
|
+
- `react-cam-roi-button-disabled-dark`
|
626
|
+
|
627
|
+
### Functions
|
628
|
+
|
629
|
+
``` ts
|
630
|
+
type INotify = { // compatible with toast (react-toastify)
|
631
|
+
info: (message: string) => void
|
632
|
+
warn: (message: string) => void
|
633
|
+
error: (message: string) => void
|
634
|
+
success: (message: string) => void
|
635
|
+
}
|
636
|
+
```
|
637
|
+
|
132
638
|
### Styles
|
133
639
|
|
134
640
|
There are components that cannot be overridden. But still you can use classes to style them.
|
@@ -141,15 +647,29 @@ There are components that cannot be overridden. But still you can use classes to
|
|
141
647
|
|
142
648
|
#### Toolbar
|
143
649
|
|
650
|
+
- `react-cam-roi-toolbar-info`
|
651
|
+
- `react-cam-roi-toolbar-info-light`
|
652
|
+
- `react-cam-roi-toolbar-info-dark`
|
653
|
+
|
144
654
|
- `react-cam-roi-toolbar`
|
145
655
|
- `react-cam-roi-toolbar-light`
|
146
656
|
- `react-cam-roi-toolbar-dark`
|
147
657
|
|
148
|
-
|
658
|
+
- `react-cam-roi-toolbar-spacer`
|
659
|
+
- `react-cam-roi-toolbar-spacer-light`
|
660
|
+
- `react-cam-roi-toolbar-spacer-dark`
|
661
|
+
|
662
|
+
#### Toolbar help text
|
663
|
+
|
664
|
+
- `react-cam-roi-toolbar-helper`
|
665
|
+
- `react-cam-roi-toolbar-helper-light`
|
666
|
+
- `react-cam-roi-toolbar-helper-dark`
|
667
|
+
|
668
|
+
#### Shapes list
|
149
669
|
|
150
|
-
- `react-cam-roi-
|
151
|
-
- `react-cam-roi-
|
152
|
-
- `react-cam-roi-
|
670
|
+
- `react-cam-roi-shapes-table`
|
671
|
+
- `react-cam-roi-shapes-table-light`
|
672
|
+
- `react-cam-roi-shapes-table-dark`
|
153
673
|
|
154
674
|
#### Colorpicker button
|
155
675
|
|
@@ -160,3 +680,42 @@ There are components that cannot be overridden. But still you can use classes to
|
|
160
680
|
- `react-cam-roi-colorpicker-button-active`
|
161
681
|
- `react-cam-roi-colorpicker-button-active-light`
|
162
682
|
- `react-cam-roi-colorpicker-button-active-dark`
|
683
|
+
|
684
|
+
#### Form
|
685
|
+
|
686
|
+
- `react-cam-roi-form`
|
687
|
+
|
688
|
+
## Development
|
689
|
+
|
690
|
+
After cloning the repository and install dependencies (`yarn install`), you can run the following commands:
|
691
|
+
|
692
|
+
| Command | Description |
|
693
|
+
| ---------------- | --------------------- |
|
694
|
+
| `yarn clean` | Clean the dist folder |
|
695
|
+
| `yarn build` | Build the library |
|
696
|
+
| `yarn storybook` | Run storybook |
|
697
|
+
|
698
|
+
In order to start developing just run the storybook, then make changes to code and the storybook will be updated.
|
699
|
+
|
700
|
+
In order to test the library in onother local react project you can:
|
701
|
+
|
702
|
+
```bash
|
703
|
+
$ cd react-cam-roi
|
704
|
+
$ yarn link
|
705
|
+
$ cd ../my-project
|
706
|
+
$ yarn link @abidibo/react-cam-roi
|
707
|
+
```
|
708
|
+
|
709
|
+
Then rebuild this library to see your changes in the project.
|
710
|
+
|
711
|
+
## CI
|
712
|
+
|
713
|
+
A github action pipeline is provided, it will publish the package to npm when a new tag is pushed. You need to add the `NPM_TOKEN` secret to your repository settings.
|
714
|
+
|
715
|
+
Example of deployment:
|
716
|
+
|
717
|
+
```bash
|
718
|
+
$ npm version patch
|
719
|
+
$ git push
|
720
|
+
$ git push --tags
|
721
|
+
```
|