@reekon-tools/boldr-utils 1.6.13 → 1.6.14

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.
Files changed (29) hide show
  1. package/dist/annotation/canvas/AnnotationCanvas.native.d.ts +2 -2
  2. package/dist/annotation/canvas/AnnotationCanvasInner.d.ts +1 -0
  3. package/dist/annotation/canvas/AnnotationCanvasInner.js +49 -11
  4. package/dist/annotation/canvas/AnnotationCanvasInner.native.d.ts +1 -0
  5. package/dist/annotation/canvas/AnnotationCanvasInner.native.js +368 -55
  6. package/dist/annotation/canvas/AnnotationCanvasSkia.d.ts +16 -1
  7. package/dist/annotation/canvas/AnnotationCanvasSkia.js +2 -2
  8. package/dist/annotation/canvas/Tool.d.ts +10 -0
  9. package/dist/annotation/canvas/elements/ShapeElement.js +41 -8
  10. package/dist/annotation/canvas/measurementGeometry.d.ts +1 -0
  11. package/dist/annotation/canvas/measurementGeometry.js +60 -2
  12. package/dist/annotation/canvas/shapeGeometry.d.ts +5 -0
  13. package/dist/annotation/canvas/shapeGeometry.js +116 -0
  14. package/dist/annotation/canvas/tools/panTool.d.ts +1 -0
  15. package/dist/annotation/canvas/tools/panTool.js +38 -5
  16. package/dist/annotation/canvas/tools/penTool.js +5 -1
  17. package/dist/annotation/canvas/tools/polygonTool.d.ts +11 -0
  18. package/dist/annotation/canvas/tools/polygonTool.js +162 -0
  19. package/dist/annotation/canvas/tools/selectTool.js +34 -73
  20. package/dist/annotation/canvas/tools/shapeTool.d.ts +25 -0
  21. package/dist/annotation/canvas/tools/shapeTool.js +111 -0
  22. package/dist/annotation/canvas/useAnnotationCanvasState.js +27 -3
  23. package/dist/annotation/data/hooks/useAnnotationCanvasDoc.js +83 -24
  24. package/dist/exports.d.ts +7 -4
  25. package/dist/exports.js +6 -3
  26. package/dist/formulas/calculateFormula.js +1 -3
  27. package/dist/types/annotation.d.ts +2 -0
  28. package/dist/types/firestore.d.ts +4 -0
  29. package/package.json +1 -1
@@ -1,6 +1,6 @@
1
1
  import type { AnnotationCanvasInnerProps } from './AnnotationCanvasInner.native.js';
