@rytass/wms-map-react-components 0.1.9 → 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.
- package/components/breadcrumb/breadcrumb-edit-modal.cjs +92 -0
- package/components/breadcrumb/breadcrumb-edit-modal.d.cts +9 -0
- package/components/breadcrumb/breadcrumb-edit-modal.js +1 -0
- package/components/breadcrumb/breadcrumb-edit-modal.module.scss.cjs +5 -0
- package/components/breadcrumb/breadcrumb.cjs +171 -0
- package/components/breadcrumb/breadcrumb.d.cts +11 -0
- package/components/breadcrumb/breadcrumb.d.ts +1 -1
- package/components/breadcrumb/breadcrumb.js +1 -0
- package/components/breadcrumb/breadcrumb.module.scss.cjs +5 -0
- package/components/canvas/react-flow-canvas.cjs +321 -0
- package/components/canvas/react-flow-canvas.d.cts +38 -0
- package/components/canvas/react-flow-canvas.d.ts +1 -1
- package/components/canvas/react-flow-canvas.js +1 -0
- package/components/canvas/react-flow-canvas.module.scss.cjs +5 -0
- package/components/modal/wms-map-content.cjs +808 -0
- package/components/modal/wms-map-content.d.cts +4 -0
- package/components/modal/wms-map-content.d.ts +1 -1
- package/components/modal/wms-map-content.js +1 -0
- package/components/modal/wms-map-modal-container.cjs +130 -0
- package/components/modal/wms-map-modal-container.d.cts +5 -0
- package/components/modal/wms-map-modal-container.d.ts +1 -1
- package/components/modal/wms-map-modal-container.js +1 -0
- package/components/modal/wms-map-modal-container.module.scss.cjs +5 -0
- package/components/nodes/base-node.d.cts +12 -0
- package/components/nodes/base-node.d.ts +1 -1
- package/components/nodes/image-node.cjs +236 -0
- package/components/nodes/image-node.d.cts +17 -0
- package/components/nodes/image-node.d.ts +1 -1
- package/components/nodes/image-node.js +1 -0
- package/components/nodes/image-node.module.scss.cjs +5 -0
- package/components/nodes/path-node.cjs +553 -0
- package/components/nodes/path-node.d.cts +19 -0
- package/components/nodes/path-node.d.ts +1 -1
- package/components/nodes/path-node.js +1 -0
- package/components/nodes/path-node.module.scss.cjs +5 -0
- package/components/nodes/rectangle-node.cjs +239 -0
- package/components/nodes/rectangle-node.d.cts +11 -0
- package/components/nodes/rectangle-node.d.ts +1 -1
- package/components/nodes/rectangle-node.js +1 -0
- package/components/nodes/rectangle-node.module.scss.cjs +5 -0
- package/components/ui/context-menu.cjs +171 -0
- package/components/ui/context-menu.d.cts +25 -0
- package/components/ui/context-menu.js +1 -0
- package/components/ui/context-menu.module.scss.cjs +5 -0
- package/components/ui/toolbar.cjs +286 -0
- package/components/ui/toolbar.d.cts +23 -0
- package/components/ui/toolbar.d.ts +1 -1
- package/components/ui/toolbar.js +1 -0
- package/components/ui/toolbar.module.scss.cjs +5 -0
- package/components/ui/view-mode-toolbar.cjs +44 -0
- package/components/ui/view-mode-toolbar.d.cts +9 -0
- package/components/ui/view-mode-toolbar.d.ts +1 -1
- package/components/ui/view-mode-toolbar.js +1 -0
- package/components/ui/view-mode-toolbar.module.scss.cjs +5 -0
- package/constants/index.cjs +54 -0
- package/constants/index.d.cts +45 -0
- package/constants/index.d.ts +2 -2
- package/constants/text-mappings.cjs +46 -0
- package/constants/text-mappings.d.cts +181 -0
- package/hooks/use-context-menu.cjs +231 -0
- package/hooks/use-context-menu.d.cts +37 -0
- package/hooks/use-context-menu.d.ts +1 -1
- package/hooks/use-context-menu.js +1 -0
- package/hooks/use-direct-state-history.cjs +217 -0
- package/hooks/use-direct-state-history.d.cts +58 -0
- package/hooks/use-direct-state-history.d.ts +2 -2
- package/hooks/use-direct-state-history.js +1 -0
- package/hooks/use-pen-drawing.cjs +366 -0
- package/hooks/use-pen-drawing.d.cts +30 -0
- package/hooks/use-pen-drawing.d.ts +1 -1
- package/hooks/use-pen-drawing.js +1 -0
- package/hooks/use-rectangle-drawing.cjs +139 -0
- package/hooks/use-rectangle-drawing.d.cts +19 -0
- package/hooks/use-rectangle-drawing.d.ts +1 -1
- package/hooks/use-rectangle-drawing.js +1 -0
- package/hooks/use-text-editing.cjs +156 -0
- package/hooks/use-text-editing.d.cts +19 -0
- package/hooks/use-text-editing.js +1 -0
- package/icons/index.cjs +233 -0
- package/icons/index.d.cts +16 -0
- package/index.cjs +26 -0
- package/index.d.cts +5 -0
- package/index.d.ts +5 -5
- package/package.json +68 -3
- package/types/callback.types.d.cts +7 -0
- package/types/callback.types.d.ts +1 -1
- package/types/canvas.types.d.cts +35 -0
- package/types/canvas.types.d.ts +1 -1
- package/types/component-props.types.d.cts +45 -0
- package/types/component-props.types.d.ts +2 -2
- package/types/history.types.d.cts +24 -0
- package/types/history.types.d.ts +2 -2
- package/types/index.d.cts +5 -0
- package/types/index.d.ts +5 -5
- package/types/react-flow.types.d.cts +30 -0
- package/typings.cjs +44 -0
- package/typings.d.cts +136 -0
- package/utils/api-data-transform.cjs +221 -0
- package/utils/api-data-transform.d.cts +33 -0
- package/utils/api-data-transform.d.ts +1 -1
- package/utils/color-utils.cjs +58 -0
- package/utils/color-utils.d.cts +17 -0
- package/utils/debug-logger.cjs +45 -0
- package/utils/debug-logger.d.cts +33 -0
- package/utils/map-data-transform.cjs +360 -0
- package/utils/map-data-transform.d.cts +18 -0
- package/utils/map-data-transform.d.ts +1 -1
- package/utils/node-operations.cjs +88 -0
- package/utils/node-operations.d.cts +26 -0
- package/utils/node-utils.cjs +40 -0
- package/utils/node-utils.d.cts +10 -0
- package/index.cjs.css +0 -1
- package/index.cjs.js +0 -5128
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var React = require('react');
|
|
5
|
+
var react = require('@xyflow/react');
|
|
6
|
+
|
|
7
|
+
const useTextEditing = ({ id, label, isEditable, onTextEditComplete })=>{
|
|
8
|
+
const { setNodes } = react.useReactFlow();
|
|
9
|
+
const updateNodeInternals = react.useUpdateNodeInternals();
|
|
10
|
+
const inputRef = React.useRef(null);
|
|
11
|
+
const [isEditing, setIsEditing] = React.useState(false);
|
|
12
|
+
const [editingText, setEditingText] = React.useState(label);
|
|
13
|
+
// Sync state with node data changes
|
|
14
|
+
React.useEffect(()=>{
|
|
15
|
+
if (!isEditing) {
|
|
16
|
+
setEditingText(label);
|
|
17
|
+
}
|
|
18
|
+
}, [
|
|
19
|
+
label,
|
|
20
|
+
isEditing
|
|
21
|
+
]);
|
|
22
|
+
const updateNodeData = React.useCallback((updates)=>{
|
|
23
|
+
console.log('📝 updateNodeData 調用 (會觸發 React Flow 資料變更):', {
|
|
24
|
+
id,
|
|
25
|
+
updates
|
|
26
|
+
});
|
|
27
|
+
setNodes((nodes)=>nodes.map((node)=>node.id === id ? {
|
|
28
|
+
...node,
|
|
29
|
+
data: {
|
|
30
|
+
...node.data,
|
|
31
|
+
...updates
|
|
32
|
+
}
|
|
33
|
+
} : node));
|
|
34
|
+
updateNodeInternals(id);
|
|
35
|
+
}, [
|
|
36
|
+
id,
|
|
37
|
+
setNodes,
|
|
38
|
+
updateNodeInternals
|
|
39
|
+
]);
|
|
40
|
+
// Handle double click to start editing
|
|
41
|
+
const handleDoubleClick = React.useCallback((event)=>{
|
|
42
|
+
event.stopPropagation();
|
|
43
|
+
if (isEditable) {
|
|
44
|
+
setIsEditing(true);
|
|
45
|
+
setEditingText(label);
|
|
46
|
+
}
|
|
47
|
+
}, [
|
|
48
|
+
isEditable,
|
|
49
|
+
label
|
|
50
|
+
]);
|
|
51
|
+
// Handle saving the edited text
|
|
52
|
+
const handleSaveText = React.useCallback(()=>{
|
|
53
|
+
// 只有在文字真的有變更時才進行更新
|
|
54
|
+
if (label === editingText) {
|
|
55
|
+
setIsEditing(false);
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
const oldText = label;
|
|
59
|
+
const newText = editingText;
|
|
60
|
+
console.log('💾 保存文字編輯 (手動觸發歷史記錄):', {
|
|
61
|
+
id,
|
|
62
|
+
oldText,
|
|
63
|
+
newText
|
|
64
|
+
});
|
|
65
|
+
setIsEditing(false);
|
|
66
|
+
updateNodeData({
|
|
67
|
+
label: editingText
|
|
68
|
+
});
|
|
69
|
+
// 通知父組件文字編輯完成(這會觸發歷史記錄)
|
|
70
|
+
if (onTextEditComplete) {
|
|
71
|
+
// 延遲執行以確保 updateNodeData 完成
|
|
72
|
+
setTimeout(()=>{
|
|
73
|
+
onTextEditComplete(id, oldText, newText);
|
|
74
|
+
}, 10);
|
|
75
|
+
}
|
|
76
|
+
}, [
|
|
77
|
+
editingText,
|
|
78
|
+
updateNodeData,
|
|
79
|
+
id,
|
|
80
|
+
label,
|
|
81
|
+
onTextEditComplete
|
|
82
|
+
]);
|
|
83
|
+
// Handle input key events
|
|
84
|
+
const handleKeyDown = React.useCallback((event)=>{
|
|
85
|
+
if (event.key === 'Enter') {
|
|
86
|
+
handleSaveText();
|
|
87
|
+
} else if (event.key === 'Escape') {
|
|
88
|
+
setIsEditing(false);
|
|
89
|
+
setEditingText(label);
|
|
90
|
+
}
|
|
91
|
+
}, [
|
|
92
|
+
handleSaveText,
|
|
93
|
+
label
|
|
94
|
+
]);
|
|
95
|
+
// Auto-focus input when editing starts
|
|
96
|
+
React.useEffect(()=>{
|
|
97
|
+
if (isEditing && inputRef.current) {
|
|
98
|
+
inputRef.current.focus();
|
|
99
|
+
inputRef.current.select();
|
|
100
|
+
}
|
|
101
|
+
}, [
|
|
102
|
+
isEditing
|
|
103
|
+
]);
|
|
104
|
+
// Handle clicking outside to save
|
|
105
|
+
React.useEffect(()=>{
|
|
106
|
+
const handleClickOutside = (event)=>{
|
|
107
|
+
if (isEditing && inputRef.current) {
|
|
108
|
+
const target = event.target;
|
|
109
|
+
// 檢查點擊是否在 input 元素外部
|
|
110
|
+
if (!inputRef.current.contains(target)) {
|
|
111
|
+
console.log('🖱️ 點擊外部區域,保存文字編輯:', {
|
|
112
|
+
id,
|
|
113
|
+
editingText
|
|
114
|
+
});
|
|
115
|
+
handleSaveText();
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
if (isEditing) {
|
|
120
|
+
// 使用 'click' 事件而不是 'mousedown' 以確保更好的兼容性
|
|
121
|
+
document.addEventListener('click', handleClickOutside, true);
|
|
122
|
+
return ()=>{
|
|
123
|
+
document.removeEventListener('click', handleClickOutside, true);
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
}, [
|
|
127
|
+
isEditing,
|
|
128
|
+
handleSaveText,
|
|
129
|
+
id,
|
|
130
|
+
editingText
|
|
131
|
+
]);
|
|
132
|
+
// Handle input blur event (when input loses focus)
|
|
133
|
+
const handleBlur = React.useCallback(()=>{
|
|
134
|
+
console.log('🔄 Input blur 事件,保存文字編輯:', {
|
|
135
|
+
id,
|
|
136
|
+
editingText
|
|
137
|
+
});
|
|
138
|
+
handleSaveText();
|
|
139
|
+
}, [
|
|
140
|
+
handleSaveText,
|
|
141
|
+
id,
|
|
142
|
+
editingText
|
|
143
|
+
]);
|
|
144
|
+
return {
|
|
145
|
+
isEditing,
|
|
146
|
+
editingText,
|
|
147
|
+
inputRef,
|
|
148
|
+
setEditingText,
|
|
149
|
+
handleDoubleClick,
|
|
150
|
+
handleKeyDown,
|
|
151
|
+
handleBlur,
|
|
152
|
+
updateNodeData
|
|
153
|
+
};
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
exports.useTextEditing = useTextEditing;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface UseTextEditingProps {
|
|
3
|
+
id: string;
|
|
4
|
+
label: string;
|
|
5
|
+
isEditable: boolean;
|
|
6
|
+
onTextEditComplete?: (id: string, oldText: string, newText: string) => void;
|
|
7
|
+
}
|
|
8
|
+
interface UseTextEditingReturn {
|
|
9
|
+
isEditing: boolean;
|
|
10
|
+
editingText: string;
|
|
11
|
+
inputRef: React.RefObject<HTMLInputElement | null>;
|
|
12
|
+
setEditingText: React.Dispatch<React.SetStateAction<string>>;
|
|
13
|
+
handleDoubleClick: (event: React.MouseEvent) => void;
|
|
14
|
+
handleKeyDown: (event: React.KeyboardEvent) => void;
|
|
15
|
+
handleBlur: () => void;
|
|
16
|
+
updateNodeData: (updates: Record<string, unknown>) => void;
|
|
17
|
+
}
|
|
18
|
+
export declare const useTextEditing: ({ id, label, isEditable, onTextEditComplete, }: UseTextEditingProps) => UseTextEditingReturn;
|
|
19
|
+
export {};
|
package/icons/index.cjs
ADDED
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
require('react');
|
|
5
|
+
|
|
6
|
+
const PenToolIcon = ({ width = 24, height = 24, className, color = '#8F8F8F' })=>/*#__PURE__*/ jsxRuntime.jsxs("svg", {
|
|
7
|
+
width: width,
|
|
8
|
+
height: height,
|
|
9
|
+
viewBox: "0 0 24 24",
|
|
10
|
+
fill: "none",
|
|
11
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
12
|
+
className: className,
|
|
13
|
+
children: [
|
|
14
|
+
/*#__PURE__*/ jsxRuntime.jsx("path", {
|
|
15
|
+
d: "M17.0707 12.9861L15.034 6.66338L4 4M4 4L6.66338 15.034L12.9861 17.0707M4 4L10.1971 10.1971M12.9861 11.3523C12.9861 12.2546 12.2546 12.9861 11.3523 12.9861C10.4499 12.9861 9.71843 12.2546 9.71843 11.3523C9.71843 10.4499 10.4499 9.71843 11.3523 9.71843C12.2546 9.71843 12.9861 10.4499 12.9861 11.3523Z",
|
|
16
|
+
stroke: color,
|
|
17
|
+
strokeWidth: "1.4",
|
|
18
|
+
strokeLinecap: "round"
|
|
19
|
+
}),
|
|
20
|
+
/*#__PURE__*/ jsxRuntime.jsx("rect", {
|
|
21
|
+
x: "12.6872",
|
|
22
|
+
y: "17.3848",
|
|
23
|
+
width: "6.6425",
|
|
24
|
+
height: "3.40799",
|
|
25
|
+
transform: "rotate(-45 12.6872 17.3848)",
|
|
26
|
+
stroke: color,
|
|
27
|
+
strokeWidth: "1.4"
|
|
28
|
+
})
|
|
29
|
+
]
|
|
30
|
+
});
|
|
31
|
+
const DeleteIcon = ({ width = 24, height = 24, className, color = '#8F8F8F' })=>/*#__PURE__*/ jsxRuntime.jsxs("svg", {
|
|
32
|
+
width: width,
|
|
33
|
+
height: height,
|
|
34
|
+
viewBox: "0 0 24 24",
|
|
35
|
+
fill: "none",
|
|
36
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
37
|
+
className: className,
|
|
38
|
+
children: [
|
|
39
|
+
/*#__PURE__*/ jsxRuntime.jsx("path", {
|
|
40
|
+
d: "M3 6H5H21",
|
|
41
|
+
stroke: color,
|
|
42
|
+
strokeWidth: "2",
|
|
43
|
+
strokeLinecap: "round",
|
|
44
|
+
strokeLinejoin: "round"
|
|
45
|
+
}),
|
|
46
|
+
/*#__PURE__*/ jsxRuntime.jsx("path", {
|
|
47
|
+
d: "M8 6V4C8 3.46957 8.21071 2.96086 8.58579 2.58579C8.96086 2.21071 9.46957 2 10 2H14C14.5304 2 15.0391 2.21071 15.4142 2.58579C15.7893 2.96086 16 3.46957 16 4V6M19 6V20C19 20.5304 18.7893 21.0391 18.4142 21.4142C18.0391 21.7893 17.5304 22 17 22H7C6.46957 22 5.96086 21.7893 5.58579 21.4142C5.21071 21.0391 5 20.5304 5 20V6H19Z",
|
|
48
|
+
stroke: color,
|
|
49
|
+
strokeWidth: "2",
|
|
50
|
+
strokeLinecap: "round",
|
|
51
|
+
strokeLinejoin: "round"
|
|
52
|
+
})
|
|
53
|
+
]
|
|
54
|
+
});
|
|
55
|
+
const ImageIcon = ({ width = 24, height = 24, className, color = '#8F8F8F' })=>/*#__PURE__*/ jsxRuntime.jsxs("svg", {
|
|
56
|
+
width: width,
|
|
57
|
+
height: height,
|
|
58
|
+
viewBox: "0 0 24 24",
|
|
59
|
+
fill: "none",
|
|
60
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
61
|
+
className: className,
|
|
62
|
+
children: [
|
|
63
|
+
/*#__PURE__*/ jsxRuntime.jsx("rect", {
|
|
64
|
+
x: "3",
|
|
65
|
+
y: "3",
|
|
66
|
+
width: "18",
|
|
67
|
+
height: "18",
|
|
68
|
+
rx: "2",
|
|
69
|
+
ry: "2",
|
|
70
|
+
stroke: color,
|
|
71
|
+
strokeWidth: "2"
|
|
72
|
+
}),
|
|
73
|
+
/*#__PURE__*/ jsxRuntime.jsx("circle", {
|
|
74
|
+
cx: "8.5",
|
|
75
|
+
cy: "8.5",
|
|
76
|
+
r: "1.5",
|
|
77
|
+
stroke: color,
|
|
78
|
+
strokeWidth: "2"
|
|
79
|
+
}),
|
|
80
|
+
/*#__PURE__*/ jsxRuntime.jsx("path", {
|
|
81
|
+
d: "M21 15L16 10L5 21",
|
|
82
|
+
stroke: color,
|
|
83
|
+
strokeWidth: "2",
|
|
84
|
+
strokeLinecap: "round",
|
|
85
|
+
strokeLinejoin: "round"
|
|
86
|
+
})
|
|
87
|
+
]
|
|
88
|
+
});
|
|
89
|
+
const SquareIcon = ({ width = 24, height = 24, className, color = '#8F8F8F' })=>/*#__PURE__*/ jsxRuntime.jsx("svg", {
|
|
90
|
+
width: width,
|
|
91
|
+
height: height,
|
|
92
|
+
viewBox: "0 0 24 24",
|
|
93
|
+
fill: "none",
|
|
94
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
95
|
+
className: className,
|
|
96
|
+
children: /*#__PURE__*/ jsxRuntime.jsx("rect", {
|
|
97
|
+
x: "3",
|
|
98
|
+
y: "3",
|
|
99
|
+
width: "18",
|
|
100
|
+
height: "18",
|
|
101
|
+
rx: "2",
|
|
102
|
+
ry: "2",
|
|
103
|
+
stroke: color,
|
|
104
|
+
strokeWidth: "2"
|
|
105
|
+
})
|
|
106
|
+
});
|
|
107
|
+
const PointerIcon = ({ width = 24, height = 24, className, color = '#8F8F8F' })=>/*#__PURE__*/ jsxRuntime.jsxs("svg", {
|
|
108
|
+
width: width,
|
|
109
|
+
height: height,
|
|
110
|
+
viewBox: "0 0 24 24",
|
|
111
|
+
fill: "none",
|
|
112
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
113
|
+
className: className,
|
|
114
|
+
children: [
|
|
115
|
+
/*#__PURE__*/ jsxRuntime.jsx("mask", {
|
|
116
|
+
id: "path-1-inside-1_pointer",
|
|
117
|
+
fill: "white",
|
|
118
|
+
children: /*#__PURE__*/ jsxRuntime.jsx("path", {
|
|
119
|
+
d: "M5.02328 5.74789C4.89692 5.30564 5.30564 4.89692 5.74789 5.02328L18.1502 8.56625C18.6081 8.69707 18.7272 9.29026 18.3553 9.58774L16.0164 12.1551L20.8114 16.9491L16.9491 20.8114L12.1551 16.0164L9.58774 18.3553C9.29026 18.7272 8.69707 18.6081 8.56625 18.1502L5.02328 5.74789Z"
|
|
120
|
+
})
|
|
121
|
+
}),
|
|
122
|
+
/*#__PURE__*/ jsxRuntime.jsx("path", {
|
|
123
|
+
d: "M5.02328 5.74789L6.36943 5.36334L6.36942 5.36328L5.02328 5.74789ZM5.74789 5.02328L5.36328 6.36942L5.36334 6.36943L5.74789 5.02328ZM18.1502 8.56625L18.5348 7.22012L18.5348 7.2201L18.1502 8.56625ZM18.3553 9.58774L17.4807 8.49452L17.3946 8.5634L17.3204 8.64492L18.3553 9.58774ZM16.0164 12.1551L14.9815 11.2123L14.0815 12.2003L15.0266 13.1452L16.0164 12.1551ZM20.8114 16.9491L21.8013 17.939L22.7914 16.949L21.8012 15.959L20.8114 16.9491ZM16.9491 20.8114L15.959 21.8012L16.949 22.7914L17.939 21.8013L16.9491 20.8114ZM12.1551 16.0164L13.1452 15.0266L12.2003 14.0815L11.2123 14.9815L12.1551 16.0164ZM9.58774 18.3553L8.64492 17.3204L8.5634 17.3946L8.49452 17.4807L9.58774 18.3553ZM8.56625 18.1502L7.2201 18.5348L7.22012 18.5348L8.56625 18.1502ZM5.02328 5.74789L6.36942 5.36328C6.5448 5.97712 5.97712 6.5448 5.36328 6.36942L5.74789 5.02328L6.1325 3.67715C4.63415 3.24905 3.24905 4.63415 3.67715 6.1325L5.02328 5.74789ZM5.74789 5.02328L5.36334 6.36943L17.7657 9.9124L18.1502 8.56625L18.5348 7.2201L6.13245 3.67713L5.74789 5.02328ZM18.1502 8.56625L17.7656 9.91238C17.1297 9.73069 16.965 8.90711 17.4807 8.49452L18.3553 9.58774L19.2299 10.681C20.4893 9.67341 20.0865 7.66346 18.5348 7.22012L18.1502 8.56625ZM18.3553 9.58774L17.3204 8.64492L14.9815 11.2123L16.0164 12.1551L17.0514 13.0979L19.3903 10.5306L18.3553 9.58774ZM16.0164 12.1551L15.0266 13.1452L19.8215 17.9391L20.8114 16.9491L21.8012 15.959L17.0063 11.1651L16.0164 12.1551ZM20.8114 16.9491L19.8214 15.9591L15.9591 19.8214L16.9491 20.8114L17.939 21.8013L21.8013 17.939L20.8114 16.9491ZM16.9491 20.8114L17.9391 19.8215L13.1452 15.0266L12.1551 16.0164L11.1651 17.0063L15.959 21.8012L16.9491 20.8114ZM12.1551 16.0164L11.2123 14.9815L8.64492 17.3204L9.58774 18.3553L10.5306 19.3903L13.0979 17.0514L12.1551 16.0164ZM9.58774 18.3553L8.49452 17.4807C8.90711 16.965 9.73069 17.1297 9.91238 17.7656L8.56625 18.1502L7.22012 18.5348C7.66346 20.0865 9.67341 20.4893 10.681 19.2299L9.58774 18.3553ZM8.56625 18.1502L9.9124 17.7657L6.36943 5.36334L5.02328 5.74789L3.67713 6.13245L7.2201 18.5348L8.56625 18.1502Z",
|
|
124
|
+
fill: color,
|
|
125
|
+
mask: "url(#path-1-inside-1_pointer)"
|
|
126
|
+
})
|
|
127
|
+
]
|
|
128
|
+
});
|
|
129
|
+
const RedoIcon = ({ width = 24, height = 24, className, color = '#8F8F8F' })=>/*#__PURE__*/ jsxRuntime.jsxs("svg", {
|
|
130
|
+
width: width,
|
|
131
|
+
height: height,
|
|
132
|
+
viewBox: "0 0 24 24",
|
|
133
|
+
fill: "none",
|
|
134
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
135
|
+
className: className,
|
|
136
|
+
children: [
|
|
137
|
+
/*#__PURE__*/ jsxRuntime.jsx("mask", {
|
|
138
|
+
id: "mask0_redo",
|
|
139
|
+
style: {
|
|
140
|
+
maskType: 'alpha'
|
|
141
|
+
},
|
|
142
|
+
maskUnits: "userSpaceOnUse",
|
|
143
|
+
x: "0",
|
|
144
|
+
y: "0",
|
|
145
|
+
width: "24",
|
|
146
|
+
height: "24",
|
|
147
|
+
children: /*#__PURE__*/ jsxRuntime.jsx("rect", {
|
|
148
|
+
width: "24",
|
|
149
|
+
height: "24",
|
|
150
|
+
fill: "#D9D9D9"
|
|
151
|
+
})
|
|
152
|
+
}),
|
|
153
|
+
/*#__PURE__*/ jsxRuntime.jsx("g", {
|
|
154
|
+
mask: "url(#mask0_redo)",
|
|
155
|
+
children: /*#__PURE__*/ jsxRuntime.jsx("path", {
|
|
156
|
+
d: "M9.32091 17.7C8.14141 17.7 7.14266 17.2686 6.32466 16.4058C5.50666 15.5429 5.09766 14.5122 5.09766 13.3135C5.09766 12.1148 5.50666 11.0857 6.32466 10.226C7.14266 9.36633 8.14141 8.9365 9.32091 8.9365H16.1919L13.6844 6.42875L14.6132 5.5L18.6997 9.5865L14.6132 13.673L13.6844 12.7442L16.1919 10.2365H9.32091C8.49391 10.2365 7.79999 10.5378 7.23916 11.1403C6.67816 11.7429 6.39766 12.4673 6.39766 13.3135C6.39766 14.1597 6.67816 14.8856 7.23916 15.4913C7.79999 16.0971 8.49391 16.4 9.32091 16.4H16.5977V17.7H9.32091Z",
|
|
157
|
+
fill: color
|
|
158
|
+
})
|
|
159
|
+
})
|
|
160
|
+
]
|
|
161
|
+
});
|
|
162
|
+
const UndoIcon = ({ width = 24, height = 24, className, color = '#8F8F8F' })=>/*#__PURE__*/ jsxRuntime.jsxs("svg", {
|
|
163
|
+
width: width,
|
|
164
|
+
height: height,
|
|
165
|
+
viewBox: "0 0 24 24",
|
|
166
|
+
fill: "none",
|
|
167
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
168
|
+
className: className,
|
|
169
|
+
children: [
|
|
170
|
+
/*#__PURE__*/ jsxRuntime.jsx("mask", {
|
|
171
|
+
id: "mask0_undo",
|
|
172
|
+
style: {
|
|
173
|
+
maskType: 'alpha'
|
|
174
|
+
},
|
|
175
|
+
maskUnits: "userSpaceOnUse",
|
|
176
|
+
x: "0",
|
|
177
|
+
y: "0",
|
|
178
|
+
width: "24",
|
|
179
|
+
height: "24",
|
|
180
|
+
children: /*#__PURE__*/ jsxRuntime.jsx("rect", {
|
|
181
|
+
width: "24",
|
|
182
|
+
height: "24",
|
|
183
|
+
fill: "#D9D9D9"
|
|
184
|
+
})
|
|
185
|
+
}),
|
|
186
|
+
/*#__PURE__*/ jsxRuntime.jsx("g", {
|
|
187
|
+
mask: "url(#mask0_undo)",
|
|
188
|
+
children: /*#__PURE__*/ jsxRuntime.jsx("path", {
|
|
189
|
+
d: "M7.4018 17.7V16.4H14.6786C15.5056 16.4 16.1995 16.0971 16.7603 15.4913C17.3213 14.8856 17.6018 14.1597 17.6018 13.3135C17.6018 12.4673 17.3213 11.7429 16.7603 11.1403C16.1995 10.5377 15.5056 10.2365 14.6786 10.2365H7.80755L10.3151 12.7442L9.3863 13.673L5.2998 9.5865L9.3863 5.5L10.3151 6.42875L7.80755 8.9365H14.6786C15.8581 8.9365 16.8568 9.36633 17.6748 10.226C18.4928 11.0857 18.9018 12.1148 18.9018 13.3135C18.9018 14.5122 18.4928 15.5429 17.6748 16.4058C16.8568 17.2686 15.8581 17.7 14.6786 17.7H7.4018Z",
|
|
190
|
+
fill: color
|
|
191
|
+
})
|
|
192
|
+
})
|
|
193
|
+
]
|
|
194
|
+
});
|
|
195
|
+
const CheckMarkIcon = ({ width = 24, height = 24, className, color = 'white' })=>/*#__PURE__*/ jsxRuntime.jsx("svg", {
|
|
196
|
+
width: width,
|
|
197
|
+
height: height,
|
|
198
|
+
viewBox: "0 0 24 24",
|
|
199
|
+
fill: "none",
|
|
200
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
201
|
+
className: className,
|
|
202
|
+
children: /*#__PURE__*/ jsxRuntime.jsx("path", {
|
|
203
|
+
fillRule: "evenodd",
|
|
204
|
+
clipRule: "evenodd",
|
|
205
|
+
d: "M16.9018 7.5L10.1083 14.301L7.09721 11.2896L6 12.3881L10.1073 16.5L18 8.59845L16.9018 7.5Z",
|
|
206
|
+
fill: color
|
|
207
|
+
})
|
|
208
|
+
});
|
|
209
|
+
const FolderIcon = ({ width = 24, height = 24, className, color = '#8F8F8F' })=>/*#__PURE__*/ jsxRuntime.jsx("svg", {
|
|
210
|
+
width: width,
|
|
211
|
+
height: height,
|
|
212
|
+
viewBox: "0 0 24 24",
|
|
213
|
+
fill: "none",
|
|
214
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
215
|
+
className: className,
|
|
216
|
+
children: /*#__PURE__*/ jsxRuntime.jsx("path", {
|
|
217
|
+
d: "M22 19C22 19.5304 21.7893 20.0391 21.4142 20.4142C21.0391 20.7893 20.5304 21 20 21H4C3.46957 21 2.96086 20.7893 2.58579 20.4142C2.21071 20.0391 2 19.5304 2 19V5C2 4.46957 2.21071 3.96086 2.58579 3.58579C2.96086 3.21071 3.46957 3 4 3H9L11 6H20C20.5304 6 21.0391 6.21071 21.4142 6.58579C21.7893 6.96086 22 7.46957 22 8V19Z",
|
|
218
|
+
stroke: color,
|
|
219
|
+
strokeWidth: "2",
|
|
220
|
+
strokeLinecap: "round",
|
|
221
|
+
strokeLinejoin: "round"
|
|
222
|
+
})
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
exports.CheckMarkIcon = CheckMarkIcon;
|
|
226
|
+
exports.DeleteIcon = DeleteIcon;
|
|
227
|
+
exports.FolderIcon = FolderIcon;
|
|
228
|
+
exports.ImageIcon = ImageIcon;
|
|
229
|
+
exports.PenToolIcon = PenToolIcon;
|
|
230
|
+
exports.PointerIcon = PointerIcon;
|
|
231
|
+
exports.RedoIcon = RedoIcon;
|
|
232
|
+
exports.SquareIcon = SquareIcon;
|
|
233
|
+
exports.UndoIcon = UndoIcon;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface IconProps {
|
|
3
|
+
width?: number;
|
|
4
|
+
height?: number;
|
|
5
|
+
className?: string;
|
|
6
|
+
color?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare const PenToolIcon: React.FC<IconProps>;
|
|
9
|
+
export declare const DeleteIcon: React.FC<IconProps>;
|
|
10
|
+
export declare const ImageIcon: React.FC<IconProps>;
|
|
11
|
+
export declare const SquareIcon: React.FC<IconProps>;
|
|
12
|
+
export declare const PointerIcon: React.FC<IconProps>;
|
|
13
|
+
export declare const RedoIcon: React.FC<IconProps>;
|
|
14
|
+
export declare const UndoIcon: React.FC<IconProps>;
|
|
15
|
+
export declare const CheckMarkIcon: React.FC<IconProps>;
|
|
16
|
+
export declare const FolderIcon: React.FC<IconProps>;
|
package/index.cjs
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var typings = require('./typings.cjs');
|
|
4
|
+
var wmsMapModalContainer = require('./components/modal/wms-map-modal-container.cjs');
|
|
5
|
+
var mapDataTransform = require('./utils/map-data-transform.cjs');
|
|
6
|
+
var apiDataTransform = require('./utils/api-data-transform.cjs');
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
exports.DrawingMode = typings.DrawingMode;
|
|
11
|
+
exports.EditMode = typings.EditMode;
|
|
12
|
+
exports.LayerDrawingTool = typings.LayerDrawingTool;
|
|
13
|
+
exports.MapRangeColor = typings.MapRangeColor;
|
|
14
|
+
exports.MapRangeType = typings.MapRangeType;
|
|
15
|
+
exports.ViewMode = typings.ViewMode;
|
|
16
|
+
exports.WMSMapModal = wmsMapModalContainer.default;
|
|
17
|
+
exports.WMSMapModalContent = wmsMapModalContainer.WMSMapModalContent;
|
|
18
|
+
exports.logMapData = mapDataTransform.logMapData;
|
|
19
|
+
exports.logNodeData = mapDataTransform.logNodeData;
|
|
20
|
+
exports.transformNodeToClickInfo = mapDataTransform.transformNodeToClickInfo;
|
|
21
|
+
exports.transformNodesToMapData = mapDataTransform.transformNodesToMapData;
|
|
22
|
+
exports.calculateNodeZIndex = apiDataTransform.calculateNodeZIndex;
|
|
23
|
+
exports.calculatePolygonBounds = apiDataTransform.calculatePolygonBounds;
|
|
24
|
+
exports.loadMapDataFromApi = apiDataTransform.loadMapDataFromApi;
|
|
25
|
+
exports.transformApiDataToNodes = apiDataTransform.transformApiDataToNodes;
|
|
26
|
+
exports.validateMapData = apiDataTransform.validateMapData;
|
package/index.d.cts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export * from './typings.cjs';
|
|
2
|
+
export * from './types/index.cjs';
|
|
3
|
+
export { WMSMapModalContent, default as WMSMapModal } from './components/modal/wms-map-modal-container.cjs';
|
|
4
|
+
export { transformNodeToClickInfo, transformNodesToMapData, logMapData, logNodeData } from './utils/map-data-transform.cjs';
|
|
5
|
+
export { transformApiDataToNodes, validateMapData, loadMapDataFromApi, calculatePolygonBounds, calculateNodeZIndex, } from './utils/api-data-transform.cjs';
|
package/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export * from './typings';
|
|
2
|
-
export * from './types';
|
|
3
|
-
export { WMSMapModalContent, default as WMSMapModal } from './components/modal/wms-map-modal-container';
|
|
4
|
-
export { transformNodeToClickInfo, transformNodesToMapData, logMapData, logNodeData } from './utils/map-data-transform';
|
|
5
|
-
export { transformApiDataToNodes, validateMapData, loadMapDataFromApi, calculatePolygonBounds, calculateNodeZIndex, } from './utils/api-data-transform';
|
|
1
|
+
export * from './typings.js';
|
|
2
|
+
export * from './types/index.js';
|
|
3
|
+
export { WMSMapModalContent, default as WMSMapModal } from './components/modal/wms-map-modal-container.js';
|
|
4
|
+
export { transformNodeToClickInfo, transformNodesToMapData, logMapData, logNodeData } from './utils/map-data-transform.js';
|
|
5
|
+
export { transformApiDataToNodes, validateMapData, loadMapDataFromApi, calculatePolygonBounds, calculateNodeZIndex, } from './utils/api-data-transform.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rytass/wms-map-react-components",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Rytass Warehouse Management System Map React Components",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"rytass",
|
|
@@ -32,7 +32,72 @@
|
|
|
32
32
|
"@storybook/react-vite": "^10.3.5",
|
|
33
33
|
"storybook": "^10.3.5"
|
|
34
34
|
},
|
|
35
|
-
"
|
|
35
|
+
"type": "module",
|
|
36
|
+
"main": "./index.cjs",
|
|
36
37
|
"module": "./index.js",
|
|
37
|
-
"
|
|
38
|
+
"types": "./index.d.ts",
|
|
39
|
+
"typings": "./index.d.ts",
|
|
40
|
+
"engines": {
|
|
41
|
+
"node": ">=20.19.0"
|
|
42
|
+
},
|
|
43
|
+
"exports": {
|
|
44
|
+
".": {
|
|
45
|
+
"import": {
|
|
46
|
+
"types": "./index.d.ts",
|
|
47
|
+
"default": "./index.js"
|
|
48
|
+
},
|
|
49
|
+
"require": {
|
|
50
|
+
"types": "./index.d.cts",
|
|
51
|
+
"default": "./index.cjs"
|
|
52
|
+
},
|
|
53
|
+
"default": "./index.js"
|
|
54
|
+
},
|
|
55
|
+
"./constants": {
|
|
56
|
+
"import": {
|
|
57
|
+
"types": "./constants/index.d.ts",
|
|
58
|
+
"default": "./constants/index.js"
|
|
59
|
+
},
|
|
60
|
+
"require": {
|
|
61
|
+
"types": "./constants/index.d.cts",
|
|
62
|
+
"default": "./constants/index.cjs"
|
|
63
|
+
},
|
|
64
|
+
"default": "./constants/index.js"
|
|
65
|
+
},
|
|
66
|
+
"./icons": {
|
|
67
|
+
"import": {
|
|
68
|
+
"types": "./icons/index.d.ts",
|
|
69
|
+
"default": "./icons/index.js"
|
|
70
|
+
},
|
|
71
|
+
"require": {
|
|
72
|
+
"types": "./icons/index.d.cts",
|
|
73
|
+
"default": "./icons/index.cjs"
|
|
74
|
+
},
|
|
75
|
+
"default": "./icons/index.js"
|
|
76
|
+
},
|
|
77
|
+
"./package.json": "./package.json",
|
|
78
|
+
"./*.css": "./*.css",
|
|
79
|
+
"./*.json": "./*.json",
|
|
80
|
+
"./*.js": {
|
|
81
|
+
"import": {
|
|
82
|
+
"types": "./*.d.ts",
|
|
83
|
+
"default": "./*.js"
|
|
84
|
+
},
|
|
85
|
+
"require": {
|
|
86
|
+
"types": "./*.d.cts",
|
|
87
|
+
"default": "./*.cjs"
|
|
88
|
+
},
|
|
89
|
+
"default": "./*.js"
|
|
90
|
+
},
|
|
91
|
+
"./*": {
|
|
92
|
+
"import": {
|
|
93
|
+
"types": "./*.d.ts",
|
|
94
|
+
"default": "./*.js"
|
|
95
|
+
},
|
|
96
|
+
"require": {
|
|
97
|
+
"types": "./*.d.cts",
|
|
98
|
+
"default": "./*.cjs"
|
|
99
|
+
},
|
|
100
|
+
"default": "./*.js"
|
|
101
|
+
}
|
|
102
|
+
}
|
|
38
103
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { FlowNode, FlowEdge } from './react-flow.types.cjs';
|
|
2
|
+
export interface NodesStateSetterCallback {
|
|
3
|
+
(updater: (currentNodes: FlowNode[]) => FlowNode[]): void;
|
|
4
|
+
}
|
|
5
|
+
export interface EdgesStateSetterCallback {
|
|
6
|
+
(updater: (currentEdges: FlowEdge[]) => FlowEdge[]): void;
|
|
7
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { FlowNode } from './react-flow.types.cjs';
|
|
2
|
+
export interface ImageNodeData {
|
|
3
|
+
imageUrl: string;
|
|
4
|
+
width: number;
|
|
5
|
+
height: number;
|
|
6
|
+
originalWidth: number;
|
|
7
|
+
originalHeight: number;
|
|
8
|
+
fileName: string;
|
|
9
|
+
}
|
|
10
|
+
export interface RectangleNodeData {
|
|
11
|
+
width: number;
|
|
12
|
+
height: number;
|
|
13
|
+
color: string;
|
|
14
|
+
label: string;
|
|
15
|
+
isResizing?: boolean;
|
|
16
|
+
}
|
|
17
|
+
export interface PathNodeData {
|
|
18
|
+
points: Array<{
|
|
19
|
+
x: number;
|
|
20
|
+
y: number;
|
|
21
|
+
}>;
|
|
22
|
+
color: string;
|
|
23
|
+
strokeWidth: number;
|
|
24
|
+
label: string;
|
|
25
|
+
}
|
|
26
|
+
export interface NodeCreationData {
|
|
27
|
+
currentNode: FlowNode;
|
|
28
|
+
nodeType: string;
|
|
29
|
+
data: ImageNodeData | RectangleNodeData | PathNodeData;
|
|
30
|
+
}
|
|
31
|
+
export interface CanvasViewport {
|
|
32
|
+
x: number;
|
|
33
|
+
y: number;
|
|
34
|
+
zoom: number;
|
|
35
|
+
}
|
package/types/canvas.types.d.ts
CHANGED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { ViewMode, WMSNodeClickInfo, Map, EditMode, DrawingMode } from '../typings.cjs';
|
|
2
|
+
import { FlowNode, FlowEdge } from './react-flow.types.cjs';
|
|
3
|
+
export interface WMSMapModalProps {
|
|
4
|
+
onClose: () => void;
|
|
5
|
+
open: boolean;
|
|
6
|
+
viewMode?: ViewMode;
|
|
7
|
+
colorPalette?: string[];
|
|
8
|
+
showBreadcrumbEditButton?: (warehouseIds: string[]) => boolean;
|
|
9
|
+
onNodeClick?: (nodeInfo: WMSNodeClickInfo) => void;
|
|
10
|
+
onNodeDoubleClick?: (nodeInfo: WMSNodeClickInfo) => void;
|
|
11
|
+
onSave?: (mapData: Map) => void;
|
|
12
|
+
onBreadcrumbClick?: (warehouseId: string, index: number) => void;
|
|
13
|
+
onNameChange?: (name: string) => Promise<void>;
|
|
14
|
+
initialNodes?: FlowNode[];
|
|
15
|
+
initialEdges?: FlowEdge[];
|
|
16
|
+
debugMode?: boolean;
|
|
17
|
+
title?: string;
|
|
18
|
+
onUpload: (files: File[]) => Promise<string[]>;
|
|
19
|
+
getFilenameFQDN?: (filename: string) => Promise<string> | string;
|
|
20
|
+
maxFileSizeKB?: number;
|
|
21
|
+
warehouseIds?: string[];
|
|
22
|
+
}
|
|
23
|
+
export interface WMSMapContentProps {
|
|
24
|
+
editMode: EditMode;
|
|
25
|
+
drawingMode: DrawingMode;
|
|
26
|
+
selectedColor: string;
|
|
27
|
+
viewMode: ViewMode;
|
|
28
|
+
colorPalette?: string[];
|
|
29
|
+
showBreadcrumbEditButton?: (warehouseIds: string[]) => boolean;
|
|
30
|
+
onEditModeChange: (mode: EditMode) => void;
|
|
31
|
+
onToggleRectangleTool: () => void;
|
|
32
|
+
onTogglePenTool: () => void;
|
|
33
|
+
onColorChange: (color: string) => void;
|
|
34
|
+
onNodeClick?: (nodeInfo: WMSNodeClickInfo) => void;
|
|
35
|
+
onNodeDoubleClick?: (nodeInfo: WMSNodeClickInfo) => void;
|
|
36
|
+
onSave?: (mapData: Map) => void;
|
|
37
|
+
onBreadcrumbClick?: (warehouseId: string, index: number) => void;
|
|
38
|
+
onNameChange?: (name: string) => Promise<void>;
|
|
39
|
+
initialNodes?: FlowNode[];
|
|
40
|
+
initialEdges?: FlowEdge[];
|
|
41
|
+
onUpload: (files: File[]) => Promise<string[]>;
|
|
42
|
+
getFilenameFQDN?: (filename: string) => Promise<string> | string;
|
|
43
|
+
maxFileSizeKB?: number;
|
|
44
|
+
warehouseIds?: string[];
|
|
45
|
+
}
|