@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.
- package/CHANGELOG.md +181 -0
- package/README.md +30 -0
- 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.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.module.scss.cjs +5 -0
- package/components/canvas/react-flow-canvas.cjs +327 -0
- package/components/canvas/react-flow-canvas.d.cts +40 -0
- package/components/canvas/react-flow-canvas.d.ts +3 -1
- package/components/canvas/react-flow-canvas.js +7 -1
- package/components/canvas/react-flow-canvas.module.scss.cjs +5 -0
- package/components/modal/wms-map-content.cjs +835 -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 +30 -3
- package/components/modal/wms-map-modal-container.cjs +132 -0
- package/components/modal/wms-map-modal-container.d.cts +5 -0
- package/components/modal/wms-map-modal-container.d.ts +2 -2
- package/components/modal/wms-map-modal-container.js +6 -4
- 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 +234 -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 +0 -2
- package/components/nodes/image-node.module.scss.cjs +5 -0
- package/components/nodes/path-node.cjs +554 -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 +6 -5
- package/components/nodes/path-node.module.scss.cjs +5 -0
- package/components/nodes/rectangle-node.cjs +240 -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 +6 -5
- package/components/nodes/rectangle-node.module.scss.cjs +5 -0
- package/components/preview/wms-map-preview.cjs +201 -0
- package/components/preview/wms-map-preview.d.cts +11 -0
- package/components/preview/wms-map-preview.d.ts +11 -0
- package/components/preview/wms-map-preview.js +199 -0
- package/components/ui/context-menu.cjs +171 -0
- package/components/ui/context-menu.d.cts +25 -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.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.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-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-fit-view-when-ready.cjs +74 -0
- package/hooks/use-fit-view-when-ready.d.cts +18 -0
- package/hooks/use-fit-view-when-ready.d.ts +18 -0
- package/hooks/use-fit-view-when-ready.js +72 -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-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-text-editing.cjs +156 -0
- package/hooks/use-text-editing.d.cts +19 -0
- package/icons/index.cjs +233 -0
- package/icons/index.d.cts +16 -0
- package/index.cjs +28 -0
- package/index.d.cts +6 -0
- package/index.d.ts +6 -5
- package/index.js +1 -0
- 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 +76 -0
- package/types/component-props.types.d.ts +33 -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/fit-trigger.cjs +41 -0
- package/utils/fit-trigger.d.cts +37 -0
- package/utils/fit-trigger.d.ts +37 -0
- package/utils/fit-trigger.js +36 -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/utils/preview-highlight.cjs +38 -0
- package/utils/preview-highlight.d.cts +12 -0
- package/utils/preview-highlight.d.ts +12 -0
- package/utils/preview-highlight.js +34 -0
- package/index.cjs.css +0 -1
- package/index.cjs.js +0 -5128
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { useMemo, useState, useEffect } from 'react';
|
|
4
|
+
import { ReactFlowProvider, useStore, ReactFlow } from '@xyflow/react';
|
|
5
|
+
import { ViewMode, EditMode } from '../../typings.js';
|
|
6
|
+
import ImageNode from '../nodes/image-node.js';
|
|
7
|
+
import RectangleNode from '../nodes/rectangle-node.js';
|
|
8
|
+
import PathNode from '../nodes/path-node.js';
|
|
9
|
+
import { useFitViewWhenReady } from '../../hooks/use-fit-view-when-ready.js';
|
|
10
|
+
import { applyPreviewHighlight } from '../../utils/preview-highlight.js';
|
|
11
|
+
import { getNodeIdSignature } from '../../utils/fit-trigger.js';
|
|
12
|
+
|
|
13
|
+
/** 與 WMSMapModal 的檢視模式一致:VIEW 不可編輯,BACKGROUND 讓底圖全不透明。 */ const PREVIEW_EDIT_MODE = EditMode.BACKGROUND;
|
|
14
|
+
const PREVIEW_VIEW_MODE = ViewMode.VIEW;
|
|
15
|
+
/** 模組層級常數,維持穩定參照,React Flow 才不會每次 render 重建節點。 */ const PREVIEW_NODE_TYPES = {
|
|
16
|
+
imageNode: (props)=>/*#__PURE__*/ jsx(ImageNode, {
|
|
17
|
+
...props,
|
|
18
|
+
editMode: PREVIEW_EDIT_MODE,
|
|
19
|
+
viewMode: PREVIEW_VIEW_MODE
|
|
20
|
+
}),
|
|
21
|
+
rectangleNode: (props)=>/*#__PURE__*/ jsx(RectangleNode, {
|
|
22
|
+
...props,
|
|
23
|
+
editMode: PREVIEW_EDIT_MODE,
|
|
24
|
+
viewMode: PREVIEW_VIEW_MODE
|
|
25
|
+
}),
|
|
26
|
+
pathNode: (props)=>/*#__PURE__*/ jsx(PathNode, {
|
|
27
|
+
...props,
|
|
28
|
+
editMode: PREVIEW_EDIT_MODE,
|
|
29
|
+
viewMode: PREVIEW_VIEW_MODE
|
|
30
|
+
})
|
|
31
|
+
};
|
|
32
|
+
/** 預覽容器可能很窄(例如 200px),minZoom 需夠低,否則 fit 會被夾住而框不住整張圖。 */ const PREVIEW_MIN_ZOOM = 0.01;
|
|
33
|
+
const PREVIEW_MAX_ZOOM = 4;
|
|
34
|
+
const NO_NODES_DELETE_KEY = null;
|
|
35
|
+
const getFileName = (node)=>{
|
|
36
|
+
const { fileName } = node.data;
|
|
37
|
+
return node.type === 'imageNode' && typeof fileName === 'string' && fileName.length > 0 ? fileName : null;
|
|
38
|
+
};
|
|
39
|
+
/** 以 getFilenameFQDN 解析背景圖網址;未提供時沿用 data.imageUrl。 */ const useResolvedImageUrls = (nodes, getFilenameFQDN)=>{
|
|
40
|
+
const [resolved, setResolved] = useState({});
|
|
41
|
+
const fileNamesKey = useMemo(()=>Array.from(new Set(nodes.map(getFileName).filter((name)=>name !== null))).sort().join('\u0000'), [
|
|
42
|
+
nodes
|
|
43
|
+
]);
|
|
44
|
+
useEffect(()=>{
|
|
45
|
+
if (!getFilenameFQDN || fileNamesKey === '') {
|
|
46
|
+
setResolved({});
|
|
47
|
+
return undefined;
|
|
48
|
+
}
|
|
49
|
+
let cancelled = false;
|
|
50
|
+
const fileNames = fileNamesKey.split('\u0000');
|
|
51
|
+
void Promise.all(fileNames.map(async (fileName)=>{
|
|
52
|
+
try {
|
|
53
|
+
return [
|
|
54
|
+
fileName,
|
|
55
|
+
await Promise.resolve(getFilenameFQDN(fileName))
|
|
56
|
+
];
|
|
57
|
+
} catch (error) {
|
|
58
|
+
console.error(`無法取得底圖網址: ${fileName}`, error);
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
})).then((entries)=>{
|
|
62
|
+
if (!cancelled) {
|
|
63
|
+
setResolved(Object.fromEntries(entries.filter((entry)=>entry !== null)));
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
return ()=>{
|
|
67
|
+
cancelled = true;
|
|
68
|
+
};
|
|
69
|
+
}, [
|
|
70
|
+
fileNamesKey,
|
|
71
|
+
getFilenameFQDN
|
|
72
|
+
]);
|
|
73
|
+
return resolved;
|
|
74
|
+
};
|
|
75
|
+
const WMSMapPreviewCanvas = ({ initialNodes, highlightIds, dimOthers = true, fitPadding = 0.15, interactive = false, getFilenameFQDN })=>{
|
|
76
|
+
const resolvedImageUrls = useResolvedImageUrls(initialNodes, getFilenameFQDN);
|
|
77
|
+
const nodes = useMemo(()=>applyPreviewHighlight(initialNodes, highlightIds, dimOthers).map((node)=>{
|
|
78
|
+
const fileName = getFileName(node);
|
|
79
|
+
const imageUrl = fileName !== null ? resolvedImageUrls[fileName] : undefined;
|
|
80
|
+
return {
|
|
81
|
+
...node,
|
|
82
|
+
data: imageUrl !== undefined ? {
|
|
83
|
+
...node.data,
|
|
84
|
+
imageUrl
|
|
85
|
+
} : node.data,
|
|
86
|
+
selectable: false,
|
|
87
|
+
draggable: false,
|
|
88
|
+
deletable: false,
|
|
89
|
+
connectable: false,
|
|
90
|
+
focusable: false
|
|
91
|
+
};
|
|
92
|
+
}), [
|
|
93
|
+
initialNodes,
|
|
94
|
+
highlightIds,
|
|
95
|
+
dimOthers,
|
|
96
|
+
resolvedImageUrls
|
|
97
|
+
]);
|
|
98
|
+
// React Flow 以自己的 ResizeObserver 量測容器並寫入 store;尺寸改變時重新 fit
|
|
99
|
+
const width = useStore((state)=>state.width);
|
|
100
|
+
const height = useStore((state)=>state.height);
|
|
101
|
+
const nodeIds = useMemo(()=>nodes.map((node)=>node.id), [
|
|
102
|
+
nodes
|
|
103
|
+
]);
|
|
104
|
+
const fitKey = [
|
|
105
|
+
getNodeIdSignature(nodes),
|
|
106
|
+
highlightIds ? [
|
|
107
|
+
...highlightIds
|
|
108
|
+
].sort().join('\u0000') : '',
|
|
109
|
+
fitPadding,
|
|
110
|
+
width,
|
|
111
|
+
height
|
|
112
|
+
].join('|');
|
|
113
|
+
const [fitRequestToken, setFitRequestToken] = useState(0);
|
|
114
|
+
useEffect(()=>{
|
|
115
|
+
if (nodeIds.length > 0 && width > 0 && height > 0) {
|
|
116
|
+
setFitRequestToken((token)=>token + 1);
|
|
117
|
+
}
|
|
118
|
+
}, [
|
|
119
|
+
fitKey,
|
|
120
|
+
nodeIds.length,
|
|
121
|
+
width,
|
|
122
|
+
height
|
|
123
|
+
]);
|
|
124
|
+
useFitViewWhenReady({
|
|
125
|
+
requestToken: fitRequestToken,
|
|
126
|
+
nodeIds,
|
|
127
|
+
focusIds: highlightIds,
|
|
128
|
+
padding: fitPadding
|
|
129
|
+
});
|
|
130
|
+
return /*#__PURE__*/ jsx(ReactFlow, {
|
|
131
|
+
nodes: nodes,
|
|
132
|
+
edges: [],
|
|
133
|
+
nodeTypes: PREVIEW_NODE_TYPES,
|
|
134
|
+
style: {
|
|
135
|
+
background: '#F5F5F5'
|
|
136
|
+
},
|
|
137
|
+
defaultViewport: {
|
|
138
|
+
x: 0,
|
|
139
|
+
y: 0,
|
|
140
|
+
zoom: 1
|
|
141
|
+
},
|
|
142
|
+
minZoom: PREVIEW_MIN_ZOOM,
|
|
143
|
+
maxZoom: PREVIEW_MAX_ZOOM,
|
|
144
|
+
nodeOrigin: [
|
|
145
|
+
0,
|
|
146
|
+
0
|
|
147
|
+
],
|
|
148
|
+
nodesDraggable: false,
|
|
149
|
+
nodesConnectable: false,
|
|
150
|
+
nodesFocusable: false,
|
|
151
|
+
edgesFocusable: false,
|
|
152
|
+
elementsSelectable: false,
|
|
153
|
+
selectNodesOnDrag: false,
|
|
154
|
+
deleteKeyCode: NO_NODES_DELETE_KEY,
|
|
155
|
+
selectionKeyCode: null,
|
|
156
|
+
multiSelectionKeyCode: null,
|
|
157
|
+
panOnDrag: interactive,
|
|
158
|
+
panOnScroll: false,
|
|
159
|
+
zoomOnScroll: interactive,
|
|
160
|
+
zoomOnPinch: interactive,
|
|
161
|
+
zoomOnDoubleClick: false,
|
|
162
|
+
preventScrolling: interactive
|
|
163
|
+
});
|
|
164
|
+
};
|
|
165
|
+
/**
|
|
166
|
+
* 唯讀的地圖預覽:不含工具列、麵包屑與右鍵選單,節點就緒後自動 fit,
|
|
167
|
+
* 有 highlightIds 時框住並高亮這些範圍。
|
|
168
|
+
*
|
|
169
|
+
* 需要 React Flow 的樣式表;與 WMSMapModal 相同,由宿主在 app 層 import:
|
|
170
|
+
* `import '@xyflow/react/dist/style.css';`
|
|
171
|
+
*/ const WMSMapPreview = (props)=>{
|
|
172
|
+
const { className, style } = props;
|
|
173
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
174
|
+
className: className,
|
|
175
|
+
style: {
|
|
176
|
+
position: 'relative',
|
|
177
|
+
width: '100%',
|
|
178
|
+
height: '100%',
|
|
179
|
+
...style
|
|
180
|
+
},
|
|
181
|
+
children: [
|
|
182
|
+
/*#__PURE__*/ jsx(ReactFlowProvider, {
|
|
183
|
+
children: /*#__PURE__*/ jsx(WMSMapPreviewCanvas, {
|
|
184
|
+
...props
|
|
185
|
+
})
|
|
186
|
+
}),
|
|
187
|
+
!props.interactive && /*#__PURE__*/ jsx("div", {
|
|
188
|
+
"aria-hidden": true,
|
|
189
|
+
style: {
|
|
190
|
+
position: 'absolute',
|
|
191
|
+
inset: 0,
|
|
192
|
+
zIndex: 10
|
|
193
|
+
}
|
|
194
|
+
})
|
|
195
|
+
]
|
|
196
|
+
});
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
export { WMSMapPreview as default };
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
5
|
+
var React = require('react');
|
|
6
|
+
var reactDom = require('react-dom');
|
|
7
|
+
var contextMenu_module = require('./context-menu.module.scss.cjs');
|
|
8
|
+
|
|
9
|
+
const ContextMenu = ({ visible, x, y, onClose, onCopyPaste, onDelete, arrangeActions, arrangeStates })=>{
|
|
10
|
+
const menuRef = React.useRef(null);
|
|
11
|
+
const [showArrangeSubmenu, setShowArrangeSubmenu] = React.useState(false);
|
|
12
|
+
// Handle clicking outside to close menu
|
|
13
|
+
React.useEffect(()=>{
|
|
14
|
+
if (!visible) return;
|
|
15
|
+
const handleClickOutside = (event)=>{
|
|
16
|
+
const target = event.target;
|
|
17
|
+
const menuElement = menuRef.current;
|
|
18
|
+
if (menuElement) {
|
|
19
|
+
const isInsideMenu = menuElement.contains(target);
|
|
20
|
+
if (!isInsideMenu) {
|
|
21
|
+
onClose();
|
|
22
|
+
}
|
|
23
|
+
} else {
|
|
24
|
+
onClose();
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
const handleKeyDown = (event)=>{
|
|
28
|
+
if (event.key === 'Escape') {
|
|
29
|
+
onClose();
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
// Add small delay to prevent immediate closing when the menu appears
|
|
33
|
+
const timeoutId = setTimeout(()=>{
|
|
34
|
+
document.addEventListener('mousedown', handleClickOutside, true);
|
|
35
|
+
document.addEventListener('click', handleClickOutside, true);
|
|
36
|
+
document.addEventListener('keydown', handleKeyDown, true);
|
|
37
|
+
}, 50);
|
|
38
|
+
return ()=>{
|
|
39
|
+
clearTimeout(timeoutId);
|
|
40
|
+
document.removeEventListener('mousedown', handleClickOutside, true);
|
|
41
|
+
document.removeEventListener('click', handleClickOutside, true);
|
|
42
|
+
document.removeEventListener('keydown', handleKeyDown, true);
|
|
43
|
+
};
|
|
44
|
+
}, [
|
|
45
|
+
visible,
|
|
46
|
+
onClose
|
|
47
|
+
]);
|
|
48
|
+
if (!visible) return null;
|
|
49
|
+
// Adjust position to ensure menu stays within viewport
|
|
50
|
+
const adjustedX = Math.min(x, window.innerWidth - 150); // 150 is approximate menu width
|
|
51
|
+
const adjustedY = Math.min(y, window.innerHeight - 120); // 120 is approximate menu height
|
|
52
|
+
const contextMenuElement = /*#__PURE__*/ jsxRuntime.jsxs("div", {
|
|
53
|
+
ref: menuRef,
|
|
54
|
+
className: contextMenu_module.contextMenu,
|
|
55
|
+
style: {
|
|
56
|
+
position: 'fixed',
|
|
57
|
+
left: Math.max(0, adjustedX),
|
|
58
|
+
top: Math.max(0, adjustedY),
|
|
59
|
+
zIndex: 10000
|
|
60
|
+
},
|
|
61
|
+
children: [
|
|
62
|
+
/*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
63
|
+
className: contextMenu_module.menuItem,
|
|
64
|
+
onClick: onCopyPaste,
|
|
65
|
+
children: /*#__PURE__*/ jsxRuntime.jsxs("div", {
|
|
66
|
+
className: contextMenu_module.menuItemContent,
|
|
67
|
+
children: [
|
|
68
|
+
/*#__PURE__*/ jsxRuntime.jsx("span", {
|
|
69
|
+
className: contextMenu_module.menuItemText,
|
|
70
|
+
children: "複製並貼上"
|
|
71
|
+
}),
|
|
72
|
+
/*#__PURE__*/ jsxRuntime.jsx("span", {
|
|
73
|
+
className: contextMenu_module.menuItemShortcut,
|
|
74
|
+
children: "⌘D"
|
|
75
|
+
})
|
|
76
|
+
]
|
|
77
|
+
})
|
|
78
|
+
}),
|
|
79
|
+
/*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
80
|
+
className: contextMenu_module.menuItem,
|
|
81
|
+
onClick: onDelete,
|
|
82
|
+
children: /*#__PURE__*/ jsxRuntime.jsxs("div", {
|
|
83
|
+
className: contextMenu_module.menuItemContent,
|
|
84
|
+
children: [
|
|
85
|
+
/*#__PURE__*/ jsxRuntime.jsx("span", {
|
|
86
|
+
className: contextMenu_module.menuItemText,
|
|
87
|
+
children: "刪除"
|
|
88
|
+
}),
|
|
89
|
+
/*#__PURE__*/ jsxRuntime.jsx("span", {
|
|
90
|
+
className: contextMenu_module.menuItemShortcut,
|
|
91
|
+
children: "Del"
|
|
92
|
+
})
|
|
93
|
+
]
|
|
94
|
+
})
|
|
95
|
+
}),
|
|
96
|
+
/*#__PURE__*/ jsxRuntime.jsxs("div", {
|
|
97
|
+
className: `${contextMenu_module.menuItem} ${contextMenu_module.hasSubmenu}`,
|
|
98
|
+
onMouseEnter: ()=>setShowArrangeSubmenu(true),
|
|
99
|
+
onMouseLeave: ()=>setShowArrangeSubmenu(false),
|
|
100
|
+
children: [
|
|
101
|
+
"排列順序",
|
|
102
|
+
/*#__PURE__*/ jsxRuntime.jsx("span", {
|
|
103
|
+
className: contextMenu_module.arrow,
|
|
104
|
+
children: "▶"
|
|
105
|
+
}),
|
|
106
|
+
showArrangeSubmenu && /*#__PURE__*/ jsxRuntime.jsxs("div", {
|
|
107
|
+
className: contextMenu_module.submenu,
|
|
108
|
+
style: {
|
|
109
|
+
position: 'absolute',
|
|
110
|
+
left: '100%',
|
|
111
|
+
top: 0,
|
|
112
|
+
zIndex: 10001
|
|
113
|
+
},
|
|
114
|
+
onMouseEnter: ()=>setShowArrangeSubmenu(true),
|
|
115
|
+
onMouseLeave: ()=>setShowArrangeSubmenu(false),
|
|
116
|
+
children: [
|
|
117
|
+
/*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
118
|
+
className: `${contextMenu_module.menuItem} ${!arrangeStates.canBringToFront ? contextMenu_module.disabled : ''}`,
|
|
119
|
+
onClick: (e)=>{
|
|
120
|
+
e.stopPropagation();
|
|
121
|
+
if (arrangeStates.canBringToFront) {
|
|
122
|
+
arrangeActions.onBringToFront();
|
|
123
|
+
onClose();
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
children: "移至最前"
|
|
127
|
+
}),
|
|
128
|
+
/*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
129
|
+
className: `${contextMenu_module.menuItem} ${!arrangeStates.canBringForward ? contextMenu_module.disabled : ''}`,
|
|
130
|
+
onClick: (e)=>{
|
|
131
|
+
e.stopPropagation();
|
|
132
|
+
if (arrangeStates.canBringForward) {
|
|
133
|
+
arrangeActions.onBringForward();
|
|
134
|
+
onClose();
|
|
135
|
+
}
|
|
136
|
+
},
|
|
137
|
+
children: "置前"
|
|
138
|
+
}),
|
|
139
|
+
/*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
140
|
+
className: `${contextMenu_module.menuItem} ${!arrangeStates.canSendBackward ? contextMenu_module.disabled : ''}`,
|
|
141
|
+
onClick: (e)=>{
|
|
142
|
+
e.stopPropagation();
|
|
143
|
+
if (arrangeStates.canSendBackward) {
|
|
144
|
+
arrangeActions.onSendBackward();
|
|
145
|
+
onClose();
|
|
146
|
+
}
|
|
147
|
+
},
|
|
148
|
+
children: "置後"
|
|
149
|
+
}),
|
|
150
|
+
/*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
151
|
+
className: `${contextMenu_module.menuItem} ${!arrangeStates.canSendToBack ? contextMenu_module.disabled : ''}`,
|
|
152
|
+
onClick: (e)=>{
|
|
153
|
+
e.stopPropagation();
|
|
154
|
+
if (arrangeStates.canSendToBack) {
|
|
155
|
+
arrangeActions.onSendToBack();
|
|
156
|
+
onClose();
|
|
157
|
+
}
|
|
158
|
+
},
|
|
159
|
+
children: "移至最後"
|
|
160
|
+
})
|
|
161
|
+
]
|
|
162
|
+
})
|
|
163
|
+
]
|
|
164
|
+
})
|
|
165
|
+
]
|
|
166
|
+
});
|
|
167
|
+
// Render to document body to avoid z-index issues
|
|
168
|
+
return /*#__PURE__*/ reactDom.createPortal(contextMenuElement, document.body);
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
module.exports = ContextMenu;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
interface ArrangeActions {
|
|
3
|
+
onBringToFront: () => void;
|
|
4
|
+
onBringForward: () => void;
|
|
5
|
+
onSendBackward: () => void;
|
|
6
|
+
onSendToBack: () => void;
|
|
7
|
+
}
|
|
8
|
+
interface ArrangeStates {
|
|
9
|
+
canBringToFront: boolean;
|
|
10
|
+
canBringForward: boolean;
|
|
11
|
+
canSendBackward: boolean;
|
|
12
|
+
canSendToBack: boolean;
|
|
13
|
+
}
|
|
14
|
+
interface ContextMenuProps {
|
|
15
|
+
visible: boolean;
|
|
16
|
+
x: number;
|
|
17
|
+
y: number;
|
|
18
|
+
onClose: () => void;
|
|
19
|
+
onCopyPaste: () => void;
|
|
20
|
+
onDelete: () => void;
|
|
21
|
+
arrangeActions: ArrangeActions;
|
|
22
|
+
arrangeStates: ArrangeStates;
|
|
23
|
+
}
|
|
24
|
+
declare const ContextMenu: FC<ContextMenuProps>;
|
|
25
|
+
export default ContextMenu;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var styles = {"contextMenu":"context-menu-module_contextMenu__sLD6R","menuItem":"context-menu-module_menuItem__f0SPx","disabled":"context-menu-module_disabled__08MXH","menuItemContent":"context-menu-module_menuItemContent__GXixI","menuItemText":"context-menu-module_menuItemText__GLxb4","menuItemShortcut":"context-menu-module_menuItemShortcut__z-DrG","hasSubmenu":"context-menu-module_hasSubmenu__JYdzl","arrow":"context-menu-module_arrow__nLoR1","submenu":"context-menu-module_submenu__pV8AQ"};
|
|
4
|
+
|
|
5
|
+
module.exports = styles;
|