@rytass/wms-map-react-components 0.1.1

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 (80) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +77 -0
  3. package/components/breadcrumb/breadcrumb-edit-modal.d.ts +9 -0
  4. package/components/breadcrumb/breadcrumb-edit-modal.js +92 -0
  5. package/components/breadcrumb/breadcrumb-edit-modal.module.scss.js +3 -0
  6. package/components/breadcrumb/breadcrumb.d.ts +8 -0
  7. package/components/breadcrumb/breadcrumb.js +167 -0
  8. package/components/breadcrumb/breadcrumb.module.scss.js +3 -0
  9. package/components/canvas/react-flow-canvas.d.ts +37 -0
  10. package/components/canvas/react-flow-canvas.js +317 -0
  11. package/components/canvas/react-flow-canvas.module.scss.js +3 -0
  12. package/components/modal/wms-map-content.d.ts +4 -0
  13. package/components/modal/wms-map-content.js +753 -0
  14. package/components/modal/wms-map-header.d.ts +6 -0
  15. package/components/modal/wms-map-header.js +19 -0
  16. package/components/modal/wms-map-header.module.scss.js +3 -0
  17. package/components/modal/wms-map-modal-container.d.ts +4 -0
  18. package/components/modal/wms-map-modal-container.js +95 -0
  19. package/components/modal/wms-map-modal-container.module.scss.js +3 -0
  20. package/components/nodes/base-node.d.ts +12 -0
  21. package/components/nodes/image-node.d.ts +17 -0
  22. package/components/nodes/image-node.js +233 -0
  23. package/components/nodes/image-node.module.scss.js +3 -0
  24. package/components/nodes/path-node.d.ts +19 -0
  25. package/components/nodes/path-node.js +550 -0
  26. package/components/nodes/path-node.module.scss.js +3 -0
  27. package/components/nodes/rectangle-node.d.ts +11 -0
  28. package/components/nodes/rectangle-node.js +236 -0
  29. package/components/nodes/rectangle-node.module.scss.js +3 -0
  30. package/components/ui/context-menu.d.ts +25 -0
  31. package/components/ui/context-menu.js +168 -0
  32. package/components/ui/context-menu.module.scss.js +3 -0
  33. package/components/ui/toolbar.d.ts +23 -0
  34. package/components/ui/toolbar.js +278 -0
  35. package/components/ui/toolbar.module.scss.js +3 -0
  36. package/components/ui/view-mode-toolbar.d.ts +9 -0
  37. package/components/ui/view-mode-toolbar.js +41 -0
  38. package/components/ui/view-mode-toolbar.module.scss.js +3 -0
  39. package/constants/index.d.ts +45 -0
  40. package/constants/index.js +37 -0
  41. package/constants/text-mappings.d.ts +181 -0
  42. package/constants/text-mappings.js +44 -0
  43. package/hooks/use-context-menu.d.ts +37 -0
  44. package/hooks/use-context-menu.js +228 -0
  45. package/hooks/use-direct-state-history.d.ts +58 -0
  46. package/hooks/use-direct-state-history.js +214 -0
  47. package/hooks/use-pen-drawing.d.ts +30 -0
  48. package/hooks/use-pen-drawing.js +363 -0
  49. package/hooks/use-rectangle-drawing.d.ts +19 -0
  50. package/hooks/use-rectangle-drawing.js +136 -0
  51. package/hooks/use-text-editing.d.ts +19 -0
  52. package/hooks/use-text-editing.js +153 -0
  53. package/icons/index.d.ts +15 -0
  54. package/icons/index.js +209 -0
  55. package/index.cjs.css +1 -0
  56. package/index.cjs.js +5033 -0
  57. package/index.css +1 -0
  58. package/index.d.ts +5 -0
  59. package/index.js +4 -0
  60. package/package.json +40 -0
  61. package/types/callback.types.d.ts +7 -0
  62. package/types/canvas.types.d.ts +35 -0
  63. package/types/component-props.types.d.ts +41 -0
  64. package/types/history.types.d.ts +24 -0
  65. package/types/index.d.ts +5 -0
  66. package/types/react-flow.types.d.ts +30 -0
  67. package/typings.d.ts +140 -0
  68. package/typings.js +37 -0
  69. package/utils/api-data-transform.d.ts +33 -0
  70. package/utils/api-data-transform.js +218 -0
  71. package/utils/color-utils.d.ts +17 -0
  72. package/utils/color-utils.js +55 -0
  73. package/utils/debug-logger.d.ts +33 -0
  74. package/utils/debug-logger.js +41 -0
  75. package/utils/map-data-transform.d.ts +18 -0
  76. package/utils/map-data-transform.js +342 -0
  77. package/utils/node-operations.d.ts +26 -0
  78. package/utils/node-operations.js +83 -0
  79. package/utils/node-utils.d.ts +10 -0
  80. package/utils/node-utils.js +37 -0
