@asup/context-menu 1.3.3 → 1.3.4

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,45 @@ $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, "subMenu", function () { return $da5a7b95ca760552$export$6e0e6ce39e5a0361; }, function (v) { return $da5a7b95ca760552$export$6e0e6ce39e5a0361 = v; });
53
+ $parcel$export($da5a7b95ca760552$exports, "visible", function () { return $da5a7b95ca760552$export$664c6d24e3175067; }, function (v) { return $da5a7b95ca760552$export$664c6d24e3175067 = v; });
54
+ var $da5a7b95ca760552$export$2e2992790a6f69a8;
55
+ var $da5a7b95ca760552$export$6ed5f4fbab298e07;
56
+ var $da5a7b95ca760552$export$218b899e1d476006;
57
+ var $da5a7b95ca760552$export$ed8ffb5bb55a3bc8;
58
+ var $da5a7b95ca760552$export$e5ea51c279904378;
59
+ var $da5a7b95ca760552$export$6ada86c5b962aa22;
60
+ var $da5a7b95ca760552$export$683472f6198a076e;
61
+ var $da5a7b95ca760552$export$6e0e6ce39e5a0361;
62
+ var $da5a7b95ca760552$export$664c6d24e3175067;
63
+ $da5a7b95ca760552$export$2e2992790a6f69a8 = `aiw-WinFxq-anchor`;
64
+ $da5a7b95ca760552$export$6ed5f4fbab298e07 = `aiw-WinFxq-caretHolder`;
65
+ $da5a7b95ca760552$export$218b899e1d476006 = `aiw-WinFxq-contextMenu`;
66
+ $da5a7b95ca760552$export$ed8ffb5bb55a3bc8 = `aiw-WinFxq-contextMenuHandler`;
67
+ $da5a7b95ca760552$export$e5ea51c279904378 = `aiw-WinFxq-contextMenuItem`;
68
+ $da5a7b95ca760552$export$6ada86c5b962aa22 = `aiw-WinFxq-contextMenuItemLabel`;
69
+ $da5a7b95ca760552$export$683472f6198a076e = `aiw-WinFxq-disabled`;
70
+ $da5a7b95ca760552$export$6e0e6ce39e5a0361 = `aiw-WinFxq-subMenu`;
71
+ $da5a7b95ca760552$export$664c6d24e3175067 = `aiw-WinFxq-visible`;
72
+
73
+
74
+
41
75
 
42
76
 
43
77
 
44
78
  const $d35a356381c44181$export$7e4e6110f96afd7e = ({ entries: entries, target: target, toClose: toClose })=>{
45
79
  const [visible, setVisible] = (0, $gTuX4$react.useState)(false);
46
80
  return /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsxs)("span", {
47
- className: "caret-holder",
81
+ className: (0, (/*@__PURE__*/$parcel$interopDefault($da5a7b95ca760552$exports))).caretHolder,
48
82
  onMouseEnter: ()=>{
49
83
  setVisible(true);
50
84
  },
@@ -63,7 +97,7 @@ const $d35a356381c44181$export$7e4e6110f96afd7e = ({ entries: entries, target: t
63
97
  })
64
98
  }),
