@asup/context-menu 1.4.1 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/main.js +118 -19
- package/dist/cjs/main.js.map +1 -1
- package/dist/context-menu.d.ts +18 -1
- package/dist/context-menu.d.ts.map +1 -1
- package/dist/main.js +120 -21
- package/dist/main.js.map +1 -1
- package/package.json +17 -11
package/dist/cjs/main.js
CHANGED
|
@@ -36,6 +36,8 @@ function $parcel$interopDefault(a) {
|
|
|
36
36
|
var $a68bd8a6c0fd98c2$exports = {};
|
|
37
37
|
|
|
38
38
|
$parcel$export($a68bd8a6c0fd98c2$exports, "AutoHeight", function () { return $95149596d5a7ed2b$export$77bf000da9303d1; });
|
|
39
|
+
$parcel$export($a68bd8a6c0fd98c2$exports, "ClickForMenu", function () { return $a79b75d040e03c92$export$d4ebdd58e04c6ace; });
|
|
40
|
+
$parcel$export($a68bd8a6c0fd98c2$exports, "ContextMenu", function () { return $5150b66b01c99189$export$8dc6765e8be191c7; });
|
|
39
41
|
$parcel$export($a68bd8a6c0fd98c2$exports, "ContextMenuHandler", function () { return $3c568ee547c732c3$export$ed4f9641643dc7e4; });
|
|
40
42
|
$parcel$export($a68bd8a6c0fd98c2$exports, "ContextWindow", function () { return $46fb0088a1bbb6d8$export$1af8984c69ba1b24; });
|
|
41
43
|
$parcel$export($a68bd8a6c0fd98c2$exports, "ContextWindowStack", function () { return $16208d559c772441$export$9f37482ccd50dad2; });
|
|
@@ -269,6 +271,95 @@ $5150b66b01c99189$export$8dc6765e8be191c7.displayName = "ContextMenu";
|
|
|
269
271
|
|
|
270
272
|
|
|
271
273
|
|
|
274
|
+
const $a79b75d040e03c92$export$d4ebdd58e04c6ace = (_param)=>{
|
|
275
|
+
var { id: id, menuItems: menuItems, children: children } = _param, rest = (0, $gTuX4$swchelperscjs_object_without_propertiescjs._)(_param, [
|
|
276
|
+
"id",
|
|
277
|
+
"menuItems",
|
|
278
|
+
"children"
|
|
279
|
+
]);
|
|
280
|
+
// Menu state
|
|
281
|
+
const [menuInDom, setMenuInDom] = (0, $gTuX4$react.useState)(false);
|
|
282
|
+
const [menuVisible, setMenuVisible] = (0, $gTuX4$react.useState)(false);
|
|
283
|
+
const [menuXPos, setMenuXPos] = (0, $gTuX4$react.useState)(0);
|
|
284
|
+
const [menuYPos, setMenuYPos] = (0, $gTuX4$react.useState)(0);
|
|
285
|
+
// Set up outsideClick handler
|
|
286
|
+
const menuRef = (0, $gTuX4$react.useRef)(null);
|
|
287
|
+
// Handle click off the menu
|
|
288
|
+
const handleClick = (0, $gTuX4$react.useCallback)((e)=>{
|
|
289
|
+
var _menuRef_current;
|
|
290
|
+
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))) setMenuInDom(false);
|
|
291
|
+
}, []);
|
|
292
|
+
const removeController = (0, $gTuX4$react.useRef)(new AbortController());
|
|
293
|
+
(0, $gTuX4$react.useEffect)(()=>{
|
|
294
|
+
if (!menuVisible) {
|
|
295
|
+
removeController.current.abort();
|
|
296
|
+
removeController.current = new AbortController();
|
|
297
|
+
setTimeout(()=>{
|
|
298
|
+
if (!removeController.current.signal.aborted) setMenuInDom(false);
|
|
299
|
+
}, 300);
|
|
300
|
+
}
|
|
301
|
+
}, [
|
|
302
|
+
menuVisible
|
|
303
|
+
]);
|
|
304
|
+
// Update the document click handler
|
|
305
|
+
(0, $gTuX4$react.useEffect)(()=>{
|
|
306
|
+
if (menuInDom) document.addEventListener("mousedown", handleClick);
|
|
307
|
+
return ()=>{
|
|
308
|
+
document.removeEventListener("mousedown", handleClick);
|
|
309
|
+
removeController.current.abort();
|
|
310
|
+
};
|
|
311
|
+
}, [
|
|
312
|
+
handleClick,
|
|
313
|
+
menuInDom
|
|
314
|
+
]);
|
|
315
|
+
return /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsxs)((0, $gTuX4$reactjsxruntime.Fragment), {
|
|
316
|
+
children: [
|
|
317
|
+
/*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)("div", (0, $gTuX4$swchelperscjs_object_spread_propscjs._)((0, $gTuX4$swchelperscjs_object_spreadcjs._)({}, rest), {
|
|
318
|
+
id: id,
|
|
319
|
+
onClick: (e)=>{
|
|
320
|
+
var _rest_onClick;
|
|
321
|
+
if (menuItems) {
|
|
322
|
+
setMenuInDom(true);
|
|
323
|
+
e.preventDefault();
|
|
324
|
+
e.stopPropagation();
|
|
325
|
+
setTimeout(()=>{
|
|
326
|
+
removeController.current.abort();
|
|
327
|
+
setMenuVisible(true);
|
|
328
|
+
setMenuXPos(e.pageX);
|
|
329
|
+
setMenuYPos(e.pageY);
|
|
330
|
+
}, 1);
|
|
331
|
+
} else (_rest_onClick = rest.onClick) === null || _rest_onClick === void 0 ? void 0 : _rest_onClick.call(rest, e);
|
|
332
|
+
},
|
|
333
|
+
children: children
|
|
334
|
+
})),
|
|
335
|
+
menuInDom && menuItems && /*#__PURE__*/ (0, $gTuX4$reactdom.createPortal)(/*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)("div", {
|
|
336
|
+
className: (0, (/*@__PURE__*/$parcel$interopDefault($da5a7b95ca760552$exports))).anchor,
|
|
337
|
+
children: /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)((0, $5150b66b01c99189$export$8dc6765e8be191c7), {
|
|
338
|
+
visible: menuVisible,
|
|
339
|
+
ref: menuRef,
|
|
340
|
+
entries: menuItems,
|
|
341
|
+
xPos: menuXPos,
|
|
342
|
+
yPos: menuYPos,
|
|
343
|
+
toClose: ()=>{
|
|
344
|
+
setMenuVisible(false);
|
|
345
|
+
}
|
|
346
|
+
})
|
|
347
|
+
}), document.body)
|
|
348
|
+
]
|
|
349
|
+
});
|
|
350
|
+
};
|
|
351
|
+
$a79b75d040e03c92$export$d4ebdd58e04c6ace.displayName = "ClickForMenu";
|
|
352
|
+
|
|
353
|
+
|
|
354
|
+
|
|
355
|
+
|
|
356
|
+
|
|
357
|
+
|
|
358
|
+
|
|
359
|
+
|
|
360
|
+
|
|
361
|
+
|
|
362
|
+
|
|
272
363
|
|
|
273
364
|
var $63cdf2819565020c$exports = {};
|
|
274
365
|
|
|
@@ -307,6 +398,7 @@ $63cdf2819565020c$export$664c6d24e3175067 = `aiw-LowMenu-module-JfzGeq-visible`;
|
|
|
307
398
|
|
|
308
399
|
|
|
309
400
|
|
|
401
|
+
|
|
310
402
|
const $d30299730ea8ec1e$export$251b9f54013cdfac = ({ entry: entry })=>{
|
|
311
403
|
const [visible, setVisible] = (0, $gTuX4$react.useState)(false);
|
|
312
404
|
if (!entry.group || entry.group.length === 0) return /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)((0, $gTuX4$reactjsxruntime.Fragment), {});
|
|
@@ -346,7 +438,6 @@ const $d30299730ea8ec1e$export$251b9f54013cdfac = ({ entry: entry })=>{
|
|
|
346
438
|
$d30299730ea8ec1e$export$251b9f54013cdfac.displayName = "LowSubMenu";
|
|
347
439
|
|
|
348
440
|
|
|
349
|
-
|
|
350
441
|
const $b34598671fff4a77$export$aafc28aea571c4bc = ({ entry: entry })=>{
|
|
351
442
|
const [target, setTarget] = (0, $gTuX4$react.useState)(null);
|
|
352
443
|
return /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsxs)("div", {
|
|
@@ -365,9 +456,10 @@ const $b34598671fff4a77$export$aafc28aea571c4bc = ({ entry: entry })=>{
|
|
|
365
456
|
setTarget(null);
|
|
366
457
|
},
|
|
367
458
|
onClick: (e)=>{
|
|
459
|
+
var _entry_action;
|
|
368
460
|
e.preventDefault();
|
|
369
461
|
e.stopPropagation();
|
|
370
|
-
|
|
462
|
+
if (!entry.disabled) (_entry_action = entry.action) === null || _entry_action === void 0 ? void 0 : _entry_action.call(entry, target);
|
|
371
463
|
},
|
|
372
464
|
children: [
|
|
373
465
|
/*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)("span", {
|
|
@@ -407,6 +499,9 @@ $10d1ee4e7fc9bbbd$export$49e8edc8ebca5f25.displayName = "LowMenu";
|
|
|
407
499
|
|
|
408
500
|
|
|
409
501
|
const $3c568ee547c732c3$export$fc58dc71afe92de2 = /*#__PURE__*/ (0, $gTuX4$react.createContext)(null);
|
|
502
|
+
function $3c568ee547c732c3$var$isDivider(label) {
|
|
503
|
+
return typeof label !== "string" && label.type === "hr";
|
|
504
|
+
}
|
|
410
505
|
const $3c568ee547c732c3$export$ed4f9641643dc7e4 = (_param)=>{
|
|
411
506
|
var { children: children, menuItems: menuItems, showLowMenu: showLowMenu = false } = _param, rest = (0, $gTuX4$swchelperscjs_object_without_propertiescjs._)(_param, [
|
|
412
507
|
"children",
|
|
@@ -419,16 +514,18 @@ const $3c568ee547c732c3$export$ed4f9641643dc7e4 = (_param)=>{
|
|
|
419
514
|
const thisMenuItems = (0, $gTuX4$react.useMemo)(()=>[
|
|
420
515
|
...higherContext !== null ? [
|
|
421
516
|
...higherContext.menuItems,
|
|
422
|
-
|
|
423
|
-
label
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
517
|
+
...[
|
|
518
|
+
higherContext.menuItems.length > 0 && !$3c568ee547c732c3$var$isDivider(higherContext.menuItems[higherContext.menuItems.length - 1].label) && menuItems.length > 0 && !$3c568ee547c732c3$var$isDivider(menuItems[0].label) ? {
|
|
519
|
+
label: /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)("hr", {
|
|
520
|
+
style: {
|
|
521
|
+
flexGrow: 1,
|
|
522
|
+
cursor: "none",
|
|
523
|
+
margin: "0",
|
|
524
|
+
padding: "0"
|
|
525
|
+
}
|
|
526
|
+
})
|
|
527
|
+
} : null
|
|
528
|
+
].filter((item)=>item !== null)
|
|
432
529
|
] : [],
|
|
433
530
|
...menuItems
|
|
434
531
|
], [
|
|
@@ -454,7 +551,6 @@ const $3c568ee547c732c3$export$ed4f9641643dc7e4 = (_param)=>{
|
|
|
454
551
|
// Update the document click handler
|
|
455
552
|
(0, $gTuX4$react.useEffect)(()=>{
|
|
456
553
|
if (menuVisible) document.addEventListener("mousedown", handleClick);
|
|
457
|
-
else document.removeEventListener("mousedown", handleClick);
|
|
458
554
|
return ()=>{
|
|
459
555
|
document.removeEventListener("mousedown", handleClick);
|
|
460
556
|
};
|
|
@@ -502,6 +598,7 @@ const $3c568ee547c732c3$export$ed4f9641643dc7e4 = (_param)=>{
|
|
|
502
598
|
}
|
|
503
599
|
},
|
|
504
600
|
onMouseEnter: async (e)=>{
|
|
601
|
+
var _rest_onMouseEnter;
|
|
505
602
|
if (showLowMenu) {
|
|
506
603
|
setMenuInDom(true);
|
|
507
604
|
setMouseOverHandlerDiv(false);
|
|
@@ -510,15 +607,16 @@ const $3c568ee547c732c3$export$ed4f9641643dc7e4 = (_param)=>{
|
|
|
510
607
|
setMouseOverHandlerDiv(true);
|
|
511
608
|
}, 1);
|
|
512
609
|
}
|
|
513
|
-
rest.onMouseEnter
|
|
610
|
+
(_rest_onMouseEnter = rest.onMouseEnter) === null || _rest_onMouseEnter === void 0 ? void 0 : _rest_onMouseEnter.call(rest, e);
|
|
514
611
|
},
|
|
515
612
|
onMouseLeave: async (e)=>{
|
|
613
|
+
var _rest_onMouseLeave;
|
|
516
614
|
if (showLowMenu) {
|
|
517
615
|
removeController.current.abort();
|
|
518
616
|
removeController.current = new AbortController();
|
|
519
617
|
setMouseOverHandlerDiv(false);
|
|
520
618
|
}
|
|
521
|
-
rest.onMouseLeave
|
|
619
|
+
(_rest_onMouseLeave = rest.onMouseLeave) === null || _rest_onMouseLeave === void 0 ? void 0 : _rest_onMouseLeave.call(rest, e);
|
|
522
620
|
},
|
|
523
621
|
children: children
|
|
524
622
|
})),
|
|
@@ -719,7 +817,7 @@ const $46fb0088a1bbb6d8$export$1af8984c69ba1b24 = (_param)=>{
|
|
|
719
817
|
}
|
|
720
818
|
windowStack.pushToTop(windowId.current);
|
|
721
819
|
setWindowVisible(visible);
|
|
722
|
-
onOpen
|
|
820
|
+
onOpen === null || onOpen === void 0 ? void 0 : onOpen();
|
|
723
821
|
// Get starting position
|
|
724
822
|
if (divRef.current && windowRef.current) {
|
|
725
823
|
const parentPos = divRef.current.getBoundingClientRect();
|
|
@@ -781,8 +879,9 @@ const $46fb0088a1bbb6d8$export$1af8984c69ba1b24 = (_param)=>{
|
|
|
781
879
|
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"
|
|
782
880
|
}),
|
|
783
881
|
onClickCapture: (e)=>{
|
|
784
|
-
|
|
785
|
-
|
|
882
|
+
var _rest_onClickCapture;
|
|
883
|
+
if (windowId.current) windowStack.pushToTop(windowId.current);
|
|
884
|
+
(_rest_onClickCapture = rest.onClickCapture) === null || _rest_onClickCapture === void 0 ? void 0 : _rest_onClickCapture.call(rest, e);
|
|
786
885
|
},
|
|
787
886
|
children: [
|
|
788
887
|
/*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsxs)("div", {
|
|
@@ -793,7 +892,7 @@ const $46fb0088a1bbb6d8$export$1af8984c69ba1b24 = (_param)=>{
|
|
|
793
892
|
onMouseDown: (e)=>{
|
|
794
893
|
if (e.target && (e.target instanceof HTMLElement || e.target instanceof SVGElement)) e.target.style.userSelect = "none";
|
|
795
894
|
setMoving(true);
|
|
796
|
-
|
|
895
|
+
if (windowId.current) windowStack.pushToTop(windowId.current);
|
|
797
896
|
document.addEventListener("mouseup", mouseUp);
|
|
798
897
|
document.addEventListener("mousemove", mouseMove);
|
|
799
898
|
window.addEventListener("resize", ()=>checkPosition());
|
package/dist/cjs/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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kCAEA,iCAAC;wBACC,WAAW;4BAAC,CAAA,GAAA,gEAAK,EAAE,kBAAkB;4BAAE,SAAS,CAAA,GAAA,gEAAK,EAAE,MAAM,GAAG;yBAAG,CAChE,MAAM,CAAC,CAAC,IAAM,MAAM,IACpB,IAAI,CAAC;wBACR,aAAa,CAAC;4BACZ,IAAI,EAAE,MAAM,IAAK,CAAA,EAAE,MAAM,YAAY,eAAe,EAAE,MAAM,YAAY,UAAS,GAC/E,EAAE,MAAM,CAAC,KAAK,CAAC,UAAU,GAAG;4BAC9B,UAAU;4BACV,YAAY,SAAS,OAAO,IAAI,YAAY,SAAS,CAAC,SAAS,OAAO;4BACtE,SAAS,gBAAgB,CAAC,WAAW;4BACrC,SAAS,gBAAgB,CAAC,aAAa;4BACvC,OAAO,gBAAgB,CAAC,UAAU,IAAM;wBAC1C;;0CAEA,gCAAC;gCACC,WAAW,CAAA,GAAA,gEAAK,EAAE,sBAAsB;gCACxC,OAAO;0CAEN,eAAe,eAAe;;0CAEjC,gCAAC;gCACC,WAAW,CAAA,GAAA,gEAAK,EAAE,uBAAuB;gCACzC,MAAK;gCACL,cAAW;gCACX,SAAS;gCACT,OAAO,CAAC,MAAM,EAAE,SAAS,MAAM,IAAI,OAAO,KAAK,QAAQ,UAAU;0CAEjE,cAAA,gCAAC;oCACC,OAAM;oCACN,OAAM;oCACN,QAAO;oCACP,MAAK;oCACL,SAAQ;8CAER,cAAA,gCAAC;wCAAK,GAAE;;;;;;kCAId,gCAAC;wBAAI,WAAW,CAAA,GAAA,gEAAK,EAAE,iBAAiB;kCACtC,cAAA,gCAAC;sCAAK;;;;iBAGV,SAAS,IAAI;;;AAIvB;AAEA,0CAAc,WAAW,GAAG;","sources":["src/main.ts","global.d.ts","src/components/index.ts","src/components/AutoHeight.tsx","src/components/AutoHeight.module.css","src/components/ContextMenuHandler.tsx","src/components/ContextMenu.tsx","src/components/ContextMenu.module.css","src/components/ContextMenuEntry.tsx","src/components/ContextSubMenu.tsx","src/components/LowMenu.tsx","src/components/LowMenu.module.css","src/components/LowMenuButton.tsx","src/components/LowSubMenu.tsx","src/components/ContextWindow.tsx","src/functions/chkPosition.ts","src/components/ContextWindow.module.css","src/components/ContextWindowStack.tsx"],"sourcesContent":["import \"../global.d.ts\";\nexport * from \"./components\";\n","declare module \"*.module.css\" {\n const classes: { readonly [key: string]: string };\n export default classes;\n}\n","import { AutoHeight } from \"./AutoHeight\";\nimport { ContextMenuHandler } from \"./ContextMenuHandler\";\nimport { ContextWindow } from \"./ContextWindow\";\nimport { ContextWindowStack } from \"./ContextWindowStack\";\nimport { MenuItem } from \"./interface\";\n\nexport { AutoHeight, ContextMenuHandler, ContextWindow, ContextWindowStack };\nexport type { MenuItem as iMenuItem };\n","import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from \"react\";\nimport styles from \"./AutoHeight.module.css\";\n\ninterface AutoHeightProps extends React.HTMLAttributes<HTMLDivElement> {\n children: React.ReactNode;\n hide?: boolean;\n duration?: number; // transition duration in ms\n}\n\nexport function AutoHeight({\n children,\n hide,\n duration = 300,\n ...rest\n}: AutoHeightProps): JSX.Element {\n const wrapperRef = useRef<HTMLDivElement>(null);\n const innerRef = useRef<HTMLDivElement>(null);\n const [height, setHeight] = useState<number | null>(null);\n const targetChildren = useMemo<React.ReactNode>(\n () => (hide || !children ? <div style={{ height: \"1px\" }} /> : children),\n [children, hide],\n );\n\n const setTargetHeight = useCallback(() => {\n const inner = innerRef.current;\n\n // Initial draw to get the height of children and deployed children\n const deployedHeight = hide ? 1 : (inner?.offsetHeight ?? 0);\n setHeight(deployedHeight);\n }, [hide]);\n\n // Add ResizeObserver to update height on content resize, debounced\n useEffect(() => {\n const transition = innerRef.current;\n if (transition) {\n const observer = new ResizeObserver(() => {\n setTargetHeight();\n });\n\n observer.observe(transition);\n\n return () => {\n observer.disconnect();\n };\n }\n }, [setTargetHeight]);\n\n // Trigger height change on children update\n useLayoutEffect(() => {\n setTargetHeight();\n }, [setTargetHeight, children]);\n\n return (\n <div\n {...rest}\n className={styles.autoHeightWrapper}\n ref={wrapperRef}\n style={{\n ...rest.style,\n height: height ? `${height}px` : \"auto\",\n transitionDuration: `${duration}ms`,\n }}\n >\n <div\n className={styles.autoHeightInner}\n ref={innerRef}\n >\n {targetChildren}\n </div>\n </div>\n );\n}\n\nAutoHeight.displayName = \"AutoHeight\";\n",".autoHeightWrapper {\n overflow: hidden;\n transition-timing-function: height ease-in-out width ease-in-out background-color ease-in-out;\n box-sizing: border-box;\n position: relative;\n}\n\n.autoHeightInner {\n height: fit-content;\n}\n","import {\n createContext,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { ContextMenu } from \"./ContextMenu\";\nimport styles from \"./ContextMenu.module.css\";\nimport { LowMenu } from \"./LowMenu\";\nimport { MenuItem } from \"./interface\";\n\nexport interface ContentMenuHandlerContextProps {\n menuItems: MenuItem[];\n}\nexport const ContentMenuHandlerContext = createContext<ContentMenuHandlerContextProps | null>(null);\n\nexport interface ContextMenuHandlerProps extends React.HTMLAttributes<HTMLDivElement> {\n children: React.ReactNode;\n menuItems: MenuItem[];\n showLowMenu?: boolean;\n}\n\nexport const ContextMenuHandler = ({\n children,\n menuItems,\n showLowMenu = false,\n ...rest\n}: ContextMenuHandlerProps): JSX.Element => {\n // Check for higher content menu\n const higherContext = useContext(ContentMenuHandlerContext);\n const thisMenuItems = useMemo(\n () => [\n ...(higherContext !== null\n ? [\n ...higherContext.menuItems,\n {\n label: <hr style={{ flexGrow: 1, cursor: \"none\", margin: \"0\", padding: \"0\" }} />,\n },\n ]\n : []),\n ...menuItems,\n ],\n [higherContext, menuItems],\n );\n\n // Menu resources\n const divHandlderRef = useRef<HTMLDivElement | null>(null);\n const menuRef = useRef<HTMLDivElement | null>(null);\n const [menuXPos, setMenuXPos] = useState<number>(0);\n const [menuYPos, setMenuYPos] = useState<number>(0);\n const [menuVisible, setMenuVisible] = useState<boolean>(false);\n const [menuInDom, setMenuInDom] = useState<boolean>(false);\n const [mouseOverHandlerDiv, setMouseOverHandlerDiv] = useState<boolean>(false);\n const [mouseOverMenu, setMouseOverMenu] = useState<boolean>(false);\n\n // Get holder position\n const divHandlerPos = divHandlderRef ? divHandlderRef.current?.getBoundingClientRect() : null;\n\n // Handle click off the menu\n const handleClick = useCallback((e: globalThis.MouseEvent) => {\n if (\n menuRef.current &&\n ((e.target instanceof Element && !menuRef.current?.contains(e.target)) ||\n !(e.target instanceof Element))\n ) {\n setMenuVisible(false);\n }\n }, []);\n\n // Update the document click handler\n useEffect(() => {\n if (menuVisible) document.addEventListener(\"mousedown\", handleClick);\n else document.removeEventListener(\"mousedown\", handleClick);\n return () => {\n document.removeEventListener(\"mousedown\", handleClick);\n };\n }, [handleClick, menuVisible]);\n\n const removeController = useRef<AbortController>(new AbortController());\n useEffect(() => {\n if (!mouseOverMenu && !menuVisible && !mouseOverHandlerDiv) {\n removeController.current.abort();\n removeController.current = new AbortController();\n setTimeout(() => {\n if (!removeController.current.signal.aborted) setMenuInDom(false);\n }, 300);\n }\n }, [mouseOverHandlerDiv, menuVisible, mouseOverMenu]);\n\n return (\n <ContentMenuHandlerContext.Provider\n value={{\n menuItems: thisMenuItems,\n }}\n >\n <div\n ref={divHandlderRef}\n {...rest}\n className={[styles.contextMenuHandler, rest.className].join(\" \")}\n onContextMenu={async (e) => {\n if (!showLowMenu) {\n setMenuInDom(true);\n e.preventDefault();\n e.stopPropagation();\n setTimeout(() => {\n removeController.current.abort();\n setMenuVisible(true);\n setMenuXPos(e.pageX);\n setMenuYPos(e.pageY);\n }, 1);\n }\n }}\n onMouseEnter={async (e) => {\n if (showLowMenu) {\n setMenuInDom(true);\n setMouseOverHandlerDiv(false);\n setTimeout(() => {\n removeController.current.abort();\n setMouseOverHandlerDiv(true);\n }, 1);\n }\n rest.onMouseEnter && rest.onMouseEnter(e);\n }}\n onMouseLeave={async (e) => {\n if (showLowMenu) {\n removeController.current.abort();\n removeController.current = new AbortController();\n setMouseOverHandlerDiv(false);\n }\n rest.onMouseLeave && rest.onMouseLeave(e);\n }}\n >\n {children}\n </div>\n {menuInDom &&\n divHandlerPos &&\n createPortal(\n <div\n className={styles.anchor}\n onMouseEnter={() => {\n removeController.current.abort();\n setMouseOverMenu(true);\n }}\n onMouseLeave={() => {\n removeController.current.abort();\n removeController.current = new AbortController();\n setMouseOverMenu(false);\n }}\n >\n {showLowMenu ? (\n <LowMenu\n visible={mouseOverHandlerDiv}\n entries={menuItems}\n xPos={divHandlerPos.left}\n yPos={divHandlerPos.bottom}\n maxWidth={divHandlerPos.width}\n />\n ) : (\n <ContextMenu\n visible={menuVisible}\n ref={menuRef}\n entries={thisMenuItems}\n xPos={menuXPos}\n yPos={menuYPos}\n toClose={() => {\n setMenuVisible(false);\n setMouseOverMenu(false);\n }}\n />\n )}\n </div>,\n document.body,\n )}\n </ContentMenuHandlerContext.Provider>\n );\n};\n\nContextMenuHandler.displayName = \"ContextMenuHandler\";\n","import { forwardRef } from \"react\";\nimport styles from \"./ContextMenu.module.css\";\nimport { ContextMenuEntry } from \"./ContextMenuEntry\";\nimport { MenuItem } from \"./interface\";\n\nexport interface ContextMenuProps {\n visible: boolean;\n entries: MenuItem[];\n xPos: number;\n yPos: number;\n toClose: () => void;\n}\n\nexport const ContextMenu = forwardRef<HTMLDivElement, ContextMenuProps>(\n ({ visible, entries, xPos, yPos, toClose }, ref): JSX.Element => {\n return (\n <div\n ref={ref}\n className={[styles.contextMenu, visible ? styles.visible : styles.hidden]\n .filter((c) => c !== \"\")\n .join(\" \")}\n style={{\n top: `${yPos}px`,\n left: `${xPos}px`,\n }}\n onContextMenu={(e) => {\n e.preventDefault();\n e.stopPropagation();\n }}\n >\n {entries.map((entry, i) => (\n <ContextMenuEntry\n key={i}\n entry={entry}\n toClose={toClose}\n />\n ))}\n </div>\n );\n },\n);\n\nContextMenu.displayName = \"ContextMenu\";\n",".anchor {\n position: absolute;\n top: 0;\n left: 0;\n font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", \"Roboto\", \"Oxygen\", \"Ubuntu\",\n \"Cantarell\", \"Fira Sans\", \"Droid Sans\", \"Helvetica Neue\", sans-serif;\n font-size: 9pt;\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n}\n\n.contextMenuHandler {\n height: fit-content;\n width: fit-content;\n}\n\n.contextMenu {\n position: absolute;\n border: 1px solid;\n border-color: rgb(17, 20, 24);\n opacity: 1;\n background-color: rgb(251, 253, 246);\n z-index: 10000;\n box-shadow: 4px 4px 4px rgb(64, 64, 64, 0.75);\n transition: opacity 0.3s linear;\n}\n\n.contextMenu.hidden {\n opacity: 0;\n}\n\n.contextMenu.visible {\n opacity: 1;\n}\n\n.contextMenuItem {\n color: rgb(17, 20, 24);\n cursor: pointer;\n padding: 0 4px;\n min-width: 80px;\n position: relative;\n display: flex;\n flex-direction: row;\n justify-content: space-between;\n white-space: nowrap;\n}\n\n.contextMenuItem.disabled {\n background-color: rgba(0, 0, 0, 0.2);\n cursor: not-allowed;\n}\n\n.contextMenuItem:first-child {\n padding-top: 4px;\n}\n\n.contextMenuItem:last-child {\n padding-bottom: 4px;\n}\n\n.contextMenuItem:not(.disabled):hover {\n background-color: rgb(251, 233, 230);\n}\n\n.contextMenuItem .caretHolder {\n align-self: flex-end;\n}\n\n.contextMenuItem .caretHolder .subMenu {\n z-index: 1;\n position: relative;\n}\n\n.contextMenuItemLabel {\n flex-grow: 1;\n height: 19px;\n}\n","import { useState } from \"react\";\nimport styles from \"./ContextMenu.module.css\";\nimport { ContextSubMenu } from \"./ContextSubMenu\";\nimport { MenuItem } from \"./interface\";\n\ninterface ContextMenuEntryProps {\n entry: MenuItem;\n toClose: () => void;\n}\n\nexport const ContextMenuEntry = ({ entry, toClose }: ContextMenuEntryProps) => {\n const [target, setTarget] = useState<Range | null>(null);\n const [subMenuVisible, setSubMenuVisible] = useState<boolean>(false);\n return (\n <div\n className={[styles.contextMenuItem, entry.disabled ? styles.disabled : \"\"]\n .filter((c) => c !== \"\")\n .join(\" \")}\n onMouseEnter={() => {\n setSubMenuVisible(true);\n }}\n onMouseLeave={() => {\n setSubMenuVisible(false);\n }}\n >\n {typeof entry.label === \"string\" ? (\n <span\n aria-label={typeof entry.label === \"string\" ? entry.label : undefined}\n aria-disabled={entry.disabled}\n className={styles.contextMenuItemLabel}\n onMouseEnter={() => {\n const sel = window.getSelection();\n const target = sel && sel.rangeCount > 0 ? sel.getRangeAt(0) : null;\n setTarget(target);\n }}\n onMouseLeave={() => {\n setTarget(null);\n }}\n onMouseDownCapture={(e) => {\n e.preventDefault();\n e.stopPropagation();\n if (!entry.disabled) {\n if (entry.action) {\n entry.action(target, e);\n }\n toClose();\n }\n }}\n >\n {entry.label}\n </span>\n ) : (\n entry.label\n )}\n {entry.group && (\n <ContextSubMenu\n toClose={toClose}\n entries={entry.group}\n visible={subMenuVisible}\n />\n )}\n </div>\n );\n};\n","import { ContextMenu } from \"./ContextMenu\";\nimport styles from \"./ContextMenu.module.css\";\nimport { MenuItem } from \"./interface\";\n\nexport interface ContextSubMenuProps {\n entries: MenuItem[];\n toClose: () => void;\n lowMenu?: boolean;\n visible: boolean;\n}\n\nexport const ContextSubMenu = ({ entries, toClose, visible }: ContextSubMenuProps): JSX.Element => {\n return (\n <span className={styles.caretHolder}>\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"16\"\n height=\"16\"\n fill=\"currentColor\"\n viewBox=\"0 0 16 16\"\n >\n <path 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\" />\n </svg>\n <div className={styles.subMenu}>\n <ContextMenu\n visible={visible}\n entries={entries}\n xPos={14}\n yPos={-21}\n toClose={toClose}\n />\n </div>\n </span>\n );\n};\n\nContextSubMenu.displayName = \"ContextSubMenu\";\n","import styles from \"./LowMenu.module.css\";\nimport { LowMenuButton } from \"./LowMenuButton\";\nimport { MenuItem } from \"./interface\";\n\ninterface LowMenuProps {\n entries: MenuItem[];\n visible: boolean;\n xPos: number;\n yPos: number;\n maxWidth: number;\n}\n\nexport const LowMenu = ({ entries, visible, xPos, yPos, maxWidth }: LowMenuProps): JSX.Element => {\n return (\n <div\n className={[styles.lowMenu, visible ? styles.visible : styles.hidden].join(\" \")}\n aria-label=\"Low context menu\"\n style={{\n left: `${xPos}px`,\n top: `${yPos}px`,\n maxWidth: `calc(${maxWidth}px)`,\n width: `calc(${maxWidth}px - 4px)`,\n }}\n >\n <div className={styles.lowMenuButtonHolder}>\n {entries.map((e, i) => (\n <LowMenuButton\n key={i}\n entry={e}\n />\n ))}\n </div>\n </div>\n );\n};\n\nLowMenu.displayName = \"LowMenu\";\n",".lowMenu {\n z-index: 2;\n position: absolute;\n margin: 0px;\n transition: opacity 0.3s linear;\n}\n\n.lowMenuButtonHolder {\n border: 2px solid rgb(17, 20, 24);\n border-top-right-radius: 4px;\n border-bottom-left-radius: 4px;\n border-bottom-right-radius: 4px;\n background-color: rgb(17, 20, 24);\n box-shadow: 2px 2px 2px rgb(64, 64, 64, 0.5);\n display: flex;\n flex-wrap: wrap;\n flex-direction: row;\n gap: 2px;\n row-gap: 2px;\n width: fit-content;\n}\n\n.lowMenu.hidden {\n opacity: 0;\n}\n\n.lowMenu.visible,\n.lowMenu:hover {\n opacity: 1;\n}\n\n.lowMenuItem {\n background-color: rgb(251, 253, 246);\n border: 0;\n color: rgb(17, 20, 24);\n cursor: pointer;\n padding: 0 4px;\n position: relative;\n display: flex;\n flex-direction: row;\n justify-content: space-between;\n white-space: nowrap;\n}\n\n.lowMenuItem.disabled {\n background-color: rgba(200, 200, 200);\n cursor: not-allowed;\n}\n\n.lowMenuItem:not(.disabled):hover {\n background-color: rgb(251, 233, 230);\n}\n\n.lowMenu-item .caretHolder {\n align-self: flex-end;\n}\n\n.lowMenuItem .caretHolder .subMenu {\n z-index: 1;\n position: relative;\n}\n","import styles from \"./LowMenu.module.css\";\nimport { LowSubMenu } from \"./LowSubMenu\";\nimport { MenuItem } from \"./interface\";\nimport { useState } from \"react\";\n\ninterface LowMenuButtonProps {\n entry: MenuItem;\n}\nexport const LowMenuButton = ({ entry }: LowMenuButtonProps) => {\n const [target, setTarget] = useState<Range | null>(null);\n return (\n <div\n className={[styles.lowMenuItem, entry.disabled ? styles.disabled : \"\"]\n .filter((c) => c !== \"\")\n .join(\" \")}\n aria-label={typeof entry.label === \"string\" ? entry.label : undefined}\n aria-disabled={entry.disabled}\n onMouseEnter={() => {\n const sel = window.getSelection();\n const target = sel && sel.rangeCount > 0 ? sel.getRangeAt(0) : null;\n setTarget(target);\n }}\n onMouseLeave={() => {\n setTarget(null);\n }}\n onClick={(e) => {\n e.preventDefault();\n e.stopPropagation();\n entry.action && !entry.disabled && entry.action(target);\n }}\n >\n <span>{entry.label}</span>\n {entry.group && <LowSubMenu entry={entry} />}\n </div>\n );\n};\n\nLowMenuButton.displayName = \"LowMenuButton\";\n","import { useState } from \"react\";\nimport { ContextMenu } from \"./ContextMenu\";\nimport styles from \"./LowMenu.module.css\";\nimport { MenuItem } from \"./interface\";\n\nexport interface LowSubMenuProps {\n entry: MenuItem;\n lowMenu?: boolean;\n}\n\nexport const LowSubMenu = ({ entry }: LowSubMenuProps): JSX.Element => {\n const [visible, setVisible] = useState<boolean>(false);\n if (!entry.group || entry.group.length === 0) return <></>;\n return (\n <span\n aria-label={`Sub menu for ${entry.label}`}\n className={styles.caretHolder}\n onMouseEnter={() => {\n setVisible(true);\n }}\n onMouseLeave={() => {\n setVisible(false);\n }}\n >\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"16\"\n height=\"16\"\n fill=\"currentColor\"\n viewBox=\"0 0 16 16\"\n >\n <path 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\" />\n </svg>\n <div className={styles.subMenu}>\n {visible && (\n <ContextMenu\n visible={visible}\n entries={entry.group}\n xPos={14}\n yPos={entry.group.length * -21 - 8}\n toClose={() => setVisible(false)}\n />\n )}\n </div>\n </span>\n );\n};\n\nLowSubMenu.displayName = \"LowSubMenu\";\n","import { ReactNode, useCallback, useContext, useEffect, useMemo, useRef, useState } from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { chkPosition } from \"../functions/chkPosition\";\nimport styles from \"./ContextWindow.module.css\";\nimport { ContextWindowStackContext } from \"./ContextWindowStack\";\n\ninterface ContextWindowProps extends React.HTMLAttributes<HTMLDivElement> {\n id: string;\n visible: boolean;\n onOpen?: () => void;\n onClose?: () => void;\n title: string;\n titleElement?: ReactNode;\n style?: React.CSSProperties;\n children: React.ReactNode;\n}\n\nexport const ContextWindow = ({\n id,\n visible,\n title,\n titleElement,\n children,\n onOpen,\n onClose,\n ...rest\n}: ContextWindowProps): JSX.Element => {\n const windowStack = useContext(ContextWindowStackContext);\n const windowId = useRef<number | null>(null);\n const divRef = useRef<HTMLDivElement | null>(null);\n const windowRef = useRef<HTMLDivElement | null>(null);\n const [windowInDOM, setWindowInDOM] = useState<boolean>(false);\n const [windowVisible, setWindowVisible] = useState<boolean>(false);\n const zIndex = useMemo(() => {\n return windowStack?.currentWindows.find((w) => w.windowId === windowId.current)?.zIndex ?? 1;\n }, [windowStack?.currentWindows]);\n\n // Position\n const windowPos = useRef<{ x: number; y: number }>({ x: 0, y: 0 });\n const [moving, setMoving] = useState<boolean>(false);\n\n const move = useCallback((x: number, y: number) => {\n if (windowRef.current && windowPos.current) {\n const window = windowRef.current;\n const pos = windowPos.current;\n pos.x += x;\n pos.y += y;\n window.style.transform = `translate(${pos.x}px, ${pos.y}px)`;\n }\n }, []);\n\n const checkPosition = useCallback(() => {\n const chkPos = chkPosition(windowRef);\n move(chkPos.translateX, chkPos.translateY);\n }, [move]);\n\n const mouseMove = useCallback(\n (e: MouseEvent) => {\n e.preventDefault();\n e.stopPropagation();\n move(e.movementX, e.movementY);\n },\n [move],\n );\n\n const mouseUp = useCallback(\n (e: MouseEvent) => {\n e.preventDefault();\n e.stopPropagation();\n setMoving(false);\n checkPosition();\n document.removeEventListener(\"mousemove\", mouseMove);\n document.removeEventListener(\"mouseup\", mouseUp);\n window.removeEventListener(\"resize\", checkPosition);\n if (e.target && (e.target instanceof HTMLElement || e.target instanceof SVGElement))\n e.target.style.userSelect = \"auto\";\n },\n [checkPosition, mouseMove],\n );\n\n // Update visibility\n useEffect(() => {\n if (windowStack) {\n // Visible set, but not in DOM\n if (visible && !windowInDOM) {\n setWindowInDOM(true);\n } else if (visible && windowInDOM && !windowVisible) {\n if (!windowId.current) {\n const maxWindowId = Math.max(0, ...windowStack.currentWindows.map((w) => w.windowId));\n windowId.current = maxWindowId + 1;\n }\n windowStack.pushToTop(windowId.current);\n setWindowVisible(visible);\n onOpen && onOpen();\n // Get starting position\n if (divRef.current && windowRef.current) {\n const parentPos = divRef.current.getBoundingClientRect();\n const pos = windowRef.current.getBoundingClientRect();\n const windowHeight = pos.bottom - pos.top;\n windowRef.current.style.left = `${parentPos.left}px`;\n windowRef.current.style.top = `${\n parentPos.bottom + windowHeight < window.innerHeight\n ? parentPos.bottom\n : Math.max(0, parentPos.top - windowHeight)\n }px`;\n windowRef.current.style.transform = \"\";\n windowPos.current = { x: 0, y: 0 };\n }\n checkPosition();\n } else if (windowId.current && !visible && windowVisible) {\n setWindowVisible(false);\n } else if (windowId.current && !visible && windowInDOM) {\n setWindowInDOM(false);\n }\n }\n }, [checkPosition, onOpen, visible, windowInDOM, windowStack, windowVisible]);\n\n return (\n <div\n className={styles.contextWindowAnchor}\n ref={divRef}\n >\n {!windowStack && (\n <div {...rest}>\n {process.env.NODE_ENV !== \"production\" && (\n <div\n style={{ backgroundColor: \"red\", color: \"white\", padding: \"8px\", fontSize: \"48px\" }}\n >\n WARNING: No ContextWindowStack found\n </div>\n )}\n {children}\n </div>\n )}\n {windowStack &&\n windowInDOM &&\n createPortal(\n <div\n {...rest}\n ref={windowRef}\n id={id}\n className={[styles.contextWindow, rest.className].filter((c) => c).join(\" \")}\n style={{\n ...rest.style,\n opacity: moving ? 0.8 : windowVisible ? 1 : 0,\n visibility: windowVisible ? \"visible\" : \"hidden\",\n zIndex: zIndex ?? 1,\n minHeight: rest.style?.minHeight ?? \"150px\",\n minWidth: rest.style?.minWidth ?? \"200px\",\n maxHeight: rest.style?.maxHeight ?? \"1000px\",\n maxWidth: rest.style?.maxWidth ?? \"1000px\",\n }}\n onClickCapture={(e) => {\n windowId && windowId.current && windowStack.pushToTop(windowId.current);\n rest.onClickCapture && rest.onClickCapture(e);\n }}\n >\n <div\n className={[styles.contextWindowTitle, moving ? styles.moving : \"\"]\n .filter((c) => c !== \"\")\n .join(\" \")}\n onMouseDown={(e: React.MouseEvent) => {\n if (e.target && (e.target instanceof HTMLElement || e.target instanceof SVGElement))\n e.target.style.userSelect = \"none\";\n setMoving(true);\n windowId && windowId.current && windowStack.pushToTop(windowId.current);\n document.addEventListener(\"mouseup\", mouseUp);\n document.addEventListener(\"mousemove\", mouseMove);\n window.addEventListener(\"resize\", () => checkPosition());\n }}\n >\n <div\n className={styles.contextWindowTitleText}\n title={title}\n >\n {titleElement ? titleElement : title}\n </div>\n <div\n className={styles.contextWindowTitleClose}\n role=\"button\"\n aria-label=\"Close\"\n onClick={onClose}\n title={`Close ${title && title.trim() !== \"\" ? title : \"window\"}`}\n >\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"16\"\n height=\"16\"\n fill=\"currentColor\"\n viewBox=\"0 0 16 16\"\n >\n <path 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\" />\n </svg>\n </div>\n </div>\n <div className={styles.contextWindowBody}>\n <div>{children}</div>\n </div>\n </div>,\n document.body,\n )}\n </div>\n );\n};\n\nContextWindow.displayName = \"ContextWindow\";\n","import { RefObject } from \"react\";\n\n/**\n * Check that an existing div is inside the viewport\n * @param divRef Check div is inside view port, and return n\n * @returns \\{ translateX, translateY \\} Amount to move on X and Y axis\n */\nexport const chkPosition = (\n divRef: RefObject<HTMLDivElement>,\n): { translateX: number; translateY: number } => {\n if (!divRef.current) {\n return { translateX: 0, translateY: 0 };\n } else {\n const innerBounce = 16;\n const posn = divRef.current.getBoundingClientRect();\n let translateX = 0;\n if (posn.left < innerBounce) {\n translateX = -posn.left + innerBounce;\n } else if (posn.right > window.innerWidth) {\n translateX = Math.max(-posn.left + innerBounce, window.innerWidth - posn.right - innerBounce);\n }\n let translateY = 0;\n if (posn.top < innerBounce) {\n translateY = -posn.top + innerBounce;\n } else if (posn.bottom > window.innerHeight) {\n translateY = Math.max(\n -posn.top + innerBounce,\n window.innerHeight - posn.bottom - innerBounce,\n );\n }\n return { translateX, translateY };\n }\n};\n",".contextWindowAnchor {\n position: relative;\n}\n\n.contextWindow {\n z-index: 2001;\n border: 1px black solid;\n margin: 0;\n padding: 4px;\n background-color: rgb(250, 250, 250);\n box-shadow: 6px 6px 6px rgb(64, 64, 64, 0.5);\n transition: opacity 0.25s linear;\n justify-content: flex-start;\n position: absolute;\n border-top-left-radius: 8px;\n border-top-right-radius: 8px;\n border-bottom-left-radius: 8px;\n resize: both;\n overflow: auto;\n max-height: 95vh;\n max-width: 95vw;\n}\n\n.contextWindowTitle {\n border-bottom: 1px black dashed;\n box-sizing: unset;\n padding-bottom: 4px;\n margin: 0 4px 3px 4px;\n height: 24px;\n line-height: 24px;\n max-height: 24px;\n cursor: grab;\n font-size: 18px;\n font-weight: 600;\n display: flex;\n flex-direction: row;\n align-items: center;\n width: calc(100% - 8px);\n}\n\n.contextWindowTitle.moving {\n cursor: grabbing;\n}\n\n.contextWindowTitleText {\n display: inline-block;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n width: calc(100% - 16px);\n}\n\n.contextWindowTitleClose {\n display: flex;\n color: black;\n height: 16px;\n width: 16px;\n border-radius: 3px;\n margin-left: 2px;\n cursor: pointer;\n line-height: 16px;\n}\n\n.contextWindowTitleClose:hover {\n background-color: black;\n color: white;\n}\n\n.contextWindowBody {\n overflow: auto;\n padding-bottom: 8px;\n margin-right: 4px;\n height: calc(100% - 40px);\n}\n\n.contextWindowBody::-webkit-scrollbar {\n width: 8px;\n height: 8px;\n}\n\n.contextWindowBody::-webkit-scrollbar-track {\n background: white;\n border-radius: 8px;\n}\n\n.contextWindowBody::-webkit-scrollbar-thumb {\n background: lightgrey;\n border: none;\n border-radius: 8px;\n}\n\n.contextWindowBody::-webkit-scrollbar-thumb:hover {\n background: grey;\n}\n","import { createContext, useState } from \"react\";\n\nexport interface ContextWindowZIndex {\n windowId: number;\n zIndex: number;\n}\n\nexport interface ContextWindowStackContextProps {\n currentWindows: ContextWindowZIndex[];\n pushToTop: (ret: number) => void;\n}\n\nexport const ContextWindowStackContext = createContext<ContextWindowStackContextProps | null>(null);\n\ninterface ContextWindowStackProps {\n id?: string;\n minZIndex?: number;\n children?: JSX.Element[] | JSX.Element;\n}\n\nconst pushToTop = (\n windowId: number,\n minZIndex: number,\n windowList: ContextWindowZIndex[],\n setWindowList: (ret: ContextWindowZIndex[]) => void,\n) => {\n const otherWindows = windowList\n .filter((w) => w.windowId !== windowId)\n .map((w, i) => ({ windowId: w.windowId, zIndex: minZIndex + i }));\n setWindowList([...otherWindows, { windowId, zIndex: minZIndex + otherWindows.length }]);\n};\n\nexport const ContextWindowStack = ({\n minZIndex = 1000,\n children,\n}: ContextWindowStackProps): JSX.Element => {\n const [currentWindows, setCurrentWindows] = useState<ContextWindowZIndex[]>([]);\n\n return (\n <ContextWindowStackContext.Provider\n value={{\n currentWindows: currentWindows.map((w) => ({\n windowId: w.windowId,\n zIndex: minZIndex + w.zIndex,\n })),\n pushToTop: (ret: number) => pushToTop(ret, minZIndex, currentWindows, setCurrentWindows),\n }}\n >\n {children}\n </ContextWindowStackContext.Provider>\n );\n};\n\nContextWindowStack.displayName = \"ContextWindowStack\";\n"],"names":[],"version":3,"file":"main.js.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AIAA,IAAA;AACA,IAAA;AADA,4CAAoC,CAAC,4CAA4C,CAAC;AAClF,4CAAsC,CAAC,8CAA8C,CAAC;;;ADQ/E,SAAS,yCAAW;QAAA,YACzB,QAAQ,QACR,IAAI,YACJ,WAAW,KAEK,GALS,QAItB,gEAJsB;QACzB;QACA;QACA;;IAGA,MAAM,aAAa,CAAA,GAAA,mBAAK,EAAkB;IAC1C,MAAM,WAAW,CAAA,GAAA,mBAAK,EAAkB;IACxC,MAAM,CAAC,QAAQ,UAAU,GAAG,CAAA,GAAA,qBAAO,EAAiB;IACpD,MAAM,iBAAiB,CAAA,GAAA,oBAAM,EAC3B,IAAO,QAAQ,CAAC,yBAAW,gCAAC;YAAI,OAAO;gBAAE,QAAQ;YAAM;aAAQ,UAC/D;QAAC;QAAU;KAAK;IAGlB,MAAM,kBAAkB,CAAA,GAAA,wBAAU,EAAE;QAClC,MAAM,QAAQ,SAAS,OAAO;YAGK;QADnC,mEAAmE;QACnE,MAAM,iBAAiB,OAAO,IAAK,CAAA,sBAAA,kBAAA,4BAAA,MAAO,YAAY,cAAnB,iCAAA,sBAAuB;QAC1D,UAAU;IACZ,GAAG;QAAC;KAAK;IAET,mEAAmE;IACnE,CAAA,GAAA,sBAAQ,EAAE;QACR,MAAM,aAAa,SAAS,OAAO;QACnC,IAAI,YAAY;YACd,MAAM,WAAW,IAAI,eAAe;gBAClC;YACF;YAEA,SAAS,OAAO,CAAC;YAEjB,OAAO;gBACL,SAAS,UAAU;YACrB;QACF;IACF,GAAG;QAAC;KAAgB;IAEpB,2CAA2C;IAC3C,CAAA,GAAA,4BAAc,EAAE;QACd;IACF,GAAG;QAAC;QAAiB;KAAS;IAE9B,qBACE,gCAAC,2GACK;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CAAA,GAAA,gEAAK,EAAE,MAAM,GAAG;yBAAG,CAChE,MAAM,CAAC,CAAC,IAAM,MAAM,IACpB,IAAI,CAAC;wBACR,aAAa,CAAC;4BACZ,IAAI,EAAE,MAAM,IAAK,CAAA,EAAE,MAAM,YAAY,eAAe,EAAE,MAAM,YAAY,UAAS,GAC/E,EAAE,MAAM,CAAC,KAAK,CAAC,UAAU,GAAG;4BAC9B,UAAU;4BACV,IAAI,SAAS,OAAO,EAAE,YAAY,SAAS,CAAC,SAAS,OAAO;4BAC5D,SAAS,gBAAgB,CAAC,WAAW;4BACrC,SAAS,gBAAgB,CAAC,aAAa;4BACvC,OAAO,gBAAgB,CAAC,UAAU,IAAM;wBAC1C;;0CAEA,gCAAC;gCACC,WAAW,CAAA,GAAA,gEAAK,EAAE,sBAAsB;gCACxC,OAAO;0CAEN,eAAe,eAAe;;0CAEjC,gCAAC;gCACC,WAAW,CAAA,GAAA,gEAAK,EAAE,uBAAuB;gCACzC,MAAK;gCACL,cAAW;gCACX,SAAS;gCACT,OAAO,CAAC,MAAM,EAAE,SAAS,MAAM,IAAI,OAAO,KAAK,QAAQ,UAAU;0CAEjE,cAAA,gCAAC;oCACC,OAAM;oCACN,OAAM;oCACN,QAAO;oCACP,MAAK;oCACL,SAAQ;8CAER,cAAA,gCAAC;wCAAK,GAAE;;;;;;kCAId,gCAAC;wBAAI,WAAW,CAAA,GAAA,gEAAK,EAAE,iBAAiB;kCACtC,cAAA,gCAAC;sCAAK;;;;iBAGV,SAAS,IAAI;;;AAIvB;AAEA,0CAAc,WAAW,GAAG;","sources":["src/main.ts","global.d.ts","src/components/index.ts","src/components/AutoHeight.tsx","src/components/AutoHeight.module.css","src/components/ClickForMenu.tsx","src/components/ContextMenu.tsx","src/components/ContextMenu.module.css","src/components/ContextMenuEntry.tsx","src/components/ContextSubMenu.tsx","src/components/ContextMenuHandler.tsx","src/components/LowMenu.tsx","src/components/LowMenu.module.css","src/components/LowMenuButton.tsx","src/components/LowSubMenu.tsx","src/components/ContextWindow.tsx","src/functions/chkPosition.ts","src/components/ContextWindow.module.css","src/components/ContextWindowStack.tsx"],"sourcesContent":["import \"../global.d.ts\";\nexport * from \"./components\";\n","declare module \"*.module.css\" {\n const classes: { readonly [key: string]: string };\n export default classes;\n}\n","import { AutoHeight } from \"./AutoHeight\";\nimport { ClickForMenu } from \"./ClickForMenu\";\nimport { ContextMenu } from \"./ContextMenu\";\nimport { ContextMenuHandler } from \"./ContextMenuHandler\";\nimport { ContextWindow } from \"./ContextWindow\";\nimport { ContextWindowStack } from \"./ContextWindowStack\";\nimport { MenuItem } from \"./interface\";\n\nexport {\n AutoHeight,\n ClickForMenu,\n ContextMenu,\n ContextMenuHandler,\n ContextWindow,\n ContextWindowStack,\n};\nexport type { MenuItem as iMenuItem };\n","import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from \"react\";\nimport styles from \"./AutoHeight.module.css\";\n\ninterface AutoHeightProps extends React.HTMLAttributes<HTMLDivElement> {\n children: React.ReactNode;\n hide?: boolean;\n duration?: number; // transition duration in ms\n}\n\nexport function AutoHeight({\n children,\n hide,\n duration = 300,\n ...rest\n}: AutoHeightProps): JSX.Element {\n const wrapperRef = useRef<HTMLDivElement>(null);\n const innerRef = useRef<HTMLDivElement>(null);\n const [height, setHeight] = useState<number | null>(null);\n const targetChildren = useMemo<React.ReactNode>(\n () => (hide || !children ? <div style={{ height: \"1px\" }} /> : children),\n [children, hide],\n );\n\n const setTargetHeight = useCallback(() => {\n const inner = innerRef.current;\n\n // Initial draw to get the height of children and deployed children\n const deployedHeight = hide ? 1 : (inner?.offsetHeight ?? 0);\n setHeight(deployedHeight);\n }, [hide]);\n\n // Add ResizeObserver to update height on content resize, debounced\n useEffect(() => {\n const transition = innerRef.current;\n if (transition) {\n const observer = new ResizeObserver(() => {\n setTargetHeight();\n });\n\n observer.observe(transition);\n\n return () => {\n observer.disconnect();\n };\n }\n }, [setTargetHeight]);\n\n // Trigger height change on children update\n useLayoutEffect(() => {\n setTargetHeight();\n }, [setTargetHeight, children]);\n\n return (\n <div\n {...rest}\n className={styles.autoHeightWrapper}\n ref={wrapperRef}\n style={{\n ...rest.style,\n height: height ? `${height}px` : \"auto\",\n transitionDuration: `${duration}ms`,\n }}\n >\n <div\n className={styles.autoHeightInner}\n ref={innerRef}\n >\n {targetChildren}\n </div>\n </div>\n );\n}\n\nAutoHeight.displayName = \"AutoHeight\";\n",".autoHeightWrapper {\n overflow: hidden;\n transition-timing-function: height ease-in-out width ease-in-out background-color ease-in-out;\n box-sizing: border-box;\n position: relative;\n}\n\n.autoHeightInner {\n height: fit-content;\n}\n","import React, { useCallback, useEffect, useRef, useState } from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { ContextMenu } from \"./ContextMenu\";\nimport styles from \"./ContextMenu.module.css\";\nimport { MenuItem } from \"./interface\";\n\ninterface ClickForMenuProps extends React.HTMLAttributes<HTMLDivElement> {\n id: string;\n menuItems?: MenuItem[];\n chidren?: React.ReactNode;\n}\n\nexport const ClickForMenu = ({\n id,\n menuItems,\n children,\n ...rest\n}: ClickForMenuProps): JSX.Element => {\n // Menu state\n const [menuInDom, setMenuInDom] = useState<boolean>(false);\n const [menuVisible, setMenuVisible] = useState<boolean>(false);\n const [menuXPos, setMenuXPos] = useState<number>(0);\n const [menuYPos, setMenuYPos] = useState<number>(0);\n\n // Set up outsideClick handler\n const menuRef = useRef<HTMLDivElement | null>(null);\n\n // Handle click off the menu\n const handleClick = useCallback((e: MouseEvent) => {\n if (\n menuRef.current &&\n ((e.target instanceof Element && !menuRef.current?.contains(e.target)) ||\n !(e.target instanceof Element))\n ) {\n setMenuInDom(false);\n }\n }, []);\n\n const removeController = useRef<AbortController>(new AbortController());\n useEffect(() => {\n if (!menuVisible) {\n removeController.current.abort();\n removeController.current = new AbortController();\n setTimeout(() => {\n if (!removeController.current.signal.aborted) setMenuInDom(false);\n }, 300);\n }\n }, [menuVisible]);\n\n // Update the document click handler\n useEffect(() => {\n if (menuInDom) document.addEventListener(\"mousedown\", handleClick);\n return () => {\n document.removeEventListener(\"mousedown\", handleClick);\n removeController.current.abort();\n };\n }, [handleClick, menuInDom]);\n\n return (\n <>\n <div\n {...rest}\n id={id}\n onClick={(e) => {\n if (menuItems) {\n setMenuInDom(true);\n e.preventDefault();\n e.stopPropagation();\n setTimeout(() => {\n removeController.current.abort();\n setMenuVisible(true);\n setMenuXPos(e.pageX);\n setMenuYPos(e.pageY);\n }, 1);\n } else {\n rest.onClick?.(e);\n }\n }}\n >\n {children}\n </div>\n {menuInDom &&\n menuItems &&\n createPortal(\n <div className={styles.anchor}>\n <ContextMenu\n visible={menuVisible}\n ref={menuRef}\n entries={menuItems}\n xPos={menuXPos}\n yPos={menuYPos}\n toClose={() => {\n setMenuVisible(false);\n }}\n />\n </div>,\n document.body,\n )}\n </>\n );\n};\n\nClickForMenu.displayName = \"ClickForMenu\";\n","import { forwardRef } from \"react\";\nimport styles from \"./ContextMenu.module.css\";\nimport { ContextMenuEntry } from \"./ContextMenuEntry\";\nimport { MenuItem } from \"./interface\";\n\nexport interface ContextMenuProps {\n visible: boolean;\n entries: MenuItem[];\n xPos: number;\n yPos: number;\n toClose: () => void;\n}\n\nexport const ContextMenu = forwardRef<HTMLDivElement, ContextMenuProps>(\n ({ visible, entries, xPos, yPos, toClose }, ref): JSX.Element => {\n return (\n <div\n ref={ref}\n className={[styles.contextMenu, visible ? styles.visible : styles.hidden]\n .filter((c) => c !== \"\")\n .join(\" \")}\n style={{\n top: `${yPos}px`,\n left: `${xPos}px`,\n }}\n onContextMenu={(e) => {\n e.preventDefault();\n e.stopPropagation();\n }}\n >\n {entries.map((entry, i) => (\n <ContextMenuEntry\n key={i}\n entry={entry}\n toClose={toClose}\n />\n ))}\n </div>\n );\n },\n);\n\nContextMenu.displayName = \"ContextMenu\";\n",".anchor {\n position: absolute;\n top: 0;\n left: 0;\n font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", \"Roboto\", \"Oxygen\", \"Ubuntu\",\n \"Cantarell\", \"Fira Sans\", \"Droid Sans\", \"Helvetica Neue\", sans-serif;\n font-size: 9pt;\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n}\n\n.contextMenuHandler {\n height: fit-content;\n width: fit-content;\n}\n\n.contextMenu {\n position: absolute;\n border: 1px solid;\n border-color: rgb(17, 20, 24);\n opacity: 1;\n background-color: rgb(251, 253, 246);\n z-index: 10000;\n box-shadow: 4px 4px 4px rgb(64, 64, 64, 0.75);\n transition: opacity 0.3s linear;\n}\n\n.contextMenu.hidden {\n opacity: 0;\n}\n\n.contextMenu.visible {\n opacity: 1;\n}\n\n.contextMenuItem {\n color: rgb(17, 20, 24);\n cursor: pointer;\n padding: 0 4px;\n min-width: 80px;\n position: relative;\n display: flex;\n flex-direction: row;\n justify-content: space-between;\n white-space: nowrap;\n}\n\n.contextMenuItem.disabled {\n background-color: rgba(0, 0, 0, 0.2);\n cursor: not-allowed;\n}\n\n.contextMenuItem:first-child {\n padding-top: 4px;\n}\n\n.contextMenuItem:last-child {\n padding-bottom: 4px;\n}\n\n.contextMenuItem:not(.disabled):hover {\n background-color: rgb(251, 233, 230);\n}\n\n.contextMenuItem .caretHolder {\n align-self: flex-end;\n}\n\n.contextMenuItem .caretHolder .subMenu {\n z-index: 1;\n position: relative;\n}\n\n.contextMenuItemLabel {\n flex-grow: 1;\n height: 19px;\n}\n","import { useState } from \"react\";\nimport styles from \"./ContextMenu.module.css\";\nimport { ContextSubMenu } from \"./ContextSubMenu\";\nimport { MenuItem } from \"./interface\";\n\ninterface ContextMenuEntryProps {\n entry: MenuItem;\n toClose: () => void;\n}\n\nexport const ContextMenuEntry = ({ entry, toClose }: ContextMenuEntryProps) => {\n const [target, setTarget] = useState<Range | null>(null);\n const [subMenuVisible, setSubMenuVisible] = useState<boolean>(false);\n return (\n <div\n className={[styles.contextMenuItem, entry.disabled ? styles.disabled : \"\"]\n .filter((c) => c !== \"\")\n .join(\" \")}\n onMouseEnter={() => {\n setSubMenuVisible(true);\n }}\n onMouseLeave={() => {\n setSubMenuVisible(false);\n }}\n >\n {typeof entry.label === \"string\" ? (\n <span\n aria-label={typeof entry.label === \"string\" ? entry.label : undefined}\n aria-disabled={entry.disabled}\n className={styles.contextMenuItemLabel}\n onMouseEnter={() => {\n const sel = window.getSelection();\n const target = sel && sel.rangeCount > 0 ? sel.getRangeAt(0) : null;\n setTarget(target);\n }}\n onMouseLeave={() => {\n setTarget(null);\n }}\n onMouseDownCapture={(e) => {\n e.preventDefault();\n e.stopPropagation();\n if (!entry.disabled) {\n if (entry.action) {\n entry.action(target, e);\n }\n toClose();\n }\n }}\n >\n {entry.label}\n </span>\n ) : (\n entry.label\n )}\n {entry.group && (\n <ContextSubMenu\n toClose={toClose}\n entries={entry.group}\n visible={subMenuVisible}\n />\n )}\n </div>\n );\n};\n","import { ContextMenu } from \"./ContextMenu\";\nimport styles from \"./ContextMenu.module.css\";\nimport { MenuItem } from \"./interface\";\n\nexport interface ContextSubMenuProps {\n entries: MenuItem[];\n toClose: () => void;\n lowMenu?: boolean;\n visible: boolean;\n}\n\nexport const ContextSubMenu = ({ entries, toClose, visible }: ContextSubMenuProps): JSX.Element => {\n return (\n <span className={styles.caretHolder}>\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"16\"\n height=\"16\"\n fill=\"currentColor\"\n viewBox=\"0 0 16 16\"\n >\n <path 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\" />\n </svg>\n <div className={styles.subMenu}>\n <ContextMenu\n visible={visible}\n entries={entries}\n xPos={14}\n yPos={-21}\n toClose={toClose}\n />\n </div>\n </span>\n );\n};\n\nContextSubMenu.displayName = \"ContextSubMenu\";\n","import {\n createContext,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { ContextMenu } from \"./ContextMenu\";\nimport styles from \"./ContextMenu.module.css\";\nimport { LowMenu } from \"./LowMenu\";\nimport { MenuItem } from \"./interface\";\n\nexport interface ContentMenuHandlerContextProps {\n menuItems: MenuItem[];\n}\nexport const ContentMenuHandlerContext = createContext<ContentMenuHandlerContextProps | null>(null);\n\nexport interface ContextMenuHandlerProps extends React.HTMLAttributes<HTMLDivElement> {\n children: React.ReactNode;\n menuItems: MenuItem[];\n showLowMenu?: boolean;\n}\n\nfunction isDivider(label: string | JSX.Element): boolean {\n return typeof label !== \"string\" && label.type === \"hr\";\n}\n\nexport const ContextMenuHandler = ({\n children,\n menuItems,\n showLowMenu = false,\n ...rest\n}: ContextMenuHandlerProps): JSX.Element => {\n // Check for higher content menu\n const higherContext = useContext(ContentMenuHandlerContext);\n const thisMenuItems = useMemo(\n () => [\n ...(higherContext !== null\n ? [\n ...higherContext.menuItems,\n ...[\n higherContext.menuItems.length > 0 &&\n !isDivider(higherContext.menuItems[higherContext.menuItems.length - 1].label) &&\n menuItems.length > 0 &&\n !isDivider(menuItems[0].label)\n ? {\n label: (\n <hr style={{ flexGrow: 1, cursor: \"none\", margin: \"0\", padding: \"0\" }} />\n ),\n }\n : null,\n ].filter((item) => item !== null),\n ]\n : []),\n ...menuItems,\n ],\n [higherContext, menuItems],\n );\n\n // Menu resources\n const divHandlderRef = useRef<HTMLDivElement | null>(null);\n const menuRef = useRef<HTMLDivElement | null>(null);\n const [menuXPos, setMenuXPos] = useState<number>(0);\n const [menuYPos, setMenuYPos] = useState<number>(0);\n const [menuVisible, setMenuVisible] = useState<boolean>(false);\n const [menuInDom, setMenuInDom] = useState<boolean>(false);\n const [mouseOverHandlerDiv, setMouseOverHandlerDiv] = useState<boolean>(false);\n const [mouseOverMenu, setMouseOverMenu] = useState<boolean>(false);\n\n // Get holder position\n const divHandlerPos = divHandlderRef ? divHandlderRef.current?.getBoundingClientRect() : null;\n\n // Handle click off the menu\n const handleClick = useCallback((e: globalThis.MouseEvent) => {\n if (\n menuRef.current &&\n ((e.target instanceof Element && !menuRef.current?.contains(e.target)) ||\n !(e.target instanceof Element))\n ) {\n setMenuVisible(false);\n }\n }, []);\n\n // Update the document click handler\n useEffect(() => {\n if (menuVisible) document.addEventListener(\"mousedown\", handleClick);\n return () => {\n document.removeEventListener(\"mousedown\", handleClick);\n };\n }, [handleClick, menuVisible]);\n\n const removeController = useRef<AbortController>(new AbortController());\n useEffect(() => {\n if (!mouseOverMenu && !menuVisible && !mouseOverHandlerDiv) {\n removeController.current.abort();\n removeController.current = new AbortController();\n setTimeout(() => {\n if (!removeController.current.signal.aborted) setMenuInDom(false);\n }, 300);\n }\n }, [mouseOverHandlerDiv, menuVisible, mouseOverMenu]);\n\n return (\n <ContentMenuHandlerContext.Provider\n value={{\n menuItems: thisMenuItems,\n }}\n >\n <div\n ref={divHandlderRef}\n {...rest}\n className={[styles.contextMenuHandler, rest.className].join(\" \")}\n onContextMenu={async (e) => {\n if (!showLowMenu) {\n setMenuInDom(true);\n e.preventDefault();\n e.stopPropagation();\n setTimeout(() => {\n removeController.current.abort();\n setMenuVisible(true);\n setMenuXPos(e.pageX);\n setMenuYPos(e.pageY);\n }, 1);\n }\n }}\n onMouseEnter={async (e) => {\n if (showLowMenu) {\n setMenuInDom(true);\n setMouseOverHandlerDiv(false);\n setTimeout(() => {\n removeController.current.abort();\n setMouseOverHandlerDiv(true);\n }, 1);\n }\n rest.onMouseEnter?.(e);\n }}\n onMouseLeave={async (e) => {\n if (showLowMenu) {\n removeController.current.abort();\n removeController.current = new AbortController();\n setMouseOverHandlerDiv(false);\n }\n rest.onMouseLeave?.(e);\n }}\n >\n {children}\n </div>\n {menuInDom &&\n divHandlerPos &&\n createPortal(\n <div\n className={styles.anchor}\n onMouseEnter={() => {\n removeController.current.abort();\n setMouseOverMenu(true);\n }}\n onMouseLeave={() => {\n removeController.current.abort();\n removeController.current = new AbortController();\n setMouseOverMenu(false);\n }}\n >\n {showLowMenu ? (\n <LowMenu\n visible={mouseOverHandlerDiv}\n entries={menuItems}\n xPos={divHandlerPos.left}\n yPos={divHandlerPos.bottom}\n maxWidth={divHandlerPos.width}\n />\n ) : (\n <ContextMenu\n visible={menuVisible}\n ref={menuRef}\n entries={thisMenuItems}\n xPos={menuXPos}\n yPos={menuYPos}\n toClose={() => {\n setMenuVisible(false);\n setMouseOverMenu(false);\n }}\n />\n )}\n </div>,\n document.body,\n )}\n </ContentMenuHandlerContext.Provider>\n );\n};\n\nContextMenuHandler.displayName = \"ContextMenuHandler\";\n","import styles from \"./LowMenu.module.css\";\nimport { LowMenuButton } from \"./LowMenuButton\";\nimport { MenuItem } from \"./interface\";\n\ninterface LowMenuProps {\n entries: MenuItem[];\n visible: boolean;\n xPos: number;\n yPos: number;\n maxWidth: number;\n}\n\nexport const LowMenu = ({ entries, visible, xPos, yPos, maxWidth }: LowMenuProps): JSX.Element => {\n return (\n <div\n className={[styles.lowMenu, visible ? styles.visible : styles.hidden].join(\" \")}\n aria-label=\"Low context menu\"\n style={{\n left: `${xPos}px`,\n top: `${yPos}px`,\n maxWidth: `calc(${maxWidth}px)`,\n width: `calc(${maxWidth}px - 4px)`,\n }}\n >\n <div className={styles.lowMenuButtonHolder}>\n {entries.map((e, i) => (\n <LowMenuButton\n key={i}\n entry={e}\n />\n ))}\n </div>\n </div>\n );\n};\n\nLowMenu.displayName = \"LowMenu\";\n",".lowMenu {\n z-index: 2;\n position: absolute;\n margin: 0px;\n transition: opacity 0.3s linear;\n}\n\n.lowMenuButtonHolder {\n border: 2px solid rgb(17, 20, 24);\n border-top-right-radius: 4px;\n border-bottom-left-radius: 4px;\n border-bottom-right-radius: 4px;\n background-color: rgb(17, 20, 24);\n box-shadow: 2px 2px 2px rgb(64, 64, 64, 0.5);\n display: flex;\n flex-wrap: wrap;\n flex-direction: row;\n gap: 2px;\n row-gap: 2px;\n width: fit-content;\n}\n\n.lowMenu.hidden {\n opacity: 0;\n}\n\n.lowMenu.visible,\n.lowMenu:hover {\n opacity: 1;\n}\n\n.lowMenuItem {\n background-color: rgb(251, 253, 246);\n border: 0;\n color: rgb(17, 20, 24);\n cursor: pointer;\n padding: 0 4px;\n position: relative;\n display: flex;\n flex-direction: row;\n justify-content: space-between;\n white-space: nowrap;\n}\n\n.lowMenuItem.disabled {\n background-color: rgba(200, 200, 200);\n cursor: not-allowed;\n}\n\n.lowMenuItem:not(.disabled):hover {\n background-color: rgb(251, 233, 230);\n}\n\n.lowMenu-item .caretHolder {\n align-self: flex-end;\n}\n\n.lowMenuItem .caretHolder .subMenu {\n z-index: 1;\n position: relative;\n}\n","import { useState } from \"react\";\nimport styles from \"./LowMenu.module.css\";\nimport { LowSubMenu } from \"./LowSubMenu\";\nimport { MenuItem } from \"./interface\";\n\ninterface LowMenuButtonProps {\n entry: MenuItem;\n}\nexport const LowMenuButton = ({ entry }: LowMenuButtonProps) => {\n const [target, setTarget] = useState<Range | null>(null);\n return (\n <div\n className={[styles.lowMenuItem, entry.disabled ? styles.disabled : \"\"]\n .filter((c) => c !== \"\")\n .join(\" \")}\n aria-label={typeof entry.label === \"string\" ? entry.label : undefined}\n aria-disabled={entry.disabled}\n onMouseEnter={() => {\n const sel = window.getSelection();\n const target = sel && sel.rangeCount > 0 ? sel.getRangeAt(0) : null;\n setTarget(target);\n }}\n onMouseLeave={() => {\n setTarget(null);\n }}\n onClick={(e) => {\n e.preventDefault();\n e.stopPropagation();\n if (!entry.disabled) entry.action?.(target);\n }}\n >\n <span>{entry.label}</span>\n {entry.group && <LowSubMenu entry={entry} />}\n </div>\n );\n};\n\nLowMenuButton.displayName = \"LowMenuButton\";\n","import { useState } from \"react\";\nimport { ContextMenu } from \"./ContextMenu\";\nimport styles from \"./LowMenu.module.css\";\nimport { MenuItem } from \"./interface\";\n\nexport interface LowSubMenuProps {\n entry: MenuItem;\n lowMenu?: boolean;\n}\n\nexport const LowSubMenu = ({ entry }: LowSubMenuProps): JSX.Element => {\n const [visible, setVisible] = useState<boolean>(false);\n if (!entry.group || entry.group.length === 0) return <></>;\n return (\n <span\n aria-label={`Sub menu for ${entry.label}`}\n className={styles.caretHolder}\n onMouseEnter={() => {\n setVisible(true);\n }}\n onMouseLeave={() => {\n setVisible(false);\n }}\n >\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"16\"\n height=\"16\"\n fill=\"currentColor\"\n viewBox=\"0 0 16 16\"\n >\n <path 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\" />\n </svg>\n <div className={styles.subMenu}>\n {visible && (\n <ContextMenu\n visible={visible}\n entries={entry.group}\n xPos={14}\n yPos={entry.group.length * -21 - 8}\n toClose={() => setVisible(false)}\n />\n )}\n </div>\n </span>\n );\n};\n\nLowSubMenu.displayName = \"LowSubMenu\";\n","import { ReactNode, useCallback, useContext, useEffect, useMemo, useRef, useState } from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { chkPosition } from \"../functions/chkPosition\";\nimport styles from \"./ContextWindow.module.css\";\nimport { ContextWindowStackContext } from \"./ContextWindowStack\";\n\ninterface ContextWindowProps extends React.HTMLAttributes<HTMLDivElement> {\n id: string;\n visible: boolean;\n onOpen?: () => void;\n onClose?: () => void;\n title: string;\n titleElement?: ReactNode;\n style?: React.CSSProperties;\n children: React.ReactNode;\n}\n\nexport const ContextWindow = ({\n id,\n visible,\n title,\n titleElement,\n children,\n onOpen,\n onClose,\n ...rest\n}: ContextWindowProps): JSX.Element => {\n const windowStack = useContext(ContextWindowStackContext);\n const windowId = useRef<number | null>(null);\n const divRef = useRef<HTMLDivElement | null>(null);\n const windowRef = useRef<HTMLDivElement | null>(null);\n const [windowInDOM, setWindowInDOM] = useState<boolean>(false);\n const [windowVisible, setWindowVisible] = useState<boolean>(false);\n const zIndex = useMemo(() => {\n return windowStack?.currentWindows.find((w) => w.windowId === windowId.current)?.zIndex ?? 1;\n }, [windowStack?.currentWindows]);\n\n // Position\n const windowPos = useRef<{ x: number; y: number }>({ x: 0, y: 0 });\n const [moving, setMoving] = useState<boolean>(false);\n\n const move = useCallback((x: number, y: number) => {\n if (windowRef.current && windowPos.current) {\n const window = windowRef.current;\n const pos = windowPos.current;\n pos.x += x;\n pos.y += y;\n window.style.transform = `translate(${pos.x}px, ${pos.y}px)`;\n }\n }, []);\n\n const checkPosition = useCallback(() => {\n const chkPos = chkPosition(windowRef);\n move(chkPos.translateX, chkPos.translateY);\n }, [move]);\n\n const mouseMove = useCallback(\n (e: MouseEvent) => {\n e.preventDefault();\n e.stopPropagation();\n move(e.movementX, e.movementY);\n },\n [move],\n );\n\n const mouseUp = useCallback(\n (e: MouseEvent) => {\n e.preventDefault();\n e.stopPropagation();\n setMoving(false);\n checkPosition();\n document.removeEventListener(\"mousemove\", mouseMove);\n document.removeEventListener(\"mouseup\", mouseUp);\n window.removeEventListener(\"resize\", checkPosition);\n if (e.target && (e.target instanceof HTMLElement || e.target instanceof SVGElement))\n e.target.style.userSelect = \"auto\";\n },\n [checkPosition, mouseMove],\n );\n\n // Update visibility\n useEffect(() => {\n if (windowStack) {\n // Visible set, but not in DOM\n if (visible && !windowInDOM) {\n setWindowInDOM(true);\n } else if (visible && windowInDOM && !windowVisible) {\n if (!windowId.current) {\n const maxWindowId = Math.max(0, ...windowStack.currentWindows.map((w) => w.windowId));\n windowId.current = maxWindowId + 1;\n }\n windowStack.pushToTop(windowId.current);\n setWindowVisible(visible);\n onOpen?.();\n // Get starting position\n if (divRef.current && windowRef.current) {\n const parentPos = divRef.current.getBoundingClientRect();\n const pos = windowRef.current.getBoundingClientRect();\n const windowHeight = pos.bottom - pos.top;\n windowRef.current.style.left = `${parentPos.left}px`;\n windowRef.current.style.top = `${\n parentPos.bottom + windowHeight < window.innerHeight\n ? parentPos.bottom\n : Math.max(0, parentPos.top - windowHeight)\n }px`;\n windowRef.current.style.transform = \"\";\n windowPos.current = { x: 0, y: 0 };\n }\n checkPosition();\n } else if (windowId.current && !visible && windowVisible) {\n setWindowVisible(false);\n } else if (windowId.current && !visible && windowInDOM) {\n setWindowInDOM(false);\n }\n }\n }, [checkPosition, onOpen, visible, windowInDOM, windowStack, windowVisible]);\n\n return (\n <div\n className={styles.contextWindowAnchor}\n ref={divRef}\n >\n {!windowStack && (\n <div {...rest}>\n {process.env.NODE_ENV !== \"production\" && (\n <div\n style={{ backgroundColor: \"red\", color: \"white\", padding: \"8px\", fontSize: \"48px\" }}\n >\n WARNING: No ContextWindowStack found\n </div>\n )}\n {children}\n </div>\n )}\n {windowStack &&\n windowInDOM &&\n createPortal(\n <div\n {...rest}\n ref={windowRef}\n id={id}\n className={[styles.contextWindow, rest.className].filter((c) => c).join(\" \")}\n style={{\n ...rest.style,\n opacity: moving ? 0.8 : windowVisible ? 1 : 0,\n visibility: windowVisible ? \"visible\" : \"hidden\",\n zIndex: zIndex ?? 1,\n minHeight: rest.style?.minHeight ?? \"150px\",\n minWidth: rest.style?.minWidth ?? \"200px\",\n maxHeight: rest.style?.maxHeight ?? \"1000px\",\n maxWidth: rest.style?.maxWidth ?? \"1000px\",\n }}\n onClickCapture={(e) => {\n if (windowId.current) windowStack.pushToTop(windowId.current);\n rest.onClickCapture?.(e);\n }}\n >\n <div\n className={[styles.contextWindowTitle, moving ? styles.moving : \"\"]\n .filter((c) => c !== \"\")\n .join(\" \")}\n onMouseDown={(e: React.MouseEvent) => {\n if (e.target && (e.target instanceof HTMLElement || e.target instanceof SVGElement))\n e.target.style.userSelect = \"none\";\n setMoving(true);\n if (windowId.current) windowStack.pushToTop(windowId.current);\n document.addEventListener(\"mouseup\", mouseUp);\n document.addEventListener(\"mousemove\", mouseMove);\n window.addEventListener(\"resize\", () => checkPosition());\n }}\n >\n <div\n className={styles.contextWindowTitleText}\n title={title}\n >\n {titleElement ? titleElement : title}\n </div>\n <div\n className={styles.contextWindowTitleClose}\n role=\"button\"\n aria-label=\"Close\"\n onClick={onClose}\n title={`Close ${title && title.trim() !== \"\" ? title : \"window\"}`}\n >\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"16\"\n height=\"16\"\n fill=\"currentColor\"\n viewBox=\"0 0 16 16\"\n >\n <path 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\" />\n </svg>\n </div>\n </div>\n <div className={styles.contextWindowBody}>\n <div>{children}</div>\n </div>\n </div>,\n document.body,\n )}\n </div>\n );\n};\n\nContextWindow.displayName = \"ContextWindow\";\n","import { RefObject } from \"react\";\n\n/**\n * Check that an existing div is inside the viewport\n * @param divRef Check div is inside view port, and return n\n * @returns \\{ translateX, translateY \\} Amount to move on X and Y axis\n */\nexport const chkPosition = (\n divRef: RefObject<HTMLDivElement>,\n): { translateX: number; translateY: number } => {\n if (!divRef.current) {\n return { translateX: 0, translateY: 0 };\n } else {\n const innerBounce = 16;\n const posn = divRef.current.getBoundingClientRect();\n let translateX = 0;\n if (posn.left < innerBounce) {\n translateX = -posn.left + innerBounce;\n } else if (posn.right > window.innerWidth) {\n translateX = Math.max(-posn.left + innerBounce, window.innerWidth - posn.right - innerBounce);\n }\n let translateY = 0;\n if (posn.top < innerBounce) {\n translateY = -posn.top + innerBounce;\n } else if (posn.bottom > window.innerHeight) {\n translateY = Math.max(\n -posn.top + innerBounce,\n window.innerHeight - posn.bottom - innerBounce,\n );\n }\n return { translateX, translateY };\n }\n};\n",".contextWindowAnchor {\n position: relative;\n}\n\n.contextWindow {\n z-index: 2001;\n border: 1px black solid;\n margin: 0;\n padding: 4px;\n background-color: rgb(250, 250, 250);\n box-shadow: 6px 6px 6px rgb(64, 64, 64, 0.5);\n transition: opacity 0.25s linear;\n justify-content: flex-start;\n position: absolute;\n border-top-left-radius: 8px;\n border-top-right-radius: 8px;\n border-bottom-left-radius: 8px;\n resize: both;\n overflow: auto;\n max-height: 95vh;\n max-width: 95vw;\n}\n\n.contextWindowTitle {\n border-bottom: 1px black dashed;\n box-sizing: unset;\n padding-bottom: 4px;\n margin: 0 4px 3px 4px;\n height: 24px;\n line-height: 24px;\n max-height: 24px;\n cursor: grab;\n font-size: 18px;\n font-weight: 600;\n display: flex;\n flex-direction: row;\n align-items: center;\n width: calc(100% - 8px);\n}\n\n.contextWindowTitle.moving {\n cursor: grabbing;\n}\n\n.contextWindowTitleText {\n display: inline-block;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n width: calc(100% - 16px);\n}\n\n.contextWindowTitleClose {\n display: flex;\n color: black;\n height: 16px;\n width: 16px;\n border-radius: 3px;\n margin-left: 2px;\n cursor: pointer;\n line-height: 16px;\n}\n\n.contextWindowTitleClose:hover {\n background-color: black;\n color: white;\n}\n\n.contextWindowBody {\n overflow: auto;\n padding-bottom: 8px;\n margin-right: 4px;\n height: calc(100% - 40px);\n}\n\n.contextWindowBody::-webkit-scrollbar {\n width: 8px;\n height: 8px;\n}\n\n.contextWindowBody::-webkit-scrollbar-track {\n background: white;\n border-radius: 8px;\n}\n\n.contextWindowBody::-webkit-scrollbar-thumb {\n background: lightgrey;\n border: none;\n border-radius: 8px;\n}\n\n.contextWindowBody::-webkit-scrollbar-thumb:hover {\n background: grey;\n}\n","import { createContext, useState } from \"react\";\n\nexport interface ContextWindowZIndex {\n windowId: number;\n zIndex: number;\n}\n\nexport interface ContextWindowStackContextProps {\n currentWindows: ContextWindowZIndex[];\n pushToTop: (ret: number) => void;\n}\n\nexport const ContextWindowStackContext = createContext<ContextWindowStackContextProps | null>(null);\n\ninterface ContextWindowStackProps {\n id?: string;\n minZIndex?: number;\n children?: JSX.Element[] | JSX.Element;\n}\n\nconst pushToTop = (\n windowId: number,\n minZIndex: number,\n windowList: ContextWindowZIndex[],\n setWindowList: (ret: ContextWindowZIndex[]) => void,\n) => {\n const otherWindows = windowList\n .filter((w) => w.windowId !== windowId)\n .map((w, i) => ({ windowId: w.windowId, zIndex: minZIndex + i }));\n setWindowList([...otherWindows, { windowId, zIndex: minZIndex + otherWindows.length }]);\n};\n\nexport const ContextWindowStack = ({\n minZIndex = 1000,\n children,\n}: ContextWindowStackProps): JSX.Element => {\n const [currentWindows, setCurrentWindows] = useState<ContextWindowZIndex[]>([]);\n\n return (\n <ContextWindowStackContext.Provider\n value={{\n currentWindows: currentWindows.map((w) => ({\n windowId: w.windowId,\n zIndex: minZIndex + w.zIndex,\n })),\n pushToTop: (ret: number) => pushToTop(ret, minZIndex, currentWindows, setCurrentWindows),\n }}\n >\n {children}\n </ContextWindowStackContext.Provider>\n );\n};\n\nContextWindowStack.displayName = \"ContextWindowStack\";\n"],"names":[],"version":3,"file":"main.js.map"}
|
package/dist/context-menu.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ReactNode } from "react";
|
|
1
|
+
import React, { RefAttributes, ForwardRefExoticComponent, ReactNode } from "react";
|
|
2
2
|
interface AutoHeightProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
3
3
|
children: React.ReactNode;
|
|
4
4
|
hide?: boolean;
|
|
@@ -14,6 +14,23 @@ interface MenuItem {
|
|
|
14
14
|
action?: (target?: Range | null, reactEvent?: React.MouseEvent) => Promise<void> | void;
|
|
15
15
|
group?: MenuItem[];
|
|
16
16
|
}
|
|
17
|
+
interface ContextMenuProps {
|
|
18
|
+
visible: boolean;
|
|
19
|
+
entries: MenuItem[];
|
|
20
|
+
xPos: number;
|
|
21
|
+
yPos: number;
|
|
22
|
+
toClose: () => void;
|
|
23
|
+
}
|
|
24
|
+
export const ContextMenu: ForwardRefExoticComponent<ContextMenuProps & RefAttributes<HTMLDivElement>>;
|
|
25
|
+
interface ClickForMenuProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
26
|
+
id: string;
|
|
27
|
+
menuItems?: MenuItem[];
|
|
28
|
+
chidren?: React.ReactNode;
|
|
29
|
+
}
|
|
30
|
+
export const ClickForMenu: {
|
|
31
|
+
({ id, menuItems, children, ...rest }: ClickForMenuProps): JSX.Element;
|
|
32
|
+
displayName: string;
|
|
33
|
+
};
|
|
17
34
|
interface ContextMenuHandlerProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
18
35
|
children: React.ReactNode;
|
|
19
36
|
menuItems: MenuItem[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";AAGA,yBAA0B,SAAQ,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC;IACpE,QAAQ,EAAE,MAAM,SAAS,CAAC;IAC1B,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,2BAA2B,EACzB,QAAQ,EACR,IAAI,EACJ,QAAc,EACd,GAAG,IAAI,EACR,EAAE,eAAe,GAAG,IAAI,OAAO,CAyD/B;AA9DD,MAAM,mBAAU,UAAU;;;ACT1B;IACE,KAAK,EAAE,MAAM,GAAG,IAAI,OAAO,CAAC;IAC5B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,EAAE,KAAK,GAAG,IAAI,EAAE,UAAU,CAAC,EAAE,MAAM,UAAU,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IACxF,KAAK,CAAC,EAAE,QAAQ,EAAE,CAAC;CACpB;
|
|
1
|
+
{"mappings":";AAGA,yBAA0B,SAAQ,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC;IACpE,QAAQ,EAAE,MAAM,SAAS,CAAC;IAC1B,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,2BAA2B,EACzB,QAAQ,EACR,IAAI,EACJ,QAAc,EACd,GAAG,IAAI,EACR,EAAE,eAAe,GAAG,IAAI,OAAO,CAyD/B;AA9DD,MAAM,mBAAU,UAAU;;;ACT1B;IACE,KAAK,EAAE,MAAM,GAAG,IAAI,OAAO,CAAC;IAC5B,QAAQ,CAAC,EAAE,OAAO,CAAC;I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jB,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,SAAS,CAAC;IACzB,KAAK,CAAC,EAAE,MAAM,aAAa,CAAC;IAC5B,QAAQ,EAAE,MAAM,SAAS,CAAC;CAC3B;AAED,OAAO,MAAM;+EASV,kBAAkB,GAAG,IAAI,OAAO;;CAiLlC,CAAC","sources":["src/src/components/AutoHeight.tsx","src/src/components/interface.ts","src/src/components/ContextSubMenu.tsx","src/src/components/ContextMenuEntry.tsx","src/src/components/ContextMenu.tsx","src/src/components/ClickForMenu.tsx","src/src/components/LowSubMenu.tsx","src/src/components/LowMenuButton.tsx","src/src/components/LowMenu.tsx","src/src/components/ContextMenuHandler.tsx","src/src/functions/chkPosition.ts","src/src/components/ContextWindowStack.tsx","src/src/components/ContextWindow.tsx","src/src/components/index.ts","src/src/main.ts","src/main.ts"],"sourcesContent":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,"import \"../global.d.ts\";\nexport * from \"./components\";\n"],"names":[],"version":3,"file":"context-menu.d.ts.map"}
|
package/dist/main.js
CHANGED
|
@@ -3,7 +3,7 @@ import {_ as $duWW8$_} from "@swc/helpers/_/_object_spread";
|
|
|
3
3
|
import {_ as $duWW8$_1} from "@swc/helpers/_/_object_spread_props";
|
|
4
4
|
import {_ as $duWW8$_2} from "@swc/helpers/_/_object_without_properties";
|
|
5
5
|
import {jsx as $duWW8$jsx, jsxs as $duWW8$jsxs, Fragment as $duWW8$Fragment} from "react/jsx-runtime";
|
|
6
|
-
import {useRef as $duWW8$useRef, useState as $duWW8$useState, useMemo as $duWW8$useMemo, useCallback as $duWW8$useCallback, useEffect as $duWW8$useEffect, useLayoutEffect as $duWW8$useLayoutEffect,
|
|
6
|
+
import {useRef as $duWW8$useRef, useState as $duWW8$useState, useMemo as $duWW8$useMemo, useCallback as $duWW8$useCallback, useEffect as $duWW8$useEffect, useLayoutEffect as $duWW8$useLayoutEffect, forwardRef as $duWW8$forwardRef, createContext as $duWW8$createContext, useContext as $duWW8$useContext} from "react";
|
|
7
7
|
import {createPortal as $duWW8$createPortal} from "react-dom";
|
|
8
8
|
|
|
9
9
|
|
|
@@ -19,6 +19,8 @@ function $parcel$interopDefault(a) {
|
|
|
19
19
|
var $b65191f6d0a0a991$exports = {};
|
|
20
20
|
|
|
21
21
|
$parcel$export($b65191f6d0a0a991$exports, "AutoHeight", function () { return $62873e7e5aeec7f1$export$77bf000da9303d1; });
|
|
22
|
+
$parcel$export($b65191f6d0a0a991$exports, "ClickForMenu", function () { return $c3e82278b501f10c$export$d4ebdd58e04c6ace; });
|
|
23
|
+
$parcel$export($b65191f6d0a0a991$exports, "ContextMenu", function () { return $567ed433af94513f$export$8dc6765e8be191c7; });
|
|
22
24
|
$parcel$export($b65191f6d0a0a991$exports, "ContextMenuHandler", function () { return $1e1c1e9e0b943830$export$ed4f9641643dc7e4; });
|
|
23
25
|
$parcel$export($b65191f6d0a0a991$exports, "ContextWindow", function () { return $b5e8657823def5be$export$1af8984c69ba1b24; });
|
|
24
26
|
$parcel$export($b65191f6d0a0a991$exports, "ContextWindowStack", function () { return $17c46b9e6a2eb66e$export$9f37482ccd50dad2; });
|
|
@@ -252,6 +254,95 @@ $567ed433af94513f$export$8dc6765e8be191c7.displayName = "ContextMenu";
|
|
|
252
254
|
|
|
253
255
|
|
|
254
256
|
|
|
257
|
+
const $c3e82278b501f10c$export$d4ebdd58e04c6ace = (_param)=>{
|
|
258
|
+
var { id: id, menuItems: menuItems, children: children } = _param, rest = (0, $duWW8$_2)(_param, [
|
|
259
|
+
"id",
|
|
260
|
+
"menuItems",
|
|
261
|
+
"children"
|
|
262
|
+
]);
|
|
263
|
+
// Menu state
|
|
264
|
+
const [menuInDom, setMenuInDom] = (0, $duWW8$useState)(false);
|
|
265
|
+
const [menuVisible, setMenuVisible] = (0, $duWW8$useState)(false);
|
|
266
|
+
const [menuXPos, setMenuXPos] = (0, $duWW8$useState)(0);
|
|
267
|
+
const [menuYPos, setMenuYPos] = (0, $duWW8$useState)(0);
|
|
268
|
+
// Set up outsideClick handler
|
|
269
|
+
const menuRef = (0, $duWW8$useRef)(null);
|
|
270
|
+
// Handle click off the menu
|
|
271
|
+
const handleClick = (0, $duWW8$useCallback)((e)=>{
|
|
272
|
+
var _menuRef_current;
|
|
273
|
+
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))) setMenuInDom(false);
|
|
274
|
+
}, []);
|
|
275
|
+
const removeController = (0, $duWW8$useRef)(new AbortController());
|
|
276
|
+
(0, $duWW8$useEffect)(()=>{
|
|
277
|
+
if (!menuVisible) {
|
|
278
|
+
removeController.current.abort();
|
|
279
|
+
removeController.current = new AbortController();
|
|
280
|
+
setTimeout(()=>{
|
|
281
|
+
if (!removeController.current.signal.aborted) setMenuInDom(false);
|
|
282
|
+
}, 300);
|
|
283
|
+
}
|
|
284
|
+
}, [
|
|
285
|
+
menuVisible
|
|
286
|
+
]);
|
|
287
|
+
// Update the document click handler
|
|
288
|
+
(0, $duWW8$useEffect)(()=>{
|
|
289
|
+
if (menuInDom) document.addEventListener("mousedown", handleClick);
|
|
290
|
+
return ()=>{
|
|
291
|
+
document.removeEventListener("mousedown", handleClick);
|
|
292
|
+
removeController.current.abort();
|
|
293
|
+
};
|
|
294
|
+
}, [
|
|
295
|
+
handleClick,
|
|
296
|
+
menuInDom
|
|
297
|
+
]);
|
|
298
|
+
return /*#__PURE__*/ (0, $duWW8$jsxs)((0, $duWW8$Fragment), {
|
|
299
|
+
children: [
|
|
300
|
+
/*#__PURE__*/ (0, $duWW8$jsx)("div", (0, $duWW8$_1)((0, $duWW8$_)({}, rest), {
|
|
301
|
+
id: id,
|
|
302
|
+
onClick: (e)=>{
|
|
303
|
+
var _rest_onClick;
|
|
304
|
+
if (menuItems) {
|
|
305
|
+
setMenuInDom(true);
|
|
306
|
+
e.preventDefault();
|
|
307
|
+
e.stopPropagation();
|
|
308
|
+
setTimeout(()=>{
|
|
309
|
+
removeController.current.abort();
|
|
310
|
+
setMenuVisible(true);
|
|
311
|
+
setMenuXPos(e.pageX);
|
|
312
|
+
setMenuYPos(e.pageY);
|
|
313
|
+
}, 1);
|
|
314
|
+
} else (_rest_onClick = rest.onClick) === null || _rest_onClick === void 0 ? void 0 : _rest_onClick.call(rest, e);
|
|
315
|
+
},
|
|
316
|
+
children: children
|
|
317
|
+
})),
|
|
318
|
+
menuInDom && menuItems && /*#__PURE__*/ (0, $duWW8$createPortal)(/*#__PURE__*/ (0, $duWW8$jsx)("div", {
|
|
319
|
+
className: (0, (/*@__PURE__*/$parcel$interopDefault($47067f35ca62d4a5$exports))).anchor,
|
|
320
|
+
children: /*#__PURE__*/ (0, $duWW8$jsx)((0, $567ed433af94513f$export$8dc6765e8be191c7), {
|
|
321
|
+
visible: menuVisible,
|
|
322
|
+
ref: menuRef,
|
|
323
|
+
entries: menuItems,
|
|
324
|
+
xPos: menuXPos,
|
|
325
|
+
yPos: menuYPos,
|
|
326
|
+
toClose: ()=>{
|
|
327
|
+
setMenuVisible(false);
|
|
328
|
+
}
|
|
329
|
+
})
|
|
330
|
+
}), document.body)
|
|
331
|
+
]
|
|
332
|
+
});
|
|
333
|
+
};
|
|
334
|
+
$c3e82278b501f10c$export$d4ebdd58e04c6ace.displayName = "ClickForMenu";
|
|
335
|
+
|
|
336
|
+
|
|
337
|
+
|
|
338
|
+
|
|
339
|
+
|
|
340
|
+
|
|
341
|
+
|
|
342
|
+
|
|
343
|
+
|
|
344
|
+
|
|
345
|
+
|
|
255
346
|
|
|
256
347
|
var $c7a6ae87165004e6$exports = {};
|
|
257
348
|
|
|
@@ -290,6 +381,7 @@ $c7a6ae87165004e6$export$664c6d24e3175067 = `aiw-LowMenu-module-JfzGeq-visible`;
|
|
|
290
381
|
|
|
291
382
|
|
|
292
383
|
|
|
384
|
+
|
|
293
385
|
const $61945e5157f5e5bf$export$251b9f54013cdfac = ({ entry: entry })=>{
|
|
294
386
|
const [visible, setVisible] = (0, $duWW8$useState)(false);
|
|
295
387
|
if (!entry.group || entry.group.length === 0) return /*#__PURE__*/ (0, $duWW8$jsx)((0, $duWW8$Fragment), {});
|
|
@@ -329,7 +421,6 @@ const $61945e5157f5e5bf$export$251b9f54013cdfac = ({ entry: entry })=>{
|
|
|
329
421
|
$61945e5157f5e5bf$export$251b9f54013cdfac.displayName = "LowSubMenu";
|
|
330
422
|
|
|
331
423
|
|
|
332
|
-
|
|
333
424
|
const $556d6f9158abfc99$export$aafc28aea571c4bc = ({ entry: entry })=>{
|
|
334
425
|
const [target, setTarget] = (0, $duWW8$useState)(null);
|
|
335
426
|
return /*#__PURE__*/ (0, $duWW8$jsxs)("div", {
|
|
@@ -348,9 +439,10 @@ const $556d6f9158abfc99$export$aafc28aea571c4bc = ({ entry: entry })=>{
|
|
|
348
439
|
setTarget(null);
|
|
349
440
|
},
|
|
350
441
|
onClick: (e)=>{
|
|
442
|
+
var _entry_action;
|
|
351
443
|
e.preventDefault();
|
|
352
444
|
e.stopPropagation();
|
|
353
|
-
|
|
445
|
+
if (!entry.disabled) (_entry_action = entry.action) === null || _entry_action === void 0 ? void 0 : _entry_action.call(entry, target);
|
|
354
446
|
},
|
|
355
447
|
children: [
|
|
356
448
|
/*#__PURE__*/ (0, $duWW8$jsx)("span", {
|
|
@@ -390,6 +482,9 @@ $914758b0c9d59759$export$49e8edc8ebca5f25.displayName = "LowMenu";
|
|
|
390
482
|
|
|
391
483
|
|
|
392
484
|
const $1e1c1e9e0b943830$export$fc58dc71afe92de2 = /*#__PURE__*/ (0, $duWW8$createContext)(null);
|
|
485
|
+
function $1e1c1e9e0b943830$var$isDivider(label) {
|
|
486
|
+
return typeof label !== "string" && label.type === "hr";
|
|
487
|
+
}
|
|
393
488
|
const $1e1c1e9e0b943830$export$ed4f9641643dc7e4 = (_param)=>{
|
|
394
489
|
var { children: children, menuItems: menuItems, showLowMenu: showLowMenu = false } = _param, rest = (0, $duWW8$_2)(_param, [
|
|
395
490
|
"children",
|
|
@@ -402,16 +497,18 @@ const $1e1c1e9e0b943830$export$ed4f9641643dc7e4 = (_param)=>{
|
|
|
402
497
|
const thisMenuItems = (0, $duWW8$useMemo)(()=>[
|
|
403
498
|
...higherContext !== null ? [
|
|
404
499
|
...higherContext.menuItems,
|
|
405
|
-
|
|
406
|
-
label
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
500
|
+
...[
|
|
501
|
+
higherContext.menuItems.length > 0 && !$1e1c1e9e0b943830$var$isDivider(higherContext.menuItems[higherContext.menuItems.length - 1].label) && menuItems.length > 0 && !$1e1c1e9e0b943830$var$isDivider(menuItems[0].label) ? {
|
|
502
|
+
label: /*#__PURE__*/ (0, $duWW8$jsx)("hr", {
|
|
503
|
+
style: {
|
|
504
|
+
flexGrow: 1,
|
|
505
|
+
cursor: "none",
|
|
506
|
+
margin: "0",
|
|
507
|
+
padding: "0"
|
|
508
|
+
}
|
|
509
|
+
})
|
|
510
|
+
} : null
|
|
511
|
+
].filter((item)=>item !== null)
|
|
415
512
|
] : [],
|
|
416
513
|
...menuItems
|
|
417
514
|
], [
|
|
@@ -437,7 +534,6 @@ const $1e1c1e9e0b943830$export$ed4f9641643dc7e4 = (_param)=>{
|
|
|
437
534
|
// Update the document click handler
|
|
438
535
|
(0, $duWW8$useEffect)(()=>{
|
|
439
536
|
if (menuVisible) document.addEventListener("mousedown", handleClick);
|
|
440
|
-
else document.removeEventListener("mousedown", handleClick);
|
|
441
537
|
return ()=>{
|
|
442
538
|
document.removeEventListener("mousedown", handleClick);
|
|
443
539
|
};
|
|
@@ -485,6 +581,7 @@ const $1e1c1e9e0b943830$export$ed4f9641643dc7e4 = (_param)=>{
|
|
|
485
581
|
}
|
|
486
582
|
},
|
|
487
583
|
onMouseEnter: async (e)=>{
|
|
584
|
+
var _rest_onMouseEnter;
|
|
488
585
|
if (showLowMenu) {
|
|
489
586
|
setMenuInDom(true);
|
|
490
587
|
setMouseOverHandlerDiv(false);
|
|
@@ -493,15 +590,16 @@ const $1e1c1e9e0b943830$export$ed4f9641643dc7e4 = (_param)=>{
|
|
|
493
590
|
setMouseOverHandlerDiv(true);
|
|
494
591
|
}, 1);
|
|
495
592
|
}
|
|
496
|
-
rest.onMouseEnter
|
|
593
|
+
(_rest_onMouseEnter = rest.onMouseEnter) === null || _rest_onMouseEnter === void 0 ? void 0 : _rest_onMouseEnter.call(rest, e);
|
|
497
594
|
},
|
|
498
595
|
onMouseLeave: async (e)=>{
|
|
596
|
+
var _rest_onMouseLeave;
|
|
499
597
|
if (showLowMenu) {
|
|
500
598
|
removeController.current.abort();
|
|
501
599
|
removeController.current = new AbortController();
|
|
502
600
|
setMouseOverHandlerDiv(false);
|
|
503
601
|
}
|
|
504
|
-
rest.onMouseLeave
|
|
602
|
+
(_rest_onMouseLeave = rest.onMouseLeave) === null || _rest_onMouseLeave === void 0 ? void 0 : _rest_onMouseLeave.call(rest, e);
|
|
505
603
|
},
|
|
506
604
|
children: children
|
|
507
605
|
})),
|
|
@@ -702,7 +800,7 @@ const $b5e8657823def5be$export$1af8984c69ba1b24 = (_param)=>{
|
|
|
702
800
|
}
|
|
703
801
|
windowStack.pushToTop(windowId.current);
|
|
704
802
|
setWindowVisible(visible);
|
|
705
|
-
onOpen
|
|
803
|
+
onOpen === null || onOpen === void 0 ? void 0 : onOpen();
|
|
706
804
|
// Get starting position
|
|
707
805
|
if (divRef.current && windowRef.current) {
|
|
708
806
|
const parentPos = divRef.current.getBoundingClientRect();
|
|
@@ -764,8 +862,9 @@ const $b5e8657823def5be$export$1af8984c69ba1b24 = (_param)=>{
|
|
|
764
862
|
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"
|
|
765
863
|
}),
|
|
766
864
|
onClickCapture: (e)=>{
|
|
767
|
-
|
|
768
|
-
|
|
865
|
+
var _rest_onClickCapture;
|
|
866
|
+
if (windowId.current) windowStack.pushToTop(windowId.current);
|
|
867
|
+
(_rest_onClickCapture = rest.onClickCapture) === null || _rest_onClickCapture === void 0 ? void 0 : _rest_onClickCapture.call(rest, e);
|
|
769
868
|
},
|
|
770
869
|
children: [
|
|
771
870
|
/*#__PURE__*/ (0, $duWW8$jsxs)("div", {
|
|
@@ -776,7 +875,7 @@ const $b5e8657823def5be$export$1af8984c69ba1b24 = (_param)=>{
|
|
|
776
875
|
onMouseDown: (e)=>{
|
|
777
876
|
if (e.target && (e.target instanceof HTMLElement || e.target instanceof SVGElement)) e.target.style.userSelect = "none";
|
|
778
877
|
setMoving(true);
|
|
779
|
-
|
|
878
|
+
if (windowId.current) windowStack.pushToTop(windowId.current);
|
|
780
879
|
document.addEventListener("mouseup", mouseUp);
|
|
781
880
|
document.addEventListener("mousemove", mouseMove);
|
|
782
881
|
window.addEventListener("resize", ()=>checkPosition());
|
|
@@ -825,5 +924,5 @@ $b5e8657823def5be$export$1af8984c69ba1b24.displayName = "ContextWindow";
|
|
|
825
924
|
|
|
826
925
|
|
|
827
926
|
|
|
828
|
-
export {$62873e7e5aeec7f1$export$77bf000da9303d1 as AutoHeight, $1e1c1e9e0b943830$export$ed4f9641643dc7e4 as ContextMenuHandler, $b5e8657823def5be$export$1af8984c69ba1b24 as ContextWindow, $17c46b9e6a2eb66e$export$9f37482ccd50dad2 as ContextWindowStack};
|
|
927
|
+
export {$62873e7e5aeec7f1$export$77bf000da9303d1 as AutoHeight, $c3e82278b501f10c$export$d4ebdd58e04c6ace as ClickForMenu, $567ed433af94513f$export$8dc6765e8be191c7 as ContextMenu, $1e1c1e9e0b943830$export$ed4f9641643dc7e4 as ContextMenuHandler, $b5e8657823def5be$export$1af8984c69ba1b24 as ContextWindow,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components/AutoHeight.tsx","src/components/AutoHeight.module.css","src/components/ContextMenuHandler.tsx","src/components/ContextMenu.tsx","src/components/ContextMenu.module.css","src/components/ContextMenuEntry.tsx","src/components/ContextSubMenu.tsx","src/components/LowMenu.tsx","src/components/LowMenu.module.css","src/components/LowMenuButton.tsx","src/components/LowSubMenu.tsx","src/components/ContextWindow.tsx","src/functions/chkPosition.ts","src/components/ContextWindow.module.css","src/components/ContextWindowStack.tsx"],"sourcesContent":["import \"../global.d.ts\";\nexport * from \"./components\";\n","declare module \"*.module.css\" {\n const classes: { readonly [key: string]: string };\n export default classes;\n}\n","import { AutoHeight } from \"./AutoHeight\";\nimport { ContextMenuHandler } from \"./ContextMenuHandler\";\nimport { ContextWindow } from \"./ContextWindow\";\nimport { ContextWindowStack } from \"./ContextWindowStack\";\nimport { MenuItem } from \"./interface\";\n\nexport { AutoHeight, ContextMenuHandler, ContextWindow, ContextWindowStack };\nexport type { MenuItem as iMenuItem };\n","import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from \"react\";\nimport styles from \"./AutoHeight.module.css\";\n\ninterface AutoHeightProps extends React.HTMLAttributes<HTMLDivElement> {\n children: React.ReactNode;\n hide?: boolean;\n duration?: number; // transition duration in ms\n}\n\nexport function AutoHeight({\n children,\n hide,\n duration = 300,\n ...rest\n}: AutoHeightProps): JSX.Element {\n const wrapperRef = useRef<HTMLDivElement>(null);\n const innerRef = useRef<HTMLDivElement>(null);\n const [height, setHeight] = useState<number | null>(null);\n const targetChildren = useMemo<React.ReactNode>(\n () => (hide || !children ? <div style={{ height: \"1px\" }} /> : children),\n [children, hide],\n );\n\n const setTargetHeight = useCallback(() => {\n const inner = innerRef.current;\n\n // Initial draw to get the height of children and deployed children\n const deployedHeight = hide ? 1 : (inner?.offsetHeight ?? 0);\n setHeight(deployedHeight);\n }, [hide]);\n\n // Add ResizeObserver to update height on content resize, debounced\n useEffect(() => {\n const transition = innerRef.current;\n if (transition) {\n const observer = new ResizeObserver(() => {\n setTargetHeight();\n });\n\n observer.observe(transition);\n\n return () => {\n observer.disconnect();\n };\n }\n }, [setTargetHeight]);\n\n // Trigger height change on children update\n useLayoutEffect(() => {\n setTargetHeight();\n }, [setTargetHeight, children]);\n\n return (\n <div\n {...rest}\n className={styles.autoHeightWrapper}\n ref={wrapperRef}\n style={{\n ...rest.style,\n height: height ? `${height}px` : \"auto\",\n transitionDuration: `${duration}ms`,\n }}\n >\n <div\n className={styles.autoHeightInner}\n ref={innerRef}\n >\n {targetChildren}\n </div>\n </div>\n );\n}\n\nAutoHeight.displayName = \"AutoHeight\";\n",".autoHeightWrapper {\n overflow: hidden;\n transition-timing-function: height ease-in-out width ease-in-out background-color ease-in-out;\n box-sizing: border-box;\n position: relative;\n}\n\n.autoHeightInner {\n height: fit-content;\n}\n","import {\n createContext,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { ContextMenu } from \"./ContextMenu\";\nimport styles from \"./ContextMenu.module.css\";\nimport { LowMenu } from \"./LowMenu\";\nimport { MenuItem } from \"./interface\";\n\nexport interface ContentMenuHandlerContextProps {\n menuItems: MenuItem[];\n}\nexport const ContentMenuHandlerContext = createContext<ContentMenuHandlerContextProps | null>(null);\n\nexport interface ContextMenuHandlerProps extends React.HTMLAttributes<HTMLDivElement> {\n children: React.ReactNode;\n menuItems: MenuItem[];\n showLowMenu?: boolean;\n}\n\nexport const ContextMenuHandler = ({\n children,\n menuItems,\n showLowMenu = false,\n ...rest\n}: ContextMenuHandlerProps): JSX.Element => {\n // Check for higher content menu\n const higherContext = useContext(ContentMenuHandlerContext);\n const thisMenuItems = useMemo(\n () => [\n ...(higherContext !== null\n ? [\n ...higherContext.menuItems,\n {\n label: <hr style={{ flexGrow: 1, cursor: \"none\", margin: \"0\", padding: \"0\" }} />,\n },\n ]\n : []),\n ...menuItems,\n ],\n [higherContext, menuItems],\n );\n\n // Menu resources\n const divHandlderRef = useRef<HTMLDivElement | null>(null);\n const menuRef = useRef<HTMLDivElement | null>(null);\n const [menuXPos, setMenuXPos] = useState<number>(0);\n const [menuYPos, setMenuYPos] = useState<number>(0);\n const [menuVisible, setMenuVisible] = useState<boolean>(false);\n const [menuInDom, setMenuInDom] = useState<boolean>(false);\n const [mouseOverHandlerDiv, setMouseOverHandlerDiv] = useState<boolean>(false);\n const [mouseOverMenu, setMouseOverMenu] = useState<boolean>(false);\n\n // Get holder position\n const divHandlerPos = divHandlderRef ? divHandlderRef.current?.getBoundingClientRect() : null;\n\n // Handle click off the menu\n const handleClick = useCallback((e: globalThis.MouseEvent) => {\n if (\n menuRef.current &&\n ((e.target instanceof Element && !menuRef.current?.contains(e.target)) ||\n !(e.target instanceof Element))\n ) {\n setMenuVisible(false);\n }\n }, []);\n\n // Update the document click handler\n useEffect(() => {\n if (menuVisible) document.addEventListener(\"mousedown\", handleClick);\n else document.removeEventListener(\"mousedown\", handleClick);\n return () => {\n document.removeEventListener(\"mousedown\", handleClick);\n };\n }, [handleClick, menuVisible]);\n\n const removeController = useRef<AbortController>(new AbortController());\n useEffect(() => {\n if (!mouseOverMenu && !menuVisible && !mouseOverHandlerDiv) {\n removeController.current.abort();\n removeController.current = new AbortController();\n setTimeout(() => {\n if (!removeController.current.signal.aborted) setMenuInDom(false);\n }, 300);\n }\n }, [mouseOverHandlerDiv, menuVisible, mouseOverMenu]);\n\n return (\n <ContentMenuHandlerContext.Provider\n value={{\n menuItems: thisMenuItems,\n }}\n >\n <div\n ref={divHandlderRef}\n {...rest}\n className={[styles.contextMenuHandler, rest.className].join(\" \")}\n onContextMenu={async (e) => {\n if (!showLowMenu) {\n setMenuInDom(true);\n e.preventDefault();\n e.stopPropagation();\n setTimeout(() => {\n removeController.current.abort();\n setMenuVisible(true);\n setMenuXPos(e.pageX);\n setMenuYPos(e.pageY);\n }, 1);\n }\n }}\n onMouseEnter={async (e) => {\n if (showLowMenu) {\n setMenuInDom(true);\n setMouseOverHandlerDiv(false);\n setTimeout(() => {\n removeController.current.abort();\n setMouseOverHandlerDiv(true);\n }, 1);\n }\n rest.onMouseEnter && rest.onMouseEnter(e);\n }}\n onMouseLeave={async (e) => {\n if (showLowMenu) {\n removeController.current.abort();\n removeController.current = new AbortController();\n setMouseOverHandlerDiv(false);\n }\n rest.onMouseLeave && rest.onMouseLeave(e);\n }}\n >\n {children}\n </div>\n {menuInDom &&\n divHandlerPos &&\n createPortal(\n <div\n className={styles.anchor}\n onMouseEnter={() => {\n removeController.current.abort();\n setMouseOverMenu(true);\n }}\n onMouseLeave={() => {\n removeController.current.abort();\n removeController.current = new AbortController();\n setMouseOverMenu(false);\n }}\n >\n {showLowMenu ? (\n <LowMenu\n visible={mouseOverHandlerDiv}\n entries={menuItems}\n xPos={divHandlerPos.left}\n yPos={divHandlerPos.bottom}\n maxWidth={divHandlerPos.width}\n />\n ) : (\n <ContextMenu\n visible={menuVisible}\n ref={menuRef}\n entries={thisMenuItems}\n xPos={menuXPos}\n yPos={menuYPos}\n toClose={() => {\n setMenuVisible(false);\n setMouseOverMenu(false);\n }}\n />\n )}\n </div>,\n document.body,\n )}\n </ContentMenuHandlerContext.Provider>\n );\n};\n\nContextMenuHandler.displayName = \"ContextMenuHandler\";\n","import { forwardRef } from \"react\";\nimport styles from \"./ContextMenu.module.css\";\nimport { ContextMenuEntry } from \"./ContextMenuEntry\";\nimport { MenuItem } from \"./interface\";\n\nexport interface ContextMenuProps {\n visible: boolean;\n entries: MenuItem[];\n xPos: number;\n yPos: number;\n toClose: () => void;\n}\n\nexport const ContextMenu = forwardRef<HTMLDivElement, ContextMenuProps>(\n ({ visible, entries, xPos, yPos, toClose }, ref): JSX.Element => {\n return (\n <div\n ref={ref}\n className={[styles.contextMenu, visible ? styles.visible : styles.hidden]\n .filter((c) => c !== \"\")\n .join(\" \")}\n style={{\n top: `${yPos}px`,\n left: `${xPos}px`,\n }}\n onContextMenu={(e) => {\n e.preventDefault();\n e.stopPropagation();\n }}\n >\n {entries.map((entry, i) => (\n <ContextMenuEntry\n key={i}\n entry={entry}\n toClose={toClose}\n />\n ))}\n </div>\n );\n },\n);\n\nContextMenu.displayName = \"ContextMenu\";\n",".anchor {\n position: absolute;\n top: 0;\n left: 0;\n font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", \"Roboto\", \"Oxygen\", \"Ubuntu\",\n \"Cantarell\", \"Fira Sans\", \"Droid Sans\", \"Helvetica Neue\", sans-serif;\n font-size: 9pt;\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n}\n\n.contextMenuHandler {\n height: fit-content;\n width: fit-content;\n}\n\n.contextMenu {\n position: absolute;\n border: 1px solid;\n border-color: rgb(17, 20, 24);\n opacity: 1;\n background-color: rgb(251, 253, 246);\n z-index: 10000;\n box-shadow: 4px 4px 4px rgb(64, 64, 64, 0.75);\n transition: opacity 0.3s linear;\n}\n\n.contextMenu.hidden {\n opacity: 0;\n}\n\n.contextMenu.visible {\n opacity: 1;\n}\n\n.contextMenuItem {\n color: rgb(17, 20, 24);\n cursor: pointer;\n padding: 0 4px;\n min-width: 80px;\n position: relative;\n display: flex;\n flex-direction: row;\n justify-content: space-between;\n white-space: nowrap;\n}\n\n.contextMenuItem.disabled {\n background-color: rgba(0, 0, 0, 0.2);\n cursor: not-allowed;\n}\n\n.contextMenuItem:first-child {\n padding-top: 4px;\n}\n\n.contextMenuItem:last-child {\n padding-bottom: 4px;\n}\n\n.contextMenuItem:not(.disabled):hover {\n background-color: rgb(251, 233, 230);\n}\n\n.contextMenuItem .caretHolder {\n align-self: flex-end;\n}\n\n.contextMenuItem .caretHolder .subMenu {\n z-index: 1;\n position: relative;\n}\n\n.contextMenuItemLabel {\n flex-grow: 1;\n height: 19px;\n}\n","import { useState } from \"react\";\nimport styles from \"./ContextMenu.module.css\";\nimport { ContextSubMenu } from \"./ContextSubMenu\";\nimport { MenuItem } from \"./interface\";\n\ninterface ContextMenuEntryProps {\n entry: MenuItem;\n toClose: () => void;\n}\n\nexport const ContextMenuEntry = ({ entry, toClose }: ContextMenuEntryProps) => {\n const [target, setTarget] = useState<Range | null>(null);\n const [subMenuVisible, setSubMenuVisible] = useState<boolean>(false);\n return (\n <div\n className={[styles.contextMenuItem, entry.disabled ? styles.disabled : \"\"]\n .filter((c) => c !== \"\")\n .join(\" \")}\n onMouseEnter={() => {\n setSubMenuVisible(true);\n }}\n onMouseLeave={() => {\n setSubMenuVisible(false);\n }}\n >\n {typeof entry.label === \"string\" ? (\n <span\n aria-label={typeof entry.label === \"string\" ? entry.label : undefined}\n aria-disabled={entry.disabled}\n className={styles.contextMenuItemLabel}\n onMouseEnter={() => {\n const sel = window.getSelection();\n const target = sel && sel.rangeCount > 0 ? sel.getRangeAt(0) : null;\n setTarget(target);\n }}\n onMouseLeave={() => {\n setTarget(null);\n }}\n onMouseDownCapture={(e) => {\n e.preventDefault();\n e.stopPropagation();\n if (!entry.disabled) {\n if (entry.action) {\n entry.action(target, e);\n }\n toClose();\n }\n }}\n >\n {entry.label}\n </span>\n ) : (\n entry.label\n )}\n {entry.group && (\n <ContextSubMenu\n toClose={toClose}\n entries={entry.group}\n visible={subMenuVisible}\n />\n )}\n </div>\n );\n};\n","import { ContextMenu } from \"./ContextMenu\";\nimport styles from \"./ContextMenu.module.css\";\nimport { MenuItem } from \"./interface\";\n\nexport interface ContextSubMenuProps {\n entries: MenuItem[];\n toClose: () => void;\n lowMenu?: boolean;\n visible: boolean;\n}\n\nexport const ContextSubMenu = ({ entries, toClose, visible }: ContextSubMenuProps): JSX.Element => {\n return (\n <span className={styles.caretHolder}>\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"16\"\n height=\"16\"\n fill=\"currentColor\"\n viewBox=\"0 0 16 16\"\n >\n <path 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\" />\n </svg>\n <div className={styles.subMenu}>\n <ContextMenu\n visible={visible}\n entries={entries}\n xPos={14}\n yPos={-21}\n toClose={toClose}\n />\n </div>\n </span>\n );\n};\n\nContextSubMenu.displayName = \"ContextSubMenu\";\n","import styles from \"./LowMenu.module.css\";\nimport { LowMenuButton } from \"./LowMenuButton\";\nimport { MenuItem } from \"./interface\";\n\ninterface LowMenuProps {\n entries: MenuItem[];\n visible: boolean;\n xPos: number;\n yPos: number;\n maxWidth: number;\n}\n\nexport const LowMenu = ({ entries, visible, xPos, yPos, maxWidth }: LowMenuProps): JSX.Element => {\n return (\n <div\n className={[styles.lowMenu, visible ? styles.visible : styles.hidden].join(\" \")}\n aria-label=\"Low context menu\"\n style={{\n left: `${xPos}px`,\n top: `${yPos}px`,\n maxWidth: `calc(${maxWidth}px)`,\n width: `calc(${maxWidth}px - 4px)`,\n }}\n >\n <div className={styles.lowMenuButtonHolder}>\n {entries.map((e, i) => (\n <LowMenuButton\n key={i}\n entry={e}\n />\n ))}\n </div>\n </div>\n );\n};\n\nLowMenu.displayName = \"LowMenu\";\n",".lowMenu {\n z-index: 2;\n position: absolute;\n margin: 0px;\n transition: opacity 0.3s linear;\n}\n\n.lowMenuButtonHolder {\n border: 2px solid rgb(17, 20, 24);\n border-top-right-radius: 4px;\n border-bottom-left-radius: 4px;\n border-bottom-right-radius: 4px;\n background-color: rgb(17, 20, 24);\n box-shadow: 2px 2px 2px rgb(64, 64, 64, 0.5);\n display: flex;\n flex-wrap: wrap;\n flex-direction: row;\n gap: 2px;\n row-gap: 2px;\n width: fit-content;\n}\n\n.lowMenu.hidden {\n opacity: 0;\n}\n\n.lowMenu.visible,\n.lowMenu:hover {\n opacity: 1;\n}\n\n.lowMenuItem {\n background-color: rgb(251, 253, 246);\n border: 0;\n color: rgb(17, 20, 24);\n cursor: pointer;\n padding: 0 4px;\n position: relative;\n display: flex;\n flex-direction: row;\n justify-content: space-between;\n white-space: nowrap;\n}\n\n.lowMenuItem.disabled {\n background-color: rgba(200, 200, 200);\n cursor: not-allowed;\n}\n\n.lowMenuItem:not(.disabled):hover {\n background-color: rgb(251, 233, 230);\n}\n\n.lowMenu-item .caretHolder {\n align-self: flex-end;\n}\n\n.lowMenuItem .caretHolder .subMenu {\n z-index: 1;\n position: relative;\n}\n","import styles from \"./LowMenu.module.css\";\nimport { LowSubMenu } from \"./LowSubMenu\";\nimport { MenuItem } from \"./interface\";\nimport { useState } from \"react\";\n\ninterface LowMenuButtonProps {\n entry: MenuItem;\n}\nexport const LowMenuButton = ({ entry }: LowMenuButtonProps) => {\n const [target, setTarget] = useState<Range | null>(null);\n return (\n <div\n className={[styles.lowMenuItem, entry.disabled ? styles.disabled : \"\"]\n .filter((c) => c !== \"\")\n .join(\" \")}\n aria-label={typeof entry.label === \"string\" ? entry.label : undefined}\n aria-disabled={entry.disabled}\n onMouseEnter={() => {\n const sel = window.getSelection();\n const target = sel && sel.rangeCount > 0 ? sel.getRangeAt(0) : null;\n setTarget(target);\n }}\n onMouseLeave={() => {\n setTarget(null);\n }}\n onClick={(e) => {\n e.preventDefault();\n e.stopPropagation();\n entry.action && !entry.disabled && entry.action(target);\n }}\n >\n <span>{entry.label}</span>\n {entry.group && <LowSubMenu entry={entry} />}\n </div>\n );\n};\n\nLowMenuButton.displayName = \"LowMenuButton\";\n","import { useState } from \"react\";\nimport { ContextMenu } from \"./ContextMenu\";\nimport styles from \"./LowMenu.module.css\";\nimport { MenuItem } from \"./interface\";\n\nexport interface LowSubMenuProps {\n entry: MenuItem;\n lowMenu?: boolean;\n}\n\nexport const LowSubMenu = ({ entry }: LowSubMenuProps): JSX.Element => {\n const [visible, setVisible] = useState<boolean>(false);\n if (!entry.group || entry.group.length === 0) return <></>;\n return (\n <span\n aria-label={`Sub menu for ${entry.label}`}\n className={styles.caretHolder}\n onMouseEnter={() => {\n setVisible(true);\n }}\n onMouseLeave={() => {\n setVisible(false);\n }}\n >\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"16\"\n height=\"16\"\n fill=\"currentColor\"\n viewBox=\"0 0 16 16\"\n >\n <path 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\" />\n </svg>\n <div className={styles.subMenu}>\n {visible && (\n <ContextMenu\n visible={visible}\n entries={entry.group}\n xPos={14}\n yPos={entry.group.length * -21 - 8}\n toClose={() => setVisible(false)}\n />\n )}\n </div>\n </span>\n );\n};\n\nLowSubMenu.displayName = \"LowSubMenu\";\n","import { ReactNode, useCallback, useContext, useEffect, useMemo, useRef, useState } from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { chkPosition } from \"../functions/chkPosition\";\nimport styles from \"./ContextWindow.module.css\";\nimport { ContextWindowStackContext } from \"./ContextWindowStack\";\n\ninterface ContextWindowProps extends React.HTMLAttributes<HTMLDivElement> {\n id: string;\n visible: boolean;\n onOpen?: () => void;\n onClose?: () => void;\n title: string;\n titleElement?: ReactNode;\n style?: React.CSSProperties;\n children: React.ReactNode;\n}\n\nexport const ContextWindow = ({\n id,\n visible,\n title,\n titleElement,\n children,\n onOpen,\n onClose,\n ...rest\n}: ContextWindowProps): JSX.Element => {\n const windowStack = useContext(ContextWindowStackContext);\n const windowId = useRef<number | null>(null);\n const divRef = useRef<HTMLDivElement | null>(null);\n const windowRef = useRef<HTMLDivElement | null>(null);\n const [windowInDOM, setWindowInDOM] = useState<boolean>(false);\n const [windowVisible, setWindowVisible] = useState<boolean>(false);\n const zIndex = useMemo(() => {\n return windowStack?.currentWindows.find((w) => w.windowId === windowId.current)?.zIndex ?? 1;\n }, [windowStack?.currentWindows]);\n\n // Position\n const windowPos = useRef<{ x: number; y: number }>({ x: 0, y: 0 });\n const [moving, setMoving] = useState<boolean>(false);\n\n const move = useCallback((x: number, y: number) => {\n if (windowRef.current && windowPos.current) {\n const window = windowRef.current;\n const pos = windowPos.current;\n pos.x += x;\n pos.y += y;\n window.style.transform = `translate(${pos.x}px, ${pos.y}px)`;\n }\n }, []);\n\n const checkPosition = useCallback(() => {\n const chkPos = chkPosition(windowRef);\n move(chkPos.translateX, chkPos.translateY);\n }, [move]);\n\n const mouseMove = useCallback(\n (e: MouseEvent) => {\n e.preventDefault();\n e.stopPropagation();\n move(e.movementX, e.movementY);\n },\n [move],\n );\n\n const mouseUp = useCallback(\n (e: MouseEvent) => {\n e.preventDefault();\n e.stopPropagation();\n setMoving(false);\n checkPosition();\n document.removeEventListener(\"mousemove\", mouseMove);\n document.removeEventListener(\"mouseup\", mouseUp);\n window.removeEventListener(\"resize\", checkPosition);\n if (e.target && (e.target instanceof HTMLElement || e.target instanceof SVGElement))\n e.target.style.userSelect = \"auto\";\n },\n [checkPosition, mouseMove],\n );\n\n // Update visibility\n useEffect(() => {\n if (windowStack) {\n // Visible set, but not in DOM\n if (visible && !windowInDOM) {\n setWindowInDOM(true);\n } else if (visible && windowInDOM && !windowVisible) {\n if (!windowId.current) {\n const maxWindowId = Math.max(0, ...windowStack.currentWindows.map((w) => w.windowId));\n windowId.current = maxWindowId + 1;\n }\n windowStack.pushToTop(windowId.current);\n setWindowVisible(visible);\n onOpen && onOpen();\n // Get starting position\n if (divRef.current && windowRef.current) {\n const parentPos = divRef.current.getBoundingClientRect();\n const pos = windowRef.current.getBoundingClientRect();\n const windowHeight = pos.bottom - pos.top;\n windowRef.current.style.left = `${parentPos.left}px`;\n windowRef.current.style.top = `${\n parentPos.bottom + windowHeight < window.innerHeight\n ? parentPos.bottom\n : Math.max(0, parentPos.top - windowHeight)\n }px`;\n windowRef.current.style.transform = \"\";\n windowPos.current = { x: 0, y: 0 };\n }\n checkPosition();\n } else if (windowId.current && !visible && windowVisible) {\n setWindowVisible(false);\n } else if (windowId.current && !visible && windowInDOM) {\n setWindowInDOM(false);\n }\n }\n }, [checkPosition, onOpen, visible, windowInDOM, windowStack, windowVisible]);\n\n return (\n <div\n className={styles.contextWindowAnchor}\n ref={divRef}\n >\n {!windowStack && (\n <div {...rest}>\n {process.env.NODE_ENV !== \"production\" && (\n <div\n style={{ backgroundColor: \"red\", color: \"white\", padding: \"8px\", fontSize: \"48px\" }}\n >\n WARNING: No ContextWindowStack found\n </div>\n )}\n {children}\n </div>\n )}\n {windowStack &&\n windowInDOM &&\n createPortal(\n <div\n {...rest}\n ref={windowRef}\n id={id}\n className={[styles.contextWindow, rest.className].filter((c) => c).join(\" \")}\n style={{\n ...rest.style,\n opacity: moving ? 0.8 : windowVisible ? 1 : 0,\n visibility: windowVisible ? \"visible\" : \"hidden\",\n zIndex: zIndex ?? 1,\n minHeight: rest.style?.minHeight ?? \"150px\",\n minWidth: rest.style?.minWidth ?? \"200px\",\n maxHeight: rest.style?.maxHeight ?? \"1000px\",\n maxWidth: rest.style?.maxWidth ?? \"1000px\",\n }}\n onClickCapture={(e) => {\n windowId && windowId.current && windowStack.pushToTop(windowId.current);\n rest.onClickCapture && rest.onClickCapture(e);\n }}\n >\n <div\n className={[styles.contextWindowTitle, moving ? styles.moving : \"\"]\n .filter((c) => c !== \"\")\n .join(\" \")}\n onMouseDown={(e: React.MouseEvent) => {\n if (e.target && (e.target instanceof HTMLElement || e.target instanceof SVGElement))\n e.target.style.userSelect = \"none\";\n setMoving(true);\n windowId && windowId.current && windowStack.pushToTop(windowId.current);\n document.addEventListener(\"mouseup\", mouseUp);\n document.addEventListener(\"mousemove\", mouseMove);\n window.addEventListener(\"resize\", () => checkPosition());\n }}\n >\n <div\n className={styles.contextWindowTitleText}\n title={title}\n >\n {titleElement ? titleElement : title}\n </div>\n <div\n className={styles.contextWindowTitleClose}\n role=\"button\"\n aria-label=\"Close\"\n onClick={onClose}\n title={`Close ${title && title.trim() !== \"\" ? title : \"window\"}`}\n >\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"16\"\n height=\"16\"\n fill=\"currentColor\"\n viewBox=\"0 0 16 16\"\n >\n <path 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\" />\n </svg>\n </div>\n </div>\n <div className={styles.contextWindowBody}>\n <div>{children}</div>\n </div>\n </div>,\n document.body,\n )}\n </div>\n );\n};\n\nContextWindow.displayName = \"ContextWindow\";\n","import { RefObject } from \"react\";\n\n/**\n * Check that an existing div is inside the viewport\n * @param divRef Check div is inside view port, and return n\n * @returns \\{ translateX, translateY \\} Amount to move on X and Y axis\n */\nexport const chkPosition = (\n divRef: RefObject<HTMLDivElement>,\n): { translateX: number; translateY: number } => {\n if (!divRef.current) {\n return { translateX: 0, translateY: 0 };\n } else {\n const innerBounce = 16;\n const posn = divRef.current.getBoundingClientRect();\n let translateX = 0;\n if (posn.left < innerBounce) {\n translateX = -posn.left + innerBounce;\n } else if (posn.right > window.innerWidth) {\n translateX = Math.max(-posn.left + innerBounce, window.innerWidth - posn.right - innerBounce);\n }\n let translateY = 0;\n if (posn.top < innerBounce) {\n translateY = -posn.top + innerBounce;\n } else if (posn.bottom > window.innerHeight) {\n translateY = Math.max(\n -posn.top + innerBounce,\n window.innerHeight - posn.bottom - innerBounce,\n );\n }\n return { translateX, translateY };\n }\n};\n",".contextWindowAnchor {\n position: relative;\n}\n\n.contextWindow {\n z-index: 2001;\n border: 1px black solid;\n margin: 0;\n padding: 4px;\n background-color: rgb(250, 250, 250);\n box-shadow: 6px 6px 6px rgb(64, 64, 64, 0.5);\n transition: opacity 0.25s linear;\n justify-content: flex-start;\n position: absolute;\n border-top-left-radius: 8px;\n border-top-right-radius: 8px;\n border-bottom-left-radius: 8px;\n resize: both;\n overflow: auto;\n max-height: 95vh;\n max-width: 95vw;\n}\n\n.contextWindowTitle {\n border-bottom: 1px black dashed;\n box-sizing: unset;\n padding-bottom: 4px;\n margin: 0 4px 3px 4px;\n height: 24px;\n line-height: 24px;\n max-height: 24px;\n cursor: grab;\n font-size: 18px;\n font-weight: 600;\n display: flex;\n flex-direction: row;\n align-items: center;\n width: calc(100% - 8px);\n}\n\n.contextWindowTitle.moving {\n cursor: grabbing;\n}\n\n.contextWindowTitleText {\n display: inline-block;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n width: calc(100% - 16px);\n}\n\n.contextWindowTitleClose {\n display: flex;\n color: black;\n height: 16px;\n width: 16px;\n border-radius: 3px;\n margin-left: 2px;\n cursor: pointer;\n line-height: 16px;\n}\n\n.contextWindowTitleClose:hover {\n background-color: black;\n color: white;\n}\n\n.contextWindowBody {\n overflow: auto;\n padding-bottom: 8px;\n margin-right: 4px;\n height: calc(100% - 40px);\n}\n\n.contextWindowBody::-webkit-scrollbar {\n width: 8px;\n height: 8px;\n}\n\n.contextWindowBody::-webkit-scrollbar-track {\n background: white;\n border-radius: 8px;\n}\n\n.contextWindowBody::-webkit-scrollbar-thumb {\n background: lightgrey;\n border: none;\n border-radius: 8px;\n}\n\n.contextWindowBody::-webkit-scrollbar-thumb:hover {\n background: grey;\n}\n","import { createContext, useState } from \"react\";\n\nexport interface ContextWindowZIndex {\n windowId: number;\n zIndex: number;\n}\n\nexport interface ContextWindowStackContextProps {\n currentWindows: ContextWindowZIndex[];\n pushToTop: (ret: number) => void;\n}\n\nexport const ContextWindowStackContext = createContext<ContextWindowStackContextProps | null>(null);\n\ninterface ContextWindowStackProps {\n id?: string;\n minZIndex?: number;\n children?: JSX.Element[] | JSX.Element;\n}\n\nconst pushToTop = (\n windowId: number,\n minZIndex: number,\n windowList: ContextWindowZIndex[],\n setWindowList: (ret: ContextWindowZIndex[]) => void,\n) => {\n const otherWindows = windowList\n .filter((w) => w.windowId !== windowId)\n .map((w, i) => ({ windowId: w.windowId, zIndex: minZIndex + i }));\n setWindowList([...otherWindows, { windowId, zIndex: minZIndex + otherWindows.length }]);\n};\n\nexport const ContextWindowStack = ({\n minZIndex = 1000,\n children,\n}: ContextWindowStackProps): JSX.Element => {\n const [currentWindows, setCurrentWindows] = useState<ContextWindowZIndex[]>([]);\n\n return (\n <ContextWindowStackContext.Provider\n value={{\n currentWindows: currentWindows.map((w) => ({\n windowId: w.windowId,\n zIndex: minZIndex + w.zIndex,\n })),\n pushToTop: (ret: number) => pushToTop(ret, minZIndex, currentWindows, setCurrentWindows),\n }}\n >\n {children}\n </ContextWindowStackContext.Provider>\n );\n};\n\nContextWindowStack.displayName = \"ContextWindowStack\";\n"],"names":[],"version":3,"file":"main.js.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AIAA,IAAA;AACA,IAAA;AADA,4CAAoC,CAAC,4CAA4C,CAAC;AAClF,4CAAsC,CAAC,8CAA8C,CAAC;;;ADQ/E,SAAS,yCAAW;QAAA,YACzB,QAAQ,QACR,IAAI,YACJ,WAAW,KAEK,GALS,QAItB,sBAJsB;QACzB;QACA;QACA;;IAGA,MAAM,aAAa,CAAA,GAAA,aAAK,EAAkB;IAC1C,MAAM,WAAW,CAAA,GAAA,aAAK,EAAkB;IACxC,MAAM,CAAC,QAAQ,UAAU,GAAG,CAAA,GAAA,eAAO,EAAiB;IACpD,MAAM,iBAAiB,CAAA,GAAA,cAAM,EAC3B,IAAO,QAAQ,CAAC,yBAAW,gBAAC;YAAI,OAAO;gBAAE,QAAQ;YAAM;aAAQ,UAC/D;QAAC;QAAU;KAAK;IAGlB,MAAM,kBAAkB,CAAA,GAAA,kBAAU,EAAE;QAClC,MAAM,QAAQ,SAAS,OAAO;YAGK;QADnC,mEAAmE;QACnE,MAAM,iBAAiB,OAAO,IAAK,CAAA,sBAAA,kBAAA,4BAAA,MAAO,YAAY,cAAnB,iCAAA,sBAAuB;QAC1D,UAAU;IACZ,GAAG;QAAC;KAAK;IAET,mEAAmE;IACnE,CAAA,GAAA,gBAAQ,EAAE;QACR,MAAM,aAAa,SAAS,OAAO;QACnC,IAAI,YAAY;YACd,MAAM,WAAW,IAAI,eAAe;gBAClC;YACF;YAEA,SAAS,OAAO,CAAC;YAEjB,OAAO;gBACL,SAAS,UAAU;YACrB;QACF;IACF,GAAG;QAAC;KA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CAEA,iBAAC;wBACC,WAAW;4BAAC,CAAA,GAAA,gEAAK,EAAE,kBAAkB;4BAAE,SAAS,CAAA,GAAA,gEAAK,EAAE,MAAM,GAAG;yBAAG,CAChE,MAAM,CAAC,CAAC,IAAM,MAAM,IACpB,IAAI,CAAC;wBACR,aAAa,CAAC;4BACZ,IAAI,EAAE,MAAM,IAAK,CAAA,EAAE,MAAM,YAAY,eAAe,EAAE,MAAM,YAAY,UAAS,GAC/E,EAAE,MAAM,CAAC,KAAK,CAAC,UAAU,GAAG;4BAC9B,UAAU;4BACV,IAAI,SAAS,OAAO,EAAE,YAAY,SAAS,CAAC,SAAS,OAAO;4BAC5D,SAAS,gBAAgB,CAAC,WAAW;4BACrC,SAAS,gBAAgB,CAAC,aAAa;4BACvC,OAAO,gBAAgB,CAAC,UAAU,IAAM;wBAC1C;;0CAEA,gBAAC;gCACC,WAAW,CAAA,GAAA,gEAAK,EAAE,sBAAsB;gCACxC,OAAO;0CAEN,eAAe,eAAe;;0CAEjC,gBAAC;gCACC,WAAW,CAAA,GAAA,gEAAK,EAAE,uBAAuB;gCACzC,MAAK;gCACL,cAAW;gCACX,SAAS;gCACT,OAAO,CAAC,MAAM,EAAE,SAAS,MAAM,IAAI,OAAO,KAAK,QAAQ,UAAU;0CAEjE,cAAA,gBAAC;oCACC,OAAM;oCACN,OAAM;oCACN,QAAO;oCACP,MAAK;oCACL,SAAQ;8CAER,cAAA,gBAAC;wCAAK,GAAE;;;;;;kCAId,gBAAC;wBAAI,WAAW,CAAA,GAAA,gEAAK,EAAE,iBAAiB;kCACtC,cAAA,gBAAC;sCAAK;;;;iBAGV,SAAS,IAAI;;;AAIvB;AAEA,0CAAc,WAAW,GAAG;","sources":["src/main.ts","global.d.ts","src/components/index.ts","src/components/AutoHeight.tsx","src/components/AutoHeight.module.css","src/components/ClickForMenu.tsx","src/components/ContextMenu.tsx","src/components/ContextMenu.module.css","src/components/ContextMenuEntry.tsx","src/components/ContextSubMenu.tsx","src/components/ContextMenuHandler.tsx","src/components/LowMenu.tsx","src/components/LowMenu.module.css","src/components/LowMenuButton.tsx","src/components/LowSubMenu.tsx","src/components/ContextWindow.tsx","src/functions/chkPosition.ts","src/components/ContextWindow.module.css","src/components/ContextWindowStack.tsx"],"sourcesContent":["import \"../global.d.ts\";\nexport * from \"./components\";\n","declare module \"*.module.css\" {\n const classes: { readonly [key: string]: string };\n export default classes;\n}\n","import { AutoHeight } from \"./AutoHeight\";\nimport { ClickForMenu } from \"./ClickForMenu\";\nimport { ContextMenu } from \"./ContextMenu\";\nimport { ContextMenuHandler } from \"./ContextMenuHandler\";\nimport { ContextWindow } from \"./ContextWindow\";\nimport { ContextWindowStack } from \"./ContextWindowStack\";\nimport { MenuItem } from \"./interface\";\n\nexport {\n AutoHeight,\n ClickForMenu,\n ContextMenu,\n ContextMenuHandler,\n ContextWindow,\n ContextWindowStack,\n};\nexport type { MenuItem as iMenuItem };\n","import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from \"react\";\nimport styles from \"./AutoHeight.module.css\";\n\ninterface AutoHeightProps extends React.HTMLAttributes<HTMLDivElement> {\n children: React.ReactNode;\n hide?: boolean;\n duration?: number; // transition duration in ms\n}\n\nexport function AutoHeight({\n children,\n hide,\n duration = 300,\n ...rest\n}: AutoHeightProps): JSX.Element {\n const wrapperRef = useRef<HTMLDivElement>(null);\n const innerRef = useRef<HTMLDivElement>(null);\n const [height, setHeight] = useState<number | null>(null);\n const targetChildren = useMemo<React.ReactNode>(\n () => (hide || !children ? <div style={{ height: \"1px\" }} /> : children),\n [children, hide],\n );\n\n const setTargetHeight = useCallback(() => {\n const inner = innerRef.current;\n\n // Initial draw to get the height of children and deployed children\n const deployedHeight = hide ? 1 : (inner?.offsetHeight ?? 0);\n setHeight(deployedHeight);\n }, [hide]);\n\n // Add ResizeObserver to update height on content resize, debounced\n useEffect(() => {\n const transition = innerRef.current;\n if (transition) {\n const observer = new ResizeObserver(() => {\n setTargetHeight();\n });\n\n observer.observe(transition);\n\n return () => {\n observer.disconnect();\n };\n }\n }, [setTargetHeight]);\n\n // Trigger height change on children update\n useLayoutEffect(() => {\n setTargetHeight();\n }, [setTargetHeight, children]);\n\n return (\n <div\n {...rest}\n className={styles.autoHeightWrapper}\n ref={wrapperRef}\n style={{\n ...rest.style,\n height: height ? `${height}px` : \"auto\",\n transitionDuration: `${duration}ms`,\n }}\n >\n <div\n className={styles.autoHeightInner}\n ref={innerRef}\n >\n {targetChildren}\n </div>\n </div>\n );\n}\n\nAutoHeight.displayName = \"AutoHeight\";\n",".autoHeightWrapper {\n overflow: hidden;\n transition-timing-function: height ease-in-out width ease-in-out background-color ease-in-out;\n box-sizing: border-box;\n position: relative;\n}\n\n.autoHeightInner {\n height: fit-content;\n}\n","import React, { useCallback, useEffect, useRef, useState } from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { ContextMenu } from \"./ContextMenu\";\nimport styles from \"./ContextMenu.module.css\";\nimport { MenuItem } from \"./interface\";\n\ninterface ClickForMenuProps extends React.HTMLAttributes<HTMLDivElement> {\n id: string;\n menuItems?: MenuItem[];\n chidren?: React.ReactNode;\n}\n\nexport const ClickForMenu = ({\n id,\n menuItems,\n children,\n ...rest\n}: ClickForMenuProps): JSX.Element => {\n // Menu state\n const [menuInDom, setMenuInDom] = useState<boolean>(false);\n const [menuVisible, setMenuVisible] = useState<boolean>(false);\n const [menuXPos, setMenuXPos] = useState<number>(0);\n const [menuYPos, setMenuYPos] = useState<number>(0);\n\n // Set up outsideClick handler\n const menuRef = useRef<HTMLDivElement | null>(null);\n\n // Handle click off the menu\n const handleClick = useCallback((e: MouseEvent) => {\n if (\n menuRef.current &&\n ((e.target instanceof Element && !menuRef.current?.contains(e.target)) ||\n !(e.target instanceof Element))\n ) {\n setMenuInDom(false);\n }\n }, []);\n\n const removeController = useRef<AbortController>(new AbortController());\n useEffect(() => {\n if (!menuVisible) {\n removeController.current.abort();\n removeController.current = new AbortController();\n setTimeout(() => {\n if (!removeController.current.signal.aborted) setMenuInDom(false);\n }, 300);\n }\n }, [menuVisible]);\n\n // Update the document click handler\n useEffect(() => {\n if (menuInDom) document.addEventListener(\"mousedown\", handleClick);\n return () => {\n document.removeEventListener(\"mousedown\", handleClick);\n removeController.current.abort();\n };\n }, [handleClick, menuInDom]);\n\n return (\n <>\n <div\n {...rest}\n id={id}\n onClick={(e) => {\n if (menuItems) {\n setMenuInDom(true);\n e.preventDefault();\n e.stopPropagation();\n setTimeout(() => {\n removeController.current.abort();\n setMenuVisible(true);\n setMenuXPos(e.pageX);\n setMenuYPos(e.pageY);\n }, 1);\n } else {\n rest.onClick?.(e);\n }\n }}\n >\n {children}\n </div>\n {menuInDom &&\n menuItems &&\n createPortal(\n <div className={styles.anchor}>\n <ContextMenu\n visible={menuVisible}\n ref={menuRef}\n entries={menuItems}\n xPos={menuXPos}\n yPos={menuYPos}\n toClose={() => {\n setMenuVisible(false);\n }}\n />\n </div>,\n document.body,\n )}\n </>\n );\n};\n\nClickForMenu.displayName = \"ClickForMenu\";\n","import { forwardRef } from \"react\";\nimport styles from \"./ContextMenu.module.css\";\nimport { ContextMenuEntry } from \"./ContextMenuEntry\";\nimport { MenuItem } from \"./interface\";\n\nexport interface ContextMenuProps {\n visible: boolean;\n entries: MenuItem[];\n xPos: number;\n yPos: number;\n toClose: () => void;\n}\n\nexport const ContextMenu = forwardRef<HTMLDivElement, ContextMenuProps>(\n ({ visible, entries, xPos, yPos, toClose }, ref): JSX.Element => {\n return (\n <div\n ref={ref}\n className={[styles.contextMenu, visible ? styles.visible : styles.hidden]\n .filter((c) => c !== \"\")\n .join(\" \")}\n style={{\n top: `${yPos}px`,\n left: `${xPos}px`,\n }}\n onContextMenu={(e) => {\n e.preventDefault();\n e.stopPropagation();\n }}\n >\n {entries.map((entry, i) => (\n <ContextMenuEntry\n key={i}\n entry={entry}\n toClose={toClose}\n />\n ))}\n </div>\n );\n },\n);\n\nContextMenu.displayName = \"ContextMenu\";\n",".anchor {\n position: absolute;\n top: 0;\n left: 0;\n font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", \"Roboto\", \"Oxygen\", \"Ubuntu\",\n \"Cantarell\", \"Fira Sans\", \"Droid Sans\", \"Helvetica Neue\", sans-serif;\n font-size: 9pt;\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n}\n\n.contextMenuHandler {\n height: fit-content;\n width: fit-content;\n}\n\n.contextMenu {\n position: absolute;\n border: 1px solid;\n border-color: rgb(17, 20, 24);\n opacity: 1;\n background-color: rgb(251, 253, 246);\n z-index: 10000;\n box-shadow: 4px 4px 4px rgb(64, 64, 64, 0.75);\n transition: opacity 0.3s linear;\n}\n\n.contextMenu.hidden {\n opacity: 0;\n}\n\n.contextMenu.visible {\n opacity: 1;\n}\n\n.contextMenuItem {\n color: rgb(17, 20, 24);\n cursor: pointer;\n padding: 0 4px;\n min-width: 80px;\n position: relative;\n display: flex;\n flex-direction: row;\n justify-content: space-between;\n white-space: nowrap;\n}\n\n.contextMenuItem.disabled {\n background-color: rgba(0, 0, 0, 0.2);\n cursor: not-allowed;\n}\n\n.contextMenuItem:first-child {\n padding-top: 4px;\n}\n\n.contextMenuItem:last-child {\n padding-bottom: 4px;\n}\n\n.contextMenuItem:not(.disabled):hover {\n background-color: rgb(251, 233, 230);\n}\n\n.contextMenuItem .caretHolder {\n align-self: flex-end;\n}\n\n.contextMenuItem .caretHolder .subMenu {\n z-index: 1;\n position: relative;\n}\n\n.contextMenuItemLabel {\n flex-grow: 1;\n height: 19px;\n}\n","import { useState } from \"react\";\nimport styles from \"./ContextMenu.module.css\";\nimport { ContextSubMenu } from \"./ContextSubMenu\";\nimport { MenuItem } from \"./interface\";\n\ninterface ContextMenuEntryProps {\n entry: MenuItem;\n toClose: () => void;\n}\n\nexport const ContextMenuEntry = ({ entry, toClose }: ContextMenuEntryProps) => {\n const [target, setTarget] = useState<Range | null>(null);\n const [subMenuVisible, setSubMenuVisible] = useState<boolean>(false);\n return (\n <div\n className={[styles.contextMenuItem, entry.disabled ? styles.disabled : \"\"]\n .filter((c) => c !== \"\")\n .join(\" \")}\n onMouseEnter={() => {\n setSubMenuVisible(true);\n }}\n onMouseLeave={() => {\n setSubMenuVisible(false);\n }}\n >\n {typeof entry.label === \"string\" ? (\n <span\n aria-label={typeof entry.label === \"string\" ? entry.label : undefined}\n aria-disabled={entry.disabled}\n className={styles.contextMenuItemLabel}\n onMouseEnter={() => {\n const sel = window.getSelection();\n const target = sel && sel.rangeCount > 0 ? sel.getRangeAt(0) : null;\n setTarget(target);\n }}\n onMouseLeave={() => {\n setTarget(null);\n }}\n onMouseDownCapture={(e) => {\n e.preventDefault();\n e.stopPropagation();\n if (!entry.disabled) {\n if (entry.action) {\n entry.action(target, e);\n }\n toClose();\n }\n }}\n >\n {entry.label}\n </span>\n ) : (\n entry.label\n )}\n {entry.group && (\n <ContextSubMenu\n toClose={toClose}\n entries={entry.group}\n visible={subMenuVisible}\n />\n )}\n </div>\n );\n};\n","import { ContextMenu } from \"./ContextMenu\";\nimport styles from \"./ContextMenu.module.css\";\nimport { MenuItem } from \"./interface\";\n\nexport interface ContextSubMenuProps {\n entries: MenuItem[];\n toClose: () => void;\n lowMenu?: boolean;\n visible: boolean;\n}\n\nexport const ContextSubMenu = ({ entries, toClose, visible }: ContextSubMenuProps): JSX.Element => {\n return (\n <span className={styles.caretHolder}>\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"16\"\n height=\"16\"\n fill=\"currentColor\"\n viewBox=\"0 0 16 16\"\n >\n <path 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\" />\n </svg>\n <div className={styles.subMenu}>\n <ContextMenu\n visible={visible}\n entries={entries}\n xPos={14}\n yPos={-21}\n toClose={toClose}\n />\n </div>\n </span>\n );\n};\n\nContextSubMenu.displayName = \"ContextSubMenu\";\n","import {\n createContext,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { ContextMenu } from \"./ContextMenu\";\nimport styles from \"./ContextMenu.module.css\";\nimport { LowMenu } from \"./LowMenu\";\nimport { MenuItem } from \"./interface\";\n\nexport interface ContentMenuHandlerContextProps {\n menuItems: MenuItem[];\n}\nexport const ContentMenuHandlerContext = createContext<ContentMenuHandlerContextProps | null>(null);\n\nexport interface ContextMenuHandlerProps extends React.HTMLAttributes<HTMLDivElement> {\n children: React.ReactNode;\n menuItems: MenuItem[];\n showLowMenu?: boolean;\n}\n\nfunction isDivider(label: string | JSX.Element): boolean {\n return typeof label !== \"string\" && label.type === \"hr\";\n}\n\nexport const ContextMenuHandler = ({\n children,\n menuItems,\n showLowMenu = false,\n ...rest\n}: ContextMenuHandlerProps): JSX.Element => {\n // Check for higher content menu\n const higherContext = useContext(ContentMenuHandlerContext);\n const thisMenuItems = useMemo(\n () => [\n ...(higherContext !== null\n ? [\n ...higherContext.menuItems,\n ...[\n higherContext.menuItems.length > 0 &&\n !isDivider(higherContext.menuItems[higherContext.menuItems.length - 1].label) &&\n menuItems.length > 0 &&\n !isDivider(menuItems[0].label)\n ? {\n label: (\n <hr style={{ flexGrow: 1, cursor: \"none\", margin: \"0\", padding: \"0\" }} />\n ),\n }\n : null,\n ].filter((item) => item !== null),\n ]\n : []),\n ...menuItems,\n ],\n [higherContext, menuItems],\n );\n\n // Menu resources\n const divHandlderRef = useRef<HTMLDivElement | null>(null);\n const menuRef = useRef<HTMLDivElement | null>(null);\n const [menuXPos, setMenuXPos] = useState<number>(0);\n const [menuYPos, setMenuYPos] = useState<number>(0);\n const [menuVisible, setMenuVisible] = useState<boolean>(false);\n const [menuInDom, setMenuInDom] = useState<boolean>(false);\n const [mouseOverHandlerDiv, setMouseOverHandlerDiv] = useState<boolean>(false);\n const [mouseOverMenu, setMouseOverMenu] = useState<boolean>(false);\n\n // Get holder position\n const divHandlerPos = divHandlderRef ? divHandlderRef.current?.getBoundingClientRect() : null;\n\n // Handle click off the menu\n const handleClick = useCallback((e: globalThis.MouseEvent) => {\n if (\n menuRef.current &&\n ((e.target instanceof Element && !menuRef.current?.contains(e.target)) ||\n !(e.target instanceof Element))\n ) {\n setMenuVisible(false);\n }\n }, []);\n\n // Update the document click handler\n useEffect(() => {\n if (menuVisible) document.addEventListener(\"mousedown\", handleClick);\n return () => {\n document.removeEventListener(\"mousedown\", handleClick);\n };\n }, [handleClick, menuVisible]);\n\n const removeController = useRef<AbortController>(new AbortController());\n useEffect(() => {\n if (!mouseOverMenu && !menuVisible && !mouseOverHandlerDiv) {\n removeController.current.abort();\n removeController.current = new AbortController();\n setTimeout(() => {\n if (!removeController.current.signal.aborted) setMenuInDom(false);\n }, 300);\n }\n }, [mouseOverHandlerDiv, menuVisible, mouseOverMenu]);\n\n return (\n <ContentMenuHandlerContext.Provider\n value={{\n menuItems: thisMenuItems,\n }}\n >\n <div\n ref={divHandlderRef}\n {...rest}\n className={[styles.contextMenuHandler, rest.className].join(\" \")}\n onContextMenu={async (e) => {\n if (!showLowMenu) {\n setMenuInDom(true);\n e.preventDefault();\n e.stopPropagation();\n setTimeout(() => {\n removeController.current.abort();\n setMenuVisible(true);\n setMenuXPos(e.pageX);\n setMenuYPos(e.pageY);\n }, 1);\n }\n }}\n onMouseEnter={async (e) => {\n if (showLowMenu) {\n setMenuInDom(true);\n setMouseOverHandlerDiv(false);\n setTimeout(() => {\n removeController.current.abort();\n setMouseOverHandlerDiv(true);\n }, 1);\n }\n rest.onMouseEnter?.(e);\n }}\n onMouseLeave={async (e) => {\n if (showLowMenu) {\n removeController.current.abort();\n removeController.current = new AbortController();\n setMouseOverHandlerDiv(false);\n }\n rest.onMouseLeave?.(e);\n }}\n >\n {children}\n </div>\n {menuInDom &&\n divHandlerPos &&\n createPortal(\n <div\n className={styles.anchor}\n onMouseEnter={() => {\n removeController.current.abort();\n setMouseOverMenu(true);\n }}\n onMouseLeave={() => {\n removeController.current.abort();\n removeController.current = new AbortController();\n setMouseOverMenu(false);\n }}\n >\n {showLowMenu ? (\n <LowMenu\n visible={mouseOverHandlerDiv}\n entries={menuItems}\n xPos={divHandlerPos.left}\n yPos={divHandlerPos.bottom}\n maxWidth={divHandlerPos.width}\n />\n ) : (\n <ContextMenu\n visible={menuVisible}\n ref={menuRef}\n entries={thisMenuItems}\n xPos={menuXPos}\n yPos={menuYPos}\n toClose={() => {\n setMenuVisible(false);\n setMouseOverMenu(false);\n }}\n />\n )}\n </div>,\n document.body,\n )}\n </ContentMenuHandlerContext.Provider>\n );\n};\n\nContextMenuHandler.displayName = \"ContextMenuHandler\";\n","import styles from \"./LowMenu.module.css\";\nimport { LowMenuButton } from \"./LowMenuButton\";\nimport { MenuItem } from \"./interface\";\n\ninterface LowMenuProps {\n entries: MenuItem[];\n visible: boolean;\n xPos: number;\n yPos: number;\n maxWidth: number;\n}\n\nexport const LowMenu = ({ entries, visible, xPos, yPos, maxWidth }: LowMenuProps): JSX.Element => {\n return (\n <div\n className={[styles.lowMenu, visible ? styles.visible : styles.hidden].join(\" \")}\n aria-label=\"Low context menu\"\n style={{\n left: `${xPos}px`,\n top: `${yPos}px`,\n maxWidth: `calc(${maxWidth}px)`,\n width: `calc(${maxWidth}px - 4px)`,\n }}\n >\n <div className={styles.lowMenuButtonHolder}>\n {entries.map((e, i) => (\n <LowMenuButton\n key={i}\n entry={e}\n />\n ))}\n </div>\n </div>\n );\n};\n\nLowMenu.displayName = \"LowMenu\";\n",".lowMenu {\n z-index: 2;\n position: absolute;\n margin: 0px;\n transition: opacity 0.3s linear;\n}\n\n.lowMenuButtonHolder {\n border: 2px solid rgb(17, 20, 24);\n border-top-right-radius: 4px;\n border-bottom-left-radius: 4px;\n border-bottom-right-radius: 4px;\n background-color: rgb(17, 20, 24);\n box-shadow: 2px 2px 2px rgb(64, 64, 64, 0.5);\n display: flex;\n flex-wrap: wrap;\n flex-direction: row;\n gap: 2px;\n row-gap: 2px;\n width: fit-content;\n}\n\n.lowMenu.hidden {\n opacity: 0;\n}\n\n.lowMenu.visible,\n.lowMenu:hover {\n opacity: 1;\n}\n\n.lowMenuItem {\n background-color: rgb(251, 253, 246);\n border: 0;\n color: rgb(17, 20, 24);\n cursor: pointer;\n padding: 0 4px;\n position: relative;\n display: flex;\n flex-direction: row;\n justify-content: space-between;\n white-space: nowrap;\n}\n\n.lowMenuItem.disabled {\n background-color: rgba(200, 200, 200);\n cursor: not-allowed;\n}\n\n.lowMenuItem:not(.disabled):hover {\n background-color: rgb(251, 233, 230);\n}\n\n.lowMenu-item .caretHolder {\n align-self: flex-end;\n}\n\n.lowMenuItem .caretHolder .subMenu {\n z-index: 1;\n position: relative;\n}\n","import { useState } from \"react\";\nimport styles from \"./LowMenu.module.css\";\nimport { LowSubMenu } from \"./LowSubMenu\";\nimport { MenuItem } from \"./interface\";\n\ninterface LowMenuButtonProps {\n entry: MenuItem;\n}\nexport const LowMenuButton = ({ entry }: LowMenuButtonProps) => {\n const [target, setTarget] = useState<Range | null>(null);\n return (\n <div\n className={[styles.lowMenuItem, entry.disabled ? styles.disabled : \"\"]\n .filter((c) => c !== \"\")\n .join(\" \")}\n aria-label={typeof entry.label === \"string\" ? entry.label : undefined}\n aria-disabled={entry.disabled}\n onMouseEnter={() => {\n const sel = window.getSelection();\n const target = sel && sel.rangeCount > 0 ? sel.getRangeAt(0) : null;\n setTarget(target);\n }}\n onMouseLeave={() => {\n setTarget(null);\n }}\n onClick={(e) => {\n e.preventDefault();\n e.stopPropagation();\n if (!entry.disabled) entry.action?.(target);\n }}\n >\n <span>{entry.label}</span>\n {entry.group && <LowSubMenu entry={entry} />}\n </div>\n );\n};\n\nLowMenuButton.displayName = \"LowMenuButton\";\n","import { useState } from \"react\";\nimport { ContextMenu } from \"./ContextMenu\";\nimport styles from \"./LowMenu.module.css\";\nimport { MenuItem } from \"./interface\";\n\nexport interface LowSubMenuProps {\n entry: MenuItem;\n lowMenu?: boolean;\n}\n\nexport const LowSubMenu = ({ entry }: LowSubMenuProps): JSX.Element => {\n const [visible, setVisible] = useState<boolean>(false);\n if (!entry.group || entry.group.length === 0) return <></>;\n return (\n <span\n aria-label={`Sub menu for ${entry.label}`}\n className={styles.caretHolder}\n onMouseEnter={() => {\n setVisible(true);\n }}\n onMouseLeave={() => {\n setVisible(false);\n }}\n >\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"16\"\n height=\"16\"\n fill=\"currentColor\"\n viewBox=\"0 0 16 16\"\n >\n <path 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\" />\n </svg>\n <div className={styles.subMenu}>\n {visible && (\n <ContextMenu\n visible={visible}\n entries={entry.group}\n xPos={14}\n yPos={entry.group.length * -21 - 8}\n toClose={() => setVisible(false)}\n />\n )}\n </div>\n </span>\n );\n};\n\nLowSubMenu.displayName = \"LowSubMenu\";\n","import { ReactNode, useCallback, useContext, useEffect, useMemo, useRef, useState } from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { chkPosition } from \"../functions/chkPosition\";\nimport styles from \"./ContextWindow.module.css\";\nimport { ContextWindowStackContext } from \"./ContextWindowStack\";\n\ninterface ContextWindowProps extends React.HTMLAttributes<HTMLDivElement> {\n id: string;\n visible: boolean;\n onOpen?: () => void;\n onClose?: () => void;\n title: string;\n titleElement?: ReactNode;\n style?: React.CSSProperties;\n children: React.ReactNode;\n}\n\nexport const ContextWindow = ({\n id,\n visible,\n title,\n titleElement,\n children,\n onOpen,\n onClose,\n ...rest\n}: ContextWindowProps): JSX.Element => {\n const windowStack = useContext(ContextWindowStackContext);\n const windowId = useRef<number | null>(null);\n const divRef = useRef<HTMLDivElement | null>(null);\n const windowRef = useRef<HTMLDivElement | null>(null);\n const [windowInDOM, setWindowInDOM] = useState<boolean>(false);\n const [windowVisible, setWindowVisible] = useState<boolean>(false);\n const zIndex = useMemo(() => {\n return windowStack?.currentWindows.find((w) => w.windowId === windowId.current)?.zIndex ?? 1;\n }, [windowStack?.currentWindows]);\n\n // Position\n const windowPos = useRef<{ x: number; y: number }>({ x: 0, y: 0 });\n const [moving, setMoving] = useState<boolean>(false);\n\n const move = useCallback((x: number, y: number) => {\n if (windowRef.current && windowPos.current) {\n const window = windowRef.current;\n const pos = windowPos.current;\n pos.x += x;\n pos.y += y;\n window.style.transform = `translate(${pos.x}px, ${pos.y}px)`;\n }\n }, []);\n\n const checkPosition = useCallback(() => {\n const chkPos = chkPosition(windowRef);\n move(chkPos.translateX, chkPos.translateY);\n }, [move]);\n\n const mouseMove = useCallback(\n (e: MouseEvent) => {\n e.preventDefault();\n e.stopPropagation();\n move(e.movementX, e.movementY);\n },\n [move],\n );\n\n const mouseUp = useCallback(\n (e: MouseEvent) => {\n e.preventDefault();\n e.stopPropagation();\n setMoving(false);\n checkPosition();\n document.removeEventListener(\"mousemove\", mouseMove);\n document.removeEventListener(\"mouseup\", mouseUp);\n window.removeEventListener(\"resize\", checkPosition);\n if (e.target && (e.target instanceof HTMLElement || e.target instanceof SVGElement))\n e.target.style.userSelect = \"auto\";\n },\n [checkPosition, mouseMove],\n );\n\n // Update visibility\n useEffect(() => {\n if (windowStack) {\n // Visible set, but not in DOM\n if (visible && !windowInDOM) {\n setWindowInDOM(true);\n } else if (visible && windowInDOM && !windowVisible) {\n if (!windowId.current) {\n const maxWindowId = Math.max(0, ...windowStack.currentWindows.map((w) => w.windowId));\n windowId.current = maxWindowId + 1;\n }\n windowStack.pushToTop(windowId.current);\n setWindowVisible(visible);\n onOpen?.();\n // Get starting position\n if (divRef.current && windowRef.current) {\n const parentPos = divRef.current.getBoundingClientRect();\n const pos = windowRef.current.getBoundingClientRect();\n const windowHeight = pos.bottom - pos.top;\n windowRef.current.style.left = `${parentPos.left}px`;\n windowRef.current.style.top = `${\n parentPos.bottom + windowHeight < window.innerHeight\n ? parentPos.bottom\n : Math.max(0, parentPos.top - windowHeight)\n }px`;\n windowRef.current.style.transform = \"\";\n windowPos.current = { x: 0, y: 0 };\n }\n checkPosition();\n } else if (windowId.current && !visible && windowVisible) {\n setWindowVisible(false);\n } else if (windowId.current && !visible && windowInDOM) {\n setWindowInDOM(false);\n }\n }\n }, [checkPosition, onOpen, visible, windowInDOM, windowStack, windowVisible]);\n\n return (\n <div\n className={styles.contextWindowAnchor}\n ref={divRef}\n >\n {!windowStack && (\n <div {...rest}>\n {process.env.NODE_ENV !== \"production\" && (\n <div\n style={{ backgroundColor: \"red\", color: \"white\", padding: \"8px\", fontSize: \"48px\" }}\n >\n WARNING: No ContextWindowStack found\n </div>\n )}\n {children}\n </div>\n )}\n {windowStack &&\n windowInDOM &&\n createPortal(\n <div\n {...rest}\n ref={windowRef}\n id={id}\n className={[styles.contextWindow, rest.className].filter((c) => c).join(\" \")}\n style={{\n ...rest.style,\n opacity: moving ? 0.8 : windowVisible ? 1 : 0,\n visibility: windowVisible ? \"visible\" : \"hidden\",\n zIndex: zIndex ?? 1,\n minHeight: rest.style?.minHeight ?? \"150px\",\n minWidth: rest.style?.minWidth ?? \"200px\",\n maxHeight: rest.style?.maxHeight ?? \"1000px\",\n maxWidth: rest.style?.maxWidth ?? \"1000px\",\n }}\n onClickCapture={(e) => {\n if (windowId.current) windowStack.pushToTop(windowId.current);\n rest.onClickCapture?.(e);\n }}\n >\n <div\n className={[styles.contextWindowTitle, moving ? styles.moving : \"\"]\n .filter((c) => c !== \"\")\n .join(\" \")}\n onMouseDown={(e: React.MouseEvent) => {\n if (e.target && (e.target instanceof HTMLElement || e.target instanceof SVGElement))\n e.target.style.userSelect = \"none\";\n setMoving(true);\n if (windowId.current) windowStack.pushToTop(windowId.current);\n document.addEventListener(\"mouseup\", mouseUp);\n document.addEventListener(\"mousemove\", mouseMove);\n window.addEventListener(\"resize\", () => checkPosition());\n }}\n >\n <div\n className={styles.contextWindowTitleText}\n title={title}\n >\n {titleElement ? titleElement : title}\n </div>\n <div\n className={styles.contextWindowTitleClose}\n role=\"button\"\n aria-label=\"Close\"\n onClick={onClose}\n title={`Close ${title && title.trim() !== \"\" ? title : \"window\"}`}\n >\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"16\"\n height=\"16\"\n fill=\"currentColor\"\n viewBox=\"0 0 16 16\"\n >\n <path 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\" />\n </svg>\n </div>\n </div>\n <div className={styles.contextWindowBody}>\n <div>{children}</div>\n </div>\n </div>,\n document.body,\n )}\n </div>\n );\n};\n\nContextWindow.displayName = \"ContextWindow\";\n","import { RefObject } from \"react\";\n\n/**\n * Check that an existing div is inside the viewport\n * @param divRef Check div is inside view port, and return n\n * @returns \\{ translateX, translateY \\} Amount to move on X and Y axis\n */\nexport const chkPosition = (\n divRef: RefObject<HTMLDivElement>,\n): { translateX: number; translateY: number } => {\n if (!divRef.current) {\n return { translateX: 0, translateY: 0 };\n } else {\n const innerBounce = 16;\n const posn = divRef.current.getBoundingClientRect();\n let translateX = 0;\n if (posn.left < innerBounce) {\n translateX = -posn.left + innerBounce;\n } else if (posn.right > window.innerWidth) {\n translateX = Math.max(-posn.left + innerBounce, window.innerWidth - posn.right - innerBounce);\n }\n let translateY = 0;\n if (posn.top < innerBounce) {\n translateY = -posn.top + innerBounce;\n } else if (posn.bottom > window.innerHeight) {\n translateY = Math.max(\n -posn.top + innerBounce,\n window.innerHeight - posn.bottom - innerBounce,\n );\n }\n return { translateX, translateY };\n }\n};\n",".contextWindowAnchor {\n position: relative;\n}\n\n.contextWindow {\n z-index: 2001;\n border: 1px black solid;\n margin: 0;\n padding: 4px;\n background-color: rgb(250, 250, 250);\n box-shadow: 6px 6px 6px rgb(64, 64, 64, 0.5);\n transition: opacity 0.25s linear;\n justify-content: flex-start;\n position: absolute;\n border-top-left-radius: 8px;\n border-top-right-radius: 8px;\n border-bottom-left-radius: 8px;\n resize: both;\n overflow: auto;\n max-height: 95vh;\n max-width: 95vw;\n}\n\n.contextWindowTitle {\n border-bottom: 1px black dashed;\n box-sizing: unset;\n padding-bottom: 4px;\n margin: 0 4px 3px 4px;\n height: 24px;\n line-height: 24px;\n max-height: 24px;\n cursor: grab;\n font-size: 18px;\n font-weight: 600;\n display: flex;\n flex-direction: row;\n align-items: center;\n width: calc(100% - 8px);\n}\n\n.contextWindowTitle.moving {\n cursor: grabbing;\n}\n\n.contextWindowTitleText {\n display: inline-block;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n width: calc(100% - 16px);\n}\n\n.contextWindowTitleClose {\n display: flex;\n color: black;\n height: 16px;\n width: 16px;\n border-radius: 3px;\n margin-left: 2px;\n cursor: pointer;\n line-height: 16px;\n}\n\n.contextWindowTitleClose:hover {\n background-color: black;\n color: white;\n}\n\n.contextWindowBody {\n overflow: auto;\n padding-bottom: 8px;\n margin-right: 4px;\n height: calc(100% - 40px);\n}\n\n.contextWindowBody::-webkit-scrollbar {\n width: 8px;\n height: 8px;\n}\n\n.contextWindowBody::-webkit-scrollbar-track {\n background: white;\n border-radius: 8px;\n}\n\n.contextWindowBody::-webkit-scrollbar-thumb {\n background: lightgrey;\n border: none;\n border-radius: 8px;\n}\n\n.contextWindowBody::-webkit-scrollbar-thumb:hover {\n background: grey;\n}\n","import { createContext, useState } from \"react\";\n\nexport interface ContextWindowZIndex {\n windowId: number;\n zIndex: number;\n}\n\nexport interface ContextWindowStackContextProps {\n currentWindows: ContextWindowZIndex[];\n pushToTop: (ret: number) => void;\n}\n\nexport const ContextWindowStackContext = createContext<ContextWindowStackContextProps | null>(null);\n\ninterface ContextWindowStackProps {\n id?: string;\n minZIndex?: number;\n children?: JSX.Element[] | JSX.Element;\n}\n\nconst pushToTop = (\n windowId: number,\n minZIndex: number,\n windowList: ContextWindowZIndex[],\n setWindowList: (ret: ContextWindowZIndex[]) => void,\n) => {\n const otherWindows = windowList\n .filter((w) => w.windowId !== windowId)\n .map((w, i) => ({ windowId: w.windowId, zIndex: minZIndex + i }));\n setWindowList([...otherWindows, { windowId, zIndex: minZIndex + otherWindows.length }]);\n};\n\nexport const ContextWindowStack = ({\n minZIndex = 1000,\n children,\n}: ContextWindowStackProps): JSX.Element => {\n const [currentWindows, setCurrentWindows] = useState<ContextWindowZIndex[]>([]);\n\n return (\n <ContextWindowStackContext.Provider\n value={{\n currentWindows: currentWindows.map((w) => ({\n windowId: w.windowId,\n zIndex: minZIndex + w.zIndex,\n })),\n pushToTop: (ret: number) => pushToTop(ret, minZIndex, currentWindows, setCurrentWindows),\n }}\n >\n {children}\n </ContextWindowStackContext.Provider>\n );\n};\n\nContextWindowStack.displayName = \"ContextWindowStack\";\n"],"names":[],"version":3,"file":"main.js.map"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@asup/context-menu",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"description": "REACT Typescript Context menu component",
|
|
5
5
|
"author": "Paul Thomas <@PaulDThomas>",
|
|
6
6
|
"private": false,
|
|
@@ -39,9 +39,9 @@
|
|
|
39
39
|
"scripts": {
|
|
40
40
|
"prepare": "husky",
|
|
41
41
|
"start": "rmdir /q/s .\\.parcel-cache && parcel demo/index.html --dist-dir demo/dist",
|
|
42
|
-
"test": "jest --
|
|
42
|
+
"test": "jest --collectCoverage=true",
|
|
43
43
|
"test-watch": "jest --watch --collectCoverage=true --maxWorkers=4",
|
|
44
|
-
"
|
|
44
|
+
"eslint": "eslint \"src/**/*.{js,jsx,ts,tsx}\" \"demo/**/*.{js,jsx,ts,tsx}\"",
|
|
45
45
|
"build": "rmdir /q/s .\\.parcel-cache && parcel build src/main.ts"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
@@ -54,6 +54,9 @@
|
|
|
54
54
|
"react-dom": "^18.0.0"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
|
+
"@eslint/compat": "^1.3.0",
|
|
58
|
+
"@eslint/eslintrc": "^3.3.1",
|
|
59
|
+
"@eslint/js": "^9.28.0",
|
|
57
60
|
"@parcel/packager-raw-url": "^2.7.0",
|
|
58
61
|
"@parcel/packager-ts": "^2.8.3",
|
|
59
62
|
"@parcel/transformer-typescript-types": "^2.8.0",
|
|
@@ -65,27 +68,30 @@
|
|
|
65
68
|
"@types/node": "^20.11.19",
|
|
66
69
|
"@types/react": "^18.0.25",
|
|
67
70
|
"@types/react-dom": "^18.0.8",
|
|
68
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
69
|
-
"@typescript-eslint/parser": "^
|
|
70
|
-
"eslint": "^
|
|
71
|
-
"eslint-config-prettier": "^
|
|
72
|
-
"eslint-config-react-app": "^7.0.1",
|
|
71
|
+
"@typescript-eslint/eslint-plugin": "^8.34.0",
|
|
72
|
+
"@typescript-eslint/parser": "^8.34.0",
|
|
73
|
+
"eslint": "^9.28.0",
|
|
74
|
+
"eslint-config-prettier": "^10.1.5",
|
|
73
75
|
"eslint-plugin-jest": "^28.6.0",
|
|
74
76
|
"eslint-plugin-prettier": "^5.1.3",
|
|
75
77
|
"eslint-plugin-react": "^7.31.10",
|
|
76
|
-
"eslint-plugin-react-hooks": "^
|
|
78
|
+
"eslint-plugin-react-hooks": "^5.2.0",
|
|
79
|
+
"eslint-plugin-unused-imports": "^4.1.4",
|
|
77
80
|
"husky": "^9.0.11",
|
|
78
81
|
"jest": "^29.2.2",
|
|
79
82
|
"jest-environment-jsdom": "^29.3.1",
|
|
80
83
|
"jest-watch-typeahead": "^2.2.2",
|
|
81
|
-
"lint-staged": "^
|
|
84
|
+
"lint-staged": "^16.1.0",
|
|
82
85
|
"parcel": "^2.7.0",
|
|
83
86
|
"prettier": "^3.2.5",
|
|
87
|
+
"prettier-plugin-organize-imports": "^4.1.0",
|
|
84
88
|
"process": "^0.11.10",
|
|
85
89
|
"ts-jest": "^29.0.3",
|
|
86
90
|
"ts-jest-mock-import-meta": "^1.2.0",
|
|
87
91
|
"ts-node": "^10.9.1",
|
|
88
|
-
"typescript": "^5.0.4"
|
|
92
|
+
"typescript": "^5.0.4",
|
|
93
|
+
"typescript-eslint": "^8.34.0",
|
|
94
|
+
"typescript-plugin-css-modules": "^5.1.0"
|
|
89
95
|
},
|
|
90
96
|
"@parcel/transformer-css": {
|
|
91
97
|
"cssModules": {
|