@@ -0,0 +1,278 @@
1
+ import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
2
+ import { useState, useEffect } from 'react';
3
+ import { Button } from '@mezzanine-ui/react';
4
+ import { EditMode, DrawingMode } from '../../typings.js';
5
+ import { DEFAULT_BACKGROUND_TOOL_COLOR } from '../../constants/index.js';
6
+ import styles from './toolbar.module.scss.js';
7
+ import { ImageIcon, DeleteIcon, UndoIcon, RedoIcon, PointerIcon, SquareIcon, PenToolIcon } from '../../icons/index.js';
8
+
9
+ // LoadingIcon 組件
10
+ const LoadingIcon = ({ className })=>/*#__PURE__*/ jsx("div", {
11
+ className: `${styles.loadingIcon} ${className || ''}`
12
+ });
13
+ const Toolbar = ({ onUpload, onDeleteAll, onSave, editMode, drawingMode, onEditModeChange, onToggleRectangleTool, onTogglePenTool, onUndo, onRedo, canUndo = false, canRedo = false, onColorChange, selectedColor: parentSelectedColor, colorPalette, isUploading = false, maxFileSizeKB = 30720 })=>{
14
+ const [showColorMenu, setShowColorMenu] = useState(false);
15
+ const selectedColor = parentSelectedColor || DEFAULT_BACKGROUND_TOOL_COLOR;
16
+ // 檔案選擇處理
17
+ const handleFileChange = async (event)=>{
18
+ const files = Array.from(event.target.files || []);
19
+ // 檔案類型驗證
20
+ const validFiles = files.filter((file)=>{
21
+ if (!file.type.match(/^image\//i)) {
22
+ return false;
23
+ }
24
+ // 檔案大小驗證 (KB)
25
+ const fileSizeKB = file.size / 1024;
26
+ if (fileSizeKB > maxFileSizeKB) {
27
+ console.warn(`檔案 ${file.name} 大小 ${Math.round(fileSizeKB)}KB 超過限制 ${maxFileSizeKB}KB`);
28
+ return false;
29
+ }
30
+ return true;
31
+ });
32
+ if (validFiles.length !== files.length) {
33
+ const invalidCount = files.length - validFiles.length;
34
+ console.warn(`${invalidCount} 個檔案被跳過:格式不支援或檔案過大`);
35
+ }
36
+ if (validFiles.length > 0) {
37
+ await onUpload(validFiles);
38
+ }
39
+ // 清空 input
40
+ event.target.value = '';
41
+ };
42
+ const handleColorChange = (color)=>{
43
+ if (onColorChange) {
44
+ onColorChange(color);
45
+ }
46
+ };
47
+ const handleColorPickerClick = ()=>{
48
+ if (colorPalette && colorPalette.length > 0) {
49
+ setShowColorMenu(!showColorMenu);
50
+ }
51
+ // 如果沒有提供 colorPalette,則不執行任何操作(顏色工具將被隱藏)
52
+ };
53
+ const handleColorSelect = (color)=>{
54
+ handleColorChange(color);
55
+ setShowColorMenu(false);
56
+ };
57
+ // 點擊外部關閉顏色選單
58
+ useEffect(()=>{
59
+ const handleClickOutside = (event)=>{
60
+ const colorPicker = document.querySelector(`.${styles.colorPicker}`);
61
+ if (colorPicker && !colorPicker.contains(event.target)) {
62
+ setShowColorMenu(false);
63
+ }
64
+ };
65
+ if (showColorMenu) {
66
+ document.addEventListener('mousedown', handleClickOutside);
67
+ }
68
+ return ()=>{
69
+ document.removeEventListener('mousedown', handleClickOutside);
70
+ };
71
+ }, [
72
+ showColorMenu
73
+ ]);
74
+ return /*#__PURE__*/ jsxs(Fragment, {
75
+ children: [
76
+ /*#__PURE__*/ jsxs("div", {
77
+ className: styles.toolbar,
78
+ children: [
79
+ /*#__PURE__*/ jsxs("div", {
80
+ className: styles.toolbarLeft,
81
+ children: [
82
+ /*#__PURE__*/ jsxs("div", {
83
+ className: styles.toggleSwitch,
84
+ children: [
85
+ /*#__PURE__*/ jsx("div", {
86
+ className: `${styles.toggleSlider} ${editMode === EditMode.BACKGROUND ? styles.toggleSliderRight : ''}`
87
+ }),
88
+ /*#__PURE__*/ jsx("button", {
89
+ className: `${styles.toggleOption} ${editMode === EditMode.LAYER ? styles.toggleOptionActive : ''}`,
90
+ onClick: ()=>onEditModeChange(EditMode.LAYER),
91
+ children: "圖層"
92
+ }),
93
+ /*#__PURE__*/ jsx("button", {
94
+ className: `${styles.toggleOption} ${editMode === EditMode.BACKGROUND ? styles.toggleOptionActive : ''}`,
95
+ onClick: ()=>onEditModeChange(EditMode.BACKGROUND),
96
+ children: "底圖"
97
+ })
98
+ ]
99
+ }),
100
+ /*#__PURE__*/ jsx("div", {
101
+ className: styles.separator
102
+ }),
103
+ editMode === EditMode.BACKGROUND && /*#__PURE__*/ jsxs("div", {
104
+ className: styles.uploadButtonContainer,
105
+ children: [
106
+ /*#__PURE__*/ jsx(Button, {
107
+ variant: "outlined",
108
+ size: "small",
109
+ className: `${styles.toolbarButton} ${styles.buttonWithIcon} ${styles.uploadButton} ${isUploading ? styles.uploading : ''}`,
110
+ disabled: isUploading,
111
+ children: /*#__PURE__*/ jsxs("div", {
112
+ className: styles.buttonContent,
113
+ children: [
114
+ isUploading ? /*#__PURE__*/ jsx(LoadingIcon, {
115
+ className: styles.toolIcon
116
+ }) : /*#__PURE__*/ jsx(ImageIcon, {
117
+ className: styles.toolIcon
118
+ }),
119
+ isUploading ? '上傳中...' : '上傳'
120
+ ]
121
+ })
122
+ }),
123
+ /*#__PURE__*/ jsx("input", {
124
+ type: "file",
125
+ accept: "image/*",
126
+ multiple: true,
127
+ onChange: handleFileChange,
128
+ className: styles.uploadInput,
129
+ disabled: isUploading
130
+ })
131
+ ]
132
+ }),
133
+ /*#__PURE__*/ jsxs(Button, {
134
+ variant: "outlined",
135
+ size: "small",
136
+ className: `${styles.toolbarButton} ${styles.buttonWithIcon}`,
137
+ onClick: (e)=>{
138
+ onDeleteAll();
139
+ // 強制重置按鈕狀態
140
+ const btn = e.target;
141
+ btn.blur();
142
+ setTimeout(()=>{
143
+ btn.blur();
144
+ }, 0);
145
+ },
146
+ children: [
147
+ /*#__PURE__*/ jsx(DeleteIcon, {
148
+ className: styles.toolIcon
149
+ }),
150
+ "刪除全部"
151
+ ]
152
+ })
153
+ ]
154
+ }),
155
+ /*#__PURE__*/ jsx(Button, {
156
+ variant: "contained",
157
+ size: "small",
158
+ className: styles.saveButton,
159
+ onClick: (e)=>{
160
+ onSave();
161
+ // 強制重置按鈕狀態
162
+ const btn = e.target;
163
+ btn.blur();
164
+ setTimeout(()=>{
165
+ btn.blur();
166
+ }, 0);
167
+ },
168
+ children: "儲存"
169
+ })
170
+ ]
171
+ }),
172
+ /*#__PURE__*/ jsxs("div", {
173
+ className: styles.unifiedTools,
174
+ children: [
175
+ /*#__PURE__*/ jsx(Button, {
176
+ variant: "outlined",
177
+ size: "small",
178
+ className: `${styles.toolButton} ${canUndo ? '' : styles.toolButtonDisabled}`,
179
+ onClick: onUndo,
180
+ disabled: !canUndo,
181
+ title: "上一步",
182
+ children: /*#__PURE__*/ jsx(UndoIcon, {
183
+ className: styles.toolIcon
184
+ })
185
+ }),
186
+ /*#__PURE__*/ jsx(Button, {
187
+ variant: "outlined",
188
+ size: "small",
189
+ className: `${styles.toolButton} ${canRedo ? '' : styles.toolButtonDisabled}`,
190
+ onClick: onRedo,
191
+ disabled: !canRedo,
192
+ title: "下一步",
193
+ children: /*#__PURE__*/ jsx(RedoIcon, {
194
+ className: styles.toolIcon
195
+ })
196
+ }),
197
+ editMode === EditMode.LAYER && /*#__PURE__*/ jsxs(Fragment, {
198
+ children: [
199
+ /*#__PURE__*/ jsx("div", {
200
+ className: styles.separator
201
+ }),
202
+ /*#__PURE__*/ jsx(Button, {
203
+ variant: drawingMode === DrawingMode.NONE ? 'contained' : 'outlined',
204
+ size: "small",
205
+ className: `${styles.toolButton} ${drawingMode === DrawingMode.NONE ? styles.toolButtonActive : ''}`,
206
+ onClick: ()=>{
207
+ // 選擇選取工具時關閉繪圖模式
208
+ if (drawingMode === DrawingMode.RECTANGLE) {
209
+ onToggleRectangleTool();
210
+ } else if (drawingMode === DrawingMode.PEN) {
211
+ onTogglePenTool();
212
+ }
213
+ },
214
+ title: "選取工具",
215
+ children: /*#__PURE__*/ jsx(PointerIcon, {
216
+ className: styles.toolIcon
217
+ })
218
+ }),
219
+ /*#__PURE__*/ jsx(Button, {
220
+ variant: drawingMode === DrawingMode.RECTANGLE ? 'contained' : 'outlined',
221
+ size: "small",
222
+ className: `${styles.toolButton} ${drawingMode === DrawingMode.RECTANGLE ? styles.toolButtonActive : ''}`,
223
+ onClick: onToggleRectangleTool,
224
+ title: "矩形工具",
225
+ children: /*#__PURE__*/ jsx(SquareIcon, {
226
+ className: styles.toolIcon
227
+ })
228
+ }),
229
+ /*#__PURE__*/ jsx(Button, {
230
+ variant: drawingMode === DrawingMode.PEN ? 'contained' : 'outlined',
231
+ size: "small",
232
+ className: `${styles.toolButton} ${drawingMode === DrawingMode.PEN ? styles.toolButtonActive : ''}`,
233
+ onClick: onTogglePenTool,
234
+ title: "鋼筆工具",
235
+ children: /*#__PURE__*/ jsx(PenToolIcon, {
236
+ className: styles.toolIcon
237
+ })
238
+ }),
239
+ colorPalette && colorPalette.length > 0 && /*#__PURE__*/ jsxs(Fragment, {
240
+ children: [
241
+ /*#__PURE__*/ jsx("div", {
242
+ className: styles.separator
243
+ }),
244
+ /*#__PURE__*/ jsxs("div", {
245
+ className: styles.colorPicker,
246
+ children: [
247
+ /*#__PURE__*/ jsx("div", {
248
+ className: styles.colorDisplay,
249
+ style: {
250
+ backgroundColor: selectedColor
251
+ },
252
+ onClick: handleColorPickerClick,
253
+ title: "選擇顏色"
254
+ }),
255
+ showColorMenu && /*#__PURE__*/ jsx("div", {
256
+ className: styles.colorMenu,
257
+ children: colorPalette.map((color, index)=>/*#__PURE__*/ jsx("div", {
258
+ className: `${styles.colorOption} ${selectedColor === color ? styles.colorOptionSelected : ''}`,
259
+ style: {
260
+ backgroundColor: color
261
+ },
262
+ onClick: ()=>handleColorSelect(color),
263
+ title: color
264
+ }, index))
265
+ })
266
+ ]
267
+ })
268
+ ]
269
+ })
270
+ ]
271
+ })
272
+ ]
273
+ })
274
+ ]
275
+ });
276
+ };
277
+
278
+ export { Toolbar as default };
@@ -0,0 +1,3 @@
1
+ var styles = {"toolbar":"toolbar-module_toolbar__96rDw","toolbarLeft":"toolbar-module_toolbarLeft__PMOYv","toggleSwitch":"toolbar-module_toggleSwitch__Gy2ML","toggleSlider":"toolbar-module_toggleSlider__7a7Nh","toggleSliderRight":"toolbar-module_toggleSliderRight__w9umy","toggleOption":"toolbar-module_toggleOption__8AIQx","toggleOptionActive":"toolbar-module_toggleOptionActive__ypvGJ","toolbarButton":"toolbar-module_toolbarButton__K8xsY","saveButton":"toolbar-module_saveButton__eiTcG","unifiedTools":"toolbar-module_unifiedTools__s27Xt","toolButton":"toolbar-module_toolButton__rQdtA","toolButtonDisabled":"toolbar-module_toolButtonDisabled__gc2mS","toolButtonActive":"toolbar-module_toolButtonActive__iCxN8","toolIcon":"toolbar-module_toolIcon__xPmHR","colorPicker":"toolbar-module_colorPicker__7PQ18","colorDisplay":"toolbar-module_colorDisplay__BEOKw","separator":"toolbar-module_separator__-IyrB","colorMenu":"toolbar-module_colorMenu__Y6gOp","colorOption":"toolbar-module_colorOption__7eLEp","colorOptionSelected":"toolbar-module_colorOptionSelected__-Zouj","buttonWithIcon":"toolbar-module_buttonWithIcon__-2ca5","uploadButtonContainer":"toolbar-module_uploadButtonContainer__vv0q8","uploadInput":"toolbar-module_uploadInput__xWb-r","uploadButton":"toolbar-module_uploadButton__SIUHi","uploading":"toolbar-module_uploading__uM5vV","loadingIcon":"toolbar-module_loadingIcon__bi-tO","buttonContent":"toolbar-module_buttonContent__nR-Kz"};
2
+
3
+ export { styles as default };
@@ -0,0 +1,9 @@
1
+ import { FC } from 'react';
2
+ import { ViewMode } from '../../typings';
3
+ interface ViewModeToolbarProps {
4
+ viewMode: ViewMode;
5
+ showBackground: boolean;
6
+ onToggleBackground: (show: boolean) => void;
7
+ }
8
+ declare const ViewModeToolbar: FC<ViewModeToolbarProps>;
9
+ export default ViewModeToolbar;
@@ -0,0 +1,41 @@
1
+ import { jsx, jsxs } from 'react/jsx-runtime';
2
+ import 'react';
3
+ import { Switch } from '@mezzanine-ui/react';
4
+ import { ViewMode } from '../../typings.js';
5
+ import styles from './view-mode-toolbar.module.scss.js';
6
+
7
+ const ViewModeToolbar = ({ viewMode, showBackground, onToggleBackground })=>{
8
+ // 只在檢視模式下顯示
9
+ if (viewMode !== ViewMode.VIEW) {
10
+ return null;
11
+ }
12
+ // console.log('🔧 ViewModeToolbar 渲染:', { viewMode, showBackground });
13
+ const handleToggle = (event)=>{
14
+ const checked = event.target.checked;
15
+ console.log('🔧 Toggle 切換:', {
16
+ from: showBackground,
17
+ to: checked
18
+ });
19
+ onToggleBackground(checked);
20
+ };
21
+ return /*#__PURE__*/ jsx("div", {
22
+ className: styles.viewModeToolbar,
23
+ children: /*#__PURE__*/ jsxs("div", {
24
+ className: styles.toolbarContent,
25
+ children: [
26
+ /*#__PURE__*/ jsx("span", {
27
+ className: styles.label,
28
+ children: "顯示底圖"
29
+ }),
30
+ /*#__PURE__*/ jsx(Switch, {
31
+ checked: showBackground,
32
+ onChange: handleToggle,
33
+ size: "medium",
34
+ className: styles.switch
35
+ })
36
+ ]
37
+ })
38
+ });
39
+ };
40
+
41
+ export { ViewModeToolbar as default };
@@ -0,0 +1,3 @@
1
+ var styles = {"viewModeToolbar":"view-mode-toolbar-module_viewModeToolbar__N0CZK","toolbarContent":"view-mode-toolbar-module_toolbarContent__aXcnS","label":"view-mode-toolbar-module_label__NyCK5","switch":"view-mode-toolbar-module_switch__RzGTA"};
2
+
3
+ export { styles as default };
@@ -0,0 +1,45 @@
1
+ export declare const DEFAULT_IMAGE_WIDTH = 300;
2
+ export declare const DEFAULT_IMAGE_HEIGHT = 200;
3
+ export declare const DEFAULT_RECTANGLE_WIDTH = 150;
4
+ export declare const DEFAULT_RECTANGLE_HEIGHT = 100;
5
+ export declare const DEFAULT_RECTANGLE_COLOR = "#3b82f6";
6
+ export declare const SELECTION_BORDER_COLOR = "#3b82f6";
7
+ export declare const DEFAULT_BACKGROUND_TOOL_COLOR = "#3b82f6";
8
+ export declare const MIN_RECTANGLE_SIZE = 10;
9
+ export declare const MIN_RESIZE_WIDTH = 50;
10
+ export declare const MIN_RESIZE_HEIGHT = 30;
11
+ export declare const DEFAULT_RECTANGLE_LABEL = "\u77E9\u5F62\u5340\u57DF";
12
+ export declare const DEFAULT_PATH_LABEL = "\u8DEF\u5F91\u5340\u57DF";
13
+ export declare const ACTIVE_OPACITY = 1;
14
+ export declare const INACTIVE_OPACITY = 0.4;
15
+ export declare const RECTANGLE_INACTIVE_OPACITY = 0.6;
16
+ export declare const RESIZE_CONTROL_SIZE = 16;
17
+ export declare const IMAGE_RESIZE_CONTROL_SIZE = 20;
18
+ export declare const UI_CONFIG: {
19
+ readonly HISTORY_SIZE: 50;
20
+ readonly COLOR_CHANGE_DELAY: 800;
21
+ readonly STAGGER_DELAY: 100;
22
+ readonly NODE_SAVE_DELAY: 50;
23
+ };
24
+ export declare const CANVAS_CONFIG: {
25
+ readonly MIN_ZOOM: 0.1;
26
+ readonly MAX_ZOOM: 4;
27
+ readonly DEFAULT_VIEWPORT: {
28
+ readonly x: 0;
29
+ readonly y: 0;
30
+ readonly zoom: 1;
31
+ };
32
+ readonly BACKGROUND_COLOR: "#F5F5F5";
33
+ };
34
+ export declare const DEFAULT_WAREHOUSE_IDS: readonly ["10001", "10001A", "10002", "100002B", "100003", "100003B"];
35
+ export declare const SUPPORTED_IMAGE_TYPES: {
36
+ readonly ACCEPT: "image/png,image/jpeg,image/jpg";
37
+ readonly PATTERN: RegExp;
38
+ readonly EXTENSIONS: readonly ["png", "jpg", "jpeg"];
39
+ };
40
+ export declare const UPLOAD_CONFIG: {
41
+ readonly DEFAULT_MAX_FILE_SIZE_KB: 30720;
42
+ readonly SUPPORTED_MIME_TYPES: readonly ["image/png", "image/jpeg", "image/jpg", "image/gif", "image/webp"];
43
+ };
44
+ export { TEXT_MAPPINGS } from './text-mappings';
45
+ export type { TextMappingKey, DebugKey, OperationKey, MessageKey, TestMessageKey } from './text-mappings';
@@ -0,0 +1,37 @@
1
+ // 預設尺寸
2
+ const DEFAULT_IMAGE_WIDTH = 300;
3
+ const DEFAULT_IMAGE_HEIGHT = 200;
4
+ const DEFAULT_RECTANGLE_WIDTH = 150;
5
+ const DEFAULT_RECTANGLE_HEIGHT = 100;
6
+ // 顏色
7
+ const DEFAULT_RECTANGLE_COLOR = '#3b82f6';
8
+ const DEFAULT_BACKGROUND_TOOL_COLOR = '#3b82f6';
9
+ // 最小尺寸
10
+ const MIN_RECTANGLE_SIZE = 10;
11
+ const MIN_RESIZE_WIDTH = 50;
12
+ const MIN_RESIZE_HEIGHT = 30;
13
+ // 文字和標籤
14
+ const DEFAULT_RECTANGLE_LABEL = '矩形區域';
15
+ const DEFAULT_PATH_LABEL = '路徑區域';
16
+ // 透明度數值
17
+ const ACTIVE_OPACITY = 1;
18
+ const INACTIVE_OPACITY = 0.4;
19
+ const RECTANGLE_INACTIVE_OPACITY = 0.6;
20
+ // UI 配置
21
+ const UI_CONFIG = {
22
+ HISTORY_SIZE: 50,
23
+ COLOR_CHANGE_DELAY: 800,
24
+ STAGGER_DELAY: 100,
25
+ NODE_SAVE_DELAY: 50
26
+ };
27
+ // 預設倉庫 ID (應該從外部傳入)
28
+ const DEFAULT_WAREHOUSE_IDS = [
29
+ '10001',
30
+ '10001A',
31
+ '10002',
32
+ '100002B',
33
+ '100003',
34
+ '100003B'
35
+ ];
36
+
37
+ export { ACTIVE_OPACITY, DEFAULT_BACKGROUND_TOOL_COLOR, DEFAULT_IMAGE_HEIGHT, DEFAULT_IMAGE_WIDTH, DEFAULT_PATH_LABEL, DEFAULT_RECTANGLE_COLOR, DEFAULT_RECTANGLE_HEIGHT, DEFAULT_RECTANGLE_LABEL, DEFAULT_RECTANGLE_WIDTH, DEFAULT_WAREHOUSE_IDS, INACTIVE_OPACITY, MIN_RECTANGLE_SIZE, MIN_RESIZE_HEIGHT, MIN_RESIZE_WIDTH, RECTANGLE_INACTIVE_OPACITY, UI_CONFIG };
@@ -0,0 +1,181 @@
1
+ /**
2
+ * 文字對應表
3
+ * 用於管理所有中文文字,避免 Non-ASCII 字符問題
4
+ */
5
+ export declare const TEXT_MAPPINGS: {
6
+ readonly DEBUG: {
7
+ readonly DATA_LOADING: "data-loading";
8
+ readonly HISTORY: "history";
9
+ readonly REACT_FLOW: "reactFlow";
10
+ readonly NODES: "nodes";
11
+ readonly EVENTS: "events";
12
+ readonly UI: "ui";
13
+ readonly TESTING: "testing";
14
+ };
15
+ readonly OPERATIONS: {
16
+ readonly LOAD_NEW_DATA: "load-new-data";
17
+ readonly CHANGE_COLOR: "change-color";
18
+ readonly MOVE_SHAPE: "move-shape";
19
+ readonly DRAW_RECTANGLE: "draw-rectangle";
20
+ readonly DRAW_PATH: "draw-path";
21
+ readonly TEXT_EDIT: "text-edit";
22
+ readonly PATH_EDIT: "path-edit";
23
+ readonly DATA_CHANGE: "data-change";
24
+ readonly DELETE_IMAGES: "delete-images";
25
+ readonly DELETE_LAYERS: "delete-layers";
26
+ readonly UPLOAD_IMAGE: "upload-image";
27
+ };
28
+ readonly MESSAGES: {
29
+ readonly IMAGE_NODE: "圖片節點";
30
+ readonly RECTANGLE_NODE: "矩形節點";
31
+ readonly PATH_NODE: "路徑節點";
32
+ readonly SELECTABLE: "可選取";
33
+ readonly DRAGGABLE: "可拖曳";
34
+ readonly DELETABLE: "可刪除";
35
+ readonly NODE_COUNT: "節點數";
36
+ readonly EDGE_COUNT: "邊數";
37
+ readonly CURRENT_NODES: "目前節點數";
38
+ readonly CURRENT_EDGES: "目前邊數";
39
+ readonly NEW_DATA_NODES: "新資料節點數";
40
+ readonly NEW_DATA_EDGES: "新資料邊數";
41
+ readonly LOADED_NODES: "載入節點數";
42
+ readonly LOADED_EDGES: "載入邊數";
43
+ readonly DETECT_INITIAL_NODES_CHANGE: "檢測到 initialNodes 變化,更新畫布資料:";
44
+ readonly NODE_ID_CHANGE: "節點ID變化";
45
+ readonly NEW_IDS: "新的";
46
+ readonly OLD_IDS: "舊的";
47
+ readonly DATA_LOADING_COMPLETE: "新資料載入完成:";
48
+ readonly CURRENT_MODE: "當前模式";
49
+ readonly NODE_TYPE_STATS: "節點類型統計";
50
+ readonly NODE_STATE_STATS: "節點狀態統計";
51
+ readonly HISTORY_REINITIALIZE: "歷史記錄已重新初始化:";
52
+ readonly OPERATION: "操作";
53
+ readonly FIRST_HISTORY_INIT: "首次初始化歷史記錄:";
54
+ readonly VIEW_MODE_ALL_NODES_DISABLED: "檢視模式下所有節點都不可選取和拖曳";
55
+ readonly BACKGROUND_NODE_RULE: "底圖節點只能在底圖模式下選取和拖曳";
56
+ readonly BACKGROUND_NODE_NO_DELETE: "底圖節點不可刪除";
57
+ readonly RECTANGLE_NODE_RULE: "矩形節點只能在圖層模式下選取和拖曳";
58
+ readonly RECTANGLE_NODE_NO_DELETE: "矩形節點不可刪除";
59
+ readonly PATH_NODE_RULE: "路徑節點只能在圖層模式下選取、拖曳和刪除";
60
+ readonly ENSURE_NEW_DATA_MANAGED: "重新初始化歷史記錄系統,確保新資料被正確管理";
61
+ readonly DELAY_ENSURE_STATE_UPDATE: "延遲確保 React 狀態更新完成";
62
+ readonly AVOID_DYNAMIC_LOADING_CONFLICT: "避免與動態載入時的明確初始化衝突";
63
+ readonly ONLY_INIT_WHEN_NO_HISTORY: "只有在沒有歷史記錄或節點/邊為空時才初始化";
64
+ readonly ON_NODES_CHANGE_TRIGGER: "onNodesChange 觸發:";
65
+ readonly DETECT_DATA_CHANGE: "檢測到資料變更:";
66
+ readonly CHANGED_NODES: "檢測到資料變更:";
67
+ readonly IMMEDIATE_RECORD_DATA_CHANGE: "立即記錄資料變更歷史:";
68
+ readonly DELAY_RECORD_COLOR_CHANGE: "延遲記錄顏色變更歷史 (800ms 後記錄,避免頻繁切換時產生過多記錄)";
69
+ readonly DELAY_TO_GET_UPDATED_STATE: "使用 setTimeout 確保能獲取到更新後的 nodes 狀態";
70
+ readonly RECORD_TEXT_EDIT_STATE: "保存文字編輯後的狀態:";
71
+ readonly RECORD_PATH_EDIT_STATE: "保存路徑點位編輯後的狀態:";
72
+ readonly UPDATED_POINTS_COUNT: "轉換後節點數:";
73
+ };
74
+ readonly TEST_MESSAGES: {
75
+ readonly SIMPLE_TEST_DATA: "簡單測試資料";
76
+ readonly COMPLEX_WAREHOUSE_DATA: "完整倉庫資料";
77
+ readonly LARGE_TEST_DATA: "大量測試資料";
78
+ readonly DEFAULT_TEST_DATA: "預設測試資料";
79
+ readonly LOAD_SUCCESS: "載入成功";
80
+ readonly LOAD_FAILED: "載入失敗";
81
+ readonly SAVE_SUCCESS: "儲存成功";
82
+ readonly OPEN_MODAL: "開啟 Modal";
83
+ readonly CLOSE_MODAL: "關閉 Modal";
84
+ readonly CLEAR_TEST_RECORD: "清空測試記錄";
85
+ readonly BREADCRUMB_OPEN_MODAL: "透過 breadcrumb 開啟 Modal";
86
+ readonly NODE_CLICK_EVENT: "節點點擊事件:";
87
+ readonly SAVE_EVENT_TRIGGER: "儲存事件觸發,接收到的資料:";
88
+ readonly BREADCRUMB_CLICK_EVENT: "Breadcrumb 點擊事件:";
89
+ readonly BREADCRUMB_LOAD_TRIGGER: "breadcrumb 觸發載入:";
90
+ readonly BREADCRUMB_LOAD_FAILED: "breadcrumb 載入失敗:";
91
+ readonly DATA_TYPE: "資料類型";
92
+ readonly CONVERTED_NODE_COUNT: "轉換後節點數";
93
+ readonly WAREHOUSE_ID: "warehouseId";
94
+ readonly INDEX: "index";
95
+ readonly WMS_MAP_MODAL_COMPREHENSIVE_TEST: "WMS Map Modal - 綜合功能測試";
96
+ readonly TEST_DATA_LOADING_DYNAMIC_SWITCH: "測試資料載入與動態切換";
97
+ readonly LOAD_DIFFERENT_TEST_DATA: "點擊下方按鈕載入不同的測試資料到 WmsMapModal 中,也可以在 Modal 開啟狀態下動態切換:";
98
+ readonly SIMPLE_TEST_DATA_BUTTON: "簡單測試資料";
99
+ readonly SIMPLE_TEST_DATA_DESC: "(1個背景 + 2個區域)";
100
+ readonly COMPLEX_WAREHOUSE_BUTTON: "完整倉庫資料";
101
+ readonly COMPLEX_WAREHOUSE_DESC: "(2個背景 + 8個區域)";
102
+ readonly LARGE_TEST_DATA_BUTTON: "大量測試資料";
103
+ readonly LARGE_TEST_DATA_DESC: "(5個背景 + 30個區域)";
104
+ readonly CLEAR_TEST_RECORD_BUTTON: "清空測試記錄";
105
+ readonly CLEAR_TEST_RECORD_DESC: "(重置記錄)";
106
+ readonly CURRENT_LOADED_DATA: "目前載入的資料";
107
+ readonly DATA_TYPE_LABEL: "資料類型:";
108
+ readonly TOTAL_NODES: "節點總數:";
109
+ readonly BACKGROUND_IMAGES: "背景圖片:";
110
+ readonly RECTANGLE_AREAS: "矩形區域:";
111
+ readonly POLYGON_AREAS: "多邊形區域:";
112
+ readonly TEST_INSTRUCTIONS: "測試說明";
113
+ readonly BUTTON_LOADING: "按鈕載入:";
114
+ readonly BUTTON_LOADING_DESC: "使用上方按鈕可手動載入不同的測試資料";
115
+ readonly DYNAMIC_LOADING: "動態載入:";
116
+ readonly DYNAMIC_LOADING_DESC: "Modal 開啟狀態下點擊不同按鈕,測試資料動態切換功能";
117
+ readonly HISTORY_RECORD_TEST: "歷史記錄測試:";
118
+ readonly HISTORY_RECORD_TEST_DESC: "載入資料後進行編輯操作,測試 Undo/Redo 功能是否正常";
119
+ readonly BREADCRUMB_LOADING: "Breadcrumb 載入:";
120
+ readonly BREADCRUMB_LOADING_DESC: "點擊 Modal 內的 breadcrumb 路徑可自動載入對應資料:";
121
+ readonly MODE_TEST: "模式測試:";
122
+ readonly MODE_TEST_DESC: "切換檢視模式/編輯模式,測試節點狀態規則";
123
+ readonly LAYER_TEST: "圖層測試:";
124
+ readonly LAYER_TEST_DESC: "在編輯模式下切換底圖/圖層模式,驗證節點互動限制";
125
+ readonly INTERACTION_TEST: "互動測試:";
126
+ readonly NODE_CLICK_OUTPUT: "點擊節點會在 console 輸出詳細資訊";
127
+ readonly SAVE_TRIGGER_ALERT: "儲存功能會觸發 alert 和 console 輸出";
128
+ readonly BREADCRUMB_AUTO_LOAD: "Breadcrumb 點擊會自動載入對應測試資料";
129
+ readonly STATE_RULE_VERIFICATION: "狀態規則驗證清單";
130
+ readonly VIEW_MODE_RULE: "檢視模式:";
131
+ readonly VIEW_MODE_RULE_DESC: "所有節點都不可選取、不可拖曳、不可刪除";
132
+ readonly EDIT_BACKGROUND_MODE_RULE: "編輯模式 - 底圖:";
133
+ readonly EDIT_BACKGROUND_MODE_DESC: "只有底圖節點(圖片)可選取拖曳,圖層節點不可互動";
134
+ readonly EDIT_LAYER_MODE_RULE: "編輯模式 - 圖層:";
135
+ readonly EDIT_LAYER_MODE_DESC: "只有圖層節點(矩形/路徑)可選取拖曳,底圖節點不可互動";
136
+ readonly DELETE_PERMISSION_RULE: "刪除權限:";
137
+ readonly DELETE_PERMISSION_DESC: "只有路徑節點在圖層模式下可刪除";
138
+ readonly EXPECTED_BEHAVIOR: "預期行為";
139
+ readonly NODE_STATE_APPLY_ON_LOAD: "每次載入新資料時,節點狀態會立即套用當前模式的規則";
140
+ readonly NODE_STATE_RECALC_ON_MODE_CHANGE: "模式切換時,所有節點狀態會重新計算";
141
+ readonly CONSOLE_DETAILED_STATS: "Console 會顯示詳細的節點狀態統計資訊";
142
+ readonly NO_DATA_MIXING: "動態載入不會出現新舊資料混合或狀態錯誤的情況";
143
+ readonly HISTORY_REINIT_ON_LOAD: "載入新資料後,歷史記錄系統會重新初始化並正常工作";
144
+ readonly EDIT_OPERATIONS_RECORDED: "編輯操作會被正確記錄,Undo/Redo 按鈕狀態正確更新";
145
+ readonly HISTORY_TEST_STEPS: "歷史記錄測試步驟";
146
+ readonly LOAD_DATA_STEP: "載入資料:";
147
+ readonly LOAD_DATA_STEP_DESC: "點擊載入按鈕開啟 Modal";
148
+ readonly PERFORM_EDIT_STEP: "進行編輯:";
149
+ readonly PERFORM_EDIT_STEP_DESC: "移動節點、編輯文字、繪製圖形等";
150
+ readonly TEST_UNDO_STEP: "測試 Undo:";
151
+ readonly TEST_UNDO_STEP_DESC: "使用 Cmd+Z 或工具列 Undo 按鈕";
152
+ readonly TEST_REDO_STEP: "測試 Redo:";
153
+ readonly TEST_REDO_STEP_DESC: "使用 Cmd+Shift+Z 或工具列 Redo 按鈕";
154
+ readonly DYNAMIC_SWITCH_STEP: "動態切換:";
155
+ readonly DYNAMIC_SWITCH_STEP_DESC: "在有編輯歷史時載入其他資料";
156
+ readonly REPEAT_TEST_STEP: "重複測試:";
157
+ readonly REPEAT_TEST_STEP_DESC: "確認新資料也有正確的歷史記錄功能";
158
+ readonly TEST_RECORD_HISTORY_TRACKING: "測試記錄與歷史追蹤";
159
+ readonly NO_TEST_RECORD: "尚無測試記錄 - 開始進行測試操作";
160
+ readonly TEST_RECORD_DESCRIPTION: "此記錄會自動追蹤您的測試操作,包括資料載入、Modal 開關、breadcrumb 點擊等,便於驗證歷史記錄功能是否正常。";
161
+ };
162
+ readonly ALERTS: {
163
+ readonly LOAD_SUCCESS_WITH_NODES: (typeName: string, nodeCount: number) => string;
164
+ readonly SAVE_SUCCESS_WITH_DATA: (backgroundCount: number, rangeCount: number) => string;
165
+ readonly LOAD_FAILED: (error: unknown) => string;
166
+ readonly INVALID_IMAGE_FORMAT: (fileName: string) => string;
167
+ };
168
+ readonly FORMATTERS: {
169
+ readonly NODES_UNIT: "個節點";
170
+ readonly BACKGROUND_COUNT: (count: number) => string;
171
+ readonly RANGE_COUNT: (count: number) => string;
172
+ readonly WAREHOUSE_ID_FORMAT: (id: string) => string;
173
+ readonly INDEX_FORMAT: (index: number) => string;
174
+ readonly CURRENT_INDICATOR: "(當前)";
175
+ };
176
+ };
177
+ export type TextMappingKey = keyof typeof TEXT_MAPPINGS;
178
+ export type DebugKey = keyof typeof TEXT_MAPPINGS.DEBUG;
179
+ export type OperationKey = keyof typeof TEXT_MAPPINGS.OPERATIONS;
180
+ export type MessageKey = keyof typeof TEXT_MAPPINGS.MESSAGES;
181
+ export type TestMessageKey = keyof typeof TEXT_MAPPINGS.TEST_MESSAGES;
@@ -0,0 +1,44 @@
1
+ /**
2
+ * 文字對應表
3
+ * 用於管理所有中文文字,避免 Non-ASCII 字符問題
4
+ */ const TEXT_MAPPINGS = {
5
+ // Debug 相關
6
+ DEBUG: {
7
+ DATA_LOADING: 'data-loading',
8
+ HISTORY: 'history'},
9
+ // 操作描述
10
+ OPERATIONS: {
11
+ LOAD_NEW_DATA: 'load-new-data'},
12
+ // 中文文字對應
13
+ MESSAGES: {
14
+ // 節點類型
15
+ IMAGE_NODE: '圖片節點',
16
+ RECTANGLE_NODE: '矩形節點',
17
+ PATH_NODE: '路徑節點',
18
+ // 狀態描述
19
+ SELECTABLE: '可選取',
20
+ DRAGGABLE: '可拖曳',
21
+ DELETABLE: '可刪除',
22
+ // 數據統計
23
+ NODE_COUNT: '節點數',
24
+ EDGE_COUNT: '邊數',
25
+ CURRENT_NODES: '目前節點數',
26
+ CURRENT_EDGES: '目前邊數',
27
+ NEW_DATA_NODES: '新資料節點數',
28
+ NEW_DATA_EDGES: '新資料邊數',
29
+ LOADED_NODES: '載入節點數',
30
+ LOADED_EDGES: '載入邊數',
31
+ // 操作消息
32
+ DETECT_INITIAL_NODES_CHANGE: '檢測到 initialNodes 變化,更新畫布資料:',
33
+ NODE_ID_CHANGE: '節點ID變化',
34
+ NEW_IDS: '新的',
35
+ OLD_IDS: '舊的',
36
+ DATA_LOADING_COMPLETE: '新資料載入完成:',
37
+ CURRENT_MODE: '當前模式',
38
+ NODE_TYPE_STATS: '節點類型統計',
39
+ NODE_STATE_STATS: '節點狀態統計',
40
+ HISTORY_REINITIALIZE: '歷史記錄已重新初始化:',
41
+ OPERATION: '操作',
42
+ FIRST_HISTORY_INIT: '首次初始化歷史記錄:'}};
43
+
44
+ export { TEXT_MAPPINGS };