@rytass/wms-map-react-components 0.1.10 → 0.3.0

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 (122) hide show
  1. package/CHANGELOG.md +181 -0
  2. package/README.md +30 -0
  3. package/components/breadcrumb/breadcrumb-edit-modal.cjs +92 -0
  4. package/components/breadcrumb/breadcrumb-edit-modal.d.cts +9 -0
  5. package/components/breadcrumb/breadcrumb-edit-modal.module.scss.cjs +5 -0
  6. package/components/breadcrumb/breadcrumb.cjs +171 -0
  7. package/components/breadcrumb/breadcrumb.d.cts +11 -0
  8. package/components/breadcrumb/breadcrumb.d.ts +1 -1
  9. package/components/breadcrumb/breadcrumb.module.scss.cjs +5 -0
  10. package/components/canvas/react-flow-canvas.cjs +327 -0
  11. package/components/canvas/react-flow-canvas.d.cts +40 -0
  12. package/components/canvas/react-flow-canvas.d.ts +3 -1
  13. package/components/canvas/react-flow-canvas.js +7 -1
  14. package/components/canvas/react-flow-canvas.module.scss.cjs +5 -0
  15. package/components/modal/wms-map-content.cjs +835 -0
  16. package/components/modal/wms-map-content.d.cts +4 -0
  17. package/components/modal/wms-map-content.d.ts +1 -1
  18. package/components/modal/wms-map-content.js +30 -3
  19. package/components/modal/wms-map-modal-container.cjs +132 -0
  20. package/components/modal/wms-map-modal-container.d.cts +5 -0
  21. package/components/modal/wms-map-modal-container.d.ts +2 -2
  22. package/components/modal/wms-map-modal-container.js +6 -4
  23. package/components/modal/wms-map-modal-container.module.scss.cjs +5 -0
  24. package/components/nodes/base-node.d.cts +12 -0
  25. package/components/nodes/base-node.d.ts +1 -1
  26. package/components/nodes/image-node.cjs +234 -0
  27. package/components/nodes/image-node.d.cts +17 -0
  28. package/components/nodes/image-node.d.ts +1 -1
  29. package/components/nodes/image-node.js +0 -2
  30. package/components/nodes/image-node.module.scss.cjs +5 -0
  31. package/components/nodes/path-node.cjs +554 -0
  32. package/components/nodes/path-node.d.cts +19 -0
  33. package/components/nodes/path-node.d.ts +1 -1
  34. package/components/nodes/path-node.js +6 -5
  35. package/components/nodes/path-node.module.scss.cjs +5 -0
  36. package/components/nodes/rectangle-node.cjs +240 -0
  37. package/components/nodes/rectangle-node.d.cts +11 -0
  38. package/components/nodes/rectangle-node.d.ts +1 -1
  39. package/components/nodes/rectangle-node.js +6 -5
  40. package/components/nodes/rectangle-node.module.scss.cjs +5 -0
  41. package/components/preview/wms-map-preview.cjs +201 -0
  42. package/components/preview/wms-map-preview.d.cts +11 -0
  43. package/components/preview/wms-map-preview.d.ts +11 -0
  44. package/components/preview/wms-map-preview.js +199 -0
  45. package/components/ui/context-menu.cjs +171 -0
  46. package/components/ui/context-menu.d.cts +25 -0
  47. package/components/ui/context-menu.module.scss.cjs +5 -0
  48. package/components/ui/toolbar.cjs +286 -0
  49. package/components/ui/toolbar.d.cts +23 -0
  50. package/components/ui/toolbar.d.ts +1 -1
  51. package/components/ui/toolbar.module.scss.cjs +5 -0
  52. package/components/ui/view-mode-toolbar.cjs +44 -0
  53. package/components/ui/view-mode-toolbar.d.cts +9 -0
  54. package/components/ui/view-mode-toolbar.d.ts +1 -1
  55. package/components/ui/view-mode-toolbar.module.scss.cjs +5 -0
  56. package/constants/index.cjs +54 -0
  57. package/constants/index.d.cts +45 -0
  58. package/constants/index.d.ts +2 -2
  59. package/constants/text-mappings.cjs +46 -0
  60. package/constants/text-mappings.d.cts +181 -0
  61. package/hooks/use-context-menu.cjs +231 -0
  62. package/hooks/use-context-menu.d.cts +37 -0
  63. package/hooks/use-context-menu.d.ts +1 -1
  64. package/hooks/use-direct-state-history.cjs +217 -0
  65. package/hooks/use-direct-state-history.d.cts +58 -0
  66. package/hooks/use-direct-state-history.d.ts +2 -2
  67. package/hooks/use-fit-view-when-ready.cjs +74 -0
  68. package/hooks/use-fit-view-when-ready.d.cts +18 -0
  69. package/hooks/use-fit-view-when-ready.d.ts +18 -0
  70. package/hooks/use-fit-view-when-ready.js +72 -0
  71. package/hooks/use-pen-drawing.cjs +366 -0
  72. package/hooks/use-pen-drawing.d.cts +30 -0
  73. package/hooks/use-pen-drawing.d.ts +1 -1
  74. package/hooks/use-rectangle-drawing.cjs +139 -0
  75. package/hooks/use-rectangle-drawing.d.cts +19 -0
  76. package/hooks/use-rectangle-drawing.d.ts +1 -1
  77. package/hooks/use-text-editing.cjs +156 -0
  78. package/hooks/use-text-editing.d.cts +19 -0
  79. package/icons/index.cjs +233 -0
  80. package/icons/index.d.cts +16 -0
  81. package/index.cjs +28 -0
  82. package/index.d.cts +6 -0
  83. package/index.d.ts +6 -5
  84. package/index.js +1 -0
  85. package/package.json +68 -3
  86. package/types/callback.types.d.cts +7 -0
  87. package/types/callback.types.d.ts +1 -1
  88. package/types/canvas.types.d.cts +35 -0
  89. package/types/canvas.types.d.ts +1 -1
  90. package/types/component-props.types.d.cts +76 -0
  91. package/types/component-props.types.d.ts +33 -2
  92. package/types/history.types.d.cts +24 -0
  93. package/types/history.types.d.ts +2 -2
  94. package/types/index.d.cts +5 -0
  95. package/types/index.d.ts +5 -5
  96. package/types/react-flow.types.d.cts +30 -0
  97. package/typings.cjs +44 -0
  98. package/typings.d.cts +136 -0
  99. package/utils/api-data-transform.cjs +221 -0
  100. package/utils/api-data-transform.d.cts +33 -0
  101. package/utils/api-data-transform.d.ts +1 -1
  102. package/utils/color-utils.cjs +58 -0
  103. package/utils/color-utils.d.cts +17 -0
  104. package/utils/debug-logger.cjs +45 -0
  105. package/utils/debug-logger.d.cts +33 -0
  106. package/utils/fit-trigger.cjs +41 -0
  107. package/utils/fit-trigger.d.cts +37 -0
  108. package/utils/fit-trigger.d.ts +37 -0
  109. package/utils/fit-trigger.js +36 -0
  110. package/utils/map-data-transform.cjs +360 -0
  111. package/utils/map-data-transform.d.cts +18 -0
  112. package/utils/map-data-transform.d.ts +1 -1
  113. package/utils/node-operations.cjs +88 -0
  114. package/utils/node-operations.d.cts +26 -0
  115. package/utils/node-utils.cjs +40 -0
  116. package/utils/node-utils.d.cts +10 -0
  117. package/utils/preview-highlight.cjs +38 -0
  118. package/utils/preview-highlight.d.cts +12 -0
  119. package/utils/preview-highlight.d.ts +12 -0
  120. package/utils/preview-highlight.js +34 -0
  121. package/index.cjs.css +0 -1
  122. package/index.cjs.js +0 -5128
