@vuu-ui/vuu-popups 0.8.22 → 0.8.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/cjs/index.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";var Jt=Object.create;var de=Object.defineProperty;var Yt=Object.getOwnPropertyDescriptor;var jt=Object.getOwnPropertyNames;var Qt=Object.getPrototypeOf,Zt=Object.prototype.hasOwnProperty;var _t=(e,o)=>{for(var t in o)de(e,t,{get:o[t],enumerable:!0})},Ze=(e,o,t,n)=>{if(o&&typeof o=="object"||typeof o=="function")for(let r of jt(o))!Zt.call(e,r)&&r!==t&&de(e,r,{get:()=>o[r],enumerable:!(n=Yt(o,r))||n.enumerable});return e};var I=(e,o,t)=>(t=e!=null?Jt(Qt(e)):{},Ze(o||!e||!e.__esModule?de(t,"default",{value:e,enumerable:!0}):t,e)),eo=e=>Ze(de({},"__esModule",{value:!0}),e);var tn={};_t(tn,{ContextMenu:()=>xe,ContextMenuContext:()=>le,ContextMenuProvider:()=>Oo,Dialog:()=>Be,DialogHeader:()=>Ie,DialogService:()=>Ae,MenuItem:()=>ue,MenuItemGroup:()=>se,MenuList:()=>be,NotificationLevel:()=>Wt,NotificationsContext:()=>Je,NotificationsProvider:()=>_o,PopupComponent:()=>Se,PopupMenu:()=>Wo,PopupService:()=>V,Portal:()=>Q,Prompt:()=>Vo,Separator:()=>$e,ToastNotification:()=>qt,Tooltip:()=>Xo,createContainer:()=>ro,isMenuItemLabel:()=>ve,reasonIsClickAway:()=>De,reasonIsMenuAction:()=>Ne,renderPortal:()=>He,useAnchoredPosition:()=>J,useContextMenu:()=>We,useDialog:()=>mo,useNotifications:()=>en,useTooltip:()=>Jo});module.exports=eo(tn);var pt=I(require("clsx")),ct=require("@vuu-ui/vuu-utils"),Y=require("react");var me=require("@salt-ds/core"),_e=I(require("clsx"));var re=require("react/jsx-runtime"),to="vuuDialogHeader",Ie=({hideCloseButton:e=!1,title:o,onClose:t,...n})=>(0,re.jsxs)("div",{...n,className:(0,_e.default)(to,"vuuToolbarProxy"),children:[(0,re.jsx)(me.Text,{className:"dialogHeader",children:o}),!e&&(0,re.jsx)(me.Button,{onClick:t,"data-align":"end","data-icon":"close",variant:"secondary"},"close")]});var ot=I(require("clsx")),ie=I(require("react")),ee=I(require("react-dom"));var et=I(require("react-dom")),tt=I(require("clsx")),oo=1,no=({className:e,dataMode:o,x:t=0,y:n=0,win:r=window})=>{let i=r.document.createElement("div");return i.className=(0,tt.default)(`vuuPopup ${oo++}`,e),i.style.cssText=`left:${t}px; top:${n}px;`,o&&(i.dataset.mode=o),r.document.body.appendChild(i),i},ro=e=>no(e),He=(e,o,t,n,r)=>{o.style.cssText=`left:${t}px; top:${n}px;position: absolute;`,et.render(e,o,r)};var X=!1,S=[],Ne=e=>(e==null?void 0:e.type)==="menu-action",De=e=>(e==null?void 0:e.type)==="click-away";function fe(e){if(e.key==="Esc"){if(S.length)rt();else if(X){let o=document.body.querySelector(".vuuDialog");o&&ee.default.unmountComponentAtNode(o)}}}function nt(e){if(S.length){let o=document.body.querySelectorAll(".vuuPopup,#vuu-portal-root");for(let t=0;t<o.length;t++)if(o[t].contains(e.target))return;rt({mouseEvt:e,type:"click-away"})}}function rt(e){if(S.length===1)V.hidePopup(e,"anon","all");else if(S.length){let o=document.body.querySelectorAll(".vuuPopup");for(let t=0;t<o.length;t++)ee.default.unmountComponentAtNode(o[t]);it("*")}}function io(){X===!1&&(X=!0,window.addEventListener("keydown",fe,!0))}function so(){X&&(X=!1,window.removeEventListener("keydown",fe,!0))}function uo(e){S.indexOf(e)===-1&&(S.push(e),X===!1&&(window.addEventListener("keydown",fe,!0),window.addEventListener("click",nt,!0)))}function it(e){if(S.length){if(e==="*")S.length=0;else{let o=S.indexOf(e);o!==-1&&S.splice(o,1)}S.length===0&&X===!1&&(window.removeEventListener("keydown",fe,!0),window.removeEventListener("click",nt,!0))}}var ao=({children:e,position:o,style:t})=>{let n=(0,ot.default)("hwPopup","hwPopupContainer",o);return(0,ie.createElement)("div",{className:n,style:t},e)},lo=1,V=class e{static showPopup({group:o="all",name:t="anon",left:n=0,position:r="",right:i="auto",top:s=0,width:d="auto",component:l}){if(!l)throw Error("PopupService showPopup, no component supplied");typeof l.props.onClose=="function"?e.onClose=l.props.onClose:e.onClose=void 0,uo(t),document.addEventListener("keydown",e.escapeKeyListener,!0);let a=document.body.querySelector(".vuuPopup."+o);a===null&&(a=document.createElement("div"),a.className="vuuPopup "+o,document.body.appendChild(a));let u={width:d};He((0,ie.createElement)(ao,{key:lo++,position:r,style:u},l),a,n,s,()=>{e.keepWithinThePage(a,i)})}static escapeKeyListener(o){o.key==="Escape"&&e.hidePopup({type:"escape",event:o})}static hidePopup(o,t="anon",n="all"){var r;if(S.indexOf(t)!==-1){it(t);let i=document.body.querySelector(`.vuuPopup.${n}`);i&&ee.default.unmountComponentAtNode(i)}document.removeEventListener("keydown",e.escapeKeyListener,!0),(r=e==null?void 0:e.onClose)==null||r.call(e,o)}static keepWithinThePage(o,t="auto"){let n=o.querySelector(".vuuPopupContainer > *");if(n){let{top:r,left:i,width:s,height:d,right:l}=n.getBoundingClientRect(),a=window.innerWidth,p=window.innerHeight-(r+d);p<0&&(n.style.top=Math.round(r)+p+"px");let c=a-(i+s);if(c<0&&(n.style.left=Math.round(i)+c+"px"),typeof t=="number"&&t!==l){let m=t-l;n.style.left=i+m+"px"}}}},Ae=class e{static showDialog(o){let t=".vuuDialog",n=o.props.onClose;io(),ee.default.render(ie.default.cloneElement(o,{container:t,onClose:()=>{e.closeDialog(),n&&n()}}),document.body.querySelector(t))}static closeDialog(){so();let o=document.body.querySelector(".vuuDialog");o&&ee.default.unmountComponentAtNode(o)}};var ut=I(require("clsx"));var U=require("react"),st=(e,o,t,n,r,i)=>{let{bottom:s,height:d,left:l,right:a,top:u,width:p}=e.getBoundingClientRect();switch(o){case"below":return{left:l+t,top:s+n};case"right":return{left:a+t,top:u+n};case"below-center":return{left:l+p/2+t,top:s+n};case"below-right":return{left:l,minWidth:r,top:s+n};case"below-full-width":return{left:l+t,minWidth:r,top:s+n,width:p};case"center":return i?{left:p/2-i.width/2+t,top:d/2-i.height/2+n,visibility:"visible"}:{left:p/2+t,top:d/2+n,visibility:"hidden"};default:throw Error("Popup getPositionRelativeToAnchor only supported placement values are below and right")}},J=({anchorElement:e,minWidth:o,offsetLeft:t=0,offsetTop:n=0,placement:r,position:i})=>{let s=(0,U.useRef)(null),[d,l]=(0,U.useState)(i);(0,U.useLayoutEffect)(()=>{if(r==="absolute"&&i)l(i);else if(e.current&&r!=="auto"){let u=s.current===null?void 0:s.current.getBoundingClientRect(),p=st(e.current,r,t,n,o,u);l(p)}},[e,o,t,n,r,i]);let a=(0,U.useCallback)(u=>{if(s.current=u,u&&r==="center"&&e.current){let{height:p,width:c}=u.getBoundingClientRect();l(st(e.current,r,t,n,void 0,{height:p,width:c}))}},[e,t,n,r]);return{position:d,popupRef:r==="center"?a:void 0}};var at=require("react/jsx-runtime"),Se=({children:e,className:o,anchorElement:t,minWidth:n,placement:r,position:i})=>{let{popupRef:s,position:d}=J({anchorElement:t,minWidth:n,placement:r,position:i});return d===void 0?null:(0,at.jsx)("div",{className:(0,ut.default)("vuuPortal",o),ref:s,style:d,children:e})};var te=require("react/jsx-runtime"),lt="vuuDialog",po={current:document.body},co={},Be=({PopupProps:e=co,children:o,className:t,isOpen:n=!1,onClose:r,style:i,title:s,hideCloseButton:d=!1,...l})=>{let{anchorElement:a=po,offsetLeft:u=0,offsetTop:p=0,placement:c="auto"}=e,m=(0,Y.useRef)(null),y=(0,Y.useRef)(null),[f,C,M]=(0,ct.useThemeAttributes)(),{position:E}=J({anchorElement:a,offsetLeft:u,offsetTop:p,placement:c}),T=(0,Y.useCallback)(()=>{r==null||r()},[r]);return(0,Y.useLayoutEffect)(()=>{if(m.current){if(n){m.current.showModal();let{left:P,top:h}=m.current.getBoundingClientRect();y.current&&(y.current.style.cssText=`left:-${P}px;position:absolute;top:-${h}px;`)}else m.current.close();if(c.endsWith("center")){let{width:P}=m.current.getBoundingClientRect();m.current.style.marginLeft=`-${P/2}px`}}},[n,c]),(0,te.jsxs)("dialog",{...l,className:(0,pt.default)(lt,f),"data-mode":M,onClose:T,id:"vuu-dialog",ref:m,style:{...i,...E},children:[(0,te.jsx)(Ie,{hideCloseButton:d,onClose:T,title:s}),(0,te.jsx)("div",{className:`${lt}-body`,children:o}),(0,te.jsx)("div",{id:"vuu-dialog-portal-root",ref:y})]})};var ge=require("react");var dt=require("react/jsx-runtime"),mo=()=>{let[e,o]=(0,ge.useState)(),t=(0,ge.useCallback)(()=>{o(void 0)},[]);return{dialog:e?(0,dt.jsx)(Be,{className:"vuDialog",isOpen:!0,onClose:t,style:{maxHeight:500},title:e.title,hideCloseButton:e.hideCloseButton,children:e.content}):null,setDialogState:o}};var Rt=require("@vuu-ui/vuu-utils"),_=require("react");var mt=require("@vuu-ui/vuu-utils"),j=require("react"),ft=require("react-dom");function fo(e){return typeof e=="function"?e():e}var go=["vuu-dialog-portal-root","vuu-portal-root"],vo=e=>{if(Array.isArray(e))for(let o of e){let t=document.getElementById(o);if(t)return t}else return document.getElementById(e);return null},Q=({children:e,container:o=document.body,id:t=go,onRender:n,open:r=!0,themeAttributes:i})=>{var m;let[s,d]=(0,j.useState)(!1),l=(0,j.useRef)(null),a=(m=fo(o))!=null?m:document.body,[u,p,c]=(0,mt.useThemeAttributes)(i);return(0,j.useLayoutEffect)(()=>{let y=vo(t);y?l.current=y:(l.current=document.createElement("div"),l.current.id=typeof t=="string"?t:t.length>0?t.at(-1):"vuu-portal-root");let f=l.current;a.contains(f)||a.appendChild(f),f.classList.add(u,p),f.dataset.mode=c,d(!0)},[t,a,u,p,c]),(0,j.useLayoutEffect)(()=>{requestAnimationFrame(()=>{n==null||n()})},[n]),r&&s&&l.current&&e?(0,ft.createPortal)(e,l.current):null};var Ke=I(require("clsx")),F=I(require("react")),Ct=require("@vuu-ui/vuu-utils");var Z=I(require("react"));var Oe=e=>e.type===se||!!e.props["data-group"],ho=e=>{if(Array.isArray(e)&&ve(e[0]))return e[0]},bo=(e,o,t,n=!1)=>{let{props:{children:r}}=e;return{childWithId:Z.default.cloneElement(e,{hasSeparator:n,id:`${o}`,key:o,children:t?ho(r):r}),grandChildren:t?r:void 0}},gt=(e,o)=>{let t=(0,Z.useCallback)(()=>{let i=(s,d=o,l={},a={})=>{let u=l[d]=[],p=0,c=!1;return Z.default.Children.forEach(s,m=>{if(!ve(m))if(m.type===$e)c=!0;else{let y=Oe(m),f=`${d}-${p}`,{props:{action:C,options:M}}=m,{childWithId:E,grandChildren:T}=bo(m,f,y,c);u.push(E),T?i(T,f,l,a):a[f]={action:C,options:M},p+=1,c=!1}}),[l,a]};return i(e)},[o,e]),[n,r]=(0,Z.useMemo)(()=>t(),[t]);return[n,r]};var D=require("react");var vt=e=>e.closest("[data-root='true']")!==null,ht=(e,o)=>{var t;return e.ariaHasPopup==="true"&&((t=e.dataset)==null?void 0:t.idx)===`${o}`||e.querySelector(`:scope > [data-index='${o}'][aria-haspopup='true']`)!==null};function xo(e,...o){let t=new Set(e);for(let n of o)for(let r of n)t.add(r);return t}var Mo="Enter";var yo="Delete",Po=new Set([Mo,yo]),Co=new Set(["Tab"]),wo=new Set(["ArrowRight","ArrowLeft"]),bt=new Set(["Home","End","ArrowDown","ArrowUp"]),xt=new Set(["Home","End","ArrowRight","ArrowLeft"]),Eo=new Set(["F1","F2","F3","F4","F5","F6","F7","F8","F9","F10","F11","F12"]),Un=xo(Po,xt,bt,wo,Eo,Co);var Mt=({key:e},o="vertical")=>(o==="vertical"?bt:xt).has(e);var he=require("@vuu-ui/vuu-utils"),yt=({autoHighlightFirstItem:e=!1,count:o,defaultHighlightedIdx:t,highlightedIndex:n,onActivate:r,onHighlight:i,onCloseMenu:s,onOpenMenu:d})=>{var P;if((0,he.isValidNumber)(n)&&(0,he.isValidNumber)(t))throw Error("useKeyboardNavigation do not pass values for both highlightedIndex and defaultHighlightedIdx");let l=(0,he.isValidNumber)(n),a=(0,D.useRef)((P=t!=null?t:n)!=null?P:e?0:-1),[,u]=(0,D.useState)(null),p=(0,D.useCallback)(h=>{a.current=h,i==null||i(h),u({})},[i]),c=(0,D.useCallback)(h=>{h!==a.current&&(l||p(h))},[l,p]),m=(0,D.useRef)(!0),y=(0,D.useRef)(!1),f=h=>y.current=h,C=l?n:a.current,M=(0,D.useCallback)(h=>{let b=To(o,h.key,a.current);b!==a.current&&c(b)},[o,c]),E=(0,D.useCallback)(h=>{if(Mt(h))h.preventDefault(),h.stopPropagation(),m.current=!0,M(h);else if((h.key==="ArrowRight"||h.key==="Enter")&&ht(h.target,C)){let g=h.target.querySelector(`:scope > [data-index='${C}']`);g&&(d==null||d(g,!0))}else h.key==="ArrowLeft"&&!vt(h.target)?s(C):h.key==="Enter"?(h.preventDefault(),h.stopPropagation(),r&&r(C)):h.key==="Tab"&&s(-1)},[C,M,r,s,d]),T=(0,D.useMemo)(()=>({onFocus:()=>{C===-1&&p(0)},onKeyDown:E,onMouseDownCapture:()=>{m.current=!1,f(!0)},onMouseMove:()=>{m.current&&(m.current=!1)},onMouseLeave:()=>{m.current=!0,f(!1),c(-1)}}),[E,C,p,c]);return{focusVisible:m.current?C:-1,controlledHighlighting:l,highlightedIndex:C,setHighlightedIndex:c,listProps:T,setIgnoreFocus:f}};function To(e,o,t){return o==="ArrowUp"?t>0?t-1:t:t===null?0:t===e-1?t:t+1}var z=require("react/jsx-runtime"),Pt="vuuMenuList",$e=()=>(0,z.jsx)("li",{className:"vuuMenuItem-divider"}),se=()=>null,ue=({children:e,idx:o,options:t,...n})=>(0,z.jsx)("div",{...n,children:e}),wt=({children:e})=>(0,z.jsx)(z.Fragment,{children:e});wt.displayName="MenuItemLabel";ue.Label=wt;var ko=e=>F.default.isValidElement(e)&&typeof e.type!="string"&&"displayName"in e.type?e.type.displayName:void 0,ve=e=>ko(e)==="MenuItemLabel",Lo=e=>e.props["data-icon"],be=({activatedByKeyboard:e,childMenuShowing:o,children:t,className:n,defaultHighlightedIdx:r,highlightedIdx:i,id:s,isRoot:d,listItemProps:l,onHighlightMenuItem:a,onActivate:u,onCloseMenu:p,openMenu:c,...m})=>{let y=(0,Ct.useId)(s),f=(0,F.useRef)(null),C=(0,F.useMemo)(()=>new Map,[]),M=v=>{var w;let x=(w=f.current)==null?void 0:w.querySelector(`:scope > [data-index='${v}']`);x!=null&&x.id&&(u==null||u(x.id))},{focusVisible:E,highlightedIndex:T,listProps:P}=yt({count:F.default.Children.count(t),defaultHighlightedIdx:r,highlightedIndex:i,onActivate:M,onHighlight:a,onOpenMenu:c,onCloseMenu:p}),h=o==null?E:-1;(0,F.useLayoutEffect)(()=>{var v;o===void 0&&e&&((v=f.current)==null||v.focus())},[e,o]);let b=()=>T===void 0||T===-1?void 0:C.get(T);function g(){let v={...l,role:"menuitem"},x=(H,k,N)=>k?[(0,z.jsx)("span",{className:"vuuIconContainer","data-icon":N},"icon")].concat(H):H;function w(H,k,N,K){var Qe;let{children:G,className:Gt,"data-icon":Ye,id:ce,hasSeparator:Vt,label:Le,...Ut}=k.props,Re=Oe(k),je=Re&&o===ce,Xt=je?`${y}-${ce}`:void 0;H.push((0,z.jsx)(ue,{...Ut,...v,...Ro(ce,N,(Qe=k.key)!=null?Qe:ce,T,h,Gt,Vt),"aria-controls":Xt,"aria-haspopup":Re||void 0,"aria-expanded":je||void 0,children:x(Re&&Le!=null?Le:G,K,Ye)}))}let R=[];if(t.length>0){let H=t.some(Lo);t.forEach((k,N)=>{w(R,k,N,H)})}return R}return(0,z.jsx)("div",{...m,...P,"aria-activedescendant":b(),className:(0,Ke.default)(Pt,n,{[`${Pt}-childMenuShowing`]:o!==void 0}),"data-root":d||void 0,id:y,ref:f,role:"menu",children:g()})},Ro=(e,o,t,n,r,i,s)=>({id:`menuitem-${e}`,key:t!=null?t:o,"data-index":o,"data-highlighted":o===n||void 0,className:(0,Ke.default)("vuuMenuItem",i,{"vuuMenuItem-separator":s,focusVisible:r===o})});be.displayName="MenuList";var L=require("react");var ze=e=>e==null?void 0:e.closest("[data-index],[aria-posinset]");var Tt=(e,o,t)=>e.map((n,r)=>r===e.length-1?{...n,[t]:n[t]-o}:n),Io=(e,o)=>Tt(e,o,"left"),Ho=(e,o)=>Tt(e,o,"top"),Ao=(e,o)=>{let[t,n]=o.slice(-2),r=document.getElementById(`${e}-${n.id}`);if(r===null)throw Error(`useCascade.flipSides element with id ${n.id} not found`);let{width:i}=r.getBoundingClientRect();return o.map(s=>s===n?{...s,left:t.left-(i-2)}:s)},No=(e,o)=>{let[{left:t,top:n}]=o.slice(-1),{offsetWidth:r,offsetTop:i}=e;return{left:t+r,top:i+n}},kt=(e,o)=>{let t=e.lastIndexOf("-");return e.startsWith("menuitem")?t>-1?e.slice(9,t):o:t>-1?e.slice(0,t):o},Do=e=>e.slice(9),Et=({ariaExpanded:e,ariaHasPopup:o,id:t},n)=>{if(t.startsWith("menuitem"))return{hostMenuId:kt(t,n),targetMenuId:Do(t),menuItemId:t,isGroup:o==="true",isOpen:e==="true"};throw Error(`getMenuItemDetails #${t} is not a menuitem`)},Lt=({id:e,onActivate:o,onMouseEnterItem:t,position:{x:n,y:r}})=>{let[,i]=(0,L.useState)({}),s=(0,L.useRef)([{id:e,left:n,top:r}]),d=(0,L.useCallback)(b=>s.current.findIndex(g=>g.id===b)!==-1,[]),l=(0,L.useCallback)(b=>{let g=c.current[b];if(g===void 0)throw Error(`getOpenMenuState no entry for menu ${b}`);return g},[]),a=(0,L.useCallback)(b=>{s.current=b,i({})},[]),u=(0,L.useRef)(),p=(0,L.useRef)(),c=(0,L.useRef)({[e]:"no-popup"}),m=(0,L.useCallback)((b=e,g,v=null)=>{if(b===e&&v===null)a([{id:e,left:n,top:r}]);else{c.current[b]="popup-open";let x=document.getElementById(v);if(x!==null){let{left:w,top:R}=No(x,s.current);a(s.current.concat({id:g,left:w,top:R}))}else throw Error(`openMenu no menuItem ${v}`)}},[e,n,r,a]),y=(0,L.useCallback)(b=>{if(b===e)a([]);else{let g=s.current.slice(),v=g.pop();c.current[v.id]="no-popup";let x=g.at(-1);x&&(c.current[x.id]="no-popup"),a(g)}},[e,a]),f=(0,L.useCallback)(b=>{let g=s.current.slice(),v=b.slice(9),{id:x}=g.at(-1);for(;g.length>1&&!v.startsWith(x);){let w=kt(x,e);g.pop(),c.current[x]="no-popup",c.current[w]="no-popup",{id:x}=g[g.length-1]}g.length<s.current.length&&a(g)},[e,a]),C=(0,L.useCallback)(()=>{u.current&&(clearTimeout(u.current),u.current=void 0)},[]),M=(0,L.useCallback)((b,g,v,x=300)=>{C(),u.current=window.setTimeout(()=>{f(v),c.current[b]="popup-open",c.current[g]="no-popup",m(b,g,v)},x)},[C,f,m]),E=(0,L.useCallback)((b,g,v)=>{c.current[g]="pending-close",p.current=window.setTimeout(()=>{f(v)},400)},[f]),T=(0,L.useCallback)(()=>{let{current:b}=s,g=b.at(-1),v=g?document.getElementById(g.id):void 0;if(v){let{right:x,bottom:w}=v.getBoundingClientRect(),{clientHeight:R,clientWidth:H}=document.body;if(x>H){let k=b.length>1?Ao(e,b):Io(b,x-H);a(k)}else if(w>R){let k=Ho(b,w-R);a(k)}typeof v.tabIndex=="number"&&v.focus()}},[e,a]),P=(0,L.useCallback)((b,g=!1)=>{let{hostMenuId:v,targetMenuId:x,menuItemId:w,isGroup:R,isOpen:H}=Et(b,e),{current:{[v]:k}}=c,N=g?0:void 0;if(k==="no-popup"&&R)c.current[v]="popup-pending",M(v,x,w,N);else if(k==="popup-pending"&&!R)c.current[v]="no-popup",clearTimeout(u.current),u.current=void 0;else if(k==="popup-pending"&&R)clearTimeout(u.current),M(v,x,w,N);else if(k==="popup-open")if(d(x)){let K=l(x);switch(f(w),K){case"pending-close":clearTimeout(p.current),p.current=void 0,c.current[x]="no-popup",C();break;default:}}else{let[K,G]=s.current.slice(-2);K.id===v&&c.current[G.id]!=="pending-close"?(E(v,G.id,w),R&&!H&&M(v,x,w,N)):K.id===v&&R&&w!==G.id&&c.current[G.id]==="pending-close"||R?M(v,x,w,N):c.current[G.id]!=="pending-close"&&f(w)}k==="pending-close"&&(C(),clearTimeout(p.current),p.current=void 0,c.current[v]="popup-open")},[C,f,l,d,e,E,M]),h=(0,L.useMemo)(()=>({onMouseEnter:b=>{let g=ze(b.target);P(g),t(b,g.id)},onClick:b=>{let g=ze(b.target),{isGroup:v,menuItemId:x}=Et(g,e);v?P(g):o(x)}}),[o,t,e,P]);return{closeMenu:y,handleRender:T,listItemProps:h,openMenu:P,openMenus:s.current}};var ae=require("react/jsx-runtime"),Fe=require("react"),So=()=>{},xe=({PortalProps:e,activatedByKeyboard:o,children:t,className:n,id:r,onClose:i=()=>{},position:s={x:0,y:0},style:d,...l})=>{let a=(0,_.useRef)(i);a.current=i;let u=(0,Rt.useId)(r),p=(0,_.useRef)(So),[c,m]=gt(t,u),y=(0,_.useRef)(o),f=(0,_.useCallback)(()=>{y.current=!1},[]),C=(0,_.useCallback)(w=>{let R=w.slice(9),{action:H,options:k}=m[R];p.current(u),i({type:"menu-action",menuId:H,options:k})},[m,u,i]),{closeMenu:M,listItemProps:E,openMenu:T,openMenus:P,handleRender:h}=Lt({id:`${u}`,onActivate:C,onMouseEnterItem:f,position:s});p.current=M;let b=()=>{y.current=!0,M()},g=()=>{},v=P.length-1,x=w=>{if(!(w>=v)){let{id:R}=P[w+1];return R}};return(0,ae.jsx)(ae.Fragment,{children:P.map(({id:w,left:R,top:H},k,N)=>{let K=x(k);return(0,Fe.createElement)(Q,{...e,key:k,onRender:h},(0,ae.jsx)(Se,{anchorElement:{current:document.body},placement:"absolute",position:{left:R,top:H},children:(0,Fe.createElement)(be,{...l,activatedByKeyboard:y.current,childMenuShowing:K,className:n,id:w,isRoot:k===0,key:k,listItemProps:E,onActivate:C,onHighlightMenuItem:g,onCloseMenu:b,openMenu:T,style:d,tabIndex:k===N.length-1?0:void 0},c[w])}))})})};xe.displayName="ContextMenu";var oe=require("react"),Me=require("react/jsx-runtime"),le=(0,oe.createContext)(null),Bo=({children:e,context:o,menuActionHandler:t,menuBuilder:n})=>{let r=(0,oe.useMemo)(()=>o!=null&&o.menuBuilders&&n?o.menuBuilders.concat(n):n?[n]:(o==null?void 0:o.menuBuilders)||[],[o,n]),i=(0,oe.useCallback)(s=>{var d;if(t!=null&&t(s)||(d=o==null?void 0:o.menuActionHandler)!=null&&d.call(o,s))return!0},[o,t]);return(0,Me.jsx)(le.Provider,{value:{menuActionHandler:i,menuBuilders:r},children:e})},Oo=({children:e,label:o,menuActionHandler:t,menuBuilder:n})=>(0,Me.jsx)(le.Consumer,{children:r=>(0,Me.jsx)(Bo,{context:r,label:o,menuActionHandler:t,menuBuilder:n,children:e})});var Pe=require("@vuu-ui/vuu-utils"),$=require("react");var ye=require("react/jsx-runtime"),We=(e,o)=>{let t=(0,$.useContext)(le),[n,r,i]=(0,Pe.useThemeAttributes)(),s=(0,$.useMemo)(()=>({themeClass:n,densityClass:r,dataMode:i}),[i,r,n]),d=(0,$.useCallback)((u,p,c)=>{let m=[];for(let y of u)m=m.concat(y(p,c));return m},[]),l=(0,$.useCallback)((u,p,{ContextMenuProps:c,contextMenu:m,...y})=>{var C,M;if((C=u.stopPropagation)==null||C.call(u),(M=u.preventDefault)==null||M.call(u),m)return Ko({x:u.clientX,y:u.clientY},m);let f=[];if(e&&f.push(e),t&&Array.isArray(t==null?void 0:t.menuBuilders)&&t.menuBuilders.length>0&&f.push(...t.menuBuilders),f.length>0){let E=d(f,p,y),T=P=>(o==null?void 0:o(P))===!0?!0:t==null?void 0:t.menuActionHandler(P);E.length&&T&&zo(u,E,T,{PortalProps:{themeAttributes:s},...c})}else console.warn("useContextMenu, no menuBuilders configured. These should be supplied via the ContextMenuProvider(s)")},[d,t,o,e,s]),a=(0,$.useCallback)(()=>{console.log("hide context menu")},[]);return[l,a]},$o={},Ko=(e,o)=>{V.showPopup({focus:!0,left:0,top:0,component:(0,$.cloneElement)(o,{position:e})})},zo=(e,o,t,{position:n,...r}=$o)=>{let i=a=>{let u=(p,c)=>(0,Pe.isGroupMenuItemDescriptor)(p)?(0,ye.jsx)(se,{label:p.label,children:p.children.map(u)},c):(0,ye.jsx)(ue,{action:p.action,className:p.className,"data-icon":p.icon,options:p.options,children:p.label},c);return a.map(u)},s=a=>{var u;Ne(a)&&(t(a),V.hidePopup()),(u=r==null?void 0:r.onClose)==null||u.call(r,a)},d=n!=null?n:{x:e.clientX,y:e.clientY},l=(0,ye.jsx)(xe,{...r,onClose:s,position:d,children:i(o)});V.showPopup({left:0,top:0,component:l,focus:!0})};var It=require("@vuu-ui/vuu-utils"),Ht=require("@salt-ds/core"),At=I(require("clsx")),W=require("react");var Nt=require("react/jsx-runtime"),qe="vuuPopupMenu",Fo=e=>{if(e){let{bottom:o,left:t}=e.getBoundingClientRect();return{x:t,y:o+6}}},Wo=({className:e,label:o,icon:t=o?"chevron-down":"more-vert",id:n,menuActionHandler:r,menuBuilder:i,menuLocation:s="header",menuOptions:d,onMenuClose:l,tabIndex:a=0,...u})=>{let p=(0,W.useRef)(null),c=(0,W.useRef)(!1),[m,y]=(0,W.useState)(!1),f=(0,It.useId)(n),[C]=We(i,r),M=(0,W.useCallback)(P=>{console.log("menu Open ",{el:P})},[]),E=(0,W.useCallback)(P=>{y(!1),De(P)?P.mouseEvt.target===p.current&&(c.current=!0):requestAnimationFrame(()=>{var h;l==null||l(P),a!==-1&&((h=p.current)==null||h.focus())})},[l,a]),T=(0,W.useCallback)(P=>{c.current?c.current=!1:(y(!0),C(P,s,{ContextMenuProps:{id:`${f}-menu`,onClose:E,openMenu:M,position:Fo(p.current)},...d}))},[E,M,f,s,d,C]);return(0,Nt.jsx)(Ht.Button,{...u,"aria-controls":`${f}-menu-root`,"aria-expanded":m,"aria-haspopup":"menu",className:(0,At.default)(qe,e,{[`${qe}-withCaption`]:o!==void 0,[`${qe}-open`]:m}),"data-icon":t,id:f,onClick:T,ref:p,tabIndex:a,variant:"secondary",children:o})};var Dt=require("@vuu-ui/vuu-utils"),Ge=require("@salt-ds/core"),St=I(require("clsx")),pe=require("react");var q=require("react/jsx-runtime"),ne="vuuPrompt",qo={current:document.body},Go={},Vo=({PopupProps:e=Go,cancelButtonLabel:o="Cancel",confirmButtonLabel:t="Confirm",icon:n,onCancel:r,onConfirm:i,style:s,text:d,title:l,variant:a="info",...u})=>{let{anchorElement:p=qo,offsetLeft:c=0,offsetTop:m=0,placement:y="below"}=e,[f,C,M]=(0,Dt.useThemeAttributes)(),{position:E}=J({anchorElement:p,offsetLeft:c,offsetTop:m,placement:y}),T=(0,pe.useRef)(null),P=(0,pe.useRef)(null);return(0,pe.useLayoutEffect)(()=>{if(T.current&&(T.current.showModal(),P.current&&P.current.focus(),y.endsWith("center"))){let{width:h}=T.current.getBoundingClientRect();T.current.style.marginLeft=`-${h/2}px`}},[y]),(0,q.jsx)("dialog",{...u,className:(0,St.default)(ne,`${ne}-${a}`,f),"data-mode":M,ref:T,style:{...s,...E},children:(0,q.jsxs)("form",{className:`${ne}-form`,children:[(0,q.jsx)("div",{className:`${ne}-header`,"data-icon":n,children:l}),(0,q.jsx)("div",{className:`${ne}-text`,children:d}),(0,q.jsxs)("div",{className:`${ne}-buttonBar`,children:[(0,q.jsx)(Ge.Button,{onClick:r,variant:"secondary",children:o}),(0,q.jsx)(Ge.Button,{onClick:i,ref:P,value:"default",children:t})]})]})})};var Ce=require("react"),Uo=(e,o,t,n)=>{let{bottom:r,height:i,left:s,right:d,top:l,width:a}=e.getBoundingClientRect(),u=s+a/2,p=l+i/2;switch(o){case"above":return{left:u+t,top:l+n};case"below":return{left:u+t,top:r+n};case"right":return{left:d+t,top:p+t};case"left":return{left:s+t,top:p+t};default:throw Error("Tooltip getPositionRelativeToAnchor only supported placement values are left, right, below and right")}},Bt=({anchorElement:e,offsetLeft:o=0,offsetTop:t=0,placement:n})=>{let[r,i]=(0,Ce.useState)();return(0,Ce.useLayoutEffect)(()=>{if(e.current){let s=Uo(e.current,n,o,t);i(s)}},[e,o,t,n]),r};var Ot=I(require("clsx"));var we=require("react/jsx-runtime"),Ve="vuuTooltip",Xo=({anchorElement:e,children:o,id:t,onMouseEnter:n,onMouseLeave:r,placement:i,status:s,style:d})=>{let l=Bt({anchorElement:e,placement:i});return l===void 0?null:(0,we.jsx)(Q,{children:(0,we.jsx)("div",{className:(0,Ot.default)(Ve,{[`${Ve}-error`]:s==="error"}),"data-align":i,id:t,style:{...d,...l},children:(0,we.jsx)("span",{className:`${Ve}-content`,onMouseEnter:n,onMouseLeave:r,children:o})})})};var $t=require("@vuu-ui/vuu-utils"),A=require("react"),Jo=({id:e,placement:o="right",tooltipContent:t})=>{let n=(0,A.useRef)(),r=(0,A.useRef)(null),i=(0,A.useRef)(),s=(0,A.useRef)(),[d,l]=(0,A.useState)(),a=(0,$t.useId)(e),u=(0,A.useCallback)(M=>{var E;M.key==="Escape"&&((E=n.current)==null||E.call(n))},[]);n.current=(0,A.useCallback)(()=>{l(void 0),document.removeEventListener("keydown",u)},[u]);let p=(0,A.useCallback)(()=>{window.clearTimeout(s.current)},[]),c=(0,A.useCallback)(()=>{var M;(M=n.current)==null||M.call(n)},[]),m=(0,A.useCallback)(()=>{let{current:M}=r;M&&(l({anchorElement:r,children:t,id:`${a}-tooltip`,onMouseEnter:p,onMouseLeave:c,placement:o}),document.addEventListener("keydown",u)),i.current=void 0},[u,p,c,a,o,t]),y=(0,A.useCallback)(M=>{let E=M.target;E&&(r.current=E,i.current=window.setTimeout(m,800))},[m]),f=(0,A.useCallback)(()=>{r.current&&(i.current?(window.clearTimeout(i.current),i.current=void 0):n.current&&(s.current=window.setTimeout(n.current,200)))},[]);return{anchorProps:{"aria-describedby":`${a}-tooltip`,onMouseEnter:y,onMouseLeave:f},tooltipProps:d}};var O=I(require("react")),Ue=I(require("clsx")),Kt=require("@vuu-ui/vuu-utils");var B=require("react/jsx-runtime"),Yo=60,zt=6e3,Xe=1e3,jo=300,Ft=56,Te=300,Qo=10,Zo=10,ke=50,Ee="vuuToastNotifications",Wt=(r=>(r.Info="info",r.Success="success",r.Warning="warning",r.Error="error",r))(Wt||{}),Je=O.default.createContext({notify:()=>"have you forgotten to provide a NotificationProvider?"}),_o=e=>{let[o,t]=(0,O.useState)([]),n=(0,O.useCallback)(r=>{let i={...r,id:(0,Kt.getUniqueId)()};t(s=>[...s,i]),setTimeout(()=>{t(s=>s.filter(d=>d!==i))},zt+Xe*2)},[]);return(0,B.jsxs)(Je.Provider,{value:{notify:n},children:[(0,B.jsx)("div",{style:{width:Te+ke+Zo},children:o.map((r,i)=>(0,B.jsx)(qt,{top:Yo+(Ft+Qo)*i,notification:r},r.id))}),e.children]})},en=()=>(0,O.useContext)(Je),qt=e=>{let{top:o,notification:t,animated:n=!0}=e,[r,i]=(0,O.useState)(-Te-ke);return(0,O.useEffect)(()=>{setTimeout(()=>i(ke)),n&&setTimeout(()=>i(-Te-ke),zt+Xe)},[n]),(0,B.jsx)(Q,{children:(0,B.jsxs)("div",{className:(0,Ue.default)(`${Ee}-toast`,t.type),style:{height:Ft,right:r,width:Te,top:o,transition:n?`right ${Xe}ms, top ${jo}ms `:"none"},children:[(0,B.jsx)("div",{className:(0,Ue.default)(`${Ee}-toastIcon`,`${t.type}-icon`)}),(0,B.jsxs)("div",{className:`${Ee}-toastContent`,children:[(0,B.jsx)("strong",{className:`${Ee}-toastHeader`,children:t.header}),(0,B.jsx)("div",{children:t.body})]})]})})};
1
+ "use strict";var Jt=Object.create;var me=Object.defineProperty;var Yt=Object.getOwnPropertyDescriptor;var jt=Object.getOwnPropertyNames;var Qt=Object.getPrototypeOf,Zt=Object.prototype.hasOwnProperty;var _t=(e,o)=>{for(var t in o)me(e,t,{get:o[t],enumerable:!0})},_e=(e,o,t,n)=>{if(o&&typeof o=="object"||typeof o=="function")for(let r of jt(o))!Zt.call(e,r)&&r!==t&&me(e,r,{get:()=>o[r],enumerable:!(n=Yt(o,r))||n.enumerable});return e};var A=(e,o,t)=>(t=e!=null?Jt(Qt(e)):{},_e(o||!e||!e.__esModule?me(t,"default",{value:e,enumerable:!0}):t,e)),eo=e=>_e(me({},"__esModule",{value:!0}),e);var en={};_t(en,{ContextMenu:()=>Me,ContextMenuContext:()=>pe,ContextMenuProvider:()=>Oo,Dialog:()=>Oe,DialogHeader:()=>Ie,DialogService:()=>Ne,MenuItem:()=>ae,MenuItemGroup:()=>ue,MenuList:()=>xe,NotificationLevel:()=>Wt,NotificationsContext:()=>Ye,NotificationsProvider:()=>Zo,PopupComponent:()=>Be,PopupMenu:()=>Fo,PopupService:()=>G,Portal:()=>Q,Prompt:()=>Go,Separator:()=>Ke,ToastNotification:()=>qt,Tooltip:()=>Uo,createContainer:()=>ro,isMenuItemLabel:()=>he,reasonIsClickAway:()=>Se,reasonIsMenuAction:()=>De,renderPortal:()=>Ae,useAnchoredPosition:()=>J,useContextMenu:()=>qe,useDialog:()=>mo,useNotifications:()=>_o,useTooltip:()=>Xo});module.exports=eo(en);var pt=A(require("clsx")),ct=require("@vuu-ui/vuu-utils"),Y=require("react");var fe=require("@salt-ds/core"),et=A(require("clsx"));var re=require("react/jsx-runtime"),to="vuuDialogHeader",Ie=({hideCloseButton:e=!1,title:o,onClose:t,...n})=>(0,re.jsxs)("div",{...n,className:(0,et.default)(to,"vuuToolbarProxy"),children:[(0,re.jsx)(fe.Text,{className:"dialogHeader",children:o}),!e&&(0,re.jsx)(fe.Button,{onClick:t,"data-align":"end","data-icon":"close",variant:"secondary"},"close")]});var nt=A(require("clsx")),ie=A(require("react")),ee=A(require("react-dom"));var tt=A(require("react-dom")),ot=A(require("clsx")),oo=1,no=({className:e,dataMode:o,x:t=0,y:n=0,win:r=window})=>{let i=r.document.createElement("div");return i.className=(0,ot.default)(`vuuPopup ${oo++}`,e),i.style.cssText=`left:${t}px; top:${n}px;`,o&&(i.dataset.mode=o),r.document.body.appendChild(i),i},ro=e=>no(e),Ae=(e,o,t,n,r)=>{o.style.cssText=`left:${t}px; top:${n}px;position: absolute;`,tt.render(e,o,r)};var X=!1,S=[],De=e=>(e==null?void 0:e.type)==="menu-action",Se=e=>(e==null?void 0:e.type)==="click-away";function ge(e){if(e.key==="Esc"){if(S.length)it();else if(X){let o=document.body.querySelector(".vuuDialog");o&&ee.default.unmountComponentAtNode(o)}}}function rt(e){if(S.length){let o=document.body.querySelectorAll(".vuuPopup,#vuu-portal-root");for(let t=0;t<o.length;t++)if(o[t].contains(e.target))return;it({mouseEvt:e,type:"click-away"})}}function it(e){if(S.length===1)G.hidePopup(e,"anon","all");else if(S.length){let o=document.body.querySelectorAll(".vuuPopup");for(let t=0;t<o.length;t++)ee.default.unmountComponentAtNode(o[t]);st("*")}}function io(){X===!1&&(X=!0,window.addEventListener("keydown",ge,!0))}function so(){X&&(X=!1,window.removeEventListener("keydown",ge,!0))}function uo(e){S.indexOf(e)===-1&&(S.push(e),X===!1&&(window.addEventListener("keydown",ge,!0),window.addEventListener("click",rt,!0)))}function st(e){if(S.length){if(e==="*")S.length=0;else{let o=S.indexOf(e);o!==-1&&S.splice(o,1)}S.length===0&&X===!1&&(window.removeEventListener("keydown",ge,!0),window.removeEventListener("click",rt,!0))}}var ao=({children:e,position:o,style:t})=>{let n=(0,nt.default)("hwPopup","hwPopupContainer",o);return(0,ie.createElement)("div",{className:n,style:t},e)},lo=1,G=class e{static showPopup({group:o="all",name:t="anon",left:n=0,position:r="",right:i="auto",top:s=0,width:m="auto",component:p}){if(!p)throw Error("PopupService showPopup, no component supplied");typeof p.props.onClose=="function"?e.onClose=p.props.onClose:e.onClose=void 0,uo(t),document.addEventListener("keydown",e.escapeKeyListener,!0);let a=document.body.querySelector(".vuuPopup."+o);a===null&&(a=document.createElement("div"),a.className="vuuPopup "+o,document.body.appendChild(a));let u={width:m};Ae((0,ie.createElement)(ao,{key:lo++,position:r,style:u},p),a,n,s,()=>{e.keepWithinThePage(a,i)})}static escapeKeyListener(o){o.key==="Escape"&&e.hidePopup({type:"escape",event:o})}static hidePopup(o,t="anon",n="all"){var r;if(S.indexOf(t)!==-1){st(t);let i=document.body.querySelector(`.vuuPopup.${n}`);i&&ee.default.unmountComponentAtNode(i)}document.removeEventListener("keydown",e.escapeKeyListener,!0),(r=e==null?void 0:e.onClose)==null||r.call(e,o?{...o,closedBy:"popup-service"}:void 0)}static keepWithinThePage(o,t="auto"){let n=o.querySelector(".vuuPopupContainer > *");if(n){let{top:r,left:i,width:s,height:m,right:p}=n.getBoundingClientRect(),a=window.innerWidth,l=window.innerHeight-(r+m);l<0&&(n.style.top=Math.round(r)+l+"px");let c=a-(i+s);if(c<0&&(n.style.left=Math.round(i)+c+"px"),typeof t=="number"&&t!==p){let f=t-p;n.style.left=i+f+"px"}}}},Ne=class e{static showDialog(o){let t=".vuuDialog",n=o.props.onClose;io(),ee.default.render(ie.default.cloneElement(o,{container:t,onClose:()=>{e.closeDialog(),n&&n()}}),document.body.querySelector(t))}static closeDialog(){so();let o=document.body.querySelector(".vuuDialog");o&&ee.default.unmountComponentAtNode(o)}};var ut=A(require("clsx"));var V=require("react");var se=(e,o,t,n,r,i)=>{let{bottom:s,height:m,left:p,right:a,top:u,width:l}=e.getBoundingClientRect();switch(console.log({top:u}),o){case"below":return{left:p+t,top:s+n};case"right":return{left:a+t,top:u+n};case"below-center":return{left:p+l/2+t,top:s+n};case"below-right":return{left:p,minWidth:r,top:s+n};case"below-full-width":return{left:p+t,minWidth:r,top:s+n,width:l};case"center":return i?{left:l/2-i.width/2+t,top:m/2-i.height/2+n,visibility:"visible"}:{left:l/2+t,top:m/2+n,visibility:"hidden"};default:throw Error(`Popup getPositionRelativeToAnchor non-supported placement value ${o}`)}};var J=({anchorElement:e,minWidth:o,offsetLeft:t=0,offsetTop:n=0,placement:r,position:i})=>{let s=(0,V.useRef)(null),[m,p]=(0,V.useState)(i);(0,V.useLayoutEffect)(()=>{if(r==="absolute"&&i)p(i);else if(e.current&&r!=="auto"){let u=s.current===null?void 0:s.current.getBoundingClientRect(),l=se(e.current,r,t,n,o,u);p(l)}},[e,o,t,n,r,i]);let a=(0,V.useCallback)(u=>{if(s.current=u,u&&r==="center"&&e.current){let{height:l,width:c}=u.getBoundingClientRect();p(se(e.current,r,t,n,void 0,{height:l,width:c}))}},[e,t,n,r]);return{position:m,popupRef:r==="center"?a:void 0}};var at=require("react/jsx-runtime"),Be=({children:e,className:o,anchorElement:t,minWidth:n,placement:r,position:i})=>{let{popupRef:s,position:m}=J({anchorElement:t,minWidth:n,placement:r,position:i});return m===void 0?null:(0,at.jsx)("div",{className:(0,ut.default)("vuuPortal",o),ref:s,style:m,children:e})};var te=require("react/jsx-runtime"),lt="vuuDialog",po={current:document.body},co={},Oe=({PopupProps:e=co,children:o,className:t,isOpen:n=!1,onClose:r,style:i,title:s,hideCloseButton:m=!1,...p})=>{let{anchorElement:a=po,offsetLeft:u=0,offsetTop:l=0,placement:c="auto"}=e,f=(0,Y.useRef)(null),C=(0,Y.useRef)(null),[v,P,y]=(0,ct.useThemeAttributes)(),{position:E}=J({anchorElement:a,offsetLeft:u,offsetTop:l,placement:c}),w=(0,Y.useCallback)(()=>{r==null||r()},[r]);return(0,Y.useLayoutEffect)(()=>{if(f.current){if(n){f.current.showModal();let{left:T,top:b}=f.current.getBoundingClientRect();C.current&&(C.current.style.cssText=`left:-${T}px;position:absolute;top:-${b}px;`)}else f.current.close();if(c.endsWith("center")){let{width:T}=f.current.getBoundingClientRect();f.current.style.marginLeft=`-${T/2}px`}}},[n,c]),(0,te.jsxs)("dialog",{...p,className:(0,pt.default)(lt,v),"data-mode":y,onClose:w,id:"vuu-dialog",ref:f,style:{...i,...E},children:[(0,te.jsx)(Ie,{hideCloseButton:m,onClose:w,title:s}),(0,te.jsx)("div",{className:`${lt}-body`,children:o}),(0,te.jsx)("div",{id:"vuu-dialog-portal-root",ref:C})]})};var ve=require("react");var dt=require("react/jsx-runtime"),mo=()=>{let[e,o]=(0,ve.useState)(),t=(0,ve.useCallback)(()=>{o(void 0)},[]);return{dialog:e?(0,dt.jsx)(Oe,{className:"vuDialog",isOpen:!0,onClose:t,style:{maxHeight:500},title:e.title,hideCloseButton:e.hideCloseButton,children:e.content}):null,setDialogState:o}};var Lt=require("@vuu-ui/vuu-utils"),_=require("react");var mt=require("@vuu-ui/vuu-utils"),j=require("react"),ft=require("react-dom");function fo(e){return typeof e=="function"?e():e}var go=["vuu-dialog-portal-root","vuu-portal-root"],vo=e=>{if(Array.isArray(e))for(let o of e){let t=document.getElementById(o);if(t)return t}else return document.getElementById(e);return null},Q=({children:e,container:o=document.body,id:t=go,onRender:n,open:r=!0,themeAttributes:i})=>{var f;let[s,m]=(0,j.useState)(!1),p=(0,j.useRef)(null),a=(f=fo(o))!=null?f:document.body,[u,l,c]=(0,mt.useThemeAttributes)(i);return(0,j.useLayoutEffect)(()=>{let C=vo(t);C?p.current=C:(p.current=document.createElement("div"),p.current.id=typeof t=="string"?t:t.length>0?t.at(-1):"vuu-portal-root");let v=p.current;a.contains(v)||a.appendChild(v),v.classList.add(u,l),v.dataset.mode=c,m(!0)},[t,a,u,l,c]),(0,j.useLayoutEffect)(()=>{requestAnimationFrame(()=>{n==null||n()})},[n]),r&&s&&p.current&&e?(0,ft.createPortal)(e,p.current):null};var ze=A(require("clsx")),F=A(require("react")),wt=require("@vuu-ui/vuu-utils");var Z=A(require("react"));var $e=e=>e.type===ue||!!e.props["data-group"],ho=e=>{if(Array.isArray(e)&&he(e[0]))return e[0]},bo=(e,o,t,n=!1)=>{let{props:{children:r}}=e;return{childWithId:Z.default.cloneElement(e,{hasSeparator:n,id:`${o}`,key:o,children:t?ho(r):r}),grandChildren:t?r:void 0}},gt=(e,o)=>{let t=(0,Z.useCallback)(()=>{let i=(s,m=o,p={},a={})=>{let u=p[m]=[],l=0,c=!1;return Z.default.Children.forEach(s,f=>{if(!he(f))if(f.type===Ke)c=!0;else{let C=$e(f),v=`${m}-${l}`,{props:{action:P,options:y}}=f,{childWithId:E,grandChildren:w}=bo(f,v,C,c);u.push(E),w?i(w,v,p,a):a[v]={action:P,options:y},l+=1,c=!1}}),[p,a]};return i(e)},[o,e]),[n,r]=(0,Z.useMemo)(()=>t(),[t]);return[n,r]};var D=require("react");var vt=e=>e.closest("[data-root='true']")!==null,ht=(e,o)=>{var t;return e.ariaHasPopup==="true"&&((t=e.dataset)==null?void 0:t.idx)===`${o}`||e.querySelector(`:scope > [data-index='${o}'][aria-haspopup='true']`)!==null};function xo(e,...o){let t=new Set(e);for(let n of o)for(let r of n)t.add(r);return t}var Mo="Enter";var yo="Delete",Po=new Set([Mo,yo]),wo=new Set(["Tab"]),Co=new Set(["ArrowRight","ArrowLeft"]),bt=new Set(["Home","End","ArrowDown","ArrowUp"]),xt=new Set(["Home","End","ArrowRight","ArrowLeft"]),Eo=new Set(["F1","F2","F3","F4","F5","F6","F7","F8","F9","F10","F11","F12"]),Jn=xo(Po,xt,bt,Co,Eo,wo);var Mt=({key:e},o="vertical")=>(o==="vertical"?bt:xt).has(e);var be=require("@vuu-ui/vuu-utils"),yt=({autoHighlightFirstItem:e=!1,count:o,defaultHighlightedIdx:t,highlightedIndex:n,onActivate:r,onHighlight:i,onCloseMenu:s,onOpenMenu:m})=>{var T;if((0,be.isValidNumber)(n)&&(0,be.isValidNumber)(t))throw Error("useKeyboardNavigation do not pass values for both highlightedIndex and defaultHighlightedIdx");let p=(0,be.isValidNumber)(n),a=(0,D.useRef)((T=t!=null?t:n)!=null?T:e?0:-1),[,u]=(0,D.useState)(null),l=(0,D.useCallback)(b=>{a.current=b,i==null||i(b),u({})},[i]),c=(0,D.useCallback)(b=>{b!==a.current&&(p||l(b))},[p,l]),f=(0,D.useRef)(!0),C=(0,D.useRef)(!1),v=b=>C.current=b,P=p?n:a.current,y=(0,D.useCallback)(b=>{let x=To(o,b.key,a.current);x!==a.current&&c(x)},[o,c]),E=(0,D.useCallback)(b=>{if(Mt(b))b.preventDefault(),b.stopPropagation(),f.current=!0,y(b);else if((b.key==="ArrowRight"||b.key==="Enter")&&ht(b.target,P)){let g=b.target.querySelector(`:scope > [data-index='${P}']`);g&&(m==null||m(g,!0))}else b.key==="ArrowLeft"&&!vt(b.target)?s(b,"close-child-menu"):b.key==="Enter"?(b.preventDefault(),b.stopPropagation(),r&&r(P)):b.key==="Tab"&&s(b,"tab-away")},[P,y,r,s,m]),w=(0,D.useMemo)(()=>({onFocus:()=>{P===-1&&l(0)},onKeyDown:E,onMouseDownCapture:()=>{f.current=!1,v(!0)},onMouseMove:()=>{f.current&&(f.current=!1)},onMouseLeave:()=>{f.current=!0,v(!1),c(-1)}}),[E,P,l,c]);return{focusVisible:f.current?P:-1,controlledHighlighting:p,highlightedIndex:P,setHighlightedIndex:c,listProps:w,setIgnoreFocus:v}};function To(e,o,t){return o==="ArrowUp"?t>0?t-1:t:t===null?0:t===e-1?t:t+1}var z=require("react/jsx-runtime"),Pt="vuuMenuList",Ke=()=>(0,z.jsx)("li",{className:"vuuMenuItem-divider"}),ue=()=>null,ae=({children:e,idx:o,options:t,...n})=>(0,z.jsx)("div",{...n,children:e}),Ct=({children:e})=>(0,z.jsx)(z.Fragment,{children:e});Ct.displayName="MenuItemLabel";ae.Label=Ct;var ko=e=>F.default.isValidElement(e)&&typeof e.type!="string"&&"displayName"in e.type?e.type.displayName:void 0,he=e=>ko(e)==="MenuItemLabel",Ro=e=>e.props["data-icon"],xe=({activatedByKeyboard:e,childMenuShowing:o,children:t,className:n,defaultHighlightedIdx:r,highlightedIdx:i,id:s,isRoot:m,listItemProps:p,onHighlightMenuItem:a,onActivate:u,onCloseMenu:l,openMenu:c,...f})=>{let C=(0,wt.useId)(s),v=(0,F.useRef)(null),P=(0,F.useMemo)(()=>new Map,[]),y=h=>{var M;let d=(M=v.current)==null?void 0:M.querySelector(`:scope > [data-index='${h}']`);d!=null&&d.id&&(u==null||u(d.id))},{focusVisible:E,highlightedIndex:w,listProps:T}=yt({count:F.default.Children.count(t),defaultHighlightedIdx:r,highlightedIndex:i,onActivate:y,onHighlight:a,onOpenMenu:c,onCloseMenu:l}),b=o==null?E:-1;(0,F.useLayoutEffect)(()=>{var h;o===void 0&&e&&((h=v.current)==null||h.focus())},[e,o]);let x=()=>w===void 0||w===-1?void 0:P.get(w);function g(){let h={...p,role:"menuitem"},d=(R,L,I)=>L?[(0,z.jsx)("span",{className:"vuuIconContainer","data-icon":I},"icon")].concat(R):R;function M(R,L,I,U){var Ze;let{children:q,className:Gt,"data-icon":je,id:de,hasSeparator:Vt,label:Le,...Ut}=L.props,He=$e(L),Qe=He&&o===de,Xt=Qe?`${C}-${de}`:void 0;R.push((0,z.jsx)(ae,{...Ut,...h,...Lo(de,I,(Ze=L.key)!=null?Ze:de,w,b,Gt,Vt),"aria-controls":Xt,"aria-haspopup":He||void 0,"aria-expanded":Qe||void 0,children:d(He&&Le!=null?Le:q,U,je)}))}let k=[];if(t.length>0){let R=t.some(Ro);t.forEach((L,I)=>{M(k,L,I,R)})}return k}return(0,z.jsx)("div",{...f,...T,"aria-activedescendant":x(),className:(0,ze.default)(Pt,n,{[`${Pt}-childMenuShowing`]:o!==void 0}),"data-root":m||void 0,id:C,ref:v,role:"menu",children:g()})},Lo=(e,o,t,n,r,i,s)=>({id:`menuitem-${e}`,key:t!=null?t:o,"data-index":o,"data-highlighted":o===n||void 0,className:(0,ze.default)("vuuMenuItem",i,{"vuuMenuItem-separator":s,focusVisible:r===o})});xe.displayName="MenuList";var H=require("react");var Fe=e=>e==null?void 0:e.closest("[data-index],[aria-posinset]");var Tt=(e,o,t)=>e.map((n,r)=>r===e.length-1?{...n,[t]:n[t]-o}:n),Ho=(e,o)=>Tt(e,o,"left"),Io=(e,o)=>Tt(e,o,"top"),Ao=(e,o)=>{let[t,n]=o.slice(-2),r=document.getElementById(`${e}-${n.id}`);if(r===null)throw Error(`useCascade.flipSides element with id ${n.id} not found`);let{width:i}=r.getBoundingClientRect();return o.map(s=>s===n?{...s,left:t.left-(i-2)}:s)},No=(e,o)=>{let[{left:t,top:n}]=o.slice(-1),{offsetWidth:r,offsetTop:i}=e;return{left:t+r,top:i+n}},kt=(e,o)=>{let t=e.lastIndexOf("-");return e.startsWith("menuitem")?t>-1?e.slice(9,t):o:t>-1?e.slice(0,t):o},Do=e=>e.slice(9),Et=({ariaExpanded:e,ariaHasPopup:o,id:t},n)=>{if(t.startsWith("menuitem"))return{hostMenuId:kt(t,n),targetMenuId:Do(t),menuItemId:t,isGroup:o==="true",isOpen:e==="true"};throw Error(`getMenuItemDetails #${t} is not a menuitem`)},Rt=({id:e,onActivate:o,onMouseEnterItem:t,position:{x:n,y:r}})=>{let[,i]=(0,H.useState)({}),s=(0,H.useRef)([{id:e,left:n,top:r}]),m=(0,H.useCallback)(x=>s.current.findIndex(g=>g.id===x)!==-1,[]),p=(0,H.useCallback)(x=>{let g=c.current[x];if(g===void 0)throw Error(`getOpenMenuState no entry for menu ${x}`);return g},[]),a=(0,H.useCallback)(x=>{s.current=x,i({})},[]),u=(0,H.useRef)(),l=(0,H.useRef)(),c=(0,H.useRef)({[e]:"no-popup"}),f=(0,H.useCallback)((x=e,g,h=null)=>{if(x===e&&h===null)a([{id:e,left:n,top:r}]);else{c.current[x]="popup-open";let d=document.getElementById(h);if(d!==null){let{left:M,top:k}=No(d,s.current);a(s.current.concat({id:g,left:M,top:k}))}else throw Error(`openMenu no menuItem ${h}`)}},[e,n,r,a]),C=(0,H.useCallback)(x=>{if(x===e)a([]);else{let g=s.current.slice(),h=g.pop();c.current[h.id]="no-popup";let d=g.at(-1);d&&(c.current[d.id]="no-popup"),a(g)}},[e,a]),v=(0,H.useCallback)(x=>{let g=s.current.slice(),h=x.slice(9),{id:d}=g.at(-1);for(;g.length>1&&!h.startsWith(d);){let M=kt(d,e);g.pop(),c.current[d]="no-popup",c.current[M]="no-popup",{id:d}=g[g.length-1]}g.length<s.current.length&&a(g)},[e,a]),P=(0,H.useCallback)(()=>{u.current&&(clearTimeout(u.current),u.current=void 0)},[]),y=(0,H.useCallback)((x,g,h,d=300)=>{P(),u.current=window.setTimeout(()=>{v(h),c.current[x]="popup-open",c.current[g]="no-popup",f(x,g,h)},d)},[P,v,f]),E=(0,H.useCallback)((x,g,h)=>{c.current[g]="pending-close",l.current=window.setTimeout(()=>{v(h)},400)},[v]),w=(0,H.useCallback)(()=>{let{current:x}=s,g=x.at(-1),h=g?document.getElementById(g.id):void 0;if(h){let{right:d,bottom:M}=h.getBoundingClientRect(),{clientHeight:k,clientWidth:R}=document.body;if(d>R){let L=x.length>1?Ao(e,x):Ho(x,d-R);a(L)}else if(M>k){let L=Io(x,M-k);a(L)}typeof h.tabIndex=="number"&&h.focus()}},[e,a]),T=(0,H.useCallback)((x,g=!1)=>{let{hostMenuId:h,targetMenuId:d,menuItemId:M,isGroup:k,isOpen:R}=Et(x,e),{current:{[h]:L}}=c,I=g?0:void 0;if(L==="no-popup"&&k)c.current[h]="popup-pending",y(h,d,M,I);else if(L==="popup-pending"&&!k)c.current[h]="no-popup",clearTimeout(u.current),u.current=void 0;else if(L==="popup-pending"&&k)clearTimeout(u.current),y(h,d,M,I);else if(L==="popup-open")if(m(d)){let U=p(d);switch(v(M),U){case"pending-close":clearTimeout(l.current),l.current=void 0,c.current[d]="no-popup",P();break;default:}}else{let[U,q]=s.current.slice(-2);U.id===h&&c.current[q.id]!=="pending-close"?(E(h,q.id,M),k&&!R&&y(h,d,M,I)):U.id===h&&k&&M!==q.id&&c.current[q.id]==="pending-close"||k?y(h,d,M,I):c.current[q.id]!=="pending-close"&&v(M)}L==="pending-close"&&(P(),clearTimeout(l.current),l.current=void 0,c.current[h]="popup-open")},[P,v,p,m,e,E,y]),b=(0,H.useMemo)(()=>({onMouseEnter:x=>{let g=Fe(x.target);T(g),t(x,g.id)},onClick:x=>{let g=Fe(x.target),{isGroup:h,menuItemId:d}=Et(g,e);h?T(g):o(d)}}),[o,t,e,T]);return{closeMenu:C,handleRender:w,listItemProps:b,openMenu:T,openMenus:s.current}};var le=require("react/jsx-runtime"),We=require("react"),So=()=>{},Me=({PortalProps:e,activatedByKeyboard:o,children:t,className:n,id:r,onClose:i=()=>{},position:s={x:0,y:0},style:m,...p})=>{let a=(0,Lt.useId)(r),u=(0,_.useRef)(So),[l,c]=gt(t,a),f=(0,_.useRef)(o),C=(0,_.useCallback)(()=>{f.current=!1},[]),v=(0,_.useCallback)(d=>{let M=d.slice(9),{action:k,options:R}=c[M];u.current(a),i({type:"menu-action",menuId:k,options:R})},[c,a,i]),{closeMenu:P,listItemProps:y,openMenu:E,openMenus:w,handleRender:T}=Rt({id:`${a}`,onActivate:v,onMouseEnterItem:C,position:s});u.current=P;let b=(0,_.useCallback)((d,M)=>{f.current=!0,P(),M==="tab-away"&&i({event:d,type:"tab-away"})},[P,i]),x=()=>{},g=w.length-1,h=d=>{if(!(d>=g)){let{id:M}=w[d+1];return M}};return(0,le.jsx)(le.Fragment,{children:w.map(({id:d,left:M,top:k},R,L)=>{let I=h(R);return(0,We.createElement)(Q,{...e,key:R,onRender:T},(0,le.jsx)(Be,{anchorElement:{current:document.body},placement:"absolute",position:{left:M,top:k},children:(0,We.createElement)(xe,{...p,activatedByKeyboard:f.current,childMenuShowing:I,className:n,id:d,isRoot:R===0,key:R,listItemProps:y,onActivate:v,onHighlightMenuItem:x,onCloseMenu:b,openMenu:E,style:m,tabIndex:R===L.length-1?0:void 0},l[d])}))})})};Me.displayName="ContextMenu";var oe=require("react"),ye=require("react/jsx-runtime"),pe=(0,oe.createContext)(null),Bo=({children:e,context:o,menuActionHandler:t,menuBuilder:n})=>{let r=(0,oe.useMemo)(()=>o!=null&&o.menuBuilders&&n?o.menuBuilders.concat(n):n?[n]:(o==null?void 0:o.menuBuilders)||[],[o,n]),i=(0,oe.useCallback)(s=>{var m;if(t!=null&&t(s)||(m=o==null?void 0:o.menuActionHandler)!=null&&m.call(o,s))return!0},[o,t]);return(0,ye.jsx)(pe.Provider,{value:{menuActionHandler:i,menuBuilders:r},children:e})},Oo=({children:e,label:o,menuActionHandler:t,menuBuilder:n})=>(0,ye.jsx)(pe.Consumer,{children:r=>(0,ye.jsx)(Bo,{context:r,label:o,menuActionHandler:t,menuBuilder:n,children:e})});var we=require("@vuu-ui/vuu-utils"),$=require("react");var Pe=require("react/jsx-runtime"),qe=(e,o)=>{let t=(0,$.useContext)(pe),[n,r,i]=(0,we.useThemeAttributes)(),s=(0,$.useMemo)(()=>({themeClass:n,densityClass:r,dataMode:i}),[i,r,n]),m=(0,$.useCallback)((u,l,c)=>{let f=[];for(let C of u)f=f.concat(C(l,c));return f},[]),p=(0,$.useCallback)((u,l,{ContextMenuProps:c,contextMenu:f,...C})=>{var P,y;if((P=u.stopPropagation)==null||P.call(u),(y=u.preventDefault)==null||y.call(u),f)return Ko({x:u.clientX,y:u.clientY},f);let v=[];if(e&&v.push(e),t&&Array.isArray(t==null?void 0:t.menuBuilders)&&t.menuBuilders.length>0&&v.push(...t.menuBuilders),v.length>0){let E=m(v,l,C),w=T=>(o==null?void 0:o(T))===!0?!0:t==null?void 0:t.menuActionHandler(T);E.length&&w&&zo(u,E,w,{PortalProps:{themeAttributes:s},...c})}else console.warn("useContextMenu, no menuBuilders configured. These should be supplied via the ContextMenuProvider(s)")},[m,t,o,e,s]),a=(0,$.useCallback)(()=>{console.log("hide context menu")},[]);return[p,a]},$o={},Ko=(e,o)=>{G.showPopup({focus:!0,left:0,top:0,component:(0,$.cloneElement)(o,{position:e})})},zo=(e,o,t,{position:n,...r}=$o)=>{let i=a=>{let u=(l,c)=>(0,we.isGroupMenuItemDescriptor)(l)?(0,Pe.jsx)(ue,{label:l.label,children:l.children.map(u)},c):(0,Pe.jsx)(ae,{action:l.action,className:l.className,"data-icon":l.icon,options:l.options,children:l.label},c);return a.map(u)},s=a=>{var u;if(De(a)){if((a==null?void 0:a.closedBy)==="popup-service")return;t(a),G.hidePopup(a)}(u=r==null?void 0:r.onClose)==null||u.call(r,a)},m=n!=null?n:{x:e.clientX,y:e.clientY},p=(0,Pe.jsx)(Me,{...r,onClose:s,position:m,children:i(o)});G.showPopup({left:0,top:0,component:p,focus:!0})};var Ht=require("@vuu-ui/vuu-utils"),It=require("@salt-ds/core"),At=A(require("clsx")),K=require("react");var Nt=require("react/jsx-runtime"),Ge="vuuPopupMenu",Fo=({anchorElement:e,className:o,label:t,icon:n=t?"chevron-down":"more-vert",id:r,menuActionHandler:i,menuBuilder:s,menuClassName:m,menuLocation:p="header",menuOptions:a,onMenuClose:u,onMenuOpen:l,popupPlacement:c="below-right",tabIndex:f=0,...C})=>{let v=(0,K.useRef)(null),P=(0,K.useRef)(!1),[y,E]=(0,K.useState)(!1),w=(0,Ht.useId)(r),[T]=qe(s,i),b=(0,K.useCallback)(d=>{E(d),d&&(l==null||l())},[l]),x=(0,K.useCallback)(d=>{console.log("menu Open ",{el:d})},[]),g=(0,K.useCallback)(d=>{console.log("onClose"),b(!1),Se(d)?(d.mouseEvt.target===v.current&&(P.current=!0),u==null||u(d)):requestAnimationFrame(()=>{var M;u==null||u(d),f!==-1&&(d==null?void 0:d.type)!=="tab-away"&&((M=v.current)==null||M.focus())})},[u,b,f]),h=(0,K.useCallback)(d=>{var M;if(P.current)P.current=!1;else{let k=(M=e==null?void 0:e.current)!=null?M:v.current;if(k){let{left:R,top:L,width:I}=se(k,c,0,0);b(!0),T(d,p,{ContextMenuProps:{className:m,id:`${w}-menu`,onClose:g,openMenu:x,position:{x:R,y:L},style:{width:I?I-2:void 0}},...a})}}},[e,g,x,w,m,p,a,c,b,T]);return(0,Nt.jsx)(It.Button,{...C,"aria-controls":y?`${w}-menu`:void 0,"aria-expanded":y,"aria-haspopup":"menu",className:(0,At.default)(Ge,o,{[`${Ge}-withCaption`]:t!==void 0,[`${Ge}-open`]:y}),"data-icon":n,id:w,onClick:h,ref:v,tabIndex:f,variant:"secondary",children:t})};var Dt=require("@vuu-ui/vuu-utils"),Ve=require("@salt-ds/core"),St=A(require("clsx")),ce=require("react");var W=require("react/jsx-runtime"),ne="vuuPrompt",Wo={current:document.body},qo={},Go=({PopupProps:e=qo,cancelButtonLabel:o="Cancel",confirmButtonLabel:t="Confirm",icon:n,onCancel:r,onConfirm:i,style:s,text:m,title:p,variant:a="info",...u})=>{let{anchorElement:l=Wo,offsetLeft:c=0,offsetTop:f=0,placement:C="below"}=e,[v,P,y]=(0,Dt.useThemeAttributes)(),{position:E}=J({anchorElement:l,offsetLeft:c,offsetTop:f,placement:C}),w=(0,ce.useRef)(null),T=(0,ce.useRef)(null);return(0,ce.useLayoutEffect)(()=>{if(w.current&&(w.current.showModal(),T.current&&T.current.focus(),C.endsWith("center"))){let{width:b}=w.current.getBoundingClientRect();w.current.style.marginLeft=`-${b/2}px`}},[C]),(0,W.jsx)("dialog",{...u,className:(0,St.default)(ne,`${ne}-${a}`,v),"data-mode":y,ref:w,style:{...s,...E},children:(0,W.jsxs)("form",{className:`${ne}-form`,children:[(0,W.jsx)("div",{className:`${ne}-header`,"data-icon":n,children:p}),(0,W.jsx)("div",{className:`${ne}-text`,children:m}),(0,W.jsxs)("div",{className:`${ne}-buttonBar`,children:[(0,W.jsx)(Ve.Button,{onClick:r,variant:"secondary",children:o}),(0,W.jsx)(Ve.Button,{onClick:i,ref:T,value:"default",children:t})]})]})})};var Ce=require("react"),Vo=(e,o,t,n)=>{let{bottom:r,height:i,left:s,right:m,top:p,width:a}=e.getBoundingClientRect(),u=s+a/2,l=p+i/2;switch(o){case"above":return{left:u+t,top:p+n};case"below":return{left:u+t,top:r+n};case"right":return{left:m+t,top:l+t};case"left":return{left:s+t,top:l+t};default:throw Error("Tooltip getPositionRelativeToAnchor only supported placement values are left, right, below and right")}},Bt=({anchorElement:e,offsetLeft:o=0,offsetTop:t=0,placement:n})=>{let[r,i]=(0,Ce.useState)();return(0,Ce.useLayoutEffect)(()=>{if(e.current){let s=Vo(e.current,n,o,t);i(s)}},[e,o,t,n]),r};var Ot=A(require("clsx"));var Ee=require("react/jsx-runtime"),Ue="vuuTooltip",Uo=({anchorElement:e,children:o,id:t,onMouseEnter:n,onMouseLeave:r,placement:i,status:s,style:m})=>{let p=Bt({anchorElement:e,placement:i});return p===void 0?null:(0,Ee.jsx)(Q,{children:(0,Ee.jsx)("div",{className:(0,Ot.default)(Ue,{[`${Ue}-error`]:s==="error"}),"data-align":i,id:t,style:{...m,...p},children:(0,Ee.jsx)("span",{className:`${Ue}-content`,onMouseEnter:n,onMouseLeave:r,children:o})})})};var $t=require("@vuu-ui/vuu-utils"),N=require("react"),Xo=({id:e,placement:o="right",tooltipContent:t})=>{let n=(0,N.useRef)(),r=(0,N.useRef)(null),i=(0,N.useRef)(),s=(0,N.useRef)(),[m,p]=(0,N.useState)(),a=(0,$t.useId)(e),u=(0,N.useCallback)(y=>{var E;y.key==="Escape"&&((E=n.current)==null||E.call(n))},[]);n.current=(0,N.useCallback)(()=>{p(void 0),document.removeEventListener("keydown",u)},[u]);let l=(0,N.useCallback)(()=>{window.clearTimeout(s.current)},[]),c=(0,N.useCallback)(()=>{var y;(y=n.current)==null||y.call(n)},[]),f=(0,N.useCallback)(()=>{let{current:y}=r;y&&(p({anchorElement:r,children:t,id:`${a}-tooltip`,onMouseEnter:l,onMouseLeave:c,placement:o}),document.addEventListener("keydown",u)),i.current=void 0},[u,l,c,a,o,t]),C=(0,N.useCallback)(y=>{let E=y.target;E&&(r.current=E,i.current=window.setTimeout(f,800))},[f]),v=(0,N.useCallback)(()=>{r.current&&(i.current?(window.clearTimeout(i.current),i.current=void 0):n.current&&(s.current=window.setTimeout(n.current,200)))},[]);return{anchorProps:{"aria-describedby":`${a}-tooltip`,onMouseEnter:C,onMouseLeave:v},tooltipProps:m}};var O=A(require("react")),Xe=A(require("clsx")),Kt=require("@vuu-ui/vuu-utils");var B=require("react/jsx-runtime"),Jo=60,zt=6e3,Je=1e3,Yo=300,Ft=56,ke=300,jo=10,Qo=10,Re=50,Te="vuuToastNotifications",Wt=(r=>(r.Info="info",r.Success="success",r.Warning="warning",r.Error="error",r))(Wt||{}),Ye=O.default.createContext({notify:()=>"have you forgotten to provide a NotificationProvider?"}),Zo=e=>{let[o,t]=(0,O.useState)([]),n=(0,O.useCallback)(r=>{let i={...r,id:(0,Kt.getUniqueId)()};t(s=>[...s,i]),setTimeout(()=>{t(s=>s.filter(m=>m!==i))},zt+Je*2)},[]);return(0,B.jsxs)(Ye.Provider,{value:{notify:n},children:[(0,B.jsx)("div",{style:{width:ke+Re+Qo},children:o.map((r,i)=>(0,B.jsx)(qt,{top:Jo+(Ft+jo)*i,notification:r},r.id))}),e.children]})},_o=()=>(0,O.useContext)(Ye),qt=e=>{let{top:o,notification:t,animated:n=!0}=e,[r,i]=(0,O.useState)(-ke-Re);return(0,O.useEffect)(()=>{setTimeout(()=>i(Re)),n&&setTimeout(()=>i(-ke-Re),zt+Je)},[n]),(0,B.jsx)(Q,{children:(0,B.jsxs)("div",{className:(0,Xe.default)(`${Te}-toast`,t.type),style:{height:Ft,right:r,width:ke,top:o,transition:n?`right ${Je}ms, top ${Yo}ms `:"none"},children:[(0,B.jsx)("div",{className:(0,Xe.default)(`${Te}-toastIcon`,`${t.type}-icon`)}),(0,B.jsxs)("div",{className:`${Te}-toastContent`,children:[(0,B.jsx)("strong",{className:`${Te}-toastHeader`,children:t.header}),(0,B.jsx)("div",{children:t.body})]})]})})};
2
2
  //# sourceMappingURL=index.js.map