@abidibo/react-cam-roi 0.11.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 CHANGED
@@ -332,6 +332,7 @@ type UiContextType = {
332
332
  primaryColor: string // primary color for internal components
333
333
  primaryFgColor: string // text color above primary bg for internal components
334
334
  Typography: React.FC<TypographyProps> // component used to surround text
335
+ Tooltip: React.FC<TooltipProps> // component used to show tooltips
335
336
  Modal: React.FC<ModalProps> // modal dialog component (it displays metadata forms)
336
337
  IconButton: React.FC<IconButtonProps> // wrapper for icon buttons
337
338
  DeleteIcon: React.FC<DeleteIconProps> // delete icon
@@ -352,6 +353,7 @@ type UiContextType = {
352
353
  cannotDrawMorePolygons: string
353
354
  cannotDrawMorePolylines: string
354
355
  cannotDrawMoreRectangles: string
356
+ fullImage: string
355
357
  id: string
356
358
  invalidSubmission: string
357
359
  mainParametersMetadata: string
@@ -382,6 +384,7 @@ type UiContextType = {
382
384
  roisToBeDrawn: string
383
385
  role: string
384
386
  save: string
387
+ selection: string
385
388
  shapeParametersMetadata: string
386
389
  shapesOfRoleShouldBeEqualToThreshold: string // with {role} and {threshold} placeholders
387
390
  shapesOfRoleShouldBeGreaterThanThreshold: string // with {role} and {threshold} placeholders
@@ -457,6 +460,17 @@ type TypographyProps = {
457
460
  }
458
461
  ```
459
462
 
463
+ #### Tooltip
464
+
465
+ ##### Interface
466
+
467
+ ```ts
468
+ type TooltipProps = {
469
+ children?: React.ReactNode
470
+ title: string
471
+ }
472
+ ```
473
+
460
474
  #### IconButton
461
475
 
462
476
  ##### Interface
package/dist/index.cjs.js CHANGED
@@ -487,6 +487,11 @@ var TextField = function (_a) {
487
487
  return (jsxRuntime.jsxs("div", { className: css('text-field-wrapper', styles$8, themeMode), style: { width: fullWidth ? '100%' : 'auto' }, children: [label && (jsxRuntime.jsx("label", { className: "".concat(css('text-field-label', styles$8, themeMode), " ").concat(error ? css('text-field-label-error', styles$8, null) : ''), children: jsxRuntime.jsxs(Typography, { children: [label, required && ' *'] }) })), jsxRuntime.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 && (jsxRuntime.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 }))] }));
488
488
  };
489
489
 
490
+ var Tooltip = function (_a) {
491
+ var title = _a.title, children = _a.children;
492
+ return jsxRuntime.jsx("div", { title: title, children: children });
493
+ };
494
+
490
495
  var Typography = function (_a) {
491
496
  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;
492
497
  var Tag = component;
@@ -525,6 +530,7 @@ var DefaultUiContext = {
525
530
  primaryColor: '#1976d2',
526
531
  primaryFgColor: '#fff',
527
532
  Typography: Typography,
533
+ Tooltip: Tooltip,
528
534
  IconButton: IconButton,
529
535
  Modal: Modal,
530
536
  DeleteIcon: DeleteIcon,
@@ -546,6 +552,7 @@ var DefaultUiContext = {
546
552
  cannotDrawMorePolygons: 'You cannot draw more polygons',
547
553
  cannotDrawMorePolylines: 'You cannot draw more polylines',
548
554
  cannotDrawMoreRectangles: 'You cannot draw more rectangles',
555
+ fullImage: 'Full image',
549
556
  id: 'ID',
550
557
  invalidSubmission: 'Invalid submission',
551
558
  mainParametersMetadata: 'Main parameters',
@@ -561,10 +568,10 @@ var DefaultUiContext = {
561
568
  polylineHelpText: 'click to draw all the polyline points, double click on the last point to stop drawing',
562
569
  presetDescription: 'Preset description',
563
570
  presetName: 'Image preset',
564
- rect: 'Rectangle',
565
- rectHelpText: 'click and drag to draw the rectangle',
566
571
  pointer: 'Selection',
567
572
  pointerHelpText: 'click a shape to select it',
573
+ rect: 'Rectangle',
574
+ rectHelpText: 'click and drag to draw the rectangle',
568
575
  requiredField: 'This field is required',
569
576
  roiMultiplicityEqRule: 'a number of "{role}" ({type}) equal to {threshold}',
570
577
  roiMultiplicityGtRule: 'a number of "{role}" ({type}) greater than {threshold}',
@@ -575,6 +582,7 @@ var DefaultUiContext = {
575
582
  roisToBeDrawn: 'ROIs to be drawn',
576
583
  role: 'Role',
577
584
  save: 'Save',
585
+ selection: 'Selection',
578
586
  shapeParametersMetadata: 'Shape parameters',
579
587
  shapesOfRoleShouldBeEqualToThreshold: 'Shapes of role {role} should be equal to {threshold}',
580
588
  shapesOfRoleShouldBeGreaterThanThreshold: 'Shapes of role {role} should be greater than {threshold}',
@@ -586,10 +594,11 @@ var DefaultUiContext = {
586
594
  };
587
595
  var UiContext = React.createContext(DefaultUiContext); // eslint-disable-line
588
596
  var UiProvider = function (_a) {
589
- 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;
597
+ 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;
590
598
  var ctx = {
591
599
  enableLogs: enableLogs !== null && enableLogs !== void 0 ? enableLogs : DefaultUiContext.enableLogs,
592
600
  Typography: Typography !== null && Typography !== void 0 ? Typography : DefaultUiContext.Typography,
601
+ Tooltip: Tooltip !== null && Tooltip !== void 0 ? Tooltip : DefaultUiContext.Tooltip,
593
602
  Modal: Modal !== null && Modal !== void 0 ? Modal : DefaultUiContext.Modal,
594
603
  IconButton: IconButton !== null && IconButton !== void 0 ? IconButton : DefaultUiContext.IconButton,
595
604
  DeleteIcon: DeleteIcon !== null && DeleteIcon !== void 0 ? DeleteIcon : DefaultUiContext.DeleteIcon,
@@ -1702,7 +1711,7 @@ var styles$1 = {"toolbar":"Toolbar-module_toolbar__ywNcv","toolbar-light":"Toolb
1702
1711
  var Toolbar = function (_a) {
1703
1712
  var _b;
1704
1713
  var canvasRef = _a.canvasRef, imageSize = _a.imageSize;
1705
- var _c = React.useContext(UiContext), IconButton = _c.IconButton, themeMode = _c.themeMode, primaryColor = _c.primaryColor, Typography = _c.Typography, strings = _c.strings;
1714
+ var _c = React.useContext(UiContext), IconButton = _c.IconButton, themeMode = _c.themeMode, primaryColor = _c.primaryColor, Typography = _c.Typography, strings = _c.strings, Tooltip = _c.Tooltip;
1706
1715
  var _d = useEditorContext(), activeTool = _d.activeTool, setActiveTool = _d.setActiveTool, configuration = _d.configuration, shapes = _d.shapes, editorId = _d.editorId, activeColor = _d.activeColor;
1707
1716
  var iconColor = function (tool) { return (tool === activeTool ? primaryColor : themeMode === 'light' ? 'black' : 'white'); };
1708
1717
  var setTool = function (tool) { return function () { return setActiveTool(tool); }; };
@@ -1716,7 +1725,7 @@ var Toolbar = function (_a) {
1716
1725
  var handleRenderFullImagePolygon = function () {
1717
1726
  renderFullImagePolygon(editorId, canvasRef.current, activeColor, imageSize);
1718
1727
  };
1719
- return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("div", { className: css('toolbar', styles$1, themeMode), children: enableRois(configuration) && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(IconButton, { onClick: setTool("pointer" /* ToolEnum.Pointer */), children: jsxRuntime.jsx(PointerIcon, { color: iconColor("pointer" /* ToolEnum.Pointer */) }) }), (!hideForbiddenTools || pointEnabled) && (jsxRuntime.jsx(IconButton, { onClick: setTool("point" /* ToolEnum.Point */), disabled: !pointEnabled, children: jsxRuntime.jsx(PointIcon, { color: iconColor("point" /* ToolEnum.Point */) }) })), (!hideForbiddenTools || polylineEnabled) && (jsxRuntime.jsx(IconButton, { onClick: setTool("polyline" /* ToolEnum.Polyline */), disabled: !polylineEnabled, children: jsxRuntime.jsx(PolylineIcon, { color: iconColor("polyline" /* ToolEnum.Polyline */) }) })), (!hideForbiddenTools || polygonEnabled) && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(IconButton, { onClick: setTool("polygon" /* ToolEnum.Polygon */), disabled: !polygonEnabled, children: jsxRuntime.jsx(PolygonIcon, { color: iconColor("polygon" /* ToolEnum.Polygon */) }) }), jsxRuntime.jsx(IconButton, { onClick: handleRenderFullImagePolygon, disabled: !polygonEnabled, children: jsxRuntime.jsx(FullRoiIcon, { color: iconColor("polygon" /* ToolEnum.Polygon */) }) })] })), (!hideForbiddenTools || rectangleEnabled) && (jsxRuntime.jsx(IconButton, { onClick: setTool("rect" /* ToolEnum.Rectangle */), disabled: !rectangleEnabled, children: jsxRuntime.jsx(RectangleIcon, { color: iconColor("rect" /* ToolEnum.Rectangle */) }) })), jsxRuntime.jsx(ColorPicker, { style: { marginLeft: 'auto', marginRight: '.5rem' } })] })) }), enableRois(configuration) && (jsxRuntime.jsx("div", { className: css('toolbar-helper', styles$1, themeMode), children: jsxRuntime.jsxs(Typography, { children: [strings[activeTool], ": ", strings["".concat(activeTool, "HelpText")]] }) }))] }));
1728
+ return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("div", { className: css('toolbar', styles$1, themeMode), children: enableRois(configuration) && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Tooltip, { title: strings.selection, children: jsxRuntime.jsx(IconButton, { onClick: setTool("pointer" /* ToolEnum.Pointer */), children: jsxRuntime.jsx(PointerIcon, { color: iconColor("pointer" /* ToolEnum.Pointer */) }) }) }), (!hideForbiddenTools || pointEnabled) && (jsxRuntime.jsx(Tooltip, { title: strings.point, children: jsxRuntime.jsx(IconButton, { onClick: setTool("point" /* ToolEnum.Point */), disabled: !pointEnabled, children: jsxRuntime.jsx(PointIcon, { color: iconColor("point" /* ToolEnum.Point */) }) }) })), (!hideForbiddenTools || polylineEnabled) && (jsxRuntime.jsx(Tooltip, { title: strings.polyline, children: jsxRuntime.jsx(IconButton, { onClick: setTool("polyline" /* ToolEnum.Polyline */), disabled: !polylineEnabled, children: jsxRuntime.jsx(PolylineIcon, { color: iconColor("polyline" /* ToolEnum.Polyline */) }) }) })), (!hideForbiddenTools || polygonEnabled) && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Tooltip, { title: strings.polygon, children: jsxRuntime.jsx(IconButton, { onClick: setTool("polygon" /* ToolEnum.Polygon */), disabled: !polygonEnabled, children: jsxRuntime.jsx(PolygonIcon, { color: iconColor("polygon" /* ToolEnum.Polygon */) }) }) }), jsxRuntime.jsx(Tooltip, { title: strings.fullImage, children: jsxRuntime.jsx(IconButton, { onClick: handleRenderFullImagePolygon, disabled: !polygonEnabled, children: jsxRuntime.jsx(FullRoiIcon, { color: iconColor("polygon" /* ToolEnum.Polygon */) }) }) })] })), (!hideForbiddenTools || rectangleEnabled) && (jsxRuntime.jsx(Tooltip, { title: strings.rect, children: jsxRuntime.jsx(IconButton, { onClick: setTool("rect" /* ToolEnum.Rectangle */), disabled: !rectangleEnabled, children: jsxRuntime.jsx(RectangleIcon, { color: iconColor("rect" /* ToolEnum.Rectangle */) }) }) })), jsxRuntime.jsx(ColorPicker, { style: { marginLeft: 'auto', marginRight: '.5rem' } })] })) }), enableRois(configuration) && (jsxRuntime.jsx("div", { className: css('toolbar-helper', styles$1, themeMode), children: jsxRuntime.jsxs(Typography, { children: [strings[activeTool], ": ", strings["".concat(activeTool, "HelpText")]] }) }))] }));
1720
1729
  };
1721
1730
 
1722
1731
  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--"};