@asup/context-menu 1.3.9 → 1.3.10

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