@@ -0,0 +1,554 @@
1
+ "use client";
2
+ 'use strict';
3
+
4
+ var jsxRuntime = require('react/jsx-runtime');
5
+ var React = require('react');
6
+ var react = require('@xyflow/react');
7
+ var typings = require('../../typings.cjs');
8
+ var index = require('../../constants/index.cjs');
9
+ var useContextMenu = require('../../hooks/use-context-menu.cjs');
10
+ var useTextEditing = require('../../hooks/use-text-editing.cjs');
11
+ var nodeOperations = require('../../utils/node-operations.cjs');
12
+ var colorUtils = require('../../utils/color-utils.cjs');
13
+ var previewHighlight = require('../../utils/preview-highlight.cjs');
14
+ var contextMenu = require('../ui/context-menu.cjs');
15
+ var pathNode_module = require('./path-node.module.scss.cjs');
16
+
17
+ const PathNode = ({ data, selected, id, editMode, viewMode, onTextEditComplete, onPathPointsChange, onPathPointDragStateChange, isHovered = false })=>{
18
+ const { points = [], color = index.DEFAULT_RECTANGLE_COLOR, strokeWidth = 2, label = index.DEFAULT_PATH_LABEL, previewHighlighted = false, previewDimmed = false } = data;
19
+ // Get React Flow instance for viewport and node operations
20
+ const { setNodes, getNodes, getViewport } = react.useReactFlow();
21
+ // Dragging state - optimized for performance
22
+ const [isDraggingPoint, setIsDraggingPoint] = React.useState(false);
23
+ const [dragPointIndex, setDragPointIndex] = React.useState(null);
24
+ const dragStartRef = React.useRef(null);
25
+ const originalPointsRef = React.useRef([]);
26
+ // Use refs for immediate access to current drag values
27
+ const currentDragOffsetRef = React.useRef({
28
+ x: 0,
29
+ y: 0
30
+ });
31
+ const currentSyncOffsetRef = React.useRef({
32
+ x: 0,
33
+ y: 0
34
+ });
35
+ // Visual-only state for smooth dragging (doesn't trigger React Flow updates)
36
+ const [dragOffset, setDragOffset] = React.useState({
37
+ x: 0,
38
+ y: 0
39
+ });
40
+ const [dragSyncOffset, setDragSyncOffset] = React.useState({
41
+ x: 0,
42
+ y: 0
43
+ });
44
+ // Only editable in LAYER mode and EDIT view mode
45
+ const isEditable = viewMode === typings.ViewMode.EDIT && editMode === typings.EditMode.LAYER;
46
+ // Check if this node should be selectable (only in LAYER mode)
47
+ const isSelectable = editMode === typings.EditMode.LAYER;
48
+ const opacity = editMode === typings.EditMode.LAYER ? index.ACTIVE_OPACITY : index.RECTANGLE_INACTIVE_OPACITY;
49
+ // Context menu functionality
50
+ const { contextMenu: contextMenu$1, handleContextMenu, handleCloseContextMenu, handleDelete, arrangeActions, arrangeStates, getNodes: getNodesFromHook, setNodes: setNodesFromHook } = useContextMenu.useContextMenu({
51
+ id,
52
+ editMode,
53
+ isEditable,
54
+ nodeType: 'pathNode'
55
+ });
56
+ // Text editing functionality
57
+ const { isEditing, editingText, inputRef, setEditingText, handleDoubleClick, handleKeyDown, handleBlur } = useTextEditing.useTextEditing({
58
+ id,
59
+ label,
60
+ isEditable,
61
+ onTextEditComplete
62
+ });
63
+ // Calculate path dimensions - use fixed bounds during dragging to prevent unwanted shifts
64
+ const getBounds = React.useCallback((pointsToUse = points)=>{
65
+ if (pointsToUse.length === 0) return {
66
+ minX: 0,
67
+ minY: 0,
68
+ maxX: 0,
69
+ maxY: 0
70
+ };
71
+ const xs = pointsToUse.map((p)=>p.x);
72
+ const ys = pointsToUse.map((p)=>p.y);
73
+ return {
74
+ minX: Math.min(...xs),
75
+ minY: Math.min(...ys),
76
+ maxX: Math.max(...xs),
77
+ maxY: Math.max(...ys)
78
+ };
79
+ }, [
80
+ points
81
+ ]);
82
+ // Always use current bounds for rendering
83
+ const bounds = getBounds();
84
+ const width = Math.max(bounds.maxX - bounds.minX, 10);
85
+ const height = Math.max(bounds.maxY - bounds.minY, 10);
86
+ // Check if path is closed (first and last points are the same)
87
+ const isClosedPath = points.length > 2 && Math.abs(points[0].x - points[points.length - 1].x) < 0.1 && Math.abs(points[0].y - points[points.length - 1].y) < 0.1;
88
+ // Simple approach: show ALL points, including duplicate first/last in closed paths
89
+ const displayPoints = points;
90
+ // Debug logging for path editing
91
+ console.log('🔍 PathNode render', {
92
+ id: id.slice(-4),
93
+ isClosedPath,
94
+ pointsCount: points.length,
95
+ points: points.map((p, i)=>`${i}:(${p.x.toFixed(1)},${p.y.toFixed(1)})`).join(' ')
96
+ });
97
+ // Performance-optimized drag handling - separate visual updates from data updates
98
+ const handlePointMouseDown = React.useCallback((pointIndex, event)=>{
99
+ if (!isEditable) return;
100
+ const isFirstPoint = pointIndex === 0;
101
+ const isLastPoint = pointIndex === points.length - 1;
102
+ console.log('🚀 Point drag start (performance mode)', {
103
+ id: id.slice(-4),
104
+ pointIndex,
105
+ isClosedPath,
106
+ isFirstPoint,
107
+ isLastPoint,
108
+ totalPoints: points.length
109
+ });
110
+ // Store original state
111
+ dragStartRef.current = {
112
+ x: event.clientX,
113
+ y: event.clientY
114
+ };
115
+ originalPointsRef.current = [
116
+ ...points
117
+ ];
118
+ setDragPointIndex(pointIndex);
119
+ setIsDraggingPoint(true);
120
+ // Notify parent about drag state change
121
+ onPathPointDragStateChange?.(id, true);
122
+ // Reset visual offsets
123
+ setDragOffset({
124
+ x: 0,
125
+ y: 0
126
+ });
127
+ setDragSyncOffset({
128
+ x: 0,
129
+ y: 0
130
+ });
131
+ currentDragOffsetRef.current = {
132
+ x: 0,
133
+ y: 0
134
+ };
135
+ currentSyncOffsetRef.current = {
136
+ x: 0,
137
+ y: 0
138
+ };
139
+ const handleMouseMove = (e)=>{
140
+ if (!dragStartRef.current) return;
141
+ const viewport = getViewport();
142
+ const deltaX = (e.clientX - dragStartRef.current.x) / viewport.zoom;
143
+ const deltaY = (e.clientY - dragStartRef.current.y) / viewport.zoom;
144
+ // Store current values in refs for immediate access
145
+ currentDragOffsetRef.current = {
146
+ x: deltaX,
147
+ y: deltaY
148
+ };
149
+ // Update visual state - triggers re-render for smooth dragging
150
+ setDragOffset({
151
+ x: deltaX,
152
+ y: deltaY
153
+ });
154
+ // For closed paths, also update sync point visual offset
155
+ if (isClosedPath && points.length > 2) {
156
+ if (isFirstPoint || isLastPoint) {
157
+ currentSyncOffsetRef.current = {
158
+ x: deltaX,
159
+ y: deltaY
160
+ };
161
+ setDragSyncOffset({
162
+ x: deltaX,
163
+ y: deltaY
164
+ });
165
+ }
166
+ }
167
+ };
168
+ const handleMouseUp = ()=>{
169
+ console.log('🏁 Point drag end (performance mode)', {
170
+ id: id.slice(-4),
171
+ pointIndex,
172
+ finalOffset: currentDragOffsetRef.current
173
+ });
174
+ if (!dragStartRef.current) return;
175
+ // Use ref values for immediate access to final position
176
+ const deltaX = currentDragOffsetRef.current.x;
177
+ const deltaY = currentDragOffsetRef.current.y;
178
+ console.log('📍 Final position calculation', {
179
+ originalPoint: originalPointsRef.current[pointIndex],
180
+ deltaX,
181
+ deltaY,
182
+ finalPoint: {
183
+ x: originalPointsRef.current[pointIndex].x + deltaX,
184
+ y: originalPointsRef.current[pointIndex].y + deltaY
185
+ }
186
+ });
187
+ // Now update the actual data (only once at the end)
188
+ const newPoints = [
189
+ ...originalPointsRef.current
190
+ ];
191
+ const targetPoint = {
192
+ x: originalPointsRef.current[pointIndex].x + deltaX,
193
+ y: originalPointsRef.current[pointIndex].y + deltaY
194
+ };
195
+ // Update the dragged point
196
+ newPoints[pointIndex] = targetPoint;
197
+ // For closed paths, sync first and last points
198
+ if (isClosedPath && newPoints.length > 2) {
199
+ if (isFirstPoint) {
200
+ newPoints[newPoints.length - 1] = targetPoint;
201
+ console.log('🔄 Final sync: last point with first point', targetPoint);
202
+ } else if (isLastPoint) {
203
+ newPoints[0] = targetPoint;
204
+ console.log('🔄 Final sync: first point with last point', targetPoint);
205
+ }
206
+ }
207
+ // Calculate new bounds and position like rectangle resize
208
+ const newBounds = getBounds(newPoints);
209
+ const currentNode = getNodes().find((n)=>n.id === id);
210
+ if (currentNode) {
211
+ // Calculate position adjustment based on bounds change (like rectangle anchor)
212
+ const oldBounds = getBounds(originalPointsRef.current);
213
+ const positionDelta = {
214
+ x: newBounds.minX - oldBounds.minX,
215
+ y: newBounds.minY - oldBounds.minY
216
+ };
217
+ const newPosition = {
218
+ x: currentNode.position.x + positionDelta.x,
219
+ y: currentNode.position.y + positionDelta.y
220
+ };
221
+ console.log('📍 Position adjustment for anchor behavior', {
222
+ oldBounds: `(${oldBounds.minX}, ${oldBounds.minY})`,
223
+ newBounds: `(${newBounds.minX}, ${newBounds.minY})`,
224
+ positionDelta,
225
+ oldPosition: currentNode.position,
226
+ newPosition
227
+ });
228
+ // Update both data and position simultaneously (like rectangle resize)
229
+ setNodes((nodes)=>nodes.map((node)=>node.id === id ? {
230
+ ...node,
231
+ data: {
232
+ ...node.data,
233
+ points: newPoints
234
+ },
235
+ position: newPosition
236
+ } : node));
237
+ } else {
238
+ // Fallback: just update data if node not found
239
+ setNodes((nodes)=>nodes.map((node)=>node.id === id ? {
240
+ ...node,
241
+ data: {
242
+ ...node.data,
243
+ points: newPoints
244
+ }
245
+ } : node));
246
+ }
247
+ // Record history for undo/redo
248
+ if (onPathPointsChange && originalPointsRef.current) {
249
+ setTimeout(()=>{
250
+ console.log('💾 Recording history', {
251
+ originalPoints: originalPointsRef.current,
252
+ newPoints
253
+ });
254
+ onPathPointsChange(id, originalPointsRef.current, newPoints);
255
+ }, 10);
256
+ }
257
+ // Reset states
258
+ setIsDraggingPoint(false);
259
+ setDragPointIndex(null);
260
+ setDragOffset({
261
+ x: 0,
262
+ y: 0
263
+ });
264
+ setDragSyncOffset({
265
+ x: 0,
266
+ y: 0
267
+ });
268
+ currentDragOffsetRef.current = {
269
+ x: 0,
270
+ y: 0
271
+ };
272
+ currentSyncOffsetRef.current = {
273
+ x: 0,
274
+ y: 0
275
+ };
276
+ // Notify parent about drag state change
277
+ onPathPointDragStateChange?.(id, false);
278
+ // Cleanup
279
+ dragStartRef.current = null;
280
+ originalPointsRef.current = [];
281
+ document.removeEventListener('mousemove', handleMouseMove);
282
+ document.removeEventListener('mouseup', handleMouseUp);
283
+ };
284
+ document.addEventListener('mousemove', handleMouseMove);
285
+ document.addEventListener('mouseup', handleMouseUp);
286
+ }, [
287
+ id,
288
+ isEditable,
289
+ points,
290
+ isClosedPath,
291
+ onPathPointsChange,
292
+ onPathPointDragStateChange,
293
+ setNodes,
294
+ getViewport,
295
+ getBounds,
296
+ getNodes
297
+ ]);
298
+ // Create SVG path string using fixed bounds during drag to prevent React Flow repositioning
299
+ const pathString = displayPoints.length > 0 ? (()=>{
300
+ // Use fixed bounds during drag to maintain stable React Flow node positioning
301
+ const pathPoints = displayPoints.map((p, index)=>{
302
+ const baseX = p.x - bounds.minX;
303
+ const baseY = p.y - bounds.minY;
304
+ // Apply drag offsets for visual feedback during dragging
305
+ const { x, y } = (()=>{
306
+ if (isDraggingPoint && dragPointIndex === index) {
307
+ return {
308
+ x: baseX + dragOffset.x,
309
+ y: baseY + dragOffset.y
310
+ };
311
+ } else if (isDraggingPoint && isClosedPath && points.length > 2) {
312
+ // Apply sync offset to opposite point in closed paths
313
+ const isFirstPoint = index === 0;
314
+ const isLastPoint = index === points.length - 1;
315
+ const draggedIsFirst = dragPointIndex === 0;
316
+ const draggedIsLast = dragPointIndex === points.length - 1;
317
+ if (draggedIsFirst && isLastPoint || draggedIsLast && isFirstPoint) {
318
+ return {
319
+ x: baseX + dragSyncOffset.x,
320
+ y: baseY + dragSyncOffset.y
321
+ };
322
+ }
323
+ }
324
+ return {
325
+ x: baseX,
326
+ y: baseY
327
+ };
328
+ })();
329
+ return `${x} ${y}`;
330
+ });
331
+ if (isClosedPath) {
332
+ // For closed paths, remove the duplicate last point and add Z to close
333
+ return `M ${pathPoints.slice(0, -1).join(' L ')} Z`;
334
+ } else {
335
+ // For open paths, connect all points
336
+ return `M ${pathPoints.join(' L ')}`;
337
+ }
338
+ })() : '';
339
+ console.log('🎨 SVG path generation (fixed bounds during drag)', {
340
+ id: id.slice(-4),
341
+ isClosedPath,
342
+ isDragging: isDraggingPoint,
343
+ draggedIndex: isDraggingPoint ? dragPointIndex : null,
344
+ pointsCount: displayPoints.length,
345
+ bounds: `(${bounds.minX}, ${bounds.minY}) to (${bounds.maxX}, ${bounds.maxY})`,
346
+ boundsSource: isDraggingPoint && originalPointsRef.current.length > 0 ? 'original (fixed)' : 'current',
347
+ pathPreview: pathString.substring(0, 50) + (pathString.length > 50 ? '...' : '')
348
+ });
349
+ // Handle copy and paste
350
+ const handleCopyPaste = React.useCallback(()=>{
351
+ const currentNode = getNodesFromHook().find((node)=>node.id === id);
352
+ if (!currentNode) {
353
+ console.error('Current node not found');
354
+ return;
355
+ }
356
+ setNodesFromHook((nds)=>{
357
+ // Calculate next zIndex
358
+ const maxZIndex = Math.max(...nds.map((n)=>n.zIndex || 0), 0);
359
+ const copiedNode = nodeOperations.createPathCopy({
360
+ currentNode,
361
+ data: {
362
+ points,
363
+ color,
364
+ strokeWidth,
365
+ label
366
+ }
367
+ });
368
+ const nodeWithZIndex = {
369
+ ...copiedNode,
370
+ zIndex: maxZIndex + 1
371
+ };
372
+ return [
373
+ ...nds,
374
+ nodeWithZIndex
375
+ ];
376
+ });
377
+ handleCloseContextMenu();
378
+ }, [
379
+ id,
380
+ points,
381
+ color,
382
+ strokeWidth,
383
+ label,
384
+ getNodesFromHook,
385
+ setNodesFromHook,
386
+ handleCloseContextMenu
387
+ ]);
388
+ // 在檢視模式下計算 hover 顏色
389
+ const displayColor = viewMode === typings.ViewMode.VIEW && isHovered ? colorUtils.createHoverColor(color) : color;
390
+ return /*#__PURE__*/ jsxRuntime.jsxs("div", {
391
+ className: `${pathNode_module.pathNode} ${selected && isEditable ? pathNode_module.selected : ''} ${!isSelectable ? pathNode_module.nonSelectable : ''}`,
392
+ children: [
393
+ /*#__PURE__*/ jsxRuntime.jsxs("div", {
394
+ className: pathNode_module.pathContainer,
395
+ style: {
396
+ width: `${width}px`,
397
+ height: `${height}px`,
398
+ opacity: previewDimmed ? previewHighlight.PREVIEW_DIMMED_OPACITY : opacity,
399
+ border: selected && isEditable ? '2px solid #3b82f6' : 'none',
400
+ borderRadius: '4px',
401
+ position: 'relative',
402
+ cursor: viewMode === typings.ViewMode.VIEW ? 'pointer' : 'default',
403
+ transition: viewMode === typings.ViewMode.VIEW ? 'all 0.2s ease' : 'none'
404
+ },
405
+ onDoubleClick: viewMode === typings.ViewMode.EDIT ? handleDoubleClick : undefined,
406
+ onContextMenu: viewMode === typings.ViewMode.EDIT ? handleContextMenu : undefined,
407
+ children: [
408
+ /*#__PURE__*/ jsxRuntime.jsx("svg", {
409
+ width: width,
410
+ height: height,
411
+ style: {
412
+ overflow: 'visible'
413
+ },
414
+ children: /*#__PURE__*/ jsxRuntime.jsx("path", {
415
+ d: pathString,
416
+ stroke: displayColor,
417
+ strokeWidth: previewHighlighted ? Math.max(strokeWidth, previewHighlight.PREVIEW_HIGHLIGHT_STROKE_WIDTH) : strokeWidth,
418
+ fill: isClosedPath ? displayColor : 'none',
419
+ fillOpacity: isClosedPath ? previewHighlighted ? 0.45 : 0.2 : 0,
420
+ strokeLinecap: "round",
421
+ strokeLinejoin: "round"
422
+ })
423
+ }),
424
+ selected && isEditable && /*#__PURE__*/ jsxRuntime.jsx("div", {
425
+ className: "nodrag",
426
+ style: {
427
+ position: 'absolute',
428
+ top: 0,
429
+ left: 0,
430
+ width: `${width}px`,
431
+ height: `${height}px`,
432
+ pointerEvents: 'none',
433
+ zIndex: 1000
434
+ },
435
+ children: displayPoints.map((point, index)=>{
436
+ // Use fixed bounds during dragging to maintain stable positioning
437
+ const relativeX = point.x - bounds.minX;
438
+ const relativeY = point.y - bounds.minY;
439
+ const isBeingDragged = dragPointIndex === index && isDraggingPoint;
440
+ // Apply visual offset during drag for smooth feedback
441
+ const { visualX, visualY } = (()=>{
442
+ if (isBeingDragged) {
443
+ // Apply drag offset to the dragged point
444
+ return {
445
+ visualX: relativeX + dragOffset.x,
446
+ visualY: relativeY + dragOffset.y
447
+ };
448
+ } else if (isDraggingPoint && isClosedPath && points.length > 2) {
449
+ // Apply sync offset to the opposite point in closed paths
450
+ const isFirstPoint = index === 0;
451
+ const isLastPoint = index === points.length - 1;
452
+ const draggedIsFirst = dragPointIndex === 0;
453
+ const draggedIsLast = dragPointIndex === points.length - 1;
454
+ if (draggedIsFirst && isLastPoint || draggedIsLast && isFirstPoint) {
455
+ return {
456
+ visualX: relativeX + dragSyncOffset.x,
457
+ visualY: relativeY + dragSyncOffset.y
458
+ };
459
+ }
460
+ }
461
+ return {
462
+ visualX: relativeX,
463
+ visualY: relativeY
464
+ };
465
+ })();
466
+ return /*#__PURE__*/ jsxRuntime.jsx("div", {
467
+ className: "nodrag nopan",
468
+ style: {
469
+ position: 'absolute',
470
+ left: `${visualX - 6}px`,
471
+ top: `${visualY - 6}px`,
472
+ width: '12px',
473
+ height: '12px',
474
+ borderRadius: '50%',
475
+ background: displayColor,
476
+ border: '2px solid white',
477
+ cursor: isDraggingPoint ? 'grabbing' : 'grab',
478
+ zIndex: 1001,
479
+ pointerEvents: 'auto',
480
+ boxShadow: isBeingDragged ? '0 4px 8px rgba(0,0,0,0.4)' : '0 2px 4px rgba(0,0,0,0.3)',
481
+ transform: isBeingDragged ? 'scale(1.3)' : 'scale(1)',
482
+ transition: isDraggingPoint ? 'none' : 'all 0.2s ease',
483
+ opacity: isBeingDragged ? 0.8 : 1
484
+ },
485
+ onMouseDown: (e)=>{
486
+ // React Flow best practice: use nodrag class and proper event handling
487
+ e.stopPropagation();
488
+ handlePointMouseDown(index, e);
489
+ },
490
+ title: `Point ${index + 1}`
491
+ }, `point-${index}`);
492
+ })
493
+ }),
494
+ /*#__PURE__*/ jsxRuntime.jsx("div", {
495
+ style: {
496
+ position: 'absolute',
497
+ top: '50%',
498
+ left: '50%',
499
+ transform: 'translate(-50%, -50%)',
500
+ display: 'flex',
501
+ alignItems: 'center',
502
+ justifyContent: 'center',
503
+ color: 'white',
504
+ fontSize: '12px',
505
+ fontWeight: 'bold',
506
+ textShadow: '1px 1px 2px rgba(0,0,0,0.8)',
507
+ pointerEvents: isEditing ? 'auto' : 'none',
508
+ width: '90%',
509
+ textAlign: 'center'
510
+ },
511
+ children: isEditing ? /*#__PURE__*/ jsxRuntime.jsx("input", {
512
+ ref: inputRef,
513
+ type: "text",
514
+ value: editingText,
515
+ onChange: (e)=>setEditingText(e.target.value),
516
+ onKeyDown: handleKeyDown,
517
+ onBlur: handleBlur,
518
+ className: "nodrag",
519
+ style: {
520
+ background: 'transparent',
521
+ border: 'none',
522
+ outline: 'none',
523
+ color: 'white',
524
+ fontSize: '12px',
525
+ fontWeight: 'bold',
526
+ textAlign: 'center',
527
+ width: '90%',
528
+ textShadow: '1px 1px 2px rgba(0,0,0,0.5)'
529
+ },
530
+ onClick: (e)=>e.stopPropagation()
531
+ }) : /*#__PURE__*/ jsxRuntime.jsx("span", {
532
+ style: {
533
+ cursor: 'default'
534
+ },
535
+ children: label
536
+ })
537
+ })
538
+ ]
539
+ }),
540
+ viewMode === typings.ViewMode.EDIT && /*#__PURE__*/ jsxRuntime.jsx(contextMenu, {
541
+ visible: contextMenu$1.visible,
542
+ x: contextMenu$1.x,
543
+ y: contextMenu$1.y,
544
+ onClose: handleCloseContextMenu,
545
+ onCopyPaste: handleCopyPaste,
546
+ onDelete: handleDelete,
547
+ arrangeActions: arrangeActions,
548
+ arrangeStates: arrangeStates
549
+ })
550
+ ]
551
+ });
552
+ };
553
+
554
+ module.exports = PathNode;
@@ -0,0 +1,19 @@
1
+ import { FC } from 'react';
2
+ import { NodeProps } from '@xyflow/react';
3
+ import { EditMode, ViewMode } from '../../typings.cjs';
4
+ interface PathNodeProps extends NodeProps {
5
+ editMode: EditMode;
6
+ viewMode: ViewMode;
7
+ onTextEditComplete?: (id: string, oldText: string, newText: string) => void;
8
+ onPathPointsChange?: (id: string, oldPoints: {
9
+ x: number;
10
+ y: number;
11
+ }[], newPoints: {
12
+ x: number;
13
+ y: number;
14
+ }[]) => void;
15
+ onPathPointDragStateChange?: (id: string, isDragging: boolean) => void;
16
+ isHovered?: boolean;
17
+ }
18
+ declare const PathNode: FC<PathNodeProps>;
19
+ export default PathNode;
@@ -1,6 +1,6 @@
1
1
  import { FC } from 'react';
