@abidibo/react-cam-roi 0.0.13 → 0.2.0
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 +22 -33
- package/package.json +28 -1
- package/dist/Components/BoolField/BoolField.module.css +0 -60
- package/dist/Components/BoolField/index.d.ts +0 -5
- package/dist/Components/BoolField/index.js +0 -13
- package/dist/Components/Button/Button.module.css +0 -29
- package/dist/Components/Button/index.d.ts +0 -8
- package/dist/Components/Button/index.js +0 -15
- package/dist/Components/EnumField/EnumField.module.css +0 -61
- package/dist/Components/EnumField/index.d.ts +0 -10
- package/dist/Components/EnumField/index.js +0 -16
- package/dist/Components/IconButton/IconButton.module.css +0 -20
- package/dist/Components/IconButton/index.d.ts +0 -7
- package/dist/Components/IconButton/index.js +0 -10
- package/dist/Components/Loader/Loader.module.css +0 -25
- package/dist/Components/Loader/index.d.ts +0 -1
- package/dist/Components/Loader/index.js +0 -9
- package/dist/Components/Modal/Modal.module.css +0 -92
- package/dist/Components/Modal/index.d.ts +0 -10
- package/dist/Components/Modal/index.js +0 -16
- package/dist/Components/NumberField/NumberField.module.css +0 -60
- package/dist/Components/NumberField/index.d.ts +0 -3
- package/dist/Components/NumberField/index.js +0 -13
- package/dist/Components/RoiEditor/Canvas.d.ts +0 -10
- package/dist/Components/RoiEditor/Canvas.js +0 -28
- package/dist/Components/RoiEditor/ColorPicker.d.ts +0 -5
- package/dist/Components/RoiEditor/ColorPicker.js +0 -12
- package/dist/Components/RoiEditor/ColorPicker.module.css +0 -17
- package/dist/Components/RoiEditor/Header.d.ts +0 -2
- package/dist/Components/RoiEditor/Header.js +0 -22
- package/dist/Components/RoiEditor/Header.module.css +0 -32
- package/dist/Components/RoiEditor/Hooks.d.ts +0 -35
- package/dist/Components/RoiEditor/Hooks.js +0 -321
- package/dist/Components/RoiEditor/ParameterField.d.ts +0 -9
- package/dist/Components/RoiEditor/ParameterField.js +0 -27
- package/dist/Components/RoiEditor/ParametersModalForm/ParametersModalForm.module.css +0 -5
- package/dist/Components/RoiEditor/ParametersModalForm/index.d.ts +0 -16
- package/dist/Components/RoiEditor/ParametersModalForm/index.js +0 -40
- package/dist/Components/RoiEditor/Polygon.d.ts +0 -18
- package/dist/Components/RoiEditor/Polygon.js +0 -77
- package/dist/Components/RoiEditor/Polyline.d.ts +0 -28
- package/dist/Components/RoiEditor/Polyline.js +0 -75
- package/dist/Components/RoiEditor/Rectangle.d.ts +0 -21
- package/dist/Components/RoiEditor/Rectangle.js +0 -73
- package/dist/Components/RoiEditor/RoiEditor.module.css +0 -5
- package/dist/Components/RoiEditor/RoisInfo.d.ts +0 -2
- package/dist/Components/RoiEditor/RoisInfo.js +0 -43
- package/dist/Components/RoiEditor/ShapesList.d.ts +0 -2
- package/dist/Components/RoiEditor/ShapesList.js +0 -77
- package/dist/Components/RoiEditor/ShapesList.module.css +0 -67
- package/dist/Components/RoiEditor/Toolbar.d.ts +0 -2
- package/dist/Components/RoiEditor/Toolbar.js +0 -25
- package/dist/Components/RoiEditor/Toolbar.module.css +0 -41
- package/dist/Components/RoiEditor/Types.d.ts +0 -119
- package/dist/Components/RoiEditor/Types.js +0 -15
- package/dist/Components/RoiEditor/Utils.d.ts +0 -22
- package/dist/Components/RoiEditor/Utils.js +0 -150
- package/dist/Components/RoiEditor/index.d.ts +0 -10
- package/dist/Components/RoiEditor/index.js +0 -78
- package/dist/Components/RoleField.d.ts +0 -7
- package/dist/Components/RoleField.js +0 -35
- package/dist/Components/TextField/TextField.module.css +0 -61
- package/dist/Components/TextField/index.d.ts +0 -6
- package/dist/Components/TextField/index.js +0 -13
- package/dist/Components/Typography/index.d.ts +0 -9
- package/dist/Components/Typography/index.js +0 -6
- package/dist/Icons/AnnotateIcon.d.ts +0 -6
- package/dist/Icons/AnnotateIcon.js +0 -5
- package/dist/Icons/CloseIcon.d.ts +0 -6
- package/dist/Icons/CloseIcon.js +0 -5
- package/dist/Icons/CopyIcon.d.ts +0 -6
- package/dist/Icons/CopyIcon.js +0 -5
- package/dist/Icons/DeleteIcon.d.ts +0 -6
- package/dist/Icons/DeleteIcon.js +0 -5
- package/dist/Icons/EditIcon.d.ts +0 -6
- package/dist/Icons/EditIcon.js +0 -5
- package/dist/Icons/PointerIcon.d.ts +0 -6
- package/dist/Icons/PointerIcon.js +0 -5
- package/dist/Icons/PolygonIcon.d.ts +0 -6
- package/dist/Icons/PolygonIcon.js +0 -5
- package/dist/Icons/PolylineIcon.d.ts +0 -6
- package/dist/Icons/PolylineIcon.js +0 -5
- package/dist/Icons/RectangleIcon.d.ts +0 -6
- package/dist/Icons/RectangleIcon.js +0 -5
- package/dist/Icons/SaveIcon.d.ts +0 -6
- package/dist/Icons/SaveIcon.js +0 -5
- package/dist/Icons/SelectIcon.d.ts +0 -6
- package/dist/Icons/SelectIcon.js +0 -5
- package/dist/Providers/EditorProvider.d.ts +0 -26
- package/dist/Providers/EditorProvider.js +0 -29
- package/dist/Providers/UiProvider.d.ts +0 -84
- package/dist/Providers/UiProvider.js +0 -107
- package/dist/Types.d.ts +0 -10
- package/dist/Types.js +0 -1
- package/dist/Utils/Dispatcher.d.ts +0 -16
- package/dist/Utils/Dispatcher.js +0 -65
- package/dist/Utils/index.d.ts +0 -4
- package/dist/Utils/index.js +0 -14
- package/dist/index.d.ts +0 -4
- package/dist/index.js +0 -4
@@ -1,29 +0,0 @@
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
2
|
-
import { createContext, useContext } from 'react';
|
3
|
-
export const EditorContext = createContext(undefined); // eslint-disable-line
|
4
|
-
export function useEditorContext() {
|
5
|
-
const context = useContext(EditorContext);
|
6
|
-
if (context === undefined) {
|
7
|
-
throw new Error('useEditorContext must be within a EditorProvider');
|
8
|
-
}
|
9
|
-
return context;
|
10
|
-
}
|
11
|
-
const EditorProvider = ({ children, editorId, hideForbiddenTools, activeTool, setActiveTool, activeColor, setActiveColor, shapes, addShape, addShapes, removeShape, configuration, metadata, setMetadata, onSubmit, }) => {
|
12
|
-
return (_jsx(EditorContext.Provider, { value: {
|
13
|
-
editorId,
|
14
|
-
hideForbiddenTools,
|
15
|
-
activeTool,
|
16
|
-
setActiveTool,
|
17
|
-
activeColor,
|
18
|
-
setActiveColor,
|
19
|
-
shapes,
|
20
|
-
addShape,
|
21
|
-
addShapes,
|
22
|
-
removeShape,
|
23
|
-
configuration,
|
24
|
-
metadata,
|
25
|
-
setMetadata,
|
26
|
-
onSubmit,
|
27
|
-
}, children: children }));
|
28
|
-
};
|
29
|
-
export default EditorProvider;
|
@@ -1,84 +0,0 @@
|
|
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 SelectIcon from '../Icons/SelectIcon';
|
7
|
-
import { INotify } from '../Components/RoiEditor/Types';
|
8
|
-
import CopyIcon from '../Icons/CopyIcon';
|
9
|
-
import AnnotateIcon from '../Icons/AnnotateIcon';
|
10
|
-
import Modal from '../Components/Modal';
|
11
|
-
import CloseIcon from '../Icons/CloseIcon';
|
12
|
-
import TextField from '../Components/TextField';
|
13
|
-
import NumberField from '../Components/NumberField';
|
14
|
-
import BoolField from '../Components/BoolField';
|
15
|
-
import EnumField from '../Components/EnumField';
|
16
|
-
import Button from '../Components/Button';
|
17
|
-
import SaveIcon from '../Icons/SaveIcon';
|
18
|
-
type UiContextType = {
|
19
|
-
children?: React.ReactNode;
|
20
|
-
enableLogs: boolean;
|
21
|
-
themeMode: 'light' | 'dark';
|
22
|
-
primaryColor: string;
|
23
|
-
primaryFgColor: string;
|
24
|
-
Typography: typeof Typography;
|
25
|
-
IconButton: typeof IconButton;
|
26
|
-
Modal: typeof Modal;
|
27
|
-
DeleteIcon: typeof DeleteIcon;
|
28
|
-
EditIcon: typeof EditIcon;
|
29
|
-
SelectIcon: typeof SelectIcon;
|
30
|
-
CopyIcon: typeof CopyIcon;
|
31
|
-
AnnotateIcon: typeof AnnotateIcon;
|
32
|
-
SaveIcon: typeof SaveIcon;
|
33
|
-
CloseIcon: typeof CloseIcon;
|
34
|
-
TextField: typeof TextField;
|
35
|
-
NumberField: typeof NumberField;
|
36
|
-
BoolField: typeof BoolField;
|
37
|
-
EnumField: typeof EnumField;
|
38
|
-
Button: typeof Button;
|
39
|
-
pickerColors: string[];
|
40
|
-
notify: INotify;
|
41
|
-
strings: {
|
42
|
-
cancel: string;
|
43
|
-
cannotDrawMorePolygons: string;
|
44
|
-
cannotDrawMorePolylines: string;
|
45
|
-
cannotDrawMoreRectangles: string;
|
46
|
-
id: string;
|
47
|
-
invalidSubmission: string;
|
48
|
-
mainParametersMetadata: string;
|
49
|
-
missingRequiredValuesInMainParameters: string;
|
50
|
-
missingRequiredValuesInShapeParameters: string;
|
51
|
-
roiMultiplicityEqRule: string;
|
52
|
-
roiMultiplicityGtRule: string;
|
53
|
-
roiMultiplicityGteRule: string;
|
54
|
-
roiMultiplicityLtRule: string;
|
55
|
-
roiMultiplicityLteRule: string;
|
56
|
-
roiMultiplicityNoRule: string;
|
57
|
-
name: string;
|
58
|
-
polygon: string;
|
59
|
-
polygonHelpText: string;
|
60
|
-
polyline: string;
|
61
|
-
polylineHelpText: string;
|
62
|
-
rect: string;
|
63
|
-
rectHelpText: string;
|
64
|
-
pointer: string;
|
65
|
-
pointerHelpText: string;
|
66
|
-
roisToBeDrawn: string;
|
67
|
-
role: string;
|
68
|
-
requiredField: string;
|
69
|
-
save: string;
|
70
|
-
shapeParametersMetadata: string;
|
71
|
-
shapesOfTypeShouldBeEqualToThreshold: string;
|
72
|
-
shapesOfTypeShouldBeGreaterThanThreshold: string;
|
73
|
-
shapesOfTypeShouldBeGreaterThanOrEqualToThreshold: string;
|
74
|
-
shapesOfTypeShouldBeLessThanThreshold: string;
|
75
|
-
shapesOfTypeShouldBeLessThanOrEqualToThreshold: string;
|
76
|
-
type: string;
|
77
|
-
};
|
78
|
-
};
|
79
|
-
export declare const DefaultUiContext: UiContextType;
|
80
|
-
export declare const UiContext: import("react").Context<UiContextType>;
|
81
|
-
declare const UiProvider: ({ children, enableLogs, themeMode, primaryColor, primaryFgColor, Typography, Modal, IconButton, DeleteIcon, EditIcon, SelectIcon, CopyIcon, AnnotateIcon, SaveIcon, CloseIcon, TextField, NumberField, BoolField, EnumField, Button, pickerColors, notify, strings, }: PropsWithChildren<Partial<Omit<UiContextType, "strings">> & {
|
82
|
-
strings?: Partial<UiContextType["strings"]>;
|
83
|
-
}>) => import("react/jsx-runtime").JSX.Element;
|
84
|
-
export default UiProvider;
|
@@ -1,107 +0,0 @@
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
2
|
-
import { createContext } from 'react';
|
3
|
-
import Typography from '../Components/Typography';
|
4
|
-
import IconButton from '../Components/IconButton';
|
5
|
-
import DeleteIcon from '../Icons/DeleteIcon';
|
6
|
-
import EditIcon from '../Icons/EditIcon';
|
7
|
-
import SelectIcon from '../Icons/SelectIcon';
|
8
|
-
import { notify } from '../Components/RoiEditor/Utils';
|
9
|
-
import CopyIcon from '../Icons/CopyIcon';
|
10
|
-
import AnnotateIcon from '../Icons/AnnotateIcon';
|
11
|
-
import Modal from '../Components/Modal';
|
12
|
-
import CloseIcon from '../Icons/CloseIcon';
|
13
|
-
import TextField from '../Components/TextField';
|
14
|
-
import NumberField from '../Components/NumberField';
|
15
|
-
import BoolField from '../Components/BoolField';
|
16
|
-
import EnumField from '../Components/EnumField';
|
17
|
-
import Button from '../Components/Button';
|
18
|
-
import SaveIcon from '../Icons/SaveIcon';
|
19
|
-
export const DefaultUiContext = {
|
20
|
-
enableLogs: true,
|
21
|
-
themeMode: 'light',
|
22
|
-
primaryColor: '#1976d2',
|
23
|
-
primaryFgColor: '#fff',
|
24
|
-
Typography,
|
25
|
-
IconButton,
|
26
|
-
Modal,
|
27
|
-
DeleteIcon,
|
28
|
-
EditIcon,
|
29
|
-
SelectIcon,
|
30
|
-
CopyIcon,
|
31
|
-
AnnotateIcon,
|
32
|
-
SaveIcon,
|
33
|
-
CloseIcon,
|
34
|
-
TextField,
|
35
|
-
NumberField,
|
36
|
-
BoolField,
|
37
|
-
EnumField,
|
38
|
-
Button,
|
39
|
-
pickerColors: ['#ffffff', '#000000', '#ff9900', '#0099ff'],
|
40
|
-
notify,
|
41
|
-
strings: {
|
42
|
-
cancel: 'Cancel',
|
43
|
-
cannotDrawMorePolygons: 'You cannot draw more polygons',
|
44
|
-
cannotDrawMorePolylines: 'You cannot draw more polylines',
|
45
|
-
cannotDrawMoreRectangles: 'You cannot draw more rectangles',
|
46
|
-
id: 'ID',
|
47
|
-
invalidSubmission: 'Invalid submission',
|
48
|
-
mainParametersMetadata: 'Main parameters',
|
49
|
-
missingRequiredValuesInMainParameters: 'Missing required values in main parameters',
|
50
|
-
missingRequiredValuesInShapeParameters: 'Missing required values in shape {id} parameters',
|
51
|
-
name: 'Name',
|
52
|
-
polygon: 'Polygon',
|
53
|
-
polygonHelpText: 'click to draw all the polygon points, double click on the last point to close the polygon',
|
54
|
-
polyline: 'Polyline',
|
55
|
-
polylineHelpText: 'click to draw all the polyline points, double click on the last point to stop drawing',
|
56
|
-
rect: 'Rectangle',
|
57
|
-
rectHelpText: 'click and drag to draw the rectangle',
|
58
|
-
pointer: 'Selection',
|
59
|
-
pointerHelpText: 'click a shape to select it',
|
60
|
-
requiredField: 'This field is required',
|
61
|
-
roiMultiplicityEqRule: 'a number of {role} ({type}) equal to {threshold}',
|
62
|
-
roiMultiplicityGtRule: 'a number of {role} ({type}) greater than {threshold}',
|
63
|
-
roiMultiplicityGteRule: 'a number of {role} ({type}) greater than or equal to {threshold}',
|
64
|
-
roiMultiplicityLtRule: 'a number of {role} ({type}) less than {threshold}',
|
65
|
-
roiMultiplicityLteRule: 'a number of {role} ({type}) less than or equal to {threshold}',
|
66
|
-
roiMultiplicityNoRule: 'a number of {role} ({type})',
|
67
|
-
roisToBeDrawn: 'ROIs to be drawn',
|
68
|
-
role: 'Role',
|
69
|
-
save: 'Save',
|
70
|
-
shapeParametersMetadata: 'Shape parameters',
|
71
|
-
shapesOfTypeShouldBeEqualToThreshold: 'Shapes of type {type} should be equal to {threshold}',
|
72
|
-
shapesOfTypeShouldBeGreaterThanThreshold: 'Shapes of type {type} should be greater than {threshold}',
|
73
|
-
shapesOfTypeShouldBeGreaterThanOrEqualToThreshold: 'Shapes of type {type} should be greater than or equal to {threshold}',
|
74
|
-
shapesOfTypeShouldBeLessThanThreshold: 'Shapes of type {type} should be less than {threshold}',
|
75
|
-
shapesOfTypeShouldBeLessThanOrEqualToThreshold: 'Shapes of type {type} should be less than or equal to {threshold}',
|
76
|
-
type: 'Type',
|
77
|
-
},
|
78
|
-
};
|
79
|
-
export const UiContext = createContext(DefaultUiContext);
|
80
|
-
const UiProvider = ({ children, enableLogs, themeMode, primaryColor, primaryFgColor, Typography, Modal, IconButton, DeleteIcon, EditIcon, SelectIcon, CopyIcon, AnnotateIcon, SaveIcon, CloseIcon, TextField, NumberField, BoolField, EnumField, Button, pickerColors, notify, strings, }) => {
|
81
|
-
const ctx = {
|
82
|
-
enableLogs: enableLogs !== null && enableLogs !== void 0 ? enableLogs : DefaultUiContext.enableLogs,
|
83
|
-
Typography: Typography !== null && Typography !== void 0 ? Typography : DefaultUiContext.Typography,
|
84
|
-
Modal: Modal !== null && Modal !== void 0 ? Modal : DefaultUiContext.Modal,
|
85
|
-
IconButton: IconButton !== null && IconButton !== void 0 ? IconButton : DefaultUiContext.IconButton,
|
86
|
-
DeleteIcon: DeleteIcon !== null && DeleteIcon !== void 0 ? DeleteIcon : DefaultUiContext.DeleteIcon,
|
87
|
-
EditIcon: EditIcon !== null && EditIcon !== void 0 ? EditIcon : DefaultUiContext.EditIcon,
|
88
|
-
SelectIcon: SelectIcon !== null && SelectIcon !== void 0 ? SelectIcon : DefaultUiContext.SelectIcon,
|
89
|
-
CopyIcon: CopyIcon !== null && CopyIcon !== void 0 ? CopyIcon : DefaultUiContext.CopyIcon,
|
90
|
-
AnnotateIcon: AnnotateIcon !== null && AnnotateIcon !== void 0 ? AnnotateIcon : DefaultUiContext.AnnotateIcon,
|
91
|
-
SaveIcon: SaveIcon !== null && SaveIcon !== void 0 ? SaveIcon : DefaultUiContext.SaveIcon,
|
92
|
-
CloseIcon: CloseIcon !== null && CloseIcon !== void 0 ? CloseIcon : DefaultUiContext.CloseIcon,
|
93
|
-
TextField: TextField !== null && TextField !== void 0 ? TextField : DefaultUiContext.TextField,
|
94
|
-
NumberField: NumberField !== null && NumberField !== void 0 ? NumberField : DefaultUiContext.NumberField,
|
95
|
-
BoolField: BoolField !== null && BoolField !== void 0 ? BoolField : DefaultUiContext.BoolField,
|
96
|
-
EnumField: EnumField !== null && EnumField !== void 0 ? EnumField : DefaultUiContext.EnumField,
|
97
|
-
Button: Button !== null && Button !== void 0 ? Button : DefaultUiContext.Button,
|
98
|
-
themeMode: themeMode !== null && themeMode !== void 0 ? themeMode : DefaultUiContext.themeMode,
|
99
|
-
primaryColor: primaryColor !== null && primaryColor !== void 0 ? primaryColor : DefaultUiContext.primaryColor,
|
100
|
-
primaryFgColor: primaryFgColor !== null && primaryFgColor !== void 0 ? primaryFgColor : DefaultUiContext.primaryFgColor,
|
101
|
-
pickerColors: pickerColors !== null && pickerColors !== void 0 ? pickerColors : DefaultUiContext.pickerColors,
|
102
|
-
notify: notify !== null && notify !== void 0 ? notify : DefaultUiContext.notify,
|
103
|
-
strings: strings ? Object.assign(Object.assign({}, DefaultUiContext.strings), strings) : DefaultUiContext.strings,
|
104
|
-
};
|
105
|
-
return _jsx(UiContext.Provider, { value: ctx, children: children });
|
106
|
-
};
|
107
|
-
export default UiProvider;
|
package/dist/Types.d.ts
DELETED
package/dist/Types.js
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
export {};
|
@@ -1,16 +0,0 @@
|
|
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;
|
package/dist/Utils/Dispatcher.js
DELETED
@@ -1,65 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* Event Dispatcher
|
3
|
-
*
|
4
|
-
* Implementation of an event dispatcher following the Mediator pattern
|
5
|
-
* @namespace
|
6
|
-
*/
|
7
|
-
const Dispatcher = {
|
8
|
-
_prefix: 'on_',
|
9
|
-
_listeners: {},
|
10
|
-
/**
|
11
|
-
* Adds a prefix to the event name
|
12
|
-
*
|
13
|
-
* Assures that event name doesn't match a standard Object property name
|
14
|
-
*/
|
15
|
-
evtName: function (evtName) {
|
16
|
-
return this._prefix + evtName;
|
17
|
-
},
|
18
|
-
/**
|
19
|
-
* Registers a callback to an event
|
20
|
-
*/
|
21
|
-
register: function (evtName, callback, bind) {
|
22
|
-
const _evtName = this.evtName(evtName);
|
23
|
-
if (typeof this._listeners[_evtName] === 'undefined') {
|
24
|
-
this._listeners[_evtName] = [];
|
25
|
-
}
|
26
|
-
this._listeners[_evtName].push([!bind ? this : bind, callback]);
|
27
|
-
},
|
28
|
-
/**
|
29
|
-
* Unregisters one or all callbacks binded to the given event
|
30
|
-
*
|
31
|
-
* @param {String} evtName name of the event
|
32
|
-
* @param {Function} callback function to unregister. All callbacks if empty
|
33
|
-
* @return void
|
34
|
-
*/
|
35
|
-
unregister: function (evtName, callback) {
|
36
|
-
const _evtName = this.evtName(evtName);
|
37
|
-
if (typeof callback === 'undefined') {
|
38
|
-
delete this._listeners[_evtName];
|
39
|
-
}
|
40
|
-
else {
|
41
|
-
// splice re-indexes the array, so I'm not declaring `var len`
|
42
|
-
// but array length is re-computed at every loop cycle
|
43
|
-
for (let i = 0; i < this._listeners[_evtName].length; i++) {
|
44
|
-
const listener = this._listeners[_evtName][i];
|
45
|
-
if (listener[1] === callback) {
|
46
|
-
this._listeners[_evtName].splice(i, 1);
|
47
|
-
}
|
48
|
-
}
|
49
|
-
}
|
50
|
-
},
|
51
|
-
/**
|
52
|
-
* Emits an event, all registered callbacks are called
|
53
|
-
*/
|
54
|
-
emit: function (evtName, ...params) {
|
55
|
-
const _evtName = this.evtName(evtName);
|
56
|
-
if (typeof this._listeners[_evtName] !== 'undefined') {
|
57
|
-
for (let i = 0, l = this._listeners[_evtName].length; i < l; i++) {
|
58
|
-
const l = this._listeners[_evtName][i];
|
59
|
-
// @ts-expect-error but it works
|
60
|
-
l[1].call(this._listeners[_evtName][i][0], evtName, ...params);
|
61
|
-
}
|
62
|
-
}
|
63
|
-
}
|
64
|
-
};
|
65
|
-
export default Dispatcher;
|
package/dist/Utils/index.d.ts
DELETED
@@ -1,4 +0,0 @@
|
|
1
|
-
export declare const log: (level: "log" | "info" | "warn" | "error", enable: boolean, ...args: unknown[]) => false | void;
|
2
|
-
export declare const css: (name: string, styles: Record<string, string>, themeMode: "light" | "dark" | null) => string;
|
3
|
-
export declare const humanize: (str: string) => string;
|
4
|
-
export declare const formatString: (str: string, placeholders: Record<string, string | number>) => string;
|
package/dist/Utils/index.js
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
export const log = (level, enable, ...args) => enable && console[level](...args);
|
2
|
-
export const css = (name, styles, themeMode) => `${styles[name]} ${styles[`${name}-${themeMode}`]} react-cam-roi-${name}${themeMode ? `react-cam-roi-${name}-${themeMode}` : ''}`;
|
3
|
-
export const humanize = (str) => {
|
4
|
-
return str
|
5
|
-
.replace(/([A-Z])/g, ' $1')
|
6
|
-
.replace('_', ' ')
|
7
|
-
.replace(/^./, (str) => str.toUpperCase());
|
8
|
-
};
|
9
|
-
export const formatString = (str, placeholders) => {
|
10
|
-
Object.keys(placeholders).forEach((key) => {
|
11
|
-
str = str.replace(`{${key}}`, placeholders[key].toString());
|
12
|
-
});
|
13
|
-
return str;
|
14
|
-
};
|
package/dist/index.d.ts
DELETED
package/dist/index.js
DELETED