canvu-react 0.4.64 → 0.4.65

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,4 +1,4 @@
1
- import { P as PlacementPreview, E as VectorViewportProps, D as VectorViewportHandle, V as VectorToolDefinition, x as VectorItemsChangeInfo, c as CanvasPlugin, h as CanvasPluginRenderContext } from './types-Ce4-OZbd.cjs';
1
+ import { P as PlacementPreview, G as VectorViewportProps, F as VectorViewportHandle, V as VectorToolDefinition, z as VectorItemsChangeInfo, c as CanvasPlugin, h as CanvasPluginRenderContext } from './types-Bw3REwrb.cjs';
2
2
  import { a as RemotePresenceMarkupStroke, R as RemotePresencePeer, b as RemotePresenceCamera, c as RealtimeConnectionState } from './types-DqsqQQVf.cjs';
3
3
  export { P as PresenceOverlayRenderContext } from './types-DqsqQQVf.cjs';
4
4
  import * as react_jsx_runtime from 'react/jsx-runtime';
@@ -1,4 +1,4 @@
1
- import { P as PlacementPreview, E as VectorViewportProps, D as VectorViewportHandle, V as VectorToolDefinition, x as VectorItemsChangeInfo, c as CanvasPlugin, h as CanvasPluginRenderContext } from './types-PsLgDGZT.js';
1
+ import { P as PlacementPreview, G as VectorViewportProps, F as VectorViewportHandle, V as VectorToolDefinition, z as VectorItemsChangeInfo, c as CanvasPlugin, h as CanvasPluginRenderContext } from './types-BZUp3LpC.js';
2
2
  import { a as RemotePresenceMarkupStroke, R as RemotePresencePeer, b as RemotePresenceCamera, c as RealtimeConnectionState } from './types-BXa2CIrc.js';
3
3
  export { P as PresenceOverlayRenderContext } from './types-BXa2CIrc.js';
4
4
  import * as react_jsx_runtime from 'react/jsx-runtime';
@@ -118,6 +118,36 @@ type VectorToolDefinition = {
118
118
  ariaLabel?: string;
119
119
  };
120
120
 
