@cratis/components 4.39.3 → 4.39.4

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.
@@ -68,7 +68,7 @@
68
68
  {
69
69
  "name": "@cratis/components",
70
70
  "role": "core",
71
- "version": "4.39.3",
71
+ "version": "4.39.4",
72
72
  "releaseMajorRange": ">=4 <5",
73
73
  "independentRelease": false,
74
74
  "private": false,
@@ -92,7 +92,7 @@
92
92
  {
93
93
  "name": "@cratis/eslint-plugin-components",
94
94
  "role": "eslint",
95
- "version": "4.39.3",
95
+ "version": "4.39.4",
96
96
  "releaseMajorRange": ">=4 <5",
97
97
  "independentRelease": false,
98
98
  "private": false,
@@ -105,7 +105,7 @@
105
105
  {
106
106
  "name": "@cratis/components.migrator",
107
107
  "role": "migrator",
108
- "version": "4.39.3",
108
+ "version": "4.39.4",
109
109
  "releaseMajorRange": ">=4 <5",
110
110
  "independentRelease": false,
111
111
  "private": false,
@@ -116,13 +116,13 @@
116
116
  {
117
117
  "name": "@cratis/components.conformance",
118
118
  "role": "conformance",
119
- "version": "4.39.3",
119
+ "version": "4.39.4",
120
120
  "releaseMajorRange": ">=4 <5",
121
121
  "independentRelease": false,
122
122
  "private": false,
123
123
  "packageAccess": "public",
124
124
  "peerDependencies": {
125
- "@cratis/components": "4.39.3",
125
+ "@cratis/components": "4.39.4",
126
126
  "react": "^19.0.0",
127
127
  "react-dom": "^19.0.0"
128
128
  },
@@ -132,13 +132,13 @@
132
132
  {
133
133
  "name": "@cratis/components.mui",
134
134
  "role": "renderer-adapter",
135
- "version": "4.39.3",
135
+ "version": "4.39.4",
136
136
  "releaseMajorRange": ">=4 <5",
137
137
  "independentRelease": false,
138
138
  "private": false,
139
139
  "packageAccess": "public",
140
140
  "peerDependencies": {
141
- "@cratis/components": "4.39.3",
141
+ "@cratis/components": "4.39.4",
142
142
  "@emotion/react": ">=11.5 <12",
143
143
  "@emotion/styled": ">=11.11 <12",
144
144
  "@mui/material": ">=9 <10",
@@ -188,13 +188,13 @@
188
188
  {
189
189
  "name": "@cratis/components.primereact",
190
190
  "role": "renderer-adapter",
191
- "version": "4.39.3",
191
+ "version": "4.39.4",
192
192
  "releaseMajorRange": ">=4 <5",
193
193
  "independentRelease": false,
194
194
  "private": false,
195
195
  "packageAccess": "public",
196
196
  "peerDependencies": {
197
- "@cratis/components": "4.39.3",
197
+ "@cratis/components": "4.39.4",
198
198
  "@primereact/core": ">=11 <12",
199
199
  "@primereact/ui": ">=11 <12",
200
200
  "@primeuix/themes": ">=3 <4",
@@ -256,13 +256,13 @@
256
256
  {
257
257
  "name": "@cratis/components.primereact10",
258
258
  "role": "renderer-adapter",
259
- "version": "4.39.3",
259
+ "version": "4.39.4",
260
260
  "releaseMajorRange": ">=4 <5",
261
261
  "independentRelease": false,
262
262
  "private": false,
263
263
  "packageAccess": "public",
264
264
  "peerDependencies": {
265
- "@cratis/components": "4.39.3",
265
+ "@cratis/components": "4.39.4",
266
266
  "primereact": ">=10.9.9 <11",
267
267
  "react": "^19.0.0",
268
268
  "react-dom": "^19.0.0"
@@ -1 +1 @@
1
- {"version":3,"file":"Canvas.d.ts","sourceRoot":"","sources":["../../../Canvas/Canvas.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAiB,MAAM,OAAO,CAAC;AACtC,OAAO,KAAK,KAAK,IAAI,MAAM,SAAS,CAAC;AACrC,OAAO,EAEH,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EAC5B,MAAM,qBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,8BAA2B,CAAC;AACzE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAiB,CAAC;AACrD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAgB,CAAC;AACnD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAkB,CAAC;AAEvD,OAAO,KAAK,EAAuB,WAAW,EAAE,MAAM,oBAAiB,CAAC;AAaxE,YAAY,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AAM,EACN,SAAS,EACT,cAAc,EACd,aAAa,EACb,4BAAmC,EACnC,oBAAoB,EACpB,oBAA4B,EAC5B,iBAAiB,EACjB,QAAgB,EAChB,kBAAyB,GAC5B,EAAE,WAAW,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,YAAY,CAoNrC;AAED,OAAO,EAAE,MAAM,EAAE,CAAC"}
@@ -12,6 +12,7 @@ import { useLatestRef } from './useLatestRef.js';
12
12
  import { usePixiApplication } from './usePixiApplication.js';
13
13
  import { usePixiItems } from './usePixiItems.js';
14
14
  import { shouldUseCssZoom, isMultiTouchCapableDevice } from './zoomMechanism.js';
15
+ import { CANVAS_SURFACE_CLASS } from './isClaimedByAnotherSurface.js';
15
16
 
16
17
  function Canvas({ children, items = [], renderItem, onItemPointerDown, onReady, onTransformChange, onHandleReady, initialZoom = 1, initialPan = { x: 0, y: 0 }, minZoom = 0.1, maxZoom = 5, showControls = true, showMinimap = false, minimapWorldWidth, minimapWorldHeight, minimapItems, controlsPlacement = 'bottom-left', className, style, onHelp, helpTitle, controlsLabels, controlsIcons, controlsFollowViewportInsets = true, controlsGlassSurface, disableControlsGlass = false, captureAttributes, readOnly = false, backgroundDragPans = true, }) {
17
18
  const containerRef = useRef(null);
@@ -98,7 +99,7 @@ function Canvas({ children, items = [], renderItem, onItemPointerDown, onReady,
98
99
  refreshMinimap,
99
100
  render,
100
101
  });
101
- return (jsxs("div", { ref: containerRef, className: `canvas-surface cratis:relative cratis:overflow-hidden${className ? ` ${className}` : ''}`, style: { cursor: 'default', ...style }, onPointerDown: handlePointerDown, onPointerMove: handlePointerMove, onPointerUp: handlePointerUp, onPointerCancel: handlePointerUp, children: [jsx(CanvasItemRegistryContext.Provider, { value: registryContextValue, children: jsx("div", { ref: overlayRef, ...(captureAttributes?.transformHost
102
+ return (jsxs("div", { ref: containerRef, className: `${CANVAS_SURFACE_CLASS} cratis:relative cratis:overflow-hidden${className ? ` ${className}` : ''}`, style: { cursor: 'default', ...style }, onPointerDown: handlePointerDown, onPointerMove: handlePointerMove, onPointerUp: handlePointerUp, onPointerCancel: handlePointerUp, children: [jsx(CanvasItemRegistryContext.Provider, { value: registryContextValue, children: jsx("div", { ref: overlayRef, ...(captureAttributes?.transformHost
102
103
  ? { [captureAttributes.transformHost]: 'true' }
103
104
  : {}), style: {
104
105
  position: 'absolute',
@@ -1 +1 @@
1
- {"version":3,"file":"Canvas.js","sources":["../../../Canvas/Canvas.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport React, { useRef } from 'react';\nimport type * as PIXI from 'pixi.js';\nimport {\n CanvasControls,\n type CanvasControlsIcons,\n type CanvasControlsLabels,\n} from './CanvasControls';\nimport type { CanvasCaptureAttributes } from './CanvasCaptureAttributes';\nimport type { CanvasContext } from './CanvasContext';\nimport type { CanvasHandle } from './CanvasHandle';\nimport type { CanvasItemData } from './CanvasItemData';\nimport { CanvasItemRegistryContext } from './CanvasItemRegistryContext';\nimport type { CanvasMinimapHandle, MinimapItem } from './CanvasMinimap';\nimport type { PointerPosition } from './pinchGesture';\nimport { useCanvasCamera } from './useCanvasCamera';\nimport { useCanvasItemRegistry } from './useCanvasItemRegistry';\nimport { useCanvasNavigation } from './useCanvasNavigation';\nimport { useCanvasPointerGestures } from './useCanvasPointerGestures';\nimport { useCanvasWheelZoom } from './useCanvasWheelZoom';\nimport { useDragSelectionGuard } from './useDragSelectionGuard';\nimport { useLatestRef } from './useLatestRef';\nimport { usePixiApplication } from './usePixiApplication';\nimport { usePixiItems } from './usePixiItems';\nimport { isMultiTouchCapableDevice, shouldUseCssZoom } from './zoomMechanism';\n\nexport type { CanvasCaptureAttributes } from './CanvasCaptureAttributes';\nexport type { CanvasContext } from './CanvasContext';\nexport type { CanvasHandle } from './CanvasHandle';\nexport type { CanvasItemData } from './CanvasItemData';\nexport { CanvasItemRegistryContext } from './CanvasItemRegistryContext';\nexport type { CanvasItemRegistryContextValue } from './CanvasItemRegistryContextValue';\nexport type { CanvasItemRegistryEntry } from './CanvasItemRegistryEntry';\n\n/** Props for the pan, zoom, item, minimap, and control surface. */\nexport interface CanvasProps<T extends CanvasItemData = CanvasItemData> {\n /** DOM content positioned inside the transformed world. */\n children?: React.ReactNode;\n /** Optional Pixi-rendered item data. */\n items?: T[];\n /** Builds a Pixi display object for one item. */\n renderItem?: (item: T) => PIXI.Container;\n /** Receives pointer activation for a Pixi-rendered item. */\n onItemPointerDown?: (item: T, event: PIXI.FederatedPointerEvent) => void;\n /** Receives the initialized Pixi application and world. */\n onReady?: (context: CanvasContext) => void;\n /** Reports every camera transform change. */\n onTransformChange?: (zoom: number, pan: { x: number; y: number }) => void;\n /** Initial zoom factor. Defaults to `1`. */\n initialZoom?: number;\n /** Initial viewport translation. Defaults to `{ x: 0, y: 0 }`. */\n initialPan?: { x: number; y: number };\n /** Minimum zoom factor. Defaults to `0.1`. */\n minZoom?: number;\n /** Maximum zoom factor. Defaults to `5`. */\n maxZoom?: number;\n /** Whether integrated zoom controls render. Defaults to `true`. */\n showControls?: boolean;\n /** Whether controls expose the minimap toggle. Defaults to `false`. */\n showMinimap?: boolean;\n /** World width represented by the minimap. */\n minimapWorldWidth?: number;\n /** World height represented by the minimap. */\n minimapWorldHeight?: number;\n /** Explicit minimap item rectangles; measured CanvasItem bounds are used otherwise. */\n minimapItems?: MinimapItem[];\n /** Edge used by the integrated control bar. Defaults to `'bottom-left'`. */\n controlsPlacement?: 'bottom-left' | 'bottom-right';\n /** Extra class name for the Canvas root. */\n className?: string;\n /** Inline style for the Canvas root. */\n style?: React.CSSProperties;\n /** Invoked when the optional help action is activated. */\n onHelp?: () => void;\n /** Accessible label and tooltip for the help action. */\n helpTitle?: string;\n /** Localized labels for integrated zoom/minimap/help controls. */\n controlsLabels?: CanvasControlsLabels;\n /** Replacement glyphs for integrated zoom/minimap/help controls. Unset fields keep the built-in icons. */\n controlsIcons?: CanvasControlsIcons;\n /**\n * Whether the integrated controls step aside by the host's `--canvas-viewport-left`/`--canvas-viewport-right`\n * inset at their edge. Defaults to `true`; set `false` when the host already moves the canvas by that inset.\n */\n controlsFollowViewportInsets?: boolean;\n /** Optional product-owned glass/acrylic surface behind integrated controls. */\n controlsGlassSurface?: React.ReactNode;\n /** Uses a low-cost CSS frosted pill instead of a consumer-supplied glass surface. */\n disableControlsGlass?: boolean;\n /** Product-owned capture/compositor marker names. Canvas has no capture-provider dependency. */\n captureAttributes?: CanvasCaptureAttributes;\n /** Receives imperative camera and measurement operations. */\n onHandleReady?: (handle: CanvasHandle) => void;\n /** Keeps pan/zoom available while absorbing interaction with canvas content. */\n readOnly?: boolean;\n /**\n * Whether mouse/pen drag on empty background pans the board. Disable when\n * the product owns that gesture for selection; wheel, middle-button, and\n * touch panning remain available.\n */\n backgroundDragPans?: boolean;\n}\n\n/**\n * A pan/zoom/Pixi-backed infinite canvas with optional HTML overlay items, integrated minimap, and\n * zoom controls. Renders Pixi-backed sprites and DOM content under one synchronized camera, manages\n * wheel/touch/trackpad gestures, and exposes imperative camera navigation.\n */\nfunction Canvas<T extends CanvasItemData = CanvasItemData>({\n children,\n items = [] as T[],\n renderItem,\n onItemPointerDown,\n onReady,\n onTransformChange,\n onHandleReady,\n initialZoom = 1,\n initialPan = { x: 0, y: 0 },\n minZoom = 0.1,\n maxZoom = 5,\n showControls = true,\n showMinimap = false,\n minimapWorldWidth,\n minimapWorldHeight,\n minimapItems,\n controlsPlacement = 'bottom-left',\n className,\n style,\n onHelp,\n helpTitle,\n controlsLabels,\n controlsIcons,\n controlsFollowViewportInsets = true,\n controlsGlassSurface,\n disableControlsGlass = false,\n captureAttributes,\n readOnly = false,\n backgroundDragPans = true,\n}: CanvasProps<T>): React.ReactElement {\n const containerRef = useRef<HTMLDivElement>(null);\n useDragSelectionGuard(containerRef);\n const minimapRef = useRef<CanvasMinimapHandle | null>(null);\n const overlayRef = useRef<HTMLDivElement>(null);\n const zoomLayerRef = useRef<HTMLDivElement>(null);\n // Shared by touch momentum and the animated camera moves, so only one of them ever drives the\n // transform at once; each cancels whichever was still running.\n const animationFrameRef = useRef<number | null>(null);\n\n // Mutable refs so event callbacks always read current values without re-binding\n const panRef = useRef({ x: initialPan.x, y: initialPan.y });\n const zoomRef = useRef(initialZoom);\n\n // The transform styles rendered by JSX are frozen at their first-mount values: after mount the\n // overlay/zoom-layer styles are owned exclusively by the imperative per-frame writes. If the JSX\n // re-rendered them from live props (a parent may persist and echo the transform back through\n // `initialPan`/`initialZoom`), a React commit racing a gesture would rewrite the styles with\n // stale values — visible as the viewport flicking to an old position and back.\n const initialTransformRef = useRef({ pan: initialPan, zoom: initialZoom });\n\n // Touch pointers currently down on the canvas, in the order they landed. Touch is the only input\n // that can deliver several simultaneous pointers, so mouse/pen never enter this map.\n const touchPointersRef = useRef<Map<number, PointerPosition>>(new Map());\n\n // Keep callback refs current to avoid stale closures in PIXI event handlers\n const onReadyRef = useLatestRef(onReady);\n const onItemPointerDownRef = useLatestRef(onItemPointerDown);\n const onTransformChangeRef = useLatestRef(onTransformChange);\n const onHandleReadyRef = useLatestRef(onHandleReady);\n\n const { itemRegistryRef, registryContextValue, autoMinimapItems } =\n useCanvasItemRegistry();\n const effectiveMinimapItems = minimapItems ?? autoMinimapItems;\n\n const { appRef, worldRef, spritesRef, pixiReady, render } = usePixiApplication({\n containerRef,\n panRef,\n zoomRef,\n onReadyRef,\n captureLayer: captureAttributes?.layer,\n });\n\n const {\n applyWorldTransform,\n refreshMinimap,\n scheduleTransformApply,\n noteGestureActivity,\n zoomTowards,\n } = useCanvasCamera({\n appRef,\n worldRef,\n minimapRef,\n overlayRef,\n zoomLayerRef,\n panRef,\n zoomRef,\n onTransformChangeRef,\n render,\n minZoom,\n maxZoom,\n });\n\n useCanvasWheelZoom({\n containerRef,\n animationFrameRef,\n panRef,\n touchPointersRef,\n zoomTowards,\n noteGestureActivity,\n scheduleTransformApply,\n });\n\n const { handlePointerDown, handlePointerMove, handlePointerUp } =\n useCanvasPointerGestures({\n containerRef,\n animationFrameRef,\n panRef,\n zoomRef,\n touchPointersRef,\n minZoom,\n maxZoom,\n readOnly,\n backgroundDragPans,\n applyWorldTransform,\n refreshMinimap,\n render,\n noteGestureActivity,\n scheduleTransformApply,\n });\n\n usePixiItems({\n pixiReady,\n appRef,\n worldRef,\n spritesRef,\n items,\n renderItem,\n onItemPointerDownRef,\n });\n\n const { handleZoomIn, handleZoomOut, handleZoomReset, handleMinimapPan } =\n useCanvasNavigation({\n containerRef,\n animationFrameRef,\n panRef,\n zoomRef,\n itemRegistryRef,\n minZoom,\n maxZoom,\n pixiReady,\n onHandleReadyRef,\n applyWorldTransform,\n refreshMinimap,\n render,\n });\n\n return (\n <div\n ref={containerRef}\n className={`canvas-surface cratis:relative cratis:overflow-hidden${className ? ` ${className}` : ''}`}\n style={{ cursor: 'default', ...style }}\n onPointerDown={handlePointerDown}\n onPointerMove={handlePointerMove}\n onPointerUp={handlePointerUp}\n onPointerCancel={handlePointerUp}\n >\n {/* HTML overlay — mirrors the PIXI world transform so CanvasItem children\n are positioned in world-space coordinates. Updated via direct DOM style\n mutation during pan/zoom to avoid React re-renders.\n The CanvasItemRegistryContext allows CanvasItem children to report their\n positions and sizes for automatic minimap item generation. */}\n <CanvasItemRegistryContext.Provider value={registryContextValue}>\n {/* Pan (this div's transform) and zoom (the inner div's `zoom`) are\n rewritten every interaction frame. Marking both as glass transform\n hosts tells the capture pipeline to treat that churn as movement,\n not content change: it stops re-rasterizing the page on every frame\n and instead refreshes once the gesture settles. */}\n <div\n ref={overlayRef}\n {...(captureAttributes?.transformHost\n ? { [captureAttributes.transformHost]: 'true' }\n : {})}\n style={{\n position: 'absolute',\n top: 0,\n left: 0,\n transformOrigin: '0 0',\n transform: `translate(${initialTransformRef.current.pan.x}px, ${initialTransformRef.current.pan.y}px)`,\n pointerEvents: 'none',\n }}\n >\n <div\n ref={zoomLayerRef}\n {...(captureAttributes?.transformHost\n ? { [captureAttributes.transformHost]: 'true' }\n : {})}\n // The read-only overlay below keeps pointers off the board; `inert` keeps the keyboard\n // and assistive tech off it too, so nothing on a read-only board can be tabbed to and\n // activated (a public viewer must never be able to fire a command).\n inert={readOnly}\n style={\n shouldUseCssZoom(\n initialTransformRef.current.zoom,\n false,\n isMultiTouchCapableDevice,\n )\n ? { zoom: initialTransformRef.current.zoom }\n : {\n transform: `scale(${initialTransformRef.current.zoom})`,\n transformOrigin: '0 0',\n }\n }\n >\n {children}\n </div>\n </div>\n </CanvasItemRegistryContext.Provider>\n {readOnly && (\n // Sits above every board item (default stacking order beats the content layer's implicit\n // z-index) but below the controls/minimap, which render after it. Nothing underneath can\n // ever become a pointer event's target, so no CanvasItem consumer needs its own read-only\n // handling — this is the entire read-only guarantee.\n <div\n style={{ position: 'absolute', inset: 0, zIndex: 2, cursor: 'grab' }}\n />\n )}\n {showControls && (\n <CanvasControls\n getZoom={() => zoomRef.current}\n onZoomIn={handleZoomIn}\n onZoomOut={handleZoomOut}\n onZoomReset={handleZoomReset}\n showMinimapToggle={showMinimap}\n minimapRef={minimapRef}\n minimapWorldWidth={minimapWorldWidth}\n minimapWorldHeight={minimapWorldHeight}\n minimapItems={effectiveMinimapItems}\n onMinimapPan={handleMinimapPan}\n placement={controlsPlacement}\n onHelp={onHelp}\n helpTitle={helpTitle}\n labels={controlsLabels}\n icons={controlsIcons}\n followViewportInsets={controlsFollowViewportInsets}\n glassSurface={controlsGlassSurface}\n contentCaptureAttribute={captureAttributes?.content}\n disableGlass={disableControlsGlass}\n />\n )}\n </div>\n );\n}\n\nexport { Canvas };\n"],"names":["_jsxs","_jsx"],"mappings":";;;;;;;;;;;;;;;AA8GA,SAAS,MAAM,CAA4C,EACvD,QAAQ,EACR,KAAK,GAAG,EAAS,EACjB,UAAU,EACV,iBAAiB,EACjB,OAAO,EACP,iBAAiB,EACjB,aAAa,EACb,WAAW,GAAG,CAAC,EACf,UAAU,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAC3B,OAAO,GAAG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file":"Canvas.js","sources":["../../../Canvas/Canvas.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport React, { useRef } from 'react';\nimport type * as PIXI from 'pixi.js';\nimport {\n CanvasControls,\n type CanvasControlsIcons,\n type CanvasControlsLabels,\n} from './CanvasControls';\nimport type { CanvasCaptureAttributes } from './CanvasCaptureAttributes';\nimport type { CanvasContext } from './CanvasContext';\nimport type { CanvasHandle } from './CanvasHandle';\nimport type { CanvasItemData } from './CanvasItemData';\nimport { CanvasItemRegistryContext } from './CanvasItemRegistryContext';\nimport type { CanvasMinimapHandle, MinimapItem } from './CanvasMinimap';\nimport type { PointerPosition } from './pinchGesture';\nimport { useCanvasCamera } from './useCanvasCamera';\nimport { useCanvasItemRegistry } from './useCanvasItemRegistry';\nimport { useCanvasNavigation } from './useCanvasNavigation';\nimport { useCanvasPointerGestures } from './useCanvasPointerGestures';\nimport { useCanvasWheelZoom } from './useCanvasWheelZoom';\nimport { useDragSelectionGuard } from './useDragSelectionGuard';\nimport { useLatestRef } from './useLatestRef';\nimport { usePixiApplication } from './usePixiApplication';\nimport { usePixiItems } from './usePixiItems';\nimport { isMultiTouchCapableDevice, shouldUseCssZoom } from './zoomMechanism';\nimport { CANVAS_SURFACE_CLASS } from './isClaimedByAnotherSurface';\n\nexport type { CanvasCaptureAttributes } from './CanvasCaptureAttributes';\nexport type { CanvasContext } from './CanvasContext';\nexport type { CanvasHandle } from './CanvasHandle';\nexport type { CanvasItemData } from './CanvasItemData';\nexport { CanvasItemRegistryContext } from './CanvasItemRegistryContext';\nexport type { CanvasItemRegistryContextValue } from './CanvasItemRegistryContextValue';\nexport type { CanvasItemRegistryEntry } from './CanvasItemRegistryEntry';\n\n/** Props for the pan, zoom, item, minimap, and control surface. */\nexport interface CanvasProps<T extends CanvasItemData = CanvasItemData> {\n /** DOM content positioned inside the transformed world. */\n children?: React.ReactNode;\n /** Optional Pixi-rendered item data. */\n items?: T[];\n /** Builds a Pixi display object for one item. */\n renderItem?: (item: T) => PIXI.Container;\n /** Receives pointer activation for a Pixi-rendered item. */\n onItemPointerDown?: (item: T, event: PIXI.FederatedPointerEvent) => void;\n /** Receives the initialized Pixi application and world. */\n onReady?: (context: CanvasContext) => void;\n /** Reports every camera transform change. */\n onTransformChange?: (zoom: number, pan: { x: number; y: number }) => void;\n /** Initial zoom factor. Defaults to `1`. */\n initialZoom?: number;\n /** Initial viewport translation. Defaults to `{ x: 0, y: 0 }`. */\n initialPan?: { x: number; y: number };\n /** Minimum zoom factor. Defaults to `0.1`. */\n minZoom?: number;\n /** Maximum zoom factor. Defaults to `5`. */\n maxZoom?: number;\n /** Whether integrated zoom controls render. Defaults to `true`. */\n showControls?: boolean;\n /** Whether controls expose the minimap toggle. Defaults to `false`. */\n showMinimap?: boolean;\n /** World width represented by the minimap. */\n minimapWorldWidth?: number;\n /** World height represented by the minimap. */\n minimapWorldHeight?: number;\n /** Explicit minimap item rectangles; measured CanvasItem bounds are used otherwise. */\n minimapItems?: MinimapItem[];\n /** Edge used by the integrated control bar. Defaults to `'bottom-left'`. */\n controlsPlacement?: 'bottom-left' | 'bottom-right';\n /** Extra class name for the Canvas root. */\n className?: string;\n /** Inline style for the Canvas root. */\n style?: React.CSSProperties;\n /** Invoked when the optional help action is activated. */\n onHelp?: () => void;\n /** Accessible label and tooltip for the help action. */\n helpTitle?: string;\n /** Localized labels for integrated zoom/minimap/help controls. */\n controlsLabels?: CanvasControlsLabels;\n /** Replacement glyphs for integrated zoom/minimap/help controls. Unset fields keep the built-in icons. */\n controlsIcons?: CanvasControlsIcons;\n /**\n * Whether the integrated controls step aside by the host's `--canvas-viewport-left`/`--canvas-viewport-right`\n * inset at their edge. Defaults to `true`; set `false` when the host already moves the canvas by that inset.\n */\n controlsFollowViewportInsets?: boolean;\n /** Optional product-owned glass/acrylic surface behind integrated controls. */\n controlsGlassSurface?: React.ReactNode;\n /** Uses a low-cost CSS frosted pill instead of a consumer-supplied glass surface. */\n disableControlsGlass?: boolean;\n /** Product-owned capture/compositor marker names. Canvas has no capture-provider dependency. */\n captureAttributes?: CanvasCaptureAttributes;\n /** Receives imperative camera and measurement operations. */\n onHandleReady?: (handle: CanvasHandle) => void;\n /** Keeps pan/zoom available while absorbing interaction with canvas content. */\n readOnly?: boolean;\n /**\n * Whether mouse/pen drag on empty background pans the board. Disable when\n * the product owns that gesture for selection; wheel, middle-button, and\n * touch panning remain available.\n */\n backgroundDragPans?: boolean;\n}\n\n/**\n * A pan/zoom/Pixi-backed infinite canvas with optional HTML overlay items, integrated minimap, and\n * zoom controls. Renders Pixi-backed sprites and DOM content under one synchronized camera, manages\n * wheel/touch/trackpad gestures, and exposes imperative camera navigation.\n */\nfunction Canvas<T extends CanvasItemData = CanvasItemData>({\n children,\n items = [] as T[],\n renderItem,\n onItemPointerDown,\n onReady,\n onTransformChange,\n onHandleReady,\n initialZoom = 1,\n initialPan = { x: 0, y: 0 },\n minZoom = 0.1,\n maxZoom = 5,\n showControls = true,\n showMinimap = false,\n minimapWorldWidth,\n minimapWorldHeight,\n minimapItems,\n controlsPlacement = 'bottom-left',\n className,\n style,\n onHelp,\n helpTitle,\n controlsLabels,\n controlsIcons,\n controlsFollowViewportInsets = true,\n controlsGlassSurface,\n disableControlsGlass = false,\n captureAttributes,\n readOnly = false,\n backgroundDragPans = true,\n}: CanvasProps<T>): React.ReactElement {\n const containerRef = useRef<HTMLDivElement>(null);\n useDragSelectionGuard(containerRef);\n const minimapRef = useRef<CanvasMinimapHandle | null>(null);\n const overlayRef = useRef<HTMLDivElement>(null);\n const zoomLayerRef = useRef<HTMLDivElement>(null);\n // Shared by touch momentum and the animated camera moves, so only one of them ever drives the\n // transform at once; each cancels whichever was still running.\n const animationFrameRef = useRef<number | null>(null);\n\n // Mutable refs so event callbacks always read current values without re-binding\n const panRef = useRef({ x: initialPan.x, y: initialPan.y });\n const zoomRef = useRef(initialZoom);\n\n // The transform styles rendered by JSX are frozen at their first-mount values: after mount the\n // overlay/zoom-layer styles are owned exclusively by the imperative per-frame writes. If the JSX\n // re-rendered them from live props (a parent may persist and echo the transform back through\n // `initialPan`/`initialZoom`), a React commit racing a gesture would rewrite the styles with\n // stale values — visible as the viewport flicking to an old position and back.\n const initialTransformRef = useRef({ pan: initialPan, zoom: initialZoom });\n\n // Touch pointers currently down on the canvas, in the order they landed. Touch is the only input\n // that can deliver several simultaneous pointers, so mouse/pen never enter this map.\n const touchPointersRef = useRef<Map<number, PointerPosition>>(new Map());\n\n // Keep callback refs current to avoid stale closures in PIXI event handlers\n const onReadyRef = useLatestRef(onReady);\n const onItemPointerDownRef = useLatestRef(onItemPointerDown);\n const onTransformChangeRef = useLatestRef(onTransformChange);\n const onHandleReadyRef = useLatestRef(onHandleReady);\n\n const { itemRegistryRef, registryContextValue, autoMinimapItems } =\n useCanvasItemRegistry();\n const effectiveMinimapItems = minimapItems ?? autoMinimapItems;\n\n const { appRef, worldRef, spritesRef, pixiReady, render } = usePixiApplication({\n containerRef,\n panRef,\n zoomRef,\n onReadyRef,\n captureLayer: captureAttributes?.layer,\n });\n\n const {\n applyWorldTransform,\n refreshMinimap,\n scheduleTransformApply,\n noteGestureActivity,\n zoomTowards,\n } = useCanvasCamera({\n appRef,\n worldRef,\n minimapRef,\n overlayRef,\n zoomLayerRef,\n panRef,\n zoomRef,\n onTransformChangeRef,\n render,\n minZoom,\n maxZoom,\n });\n\n useCanvasWheelZoom({\n containerRef,\n animationFrameRef,\n panRef,\n touchPointersRef,\n zoomTowards,\n noteGestureActivity,\n scheduleTransformApply,\n });\n\n const { handlePointerDown, handlePointerMove, handlePointerUp } =\n useCanvasPointerGestures({\n containerRef,\n animationFrameRef,\n panRef,\n zoomRef,\n touchPointersRef,\n minZoom,\n maxZoom,\n readOnly,\n backgroundDragPans,\n applyWorldTransform,\n refreshMinimap,\n render,\n noteGestureActivity,\n scheduleTransformApply,\n });\n\n usePixiItems({\n pixiReady,\n appRef,\n worldRef,\n spritesRef,\n items,\n renderItem,\n onItemPointerDownRef,\n });\n\n const { handleZoomIn, handleZoomOut, handleZoomReset, handleMinimapPan } =\n useCanvasNavigation({\n containerRef,\n animationFrameRef,\n panRef,\n zoomRef,\n itemRegistryRef,\n minZoom,\n maxZoom,\n pixiReady,\n onHandleReadyRef,\n applyWorldTransform,\n refreshMinimap,\n render,\n });\n\n return (\n <div\n ref={containerRef}\n className={`${CANVAS_SURFACE_CLASS} cratis:relative cratis:overflow-hidden${className ? ` ${className}` : ''}`}\n style={{ cursor: 'default', ...style }}\n onPointerDown={handlePointerDown}\n onPointerMove={handlePointerMove}\n onPointerUp={handlePointerUp}\n onPointerCancel={handlePointerUp}\n >\n {/* HTML overlay — mirrors the PIXI world transform so CanvasItem children\n are positioned in world-space coordinates. Updated via direct DOM style\n mutation during pan/zoom to avoid React re-renders.\n The CanvasItemRegistryContext allows CanvasItem children to report their\n positions and sizes for automatic minimap item generation. */}\n <CanvasItemRegistryContext.Provider value={registryContextValue}>\n {/* Pan (this div's transform) and zoom (the inner div's `zoom`) are\n rewritten every interaction frame. Marking both as glass transform\n hosts tells the capture pipeline to treat that churn as movement,\n not content change: it stops re-rasterizing the page on every frame\n and instead refreshes once the gesture settles. */}\n <div\n ref={overlayRef}\n {...(captureAttributes?.transformHost\n ? { [captureAttributes.transformHost]: 'true' }\n : {})}\n style={{\n position: 'absolute',\n top: 0,\n left: 0,\n transformOrigin: '0 0',\n transform: `translate(${initialTransformRef.current.pan.x}px, ${initialTransformRef.current.pan.y}px)`,\n pointerEvents: 'none',\n }}\n >\n <div\n ref={zoomLayerRef}\n {...(captureAttributes?.transformHost\n ? { [captureAttributes.transformHost]: 'true' }\n : {})}\n // The read-only overlay below keeps pointers off the board; `inert` keeps the keyboard\n // and assistive tech off it too, so nothing on a read-only board can be tabbed to and\n // activated (a public viewer must never be able to fire a command).\n inert={readOnly}\n style={\n shouldUseCssZoom(\n initialTransformRef.current.zoom,\n false,\n isMultiTouchCapableDevice,\n )\n ? { zoom: initialTransformRef.current.zoom }\n : {\n transform: `scale(${initialTransformRef.current.zoom})`,\n transformOrigin: '0 0',\n }\n }\n >\n {children}\n </div>\n </div>\n </CanvasItemRegistryContext.Provider>\n {readOnly && (\n // Sits above every board item (default stacking order beats the content layer's implicit\n // z-index) but below the controls/minimap, which render after it. Nothing underneath can\n // ever become a pointer event's target, so no CanvasItem consumer needs its own read-only\n // handling — this is the entire read-only guarantee.\n <div\n style={{ position: 'absolute', inset: 0, zIndex: 2, cursor: 'grab' }}\n />\n )}\n {showControls && (\n <CanvasControls\n getZoom={() => zoomRef.current}\n onZoomIn={handleZoomIn}\n onZoomOut={handleZoomOut}\n onZoomReset={handleZoomReset}\n showMinimapToggle={showMinimap}\n minimapRef={minimapRef}\n minimapWorldWidth={minimapWorldWidth}\n minimapWorldHeight={minimapWorldHeight}\n minimapItems={effectiveMinimapItems}\n onMinimapPan={handleMinimapPan}\n placement={controlsPlacement}\n onHelp={onHelp}\n helpTitle={helpTitle}\n labels={controlsLabels}\n icons={controlsIcons}\n followViewportInsets={controlsFollowViewportInsets}\n glassSurface={controlsGlassSurface}\n contentCaptureAttribute={captureAttributes?.content}\n disableGlass={disableControlsGlass}\n />\n )}\n </div>\n );\n}\n\nexport { Canvas };\n"],"names":["_jsxs","_jsx"],"mappings":";;;;;;;;;;;;;;;;AA+GA,SAAS,MAAM,CAA4C,EACvD,QAAQ,EACR,KAAK,GAAG,EAAS,EACjB,UAAU,EACV,iBAAiB,EACjB,OAAO,EACP,iBAAiB,EACjB,aAAa,EACb,WAAW,GAAG,CAAC,EACf,UAAU,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAC3B,OAAO,GAAG,GAAG,EACb,OAAO,GAAG,CAAC,EACX,YAAY,GAAG,IAAI,EACnB,WAAW,GAAG,KAAK,EACnB,iBAAiB,EACjB,kBAAkB,EAClB,YAAY,EACZ,iBAAiB,GAAG,aAAa,EACjC,SAAS,EACT,KAAK,EACL,MAAM,E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AAE,eAAe,CAAC,CAAC;IACpD,WAAW,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACtE,mBAAmB,EAAE,MAAM,IAAI,CAAC;IAChC,sBAAsB,EAAE,MAAM,IAAI,CAAC;CACtC;AAKD;;;;;;;GAOG;AACH,eAAO,MAAM,yBAAyB,4HASnC,yBAAyB,KAAG,CAAC,MAAM,IAAI,CAoJzC,CAAC"}
@@ -1,4 +1,5 @@
1
1
  import { ZOOM_INTENSITY } from './canvasGestureTuning.js';
2
+ import { isClaimedByAnotherSurface } from './isClaimedByAnotherSurface.js';
2
3
  import { isWithinScrollableContent } from './isWithinScrollableContent.js';
3
4
 
4
5
  const isFinitePoint = (x, y) => typeof x === 'number' && typeof y === 'number' && Number.isFinite(x) && Number.isFinite(y);
@@ -26,7 +27,10 @@ const attachCanvasZoomListeners = ({ container, cancelMomentum, getPan, setPan,
26
27
  point.y >= rect.top &&
27
28
  point.y <= rect.bottom);
28
29
  };
30
+ const claimedElsewhere = (event) => isClaimedByAnotherSurface(event.target, container);
29
31
  const handleWheel = (event) => {
32
+ if (claimedElsewhere(event))
33
+ return;
30
34
  if (!(event.ctrlKey || event.metaKey) &&
31
35
  isWithinScrollableContent(event.target, container))
32
36
  return;
@@ -55,30 +59,36 @@ const attachCanvasZoomListeners = ({ container, cancelMomentum, getPan, setPan,
55
59
  lastScale = gesture.scale;
56
60
  };
57
61
  const handleGestureStart = (event) => {
62
+ if (claimedElsewhere(event))
63
+ return;
58
64
  event.preventDefault();
59
65
  lastScale = event.scale || 1;
60
66
  };
61
67
  const handleGestureChange = (event) => {
68
+ if (claimedElsewhere(event))
69
+ return;
62
70
  event.preventDefault();
63
71
  applyGestureChange(event, gestureFocus(event));
64
72
  };
65
73
  const handleGestureEnd = (event) => event.preventDefault();
66
74
  const reachesContainerListeners = (event) => event.target instanceof Node && container.contains(event.target);
67
75
  const handleWindowWheel = (event) => {
76
+ if (claimedElsewhere(event))
77
+ return;
68
78
  if ((event.ctrlKey || event.metaKey) &&
69
79
  isWithinCanvas({ x: event.clientX, y: event.clientY })) {
70
80
  event.preventDefault();
71
81
  }
72
82
  };
73
83
  const handleWindowGestureStart = (event) => {
74
- if (!isWithinCanvas(gestureFocus(event)))
84
+ if (claimedElsewhere(event) || !isWithinCanvas(gestureFocus(event)))
75
85
  return;
76
86
  event.preventDefault();
77
87
  lastScale = event.scale || 1;
78
88
  };
79
89
  const handleWindowGestureChange = (event) => {
80
90
  const focus = gestureFocus(event);
81
- if (!isWithinCanvas(focus))
91
+ if (claimedElsewhere(event) || !isWithinCanvas(focus))
82
92
  return;
83
93
  event.preventDefault();
84
94
  if (reachesContainerListeners(event))
@@ -86,7 +96,7 @@ const attachCanvasZoomListeners = ({ container, cancelMomentum, getPan, setPan,
86
96
  applyGestureChange(event, focus);
87
97
  };
88
98
  const handleWindowGestureEnd = (event) => {
89
- if (isWithinCanvas(gestureFocus(event)))
99
+ if (!claimedElsewhere(event) && isWithinCanvas(gestureFocus(event)))
90
100
  event.preventDefault();
91
101
  };
92
102
  const nonPassive = { passive: false };
@@ -1 +1 @@
1
- {"version":3,"file":"canvasZoomListeners.js","sources":["../../../Canvas/canvasZoomListeners.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { ZOOM_INTENSITY } from './canvasGestureTuning';\nimport { isWithinScrollableContent } from './isWithinScrollableContent';\nimport type { PointerPosition } from './pinchGesture';\nimport type { WebKitGestureEvent } from './WebKitGestureEvent';\n\n/** The camera state and operations {@link attachCanvasZoomListeners} drives. */\nexport interface CanvasZoomListenerOptions {\n container: HTMLElement;\n /** Cancels a still-coasting touch pan when a fresh gesture starts. */\n cancelMomentum: () => void;\n getPan: () => { x: number; y: number };\n setPan: (pan: { x: number; y: number }) => void;\n /** Touch pointers currently down; a touch pinch owns zooming while any are. */\n touchPointers: ReadonlyMap<number, PointerPosition>;\n zoomTowards: (focusX: number, focusY: number, factor: number) => void;\n noteGestureActivity: () => void;\n scheduleTransformApply: () => void;\n}\n\nconst isFinitePoint = (x: unknown, y: unknown): boolean =>\n typeof x === 'number' && typeof y === 'number' && Number.isFinite(x) && Number.isFinite(y);\n\n/**\n * Wires wheel pan, Ctrl/Cmd+wheel zoom (a trackpad pinch in Chrome/Firefox/Edge, and Safari's\n * synthesized equivalent) and Safari/iPadOS gesture events to the canvas camera, and cancels the\n * browser's own page zoom for all of them. A real touch pinch is handled elsewhere from pointer\n * events; here, with touch pointers down, the gesture events only have their page zoom cancelled.\n * @param options The container, camera state and operations.\n * @returns A function removing every listener.\n */\nexport const attachCanvasZoomListeners = ({\n container,\n cancelMomentum,\n getPan,\n setPan,\n touchPointers,\n zoomTowards,\n noteGestureActivity,\n scheduleTransformApply,\n}: CanvasZoomListenerOptions): (() => void) => {\n // The last place a pointer was seen in the viewport. iPadOS reports its gesture events without\n // coordinates, and a NaN focus would poison the camera and defeat the \"is it over the canvas\"\n // test, so a missing position falls back to this, then to the canvas centre.\n let lastPointer: PointerPosition | null = null;\n const trackPointer = (event: PointerEvent | MouseEvent) => {\n if (isFinitePoint(event.clientX, event.clientY)) {\n lastPointer = { x: event.clientX, y: event.clientY };\n }\n };\n\n const gestureFocus = (event: Event): PointerPosition => {\n const gesture = event as WebKitGestureEvent;\n if (isFinitePoint(gesture.clientX, gesture.clientY)) {\n return { x: gesture.clientX, y: gesture.clientY };\n }\n if (lastPointer) return lastPointer;\n const rect = container.getBoundingClientRect();\n return { x: rect.left + rect.width / 2, y: rect.top + rect.height / 2 };\n };\n\n const isWithinCanvas = (point: PointerPosition) => {\n const rect = container.getBoundingClientRect();\n return (\n point.x >= rect.left &&\n point.x <= rect.right &&\n point.y >= rect.top &&\n point.y <= rect.bottom\n );\n };\n\n const handleWheel = (event: WheelEvent) => {\n // A plain scroll landing over a scrollable overlay (a chat's message list and similar)\n // scrolls that content instead of panning the board. A zoom gesture (ctrl/cmd) always wins.\n if (\n !(event.ctrlKey || event.metaKey) &&\n isWithinScrollableContent(event.target, container)\n )\n return;\n\n event.preventDefault();\n cancelMomentum();\n\n const rect = container.getBoundingClientRect();\n if (event.ctrlKey || event.metaKey) {\n zoomTowards(\n event.clientX - rect.left,\n event.clientY - rect.top,\n Math.exp(-event.deltaY * ZOOM_INTENSITY),\n );\n } else {\n const pan = getPan();\n setPan({ x: pan.x - event.deltaX, y: pan.y - event.deltaY });\n noteGestureActivity();\n scheduleTransformApply();\n }\n };\n\n // Safari/WebKit reports a trackpad pinch (including iPadOS with a Magic Keyboard) through its\n // own gesture events, never as wheel+ctrlKey. Cancelling the default stops the page zoom; the\n // change event also has to drive the zoom or the pinch would be swallowed entirely.\n let lastScale = 1;\n const applyGestureChange = (event: Event, focus: PointerPosition) => {\n if (touchPointers.size > 0) return;\n const gesture = event as WebKitGestureEvent;\n if (!gesture.scale || !lastScale) return;\n\n const rect = container.getBoundingClientRect();\n zoomTowards(focus.x - rect.left, focus.y - rect.top, gesture.scale / lastScale);\n lastScale = gesture.scale;\n };\n const handleGestureStart = (event: Event) => {\n event.preventDefault();\n lastScale = (event as WebKitGestureEvent).scale || 1;\n };\n const handleGestureChange = (event: Event) => {\n event.preventDefault();\n applyGestureChange(event, gestureFocus(event));\n };\n const handleGestureEnd = (event: Event) => event.preventDefault();\n\n // Floating content over the canvas (toolbars, panels, the minimap) is often portalled out of the\n // container's subtree, so its events never reach the listeners above and the browser would zoom\n // the page. Listen on the window as well, going purely by screen position. For targets inside\n // the container this only cancels the browser zoom — the container listeners drive the zoom.\n const reachesContainerListeners = (event: Event) =>\n event.target instanceof Node && container.contains(event.target);\n const handleWindowWheel = (event: WheelEvent) => {\n if (\n (event.ctrlKey || event.metaKey) &&\n isWithinCanvas({ x: event.clientX, y: event.clientY })\n ) {\n event.preventDefault();\n }\n };\n const handleWindowGestureStart = (event: Event) => {\n if (!isWithinCanvas(gestureFocus(event))) return;\n event.preventDefault();\n lastScale = (event as WebKitGestureEvent).scale || 1;\n };\n const handleWindowGestureChange = (event: Event) => {\n const focus = gestureFocus(event);\n if (!isWithinCanvas(focus)) return;\n event.preventDefault();\n if (reachesContainerListeners(event)) return;\n applyGestureChange(event, focus);\n };\n const handleWindowGestureEnd = (event: Event) => {\n if (isWithinCanvas(gestureFocus(event))) event.preventDefault();\n };\n\n // Everything is explicitly non-passive: WebKit treating an options-less listener as passive\n // silently ignores preventDefault(), which is what lets the page zoom through.\n const nonPassive = { passive: false } as const;\n const trackingOptions = { passive: true, capture: true } as const;\n container.addEventListener('wheel', handleWheel, nonPassive);\n container.addEventListener('gesturestart', handleGestureStart, nonPassive);\n container.addEventListener('gesturechange', handleGestureChange, nonPassive);\n container.addEventListener('gestureend', handleGestureEnd, nonPassive);\n window.addEventListener('wheel', handleWindowWheel, nonPassive);\n window.addEventListener('gesturestart', handleWindowGestureStart, nonPassive);\n window.addEventListener('gesturechange', handleWindowGestureChange, nonPassive);\n window.addEventListener('gestureend', handleWindowGestureEnd, nonPassive);\n window.addEventListener('pointermove', trackPointer, trackingOptions);\n window.addEventListener('pointerdown', trackPointer, trackingOptions);\n window.addEventListener('wheel', trackPointer, trackingOptions);\n\n return () => {\n container.removeEventListener('wheel', handleWheel);\n container.removeEventListener('gesturestart', handleGestureStart);\n container.removeEventListener('gesturechange', handleGestureChange);\n container.removeEventListener('gestureend', handleGestureEnd);\n window.removeEventListener('wheel', handleWindowWheel);\n window.removeEventListener('gesturestart', handleWindowGestureStart);\n window.removeEventListener('gesturechange', handleWindowGestureChange);\n window.removeEventListener('gestureend', handleWindowGestureEnd);\n window.removeEventListener('pointermove', trackPointer, trackingOptions);\n window.removeEventListener('pointerdown', trackPointer, trackingOptions);\n window.removeEventListener('wheel', trackPointer, trackingOptions);\n };\n};\n"],"names":[],"mappings":";;;AAsBA,MAAM,aAAa,GAAG,CAAC,CAAU,EAAE,CAAU,KACzC,OAAO,CAAC,KAAK,QAAQ,IAAI,OAAO,CAAC,KAA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AE,sBAAsB,EAAE,UAAU,CAAC;IACzE,MAAM,CAAC,gBAAgB,CAAC,aAAa,EAAE,YAAY,EAAE,eAAe,CAAC;IACrE,MAAM,CAAC,gBAAgB,CAAC,aAAa,EAAE,YAAY,EAAE,eAAe,CAAC;IACrE,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,YAAY,EAAE,eAAe,CAAC;AAE/D,IAAA,OAAO,MAAK;AACR,QAAA,SAAS,CAAC,mBAAmB,CAAC,OAAO,EAAE,WAAW,CAAC;AACnD,QAAA,SAAS,CAAC,mBAAmB,CAAC,cAAc,EAAE,kBAAkB,CAAC;AACjE,QAAA,SAAS,CAAC,mBAAmB,CAAC,eAAe,EAAE,mBAAmB,CAAC;AACnE,QAAA,SAAS,CAAC,mBAAmB,CAAC,YAAY,EAAE,gBAAgB,CAAC;AAC7D,QAAA,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,iBAAiB,CAAC;AACtD,QAAA,MAAM,CAAC,mBAAmB,CAAC,cAAc,EAAE,wBAAwB,CAAC;AACpE,QAAA,MAAM,CAAC,mBAAmB,CAAC,eAAe,EAAE,yBAAyB,CAAC;AACtE,QAAA,MAAM,CAAC,mBAAmB,CAAC,YAAY,EAAE,sBAAsB,CAAC;QAChE,MAAM,CAAC,mBAAmB,CAAC,aAAa,EAAE,YAAY,EAAE,eAAe,CAAC;QACxE,MAAM,CAAC,mBAAmB,CAAC,aAAa,EAAE,YAAY,EAAE,eAAe,CAAC;QACxE,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,YAAY,EAAE,eAAe,CAAC;AACtE,IAAA,CAAC;AACL;;"}
1
+ {"version":3,"file":"canvasZoomListeners.js","sources":["../../../Canvas/canvasZoomListeners.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { ZOOM_INTENSITY } from './canvasGestureTuning';\nimport { isClaimedByAnotherSurface } from './isClaimedByAnotherSurface';\nimport { isWithinScrollableContent } from './isWithinScrollableContent';\nimport type { PointerPosition } from './pinchGesture';\nimport type { WebKitGestureEvent } from './WebKitGestureEvent';\n\n/** The camera state and operations {@link attachCanvasZoomListeners} drives. */\nexport interface CanvasZoomListenerOptions {\n container: HTMLElement;\n /** Cancels a still-coasting touch pan when a fresh gesture starts. */\n cancelMomentum: () => void;\n getPan: () => { x: number; y: number };\n setPan: (pan: { x: number; y: number }) => void;\n /** Touch pointers currently down; a touch pinch owns zooming while any are. */\n touchPointers: ReadonlyMap<number, PointerPosition>;\n zoomTowards: (focusX: number, focusY: number, factor: number) => void;\n noteGestureActivity: () => void;\n scheduleTransformApply: () => void;\n}\n\nconst isFinitePoint = (x: unknown, y: unknown): boolean =>\n typeof x === 'number' && typeof y === 'number' && Number.isFinite(x) && Number.isFinite(y);\n\n/**\n * Wires wheel pan, Ctrl/Cmd+wheel zoom (a trackpad pinch in Chrome/Firefox/Edge, and Safari's\n * synthesized equivalent) and Safari/iPadOS gesture events to the canvas camera, and cancels the\n * browser's own page zoom for all of them. A real touch pinch is handled elsewhere from pointer\n * events; here, with touch pointers down, the gesture events only have their page zoom cancelled.\n * @param options The container, camera state and operations.\n * @returns A function removing every listener.\n */\nexport const attachCanvasZoomListeners = ({\n container,\n cancelMomentum,\n getPan,\n setPan,\n touchPointers,\n zoomTowards,\n noteGestureActivity,\n scheduleTransformApply,\n}: CanvasZoomListenerOptions): (() => void) => {\n // The last place a pointer was seen in the viewport. iPadOS reports its gesture events without\n // coordinates, and a NaN focus would poison the camera and defeat the \"is it over the canvas\"\n // test, so a missing position falls back to this, then to the canvas centre.\n let lastPointer: PointerPosition | null = null;\n const trackPointer = (event: PointerEvent | MouseEvent) => {\n if (isFinitePoint(event.clientX, event.clientY)) {\n lastPointer = { x: event.clientX, y: event.clientY };\n }\n };\n\n const gestureFocus = (event: Event): PointerPosition => {\n const gesture = event as WebKitGestureEvent;\n if (isFinitePoint(gesture.clientX, gesture.clientY)) {\n return { x: gesture.clientX, y: gesture.clientY };\n }\n if (lastPointer) return lastPointer;\n const rect = container.getBoundingClientRect();\n return { x: rect.left + rect.width / 2, y: rect.top + rect.height / 2 };\n };\n\n const isWithinCanvas = (point: PointerPosition) => {\n const rect = container.getBoundingClientRect();\n return (\n point.x >= rect.left &&\n point.x <= rect.right &&\n point.y >= rect.top &&\n point.y <= rect.bottom\n );\n };\n\n // A gesture over another canvas, or over a modal dialog this canvas is not in, is that surface's to\n // handle; this canvas neither zooms nor pans for it.\n const claimedElsewhere = (event: Event) => isClaimedByAnotherSurface(event.target, container);\n\n const handleWheel = (event: WheelEvent) => {\n if (claimedElsewhere(event)) return;\n // A plain scroll landing over a scrollable overlay (a chat's message list and similar)\n // scrolls that content instead of panning the board. A zoom gesture (ctrl/cmd) always wins.\n if (\n !(event.ctrlKey || event.metaKey) &&\n isWithinScrollableContent(event.target, container)\n )\n return;\n\n event.preventDefault();\n cancelMomentum();\n\n const rect = container.getBoundingClientRect();\n if (event.ctrlKey || event.metaKey) {\n zoomTowards(\n event.clientX - rect.left,\n event.clientY - rect.top,\n Math.exp(-event.deltaY * ZOOM_INTENSITY),\n );\n } else {\n const pan = getPan();\n setPan({ x: pan.x - event.deltaX, y: pan.y - event.deltaY });\n noteGestureActivity();\n scheduleTransformApply();\n }\n };\n\n // Safari/WebKit reports a trackpad pinch (including iPadOS with a Magic Keyboard) through its\n // own gesture events, never as wheel+ctrlKey. Cancelling the default stops the page zoom; the\n // change event also has to drive the zoom or the pinch would be swallowed entirely.\n let lastScale = 1;\n const applyGestureChange = (event: Event, focus: PointerPosition) => {\n if (touchPointers.size > 0) return;\n const gesture = event as WebKitGestureEvent;\n if (!gesture.scale || !lastScale) return;\n\n const rect = container.getBoundingClientRect();\n zoomTowards(focus.x - rect.left, focus.y - rect.top, gesture.scale / lastScale);\n lastScale = gesture.scale;\n };\n const handleGestureStart = (event: Event) => {\n if (claimedElsewhere(event)) return;\n event.preventDefault();\n lastScale = (event as WebKitGestureEvent).scale || 1;\n };\n const handleGestureChange = (event: Event) => {\n if (claimedElsewhere(event)) return;\n event.preventDefault();\n applyGestureChange(event, gestureFocus(event));\n };\n const handleGestureEnd = (event: Event) => event.preventDefault();\n\n // Floating content over the canvas (toolbars, panels, the minimap) is often portalled out of the\n // container's subtree, so its events never reach the listeners above and the browser would zoom\n // the page. Listen on the window as well, going purely by screen position. For targets inside\n // the container this only cancels the browser zoom — the container listeners drive the zoom.\n const reachesContainerListeners = (event: Event) =>\n event.target instanceof Node && container.contains(event.target);\n const handleWindowWheel = (event: WheelEvent) => {\n if (claimedElsewhere(event)) return;\n if (\n (event.ctrlKey || event.metaKey) &&\n isWithinCanvas({ x: event.clientX, y: event.clientY })\n ) {\n event.preventDefault();\n }\n };\n const handleWindowGestureStart = (event: Event) => {\n if (claimedElsewhere(event) || !isWithinCanvas(gestureFocus(event))) return;\n event.preventDefault();\n lastScale = (event as WebKitGestureEvent).scale || 1;\n };\n const handleWindowGestureChange = (event: Event) => {\n const focus = gestureFocus(event);\n if (claimedElsewhere(event) || !isWithinCanvas(focus)) return;\n event.preventDefault();\n if (reachesContainerListeners(event)) return;\n applyGestureChange(event, focus);\n };\n const handleWindowGestureEnd = (event: Event) => {\n if (!claimedElsewhere(event) && isWithinCanvas(gestureFocus(event))) event.preventDefault();\n };\n\n // Everything is explicitly non-passive: WebKit treating an options-less listener as passive\n // silently ignores preventDefault(), which is what lets the page zoom through.\n const nonPassive = { passive: false } as const;\n const trackingOptions = { passive: true, capture: true } as const;\n container.addEventListener('wheel', handleWheel, nonPassive);\n container.addEventListener('gesturestart', handleGestureStart, nonPassive);\n container.addEventListener('gesturechange', handleGestureChange, nonPassive);\n container.addEventListener('gestureend', handleGestureEnd, nonPassive);\n window.addEventListener('wheel', handleWindowWheel, nonPassive);\n window.addEventListener('gesturestart', handleWindowGestureStart, nonPassive);\n window.addEventListener('gesturechange', handleWindowGestureChange, nonPassive);\n window.addEventListener('gestureend', handleWindowGestureEnd, nonPassive);\n window.addEventListener('pointermove', trackPointer, trackingOptions);\n window.addEventListener('pointerdown', trackPointer, trackingOptions);\n window.addEventListener('wheel', trackPointer, trackingOptions);\n\n return () => {\n container.removeEventListener('wheel', handleWheel);\n container.removeEventListener('gesturestart', handleGestureStart);\n container.removeEventListener('gesturechange', handleGestureChange);\n container.removeEventListener('gestureend', handleGestureEnd);\n window.removeEventListener('wheel', handleWindowWheel);\n window.removeEventListener('gesturestart', handleWindowGestureStart);\n window.removeEventListener('gesturechange', handleWindowGestureChange);\n window.removeEventListener('gestureend', handleWindowGestureEnd);\n window.removeEventListener('pointermove', trackPointer, trackingOptions);\n window.removeEventListener('pointerdown', trackPointer, trackingOptions);\n window.removeEventListener('wheel', trackPointer, trackingOptions);\n };\n};\n"],"names":[],"mappings":";;;;AAuBA,MAAM,aAAa,GAAG,CAAC,CAAU,EAAE,CAAU,KACzC,OAAO,CAAC,KAAK,QAAQ,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC;MAUjF,yBAAyB,GAAG,CAAC,EACtC,SAAS,EACT,cAAc,EACd,MAAM,EACN,MAAM,EACN,aAAa,EACb,WAAW,EACX,mBAAmB,EACnB,sBAAsB,GACE,KAAkB;IAI1C,IAAI,WAAW,GAA2B,IAAI;AAC9C,IAAA,MAAM,YAAY,GAAG,CAAC,KAAgC,KAAI;QACtD,IAAI,aAAa,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,EAAE;AAC7C,YAAA,WAAW,GAAG,EAAE,CAAC,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC,EAAE,KAAK,CAAC,OAAO,EAAE;QACxD;AACJ,IAAA,CAAC;AAED,IAAA,MAAM,YAAY,GAAG,CAAC,KAAY,KAAqB;QACnD,MAAM,OAAO,GAAG,KAA2B;QAC3C,IAAI,aAAa,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,O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AC,mBAAmB,CAAC,OAAO,EAAE,WAAW,CAAC;AACnD,QAAA,SAAS,CAAC,mBAAmB,CAAC,cAAc,EAAE,kBAAkB,CAAC;AACjE,QAAA,SAAS,CAAC,mBAAmB,CAAC,eAAe,EAAE,mBAAmB,CAAC;AACnE,QAAA,SAAS,CAAC,mBAAmB,CAAC,YAAY,EAAE,gBAAgB,CAAC;AAC7D,QAAA,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,iBAAiB,CAAC;AACtD,QAAA,MAAM,CAAC,mBAAmB,CAAC,cAAc,EAAE,wBAAwB,CAAC;AACpE,QAAA,MAAM,CAAC,mBAAmB,CAAC,eAAe,EAAE,yBAAyB,CAAC;AACtE,QAAA,MAAM,CAAC,mBAAmB,CAAC,YAAY,EAAE,sBAAsB,CAAC;QAChE,MAAM,CAAC,mBAAmB,CAAC,aAAa,EAAE,YAAY,EAAE,eAAe,CAAC;QACxE,MAAM,CAAC,mBAAmB,CAAC,aAAa,EAAE,YAAY,EAAE,eAAe,CAAC;QACxE,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,YAAY,EAAE,eAAe,CAAC;AACtE,IAAA,CAAC;AACL;;"}
@@ -0,0 +1,11 @@
1
+ /** The class every canvas puts on its container element. */
2
+ export declare const CANVAS_SURFACE_CLASS = "canvas-surface";
3
+ /**
4
+ * Whether a wheel or pinch over the canvas belongs to something else in front of it: another canvas
5
+ * (one inside a dialog, or one nested in this canvas) or a modal dialog this canvas is not part of.
6
+ * Such a gesture is left alone, so a pinch on an editor's canvas does not also zoom the board behind
7
+ * it. Content of the canvas's own that is portalled out of its subtree (toolbars, menus, the minimap)
8
+ * is not claimed by anything, so pinching over it still zooms the canvas.
9
+ */
10
+ export declare function isClaimedByAnotherSurface(target: EventTarget | null, container: HTMLElement): boolean;
11
+ //# sourceMappingURL=isClaimedByAnotherSurface.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isClaimedByAnotherSurface.d.ts","sourceRoot":"","sources":["../../../Canvas/isClaimedByAnotherSurface.ts"],"names":[],"mappings":"AAGA,4DAA4D;AAC5D,eAAO,MAAM,oBAAoB,mBAAmB,CAAC;AAIrD;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI,EAAE,SAAS,EAAE,WAAW,GAAG,OAAO,CASrG"}
@@ -0,0 +1,15 @@
1
+ const CANVAS_SURFACE_CLASS = 'canvas-surface';
2
+ const MODAL_SELECTOR = '[aria-modal="true"], [data-cratis-dialog-id]';
3
+ function isClaimedByAnotherSurface(target, container) {
4
+ const element = target instanceof Element ? target : target instanceof Node ? target.parentElement : null;
5
+ if (!element)
6
+ return false;
7
+ const surface = element.closest(`.${CANVAS_SURFACE_CLASS}`);
8
+ if (surface && surface !== container && !surface.contains(container))
9
+ return true;
10
+ const modal = element.closest(MODAL_SELECTOR);
11
+ return !!modal && !modal.contains(container);
12
+ }
13
+
14
+ export { CANVAS_SURFACE_CLASS, isClaimedByAnotherSurface };
15
+ //# sourceMappingURL=isClaimedByAnotherSurface.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isClaimedByAnotherSurface.js","sources":["../../../Canvas/isClaimedByAnotherSurface.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\n/** The class every canvas puts on its container element. */\nexport const CANVAS_SURFACE_CLASS = 'canvas-surface';\n\nconst MODAL_SELECTOR = '[aria-modal=\"true\"], [data-cratis-dialog-id]';\n\n/**\n * Whether a wheel or pinch over the canvas belongs to something else in front of it: another canvas\n * (one inside a dialog, or one nested in this canvas) or a modal dialog this canvas is not part of.\n * Such a gesture is left alone, so a pinch on an editor's canvas does not also zoom the board behind\n * it. Content of the canvas's own that is portalled out of its subtree (toolbars, menus, the minimap)\n * is not claimed by anything, so pinching over it still zooms the canvas.\n */\nexport function isClaimedByAnotherSurface(target: EventTarget | null, container: HTMLElement): boolean {\n const element = target instanceof Element ? target : target instanceof Node ? target.parentElement : null;\n if (!element) return false;\n\n const surface = element.closest(`.${CANVAS_SURFACE_CLASS}`);\n if (surface && surface !== container && !surface.contains(container)) return true;\n\n const modal = element.closest(MODAL_SELECTOR);\n return !!modal && !modal.contains(container);\n}\n"],"names":[],"mappings":"AAIO,MAAM,oBAAoB,GAAG;AAEpC,MAAM,cAAc,GAAG,8CAA8C;AAS/D,SAAU,yBAAyB,CAAC,MAA0B,EAAE,SAAsB,EAAA;IACxF,MAAM,OAAO,GAAG,MAAM,YAAY,OAAO,GAAG,MAAM,GAAG,MAAM,YAAY,IAAI,GAAG,MAAM,CAAC,aAAa,GAAG,IAAI;AACzG,IAAA,IAAI,CAAC,OAAO;AAAE,QAAA,OAAO,KAAK;IAE1B,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA,CAAA,EAAI,oBAAoB,CAAA,CAAE,CAAC;AAC3D,IAAA,IAAI,OAAO,IAAI,OAAO,KAAK,SAAS,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC;AAAE,QAAA,OAAO,IAAI;IAEjF,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,cAAc,CAAC;IAC7C,OAAO,CAAC,CAAC,KAAK,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,SAAS,CAAC;AAChD;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cratis/components",
3
- "version": "4.39.3",
3
+ "version": "4.39.4",
4
4
  "description": "React components for CQRS and event-sourced apps — command dialogs, typed forms, and query-backed data tables for Cratis Arc",
5
5
  "keywords": [
6
6
  "react",