2
2
  import { NodeProps } from '@xyflow/react';
3
- import { EditMode, ViewMode } from '../../typings';
3
+ import { EditMode, ViewMode } from '../../typings.js';
4
4
  interface PathNodeProps extends NodeProps {
5
5
  editMode: EditMode;
6
6
  viewMode: ViewMode;
@@ -3,16 +3,17 @@ import { jsxs, jsx } from 'react/jsx-runtime';
3
3
  import { useState, useRef, useCallback } from 'react';
4
4
  import { useReactFlow } from '@xyflow/react';
5
5
  import { ViewMode, EditMode } from '../../typings.js';
6
- import { DEFAULT_PATH_LABEL, DEFAULT_RECTANGLE_COLOR, ACTIVE_OPACITY, RECTANGLE_INACTIVE_OPACITY } from '../../constants/index.js';
6
+ import { DEFAULT_RECTANGLE_COLOR, DEFAULT_PATH_LABEL, ACTIVE_OPACITY, RECTANGLE_INACTIVE_OPACITY } from '../../constants/index.js';
7
7
  import { useContextMenu } from '../../hooks/use-context-menu.js';
8
8
  import { useTextEditing } from '../../hooks/use-text-editing.js';
9
9
  import { createPathCopy } from '../../utils/node-operations.js';
10
10
  import { createHoverColor } from '../../utils/color-utils.js';
11
+ import { PREVIEW_DIMMED_OPACITY, PREVIEW_HIGHLIGHT_STROKE_WIDTH } from '../../utils/preview-highlight.js';
11
12
  import ContextMenu from '../ui/context-menu.js';
12
13
  import styles from './path-node.module.scss.js';
13
14
 
14
15
  const PathNode = ({ data, selected, id, editMode, viewMode, onTextEditComplete, onPathPointsChange, onPathPointDragStateChange, isHovered = false })=>{
15
- const { points = [], color = DEFAULT_RECTANGLE_COLOR, strokeWidth = 2, label = DEFAULT_PATH_LABEL } = data;
16
+ const { points = [], color = DEFAULT_RECTANGLE_COLOR, strokeWidth = 2, label = DEFAULT_PATH_LABEL, previewHighlighted = false, previewDimmed = false } = data;
16
17
  // Get React Flow instance for viewport and node operations
17
18
  const { setNodes, getNodes, getViewport } = useReactFlow();
18
19
  // Dragging state - optimized for performance
@@ -392,7 +393,7 @@ const PathNode = ({ data, selected, id, editMode, viewMode, onTextEditComplete,
392
393
  style: {
393
394
  width: `${width}px`,
394
395
  height: `${height}px`,
395
- opacity: opacity,
396
+ opacity: previewDimmed ? PREVIEW_DIMMED_OPACITY : opacity,
396
397
  border: selected && isEditable ? '2px solid #3b82f6' : 'none',
397
398
  borderRadius: '4px',
398
399
  position: 'relative',
@@ -411,9 +412,9 @@ const PathNode = ({ data, selected, id, editMode, viewMode, onTextEditComplete,
411
412
  children: /*#__PURE__*/ jsx("path", {
412
413
  d: pathString,
413
414
  stroke: displayColor,
414
- strokeWidth: strokeWidth,
415
+ strokeWidth: previewHighlighted ? Math.max(strokeWidth, PREVIEW_HIGHLIGHT_STROKE_WIDTH) : strokeWidth,
415
416
  fill: isClosedPath ? displayColor : 'none',
416
- fillOpacity: isClosedPath ? 0.2 : 0,
417
+ fillOpacity: isClosedPath ? previewHighlighted ? 0.45 : 0.2 : 0,
417
418
  strokeLinecap: "round",
418
419
  strokeLinejoin: "round"
419
420
  })
@@ -0,0 +1,5 @@
1
+ 'use strict';
2
+
3
+ var styles = {"pathNode":"path-node-module_pathNode__i--rx","selected":"path-node-module_selected__YUYXs","nonSelectable":"path-node-module_nonSelectable__YkOT9","pathContainer":"path-node-module_pathContainer__UPL49"};
4
+
5
+ module.exports = styles;