cloudmr-ux 4.4.5 → 4.4.6

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.
@@ -1,2 +1,8 @@
1
- export default DrawColorPlatte;
2
- declare function DrawColorPlatte(_a: any): import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
1
+ export default function DrawColorPlatte({ expanded, updateDrawPen, setDrawingEnabled, shapeDraftActive, onApplyShapeDraft, onCancelShapeDraft, }: {
2
+ expanded: any;
3
+ updateDrawPen: any;
4
+ setDrawingEnabled: any;
5
+ shapeDraftActive?: boolean | undefined;
6
+ onApplyShapeDraft: any;
7
+ onCancelShapeDraft: any;
8
+ }): import("react/jsx-runtime").JSX.Element;
@@ -1,35 +1,34 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
13
  /**
2
14
  * Shared ROI label color row (NiiVue pen indices 1–6). Used by pen, rectangle, and ellipse tools.
15
+ * Rectangle/ellipse palettes may also show Apply/Cancel while a shape draft is being adjusted.
3
16
  */
4
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
5
- import { Stack, IconButton } from "@mui/material";
17
+ import { Stack, IconButton, Tooltip, Typography } from "@mui/material";
6
18
  import FiberManualRecordIcon from "@mui/icons-material/FiberManualRecord";
7
- var __assign = function () {
8
- __assign =
9
- Object.assign ||
10
- function (t) {
11
- for (var s, i = 1, n = arguments.length; i < n; i++) {
12
- s = arguments[i];
13
- for (var p in s)
14
- if (Object.prototype.hasOwnProperty.call(s, p))
15
- t[p] = s[p];
16
- }
17
- return t;
18
- };
19
- return __assign.apply(this, arguments);
20
- };
21
- var DrawColorPlatte = function (_a) {
22
- var expanded = _a.expanded, updateDrawPen = _a.updateDrawPen, setDrawingEnabled = _a.setDrawingEnabled;
23
- var filledOptions = [
24
- _jsx(FiberManualRecordIcon, { sx: { color: "red" } }, "f0"),
25
- _jsx(FiberManualRecordIcon, { sx: { color: "green" } }, "f1"),
26
- _jsx(FiberManualRecordIcon, { sx: { color: "blue" } }, "f2"),
27
- _jsx(FiberManualRecordIcon, { sx: { color: "yellow" } }, "f3"),
28
- _jsx(FiberManualRecordIcon, { sx: { color: "cyan" } }, "f4"),
29
- _jsx(FiberManualRecordIcon, { sx: { color: "#e81ce8" } }, "f5"),
30
- ];
31
- return _jsxs(Stack, __assign({
32
- style: {
19
+ import CheckIcon from "@mui/icons-material/Check";
20
+ import CloseIcon from "@mui/icons-material/Close";
21
+ var FILLED_COLORS = [
22
+ { sx: { color: "red" } },
23
+ { sx: { color: "green" } },
24
+ { sx: { color: "blue" } },
25
+ { sx: { color: "yellow" } },
26
+ { sx: { color: "cyan" } },
27
+ { sx: { color: "#e81ce8" } },
28
+ ];
29
+ export default function DrawColorPlatte(_a) {
30
+ var expanded = _a.expanded, updateDrawPen = _a.updateDrawPen, setDrawingEnabled = _a.setDrawingEnabled, _b = _a.shapeDraftActive, shapeDraftActive = _b === void 0 ? false : _b, onApplyShapeDraft = _a.onApplyShapeDraft, onCancelShapeDraft = _a.onCancelShapeDraft;
31
+ return (_jsxs(Stack, __assign({ style: {
33
32
  position: "absolute",
34
33
  top: "100%",
35
34
  left: 0,
@@ -41,21 +40,8 @@ var DrawColorPlatte = function (_a) {
41
40
  borderTopLeftRadius: "6pt",
42
41
  borderTopRightRadius: "6pt",
43
42
  background: "#333"
44
- },
45
- direction: "column"
46
- }, {
47
- children: [
48
- _jsx(Stack, __assign({ direction: "row" }, {
49
- children: filledOptions.map(function (value, index) {
50
- return _jsx(IconButton, __assign({
51
- onClick: function () {
52
- updateDrawPen({ target: { value: index + 1 } });
53
- setDrawingEnabled(true);
54
- }
55
- }, { children: value }), index);
56
- })
57
- })),
58
- ]
59
- }));
60
- };
61
- export default DrawColorPlatte;
43
+ }, direction: "column", spacing: 0.5, sx: { py: shapeDraftActive && expanded ? 0.5 : 0 } }, { children: [_jsx(Stack, __assign({ direction: "row" }, { children: FILLED_COLORS.map(function (color, index) { return (_jsx(IconButton, __assign({ onClick: function () {
44
+ updateDrawPen({ target: { value: index + 1 } });
45
+ setDrawingEnabled(true);
46
+ } }, { children: _jsx(FiberManualRecordIcon, { sx: color.sx }) }), index)); }) })), shapeDraftActive && expanded && (_jsxs(Stack, __assign({ direction: "row", alignItems: "center", spacing: 0.5, sx: { px: 0.5, pb: 0.5, borderTop: "1px solid #555" } }, { children: [_jsx(Tooltip, __assign({ title: "Apply shape (Enter)" }, { children: _jsx(IconButton, __assign({ "aria-label": "apply shape", size: "small", onClick: function () { return onApplyShapeDraft === null || onApplyShapeDraft === void 0 ? void 0 : onApplyShapeDraft(); }, sx: { color: "#c9a0e8" } }, { children: _jsx(CheckIcon, { fontSize: "small" }) })) })), _jsx(Tooltip, __assign({ title: "Cancel shape (Esc)" }, { children: _jsx(IconButton, __assign({ "aria-label": "cancel shape", size: "small", onClick: function () { return onCancelShapeDraft === null || onCancelShapeDraft === void 0 ? void 0 : onCancelShapeDraft(); }, sx: { color: "#ccc" } }, { children: _jsx(CloseIcon, { fontSize: "small" }) })) })), _jsx(Typography, __assign({ component: "span", sx: { fontSize: "0.68rem", color: "#bbb", userSelect: "none" } }, { children: "Apply or cancel" }))] })))] })));
47
+ }
@@ -9,7 +9,7 @@ var __assign = (this && this.__assign) || function () {
9
9
  };
10
10
  return __assign.apply(this, arguments);
11
11
  };
