Build 533169stable
Module 301679
2,212 characters · in no known chunkDependencies
Source Raw
function(e,t,n){"use strict";n.d(t,{A:()=>d,L:()=>c});var r=n(627968),i=n(64700),s=n(844222),a=n(350535),o=n(642481),l=n(525576);let u=200;function c(e){let{children:t,targetElementRef:n,estimatedTooltipHeight:c,delay:d=300,onShow:_,title:f,body:p,graphic:h,size:m="md",actions:E,gradientColor:g}=e,A=i.useContext(s.C),[I,T]=i.useState("closed"),S=i.useRef(null),y=i.useRef(!1),v="opening-mouse"===I||"open-mouse"===I,N="opening-keyboard"===I||"open-keyboard"===I,C="open-mouse"===I||"open-keyboard"===I,R=(A.keyboardModeEnabled||N)&&null!=E,O=R,[b,D]=i.useState(0),L=(0,l._)(n,c,I),w=i.useCallback(()=>{null!=S.current&&(clearTimeout(S.current),S.current=null)},[]),M=i.useCallback(e=>{e&&(y.current=!0),w(),T("closing")},[w]);i.useEffect(()=>w,[w]);let P=i.useCallback(()=>{("closed"===I||"closing"===I)&&(w(),T("opening-mouse"))},[w,I]),x=i.useCallback(()=>{v&&M(!1)},[M,v]),k=i.useCallback(()=>{if(y.current||"closed"!==I&&"closing"!==I){y.current=!1;return}w(),T("opening-keyboard")},[w,I]),U=i.useCallback(()=>{R&&"opening-keyboard"!==I||M(!1)},[M,I,R]);i.useEffect(()=>{if("opening-mouse"===I)return S.current=window.setTimeout(()=>{S.current=null,T("open-mouse"),_?.()},d),w},[I,d,_,w]),i.useEffect(()=>{if("opening-keyboard"===I)return S.current=window.setTimeout(()=>{S.current=null,T("open-keyboard"),_?.()},d),w},[I,d,_,w]),i.useEffect(()=>{if("closing"===I)return S.current=window.setTimeout(()=>{S.current=null,T("closed")},u),w},[I,w]),i.useEffect(()=>{if(!C)return;let e=e=>{("Escape"===e.key||"Esc"===e.key)&&(e.preventDefault(),e.stopPropagation(),M(!0))};return document.addEventListener("keydown",e,!0),()=>{document.removeEventListener("keydown",e,!0)}},[C,M]);let G=i.useMemo(()=>null==E?E:E.map(e=>({...e,onClick:t=>{e.onClick?.(t),M(!1)}})),[E,M]),F=i.useCallback(e=>{D(e)},[]);return(0,r.jsxs)("div",{onMouseEnter:P,onMouseLeave:x,onFocus:k,onBlur:U,children:[t,(0,r.jsx)(o.j,{targetElementRef:n,shouldShow:C,position:L,align:"center",title:f,body:p,graphic:h,size:m,actions:G,gradientColor:g,showCloseButton:O,shouldTrapFocus:R,returnRef:R?n:void 0,isCaretHoverable:!0,caretConfig:{align:"custom",customOffset:b},onNudgeChange:F,onRequestClose:e=>{M(null!=e&&(0,a.sg)(e))}})]})}let d=c}