PageSourceSearch

https://eosone.com/assets/toaster-u8sc5w8A.js

js eosone.com collected 2026-10-05 22:13:48 UTC 14,204 bytes, 1 lines download raw bytes

1import{r as s,j as n}from"./framer-motion-36TZcv1S.js";import{u as Ae}from"./use-toast-DDS6lMJl.js";import{h as re,r as je,e as F,X as _e,k as Fe}from"./index-D1j7DId9.js";import{P as A,c as De,u as Le,b as Me,a as P,d as Oe,f as ke}from"./index-C-jiFLDd.js";import{c as Ve}from"./index-CNUc3B7K.js";import{B as Ke,u as W,R as He,P as $e}from"./index-DweCaJlN.js";var We=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),Ue="VisuallyHidden",J=s.forwardRef((e,t)=>n.jsx(A.span,{...e,ref:t,style:{...We,...e.style}}));J.displayName=Ue;var Q="ToastProvider",[Z,Xe,Ye]=Ve("Toast"),[se,xt]=De("Toast",[Ye]),[Be,U]=se(Q),ne=e=>{const{__scopeToast:t,label:o="Notification",duration:r=5e3,swipeDirection:d="right",swipeThreshold:u=50,children:p}=e,[v,w]=s.useState(null),[a,b]=s.useState(0),E=s.useRef(!1),D=s.useRef(!1);return o.trim()||console.error(`Invalid prop \`label\` supplied to \`${Q}\`. Expected non-empty \`string\`.`),n.jsx(Z.Provider,{scope:t,children:n.jsx(Be,{scope:t,label:o,duration:r,swipeDirection:d,swipeThreshold:u,toastCount:a,viewport:v,onViewportChange:w,onToastAdd:s.useCallback(()=>b(R=>R+1),[]),onToastRemove:s.useCallback(()=>b(R=>R-1),[]),isFocusedToastEscapeKeyDownRef:E,isClosePausedRef:D,children:p})})};ne.displayName=Q;var ae="ToastViewport",ze=["F8"],z="toast.viewportPause",q="toast.viewportResume",ie=s.forwardRef((e,t)=>{const{__scopeToast:o,hotkey:r=ze,label:d="Notifications ({hotkey})",...u}=e,p=U(ae,o),v=Xe(o),w=s.useRef(null),a=s.useRef(null),b=s.useRef(null),E=s.useRef(null),D=re(t,E,p.onViewportChange),R=r.join("+").replace(/Key/g,"").replace(/Digit/g,""),N=p.toastCount>0;s.useEffect(()=>{const c=y=>{var m;r.length!==0&&r.every(T=>y[T]||y.code===T)&&((m=E.current)==null||m.focus())};return document.addEventListener("keydown",c),()=>document.removeEventListener("keydown",c)},[r]),s.useEffect(()=>{const c=w.current,y=E.current;if(N&&c&&y){const f=()=>{if(!p.isClosePausedRef.current){const h=new CustomEvent(z);y.dispatchEvent(h),p.isClosePausedRef.current=!0}},m=()=>{if(p.isClosePausedRef.current){const h=new CustomEvent(q);y.dispatchEvent(h),p.isClosePausedRef.current=!1}},T=h=>{!c.contains(h.relatedTarget)&&m()},x=()=>{c.contains(document.activeElement)||m()};return c.addEventListener("focusin",f),c.addEventListener("focusout",T),c.addEventListener("pointermove",f),c.addEventListener("pointerleave",x),window.addEventListener("blur",f),window.addEventListener("focus",m),()=>{c.removeEventListener("focusin",f),c.removeEventListener("focusout",T),c.removeEventListener("pointermove",f),c.removeEventListener("pointerleave",x),window.removeEventListener("blur",f),window.removeEventListener("focus",m)}}},[N,p.isClosePausedRef]);const l=s.useCallback(({tabbingDirection:c})=>{const f=v().map(m=>{const T=m.ref.current,x=[T,...it(T)];return c==="forwards"?x:x.reverse()});return(c==="forwards"?f.reverse():f).flat()},[v]);return s.useEffect(()=>{const c=E.current;if(c){const y=f=>{var x,h,S;const m=f.altKey||f.ctrlKey||f.metaKey;if(f.key==="Tab"&&!m){const L=document.activeElement,j=f.shiftKey;if(f.target===c&&j){(x=a.current)==null||x.focus();return}const I=l({tabbingDirection:j?"backwards":"forwards"}),V=I.findIndex(i=>i===L);B(I.slice(V+1))?f.preventDefault():j?(h=a.current)==null||h.focus():(S=b.current)==null||S.focus()}};return c.addEventListener("keydown",y),()=>c.removeEventListener("keydown",y)}},[v,l]),n.jsxs(Ke,{ref:w,role:"region","aria-label":d.replace("{hotkey}",R),tabIndex:-1,style:{pointerEvents:N?void 0:"none"},children:[N&&n.jsx(G,{ref:a,onFocusFromOutsideViewport:()=>{const c=l({tabbingDirection:"forwards"});B(c)}}),n.jsx(Z.Slot,{scope:o,children:n.jsx(A.ol,{tabIndex:-1,...u,ref:D})}),N&&n.jsx(G,{ref:b,onFocusFromOutsideViewport:()=>{const c=l({tabbingDirection:"backwards"});B(c)}})]})});ie.displayName=ae;var ce="ToastFocusProxy",G=s.forwardRef((e,t)=>{const{__scopeToast:o,onFocusFromOutsideViewport:r,...d}=e,u=U(ce,o);return n.jsx(J,{"aria-hidden":!0,tabIndex:0,...d,ref:t,style:{position:"fixed"},onFocus:p=>{var a;const v=p.relatedTarget;!((a=u.viewport)!=null&&a.contains(v))&&r()}})});G.displayName=ce;var k="Toast",qe="toast.swipeStart",Ge="toast.swipeMove",Je="toast.swipeCancel",Qe="toast.swipeEnd",de=s.forwardRef((e,t)=>
1{const{forceMount:o,open:r,defaultOpen:d,onOpenChange:u,...p}=e,[v,w]=Le({prop:r,defaultProp:d??!0,onChange:u,caller:k});return n.jsx(Me,{present:o||v,children:n.jsx(tt,{open:v,...p,ref:t,onClose:()=>w(!1),onPause:W(e.onPause),onResume:W(e.onResume),onSwipeStart:P(e.onSwipeStart,a=>{a.currentTarget.setAttribute("data-swipe","start")}),onSwipeMove:P(e.onSwipeMove,a=>{const{x:b,y:E}=a.detail.delta;a.currentTarget.setAttribute("data-swipe","move"),a.currentTarget.style.setProperty("--radix-toast-swipe-move-x",`${b}px`),a.currentTarget.style.setProperty("--radix-toast-swipe-move-y",`${E}px`)}),onSwipeCancel:P(e.onSwipeCancel,a=>{a.currentTarget.setAttribute("data-swipe","cancel"),a.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),a.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),a.currentTarget.style.removeProperty("--radix-toast-swipe-end-x"),a.currentTarget.style.removeProperty("--radix-toast-swipe-end-y")}),onSwipeEnd:P(e.onSwipeEnd,a=>{const{x:b,y:E}=a.detail.delta;a.currentTarget.setAttribute("data-swipe","end"),a.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),a.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),a.currentTarget.style.setProperty("--radix-toast-swipe-end-x",`${b}px`),a.currentTarget.style.setProperty("--radix-toast-swipe-end-y",`${E}px`),w(!1)})})})});de.displayName=k;var[Ze,et]=se(k,{onClose(){}}),tt=s.forwardRef((e,t)=>{const{__scopeToast:o,type:r="foreground",duration:d,open:u,onClose:p,onEscapeKeyDown:v,onPause:w,onResume:a,onSwipeStart:b,onSwipeMove:E,onSwipeCancel:D,onSwipeEnd:R,...N}=e,l=U(k,o),[c,y]=s.useState(null),f=re(t,i=>y(i)),m=s.useRef(null),T=s.useRef(null),x=d||l.duration,h=s.useRef(0),S=s.useRef(x),L=s.useRef(0),{onToastAdd:j,onToastRemove:X}=l,_=W(()=>{var g;(c==null?void 0:c.contains(document.activeElement))&&((g=l.viewport)==null||g.focus()),p()}),I=s.useCallback(i=>{!i||i===1/0||(window.clearTimeout(L.current),h.current=new Date().getTime(),L.current=window.setTimeout(_,i))},[_]);s.useEffect(()=>{const i=l.viewport;if(i){const g=()=>{I(S.current),a==null||a()},C=()=>{const M=new Date().getTime()-h.current;S.current=S.current-M,window.clearTimeout(L.current),w==null||w()};return i.addEventListener(z,C),i.addEventListener(q,g),()=>{i.removeEventListener(z,C),i.removeEventListener(q,g)}}},[l.viewport,x,w,a,I]),s.useEffect(()=>{u&&!l.isClosePausedRef.current&&I(x)},[u,x,l.isClosePausedRef,I]),s.useEffect(()=>(j(),()=>X()),[j,X]);const V=s.useMemo(()=>c?we(c):null,[c]);return l.viewport?n.jsxs(n.Fragment,{children:[V&&n.jsx(ot,{__scopeToast:o,role:"status","aria-live":r==="foreground"?"assertive":"polite","aria-atomic":!0,children:V}),n.jsx(Ze,{scope:o,onClose:_,children:je.createPortal(n.jsx(Z.ItemSlot,{scope:o,children:n.jsx(He,{asChild:!0,onEscapeKeyDown:P(v,()=>{l.isFocusedToastEscapeKeyDownRef.current||_(),l.isFocusedToastEscapeKeyDownRef.current=!1}),children:n.jsx(A.li,{role:"status","aria-live":"off","aria-atomic":!0,tabIndex:0,"data-state":u?"open":"closed","data-swipe-direction":l.swipeDirection,...N,ref:f,style:{userSelect:"none",touchAction:"none",...e.style},onKeyDown:P(e.onKeyDown,i=>{i.key==="Escape"&&(v==null||v(i.nativeEvent),i.nativeEvent.defaultPrevented||(l.isFocusedToastEscapeKeyDownRef.current=!0,_()))}),onPointerDown:P(e.onPointerDown,i=>{i.button===0&&(m.current={x:i.clientX,y:i.clientY})}),onPointerMove:P(e.onPointerMove,i=>{if(!m.current)return;const g=i.clientX-m.current.x,C=i.clientY-m.current.y,M=!!T.current,O=["left","right"].includes(l.swipeDirection),K=["left","up"].includes(l.swipeDirection)?Math.min:Math.max,Se=O?K(0,g):0,Ie=O?0:K(0,C),Y=i.pointerType==="touch"?10:2,H={x:Se,y:Ie},te={originalEvent:i,delta:H};M?(T.current=H,$(Ge,E,te,{discrete:!1})):oe(H,l.swipeDirection,Y)?(T.current=H,$(qe,b,te,{discrete:!1}),i.target.setPointerCapture(i.pointerId)):(Math.abs(g)>Y||Math.abs(C)>Y)&&(m.current=null)}),onPointerUp:P(e.onPointerUp,i=>{const g=T.current,C=i.target;if(C.hasPointerCapture(i.pointerId)&&C.releasePointerCapture(i.pointerId),T.current=null,m.current=null,g){const M=i.currentTarget,O={originalEvent:i,delta:g};oe(g,l.swipeDirection,l.swipeThreshold)?$(Qe,R,O,{discrete:!0}):$(Je,D,O,{discrete:!0}),M.addEventListener("click",K=>K.preventDefault(),{once:!0})}})})})}),l.viewport)})]}):null}),ot=e=>{const{__scopeToast:t,children:o,...r}=e,d=U(k,t),[u,p]=s.useState(!1),[v,w]=s.useState(!1);return nt(()=>p(!0)),s.useEffect(()=>{const a=window.setTimeout(()=>w(!0),1e3);return()=>window.clearTimeout(a)},[]),v?null:n.jsx($e,{asChild:!0,children:n.jsx(J,{...r,children:u&&n.jsxs(n.Fragment,{children:[d.label," ",o]})})})},rt="ToastTitle",ue=s.forwardRef((e,t)=>
1{const{__scopeToast:o,...r}=e;return n.jsx(A.div,{...r,ref:t})});ue.displayName=rt;var st="ToastDescription",le=s.forwardRef((e,t)=>{const{__scopeToast:o,...r}=e;return n.jsx(A.div,{...r,ref:t})});le.displayName=st;var pe="ToastAction",fe=s.forwardRef((e,t)=>{const{altText:o,...r}=e;return o.trim()?n.jsx(ve,{altText:o,asChild:!0,children:n.jsx(ee,{...r,ref:t})}):(console.error(`Invalid prop \`altText\` supplied to \`${pe}\`. Expected non-empty \`string\`.`),null)});fe.displayName=pe;var me="ToastClose",ee=s.forwardRef((e,t)=>{const{__scopeToast:o,...r}=e,d=et(me,o);return n.jsx(ve,{asChild:!0,children:n.jsx(A.button,{type:"button",...r,ref:t,onClick:P(e.onClick,d.onClose)})})});ee.displayName=me;var ve=s.forwardRef((e,t)=>{const{__scopeToast:o,altText:r,...d}=e;return n.jsx(A.div,{"data-radix-toast-announce-exclude":"","data-radix-toast-announce-alt":r||void 0,...d,ref:t})});function we(e){const t=[];return Array.from(e.childNodes).forEach(r=>{if(r.nodeType===r.TEXT_NODE&&r.textContent&&t.push(r.textContent),at(r)){const d=r.ariaHidden||r.hidden||r.style.display==="none",u=r.dataset.radixToastAnnounceExclude==="";if(!d)if(u){const p=r.dataset.radixToastAnnounceAlt;p&&t.push(p)}else t.push(...we(r))}}),t}function $(e,t,o,{discrete:r}){const d=o.originalEvent.currentTarget,u=new CustomEvent(e,{bubbles:!0,cancelable:!0,detail:o});t&&d.addEventListener(e,t,{once:!0}),r?ke(d,u):d.dispatchEvent(u)}var oe=(e,t,o=0)=>{const r=Math.abs(e.x),d=Math.abs(e.y),u=r>d;return t==="left"||t==="right"?u&&r>o:!u&&d>o};function nt(e=()=>{}){const t=W(e);Oe(()=>{let o=0,r=0;return o=window.requestAnimationFrame(()=>r=window.requestAnimationFrame(t)),()=>{window.cancelAnimationFrame(o),window.cancelAnimationFrame(r)}},[t])}function at(e){return e.nodeType===e.ELEMENT_NODE}function it(e){const t=[],o=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const d=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||d?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;o.nextNode();)t.push(o.currentNode);return t}function B(e){const t=document.activeElement;return e.some(o=>o===t?!0:(o.focus(),document.activeElement!==t))}var ct=ne,Te=ie,xe=de,Ee=ue,ye=le,he=fe,ge=ee;const dt=ct,be=s.forwardRef(({className:e,...t},o)=>n.jsx(Te,{ref:o,className:F("fixed top-0 z-[100] flex max-h-screen w-full flex-col-reverse p-4 sm:bottom-0 sm:right-0 sm:top-auto sm:flex-col md:max-w-[420px]",e),...t}));be.displayName=Te.displayName;const ut=Fe("group pointer-events-auto relative flex w-full items-center justify-between space-x-4 overflow-hidden rounded-md border p-6 pr-8 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full data-[state=open]:sm:slide-in-from-bottom-full",{variants:{variant:{default:"border bg-background text-foreground",destructive:"destructive group border-destructive bg-destructive text-destructive-foreground"}},defaultVariants:{variant:"default"}}),Pe=s.forwardRef(({className:e,variant:t,...o},r)=>n.jsx(xe,{ref:r,className:F(ut({variant:t}),e),...o}));Pe.displayName=xe.displayName;const lt=s.forwardRef(({className:e,...t},o)=>n.jsx(he,{ref:o,className:F("inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium ring-offset-background transition-colors group-[.destructive]:border-muted/40 hover:bg-secondary group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 group-[.destructive]:focus:ring-destructive disabled:pointer-events-none disabled:opacity-50",e),...t}));lt.displayName=he.displayName;const Ce=s.forwardRef(({className:e,...t},o)=>n.jsx(ge,{ref:o,className:F("absolute right-2 top-2 rounded-md p-1 text-foreground
1/50 opacity-0 transition-opacity group-hover:opacity-100 group-[.destructive]:text-red-300 hover:text-foreground group-[.destructive]:hover:text-red-50 focus:opacity-100 focus:outline-none focus:ring-2 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600",e),"toast-close":"",...t,children:n.jsx(_e,{className:"h-4 w-4"})}));Ce.displayName=ge.displayName;const Re=s.forwardRef(({className:e,...t},o)=>n.jsx(Ee,{ref:o,className:F("text-sm font-semibold",e),...t}));Re.displayName=Ee.displayName;const Ne=s.forwardRef(({className:e,...t},o)=>n.jsx(ye,{ref:o,className:F("text-sm opacity-90",e),...t}));Ne.displayName=ye.displayName;function Et(){const{toasts:e}=Ae();return n.jsxs(dt,{children:[e.map(function({id:t,title:o,description:r,action:d,...u}){return n.jsxs(Pe,{...u,children:[n.jsxs("div",{className:"grid gap-1",children:[o&&n.jsx(Re,{children:o}),r&&n.jsx(Ne,{children:r})]}),d,n.jsx(Ce,{})]},t)}),n.jsx(be,{})]})}export{Et as Toaster};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.