121
+ type ReadOnlyItemClickCandidateDetail = {
122
+ /** The item Canvu hit-tested under the read-only click. */
123
+ item: VectorSceneItem;
124
+ /** World-space pointer location at press time. */
125
+ worldX: number;
126
+ worldY: number;
127
+ /** Viewport/client pointer location at press time. */
128
+ clientX: number;
129
+ clientY: number;
130
+ pointerType: string;
131
+ shiftKey: boolean;
132
+ altKey: boolean;
133
+ metaKey: boolean;
134
+ ctrlKey: boolean;
135
+ /** Current viewport items. */
136
+ items: readonly VectorSceneItem[];
137
+ /** Selection snapshot before read-only activation handles the click. */
138
+ selectedIds: readonly string[];
139
+ };
140
+ /**
141
+ * Controls which items may receive select-mode click activation while
142
+ * `VectorViewport` is read-only (`interactive={false}`).
143
+ *
144
+ * `"custom"` keeps the default high-level behavior: custom placement/tool
145
+ * items with `onSelectModeItemClick` remain clickable, while regular items do
146
+ * not become selectable unless the app opts in. Use `"all"` or a predicate for
147
+ * read-only viewers that still need item selection or item-specific side effects.
148
+ */
149
+ type ReadOnlyItemClickScope = "custom" | "all" | ((detail: ReadOnlyItemClickCandidateDetail) => boolean);
150
+
121
151
  type ActiveToolStyle = StrokeStyle & {
122
152
  toolKind: "draw" | "marker" | "text" | "rect" | "ellipse" | "architectural-cloud" | "line" | "arrow";
123
153
  label?: string;
@@ -179,6 +209,47 @@ type SelectModeItemClickDetail = {
179
209
  /** Set the viewport selection when activation should also select or clear. */
180
210
  setSelectedIds: (ids: readonly string[]) => void;
181
211
  };
212
+
213
+ /**
214
+ * Read-only interaction exceptions for viewers that should stay immutable while
215
+ * still allowing explicit activation/selection clicks.
216
+ *
217
+ * Canvu-owned editing remains disabled: no placement, draw, move, resize,
218
+ * rotate, eraser, paste/drop mutation, text editing, handles, or inspector.
219
+ * Explicit user callbacks may still call `updateItem` when that is the desired
220
+ * app-level exception.
221
+ *
222
+ * @example
223
+ * ```tsx
224
+ * <VectorViewport
225
+ * interactive={false}
226
+ * readOnlyInteraction={{
227
+ * itemClicks: "all",
228
+ * onItemClick: ({ item, setSelectedIds }) => {
229
+ * setSelectedIds([item.id]);
230
+ * return "handled";
231
+ * },
232
+ * }}
233
+ * />
234
+ * ```
235
+ */
236
+ type ReadOnlyInteractionOptions = {
237
+ /**
238
+ * Which read-only item clicks Canvu should capture.
239
+ *
240
+ * Defaults to `"custom"`, which only activates custom placement/tool items
241
+ * that provide `onSelectModeItemClick`.
242
+ */
243
+ itemClicks?: ReadOnlyItemClickScope;
244
+ /**
245
+ * Optional handler for read-only item clicks enabled by `itemClicks`.
246
+ *
247
+ * Custom placement `onSelectModeItemClick` handlers run first for their own
248
+ * items. For non-custom opt-in clicks, returning `undefined` lets Canvu apply
249
+ * default read-only selection semantics.
250
+ */
251
+ onItemClick?: (detail: SelectModeItemClickDetail) => SelectModeItemClickResult;
252
+ };
182
253
  /**
183
254
  * Best-effort reason attached to a React viewport item change.
184
255
  *
@@ -338,8 +409,10 @@ type CustomShapePlacementOptions = {
338
409
  * Optional select-mode click handler for items created by this placement.
339
410
  *
340
411
  * If provided, a plain click on the item in select mode calls this handler instead
341
- * of selecting or moving the item. Resize and rotate handles still win first, and
342
- * dragging past the tap threshold falls back to normal move behavior.
412
+ * of selecting or moving the item. Resize and rotate handles still win first in
413
+ * interactive viewports, and dragging past the tap threshold falls back to normal
414
+ * move behavior. In read-only viewports, the same click still activates the item
415
+ * by default, while dragging past the tap threshold cancels activation.
343
416
  */
344
417
  onSelectModeItemClick?: (detail: SelectModeItemClickDetail) => SelectModeItemClickResult;
345
418
  };
