@abidibo/react-cam-roi 0.10.0 → 0.12.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 +15 -1
- package/dist/index.cjs.js +27 -11
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +27 -11
- package/dist/index.esm.js.map +1 -1
- package/dist/types/Components/Tooltip/index.d.ts +6 -0
- package/dist/types/Providers/UiProvider.d.ts +6 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
@@ -485,6 +485,11 @@ var TextField = function (_a) {
|
|
485
485
|
return (jsxs("div", { className: css('text-field-wrapper', styles$8, themeMode), style: { width: fullWidth ? '100%' : 'auto' }, children: [label && (jsx("label", { className: "".concat(css('text-field-label', styles$8, themeMode), " ").concat(error ? css('text-field-label-error', styles$8, null) : ''), children: jsxs(Typography, { children: [label, required && ' *'] }) })), jsx("input", { type: type, className: "".concat(css('text-field', styles$8, themeMode), " ").concat(error ? css('text-field-error', styles$8, null) : ''), onChange: handleChange, value: value, readOnly: readOnly, disabled: disabled }), helperText && (jsx(Typography, { component: 'div', className: "".concat(css('text-field-helper-text', styles$8, themeMode), " ").concat(error ? css('text-field-helper-text-error', styles$8, null) : ''), children: helperText }))] }));
|
486
486
|
};
|
487
487
|
|
488
|
+
var Tooltip = function (_a) {
|
489
|
+
var title = _a.title, children = _a.children;
|
490
|
+
return jsx("div", { title: title, children: children });
|
491
|
+
};
|
492
|
+
|
488
493
|
var Typography = function (_a) {
|
489
494
|
var children = _a.children, _b = _a.style, style = _b === void 0 ? {} : _b, _c = _a.className, className = _c === void 0 ? '' : _c, _d = _a.component, component = _d === void 0 ? 'span' : _d;
|
490
495
|
var Tag = component;
|
@@ -523,6 +528,7 @@ var DefaultUiContext = {
|
|
523
528
|
primaryColor: '#1976d2',
|
524
529
|
primaryFgColor: '#fff',
|
525
530
|
Typography: Typography,
|
531
|
+
Tooltip: Tooltip,
|
526
532
|
IconButton: IconButton,
|
527
533
|
Modal: Modal,
|
528
534
|
DeleteIcon: DeleteIcon,
|
@@ -544,6 +550,7 @@ var DefaultUiContext = {
|
|
544
550
|
cannotDrawMorePolygons: 'You cannot draw more polygons',
|
545
551
|
cannotDrawMorePolylines: 'You cannot draw more polylines',
|
546
552
|
cannotDrawMoreRectangles: 'You cannot draw more rectangles',
|
553
|
+
fullImage: 'Full image',
|
547
554
|
id: 'ID',
|
548
555
|
invalidSubmission: 'Invalid submission',
|
549
556
|
mainParametersMetadata: 'Main parameters',
|
@@ -559,10 +566,10 @@ var DefaultUiContext = {
|
|
559
566
|
polylineHelpText: 'click to draw all the polyline points, double click on the last point to stop drawing',
|
560
567
|
presetDescription: 'Preset description',
|
561
568
|
presetName: 'Image preset',
|
562
|
-
rect: 'Rectangle',
|
563
|
-
rectHelpText: 'click and drag to draw the rectangle',
|
564
569
|
pointer: 'Selection',
|
565
570
|
pointerHelpText: 'click a shape to select it',
|
571
|
+
rect: 'Rectangle',
|
572
|
+
rectHelpText: 'click and drag to draw the rectangle',
|
566
573
|
requiredField: 'This field is required',
|
567
574
|
roiMultiplicityEqRule: 'a number of "{role}" ({type}) equal to {threshold}',
|
568
575
|
roiMultiplicityGtRule: 'a number of "{role}" ({type}) greater than {threshold}',
|
@@ -573,6 +580,7 @@ var DefaultUiContext = {
|
|
573
580
|
roisToBeDrawn: 'ROIs to be drawn',
|
574
581
|
role: 'Role',
|
575
582
|
save: 'Save',
|
583
|
+
selection: 'Selection',
|
576
584
|
shapeParametersMetadata: 'Shape parameters',
|
577
585
|
shapesOfRoleShouldBeEqualToThreshold: 'Shapes of role {role} should be equal to {threshold}',
|
578
586
|
shapesOfRoleShouldBeGreaterThanThreshold: 'Shapes of role {role} should be greater than {threshold}',
|
@@ -584,10 +592,11 @@ var DefaultUiContext = {
|
|
584
592
|
};
|
585
593
|
var UiContext = createContext(DefaultUiContext); // eslint-disable-line
|
586
594
|
var UiProvider = function (_a) {
|
587
|
-
var children = _a.children, enableLogs = _a.enableLogs, themeMode = _a.themeMode, primaryColor = _a.primaryColor, primaryFgColor = _a.primaryFgColor, Typography = _a.Typography, Modal = _a.Modal, IconButton = _a.IconButton, DeleteIcon = _a.DeleteIcon, EditIcon = _a.EditIcon, CopyIcon = _a.CopyIcon, AnnotateIcon = _a.AnnotateIcon, SaveIcon = _a.SaveIcon, CloseIcon = _a.CloseIcon, TextField = _a.TextField, NumberField = _a.NumberField, BoolField = _a.BoolField, EnumField = _a.EnumField, Button = _a.Button, pickerColors = _a.pickerColors, notify = _a.notify, strings = _a.strings;
|
595
|
+
var children = _a.children, enableLogs = _a.enableLogs, themeMode = _a.themeMode, primaryColor = _a.primaryColor, primaryFgColor = _a.primaryFgColor, Typography = _a.Typography, Tooltip = _a.Tooltip, Modal = _a.Modal, IconButton = _a.IconButton, DeleteIcon = _a.DeleteIcon, EditIcon = _a.EditIcon, CopyIcon = _a.CopyIcon, AnnotateIcon = _a.AnnotateIcon, SaveIcon = _a.SaveIcon, CloseIcon = _a.CloseIcon, TextField = _a.TextField, NumberField = _a.NumberField, BoolField = _a.BoolField, EnumField = _a.EnumField, Button = _a.Button, pickerColors = _a.pickerColors, notify = _a.notify, strings = _a.strings;
|
588
596
|
var ctx = {
|
589
597
|
enableLogs: enableLogs !== null && enableLogs !== void 0 ? enableLogs : DefaultUiContext.enableLogs,
|
590
598
|
Typography: Typography !== null && Typography !== void 0 ? Typography : DefaultUiContext.Typography,
|
599
|
+
Tooltip: Tooltip !== null && Tooltip !== void 0 ? Tooltip : DefaultUiContext.Tooltip,
|
591
600
|
Modal: Modal !== null && Modal !== void 0 ? Modal : DefaultUiContext.Modal,
|
592
601
|
IconButton: IconButton !== null && IconButton !== void 0 ? IconButton : DefaultUiContext.IconButton,
|
593
602
|
DeleteIcon: DeleteIcon !== null && DeleteIcon !== void 0 ? DeleteIcon : DefaultUiContext.DeleteIcon,
|
@@ -811,12 +820,13 @@ var handleDoubleClickPolygon = function (editorId, canvas, activeColor, setIsDra
|
|
811
820
|
}
|
812
821
|
};
|
813
822
|
var renderFullImagePolygon = function (editorId, canvas, activeColor, imageSize) {
|
823
|
+
var OFFSET = 5;
|
814
824
|
var id = v4();
|
815
825
|
var points = [
|
816
|
-
{ x:
|
817
|
-
{ x: imageSize.width -
|
818
|
-
{ x: imageSize.width -
|
819
|
-
{ x:
|
826
|
+
{ x: OFFSET, y: OFFSET },
|
827
|
+
{ x: imageSize.width - OFFSET, y: OFFSET },
|
828
|
+
{ x: imageSize.width - OFFSET, y: imageSize.height - OFFSET },
|
829
|
+
{ x: OFFSET, y: imageSize.height - OFFSET },
|
820
830
|
];
|
821
831
|
var polygon = new oo(points, {
|
822
832
|
fill: 'transparent',
|
@@ -1547,11 +1557,17 @@ var ParametersModalForm = function (_a) {
|
|
1547
1557
|
var _a;
|
1548
1558
|
return (__assign(__assign({}, acc), (_a = {}, _a[p.codename] = p.value, _a)));
|
1549
1559
|
}, {});
|
1560
|
+
// if not in modal we save at every field change
|
1561
|
+
useEffect(function () {
|
1562
|
+
if (noModal) {
|
1563
|
+
handleSubmit();
|
1564
|
+
}
|
1565
|
+
}, [fields]);
|
1550
1566
|
var handleSubmit = function () {
|
1551
1567
|
if (shapeType && name === '') {
|
1552
1568
|
setErrors({ name: strings.requiredField });
|
1553
1569
|
}
|
1554
|
-
else if (validateParametersForm(parameters, fields, setErrors, strings)) {
|
1570
|
+
else if (!noModal || validateParametersForm(parameters, fields, setErrors, strings)) {
|
1555
1571
|
var data_1 = __spreadArray([], parameters.map(function (p) { return ({ codename: p.codename, value: fields[p.codename] }); }), true);
|
1556
1572
|
if (shapeType) {
|
1557
1573
|
onSubmit(data_1, { name: name, role: role });
|
@@ -1693,7 +1709,7 @@ var styles$1 = {"toolbar":"Toolbar-module_toolbar__ywNcv","toolbar-light":"Toolb
|
|
1693
1709
|
var Toolbar = function (_a) {
|
1694
1710
|
var _b;
|
1695
1711
|
var canvasRef = _a.canvasRef, imageSize = _a.imageSize;
|
1696
|
-
var _c = useContext(UiContext), IconButton = _c.IconButton, themeMode = _c.themeMode, primaryColor = _c.primaryColor, Typography = _c.Typography, strings = _c.strings;
|
1712
|
+
var _c = useContext(UiContext), IconButton = _c.IconButton, themeMode = _c.themeMode, primaryColor = _c.primaryColor, Typography = _c.Typography, strings = _c.strings, Tooltip = _c.Tooltip;
|
1697
1713
|
var _d = useEditorContext(), activeTool = _d.activeTool, setActiveTool = _d.setActiveTool, configuration = _d.configuration, shapes = _d.shapes, editorId = _d.editorId, activeColor = _d.activeColor;
|
1698
1714
|
var iconColor = function (tool) { return (tool === activeTool ? primaryColor : themeMode === 'light' ? 'black' : 'white'); };
|
1699
1715
|
var setTool = function (tool) { return function () { return setActiveTool(tool); }; };
|
@@ -1707,7 +1723,7 @@ var Toolbar = function (_a) {
|
|
1707
1723
|
var handleRenderFullImagePolygon = function () {
|
1708
1724
|
renderFullImagePolygon(editorId, canvasRef.current, activeColor, imageSize);
|
1709
1725
|
};
|
1710
|
-
return (jsxs(Fragment, { children: [jsx("div", { className: css('toolbar', styles$1, themeMode), children: enableRois(configuration) && (jsxs(Fragment, { children: [jsx(IconButton, { onClick: setTool("pointer" /* ToolEnum.Pointer */), children: jsx(PointerIcon, { color: iconColor("pointer" /* ToolEnum.Pointer */) }) }), (!hideForbiddenTools || pointEnabled) && (jsx(IconButton, { onClick: setTool("point" /* ToolEnum.Point */), disabled: !pointEnabled, children: jsx(PointIcon, { color: iconColor("point" /* ToolEnum.Point */) }) })), (!hideForbiddenTools || polylineEnabled) && (jsx(IconButton, { onClick: setTool("polyline" /* ToolEnum.Polyline */), disabled: !polylineEnabled, children: jsx(PolylineIcon, { color: iconColor("polyline" /* ToolEnum.Polyline */) }) })), (!hideForbiddenTools || polygonEnabled) && (jsxs(Fragment, { children: [jsx(IconButton, { onClick: setTool("polygon" /* ToolEnum.Polygon */), disabled: !polygonEnabled, children: jsx(PolygonIcon, { color: iconColor("polygon" /* ToolEnum.Polygon */) }) }), jsx(IconButton, { onClick: handleRenderFullImagePolygon, disabled: !polygonEnabled, children: jsx(FullRoiIcon, { color: iconColor("polygon" /* ToolEnum.Polygon */) }) })] })), (!hideForbiddenTools || rectangleEnabled) && (jsx(IconButton, { onClick: setTool("rect" /* ToolEnum.Rectangle */), disabled: !rectangleEnabled, children: jsx(RectangleIcon, { color: iconColor("rect" /* ToolEnum.Rectangle */) }) })), jsx(ColorPicker, { style: { marginLeft: 'auto', marginRight: '.5rem' } })] })) }), enableRois(configuration) && (jsx("div", { className: css('toolbar-helper', styles$1, themeMode), children: jsxs(Typography, { children: [strings[activeTool], ": ", strings["".concat(activeTool, "HelpText")]] }) }))] }));
|
1726
|
+
return (jsxs(Fragment, { children: [jsx("div", { className: css('toolbar', styles$1, themeMode), children: enableRois(configuration) && (jsxs(Fragment, { children: [jsx(Tooltip, { title: strings.selection, children: jsx(IconButton, { onClick: setTool("pointer" /* ToolEnum.Pointer */), children: jsx(PointerIcon, { color: iconColor("pointer" /* ToolEnum.Pointer */) }) }) }), (!hideForbiddenTools || pointEnabled) && (jsx(Tooltip, { title: strings.point, children: jsx(IconButton, { onClick: setTool("point" /* ToolEnum.Point */), disabled: !pointEnabled, children: jsx(PointIcon, { color: iconColor("point" /* ToolEnum.Point */) }) }) })), (!hideForbiddenTools || polylineEnabled) && (jsx(Tooltip, { title: strings.polyline, children: jsx(IconButton, { onClick: setTool("polyline" /* ToolEnum.Polyline */), disabled: !polylineEnabled, children: jsx(PolylineIcon, { color: iconColor("polyline" /* ToolEnum.Polyline */) }) }) })), (!hideForbiddenTools || polygonEnabled) && (jsxs(Fragment, { children: [jsx(Tooltip, { title: strings.polygon, children: jsx(IconButton, { onClick: setTool("polygon" /* ToolEnum.Polygon */), disabled: !polygonEnabled, children: jsx(PolygonIcon, { color: iconColor("polygon" /* ToolEnum.Polygon */) }) }) }), jsx(Tooltip, { title: strings.fullImage, children: jsx(IconButton, { onClick: handleRenderFullImagePolygon, disabled: !polygonEnabled, children: jsx(FullRoiIcon, { color: iconColor("polygon" /* ToolEnum.Polygon */) }) }) })] })), (!hideForbiddenTools || rectangleEnabled) && (jsx(Tooltip, { title: strings.rect, children: jsx(IconButton, { onClick: setTool("rect" /* ToolEnum.Rectangle */), disabled: !rectangleEnabled, children: jsx(RectangleIcon, { color: iconColor("rect" /* ToolEnum.Rectangle */) }) }) })), jsx(ColorPicker, { style: { marginLeft: 'auto', marginRight: '.5rem' } })] })) }), enableRois(configuration) && (jsx("div", { className: css('toolbar-helper', styles$1, themeMode), children: jsxs(Typography, { children: [strings[activeTool], ": ", strings["".concat(activeTool, "HelpText")]] }) }))] }));
|
1711
1727
|
};
|
1712
1728
|
|
1713
1729
|
var styles = {"top-bar":"TopBar-module_top-bar__9oCUR","main-parameters-view":"TopBar-module_main-parameters-view__f-0SX","main-parameters-view-light":"TopBar-module_main-parameters-view-light__o-dbi","main-parameters-view-dark":"TopBar-module_main-parameters-view-dark__FnEnj","main-parameters-button":"TopBar-module_main-parameters-button__9JX--"};
|
@@ -1722,7 +1738,7 @@ var TopBar = function () {
|
|
1722
1738
|
setMetadata(__assign(__assign({}, metadata), { parameters: data }));
|
1723
1739
|
setForm({ isOpen: false });
|
1724
1740
|
};
|
1725
|
-
return (jsxs(Fragment, { children: [jsxs("div", { className: css('top-bar', styles, themeMode), children: [enableMainMetadata(configuration) && !((_a = configuration.options) === null || _a === void 0 ? void 0 : _a.viewMainParameters) && (jsxs(Button, { onClick: function () { return setForm({ isOpen: true }); }, children: [jsx(AnnotateIcon, { color: iconColor }), " ", strings.mainParametersMetadata] })), jsxs(Button, { primary: true, onClick: onSubmit, children: [jsx(SaveIcon, { color: primaryFgColor }), " ", strings.save] }), form.isOpen && (jsx(ParametersModalForm, { parameters: configuration.parameters, data: metadata.parameters, title: strings.mainParametersMetadata, onClose: function () { return setForm({ isOpen: false }); }, onSubmit: handleSubmitMetadata }))] }), enableMainMetadata(configuration) && ((_b = configuration.options) === null || _b === void 0 ? void 0 : _b.viewMainParameters) && (
|
1741
|
+
return (jsxs(Fragment, { children: [jsxs("div", { className: css('top-bar', styles, themeMode), children: [enableMainMetadata(configuration) && !((_a = configuration.options) === null || _a === void 0 ? void 0 : _a.viewMainParameters) && (jsxs(Button, { onClick: function () { return setForm({ isOpen: true }); }, children: [jsx(AnnotateIcon, { color: iconColor }), " ", strings.mainParametersMetadata] })), jsxs(Button, { primary: true, onClick: onSubmit, children: [jsx(SaveIcon, { color: primaryFgColor }), " ", strings.save] }), form.isOpen && (jsx(ParametersModalForm, { parameters: configuration.parameters, data: metadata.parameters, title: strings.mainParametersMetadata, onClose: function () { return setForm({ isOpen: false }); }, onSubmit: handleSubmitMetadata }))] }), enableMainMetadata(configuration) && ((_b = configuration.options) === null || _b === void 0 ? void 0 : _b.viewMainParameters) && (jsx("div", { className: css('main-parameters-view', styles, themeMode), children: jsx(ParametersModalForm, { parameters: configuration.parameters, data: metadata.parameters, title: strings.mainParametersMetadata, onClose: function () { return setForm({ isOpen: false }); }, onSubmit: handleSubmitMetadata, noModal: true }) }))] }));
|
1726
1742
|
};
|
1727
1743
|
|
1728
1744
|
// https://github.com/n-mazaheri/image-editor
|