12
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
12
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
13
  /**
14
14
  * MROptimum fork of cloudmr-ux DrawToolkit.
15
15
  * Click-away exits drawing mode when you focus elsewhere (slice controls, histogram, etc.),
@@ -17,7 +17,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
17
17
  *
18
18
  * Layout matches {@link NiivueSlicePosition}: outer wrapper → `.title` → `Card` + `CardContent` (no custom fill).
19
19
  */
20
- import React, { useState } from "react";
20
+ import React, { useState, useEffect } from "react";
21
21
  import { Box, Card, CardContent, IconButton, Slider, Stack, Tooltip, Typography, } from "@mui/material";
22
22
  import DrawIcon from "@mui/icons-material/Draw";
23
23
  import CropSquareOutlinedIcon from "@mui/icons-material/CropSquareOutlined";
@@ -31,8 +31,6 @@ import DeleteIcon from "@mui/icons-material/Delete";
31
31
  import VisibilityIcon from "@mui/icons-material/Visibility";
32
32
  import VisibilityOffIcon from "@mui/icons-material/VisibilityOff";
33
33
  import OpacityIcon from "@mui/icons-material/Opacity";
34
- import CheckIcon from "@mui/icons-material/Check";
35
- import CloseIcon from "@mui/icons-material/Close";
36
34
  import ClickAwayListener from "@mui/material/ClickAwayListener";
37
35
  import DrawColorPlatte from "./DrawColorPlatte";
38
36
  import EraserPlatte from "./EraserPlatte";
