@lax-wp/design-system 0.14.40 → 0.14.42

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.
Files changed (91) hide show
  1. package/dist/components/data-display/infinite-table/CellContextMenuPortal.cjs.js +2 -0
  2. package/dist/components/data-display/infinite-table/CellContextMenuPortal.cjs.js.map +1 -0
  3. package/dist/components/data-display/infinite-table/CellContextMenuPortal.d.ts +30 -0
  4. package/dist/components/data-display/infinite-table/CellContextMenuPortal.es.js +248 -0
  5. package/dist/components/data-display/infinite-table/CellContextMenuPortal.es.js.map +1 -0
  6. package/dist/components/data-display/infinite-table/body/cell/DataCell.cjs.js +1 -1
  7. package/dist/components/data-display/infinite-table/body/cell/DataCell.cjs.js.map +1 -1
  8. package/dist/components/data-display/infinite-table/body/cell/DataCell.es.js +166 -149
  9. package/dist/components/data-display/infinite-table/body/cell/DataCell.es.js.map +1 -1
  10. package/dist/components/data-display/infinite-table/constants.cjs.js +1 -1
  11. package/dist/components/data-display/infinite-table/constants.cjs.js.map +1 -1
  12. package/dist/components/data-display/infinite-table/constants.d.ts +8 -0
  13. package/dist/components/data-display/infinite-table/constants.es.js +24 -20
  14. package/dist/components/data-display/infinite-table/constants.es.js.map +1 -1
  15. package/dist/components/data-display/infinite-table/context.cjs.js +1 -1
  16. package/dist/components/data-display/infinite-table/context.cjs.js.map +1 -1
  17. package/dist/components/data-display/infinite-table/context.d.ts +5 -2
  18. package/dist/components/data-display/infinite-table/context.es.js +3 -1
  19. package/dist/components/data-display/infinite-table/context.es.js.map +1 -1
  20. package/dist/components/data-display/infinite-table/copy-text.cjs.js +2 -0
  21. package/dist/components/data-display/infinite-table/copy-text.cjs.js.map +1 -0
  22. package/dist/components/data-display/infinite-table/copy-text.d.ts +13 -0
  23. package/dist/components/data-display/infinite-table/copy-text.es.js +56 -0
  24. package/dist/components/data-display/infinite-table/copy-text.es.js.map +1 -0
  25. package/dist/components/data-display/infinite-table/head/cell/index.cjs.js +1 -1
  26. package/dist/components/data-display/infinite-table/head/cell/index.cjs.js.map +1 -1
  27. package/dist/components/data-display/infinite-table/head/cell/index.es.js +44 -46
  28. package/dist/components/data-display/infinite-table/head/cell/index.es.js.map +1 -1
  29. package/dist/components/data-display/infinite-table/index.cjs.js +1 -1
  30. package/dist/components/data-display/infinite-table/index.cjs.js.map +1 -1
  31. package/dist/components/data-display/infinite-table/index.d.ts +1 -1
  32. package/dist/components/data-display/infinite-table/index.es.js +623 -606
  33. package/dist/components/data-display/infinite-table/index.es.js.map +1 -1
  34. package/dist/components/data-display/infinite-table/types.d.ts +75 -4
  35. package/dist/components/data-display/label-value/LabelValue.cjs.js +1 -1
  36. package/dist/components/data-display/label-value/LabelValue.cjs.js.map +1 -1
  37. package/dist/components/data-display/label-value/LabelValue.es.js +1 -1
  38. package/dist/components/data-display/label-value/LabelValue.es.js.map +1 -1
  39. package/dist/components/floating-bar/FloatingBar.cjs.js +1 -1
  40. package/dist/components/floating-bar/FloatingBar.cjs.js.map +1 -1
  41. package/dist/components/floating-bar/FloatingBar.es.js +32 -29
  42. package/dist/components/floating-bar/FloatingBar.es.js.map +1 -1
  43. package/dist/components/forms/currency-input/CurrencyInputField.cjs.js +1 -1
  44. package/dist/components/forms/currency-input/CurrencyInputField.cjs.js.map +1 -1
  45. package/dist/components/forms/currency-input/CurrencyInputField.es.js +24 -24
  46. package/dist/components/forms/currency-input/CurrencyInputField.es.js.map +1 -1
  47. package/dist/components/forms/icon-picker/IconPicker.cjs.js +1 -1
  48. package/dist/components/forms/icon-picker/IconPicker.cjs.js.map +1 -1
  49. package/dist/components/forms/icon-picker/IconPicker.es.js +79 -65
  50. package/dist/components/forms/icon-picker/IconPicker.es.js.map +1 -1
  51. package/dist/components/forms/master-data-input/MasterDataInputField.cjs.js +1 -1
  52. package/dist/components/forms/master-data-input/MasterDataInputField.cjs.js.map +1 -1
  53. package/dist/components/forms/master-data-input/MasterDataInputField.es.js +2 -2
  54. package/dist/components/forms/master-data-input/MasterDataInputField.es.js.map +1 -1
  55. package/dist/components/forms/md-input/RichMarkdownInput.cjs.js +1 -1
  56. package/dist/components/forms/md-input/RichMarkdownInput.cjs.js.map +1 -1
  57. package/dist/components/forms/md-input/RichMarkdownInput.es.js +39 -38
  58. package/dist/components/forms/md-input/RichMarkdownInput.es.js.map +1 -1
  59. package/dist/components/icons/ShieldIcon.cjs.js +2 -0
  60. package/dist/components/icons/ShieldIcon.cjs.js.map +1 -0
  61. package/dist/components/icons/ShieldIcon.d.ts +20 -0
  62. package/dist/components/icons/ShieldIcon.es.js +30 -0
  63. package/dist/components/icons/ShieldIcon.es.js.map +1 -0
  64. package/dist/components/navigation/tabs/TabSwitch.cjs.js +1 -1
  65. package/dist/components/navigation/tabs/TabSwitch.cjs.js.map +1 -1
  66. package/dist/components/navigation/tabs/TabSwitch.d.ts +3 -1
  67. package/dist/components/navigation/tabs/TabSwitch.es.js +88 -67
  68. package/dist/components/navigation/tabs/TabSwitch.es.js.map +1 -1
  69. package/dist/components/navigation/tabs/Tabs.cjs.js +1 -1
  70. package/dist/components/navigation/tabs/Tabs.cjs.js.map +1 -1
  71. package/dist/components/navigation/tabs/Tabs.d.ts +1 -1
  72. package/dist/components/navigation/tabs/Tabs.es.js +339 -325
  73. package/dist/components/navigation/tabs/Tabs.es.js.map +1 -1
  74. package/dist/components/navigation/tabs/types.cjs.js.map +1 -1
  75. package/dist/components/navigation/tabs/types.d.ts +13 -0
  76. package/dist/components/navigation/tabs/types.es.js.map +1 -1
  77. package/dist/constants/colors.cjs.js +2 -0
  78. package/dist/constants/colors.cjs.js.map +1 -0
  79. package/dist/constants/colors.es.js +9 -0
  80. package/dist/constants/colors.es.js.map +1 -0
  81. package/dist/index.cjs.js +1 -1
  82. package/dist/index.d.ts +3 -1
  83. package/dist/index.es.js +325 -323
  84. package/dist/index.es.js.map +1 -1
  85. package/dist/providers/design-system-provider/types.d.ts +1 -0
  86. package/dist/utils/table.cjs.js +1 -1
  87. package/dist/utils/table.cjs.js.map +1 -1
  88. package/dist/utils/table.d.ts +1 -0
  89. package/dist/utils/table.es.js +26 -25
  90. package/dist/utils/table.es.js.map +1 -1
  91. package/package.json +1 -1
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react/jsx-runtime"),Y=require("../../../providers/design-system-provider/hooks.cjs.js"),K=require("./copy-text.cjs.js"),O=require("../../../_virtual/index.cjs.js"),o=require("react"),Z=require("react-dom"),T=require("./constants.cjs.js"),L=require("../../icon/icons.generated.cjs.js"),Q=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}},ee=t=>{if(!t)return"";try{return new URL(t,window.location.href).href}catch{return""}},S=(t,i,d)=>t===void 0?d:typeof t=="function"?t(i):t,te=({item:t,isDisabled:i,isActive:d,onSelect:w,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:w,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]}),ne=({state:t,config:i,rowOptions:d,asyncRowOptionsFilter:w,checkedIds:y,rows:P,columns:g,rowLinkConfig:E,onClose:m})=>{const p=Y.useTableConfig(),c=o.useMemo(()=>p?.t??(e=>e),[p]),b=o.useRef(null),[j,B]=o.useState(null),[M,v]=o.useState(-1),[k,U]=o.useState(null),[h,N]=o.useState({status:"off"}),z=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 Q(n);s?(i?.onCopy?.(n,r),p?.showNotification?.("success",c("Copied to clipboard"))):p?.showNotification?.("error",c("Could not copy to clipboard")),U({key:e,isCopied:s}),z.current=setTimeout(()=>m(),T.COPY_FEEDBACK_DURATION)},[i,p,c,m,k]),C=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:q=>F(e,r,q)}},[k,F,c]),H=o.useMemo(()=>K.getRowJson(t?.target.rowData,g),[t?.target.rowData,g]),J=o.useMemo(()=>t?K.getSelectedRowsJson(P,g,y):"",[t,P,g,y]),R=y?.length??0,x=o.useMemo(()=>!t||!E?.isEnabled||!E.linkTo||t.target.column?.disableRowClick?"":ee(E.linkTo(String(t.target.rowId),t.target.rowData)),[t,E]),X=o.useCallback(()=>{x&&window.open(x,"_blank","noopener,noreferrer")},[x]),_=o.useMemo(()=>{if(!a)return[];const e=i?.hideDefaultItems?[]:[C("copy-cell",i?.copyLabel??c("Copy Cell"),a.text),C("copy-row",c("Copy Row"),H),...R>0?[C("copy-selected-rows",R===1?c("Copy Selected Row"):`${c("Copy Selected Rows")} (${R})`,J)]:[],...x&&!i?.hideLinkItems?[{...C("copy-link",c("Copy Link"),x,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:X}]:[]],n=typeof i?.items=="function"?i.items(a):i?.items??[];return[...e,...n].filter(r=>S(r.isVisible,a,!0))},[i,a,C,R,H,J,x,X,c]),D=o.useMemo(()=>!t||i?.includeRowOptions===!1||!d?[]:((typeof d=="function"?d(t.target.rowData):d)??[]).filter(n=>n.isVisible!==!1),[t,d,i?.includeRowOptions]),V=D.length>0;o.useEffect(()=>{if(!t||!V||!w){N({status:"off"});return}let e=!1;return N({status:"loading"}),w(String(t.target.rowId)).then(n=>!e&&N({status:"ready",available:n})).catch(()=>!e&&N({status:"failed"})),()=>{e=!0}},[t,V,w]);const A=o.useMemo(()=>{if(h.status==="off")return D;if(h.status!=="ready")return[];const{available:e}=h;return D.filter(n=>e[n.key]??!0)},[D,h]),f=o.useMemo(()=>{const e=_.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,...A.map((r,s)=>({kind:"node",key:`row-option-${r.key}`,node:r.label,withDividerBefore:n&&s===0}))]},[_,A,h.status]),I=o.useCallback(e=>e.kind==="item"?!(a&&S(e.item.isDisabled,a,!1)):e.kind==="node",[a]),W=o.useMemo(()=>f.findIndex(I),[f,I]);o.useLayoutEffect(()=>{if(!t||!b.current){B(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,q=t.y+n+r>window.innerHeight?t.y-n-s:t.y+s;B({left:Math.max(r,Math.min(u,window.innerWidth-e-r)),top:Math.max(r,Math.min(q,window.innerHeight-n-r))})},[t,f.length]),o.useEffect(()=>(U(null),()=>clearTimeout(z.current)),[t]),o.useEffect(()=>{if(!t){v(-1);return}v(W)},[t,W]),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 $=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(),$(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,$]),!t||!a||f.length===0)return null;if(p?.renderCellContextMenu)return p.renderCellContextMenu({state:t,context:a,items:_,rowOptions:A,onClose:m});const G=async e=>{S(e.isDisabled,a,!1)||(e.keepOpenOnClick||m(),await e.onClick?.(a))};return Z.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(te,{item:e.item,isDisabled:S(e.item.isDisabled,a,!1),isActive:n===M,onSelect:()=>void G(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=ne;
2
+ //# sourceMappingURL=CellContextMenuPortal.cjs.js.map
@@ -0,0 +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,Q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AK,EACpI,WAAI,IAAA,CACP,CAAA,CAAA,EApBiBE,EAAI,GAsBzB,CACD,CAAA,CAAA,EAEH,SAAS,IAAA,CAEb"}
@@ -0,0 +1,30 @@
1
+ import type { ICellContextMenuConfig, ICellContextMenuState, IColumn, IRowLinkConfig } from './types';
2
+ import React from 'react';
3
+ type TRowOption = {
4
+ key: string;
5
+ label: React.ReactNode;
6
+ isVisible?: boolean;
7
+ };
8
+ interface CellContextMenuPortalProps {
9
+ state: ICellContextMenuState | null;
10
+ config?: ICellContextMenuConfig | null;
11
+ /** The table's row actions, appended to the menu — same list the three-dot cell renders. */
12
+ rowOptions?: TRowOption[] | ((rowData: Record<string, unknown>) => TRowOption[] | null) | null;
13
+ /** Per-row availability check for `rowOptions`, mirroring the three-dot cell so both menus agree. */
14
+ asyncRowOptionsFilter?: ((rowId: string) => Promise<Record<string, boolean>>) | null;
15
+ /** Checked row ids, enabling the "Copy selected rows" item. */
16
+ checkedIds?: (string | number)[];
17
+ /** Table rows, used to build the text for selected rows that are scrolled out of view. */
18
+ rows?: Record<string, unknown>[];
19
+ /** Visible columns in display order, used to order the copied values. */
20
+ columns?: IColumn[];
21
+ /** The table's row link, enabling the "Copy Link" / "Open in New Tab" items. */
22
+ rowLinkConfig?: IRowLinkConfig | null;
23
+ onClose: () => void;
24
+ }
25
+ /**
26
+ * Right-click menu for data cells. Rendered once per table and positioned at the
27
+ * cursor; `DataCell` opens it through `openCellContextMenu` on the table context.
28
+ */
29
+ export declare const CellContextMenuPortal: React.FC<CellContextMenuPortalProps>;
30
+ export {};
@@ -0,0 +1,248 @@
1
+ import { jsx as c, jsxs as Y } from "react/jsx-runtime";
2
+ import { useTableConfig as Q } from "../../../providers/design-system-provider/hooks.es.js";
3
+ import { getRowJson as ee, getSelectedRowsJson as te } from "./copy-text.es.js";
4
+ import S from "../../../_virtual/index.es.js";
5
+ import ne, { useMemo as f, useRef as G, useState as O, useCallback as C, useEffect as E, useLayoutEffect as re } from "react";
6
+ import { createPortal as oe } from "react-dom";
7
+ import { COPY_FEEDBACK_DURATION as ie, CELL_CONTEXT_MENU_VIEWPORT_MARGIN as le, CELL_CONTEXT_MENU_Z_INDEX as se, CELL_CONTEXT_MENU_CURSOR_OFFSET as ae } from "./constants.es.js";
8
+ import { CheckIcon as ce, ContentCopyIcon as de, LinkIcon as ue, OpenInNewIcon as me } from "../../icon/icons.generated.es.js";
9
+ const fe = async (t) => {
10
+ try {
11
+ if (navigator?.clipboard?.writeText)
12
+ return await navigator.clipboard.writeText(t), !0;
13
+ } catch {
14
+ }
15
+ try {
16
+ const o = document.createElement("textarea");
17
+ o.value = t, o.setAttribute("readonly", ""), o.style.position = "fixed", o.style.opacity = "0", document.body.appendChild(o), o.select();
18
+ const d = document.execCommand("copy");
19
+ return document.body.removeChild(o), d;
20
+ } catch {
21
+ return !1;
22
+ }
23
+ }, pe = (t) => {
24
+ if (!t) return "";
25
+ try {
26
+ return new URL(t, window.location.href).href;
27
+ } catch {
28
+ return "";
29
+ }
30
+ }, _ = (t, o, d) => t === void 0 ? d : typeof t == "function" ? t(o) : t, be = ({ item: t, isDisabled: o, isActive: d, onSelect: y, onHover: x }) => /* @__PURE__ */ Y(
31
+ "button",
32
+ {
33
+ type: "button",
34
+ role: "menuitem",
35
+ "data-menu-item": !0,
36
+ disabled: o,
37
+ "aria-disabled": o,
38
+ tabIndex: d ? 0 : -1,
39
+ className: S(
40
+ "flex w-full items-center gap-3 px-3 py-2 text-sm font-medium text-left outline-none",
41
+ o ? "opacity-50 cursor-not-allowed" : S(
42
+ "cursor-pointer",
43
+ 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"
44
+ )
45
+ ),
46
+ onClick: y,
47
+ onMouseEnter: () => !o && x(),
48
+ children: [
49
+ t.icon ? /* @__PURE__ */ c("span", { className: S("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,
50
+ /* @__PURE__ */ c("span", { className: "flex-1 truncate", children: t.label }),
51
+ t.shortcut ? /* @__PURE__ */ c("span", { className: "shrink-0 text-xs text-neutral-400 dark:text-black-300", children: t.shortcut }) : null
52
+ ]
53
+ }
54
+ ), Ee = ({
55
+ state: t,
56
+ config: o,
57
+ rowOptions: d,
58
+ asyncRowOptionsFilter: y,
59
+ checkedIds: x,
60
+ rows: P,
61
+ columns: N,
62
+ rowLinkConfig: I,
63
+ onClose: u
64
+ }) => {
65
+ const p = Q(), l = f(() => p?.t ?? ((e) => e), [p]), b = G(null), [A, F] = O(null), [D, v] = O(-1), [h, H] = O(null), [w, R] = O({ status: "off" }), J = G(), s = f(
66
+ () => t ? { ...t.target, close: u } : null,
67
+ [t, u]
68
+ ), X = C(
69
+ async (e, n, r) => {
70
+ if (h) return;
71
+ const i = await fe(n);
72
+ i ? (o?.onCopy?.(n, r), p?.showNotification?.("success", l("Copied to clipboard"))) : p?.showNotification?.("error", l("Could not copy to clipboard")), H({ key: e, isCopied: i }), J.current = setTimeout(() => u(), ie);
73
+ },
74
+ [o, p, l, u, h]
75
+ ), g = C(
76
+ (e, n, r, i) => {
77
+ const a = h?.key === e;
78
+ return {
79
+ key: e,
80
+ label: a ? h?.isCopied ? l("Copied") : l("Copy failed") : n,
81
+ icon: a && h?.isCopied ? /* @__PURE__ */ c(ce, { size: 16, className: "text-success-600 dark:text-success-400" }) : i ?? /* @__PURE__ */ c(de, { size: 16 }),
82
+ isDisabled: !r,
83
+ keepOpenOnClick: !0,
84
+ onClick: (z) => X(e, r, z)
85
+ };
86
+ },
87
+ [h, X, l]
88
+ ), V = f(() => ee(t?.target.rowData, N), [t?.target.rowData, N]), W = f(() => t ? te(P, N, x) : "", [t, P, N, x]), T = x?.length ?? 0, k = f(() => !t || !I?.isEnabled || !I.linkTo || t.target.column?.disableRowClick ? "" : pe(I.linkTo(String(t.target.rowId), t.target.rowData)), [t, I]), $ = C(() => {
89
+ k && window.open(k, "_blank", "noopener,noreferrer");
90
+ }, [k]), B = f(() => {
91
+ if (!s) return [];
92
+ const e = o?.hideDefaultItems ? [] : [
93
+ g("copy-cell", o?.copyLabel ?? l("Copy Cell"), s.text),
94
+ g("copy-row", l("Copy Row"), V),
95
+ ...T > 0 ? [
96
+ g(
97
+ "copy-selected-rows",
98
+ T === 1 ? l("Copy Selected Row") : `${l("Copy Selected Rows")} (${T})`,
99
+ W
100
+ )
101
+ ] : [],
102
+ ...k && !o?.hideLinkItems ? [
103
+ {
104
+ ...g("copy-link", l("Copy Link"), k, /* @__PURE__ */ c(ue, { size: 16 })),
105
+ withDividerBefore: !0
106
+ },
107
+ {
108
+ key: "open-in-new-tab",
109
+ label: l("Open in New Tab"),
110
+ icon: /* @__PURE__ */ c(me, { size: 16 }),
111
+ onClick: $
112
+ }
113
+ ] : []
114
+ ], n = typeof o?.items == "function" ? o.items(s) : o?.items ?? [];
115
+ return [...e, ...n].filter((r) => _(r.isVisible, s, !0));
116
+ }, [o, s, g, T, V, W, k, $, l]), L = f(() => !t || o?.includeRowOptions === !1 || !d ? [] : ((typeof d == "function" ? d(t.target.rowData) : d) ?? []).filter((n) => n.isVisible !== !1), [t, d, o?.includeRowOptions]), j = L.length > 0;
117
+ E(() => {
118
+ if (!t || !j || !y) {
119
+ R({ status: "off" });
120
+ return;
121
+ }
122
+ let e = !1;
123
+ return R({ status: "loading" }), y(String(t.target.rowId)).then((n) => !e && R({ status: "ready", available: n })).catch(() => !e && R({ status: "failed" })), () => {
124
+ e = !0;
125
+ };
126
+ }, [t, j, y]);
127
+ const U = f(() => {
128
+ if (w.status === "off") return L;
129
+ if (w.status !== "ready") return [];
130
+ const { available: e } = w;
131
+ return L.filter((n) => e[n.key] ?? !0);
132
+ }, [L, w]), m = f(() => {
133
+ const e = B.map((r) => ({ kind: "item", key: r.key, item: r })), n = e.length > 0;
134
+ return w.status === "loading" ? [...e, { kind: "skeleton", key: "row-options-loading", withDividerBefore: n }] : [
135
+ ...e,
136
+ ...U.map((r, i) => ({
137
+ kind: "node",
138
+ key: `row-option-${r.key}`,
139
+ node: r.label,
140
+ withDividerBefore: n && i === 0
141
+ }))
142
+ ];
143
+ }, [B, U, w.status]), M = C(
144
+ (e) => e.kind === "item" ? !(s && _(e.item.isDisabled, s, !1)) : e.kind === "node",
145
+ [s]
146
+ ), q = f(() => m.findIndex(M), [m, M]);
147
+ re(() => {
148
+ if (!t || !b.current) {
149
+ F(null);
150
+ return;
151
+ }
152
+ const { width: e, height: n } = b.current.getBoundingClientRect(), r = le, i = ae, 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
+ F({
154
+ left: Math.max(r, Math.min(a, window.innerWidth - e - r)),
155
+ top: Math.max(r, Math.min(z, window.innerHeight - n - r))
156
+ });
157
+ }, [t, m.length]), E(() => (H(null), () => clearTimeout(J.current)), [t]), E(() => {
158
+ if (!t) {
159
+ v(-1);
160
+ return;
161
+ }
162
+ v(q);
163
+ }, [t, q]), E(() => {
164
+ if (!t || D < 0) return;
165
+ const e = b.current?.querySelectorAll("[data-menu-item]")[D];
166
+ (e?.matches("button") ? e : e?.querySelector("button") ?? e)?.focus({ preventScroll: !0 });
167
+ }, [t, D]);
168
+ const K = C(
169
+ (e) => {
170
+ m.length !== 0 && v((n) => {
171
+ let r = n;
172
+ for (let i = 0; i < m.length; i += 1)
173
+ if (r = (r + e + m.length) % m.length, M(m[r])) return r;
174
+ return n;
175
+ });
176
+ },
177
+ [m, M]
178
+ );
179
+ if (E(() => {
180
+ if (!t) return;
181
+ const e = (a) => {
182
+ b.current && !b.current.contains(a.target) && u();
183
+ }, n = (a) => {
184
+ if (a.key === "Escape") {
185
+ a.stopPropagation(), u();
186
+ return;
187
+ }
188
+ (a.key === "ArrowDown" || a.key === "ArrowUp") && (a.preventDefault(), K(a.key === "ArrowDown" ? 1 : -1));
189
+ }, r = () => u(), i = setTimeout(() => {
190
+ document.addEventListener("mousedown", e), document.addEventListener("touchstart", e), document.addEventListener("keydown", n), document.addEventListener("scroll", r, !0), window.addEventListener("resize", r);
191
+ }, 0);
192
+ return () => {
193
+ 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
+ }, [t, u, K]), !t || !s || m.length === 0) return null;
196
+ if (p?.renderCellContextMenu)
197
+ return p.renderCellContextMenu({ state: t, context: s, items: B, rowOptions: U, onClose: u });
198
+ const Z = async (e) => {
199
+ _(e.isDisabled, s, !1) || (e.keepOpenOnClick || u(), await e.onClick?.(s));
200
+ };
201
+ return oe(
202
+ /* @__PURE__ */ c(
203
+ "div",
204
+ {
205
+ ref: b,
206
+ role: "menu",
207
+ "aria-label": l("Cell actions"),
208
+ "data-testid": "cell-context-menu",
209
+ className: S(
210
+ "fixed min-w-[180px] max-w-[280px] py-1 rounded-lg font-inter",
211
+ "bg-white dark:bg-black-700",
212
+ "border border-neutral-200 dark:border-black-600",
213
+ "shadow-lg dark:shadow-black/40",
214
+ o?.className
215
+ ),
216
+ style: {
217
+ left: A?.left ?? t.x,
218
+ top: A?.top ?? t.y,
219
+ zIndex: se,
220
+ // Hidden until measured so the flip/clamp never flashes at the wrong spot.
221
+ visibility: A ? "visible" : "hidden"
222
+ },
223
+ onContextMenu: (e) => e.preventDefault(),
224
+ children: m.map((e, n) => /* @__PURE__ */ Y(ne.Fragment, { children: [
225
+ (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
+ e.kind === "item" ? /* @__PURE__ */ c(
227
+ be,
228
+ {
229
+ item: e.item,
230
+ isDisabled: _(e.item.isDisabled, s, !1),
231
+ isActive: n === D,
232
+ onSelect: () => void Z(e.item),
233
+ onHover: () => v(n)
234
+ }
235
+ ) : 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
+ /* 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: u, onMouseEnter: () => v(n), children: e.node })
238
+ )
239
+ ] }, e.key))
240
+ }
241
+ ),
242
+ document.body
243
+ );
244
+ };
245
+ export {
246
+ Ee as CellContextMenuPortal
247
+ };
248
+ //# sourceMappingURL=CellContextMenuPortal.es.js.map
@@ -0,0 +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,UAAU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../../../../../hooks/useTheme.cjs.js"),S=require("../../../../../utils/formatters.cjs.js"),Ie=require("../../../../../constants/table.cjs.js"),Oe=require("../../../../../providers/design-system-provider/hooks.cjs.js"),U=require("../../../../tooltip/Tooltip.cjs.js"),Ve=require("../../../typography/Typography.cjs.js"),qe=require("@mui/icons-material"),k=require("../../../../../_virtual/index.cjs.js"),a=require("react"),ze=require("react-router-dom"),Ae=require("../../context.cjs.js"),Fe=require("./InlineEditField.cjs.js"),C=require("../../constants.cjs.js"),g=require("../../../../icon/icons.generated.cjs.js");let Y;const se=e=>{const t=Number(e);if(Number.isNaN(t)||e===null||e===void 0)return"0ms";if(t>=864e5){const p=Math.floor(t/864e5),f=Math.floor(t%864e5/36e5),i=Math.floor(t%36e5/6e4),b=Math.floor(t%6e4/1e3);return`${p}d ${f}h ${i}m ${b}s`}if(t>=36e5){const p=Math.floor(t/36e5),f=Math.floor(t%36e5/6e4),i=Math.floor(t%6e4/1e3);return`${p}h ${f}m ${i}s`}if(t>=6e4){const p=Math.floor(t/6e4),f=Math.floor(t%6e4/1e3);return`${p}m ${f}s`}return t>=1e3?`${(t/1e3).toFixed(2)}s`:`${t}ms`},Ee=({children:e,withLink:t,linkTo:p,rowData:f,disableRowClick:i})=>t&&!i?o.jsx(ze.Link,{to:p?.(f?.id,f)||"",children:e}):e,Ke=({cell:e,id:t,nextWidthSum:p,isLastCell:f,rowHovering:i,index:b,isFirstStickyCell:ne,handleCellClick:ue,currentData:y,highlightSubstring:D,is_read:Ue,is_modified:B,is_row_modified:X,is_deleted:R,is_added:I,level:x,inlineEditing:v,isInlineEditing:c,setRowHovering:M,handleCellValueChange:ie,cellRef:le,handleUpdateCellData:ce,registerValidation:me,loadingExpand:de,toggleRowExpand:G,isDraggingOver:fe,isLoading:$,is_incomplete:H,pendingEdit:s,hasPendingEdit:l,pendingValidationError:we})=>{const{cascadingTableConfig:P,originalsOnly:pe,maxLevel:he,showNewItem:Ye,expandedRows:be,rowLinkConfig:O,multiSelectConfig:ye,cellEditing:V,cellEditingValue:q,allowInlineEdit:J,fieldOperationLoading:xe,pendingEdits:ve,selectedRowId:z}=a.useContext(Ae.TableContext),ke=z!=null&&String(z)===String(t),Te=Oe.useTableConfig(),A=(e?.column?.key?e?.row?.original?.__cellMetadata?.[e.column.key]:void 0)?.is_locked??e?.column?.is_locked,F=(e?.column?.key?ve?.[t]?.[e.column.key]?.validationError:null)||we||null,Q=v===e.column.key&&e?.column?.canEdit&&!A&&!e?.column?.is_disabled,Ce=xe===`${t}-${e?.column?.id}`,{theme:ge}=Re.useTheme(),_e=ge==="dark",je=a.useCallback(()=>M(t),[M,t]),Le=a.useCallback(()=>M(null),[M]),_=Te?.formatDuration,[n,w]=a.useState(e?.column?.dataType==="duration"&&e?.value?_?_(e.value):se(e.value):e.value),[h,Z]=a.useState(null),[E,Ne]=a.useState(!1),[Se,ee]=a.useState(!1),[De,oe]=a.useState(!1),j=a.useRef(null),L=a.useRef(),N=a.useRef(),{selectedColumnIds:te=[]}=ye||{},re=!Object.prototype.hasOwnProperty.call(e?.column?.meta??{},"shouldHighlight")||e?.column?.meta?.shouldHighlight,ae=a.useCallback(()=>{j.current&&Ne(j.current.scrollWidth>j.current.clientWidth)},[]),K=a.useCallback(r=>{L.current&&clearTimeout(L.current),r?ee(!0):L.current=setTimeout(()=>ee(!1),200)},[]),W=a.useCallback(r=>{N.current&&clearTimeout(N.current),r?oe(!0):N.current=setTimeout(()=>oe(!1),200)},[]),T=k({"bg-amber-100 dark:bg-amber-900/30":l,"bg-neutral-100 dark:bg-black-600":i===t&&!c&&!l&&!(R||y?.is_deleted)&&!(I||y?.is_added),"bg-error-200 dark:bg-error-900":i===t&&!c&&!l&&(R||y?.is_deleted),"bg-success-100 dark:bg-success-800":i===t&&!c&&!l&&(I||y?.is_added),"bg-warning-100 dark:bg-warning-950":i===t&&!c&&!l&&(H||B||X||y?.is_row_modified),"bg-warning-50 dark:bg-orange-900":(H||B||X||y?.is_row_modified)&&!$&&i!==t&&!c&&!l,"bg-error-100 dark:bg-error-975":(R||y?.is_deleted)&&!$&&i!==t&&!c&&!l,"bg-success-50 dark:bg-success-900":(I||y?.is_added)&&!$&&i!==t&&!c&&!l,"bg-primary-50 dark:bg-primary-900":(fe||c)&&!l,"bg-primary-50 dark:bg-primary-800":te?.includes(e.column.id)&&!c&&!l,"bg-primary-50 dark:bg-primary-700":ke&&i!==t&&!c&&!l&&!$,[Ie.getTableRowBgClassNamesByStatus[e?.row?.original?.__rowBgStatus]]:e?.row?.original?.__rowBgStatus&&!c&&!l}),Me=r=>{e.column?.disableRowClick||ue(r)};a.useEffect(()=>(e?.row?.original?.status==="running"&&e.column?.dataType==="duration"&&(Y=setInterval(()=>{const u=new Date(S.formatDate(e?.row?.original?.created_at||e?.row?.original?.executed_on,{withTime:!0,format:"yyyy-MM-dd HH:mm:ss"})),d=Math.abs(new Date().getTime()-new Date(u).getTime());w(_?_(d):se(d))},500)),()=>{Y&&clearInterval(Y)}),[n,e.value,e?.row?.original?.created_at,e?.row?.original?.executed_on,e?.row?.original?.status,e.column?.dataType,_]),a.useEffect(()=>{(e?.column?.tooltipCellKey||e?.column?.type?.toLowerCase()==="url")&&(e?.column?.type?.toLowerCase()==="url"?Z(e?.value):Z(e?.row?.original?.[String(e?.column?.tooltipCellKey)]))},[e?.column?.tooltipCellKey,e?.row?.original,e?.column?.type,e?.value]),a.useEffect(()=>{if(e?.column?.type?.toLowerCase()==="currency")if(s?.value!==void 0){const r=e?.row?.original?.__rawData,u=e?.column?.Header,d=s?.meta?.currency_code||r?.[u]?.currency_code||"USD";w(S.formatCurrency(s.value,d))}else{const r=e?.row?.original?.__rawData,u=e?.column?.Header;w(S.formatCurrency(e?.value,r?.[u]?.currency_code||"USD"))}},[e?.value,e?.column?.type,e?.column?.Header,e?.row?.original?.__rawData,s?.value,s?.meta?.currency_code]),a.useEffect(()=>{e?.column?.type?.toLowerCase()==="percentage"&&(s?.value!==void 0?w(s.value?.toString()+"%"||""):w(e?.value?.toString()+"%"||""))},[e?.value,e?.column?.type,s?.value]),a.useEffect(()=>{const r=e?.column?.type?.toLowerCase()||"";if(["date","datetime"].includes(r))if(s?.value!==void 0){const u=r==="datetime",d=S.formatDate(s.value,{withTime:u,skipTimezone:!0});w(d||s.value)}else w(e.value)},[e?.value,e?.column?.type,s?.value]),a.useEffect(()=>{const r=e?.column?.type?.toLowerCase()||"";["currency","percentage","duration","boolean","date","datetime"].includes(r)||(s?.value!==void 0?w(s.value):e?.column?.dataType!=="duration"&&w(e.value))},[e?.value,e?.column?.type,e?.column?.dataType,s?.value]),a.useEffect(()=>{if(e?.column?.type?.toLowerCase()==="boolean"&&J){const r=s?.value!==void 0?s.value:e?.value;w(r===!0||r==="true"||r==="True"||r==="Yes"||r===1?"Yes":"No")}},[e?.value,e?.column?.type,J,s?.value]),a.useEffect(()=>()=>{L.current&&clearTimeout(L.current),N.current&&clearTimeout(N.current)},[]);const m=a.isValidElement(n);return o.jsxs("td",{id:e.value,"data-column-key":e?.column?.key,...e.getCellProps(),onClick:O?.isEnabled?void 0:Me,className:k("h-row",{"sticky left-0":e?.column?.sticky,relative:!e?.column?.sticky,"w-full":f,"overflow-visible":v===e.column.key,"overflow-x-hidden overflow-y-visible":v!==e.column.key&&m,"overflow-hidden":v!==e.column.key&&!m},F&&!Q?"outline outline-2 outline-error-500 -outline-offset-2 z-[5]":"",`${T||"bg-white dark:bg-black-800"}`),style:{minWidth:`${e.column.width}px`,maxWidth:`${e.column.width}px`,right:e?.column?.sticky?`${p}px`:C.CELL_DEFAULT_RIGHT_OFFSET,paddingLeft:x>0&&b===0?`${x*C.CELL_INDENT_PER_LEVEL_PX}px`:void 0},onMouseEnter:je,onMouseLeave:Le,children:[o.jsx(Ee,{withLink:O?.isEnabled,linkTo:O?.linkTo||void 0,rowData:e?.row?.original,disableRowClick:e?.column?.disableRowClick,children:(Array.isArray(V)?V.includes(`${t}-${e?.column?.id}`):V===`${t}-${e?.column?.id}`)?o.jsxs("div",{className:"h-row top-0 font-medium font-inter w-full absolute flex items-center px-4",children:[o.jsx("span",{className:"text-neutral-400 dark:text-black-400 truncate",children:(()=>{const r=`${t}-${e?.column?.id}`,u=typeof q=="object"?q?.[r]:q,d=e?.column?.type?.toLowerCase();if(d==="boolean")return u===!0||u==="true"||u==="True"?"Yes":"No";if((d==="date"||d==="datetime")&&u){const $e=d==="datetime";return S.formatDate(u,{withTime:$e,skipTimezone:!0})||String(u)}return u!=null?String(u):n})()}),o.jsx("div",{className:"ml-2 flex items-center gap-1.5",children:o.jsx(g.LoadingSpinnerIcon,{className:"spinner text-neutral-600 dark:text-white",size:12})})]}):v===e.column.key&&e?.column?.canEdit&&!A&&!e?.column?.is_disabled?o.jsx("div",{className:"h-row w-full absolute top-0 left-0 flex items-center",style:{marginLeft:x>0&&b===0?`-${x*C.CELL_INDENT_PER_LEVEL_PX}px`:void 0,width:x>0&&b===0?`calc(100% + ${x*C.CELL_INDENT_PER_LEVEL_PX}px)`:"100%"},children:o.jsx(Fe.InlineEditField,{cell:e,id:t,inlineEditing:v,cellRef:le,handleCellValueChange:ie,handleUpdateCellData:ce,registerValidation:me})}):o.jsxs(o.Fragment,{children:[x>0&&b===0&&o.jsx("div",{className:"h-row border-l border-neutral-300 dark:border-black-600 ml-2"}),o.jsx("div",{className:"min-h-6",children:o.jsx(U,{title:h&&e?.column?.type?.toLowerCase()!=="url"?h:void 0,hideTooltip:!h||e?.column?.type?.toLowerCase()==="url",delayShow:!0,placement:"top",children:o.jsxs("div",{className:k(`h-row top-0 font-medium font-inter overflow-index-auto whitespace-nowrap text-ellipsis dark:text-black-200 w-full absolute flex items-center ${T||"bg-white dark:bg-black-800"}`,m?"overflow-x-hidden overflow-y-visible":"overflow-x-hidden",{"border border-b-0 border-t-0 border-primary-600 dark:border-blue-800":te?.includes(e.column.id)}),style:e?.column?.sticky&&ne?{boxShadow:_e?C.CELL_STICKY_SHADOW_DARK:C.CELL_STICKY_SHADOW_LIGHT}:{},children:[P?.isCascading&&!pe&&b===0&&o.jsx("div",{className:k("w-[22px] h-row flex items-center px-4",`${T||"bg-white dark:bg-black-800"}`),id:"cascading",children:he>x&&(e?.row?.original?.__has_children||P?.showAllDropdown)&&o.jsx("div",{children:de?o.jsx(g.LoadingSpinnerIcon,{className:"text-neutral-600 dark:text-white",size:8}):o.jsx("div",{children:be?.[t]?.isOpen?o.jsx(g.KeyboardArrowDownIcon,{size:20,className:"text-neutral-400 dark:text-neutral-400",onClick:r=>{G(),r.stopPropagation()}}):o.jsx(g.KeyboardArrowRightFilledIcon,{size:20,className:"text-neutral-400 dark:text-neutral-400",onClick:r=>{G(),r.stopPropagation()}})})})}),e?.column?.type?.toLowerCase()==="url"&&h?o.jsx(U,{title:o.jsx("div",{onMouseEnter:()=>K(!0),onMouseLeave:()=>K(!1),children:o.jsx("a",{href:h,target:"_blank",rel:"noopener noreferrer",onClick:r=>r.stopPropagation(),children:o.jsxs("div",{className:"flex gap-1 items-center w-full",children:[o.jsx("div",{className:"w-4 h-4",children:o.jsx(g.LinkIcon,{height:16,width:16})}),o.jsx(Ve.Typography,{variant:"medium",size:"small",className:"truncate",appearance:"custom",children:h}),o.jsx(qe.OpenInNewRounded,{sx:{height:"16px",width:"16px",color:"#016DCF"}})]})})}),placement:"top",open:Se,onOpenChange:K,className:"block w-full min-w-0 overflow-hidden",children:o.jsx("div",{className:"w-full h-row flex items-center px-4 min-w-0 overflow-hidden text-primary-400",children:o.jsx("span",{ref:j,onMouseEnter:ae,className:"truncate w-full",children:D&&re&&!a.isValidElement(n)&&typeof n!="object"?D(n):n})})}):o.jsx(U,{title:E&&n&&!m?o.jsx("div",{onMouseEnter:()=>W(!0),onMouseLeave:()=>W(!1),className:"max-h-96 overflow-y-auto whitespace-pre-wrap break-words no-scroll",children:String(n)}):void 0,placement:"top",delayShow:!0,hideTooltip:!!h,open:E&&!h&&!m?De:void 0,onOpenChange:E&&!h&&!m?W:void 0,className:k("block w-full min-w-0",m?"overflow-x-hidden overflow-y-visible":"overflow-hidden"),children:o.jsx("div",{className:k("w-full h-row flex items-center px-4 min-w-0",m?"overflow-x-hidden overflow-y-visible":"overflow-hidden"),children:o.jsx("span",{ref:m?void 0:j,onMouseEnter:m?void 0:ae,className:k(m?"flex min-w-0 max-w-full items-center justify-start gap-1":"truncate w-full"),children:D&&re&&!a.isValidElement(n)&&typeof n!="object"?D(n):a.isValidElement(n)?typeof n.type=="string"?n:a.cloneElement(n,{...n.props,containerWidth:e.column.width}):n})})})]})})})]})}),F&&!Q&&o.jsx("div",{className:"absolute bottom-0 left-0 right-0 h-row flex items-end pointer-events-none z-[5]",children:o.jsx("div",{className:"w-full bg-error-50 dark:bg-error-975 px-1.5 py-0.5 truncate",children:o.jsx("span",{className:"text-error-600 text-2xs font-medium leading-none",children:F})})}),Ce&&!(v===e.column.key&&e?.column?.canEdit&&!A&&!e?.column?.is_disabled)&&o.jsx("div",{className:"absolute top-0 right-0 bg-white dark:bg-black-800 rounded-full w-5 h-5 flex items-center justify-center border border-primary-300 dark:border-primary-600 shadow-sm z-10",children:o.jsx(g.LoadingSpinnerIcon,{className:"text-primary-600 dark:text-white",size:8})})]},b)},We=a.memo(Ke);exports.DataCell=We;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),qe=require("../../../../../hooks/useTheme.cjs.js"),S=require("../../../../../utils/formatters.cjs.js"),Ve=require("../../../../../constants/table.cjs.js"),Fe=require("../../../../../providers/design-system-provider/hooks.cjs.js"),X=require("../../../../tooltip/Tooltip.cjs.js"),ze=require("../../../typography/Typography.cjs.js"),Ae=require("@mui/icons-material"),k=require("../../../../../_virtual/index.cjs.js"),a=require("react"),Ee=require("react-router-dom"),Ke=require("../../context.cjs.js"),We=require("../../copy-text.cjs.js"),Ue=require("./InlineEditField.cjs.js"),T=require("../../constants.cjs.js"),g=require("../../../../icon/icons.generated.cjs.js");let P;const ue=e=>{const t=Number(e);if(Number.isNaN(t)||e===null||e===void 0)return"0ms";if(t>=864e5){const w=Math.floor(t/864e5),f=Math.floor(t%864e5/36e5),i=Math.floor(t%36e5/6e4),x=Math.floor(t%6e4/1e3);return`${w}d ${f}h ${i}m ${x}s`}if(t>=36e5){const w=Math.floor(t/36e5),f=Math.floor(t%36e5/6e4),i=Math.floor(t%6e4/1e3);return`${w}h ${f}m ${i}s`}if(t>=6e4){const w=Math.floor(t/6e4),f=Math.floor(t%6e4/1e3);return`${w}m ${f}s`}return t>=1e3?`${(t/1e3).toFixed(2)}s`:`${t}ms`},Ye=({children:e,withLink:t,linkTo:w,rowData:f,disableRowClick:i})=>t&&!i?o.jsx(Ee.Link,{to:w?.(f?.id,f)||"",children:e}):e,Be=({cell:e,id:t,nextWidthSum:w,isLastCell:f,rowHovering:i,index:x,isFirstStickyCell:ie,handleCellClick:le,currentData:y,highlightSubstring:M,is_read:Pe,is_modified:G,is_row_modified:H,is_deleted:R,is_added:O,level:b,inlineEditing:v,isInlineEditing:c,setRowHovering:D,handleCellValueChange:ce,cellRef:me,handleUpdateCellData:de,registerValidation:fe,loadingExpand:pe,toggleRowExpand:J,isDraggingOver:we,isLoading:$,is_incomplete:Q,pendingEdit:u,hasPendingEdit:l,pendingValidationError:he})=>{const{cascadingTableConfig:Z,originalsOnly:xe,maxLevel:ye,showNewItem:Ge,expandedRows:be,rowLinkConfig:q,multiSelectConfig:ve,cellEditing:V,cellEditingValue:F,allowInlineEdit:ee,fieldOperationLoading:ke,pendingEdits:Ce,selectedRowId:z,cellContextMenuConfig:A,openCellContextMenu:E}=a.useContext(Ke.TableContext),Te=z!=null&&String(z)===String(t),ge=Fe.useTableConfig(),K=(e?.column?.key?e?.row?.original?.__cellMetadata?.[e.column.key]:void 0)?.is_locked??e?.column?.is_locked,W=(e?.column?.key?Ce?.[t]?.[e.column.key]?.validationError:null)||he||null,I=v===e.column.key&&e?.column?.canEdit&&!K&&!e?.column?.is_disabled,_e=ke===`${t}-${e?.column?.id}`,{theme:je}=qe.useTheme(),Le=je==="dark",Ne=a.useCallback(()=>D(t),[D,t]),Se=a.useCallback(()=>D(null),[D]),_=ge?.formatDuration,[s,p]=a.useState(e?.column?.dataType==="duration"&&e?.value?_?_(e.value):ue(e.value):e.value),[h,oe]=a.useState(null),[U,Me]=a.useState(!1),[De,te]=a.useState(!1),[$e,re]=a.useState(!1),j=a.useRef(null),L=a.useRef(),N=a.useRef(),{selectedColumnIds:ae=[]}=ve||{},ne=!Object.prototype.hasOwnProperty.call(e?.column?.meta??{},"shouldHighlight")||e?.column?.meta?.shouldHighlight,se=a.useCallback(()=>{j.current&&Me(j.current.scrollWidth>j.current.clientWidth)},[]),Y=a.useCallback(r=>{L.current&&clearTimeout(L.current),r?te(!0):L.current=setTimeout(()=>te(!1),200)},[]),B=a.useCallback(r=>{N.current&&clearTimeout(N.current),r?re(!0):N.current=setTimeout(()=>re(!1),200)},[]),C=k({"bg-amber-100 dark:bg-amber-900/30":l,"bg-neutral-100 dark:bg-black-600":i===t&&!c&&!l&&!(R||y?.is_deleted)&&!(O||y?.is_added),"bg-error-200 dark:bg-error-900":i===t&&!c&&!l&&(R||y?.is_deleted),"bg-success-100 dark:bg-success-800":i===t&&!c&&!l&&(O||y?.is_added),"bg-warning-100 dark:bg-warning-950":i===t&&!c&&!l&&(Q||G||H||y?.is_row_modified),"bg-warning-50 dark:bg-orange-900":(Q||G||H||y?.is_row_modified)&&!$&&i!==t&&!c&&!l,"bg-error-100 dark:bg-error-975":(R||y?.is_deleted)&&!$&&i!==t&&!c&&!l,"bg-success-50 dark:bg-success-900":(O||y?.is_added)&&!$&&i!==t&&!c&&!l,"bg-primary-50 dark:bg-primary-900":(we||c)&&!l,"bg-primary-50 dark:bg-primary-800":ae?.includes(e.column.id)&&!c&&!l,"bg-primary-50 dark:bg-primary-700":Te&&i!==t&&!c&&!l&&!$,[Ve.getTableRowBgClassNamesByStatus[e?.row?.original?.__rowBgStatus]]:e?.row?.original?.__rowBgStatus&&!c&&!l}),Ie=r=>{e.column?.disableRowClick||le(r)},Re=a.useCallback(r=>{if(A?.isEnabled===!1||!E||I)return;const n={rowId:t,rowData:e?.row?.original??{},columnKey:e?.column?.key??"",column:e.column,value:e?.value,text:We.getCellText(s,e?.value,r.currentTarget),cell:e};A?.isDisabledForCell?.(n)||(r.preventDefault(),r.stopPropagation(),E({x:r.clientX,y:r.clientY,target:n}))},[A,E,I,t,e,s]);a.useEffect(()=>(e?.row?.original?.status==="running"&&e.column?.dataType==="duration"&&(P=setInterval(()=>{const n=new Date(S.formatDate(e?.row?.original?.created_at||e?.row?.original?.executed_on,{withTime:!0,format:"yyyy-MM-dd HH:mm:ss"})),d=Math.abs(new Date().getTime()-new Date(n).getTime());p(_?_(d):ue(d))},500)),()=>{P&&clearInterval(P)}),[s,e.value,e?.row?.original?.created_at,e?.row?.original?.executed_on,e?.row?.original?.status,e.column?.dataType,_]),a.useEffect(()=>{(e?.column?.tooltipCellKey||e?.column?.type?.toLowerCase()==="url")&&(e?.column?.type?.toLowerCase()==="url"?oe(e?.value):oe(e?.row?.original?.[String(e?.column?.tooltipCellKey)]))},[e?.column?.tooltipCellKey,e?.row?.original,e?.column?.type,e?.value]),a.useEffect(()=>{if(e?.column?.type?.toLowerCase()==="currency")if(u?.value!==void 0){const r=e?.row?.original?.__rawData,n=e?.column?.Header,d=u?.meta?.currency_code||r?.[n]?.currency_code||"USD";p(S.formatCurrency(u.value,d))}else{const r=e?.row?.original?.__rawData,n=e?.column?.Header;p(S.formatCurrency(e?.value,r?.[n]?.currency_code||"USD"))}},[e?.value,e?.column?.type,e?.column?.Header,e?.row?.original?.__rawData,u?.value,u?.meta?.currency_code]),a.useEffect(()=>{e?.column?.type?.toLowerCase()==="percentage"&&(u?.value!==void 0?p(u.value?.toString()+"%"||""):p(e?.value?.toString()+"%"||""))},[e?.value,e?.column?.type,u?.value]),a.useEffect(()=>{const r=e?.column?.type?.toLowerCase()||"";if(["date","datetime"].includes(r))if(u?.value!==void 0){const n=r==="datetime",d=S.formatDate(u.value,{withTime:n,skipTimezone:!0});p(d||u.value)}else p(e.value)},[e?.value,e?.column?.type,u?.value]),a.useEffect(()=>{const r=e?.column?.type?.toLowerCase()||"";["currency","percentage","duration","boolean","date","datetime"].includes(r)||(u?.value!==void 0?p(u.value):e?.column?.dataType!=="duration"&&p(e.value))},[e?.value,e?.column?.type,e?.column?.dataType,u?.value]),a.useEffect(()=>{if(e?.column?.type?.toLowerCase()==="boolean"&&ee){const r=u?.value!==void 0?u.value:e?.value;p(r===!0||r==="true"||r==="True"||r==="Yes"||r===1?"Yes":"No")}},[e?.value,e?.column?.type,ee,u?.value]),a.useEffect(()=>()=>{L.current&&clearTimeout(L.current),N.current&&clearTimeout(N.current)},[]);const m=a.isValidElement(s);return o.jsxs("td",{id:e.value,"data-column-key":e?.column?.key,...e.getCellProps(),onClick:q?.isEnabled?void 0:Ie,className:k("h-row",{"sticky left-0":e?.column?.sticky,relative:!e?.column?.sticky,"w-full":f,"overflow-visible":v===e.column.key,"overflow-x-hidden overflow-y-visible":v!==e.column.key&&m,"overflow-hidden":v!==e.column.key&&!m},W&&!I?"outline outline-2 outline-error-500 -outline-offset-2 z-[5]":"",`${C||"bg-white dark:bg-black-800"}`),style:{minWidth:`${e.column.width}px`,maxWidth:`${e.column.width}px`,right:e?.column?.sticky?`${w}px`:T.CELL_DEFAULT_RIGHT_OFFSET,paddingLeft:b>0&&x===0?`${b*T.CELL_INDENT_PER_LEVEL_PX}px`:void 0},onMouseEnter:Ne,onMouseLeave:Se,onContextMenu:Re,children:[o.jsx(Ye,{withLink:q?.isEnabled,linkTo:q?.linkTo||void 0,rowData:e?.row?.original,disableRowClick:e?.column?.disableRowClick,children:(Array.isArray(V)?V.includes(`${t}-${e?.column?.id}`):V===`${t}-${e?.column?.id}`)?o.jsxs("div",{className:"h-row top-0 font-medium font-inter w-full absolute flex items-center px-4",children:[o.jsx("span",{className:"text-neutral-400 dark:text-black-400 truncate",children:(()=>{const r=`${t}-${e?.column?.id}`,n=typeof F=="object"?F?.[r]:F,d=e?.column?.type?.toLowerCase();if(d==="boolean")return n===!0||n==="true"||n==="True"?"Yes":"No";if((d==="date"||d==="datetime")&&n){const Oe=d==="datetime";return S.formatDate(n,{withTime:Oe,skipTimezone:!0})||String(n)}return n!=null?String(n):s})()}),o.jsx("div",{className:"ml-2 flex items-center gap-1.5",children:o.jsx(g.LoadingSpinnerIcon,{className:"spinner text-neutral-600 dark:text-white",size:12})})]}):v===e.column.key&&e?.column?.canEdit&&!K&&!e?.column?.is_disabled?o.jsx("div",{className:"h-row w-full absolute top-0 left-0 flex items-center",style:{marginLeft:b>0&&x===0?`-${b*T.CELL_INDENT_PER_LEVEL_PX}px`:void 0,width:b>0&&x===0?`calc(100% + ${b*T.CELL_INDENT_PER_LEVEL_PX}px)`:"100%"},children:o.jsx(Ue.InlineEditField,{cell:e,id:t,inlineEditing:v,cellRef:me,handleCellValueChange:ce,handleUpdateCellData:de,registerValidation:fe})}):o.jsxs(o.Fragment,{children:[b>0&&x===0&&o.jsx("div",{className:"h-row border-l border-neutral-300 dark:border-black-600 ml-2"}),o.jsx("div",{className:"min-h-6",children:o.jsx(X,{title:h&&e?.column?.type?.toLowerCase()!=="url"?h:void 0,hideTooltip:!h||e?.column?.type?.toLowerCase()==="url",delayShow:!0,placement:"top",children:o.jsxs("div",{className:k(`h-row top-0 font-medium font-inter overflow-index-auto whitespace-nowrap text-ellipsis dark:text-black-200 w-full absolute flex items-center ${C||"bg-white dark:bg-black-800"}`,m?"overflow-x-hidden overflow-y-visible":"overflow-x-hidden",{"border border-b-0 border-t-0 border-primary-600 dark:border-blue-800":ae?.includes(e.column.id)}),style:e?.column?.sticky&&ie?{boxShadow:Le?T.CELL_STICKY_SHADOW_DARK:T.CELL_STICKY_SHADOW_LIGHT}:{},children:[Z?.isCascading&&!xe&&x===0&&o.jsx("div",{className:k("w-[22px] h-row flex items-center px-4",`${C||"bg-white dark:bg-black-800"}`),id:"cascading",children:ye>b&&(e?.row?.original?.__has_children||Z?.showAllDropdown)&&o.jsx("div",{children:pe?o.jsx(g.LoadingSpinnerIcon,{className:"text-neutral-600 dark:text-white",size:8}):o.jsx("div",{children:be?.[t]?.isOpen?o.jsx(g.KeyboardArrowDownIcon,{size:20,className:"text-neutral-400 dark:text-neutral-400",onClick:r=>{J(),r.stopPropagation()}}):o.jsx(g.KeyboardArrowRightFilledIcon,{size:20,className:"text-neutral-400 dark:text-neutral-400",onClick:r=>{J(),r.stopPropagation()}})})})}),e?.column?.type?.toLowerCase()==="url"&&h?o.jsx(X,{title:o.jsx("div",{onMouseEnter:()=>Y(!0),onMouseLeave:()=>Y(!1),children:o.jsx("a",{href:h,target:"_blank",rel:"noopener noreferrer",onClick:r=>r.stopPropagation(),children:o.jsxs("div",{className:"flex gap-1 items-center w-full",children:[o.jsx("div",{className:"w-4 h-4",children:o.jsx(g.LinkIcon,{height:16,width:16})}),o.jsx(ze.Typography,{variant:"medium",size:"small",className:"truncate",appearance:"custom",children:h}),o.jsx(Ae.OpenInNewRounded,{sx:{height:"16px",width:"16px",color:"#016DCF"}})]})})}),placement:"top",open:De,onOpenChange:Y,className:"block w-full min-w-0 overflow-hidden",children:o.jsx("div",{className:"w-full h-row flex items-center px-4 min-w-0 overflow-hidden text-primary-400",children:o.jsx("span",{ref:j,"data-cell-content":!0,onMouseEnter:se,className:"truncate w-full",children:M&&ne&&!a.isValidElement(s)&&typeof s!="object"?M(s):s})})}):o.jsx(X,{title:U&&s&&!m?o.jsx("div",{onMouseEnter:()=>B(!0),onMouseLeave:()=>B(!1),className:"max-h-96 overflow-y-auto whitespace-pre-wrap break-words no-scroll",children:String(s)}):void 0,placement:"top",delayShow:!0,hideTooltip:!!h,open:U&&!h&&!m?$e:void 0,onOpenChange:U&&!h&&!m?B:void 0,className:k("block w-full min-w-0",m?"overflow-x-hidden overflow-y-visible":"overflow-hidden"),children:o.jsx("div",{className:k("w-full h-row flex items-center px-4 min-w-0",m?"overflow-x-hidden overflow-y-visible":"overflow-hidden"),children:o.jsx("span",{ref:m?void 0:j,"data-cell-content":!0,onMouseEnter:m?void 0:se,className:k(m?"flex min-w-0 max-w-full items-center justify-start gap-1":"truncate w-full"),children:M&&ne&&!a.isValidElement(s)&&typeof s!="object"?M(s):a.isValidElement(s)?typeof s.type=="string"?s:a.cloneElement(s,{...s.props,containerWidth:e.column.width}):s})})})]})})})]})}),W&&!I&&o.jsx("div",{className:"absolute bottom-0 left-0 right-0 h-row flex items-end pointer-events-none z-[5]",children:o.jsx("div",{className:"w-full bg-error-50 dark:bg-error-975 px-1.5 py-0.5 truncate",children:o.jsx("span",{className:"text-error-600 text-2xs font-medium leading-none",children:W})})}),_e&&!(v===e.column.key&&e?.column?.canEdit&&!K&&!e?.column?.is_disabled)&&o.jsx("div",{className:"absolute top-0 right-0 bg-white dark:bg-black-800 rounded-full w-5 h-5 flex items-center justify-center border border-primary-300 dark:border-primary-600 shadow-sm z-10",children:o.jsx(g.LoadingSpinnerIcon,{className:"text-primary-600 dark:text-white",size:8})})]},x)},Xe=a.memo(Be);exports.DataCell=Xe;
2
2
  //# sourceMappingURL=DataCell.cjs.js.map