cloudmr-ux 4.7.5 → 4.7.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.
@@ -195,7 +195,7 @@ export function CloudMrNiivuePanel(props) {
195
195
  left: 0,
196
196
  width: "100%",
197
197
  height: "100%"
198
- } }), props.shapeDraft && (_jsx(ShapeDraftOverlay, { nv: props.nv, draft: props.shapeDraft, onDraftChange: props.onShapeDraftChange, overlayKey: props.mms })), props.penDraft && (_jsx(PenDraftOverlay, { nv: props.nv, draft: props.penDraft, onDraftChange: props.onPenDraftChange, overlayKey: props.mms }))] }))] })), _jsxs(Box, __assign({ sx: {
198
+ } }), props.shapeDraft && (_jsx(ShapeDraftOverlay, { nv: props.nv, draft: props.shapeDraft, onDraftChange: props.onShapeDraftChange, onApplyDraft: props.onApplyShapeDraft, overlayKey: props.mms })), props.penDraft && (_jsx(PenDraftOverlay, { nv: props.nv, draft: props.penDraft, onDraftChange: props.onPenDraftChange, onApplyDraft: props.onApplyPenDraft, overlayKey: props.mms }))] }))] })), _jsxs(Box, __assign({ sx: {
199
199
  width: {
200
200
  xs: "100%",
201
201
  md: "35%"
@@ -1,10 +1,12 @@
1
1
  /**
2
2
  * Adjust handles for polyline (vertex drag) or freehand (move only) drafts.
3
+ * @param {{ nv: any, draft: import('./penDraftUtils').PenDraft, onDraftChange: (d: any) => void, onApplyDraft?: () => void, overlayKey?: unknown }} props
3
4
  */
4
- export function PenDraftOverlay({ nv, draft, onDraftChange, overlayKey }: {
5
+ export function PenDraftOverlay({ nv, draft, onDraftChange, onApplyDraft, overlayKey }: {
5
6
  nv: any;
6
- draft: any;
7
- onDraftChange: any;
8
- overlayKey: any;
7
+ draft: import('./penDraftUtils').PenDraft;
8
+ onDraftChange: (d: any) => void;
9
+ onApplyDraft?: (() => void) | undefined;
10
+ overlayKey?: unknown;
9
11
  }): import("react/jsx-runtime").JSX.Element | null;
10
12
  export default PenDraftOverlay;
@@ -29,14 +29,17 @@ function cloneFreehandDraft(draft) {
29
29
  }
30
30
  /**
31
31
  * Adjust handles for polyline (vertex drag) or freehand (move only) drafts.
32
+ * @param {{ nv: any, draft: import('./penDraftUtils').PenDraft, onDraftChange: (d: any) => void, onApplyDraft?: () => void, overlayKey?: unknown }} props
32
33
  */
33
34
  export function PenDraftOverlay(_a) {
34
- var nv = _a.nv, draft = _a.draft, onDraftChange = _a.onDraftChange, overlayKey = _a.overlayKey;
35
+ var nv = _a.nv, draft = _a.draft, onDraftChange = _a.onDraftChange, onApplyDraft = _a.onApplyDraft, overlayKey = _a.overlayKey;
35
36
  var dragRef = useRef(null);
36
37
  var draftRef = useRef(draft);
37
38
  draftRef.current = draft;
38
39
  var onPointerMoveRef = useRef(null);
39
40
  var finishDragRef = useRef(null);
41
+ var onApplyDraftRef = useRef(onApplyDraft);
42
+ onApplyDraftRef.current = onApplyDraft;
40
43
  var _b = useState(0), setTick = _b[1];
41
44
  var bump = useCallback(function () { return setTick(function (t) { return t + 1; }); }, []);
42
45
  useEffect(function () {
@@ -109,6 +112,8 @@ export function PenDraftOverlay(_a) {
109
112
  onDraftChange(nextDraft);
110
113
  }, [nv, onDraftChange]);
111
114
  finishDragRef.current = function () {
115
+ var _a, _b;
116
+ var hadDrag = (_a = dragRef.current) === null || _a === void 0 ? void 0 : _a.didMove;
112
117
  dragRef.current = null;
113
118
  if (onPointerMoveRef.current) {
114
119
  window.removeEventListener("pointermove", onPointerMoveRef.current);
@@ -116,11 +121,15 @@ export function PenDraftOverlay(_a) {
116
121
  if (finishDragRef.current) {
117
122
  window.removeEventListener("pointerup", finishDragRef.current);
118
123
  }
124
+ if (hadDrag) {
125
+ (_b = onApplyDraftRef.current) === null || _b === void 0 ? void 0 : _b.call(onApplyDraftRef);
126
+ }
119
127
  };
120
128
  onPointerMoveRef.current = function (event) {
121
129
  var drag = dragRef.current;
122
130
  if (!drag)
123
131
  return;
132
+ drag.didMove = true;
124
133
  event.preventDefault();
125
134
  var canvas = nv.canvas || document.getElementById("niiCanvas");
126
135
  if (!canvas)
@@ -154,6 +163,7 @@ export function PenDraftOverlay(_a) {
154
163
  mode: mode,
155
164
  cornerIndex: cornerIndex,
156
165
  kind: current.kind,
166
+ didMove: false,
157
167
  startClientX: event.clientX,
158
168
  startClientY: event.clientY,
159
169
  startDraft: current,
@@ -1,11 +1,12 @@
1
1
  /**
2
2
  * Overlay handles for adjusting a rectangle/ellipse draft before commit.
3
- * @param {{ nv: any, draft: import('./shapeDraftUtils').ShapeDraft, onDraftChange: (d: any) => void, overlayKey?: unknown }} props
3
+ * @param {{ nv: any, draft: import('./shapeDraftUtils').ShapeDraft, onDraftChange: (d: any) => void, onApplyDraft?: () => void, overlayKey?: unknown }} props
4
4
  */
5
- export function ShapeDraftOverlay({ nv, draft, onDraftChange, overlayKey }: {
5
+ export function ShapeDraftOverlay({ nv, draft, onDraftChange, onApplyDraft, overlayKey }: {
6
6
  nv: any;
7
7
  draft: import('./shapeDraftUtils').ShapeDraft;
8
8
  onDraftChange: (d: any) => void;
9
+ onApplyDraft?: (() => void) | undefined;
9
10
  overlayKey?: unknown;
10
11
  }): import("react/jsx-runtime").JSX.Element | null;
11
12
  export default ShapeDraftOverlay;
@@ -25,16 +25,18 @@ var HANDLE_SIZE = 10;
25
25
  var ACCENT = "#580f8b";
26
26
  /**
27
27
  * Overlay handles for adjusting a rectangle/ellipse draft before commit.
28
- * @param {{ nv: any, draft: import('./shapeDraftUtils').ShapeDraft, onDraftChange: (d: any) => void, overlayKey?: unknown }} props
28
+ * @param {{ nv: any, draft: import('./shapeDraftUtils').ShapeDraft, onDraftChange: (d: any) => void, onApplyDraft?: () => void, overlayKey?: unknown }} props
29
29
  */
30
30
  export function ShapeDraftOverlay(_a) {
31
31
  var _b;
32
- var nv = _a.nv, draft = _a.draft, onDraftChange = _a.onDraftChange, overlayKey = _a.overlayKey;
32
+ var nv = _a.nv, draft = _a.draft, onDraftChange = _a.onDraftChange, onApplyDraft = _a.onApplyDraft, overlayKey = _a.overlayKey;
33
33
  var dragRef = useRef(null);
34
34
  var draftRef = useRef(draft);
35
35
  draftRef.current = draft;
36
36
  var onPointerMoveRef = useRef(null);
37
37
  var finishDragRef = useRef(null);
38
+ var onApplyDraftRef = useRef(onApplyDraft);
39
+ onApplyDraftRef.current = onApplyDraft;
38
40
  var _c = useState(0), setTick = _c[1];
39
41
  var bump = useCallback(function () { return setTick(function (t) { return t + 1; }); }, []);
40
42
  useEffect(function () {
@@ -84,6 +86,8 @@ export function ShapeDraftOverlay(_a) {
84
86
  onDraftChange(nextDraft);
85
87
  }, [nv, onDraftChange]);
86
88
  finishDragRef.current = function () {
89
+ var _a, _b;
90
+ var hadDrag = (_a = dragRef.current) === null || _a === void 0 ? void 0 : _a.didMove;
87
91
  dragRef.current = null;
88
92
  if (onPointerMoveRef.current) {
89
93
  window.removeEventListener("pointermove", onPointerMoveRef.current);
@@ -91,12 +95,16 @@ export function ShapeDraftOverlay(_a) {
91
95
  if (finishDragRef.current) {
92
96
  window.removeEventListener("pointerup", finishDragRef.current);
93
97
  }
98
+ if (hadDrag) {
99
+ (_b = onApplyDraftRef.current) === null || _b === void 0 ? void 0 : _b.call(onApplyDraftRef);
100
+ }
94
101
  };
95
102
  onPointerMoveRef.current = function (event) {
96
103
  var drag = dragRef.current;
97
104
  var currentDraft = draftRef.current;
98
105
  if (!drag || !currentDraft)
99
106
  return;
107
+ drag.didMove = true;
100
108
  event.preventDefault();
101
109
  if (drag.mode === "move") {
102
110
  var canvas = nv.canvas || document.getElementById("niiCanvas");
@@ -124,6 +132,7 @@ export function ShapeDraftOverlay(_a) {
124
132
  dragRef.current = {
125
133
  mode: mode,
126
134
  cornerIndex: cornerIndex,
135
+ didMove: false,
127
136
  startClientX: event.clientX,
128
137
  startClientY: event.clientY,
129
138
  startPtA: __spreadArray([], draft.ptA, true),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cloudmr-ux",
3
- "version": "4.7.5",
3
+ "version": "4.7.6",
4
4
  "author": "erosmontin@gmail.com",
5
5
  "license": "MIT",
6
6
  "repository": "erosmontin/cloudmr-ux",