65
99
  /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)("div", {
66
- className: "sub-menu",
100
+ className: (0, (/*@__PURE__*/$parcel$interopDefault($da5a7b95ca760552$exports))).subMenu,
67
101
  children: /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)((0, $5150b66b01c99189$export$8dc6765e8be191c7), {
68
102
  visible: visible,
69
103
  entries: entries,
@@ -83,7 +117,10 @@ const $5150b66b01c99189$export$8dc6765e8be191c7 = /*#__PURE__*/ (0, ($parcel$int
83
117
  $5150b66b01c99189$export$8dc6765e8be191c7.displayName = "ContextMenu";
84
118
  return /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)("div", {
85
119
  ref: ref,
86
- className: `context-menu${visible ? " visible" : ""}`,
120
+ className: [
121
+ (0, (/*@__PURE__*/$parcel$interopDefault($da5a7b95ca760552$exports))).contextMenu,
122
+ visible ? (0, (/*@__PURE__*/$parcel$interopDefault($da5a7b95ca760552$exports))).visible : ""
123
+ ].filter((c)=>c !== "").join(" "),
87
124
  style: {
88
125
  top: `${yPos}px`,
89
126
  left: `${xPos}px`
@@ -93,12 +130,15 @@ const $5150b66b01c99189$export$8dc6765e8be191c7 = /*#__PURE__*/ (0, ($parcel$int
93
130
  e.stopPropagation();
94
131
  },
95
132
  children: entries.map((entry, i)=>/*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsxs)("div", {
96
- className: `context-menu-item${entry.disabled ? " disabled" : ""}`,
133
+ className: [
134
+ (0, (/*@__PURE__*/$parcel$interopDefault($da5a7b95ca760552$exports))).contextMenuItem,
135
+ entry.disabled ? (0, (/*@__PURE__*/$parcel$interopDefault($da5a7b95ca760552$exports))).disabled : ""
136
+ ].filter((c)=>c !== "").join(" "),
97
137
  children: [
98
- /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)("span", {
138
+ typeof entry.label === "string" ? /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)("span", {
99
139
  "aria-label": typeof entry.label === "string" ? entry.label : undefined,
100
140
  "aria-disabled": entry.disabled,
101
- className: "context-menu-item-label",
141
+ className: (0, (/*@__PURE__*/$parcel$interopDefault($da5a7b95ca760552$exports))).contextMenuItemLabel,
102
142
  onMouseDownCapture: (ev)=>{
103
143
  ev.preventDefault();
104
144
  ev.stopPropagation();
@@ -106,7 +146,7 @@ const $5150b66b01c99189$export$8dc6765e8be191c7 = /*#__PURE__*/ (0, ($parcel$int
106
146
  !entry.disabled && toClose();
107
147
  },
108
148
  children: entry.label
109
- }),
149
+ }) : entry.label,
110
150
  entry.group && /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)((0, $d35a356381c44181$export$7e4e6110f96afd7e), {
111
151
  toClose: toClose,
112
152
  entries: entry.group,
@@ -121,6 +161,35 @@ $5150b66b01c99189$export$8dc6765e8be191c7.displayName = "ContextMenu";
121
161
 
122
162
 
123
163
 
164
+ var $63cdf2819565020c$exports = {};
165
+
166
+ $parcel$export($63cdf2819565020c$exports, "caretHolder", function () { return $63cdf2819565020c$export$6ed5f4fbab298e07; }, function (v) { return $63cdf2819565020c$export$6ed5f4fbab298e07 = v; });
167
+ $parcel$export($63cdf2819565020c$exports, "disabled", function () { return $63cdf2819565020c$export$683472f6198a076e; }, function (v) { return $63cdf2819565020c$export$683472f6198a076e = v; });
168
+ $parcel$export($63cdf2819565020c$exports, "hidden", function () { return $63cdf2819565020c$export$73920f18ca706874; }, function (v) { return $63cdf2819565020c$export$73920f18ca706874 = v; });
169
+ $parcel$export($63cdf2819565020c$exports, "lowMenu", function () { return $63cdf2819565020c$export$59e4b099a896b33; }, function (v) { return $63cdf2819565020c$export$59e4b099a896b33 = v; });
170
+ $parcel$export($63cdf2819565020c$exports, "lowMenu-item", function () { return $63cdf2819565020c$export$19fbf76b734bf310; }, function (v) { return $63cdf2819565020c$export$19fbf76b734bf310 = v; });
171
+ $parcel$export($63cdf2819565020c$exports, "lowMenuItem", function () { return $63cdf2819565020c$export$2ad34a478577e75d; }, function (v) { return $63cdf2819565020c$export$2ad34a478577e75d = v; });
172
+ $parcel$export($63cdf2819565020c$exports, "subMenu", function () { return $63cdf2819565020c$export$6e0e6ce39e5a0361; }, function (v) { return $63cdf2819565020c$export$6e0e6ce39e5a0361 = v; });
173
+ $parcel$export($63cdf2819565020c$exports, "visible", function () { return $63cdf2819565020c$export$664c6d24e3175067; }, function (v) { return $63cdf2819565020c$export$664c6d24e3175067 = v; });
174
+ var $63cdf2819565020c$export$6ed5f4fbab298e07;
175
+ var $63cdf2819565020c$export$683472f6198a076e;
176
+ var $63cdf2819565020c$export$73920f18ca706874;
177
+ var $63cdf2819565020c$export$59e4b099a896b33;
178
+ var $63cdf2819565020c$export$19fbf76b734bf310;
179
+ var $63cdf2819565020c$export$2ad34a478577e75d;
180
+ var $63cdf2819565020c$export$6e0e6ce39e5a0361;
181
+ var $63cdf2819565020c$export$664c6d24e3175067;
182
+ $63cdf2819565020c$export$6ed5f4fbab298e07 = `aiw-JfzGeq-caretHolder`;
183
+ $63cdf2819565020c$export$683472f6198a076e = `aiw-JfzGeq-disabled`;
184
+ $63cdf2819565020c$export$73920f18ca706874 = `aiw-JfzGeq-hidden`;
185
+ $63cdf2819565020c$export$59e4b099a896b33 = `aiw-JfzGeq-lowMenu`;
186
+ $63cdf2819565020c$export$19fbf76b734bf310 = `aiw-JfzGeq-lowMenu-item`;
187
+ $63cdf2819565020c$export$2ad34a478577e75d = `aiw-JfzGeq-lowMenuItem`;
188
+ $63cdf2819565020c$export$6e0e6ce39e5a0361 = `aiw-JfzGeq-subMenu`;
189
+ $63cdf2819565020c$export$664c6d24e3175067 = `aiw-JfzGeq-visible`;
190
+
191
+
192
+
124
193
 
125
194
 
126
195
 
@@ -131,7 +200,7 @@ const $d30299730ea8ec1e$export$251b9f54013cdfac = ({ entry: entry, target: targe
131
200
  if (!entry.group || entry.group.length === 0) return /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)((0, $gTuX4$reactjsxruntime.Fragment), {});
132
201
  return /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsxs)("span", {
133
202
  "aria-label": `Sub menu for ${entry.label}`,
134
- className: "caret-holder",
203
+ className: (0, (/*@__PURE__*/$parcel$interopDefault($63cdf2819565020c$exports))).caretHolder,
135
204
  onMouseEnter: ()=>{
136
205
  setVisible(true);
137
206
  },
@@ -150,7 +219,7 @@ const $d30299730ea8ec1e$export$251b9f54013cdfac = ({ entry: entry, target: targe
150
219
  })
151
220
  }),
152
221
  /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)("div", {
153
- className: "sub-menu",
222
+ className: (0, (/*@__PURE__*/$parcel$interopDefault($63cdf2819565020c$exports))).subMenu,
154
223
  children: /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)((0, $5150b66b01c99189$export$8dc6765e8be191c7), {
155
224
  visible: visible,
156
225
  entries: entry.group,
@@ -168,7 +237,10 @@ $d30299730ea8ec1e$export$251b9f54013cdfac.displayName = "LowSubMenu";
168
237
 
169
238
  const $b34598671fff4a77$export$aafc28aea571c4bc = ({ entry: entry, target: target })=>{
170
239
  return /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsxs)("div", {
171
- className: `low-menu-item${entry.disabled ? " disabled" : ""}`,
240
+ className: [
241
+ (0, (/*@__PURE__*/$parcel$interopDefault($63cdf2819565020c$exports))).lowMenuItem,
242
+ entry.disabled ? (0, (/*@__PURE__*/$parcel$interopDefault($63cdf2819565020c$exports))).disabled : ""
243
+ ].filter((c)=>c !== "").join(" "),
172
244
  "aria-label": typeof entry.label === "string" ? entry.label : undefined,
173
245
  "aria-disabled": entry.disabled,
174
246
  onClick: (event)=>{
@@ -178,7 +250,6 @@ const $b34598671fff4a77$export$aafc28aea571c4bc = ({ entry: entry, target: targe
178
250
  },
179
251
  children: [
180
252
  /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)("span", {
181
- className: "low-menu-item-label",
182
253
  children: entry.label
183
254
  }),
184
255
  entry.group && /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)((0, $d30299730ea8ec1e$export$251b9f54013cdfac), {
@@ -191,10 +262,17 @@ const $b34598671fff4a77$export$aafc28aea571c4bc = ({ entry: entry, target: targe
191
262
  $b34598671fff4a77$export$aafc28aea571c4bc.displayName = "LowMenuButton";
192
263
 
193
264
 
194
- const $10d1ee4e7fc9bbbd$export$49e8edc8ebca5f25 = ({ entries: entries, target: target, visible: visible })=>{
265
+ const $10d1ee4e7fc9bbbd$export$49e8edc8ebca5f25 = ({ entries: entries, target: target, visible: visible, xPos: xPos, yPos: yPos })=>{
195
266
  return /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)("div", {
196
- className: `low-menu ${visible ? "visible" : "hidden"}`,
267
+ className: [
268
+ (0, (/*@__PURE__*/$parcel$interopDefault($63cdf2819565020c$exports))).lowMenu,
269
+ visible ? (0, (/*@__PURE__*/$parcel$interopDefault($63cdf2819565020c$exports))).visible : (0, (/*@__PURE__*/$parcel$interopDefault($63cdf2819565020c$exports))).hidden
270
+ ].join(" "),
197
271
  "aria-label": "Low context menu",
272
+ style: {
273
+ left: `${xPos}px`,
274
+ top: `${yPos}px`
275
+ },
198
276
  children: entries.map((e, i)=>/*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)((0, $b34598671fff4a77$export$aafc28aea571c4bc), {
199
277
  entry: e,
200
278
  target: target
@@ -204,12 +282,33 @@ const $10d1ee4e7fc9bbbd$export$49e8edc8ebca5f25 = ({ entries: entries, target: t
204
282
  $10d1ee4e7fc9bbbd$export$49e8edc8ebca5f25.displayName = "LowMenu";
205
283
 
206
284
 
207
- const $3c568ee547c732c3$export$ed4f9641643dc7e4 = ({ children: children, menuItems: menuItems, showLowMenu: showLowMenu = false, style: style = {
208
- height: "fit-content",
209
- width: "fit-content"
210
- } })=>{
285
+ const $3c568ee547c732c3$export$fc58dc71afe92de2 = /*#__PURE__*/ (0, $gTuX4$react.createContext)(null);
286
+ const $3c568ee547c732c3$export$ed4f9641643dc7e4 = ({ children: children, menuItems: menuItems, showLowMenu: showLowMenu = false, ...rest })=>{
287
+ var _divHandlderRef_current;
288
+ // Check for higher content menu
289
+ const higherContext = (0, $gTuX4$react.useContext)($3c568ee547c732c3$export$fc58dc71afe92de2);
290
+ const thisMenuItems = (0, $gTuX4$react.useMemo)(()=>[
291
+ ...higherContext !== null ? [
292
+ ...higherContext.menuItems,
293
+ {
294
+ label: /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)("hr", {
295
+ style: {
296
+ flexGrow: 1,
297
+ cursor: "none",
298
+ margin: "0",
299
+ padding: "0"
300
+ }
301
+ })
302
+ }
303
+ ] : [],
304
+ ...menuItems
305
+ ], [
306
+ higherContext,
307
+ menuItems
308
+ ]);
211
309
  // Menu resources
212
- const divRef = (0, $gTuX4$react.useRef)(null);
310
+ const divHandlderRef = (0, $gTuX4$react.useRef)(null);
311
+ const divMenuRef = (0, $gTuX4$react.useRef)(null);
213
312
  const menuRef = (0, $gTuX4$react.useRef)(null);
214
313
  const [menuXPos, setMenuXPos] = (0, $gTuX4$react.useState)(0);
215
314
  const [menuYPos, setMenuYPos] = (0, $gTuX4$react.useState)(0);
@@ -217,6 +316,8 @@ const $3c568ee547c732c3$export$ed4f9641643dc7e4 = ({ children: children, menuIte
217
316
  const [target, setTarget] = (0, $gTuX4$react.useState)(null);
218
317
  const [lowTarget, setLowTarget] = (0, $gTuX4$react.useState)(null);
219
318
  const [lowMenuVisible, setLowMenuVisible] = (0, $gTuX4$react.useState)(false);
319
+ // Get holder position
320
+ const divHandlerPos = divHandlderRef ? (_divHandlderRef_current = divHandlderRef.current) === null || _divHandlderRef_current === void 0 ? void 0 : _divHandlderRef_current.getBoundingClientRect() : null;
220
321
  // Show menu when context is requested
221
322
  const showMenu = (e)=>{
222
323
  const sel = window.getSelection();
@@ -243,12 +344,22 @@ const $3c568ee547c732c3$export$ed4f9641643dc7e4 = ({ children: children, menuIte
243
344
  handleClick,
244
345
  menuVisible
245
346
  ]);
246
- return /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsxs)((0, $gTuX4$reactjsxruntime.Fragment), {
347
+ return /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsxs)($3c568ee547c732c3$export$fc58dc71afe92de2.Provider, {
348
+ value: {
349
+ menuItems: thisMenuItems
350
+ },
247
351
  children: [
248
352
  /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)("div", {
353
+ ref: divHandlderRef,
354
+ ...rest,
355
+ className: [
356
+ (0, (/*@__PURE__*/$parcel$interopDefault($da5a7b95ca760552$exports))).contextMenuHandler,
357
+ rest.className
358
+ ].join(" "),
359
+ style: {
360
+ ...rest.style
361
+ },
249
362
  onContextMenu: showLowMenu ? undefined : showMenu,
250
- className: "context-menu-handler",
251
- style: style,
252
363
  onMouseEnter: ()=>{
253
364
  showLowMenu && setLowMenuVisible(true);
254
365
  },
@@ -258,26 +369,20 @@ const $3c568ee547c732c3$export$ed4f9641643dc7e4 = ({ children: children, menuIte
258
369
  children: children
259
370
  }),
260
371
  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,
372
+ className: (0, (/*@__PURE__*/$parcel$interopDefault($da5a7b95ca760552$exports))).anchor,
373
+ ref: divMenuRef,
267
374
  children: /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)((0, $5150b66b01c99189$export$8dc6765e8be191c7), {
268
375
  visible: true,
269
376
  ref: menuRef,
270
- entries: menuItems,
377
+ entries: thisMenuItems,
271
378
  xPos: menuXPos,
272
379
  yPos: menuYPos,
273
380
  target: target,
274
381
  toClose: ()=>setMenuVisible(false)
275
382
  })
276
383
  }), document.body),
277
- showLowMenu && /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)("div", {
278
- style: {
279
- position: "relative"
280
- },
384
+ showLowMenu && divHandlerPos && /*#__PURE__*/ (0, $gTuX4$reactdom.createPortal)(/*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)("div", {
385
+ className: (0, (/*@__PURE__*/$parcel$interopDefault($da5a7b95ca760552$exports))).anchor,
281
386
  onMouseEnter: ()=>{
282
387
  const sel = window.getSelection();
283
388
  const lowSel = sel && sel.rangeCount > 0 ? sel.getRangeAt(0) : null;
@@ -289,9 +394,11 @@ const $3c568ee547c732c3$export$ed4f9641643dc7e4 = ({ children: children, menuIte
289
394
  children: /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)((0, $10d1ee4e7fc9bbbd$export$49e8edc8ebca5f25), {
290
395
  visible: lowMenuVisible,
291
396
  entries: menuItems,
292
- target: lowTarget
397
+ target: lowTarget,
398
+ xPos: divHandlerPos.left,
399
+ yPos: divHandlerPos.bottom
293
400
  })
294
- })
401
+ }), document.body)
295
402
  ]
296
403
  });
297
404
  };
@@ -301,6 +408,27 @@ $3c568ee547c732c3$export$ed4f9641643dc7e4.displayName = "ContextMenuHandler";
301
408
 
302
409
 
303
410
 
411
+ const $c986bcdcae4b83bd$export$d81cfea7c54be196 = (divRef)=>{
412
+ if (!divRef.current) return {
413
+ translateX: 0,
414
+ translateY: 0
415
+ };
416
+ else {
417
+ const innerBounce = 16;
418
+ const posn = divRef.current.getBoundingClientRect();
419
+ let translateX = 0;
420
+ if (posn.left < innerBounce) translateX = -posn.left + innerBounce;
421
+ else if (posn.right > window.innerWidth) translateX = Math.max(-posn.left + innerBounce, window.innerWidth - posn.right - innerBounce);
422
+ let translateY = 0;
423
+ if (posn.top < innerBounce) translateY = -posn.top + innerBounce;
424
+ else if (posn.bottom > window.innerHeight) translateY = Math.max(-posn.top + innerBounce, window.innerHeight - posn.bottom - innerBounce);
425
+ return {
426
+ translateX: translateX,
427
+ translateY: translateY
428
+ };
429
+ }
430
+ };
431
+
304
432
 
305
433
 
306
434
 
@@ -334,29 +462,33 @@ const $16208d559c772441$export$9f37482ccd50dad2 = ({ minZIndex: minZIndex = 1000
334
462
  $16208d559c772441$export$9f37482ccd50dad2.displayName = "ContextWindowStack";
335
463
 
336
464
 
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 })=>{
465
+ var $7c5fb3f6c1601913$exports = {};
466
+
467
+ $parcel$export($7c5fb3f6c1601913$exports, "contextWindow", function () { return $7c5fb3f6c1601913$export$72cad2e5ad4d2674; }, function (v) { return $7c5fb3f6c1601913$export$72cad2e5ad4d2674 = v; });
468
+ $parcel$export($7c5fb3f6c1601913$exports, "contextWindowAnchor", function () { return $7c5fb3f6c1601913$export$9f3a8a17ac700f7d; }, function (v) { return $7c5fb3f6c1601913$export$9f3a8a17ac700f7d = v; });
469
+ $parcel$export($7c5fb3f6c1601913$exports, "contextWindowBody", function () { return $7c5fb3f6c1601913$export$dfb2c4d2d1c0156f; }, function (v) { return $7c5fb3f6c1601913$export$dfb2c4d2d1c0156f = v; });
470
+ $parcel$export($7c5fb3f6c1601913$exports, "contextWindowTitle", function () { return $7c5fb3f6c1601913$export$1b02f2cd2f7db0f4; }, function (v) { return $7c5fb3f6c1601913$export$1b02f2cd2f7db0f4 = v; });
471
+ $parcel$export($7c5fb3f6c1601913$exports, "contextWindowTitleClose", function () { return $7c5fb3f6c1601913$export$7ba38d4cc2870e66; }, function (v) { return $7c5fb3f6c1601913$export$7ba38d4cc2870e66 = v; });
472
+ $parcel$export($7c5fb3f6c1601913$exports, "contextWindowTitleText", function () { return $7c5fb3f6c1601913$export$cebbac70b4d99c48; }, function (v) { return $7c5fb3f6c1601913$export$cebbac70b4d99c48 = v; });
473
+ $parcel$export($7c5fb3f6c1601913$exports, "moving", function () { return $7c5fb3f6c1601913$export$d03a2f3acc60252b; }, function (v) { return $7c5fb3f6c1601913$export$d03a2f3acc60252b = v; });
474
+ var $7c5fb3f6c1601913$export$72cad2e5ad4d2674;
475
+ var $7c5fb3f6c1601913$export$9f3a8a17ac700f7d;
476
+ var $7c5fb3f6c1601913$export$dfb2c4d2d1c0156f;
477
+ var $7c5fb3f6c1601913$export$1b02f2cd2f7db0f4;
478
+ var $7c5fb3f6c1601913$export$7ba38d4cc2870e66;
479
+ var $7c5fb3f6c1601913$export$cebbac70b4d99c48;
480
+ var $7c5fb3f6c1601913$export$d03a2f3acc60252b;
481
+ $7c5fb3f6c1601913$export$72cad2e5ad4d2674 = `aiw-RIIF9a-contextWindow`;
482
+ $7c5fb3f6c1601913$export$9f3a8a17ac700f7d = `aiw-RIIF9a-contextWindowAnchor`;
483
+ $7c5fb3f6c1601913$export$dfb2c4d2d1c0156f = `aiw-RIIF9a-contextWindowBody`;
484
+ $7c5fb3f6c1601913$export$1b02f2cd2f7db0f4 = `aiw-RIIF9a-contextWindowTitle`;
485
+ $7c5fb3f6c1601913$export$7ba38d4cc2870e66 = `aiw-RIIF9a-contextWindowTitleClose`;
486
+ $7c5fb3f6c1601913$export$cebbac70b4d99c48 = `aiw-RIIF9a-contextWindowTitleText`;
487
+ $7c5fb3f6c1601913$export$d03a2f3acc60252b = `aiw-RIIF9a-moving`;
488
+
489
+
490
+ const $46fb0088a1bbb6d8$export$1af8984c69ba1b24 = ({ id: id, visible: visible, title: title, children: children, onOpen: onOpen, onClose: onClose, ...rest })=>{
491
+ var _rest_style, _rest_style1, _rest_style2, _rest_style3;
360
492
  const windowStack = (0, $gTuX4$react.useContext)((0, $16208d559c772441$export$aff5d0593e3727b0));
361
493
  const windowId = (0, $gTuX4$react.useRef)(null);
362
494
  const divRef = (0, $gTuX4$react.useRef)(null);
@@ -444,22 +576,23 @@ const $46fb0088a1bbb6d8$export$1af8984c69ba1b24 = ({ id: id, visible: visible, t
444
576
  windowStack,
445
577
  windowVisible
446
578
  ]);
447
- var _style_minHeight, _style_minWidth, _style_maxHeight, _style_maxWidth;
579
+ var _rest_style_minHeight, _rest_style_minWidth, _rest_style_maxHeight, _rest_style_maxWidth;
448
580
  return /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)("div", {
449
- className: "contextwindow-anchor",
581
+ className: (0, (/*@__PURE__*/$parcel$interopDefault($7c5fb3f6c1601913$exports))).contextWindowAnchor,
450
582
  ref: divRef,
451
583
  children: windowStack && /*#__PURE__*/ (0, $gTuX4$reactdom.createPortal)(/*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsxs)("div", {
584
+ ...rest,
452
585
  id: id,
453
- className: "contextwindow",
586
+ className: (0, (/*@__PURE__*/$parcel$interopDefault($7c5fb3f6c1601913$exports))).contextWindow,
454
587
  style: {
455
- ...style,
588
+ ...rest.style,
456
589
  opacity: moving ? 0.8 : windowVisible ? 1 : 0,
457
590
  visibility: windowVisible ? "visible" : "hidden",
458
591
  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"
592
+ 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",
593
+ 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",
594
+ 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",
595
+ 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
596
  },
464
597
  onClickCapture: ()=>{
465
598
  windowId && windowId.current && windowStack.pushToTop(windowId.current);
@@ -467,7 +600,10 @@ const $46fb0088a1bbb6d8$export$1af8984c69ba1b24 = ({ id: id, visible: visible, t
467
600
  ref: windowRef,
468
601
  children: [
469
602
  /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsxs)("div", {
470
- className: `contextwindow-title ${moving ? "moving" : ""}`,
603
+ className: [
604
+ (0, (/*@__PURE__*/$parcel$interopDefault($7c5fb3f6c1601913$exports))).contextWindowTitle,
605
+ moving ? (0, (/*@__PURE__*/$parcel$interopDefault($7c5fb3f6c1601913$exports))).moving : ""
606
+ ].filter((c)=>c !== "").join(" "),
471
607
  onMouseDown: (e)=>{
472
608
  if (e.target && (e.target instanceof HTMLElement || e.target instanceof SVGElement)) e.target.style.userSelect = "none";
473
609
  setMoving(true);
@@ -478,11 +614,11 @@ const $46fb0088a1bbb6d8$export$1af8984c69ba1b24 = ({ id: id, visible: visible, t
478
614
  },
479
615
  children: [
480
616
  /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)("div", {
481
- className: "contextwindow-title-text",
617
+ className: (0, (/*@__PURE__*/$parcel$interopDefault($7c5fb3f6c1601913$exports))).contextWindowTitleText,
482
618
  children: title
483
619
  }),
484
620
  /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)("div", {
485
- className: "contextwindow-title-close",
621
+ className: (0, (/*@__PURE__*/$parcel$interopDefault($7c5fb3f6c1601913$exports))).contextWindowTitleClose,
486
622
  children: /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)("svg", {
487
623
  xmlns: "http://www.w3.org/2000/svg",
488
624
  width: "16",
@@ -499,7 +635,7 @@ const $46fb0088a1bbb6d8$export$1af8984c69ba1b24 = ({ id: id, visible: visible, t
499
635
  ]
500
636
  }),
501
637
  /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)("div", {
502
- className: "contextwindow-body",
638
+ className: (0, (/*@__PURE__*/$parcel$interopDefault($7c5fb3f6c1601913$exports))).contextWindowBody,
503
639
  children: /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)("div", {
504
640
  children: children
505
641
  })