@abidibo/react-cam-roi 0.13.0 → 0.13.1

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/dist/index.esm.js CHANGED
@@ -113,7 +113,17 @@ var formatString = function (str, placeholders) {
113
113
  return str;
114
114
  };
115
115
  var abs2Perc = function (value, ref) { return Math.round((value / ref) * 100 * 100) / 100; };
116
- var perc2Abs = function (value, ref) { return Math.round(ref * value * 100 / 100) / 100; };
116
+ var perc2Abs = function (value, ref) { return Math.round((ref * value * 100) / 100) / 100; };
117
+ var defaultTo = function (dft) { return function (value) { return value !== null && value !== void 0 ? value : dft; }; };
118
+ var compose = function () {
119
+ var fns = [];
120
+ for (var _i = 0; _i < arguments.length; _i++) {
121
+ fns[_i] = arguments[_i];
122
+ }
123
+ return function (x) {
124
+ return fns.reduceRight(function (y, f) { return f(y); }, x);
125
+ };
126
+ };
117
127
 
118
128
  var styles$e = {"bool-field":"BoolField-module_bool-field__-Qg7I","bool-field-light":"BoolField-module_bool-field-light__CHITs","bool-field-dark":"BoolField-module_bool-field-dark__gy9uQ","bool-field-error":"BoolField-module_bool-field-error__qJV-E","bool-field-label":"BoolField-module_bool-field-label__LZbjy","bool-field-label-error":"BoolField-module_bool-field-label-error__gBzdk","bool-field-helper-text":"BoolField-module_bool-field-helper-text__fH8fC","bool-field-helper-text-error":"BoolField-module_bool-field-helper-text-error__McdWn"};
119
129
 
@@ -569,6 +579,7 @@ var DefaultUiContext = {
569
579
  pointer: 'Selection',
570
580
  pointerHelpText: 'click a shape to select it',
571
581
  rect: 'Rectangle',
582
+ rectangle: 'Rectangle',
572
583
  rectHelpText: 'click and drag to draw the rectangle',
573
584
  requiredField: 'This field is required',
574
585
  roiMultiplicityEqRule: 'a number of "{role}" ({type}) equal to {threshold}',
@@ -1459,7 +1470,7 @@ var RoisInfo = function () {
1459
1470
  var _d = useEditorContext(), configuration = _d.configuration, presetName = _d.presetName, setPresetName = _d.setPresetName, presetDescription = _d.presetDescription, setPresetDescription = _d.setPresetDescription;
1460
1471
  if (!((_a = configuration.rois) === null || _a === void 0 ? void 0 : _a.length))
1461
1472
  return null;
1462
- return (jsxs("div", { children: [jsx("div", { style: { marginBottom: '1rem' }, children: jsx(TextField, { required: true, value: presetName, onChange: setPresetName, label: strings.presetName, fullWidth: true }) }), jsx("div", { style: { marginBottom: '1rem' }, children: jsx(TextField, { value: presetDescription, onChange: setPresetDescription, label: strings.presetDescription, fullWidth: true }) }), ((_b = configuration.options) === null || _b === void 0 ? void 0 : _b.description) && jsx(Typography, { children: configuration.options.description }), jsxs(Typography, { component: "div", children: [strings.roisToBeDrawn, ":"] }), jsx("ul", { children: configuration.rois.map(function (r) {
1473
+ return (jsxs("div", { children: [jsx("div", { style: { marginBottom: '1rem' }, children: jsx(TextField, { required: true, value: presetName, onChange: compose(setPresetName, defaultTo('')), label: strings.presetName, fullWidth: true }) }), jsx("div", { style: { marginBottom: '1rem' }, children: jsx(TextField, { value: presetDescription, onChange: compose(setPresetDescription, defaultTo('')), label: strings.presetDescription, fullWidth: true }) }), ((_b = configuration.options) === null || _b === void 0 ? void 0 : _b.description) && jsx(Typography, { children: configuration.options.description }), jsxs(Typography, { component: "div", children: [strings.roisToBeDrawn, ":"] }), jsx("ul", { children: configuration.rois.map(function (r) {
1463
1474
  var _a, _b;
1464
1475
  var rule;
1465
1476
  var data = {
@@ -1577,7 +1588,7 @@ var ParametersModalForm = function (_a) {
1577
1588
  }
1578
1589
  }
1579
1590
  };
1580
- var form = (jsxs("div", { className: css('form', styles$4, null), children: [shapeType && (jsxs(Fragment, { children: [jsx(TextField, { required: true, label: strings.name, type: "text", value: name, onChange: setName, error: !!errors.name, helperText: errors.name, readOnly: readOnly }), jsx(RoleField, { required: true, value: role, onChange: setRole, error: !!errors.role, helperText: errors.role, shapeType: shapeType, readOnly: readOnly, disabled: readOnly })] })), parameters.map(function (parameter) {
1591
+ var form = (jsxs("div", { className: css('form', styles$4, null), children: [shapeType && (jsxs(Fragment, { children: [jsx(TextField, { required: true, label: strings.name, type: "text", value: name, onChange: compose(setName, defaultTo('')), error: !!errors.name, helperText: errors.name, readOnly: readOnly }), jsx(RoleField, { required: true, value: role, onChange: compose(setRole, defaultTo('')), error: !!errors.role, helperText: errors.role, shapeType: shapeType, readOnly: readOnly, disabled: readOnly })] })), parameters.map(function (parameter) {
1581
1592
  switch (parameter.type) {
1582
1593
  case 'string':
1583
1594
  return (jsx(ParameterField, { value: String((readOnly ? readonlyFields : fields)[parameter.codename]), onChange: setField(parameter.codename), parameter: parameter, errors: errors, readOnly: readOnly }, parameter.codename));
@@ -1721,6 +1732,8 @@ var Toolbar = function (_a) {
1721
1732
  var rectangleEnabled = configuration.rois.find(function (r) { return r.type === "rect" /* ToolEnum.Rectangle */; }) &&
1722
1733
  canDrawShape(configuration, "rect" /* ToolEnum.Rectangle */, shapes);
1723
1734
  var handleRenderFullImagePolygon = function () {
1735
+ if (!canvasRef.current)
1736
+ return;
1724
1737
  renderFullImagePolygon(editorId, canvasRef.current, activeColor, imageSize);
1725
1738
  };
1726
1739
  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")]] }) }))] }));