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