2
- export type { AnnotationCanvasHandle, } from './useAnnotationCanvasState.js';
3
- export type { GestureConfig, PanTrigger, } from './AnnotationCanvasInner.js';
2
+ export type { AnnotationCanvasHandle } from './useAnnotationCanvasState.js';
3
+ export type { GestureConfig, PanTrigger } from './AnnotationCanvasInner.js';
4
4
  export type AnnotationCanvasProps = AnnotationCanvasInnerProps & {
5
5
  fallback?: unknown;
6
6
  canvasKitOpts?: unknown;
@@ -23,6 +23,7 @@ export interface AnnotationCanvasInnerProps {
23
23
  requestTextInput?: RequestTextInput;
24
24
  renderMeasurementStamp?: RenderMeasurementStamp;
25
25
  onMeasurementStampPress?: (placed: PlacedMeasurementRef) => void;
26
+ onMeasurementStampLongPress?: (placed: PlacedMeasurementRef) => void;
26
27
  stampFontSource?: unknown;
27
28
  stampValueFontSize?: number;
28
29
  stampLabelFontSize?: number;
@@ -171,7 +171,7 @@ export const AnnotationCanvasInner = (props) => {
171
171
  ...style,
172
172
  };
173
173
  const customPreview = activeTool?.renderPreview?.(state.customPreviewState, state.ctx);
174
- const { renderMeasurementStamp, onMeasurementStampPress, selection } = props;
174
+ const { renderMeasurementStamp, onMeasurementStampPress, onMeasurementStampLongPress, selection, } = props;
175
175
  return (_jsxs("div", { ref: containerRef, style: containerStyle, onPointerDown: handlePointerDown, onPointerMove: handlePointerMove, onPointerUp: handlePointerUp, onPointerCancel: handlePointerCancel, onWheel: handleWheel, onContextMenu: handleContextMenu, children: [AnnotationCanvasSkia({
176
176
  width,
177
177
  height,
@@ -183,8 +183,13 @@ export const AnnotationCanvasInner = (props) => {
183
183
  // Endpoint handles on the selected line annotation. Web drives endpoint
184
184
  // drag through selectTool's pointer handlers (preview patches update the
185
185
  // line, so the handles follow via re-render); no live geometry needed.
186
+ // Handles are drag affordances — suppressed unless the active tool can
187
+ // act on them (view mode's pan tool selects measurements but must not
188
+ // advertise draggability).
186
189
  selectedId: selection?.ids[0] ?? null,
187
- handleRadius: HANDLE_PX / state.viewport.zoom,
190
+ handleRadius: activeTool?.dragSelection
191
+ ? HANDLE_PX / state.viewport.zoom
192
+ : undefined,
188
193
  customPreview,
189
194
  }), renderMeasurementStamp && (_jsx("div", { style: {
190
195
  position: 'absolute',
@@ -211,15 +216,9 @@ export const AnnotationCanvasInner = (props) => {
211
216
  selected: isSelected,
212
217
  size,
213
218
  zoom: state.viewport.zoom,
214
- }), onMeasurementStampPress && (_jsx("button", { "aria-label": "Open measurement", onPointerDown: (e) => e.stopPropagation(), onClick: () => onMeasurementStampPress(placed), style: {
215
- position: 'absolute',
216
- inset: 0,
217
- pointerEvents: 'auto',
218
- cursor: 'pointer',
219
- background: 'transparent',
220
- border: 'none',
221
- padding: 0,
222
- } })), isSelected && measurement && (_jsx("div", { role: "button", "aria-label": "Remove measurement", onPointerDown: (e) => {
219
+ }), onMeasurementStampPress && (_jsx(StampPressTarget, { onPress: () => onMeasurementStampPress(placed), onLongPress: onMeasurementStampLongPress
220
+ ? () => onMeasurementStampLongPress(placed)
221
+ : undefined })), isSelected && measurement && (_jsx("div", { role: "button", "aria-label": "Remove measurement", onPointerDown: (e) => {
223
222
  e.stopPropagation();
224
223
  const { ops, keepSelection } = buildRemoveMeasurementOps(placed);
225
224
  state.ctx.commit({ ops });
@@ -236,3 +235,42 @@ export const AnnotationCanvasInner = (props) => {
236
235
  } }))] }, placed.id));
237
236
  }) }))] }));
238
237
  };
238
+ // Whole-tile press target for the stamp overlay. The DOM has no native
239
+ // long-press, so it's derived: pointerdown arms a timer; if it fires before
240
+ // the pointer lifts (or leaves/cancels), the long-press callback runs and the
241
+ // trailing click is swallowed. Mirrors the native overlay's TouchableOpacity
242
+ // onPress/onLongPress semantics (500ms, RN's default delayLongPress).
243
+ const LONG_PRESS_MS = 500;
244
+ const StampPressTarget = ({ onPress, onLongPress, }) => {
245
+ const timerRef = useRef(null);
246
+ const longPressFiredRef = useRef(false);
247
+ const clearTimer = () => {
248
+ if (timerRef.current != null) {
249
+ clearTimeout(timerRef.current);
250
+ timerRef.current = null;
251
+ }
252
+ };
253
+ return (_jsx("button", { "aria-label": "Open measurement", onPointerDown: (e) => {
254
+ e.stopPropagation();
255
+ longPressFiredRef.current = false;
256
+ if (onLongPress) {
257
+ clearTimer();
258
+ timerRef.current = setTimeout(() => {
259
+ timerRef.current = null;
260
+ longPressFiredRef.current = true;
261
+ onLongPress();
262
+ }, LONG_PRESS_MS);
263
+ }
264
+ }, onPointerUp: clearTimer, onPointerLeave: clearTimer, onPointerCancel: clearTimer, onClick: () => {
265
+ if (!longPressFiredRef.current)
266
+ onPress();
267
+ }, style: {
268
+ position: 'absolute',
269
+ inset: 0,
270
+ pointerEvents: 'auto',
271
+ cursor: 'pointer',
272
+ background: 'transparent',
273
+ border: 'none',
274
+ padding: 0,
275
+ } }));
276
+ };
@@ -24,6 +24,7 @@ export interface AnnotationCanvasInnerProps {
24
24
  requestTextInput?: RequestTextInput;
25
25
  renderMeasurementStamp?: RenderMeasurementStamp;
26
26
  onMeasurementStampPress?: (placed: PlacedMeasurementRef) => void;
27
+ onMeasurementStampLongPress?: (placed: PlacedMeasurementRef) => void;
27
28
  stampFontSource?: unknown;
28
29
  stampValueFontSize?: number;
29
30
  stampLabelFontSize?: number;