@asup/context-menu 1.1.4 → 1.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cjs/main.js CHANGED
@@ -364,7 +364,7 @@ var $46fb0088a1bbb6d8$export$1af8984c69ba1b24 = function(param) {
364
364
  ]);
365
365
  var _style_minHeight, _style_minWidth, _style_maxHeight, _style_maxWidth;
366
366
  return /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)("div", {
367
- className: "contentwindow-anchor",
367
+ className: "contextwindow-anchor",
368
368
  ref: divRef,
369
369
  children: windowStack && /*#__PURE__*/ (0, $gTuX4$reactdom.createPortal)(/*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsxs)("div", {
370
370
  id: id,
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AIUO,IAAM,4CAAU;QAAG,gBAAA,SAAS,eAAA,QAAQ,gBAAA;IACzC,IAA8B,2DAAA,CAAA,GAAA,qBAAO,EAAW,YAAzC,UAAuB,cAAd,aAAc;IAE9B,qBACE,iCAAC;QACC,WAAU;QACV,cAAc;YACZ,WAAW;QACb;QACA,cAAc;YACZ,WAAW;QACb;;0BAEA,gCAAC;gBACC,OAAM;gBACN,OAAM;gBACN,QAAO;gBACP,MAAK;gBACL,SAAQ;0BAER,cAAA,gCAAC;oBAAK,GAAE;;;0BAEV,gCAAC;gBAAI,WAAU;0BACb,cAAA,gCAAC,CAAA,GAAA,yCAAU;oBACT,SAAS;oBACT,SAAS;oBACT,QAAQ;oBACR,MAAM;oBACN,MAAM;oBACN,SAAS;;;;;AAKnB;AAEA,0CAAQ,cAAc;;;ADjCf,IAAM,0DAAc,CAAA,GAAA,sCAAI,EAAE,WAC/B,gBAAoD;QAAjD,gBAAA,SAAS,gBAAA,SAAS,eAAA,QAAQ,aAAA,MAAM,aAAA,MAAM,gBAAA;IACvC,0CAAY,cAAc;IAE1B,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gBAAgB,YAAY;gBACxC,QAAQ,mBAAA,oBAAA,SAAU;gBAClB,WAAW,CAAA,mBAAA,kBAAA,mBAAA,KAAA,IAAA,MAAO,uBAAP,8BAAA,mBAAoB;gBAC/B,UAAU,CAAA,kBAAA,kBAAA,mBAAA,KAAA,IAAA,MAAO,sBAAP,6BAAA,kBAAmB;gBAC7B,WAAW,CAAA,mBAAA,kBAAA,mBAAA,KAAA,IAAA,MAAO,uBAAP,8BAAA,mBAAoB;gBAC/B,UAAU,CAAA,kBAAA,kBAAA,mBAAA,KAAA,IAAA,MAAO,sBAAP,6BAAA,kBAAmB;;YAE/B,gBAAgB;gBACd,YAAY,SAAS,WAAW,YAAY,UAAU,SAAS;YACjE;YACA,KAAK;;8BAEL,iCAAC;oBACC,WAAW,AAAC,uBAA6C,OAAvB,SAAS,WAAW;oBACtD,aAAa,SAAC;wBACZ,IAAI,EAAE,UAAW,CAAA,EAAE,kBAAkB,eAAe,EAAE,kBAAkB,UAAS,GAC/E,EAAE,OAAO,MAAM,aAAa;wBAC9B,UAAU;wBACV,YAAY,SAAS,WAAW,YAAY,UAAU,SAAS;wBAC/D,SAAS,iBAAiB,WAAW;wBACrC,SAAS,iBAAiB,aAAa;wBACvC,OAAO,iBAAiB,UAAU;mCAAM;;oBAC1C;;sCAEA,gCAAC;4BAAK,WAAU;sCAA4B;;sCAC5C,gCAAC;4BAAK,WAAU;sCACd,cAAA,gCAAC;gCACC,OAAM;gCACN,OAAM;gCACN,QAAO;gCACP,MAAK;gCACL,SAAQ;gCACR,SAAS;gCACT,cAAW;0CAEX,cAAA,gCAAC;oCAAK,GAAE;;;;;;8BAId,gCAAC;oBAAI,WAAU;8BACb,cAAA,gCAAC;kCAAK;;;;YAGV,SAAS;;AAInB;AAEA,0CAAc,cAAc;;","sources":["src/main.ts","src/components/index.ts","src/components/ContextMenuHandler.tsx","src/components/ContextMenu.tsx","src/components/SubMenu.tsx","src/components/ContextWindow.tsx","src/components/ContextWindowStack.tsx","src/functions/chkPosition.ts"],"sourcesContent":["export * from './components';\n","import { ContextMenuHandler } from './ContextMenuHandler';\nimport { ContextWindow } from './ContextWindow';\nimport { ContextWindowStack } from './ContextWindowStack';\nimport { iMenuItem } from './interface';\n\nexport { ContextMenuHandler, ContextWindow, ContextWindowStack };\nexport type { iMenuItem };\n","import { MouseEvent, useCallback, useEffect, useRef, useState } from 'react';\nimport { createPortal } from 'react-dom';\nimport { ContextMenu } from './ContextMenu';\nimport { iMenuItem } from './interface';\nimport './ContextMenu.css';\n\nexport const ContextMenuHandler = ({\n children,\n menuItems,\n style = {\n height: 'fit-content',\n width: 'fit-content',\n },\n}: {\n children: JSX.Element[] | JSX.Element;\n menuItems: iMenuItem[];\n style?: React.CSSProperties;\n}): JSX.Element => {\n // Menu resources\n const divRef = 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 [target, setTarget] = useState<Range | null>(null);\n\n // Show menu when context is requested\n const showMenu = (e: MouseEvent<HTMLDivElement>) => {\n const sel = window.getSelection();\n setTarget(sel && sel.rangeCount > 0 ? sel.getRangeAt(0) : null);\n e.preventDefault();\n e.stopPropagation();\n setMenuVisible(true);\n setMenuXPos(e.pageX);\n setMenuYPos(e.pageY);\n };\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 return (\n <>\n <div\n onContextMenu={showMenu}\n className='context-menu-handler'\n style={style}\n >\n {children}\n </div>\n {menuVisible &&\n createPortal(\n <div\n style={{ position: 'absolute', top: 0, left: 0 }}\n ref={divRef}\n >\n <ContextMenu\n visible={true}\n ref={menuRef}\n entries={menuItems}\n xPos={menuXPos}\n yPos={menuYPos}\n target={target}\n toClose={() => setMenuVisible(false)}\n />\n </div>,\n document.body,\n )}\n </>\n );\n};\n\nContextMenuHandler.displayName = 'ContextMenuHandler';\n","import React from 'react';\nimport { iMenuItem } from './interface';\nimport { SubMenu } from './SubMenu';\n\nexport interface contextMenuProps {\n visible: boolean;\n entries: iMenuItem[];\n target: Range | null;\n xPos: number;\n yPos: number;\n toClose: () => void;\n}\n\nexport const ContextMenu = React.forwardRef<HTMLDivElement, contextMenuProps>(\n ({ visible, entries, target, xPos, yPos, toClose }, ref): JSX.Element => {\n ContextMenu.displayName = 'ContextMenu';\n\n return (\n <div\n ref={ref}\n className={`context-menu${visible ? ' visible' : ''}`}\n style={{\n top: `${yPos}px`,\n left: `${xPos}px`,\n }}\n onContextMenuCapture={(e) => {\n e.preventDefault();\n e.stopPropagation();\n }}\n >\n {entries.map((e, i) => (\n <div\n key={i}\n className={`context-menu-item${e.disabled ? ' disabled' : ''}`}\n onClick={(ev) => {\n ev.preventDefault();\n ev.stopPropagation();\n e.action && !e.disabled && e.action(target);\n !e.disabled && toClose();\n }}\n >\n <span className='context-menu-item-label'>{e.label}</span>\n {e.group && (\n <SubMenu\n toClose={toClose}\n entries={e.group}\n target={target}\n />\n )}\n </div>\n ))}\n </div>\n );\n },\n);\n\nContextMenu.displayName = 'ContextMenu';\n","import { useState } from 'react';\nimport { ContextMenu } from './ContextMenu';\nimport { iMenuItem } from './interface';\n\nexport interface subMenuProps {\n entries: iMenuItem[];\n target: Range | null;\n toClose: () => void;\n}\n\nexport const SubMenu = ({ entries, target, toClose }: subMenuProps): JSX.Element => {\n const [visible, setVisible] = useState<boolean>(false);\n\n return (\n <span\n className='caret-holder'\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='sub-menu'>\n <ContextMenu\n visible={visible}\n entries={entries}\n target={target}\n xPos={14}\n yPos={-21}\n toClose={toClose}\n />\n </div>\n </span>\n );\n};\n\nSubMenu.displayName = 'SubMenu';\n","import React, { useCallback, useContext, useEffect, useMemo, useRef, useState } from 'react';\nimport { createPortal } from 'react-dom';\nimport './ContextWindow.css';\nimport { ContextWindowStackContext } from './ContextWindowStack';\nimport { chkPosition } from '../functions/chkPosition';\n\ninterface ContextWindowProps {\n id: string;\n visible: boolean;\n onOpen?: () => void;\n onClose?: () => void;\n title: string;\n style?: React.CSSProperties;\n children: JSX.Element[] | JSX.Element | string;\n}\n\nexport const ContextWindow = ({\n id,\n visible,\n title,\n style,\n children,\n onOpen,\n onClose,\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 [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 if (visible && !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 } else if (windowId.current && !visible && windowVisible) {\n setWindowVisible(false);\n }\n }\n }, [onOpen, visible, windowStack, windowVisible]);\n\n return (\n <div\n className='contentwindow-anchor'\n ref={divRef}\n >\n {windowStack &&\n createPortal(\n <div\n id={id}\n className='contextwindow'\n style={{\n ...style,\n opacity: moving ? 0.8 : windowVisible ? 1 : 0,\n visibility: windowVisible ? 'visible' : 'hidden',\n zIndex: zIndex ?? 1,\n minHeight: style?.minHeight ?? '150px',\n minWidth: style?.minWidth ?? '200px',\n maxHeight: style?.maxHeight ?? '1000px',\n maxWidth: style?.maxWidth ?? '1000px',\n }}\n onClickCapture={() => {\n windowId && windowId.current && windowStack.pushToTop(windowId.current);\n }}\n ref={windowRef}\n >\n <div\n className={`contextwindow-title ${moving ? 'moving' : ''}`}\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 <span className='contextwindow-title-text'>{title}</span>\n <span className='contextwindow-title-close'>\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 onClick={onClose}\n aria-label='Close window'\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 </span>\n </div>\n <div className='contextwindow-body'>\n <div>{children}</div>\n </div>\n </div>,\n document.body,\n )}\n </div>\n );\n};\n\nContextWindow.displayName = 'ContextWindow';\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","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"],"names":[],"version":3,"file":"main.js.map"}
1
+ {"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AIUO,IAAM,4CAAU;QAAG,gBAAA,SAAS,eAAA,QAAQ,gBAAA;IACzC,IAA8B,2DAAA,CAAA,GAAA,qBAAO,EAAW,YAAzC,UAAuB,cAAd,aAAc;IAE9B,qBACE,iCAAC;QACC,WAAU;QACV,cAAc;YACZ,WAAW;QACb;QAC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BACvC,OAAO,iBAAiB,UAAU;mCAAM;;oBAC1C;;sCAEA,gCAAC;4BAAK,WAAU;sCAA4B;;sCAC5C,gCAAC;4BAAK,WAAU;sCACd,cAAA,gCAAC;gCACC,OAAM;gCACN,OAAM;gCACN,QAAO;gCACP,MAAK;gCACL,SAAQ;gCACR,SAAS;gCACT,cAAW;0CAEX,cAAA,gCAAC;oCAAK,GAAE;;;;;;8BAId,gCAAC;oBAAI,WAAU;8BACb,cAAA,gCAAC;kCAAK;;;;YAGV,SAAS;;AAInB;AAEA,0CAAc,cAAc;;","sources":["src/main.ts","src/components/index.ts","src/components/ContextMenuHandler.tsx","src/components/ContextMenu.tsx","src/components/SubMenu.tsx","src/components/ContextWindow.tsx","src/components/ContextWindowStack.tsx","src/functions/chkPosition.ts"],"sourcesContent":["export * from './components';\n","import { ContextMenuHandler } from './ContextMenuHandler';\nimport { ContextWindow } from './ContextWindow';\nimport { ContextWindowStack } from './ContextWindowStack';\nimport { iMenuItem } from './interface';\n\nexport { ContextMenuHandler, ContextWindow, ContextWindowStack };\nexport type { iMenuItem };\n","import { MouseEvent, useCallback, useEffect, useRef, useState } from 'react';\nimport { createPortal } from 'react-dom';\nimport { ContextMenu } from './ContextMenu';\nimport { iMenuItem } from './interface';\nimport './ContextMenu.css';\n\nexport const ContextMenuHandler = ({\n children,\n menuItems,\n style = {\n height: 'fit-content',\n width: 'fit-content',\n },\n}: {\n children: JSX.Element[] | JSX.Element;\n menuItems: iMenuItem[];\n style?: React.CSSProperties;\n}): JSX.Element => {\n // Menu resources\n const divRef = 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 [target, setTarget] = useState<Range | null>(null);\n\n // Show menu when context is requested\n const showMenu = (e: MouseEvent<HTMLDivElement>) => {\n const sel = window.getSelection();\n setTarget(sel && sel.rangeCount > 0 ? sel.getRangeAt(0) : null);\n e.preventDefault();\n e.stopPropagation();\n setMenuVisible(true);\n setMenuXPos(e.pageX);\n setMenuYPos(e.pageY);\n };\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 return (\n <>\n <div\n onContextMenu={showMenu}\n className='context-menu-handler'\n style={style}\n >\n {children}\n </div>\n {menuVisible &&\n createPortal(\n <div\n style={{ position: 'absolute', top: 0, left: 0 }}\n ref={divRef}\n >\n <ContextMenu\n visible={true}\n ref={menuRef}\n entries={menuItems}\n xPos={menuXPos}\n yPos={menuYPos}\n target={target}\n toClose={() => setMenuVisible(false)}\n />\n </div>,\n document.body,\n )}\n </>\n );\n};\n\nContextMenuHandler.displayName = 'ContextMenuHandler';\n","import React from 'react';\nimport { iMenuItem } from './interface';\nimport { SubMenu } from './SubMenu';\n\nexport interface contextMenuProps {\n visible: boolean;\n entries: iMenuItem[];\n target: Range | null;\n xPos: number;\n yPos: number;\n toClose: () => void;\n}\n\nexport const ContextMenu = React.forwardRef<HTMLDivElement, contextMenuProps>(\n ({ visible, entries, target, xPos, yPos, toClose }, ref): JSX.Element => {\n ContextMenu.displayName = 'ContextMenu';\n\n return (\n <div\n ref={ref}\n className={`context-menu${visible ? ' visible' : ''}`}\n style={{\n top: `${yPos}px`,\n left: `${xPos}px`,\n }}\n onContextMenuCapture={(e) => {\n e.preventDefault();\n e.stopPropagation();\n }}\n >\n {entries.map((e, i) => (\n <div\n key={i}\n className={`context-menu-item${e.disabled ? ' disabled' : ''}`}\n onClick={(ev) => {\n ev.preventDefault();\n ev.stopPropagation();\n e.action && !e.disabled && e.action(target);\n !e.disabled && toClose();\n }}\n >\n <span className='context-menu-item-label'>{e.label}</span>\n {e.group && (\n <SubMenu\n toClose={toClose}\n entries={e.group}\n target={target}\n />\n )}\n </div>\n ))}\n </div>\n );\n },\n);\n\nContextMenu.displayName = 'ContextMenu';\n","import { useState } from 'react';\nimport { ContextMenu } from './ContextMenu';\nimport { iMenuItem } from './interface';\n\nexport interface subMenuProps {\n entries: iMenuItem[];\n target: Range | null;\n toClose: () => void;\n}\n\nexport const SubMenu = ({ entries, target, toClose }: subMenuProps): JSX.Element => {\n const [visible, setVisible] = useState<boolean>(false);\n\n return (\n <span\n className='caret-holder'\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='sub-menu'>\n <ContextMenu\n visible={visible}\n entries={entries}\n target={target}\n xPos={14}\n yPos={-21}\n toClose={toClose}\n />\n </div>\n </span>\n );\n};\n\nSubMenu.displayName = 'SubMenu';\n","import React, { useCallback, useContext, useEffect, useMemo, useRef, useState } from 'react';\nimport { createPortal } from 'react-dom';\nimport './ContextWindow.css';\nimport { ContextWindowStackContext } from './ContextWindowStack';\nimport { chkPosition } from '../functions/chkPosition';\n\ninterface ContextWindowProps {\n id: string;\n visible: boolean;\n onOpen?: () => void;\n onClose?: () => void;\n title: string;\n style?: React.CSSProperties;\n children: JSX.Element[] | JSX.Element | string;\n}\n\nexport const ContextWindow = ({\n id,\n visible,\n title,\n style,\n children,\n onOpen,\n onClose,\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 [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 if (visible && !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 } else if (windowId.current && !visible && windowVisible) {\n setWindowVisible(false);\n }\n }\n }, [onOpen, visible, windowStack, windowVisible]);\n\n return (\n <div\n className='contextwindow-anchor'\n ref={divRef}\n >\n {windowStack &&\n createPortal(\n <div\n id={id}\n className='contextwindow'\n style={{\n ...style,\n opacity: moving ? 0.8 : windowVisible ? 1 : 0,\n visibility: windowVisible ? 'visible' : 'hidden',\n zIndex: zIndex ?? 1,\n minHeight: style?.minHeight ?? '150px',\n minWidth: style?.minWidth ?? '200px',\n maxHeight: style?.maxHeight ?? '1000px',\n maxWidth: style?.maxWidth ?? '1000px',\n }}\n onClickCapture={() => {\n windowId && windowId.current && windowStack.pushToTop(windowId.current);\n }}\n ref={windowRef}\n >\n <div\n className={`contextwindow-title ${moving ? 'moving' : ''}`}\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 <span className='contextwindow-title-text'>{title}</span>\n <span className='contextwindow-title-close'>\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 onClick={onClose}\n aria-label='Close window'\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 </span>\n </div>\n <div className='contextwindow-body'>\n <div>{children}</div>\n </div>\n </div>,\n document.body,\n )}\n </div>\n );\n};\n\nContextWindow.displayName = 'ContextWindow';\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","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"],"names":[],"version":3,"file":"main.js.map"}
package/dist/main.js CHANGED
@@ -310,7 +310,7 @@ const $b5e8657823def5be$export$1af8984c69ba1b24 = ({ id: id, visible: visible, t
310
310
  ]);
311
311
  var _style_minHeight, _style_minWidth, _style_maxHeight, _style_maxWidth;
312
312
  return /*#__PURE__*/ (0, $duWW8$jsx)("div", {
313
- className: "contentwindow-anchor",
313
+ className: "contextwindow-anchor",
314
314
  ref: divRef,
315
315
  children: windowStack && /*#__PURE__*/ (0, $duWW8$createPortal)(/*#__PURE__*/ (0, $duWW8$jsxs)("div", {
316
316
  id: id,
package/dist/main.js.map CHANGED
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;;;;;;;;;;AIUO,MAAM,4CAAU,CAAC,WAAE,OAAO,UAAE,MAAM,WAAE,OAAO,EAAgB;IAChE,MAAM,CAAC,SAAS,WAAW,GAAG,CAAA,GAAA,eAAO,EAAW;IAEhD,qBACE,iBAAC;QACC,WAAU;QACV,cAAc;YACZ,WAAW;QACb;QACA,cAAc;YACZ,WAAW;QACb;;0BAEA,gBAAC;gBACC,OAAM;gBACN,OAAM;gBACN,QAAO;gBACP,MAAK;gBACL,SAAQ;0BAER,cAAA,gBAAC;oBAAK,GAAE;;;0BAEV,gBAAC;gBAAI,WAAU;0BACb,cAAA,gBAAC,CAAA,GAAA,yCAAU;oBACT,SAAS;oBACT,SAAS;oBACT,QAAQ;oBACR,MAAM;oBACN,MAAM;oBACN,SAAS;;;;;AAKnB;AAEA,0CAAQ,cAAc;;;ADjCf,MAAM,0DAAc,CAAA,GAAA,YAAI,EAAE,WAC/B,CAAC,WAAE,OAAO,WAAE,OAAO,UAAE,MAAM,QAAE,IA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A,oBAAA,SAAU;gBAClB,WAAW,CAAA,mBAAA,kBAAA,mBAAA,KAAA,IAAA,MAAO,uBAAP,8BAAA,mBAAoB;gBAC/B,UAAU,CAAA,kBAAA,kBAAA,mBAAA,KAAA,IAAA,MAAO,sBAAP,6BAAA,kBAAmB;gBAC7B,WAAW,CAAA,mBAAA,kBAAA,mBAAA,KAAA,IAAA,MAAO,uBAAP,8BAAA,mBAAoB;gBAC/B,UAAU,CAAA,kBAAA,kBAAA,mBAAA,KAAA,IAAA,MAAO,sBAAP,6BAAA,kBAAmB;YAC/B;YACA,gBAAgB;gBACd,YAAY,SAAS,WAAW,YAAY,UAAU,SAAS;YACjE;YACA,KAAK;;8BAEL,iBAAC;oBACC,WAAW,CAAC,oBAAoB,EAAE,SAAS,WAAW,GAAG,CAAC;oBAC1D,aAAa,CAAC;wBACZ,IAAI,EAAE,UAAW,CAAA,EAAE,kBAAkB,eAAe,EAAE,kBAAkB,UAAS,GAC/E,EAAE,OAAO,MAAM,aAAa;wBAC9B,UAAU;wBACV,YAAY,SAAS,WAAW,YAAY,UAAU,SAAS;wBAC/D,SAAS,iBAAiB,WAAW;wBACrC,SAAS,iBAAiB,aAAa;wBACvC,OAAO,iBAAiB,UAAU,IAAM;oBAC1C;;sCAEA,gBAAC;4BAAK,WAAU;sCAA4B;;sCAC5C,gBAAC;4BAAK,WAAU;sCACd,cAAA,gBAAC;gCACC,OAAM;gCACN,OAAM;gCACN,QAAO;gCACP,MAAK;gCACL,SAAQ;gCACR,SAAS;gCACT,cAAW;0CAEX,cAAA,gBAAC;oCAAK,GAAE;;;;;;8BAId,gBAAC;oBAAI,WAAU;8BACb,cAAA,gBAAC;kCAAK;;;;YAGV,SAAS;;AAInB;AAEA,0CAAc,cAAc;;","sources":["src/main.ts","src/components/index.ts","src/components/ContextMenuHandler.tsx","src/components/ContextMenu.tsx","src/components/SubMenu.tsx","src/components/ContextWindow.tsx","src/components/ContextWindowStack.tsx","src/functions/chkPosition.ts"],"sourcesContent":["export * from './components';\n","import { ContextMenuHandler } from './ContextMenuHandler';\nimport { ContextWindow } from './ContextWindow';\nimport { ContextWindowStack } from './ContextWindowStack';\nimport { iMenuItem } from './interface';\n\nexport { ContextMenuHandler, ContextWindow, ContextWindowStack };\nexport type { iMenuItem };\n","import { MouseEvent, useCallback, useEffect, useRef, useState } from 'react';\nimport { createPortal } from 'react-dom';\nimport { ContextMenu } from './ContextMenu';\nimport { iMenuItem } from './interface';\nimport './ContextMenu.css';\n\nexport const ContextMenuHandler = ({\n children,\n menuItems,\n style = {\n height: 'fit-content',\n width: 'fit-content',\n },\n}: {\n children: JSX.Element[] | JSX.Element;\n menuItems: iMenuItem[];\n style?: React.CSSProperties;\n}): JSX.Element => {\n // Menu resources\n const divRef = 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 [target, setTarget] = useState<Range | null>(null);\n\n // Show menu when context is requested\n const showMenu = (e: MouseEvent<HTMLDivElement>) => {\n const sel = window.getSelection();\n setTarget(sel && sel.rangeCount > 0 ? sel.getRangeAt(0) : null);\n e.preventDefault();\n e.stopPropagation();\n setMenuVisible(true);\n setMenuXPos(e.pageX);\n setMenuYPos(e.pageY);\n };\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 return (\n <>\n <div\n onContextMenu={showMenu}\n className='context-menu-handler'\n style={style}\n >\n {children}\n </div>\n {menuVisible &&\n createPortal(\n <div\n style={{ position: 'absolute', top: 0, left: 0 }}\n ref={divRef}\n >\n <ContextMenu\n visible={true}\n ref={menuRef}\n entries={menuItems}\n xPos={menuXPos}\n yPos={menuYPos}\n target={target}\n toClose={() => setMenuVisible(false)}\n />\n </div>,\n document.body,\n )}\n </>\n );\n};\n\nContextMenuHandler.displayName = 'ContextMenuHandler';\n","import React from 'react';\nimport { iMenuItem } from './interface';\nimport { SubMenu } from './SubMenu';\n\nexport interface contextMenuProps {\n visible: boolean;\n entries: iMenuItem[];\n target: Range | null;\n xPos: number;\n yPos: number;\n toClose: () => void;\n}\n\nexport const ContextMenu = React.forwardRef<HTMLDivElement, contextMenuProps>(\n ({ visible, entries, target, xPos, yPos, toClose }, ref): JSX.Element => {\n ContextMenu.displayName = 'ContextMenu';\n\n return (\n <div\n ref={ref}\n className={`context-menu${visible ? ' visible' : ''}`}\n style={{\n top: `${yPos}px`,\n left: `${xPos}px`,\n }}\n onContextMenuCapture={(e) => {\n e.preventDefault();\n e.stopPropagation();\n }}\n >\n {entries.map((e, i) => (\n <div\n key={i}\n className={`context-menu-item${e.disabled ? ' disabled' : ''}`}\n onClick={(ev) => {\n ev.preventDefault();\n ev.stopPropagation();\n e.action && !e.disabled && e.action(target);\n !e.disabled && toClose();\n }}\n >\n <span className='context-menu-item-label'>{e.label}</span>\n {e.group && (\n <SubMenu\n toClose={toClose}\n entries={e.group}\n target={target}\n />\n )}\n </div>\n ))}\n </div>\n );\n },\n);\n\nContextMenu.displayName = 'ContextMenu';\n","import { useState } from 'react';\nimport { ContextMenu } from './ContextMenu';\nimport { iMenuItem } from './interface';\n\nexport interface subMenuProps {\n entries: iMenuItem[];\n target: Range | null;\n toClose: () => void;\n}\n\nexport const SubMenu = ({ entries, target, toClose }: subMenuProps): JSX.Element => {\n const [visible, setVisible] = useState<boolean>(false);\n\n return (\n <span\n className='caret-holder'\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='sub-menu'>\n <ContextMenu\n visible={visible}\n entries={entries}\n target={target}\n xPos={14}\n yPos={-21}\n toClose={toClose}\n />\n </div>\n </span>\n );\n};\n\nSubMenu.displayName = 'SubMenu';\n","import React, { useCallback, useContext, useEffect, useMemo, useRef, useState } from 'react';\nimport { createPortal } from 'react-dom';\nimport './ContextWindow.css';\nimport { ContextWindowStackContext } from './ContextWindowStack';\nimport { chkPosition } from '../functions/chkPosition';\n\ninterface ContextWindowProps {\n id: string;\n visible: boolean;\n onOpen?: () => void;\n onClose?: () => void;\n title: string;\n style?: React.CSSProperties;\n children: JSX.Element[] | JSX.Element | string;\n}\n\nexport const ContextWindow = ({\n id,\n visible,\n title,\n style,\n children,\n onOpen,\n onClose,\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 [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 if (visible && !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 } else if (windowId.current && !visible && windowVisible) {\n setWindowVisible(false);\n }\n }\n }, [onOpen, visible, windowStack, windowVisible]);\n\n return (\n <div\n className='contentwindow-anchor'\n ref={divRef}\n >\n {windowStack &&\n createPortal(\n <div\n id={id}\n className='contextwindow'\n style={{\n ...style,\n opacity: moving ? 0.8 : windowVisible ? 1 : 0,\n visibility: windowVisible ? 'visible' : 'hidden',\n zIndex: zIndex ?? 1,\n minHeight: style?.minHeight ?? '150px',\n minWidth: style?.minWidth ?? '200px',\n maxHeight: style?.maxHeight ?? '1000px',\n maxWidth: style?.maxWidth ?? '1000px',\n }}\n onClickCapture={() => {\n windowId && windowId.current && windowStack.pushToTop(windowId.current);\n }}\n ref={windowRef}\n >\n <div\n className={`contextwindow-title ${moving ? 'moving' : ''}`}\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 <span className='contextwindow-title-text'>{title}</span>\n <span className='contextwindow-title-close'>\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 onClick={onClose}\n aria-label='Close window'\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 </span>\n </div>\n <div className='contextwindow-body'>\n <div>{children}</div>\n </div>\n </div>,\n document.body,\n )}\n </div>\n );\n};\n\nContextWindow.displayName = 'ContextWindow';\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","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"],"names":[],"version":3,"file":"main.js.map"}
1
+ {"mappings":";;;;;;;;;;;;;;;;;;;;;AIUO,MAAM,4CAAU,CAAC,WAAE,OAAO,UAAE,MAAM,WAAE,OAAO,EAAgB;IAChE,MAAM,CAAC,SAAS,WAAW,GAAG,CAAA,GAAA,eAAO,EAAW;IAEhD,qBACE,iBAAC;QACC,WAAU;QACV,cAAc;YACZ,WAAW;QACb;QACA,cAAc;YACZ,WAAW;QACb;;0BAEA,gBAAC;gBACC,OAAM;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AAM;gCACN,OAAM;gCACN,QAAO;gCACP,MAAK;gCACL,SAAQ;gCACR,SAAS;gCACT,cAAW;0CAEX,cAAA,gBAAC;oCAAK,GAAE;;;;;;8BAId,gBAAC;oBAAI,WAAU;8BACb,cAAA,gBAAC;kCAAK;;;;YAGV,SAAS;;AAInB;AAEA,0CAAc,cAAc;;","sources":["src/main.ts","src/components/index.ts","src/components/ContextMenuHandler.tsx","src/components/ContextMenu.tsx","src/components/SubMenu.tsx","src/components/ContextWindow.tsx","src/components/ContextWindowStack.tsx","src/functions/chkPosition.ts"],"sourcesContent":["export * from './components';\n","import { ContextMenuHandler } from './ContextMenuHandler';\nimport { ContextWindow } from './ContextWindow';\nimport { ContextWindowStack } from './ContextWindowStack';\nimport { iMenuItem } from './interface';\n\nexport { ContextMenuHandler, ContextWindow, ContextWindowStack };\nexport type { iMenuItem };\n","import { MouseEvent, useCallback, useEffect, useRef, useState } from 'react';\nimport { createPortal } from 'react-dom';\nimport { ContextMenu } from './ContextMenu';\nimport { iMenuItem } from './interface';\nimport './ContextMenu.css';\n\nexport const ContextMenuHandler = ({\n children,\n menuItems,\n style = {\n height: 'fit-content',\n width: 'fit-content',\n },\n}: {\n children: JSX.Element[] | JSX.Element;\n menuItems: iMenuItem[];\n style?: React.CSSProperties;\n}): JSX.Element => {\n // Menu resources\n const divRef = 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 [target, setTarget] = useState<Range | null>(null);\n\n // Show menu when context is requested\n const showMenu = (e: MouseEvent<HTMLDivElement>) => {\n const sel = window.getSelection();\n setTarget(sel && sel.rangeCount > 0 ? sel.getRangeAt(0) : null);\n e.preventDefault();\n e.stopPropagation();\n setMenuVisible(true);\n setMenuXPos(e.pageX);\n setMenuYPos(e.pageY);\n };\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 return (\n <>\n <div\n onContextMenu={showMenu}\n className='context-menu-handler'\n style={style}\n >\n {children}\n </div>\n {menuVisible &&\n createPortal(\n <div\n style={{ position: 'absolute', top: 0, left: 0 }}\n ref={divRef}\n >\n <ContextMenu\n visible={true}\n ref={menuRef}\n entries={menuItems}\n xPos={menuXPos}\n yPos={menuYPos}\n target={target}\n toClose={() => setMenuVisible(false)}\n />\n </div>,\n document.body,\n )}\n </>\n );\n};\n\nContextMenuHandler.displayName = 'ContextMenuHandler';\n","import React from 'react';\nimport { iMenuItem } from './interface';\nimport { SubMenu } from './SubMenu';\n\nexport interface contextMenuProps {\n visible: boolean;\n entries: iMenuItem[];\n target: Range | null;\n xPos: number;\n yPos: number;\n toClose: () => void;\n}\n\nexport const ContextMenu = React.forwardRef<HTMLDivElement, contextMenuProps>(\n ({ visible, entries, target, xPos, yPos, toClose }, ref): JSX.Element => {\n ContextMenu.displayName = 'ContextMenu';\n\n return (\n <div\n ref={ref}\n className={`context-menu${visible ? ' visible' : ''}`}\n style={{\n top: `${yPos}px`,\n left: `${xPos}px`,\n }}\n onContextMenuCapture={(e) => {\n e.preventDefault();\n e.stopPropagation();\n }}\n >\n {entries.map((e, i) => (\n <div\n key={i}\n className={`context-menu-item${e.disabled ? ' disabled' : ''}`}\n onClick={(ev) => {\n ev.preventDefault();\n ev.stopPropagation();\n e.action && !e.disabled && e.action(target);\n !e.disabled && toClose();\n }}\n >\n <span className='context-menu-item-label'>{e.label}</span>\n {e.group && (\n <SubMenu\n toClose={toClose}\n entries={e.group}\n target={target}\n />\n )}\n </div>\n ))}\n </div>\n );\n },\n);\n\nContextMenu.displayName = 'ContextMenu';\n","import { useState } from 'react';\nimport { ContextMenu } from './ContextMenu';\nimport { iMenuItem } from './interface';\n\nexport interface subMenuProps {\n entries: iMenuItem[];\n target: Range | null;\n toClose: () => void;\n}\n\nexport const SubMenu = ({ entries, target, toClose }: subMenuProps): JSX.Element => {\n const [visible, setVisible] = useState<boolean>(false);\n\n return (\n <span\n className='caret-holder'\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='sub-menu'>\n <ContextMenu\n visible={visible}\n entries={entries}\n target={target}\n xPos={14}\n yPos={-21}\n toClose={toClose}\n />\n </div>\n </span>\n );\n};\n\nSubMenu.displayName = 'SubMenu';\n","import React, { useCallback, useContext, useEffect, useMemo, useRef, useState } from 'react';\nimport { createPortal } from 'react-dom';\nimport './ContextWindow.css';\nimport { ContextWindowStackContext } from './ContextWindowStack';\nimport { chkPosition } from '../functions/chkPosition';\n\ninterface ContextWindowProps {\n id: string;\n visible: boolean;\n onOpen?: () => void;\n onClose?: () => void;\n title: string;\n style?: React.CSSProperties;\n children: JSX.Element[] | JSX.Element | string;\n}\n\nexport const ContextWindow = ({\n id,\n visible,\n title,\n style,\n children,\n onOpen,\n onClose,\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 [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 if (visible && !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 } else if (windowId.current && !visible && windowVisible) {\n setWindowVisible(false);\n }\n }\n }, [onOpen, visible, windowStack, windowVisible]);\n\n return (\n <div\n className='contextwindow-anchor'\n ref={divRef}\n >\n {windowStack &&\n createPortal(\n <div\n id={id}\n className='contextwindow'\n style={{\n ...style,\n opacity: moving ? 0.8 : windowVisible ? 1 : 0,\n visibility: windowVisible ? 'visible' : 'hidden',\n zIndex: zIndex ?? 1,\n minHeight: style?.minHeight ?? '150px',\n minWidth: style?.minWidth ?? '200px',\n maxHeight: style?.maxHeight ?? '1000px',\n maxWidth: style?.maxWidth ?? '1000px',\n }}\n onClickCapture={() => {\n windowId && windowId.current && windowStack.pushToTop(windowId.current);\n }}\n ref={windowRef}\n >\n <div\n className={`contextwindow-title ${moving ? 'moving' : ''}`}\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 <span className='contextwindow-title-text'>{title}</span>\n <span className='contextwindow-title-close'>\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 onClick={onClose}\n aria-label='Close window'\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 </span>\n </div>\n <div className='contextwindow-body'>\n <div>{children}</div>\n </div>\n </div>,\n document.body,\n )}\n </div>\n );\n};\n\nContextWindow.displayName = 'ContextWindow';\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","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"],"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.1.4",
3
+ "version": "1.1.5",
4
4
  "description": "REACT Typescript Context menu component",
5
5
  "author": "Paul Thomas <@PaulDThomas>",
6
6
  "private": false,