@asup/context-menu 1.3.3 → 1.3.5

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 CHANGED
@@ -28,6 +28,8 @@ function $parcel$export(e, n, v, s) {
28
28
  function $parcel$interopDefault(a) {
29
29
  return a && a.__esModule ? a.default : a;
30
30
  }
31
+
32
+
31
33
  var $a68bd8a6c0fd98c2$exports = {};
32
34
 
33
35
  $parcel$export($a68bd8a6c0fd98c2$exports, "ContextMenuHandler", function () { return $3c568ee547c732c3$export$ed4f9641643dc7e4; });
@@ -38,13 +40,48 @@ $parcel$export($a68bd8a6c0fd98c2$exports, "ContextWindowStack", function () { re
38
40
 
39
41
 
40
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-WinFxq-anchor`;
66
+ $da5a7b95ca760552$export$6ed5f4fbab298e07 = `aiw-WinFxq-caretHolder`;
67
+ $da5a7b95ca760552$export$218b899e1d476006 = `aiw-WinFxq-contextMenu`;
68
+ $da5a7b95ca760552$export$ed8ffb5bb55a3bc8 = `aiw-WinFxq-contextMenuHandler`;
69
+ $da5a7b95ca760552$export$e5ea51c279904378 = `aiw-WinFxq-contextMenuItem`;
70
+ $da5a7b95ca760552$export$6ada86c5b962aa22 = `aiw-WinFxq-contextMenuItemLabel`;
71
+ $da5a7b95ca760552$export$683472f6198a076e = `aiw-WinFxq-disabled`;
72
+ $da5a7b95ca760552$export$73920f18ca706874 = `aiw-WinFxq-hidden`;
73
+ $da5a7b95ca760552$export$6e0e6ce39e5a0361 = `aiw-WinFxq-subMenu`;
74
+ $da5a7b95ca760552$export$664c6d24e3175067 = `aiw-WinFxq-visible`;
75
+
41
76
 
42
77
 
43
78
 
44
- const $d35a356381c44181$export$7e4e6110f96afd7e = ({ entries: entries, target: target, toClose: toClose })=>{
79
+
80
+
81
+ const $d35a356381c44181$export$7e4e6110f96afd7e = ({ entries: entries, toClose: toClose })=>{
45
82
  const [visible, setVisible] = (0, $gTuX4$react.useState)(false);
46
83
  return /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsxs)("span", {
47
- className: "caret-holder",
84
+ className: (0, (/*@__PURE__*/$parcel$interopDefault($da5a7b95ca760552$exports))).caretHolder,
48
85
  onMouseEnter: ()=>{
49
86
  setVisible(true);
50
87
  },
@@ -63,11 +100,10 @@ const $d35a356381c44181$export$7e4e6110f96afd7e = ({ entries: entries, target: t
63
100
  })
64
101
  }),
65
102
  /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)("div", {
66
- className: "sub-menu",
103
+ className: (0, (/*@__PURE__*/$parcel$interopDefault($da5a7b95ca760552$exports))).subMenu,
67
104
  children: /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)((0, $5150b66b01c99189$export$8dc6765e8be191c7), {
68
105
  visible: visible,
69
106
  entries: entries,
70
- target: target,
71
107
  xPos: 14,
72
108
  yPos: -21,
73
109
  toClose: toClose
@@ -79,11 +115,14 @@ const $d35a356381c44181$export$7e4e6110f96afd7e = ({ entries: entries, target: t
79
115
  $d35a356381c44181$export$7e4e6110f96afd7e.displayName = "ContextSubMenu";
80
116
 
81
117
 
82
- const $5150b66b01c99189$export$8dc6765e8be191c7 = /*#__PURE__*/ (0, ($parcel$interopDefault($gTuX4$react))).forwardRef(({ visible: visible, entries: entries, target: target, xPos: xPos, yPos: yPos, toClose: toClose }, ref)=>{
83
- $5150b66b01c99189$export$8dc6765e8be191c7.displayName = "ContextMenu";
118
+ const $5150b66b01c99189$export$8dc6765e8be191c7 = /*#__PURE__*/ (0, ($parcel$interopDefault($gTuX4$react))).forwardRef(({ visible: visible, entries: entries, xPos: xPos, yPos: yPos, toClose: toClose }, ref)=>{
119
+ const [target, setTarget] = (0, $gTuX4$react.useState)(null);
84
120
  return /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)("div", {
85
121
  ref: ref,
86
- className: `context-menu${visible ? " visible" : ""}`,
122
+ className: [
123
+ (0, (/*@__PURE__*/$parcel$interopDefault($da5a7b95ca760552$exports))).contextMenu,
124
+ visible ? (0, (/*@__PURE__*/$parcel$interopDefault($da5a7b95ca760552$exports))).visible : (0, (/*@__PURE__*/$parcel$interopDefault($da5a7b95ca760552$exports))).hidden
125
+ ].filter((c)=>c !== "").join(" "),
87
126
  style: {
88
127
  top: `${yPos}px`,
89
128
  left: `${xPos}px`
@@ -93,24 +132,34 @@ const $5150b66b01c99189$export$8dc6765e8be191c7 = /*#__PURE__*/ (0, ($parcel$int
93
132
  e.stopPropagation();
94
133
  },
95
134
  children: entries.map((entry, i)=>/*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsxs)("div", {
96
- className: `context-menu-item${entry.disabled ? " disabled" : ""}`,
135
+ className: [
136
+ (0, (/*@__PURE__*/$parcel$interopDefault($da5a7b95ca760552$exports))).contextMenuItem,
137
+ entry.disabled ? (0, (/*@__PURE__*/$parcel$interopDefault($da5a7b95ca760552$exports))).disabled : ""
138
+ ].filter((c)=>c !== "").join(" "),
97
139
  children: [
98
- /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)("span", {
140
+ typeof entry.label === "string" ? /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)("span", {
99
141
  "aria-label": typeof entry.label === "string" ? entry.label : undefined,
100
142
  "aria-disabled": entry.disabled,
101
- className: "context-menu-item-label",
102
- onMouseDownCapture: (ev)=>{
103
- ev.preventDefault();
104
- ev.stopPropagation();
143
+ className: (0, (/*@__PURE__*/$parcel$interopDefault($da5a7b95ca760552$exports))).contextMenuItemLabel,
144
+ onMouseEnter: ()=>{
145
+ const sel = window.getSelection();
146
+ const target = sel && sel.rangeCount > 0 ? sel.getRangeAt(0) : null;
147
+ setTarget(target);
148
+ },
149
+ onMouseLeave: ()=>{
150
+ setTarget(null);
151
+ },
152
+ onMouseDownCapture: (e)=>{
153
+ e.preventDefault();
154
+ e.stopPropagation();
105
155
  entry.action && !entry.disabled && entry.action(target);
106
156
  !entry.disabled && toClose();
107
157
  },
108
158
  children: entry.label
109
- }),
159
+ }) : entry.label,
110
160
  entry.group && /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)((0, $d35a356381c44181$export$7e4e6110f96afd7e), {
111
161
  toClose: toClose,
112
- entries: entry.group,
113
- target: target
162
+ entries: entry.group
114
163
  })
115
164
  ]
116
165
  }, i))
@@ -121,17 +170,49 @@ $5150b66b01c99189$export$8dc6765e8be191c7.displayName = "ContextMenu";
121
170
 
122
171
 
123
172
 
173
+ var $63cdf2819565020c$exports = {};
174
+
175
+ $parcel$export($63cdf2819565020c$exports, "caretHolder", function () { return $63cdf2819565020c$export$6ed5f4fbab298e07; }, function (v) { return $63cdf2819565020c$export$6ed5f4fbab298e07 = v; });
176
+ $parcel$export($63cdf2819565020c$exports, "disabled", function () { return $63cdf2819565020c$export$683472f6198a076e; }, function (v) { return $63cdf2819565020c$export$683472f6198a076e = v; });
177
+ $parcel$export($63cdf2819565020c$exports, "hidden", function () { return $63cdf2819565020c$export$73920f18ca706874; }, function (v) { return $63cdf2819565020c$export$73920f18ca706874 = v; });
178
+ $parcel$export($63cdf2819565020c$exports, "lowMenu", function () { return $63cdf2819565020c$export$59e4b099a896b33; }, function (v) { return $63cdf2819565020c$export$59e4b099a896b33 = v; });
179
+ $parcel$export($63cdf2819565020c$exports, "lowMenu-item", function () { return $63cdf2819565020c$export$19fbf76b734bf310; }, function (v) { return $63cdf2819565020c$export$19fbf76b734bf310 = v; });
180
+ $parcel$export($63cdf2819565020c$exports, "lowMenuButtonHolder", function () { return $63cdf2819565020c$export$22ec12d194e0789c; }, function (v) { return $63cdf2819565020c$export$22ec12d194e0789c = v; });
181
+ $parcel$export($63cdf2819565020c$exports, "lowMenuItem", function () { return $63cdf2819565020c$export$2ad34a478577e75d; }, function (v) { return $63cdf2819565020c$export$2ad34a478577e75d = v; });
182
+ $parcel$export($63cdf2819565020c$exports, "subMenu", function () { return $63cdf2819565020c$export$6e0e6ce39e5a0361; }, function (v) { return $63cdf2819565020c$export$6e0e6ce39e5a0361 = v; });
183
+ $parcel$export($63cdf2819565020c$exports, "visible", function () { return $63cdf2819565020c$export$664c6d24e3175067; }, function (v) { return $63cdf2819565020c$export$664c6d24e3175067 = v; });
184
+ var $63cdf2819565020c$export$6ed5f4fbab298e07;
185
+ var $63cdf2819565020c$export$683472f6198a076e;
186
+ var $63cdf2819565020c$export$73920f18ca706874;
187
+ var $63cdf2819565020c$export$59e4b099a896b33;
188
+ var $63cdf2819565020c$export$19fbf76b734bf310;
189
+ var $63cdf2819565020c$export$22ec12d194e0789c;
190
+ var $63cdf2819565020c$export$2ad34a478577e75d;
191
+ var $63cdf2819565020c$export$6e0e6ce39e5a0361;
192
+ var $63cdf2819565020c$export$664c6d24e3175067;
193
+ $63cdf2819565020c$export$6ed5f4fbab298e07 = `aiw-JfzGeq-caretHolder`;
194
+ $63cdf2819565020c$export$683472f6198a076e = `aiw-JfzGeq-disabled`;
195
+ $63cdf2819565020c$export$73920f18ca706874 = `aiw-JfzGeq-hidden`;
196
+ $63cdf2819565020c$export$59e4b099a896b33 = `aiw-JfzGeq-lowMenu`;
197
+ $63cdf2819565020c$export$19fbf76b734bf310 = `aiw-JfzGeq-lowMenu-item`;
198
+ $63cdf2819565020c$export$22ec12d194e0789c = `aiw-JfzGeq-lowMenuButtonHolder`;
199
+ $63cdf2819565020c$export$2ad34a478577e75d = `aiw-JfzGeq-lowMenuItem`;
200
+ $63cdf2819565020c$export$6e0e6ce39e5a0361 = `aiw-JfzGeq-subMenu`;
201
+ $63cdf2819565020c$export$664c6d24e3175067 = `aiw-JfzGeq-visible`;
202
+
203
+
204
+
124
205
 
125
206
 
126
207
 
127
208
 
128
209
 
129
- const $d30299730ea8ec1e$export$251b9f54013cdfac = ({ entry: entry, target: target })=>{
210
+ const $d30299730ea8ec1e$export$251b9f54013cdfac = ({ entry: entry })=>{
130
211
  const [visible, setVisible] = (0, $gTuX4$react.useState)(false);
131
212
  if (!entry.group || entry.group.length === 0) return /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)((0, $gTuX4$reactjsxruntime.Fragment), {});
132
213
  return /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsxs)("span", {
133
214
  "aria-label": `Sub menu for ${entry.label}`,
134
- className: "caret-holder",
215
+ className: (0, (/*@__PURE__*/$parcel$interopDefault($63cdf2819565020c$exports))).caretHolder,
135
216
  onMouseEnter: ()=>{
136
217
  setVisible(true);
137
218
  },
@@ -150,11 +231,10 @@ const $d30299730ea8ec1e$export$251b9f54013cdfac = ({ entry: entry, target: targe
150
231
  })
151
232
  }),
152
233
  /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)("div", {
153
- className: "sub-menu",
154
- children: /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)((0, $5150b66b01c99189$export$8dc6765e8be191c7), {
234
+ className: (0, (/*@__PURE__*/$parcel$interopDefault($63cdf2819565020c$exports))).subMenu,
235
+ children: visible && /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)((0, $5150b66b01c99189$export$8dc6765e8be191c7), {
155
236
  visible: visible,
156
237
  entries: entry.group,
157
- target: target,
158
238
  xPos: 14,
159
239
  yPos: entry.group.length * -21 - 8,
160
240
  toClose: ()=>setVisible(false)
@@ -166,24 +246,35 @@ const $d30299730ea8ec1e$export$251b9f54013cdfac = ({ entry: entry, target: targe
166
246
  $d30299730ea8ec1e$export$251b9f54013cdfac.displayName = "LowSubMenu";
167
247
 
168
248
 
169
- const $b34598671fff4a77$export$aafc28aea571c4bc = ({ entry: entry, target: target })=>{
249
+
250
+ const $b34598671fff4a77$export$aafc28aea571c4bc = ({ entry: entry })=>{
251
+ const [target, setTarget] = (0, $gTuX4$react.useState)(null);
170
252
  return /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsxs)("div", {
171
- className: `low-menu-item${entry.disabled ? " disabled" : ""}`,
253
+ className: [
254
+ (0, (/*@__PURE__*/$parcel$interopDefault($63cdf2819565020c$exports))).lowMenuItem,
255
+ entry.disabled ? (0, (/*@__PURE__*/$parcel$interopDefault($63cdf2819565020c$exports))).disabled : ""
256
+ ].filter((c)=>c !== "").join(" "),
172
257
  "aria-label": typeof entry.label === "string" ? entry.label : undefined,
173
258
  "aria-disabled": entry.disabled,
174
- onClick: (event)=>{
175
- event.preventDefault();
176
- event.stopPropagation();
259
+ onMouseEnter: ()=>{
260
+ const sel = window.getSelection();
261
+ const target = sel && sel.rangeCount > 0 ? sel.getRangeAt(0) : null;
262
+ setTarget(target);
263
+ },
264
+ onMouseLeave: ()=>{
265
+ setTarget(null);
266
+ },
267
+ onClick: (e)=>{
268
+ e.preventDefault();
269
+ e.stopPropagation();
177
270
  entry.action && !entry.disabled && entry.action(target);
178
271
  },
179
272
  children: [
180
273
  /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)("span", {
181
- className: "low-menu-item-label",
182
274
  children: entry.label
183
275
  }),
184
276
  entry.group && /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)((0, $d30299730ea8ec1e$export$251b9f54013cdfac), {
185
- entry: entry,
186
- target: target
277
+ entry: entry
187
278
  })
188
279
  ]
189
280
  });
@@ -191,42 +282,65 @@ const $b34598671fff4a77$export$aafc28aea571c4bc = ({ entry: entry, target: targe
191
282
  $b34598671fff4a77$export$aafc28aea571c4bc.displayName = "LowMenuButton";
192
283
 
193
284
 
194
- const $10d1ee4e7fc9bbbd$export$49e8edc8ebca5f25 = ({ entries: entries, target: target, visible: visible })=>{
285
+ const $10d1ee4e7fc9bbbd$export$49e8edc8ebca5f25 = ({ entries: entries, visible: visible, xPos: xPos, yPos: yPos, maxWidth: maxWidth })=>{
195
286
  return /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)("div", {
196
- className: `low-menu ${visible ? "visible" : "hidden"}`,
287
+ className: [
288
+ (0, (/*@__PURE__*/$parcel$interopDefault($63cdf2819565020c$exports))).lowMenu,
289
+ visible ? (0, (/*@__PURE__*/$parcel$interopDefault($63cdf2819565020c$exports))).visible : (0, (/*@__PURE__*/$parcel$interopDefault($63cdf2819565020c$exports))).hidden
290
+ ].join(" "),
197
291
  "aria-label": "Low context menu",
198
- children: entries.map((e, i)=>/*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)((0, $b34598671fff4a77$export$aafc28aea571c4bc), {
199
- entry: e,
200
- target: target
201
- }, i))
292
+ style: {
293
+ left: `${xPos}px`,
294
+ top: `${yPos}px`,
295
+ maxWidth: `calc(${maxWidth}px)`,
296
+ width: `calc(${maxWidth}px - 4px)`
297
+ },
298
+ children: /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)("div", {
299
+ className: (0, (/*@__PURE__*/$parcel$interopDefault($63cdf2819565020c$exports))).lowMenuButtonHolder,
300
+ children: entries.map((e, i)=>/*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)((0, $b34598671fff4a77$export$aafc28aea571c4bc), {
301
+ entry: e
302
+ }, i))
303
+ })
202
304
  });
203
305
  };
204
306
  $10d1ee4e7fc9bbbd$export$49e8edc8ebca5f25.displayName = "LowMenu";
205
307
 
206
308
 
207
- const $3c568ee547c732c3$export$ed4f9641643dc7e4 = ({ children: children, menuItems: menuItems, showLowMenu: showLowMenu = false, style: style = {
208
- height: "fit-content",
209
- width: "fit-content"
210
- } })=>{
309
+ const $3c568ee547c732c3$export$fc58dc71afe92de2 = /*#__PURE__*/ (0, $gTuX4$react.createContext)(null);
310
+ const $3c568ee547c732c3$export$ed4f9641643dc7e4 = ({ children: children, menuItems: menuItems, showLowMenu: showLowMenu = false, ...rest })=>{
311
+ var _divHandlderRef_current;
312
+ // Check for higher content menu
313
+ const higherContext = (0, $gTuX4$react.useContext)($3c568ee547c732c3$export$fc58dc71afe92de2);
314
+ const thisMenuItems = (0, $gTuX4$react.useMemo)(()=>[
315
+ ...higherContext !== null ? [
316
+ ...higherContext.menuItems,
317
+ {
318
+ label: /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)("hr", {
319
+ style: {
320
+ flexGrow: 1,
321
+ cursor: "none",
322
+ margin: "0",
323
+ padding: "0"
324
+ }
325
+ })
326
+ }
327
+ ] : [],
328
+ ...menuItems
329
+ ], [
330
+ higherContext,
331
+ menuItems
332
+ ]);
211
333
  // Menu resources
212
- const divRef = (0, $gTuX4$react.useRef)(null);
334
+ const divHandlderRef = (0, $gTuX4$react.useRef)(null);
213
335
  const menuRef = (0, $gTuX4$react.useRef)(null);
214
336
  const [menuXPos, setMenuXPos] = (0, $gTuX4$react.useState)(0);
215
337
  const [menuYPos, setMenuYPos] = (0, $gTuX4$react.useState)(0);
216
338
  const [menuVisible, setMenuVisible] = (0, $gTuX4$react.useState)(false);
217
- const [target, setTarget] = (0, $gTuX4$react.useState)(null);
218
- const [lowTarget, setLowTarget] = (0, $gTuX4$react.useState)(null);
219
- const [lowMenuVisible, setLowMenuVisible] = (0, $gTuX4$react.useState)(false);
220
- // Show menu when context is requested
221
- const showMenu = (e)=>{
222
- const sel = window.getSelection();
223
- setTarget(sel && sel.rangeCount > 0 ? sel.getRangeAt(0) : null);
224
- e.preventDefault();
225
- e.stopPropagation();
226
- setMenuVisible(true);
227
- setMenuXPos(e.pageX);
228
- setMenuYPos(e.pageY);
229
- };
339
+ const [menuInDom, setMenuInDom] = (0, $gTuX4$react.useState)(false);
340
+ const [mouseOverHandlerDiv, setMouseOverHandlerDiv] = (0, $gTuX4$react.useState)(false);
341
+ const [mouseOverMenu, setMouseOverMenu] = (0, $gTuX4$react.useState)(false);
342
+ // Get holder position
343
+ const divHandlerPos = divHandlderRef ? (_divHandlderRef_current = divHandlderRef.current) === null || _divHandlderRef_current === void 0 ? void 0 : _divHandlderRef_current.getBoundingClientRect() : null;
230
344
  // Handle click off the menu
231
345
  const handleClick = (0, $gTuX4$react.useCallback)((e)=>{
232
346
  var _menuRef_current;
@@ -243,55 +357,96 @@ const $3c568ee547c732c3$export$ed4f9641643dc7e4 = ({ children: children, menuIte
243
357
  handleClick,
244
358
  menuVisible
245
359
  ]);
246
- return /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsxs)((0, $gTuX4$reactjsxruntime.Fragment), {
360
+ const removeController = (0, $gTuX4$react.useRef)(new AbortController());
361
+ (0, $gTuX4$react.useEffect)(()=>{
362
+ if (!mouseOverMenu && !menuVisible && !mouseOverHandlerDiv) {
363
+ removeController.current.abort();
364
+ removeController.current = new AbortController();
365
+ setTimeout(()=>{
366
+ if (!removeController.current.signal.aborted) setMenuInDom(false);
367
+ }, 300);
368
+ }
369
+ }, [
370
+ mouseOverHandlerDiv,
371
+ menuVisible,
372
+ mouseOverMenu
373
+ ]);
374
+ return /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsxs)($3c568ee547c732c3$export$fc58dc71afe92de2.Provider, {
375
+ value: {
376
+ menuItems: thisMenuItems
377
+ },
247
378
  children: [
248
379
  /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)("div", {
249
- onContextMenu: showLowMenu ? undefined : showMenu,
250
- className: "context-menu-handler",
251
- style: style,
380
+ ref: divHandlderRef,
381
+ ...rest,
382
+ className: [
383
+ (0, (/*@__PURE__*/$parcel$interopDefault($da5a7b95ca760552$exports))).contextMenuHandler,
384
+ rest.className
385
+ ].join(" "),
386
+ style: {
387
+ ...rest.style
388
+ },
389
+ onContextMenu: (e)=>{
390
+ if (!showLowMenu) {
391
+ setMenuInDom(true);
392
+ e.preventDefault();
393
+ e.stopPropagation();
394
+ setTimeout(()=>{
395
+ removeController.current.abort();
396
+ setMenuVisible(true);
397
+ setMenuXPos(e.pageX);
398
+ setMenuYPos(e.pageY);
399
+ }, 1);
400
+ }
401
+ },
252
402
  onMouseEnter: ()=>{
253
- showLowMenu && setLowMenuVisible(true);
403
+ if (showLowMenu) {
404
+ setMenuInDom(true);
405
+ setMouseOverHandlerDiv(false);
406
+ setTimeout(()=>{
407
+ removeController.current.abort();
408
+ setMouseOverHandlerDiv(true);
409
+ }, 1);
410
+ }
254
411
  },
255
412
  onMouseLeave: ()=>{
256
- showLowMenu && setLowMenuVisible(false);
413
+ if (showLowMenu) {
414
+ removeController.current.abort();
415
+ removeController.current = new AbortController();
416
+ setMouseOverHandlerDiv(false);
417
+ }
257
418
  },
258
419
  children: children
259
420
  }),
260
- menuVisible && !showLowMenu && /*#__PURE__*/ (0, $gTuX4$reactdom.createPortal)(/*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)("div", {
261
- style: {
262
- position: "absolute",
263
- top: 0,
264
- left: 0
265
- },
266
- ref: divRef,
267
- children: /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)((0, $5150b66b01c99189$export$8dc6765e8be191c7), {
268
- visible: true,
269
- ref: menuRef,
270
- entries: menuItems,
271
- xPos: menuXPos,
272
- yPos: menuYPos,
273
- target: target,
274
- toClose: ()=>setMenuVisible(false)
275
- })
276
- }), document.body),
277
- showLowMenu && /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)("div", {
278
- style: {
279
- position: "relative"
280
- },
421
+ menuInDom && divHandlerPos && /*#__PURE__*/ (0, $gTuX4$reactdom.createPortal)(/*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)("div", {
422
+ className: (0, (/*@__PURE__*/$parcel$interopDefault($da5a7b95ca760552$exports))).anchor,
281
423
  onMouseEnter: ()=>{
282
- const sel = window.getSelection();
283
- const lowSel = sel && sel.rangeCount > 0 ? sel.getRangeAt(0) : null;
284
- setLowTarget(lowSel);
424
+ removeController.current.abort();
425
+ setMouseOverMenu(true);
285
426
  },
286
427
  onMouseLeave: ()=>{
287
- setLowTarget(null);
428
+ removeController.current.abort();
429
+ removeController.current = new AbortController();
430
+ setMouseOverMenu(false);
288
431
  },
289
- children: /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)((0, $10d1ee4e7fc9bbbd$export$49e8edc8ebca5f25), {
290
- visible: lowMenuVisible,
432
+ children: showLowMenu ? /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)((0, $10d1ee4e7fc9bbbd$export$49e8edc8ebca5f25), {
433
+ visible: mouseOverHandlerDiv,
291
434
  entries: menuItems,
292
- target: lowTarget
435
+ xPos: divHandlerPos.left,
436
+ yPos: divHandlerPos.bottom,
437
+ maxWidth: divHandlerPos.width
438
+ }) : /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)((0, $5150b66b01c99189$export$8dc6765e8be191c7), {
439
+ visible: menuVisible,
440
+ ref: menuRef,
441
+ entries: thisMenuItems,
442
+ xPos: menuXPos,
443
+ yPos: menuYPos,
444
+ toClose: ()=>{
445
+ setMenuVisible(false);
446
+ setMouseOverMenu(false);
447
+ }
293
448
  })
294
- })
449
+ }), document.body)
295
450
  ]
296
451
  });
297
452
  };
@@ -301,6 +456,27 @@ $3c568ee547c732c3$export$ed4f9641643dc7e4.displayName = "ContextMenuHandler";
301
456
 
302
457
 
303
458
 
459
+ const $c986bcdcae4b83bd$export$d81cfea7c54be196 = (divRef)=>{
460
+ if (!divRef.current) return {
461
+ translateX: 0,
462
+ translateY: 0
463
+ };
464
+ else {
465
+ const innerBounce = 16;
466
+ const posn = divRef.current.getBoundingClientRect();
467
+ let translateX = 0;
468
+ if (posn.left < innerBounce) translateX = -posn.left + innerBounce;
469
+ else if (posn.right > window.innerWidth) translateX = Math.max(-posn.left + innerBounce, window.innerWidth - posn.right - innerBounce);
470
+ let translateY = 0;
471
+ if (posn.top < innerBounce) translateY = -posn.top + innerBounce;
472
+ else if (posn.bottom > window.innerHeight) translateY = Math.max(-posn.top + innerBounce, window.innerHeight - posn.bottom - innerBounce);
473
+ return {
474
+ translateX: translateX,
475
+ translateY: translateY
476
+ };
477
+ }
478
+ };
479
+
304
480
 
305
481
 
306
482
 
@@ -334,33 +510,38 @@ const $16208d559c772441$export$9f37482ccd50dad2 = ({ minZIndex: minZIndex = 1000
334
510
  $16208d559c772441$export$9f37482ccd50dad2.displayName = "ContextWindowStack";
335
511
 
336
512
 
337
- const $c986bcdcae4b83bd$export$d81cfea7c54be196 = (divRef)=>{
338
- if (!divRef.current) return {
339
- translateX: 0,
340
- translateY: 0
341
- };
342
- else {
343
- const innerBounce = 16;
344
- const posn = divRef.current.getBoundingClientRect();
345
- let translateX = 0;
346
- if (posn.left < innerBounce) translateX = -posn.left + innerBounce;
347
- else if (posn.right > window.innerWidth) translateX = Math.max(-posn.left + innerBounce, window.innerWidth - posn.right - innerBounce);
348
- let translateY = 0;
349
- if (posn.top < innerBounce) translateY = -posn.top + innerBounce;
350
- else if (posn.bottom > window.innerHeight) translateY = Math.max(-posn.top + innerBounce, window.innerHeight - posn.bottom - innerBounce);
351
- return {
352
- translateX: translateX,
353
- translateY: translateY
354
- };
355
- }
356
- };
357
-
358
-
359
- const $46fb0088a1bbb6d8$export$1af8984c69ba1b24 = ({ id: id, visible: visible, title: title, style: style, children: children, onOpen: onOpen, onClose: onClose })=>{
513
+ var $7c5fb3f6c1601913$exports = {};
514
+
515
+ $parcel$export($7c5fb3f6c1601913$exports, "contextWindow", function () { return $7c5fb3f6c1601913$export$72cad2e5ad4d2674; }, function (v) { return $7c5fb3f6c1601913$export$72cad2e5ad4d2674 = v; });
516
+ $parcel$export($7c5fb3f6c1601913$exports, "contextWindowAnchor", function () { return $7c5fb3f6c1601913$export$9f3a8a17ac700f7d; }, function (v) { return $7c5fb3f6c1601913$export$9f3a8a17ac700f7d = v; });
517
+ $parcel$export($7c5fb3f6c1601913$exports, "contextWindowBody", function () { return $7c5fb3f6c1601913$export$dfb2c4d2d1c0156f; }, function (v) { return $7c5fb3f6c1601913$export$dfb2c4d2d1c0156f = v; });
518
+ $parcel$export($7c5fb3f6c1601913$exports, "contextWindowTitle", function () { return $7c5fb3f6c1601913$export$1b02f2cd2f7db0f4; }, function (v) { return $7c5fb3f6c1601913$export$1b02f2cd2f7db0f4 = v; });
519
+ $parcel$export($7c5fb3f6c1601913$exports, "contextWindowTitleClose", function () { return $7c5fb3f6c1601913$export$7ba38d4cc2870e66; }, function (v) { return $7c5fb3f6c1601913$export$7ba38d4cc2870e66 = v; });
520
+ $parcel$export($7c5fb3f6c1601913$exports, "contextWindowTitleText", function () { return $7c5fb3f6c1601913$export$cebbac70b4d99c48; }, function (v) { return $7c5fb3f6c1601913$export$cebbac70b4d99c48 = v; });
521
+ $parcel$export($7c5fb3f6c1601913$exports, "moving", function () { return $7c5fb3f6c1601913$export$d03a2f3acc60252b; }, function (v) { return $7c5fb3f6c1601913$export$d03a2f3acc60252b = v; });
522
+ var $7c5fb3f6c1601913$export$72cad2e5ad4d2674;
523
+ var $7c5fb3f6c1601913$export$9f3a8a17ac700f7d;
524
+ var $7c5fb3f6c1601913$export$dfb2c4d2d1c0156f;
525
+ var $7c5fb3f6c1601913$export$1b02f2cd2f7db0f4;
526
+ var $7c5fb3f6c1601913$export$7ba38d4cc2870e66;
527
+ var $7c5fb3f6c1601913$export$cebbac70b4d99c48;
528
+ var $7c5fb3f6c1601913$export$d03a2f3acc60252b;
529
+ $7c5fb3f6c1601913$export$72cad2e5ad4d2674 = `aiw-RIIF9a-contextWindow`;
530
+ $7c5fb3f6c1601913$export$9f3a8a17ac700f7d = `aiw-RIIF9a-contextWindowAnchor`;
531
+ $7c5fb3f6c1601913$export$dfb2c4d2d1c0156f = `aiw-RIIF9a-contextWindowBody`;
532
+ $7c5fb3f6c1601913$export$1b02f2cd2f7db0f4 = `aiw-RIIF9a-contextWindowTitle`;
533
+ $7c5fb3f6c1601913$export$7ba38d4cc2870e66 = `aiw-RIIF9a-contextWindowTitleClose`;
534
+ $7c5fb3f6c1601913$export$cebbac70b4d99c48 = `aiw-RIIF9a-contextWindowTitleText`;
535
+ $7c5fb3f6c1601913$export$d03a2f3acc60252b = `aiw-RIIF9a-moving`;
536
+
537
+
538
+ const $46fb0088a1bbb6d8$export$1af8984c69ba1b24 = ({ id: id, visible: visible, title: title, children: children, onOpen: onOpen, onClose: onClose, ...rest })=>{
539
+ var _rest_style, _rest_style1, _rest_style2, _rest_style3;
360
540
  const windowStack = (0, $gTuX4$react.useContext)((0, $16208d559c772441$export$aff5d0593e3727b0));
361
541
  const windowId = (0, $gTuX4$react.useRef)(null);
362
542
  const divRef = (0, $gTuX4$react.useRef)(null);
363
543
  const windowRef = (0, $gTuX4$react.useRef)(null);
544
+ const [windowInDOM, setWindowInDOM] = (0, $gTuX4$react.useState)(false);
364
545
  const [windowVisible, setWindowVisible] = (0, $gTuX4$react.useState)(false);
365
546
  const zIndex = (0, $gTuX4$react.useMemo)(()=>{
366
547
  var _windowStack_currentWindows_find;
@@ -413,7 +594,9 @@ const $46fb0088a1bbb6d8$export$1af8984c69ba1b24 = ({ id: id, visible: visible, t
413
594
  // Update visibility
414
595
  (0, $gTuX4$react.useEffect)(()=>{
415
596
  if (windowStack) {
416
- if (visible && !windowVisible) {
597
+ // Visible set, but not in DOM
598
+ if (visible && !windowInDOM) setWindowInDOM(true);
599
+ else if (visible && windowInDOM && !windowVisible) {
417
600
  if (!windowId.current) {
418
601
  const maxWindowId = Math.max(0, ...windowStack.currentWindows.map((w)=>w.windowId));
419
602
  windowId.current = maxWindowId + 1;
@@ -436,30 +619,33 @@ const $46fb0088a1bbb6d8$export$1af8984c69ba1b24 = ({ id: id, visible: visible, t
436
619
  }
437
620
  checkPosition();
438
621
  } else if (windowId.current && !visible && windowVisible) setWindowVisible(false);
622
+ else if (windowId.current && !visible && windowInDOM) setWindowInDOM(false);
439
623
  }
440
624
  }, [
441
625
  checkPosition,
442
626
  onOpen,
443
627
  visible,
628
+ windowInDOM,
444
629
  windowStack,
445
630
  windowVisible
446
631
  ]);
447
- var _style_minHeight, _style_minWidth, _style_maxHeight, _style_maxWidth;
632
+ var _rest_style_minHeight, _rest_style_minWidth, _rest_style_maxHeight, _rest_style_maxWidth;
448
633
  return /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)("div", {
449
- className: "contextwindow-anchor",
634
+ className: (0, (/*@__PURE__*/$parcel$interopDefault($7c5fb3f6c1601913$exports))).contextWindowAnchor,
450
635
  ref: divRef,
451
- children: windowStack && /*#__PURE__*/ (0, $gTuX4$reactdom.createPortal)(/*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsxs)("div", {
636
+ children: windowStack && windowInDOM && /*#__PURE__*/ (0, $gTuX4$reactdom.createPortal)(/*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsxs)("div", {
637
+ ...rest,
452
638
  id: id,
453
- className: "contextwindow",
639
+ className: (0, (/*@__PURE__*/$parcel$interopDefault($7c5fb3f6c1601913$exports))).contextWindow,
454
640
  style: {
455
- ...style,
641
+ ...rest.style,
456
642
  opacity: moving ? 0.8 : windowVisible ? 1 : 0,
457
643
  visibility: windowVisible ? "visible" : "hidden",
458
644
  zIndex: zIndex !== null && zIndex !== void 0 ? zIndex : 1,
459
- minHeight: (_style_minHeight = style === null || style === void 0 ? void 0 : style.minHeight) !== null && _style_minHeight !== void 0 ? _style_minHeight : "150px",
460
- minWidth: (_style_minWidth = style === null || style === void 0 ? void 0 : style.minWidth) !== null && _style_minWidth !== void 0 ? _style_minWidth : "200px",
461
- maxHeight: (_style_maxHeight = style === null || style === void 0 ? void 0 : style.maxHeight) !== null && _style_maxHeight !== void 0 ? _style_maxHeight : "1000px",
462
- maxWidth: (_style_maxWidth = style === null || style === void 0 ? void 0 : style.maxWidth) !== null && _style_maxWidth !== void 0 ? _style_maxWidth : "1000px"
645
+ 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",
646
+ 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",
647
+ 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",
648
+ 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"
463
649
  },
464
650
  onClickCapture: ()=>{
465
651
  windowId && windowId.current && windowStack.pushToTop(windowId.current);
@@ -467,7 +653,10 @@ const $46fb0088a1bbb6d8$export$1af8984c69ba1b24 = ({ id: id, visible: visible, t
467
653
  ref: windowRef,
468
654
  children: [
469
655
  /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsxs)("div", {
470
- className: `contextwindow-title ${moving ? "moving" : ""}`,
656
+ className: [
657
+ (0, (/*@__PURE__*/$parcel$interopDefault($7c5fb3f6c1601913$exports))).contextWindowTitle,
658
+ moving ? (0, (/*@__PURE__*/$parcel$interopDefault($7c5fb3f6c1601913$exports))).moving : ""
659
+ ].filter((c)=>c !== "").join(" "),
471
660
  onMouseDown: (e)=>{
472
661
  if (e.target && (e.target instanceof HTMLElement || e.target instanceof SVGElement)) e.target.style.userSelect = "none";
473
662
  setMoving(true);
@@ -478,11 +667,11 @@ const $46fb0088a1bbb6d8$export$1af8984c69ba1b24 = ({ id: id, visible: visible, t
478
667
  },
479
668
  children: [
480
669
  /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)("div", {
481
- className: "contextwindow-title-text",
670
+ className: (0, (/*@__PURE__*/$parcel$interopDefault($7c5fb3f6c1601913$exports))).contextWindowTitleText,
482
671
  children: title
483
672
  }),
484
673
  /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)("div", {
485
- className: "contextwindow-title-close",
674
+ className: (0, (/*@__PURE__*/$parcel$interopDefault($7c5fb3f6c1601913$exports))).contextWindowTitleClose,
486
675
  children: /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)("svg", {
487
676
  xmlns: "http://www.w3.org/2000/svg",
488
677
  width: "16",
@@ -499,7 +688,7 @@ const $46fb0088a1bbb6d8$export$1af8984c69ba1b24 = ({ id: id, visible: visible, t
499
688
  ]
500
689
  }),
501
690
  /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)("div", {
502
- className: "contextwindow-body",
691
+ className: (0, (/*@__PURE__*/$parcel$interopDefault($7c5fb3f6c1601913$exports))).contextWindowBody,
503
692
  children: /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)("div", {
504
693
  children: children
505
694
  })