@lax-wp/design-system 0.14.56 → 0.14.58
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/components/data-display/infinite-table/CellContextMenuPortal.cjs.js +1 -1
- package/dist/components/data-display/infinite-table/CellContextMenuPortal.cjs.js.map +1 -1
- package/dist/components/data-display/infinite-table/CellContextMenuPortal.es.js +71 -70
- package/dist/components/data-display/infinite-table/CellContextMenuPortal.es.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react/jsx-runtime"),Q=require("../../../providers/design-system-provider/hooks.cjs.js"),Y=require("./copy-text.cjs.js"),O=require("../../../_virtual/index.cjs.js"),o=require("react"),ee=require("react-dom"),te=require("react-router-dom"),T=require("./constants.cjs.js"),L=require("../../icon/icons.generated.cjs.js"),ne=async t=>{try{if(navigator?.clipboard?.writeText)return await navigator.clipboard.writeText(t),!0}catch{}try{const i=document.createElement("textarea");i.value=t,i.setAttribute("readonly",""),i.style.position="fixed",i.style.opacity="0",document.body.appendChild(i),i.select();const d=document.execCommand("copy");return document.body.removeChild(i),d}catch{return!1}},re=t=>{if(!t)return"";try{return new URL(t,window.location.origin).href}catch{return""}},S=(t,i,d)=>t===void 0?d:typeof t=="function"?t(i):t,oe=({item:t,isDisabled:i,isActive:d,onSelect:x,onHover:y})=>l.jsxs("button",{type:"button",role:"menuitem","data-menu-item":!0,disabled:i,"aria-disabled":i,tabIndex:d?0:-1,className:O("flex w-full items-center gap-3 px-3 py-2 text-sm font-medium text-left outline-none",i?"opacity-50 cursor-not-allowed":O("cursor-pointer",t.isDanger?"text-error-600 dark:text-error-400 hover:bg-error-50 dark:hover:bg-error-950 focus-visible:bg-error-50 dark:focus-visible:bg-error-950":"text-neutral-900 dark:text-white hover:bg-neutral-100 dark:hover:bg-black-600 focus-visible:bg-neutral-100 dark:focus-visible:bg-black-600")),onClick:x,onMouseEnter:()=>!i&&y(),children:[t.icon?l.jsx("span",{className:O("flex shrink-0 items-center",t.isDanger?"text-error-600 dark:text-error-400":"text-neutral-500 dark:text-black-300"),children:t.icon}):null,l.jsx("span",{className:"flex-1 truncate",children:t.label}),t.shortcut?l.jsx("span",{className:"shrink-0 text-xs text-neutral-400 dark:text-black-300",children:t.shortcut}):null]}),ie=({state:t,config:i,rowOptions:d,asyncRowOptionsFilter:x,checkedIds:y,rows:B,columns:C,rowLinkConfig:E,onClose:m})=>{const p=Q.useTableConfig(),c=o.useMemo(()=>p?.t??(e=>e),[p]),b=o.useRef(null),[j,U]=o.useState(null),[M,v]=o.useState(-1),[k,z]=o.useState(null),[h,R]=o.useState({status:"off"}),H=o.useRef(),a=o.useMemo(()=>t?{...t.target,close:m}:null,[t,m]),F=o.useCallback(async(e,n,r)=>{if(k)return;const s=await ne(n);s?(i?.onCopy?.(n,r),p?.showNotification?.("success",c("Copied to clipboard"))):p?.showNotification?.("error",c("Could not copy to clipboard")),z({key:e,isCopied:s}),H.current=setTimeout(()=>m(),T.COPY_FEEDBACK_DURATION)},[i,p,c,m,k]),g=o.useCallback((e,n,r,s)=>{const u=k?.key===e;return{key:e,label:u?k?.isCopied?c("Copied"):c("Copy failed"):n,icon:u&&k?.isCopied?l.jsx(L.CheckIcon,{size:16,className:"text-success-600 dark:text-success-400"}):s??l.jsx(L.ContentCopyIcon,{size:16}),isDisabled:!r,keepOpenOnClick:!0,onClick:P=>F(e,r,P)}},[k,F,c]),J=o.useMemo(()=>Y.getRowJson(t?.target.rowData,C),[t?.target.rowData,C]),X=o.useMemo(()=>t?Y.getSelectedRowsJson(B,C,y):"",[t,B,C,y]),D=y?.length??0,_=o.useMemo(()=>!t||!E?.isEnabled||!E.linkTo||t.target.column?.disableRowClick?"":E.linkTo(String(t.target.rowId),t.target.rowData)||"",[t,E]),V=te.useHref(_||"/"),w=o.useMemo(()=>_?re(V):"",[_,V]),W=o.useCallback(()=>{w&&window.open(w,"_blank","noopener,noreferrer")},[w]),A=o.useMemo(()=>{if(!a)return[];const e=i?.hideDefaultItems?[]:[g("copy-cell",i?.copyLabel??c("Copy Cell"),a.text),g("copy-row",c("Copy Row"),J),...D>0?[g("copy-selected-rows",D===1?c("Copy Selected Row"):`${c("Copy Selected Rows")} (${D})`,X)]:[],...w&&!i?.hideLinkItems?[{...g("copy-link",c("Copy Link"),w,l.jsx(L.LinkIcon,{size:16})),withDividerBefore:!0},{key:"open-in-new-tab",label:c("Open in New Tab"),icon:l.jsx(L.OpenInNewIcon,{size:16}),onClick:W}]:[]],n=typeof i?.items=="function"?i.items(a):i?.items??[];return[...e,...n].filter(r=>S(r.isVisible,a,!0))},[i,a,g,D,J,X,w,W,c]),N=o.useMemo(()=>!t||i?.includeRowOptions===!1||!d?[]:((typeof d=="function"?d(t.target.rowData):d)??[]).filter(n=>n.isVisible!==!1),[t,d,i?.includeRowOptions]),$=N.length>0;o.useEffect(()=>{if(!t||!$||!x){R({status:"off"});return}let e=!1;return R({status:"loading"}),x(String(t.target.rowId)).then(n=>!e&&R({status:"ready",available:n})).catch(()=>!e&&R({status:"failed"})),()=>{e=!0}},[t,$,x]);const q=o.useMemo(()=>{if(h.status==="off")return N;if(h.status!=="ready")return[];const{available:e}=h;return N.filter(n=>e[n.key]??!0)},[N,h]),f=o.useMemo(()=>{const e=A.map(r=>({kind:"item",key:r.key,item:r})),n=e.length>0;return h.status==="loading"?[...e,{kind:"skeleton",key:"row-options-loading",withDividerBefore:n}]:[...e,...q.map((r,s)=>({kind:"node",key:`row-option-${r.key}`,node:r.label,withDividerBefore:n&&s===0}))]},[A,q,h.status]),I=o.useCallback(e=>e.kind==="item"?!(a&&S(e.item.isDisabled,a,!1)):e.kind==="node",[a]),K=o.useMemo(()=>f.findIndex(I),[f,I]);o.useLayoutEffect(()=>{if(!t||!b.current){U(null);return}const{width:e,height:n}=b.current.getBoundingClientRect(),r=T.CELL_CONTEXT_MENU_VIEWPORT_MARGIN,s=T.CELL_CONTEXT_MENU_CURSOR_OFFSET,u=t.x+e+r>window.innerWidth?t.x-e-s:t.x+s,P=t.y+n+r>window.innerHeight?t.y-n-s:t.y+s;U({left:Math.max(r,Math.min(u,window.innerWidth-e-r)),top:Math.max(r,Math.min(P,window.innerHeight-n-r))})},[t,f.length]),o.useEffect(()=>(z(null),()=>clearTimeout(H.current)),[t]),o.useEffect(()=>{if(!t){v(-1);return}v(K)},[t,K]),o.useEffect(()=>{if(!t||M<0)return;const e=b.current?.querySelectorAll("[data-menu-item]")[M];(e?.matches("button")?e:e?.querySelector("button")??e)?.focus({preventScroll:!0})},[t,M]);const G=o.useCallback(e=>{f.length!==0&&v(n=>{let r=n;for(let s=0;s<f.length;s+=1)if(r=(r+e+f.length)%f.length,I(f[r]))return r;return n})},[f,I]);if(o.useEffect(()=>{if(!t)return;const e=u=>{b.current&&!b.current.contains(u.target)&&m()},n=u=>{if(u.key==="Escape"){u.stopPropagation(),m();return}(u.key==="ArrowDown"||u.key==="ArrowUp")&&(u.preventDefault(),G(u.key==="ArrowDown"?1:-1))},r=()=>m(),s=setTimeout(()=>{document.addEventListener("mousedown",e),document.addEventListener("touchstart",e),document.addEventListener("keydown",n),document.addEventListener("scroll",r,!0),window.addEventListener("resize",r)},0);return()=>{clearTimeout(s),document.removeEventListener("mousedown",e),document.removeEventListener("touchstart",e),document.removeEventListener("keydown",n),document.removeEventListener("scroll",r,!0),window.removeEventListener("resize",r)}},[t,m,G]),!t||!a||f.length===0)return null;if(p?.renderCellContextMenu)return p.renderCellContextMenu({state:t,context:a,items:A,rowOptions:q,onClose:m});const Z=async e=>{S(e.isDisabled,a,!1)||(e.keepOpenOnClick||m(),await e.onClick?.(a))};return ee.createPortal(l.jsx("div",{ref:b,role:"menu","aria-label":c("Cell actions"),"data-testid":"cell-context-menu",className:O("fixed min-w-[180px] max-w-[280px] py-1 rounded-lg font-inter","bg-white dark:bg-black-700","border border-neutral-200 dark:border-black-600","shadow-lg dark:shadow-black/40",i?.className),style:{left:j?.left??t.x,top:j?.top??t.y,zIndex:T.CELL_CONTEXT_MENU_Z_INDEX,visibility:j?"visible":"hidden"},onContextMenu:e=>e.preventDefault(),children:f.map((e,n)=>l.jsxs(o.Fragment,{children:[(e.kind==="item"?e.item.withDividerBefore&&n>0:e.withDividerBefore)?l.jsx("div",{className:"my-1 h-px bg-neutral-200 dark:bg-black-600"}):null,e.kind==="item"?l.jsx(oe,{item:e.item,isDisabled:S(e.item.isDisabled,a,!1),isActive:n===M,onSelect:()=>void Z(e.item),onHover:()=>v(n)}):e.kind==="skeleton"?l.jsx("div",{className:"px-3 py-2","data-testid":"cell-context-menu-loading",children:l.jsx("div",{className:"h-3.5 w-full animate-pulse rounded bg-neutral-200 dark:bg-black-600"})}):l.jsx("div",{"data-menu-item":!0,tabIndex:-1,className:"outline-none [&_button]:w-full",onClick:m,onMouseEnter:()=>v(n),children:e.node})]},e.key))}),document.body)};exports.CellContextMenuPortal=ie;
|
|
2
2
|
//# sourceMappingURL=CellContextMenuPortal.cjs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CellContextMenuPortal.cjs.js","sources":["../../../../src/components/data-display/infinite-table/CellContextMenuPortal.tsx"],"sourcesContent":["import { useTableConfig } from '../../../providers/design-system-provider/hooks';\nimport { CheckIcon, ContentCopyIcon, LinkIcon, OpenInNewIcon } from '../../icon';\nimport type {\n ICellContextMenuConfig,\n ICellContextMenuContext,\n ICellContextMenuItem,\n ICellContextMenuState,\n IColumn,\n IRowLinkConfig,\n} from './types';\nimport { getRowJson, getSelectedRowsJson } from './copy-text';\nimport cn from 'classnames';\nimport React, { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react';\nimport { createPortal } from 'react-dom';\n\nimport {\n CELL_CONTEXT_MENU_CURSOR_OFFSET,\n COPY_FEEDBACK_DURATION,\n CELL_CONTEXT_MENU_VIEWPORT_MARGIN,\n CELL_CONTEXT_MENU_Z_INDEX,\n} from './constants';\n\ntype TRowOption = { key: string; label: React.ReactNode; isVisible?: boolean };\n\n/** Result of the per-row availability check for row actions. */\ntype TRowOptionsFilter =\n | { status: 'off' }\n | { status: 'loading' }\n | { status: 'ready'; available: Record<string, boolean> }\n | { status: 'failed' };\n\n/** One rendered menu line: a declared item, a row-action node supplied by the table, or the row-action placeholder. */\ntype TMenuRow =\n | { kind: 'item'; key: string; item: ICellContextMenuItem }\n | { kind: 'node'; key: string; node: React.ReactNode; withDividerBefore?: boolean }\n | { kind: 'skeleton'; key: string; withDividerBefore?: boolean };\n\ninterface CellContextMenuPortalProps {\n state: ICellContextMenuState | null;\n config?: ICellContextMenuConfig | null;\n /** The table's row actions, appended to the menu — same list the three-dot cell renders. */\n rowOptions?: TRowOption[] | ((rowData: Record<string, unknown>) => TRowOption[] | null) | null;\n /** Per-row availability check for `rowOptions`, mirroring the three-dot cell so both menus agree. */\n asyncRowOptionsFilter?: ((rowId: string) => Promise<Record<string, boolean>>) | null;\n /** Checked row ids, enabling the \"Copy selected rows\" item. */\n checkedIds?: (string | number)[];\n /** Table rows, used to build the text for selected rows that are scrolled out of view. */\n rows?: Record<string, unknown>[];\n /** Visible columns in display order, used to order the copied values. */\n columns?: IColumn[];\n /** The table's row link, enabling the \"Copy Link\" / \"Open in New Tab\" items. */\n rowLinkConfig?: IRowLinkConfig | null;\n onClose: () => void;\n}\n\n/** Clipboard write with a fallback for browsers / insecure contexts without the async clipboard API. */\nconst writeToClipboard = async (text: string): Promise<boolean> => {\n try {\n if (navigator?.clipboard?.writeText) {\n await navigator.clipboard.writeText(text);\n return true;\n }\n } catch {\n // fall through to the textarea fallback\n }\n\n try {\n const textarea = document.createElement('textarea');\n textarea.value = text;\n textarea.setAttribute('readonly', '');\n textarea.style.position = 'fixed';\n textarea.style.opacity = '0';\n document.body.appendChild(textarea);\n textarea.select();\n const copied = document.execCommand('copy');\n document.body.removeChild(textarea);\n return copied;\n } catch {\n return false;\n }\n};\n\n/** `linkTo` returns a router path; the clipboard and a new tab both need a full URL. */\nconst toAbsoluteUrl = (path: string): string => {\n if (!path) return '';\n\n try {\n return new URL(path, window.location.href).href;\n } catch {\n return '';\n }\n};\n\nconst resolveFlag = (\n flag: boolean | ((context: ICellContextMenuContext) => boolean) | undefined,\n context: ICellContextMenuContext,\n fallback: boolean,\n): boolean => {\n if (flag === undefined) return fallback;\n return typeof flag === 'function' ? flag(context) : flag;\n};\n\nconst MenuItemButton: React.FC<{\n item: ICellContextMenuItem;\n isDisabled: boolean;\n isActive: boolean;\n onSelect: () => void;\n onHover: () => void;\n}> = ({ item, isDisabled, isActive, onSelect, onHover }) => (\n <button\n type='button'\n role='menuitem'\n data-menu-item\n disabled={isDisabled}\n aria-disabled={isDisabled}\n tabIndex={isActive ? 0 : -1}\n className={cn(\n 'flex w-full items-center gap-3 px-3 py-2 text-sm font-medium text-left outline-none',\n isDisabled\n ? 'opacity-50 cursor-not-allowed'\n : cn(\n 'cursor-pointer',\n item.isDanger\n ? 'text-error-600 dark:text-error-400 hover:bg-error-50 dark:hover:bg-error-950 focus-visible:bg-error-50 dark:focus-visible:bg-error-950'\n : 'text-neutral-900 dark:text-white hover:bg-neutral-100 dark:hover:bg-black-600 focus-visible:bg-neutral-100 dark:focus-visible:bg-black-600',\n ),\n )}\n onClick={onSelect}\n onMouseEnter={() => !isDisabled && onHover()}\n >\n {item.icon ? (\n <span className={cn('flex shrink-0 items-center', item.isDanger ? 'text-error-600 dark:text-error-400' : 'text-neutral-500 dark:text-black-300')}>\n {item.icon}\n </span>\n ) : null}\n <span className='flex-1 truncate'>{item.label}</span>\n {item.shortcut ? <span className='shrink-0 text-xs text-neutral-400 dark:text-black-300'>{item.shortcut}</span> : null}\n </button>\n);\n\n/**\n * Right-click menu for data cells. Rendered once per table and positioned at the\n * cursor; `DataCell` opens it through `openCellContextMenu` on the table context.\n */\nexport const CellContextMenuPortal: React.FC<CellContextMenuPortalProps> = ({\n state, config, rowOptions, asyncRowOptionsFilter, checkedIds, rows, columns, rowLinkConfig, onClose,\n}) => {\n const tableConfig = useTableConfig();\n const t = useMemo(() => tableConfig?.t ?? ((key: string) => key), [tableConfig]);\n const menuRef = useRef<HTMLDivElement>(null);\n const [position, setPosition] = useState<{ left: number; top: number } | null>(null);\n const [activeIndex, setActiveIndex] = useState(-1);\n const [copyState, setCopyState] = useState<{ key: string; isCopied: boolean } | null>(null);\n const [rowOptionsFilter, setRowOptionsFilter] = useState<TRowOptionsFilter>({ status: 'off' });\n const closeTimer = useRef<ReturnType<typeof setTimeout>>();\n\n const context = useMemo<ICellContextMenuContext | null>(\n () => (state ? { ...state.target, close: onClose } : null),\n [state, onClose],\n );\n\n const handleCopy = useCallback(\n async (key: string, text: string, menuContext: ICellContextMenuContext) => {\n if (copyState) return;\n\n const isCopied = await writeToClipboard(text);\n\n if (isCopied) {\n config?.onCopy?.(text, menuContext);\n tableConfig?.showNotification?.('success', t('Copied to clipboard'));\n } else {\n tableConfig?.showNotification?.('error', t('Could not copy to clipboard'));\n }\n\n // Confirmed inline instead of with a toast, so the menu owns its own feedback.\n setCopyState({ key, isCopied });\n closeTimer.current = setTimeout(() => onClose(), COPY_FEEDBACK_DURATION);\n },\n [config, tableConfig, t, onClose, copyState],\n );\n\n const buildCopyItem = useCallback(\n (key: string, label: string, text: string, icon?: React.ReactNode): ICellContextMenuItem => {\n const isDone = copyState?.key === key;\n\n return {\n key,\n label: !isDone ? label : copyState?.isCopied ? t('Copied') : t('Copy failed'),\n icon:\n isDone && copyState?.isCopied ? (\n <CheckIcon size={16} className='text-success-600 dark:text-success-400' />\n ) : (\n icon ?? <ContentCopyIcon size={16} />\n ),\n isDisabled: !text,\n keepOpenOnClick: true,\n onClick: (menuContext) => handleCopy(key, text, menuContext),\n };\n },\n [copyState, handleCopy, t],\n );\n\n const rowJson = useMemo(() => getRowJson(state?.target.rowData, columns), [state?.target.rowData, columns]);\n // Only while the menu is open — otherwise every checkbox tick would serialize the selection.\n const selectedRowsJson = useMemo(() => (state ? getSelectedRowsJson(rows, columns, checkedIds) : ''), [state, rows, columns, checkedIds]);\n const selectedCount = checkedIds?.length ?? 0;\n\n /** The row link as an absolute URL — empty unless the table opted in, and never on a cell that opts out of the row link. */\n const rowLinkHref = useMemo(() => {\n if (!state || !rowLinkConfig?.isEnabled || !rowLinkConfig.linkTo || state.target.column?.disableRowClick) return '';\n\n return toAbsoluteUrl(rowLinkConfig.linkTo(String(state.target.rowId), state.target.rowData));\n }, [state, rowLinkConfig]);\n\n const openInNewTab = useCallback(() => {\n if (rowLinkHref) window.open(rowLinkHref, '_blank', 'noopener,noreferrer');\n }, [rowLinkHref]);\n\n const items = useMemo<ICellContextMenuItem[]>(() => {\n if (!context) return [];\n\n const defaultItems: ICellContextMenuItem[] = config?.hideDefaultItems\n ? []\n : [\n buildCopyItem('copy-cell', config?.copyLabel ?? t('Copy Cell'), context.text),\n buildCopyItem('copy-row', t('Copy Row'), rowJson),\n ...(selectedCount > 0\n ? [\n buildCopyItem(\n 'copy-selected-rows',\n selectedCount === 1 ? t('Copy Selected Row') : `${t('Copy Selected Rows')} (${selectedCount})`,\n selectedRowsJson,\n ),\n ]\n : []),\n ...(rowLinkHref && !config?.hideLinkItems\n ? [\n {\n ...buildCopyItem('copy-link', t('Copy Link'), rowLinkHref, <LinkIcon size={16} />),\n withDividerBefore: true,\n },\n {\n key: 'open-in-new-tab',\n label: t('Open in New Tab'),\n icon: <OpenInNewIcon size={16} />,\n onClick: openInNewTab,\n },\n ]\n : []),\n ];\n\n const extraItems = typeof config?.items === 'function' ? config.items(context) : config?.items ?? [];\n\n return [...defaultItems, ...extraItems].filter((item) => resolveFlag(item.isVisible, context, true));\n }, [config, context, buildCopyItem, selectedCount, rowJson, selectedRowsJson, rowLinkHref, openInNewTab, t]);\n\n /** The table's own row actions, resolved for the right-clicked row. */\n const resolvedRowOptions = useMemo<TRowOption[]>(() => {\n if (!state || config?.includeRowOptions === false || !rowOptions) return [];\n\n const list = typeof rowOptions === 'function' ? rowOptions(state.target.rowData) : rowOptions;\n\n return (list ?? []).filter((option) => option.isVisible !== false);\n }, [state, rowOptions, config?.includeRowOptions]);\n\n const hasRowOptions = resolvedRowOptions.length > 0;\n\n /** Row actions can be gated per row by the API — ask before showing them, exactly as the three-dot cell does. */\n useEffect(() => {\n if (!state || !hasRowOptions || !asyncRowOptionsFilter) {\n setRowOptionsFilter({ status: 'off' });\n return;\n }\n\n let isCancelled = false;\n setRowOptionsFilter({ status: 'loading' });\n\n asyncRowOptionsFilter(String(state.target.rowId))\n .then((available) => !isCancelled && setRowOptionsFilter({ status: 'ready', available }))\n .catch(() => !isCancelled && setRowOptionsFilter({ status: 'failed' }));\n\n return () => {\n isCancelled = true;\n };\n }, [state, hasRowOptions, asyncRowOptionsFilter]);\n\n const allowedRowOptions = useMemo<TRowOption[]>(() => {\n if (rowOptionsFilter.status === 'off') return resolvedRowOptions;\n if (rowOptionsFilter.status !== 'ready') return [];\n\n const { available } = rowOptionsFilter;\n\n return resolvedRowOptions.filter((option) => available[option.key] ?? true);\n }, [resolvedRowOptions, rowOptionsFilter]);\n\n const menuRows = useMemo<TMenuRow[]>(() => {\n const itemRows: TMenuRow[] = items.map((item) => ({ kind: 'item', key: item.key, item }));\n const needsDivider = itemRows.length > 0;\n\n if (rowOptionsFilter.status === 'loading') {\n return [...itemRows, { kind: 'skeleton', key: 'row-options-loading', withDividerBefore: needsDivider }];\n }\n\n return [\n ...itemRows,\n ...allowedRowOptions.map<TMenuRow>((option, index) => ({\n kind: 'node',\n key: `row-option-${option.key}`,\n node: option.label,\n withDividerBefore: needsDivider && index === 0,\n })),\n ];\n }, [items, allowedRowOptions, rowOptionsFilter.status]);\n\n const isRowNavigable = useCallback(\n (row: TMenuRow): boolean => (row.kind === 'item' ? !(context && resolveFlag(row.item.isDisabled, context, false)) : row.kind === 'node'),\n [context],\n );\n\n const firstNavigableIndex = useMemo(() => menuRows.findIndex(isRowNavigable), [menuRows, isRowNavigable]);\n\n /** Clamp into the viewport once the menu has been measured; row actions can arrive after the first paint. */\n useLayoutEffect(() => {\n if (!state || !menuRef.current) {\n setPosition(null);\n return;\n }\n\n const { width, height } = menuRef.current.getBoundingClientRect();\n const margin = CELL_CONTEXT_MENU_VIEWPORT_MARGIN;\n const offset = CELL_CONTEXT_MENU_CURSOR_OFFSET;\n\n // Flip to the other side of the cursor when there is no room, then clamp.\n const left = state.x + width + margin > window.innerWidth ? state.x - width - offset : state.x + offset;\n const top = state.y + height + margin > window.innerHeight ? state.y - height - offset : state.y + offset;\n\n setPosition({\n left: Math.max(margin, Math.min(left, window.innerWidth - width - margin)),\n top: Math.max(margin, Math.min(top, window.innerHeight - height - margin)),\n });\n }, [state, menuRows.length]);\n\n useEffect(() => {\n setCopyState(null);\n return () => clearTimeout(closeTimer.current);\n }, [state]);\n\n useEffect(() => {\n if (!state) {\n setActiveIndex(-1);\n return;\n }\n setActiveIndex(firstNavigableIndex);\n }, [state, firstNavigableIndex]);\n\n /** Focus follows the active row so the menu is keyboard operable; row actions bring their own button. */\n useEffect(() => {\n if (!state || activeIndex < 0) return;\n\n const row = menuRef.current?.querySelectorAll<HTMLElement>('[data-menu-item]')[activeIndex];\n const focusTarget = row?.matches('button') ? row : row?.querySelector('button') ?? row;\n\n // preventScroll: a focus-driven scroll would immediately close the menu.\n focusTarget?.focus({ preventScroll: true });\n }, [state, activeIndex]);\n\n const moveActiveIndex = useCallback(\n (direction: 1 | -1) => {\n if (menuRows.length === 0) return;\n setActiveIndex((current) => {\n let next = current;\n for (let step = 0; step < menuRows.length; step += 1) {\n next = (next + direction + menuRows.length) % menuRows.length;\n if (isRowNavigable(menuRows[next])) return next;\n }\n return current;\n });\n },\n [menuRows, isRowNavigable],\n );\n\n useEffect(() => {\n if (!state) return;\n\n const handlePointerDown = (event: MouseEvent | TouchEvent) => {\n if (menuRef.current && !menuRef.current.contains(event.target as Node)) onClose();\n };\n const handleKeyDown = (event: KeyboardEvent) => {\n if (event.key === 'Escape') {\n event.stopPropagation();\n onClose();\n return;\n }\n if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {\n event.preventDefault();\n moveActiveIndex(event.key === 'ArrowDown' ? 1 : -1);\n }\n };\n // Any scroll (table viewport included) detaches the menu from its cell, so close it.\n const handleScroll = () => onClose();\n\n // Deferred so the right click that opened the menu does not immediately close it.\n const timeoutId = setTimeout(() => {\n document.addEventListener('mousedown', handlePointerDown);\n document.addEventListener('touchstart', handlePointerDown);\n document.addEventListener('keydown', handleKeyDown);\n document.addEventListener('scroll', handleScroll, true);\n window.addEventListener('resize', handleScroll);\n }, 0);\n\n return () => {\n clearTimeout(timeoutId);\n document.removeEventListener('mousedown', handlePointerDown);\n document.removeEventListener('touchstart', handlePointerDown);\n document.removeEventListener('keydown', handleKeyDown);\n document.removeEventListener('scroll', handleScroll, true);\n window.removeEventListener('resize', handleScroll);\n };\n }, [state, onClose, moveActiveIndex]);\n\n if (!state || !context || menuRows.length === 0) return null;\n\n if (tableConfig?.renderCellContextMenu) {\n return tableConfig.renderCellContextMenu({ state, context, items, rowOptions: allowedRowOptions, onClose }) as JSX.Element;\n }\n\n const handleItemClick = async (item: ICellContextMenuItem): Promise<void> => {\n if (resolveFlag(item.isDisabled, context, false)) return;\n if (!item.keepOpenOnClick) onClose();\n await item.onClick?.(context);\n };\n\n return createPortal(\n <div\n ref={menuRef}\n role='menu'\n aria-label={t('Cell actions')}\n data-testid='cell-context-menu'\n className={cn(\n 'fixed min-w-[180px] max-w-[280px] py-1 rounded-lg font-inter',\n 'bg-white dark:bg-black-700',\n 'border border-neutral-200 dark:border-black-600',\n 'shadow-lg dark:shadow-black/40',\n config?.className,\n )}\n style={{\n left: position?.left ?? state.x,\n top: position?.top ?? state.y,\n zIndex: CELL_CONTEXT_MENU_Z_INDEX,\n // Hidden until measured so the flip/clamp never flashes at the wrong spot.\n visibility: position ? 'visible' : 'hidden',\n }}\n onContextMenu={(event) => event.preventDefault()}\n >\n {menuRows.map((row, index) => (\n <React.Fragment key={row.key}>\n {(row.kind === 'item' ? row.item.withDividerBefore && index > 0 : row.withDividerBefore) ? (\n <div className='my-1 h-px bg-neutral-200 dark:bg-black-600' />\n ) : null}\n {row.kind === 'item' ? (\n <MenuItemButton\n item={row.item}\n isDisabled={resolveFlag(row.item.isDisabled, context, false)}\n isActive={index === activeIndex}\n onSelect={() => void handleItemClick(row.item)}\n onHover={() => setActiveIndex(index)}\n />\n ) : row.kind === 'skeleton' ? (\n <div className='px-3 py-2' data-testid='cell-context-menu-loading'>\n <div className='h-3.5 w-full animate-pulse rounded bg-neutral-200 dark:bg-black-600' />\n </div>\n ) : (\n /* Row actions are rendered as the table supplied them — they carry their own button and handler. */\n <div data-menu-item tabIndex={-1} className='outline-none [&_button]:w-full' onClick={onClose} onMouseEnter={() => setActiveIndex(index)}>\n {row.node}\n </div>\n )}\n </React.Fragment>\n ))}\n </div>,\n document.body,\n );\n};\n"],"names":["writeToClipboard","text","textarea","copied","toAbsoluteUrl","path","resolveFlag","flag","context","fallback","MenuItemButton","item","isDisabled","isActive","onSelect","onHover","jsxs","cn","jsx","CellContextMenuPortal","state","config","rowOptions","asyncRowOptionsFilter","checkedIds","rows","columns","rowLinkConfig","onClose","tableConfig","useTableConfig","t","useMemo","key","menuRef","useRef","position","setPosition","useState","activeIndex","setActiveIndex","copyState","setCopyState","rowOptionsFilter","setRowOptionsFilter","closeTimer","handleCopy","useCallback","menuContext","isCopied","COPY_FEEDBACK_DURATION","buildCopyItem","label","icon","isDone","CheckIcon","ContentCopyIcon","rowJson","getRowJson","selectedRowsJson","getSelectedRowsJson","selectedCount","rowLinkHref","openInNewTab","items","defaultItems","LinkIcon","OpenInNewIcon","extraItems","resolvedRowOptions","option","hasRowOptions","useEffect","isCancelled","available","allowedRowOptions","menuRows","itemRows","needsDivider","index","isRowNavigable","row","firstNavigableIndex","useLayoutEffect","width","height","margin","CELL_CONTEXT_MENU_VIEWPORT_MARGIN","offset","CELL_CONTEXT_MENU_CURSOR_OFFSET","left","top","moveActiveIndex","direction","current","next","step","handlePointerDown","event","handleKeyDown","handleScroll","timeoutId","handleItemClick","createPortal","CELL_CONTEXT_MENU_Z_INDEX","React"],"mappings":"8XAwDMA,EAAmB,MAAOC,GAAmC,CACjE,GAAI,CACF,GAAI,WAAW,WAAW,UACxB,aAAM,UAAU,UAAU,UAAUA,CAAI,EACjC,EAEX,MAAQ,CAER,CAEA,GAAI,CACF,MAAMC,EAAW,SAAS,cAAc,UAAU,EAClDA,EAAS,MAAQD,EACjBC,EAAS,aAAa,WAAY,EAAE,EACpCA,EAAS,MAAM,SAAW,QAC1BA,EAAS,MAAM,QAAU,IACzB,SAAS,KAAK,YAAYA,CAAQ,EAClCA,EAAS,OAAA,EACT,MAAMC,EAAS,SAAS,YAAY,MAAM,EAC1C,gBAAS,KAAK,YAAYD,CAAQ,EAC3BC,CACT,MAAQ,CACN,MAAO,EACT,CACF,EAGMC,GAAiBC,GAAyB,CAC9C,GAAI,CAACA,EAAM,MAAO,GAElB,GAAI,CACF,OAAO,IAAI,IAAIA,EAAM,OAAO,SAAS,IAAI,EAAE,IAC7C,MAAQ,CACN,MAAO,EACT,CACF,EAEMC,EAAc,CAClBC,EACAC,EACAC,IAEIF,IAAS,OAAkBE,EACxB,OAAOF,GAAS,WAAaA,EAAKC,CAAO,EAAID,EAGhDG,GAMD,CAAC,CAAE,KAAAC,EAAM,WAAAC,EAAY,SAAAC,EAAU,SAAAC,EAAU,QAAAC,KAC5CC,EAAAA,KAAC,SAAA,CACC,KAAK,SACL,KAAK,WACL,iBAAc,GACd,SAAUJ,EACV,gBAAeA,EACf,SAAUC,EAAW,EAAI,GACzB,UAAWI,EACT,sFACAL,EACI,gCACAK,EACE,iBACAN,EAAK,SACD,yIACA,4IAAA,CACN,EAEN,QAASG,EACT,aAAc,IAAM,CAACF,GAAcG,EAAA,EAElC,SAAA,CAAAJ,EAAK,KACJO,MAAC,OAAA,CAAK,UAAWD,EAAG,6BAA8BN,EA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E,EAAI,KACV,WAAY3E,EAAY2E,EAAI,KAAK,WAAYzE,EAAS,EAAK,EAC3D,SAAUuE,IAAUxC,EACpB,SAAU,IAAM,KAAK+D,EAAgBrB,EAAI,IAAI,EAC7C,QAAS,IAAMzC,EAAeuC,CAAK,CAAA,CAAA,EAEnCE,EAAI,OAAS,iBACd,MAAA,CAAI,UAAU,YAAY,cAAY,4BACrC,SAAA/D,MAAC,MAAA,CAAI,UAAU,sEAAsE,EACvF,QAGC,MAAA,CAAI,iBAAc,GAAC,SAAU,GAAI,UAAU,iCAAiC,QAASU,EAAS,aAAc,IAAMY,EAAeuC,CAAK,EACpI,WAAI,IAAA,CACP,CAAA,CAAA,EApBiBE,EAAI,GAsBzB,CACD,CAAA,CAAA,EAEH,SAAS,IAAA,CAEb"}
|
|
1
|
+
{"version":3,"file":"CellContextMenuPortal.cjs.js","sources":["../../../../src/components/data-display/infinite-table/CellContextMenuPortal.tsx"],"sourcesContent":["import { useTableConfig } from '../../../providers/design-system-provider/hooks';\nimport { CheckIcon, ContentCopyIcon, LinkIcon, OpenInNewIcon } from '../../icon';\nimport type {\n ICellContextMenuConfig,\n ICellContextMenuContext,\n ICellContextMenuItem,\n ICellContextMenuState,\n IColumn,\n IRowLinkConfig,\n} from './types';\nimport { getRowJson, getSelectedRowsJson } from './copy-text';\nimport cn from 'classnames';\nimport React, { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react';\nimport { createPortal } from 'react-dom';\nimport { useHref } from 'react-router-dom';\n\nimport {\n CELL_CONTEXT_MENU_CURSOR_OFFSET,\n COPY_FEEDBACK_DURATION,\n CELL_CONTEXT_MENU_VIEWPORT_MARGIN,\n CELL_CONTEXT_MENU_Z_INDEX,\n} from './constants';\n\ntype TRowOption = { key: string; label: React.ReactNode; isVisible?: boolean };\n\n/** Result of the per-row availability check for row actions. */\ntype TRowOptionsFilter =\n | { status: 'off' }\n | { status: 'loading' }\n | { status: 'ready'; available: Record<string, boolean> }\n | { status: 'failed' };\n\n/** One rendered menu line: a declared item, a row-action node supplied by the table, or the row-action placeholder. */\ntype TMenuRow =\n | { kind: 'item'; key: string; item: ICellContextMenuItem }\n | { kind: 'node'; key: string; node: React.ReactNode; withDividerBefore?: boolean }\n | { kind: 'skeleton'; key: string; withDividerBefore?: boolean };\n\ninterface CellContextMenuPortalProps {\n state: ICellContextMenuState | null;\n config?: ICellContextMenuConfig | null;\n /** The table's row actions, appended to the menu — same list the three-dot cell renders. */\n rowOptions?: TRowOption[] | ((rowData: Record<string, unknown>) => TRowOption[] | null) | null;\n /** Per-row availability check for `rowOptions`, mirroring the three-dot cell so both menus agree. */\n asyncRowOptionsFilter?: ((rowId: string) => Promise<Record<string, boolean>>) | null;\n /** Checked row ids, enabling the \"Copy selected rows\" item. */\n checkedIds?: (string | number)[];\n /** Table rows, used to build the text for selected rows that are scrolled out of view. */\n rows?: Record<string, unknown>[];\n /** Visible columns in display order, used to order the copied values. */\n columns?: IColumn[];\n /** The table's row link, enabling the \"Copy Link\" / \"Open in New Tab\" items. */\n rowLinkConfig?: IRowLinkConfig | null;\n onClose: () => void;\n}\n\n/** Clipboard write with a fallback for browsers / insecure contexts without the async clipboard API. */\nconst writeToClipboard = async (text: string): Promise<boolean> => {\n try {\n if (navigator?.clipboard?.writeText) {\n await navigator.clipboard.writeText(text);\n return true;\n }\n } catch {\n // fall through to the textarea fallback\n }\n\n try {\n const textarea = document.createElement('textarea');\n textarea.value = text;\n textarea.setAttribute('readonly', '');\n textarea.style.position = 'fixed';\n textarea.style.opacity = '0';\n document.body.appendChild(textarea);\n textarea.select();\n const copied = document.execCommand('copy');\n document.body.removeChild(textarea);\n return copied;\n } catch {\n return false;\n }\n};\n\n/** An already basename-resolved href (from `useHref`); the clipboard and a new tab both need a full URL. */\nconst toAbsoluteUrl = (href: string): string => {\n if (!href) return '';\n\n try {\n return new URL(href, window.location.origin).href;\n } catch {\n return '';\n }\n};\n\nconst resolveFlag = (\n flag: boolean | ((context: ICellContextMenuContext) => boolean) | undefined,\n context: ICellContextMenuContext,\n fallback: boolean,\n): boolean => {\n if (flag === undefined) return fallback;\n return typeof flag === 'function' ? flag(context) : flag;\n};\n\nconst MenuItemButton: React.FC<{\n item: ICellContextMenuItem;\n isDisabled: boolean;\n isActive: boolean;\n onSelect: () => void;\n onHover: () => void;\n}> = ({ item, isDisabled, isActive, onSelect, onHover }) => (\n <button\n type='button'\n role='menuitem'\n data-menu-item\n disabled={isDisabled}\n aria-disabled={isDisabled}\n tabIndex={isActive ? 0 : -1}\n className={cn(\n 'flex w-full items-center gap-3 px-3 py-2 text-sm font-medium text-left outline-none',\n isDisabled\n ? 'opacity-50 cursor-not-allowed'\n : cn(\n 'cursor-pointer',\n item.isDanger\n ? 'text-error-600 dark:text-error-400 hover:bg-error-50 dark:hover:bg-error-950 focus-visible:bg-error-50 dark:focus-visible:bg-error-950'\n : 'text-neutral-900 dark:text-white hover:bg-neutral-100 dark:hover:bg-black-600 focus-visible:bg-neutral-100 dark:focus-visible:bg-black-600',\n ),\n )}\n onClick={onSelect}\n onMouseEnter={() => !isDisabled && onHover()}\n >\n {item.icon ? (\n <span className={cn('flex shrink-0 items-center', item.isDanger ? 'text-error-600 dark:text-error-400' : 'text-neutral-500 dark:text-black-300')}>\n {item.icon}\n </span>\n ) : null}\n <span className='flex-1 truncate'>{item.label}</span>\n {item.shortcut ? <span className='shrink-0 text-xs text-neutral-400 dark:text-black-300'>{item.shortcut}</span> : null}\n </button>\n);\n\n/**\n * Right-click menu for data cells. Rendered once per table and positioned at the\n * cursor; `DataCell` opens it through `openCellContextMenu` on the table context.\n */\nexport const CellContextMenuPortal: React.FC<CellContextMenuPortalProps> = ({\n state, config, rowOptions, asyncRowOptionsFilter, checkedIds, rows, columns, rowLinkConfig, onClose,\n}) => {\n const tableConfig = useTableConfig();\n const t = useMemo(() => tableConfig?.t ?? ((key: string) => key), [tableConfig]);\n const menuRef = useRef<HTMLDivElement>(null);\n const [position, setPosition] = useState<{ left: number; top: number } | null>(null);\n const [activeIndex, setActiveIndex] = useState(-1);\n const [copyState, setCopyState] = useState<{ key: string; isCopied: boolean } | null>(null);\n const [rowOptionsFilter, setRowOptionsFilter] = useState<TRowOptionsFilter>({ status: 'off' });\n const closeTimer = useRef<ReturnType<typeof setTimeout>>();\n\n const context = useMemo<ICellContextMenuContext | null>(\n () => (state ? { ...state.target, close: onClose } : null),\n [state, onClose],\n );\n\n const handleCopy = useCallback(\n async (key: string, text: string, menuContext: ICellContextMenuContext) => {\n if (copyState) return;\n\n const isCopied = await writeToClipboard(text);\n\n if (isCopied) {\n config?.onCopy?.(text, menuContext);\n tableConfig?.showNotification?.('success', t('Copied to clipboard'));\n } else {\n tableConfig?.showNotification?.('error', t('Could not copy to clipboard'));\n }\n\n // Confirmed inline instead of with a toast, so the menu owns its own feedback.\n setCopyState({ key, isCopied });\n closeTimer.current = setTimeout(() => onClose(), COPY_FEEDBACK_DURATION);\n },\n [config, tableConfig, t, onClose, copyState],\n );\n\n const buildCopyItem = useCallback(\n (key: string, label: string, text: string, icon?: React.ReactNode): ICellContextMenuItem => {\n const isDone = copyState?.key === key;\n\n return {\n key,\n label: !isDone ? label : copyState?.isCopied ? t('Copied') : t('Copy failed'),\n icon:\n isDone && copyState?.isCopied ? (\n <CheckIcon size={16} className='text-success-600 dark:text-success-400' />\n ) : (\n icon ?? <ContentCopyIcon size={16} />\n ),\n isDisabled: !text,\n keepOpenOnClick: true,\n onClick: (menuContext) => handleCopy(key, text, menuContext),\n };\n },\n [copyState, handleCopy, t],\n );\n\n const rowJson = useMemo(() => getRowJson(state?.target.rowData, columns), [state?.target.rowData, columns]);\n // Only while the menu is open — otherwise every checkbox tick would serialize the selection.\n const selectedRowsJson = useMemo(() => (state ? getSelectedRowsJson(rows, columns, checkedIds) : ''), [state, rows, columns, checkedIds]);\n const selectedCount = checkedIds?.length ?? 0;\n\n /** The router path from `linkTo`, before the router's basename (e.g. `/integrations`) is applied. */\n const rowLinkPath = useMemo(() => {\n if (!state || !rowLinkConfig?.isEnabled || !rowLinkConfig.linkTo || state.target.column?.disableRowClick) return '';\n\n return rowLinkConfig.linkTo(String(state.target.rowId), state.target.rowData) || '';\n }, [state, rowLinkConfig]);\n\n // `useHref` resolves `rowLinkPath` the same way a <Link> would, basename included — a manual\n // `new URL(path, location.href)` would silently drop a router basename like `/integrations`.\n const rowLinkResolvedHref = useHref(rowLinkPath || '/');\n\n /** The row link as an absolute URL — empty unless the table opted in, and never on a cell that opts out of the row link. */\n const rowLinkHref = useMemo(() => {\n if (!rowLinkPath) return '';\n\n return toAbsoluteUrl(rowLinkResolvedHref);\n }, [rowLinkPath, rowLinkResolvedHref]);\n\n const openInNewTab = useCallback(() => {\n if (rowLinkHref) window.open(rowLinkHref, '_blank', 'noopener,noreferrer');\n }, [rowLinkHref]);\n\n const items = useMemo<ICellContextMenuItem[]>(() => {\n if (!context) return [];\n\n const defaultItems: ICellContextMenuItem[] = config?.hideDefaultItems\n ? []\n : [\n buildCopyItem('copy-cell', config?.copyLabel ?? t('Copy Cell'), context.text),\n buildCopyItem('copy-row', t('Copy Row'), rowJson),\n ...(selectedCount > 0\n ? [\n buildCopyItem(\n 'copy-selected-rows',\n selectedCount === 1 ? t('Copy Selected Row') : `${t('Copy Selected Rows')} (${selectedCount})`,\n selectedRowsJson,\n ),\n ]\n : []),\n ...(rowLinkHref && !config?.hideLinkItems\n ? [\n {\n ...buildCopyItem('copy-link', t('Copy Link'), rowLinkHref, <LinkIcon size={16} />),\n withDividerBefore: true,\n },\n {\n key: 'open-in-new-tab',\n label: t('Open in New Tab'),\n icon: <OpenInNewIcon size={16} />,\n onClick: openInNewTab,\n },\n ]\n : []),\n ];\n\n const extraItems = typeof config?.items === 'function' ? config.items(context) : config?.items ?? [];\n\n return [...defaultItems, ...extraItems].filter((item) => resolveFlag(item.isVisible, context, true));\n }, [config, context, buildCopyItem, selectedCount, rowJson, selectedRowsJson, rowLinkHref, openInNewTab, t]);\n\n /** The table's own row actions, resolved for the right-clicked row. */\n const resolvedRowOptions = useMemo<TRowOption[]>(() => {\n if (!state || config?.includeRowOptions === false || !rowOptions) return [];\n\n const list = typeof rowOptions === 'function' ? rowOptions(state.target.rowData) : rowOptions;\n\n return (list ?? []).filter((option) => option.isVisible !== false);\n }, [state, rowOptions, config?.includeRowOptions]);\n\n const hasRowOptions = resolvedRowOptions.length > 0;\n\n /** Row actions can be gated per row by the API — ask before showing them, exactly as the three-dot cell does. */\n useEffect(() => {\n if (!state || !hasRowOptions || !asyncRowOptionsFilter) {\n setRowOptionsFilter({ status: 'off' });\n return;\n }\n\n let isCancelled = false;\n setRowOptionsFilter({ status: 'loading' });\n\n asyncRowOptionsFilter(String(state.target.rowId))\n .then((available) => !isCancelled && setRowOptionsFilter({ status: 'ready', available }))\n .catch(() => !isCancelled && setRowOptionsFilter({ status: 'failed' }));\n\n return () => {\n isCancelled = true;\n };\n }, [state, hasRowOptions, asyncRowOptionsFilter]);\n\n const allowedRowOptions = useMemo<TRowOption[]>(() => {\n if (rowOptionsFilter.status === 'off') return resolvedRowOptions;\n if (rowOptionsFilter.status !== 'ready') return [];\n\n const { available } = rowOptionsFilter;\n\n return resolvedRowOptions.filter((option) => available[option.key] ?? true);\n }, [resolvedRowOptions, rowOptionsFilter]);\n\n const menuRows = useMemo<TMenuRow[]>(() => {\n const itemRows: TMenuRow[] = items.map((item) => ({ kind: 'item', key: item.key, item }));\n const needsDivider = itemRows.length > 0;\n\n if (rowOptionsFilter.status === 'loading') {\n return [...itemRows, { kind: 'skeleton', key: 'row-options-loading', withDividerBefore: needsDivider }];\n }\n\n return [\n ...itemRows,\n ...allowedRowOptions.map<TMenuRow>((option, index) => ({\n kind: 'node',\n key: `row-option-${option.key}`,\n node: option.label,\n withDividerBefore: needsDivider && index === 0,\n })),\n ];\n }, [items, allowedRowOptions, rowOptionsFilter.status]);\n\n const isRowNavigable = useCallback(\n (row: TMenuRow): boolean => (row.kind === 'item' ? !(context && resolveFlag(row.item.isDisabled, context, false)) : row.kind === 'node'),\n [context],\n );\n\n const firstNavigableIndex = useMemo(() => menuRows.findIndex(isRowNavigable), [menuRows, isRowNavigable]);\n\n /** Clamp into the viewport once the menu has been measured; row actions can arrive after the first paint. */\n useLayoutEffect(() => {\n if (!state || !menuRef.current) {\n setPosition(null);\n return;\n }\n\n const { width, height } = menuRef.current.getBoundingClientRect();\n const margin = CELL_CONTEXT_MENU_VIEWPORT_MARGIN;\n const offset = CELL_CONTEXT_MENU_CURSOR_OFFSET;\n\n // Flip to the other side of the cursor when there is no room, then clamp.\n const left = state.x + width + margin > window.innerWidth ? state.x - width - offset : state.x + offset;\n const top = state.y + height + margin > window.innerHeight ? state.y - height - offset : state.y + offset;\n\n setPosition({\n left: Math.max(margin, Math.min(left, window.innerWidth - width - margin)),\n top: Math.max(margin, Math.min(top, window.innerHeight - height - margin)),\n });\n }, [state, menuRows.length]);\n\n useEffect(() => {\n setCopyState(null);\n return () => clearTimeout(closeTimer.current);\n }, [state]);\n\n useEffect(() => {\n if (!state) {\n setActiveIndex(-1);\n return;\n }\n setActiveIndex(firstNavigableIndex);\n }, [state, firstNavigableIndex]);\n\n /** Focus follows the active row so the menu is keyboard operable; row actions bring their own button. */\n useEffect(() => {\n if (!state || activeIndex < 0) return;\n\n const row = menuRef.current?.querySelectorAll<HTMLElement>('[data-menu-item]')[activeIndex];\n const focusTarget = row?.matches('button') ? row : row?.querySelector('button') ?? row;\n\n // preventScroll: a focus-driven scroll would immediately close the menu.\n focusTarget?.focus({ preventScroll: true });\n }, [state, activeIndex]);\n\n const moveActiveIndex = useCallback(\n (direction: 1 | -1) => {\n if (menuRows.length === 0) return;\n setActiveIndex((current) => {\n let next = current;\n for (let step = 0; step < menuRows.length; step += 1) {\n next = (next + direction + menuRows.length) % menuRows.length;\n if (isRowNavigable(menuRows[next])) return next;\n }\n return current;\n });\n },\n [menuRows, isRowNavigable],\n );\n\n useEffect(() => {\n if (!state) return;\n\n const handlePointerDown = (event: MouseEvent | TouchEvent) => {\n if (menuRef.current && !menuRef.current.contains(event.target as Node)) onClose();\n };\n const handleKeyDown = (event: KeyboardEvent) => {\n if (event.key === 'Escape') {\n event.stopPropagation();\n onClose();\n return;\n }\n if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {\n event.preventDefault();\n moveActiveIndex(event.key === 'ArrowDown' ? 1 : -1);\n }\n };\n // Any scroll (table viewport included) detaches the menu from its cell, so close it.\n const handleScroll = () => onClose();\n\n // Deferred so the right click that opened the menu does not immediately close it.\n const timeoutId = setTimeout(() => {\n document.addEventListener('mousedown', handlePointerDown);\n document.addEventListener('touchstart', handlePointerDown);\n document.addEventListener('keydown', handleKeyDown);\n document.addEventListener('scroll', handleScroll, true);\n window.addEventListener('resize', handleScroll);\n }, 0);\n\n return () => {\n clearTimeout(timeoutId);\n document.removeEventListener('mousedown', handlePointerDown);\n document.removeEventListener('touchstart', handlePointerDown);\n document.removeEventListener('keydown', handleKeyDown);\n document.removeEventListener('scroll', handleScroll, true);\n window.removeEventListener('resize', handleScroll);\n };\n }, [state, onClose, moveActiveIndex]);\n\n if (!state || !context || menuRows.length === 0) return null;\n\n if (tableConfig?.renderCellContextMenu) {\n return tableConfig.renderCellContextMenu({ state, context, items, rowOptions: allowedRowOptions, onClose }) as JSX.Element;\n }\n\n const handleItemClick = async (item: ICellContextMenuItem): Promise<void> => {\n if (resolveFlag(item.isDisabled, context, false)) return;\n if (!item.keepOpenOnClick) onClose();\n await item.onClick?.(context);\n };\n\n return createPortal(\n <div\n ref={menuRef}\n role='menu'\n aria-label={t('Cell actions')}\n data-testid='cell-context-menu'\n className={cn(\n 'fixed min-w-[180px] max-w-[280px] py-1 rounded-lg font-inter',\n 'bg-white dark:bg-black-700',\n 'border border-neutral-200 dark:border-black-600',\n 'shadow-lg dark:shadow-black/40',\n config?.className,\n )}\n style={{\n left: position?.left ?? state.x,\n top: position?.top ?? state.y,\n zIndex: CELL_CONTEXT_MENU_Z_INDEX,\n // Hidden until measured so the flip/clamp never flashes at the wrong spot.\n visibility: position ? 'visible' : 'hidden',\n }}\n onContextMenu={(event) => event.preventDefault()}\n >\n {menuRows.map((row, index) => (\n <React.Fragment key={row.key}>\n {(row.kind === 'item' ? row.item.withDividerBefore && index > 0 : row.withDividerBefore) ? (\n <div className='my-1 h-px bg-neutral-200 dark:bg-black-600' />\n ) : null}\n {row.kind === 'item' ? (\n <MenuItemButton\n item={row.item}\n isDisabled={resolveFlag(row.item.isDisabled, context, false)}\n isActive={index === activeIndex}\n onSelect={() => void handleItemClick(row.item)}\n onHover={() => setActiveIndex(index)}\n />\n ) : row.kind === 'skeleton' ? (\n <div className='px-3 py-2' data-testid='cell-context-menu-loading'>\n <div className='h-3.5 w-full animate-pulse rounded bg-neutral-200 dark:bg-black-600' />\n </div>\n ) : (\n /* Row actions are rendered as the table supplied them — they carry their own button and handler. */\n <div data-menu-item tabIndex={-1} className='outline-none [&_button]:w-full' onClick={onClose} onMouseEnter={() => setActiveIndex(index)}>\n {row.node}\n </div>\n )}\n </React.Fragment>\n ))}\n </div>,\n document.body,\n );\n};\n"],"names":["writeToClipboard","text","textarea","copied","toAbsoluteUrl","href","resolveFlag","flag","context","fallback","MenuItemButton","item","isDisabled","isActive","onSelect","onHover","jsxs","cn","jsx","CellContextMenuPortal","state","config","rowOptions","asyncRowOptionsFilter","checkedIds","rows","columns","rowLinkConfig","onClose","tableConfig","useTableConfig","t","useMemo","key","menuRef","useRef","position","setPosition","useState","activeIndex","setActiveIndex","copyState","setCopyState","rowOptionsFilter","setRowOptionsFilter","closeTimer","handleCopy","useCallback","menuContext","isCopied","COPY_FEEDBACK_DURATION","buildCopyItem","label","icon","isDone","CheckIcon","ContentCopyIcon","rowJson","getRowJson","selectedRowsJson","getSelectedRowsJson","selectedCount","rowLinkPath","rowLinkResolvedHref","useHref","rowLinkHref","openInNewTab","items","defaultItems","LinkIcon","OpenInNewIcon","extraItems","resolvedRowOptions","option","hasRowOptions","useEffect","isCancelled","available","allowedRowOptions","menuRows","itemRows","needsDivider","index","isRowNavigable","row","firstNavigableIndex","useLayoutEffect","width","height","margin","CELL_CONTEXT_MENU_VIEWPORT_MARGIN","offset","CELL_CONTEXT_MENU_CURSOR_OFFSET","left","top","moveActiveIndex","direction","current","next","step","handlePointerDown","event","handleKeyDown","handleScroll","timeoutId","handleItemClick","createPortal","CELL_CONTEXT_MENU_Z_INDEX","React"],"mappings":"8ZAyDMA,GAAmB,MAAOC,GAAmC,CACjE,GAAI,CACF,GAAI,WAAW,WAAW,UACxB,aAAM,UAAU,UAAU,UAAUA,CAAI,EACjC,EAEX,MAAQ,CAER,CAEA,GAAI,CACF,MAAMC,EAAW,SAAS,cAAc,UAAU,EAClDA,EAAS,MAAQD,EACjBC,EAAS,aAAa,WAAY,EAAE,EACpCA,EAAS,MAAM,SAAW,QAC1BA,EAAS,MAAM,QAAU,IACzB,SAAS,KAAK,YAAYA,CAAQ,EAClCA,EAAS,OAAA,EACT,MAAMC,EAAS,SAAS,YAAY,MAAM,EAC1C,gBAAS,KAAK,YAAYD,CAAQ,EAC3BC,CACT,MAAQ,CACN,MAAO,EACT,CACF,EAGMC,GAAiBC,GAAyB,CAC9C,GAAI,CAACA,EAAM,MAAO,GAElB,GAAI,CACF,OAAO,IAAI,IAAIA,EAAM,OAAO,SAAS,MAAM,EAAE,IAC/C,MAAQ,CACN,MAAO,EACT,CACF,EAEMC,EAAc,CAClBC,EACAC,EACAC,IAEIF,IAAS,OAAkBE,EACxB,OAAOF,GAAS,WAAaA,EAAKC,CAAO,EAAID,EAGhDG,GAMD,CAAC,CAAE,KAAAC,EAAM,WAAAC,EAAY,SAAAC,EAAU,SAAAC,EAAU,QAAAC,KAC5CC,EAAAA,KAAC,SAAA,CACC,KAAK,SACL,KAAK,WACL,iBAAc,GACd,SAAUJ,EACV,gBAAeA,EACf,SAAUC,EAAW,EAAI,GACzB,UAAWI,EACT,sFACAL,EACI,gCACAK,EACE,iBACAN,EAAK,SACD,yIACA,4IAAA,CACN,EAEN,QAASG,EACT,aAAc,IAAM,CAACF,GAAcG,E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,KAAC4F,EAAM,SAAN,CACG,SAAA,EAAAxB,EAAI,OAAS,OAASA,EAAI,KAAK,mBAAqBF,EAAQ,EAAIE,EAAI,mBACpElE,EAAAA,IAAC,MAAA,CAAI,UAAU,6CAA6C,EAC1D,KACHkE,EAAI,OAAS,OACZlE,EAAAA,IAACR,GAAA,CACC,KAAM0E,EAAI,KACV,WAAY9E,EAAY8E,EAAI,KAAK,WAAY5E,EAAS,EAAK,EAC3D,SAAU0E,IAAU3C,EACpB,SAAU,IAAM,KAAKkE,EAAgBrB,EAAI,IAAI,EAC7C,QAAS,IAAM5C,EAAe0C,CAAK,CAAA,CAAA,EAEnCE,EAAI,OAAS,iBACd,MAAA,CAAI,UAAU,YAAY,cAAY,4BACrC,SAAAlE,MAAC,MAAA,CAAI,UAAU,sEAAsE,EACvF,QAGC,MAAA,CAAI,iBAAc,GAAC,SAAU,GAAI,UAAU,iCAAiC,QAASU,EAAS,aAAc,IAAMY,EAAe0C,CAAK,EACpI,WAAI,IAAA,CACP,CAAA,CAAA,EApBiBE,EAAI,GAsBzB,CACD,CAAA,CAAA,EAEH,SAAS,IAAA,CAEb"}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { jsx as c, jsxs as
|
|
2
|
-
import { useTableConfig as
|
|
3
|
-
import { getRowJson as
|
|
1
|
+
import { jsx as c, jsxs as Q } from "react/jsx-runtime";
|
|
2
|
+
import { useTableConfig as te } from "../../../providers/design-system-provider/hooks.es.js";
|
|
3
|
+
import { getRowJson as ne, getSelectedRowsJson as re } from "./copy-text.es.js";
|
|
4
4
|
import S from "../../../_virtual/index.es.js";
|
|
5
|
-
import
|
|
6
|
-
import { createPortal as
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
|
|
5
|
+
import oe, { useMemo as f, useRef as Z, useState as O, useCallback as C, useEffect as E, useLayoutEffect as ie } from "react";
|
|
6
|
+
import { createPortal as le } from "react-dom";
|
|
7
|
+
import { useHref as se } from "react-router-dom";
|
|
8
|
+
import { COPY_FEEDBACK_DURATION as ae, CELL_CONTEXT_MENU_VIEWPORT_MARGIN as ce, CELL_CONTEXT_MENU_Z_INDEX as ue, CELL_CONTEXT_MENU_CURSOR_OFFSET as de } from "./constants.es.js";
|
|
9
|
+
import { CheckIcon as me, ContentCopyIcon as fe, LinkIcon as pe, OpenInNewIcon as be } from "../../icon/icons.generated.es.js";
|
|
10
|
+
const we = async (t) => {
|
|
10
11
|
try {
|
|
11
12
|
if (navigator?.clipboard?.writeText)
|
|
12
13
|
return await navigator.clipboard.writeText(t), !0;
|
|
@@ -15,19 +16,19 @@ const fe = async (t) => {
|
|
|
15
16
|
try {
|
|
16
17
|
const o = document.createElement("textarea");
|
|
17
18
|
o.value = t, o.setAttribute("readonly", ""), o.style.position = "fixed", o.style.opacity = "0", document.body.appendChild(o), o.select();
|
|
18
|
-
const
|
|
19
|
-
return document.body.removeChild(o),
|
|
19
|
+
const u = document.execCommand("copy");
|
|
20
|
+
return document.body.removeChild(o), u;
|
|
20
21
|
} catch {
|
|
21
22
|
return !1;
|
|
22
23
|
}
|
|
23
|
-
},
|
|
24
|
+
}, he = (t) => {
|
|
24
25
|
if (!t) return "";
|
|
25
26
|
try {
|
|
26
|
-
return new URL(t, window.location.
|
|
27
|
+
return new URL(t, window.location.origin).href;
|
|
27
28
|
} catch {
|
|
28
29
|
return "";
|
|
29
30
|
}
|
|
30
|
-
}, _ = (t, o,
|
|
31
|
+
}, _ = (t, o, u) => t === void 0 ? u : typeof t == "function" ? t(o) : t, ke = ({ item: t, isDisabled: o, isActive: u, onSelect: y, onHover: x }) => /* @__PURE__ */ Q(
|
|
31
32
|
"button",
|
|
32
33
|
{
|
|
33
34
|
type: "button",
|
|
@@ -35,7 +36,7 @@ const fe = async (t) => {
|
|
|
35
36
|
"data-menu-item": !0,
|
|
36
37
|
disabled: o,
|
|
37
38
|
"aria-disabled": o,
|
|
38
|
-
tabIndex:
|
|
39
|
+
tabIndex: u ? 0 : -1,
|
|
39
40
|
className: S(
|
|
40
41
|
"flex w-full items-center gap-3 px-3 py-2 text-sm font-medium text-left outline-none",
|
|
41
42
|
o ? "opacity-50 cursor-not-allowed" : S(
|
|
@@ -51,71 +52,71 @@ const fe = async (t) => {
|
|
|
51
52
|
t.shortcut ? /* @__PURE__ */ c("span", { className: "shrink-0 text-xs text-neutral-400 dark:text-black-300", children: t.shortcut }) : null
|
|
52
53
|
]
|
|
53
54
|
}
|
|
54
|
-
),
|
|
55
|
+
), Re = ({
|
|
55
56
|
state: t,
|
|
56
57
|
config: o,
|
|
57
|
-
rowOptions:
|
|
58
|
+
rowOptions: u,
|
|
58
59
|
asyncRowOptionsFilter: y,
|
|
59
60
|
checkedIds: x,
|
|
60
|
-
rows:
|
|
61
|
+
rows: H,
|
|
61
62
|
columns: N,
|
|
62
63
|
rowLinkConfig: I,
|
|
63
|
-
onClose:
|
|
64
|
+
onClose: d
|
|
64
65
|
}) => {
|
|
65
|
-
const p =
|
|
66
|
-
() => t ? { ...t.target, close:
|
|
67
|
-
[t,
|
|
68
|
-
),
|
|
66
|
+
const p = te(), l = f(() => p?.t ?? ((e) => e), [p]), b = Z(null), [A, F] = O(null), [D, v] = O(-1), [w, J] = O(null), [h, R] = O({ status: "off" }), X = Z(), s = f(
|
|
67
|
+
() => t ? { ...t.target, close: d } : null,
|
|
68
|
+
[t, d]
|
|
69
|
+
), V = C(
|
|
69
70
|
async (e, n, r) => {
|
|
70
|
-
if (
|
|
71
|
-
const i = await
|
|
72
|
-
i ? (o?.onCopy?.(n, r), p?.showNotification?.("success", l("Copied to clipboard"))) : p?.showNotification?.("error", l("Could not copy to clipboard")),
|
|
71
|
+
if (w) return;
|
|
72
|
+
const i = await we(n);
|
|
73
|
+
i ? (o?.onCopy?.(n, r), p?.showNotification?.("success", l("Copied to clipboard"))) : p?.showNotification?.("error", l("Could not copy to clipboard")), J({ key: e, isCopied: i }), X.current = setTimeout(() => d(), ae);
|
|
73
74
|
},
|
|
74
|
-
[o, p, l,
|
|
75
|
+
[o, p, l, d, w]
|
|
75
76
|
), g = C(
|
|
76
77
|
(e, n, r, i) => {
|
|
77
|
-
const a =
|
|
78
|
+
const a = w?.key === e;
|
|
78
79
|
return {
|
|
79
80
|
key: e,
|
|
80
|
-
label: a ?
|
|
81
|
-
icon: a &&
|
|
81
|
+
label: a ? w?.isCopied ? l("Copied") : l("Copy failed") : n,
|
|
82
|
+
icon: a && w?.isCopied ? /* @__PURE__ */ c(me, { size: 16, className: "text-success-600 dark:text-success-400" }) : i ?? /* @__PURE__ */ c(fe, { size: 16 }),
|
|
82
83
|
isDisabled: !r,
|
|
83
84
|
keepOpenOnClick: !0,
|
|
84
|
-
onClick: (z) =>
|
|
85
|
+
onClick: (z) => V(e, r, z)
|
|
85
86
|
};
|
|
86
87
|
},
|
|
87
|
-
[
|
|
88
|
-
),
|
|
88
|
+
[w, V, l]
|
|
89
|
+
), W = f(() => ne(t?.target.rowData, N), [t?.target.rowData, N]), $ = f(() => t ? re(H, N, x) : "", [t, H, N, x]), T = x?.length ?? 0, B = f(() => !t || !I?.isEnabled || !I.linkTo || t.target.column?.disableRowClick ? "" : I.linkTo(String(t.target.rowId), t.target.rowData) || "", [t, I]), j = se(B || "/"), k = f(() => B ? he(j) : "", [B, j]), q = C(() => {
|
|
89
90
|
k && window.open(k, "_blank", "noopener,noreferrer");
|
|
90
|
-
}, [k]),
|
|
91
|
+
}, [k]), P = f(() => {
|
|
91
92
|
if (!s) return [];
|
|
92
93
|
const e = o?.hideDefaultItems ? [] : [
|
|
93
94
|
g("copy-cell", o?.copyLabel ?? l("Copy Cell"), s.text),
|
|
94
|
-
g("copy-row", l("Copy Row"),
|
|
95
|
+
g("copy-row", l("Copy Row"), W),
|
|
95
96
|
...T > 0 ? [
|
|
96
97
|
g(
|
|
97
98
|
"copy-selected-rows",
|
|
98
99
|
T === 1 ? l("Copy Selected Row") : `${l("Copy Selected Rows")} (${T})`,
|
|
99
|
-
|
|
100
|
+
$
|
|
100
101
|
)
|
|
101
102
|
] : [],
|
|
102
103
|
...k && !o?.hideLinkItems ? [
|
|
103
104
|
{
|
|
104
|
-
...g("copy-link", l("Copy Link"), k, /* @__PURE__ */ c(
|
|
105
|
+
...g("copy-link", l("Copy Link"), k, /* @__PURE__ */ c(pe, { size: 16 })),
|
|
105
106
|
withDividerBefore: !0
|
|
106
107
|
},
|
|
107
108
|
{
|
|
108
109
|
key: "open-in-new-tab",
|
|
109
110
|
label: l("Open in New Tab"),
|
|
110
|
-
icon: /* @__PURE__ */ c(
|
|
111
|
-
onClick:
|
|
111
|
+
icon: /* @__PURE__ */ c(be, { size: 16 }),
|
|
112
|
+
onClick: q
|
|
112
113
|
}
|
|
113
114
|
] : []
|
|
114
115
|
], n = typeof o?.items == "function" ? o.items(s) : o?.items ?? [];
|
|
115
116
|
return [...e, ...n].filter((r) => _(r.isVisible, s, !0));
|
|
116
|
-
}, [o, s, g, T,
|
|
117
|
+
}, [o, s, g, T, W, $, k, q, l]), L = f(() => !t || o?.includeRowOptions === !1 || !u ? [] : ((typeof u == "function" ? u(t.target.rowData) : u) ?? []).filter((n) => n.isVisible !== !1), [t, u, o?.includeRowOptions]), K = L.length > 0;
|
|
117
118
|
E(() => {
|
|
118
|
-
if (!t || !
|
|
119
|
+
if (!t || !K || !y) {
|
|
119
120
|
R({ status: "off" });
|
|
120
121
|
return;
|
|
121
122
|
}
|
|
@@ -123,15 +124,15 @@ const fe = async (t) => {
|
|
|
123
124
|
return R({ status: "loading" }), y(String(t.target.rowId)).then((n) => !e && R({ status: "ready", available: n })).catch(() => !e && R({ status: "failed" })), () => {
|
|
124
125
|
e = !0;
|
|
125
126
|
};
|
|
126
|
-
}, [t,
|
|
127
|
+
}, [t, K, y]);
|
|
127
128
|
const U = f(() => {
|
|
128
|
-
if (
|
|
129
|
-
if (
|
|
130
|
-
const { available: e } =
|
|
129
|
+
if (h.status === "off") return L;
|
|
130
|
+
if (h.status !== "ready") return [];
|
|
131
|
+
const { available: e } = h;
|
|
131
132
|
return L.filter((n) => e[n.key] ?? !0);
|
|
132
|
-
}, [L,
|
|
133
|
-
const e =
|
|
134
|
-
return
|
|
133
|
+
}, [L, h]), m = f(() => {
|
|
134
|
+
const e = P.map((r) => ({ kind: "item", key: r.key, item: r })), n = e.length > 0;
|
|
135
|
+
return h.status === "loading" ? [...e, { kind: "skeleton", key: "row-options-loading", withDividerBefore: n }] : [
|
|
135
136
|
...e,
|
|
136
137
|
...U.map((r, i) => ({
|
|
137
138
|
kind: "node",
|
|
@@ -140,32 +141,32 @@ const fe = async (t) => {
|
|
|
140
141
|
withDividerBefore: n && i === 0
|
|
141
142
|
}))
|
|
142
143
|
];
|
|
143
|
-
}, [
|
|
144
|
+
}, [P, U, h.status]), M = C(
|
|
144
145
|
(e) => e.kind === "item" ? !(s && _(e.item.isDisabled, s, !1)) : e.kind === "node",
|
|
145
146
|
[s]
|
|
146
|
-
),
|
|
147
|
-
|
|
147
|
+
), G = f(() => m.findIndex(M), [m, M]);
|
|
148
|
+
ie(() => {
|
|
148
149
|
if (!t || !b.current) {
|
|
149
150
|
F(null);
|
|
150
151
|
return;
|
|
151
152
|
}
|
|
152
|
-
const { width: e, height: n } = b.current.getBoundingClientRect(), r =
|
|
153
|
+
const { width: e, height: n } = b.current.getBoundingClientRect(), r = ce, i = de, a = t.x + e + r > window.innerWidth ? t.x - e - i : t.x + i, z = t.y + n + r > window.innerHeight ? t.y - n - i : t.y + i;
|
|
153
154
|
F({
|
|
154
155
|
left: Math.max(r, Math.min(a, window.innerWidth - e - r)),
|
|
155
156
|
top: Math.max(r, Math.min(z, window.innerHeight - n - r))
|
|
156
157
|
});
|
|
157
|
-
}, [t, m.length]), E(() => (
|
|
158
|
+
}, [t, m.length]), E(() => (J(null), () => clearTimeout(X.current)), [t]), E(() => {
|
|
158
159
|
if (!t) {
|
|
159
160
|
v(-1);
|
|
160
161
|
return;
|
|
161
162
|
}
|
|
162
|
-
v(
|
|
163
|
-
}, [t,
|
|
163
|
+
v(G);
|
|
164
|
+
}, [t, G]), E(() => {
|
|
164
165
|
if (!t || D < 0) return;
|
|
165
166
|
const e = b.current?.querySelectorAll("[data-menu-item]")[D];
|
|
166
167
|
(e?.matches("button") ? e : e?.querySelector("button") ?? e)?.focus({ preventScroll: !0 });
|
|
167
168
|
}, [t, D]);
|
|
168
|
-
const
|
|
169
|
+
const Y = C(
|
|
169
170
|
(e) => {
|
|
170
171
|
m.length !== 0 && v((n) => {
|
|
171
172
|
let r = n;
|
|
@@ -179,26 +180,26 @@ const fe = async (t) => {
|
|
|
179
180
|
if (E(() => {
|
|
180
181
|
if (!t) return;
|
|
181
182
|
const e = (a) => {
|
|
182
|
-
b.current && !b.current.contains(a.target) &&
|
|
183
|
+
b.current && !b.current.contains(a.target) && d();
|
|
183
184
|
}, n = (a) => {
|
|
184
185
|
if (a.key === "Escape") {
|
|
185
|
-
a.stopPropagation(),
|
|
186
|
+
a.stopPropagation(), d();
|
|
186
187
|
return;
|
|
187
188
|
}
|
|
188
|
-
(a.key === "ArrowDown" || a.key === "ArrowUp") && (a.preventDefault(),
|
|
189
|
-
}, r = () =>
|
|
189
|
+
(a.key === "ArrowDown" || a.key === "ArrowUp") && (a.preventDefault(), Y(a.key === "ArrowDown" ? 1 : -1));
|
|
190
|
+
}, r = () => d(), i = setTimeout(() => {
|
|
190
191
|
document.addEventListener("mousedown", e), document.addEventListener("touchstart", e), document.addEventListener("keydown", n), document.addEventListener("scroll", r, !0), window.addEventListener("resize", r);
|
|
191
192
|
}, 0);
|
|
192
193
|
return () => {
|
|
193
194
|
clearTimeout(i), document.removeEventListener("mousedown", e), document.removeEventListener("touchstart", e), document.removeEventListener("keydown", n), document.removeEventListener("scroll", r, !0), window.removeEventListener("resize", r);
|
|
194
195
|
};
|
|
195
|
-
}, [t,
|
|
196
|
+
}, [t, d, Y]), !t || !s || m.length === 0) return null;
|
|
196
197
|
if (p?.renderCellContextMenu)
|
|
197
|
-
return p.renderCellContextMenu({ state: t, context: s, items:
|
|
198
|
-
const
|
|
199
|
-
_(e.isDisabled, s, !1) || (e.keepOpenOnClick ||
|
|
198
|
+
return p.renderCellContextMenu({ state: t, context: s, items: P, rowOptions: U, onClose: d });
|
|
199
|
+
const ee = async (e) => {
|
|
200
|
+
_(e.isDisabled, s, !1) || (e.keepOpenOnClick || d(), await e.onClick?.(s));
|
|
200
201
|
};
|
|
201
|
-
return
|
|
202
|
+
return le(
|
|
202
203
|
/* @__PURE__ */ c(
|
|
203
204
|
"div",
|
|
204
205
|
{
|
|
@@ -216,25 +217,25 @@ const fe = async (t) => {
|
|
|
216
217
|
style: {
|
|
217
218
|
left: A?.left ?? t.x,
|
|
218
219
|
top: A?.top ?? t.y,
|
|
219
|
-
zIndex:
|
|
220
|
+
zIndex: ue,
|
|
220
221
|
// Hidden until measured so the flip/clamp never flashes at the wrong spot.
|
|
221
222
|
visibility: A ? "visible" : "hidden"
|
|
222
223
|
},
|
|
223
224
|
onContextMenu: (e) => e.preventDefault(),
|
|
224
|
-
children: m.map((e, n) => /* @__PURE__ */
|
|
225
|
+
children: m.map((e, n) => /* @__PURE__ */ Q(oe.Fragment, { children: [
|
|
225
226
|
(e.kind === "item" ? e.item.withDividerBefore && n > 0 : e.withDividerBefore) ? /* @__PURE__ */ c("div", { className: "my-1 h-px bg-neutral-200 dark:bg-black-600" }) : null,
|
|
226
227
|
e.kind === "item" ? /* @__PURE__ */ c(
|
|
227
|
-
|
|
228
|
+
ke,
|
|
228
229
|
{
|
|
229
230
|
item: e.item,
|
|
230
231
|
isDisabled: _(e.item.isDisabled, s, !1),
|
|
231
232
|
isActive: n === D,
|
|
232
|
-
onSelect: () => void
|
|
233
|
+
onSelect: () => void ee(e.item),
|
|
233
234
|
onHover: () => v(n)
|
|
234
235
|
}
|
|
235
236
|
) : e.kind === "skeleton" ? /* @__PURE__ */ c("div", { className: "px-3 py-2", "data-testid": "cell-context-menu-loading", children: /* @__PURE__ */ c("div", { className: "h-3.5 w-full animate-pulse rounded bg-neutral-200 dark:bg-black-600" }) }) : (
|
|
236
237
|
/* Row actions are rendered as the table supplied them — they carry their own button and handler. */
|
|
237
|
-
/* @__PURE__ */ c("div", { "data-menu-item": !0, tabIndex: -1, className: "outline-none [&_button]:w-full", onClick:
|
|
238
|
+
/* @__PURE__ */ c("div", { "data-menu-item": !0, tabIndex: -1, className: "outline-none [&_button]:w-full", onClick: d, onMouseEnter: () => v(n), children: e.node })
|
|
238
239
|
)
|
|
239
240
|
] }, e.key))
|
|
240
241
|
}
|
|
@@ -243,6 +244,6 @@ const fe = async (t) => {
|
|
|
243
244
|
);
|
|
244
245
|
};
|
|
245
246
|
export {
|
|
246
|
-
|
|
247
|
+
Re as CellContextMenuPortal
|
|
247
248
|
};
|
|
248
249
|
//# sourceMappingURL=CellContextMenuPortal.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CellContextMenuPortal.es.js","sources":["../../../../src/components/data-display/infinite-table/CellContextMenuPortal.tsx"],"sourcesContent":["import { useTableConfig } from '../../../providers/design-system-provider/hooks';\nimport { CheckIcon, ContentCopyIcon, LinkIcon, OpenInNewIcon } from '../../icon';\nimport type {\n ICellContextMenuConfig,\n ICellContextMenuContext,\n ICellContextMenuItem,\n ICellContextMenuState,\n IColumn,\n IRowLinkConfig,\n} from './types';\nimport { getRowJson, getSelectedRowsJson } from './copy-text';\nimport cn from 'classnames';\nimport React, { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react';\nimport { createPortal } from 'react-dom';\n\nimport {\n CELL_CONTEXT_MENU_CURSOR_OFFSET,\n COPY_FEEDBACK_DURATION,\n CELL_CONTEXT_MENU_VIEWPORT_MARGIN,\n CELL_CONTEXT_MENU_Z_INDEX,\n} from './constants';\n\ntype TRowOption = { key: string; label: React.ReactNode; isVisible?: boolean };\n\n/** Result of the per-row availability check for row actions. */\ntype TRowOptionsFilter =\n | { status: 'off' }\n | { status: 'loading' }\n | { status: 'ready'; available: Record<string, boolean> }\n | { status: 'failed' };\n\n/** One rendered menu line: a declared item, a row-action node supplied by the table, or the row-action placeholder. */\ntype TMenuRow =\n | { kind: 'item'; key: string; item: ICellContextMenuItem }\n | { kind: 'node'; key: string; node: React.ReactNode; withDividerBefore?: boolean }\n | { kind: 'skeleton'; key: string; withDividerBefore?: boolean };\n\ninterface CellContextMenuPortalProps {\n state: ICellContextMenuState | null;\n config?: ICellContextMenuConfig | null;\n /** The table's row actions, appended to the menu — same list the three-dot cell renders. */\n rowOptions?: TRowOption[] | ((rowData: Record<string, unknown>) => TRowOption[] | null) | null;\n /** Per-row availability check for `rowOptions`, mirroring the three-dot cell so both menus agree. */\n asyncRowOptionsFilter?: ((rowId: string) => Promise<Record<string, boolean>>) | null;\n /** Checked row ids, enabling the \"Copy selected rows\" item. */\n checkedIds?: (string | number)[];\n /** Table rows, used to build the text for selected rows that are scrolled out of view. */\n rows?: Record<string, unknown>[];\n /** Visible columns in display order, used to order the copied values. */\n columns?: IColumn[];\n /** The table's row link, enabling the \"Copy Link\" / \"Open in New Tab\" items. */\n rowLinkConfig?: IRowLinkConfig | null;\n onClose: () => void;\n}\n\n/** Clipboard write with a fallback for browsers / insecure contexts without the async clipboard API. */\nconst writeToClipboard = async (text: string): Promise<boolean> => {\n try {\n if (navigator?.clipboard?.writeText) {\n await navigator.clipboard.writeText(text);\n return true;\n }\n } catch {\n // fall through to the textarea fallback\n }\n\n try {\n const textarea = document.createElement('textarea');\n textarea.value = text;\n textarea.setAttribute('readonly', '');\n textarea.style.position = 'fixed';\n textarea.style.opacity = '0';\n document.body.appendChild(textarea);\n textarea.select();\n const copied = document.execCommand('copy');\n document.body.removeChild(textarea);\n return copied;\n } catch {\n return false;\n }\n};\n\n/** `linkTo` returns a router path; the clipboard and a new tab both need a full URL. */\nconst toAbsoluteUrl = (path: string): string => {\n if (!path) return '';\n\n try {\n return new URL(path, window.location.href).href;\n } catch {\n return '';\n }\n};\n\nconst resolveFlag = (\n flag: boolean | ((context: ICellContextMenuContext) => boolean) | undefined,\n context: ICellContextMenuContext,\n fallback: boolean,\n): boolean => {\n if (flag === undefined) return fallback;\n return typeof flag === 'function' ? flag(context) : flag;\n};\n\nconst MenuItemButton: React.FC<{\n item: ICellContextMenuItem;\n isDisabled: boolean;\n isActive: boolean;\n onSelect: () => void;\n onHover: () => void;\n}> = ({ item, isDisabled, isActive, onSelect, onHover }) => (\n <button\n type='button'\n role='menuitem'\n data-menu-item\n disabled={isDisabled}\n aria-disabled={isDisabled}\n tabIndex={isActive ? 0 : -1}\n className={cn(\n 'flex w-full items-center gap-3 px-3 py-2 text-sm font-medium text-left outline-none',\n isDisabled\n ? 'opacity-50 cursor-not-allowed'\n : cn(\n 'cursor-pointer',\n item.isDanger\n ? 'text-error-600 dark:text-error-400 hover:bg-error-50 dark:hover:bg-error-950 focus-visible:bg-error-50 dark:focus-visible:bg-error-950'\n : 'text-neutral-900 dark:text-white hover:bg-neutral-100 dark:hover:bg-black-600 focus-visible:bg-neutral-100 dark:focus-visible:bg-black-600',\n ),\n )}\n onClick={onSelect}\n onMouseEnter={() => !isDisabled && onHover()}\n >\n {item.icon ? (\n <span className={cn('flex shrink-0 items-center', item.isDanger ? 'text-error-600 dark:text-error-400' : 'text-neutral-500 dark:text-black-300')}>\n {item.icon}\n </span>\n ) : null}\n <span className='flex-1 truncate'>{item.label}</span>\n {item.shortcut ? <span className='shrink-0 text-xs text-neutral-400 dark:text-black-300'>{item.shortcut}</span> : null}\n </button>\n);\n\n/**\n * Right-click menu for data cells. Rendered once per table and positioned at the\n * cursor; `DataCell` opens it through `openCellContextMenu` on the table context.\n */\nexport const CellContextMenuPortal: React.FC<CellContextMenuPortalProps> = ({\n state, config, rowOptions, asyncRowOptionsFilter, checkedIds, rows, columns, rowLinkConfig, onClose,\n}) => {\n const tableConfig = useTableConfig();\n const t = useMemo(() => tableConfig?.t ?? ((key: string) => key), [tableConfig]);\n const menuRef = useRef<HTMLDivElement>(null);\n const [position, setPosition] = useState<{ left: number; top: number } | null>(null);\n const [activeIndex, setActiveIndex] = useState(-1);\n const [copyState, setCopyState] = useState<{ key: string; isCopied: boolean } | null>(null);\n const [rowOptionsFilter, setRowOptionsFilter] = useState<TRowOptionsFilter>({ status: 'off' });\n const closeTimer = useRef<ReturnType<typeof setTimeout>>();\n\n const context = useMemo<ICellContextMenuContext | null>(\n () => (state ? { ...state.target, close: onClose } : null),\n [state, onClose],\n );\n\n const handleCopy = useCallback(\n async (key: string, text: string, menuContext: ICellContextMenuContext) => {\n if (copyState) return;\n\n const isCopied = await writeToClipboard(text);\n\n if (isCopied) {\n config?.onCopy?.(text, menuContext);\n tableConfig?.showNotification?.('success', t('Copied to clipboard'));\n } else {\n tableConfig?.showNotification?.('error', t('Could not copy to clipboard'));\n }\n\n // Confirmed inline instead of with a toast, so the menu owns its own feedback.\n setCopyState({ key, isCopied });\n closeTimer.current = setTimeout(() => onClose(), COPY_FEEDBACK_DURATION);\n },\n [config, tableConfig, t, onClose, copyState],\n );\n\n const buildCopyItem = useCallback(\n (key: string, label: string, text: string, icon?: React.ReactNode): ICellContextMenuItem => {\n const isDone = copyState?.key === key;\n\n return {\n key,\n label: !isDone ? label : copyState?.isCopied ? t('Copied') : t('Copy failed'),\n icon:\n isDone && copyState?.isCopied ? (\n <CheckIcon size={16} className='text-success-600 dark:text-success-400' />\n ) : (\n icon ?? <ContentCopyIcon size={16} />\n ),\n isDisabled: !text,\n keepOpenOnClick: true,\n onClick: (menuContext) => handleCopy(key, text, menuContext),\n };\n },\n [copyState, handleCopy, t],\n );\n\n const rowJson = useMemo(() => getRowJson(state?.target.rowData, columns), [state?.target.rowData, columns]);\n // Only while the menu is open — otherwise every checkbox tick would serialize the selection.\n const selectedRowsJson = useMemo(() => (state ? getSelectedRowsJson(rows, columns, checkedIds) : ''), [state, rows, columns, checkedIds]);\n const selectedCount = checkedIds?.length ?? 0;\n\n /** The row link as an absolute URL — empty unless the table opted in, and never on a cell that opts out of the row link. */\n const rowLinkHref = useMemo(() => {\n if (!state || !rowLinkConfig?.isEnabled || !rowLinkConfig.linkTo || state.target.column?.disableRowClick) return '';\n\n return toAbsoluteUrl(rowLinkConfig.linkTo(String(state.target.rowId), state.target.rowData));\n }, [state, rowLinkConfig]);\n\n const openInNewTab = useCallback(() => {\n if (rowLinkHref) window.open(rowLinkHref, '_blank', 'noopener,noreferrer');\n }, [rowLinkHref]);\n\n const items = useMemo<ICellContextMenuItem[]>(() => {\n if (!context) return [];\n\n const defaultItems: ICellContextMenuItem[] = config?.hideDefaultItems\n ? []\n : [\n buildCopyItem('copy-cell', config?.copyLabel ?? t('Copy Cell'), context.text),\n buildCopyItem('copy-row', t('Copy Row'), rowJson),\n ...(selectedCount > 0\n ? [\n buildCopyItem(\n 'copy-selected-rows',\n selectedCount === 1 ? t('Copy Selected Row') : `${t('Copy Selected Rows')} (${selectedCount})`,\n selectedRowsJson,\n ),\n ]\n : []),\n ...(rowLinkHref && !config?.hideLinkItems\n ? [\n {\n ...buildCopyItem('copy-link', t('Copy Link'), rowLinkHref, <LinkIcon size={16} />),\n withDividerBefore: true,\n },\n {\n key: 'open-in-new-tab',\n label: t('Open in New Tab'),\n icon: <OpenInNewIcon size={16} />,\n onClick: openInNewTab,\n },\n ]\n : []),\n ];\n\n const extraItems = typeof config?.items === 'function' ? config.items(context) : config?.items ?? [];\n\n return [...defaultItems, ...extraItems].filter((item) => resolveFlag(item.isVisible, context, true));\n }, [config, context, buildCopyItem, selectedCount, rowJson, selectedRowsJson, rowLinkHref, openInNewTab, t]);\n\n /** The table's own row actions, resolved for the right-clicked row. */\n const resolvedRowOptions = useMemo<TRowOption[]>(() => {\n if (!state || config?.includeRowOptions === false || !rowOptions) return [];\n\n const list = typeof rowOptions === 'function' ? rowOptions(state.target.rowData) : rowOptions;\n\n return (list ?? []).filter((option) => option.isVisible !== false);\n }, [state, rowOptions, config?.includeRowOptions]);\n\n const hasRowOptions = resolvedRowOptions.length > 0;\n\n /** Row actions can be gated per row by the API — ask before showing them, exactly as the three-dot cell does. */\n useEffect(() => {\n if (!state || !hasRowOptions || !asyncRowOptionsFilter) {\n setRowOptionsFilter({ status: 'off' });\n return;\n }\n\n let isCancelled = false;\n setRowOptionsFilter({ status: 'loading' });\n\n asyncRowOptionsFilter(String(state.target.rowId))\n .then((available) => !isCancelled && setRowOptionsFilter({ status: 'ready', available }))\n .catch(() => !isCancelled && setRowOptionsFilter({ status: 'failed' }));\n\n return () => {\n isCancelled = true;\n };\n }, [state, hasRowOptions, asyncRowOptionsFilter]);\n\n const allowedRowOptions = useMemo<TRowOption[]>(() => {\n if (rowOptionsFilter.status === 'off') return resolvedRowOptions;\n if (rowOptionsFilter.status !== 'ready') return [];\n\n const { available } = rowOptionsFilter;\n\n return resolvedRowOptions.filter((option) => available[option.key] ?? true);\n }, [resolvedRowOptions, rowOptionsFilter]);\n\n const menuRows = useMemo<TMenuRow[]>(() => {\n const itemRows: TMenuRow[] = items.map((item) => ({ kind: 'item', key: item.key, item }));\n const needsDivider = itemRows.length > 0;\n\n if (rowOptionsFilter.status === 'loading') {\n return [...itemRows, { kind: 'skeleton', key: 'row-options-loading', withDividerBefore: needsDivider }];\n }\n\n return [\n ...itemRows,\n ...allowedRowOptions.map<TMenuRow>((option, index) => ({\n kind: 'node',\n key: `row-option-${option.key}`,\n node: option.label,\n withDividerBefore: needsDivider && index === 0,\n })),\n ];\n }, [items, allowedRowOptions, rowOptionsFilter.status]);\n\n const isRowNavigable = useCallback(\n (row: TMenuRow): boolean => (row.kind === 'item' ? !(context && resolveFlag(row.item.isDisabled, context, false)) : row.kind === 'node'),\n [context],\n );\n\n const firstNavigableIndex = useMemo(() => menuRows.findIndex(isRowNavigable), [menuRows, isRowNavigable]);\n\n /** Clamp into the viewport once the menu has been measured; row actions can arrive after the first paint. */\n useLayoutEffect(() => {\n if (!state || !menuRef.current) {\n setPosition(null);\n return;\n }\n\n const { width, height } = menuRef.current.getBoundingClientRect();\n const margin = CELL_CONTEXT_MENU_VIEWPORT_MARGIN;\n const offset = CELL_CONTEXT_MENU_CURSOR_OFFSET;\n\n // Flip to the other side of the cursor when there is no room, then clamp.\n const left = state.x + width + margin > window.innerWidth ? state.x - width - offset : state.x + offset;\n const top = state.y + height + margin > window.innerHeight ? state.y - height - offset : state.y + offset;\n\n setPosition({\n left: Math.max(margin, Math.min(left, window.innerWidth - width - margin)),\n top: Math.max(margin, Math.min(top, window.innerHeight - height - margin)),\n });\n }, [state, menuRows.length]);\n\n useEffect(() => {\n setCopyState(null);\n return () => clearTimeout(closeTimer.current);\n }, [state]);\n\n useEffect(() => {\n if (!state) {\n setActiveIndex(-1);\n return;\n }\n setActiveIndex(firstNavigableIndex);\n }, [state, firstNavigableIndex]);\n\n /** Focus follows the active row so the menu is keyboard operable; row actions bring their own button. */\n useEffect(() => {\n if (!state || activeIndex < 0) return;\n\n const row = menuRef.current?.querySelectorAll<HTMLElement>('[data-menu-item]')[activeIndex];\n const focusTarget = row?.matches('button') ? row : row?.querySelector('button') ?? row;\n\n // preventScroll: a focus-driven scroll would immediately close the menu.\n focusTarget?.focus({ preventScroll: true });\n }, [state, activeIndex]);\n\n const moveActiveIndex = useCallback(\n (direction: 1 | -1) => {\n if (menuRows.length === 0) return;\n setActiveIndex((current) => {\n let next = current;\n for (let step = 0; step < menuRows.length; step += 1) {\n next = (next + direction + menuRows.length) % menuRows.length;\n if (isRowNavigable(menuRows[next])) return next;\n }\n return current;\n });\n },\n [menuRows, isRowNavigable],\n );\n\n useEffect(() => {\n if (!state) return;\n\n const handlePointerDown = (event: MouseEvent | TouchEvent) => {\n if (menuRef.current && !menuRef.current.contains(event.target as Node)) onClose();\n };\n const handleKeyDown = (event: KeyboardEvent) => {\n if (event.key === 'Escape') {\n event.stopPropagation();\n onClose();\n return;\n }\n if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {\n event.preventDefault();\n moveActiveIndex(event.key === 'ArrowDown' ? 1 : -1);\n }\n };\n // Any scroll (table viewport included) detaches the menu from its cell, so close it.\n const handleScroll = () => onClose();\n\n // Deferred so the right click that opened the menu does not immediately close it.\n const timeoutId = setTimeout(() => {\n document.addEventListener('mousedown', handlePointerDown);\n document.addEventListener('touchstart', handlePointerDown);\n document.addEventListener('keydown', handleKeyDown);\n document.addEventListener('scroll', handleScroll, true);\n window.addEventListener('resize', handleScroll);\n }, 0);\n\n return () => {\n clearTimeout(timeoutId);\n document.removeEventListener('mousedown', handlePointerDown);\n document.removeEventListener('touchstart', handlePointerDown);\n document.removeEventListener('keydown', handleKeyDown);\n document.removeEventListener('scroll', handleScroll, true);\n window.removeEventListener('resize', handleScroll);\n };\n }, [state, onClose, moveActiveIndex]);\n\n if (!state || !context || menuRows.length === 0) return null;\n\n if (tableConfig?.renderCellContextMenu) {\n return tableConfig.renderCellContextMenu({ state, context, items, rowOptions: allowedRowOptions, onClose }) as JSX.Element;\n }\n\n const handleItemClick = async (item: ICellContextMenuItem): Promise<void> => {\n if (resolveFlag(item.isDisabled, context, false)) return;\n if (!item.keepOpenOnClick) onClose();\n await item.onClick?.(context);\n };\n\n return createPortal(\n <div\n ref={menuRef}\n role='menu'\n aria-label={t('Cell actions')}\n data-testid='cell-context-menu'\n className={cn(\n 'fixed min-w-[180px] max-w-[280px] py-1 rounded-lg font-inter',\n 'bg-white dark:bg-black-700',\n 'border border-neutral-200 dark:border-black-600',\n 'shadow-lg dark:shadow-black/40',\n config?.className,\n )}\n style={{\n left: position?.left ?? state.x,\n top: position?.top ?? state.y,\n zIndex: CELL_CONTEXT_MENU_Z_INDEX,\n // Hidden until measured so the flip/clamp never flashes at the wrong spot.\n visibility: position ? 'visible' : 'hidden',\n }}\n onContextMenu={(event) => event.preventDefault()}\n >\n {menuRows.map((row, index) => (\n <React.Fragment key={row.key}>\n {(row.kind === 'item' ? row.item.withDividerBefore && index > 0 : row.withDividerBefore) ? (\n <div className='my-1 h-px bg-neutral-200 dark:bg-black-600' />\n ) : null}\n {row.kind === 'item' ? (\n <MenuItemButton\n item={row.item}\n isDisabled={resolveFlag(row.item.isDisabled, context, false)}\n isActive={index === activeIndex}\n onSelect={() => void handleItemClick(row.item)}\n onHover={() => setActiveIndex(index)}\n />\n ) : row.kind === 'skeleton' ? (\n <div className='px-3 py-2' data-testid='cell-context-menu-loading'>\n <div className='h-3.5 w-full animate-pulse rounded bg-neutral-200 dark:bg-black-600' />\n </div>\n ) : (\n /* Row actions are rendered as the table supplied them — they carry their own button and handler. */\n <div data-menu-item tabIndex={-1} className='outline-none [&_button]:w-full' onClick={onClose} onMouseEnter={() => setActiveIndex(index)}>\n {row.node}\n </div>\n )}\n </React.Fragment>\n ))}\n </div>,\n document.body,\n );\n};\n"],"names":["writeToClipboard","text","textarea","copied","toAbsoluteUrl","path","resolveFlag","flag","context","fallback","MenuItemButton","item","isDisabled","isActive","onSelect","onHover","jsxs","cn","jsx","CellContextMenuPortal","state","config","rowOptions","asyncRowOptionsFilter","checkedIds","rows","columns","rowLinkConfig","onClose","tableConfig","useTableConfig","t","useMemo","key","menuRef","useRef","position","setPosition","useState","activeIndex","setActiveIndex","copyState","setCopyState","rowOptionsFilter","setRowOptionsFilter","closeTimer","handleCopy","useCallback","menuContext","isCopied","COPY_FEEDBACK_DURATION","buildCopyItem","label","icon","isDone","CheckIcon","ContentCopyIcon","rowJson","getRowJson","selectedRowsJson","getSelectedRowsJson","selectedCount","rowLinkHref","openInNewTab","items","defaultItems","LinkIcon","OpenInNewIcon","extraItems","resolvedRowOptions","option","hasRowOptions","useEffect","isCancelled","available","allowedRowOptions","menuRows","itemRows","needsDivider","index","isRowNavigable","row","firstNavigableIndex","useLayoutEffect","width","height","margin","CELL_CONTEXT_MENU_VIEWPORT_MARGIN","offset","CELL_CONTEXT_MENU_CURSOR_OFFSET","left","top","moveActiveIndex","direction","current","next","step","handlePointerDown","event","handleKeyDown","handleScroll","timeoutId","handleItemClick","createPortal","CELL_CONTEXT_MENU_Z_INDEX","React"],"mappings":";;;;;;;;AAwDA,MAAMA,KAAmB,OAAOC,MAAmC;AACjE,MAAI;AACF,QAAI,WAAW,WAAW;AACxB,mBAAM,UAAU,UAAU,UAAUA,CAA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A,UACAI,GAAQ;AAAA,QAAA;AAAA,QAEV,OAAO;AAAA,UACL,MAAMe,GAAU,QAAQhB,EAAM;AAAA,UAC9B,KAAKgB,GAAU,OAAOhB,EAAM;AAAA,UAC5B,QAAQoF;AAAA;AAAA,UAER,YAAYpE,IAAW,YAAY;AAAA,QAAA;AAAA,QAErC,eAAe,CAAC8D,MAAUA,EAAM,eAAA;AAAA,QAE/B,UAAAtB,EAAS,IAAI,CAACK,GAAKF,MAClB,gBAAA/D,EAACyF,GAAM,UAAN,EACG,UAAA;AAAA,WAAAxB,EAAI,SAAS,SAASA,EAAI,KAAK,qBAAqBF,IAAQ,IAAIE,EAAI,qBACpE,gBAAA/D,EAAC,OAAA,EAAI,WAAU,8CAA6C,IAC1D;AAAA,UACH+D,EAAI,SAAS,SACZ,gBAAA/D;AAAA,YAACR;AAAA,YAAA;AAAA,cACC,MAAMuE,EAAI;AAAA,cACV,YAAY3E,EAAY2E,EAAI,KAAK,YAAYzE,GAAS,EAAK;AAAA,cAC3D,UAAUuE,MAAUxC;AAAA,cACpB,UAAU,MAAM,KAAK+D,EAAgBrB,EAAI,IAAI;AAAA,cAC7C,SAAS,MAAMzC,EAAeuC,CAAK;AAAA,YAAA;AAAA,UAAA,IAEnCE,EAAI,SAAS,+BACd,OAAA,EAAI,WAAU,aAAY,eAAY,6BACrC,UAAA,gBAAA/D,EAAC,OAAA,EAAI,WAAU,uEAAsE,GACvF;AAAA;AAAA,8BAGC,OAAA,EAAI,kBAAc,IAAC,UAAU,IAAI,WAAU,kCAAiC,SAASU,GAAS,cAAc,MAAMY,EAAeuC,CAAK,GACpI,YAAI,KAAA,CACP;AAAA;AAAA,QAAA,EAAA,GApBiBE,EAAI,GAsBzB,CACD;AAAA,MAAA;AAAA,IAAA;AAAA,IAEH,SAAS;AAAA,EAAA;AAEb;"}
|
|
1
|
+
{"version":3,"file":"CellContextMenuPortal.es.js","sources":["../../../../src/components/data-display/infinite-table/CellContextMenuPortal.tsx"],"sourcesContent":["import { useTableConfig } from '../../../providers/design-system-provider/hooks';\nimport { CheckIcon, ContentCopyIcon, LinkIcon, OpenInNewIcon } from '../../icon';\nimport type {\n ICellContextMenuConfig,\n ICellContextMenuContext,\n ICellContextMenuItem,\n ICellContextMenuState,\n IColumn,\n IRowLinkConfig,\n} from './types';\nimport { getRowJson, getSelectedRowsJson } from './copy-text';\nimport cn from 'classnames';\nimport React, { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react';\nimport { createPortal } from 'react-dom';\nimport { useHref } from 'react-router-dom';\n\nimport {\n CELL_CONTEXT_MENU_CURSOR_OFFSET,\n COPY_FEEDBACK_DURATION,\n CELL_CONTEXT_MENU_VIEWPORT_MARGIN,\n CELL_CONTEXT_MENU_Z_INDEX,\n} from './constants';\n\ntype TRowOption = { key: string; label: React.ReactNode; isVisible?: boolean };\n\n/** Result of the per-row availability check for row actions. */\ntype TRowOptionsFilter =\n | { status: 'off' }\n | { status: 'loading' }\n | { status: 'ready'; available: Record<string, boolean> }\n | { status: 'failed' };\n\n/** One rendered menu line: a declared item, a row-action node supplied by the table, or the row-action placeholder. */\ntype TMenuRow =\n | { kind: 'item'; key: string; item: ICellContextMenuItem }\n | { kind: 'node'; key: string; node: React.ReactNode; withDividerBefore?: boolean }\n | { kind: 'skeleton'; key: string; withDividerBefore?: boolean };\n\ninterface CellContextMenuPortalProps {\n state: ICellContextMenuState | null;\n config?: ICellContextMenuConfig | null;\n /** The table's row actions, appended to the menu — same list the three-dot cell renders. */\n rowOptions?: TRowOption[] | ((rowData: Record<string, unknown>) => TRowOption[] | null) | null;\n /** Per-row availability check for `rowOptions`, mirroring the three-dot cell so both menus agree. */\n asyncRowOptionsFilter?: ((rowId: string) => Promise<Record<string, boolean>>) | null;\n /** Checked row ids, enabling the \"Copy selected rows\" item. */\n checkedIds?: (string | number)[];\n /** Table rows, used to build the text for selected rows that are scrolled out of view. */\n rows?: Record<string, unknown>[];\n /** Visible columns in display order, used to order the copied values. */\n columns?: IColumn[];\n /** The table's row link, enabling the \"Copy Link\" / \"Open in New Tab\" items. */\n rowLinkConfig?: IRowLinkConfig | null;\n onClose: () => void;\n}\n\n/** Clipboard write with a fallback for browsers / insecure contexts without the async clipboard API. */\nconst writeToClipboard = async (text: string): Promise<boolean> => {\n try {\n if (navigator?.clipboard?.writeText) {\n await navigator.clipboard.writeText(text);\n return true;\n }\n } catch {\n // fall through to the textarea fallback\n }\n\n try {\n const textarea = document.createElement('textarea');\n textarea.value = text;\n textarea.setAttribute('readonly', '');\n textarea.style.position = 'fixed';\n textarea.style.opacity = '0';\n document.body.appendChild(textarea);\n textarea.select();\n const copied = document.execCommand('copy');\n document.body.removeChild(textarea);\n return copied;\n } catch {\n return false;\n }\n};\n\n/** An already basename-resolved href (from `useHref`); the clipboard and a new tab both need a full URL. */\nconst toAbsoluteUrl = (href: string): string => {\n if (!href) return '';\n\n try {\n return new URL(href, window.location.origin).href;\n } catch {\n return '';\n }\n};\n\nconst resolveFlag = (\n flag: boolean | ((context: ICellContextMenuContext) => boolean) | undefined,\n context: ICellContextMenuContext,\n fallback: boolean,\n): boolean => {\n if (flag === undefined) return fallback;\n return typeof flag === 'function' ? flag(context) : flag;\n};\n\nconst MenuItemButton: React.FC<{\n item: ICellContextMenuItem;\n isDisabled: boolean;\n isActive: boolean;\n onSelect: () => void;\n onHover: () => void;\n}> = ({ item, isDisabled, isActive, onSelect, onHover }) => (\n <button\n type='button'\n role='menuitem'\n data-menu-item\n disabled={isDisabled}\n aria-disabled={isDisabled}\n tabIndex={isActive ? 0 : -1}\n className={cn(\n 'flex w-full items-center gap-3 px-3 py-2 text-sm font-medium text-left outline-none',\n isDisabled\n ? 'opacity-50 cursor-not-allowed'\n : cn(\n 'cursor-pointer',\n item.isDanger\n ? 'text-error-600 dark:text-error-400 hover:bg-error-50 dark:hover:bg-error-950 focus-visible:bg-error-50 dark:focus-visible:bg-error-950'\n : 'text-neutral-900 dark:text-white hover:bg-neutral-100 dark:hover:bg-black-600 focus-visible:bg-neutral-100 dark:focus-visible:bg-black-600',\n ),\n )}\n onClick={onSelect}\n onMouseEnter={() => !isDisabled && onHover()}\n >\n {item.icon ? (\n <span className={cn('flex shrink-0 items-center', item.isDanger ? 'text-error-600 dark:text-error-400' : 'text-neutral-500 dark:text-black-300')}>\n {item.icon}\n </span>\n ) : null}\n <span className='flex-1 truncate'>{item.label}</span>\n {item.shortcut ? <span className='shrink-0 text-xs text-neutral-400 dark:text-black-300'>{item.shortcut}</span> : null}\n </button>\n);\n\n/**\n * Right-click menu for data cells. Rendered once per table and positioned at the\n * cursor; `DataCell` opens it through `openCellContextMenu` on the table context.\n */\nexport const CellContextMenuPortal: React.FC<CellContextMenuPortalProps> = ({\n state, config, rowOptions, asyncRowOptionsFilter, checkedIds, rows, columns, rowLinkConfig, onClose,\n}) => {\n const tableConfig = useTableConfig();\n const t = useMemo(() => tableConfig?.t ?? ((key: string) => key), [tableConfig]);\n const menuRef = useRef<HTMLDivElement>(null);\n const [position, setPosition] = useState<{ left: number; top: number } | null>(null);\n const [activeIndex, setActiveIndex] = useState(-1);\n const [copyState, setCopyState] = useState<{ key: string; isCopied: boolean } | null>(null);\n const [rowOptionsFilter, setRowOptionsFilter] = useState<TRowOptionsFilter>({ status: 'off' });\n const closeTimer = useRef<ReturnType<typeof setTimeout>>();\n\n const context = useMemo<ICellContextMenuContext | null>(\n () => (state ? { ...state.target, close: onClose } : null),\n [state, onClose],\n );\n\n const handleCopy = useCallback(\n async (key: string, text: string, menuContext: ICellContextMenuContext) => {\n if (copyState) return;\n\n const isCopied = await writeToClipboard(text);\n\n if (isCopied) {\n config?.onCopy?.(text, menuContext);\n tableConfig?.showNotification?.('success', t('Copied to clipboard'));\n } else {\n tableConfig?.showNotification?.('error', t('Could not copy to clipboard'));\n }\n\n // Confirmed inline instead of with a toast, so the menu owns its own feedback.\n setCopyState({ key, isCopied });\n closeTimer.current = setTimeout(() => onClose(), COPY_FEEDBACK_DURATION);\n },\n [config, tableConfig, t, onClose, copyState],\n );\n\n const buildCopyItem = useCallback(\n (key: string, label: string, text: string, icon?: React.ReactNode): ICellContextMenuItem => {\n const isDone = copyState?.key === key;\n\n return {\n key,\n label: !isDone ? label : copyState?.isCopied ? t('Copied') : t('Copy failed'),\n icon:\n isDone && copyState?.isCopied ? (\n <CheckIcon size={16} className='text-success-600 dark:text-success-400' />\n ) : (\n icon ?? <ContentCopyIcon size={16} />\n ),\n isDisabled: !text,\n keepOpenOnClick: true,\n onClick: (menuContext) => handleCopy(key, text, menuContext),\n };\n },\n [copyState, handleCopy, t],\n );\n\n const rowJson = useMemo(() => getRowJson(state?.target.rowData, columns), [state?.target.rowData, columns]);\n // Only while the menu is open — otherwise every checkbox tick would serialize the selection.\n const selectedRowsJson = useMemo(() => (state ? getSelectedRowsJson(rows, columns, checkedIds) : ''), [state, rows, columns, checkedIds]);\n const selectedCount = checkedIds?.length ?? 0;\n\n /** The router path from `linkTo`, before the router's basename (e.g. `/integrations`) is applied. */\n const rowLinkPath = useMemo(() => {\n if (!state || !rowLinkConfig?.isEnabled || !rowLinkConfig.linkTo || state.target.column?.disableRowClick) return '';\n\n return rowLinkConfig.linkTo(String(state.target.rowId), state.target.rowData) || '';\n }, [state, rowLinkConfig]);\n\n // `useHref` resolves `rowLinkPath` the same way a <Link> would, basename included — a manual\n // `new URL(path, location.href)` would silently drop a router basename like `/integrations`.\n const rowLinkResolvedHref = useHref(rowLinkPath || '/');\n\n /** The row link as an absolute URL — empty unless the table opted in, and never on a cell that opts out of the row link. */\n const rowLinkHref = useMemo(() => {\n if (!rowLinkPath) return '';\n\n return toAbsoluteUrl(rowLinkResolvedHref);\n }, [rowLinkPath, rowLinkResolvedHref]);\n\n const openInNewTab = useCallback(() => {\n if (rowLinkHref) window.open(rowLinkHref, '_blank', 'noopener,noreferrer');\n }, [rowLinkHref]);\n\n const items = useMemo<ICellContextMenuItem[]>(() => {\n if (!context) return [];\n\n const defaultItems: ICellContextMenuItem[] = config?.hideDefaultItems\n ? []\n : [\n buildCopyItem('copy-cell', config?.copyLabel ?? t('Copy Cell'), context.text),\n buildCopyItem('copy-row', t('Copy Row'), rowJson),\n ...(selectedCount > 0\n ? [\n buildCopyItem(\n 'copy-selected-rows',\n selectedCount === 1 ? t('Copy Selected Row') : `${t('Copy Selected Rows')} (${selectedCount})`,\n selectedRowsJson,\n ),\n ]\n : []),\n ...(rowLinkHref && !config?.hideLinkItems\n ? [\n {\n ...buildCopyItem('copy-link', t('Copy Link'), rowLinkHref, <LinkIcon size={16} />),\n withDividerBefore: true,\n },\n {\n key: 'open-in-new-tab',\n label: t('Open in New Tab'),\n icon: <OpenInNewIcon size={16} />,\n onClick: openInNewTab,\n },\n ]\n : []),\n ];\n\n const extraItems = typeof config?.items === 'function' ? config.items(context) : config?.items ?? [];\n\n return [...defaultItems, ...extraItems].filter((item) => resolveFlag(item.isVisible, context, true));\n }, [config, context, buildCopyItem, selectedCount, rowJson, selectedRowsJson, rowLinkHref, openInNewTab, t]);\n\n /** The table's own row actions, resolved for the right-clicked row. */\n const resolvedRowOptions = useMemo<TRowOption[]>(() => {\n if (!state || config?.includeRowOptions === false || !rowOptions) return [];\n\n const list = typeof rowOptions === 'function' ? rowOptions(state.target.rowData) : rowOptions;\n\n return (list ?? []).filter((option) => option.isVisible !== false);\n }, [state, rowOptions, config?.includeRowOptions]);\n\n const hasRowOptions = resolvedRowOptions.length > 0;\n\n /** Row actions can be gated per row by the API — ask before showing them, exactly as the three-dot cell does. */\n useEffect(() => {\n if (!state || !hasRowOptions || !asyncRowOptionsFilter) {\n setRowOptionsFilter({ status: 'off' });\n return;\n }\n\n let isCancelled = false;\n setRowOptionsFilter({ status: 'loading' });\n\n asyncRowOptionsFilter(String(state.target.rowId))\n .then((available) => !isCancelled && setRowOptionsFilter({ status: 'ready', available }))\n .catch(() => !isCancelled && setRowOptionsFilter({ status: 'failed' }));\n\n return () => {\n isCancelled = true;\n };\n }, [state, hasRowOptions, asyncRowOptionsFilter]);\n\n const allowedRowOptions = useMemo<TRowOption[]>(() => {\n if (rowOptionsFilter.status === 'off') return resolvedRowOptions;\n if (rowOptionsFilter.status !== 'ready') return [];\n\n const { available } = rowOptionsFilter;\n\n return resolvedRowOptions.filter((option) => available[option.key] ?? true);\n }, [resolvedRowOptions, rowOptionsFilter]);\n\n const menuRows = useMemo<TMenuRow[]>(() => {\n const itemRows: TMenuRow[] = items.map((item) => ({ kind: 'item', key: item.key, item }));\n const needsDivider = itemRows.length > 0;\n\n if (rowOptionsFilter.status === 'loading') {\n return [...itemRows, { kind: 'skeleton', key: 'row-options-loading', withDividerBefore: needsDivider }];\n }\n\n return [\n ...itemRows,\n ...allowedRowOptions.map<TMenuRow>((option, index) => ({\n kind: 'node',\n key: `row-option-${option.key}`,\n node: option.label,\n withDividerBefore: needsDivider && index === 0,\n })),\n ];\n }, [items, allowedRowOptions, rowOptionsFilter.status]);\n\n const isRowNavigable = useCallback(\n (row: TMenuRow): boolean => (row.kind === 'item' ? !(context && resolveFlag(row.item.isDisabled, context, false)) : row.kind === 'node'),\n [context],\n );\n\n const firstNavigableIndex = useMemo(() => menuRows.findIndex(isRowNavigable), [menuRows, isRowNavigable]);\n\n /** Clamp into the viewport once the menu has been measured; row actions can arrive after the first paint. */\n useLayoutEffect(() => {\n if (!state || !menuRef.current) {\n setPosition(null);\n return;\n }\n\n const { width, height } = menuRef.current.getBoundingClientRect();\n const margin = CELL_CONTEXT_MENU_VIEWPORT_MARGIN;\n const offset = CELL_CONTEXT_MENU_CURSOR_OFFSET;\n\n // Flip to the other side of the cursor when there is no room, then clamp.\n const left = state.x + width + margin > window.innerWidth ? state.x - width - offset : state.x + offset;\n const top = state.y + height + margin > window.innerHeight ? state.y - height - offset : state.y + offset;\n\n setPosition({\n left: Math.max(margin, Math.min(left, window.innerWidth - width - margin)),\n top: Math.max(margin, Math.min(top, window.innerHeight - height - margin)),\n });\n }, [state, menuRows.length]);\n\n useEffect(() => {\n setCopyState(null);\n return () => clearTimeout(closeTimer.current);\n }, [state]);\n\n useEffect(() => {\n if (!state) {\n setActiveIndex(-1);\n return;\n }\n setActiveIndex(firstNavigableIndex);\n }, [state, firstNavigableIndex]);\n\n /** Focus follows the active row so the menu is keyboard operable; row actions bring their own button. */\n useEffect(() => {\n if (!state || activeIndex < 0) return;\n\n const row = menuRef.current?.querySelectorAll<HTMLElement>('[data-menu-item]')[activeIndex];\n const focusTarget = row?.matches('button') ? row : row?.querySelector('button') ?? row;\n\n // preventScroll: a focus-driven scroll would immediately close the menu.\n focusTarget?.focus({ preventScroll: true });\n }, [state, activeIndex]);\n\n const moveActiveIndex = useCallback(\n (direction: 1 | -1) => {\n if (menuRows.length === 0) return;\n setActiveIndex((current) => {\n let next = current;\n for (let step = 0; step < menuRows.length; step += 1) {\n next = (next + direction + menuRows.length) % menuRows.length;\n if (isRowNavigable(menuRows[next])) return next;\n }\n return current;\n });\n },\n [menuRows, isRowNavigable],\n );\n\n useEffect(() => {\n if (!state) return;\n\n const handlePointerDown = (event: MouseEvent | TouchEvent) => {\n if (menuRef.current && !menuRef.current.contains(event.target as Node)) onClose();\n };\n const handleKeyDown = (event: KeyboardEvent) => {\n if (event.key === 'Escape') {\n event.stopPropagation();\n onClose();\n return;\n }\n if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {\n event.preventDefault();\n moveActiveIndex(event.key === 'ArrowDown' ? 1 : -1);\n }\n };\n // Any scroll (table viewport included) detaches the menu from its cell, so close it.\n const handleScroll = () => onClose();\n\n // Deferred so the right click that opened the menu does not immediately close it.\n const timeoutId = setTimeout(() => {\n document.addEventListener('mousedown', handlePointerDown);\n document.addEventListener('touchstart', handlePointerDown);\n document.addEventListener('keydown', handleKeyDown);\n document.addEventListener('scroll', handleScroll, true);\n window.addEventListener('resize', handleScroll);\n }, 0);\n\n return () => {\n clearTimeout(timeoutId);\n document.removeEventListener('mousedown', handlePointerDown);\n document.removeEventListener('touchstart', handlePointerDown);\n document.removeEventListener('keydown', handleKeyDown);\n document.removeEventListener('scroll', handleScroll, true);\n window.removeEventListener('resize', handleScroll);\n };\n }, [state, onClose, moveActiveIndex]);\n\n if (!state || !context || menuRows.length === 0) return null;\n\n if (tableConfig?.renderCellContextMenu) {\n return tableConfig.renderCellContextMenu({ state, context, items, rowOptions: allowedRowOptions, onClose }) as JSX.Element;\n }\n\n const handleItemClick = async (item: ICellContextMenuItem): Promise<void> => {\n if (resolveFlag(item.isDisabled, context, false)) return;\n if (!item.keepOpenOnClick) onClose();\n await item.onClick?.(context);\n };\n\n return createPortal(\n <div\n ref={menuRef}\n role='menu'\n aria-label={t('Cell actions')}\n data-testid='cell-context-menu'\n className={cn(\n 'fixed min-w-[180px] max-w-[280px] py-1 rounded-lg font-inter',\n 'bg-white dark:bg-black-700',\n 'border border-neutral-200 dark:border-black-600',\n 'shadow-lg dark:shadow-black/40',\n config?.className,\n )}\n style={{\n left: position?.left ?? state.x,\n top: position?.top ?? state.y,\n zIndex: CELL_CONTEXT_MENU_Z_INDEX,\n // Hidden until measured so the flip/clamp never flashes at the wrong spot.\n visibility: position ? 'visible' : 'hidden',\n }}\n onContextMenu={(event) => event.preventDefault()}\n >\n {menuRows.map((row, index) => (\n <React.Fragment key={row.key}>\n {(row.kind === 'item' ? row.item.withDividerBefore && index > 0 : row.withDividerBefore) ? (\n <div className='my-1 h-px bg-neutral-200 dark:bg-black-600' />\n ) : null}\n {row.kind === 'item' ? (\n <MenuItemButton\n item={row.item}\n isDisabled={resolveFlag(row.item.isDisabled, context, false)}\n isActive={index === activeIndex}\n onSelect={() => void handleItemClick(row.item)}\n onHover={() => setActiveIndex(index)}\n />\n ) : row.kind === 'skeleton' ? (\n <div className='px-3 py-2' data-testid='cell-context-menu-loading'>\n <div className='h-3.5 w-full animate-pulse rounded bg-neutral-200 dark:bg-black-600' />\n </div>\n ) : (\n /* Row actions are rendered as the table supplied them — they carry their own button and handler. */\n <div data-menu-item tabIndex={-1} className='outline-none [&_button]:w-full' onClick={onClose} onMouseEnter={() => setActiveIndex(index)}>\n {row.node}\n </div>\n )}\n </React.Fragment>\n ))}\n </div>,\n document.body,\n );\n};\n"],"names":["writeToClipboard","text","textarea","copied","toAbsoluteUrl","href","resolveFlag","flag","context","fallback","MenuItemButton","item","isDisabled","isActive","onSelect","onHover","jsxs","cn","jsx","CellContextMenuPortal","state","config","rowOptions","asyncRowOptionsFilter","checkedIds","rows","columns","rowLinkConfig","onClose","tableConfig","useTableConfig","t","useMemo","key","menuRef","useRef","position","setPosition","useState","activeIndex","setActiveIndex","copyState","setCopyState","rowOptionsFilter","setRowOptionsFilter","closeTimer","handleCopy","useCallback","menuContext","isCopied","COPY_FEEDBACK_DURATION","buildCopyItem","label","icon","isDone","CheckIcon","ContentCopyIcon","rowJson","getRowJson","selectedRowsJson","getSelectedRowsJson","selectedCount","rowLinkPath","rowLinkResolvedHref","useHref","rowLinkHref","openInNewTab","items","defaultItems","LinkIcon","OpenInNewIcon","extraItems","resolvedRowOptions","option","hasRowOptions","useEffect","isCancelled","available","allowedRowOptions","menuRows","itemRows","needsDivider","index","isRowNavigable","row","firstNavigableIndex","useLayoutEffect","width","height","margin","CELL_CONTEXT_MENU_VIEWPORT_MARGIN","offset","CELL_CONTEXT_MENU_CURSOR_OFFSET","left","top","moveActiveIndex","direction","current","next","step","handlePointerDown","event","handleKeyDown","handleScroll","timeoutId","handleItemClick","createPortal","CELL_CONTEXT_MENU_Z_INDEX","React"],"mappings":";;;;;;;;;AAyDA,MAAMA,KAAmB,OAAOC,MAAmC;AACjE,MAAI;AACF,QAAI,WAAW,WAAW;AACxB,mBAAM,UAAU,UAAU,UAAUA,CAAI,GACjC;AAAA,EAEX,QAAQ;AAAA,EAER;AAEA,MAAI;AACF,UAAMC,IAAW,SAAS,cAAc,UAAU;AAClD,IAAAA,EAAS,QAAQD,GACjBC,EAAS,aAAa,YAAY,EAAE,GACpCA,EAAS,MAAM,WAAW,SAC1BA,EAAS,MAAM,UAAU,KACzB,SAAS,KAAK,YAAYA,CAAQ,GAClCA,EAAS,OAAA;AACT,UAAMC,IA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