@@ -72,6 +70,14 @@ export function MroDrawToolkit(props) {
72
70
  var _c = useState(false), expandOpacityOptions = _c[0], setExpandOpacityOptions = _c[1];
73
71
  var _d = useState(undefined), setMaskColor = _d[1];
74
72
  var filled = props.drawPen > 7;
73
+ useEffect(function () {
74
+ if (!props.shapeDraftActive)
75
+ return;
76
+ if (drawShapeTool === "rectangle")
77
+ setExpandedOption("r");
78
+ else if (drawShapeTool === "ellipse")
79
+ setExpandedOption("l");
80
+ }, [props.shapeDraftActive, drawShapeTool]);
75
81
  var shapeSelectedSx = function (shape) {
76
82
  return drawShapeTool === shape
77
83
  ? { backgroundColor: "rgba(88, 15, 139, 0.12)", color: "#580f8b" }
@@ -164,7 +170,7 @@ export function MroDrawToolkit(props) {
164
170
  alignItems: "center",
165
171
  gap: 4,
166
172
  overflow: "visible"
167
- } }, { children: [_jsxs(Box, __assign({ sx: { position: "relative", zIndex: expandedOption === "d" ? 1600 : "auto", display: "inline-flex", alignItems: "center" } }, { children: [_jsx(Tooltip, __assign({ title: "Pen" }, { children: _jsx(IconButton, __assign({ "aria-label": "pen", size: "small", onClick: clickPen, sx: __assign(__assign({}, toolBtnSx), shapeSelectedSx("pen")) }, { children: _jsx(DrawIcon, { sx: { color: "inherit" } }) })) })), _jsx(DrawColorPlatte, { expanded: expandedOption === "d", updateDrawPen: props.updateDrawPen, setDrawingEnabled: props.setDrawingEnabled })] })), _jsxs(Box, __assign({ sx: { position: "relative", zIndex: expandedOption === "r" ? 1600 : "auto", display: "inline-flex", alignItems: "center" } }, { children: [_jsx(Tooltip, __assign({ title: "Rectangle" }, { children: _jsx(IconButton, __assign({ "aria-label": "rectangle", size: "small", onClick: clickRectangle, sx: __assign(__assign({}, toolBtnSx), shapeSelectedSx("rectangle")) }, { children: _jsx(CropSquareOutlinedIcon, { sx: { color: "inherit" } }) })) })), _jsx(DrawColorPlatte, { expanded: expandedOption === "r", updateDrawPen: props.updateDrawPen, setDrawingEnabled: props.setDrawingEnabled })] })), _jsxs(Box, __assign({ sx: { position: "relative", zIndex: expandedOption === "l" ? 1600 : "auto", display: "inline-flex", alignItems: "center" } }, { children: [_jsx(Tooltip, __assign({ title: "Ellipse" }, { children: _jsx(IconButton, __assign({ "aria-label": "ellipse", size: "small", onClick: clickEllipse, sx: __assign(__assign({}, toolBtnSx), shapeSelectedSx("ellipse")) }, { children: _jsx(CircleOutlinedIcon, { sx: { color: "inherit" } }) })) })), _jsx(DrawColorPlatte, { expanded: expandedOption === "l", updateDrawPen: props.updateDrawPen, setDrawingEnabled: props.setDrawingEnabled })] })), _jsxs(Box, __assign({ sx: { position: "relative", zIndex: expandedOption === "e" ? 1600 : "auto", display: "inline-flex", alignItems: "center" } }, { children: [_jsx(Tooltip, __assign({ title: "Eraser" }, { children: _jsx(IconButton, __assign({ "aria-label": "erase", size: "small", onClick: clickEraser, sx: toolBtnSx }, { children: filled || expandedOption !== "e" ? (_jsx(EraserIcon, {})) : (_jsx(AutoFixNormalOutlinedIcon, { sx: { color: ICON_COLOR } })) })) })), _jsx(EraserPlatte, { expandEraseOptions: expandedOption === "e", updateDrawPen: props.updateDrawPen, setDrawingEnabled: props.setDrawingEnabled })] })), _jsx(Tooltip, __assign({ title: "Undo" }, { children: _jsx(IconButton, __assign({ "aria-label": "revert", size: "small", onClick: function () { return props.drawUndo(); }, sx: toolBtnSx }, { children: _jsx(ReplyIcon, { sx: { color: ICON_COLOR } }) })) })), props.shapeDraftActive && (_jsxs(_Fragment, { children: [_jsx(Tooltip, __assign({ title: "Apply shape (Enter)" }, { children: _jsx(IconButton, __assign({ "aria-label": "apply shape", size: "small", onClick: function () { var _a; return (_a = props.onApplyShapeDraft) === null || _a === void 0 ? void 0 : _a.call(props); }, sx: __assign(__assign({}, toolBtnSx), { backgroundColor: "rgba(88, 15, 139, 0.12)", color: "#580f8b" }) }, { children: _jsx(CheckIcon, { sx: { color: "inherit" } }) })) })), _jsx(Tooltip, __assign({ title: "Cancel shape (Esc)" }, { children: _jsx(IconButton, __assign({ "aria-label": "cancel shape", size: "small", onClick: function () { var _a; return (_a = props.onCancelShapeDraft) === null || _a === void 0 ? void 0 : _a.call(props); }, sx: toolBtnSx }, { children: _jsx(CloseIcon, { sx: { color: ICON_COLOR } }) })) })), _jsx(Typography, __assign({ component: "span", sx: { fontSize: "0.72rem", color: "#580f8b", userSelect: "none", ml: 0.5 } }, { children: "Adjust shape, then Apply" }))] })), _jsx(Tooltip, __assign({ title: "Save screenshot" }, { children: _jsx("span", { children: _jsx(IconButton, __assign({ "aria-label": "capture", size: "small", disabled: !vol, onClick: function () { return vol && props.nv.saveScene("".concat(vol.name, "_drawing.png")); }, sx: toolBtnSx }, { children: _jsx(CameraAltIcon, { sx: { color: ICON_COLOR } }) })) }) })), _jsx(Tooltip, __assign({ title: "Clear drawing" }, { children: _jsx(IconButton, __assign({ "aria-label": "delete", size: "small", onClick: function () {
173
+ } }, { children: [_jsxs(Box, __assign({ sx: { position: "relative", zIndex: expandedOption === "d" ? 1600 : "auto", display: "inline-flex", alignItems: "center" } }, { children: [_jsx(Tooltip, __assign({ title: "Pen" }, { children: _jsx(IconButton, __assign({ "aria-label": "pen", size: "small", onClick: clickPen, sx: __assign(__assign({}, toolBtnSx), shapeSelectedSx("pen")) }, { children: _jsx(DrawIcon, { sx: { color: "inherit" } }) })) })), _jsx(DrawColorPlatte, { expanded: expandedOption === "d", updateDrawPen: props.updateDrawPen, setDrawingEnabled: props.setDrawingEnabled })] })), _jsxs(Box, __assign({ sx: { position: "relative", zIndex: expandedOption === "r" ? 1600 : "auto", display: "inline-flex", alignItems: "center" } }, { children: [_jsx(Tooltip, __assign({ title: "Rectangle" }, { children: _jsx(IconButton, __assign({ "aria-label": "rectangle", size: "small", onClick: clickRectangle, sx: __assign(__assign({}, toolBtnSx), shapeSelectedSx("rectangle")) }, { children: _jsx(CropSquareOutlinedIcon, { sx: { color: "inherit" } }) })) })), _jsx(DrawColorPlatte, { expanded: expandedOption === "r", updateDrawPen: props.updateDrawPen, setDrawingEnabled: props.setDrawingEnabled, shapeDraftActive: props.shapeDraftActive && drawShapeTool === "rectangle", onApplyShapeDraft: props.onApplyShapeDraft, onCancelShapeDraft: props.onCancelShapeDraft })] })), _jsxs(Box, __assign({ sx: { position: "relative", zIndex: expandedOption === "l" ? 1600 : "auto", display: "inline-flex", alignItems: "center" } }, { children: [_jsx(Tooltip, __assign({ title: "Ellipse" }, { children: _jsx(IconButton, __assign({ "aria-label": "ellipse", size: "small", onClick: clickEllipse, sx: __assign(__assign({}, toolBtnSx), shapeSelectedSx("ellipse")) }, { children: _jsx(CircleOutlinedIcon, { sx: { color: "inherit" } }) })) })), _jsx(DrawColorPlatte, { expanded: expandedOption === "l", updateDrawPen: props.updateDrawPen, setDrawingEnabled: props.setDrawingEnabled, shapeDraftActive: props.shapeDraftActive && drawShapeTool === "ellipse", onApplyShapeDraft: props.onApplyShapeDraft, onCancelShapeDraft: props.onCancelShapeDraft })] })), _jsxs(Box, __assign({ sx: { position: "relative", zIndex: expandedOption === "e" ? 1600 : "auto", display: "inline-flex", alignItems: "center" } }, { children: [_jsx(Tooltip, __assign({ title: "Eraser" }, { children: _jsx(IconButton, __assign({ "aria-label": "erase", size: "small", onClick: clickEraser, sx: toolBtnSx }, { children: filled || expandedOption !== "e" ? (_jsx(EraserIcon, {})) : (_jsx(AutoFixNormalOutlinedIcon, { sx: { color: ICON_COLOR } })) })) })), _jsx(EraserPlatte, { expandEraseOptions: expandedOption === "e", updateDrawPen: props.updateDrawPen, setDrawingEnabled: props.setDrawingEnabled })] })), _jsx(Tooltip, __assign({ title: "Undo" }, { children: _jsx(IconButton, __assign({ "aria-label": "revert", size: "small", onClick: function () { return props.drawUndo(); }, sx: toolBtnSx }, { children: _jsx(ReplyIcon, { sx: { color: ICON_COLOR } }) })) })), _jsx(Tooltip, __assign({ title: "Save screenshot" }, { children: _jsx("span", { children: _jsx(IconButton, __assign({ "aria-label": "capture", size: "small", disabled: !vol, onClick: function () { return vol && props.nv.saveScene("".concat(vol.name, "_drawing.png")); }, sx: toolBtnSx }, { children: _jsx(CameraAltIcon, { sx: { color: ICON_COLOR } }) })) }) })), _jsx(Tooltip, __assign({ title: "Clear drawing" }, { children: _jsx(IconButton, __assign({ "aria-label": "delete", size: "small", onClick: function () {
168
174
  props.nv.clearDrawing();
169
175
  props.resampleImage();
170
176
  props.setDrawingChanged(false);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cloudmr-ux",
3
- "version": "4.4.5",
3
+ "version": "4.4.6",
4
4
  "author": "erosmontin@gmail.com",
5
5
  "license": "MIT",
6
6
  "repository": "erosmontin/cloudmr-ux",