1 | import "./main.css";
|
2 | import {jsx as $duWW8$jsx, jsxs as $duWW8$jsxs, Fragment as $duWW8$Fragment} from "react/jsx-runtime";
|
3 | import $duWW8$react, {createContext as $duWW8$createContext, useContext as $duWW8$useContext, useMemo as $duWW8$useMemo, useRef as $duWW8$useRef, useState as $duWW8$useState, useCallback as $duWW8$useCallback, useEffect as $duWW8$useEffect} from "react";
|
4 | import {createPortal as $duWW8$createPortal} from "react-dom";
|
5 |
|
6 |
|
7 | function $parcel$export(e, n, v, s) {
|
8 | Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
9 | }
|
10 |
|
11 | function $parcel$interopDefault(a) {
|
12 | return a && a.__esModule ? a.default : a;
|
13 | }
|
14 |
|
15 |
|
16 | var $b65191f6d0a0a991$exports = {};
|
17 |
|
18 | $parcel$export($b65191f6d0a0a991$exports, "ContextMenuHandler", function () { return $1e1c1e9e0b943830$export$ed4f9641643dc7e4; });
|
19 | $parcel$export($b65191f6d0a0a991$exports, "ContextWindow", function () { return $b5e8657823def5be$export$1af8984c69ba1b24; });
|
20 | $parcel$export($b65191f6d0a0a991$exports, "ContextWindowStack", function () { return $17c46b9e6a2eb66e$export$9f37482ccd50dad2; });
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 | var $47067f35ca62d4a5$exports = {};
|
27 |
|
28 | $parcel$export($47067f35ca62d4a5$exports, "anchor", function () { return $47067f35ca62d4a5$export$2e2992790a6f69a8; }, function (v) { return $47067f35ca62d4a5$export$2e2992790a6f69a8 = v; });
|
29 | $parcel$export($47067f35ca62d4a5$exports, "caretHolder", function () { return $47067f35ca62d4a5$export$6ed5f4fbab298e07; }, function (v) { return $47067f35ca62d4a5$export$6ed5f4fbab298e07 = v; });
|
30 | $parcel$export($47067f35ca62d4a5$exports, "contextMenu", function () { return $47067f35ca62d4a5$export$218b899e1d476006; }, function (v) { return $47067f35ca62d4a5$export$218b899e1d476006 = v; });
|
31 | $parcel$export($47067f35ca62d4a5$exports, "contextMenuHandler", function () { return $47067f35ca62d4a5$export$ed8ffb5bb55a3bc8; }, function (v) { return $47067f35ca62d4a5$export$ed8ffb5bb55a3bc8 = v; });
|
32 | $parcel$export($47067f35ca62d4a5$exports, "contextMenuItem", function () { return $47067f35ca62d4a5$export$e5ea51c279904378; }, function (v) { return $47067f35ca62d4a5$export$e5ea51c279904378 = v; });
|
33 | $parcel$export($47067f35ca62d4a5$exports, "contextMenuItemLabel", function () { return $47067f35ca62d4a5$export$6ada86c5b962aa22; }, function (v) { return $47067f35ca62d4a5$export$6ada86c5b962aa22 = v; });
|
34 | $parcel$export($47067f35ca62d4a5$exports, "disabled", function () { return $47067f35ca62d4a5$export$683472f6198a076e; }, function (v) { return $47067f35ca62d4a5$export$683472f6198a076e = v; });
|
35 | $parcel$export($47067f35ca62d4a5$exports, "hidden", function () { return $47067f35ca62d4a5$export$73920f18ca706874; }, function (v) { return $47067f35ca62d4a5$export$73920f18ca706874 = v; });
|
36 | $parcel$export($47067f35ca62d4a5$exports, "subMenu", function () { return $47067f35ca62d4a5$export$6e0e6ce39e5a0361; }, function (v) { return $47067f35ca62d4a5$export$6e0e6ce39e5a0361 = v; });
|
37 | $parcel$export($47067f35ca62d4a5$exports, "visible", function () { return $47067f35ca62d4a5$export$664c6d24e3175067; }, function (v) { return $47067f35ca62d4a5$export$664c6d24e3175067 = v; });
|
38 | var $47067f35ca62d4a5$export$2e2992790a6f69a8;
|
39 | var $47067f35ca62d4a5$export$6ed5f4fbab298e07;
|
40 | var $47067f35ca62d4a5$export$218b899e1d476006;
|
41 | var $47067f35ca62d4a5$export$ed8ffb5bb55a3bc8;
|
42 | var $47067f35ca62d4a5$export$e5ea51c279904378;
|
43 | var $47067f35ca62d4a5$export$6ada86c5b962aa22;
|
44 | var $47067f35ca62d4a5$export$683472f6198a076e;
|
45 | var $47067f35ca62d4a5$export$73920f18ca706874;
|
46 | var $47067f35ca62d4a5$export$6e0e6ce39e5a0361;
|
47 | var $47067f35ca62d4a5$export$664c6d24e3175067;
|
48 | $47067f35ca62d4a5$export$2e2992790a6f69a8 = `aiw-WinFxq-anchor`;
|
49 | $47067f35ca62d4a5$export$6ed5f4fbab298e07 = `aiw-WinFxq-caretHolder`;
|
50 | $47067f35ca62d4a5$export$218b899e1d476006 = `aiw-WinFxq-contextMenu`;
|
51 | $47067f35ca62d4a5$export$ed8ffb5bb55a3bc8 = `aiw-WinFxq-contextMenuHandler`;
|
52 | $47067f35ca62d4a5$export$e5ea51c279904378 = `aiw-WinFxq-contextMenuItem`;
|
53 | $47067f35ca62d4a5$export$6ada86c5b962aa22 = `aiw-WinFxq-contextMenuItemLabel`;
|
54 | $47067f35ca62d4a5$export$683472f6198a076e = `aiw-WinFxq-disabled`;
|
55 | $47067f35ca62d4a5$export$73920f18ca706874 = `aiw-WinFxq-hidden`;
|
56 | $47067f35ca62d4a5$export$6e0e6ce39e5a0361 = `aiw-WinFxq-subMenu`;
|
57 | $47067f35ca62d4a5$export$664c6d24e3175067 = `aiw-WinFxq-visible`;
|
58 |
|
59 |
|
60 |
|
61 |
|
62 |
|
63 |
|
64 | const $6ca59110355c8bf1$export$7e4e6110f96afd7e = ({ entries: entries, toClose: toClose })=>{
|
65 | const [visible, setVisible] = (0, $duWW8$useState)(false);
|
66 | return (0, $duWW8$jsxs)("span", {
|
67 | className: (0, ($parcel$interopDefault($47067f35ca62d4a5$exports))).caretHolder,
|
68 | onMouseEnter: ()=>{
|
69 | setVisible(true);
|
70 | },
|
71 | onMouseLeave: ()=>{
|
72 | setVisible(false);
|
73 | },
|
74 | children: [
|
75 | (0, $duWW8$jsx)("svg", {
|
76 | xmlns: "http://www.w3.org/2000/svg",
|
77 | width: "16",
|
78 | height: "16",
|
79 | fill: "currentColor",
|
80 | viewBox: "0 0 16 16",
|
81 | children: (0, $duWW8$jsx)("path", {
|
82 | d: "m12.14 8.753-5.482 4.796c-.646.566-1.658.106-1.658-.753V3.204a1 1 0 0 1 1.659-.753l5.48 4.796a1 1 0 0 1 0 1.506z"
|
83 | })
|
84 | }),
|
85 | (0, $duWW8$jsx)("div", {
|
86 | className: (0, ($parcel$interopDefault($47067f35ca62d4a5$exports))).subMenu,
|
87 | children: (0, $duWW8$jsx)((0, $567ed433af94513f$export$8dc6765e8be191c7), {
|
88 | visible: visible,
|
89 | entries: entries,
|
90 | xPos: 14,
|
91 | yPos: -21,
|
92 | toClose: toClose
|
93 | })
|
94 | })
|
95 | ]
|
96 | });
|
97 | };
|
98 | $6ca59110355c8bf1$export$7e4e6110f96afd7e.displayName = "ContextSubMenu";
|
99 |
|
100 |
|
101 | const $567ed433af94513f$export$8dc6765e8be191c7 = (0, $duWW8$react).forwardRef(({ visible: visible, entries: entries, xPos: xPos, yPos: yPos, toClose: toClose }, ref)=>{
|
102 | const [target, setTarget] = (0, $duWW8$useState)(null);
|
103 | return (0, $duWW8$jsx)("div", {
|
104 | ref: ref,
|
105 | className: [
|
106 | (0, ($parcel$interopDefault($47067f35ca62d4a5$exports))).contextMenu,
|
107 | visible ? (0, ($parcel$interopDefault($47067f35ca62d4a5$exports))).visible : (0, ($parcel$interopDefault($47067f35ca62d4a5$exports))).hidden
|
108 | ].filter((c)=>c !== "").join(" "),
|
109 | style: {
|
110 | top: `${yPos}px`,
|
111 | left: `${xPos}px`
|
112 | },
|
113 | onContextMenuCapture: (e)=>{
|
114 | e.preventDefault();
|
115 | e.stopPropagation();
|
116 | },
|
117 | children: entries.map((entry, i)=> (0, $duWW8$jsxs)("div", {
|
118 | className: [
|
119 | (0, ($parcel$interopDefault($47067f35ca62d4a5$exports))).contextMenuItem,
|
120 | entry.disabled ? (0, ($parcel$interopDefault($47067f35ca62d4a5$exports))).disabled : ""
|
121 | ].filter((c)=>c !== "").join(" "),
|
122 | children: [
|
123 | typeof entry.label === "string" ? (0, $duWW8$jsx)("span", {
|
124 | "aria-label": typeof entry.label === "string" ? entry.label : undefined,
|
125 | "aria-disabled": entry.disabled,
|
126 | className: (0, ($parcel$interopDefault($47067f35ca62d4a5$exports))).contextMenuItemLabel,
|
127 | onMouseEnter: ()=>{
|
128 | const sel = window.getSelection();
|
129 | const target = sel && sel.rangeCount > 0 ? sel.getRangeAt(0) : null;
|
130 | setTarget(target);
|
131 | },
|
132 | onMouseLeave: ()=>{
|
133 | setTarget(null);
|
134 | },
|
135 | onMouseDownCapture: (e)=>{
|
136 | e.preventDefault();
|
137 | e.stopPropagation();
|
138 | entry.action && !entry.disabled && entry.action(target);
|
139 | !entry.disabled && toClose();
|
140 | },
|
141 | children: entry.label
|
142 | }) : entry.label,
|
143 | entry.group && (0, $duWW8$jsx)((0, $6ca59110355c8bf1$export$7e4e6110f96afd7e), {
|
144 | toClose: toClose,
|
145 | entries: entry.group
|
146 | })
|
147 | ]
|
148 | }, i))
|
149 | });
|
150 | });
|
151 | $567ed433af94513f$export$8dc6765e8be191c7.displayName = "ContextMenu";
|
152 |
|
153 |
|
154 |
|
155 |
|
156 | var $c7a6ae87165004e6$exports = {};
|
157 |
|
158 | $parcel$export($c7a6ae87165004e6$exports, "caretHolder", function () { return $c7a6ae87165004e6$export$6ed5f4fbab298e07; }, function (v) { return $c7a6ae87165004e6$export$6ed5f4fbab298e07 = v; });
|
159 | $parcel$export($c7a6ae87165004e6$exports, "disabled", function () { return $c7a6ae87165004e6$export$683472f6198a076e; }, function (v) { return $c7a6ae87165004e6$export$683472f6198a076e = v; });
|
160 | $parcel$export($c7a6ae87165004e6$exports, "hidden", function () { return $c7a6ae87165004e6$export$73920f18ca706874; }, function (v) { return $c7a6ae87165004e6$export$73920f18ca706874 = v; });
|
161 | $parcel$export($c7a6ae87165004e6$exports, "lowMenu", function () { return $c7a6ae87165004e6$export$59e4b099a896b33; }, function (v) { return $c7a6ae87165004e6$export$59e4b099a896b33 = v; });
|
162 | $parcel$export($c7a6ae87165004e6$exports, "lowMenu-item", function () { return $c7a6ae87165004e6$export$19fbf76b734bf310; }, function (v) { return $c7a6ae87165004e6$export$19fbf76b734bf310 = v; });
|
163 | $parcel$export($c7a6ae87165004e6$exports, "lowMenuButtonHolder", function () { return $c7a6ae87165004e6$export$22ec12d194e0789c; }, function (v) { return $c7a6ae87165004e6$export$22ec12d194e0789c = v; });
|
164 | $parcel$export($c7a6ae87165004e6$exports, "lowMenuItem", function () { return $c7a6ae87165004e6$export$2ad34a478577e75d; }, function (v) { return $c7a6ae87165004e6$export$2ad34a478577e75d = v; });
|
165 | $parcel$export($c7a6ae87165004e6$exports, "subMenu", function () { return $c7a6ae87165004e6$export$6e0e6ce39e5a0361; }, function (v) { return $c7a6ae87165004e6$export$6e0e6ce39e5a0361 = v; });
|
166 | $parcel$export($c7a6ae87165004e6$exports, "visible", function () { return $c7a6ae87165004e6$export$664c6d24e3175067; }, function (v) { return $c7a6ae87165004e6$export$664c6d24e3175067 = v; });
|
167 | var $c7a6ae87165004e6$export$6ed5f4fbab298e07;
|
168 | var $c7a6ae87165004e6$export$683472f6198a076e;
|
169 | var $c7a6ae87165004e6$export$73920f18ca706874;
|
170 | var $c7a6ae87165004e6$export$59e4b099a896b33;
|
171 | var $c7a6ae87165004e6$export$19fbf76b734bf310;
|
172 | var $c7a6ae87165004e6$export$22ec12d194e0789c;
|
173 | var $c7a6ae87165004e6$export$2ad34a478577e75d;
|
174 | var $c7a6ae87165004e6$export$6e0e6ce39e5a0361;
|
175 | var $c7a6ae87165004e6$export$664c6d24e3175067;
|
176 | $c7a6ae87165004e6$export$6ed5f4fbab298e07 = `aiw-JfzGeq-caretHolder`;
|
177 | $c7a6ae87165004e6$export$683472f6198a076e = `aiw-JfzGeq-disabled`;
|
178 | $c7a6ae87165004e6$export$73920f18ca706874 = `aiw-JfzGeq-hidden`;
|
179 | $c7a6ae87165004e6$export$59e4b099a896b33 = `aiw-JfzGeq-lowMenu`;
|
180 | $c7a6ae87165004e6$export$19fbf76b734bf310 = `aiw-JfzGeq-lowMenu-item`;
|
181 | $c7a6ae87165004e6$export$22ec12d194e0789c = `aiw-JfzGeq-lowMenuButtonHolder`;
|
182 | $c7a6ae87165004e6$export$2ad34a478577e75d = `aiw-JfzGeq-lowMenuItem`;
|
183 | $c7a6ae87165004e6$export$6e0e6ce39e5a0361 = `aiw-JfzGeq-subMenu`;
|
184 | $c7a6ae87165004e6$export$664c6d24e3175067 = `aiw-JfzGeq-visible`;
|
185 |
|
186 |
|
187 |
|
188 |
|
189 |
|
190 |
|
191 |
|
192 |
|
193 | const $61945e5157f5e5bf$export$251b9f54013cdfac = ({ entry: entry })=>{
|
194 | const [visible, setVisible] = (0, $duWW8$useState)(false);
|
195 | if (!entry.group || entry.group.length === 0) return (0, $duWW8$jsx)((0, $duWW8$Fragment), {});
|
196 | return (0, $duWW8$jsxs)("span", {
|
197 | "aria-label": `Sub menu for ${entry.label}`,
|
198 | className: (0, ($parcel$interopDefault($c7a6ae87165004e6$exports))).caretHolder,
|
199 | onMouseEnter: ()=>{
|
200 | setVisible(true);
|
201 | },
|
202 | onMouseLeave: ()=>{
|
203 | setVisible(false);
|
204 | },
|
205 | children: [
|
206 | (0, $duWW8$jsx)("svg", {
|
207 | xmlns: "http://www.w3.org/2000/svg",
|
208 | width: "16",
|
209 | height: "16",
|
210 | fill: "currentColor",
|
211 | viewBox: "0 0 16 16",
|
212 | children: (0, $duWW8$jsx)("path", {
|
213 | d: "m12.14 8.753-5.482 4.796c-.646.566-1.658.106-1.658-.753V3.204a1 1 0 0 1 1.659-.753l5.48 4.796a1 1 0 0 1 0 1.506z"
|
214 | })
|
215 | }),
|
216 | (0, $duWW8$jsx)("div", {
|
217 | className: (0, ($parcel$interopDefault($c7a6ae87165004e6$exports))).subMenu,
|
218 | children: visible && (0, $duWW8$jsx)((0, $567ed433af94513f$export$8dc6765e8be191c7), {
|
219 | visible: visible,
|
220 | entries: entry.group,
|
221 | xPos: 14,
|
222 | yPos: entry.group.length * -21 - 8,
|
223 | toClose: ()=>setVisible(false)
|
224 | })
|
225 | })
|
226 | ]
|
227 | });
|
228 | };
|
229 | $61945e5157f5e5bf$export$251b9f54013cdfac.displayName = "LowSubMenu";
|
230 |
|
231 |
|
232 |
|
233 | const $556d6f9158abfc99$export$aafc28aea571c4bc = ({ entry: entry })=>{
|
234 | const [target, setTarget] = (0, $duWW8$useState)(null);
|
235 | return (0, $duWW8$jsxs)("div", {
|
236 | className: [
|
237 | (0, ($parcel$interopDefault($c7a6ae87165004e6$exports))).lowMenuItem,
|
238 | entry.disabled ? (0, ($parcel$interopDefault($c7a6ae87165004e6$exports))).disabled : ""
|
239 | ].filter((c)=>c !== "").join(" "),
|
240 | "aria-label": typeof entry.label === "string" ? entry.label : undefined,
|
241 | "aria-disabled": entry.disabled,
|
242 | onMouseEnter: ()=>{
|
243 | const sel = window.getSelection();
|
244 | const target = sel && sel.rangeCount > 0 ? sel.getRangeAt(0) : null;
|
245 | setTarget(target);
|
246 | },
|
247 | onMouseLeave: ()=>{
|
248 | setTarget(null);
|
249 | },
|
250 | onClick: (e)=>{
|
251 | e.preventDefault();
|
252 | e.stopPropagation();
|
253 | entry.action && !entry.disabled && entry.action(target);
|
254 | },
|
255 | children: [
|
256 | (0, $duWW8$jsx)("span", {
|
257 | children: entry.label
|
258 | }),
|
259 | entry.group && (0, $duWW8$jsx)((0, $61945e5157f5e5bf$export$251b9f54013cdfac), {
|
260 | entry: entry
|
261 | })
|
262 | ]
|
263 | });
|
264 | };
|
265 | $556d6f9158abfc99$export$aafc28aea571c4bc.displayName = "LowMenuButton";
|
266 |
|
267 |
|
268 | const $914758b0c9d59759$export$49e8edc8ebca5f25 = ({ entries: entries, visible: visible, xPos: xPos, yPos: yPos, maxWidth: maxWidth })=>{
|
269 | return (0, $duWW8$jsx)("div", {
|
270 | className: [
|
271 | (0, ($parcel$interopDefault($c7a6ae87165004e6$exports))).lowMenu,
|
272 | visible ? (0, ($parcel$interopDefault($c7a6ae87165004e6$exports))).visible : (0, ($parcel$interopDefault($c7a6ae87165004e6$exports))).hidden
|
273 | ].join(" "),
|
274 | "aria-label": "Low context menu",
|
275 | style: {
|
276 | left: `${xPos}px`,
|
277 | top: `${yPos}px`,
|
278 | maxWidth: `calc(${maxWidth}px)`,
|
279 | width: `calc(${maxWidth}px - 4px)`
|
280 | },
|
281 | children: (0, $duWW8$jsx)("div", {
|
282 | className: (0, ($parcel$interopDefault($c7a6ae87165004e6$exports))).lowMenuButtonHolder,
|
283 | children: entries.map((e, i)=> (0, $duWW8$jsx)((0, $556d6f9158abfc99$export$aafc28aea571c4bc), {
|
284 | entry: e
|
285 | }, i))
|
286 | })
|
287 | });
|
288 | };
|
289 | $914758b0c9d59759$export$49e8edc8ebca5f25.displayName = "LowMenu";
|
290 |
|
291 |
|
292 | const $1e1c1e9e0b943830$export$fc58dc71afe92de2 = (0, $duWW8$createContext)(null);
|
293 | const $1e1c1e9e0b943830$export$ed4f9641643dc7e4 = ({ children: children, menuItems: menuItems, showLowMenu: showLowMenu = false, ...rest })=>{
|
294 | var _divHandlderRef_current;
|
295 |
|
296 | const higherContext = (0, $duWW8$useContext)($1e1c1e9e0b943830$export$fc58dc71afe92de2);
|
297 | const thisMenuItems = (0, $duWW8$useMemo)(()=>[
|
298 | ...higherContext !== null ? [
|
299 | ...higherContext.menuItems,
|
300 | {
|
301 | label: (0, $duWW8$jsx)("hr", {
|
302 | style: {
|
303 | flexGrow: 1,
|
304 | cursor: "none",
|
305 | margin: "0",
|
306 | padding: "0"
|
307 | }
|
308 | })
|
309 | }
|
310 | ] : [],
|
311 | ...menuItems
|
312 | ], [
|
313 | higherContext,
|
314 | menuItems
|
315 | ]);
|
316 |
|
317 | const divHandlderRef = (0, $duWW8$useRef)(null);
|
318 | const menuRef = (0, $duWW8$useRef)(null);
|
319 | const [menuXPos, setMenuXPos] = (0, $duWW8$useState)(0);
|
320 | const [menuYPos, setMenuYPos] = (0, $duWW8$useState)(0);
|
321 | const [menuVisible, setMenuVisible] = (0, $duWW8$useState)(false);
|
322 | const [menuInDom, setMenuInDom] = (0, $duWW8$useState)(false);
|
323 | const [mouseOverHandlerDiv, setMouseOverHandlerDiv] = (0, $duWW8$useState)(false);
|
324 | const [mouseOverMenu, setMouseOverMenu] = (0, $duWW8$useState)(false);
|
325 |
|
326 | const divHandlerPos = divHandlderRef ? (_divHandlderRef_current = divHandlderRef.current) === null || _divHandlderRef_current === void 0 ? void 0 : _divHandlderRef_current.getBoundingClientRect() : null;
|
327 |
|
328 | const handleClick = (0, $duWW8$useCallback)((e)=>{
|
329 | var _menuRef_current;
|
330 | if (menuRef.current && (e.target instanceof Element && !((_menuRef_current = menuRef.current) === null || _menuRef_current === void 0 ? void 0 : _menuRef_current.contains(e.target)) || !(e.target instanceof Element))) setMenuVisible(false);
|
331 | }, []);
|
332 |
|
333 | (0, $duWW8$useEffect)(()=>{
|
334 | if (menuVisible) document.addEventListener("mousedown", handleClick);
|
335 | else document.removeEventListener("mousedown", handleClick);
|
336 | return ()=>{
|
337 | document.removeEventListener("mousedown", handleClick);
|
338 | };
|
339 | }, [
|
340 | handleClick,
|
341 | menuVisible
|
342 | ]);
|
343 | const removeController = (0, $duWW8$useRef)(new AbortController());
|
344 | (0, $duWW8$useEffect)(()=>{
|
345 | if (!mouseOverMenu && !menuVisible && !mouseOverHandlerDiv) {
|
346 | removeController.current.abort();
|
347 | removeController.current = new AbortController();
|
348 | setTimeout(()=>{
|
349 | if (!removeController.current.signal.aborted) setMenuInDom(false);
|
350 | }, 300);
|
351 | }
|
352 | }, [
|
353 | mouseOverHandlerDiv,
|
354 | menuVisible,
|
355 | mouseOverMenu
|
356 | ]);
|
357 | return (0, $duWW8$jsxs)($1e1c1e9e0b943830$export$fc58dc71afe92de2.Provider, {
|
358 | value: {
|
359 | menuItems: thisMenuItems
|
360 | },
|
361 | children: [
|
362 | (0, $duWW8$jsx)("div", {
|
363 | ref: divHandlderRef,
|
364 | ...rest,
|
365 | className: [
|
366 | (0, ($parcel$interopDefault($47067f35ca62d4a5$exports))).contextMenuHandler,
|
367 | rest.className
|
368 | ].join(" "),
|
369 | style: {
|
370 | ...rest.style
|
371 | },
|
372 | onContextMenu: (e)=>{
|
373 | if (!showLowMenu) {
|
374 | setMenuInDom(true);
|
375 | e.preventDefault();
|
376 | e.stopPropagation();
|
377 | setTimeout(()=>{
|
378 | removeController.current.abort();
|
379 | setMenuVisible(true);
|
380 | setMenuXPos(e.pageX);
|
381 | setMenuYPos(e.pageY);
|
382 | }, 1);
|
383 | }
|
384 | },
|
385 | onMouseEnter: ()=>{
|
386 | if (showLowMenu) {
|
387 | setMenuInDom(true);
|
388 | setMouseOverHandlerDiv(false);
|
389 | setTimeout(()=>{
|
390 | removeController.current.abort();
|
391 | setMouseOverHandlerDiv(true);
|
392 | }, 1);
|
393 | }
|
394 | },
|
395 | onMouseLeave: ()=>{
|
396 | if (showLowMenu) {
|
397 | removeController.current.abort();
|
398 | removeController.current = new AbortController();
|
399 | setMouseOverHandlerDiv(false);
|
400 | }
|
401 | },
|
402 | children: children
|
403 | }),
|
404 | menuInDom && divHandlerPos && (0, $duWW8$createPortal)( (0, $duWW8$jsx)("div", {
|
405 | className: (0, ($parcel$interopDefault($47067f35ca62d4a5$exports))).anchor,
|
406 | onMouseEnter: ()=>{
|
407 | removeController.current.abort();
|
408 | setMouseOverMenu(true);
|
409 | },
|
410 | onMouseLeave: ()=>{
|
411 | removeController.current.abort();
|
412 | removeController.current = new AbortController();
|
413 | setMouseOverMenu(false);
|
414 | },
|
415 | children: showLowMenu ? (0, $duWW8$jsx)((0, $914758b0c9d59759$export$49e8edc8ebca5f25), {
|
416 | visible: mouseOverHandlerDiv,
|
417 | entries: menuItems,
|
418 | xPos: divHandlerPos.left,
|
419 | yPos: divHandlerPos.bottom,
|
420 | maxWidth: divHandlerPos.width
|
421 | }) : (0, $duWW8$jsx)((0, $567ed433af94513f$export$8dc6765e8be191c7), {
|
422 | visible: menuVisible,
|
423 | ref: menuRef,
|
424 | entries: thisMenuItems,
|
425 | xPos: menuXPos,
|
426 | yPos: menuYPos,
|
427 | toClose: ()=>{
|
428 | setMenuVisible(false);
|
429 | setMouseOverMenu(false);
|
430 | }
|
431 | })
|
432 | }), document.body)
|
433 | ]
|
434 | });
|
435 | };
|
436 | $1e1c1e9e0b943830$export$ed4f9641643dc7e4.displayName = "ContextMenuHandler";
|
437 |
|
438 |
|
439 |
|
440 |
|
441 |
|
442 | const $ab4d5d6bf03370d0$export$d81cfea7c54be196 = (divRef)=>{
|
443 | if (!divRef.current) return {
|
444 | translateX: 0,
|
445 | translateY: 0
|
446 | };
|
447 | else {
|
448 | const innerBounce = 16;
|
449 | const posn = divRef.current.getBoundingClientRect();
|
450 | let translateX = 0;
|
451 | if (posn.left < innerBounce) translateX = -posn.left + innerBounce;
|
452 | else if (posn.right > window.innerWidth) translateX = Math.max(-posn.left + innerBounce, window.innerWidth - posn.right - innerBounce);
|
453 | let translateY = 0;
|
454 | if (posn.top < innerBounce) translateY = -posn.top + innerBounce;
|
455 | else if (posn.bottom > window.innerHeight) translateY = Math.max(-posn.top + innerBounce, window.innerHeight - posn.bottom - innerBounce);
|
456 | return {
|
457 | translateX: translateX,
|
458 | translateY: translateY
|
459 | };
|
460 | }
|
461 | };
|
462 |
|
463 |
|
464 |
|
465 |
|
466 | const $17c46b9e6a2eb66e$export$aff5d0593e3727b0 = (0, $duWW8$createContext)(null);
|
467 | const $17c46b9e6a2eb66e$var$pushToTop = (windowId, minZIndex, windowList, setWindowList)=>{
|
468 | const otherWindows = windowList.filter((w)=>w.windowId !== windowId).map((w, i)=>({
|
469 | windowId: w.windowId,
|
470 | zIndex: minZIndex + i
|
471 | }));
|
472 | setWindowList([
|
473 | ...otherWindows,
|
474 | {
|
475 | windowId: windowId,
|
476 | zIndex: minZIndex + otherWindows.length
|
477 | }
|
478 | ]);
|
479 | };
|
480 | const $17c46b9e6a2eb66e$export$9f37482ccd50dad2 = ({ minZIndex: minZIndex = 1000, children: children })=>{
|
481 | const [currentWindows, setCurrentWindows] = (0, $duWW8$useState)([]);
|
482 | return (0, $duWW8$jsx)($17c46b9e6a2eb66e$export$aff5d0593e3727b0.Provider, {
|
483 | value: {
|
484 | currentWindows: currentWindows.map((w)=>({
|
485 | windowId: w.windowId,
|
486 | zIndex: minZIndex + w.zIndex
|
487 | })),
|
488 | pushToTop: (ret)=>$17c46b9e6a2eb66e$var$pushToTop(ret, minZIndex, currentWindows, setCurrentWindows)
|
489 | },
|
490 | children: children
|
491 | });
|
492 | };
|
493 | $17c46b9e6a2eb66e$export$9f37482ccd50dad2.displayName = "ContextWindowStack";
|
494 |
|
495 |
|
496 | var $ddf7153c7c69b209$exports = {};
|
497 |
|
498 | $parcel$export($ddf7153c7c69b209$exports, "contextWindow", function () { return $ddf7153c7c69b209$export$72cad2e5ad4d2674; }, function (v) { return $ddf7153c7c69b209$export$72cad2e5ad4d2674 = v; });
|
499 | $parcel$export($ddf7153c7c69b209$exports, "contextWindowAnchor", function () { return $ddf7153c7c69b209$export$9f3a8a17ac700f7d; }, function (v) { return $ddf7153c7c69b209$export$9f3a8a17ac700f7d = v; });
|
500 | $parcel$export($ddf7153c7c69b209$exports, "contextWindowBody", function () { return $ddf7153c7c69b209$export$dfb2c4d2d1c0156f; }, function (v) { return $ddf7153c7c69b209$export$dfb2c4d2d1c0156f = v; });
|
501 | $parcel$export($ddf7153c7c69b209$exports, "contextWindowTitle", function () { return $ddf7153c7c69b209$export$1b02f2cd2f7db0f4; }, function (v) { return $ddf7153c7c69b209$export$1b02f2cd2f7db0f4 = v; });
|
502 | $parcel$export($ddf7153c7c69b209$exports, "contextWindowTitleClose", function () { return $ddf7153c7c69b209$export$7ba38d4cc2870e66; }, function (v) { return $ddf7153c7c69b209$export$7ba38d4cc2870e66 = v; });
|
503 | $parcel$export($ddf7153c7c69b209$exports, "contextWindowTitleText", function () { return $ddf7153c7c69b209$export$cebbac70b4d99c48; }, function (v) { return $ddf7153c7c69b209$export$cebbac70b4d99c48 = v; });
|
504 | $parcel$export($ddf7153c7c69b209$exports, "moving", function () { return $ddf7153c7c69b209$export$d03a2f3acc60252b; }, function (v) { return $ddf7153c7c69b209$export$d03a2f3acc60252b = v; });
|
505 | var $ddf7153c7c69b209$export$72cad2e5ad4d2674;
|
506 | var $ddf7153c7c69b209$export$9f3a8a17ac700f7d;
|
507 | var $ddf7153c7c69b209$export$dfb2c4d2d1c0156f;
|
508 | var $ddf7153c7c69b209$export$1b02f2cd2f7db0f4;
|
509 | var $ddf7153c7c69b209$export$7ba38d4cc2870e66;
|
510 | var $ddf7153c7c69b209$export$cebbac70b4d99c48;
|
511 | var $ddf7153c7c69b209$export$d03a2f3acc60252b;
|
512 | $ddf7153c7c69b209$export$72cad2e5ad4d2674 = `aiw-RIIF9a-contextWindow`;
|
513 | $ddf7153c7c69b209$export$9f3a8a17ac700f7d = `aiw-RIIF9a-contextWindowAnchor`;
|
514 | $ddf7153c7c69b209$export$dfb2c4d2d1c0156f = `aiw-RIIF9a-contextWindowBody`;
|
515 | $ddf7153c7c69b209$export$1b02f2cd2f7db0f4 = `aiw-RIIF9a-contextWindowTitle`;
|
516 | $ddf7153c7c69b209$export$7ba38d4cc2870e66 = `aiw-RIIF9a-contextWindowTitleClose`;
|
517 | $ddf7153c7c69b209$export$cebbac70b4d99c48 = `aiw-RIIF9a-contextWindowTitleText`;
|
518 | $ddf7153c7c69b209$export$d03a2f3acc60252b = `aiw-RIIF9a-moving`;
|
519 |
|
520 |
|
521 | const $b5e8657823def5be$export$1af8984c69ba1b24 = ({ id: id, visible: visible, title: title, children: children, onOpen: onOpen, onClose: onClose, ...rest })=>{
|
522 | var _rest_style, _rest_style1, _rest_style2, _rest_style3;
|
523 | const windowStack = (0, $duWW8$useContext)((0, $17c46b9e6a2eb66e$export$aff5d0593e3727b0));
|
524 | const windowId = (0, $duWW8$useRef)(null);
|
525 | const divRef = (0, $duWW8$useRef)(null);
|
526 | const windowRef = (0, $duWW8$useRef)(null);
|
527 | const [windowInDOM, setWindowInDOM] = (0, $duWW8$useState)(false);
|
528 | const [windowVisible, setWindowVisible] = (0, $duWW8$useState)(false);
|
529 | const zIndex = (0, $duWW8$useMemo)(()=>{
|
530 | var _windowStack_currentWindows_find;
|
531 | var _windowStack_currentWindows_find_zIndex;
|
532 | return (_windowStack_currentWindows_find_zIndex = windowStack === null || windowStack === void 0 ? void 0 : (_windowStack_currentWindows_find = windowStack.currentWindows.find((w)=>w.windowId === windowId.current)) === null || _windowStack_currentWindows_find === void 0 ? void 0 : _windowStack_currentWindows_find.zIndex) !== null && _windowStack_currentWindows_find_zIndex !== void 0 ? _windowStack_currentWindows_find_zIndex : 1;
|
533 | }, [
|
534 | windowStack === null || windowStack === void 0 ? void 0 : windowStack.currentWindows
|
535 | ]);
|
536 |
|
537 | const windowPos = (0, $duWW8$useRef)({
|
538 | x: 0,
|
539 | y: 0
|
540 | });
|
541 | const [moving, setMoving] = (0, $duWW8$useState)(false);
|
542 | const move = (0, $duWW8$useCallback)((x, y)=>{
|
543 | if (windowRef.current && windowPos.current) {
|
544 | const window1 = windowRef.current;
|
545 | const pos = windowPos.current;
|
546 | pos.x += x;
|
547 | pos.y += y;
|
548 | window1.style.transform = `translate(${pos.x}px, ${pos.y}px)`;
|
549 | }
|
550 | }, []);
|
551 | const checkPosition = (0, $duWW8$useCallback)(()=>{
|
552 | const chkPos = (0, $ab4d5d6bf03370d0$export$d81cfea7c54be196)(windowRef);
|
553 | move(chkPos.translateX, chkPos.translateY);
|
554 | }, [
|
555 | move
|
556 | ]);
|
557 | const mouseMove = (0, $duWW8$useCallback)((e)=>{
|
558 | e.preventDefault();
|
559 | e.stopPropagation();
|
560 | move(e.movementX, e.movementY);
|
561 | }, [
|
562 | move
|
563 | ]);
|
564 | const mouseUp = (0, $duWW8$useCallback)((e)=>{
|
565 | e.preventDefault();
|
566 | e.stopPropagation();
|
567 | setMoving(false);
|
568 | checkPosition();
|
569 | document.removeEventListener("mousemove", mouseMove);
|
570 | document.removeEventListener("mouseup", mouseUp);
|
571 | window.removeEventListener("resize", checkPosition);
|
572 | if (e.target && (e.target instanceof HTMLElement || e.target instanceof SVGElement)) e.target.style.userSelect = "auto";
|
573 | }, [
|
574 | checkPosition,
|
575 | mouseMove
|
576 | ]);
|
577 |
|
578 | (0, $duWW8$useEffect)(()=>{
|
579 | if (windowStack) {
|
580 |
|
581 | if (visible && !windowInDOM) setWindowInDOM(true);
|
582 | else if (visible && windowInDOM && !windowVisible) {
|
583 | if (!windowId.current) {
|
584 | const maxWindowId = Math.max(0, ...windowStack.currentWindows.map((w)=>w.windowId));
|
585 | windowId.current = maxWindowId + 1;
|
586 | }
|
587 | windowStack.pushToTop(windowId.current);
|
588 | setWindowVisible(visible);
|
589 | onOpen && onOpen();
|
590 |
|
591 | if (divRef.current && windowRef.current) {
|
592 | const parentPos = divRef.current.getBoundingClientRect();
|
593 | const pos = windowRef.current.getBoundingClientRect();
|
594 | const windowHeight = pos.bottom - pos.top;
|
595 | windowRef.current.style.left = `${parentPos.left}px`;
|
596 | windowRef.current.style.top = `${parentPos.bottom + windowHeight < window.innerHeight ? parentPos.bottom : Math.max(0, parentPos.top - windowHeight)}px`;
|
597 | windowRef.current.style.transform = "";
|
598 | windowPos.current = {
|
599 | x: 0,
|
600 | y: 0
|
601 | };
|
602 | }
|
603 | checkPosition();
|
604 | } else if (windowId.current && !visible && windowVisible) setWindowVisible(false);
|
605 | else if (windowId.current && !visible && windowInDOM) setWindowInDOM(false);
|
606 | }
|
607 | }, [
|
608 | checkPosition,
|
609 | onOpen,
|
610 | visible,
|
611 | windowInDOM,
|
612 | windowStack,
|
613 | windowVisible
|
614 | ]);
|
615 | var _rest_style_minHeight, _rest_style_minWidth, _rest_style_maxHeight, _rest_style_maxWidth;
|
616 | return (0, $duWW8$jsx)("div", {
|
617 | className: (0, ($parcel$interopDefault($ddf7153c7c69b209$exports))).contextWindowAnchor,
|
618 | ref: divRef,
|
619 | children: windowStack && windowInDOM && (0, $duWW8$createPortal)( (0, $duWW8$jsxs)("div", {
|
620 | ...rest,
|
621 | id: id,
|
622 | className: (0, ($parcel$interopDefault($ddf7153c7c69b209$exports))).contextWindow,
|
623 | style: {
|
624 | ...rest.style,
|
625 | opacity: moving ? 0.8 : windowVisible ? 1 : 0,
|
626 | visibility: windowVisible ? "visible" : "hidden",
|
627 | zIndex: zIndex !== null && zIndex !== void 0 ? zIndex : 1,
|
628 | minHeight: (_rest_style_minHeight = (_rest_style = rest.style) === null || _rest_style === void 0 ? void 0 : _rest_style.minHeight) !== null && _rest_style_minHeight !== void 0 ? _rest_style_minHeight : "150px",
|
629 | minWidth: (_rest_style_minWidth = (_rest_style1 = rest.style) === null || _rest_style1 === void 0 ? void 0 : _rest_style1.minWidth) !== null && _rest_style_minWidth !== void 0 ? _rest_style_minWidth : "200px",
|
630 | maxHeight: (_rest_style_maxHeight = (_rest_style2 = rest.style) === null || _rest_style2 === void 0 ? void 0 : _rest_style2.maxHeight) !== null && _rest_style_maxHeight !== void 0 ? _rest_style_maxHeight : "1000px",
|
631 | maxWidth: (_rest_style_maxWidth = (_rest_style3 = rest.style) === null || _rest_style3 === void 0 ? void 0 : _rest_style3.maxWidth) !== null && _rest_style_maxWidth !== void 0 ? _rest_style_maxWidth : "1000px"
|
632 | },
|
633 | onClickCapture: ()=>{
|
634 | windowId && windowId.current && windowStack.pushToTop(windowId.current);
|
635 | },
|
636 | ref: windowRef,
|
637 | children: [
|
638 | (0, $duWW8$jsxs)("div", {
|
639 | className: [
|
640 | (0, ($parcel$interopDefault($ddf7153c7c69b209$exports))).contextWindowTitle,
|
641 | moving ? (0, ($parcel$interopDefault($ddf7153c7c69b209$exports))).moving : ""
|
642 | ].filter((c)=>c !== "").join(" "),
|
643 | onMouseDown: (e)=>{
|
644 | if (e.target && (e.target instanceof HTMLElement || e.target instanceof SVGElement)) e.target.style.userSelect = "none";
|
645 | setMoving(true);
|
646 | windowId && windowId.current && windowStack.pushToTop(windowId.current);
|
647 | document.addEventListener("mouseup", mouseUp);
|
648 | document.addEventListener("mousemove", mouseMove);
|
649 | window.addEventListener("resize", ()=>checkPosition());
|
650 | },
|
651 | children: [
|
652 | (0, $duWW8$jsx)("div", {
|
653 | className: (0, ($parcel$interopDefault($ddf7153c7c69b209$exports))).contextWindowTitleText,
|
654 | children: title
|
655 | }),
|
656 | (0, $duWW8$jsx)("div", {
|
657 | className: (0, ($parcel$interopDefault($ddf7153c7c69b209$exports))).contextWindowTitleClose,
|
658 | children: (0, $duWW8$jsx)("svg", {
|
659 | xmlns: "http://www.w3.org/2000/svg",
|
660 | width: "16",
|
661 | height: "16",
|
662 | fill: "currentColor",
|
663 | viewBox: "0 0 16 16",
|
664 | "aria-label": "Close window",
|
665 | onClick: onClose,
|
666 | children: (0, $duWW8$jsx)("path", {
|
667 | d: "M4.646 4.646a.5.5 0 0 1 .708 0L8 7.293l2.646-2.647a.5.5 0 0 1 .708.708L8.707 8l2.647 2.646a.5.5 0 0 1-.708.708L8 8.707l-2.646 2.647a.5.5 0 0 1-.708-.708L7.293 8 4.646 5.354a.5.5 0 0 1 0-.708z"
|
668 | })
|
669 | })
|
670 | })
|
671 | ]
|
672 | }),
|
673 | (0, $duWW8$jsx)("div", {
|
674 | className: (0, ($parcel$interopDefault($ddf7153c7c69b209$exports))).contextWindowBody,
|
675 | children: (0, $duWW8$jsx)("div", {
|
676 | children: children
|
677 | })
|
678 | })
|
679 | ]
|
680 | }), document.body)
|
681 | });
|
682 | };
|
683 | $b5e8657823def5be$export$1af8984c69ba1b24.displayName = "ContextWindow";
|
684 |
|
685 |
|
686 |
|
687 |
|
688 |
|
689 |
|
690 |
|
691 | export {$1e1c1e9e0b943830$export$ed4f9641643dc7e4 as ContextMenuHandler, $b5e8657823def5be$export$1af8984c69ba1b24 as ContextWindow, $17c46b9e6a2eb66e$export$9f37482ccd50dad2 as ContextWindowStack};
|
692 |
|