Comparing version 0.7.3 to 0.7.4
@@ -18,2 +18,3 @@ import React from 'react'; | ||
invert?: boolean; | ||
dismissible?: boolean; | ||
description?: React.ReactNode; | ||
@@ -20,0 +21,0 @@ duration?: number; |
"use client" | ||
"use client";import e from"react";import xt from"react-dom";function et(i,{insertAt:a}={}){if(!i||typeof document=="undefined")return;let t=document.head||document.getElementsByTagName("head")[0],s=document.createElement("style");s.type="text/css",a==="top"&&t.firstChild?t.insertBefore(s,t.firstChild):t.appendChild(s),s.styleSheet?s.styleSheet.cssText=i:s.appendChild(document.createTextNode(i))}et(`html[dir=ltr],[data-sonner-toaster][dir=ltr]{--toast-icon-margin-start: -3px;--toast-icon-margin-end: 4px;--toast-svg-margin-start: -1px;--toast-svg-margin-end: 0px;--toast-button-margin-start: auto;--toast-button-margin-end: 0;--toast-close-button-start: 0;--toast-close-button-end: unset;--toast-close-button-transform: translate(-35%, -35%)}html[dir=rtl],[data-sonner-toaster][dir=rtl]{--toast-icon-margin-start: 4px;--toast-icon-margin-end: -3px;--toast-svg-margin-start: 0px;--toast-svg-margin-end: -1px;--toast-button-margin-start: 0;--toast-button-margin-end: auto;--toast-close-button-start: unset;--toast-close-button-end: 0;--toast-close-button-transform: translate(35%, -35%)}[data-sonner-toaster]{position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1: hsl(0, 0%, 99%);--gray2: hsl(0, 0%, 97.3%);--gray3: hsl(0, 0%, 95.1%);--gray4: hsl(0, 0%, 93%);--gray5: hsl(0, 0%, 90.9%);--gray6: hsl(0, 0%, 88.7%);--gray7: hsl(0, 0%, 85.8%);--gray8: hsl(0, 0%, 78%);--gray9: hsl(0, 0%, 56.1%);--gray10: hsl(0, 0%, 52.3%);--gray11: hsl(0, 0%, 43.5%);--gray12: hsl(0, 0%, 9%);--border-radius: 8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:none;z-index:999999999}[data-sonner-toaster][data-x-position=right]{right:max(var(--offset),env(safe-area-inset-right))}[data-sonner-toaster][data-x-position=left]{left:max(var(--offset),env(safe-area-inset-left))}[data-sonner-toaster][data-x-position=center]{left:50%;transform:translate(-50%)}[data-sonner-toaster][data-y-position=top]{top:max(var(--offset),env(safe-area-inset-top))}[data-sonner-toaster][data-y-position=bottom]{bottom:max(var(--offset),env(safe-area-inset-bottom))}[data-sonner-toast]{--y: translateY(100%);--lift-amount: calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);touch-action:none;will-change:transform,opacity,height;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:none}[data-sonner-toast][data-styled=true]{padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px #0000001a;width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}[data-sonner-toast]:focus-visible{box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}[data-sonner-toast][data-y-position=top]{top:0;--y: translateY(-100%);--lift: 1;--lift-amount: calc(1 * var(--gap))}[data-sonner-toast][data-y-position=bottom]{bottom:0;--y: translateY(100%);--lift: -1;--lift-amount: calc(var(--lift) * var(--gap))}[data-sonner-toast] [data-description]{font-weight:400;line-height:1.4;color:inherit}[data-sonner-toast] [data-title]{font-weight:500;line-height:1.5;color:inherit}[data-sonner-toast] [data-icon]{display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}[data-sonner-toast][data-promise=true] [data-icon]>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}[data-sonner-toast] [data-icon]>*{flex-shrink:0}[data-sonner-toast] [data-icon] svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}[data-sonner-toast] [data-content]{display:flex;flex-direction:column;gap:2px}[data-sonner-toast] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;cursor:pointer;outline:none;transition:opacity .4s,box-shadow .2s}[data-sonner-toast] [data-button]:focus-visible{box-shadow:0 0 0 2px #0006}[data-sonner-toast] [data-button]:first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}[data-sonner-toast] [data-cancel]{color:var(--color);background:var(--border-color)}[data-sonner-toast] [data-close-button]{position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;background:var(--gray1);color:var(--gray12);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;opacity:0;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast] [data-close-button]:focus-visible{box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}[data-sonner-toast] [data-disabled=true]{cursor:not-allowed}[data-sonner-toast]:hover [data-close-button]{opacity:1}[data-sonner-toast]:focus [data-close-button]{opacity:1}[data-sonner-toast]:focus-within [data-close-button]{opacity:1}[data-sonner-toast]:hover [data-close-button]:hover{background:var(--gray2);border-color:var(--gray5)}[data-sonner-toast][data-swiping=true]:before{content:"";position:absolute;left:0;right:0;height:100%}[data-sonner-toast][data-y-position=top][data-swiping=true]:before{bottom:50%;transform:scaleY(3) translateY(50%)}[data-sonner-toast][data-y-position=bottom][data-swiping=true]:before{top:50%;transform:scaleY(3) translateY(-50%)}[data-sonner-toast][data-swiping=false][data-removed=true]:before{content:"";position:absolute;inset:0;transform:scaleY(2)}[data-sonner-toast]:after{content:"";position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}[data-sonner-toast][data-mounted=true]{--y: translateY(0);opacity:1}[data-sonner-toast][data-expanded=false][data-front=false]{--scale: var(--toasts-before) * .05 + 1;--y: translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}[data-sonner-toast]>*{transition:opacity .4s}[data-sonner-toast][data-expanded=false][data-front=false][data-styled=true]>*{opacity:0}[data-sonner-toast][data-visible=false]{opacity:0;pointer-events:none}[data-sonner-toast][data-mounted=true][data-expanded=true]{--y: translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}[data-sonner-toast][data-removed=true][data-front=true][data-swipe-out=false]{--y: translateY(calc(var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=true]{--y: translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=false]{--y: translateY(40%);opacity:0;transition:transform .5s,opacity .2s}[data-sonner-toast][data-removed=true][data-front=false]:before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount, 0px));transition:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation:swipe-out .2s ease-out forwards}@keyframes swipe-out{0%{transform:translateY(calc(var(--lift) * var(--offset) + var(--swipe-amount)));opacity:1}to{transform:translateY(calc(var(--lift) * var(--offset) + var(--swipe-amount) + var(--lift) * -100%));opacity:0}}@media (max-width: 600px){[data-sonner-toaster]{position:fixed;--mobile-offset: 16px;right:var(--mobile-offset);left:var(--mobile-offset);width:100%}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - 32px)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset)}[data-sonner-toaster][data-y-position=bottom]{bottom:20px}[data-sonner-toaster][data-y-position=top]{top:20px}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset);right:var(--mobile-offset);transform:none}}[data-sonner-toaster][data-theme=light]{--normal-bg: #fff;--normal-border: var(--gray4);--normal-text: var(--gray12);--success-bg: hsl(143, 85%, 96%);--success-border: hsl(145, 92%, 91%);--success-text: hsl(140, 100%, 27%);--error-bg: hsl(359, 100%, 97%);--error-border: hsl(359, 100%, 94%);--error-text: hsl(360, 100%, 45%)}[data-sonner-toaster][data-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg: #000;--normal-border: hsl(0, 0%, 20%);--normal-text: var(--gray1)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg: #fff;--normal-border: var(--gray3);--normal-text: var(--gray12)}[data-sonner-toaster][data-theme=dark]{--normal-bg: #000;--normal-border: hsl(0, 0%, 20%);--normal-text: var(--gray1);--success-bg: hsl(150, 100%, 6%);--success-border: hsl(147, 100%, 12%);--success-text: hsl(150, 86%, 65%);--error-bg: hsl(358, 76%, 10%);--error-border: hsl(357, 89%, 16%);--error-text: hsl(358, 100%, 81%)}[data-rich-colors=true] [data-sonner-toast][data-type=success],[data-rich-colors=true] [data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true] [data-sonner-toast][data-type=error],[data-rich-colors=true] [data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size: 16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:nth-child(1){animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}to{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}to{opacity:.15}}@media (prefers-reduced-motion){[data-sonner-toast],[data-sonner-toast]>*,.sonner-loading-bar{transition:none!important;animation:none!important}} | ||
`);import P from"react";var lt=i=>{switch(i){case"success":return gt;case"error":return ht;default:return null}},ft=Array(12).fill(0),dt=({visible:i})=>P.createElement("div",{className:"sonner-loading-wrapper","data-visible":i},P.createElement("div",{className:"sonner-spinner"},ft.map((a,t)=>P.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${t}`})))),gt=P.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},P.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"}));var ht=P.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},P.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"}));var at=0,ot=class{constructor(){this.subscribe=a=>(this.subscribers.push(a),()=>{let t=this.subscribers.indexOf(a);this.subscribers.splice(t,1)});this.publish=a=>{this.subscribers.forEach(t=>t(a))};this.addToast=a=>{this.publish(a),this.toasts=[...this.toasts,a]};this.create=a=>{var p;let{message:t,...s}=a,l=typeof(a==null?void 0:a.id)=="number"||((p=a.id)==null?void 0:p.length)>0?a.id:at++;return this.toasts.find(d=>d.id===l)?this.toasts=this.toasts.map(d=>d.id===l?(this.publish({...d,...a,id:l,title:t}),{...d,...a,id:l,title:t}):d):this.addToast({title:t,...s,id:l}),l};this.dismiss=a=>(a||this.toasts.forEach(t=>{this.subscribers.forEach(s=>s({id:t.id,dismiss:!0}))}),this.subscribers.forEach(t=>t({id:a,dismiss:!0})),a);this.message=(a,t)=>this.create({...t,message:a});this.error=(a,t)=>this.create({...t,message:a,type:"error"});this.success=(a,t)=>this.create({...t,type:"success",message:a});this.loading=(a,t)=>this.create({...t,type:"loading",message:a});this.promise=(a,t)=>{let s=this.create({...t,promise:a,type:"loading",message:t.loading});return(a instanceof Promise?a:a()).then(T=>{let p=typeof t.success=="function"?t.success(T):t.success;this.create({id:s,type:"success",message:p})}).catch(T=>{let p=typeof t.error=="function"?t.error(T):t.error;this.create({id:s,type:"error",message:p})}).finally(t.finally),s};this.custom=(a,t)=>{let s=(t==null?void 0:t.id)||at++;this.publish({jsx:a(s),id:s,...t})};this.subscribers=[],this.toasts=[]}},v=new ot,bt=(i,a)=>{let t=(a==null?void 0:a.id)||at++;return v.addToast({title:i,...a,id:t}),t},yt=bt,vt=Object.assign(yt,{success:v.success,error:v.error,custom:v.custom,message:v.message,promise:v.promise,dismiss:v.dismiss,loading:v.loading});var Tt=3,wt="32px",Et=4e3,St=356,ut=14,Nt=20,Rt=200,kt=i=>{let{invert:a,toast:t,interacting:s,setHeights:l,visibleToasts:T,heights:p,index:d,toasts:w,expanded:A,removeToast:O,closeButton:K,style:V,className:g="",descriptionClassName:j="",duration:E,position:z,expandByDefault:D}=i,[M,W]=e.useState(!1),[x,F]=e.useState(!1),[U,_]=e.useState(!1),[S,X]=e.useState(!1),[J,b]=e.useState(0),[G,y]=e.useState(0),N=e.useRef(null),R=e.useRef(null),$=d===0,n=d+1<=T,r=t.type,f=t.className||"",I=t.descriptionClassName||"",C=e.useMemo(()=>p.findIndex(o=>o.toastId===t.id)||0,[p,t.id]),L=e.useMemo(()=>t.duration||E||Et,[t.duration,E]),q=e.useRef(0),B=e.useRef(0),Q=e.useRef(L),st=e.useRef(0),H=e.useRef(null),[rt,mt]=z.split("-"),nt=e.useMemo(()=>p.reduce((o,c,u)=>u>=C?o:o+c.height,0),[p,C]),pt=t.invert||a,Z=r==="loading";B.current=e.useMemo(()=>C*ut+nt,[C,nt]),e.useEffect(()=>{W(!0)},[]),e.useLayoutEffect(()=>{if(!M)return;let o=R.current,c=o.style.height;o.style.height="auto";let u=o.getBoundingClientRect().height;o.style.height=c,y(u),l(m=>m.find(h=>h.toastId===t.id)?m.map(h=>h.toastId===t.id?{...h,height:u}:h):[{toastId:t.id,height:u},...m])},[M,t.title,t.description,l,t.id]);let k=e.useCallback(()=>{F(!0),b(B.current),l(o=>o.filter(c=>c.toastId!==t.id)),setTimeout(()=>{O(t)},Rt)},[t,O,l,B]);return e.useEffect(()=>{if(t.promise&&r==="loading"||t.duration===1/0)return;let o;return A||s?(()=>{if(st.current<q.current){let m=new Date().getTime()-q.current;Q.current=Q.current-m}st.current=new Date().getTime()})():(()=>{q.current=new Date().getTime(),o=setTimeout(()=>{var m;(m=t.onAutoClose)==null||m.call(t,t),k()},Q.current)})(),()=>clearTimeout(o)},[A,s,D,t,L,k,t.promise,r]),e.useEffect(()=>{let o=R.current;if(o){let c=o.getBoundingClientRect().height;return y(c),l(u=>[{toastId:t.id,height:c},...u]),()=>l(u=>u.filter(m=>m.toastId!==t.id))}},[l,t.id]),e.useEffect(()=>{t.delete&&k()},[k,t.delete]),e.createElement("li",{"aria-live":t.important?"assertive":"polite","aria-atomic":"true",role:"status",tabIndex:0,ref:R,className:g+" "+f,"data-sonner-toast":"","data-styled":!t.jsx,"data-mounted":M,"data-promise":!!t.promise,"data-removed":x,"data-visible":n,"data-y-position":rt,"data-x-position":mt,"data-index":d,"data-front":$,"data-swiping":U,"data-type":r,"data-invert":pt,"data-swipe-out":S,"data-expanded":!!(A||D&&M),style:{"--index":d,"--toasts-before":d,"--z-index":w.length-d,"--offset":`${x?J:B.current}px`,"--initial-height":D?"auto":`${G}px`,...V,...t.style},onPointerDown:o=>{Z||(N.current=new Date,b(B.current),o.target.setPointerCapture(o.pointerId),o.target.tagName!=="BUTTON"&&(_(!0),H.current={x:o.clientX,y:o.clientY}))},onPointerUp:()=>{var m,Y,h,tt;if(S)return;H.current=null;let o=Number(((m=R.current)==null?void 0:m.style.getPropertyValue("--swipe-amount").replace("px",""))||0),c=new Date().getTime()-((Y=N.current)==null?void 0:Y.getTime()),u=Math.abs(o)/c;if(Math.abs(o)>=Nt||u>.11){b(B.current),(h=t.onDismiss)==null||h.call(t,t),k(),X(!0);return}(tt=R.current)==null||tt.style.setProperty("--swipe-amount","0px"),_(!1)},onPointerMove:o=>{var it;if(!H.current)return;let c=o.clientY-H.current.y,u=o.clientX-H.current.x,Y=(rt==="top"?Math.min:Math.max)(0,c),h=o.pointerType==="touch"?10:2;Math.abs(Y)>h?(it=R.current)==null||it.style.setProperty("--swipe-amount",`${c}px`):Math.abs(u)>h&&(H.current=null)}},K&&!t.jsx?e.createElement("button",{"aria-label":"Close toast","data-disabled":Z,"data-close-button":!0,onClick:Z?void 0:()=>{var o;k(),(o=t.onDismiss)==null||o.call(t,t)}},e.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},e.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"}))):null,t.jsx||e.isValidElement(t.title)?t.jsx||t.title:e.createElement(e.Fragment,null,r||t.icon||t.promise?e.createElement("div",{"data-icon":""},t.promise||t.type==="loading"?e.createElement(dt,{visible:r==="loading"}):null,t.icon||lt(r)):null,e.createElement("div",{"data-content":""},e.createElement("div",{"data-title":""},t.title),t.description?e.createElement("div",{"data-description":"",className:j+I},t.description):null),t.cancel?e.createElement("button",{"data-button":!0,"data-cancel":!0,onClick:()=>{var o;k(),(o=t.cancel)!=null&&o.onClick&&t.cancel.onClick()}},t.cancel.label):null,t.action?e.createElement("button",{"data-button":"",onClick:o=>{var c;(c=t.action)==null||c.onClick(o),!o.defaultPrevented&&k()}},t.action.label):null))};function ct(){if(typeof window=="undefined")return"ltr";let i=document.documentElement.getAttribute("dir");return i==="auto"||!i?window.getComputedStyle(document.documentElement).direction:i}var Vt=i=>{var $;let{invert:a,position:t="bottom-right",hotkey:s=["altKey","KeyT"],expand:l,closeButton:T,className:p,offset:d,theme:w="light",richColors:A,duration:O,style:K,visibleToasts:V=Tt,toastOptions:g,dir:j=ct()}=i,[E,z]=e.useState([]),[D,M]=e.useState([]),[W,x]=e.useState(!1),[F,U]=e.useState(!1),[_,S]=e.useState(w!=="system"?w:typeof window!="undefined"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),[X,J]=t.split("-"),b=e.useRef(null),G=s.join("+").replace(/Key/g,"").replace(/Digit/g,""),y=e.useRef(null),N=e.useRef(!1),R=e.useCallback(n=>z(r=>r.filter(({id:f})=>f!==n.id)),[]);return e.useEffect(()=>v.subscribe(n=>{if(n.dismiss){z(r=>r.map(f=>f.id===n.id?{...f,delete:!0}:f));return}setTimeout(()=>{xt.flushSync(()=>{z(r=>{let f=r.findIndex(I=>I.id===n.id);return f!==-1?[...r.slice(0,f),{...r[f],...n},...r.slice(f+1)]:[n,...r]})})})}),[]),e.useEffect(()=>{if(w!=="system"){S(w);return}w==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?S("dark"):S("light")),typeof window!="undefined"&&window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",({matches:n})=>{S(n?"dark":"light")})},[w]),e.useEffect(()=>{E.length<=1&&x(!1)},[E]),e.useEffect(()=>{let n=r=>{var I,C;s.every(L=>r[L]||r.code===L)&&(x(!0),(I=b.current)==null||I.focus()),r.code==="Escape"&&(document.activeElement===b.current||(C=b.current)!=null&&C.contains(document.activeElement))&&x(!1)};return document.addEventListener("keydown",n),()=>document.removeEventListener("keydown",n)},[s]),e.useEffect(()=>{if(b.current)return()=>{y.current&&(y.current.focus({preventScroll:!0}),y.current=null,N.current=!1)}},[b.current]),E.length?e.createElement("section",{"aria-label":`Notifications ${G}`,tabIndex:-1},e.createElement("ol",{dir:j==="auto"?ct():j,tabIndex:-1,ref:b,className:p,"data-sonner-toaster":!0,"data-theme":_,"data-rich-colors":A,"data-y-position":X,"data-x-position":J,style:{"--front-toast-height":`${($=D[0])==null?void 0:$.height}px`,"--offset":typeof d=="number"?`${d}px`:d||wt,"--width":`${St}px`,"--gap":`${ut}px`,...K},onBlur:n=>{N.current&&!n.currentTarget.contains(n.relatedTarget)&&(N.current=!1,y.current&&(y.current.focus({preventScroll:!0}),y.current=null))},onFocus:n=>{N.current||(N.current=!0,y.current=n.relatedTarget)},onMouseEnter:()=>x(!0),onMouseMove:()=>x(!0),onMouseLeave:()=>{F||x(!1)},onPointerDown:()=>{U(!0)},onPointerUp:()=>U(!1)},E.map((n,r)=>e.createElement(kt,{key:n.id,index:r,toast:n,duration:O,className:g==null?void 0:g.className,descriptionClassName:g==null?void 0:g.descriptionClassName,invert:a,visibleToasts:V,closeButton:T,interacting:F,position:t,style:g==null?void 0:g.style,removeToast:R,toasts:E,heights:D,setHeights:M,expandByDefault:l,expanded:W})))):null};export{Vt as Toaster,vt as toast}; | ||
"use client";var vt=Object.create;var K=Object.defineProperty;var Tt=Object.getOwnPropertyDescriptor;var wt=Object.getOwnPropertyNames;var Et=Object.getPrototypeOf,St=Object.prototype.hasOwnProperty;var Nt=(o,e)=>{for(var t in e)K(o,t,{get:e[t],enumerable:!0})},ut=(o,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let l of wt(e))!St.call(o,l)&&l!==t&&K(o,l,{get:()=>e[l],enumerable:!(r=Tt(e,l))||r.enumerable});return o};var at=(o,e,t)=>(t=o!=null?vt(Et(o)):{},ut(e||!o||!o.__esModule?K(t,"default",{value:o,enumerable:!0}):t,o)),Rt=o=>ut(K({},"__esModule",{value:!0}),o);var jt={};Nt(jt,{Toaster:()=>Ot,toast:()=>pt});module.exports=Rt(jt);var a=at(require("react")),ht=at(require("react-dom"));function st(o,{insertAt:e}={}){if(!o||typeof document=="undefined")return;let t=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css",e==="top"&&t.firstChild?t.insertBefore(r,t.firstChild):t.appendChild(r),r.styleSheet?r.styleSheet.cssText=o:r.appendChild(document.createTextNode(o))}st(`html[dir=ltr],[data-sonner-toaster][dir=ltr]{--toast-icon-margin-start: -3px;--toast-icon-margin-end: 4px;--toast-svg-margin-start: -1px;--toast-svg-margin-end: 0px;--toast-button-margin-start: auto;--toast-button-margin-end: 0;--toast-close-button-start: 0;--toast-close-button-end: unset;--toast-close-button-transform: translate(-35%, -35%)}html[dir=rtl],[data-sonner-toaster][dir=rtl]{--toast-icon-margin-start: 4px;--toast-icon-margin-end: -3px;--toast-svg-margin-start: 0px;--toast-svg-margin-end: -1px;--toast-button-margin-start: 0;--toast-button-margin-end: auto;--toast-close-button-start: unset;--toast-close-button-end: 0;--toast-close-button-transform: translate(35%, -35%)}[data-sonner-toaster]{position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1: hsl(0, 0%, 99%);--gray2: hsl(0, 0%, 97.3%);--gray3: hsl(0, 0%, 95.1%);--gray4: hsl(0, 0%, 93%);--gray5: hsl(0, 0%, 90.9%);--gray6: hsl(0, 0%, 88.7%);--gray7: hsl(0, 0%, 85.8%);--gray8: hsl(0, 0%, 78%);--gray9: hsl(0, 0%, 56.1%);--gray10: hsl(0, 0%, 52.3%);--gray11: hsl(0, 0%, 43.5%);--gray12: hsl(0, 0%, 9%);--border-radius: 8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:none;z-index:999999999}[data-sonner-toaster][data-x-position=right]{right:max(var(--offset),env(safe-area-inset-right))}[data-sonner-toaster][data-x-position=left]{left:max(var(--offset),env(safe-area-inset-left))}[data-sonner-toaster][data-x-position=center]{left:50%;transform:translate(-50%)}[data-sonner-toaster][data-y-position=top]{top:max(var(--offset),env(safe-area-inset-top))}[data-sonner-toaster][data-y-position=bottom]{bottom:max(var(--offset),env(safe-area-inset-bottom))}[data-sonner-toast]{--y: translateY(100%);--lift-amount: calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);touch-action:none;will-change:transform,opacity,height;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:none}[data-sonner-toast][data-styled=true]{padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px #0000001a;width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}[data-sonner-toast]:focus-visible{box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}[data-sonner-toast][data-y-position=top]{top:0;--y: translateY(-100%);--lift: 1;--lift-amount: calc(1 * var(--gap))}[data-sonner-toast][data-y-position=bottom]{bottom:0;--y: translateY(100%);--lift: -1;--lift-amount: calc(var(--lift) * var(--gap))}[data-sonner-toast] [data-description]{font-weight:400;line-height:1.4;color:inherit}[data-sonner-toast] [data-title]{font-weight:500;line-height:1.5;color:inherit}[data-sonner-toast] [data-icon]{display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}[data-sonner-toast][data-promise=true] [data-icon]>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}[data-sonner-toast] [data-icon]>*{flex-shrink:0}[data-sonner-toast] [data-icon] svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}[data-sonner-toast] [data-content]{display:flex;flex-direction:column;gap:2px}[data-sonner-toast] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;cursor:pointer;outline:none;transition:opacity .4s,box-shadow .2s}[data-sonner-toast] [data-button]:focus-visible{box-shadow:0 0 0 2px #0006}[data-sonner-toast] [data-button]:first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}[data-sonner-toast] [data-cancel]{color:var(--color);background:var(--border-color)}[data-sonner-toast] [data-close-button]{position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;background:var(--gray1);color:var(--gray12);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;opacity:0;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast] [data-close-button]:focus-visible{box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}[data-sonner-toast] [data-disabled=true]{cursor:not-allowed}[data-sonner-toast]:hover [data-close-button]{opacity:1}[data-sonner-toast]:focus [data-close-button]{opacity:1}[data-sonner-toast]:focus-within [data-close-button]{opacity:1}[data-sonner-toast]:hover [data-close-button]:hover{background:var(--gray2);border-color:var(--gray5)}[data-sonner-toast][data-swiping=true]:before{content:"";position:absolute;left:0;right:0;height:100%}[data-sonner-toast][data-y-position=top][data-swiping=true]:before{bottom:50%;transform:scaleY(3) translateY(50%)}[data-sonner-toast][data-y-position=bottom][data-swiping=true]:before{top:50%;transform:scaleY(3) translateY(-50%)}[data-sonner-toast][data-swiping=false][data-removed=true]:before{content:"";position:absolute;inset:0;transform:scaleY(2)}[data-sonner-toast]:after{content:"";position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}[data-sonner-toast][data-mounted=true]{--y: translateY(0);opacity:1}[data-sonner-toast][data-expanded=false][data-front=false]{--scale: var(--toasts-before) * .05 + 1;--y: translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}[data-sonner-toast]>*{transition:opacity .4s}[data-sonner-toast][data-expanded=false][data-front=false][data-styled=true]>*{opacity:0}[data-sonner-toast][data-visible=false]{opacity:0;pointer-events:none}[data-sonner-toast][data-mounted=true][data-expanded=true]{--y: translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}[data-sonner-toast][data-removed=true][data-front=true][data-swipe-out=false]{--y: translateY(calc(var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=true]{--y: translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=false]{--y: translateY(40%);opacity:0;transition:transform .5s,opacity .2s}[data-sonner-toast][data-removed=true][data-front=false]:before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount, 0px));transition:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation:swipe-out .2s ease-out forwards}@keyframes swipe-out{0%{transform:translateY(calc(var(--lift) * var(--offset) + var(--swipe-amount)));opacity:1}to{transform:translateY(calc(var(--lift) * var(--offset) + var(--swipe-amount) + var(--lift) * -100%));opacity:0}}@media (max-width: 600px){[data-sonner-toaster]{position:fixed;--mobile-offset: 16px;right:var(--mobile-offset);left:var(--mobile-offset);width:100%}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - 32px)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset)}[data-sonner-toaster][data-y-position=bottom]{bottom:20px}[data-sonner-toaster][data-y-position=top]{top:20px}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset);right:var(--mobile-offset);transform:none}}[data-sonner-toaster][data-theme=light]{--normal-bg: #fff;--normal-border: var(--gray4);--normal-text: var(--gray12);--success-bg: hsl(143, 85%, 96%);--success-border: hsl(145, 92%, 91%);--success-text: hsl(140, 100%, 27%);--error-bg: hsl(359, 100%, 97%);--error-border: hsl(359, 100%, 94%);--error-text: hsl(360, 100%, 45%)}[data-sonner-toaster][data-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg: #000;--normal-border: hsl(0, 0%, 20%);--normal-text: var(--gray1)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg: #fff;--normal-border: var(--gray3);--normal-text: var(--gray12)}[data-sonner-toaster][data-theme=dark]{--normal-bg: #000;--normal-border: hsl(0, 0%, 20%);--normal-text: var(--gray1);--success-bg: hsl(150, 100%, 6%);--success-border: hsl(147, 100%, 12%);--success-text: hsl(150, 86%, 65%);--error-bg: hsl(358, 76%, 10%);--error-border: hsl(357, 89%, 16%);--error-text: hsl(358, 100%, 81%)}[data-rich-colors=true] [data-sonner-toast][data-type=success],[data-rich-colors=true] [data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true] [data-sonner-toast][data-type=error],[data-rich-colors=true] [data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size: 16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:nth-child(1){animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}to{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}to{opacity:.15}}@media (prefers-reduced-motion){[data-sonner-toast],[data-sonner-toast]>*,.sonner-loading-bar{transition:none!important;animation:none!important}} | ||
`);var C=at(require("react")),mt=o=>{switch(o){case"success":return Ct;case"error":return Pt;default:return null}},kt=Array(12).fill(0),ft=({visible:o})=>C.default.createElement("div",{className:"sonner-loading-wrapper","data-visible":o},C.default.createElement("div",{className:"sonner-spinner"},kt.map((e,t)=>C.default.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${t}`})))),Ct=C.default.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},C.default.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"}));var Pt=C.default.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},C.default.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"}));var ot=0,rt=class{constructor(){this.subscribe=e=>(this.subscribers.push(e),()=>{let t=this.subscribers.indexOf(e);this.subscribers.splice(t,1)});this.publish=e=>{this.subscribers.forEach(t=>t(e))};this.addToast=e=>{this.publish(e),this.toasts=[...this.toasts,e]};this.create=e=>{var g;let{message:t,...r}=e,l=typeof(e==null?void 0:e.id)=="number"||((g=e.id)==null?void 0:g.length)>0?e.id:ot++,T=this.toasts.find(u=>u.id===l),p=e.dismissible===void 0?!0:e.dismissible;return T?this.toasts=this.toasts.map(u=>u.id===l?(this.publish({...u,...e,id:l,title:t}),{...u,...e,id:l,dismissible:p,title:t}):u):this.addToast({title:t,...r,dismissible:p,id:l}),l};this.dismiss=e=>(e||this.toasts.forEach(t=>{this.subscribers.forEach(r=>r({id:t.id,dismiss:!0}))}),this.subscribers.forEach(t=>t({id:e,dismiss:!0})),e);this.message=(e,t)=>this.create({...t,message:e});this.error=(e,t)=>this.create({...t,message:e,type:"error"});this.success=(e,t)=>this.create({...t,type:"success",message:e});this.loading=(e,t)=>this.create({...t,type:"loading",message:e});this.promise=(e,t)=>{let r=this.create({...t,promise:e,type:"loading",message:t.loading});return(e instanceof Promise?e:e()).then(T=>{let p=typeof t.success=="function"?t.success(T):t.success;this.create({id:r,type:"success",message:p})}).catch(T=>{let p=typeof t.error=="function"?t.error(T):t.error;this.create({id:r,type:"error",message:p})}).finally(t.finally),r};this.custom=(e,t)=>{let r=(t==null?void 0:t.id)||ot++;this.publish({jsx:e(r),id:r,...t})};this.subscribers=[],this.toasts=[]}},v=new rt,Dt=(o,e)=>{let t=(e==null?void 0:e.id)||ot++;return v.addToast({title:o,...e,id:t}),t},Mt=Dt,pt=Object.assign(Mt,{success:v.success,error:v.error,custom:v.custom,message:v.message,promise:v.promise,dismiss:v.dismiss,loading:v.loading});var It=3,Ht="32px",Bt=4e3,At=356,bt=14,Lt=20,zt=200,Yt=o=>{let{invert:e,toast:t,interacting:r,setHeights:l,visibleToasts:T,heights:p,index:g,toasts:u,expanded:A,removeToast:Y,closeButton:V,style:W,className:h="",descriptionClassName:O="",duration:E,position:L,expandByDefault:D}=o,[M,X]=a.default.useState(!1),[w,j]=a.default.useState(!1),[F,U]=a.default.useState(!1),[S,J]=a.default.useState(!1),[G,y]=a.default.useState(0),[q,x]=a.default.useState(0),N=a.default.useRef(null),R=a.default.useRef(null),_=g===0,n=g+1<=T,i=t.type,d=t.dismissible!==!1,I=t.className||"",$=t.descriptionClassName||"",P=a.default.useMemo(()=>p.findIndex(s=>s.toastId===t.id)||0,[p,t.id]),nt=a.default.useMemo(()=>t.duration||E||Bt,[t.duration,E]),Q=a.default.useRef(0),H=a.default.useRef(0),Z=a.default.useRef(nt),it=a.default.useRef(0),B=a.default.useRef(null),[lt,yt]=L.split("-"),dt=a.default.useMemo(()=>p.reduce((s,c,m)=>m>=P?s:s+c.height,0),[p,P]),xt=t.invert||e,tt=i==="loading";H.current=a.default.useMemo(()=>P*bt+dt,[P,dt]),a.default.useEffect(()=>{X(!0)},[]),a.default.useLayoutEffect(()=>{if(!M)return;let s=R.current,c=s.style.height;s.style.height="auto";let m=s.getBoundingClientRect().height;s.style.height=c,x(m),l(f=>f.find(b=>b.toastId===t.id)?f.map(b=>b.toastId===t.id?{...b,height:m}:b):[{toastId:t.id,height:m},...f])},[M,t.title,t.description,l,t.id]);let k=a.default.useCallback(()=>{j(!0),y(H.current),l(s=>s.filter(c=>c.toastId!==t.id)),setTimeout(()=>{Y(t)},zt)},[t,Y,l,H]);return a.default.useEffect(()=>{if(t.promise&&i==="loading"||t.duration===1/0)return;let s;return A||r?(()=>{if(it.current<Q.current){let f=new Date().getTime()-Q.current;Z.current=Z.current-f}it.current=new Date().getTime()})():(()=>{Q.current=new Date().getTime(),s=setTimeout(()=>{var f;(f=t.onAutoClose)==null||f.call(t,t),k()},Z.current)})(),()=>clearTimeout(s)},[A,r,D,t,nt,k,t.promise,i]),a.default.useEffect(()=>{let s=R.current;if(s){let c=s.getBoundingClientRect().height;return x(c),l(m=>[{toastId:t.id,height:c},...m]),()=>l(m=>m.filter(f=>f.toastId!==t.id))}},[l,t.id]),a.default.useEffect(()=>{t.delete&&k()},[k,t.delete]),a.default.createElement("li",{"aria-live":t.important?"assertive":"polite","aria-atomic":"true",role:"status",tabIndex:0,ref:R,className:h+" "+I,"data-sonner-toast":"","data-styled":!t.jsx,"data-mounted":M,"data-promise":!!t.promise,"data-removed":w,"data-visible":n,"data-y-position":lt,"data-x-position":yt,"data-index":g,"data-front":_,"data-swiping":F,"data-dismissible":d,"data-type":i,"data-invert":xt,"data-swipe-out":S,"data-expanded":!!(A||D&&M),style:{"--index":g,"--toasts-before":g,"--z-index":u.length-g,"--offset":`${w?G:H.current}px`,"--initial-height":D?"auto":`${q}px`,...W,...t.style},onPointerDown:s=>{tt||!d||(N.current=new Date,y(H.current),s.target.setPointerCapture(s.pointerId),s.target.tagName!=="BUTTON"&&(U(!0),B.current={x:s.clientX,y:s.clientY}))},onPointerUp:()=>{var f,z,b,et;if(S||!d)return;B.current=null;let s=Number(((f=R.current)==null?void 0:f.style.getPropertyValue("--swipe-amount").replace("px",""))||0),c=new Date().getTime()-((z=N.current)==null?void 0:z.getTime()),m=Math.abs(s)/c;if(Math.abs(s)>=Lt||m>.11){y(H.current),(b=t.onDismiss)==null||b.call(t,t),k(),J(!0);return}(et=R.current)==null||et.style.setProperty("--swipe-amount","0px"),U(!1)},onPointerMove:s=>{var ct;if(!B.current||!d)return;let c=s.clientY-B.current.y,m=s.clientX-B.current.x,z=(lt==="top"?Math.min:Math.max)(0,c),b=s.pointerType==="touch"?10:2;Math.abs(z)>b?(ct=R.current)==null||ct.style.setProperty("--swipe-amount",`${c}px`):Math.abs(m)>b&&(B.current=null)}},V&&!t.jsx?a.default.createElement("button",{"aria-label":"Close toast","data-disabled":tt,"data-close-button":!0,onClick:tt||!d?void 0:()=>{var s;k(),(s=t.onDismiss)==null||s.call(t,t)}},a.default.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},a.default.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),a.default.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"}))):null,t.jsx||a.default.isValidElement(t.title)?t.jsx||t.title:a.default.createElement(a.default.Fragment,null,i||t.icon||t.promise?a.default.createElement("div",{"data-icon":""},t.promise||t.type==="loading"?a.default.createElement(ft,{visible:i==="loading"}):null,t.icon||mt(i)):null,a.default.createElement("div",{"data-content":""},a.default.createElement("div",{"data-title":""},t.title),t.description?a.default.createElement("div",{"data-description":"",className:O+$},t.description):null),t.cancel?a.default.createElement("button",{"data-button":!0,"data-cancel":!0,onClick:()=>{var s;d&&(k(),(s=t.cancel)!=null&&s.onClick&&t.cancel.onClick())}},t.cancel.label):null,t.action?a.default.createElement("button",{"data-button":"",onClick:s=>{var c;(c=t.action)==null||c.onClick(s),!s.defaultPrevented&&k()}},t.action.label):null))};function gt(){if(typeof window=="undefined")return"ltr";let o=document.documentElement.getAttribute("dir");return o==="auto"||!o?window.getComputedStyle(document.documentElement).direction:o}var Ot=o=>{var _;let{invert:e,position:t="bottom-right",hotkey:r=["altKey","KeyT"],expand:l,closeButton:T,className:p,offset:g,theme:u="light",richColors:A,duration:Y,style:V,visibleToasts:W=It,toastOptions:h,dir:O=gt()}=o,[E,L]=a.default.useState([]),[D,M]=a.default.useState([]),[X,w]=a.default.useState(!1),[j,F]=a.default.useState(!1),[U,S]=a.default.useState(u!=="system"?u:typeof window!="undefined"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),[J,G]=t.split("-"),y=a.default.useRef(null),q=r.join("+").replace(/Key/g,"").replace(/Digit/g,""),x=a.default.useRef(null),N=a.default.useRef(!1),R=a.default.useCallback(n=>L(i=>i.filter(({id:d})=>d!==n.id)),[]);return a.default.useEffect(()=>v.subscribe(n=>{if(n.dismiss){L(i=>i.map(d=>d.id===n.id?{...d,delete:!0}:d));return}setTimeout(()=>{ht.default.flushSync(()=>{L(i=>{let d=i.findIndex(I=>I.id===n.id);return d!==-1?[...i.slice(0,d),{...i[d],...n},...i.slice(d+1)]:[n,...i]})})})}),[]),a.default.useEffect(()=>{if(u!=="system"){S(u);return}u==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?S("dark"):S("light")),typeof window!="undefined"&&window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",({matches:n})=>{S(n?"dark":"light")})},[u]),a.default.useEffect(()=>{E.length<=1&&w(!1)},[E]),a.default.useEffect(()=>{let n=i=>{var I,$;r.every(P=>i[P]||i.code===P)&&(w(!0),(I=y.current)==null||I.focus()),i.code==="Escape"&&(document.activeElement===y.current||($=y.current)!=null&&$.contains(document.activeElement))&&w(!1)};return document.addEventListener("keydown",n),()=>document.removeEventListener("keydown",n)},[r]),a.default.useEffect(()=>{if(y.current)return()=>{x.current&&(x.current.focus({preventScroll:!0}),x.current=null,N.current=!1)}},[y.current]),E.length?a.default.createElement("section",{"aria-label":`Notifications ${q}`,tabIndex:-1},a.default.createElement("ol",{dir:O==="auto"?gt():O,tabIndex:-1,ref:y,className:p,"data-sonner-toaster":!0,"data-theme":U,"data-rich-colors":A,"data-y-position":J,"data-x-position":G,style:{"--front-toast-height":`${(_=D[0])==null?void 0:_.height}px`,"--offset":typeof g=="number"?`${g}px`:g||Ht,"--width":`${At}px`,"--gap":`${bt}px`,...V},onBlur:n=>{N.current&&!n.currentTarget.contains(n.relatedTarget)&&(N.current=!1,x.current&&(x.current.focus({preventScroll:!0}),x.current=null))},onFocus:n=>{n.target instanceof HTMLElement&&n.target.dataset.dismissible==="false"||N.current||(N.current=!0,x.current=n.relatedTarget)},onMouseEnter:()=>w(!0),onMouseMove:()=>w(!0),onMouseLeave:()=>{j||w(!1)},onPointerDown:n=>{n.target instanceof HTMLElement&&n.target.dataset.dismissible==="false"||F(!0)},onPointerUp:()=>F(!1)},E.map((n,i)=>a.default.createElement(Yt,{key:n.id,index:i,toast:n,duration:Y,className:h==null?void 0:h.className,descriptionClassName:h==null?void 0:h.descriptionClassName,invert:e,visibleToasts:W,closeButton:T,interacting:j,position:t,style:h==null?void 0:h.style,removeToast:R,toasts:E,heights:D,setHeights:M,expandByDefault:l,expanded:X})))):null};0&&(module.exports={Toaster,toast}); | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "sonner", | ||
"version": "0.7.3", | ||
"version": "0.7.4", | ||
"description": "An opinionated toast component for React.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
242765
345
3