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