@@ -361,6 +434,15 @@ type VectorViewportProps = {
361
434
  * Requires `onItemsChange` to persist mutations.
362
435
  */
363
436
  interactive?: boolean;
437
+ /**
438
+ * Read-only click exceptions used when `interactive` is false.
439
+ *
440
+ * By default, read-only viewports still allow custom placement/tool items
441
+ * with `onSelectModeItemClick` to activate. Opt into `"all"` or a predicate
442
+ * when a read-only viewer should also allow regular item selection/clicks.
443
+ * Canvu-owned editing stays disabled; only explicit callbacks may mutate.
444
+ */
445
+ readOnlyInteraction?: ReadOnlyInteractionOptions;
364
446
  /** Selected item ids (order preserved). Empty = none. */
365
447
  selectedIds?: readonly string[];
366
448
  onSelectionChange?: (ids: string[]) => void;
@@ -624,4 +706,4 @@ declare function useCanvuResolvedTools(): VectorToolDefinition[];
624
706
  */
625
707
  declare function useCanvuPluginContribution(pluginId: string, contribution: CanvasPluginContribution): void;
626
708
 
627
- export { VectorViewport as A, type BoardComponentPosition as B, type CustomShapePlacementOptions as C, type VectorViewportHandle as D, type VectorViewportProps as E, createCanvuPlugin as F, getBoardPositionStyle as G, useCanvuChromeContext as H, useCanvuDocumentContext as I, useCanvuPluginContext as J, useCanvuPluginContribution as K, useCanvuResolvedTools as L, useCanvuViewportContext as M, type PlacementPreview as P, type SelectModeItemClickDetail as S, type VectorToolDefinition as V, type WorldPointerDownDetail as W, type CanvuBeforeInteractionHook as a, type CanvuAfterInteractionHook as b, type CanvasPlugin as c, VectorSelectionInspector as d, type CanvasPluginComponentProps as e, type CanvasPluginContribution as f, type CanvasPluginItemsChangeMiddlewareContext as g, type CanvasPluginRenderContext as h, type CanvuAfterInteractionDetail as i, type CanvuBeforeInteractionResult as j, type CanvuChromeActiveToolStyle as k, CanvuChromeContext as l, type CanvuChromeContextValue as m, type CanvuChromeSelectionStyleChange as n, type CanvuInteractionDetail as o, type CanvuInteractionKind as p, type CanvuInteractionOutcome as q, type CanvuInteractionPoint as r, CanvuPluginContext as s, type CanvuPluginContextValue as t, type CanvuPluginViewportSnapshot as u, type SelectModeItemClickResult as v, type VectorCanvasSpacePosition as w, type VectorItemsChangeInfo as x, type VectorItemsChangeMotive as y, type VectorSelectionInspectorProps as z };
709
+ export { type VectorItemsChangeMotive as A, type BoardComponentPosition as B, type CustomShapePlacementOptions as C, type VectorSelectionInspectorProps as D, VectorViewport as E, type VectorViewportHandle as F, type VectorViewportProps as G, createCanvuPlugin as H, getBoardPositionStyle as I, useCanvuChromeContext as J, useCanvuDocumentContext as K, useCanvuPluginContext as L, useCanvuPluginContribution as M, useCanvuResolvedTools as N, useCanvuViewportContext as O, type PlacementPreview as P, type ReadOnlyInteractionOptions as R, type SelectModeItemClickDetail as S, type VectorToolDefinition as V, type WorldPointerDownDetail as W, type CanvuBeforeInteractionHook as a, type CanvuAfterInteractionHook as b, type CanvasPlugin as c, VectorSelectionInspector as d, type CanvasPluginComponentProps as e, type CanvasPluginContribution as f, type CanvasPluginItemsChangeMiddlewareContext as g, type CanvasPluginRenderContext as h, type CanvuAfterInteractionDetail as i, type CanvuBeforeInteractionResult as j, type CanvuChromeActiveToolStyle as k, CanvuChromeContext as l, type CanvuChromeContextValue as m, type CanvuChromeSelectionStyleChange as n, type CanvuInteractionDetail as o, type CanvuInteractionKind as p, type CanvuInteractionOutcome as q, type CanvuInteractionPoint as r, CanvuPluginContext as s, type CanvuPluginContextValue as t, type CanvuPluginViewportSnapshot as u, type ReadOnlyItemClickCandidateDetail as v, type ReadOnlyItemClickScope as w, type SelectModeItemClickResult as x, type VectorCanvasSpacePosition as y, type VectorItemsChangeInfo as z };
@@ -118,6 +118,36 @@ type VectorToolDefinition = {
118
118
  ariaLabel?: string;
119
119
  };
120
120
 
121
+ type ReadOnlyItemClickCandidateDetail = {
122
+ /** The item Canvu hit-tested under the read-only click. */
123
+ item: VectorSceneItem;
124
+ /** World-space pointer location at press time. */
125
+ worldX: number;
126
+ worldY: number;
127
+ /** Viewport/client pointer location at press time. */
128
+ clientX: number;
129
+ clientY: number;
130
+ pointerType: string;
131
+ shiftKey: boolean;
132
+ altKey: boolean;
133
+ metaKey: boolean;
134
+ ctrlKey: boolean;
135
+ /** Current viewport items. */
136
+ items: readonly VectorSceneItem[];
137
+ /** Selection snapshot before read-only activation handles the click. */
138
+ selectedIds: readonly string[];
139
+ };
140
+ /**
141
+ * Controls which items may receive select-mode click activation while
142
+ * `VectorViewport` is read-only (`interactive={false}`).
143
+ *
144
+ * `"custom"` keeps the default high-level behavior: custom placement/tool
145
+ * items with `onSelectModeItemClick` remain clickable, while regular items do
146
+ * not become selectable unless the app opts in. Use `"all"` or a predicate for
147
+ * read-only viewers that still need item selection or item-specific side effects.
148
+ */
149
+ type ReadOnlyItemClickScope = "custom" | "all" | ((detail: ReadOnlyItemClickCandidateDetail) => boolean);
150
+
121
151
  type ActiveToolStyle = StrokeStyle & {
122
152
  toolKind: "draw" | "marker" | "text" | "rect" | "ellipse" | "architectural-cloud" | "line" | "arrow";
123
153
  label?: string;
@@ -179,6 +209,47 @@ type SelectModeItemClickDetail = {
179
209
  /** Set the viewport selection when activation should also select or clear. */
180
210
  setSelectedIds: (ids: readonly string[]) => void;
181
211
  };
212
+
213
+ /**
214
+ * Read-only interaction exceptions for viewers that should stay immutable while
215
+ * still allowing explicit activation/selection clicks.
216
+ *
217
+ * Canvu-owned editing remains disabled: no placement, draw, move, resize,
218
+ * rotate, eraser, paste/drop mutation, text editing, handles, or inspector.
219
+ * Explicit user callbacks may still call `updateItem` when that is the desired
220
+ * app-level exception.
221
+ *
222
+ * @example
223
+ * ```tsx
224
+ * <VectorViewport
225
+ * interactive={false}
226
+ * readOnlyInteraction={{
227
+ * itemClicks: "all",
228
+ * onItemClick: ({ item, setSelectedIds }) => {
229
+ * setSelectedIds([item.id]);
230
+ * return "handled";
231
+ * },
232
+ * }}
233
+ * />
234
+ * ```
235
+ */
236
+ type ReadOnlyInteractionOptions = {
237
+ /**
238
+ * Which read-only item clicks Canvu should capture.
239
+ *
240
+ * Defaults to `"custom"`, which only activates custom placement/tool items
241
+ * that provide `onSelectModeItemClick`.
242
+ */
243
+ itemClicks?: ReadOnlyItemClickScope;
244
+ /**
245
+ * Optional handler for read-only item clicks enabled by `itemClicks`.
246
+ *
247
+ * Custom placement `onSelectModeItemClick` handlers run first for their own
248
+ * items. For non-custom opt-in clicks, returning `undefined` lets Canvu apply
249
+ * default read-only selection semantics.
250
+ */
251
+ onItemClick?: (detail: SelectModeItemClickDetail) => SelectModeItemClickResult;
252
+ };
182
253
  /**
183
254
  * Best-effort reason attached to a React viewport item change.
184
255
  *
@@ -338,8 +409,10 @@ type CustomShapePlacementOptions = {
338
409
  * Optional select-mode click handler for items created by this placement.
339
410
  *
340
411
  * If provided, a plain click on the item in select mode calls this handler instead
341
- * of selecting or moving the item. Resize and rotate handles still win first, and
342
- * dragging past the tap threshold falls back to normal move behavior.
412
+ * of selecting or moving the item. Resize and rotate handles still win first in
413
+ * interactive viewports, and dragging past the tap threshold falls back to normal
414
+ * move behavior. In read-only viewports, the same click still activates the item
415
+ * by default, while dragging past the tap threshold cancels activation.
343
416
  */
344
417
  onSelectModeItemClick?: (detail: SelectModeItemClickDetail) => SelectModeItemClickResult;
345
418
  };
@@ -361,6 +434,15 @@ type VectorViewportProps = {
361
434
  * Requires `onItemsChange` to persist mutations.
362
435
  */
363
436
  interactive?: boolean;
437
+ /**
438
+ * Read-only click exceptions used when `interactive` is false.
439
+ *
440
+ * By default, read-only viewports still allow custom placement/tool items
441
+ * with `onSelectModeItemClick` to activate. Opt into `"all"` or a predicate
442
+ * when a read-only viewer should also allow regular item selection/clicks.
443
+ * Canvu-owned editing stays disabled; only explicit callbacks may mutate.
444
+ */
445
+ readOnlyInteraction?: ReadOnlyInteractionOptions;
364
446
  /** Selected item ids (order preserved). Empty = none. */
365
447
  selectedIds?: readonly string[];
366
448
  onSelectionChange?: (ids: string[]) => void;
@@ -624,4 +706,4 @@ declare function useCanvuResolvedTools(): VectorToolDefinition[];
624
706
  */
625
707
  declare function useCanvuPluginContribution(pluginId: string, contribution: CanvasPluginContribution): void;
626
708
 
627
- export { VectorViewport as A, type BoardComponentPosition as B, type CustomShapePlacementOptions as C, type VectorViewportHandle as D, type VectorViewportProps as E, createCanvuPlugin as F, getBoardPositionStyle as G, useCanvuChromeContext as H, useCanvuDocumentContext as I, useCanvuPluginContext as J, useCanvuPluginContribution as K, useCanvuResolvedTools as L, useCanvuViewportContext as M, type PlacementPreview as P, type SelectModeItemClickDetail as S, type VectorToolDefinition as V, type WorldPointerDownDetail as W, type CanvuBeforeInteractionHook as a, type CanvuAfterInteractionHook as b, type CanvasPlugin as c, VectorSelectionInspector as d, type CanvasPluginComponentProps as e, type CanvasPluginContribution as f, type CanvasPluginItemsChangeMiddlewareContext as g, type CanvasPluginRenderContext as h, type CanvuAfterInteractionDetail as i, type CanvuBeforeInteractionResult as j, type CanvuChromeActiveToolStyle as k, CanvuChromeContext as l, type CanvuChromeContextValue as m, type CanvuChromeSelectionStyleChange as n, type CanvuInteractionDetail as o, type CanvuInteractionKind as p, type CanvuInteractionOutcome as q, type CanvuInteractionPoint as r, CanvuPluginContext as s, type CanvuPluginContextValue as t, type CanvuPluginViewportSnapshot as u, type SelectModeItemClickResult as v, type VectorCanvasSpacePosition as w, type VectorItemsChangeInfo as x, type VectorItemsChangeMotive as y, type VectorSelectionInspectorProps as z };
709
+ export { type VectorItemsChangeMotive as A, type BoardComponentPosition as B, type CustomShapePlacementOptions as C, type VectorSelectionInspectorProps as D, VectorViewport as E, type VectorViewportHandle as F, type VectorViewportProps as G, createCanvuPlugin as H, getBoardPositionStyle as I, useCanvuChromeContext as J, useCanvuDocumentContext as K, useCanvuPluginContext as L, useCanvuPluginContribution as M, useCanvuResolvedTools as N, useCanvuViewportContext as O, type PlacementPreview as P, type ReadOnlyInteractionOptions as R, type SelectModeItemClickDetail as S, type VectorToolDefinition as V, type WorldPointerDownDetail as W, type CanvuBeforeInteractionHook as a, type CanvuAfterInteractionHook as b, type CanvasPlugin as c, VectorSelectionInspector as d, type CanvasPluginComponentProps as e, type CanvasPluginContribution as f, type CanvasPluginItemsChangeMiddlewareContext as g, type CanvasPluginRenderContext as h, type CanvuAfterInteractionDetail as i, type CanvuBeforeInteractionResult as j, type CanvuChromeActiveToolStyle as k, CanvuChromeContext as l, type CanvuChromeContextValue as m, type CanvuChromeSelectionStyleChange as n, type CanvuInteractionDetail as o, type CanvuInteractionKind as p, type CanvuInteractionOutcome as q, type CanvuInteractionPoint as r, CanvuPluginContext as s, type CanvuPluginContextValue as t, type CanvuPluginViewportSnapshot as u, type ReadOnlyItemClickCandidateDetail as v, type ReadOnlyItemClickScope as w, type SelectModeItemClickResult as x, type VectorCanvasSpacePosition as y, type VectorItemsChangeInfo as z };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "canvu-react",
3
- "version": "0.4.64",
3
+ "version": "0.4.65",
4
4
  "description": "Vector-first infinite canvas (SVG) with pan, zoom, React bindings, and optional plugins",
5
5
  "license": "MIT",
6
6
  "type": "module",