vyrn 1.8.8 → 1.9.0
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/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Toast.tsx +136 -41
- package/src/components/ToastContainer.tsx +18 -14
- package/src/styles/toast.css +145 -114
package/dist/index.esm.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import t,{useEffect as e,useState as n,useRef as r,useCallback as o}from"react";import{X as a,AlertTriangle as i,Info as s,AlertCircle as c,CheckCircle as l}from"lucide-react";import{motion as d,AnimatePresence as p}from"framer-motion";var u=function(){return u=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},u.apply(this,arguments)};function m(t,e,n){if(n||2===arguments.length)for(var r,o=0,a=e.length;o<a;o++)!r&&o in e||(r||(r=Array.prototype.slice.call(e,0,o)),r[o]=e[o]);return t.concat(r||Array.prototype.slice.call(e))}"function"==typeof SuppressedError&&SuppressedError;var f=t.createContext(void 0),v=function(){var e=t.useContext(f);if(void 0===e)throw new Error("useToastContext must be used within a ToastProvider");return e},y=function(n){var r=n.id,o=n.message,p=n.type,u=n.duration,m=void 0===u?3e3:u,f=n.title,y=n.description,g=n.action,h=n.isExpanded,x=v(),b=x.removeToast;x.updateToast,e((function(){var t=setTimeout((function(){b(r)}),m);return function(){return clearTimeout(t)}}),[r,m,b]);return t.createElement(d.div,{className:"vyrn-toast vyrn-toast-".concat(p," ").concat(h?"vyrn-toast-expanded":""),role:"alert",animate:{height:h?"auto":"60px"}},function(){switch(p){case"success":return t.createElement(l,{className:"vyrn-toast-icon"});case"error":return t.createElement(c,{className:"vyrn-toast-icon"});case"info":return t.createElement(s,{className:"vyrn-toast-icon"});case"warning":return t.createElement(i,{className:"vyrn-toast-icon"});default:return null}}(),t.createElement("div",{className:"vyrn-toast-content"},f&&t.createElement("div",{className:"vyrn-toast-title"},f),t.createElement("div",{className:"vyrn-toast-message"},o),h&&y&&t.createElement("div",{className:"vyrn-toast-description"},y)),h&&g&&t.createElement("button",{className:"vyrn-toast-action",onClick:g.onClick},g.label),t.createElement("button",{className:"vyrn-toast-close",onClick:function(){return b(r)},"aria-label":"Close"},t.createElement(a,{size:18})),t.createElement(d.div,{className:"vyrn-toast-progress",initial:{width:"100%"},animate:{width:"0%"},transition:{duration:m/1e3,ease:"linear"}}))},g=function(o){var a=o.toasts,i=o.position,s=o.swipeDirection,c=n(null),l=c[0],f=c[1],v=r(null);e((function(){var t=function(t){v.current&&!v.current.contains(t.target)&&f(null)};return document.addEventListener("mousedown",t),function(){document.removeEventListener("mousedown",t)}}),[]);var g=function(){switch(s){case"left":return{x:-100};case"right":return{x:100};case"up":return{y:-100};case"down":return{y:100}}},h=m([],a,!0).reverse();return t.createElement("div",{className:"vyrn-toast-container vyrn-toast-".concat(i),"aria-live":"polite","aria-atomic":"true",ref:v},t.createElement(p,{initial:!1},h.map((function(e,n){var r=l===e.id,o=70*n,a=h.slice(0,n).reduce((function(t,e){return t+(l===e.id?40:0)}),0);return t.createElement(d.div,{key:e.id,layout:!0,initial:u({opacity:0,y:-20},g()),animate:{opacity:1,x:0,y:i.startsWith("top")?o+a:-(o+a),scale:r?1.02:1,zIndex:r?9999:9999-n},exit:{opacity:0,x:"left"===s?-100:"right"===s?100:0,y:"up"===s?-100:"down"===s?100:0},transition:{type:"spring",stiffness:500,damping:30,layout:{type:"spring",stiffness:200,damping:25}},style:{position:"absolute",width:"100%",transformOrigin:i.startsWith("top")?"top":"bottom"},onHoverStart:function(){return f(e.id)},onHoverEnd:function(){return f(null)},drag:"left"===s||"right"===s?"x":"y",dragConstraints:{left:0,right:0,top:0,bottom:0},dragElastic:.9,onDragEnd:function(t,n){var r;(Math.abs(n.offset.x)>100||Math.abs(n.offset.y)>100)&&(null===(r=e.onClose)||void 0===r||r.call(e))}},t.createElement(y,u({},e,{isExpanded:r})))}))))};!function(t,e){void 0===e&&(e={});var n=e.insertAt;if(t&&"undefined"!=typeof document){var r=document.head||document.getElementsByTagName("head")[0],o=document.createElement("style");o.type="text/css","top"===n&&r.firstChild?r.insertBefore(o,r.firstChild):r.appendChild(o),o.styleSheet?o.styleSheet.cssText=t:o.appendChild(document.createTextNode(t))}}(".vyrn-toast-container{box-sizing:border-box;display:flex;flex-direction:column;gap:10px;max-width:380px;padding:1rem;pointer-events:none;position:fixed;width:100%;z-index:9999}.vyrn-toast-bottom-right,.vyrn-toast-top-right{right:1rem}.vyrn-toast-bottom-left,.vyrn-toast-top-left{left:1rem}.vyrn-toast-bottom-center,.vyrn-toast-top-center{left:50%;transform:translateX(-50%)}.vyrn-toast-top-center,.vyrn-toast-top-left,.vyrn-toast-top-right{top:1rem}.vyrn-toast-bottom-center,.vyrn-toast-bottom-left,.vyrn-toast-bottom-right{bottom:1rem}.vyrn-toast{align-items:center;backdrop-filter:blur(8px);background:#fff;border-radius:8px;box-shadow:0 4px 12px rgba(0,0,0,.15);cursor:pointer;display:flex;overflow:hidden;padding:12px 16px;pointer-events:auto;position:relative;transition:transform .2s ease,box-shadow .2s ease;will-change:transform,height,opacity}.vyrn-toast-expanded{box-shadow:0 8px 24px rgba(0,0,0,.2);height:auto!important;z-index:10000}.vyrn-toast-expanded .vyrn-toast-message{overflow:visible;white-space:normal}.vyrn-toast-expanded .vyrn-toast-description{max-height:200px;opacity:1;transition:max-height .3s ease,opacity .3s ease}.vyrn-toast-icon{flex-shrink:0;height:20px;margin-right:12px;width:20px}.vyrn-toast-content{flex-grow:1;margin-right:12px;overflow:hidden}.vyrn-toast-title{font-size:1rem;font-weight:600;margin-bottom:4px}.vyrn-toast-message,.vyrn-toast-title{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.vyrn-toast-message{font-size:.875rem;line-height:1.25rem;transition:white-space .2s ease}.vyrn-toast-description{font-size:.75rem;margin-top:4px;max-height:0;opacity:.8;overflow:hidden;transition:max-height .3s ease,opacity .3s ease}.vyrn-toast-close{align-items:center;background:none;border:none;color:inherit;cursor:pointer;display:flex;justify-content:center;opacity:.7;padding:0;transition:opacity .2s}.vyrn-toast-close:hover{opacity:1}.vyrn-toast-action{background:none;border:none;border-radius:4px;color:inherit;cursor:pointer;font-weight:600;padding:4px 8px;transition:background-color .2s}.vyrn-toast-action:hover{background-color:rgba(0,0,0,.05)}.vyrn-toast-info{border-left:4px solid #3498db}.vyrn-toast-success{border-left:4px solid #2ecc71}.vyrn-toast-warning{border-left:4px solid #f39c12}.vyrn-toast-error{border-left:4px solid #e74c3c}.vyrn-toast-progress{background-color:rgba(0,0,0,.2);bottom:0;height:3px;left:0;position:absolute}@keyframes vyrnSlideIn{0%{opacity:0;transform:translateY(20px)}to{opacity:1;transform:translateY(0)}}@keyframes vyrnFadeOut{0%{opacity:1}to{opacity:0}}.vyrn-toast-enter{animation:vyrnSlideIn .3s ease-out}.vyrn-toast-exit{animation:vyrnFadeOut .3s ease-in forwards}",{insertAt:"top"});var h=function(e){var r=e.children,a=e.position,i=void 0===a?"top-right":a,s=e.maxToasts,c=void 0===s?5:s,l=e.swipeDirection,d=void 0===l?"right":l,p=n([]),v=p[0],y=p[1],h=o((function(t){var e=Math.random().toString(36).substr(2,9);return y((function(n){return m(m([],n,!0),[u(u({},t),{id:e})],!1).slice(-c)})),e}),[c]),x=o((function(t){y((function(e){return e.filter((function(e){return e.id!==t}))}))}),[]),b=o((function(t,e){y((function(n){return n.map((function(n){return n.id===t?u(u({},n),e):n}))}))}),[]);return t.createElement(f.Provider,{value:{addToast:h,removeToast:x,updateToast:b,position:i}},r,t.createElement(g,{toasts:v,position:i,swipeDirection:d}))},x=function(){var t=v(),e=t.addToast,n=t.removeToast,r=t.updateToast,a=t.position,i=o((function(t){return e(u(u({},t),{type:t.type||"info"}))}),[e]),s=o((function(t,e){r(t,e)}),[r]),c=o((function(t){n(t)}),[n]);return{toast:i,update:s,dismiss:c,info:function(t,e){return i(u({message:t,type:"info"},e))},success:function(t,e){return i(u({message:t,type:"success"},e))},warning:function(t,e){return i(u({message:t,type:"warning"},e))},error:function(t,e){return i(u({message:t,type:"error"},e))},position:a}},b=function(e){var n=e.children,r=e.position,o=e.maxToasts,a=e.swipeDirection;return t.createElement(h,{position:r,maxToasts:o,swipeDirection:a},n)};export{b as ClientToastProvider,h as ToastProvider,x as useToast};
|
|
1
|
+
import t,{useEffect as e,useState as r,useRef as n,useCallback as a}from"react";import{X as o,Info as i,AlertTriangle as s,AlertCircle as c,CheckCircle as l}from"lucide-react";import{motion as m,AnimatePresence as d}from"framer-motion";var p=function(){return p=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var a in e=arguments[r])Object.prototype.hasOwnProperty.call(e,a)&&(t[a]=e[a]);return t},p.apply(this,arguments)};function u(t,e,r){if(r||2===arguments.length)for(var n,a=0,o=e.length;a<o;a++)!n&&a in e||(n||(n=Array.prototype.slice.call(e,0,a)),n[a]=e[a]);return t.concat(n||Array.prototype.slice.call(e))}"function"==typeof SuppressedError&&SuppressedError;var f=t.createContext(void 0),v=function(){var e=t.useContext(f);if(void 0===e)throw new Error("useToastContext must be used within a ToastProvider");return e},y=function(r){var n=r.id,a=r.message,d=r.type,u=r.duration,f=void 0===u?3e3:u,y=r.title,b=r.description,x=r.action,g=r.isExpanded,h=v().removeToast;e((function(){var t=setTimeout((function(){h(n)}),f);return function(){return clearTimeout(t)}}),[n,f,h]);var w={className:"w-5 h-5 ".concat("success"===d?"text-emerald-500":"error"===d?"text-rose-500":"warning"===d?"text-amber-500":"text-blue-500")};return t.createElement(m.div,{className:"\n relative\n overflow-hidden\n rounded-lg\n border-l-4\n shadow-lg\n backdrop-blur-md\n ".concat({success:"bg-gradient-to-r from-emerald-50 to-green-50 border-l-emerald-500",error:"bg-gradient-to-r from-rose-50 to-red-50 border-l-rose-500",warning:"bg-gradient-to-r from-amber-50 to-yellow-50 border-l-amber-500",info:"bg-gradient-to-r from-blue-50 to-sky-50 border-l-blue-500"}[d],"\n transition-all\n duration-200\n hover:shadow-xl\n hover:scale-[1.02]\n ").concat(g?"ring-2 ring-offset-2 ring-offset-white dark:ring-offset-gray-900":"","\n "),role:"alert",initial:{opacity:0,y:-20},animate:{opacity:1,y:0,height:g?"auto":"64px"},exit:{opacity:0,scale:.95},transition:{duration:.2}},t.createElement("div",{className:"flex items-start p-4 gap-3"},t.createElement("div",{className:"flex-shrink-0 mt-0.5"},function(){switch(d){case"success":return t.createElement(l,p({},w));case"error":return t.createElement(c,p({},w));case"warning":return t.createElement(s,p({},w));default:return t.createElement(i,p({},w))}}()),t.createElement("div",{className:"flex-1 min-w-0"},y&&t.createElement(m.h3,{className:"font-semibold text-gray-900 dark:text-gray-100 mb-1",layout:!0},y),t.createElement(m.div,{className:"\n text-sm text-gray-700 dark:text-gray-300\n transition-all duration-200\n ".concat(g?"whitespace-normal":"whitespace-nowrap overflow-hidden text-ellipsis","\n "),layout:!0},a),b&&t.createElement(m.div,{className:"\n mt-2 text-sm text-gray-600 dark:text-gray-400\n transition-all duration-200\n ".concat(g?"opacity-100":"opacity-0 h-0","\n "),layout:!0},b)),t.createElement("div",{className:"flex-shrink-0 flex items-start gap-2"},x&&g&&t.createElement(m.button,{className:"\n px-3 py-1.5\n text-sm font-medium\n rounded-md\n transition-colors\n ".concat("success"===d?"bg-emerald-100 hover:bg-emerald-200 text-emerald-700":"error"===d?"bg-rose-100 hover:bg-rose-200 text-rose-700":"warning"===d?"bg-amber-100 hover:bg-amber-200 text-amber-700":"bg-blue-100 hover:bg-blue-200 text-blue-700","\n "),onClick:x.onClick,initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.9}},x.label),t.createElement("button",{className:"p-1 rounded-full opacity-60 hover:opacity-100 transition-opacity",onClick:function(){return h(n)},"aria-label":"Close"},t.createElement(o,{className:"w-4 h-4"})))),t.createElement(m.div,{className:"\n absolute bottom-0 left-0 h-1\n ".concat({success:"bg-emerald-500",error:"bg-rose-500",warning:"bg-amber-500",info:"bg-blue-500"}[d],"\n opacity-80\n "),initial:{width:"100%"},animate:{width:"0%"},transition:{duration:f/1e3,ease:"linear"}}))},b=function(a){var o=a.toasts,i=a.position,s=a.swipeDirection,c=r(null),l=c[0],f=c[1],v=n(null);e((function(){var t=function(t){v.current&&!v.current.contains(t.target)&&f(null)};return document.addEventListener("mousedown",t),function(){document.removeEventListener("mousedown",t)}}),[]);var b=function(){switch(s){case"left":return{x:-100};case"right":return{x:100};case"up":return{y:-100};case"down":return{y:100}}},x=u([],o,!0).reverse();return t.createElement("div",{className:"vyrn-toast-container vyrn-toast-".concat(i),"aria-live":"polite","aria-atomic":"true",ref:v,onMouseLeave:function(){return f(null)}},t.createElement(d,{initial:!1},x.map((function(e,r){var n=l===e.id,a=null!==l,o=r*(a?10:-45);a&&(r>x.findIndex((function(t){return t.id===l}))&&(o+=60));return t.createElement(m.div,{key:e.id,layout:!0,initial:p({opacity:0,y:-20},b()),animate:{opacity:1,x:0,y:i.startsWith("top")?o:-o,scale:n?1.02:1,zIndex:n?9999:9999-r},exit:{opacity:0,x:"left"===s?-100:"right"===s?100:0,y:"up"===s?-100:"down"===s?100:0},transition:{type:"spring",stiffness:500,damping:30,layout:{type:"spring",stiffness:200,damping:25}},style:{position:"absolute",width:"100%",transformOrigin:i.startsWith("top")?"top":"bottom"},onHoverStart:function(){return f(e.id)},drag:"left"===s||"right"===s?"x":"y",dragConstraints:{left:0,right:0,top:0,bottom:0},dragElastic:.9,onDragEnd:function(t,r){var n;(Math.abs(r.offset.x)>100||Math.abs(r.offset.y)>100)&&(null===(n=e.onClose)||void 0===n||n.call(e))}},t.createElement(y,p({},e,{isExpanded:n})))}))))};!function(t,e){void 0===e&&(e={});var r=e.insertAt;if(t&&"undefined"!=typeof document){var n=document.head||document.getElementsByTagName("head")[0],a=document.createElement("style");a.type="text/css","top"===r&&n.firstChild?n.insertBefore(a,n.firstChild):n.appendChild(a),a.styleSheet?a.styleSheet.cssText=t:a.appendChild(document.createTextNode(t))}}('.vyrn-toast-container{box-sizing:border-box;max-width:420px;padding:1rem;perspective:1000px;pointer-events:none;position:fixed;transform-style:preserve-3d;width:calc(100% - 2rem);z-index:9999}.vyrn-toast-top-right{right:max(env(safe-area-inset-right,0px),1rem);top:max(env(safe-area-inset-top,0px),1rem);transform-origin:top right}.vyrn-toast-top-left{left:max(env(safe-area-inset-left,0px),1rem);top:max(env(safe-area-inset-top,0px),1rem);transform-origin:top left}.vyrn-toast-bottom-right{bottom:max(env(safe-area-inset-bottom,0px),1rem);right:max(env(safe-area-inset-right,0px),1rem);transform-origin:bottom right}.vyrn-toast-bottom-left{bottom:max(env(safe-area-inset-bottom,0px),1rem);left:max(env(safe-area-inset-left,0px),1rem);transform-origin:bottom left}.vyrn-toast-top-center{left:50%;top:max(env(safe-area-inset-top,0px),1rem);transform:translateX(-50%);transform-origin:top center}.vyrn-toast-bottom-center{bottom:max(env(safe-area-inset-bottom,0px),1rem);left:50%;transform:translateX(-50%);transform-origin:bottom center}.vyrn-toast{-webkit-font-smoothing:subpixel-antialiased;backface-visibility:hidden;margin-bottom:.75rem;pointer-events:auto;position:relative;transform:translateZ(0)}.vyrn-toast-container::-webkit-scrollbar{width:6px}.vyrn-toast-container::-webkit-scrollbar-track{background:transparent}.vyrn-toast-container::-webkit-scrollbar-thumb{background-color:rgba(0,0,0,.2);border:2px solid transparent;border-radius:3px}.vyrn-toast-container>div{filter:drop-shadow(0 4px 12px rgba(0,0,0,.1));opacity:1;transform:scale(1);transition:all .2s cubic-bezier(.68,-.55,.265,1.55)}.vyrn-toast-container>div:not(:first-child){margin-top:-.5rem;opacity:.95;transform:scale(.95) translateY(5px);z-index:-1}.vyrn-toast-container>div:not(:first-child):not(:nth-child(2)){opacity:.9;transform:scale(.9) translateY(10px);z-index:-2}.vyrn-toast-container:hover>div:not(:first-child){opacity:1;transform:scale(.98) translateY(0)}@media (max-width:640px){.vyrn-toast-container{max-width:calc(100vw - 2rem);padding:.5rem}.vyrn-toast{margin-bottom:.5rem}.vyrn-toast-bottom-center,.vyrn-toast-bottom-left,.vyrn-toast-bottom-right{bottom:max(env(safe-area-inset-bottom,0px),.5rem)}}@media (prefers-reduced-motion:reduce){.vyrn-toast-container>div{transition:none}}@media (prefers-color-scheme:dark){.vyrn-toast-container>div{filter:drop-shadow(0 4px 12px rgba(0,0,0,.3))}}@supports (backdrop-filter:blur(10px)){.vyrn-toast-container:before{backdrop-filter:blur(8px);-webkit-backdrop-filter:blur(8px);content:"";inset:0;opacity:0;position:absolute;transition:opacity .3s ease;z-index:-1}.vyrn-toast-container:hover:before{opacity:1}}@keyframes vyrnSlideIn{0%{opacity:0;transform:translateY(20px) scale(.95)}to{opacity:1;transform:translateY(0) scale(1)}}@keyframes vyrnSlideOut{0%{opacity:1;transform:translateY(0) scale(1)}to{opacity:0;transform:translateY(-20px) scale(.95)}}.vyrn-toast-enter{animation:vyrnSlideIn .3s cubic-bezier(.68,-.55,.265,1.55) forwards}.vyrn-toast-exit{animation:vyrnSlideOut .2s cubic-bezier(.68,-.55,.265,1.55) forwards}',{insertAt:"top"});var x=function(e){var n=e.children,o=e.position,i=void 0===o?"top-right":o,s=e.maxToasts,c=void 0===s?5:s,l=e.swipeDirection,m=void 0===l?"right":l,d=r([]),v=d[0],y=d[1],x=a((function(t){var e=Math.random().toString(36).substr(2,9);return y((function(r){return u(u([],r,!0),[p(p({},t),{id:e})],!1).slice(-c)})),e}),[c]),g=a((function(t){y((function(e){return e.filter((function(e){return e.id!==t}))}))}),[]),h=a((function(t,e){y((function(r){return r.map((function(r){return r.id===t?p(p({},r),e):r}))}))}),[]);return t.createElement(f.Provider,{value:{addToast:x,removeToast:g,updateToast:h,position:i}},n,t.createElement(b,{toasts:v,position:i,swipeDirection:m}))},g=function(){var t=v(),e=t.addToast,r=t.removeToast,n=t.updateToast,o=t.position,i=a((function(t){return e(p(p({},t),{type:t.type||"info"}))}),[e]),s=a((function(t,e){n(t,e)}),[n]),c=a((function(t){r(t)}),[r]);return{toast:i,update:s,dismiss:c,info:function(t,e){return i(p({message:t,type:"info"},e))},success:function(t,e){return i(p({message:t,type:"success"},e))},warning:function(t,e){return i(p({message:t,type:"warning"},e))},error:function(t,e){return i(p({message:t,type:"error"},e))},position:o}},h=function(e){var r=e.children,n=e.position,a=e.maxToasts,o=e.swipeDirection;return t.createElement(x,{position:n,maxToasts:a,swipeDirection:o},r)};export{h as ClientToastProvider,x as ToastProvider,g as useToast};
|
|
2
2
|
//# sourceMappingURL=index.esm.js.map
|
package/dist/index.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.js","sources":["../node_modules/style-inject/dist/style-inject.es.js"],"sourcesContent":["function styleInject(css, ref) {\n if ( ref === void 0 ) ref = {};\n var insertAt = ref.insertAt;\n\n if (!css || typeof document === 'undefined') { return; }\n\n var head = document.head || document.getElementsByTagName('head')[0];\n var style = document.createElement('style');\n style.type = 'text/css';\n\n if (insertAt === 'top') {\n if (head.firstChild) {\n head.insertBefore(style, head.firstChild);\n } else {\n head.appendChild(style);\n }\n } else {\n head.appendChild(style);\n }\n\n if (style.styleSheet) {\n style.styleSheet.cssText = css;\n } else {\n style.appendChild(document.createTextNode(css));\n }\n}\n\nexport default styleInject;\n"],"names":["css","ref","insertAt","document","head","getElementsByTagName","style","createElement","type","firstChild","insertBefore","appendChild","styleSheet","cssText","createTextNode"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":["../node_modules/style-inject/dist/style-inject.es.js"],"sourcesContent":["function styleInject(css, ref) {\n if ( ref === void 0 ) ref = {};\n var insertAt = ref.insertAt;\n\n if (!css || typeof document === 'undefined') { return; }\n\n var head = document.head || document.getElementsByTagName('head')[0];\n var style = document.createElement('style');\n style.type = 'text/css';\n\n if (insertAt === 'top') {\n if (head.firstChild) {\n head.insertBefore(style, head.firstChild);\n } else {\n head.appendChild(style);\n }\n } else {\n head.appendChild(style);\n }\n\n if (style.styleSheet) {\n style.styleSheet.cssText = css;\n } else {\n style.appendChild(document.createTextNode(css));\n }\n}\n\nexport default styleInject;\n"],"names":["css","ref","insertAt","document","head","getElementsByTagName","style","createElement","type","firstChild","insertBefore","appendChild","styleSheet","cssText","createTextNode"],"mappings":"+mLAAA,SAAqBA,EAAKC,QACX,IAARA,IAAiBA,EAAM,CAAA,GAC5B,IAAIC,EAAWD,EAAIC,SAEnB,GAAKF,GAA2B,oBAAbG,SAAnB,CAEA,IAAIC,EAAOD,SAASC,MAAQD,SAASE,qBAAqB,QAAQ,GAC9DC,EAAQH,SAASI,cAAc,SACnCD,EAAME,KAAO,WAEI,QAAbN,GACEE,EAAKK,WACPL,EAAKM,aAAaJ,EAAOF,EAAKK,YAKhCL,EAAKO,YAAYL,GAGfA,EAAMM,WACRN,EAAMM,WAAWC,QAAUb,EAE3BM,EAAMK,YAAYR,SAASW,eAAed,GAnBY,CAqB1D"}
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("react"),e=require("lucide-react"),n=require("framer-motion");function r(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var o=r(t),a=function(){return a=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},a.apply(this,arguments)};function i(t,e,n){if(n||2===arguments.length)for(var r,o=0,a=e.length;o<a;o++)!r&&o in e||(r||(r=Array.prototype.slice.call(e,0,o)),r[o]=e[o]);return t.concat(r||Array.prototype.slice.call(e))}"function"==typeof SuppressedError&&SuppressedError;var s=o.default.createContext(void 0),c=function(){var t=o.default.useContext(s);if(void 0===t)throw new Error("useToastContext must be used within a ToastProvider");return t},l=function(r){var a=r.id,i=r.message,s=r.type,l=r.duration,u=void 0===l?3e3:l,d=r.title,p=r.description,f=r.action,m=r.isExpanded,v=c(),y=v.removeToast;v.updateToast,t.useEffect((function(){var t=setTimeout((function(){y(a)}),u);return function(){return clearTimeout(t)}}),[a,u,y]);return o.default.createElement(n.motion.div,{className:"vyrn-toast vyrn-toast-".concat(s," ").concat(m?"vyrn-toast-expanded":""),role:"alert",animate:{height:m?"auto":"60px"}},function(){switch(s){case"success":return o.default.createElement(e.CheckCircle,{className:"vyrn-toast-icon"});case"error":return o.default.createElement(e.AlertCircle,{className:"vyrn-toast-icon"});case"info":return o.default.createElement(e.Info,{className:"vyrn-toast-icon"});case"warning":return o.default.createElement(e.AlertTriangle,{className:"vyrn-toast-icon"});default:return null}}(),o.default.createElement("div",{className:"vyrn-toast-content"},d&&o.default.createElement("div",{className:"vyrn-toast-title"},d),o.default.createElement("div",{className:"vyrn-toast-message"},i),m&&p&&o.default.createElement("div",{className:"vyrn-toast-description"},p)),m&&f&&o.default.createElement("button",{className:"vyrn-toast-action",onClick:f.onClick},f.label),o.default.createElement("button",{className:"vyrn-toast-close",onClick:function(){return y(a)},"aria-label":"Close"},o.default.createElement(e.X,{size:18})),o.default.createElement(n.motion.div,{className:"vyrn-toast-progress",initial:{width:"100%"},animate:{width:"0%"},transition:{duration:u/1e3,ease:"linear"}}))},u=function(e){var r=e.toasts,s=e.position,c=e.swipeDirection,u=t.useState(null),d=u[0],p=u[1],f=t.useRef(null);t.useEffect((function(){var t=function(t){f.current&&!f.current.contains(t.target)&&p(null)};return document.addEventListener("mousedown",t),function(){document.removeEventListener("mousedown",t)}}),[]);var m=function(){switch(c){case"left":return{x:-100};case"right":return{x:100};case"up":return{y:-100};case"down":return{y:100}}},v=i([],r,!0).reverse();return o.default.createElement("div",{className:"vyrn-toast-container vyrn-toast-".concat(s),"aria-live":"polite","aria-atomic":"true",ref:f},o.default.createElement(n.AnimatePresence,{initial:!1},v.map((function(t,e){var r=d===t.id,i=70*e,u=v.slice(0,e).reduce((function(t,e){return t+(d===e.id?40:0)}),0);return o.default.createElement(n.motion.div,{key:t.id,layout:!0,initial:a({opacity:0,y:-20},m()),animate:{opacity:1,x:0,y:s.startsWith("top")?i+u:-(i+u),scale:r?1.02:1,zIndex:r?9999:9999-e},exit:{opacity:0,x:"left"===c?-100:"right"===c?100:0,y:"up"===c?-100:"down"===c?100:0},transition:{type:"spring",stiffness:500,damping:30,layout:{type:"spring",stiffness:200,damping:25}},style:{position:"absolute",width:"100%",transformOrigin:s.startsWith("top")?"top":"bottom"},onHoverStart:function(){return p(t.id)},onHoverEnd:function(){return p(null)},drag:"left"===c||"right"===c?"x":"y",dragConstraints:{left:0,right:0,top:0,bottom:0},dragElastic:.9,onDragEnd:function(e,n){var r;(Math.abs(n.offset.x)>100||Math.abs(n.offset.y)>100)&&(null===(r=t.onClose)||void 0===r||r.call(t))}},o.default.createElement(l,a({},t,{isExpanded:r})))}))))};!function(t,e){void 0===e&&(e={});var n=e.insertAt;if(t&&"undefined"!=typeof document){var r=document.head||document.getElementsByTagName("head")[0],o=document.createElement("style");o.type="text/css","top"===n&&r.firstChild?r.insertBefore(o,r.firstChild):r.appendChild(o),o.styleSheet?o.styleSheet.cssText=t:o.appendChild(document.createTextNode(t))}}(".vyrn-toast-container{box-sizing:border-box;display:flex;flex-direction:column;gap:10px;max-width:380px;padding:1rem;pointer-events:none;position:fixed;width:100%;z-index:9999}.vyrn-toast-bottom-right,.vyrn-toast-top-right{right:1rem}.vyrn-toast-bottom-left,.vyrn-toast-top-left{left:1rem}.vyrn-toast-bottom-center,.vyrn-toast-top-center{left:50%;transform:translateX(-50%)}.vyrn-toast-top-center,.vyrn-toast-top-left,.vyrn-toast-top-right{top:1rem}.vyrn-toast-bottom-center,.vyrn-toast-bottom-left,.vyrn-toast-bottom-right{bottom:1rem}.vyrn-toast{align-items:center;backdrop-filter:blur(8px);background:#fff;border-radius:8px;box-shadow:0 4px 12px rgba(0,0,0,.15);cursor:pointer;display:flex;overflow:hidden;padding:12px 16px;pointer-events:auto;position:relative;transition:transform .2s ease,box-shadow .2s ease;will-change:transform,height,opacity}.vyrn-toast-expanded{box-shadow:0 8px 24px rgba(0,0,0,.2);height:auto!important;z-index:10000}.vyrn-toast-expanded .vyrn-toast-message{overflow:visible;white-space:normal}.vyrn-toast-expanded .vyrn-toast-description{max-height:200px;opacity:1;transition:max-height .3s ease,opacity .3s ease}.vyrn-toast-icon{flex-shrink:0;height:20px;margin-right:12px;width:20px}.vyrn-toast-content{flex-grow:1;margin-right:12px;overflow:hidden}.vyrn-toast-title{font-size:1rem;font-weight:600;margin-bottom:4px}.vyrn-toast-message,.vyrn-toast-title{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.vyrn-toast-message{font-size:.875rem;line-height:1.25rem;transition:white-space .2s ease}.vyrn-toast-description{font-size:.75rem;margin-top:4px;max-height:0;opacity:.8;overflow:hidden;transition:max-height .3s ease,opacity .3s ease}.vyrn-toast-close{align-items:center;background:none;border:none;color:inherit;cursor:pointer;display:flex;justify-content:center;opacity:.7;padding:0;transition:opacity .2s}.vyrn-toast-close:hover{opacity:1}.vyrn-toast-action{background:none;border:none;border-radius:4px;color:inherit;cursor:pointer;font-weight:600;padding:4px 8px;transition:background-color .2s}.vyrn-toast-action:hover{background-color:rgba(0,0,0,.05)}.vyrn-toast-info{border-left:4px solid #3498db}.vyrn-toast-success{border-left:4px solid #2ecc71}.vyrn-toast-warning{border-left:4px solid #f39c12}.vyrn-toast-error{border-left:4px solid #e74c3c}.vyrn-toast-progress{background-color:rgba(0,0,0,.2);bottom:0;height:3px;left:0;position:absolute}@keyframes vyrnSlideIn{0%{opacity:0;transform:translateY(20px)}to{opacity:1;transform:translateY(0)}}@keyframes vyrnFadeOut{0%{opacity:1}to{opacity:0}}.vyrn-toast-enter{animation:vyrnSlideIn .3s ease-out}.vyrn-toast-exit{animation:vyrnFadeOut .3s ease-in forwards}",{insertAt:"top"});var d=function(e){var n=e.children,r=e.position,c=void 0===r?"top-right":r,l=e.maxToasts,d=void 0===l?5:l,p=e.swipeDirection,f=void 0===p?"right":p,m=t.useState([]),v=m[0],y=m[1],g=t.useCallback((function(t){var e=Math.random().toString(36).substr(2,9);return y((function(n){return i(i([],n,!0),[a(a({},t),{id:e})],!1).slice(-d)})),e}),[d]),h=t.useCallback((function(t){y((function(e){return e.filter((function(e){return e.id!==t}))}))}),[]),x=t.useCallback((function(t,e){y((function(n){return n.map((function(n){return n.id===t?a(a({},n),e):n}))}))}),[]);return o.default.createElement(s.Provider,{value:{addToast:g,removeToast:h,updateToast:x,position:c}},n,o.default.createElement(u,{toasts:v,position:c,swipeDirection:f}))};exports.ClientToastProvider=function(t){var e=t.children,n=t.position,r=t.maxToasts,a=t.swipeDirection;return o.default.createElement(d,{position:n,maxToasts:r,swipeDirection:a},e)},exports.ToastProvider=d,exports.useToast=function(){var e=c(),n=e.addToast,r=e.removeToast,o=e.updateToast,i=e.position,s=t.useCallback((function(t){return n(a(a({},t),{type:t.type||"info"}))}),[n]),l=t.useCallback((function(t,e){o(t,e)}),[o]),u=t.useCallback((function(t){r(t)}),[r]);return{toast:s,update:l,dismiss:u,info:function(t,e){return s(a({message:t,type:"info"},e))},success:function(t,e){return s(a({message:t,type:"success"},e))},warning:function(t,e){return s(a({message:t,type:"warning"},e))},error:function(t,e){return s(a({message:t,type:"error"},e))},position:i}};
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("react"),e=require("lucide-react"),r=require("framer-motion");function n(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var a=n(t),o=function(){return o=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var a in e=arguments[r])Object.prototype.hasOwnProperty.call(e,a)&&(t[a]=e[a]);return t},o.apply(this,arguments)};function i(t,e,r){if(r||2===arguments.length)for(var n,a=0,o=e.length;a<o;a++)!n&&a in e||(n||(n=Array.prototype.slice.call(e,0,a)),n[a]=e[a]);return t.concat(n||Array.prototype.slice.call(e))}"function"==typeof SuppressedError&&SuppressedError;var s=a.default.createContext(void 0),l=function(){var t=a.default.useContext(s);if(void 0===t)throw new Error("useToastContext must be used within a ToastProvider");return t},c=function(n){var i=n.id,s=n.message,c=n.type,d=n.duration,u=void 0===d?3e3:d,m=n.title,f=n.description,p=n.action,v=n.isExpanded,b=l().removeToast;t.useEffect((function(){var t=setTimeout((function(){b(i)}),u);return function(){return clearTimeout(t)}}),[i,u,b]);var y={className:"w-5 h-5 ".concat("success"===c?"text-emerald-500":"error"===c?"text-rose-500":"warning"===c?"text-amber-500":"text-blue-500")};return a.default.createElement(r.motion.div,{className:"\n relative\n overflow-hidden\n rounded-lg\n border-l-4\n shadow-lg\n backdrop-blur-md\n ".concat({success:"bg-gradient-to-r from-emerald-50 to-green-50 border-l-emerald-500",error:"bg-gradient-to-r from-rose-50 to-red-50 border-l-rose-500",warning:"bg-gradient-to-r from-amber-50 to-yellow-50 border-l-amber-500",info:"bg-gradient-to-r from-blue-50 to-sky-50 border-l-blue-500"}[c],"\n transition-all\n duration-200\n hover:shadow-xl\n hover:scale-[1.02]\n ").concat(v?"ring-2 ring-offset-2 ring-offset-white dark:ring-offset-gray-900":"","\n "),role:"alert",initial:{opacity:0,y:-20},animate:{opacity:1,y:0,height:v?"auto":"64px"},exit:{opacity:0,scale:.95},transition:{duration:.2}},a.default.createElement("div",{className:"flex items-start p-4 gap-3"},a.default.createElement("div",{className:"flex-shrink-0 mt-0.5"},function(){switch(c){case"success":return a.default.createElement(e.CheckCircle,o({},y));case"error":return a.default.createElement(e.AlertCircle,o({},y));case"warning":return a.default.createElement(e.AlertTriangle,o({},y));default:return a.default.createElement(e.Info,o({},y))}}()),a.default.createElement("div",{className:"flex-1 min-w-0"},m&&a.default.createElement(r.motion.h3,{className:"font-semibold text-gray-900 dark:text-gray-100 mb-1",layout:!0},m),a.default.createElement(r.motion.div,{className:"\n text-sm text-gray-700 dark:text-gray-300\n transition-all duration-200\n ".concat(v?"whitespace-normal":"whitespace-nowrap overflow-hidden text-ellipsis","\n "),layout:!0},s),f&&a.default.createElement(r.motion.div,{className:"\n mt-2 text-sm text-gray-600 dark:text-gray-400\n transition-all duration-200\n ".concat(v?"opacity-100":"opacity-0 h-0","\n "),layout:!0},f)),a.default.createElement("div",{className:"flex-shrink-0 flex items-start gap-2"},p&&v&&a.default.createElement(r.motion.button,{className:"\n px-3 py-1.5\n text-sm font-medium\n rounded-md\n transition-colors\n ".concat("success"===c?"bg-emerald-100 hover:bg-emerald-200 text-emerald-700":"error"===c?"bg-rose-100 hover:bg-rose-200 text-rose-700":"warning"===c?"bg-amber-100 hover:bg-amber-200 text-amber-700":"bg-blue-100 hover:bg-blue-200 text-blue-700","\n "),onClick:p.onClick,initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.9}},p.label),a.default.createElement("button",{className:"p-1 rounded-full opacity-60 hover:opacity-100 transition-opacity",onClick:function(){return b(i)},"aria-label":"Close"},a.default.createElement(e.X,{className:"w-4 h-4"})))),a.default.createElement(r.motion.div,{className:"\n absolute bottom-0 left-0 h-1\n ".concat({success:"bg-emerald-500",error:"bg-rose-500",warning:"bg-amber-500",info:"bg-blue-500"}[c],"\n opacity-80\n "),initial:{width:"100%"},animate:{width:"0%"},transition:{duration:u/1e3,ease:"linear"}}))},d=function(e){var n=e.toasts,s=e.position,l=e.swipeDirection,d=t.useState(null),u=d[0],m=d[1],f=t.useRef(null);t.useEffect((function(){var t=function(t){f.current&&!f.current.contains(t.target)&&m(null)};return document.addEventListener("mousedown",t),function(){document.removeEventListener("mousedown",t)}}),[]);var p=function(){switch(l){case"left":return{x:-100};case"right":return{x:100};case"up":return{y:-100};case"down":return{y:100}}},v=i([],n,!0).reverse();return a.default.createElement("div",{className:"vyrn-toast-container vyrn-toast-".concat(s),"aria-live":"polite","aria-atomic":"true",ref:f,onMouseLeave:function(){return m(null)}},a.default.createElement(r.AnimatePresence,{initial:!1},v.map((function(t,e){var n=u===t.id,i=null!==u,d=e*(i?10:-45);i&&(e>v.findIndex((function(t){return t.id===u}))&&(d+=60));return a.default.createElement(r.motion.div,{key:t.id,layout:!0,initial:o({opacity:0,y:-20},p()),animate:{opacity:1,x:0,y:s.startsWith("top")?d:-d,scale:n?1.02:1,zIndex:n?9999:9999-e},exit:{opacity:0,x:"left"===l?-100:"right"===l?100:0,y:"up"===l?-100:"down"===l?100:0},transition:{type:"spring",stiffness:500,damping:30,layout:{type:"spring",stiffness:200,damping:25}},style:{position:"absolute",width:"100%",transformOrigin:s.startsWith("top")?"top":"bottom"},onHoverStart:function(){return m(t.id)},drag:"left"===l||"right"===l?"x":"y",dragConstraints:{left:0,right:0,top:0,bottom:0},dragElastic:.9,onDragEnd:function(e,r){var n;(Math.abs(r.offset.x)>100||Math.abs(r.offset.y)>100)&&(null===(n=t.onClose)||void 0===n||n.call(t))}},a.default.createElement(c,o({},t,{isExpanded:n})))}))))};!function(t,e){void 0===e&&(e={});var r=e.insertAt;if(t&&"undefined"!=typeof document){var n=document.head||document.getElementsByTagName("head")[0],a=document.createElement("style");a.type="text/css","top"===r&&n.firstChild?n.insertBefore(a,n.firstChild):n.appendChild(a),a.styleSheet?a.styleSheet.cssText=t:a.appendChild(document.createTextNode(t))}}('.vyrn-toast-container{box-sizing:border-box;max-width:420px;padding:1rem;perspective:1000px;pointer-events:none;position:fixed;transform-style:preserve-3d;width:calc(100% - 2rem);z-index:9999}.vyrn-toast-top-right{right:max(env(safe-area-inset-right,0px),1rem);top:max(env(safe-area-inset-top,0px),1rem);transform-origin:top right}.vyrn-toast-top-left{left:max(env(safe-area-inset-left,0px),1rem);top:max(env(safe-area-inset-top,0px),1rem);transform-origin:top left}.vyrn-toast-bottom-right{bottom:max(env(safe-area-inset-bottom,0px),1rem);right:max(env(safe-area-inset-right,0px),1rem);transform-origin:bottom right}.vyrn-toast-bottom-left{bottom:max(env(safe-area-inset-bottom,0px),1rem);left:max(env(safe-area-inset-left,0px),1rem);transform-origin:bottom left}.vyrn-toast-top-center{left:50%;top:max(env(safe-area-inset-top,0px),1rem);transform:translateX(-50%);transform-origin:top center}.vyrn-toast-bottom-center{bottom:max(env(safe-area-inset-bottom,0px),1rem);left:50%;transform:translateX(-50%);transform-origin:bottom center}.vyrn-toast{-webkit-font-smoothing:subpixel-antialiased;backface-visibility:hidden;margin-bottom:.75rem;pointer-events:auto;position:relative;transform:translateZ(0)}.vyrn-toast-container::-webkit-scrollbar{width:6px}.vyrn-toast-container::-webkit-scrollbar-track{background:transparent}.vyrn-toast-container::-webkit-scrollbar-thumb{background-color:rgba(0,0,0,.2);border:2px solid transparent;border-radius:3px}.vyrn-toast-container>div{filter:drop-shadow(0 4px 12px rgba(0,0,0,.1));opacity:1;transform:scale(1);transition:all .2s cubic-bezier(.68,-.55,.265,1.55)}.vyrn-toast-container>div:not(:first-child){margin-top:-.5rem;opacity:.95;transform:scale(.95) translateY(5px);z-index:-1}.vyrn-toast-container>div:not(:first-child):not(:nth-child(2)){opacity:.9;transform:scale(.9) translateY(10px);z-index:-2}.vyrn-toast-container:hover>div:not(:first-child){opacity:1;transform:scale(.98) translateY(0)}@media (max-width:640px){.vyrn-toast-container{max-width:calc(100vw - 2rem);padding:.5rem}.vyrn-toast{margin-bottom:.5rem}.vyrn-toast-bottom-center,.vyrn-toast-bottom-left,.vyrn-toast-bottom-right{bottom:max(env(safe-area-inset-bottom,0px),.5rem)}}@media (prefers-reduced-motion:reduce){.vyrn-toast-container>div{transition:none}}@media (prefers-color-scheme:dark){.vyrn-toast-container>div{filter:drop-shadow(0 4px 12px rgba(0,0,0,.3))}}@supports (backdrop-filter:blur(10px)){.vyrn-toast-container:before{backdrop-filter:blur(8px);-webkit-backdrop-filter:blur(8px);content:"";inset:0;opacity:0;position:absolute;transition:opacity .3s ease;z-index:-1}.vyrn-toast-container:hover:before{opacity:1}}@keyframes vyrnSlideIn{0%{opacity:0;transform:translateY(20px) scale(.95)}to{opacity:1;transform:translateY(0) scale(1)}}@keyframes vyrnSlideOut{0%{opacity:1;transform:translateY(0) scale(1)}to{opacity:0;transform:translateY(-20px) scale(.95)}}.vyrn-toast-enter{animation:vyrnSlideIn .3s cubic-bezier(.68,-.55,.265,1.55) forwards}.vyrn-toast-exit{animation:vyrnSlideOut .2s cubic-bezier(.68,-.55,.265,1.55) forwards}',{insertAt:"top"});var u=function(e){var r=e.children,n=e.position,l=void 0===n?"top-right":n,c=e.maxToasts,u=void 0===c?5:c,m=e.swipeDirection,f=void 0===m?"right":m,p=t.useState([]),v=p[0],b=p[1],y=t.useCallback((function(t){var e=Math.random().toString(36).substr(2,9);return b((function(r){return i(i([],r,!0),[o(o({},t),{id:e})],!1).slice(-u)})),e}),[u]),x=t.useCallback((function(t){b((function(e){return e.filter((function(e){return e.id!==t}))}))}),[]),g=t.useCallback((function(t,e){b((function(r){return r.map((function(r){return r.id===t?o(o({},r),e):r}))}))}),[]);return a.default.createElement(s.Provider,{value:{addToast:y,removeToast:x,updateToast:g,position:l}},r,a.default.createElement(d,{toasts:v,position:l,swipeDirection:f}))};exports.ClientToastProvider=function(t){var e=t.children,r=t.position,n=t.maxToasts,o=t.swipeDirection;return a.default.createElement(u,{position:r,maxToasts:n,swipeDirection:o},e)},exports.ToastProvider=u,exports.useToast=function(){var e=l(),r=e.addToast,n=e.removeToast,a=e.updateToast,i=e.position,s=t.useCallback((function(t){return r(o(o({},t),{type:t.type||"info"}))}),[r]),c=t.useCallback((function(t,e){a(t,e)}),[a]),d=t.useCallback((function(t){n(t)}),[n]);return{toast:s,update:c,dismiss:d,info:function(t,e){return s(o({message:t,type:"info"},e))},success:function(t,e){return s(o({message:t,type:"success"},e))},warning:function(t,e){return s(o({message:t,type:"warning"},e))},error:function(t,e){return s(o({message:t,type:"error"},e))},position:i}};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../node_modules/style-inject/dist/style-inject.es.js"],"sourcesContent":["function styleInject(css, ref) {\n if ( ref === void 0 ) ref = {};\n var insertAt = ref.insertAt;\n\n if (!css || typeof document === 'undefined') { return; }\n\n var head = document.head || document.getElementsByTagName('head')[0];\n var style = document.createElement('style');\n style.type = 'text/css';\n\n if (insertAt === 'top') {\n if (head.firstChild) {\n head.insertBefore(style, head.firstChild);\n } else {\n head.appendChild(style);\n }\n } else {\n head.appendChild(style);\n }\n\n if (style.styleSheet) {\n style.styleSheet.cssText = css;\n } else {\n style.appendChild(document.createTextNode(css));\n }\n}\n\nexport default styleInject;\n"],"names":["css","ref","insertAt","document","head","getElementsByTagName","style","createElement","type","firstChild","insertBefore","appendChild","styleSheet","cssText","createTextNode"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../node_modules/style-inject/dist/style-inject.es.js"],"sourcesContent":["function styleInject(css, ref) {\n if ( ref === void 0 ) ref = {};\n var insertAt = ref.insertAt;\n\n if (!css || typeof document === 'undefined') { return; }\n\n var head = document.head || document.getElementsByTagName('head')[0];\n var style = document.createElement('style');\n style.type = 'text/css';\n\n if (insertAt === 'top') {\n if (head.firstChild) {\n head.insertBefore(style, head.firstChild);\n } else {\n head.appendChild(style);\n }\n } else {\n head.appendChild(style);\n }\n\n if (style.styleSheet) {\n style.styleSheet.cssText = css;\n } else {\n style.appendChild(document.createTextNode(css));\n }\n}\n\nexport default styleInject;\n"],"names":["css","ref","insertAt","document","head","getElementsByTagName","style","createElement","type","firstChild","insertBefore","appendChild","styleSheet","cssText","createTextNode"],"mappings":"o6LAAA,SAAqBA,EAAKC,QACX,IAARA,IAAiBA,EAAM,CAAA,GAC5B,IAAIC,EAAWD,EAAIC,SAEnB,GAAKF,GAA2B,oBAAbG,SAAnB,CAEA,IAAIC,EAAOD,SAASC,MAAQD,SAASE,qBAAqB,QAAQ,GAC9DC,EAAQH,SAASI,cAAc,SACnCD,EAAME,KAAO,WAEI,QAAbN,GACEE,EAAKK,WACPL,EAAKM,aAAaJ,EAAOF,EAAKK,YAKhCL,EAAKO,YAAYL,GAGfA,EAAMM,WACRN,EAAMM,WAAWC,QAAUb,EAE3BM,EAAMK,YAAYR,SAASW,eAAed,GAnBY,CAqB1D"}
|
package/package.json
CHANGED
package/src/components/Toast.tsx
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
1
|
import React, { useEffect } from 'react';
|
|
4
2
|
import { ToastProps } from '../types';
|
|
5
3
|
import { useToastContext } from '../context/ToastContext';
|
|
@@ -11,17 +9,17 @@ interface ToastComponentProps extends ToastProps {
|
|
|
11
9
|
isExpanded: boolean;
|
|
12
10
|
}
|
|
13
11
|
|
|
14
|
-
export const Toast: React.FC<ToastComponentProps> = ({
|
|
15
|
-
id,
|
|
16
|
-
message,
|
|
17
|
-
type,
|
|
12
|
+
export const Toast: React.FC<ToastComponentProps> = ({
|
|
13
|
+
id,
|
|
14
|
+
message,
|
|
15
|
+
type,
|
|
18
16
|
duration = DEFAULT_DURATION,
|
|
19
17
|
title,
|
|
20
18
|
description,
|
|
21
19
|
action,
|
|
22
20
|
isExpanded
|
|
23
21
|
}) => {
|
|
24
|
-
const { removeToast
|
|
22
|
+
const { removeToast } = useToastContext();
|
|
25
23
|
|
|
26
24
|
useEffect(() => {
|
|
27
25
|
const timer = setTimeout(() => {
|
|
@@ -31,52 +29,149 @@ export const Toast: React.FC<ToastComponentProps> = ({
|
|
|
31
29
|
return () => clearTimeout(timer);
|
|
32
30
|
}, [id, duration, removeToast]);
|
|
33
31
|
|
|
32
|
+
const iconProps = {
|
|
33
|
+
className: `w-5 h-5 ${
|
|
34
|
+
type === 'success' ? 'text-emerald-500' :
|
|
35
|
+
type === 'error' ? 'text-rose-500' :
|
|
36
|
+
type === 'warning' ? 'text-amber-500' :
|
|
37
|
+
'text-blue-500'
|
|
38
|
+
}`
|
|
39
|
+
};
|
|
40
|
+
|
|
34
41
|
const getIcon = () => {
|
|
35
42
|
switch (type) {
|
|
36
|
-
case 'success':
|
|
37
|
-
|
|
38
|
-
case '
|
|
39
|
-
|
|
40
|
-
case 'info':
|
|
41
|
-
return <Info className="vyrn-toast-icon" />;
|
|
42
|
-
case 'warning':
|
|
43
|
-
return <AlertTriangle className="vyrn-toast-icon" />;
|
|
44
|
-
default:
|
|
45
|
-
return null;
|
|
43
|
+
case 'success': return <CheckCircle {...iconProps} />;
|
|
44
|
+
case 'error': return <AlertCircle {...iconProps} />;
|
|
45
|
+
case 'warning': return <AlertTriangle {...iconProps} />;
|
|
46
|
+
default: return <Info {...iconProps} />;
|
|
46
47
|
}
|
|
47
48
|
};
|
|
48
49
|
|
|
50
|
+
const toastStyles = {
|
|
51
|
+
success: 'bg-gradient-to-r from-emerald-50 to-green-50 border-l-emerald-500',
|
|
52
|
+
error: 'bg-gradient-to-r from-rose-50 to-red-50 border-l-rose-500',
|
|
53
|
+
warning: 'bg-gradient-to-r from-amber-50 to-yellow-50 border-l-amber-500',
|
|
54
|
+
info: 'bg-gradient-to-r from-blue-50 to-sky-50 border-l-blue-500'
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const progressStyles = {
|
|
58
|
+
success: 'bg-emerald-500',
|
|
59
|
+
error: 'bg-rose-500',
|
|
60
|
+
warning: 'bg-amber-500',
|
|
61
|
+
info: 'bg-blue-500'
|
|
62
|
+
};
|
|
63
|
+
|
|
49
64
|
return (
|
|
50
|
-
<motion.div
|
|
51
|
-
className={`
|
|
65
|
+
<motion.div
|
|
66
|
+
className={`
|
|
67
|
+
relative
|
|
68
|
+
overflow-hidden
|
|
69
|
+
rounded-lg
|
|
70
|
+
border-l-4
|
|
71
|
+
shadow-lg
|
|
72
|
+
backdrop-blur-md
|
|
73
|
+
${toastStyles[type]}
|
|
74
|
+
transition-all
|
|
75
|
+
duration-200
|
|
76
|
+
hover:shadow-xl
|
|
77
|
+
hover:scale-[1.02]
|
|
78
|
+
${isExpanded ? 'ring-2 ring-offset-2 ring-offset-white dark:ring-offset-gray-900' : ''}
|
|
79
|
+
`}
|
|
52
80
|
role="alert"
|
|
53
|
-
|
|
81
|
+
initial={{ opacity: 0, y: -20 }}
|
|
82
|
+
animate={{
|
|
83
|
+
opacity: 1,
|
|
84
|
+
y: 0,
|
|
85
|
+
height: isExpanded ? 'auto' : '64px'
|
|
86
|
+
}}
|
|
87
|
+
exit={{ opacity: 0, scale: 0.95 }}
|
|
88
|
+
transition={{ duration: 0.2 }}
|
|
54
89
|
>
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
90
|
+
<div className="flex items-start p-4 gap-3">
|
|
91
|
+
<div className="flex-shrink-0 mt-0.5">
|
|
92
|
+
{getIcon()}
|
|
93
|
+
</div>
|
|
94
|
+
|
|
95
|
+
<div className="flex-1 min-w-0">
|
|
96
|
+
{title && (
|
|
97
|
+
<motion.h3
|
|
98
|
+
className="font-semibold text-gray-900 dark:text-gray-100 mb-1"
|
|
99
|
+
layout
|
|
100
|
+
>
|
|
101
|
+
{title}
|
|
102
|
+
</motion.h3>
|
|
103
|
+
)}
|
|
104
|
+
|
|
105
|
+
<motion.div
|
|
106
|
+
className={`
|
|
107
|
+
text-sm text-gray-700 dark:text-gray-300
|
|
108
|
+
transition-all duration-200
|
|
109
|
+
${isExpanded ? 'whitespace-normal' : 'whitespace-nowrap overflow-hidden text-ellipsis'}
|
|
110
|
+
`}
|
|
111
|
+
layout
|
|
112
|
+
>
|
|
113
|
+
{message}
|
|
114
|
+
</motion.div>
|
|
115
|
+
|
|
116
|
+
{description && (
|
|
117
|
+
<motion.div
|
|
118
|
+
className={`
|
|
119
|
+
mt-2 text-sm text-gray-600 dark:text-gray-400
|
|
120
|
+
transition-all duration-200
|
|
121
|
+
${isExpanded ? 'opacity-100' : 'opacity-0 h-0'}
|
|
122
|
+
`}
|
|
123
|
+
layout
|
|
124
|
+
>
|
|
125
|
+
{description}
|
|
126
|
+
</motion.div>
|
|
127
|
+
)}
|
|
128
|
+
</div>
|
|
129
|
+
|
|
130
|
+
<div className="flex-shrink-0 flex items-start gap-2">
|
|
131
|
+
{action && isExpanded && (
|
|
132
|
+
<motion.button
|
|
133
|
+
className={`
|
|
134
|
+
px-3 py-1.5
|
|
135
|
+
text-sm font-medium
|
|
136
|
+
rounded-md
|
|
137
|
+
transition-colors
|
|
138
|
+
${type === 'success' ? 'bg-emerald-100 hover:bg-emerald-200 text-emerald-700' :
|
|
139
|
+
type === 'error' ? 'bg-rose-100 hover:bg-rose-200 text-rose-700' :
|
|
140
|
+
type === 'warning' ? 'bg-amber-100 hover:bg-amber-200 text-amber-700' :
|
|
141
|
+
'bg-blue-100 hover:bg-blue-200 text-blue-700'}
|
|
142
|
+
`}
|
|
143
|
+
onClick={action.onClick}
|
|
144
|
+
initial={{ opacity: 0, scale: 0.9 }}
|
|
145
|
+
animate={{ opacity: 1, scale: 1 }}
|
|
146
|
+
exit={{ opacity: 0, scale: 0.9 }}
|
|
147
|
+
>
|
|
148
|
+
{action.label}
|
|
149
|
+
</motion.button>
|
|
150
|
+
)}
|
|
151
|
+
|
|
152
|
+
<button
|
|
153
|
+
className="p-1 rounded-full opacity-60 hover:opacity-100 transition-opacity"
|
|
154
|
+
onClick={() => removeToast(id)}
|
|
155
|
+
aria-label="Close"
|
|
156
|
+
>
|
|
157
|
+
<X className="w-4 h-4" />
|
|
158
|
+
</button>
|
|
159
|
+
</div>
|
|
60
160
|
</div>
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
onClick={() => removeToast(id)}
|
|
69
|
-
aria-label="Close"
|
|
70
|
-
>
|
|
71
|
-
<X size={18} />
|
|
72
|
-
</button>
|
|
73
|
-
<motion.div
|
|
74
|
-
className="vyrn-toast-progress"
|
|
161
|
+
|
|
162
|
+
<motion.div
|
|
163
|
+
className={`
|
|
164
|
+
absolute bottom-0 left-0 h-1
|
|
165
|
+
${progressStyles[type]}
|
|
166
|
+
opacity-80
|
|
167
|
+
`}
|
|
75
168
|
initial={{ width: '100%' }}
|
|
76
169
|
animate={{ width: '0%' }}
|
|
77
|
-
transition={{
|
|
170
|
+
transition={{
|
|
171
|
+
duration: duration / 1000,
|
|
172
|
+
ease: 'linear'
|
|
173
|
+
}}
|
|
78
174
|
/>
|
|
79
175
|
</motion.div>
|
|
80
176
|
);
|
|
81
177
|
};
|
|
82
|
-
|
|
@@ -19,11 +19,9 @@ export const ToastContainer: React.FC<ToastContainerProps> = ({
|
|
|
19
19
|
const [expandedToast, setExpandedToast] = useState<string | null>(null);
|
|
20
20
|
const containerRef = useRef<HTMLDivElement>(null);
|
|
21
21
|
|
|
22
|
-
//
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
const EXPANDED_SCALE = 1.02;
|
|
26
|
-
|
|
22
|
+
const OVERLAP_OFFSET = -45; // Negative value for overlap
|
|
23
|
+
const EXPANDED_OFFSET = 10; // Spacing when expanded
|
|
24
|
+
|
|
27
25
|
useEffect(() => {
|
|
28
26
|
const handleClickOutside = (event: MouseEvent) => {
|
|
29
27
|
if (containerRef.current && !containerRef.current.contains(event.target as Node)) {
|
|
@@ -46,7 +44,7 @@ export const ToastContainer: React.FC<ToastContainerProps> = ({
|
|
|
46
44
|
}
|
|
47
45
|
};
|
|
48
46
|
|
|
49
|
-
// Reverse
|
|
47
|
+
// Reverse toasts array so newest appears on top
|
|
50
48
|
const reversedToasts = [...toasts].reverse();
|
|
51
49
|
|
|
52
50
|
return (
|
|
@@ -55,16 +53,23 @@ export const ToastContainer: React.FC<ToastContainerProps> = ({
|
|
|
55
53
|
aria-live="polite"
|
|
56
54
|
aria-atomic="true"
|
|
57
55
|
ref={containerRef}
|
|
56
|
+
onMouseLeave={() => setExpandedToast(null)}
|
|
58
57
|
>
|
|
59
58
|
<AnimatePresence initial={false}>
|
|
60
59
|
{reversedToasts.map((toast, index) => {
|
|
61
60
|
const isExpanded = expandedToast === toast.id;
|
|
62
|
-
const
|
|
61
|
+
const isAnyExpanded = expandedToast !== null;
|
|
62
|
+
|
|
63
|
+
// Calculate base offset
|
|
64
|
+
let yOffset = index * (isAnyExpanded ? EXPANDED_OFFSET : OVERLAP_OFFSET);
|
|
63
65
|
|
|
64
|
-
//
|
|
65
|
-
|
|
66
|
-
.
|
|
67
|
-
|
|
66
|
+
// Adjust offset when a toast above this one is expanded
|
|
67
|
+
if (isAnyExpanded) {
|
|
68
|
+
const expandedIndex = reversedToasts.findIndex(t => t.id === expandedToast);
|
|
69
|
+
if (index > expandedIndex) {
|
|
70
|
+
yOffset += 60; // Add extra space for expanded toast
|
|
71
|
+
}
|
|
72
|
+
}
|
|
68
73
|
|
|
69
74
|
return (
|
|
70
75
|
<motion.div
|
|
@@ -74,8 +79,8 @@ export const ToastContainer: React.FC<ToastContainerProps> = ({
|
|
|
74
79
|
animate={{
|
|
75
80
|
opacity: 1,
|
|
76
81
|
x: 0,
|
|
77
|
-
y: position.startsWith('top') ? yOffset
|
|
78
|
-
scale: isExpanded ?
|
|
82
|
+
y: position.startsWith('top') ? yOffset : -yOffset,
|
|
83
|
+
scale: isExpanded ? 1.02 : 1,
|
|
79
84
|
zIndex: isExpanded ? 9999 : 9999 - index
|
|
80
85
|
}}
|
|
81
86
|
exit={{
|
|
@@ -99,7 +104,6 @@ export const ToastContainer: React.FC<ToastContainerProps> = ({
|
|
|
99
104
|
transformOrigin: position.startsWith('top') ? 'top' : 'bottom'
|
|
100
105
|
}}
|
|
101
106
|
onHoverStart={() => setExpandedToast(toast.id)}
|
|
102
|
-
onHoverEnd={() => setExpandedToast(null)}
|
|
103
107
|
drag={swipeDirection === 'left' || swipeDirection === 'right' ? 'x' : 'y'}
|
|
104
108
|
dragConstraints={{ left: 0, right: 0, top: 0, bottom: 0 }}
|
|
105
109
|
dragElastic={0.9}
|
package/src/styles/toast.css
CHANGED
|
@@ -1,156 +1,187 @@
|
|
|
1
|
+
/* Base container styles */
|
|
1
2
|
.vyrn-toast-container {
|
|
2
3
|
position: fixed;
|
|
3
4
|
z-index: 9999;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
gap: 10px;
|
|
7
|
-
max-width: 380px;
|
|
8
|
-
width: 100%;
|
|
5
|
+
max-width: 420px;
|
|
6
|
+
width: calc(100% - 2rem);
|
|
9
7
|
pointer-events: none;
|
|
10
8
|
padding: 1rem;
|
|
11
9
|
box-sizing: border-box;
|
|
10
|
+
perspective: 1000px;
|
|
11
|
+
transform-style: preserve-3d;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
/*
|
|
15
|
-
.vyrn-toast-top-right
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
transform: translateX(-50%);
|
|
14
|
+
/* Container positions with safe area insets */
|
|
15
|
+
.vyrn-toast-top-right {
|
|
16
|
+
top: max(env(safe-area-inset-top, 0px), 1rem);
|
|
17
|
+
right: max(env(safe-area-inset-right, 0px), 1rem);
|
|
18
|
+
transform-origin: top right;
|
|
20
19
|
}
|
|
21
|
-
.vyrn-toast-top-right, .vyrn-toast-top-left, .vyrn-toast-top-center { top: 1rem; }
|
|
22
|
-
.vyrn-toast-bottom-right, .vyrn-toast-bottom-left, .vyrn-toast-bottom-center { bottom: 1rem; }
|
|
23
20
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
padding: 12px 16px;
|
|
29
|
-
border-radius: 8px;
|
|
30
|
-
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
|
31
|
-
background: #fff;
|
|
32
|
-
overflow: hidden;
|
|
33
|
-
position: relative;
|
|
34
|
-
pointer-events: auto;
|
|
35
|
-
cursor: pointer;
|
|
36
|
-
transition: transform 0.2s ease, box-shadow 0.2s ease;
|
|
37
|
-
will-change: transform, height, opacity;
|
|
38
|
-
backdrop-filter: blur(8px);
|
|
21
|
+
.vyrn-toast-top-left {
|
|
22
|
+
top: max(env(safe-area-inset-top, 0px), 1rem);
|
|
23
|
+
left: max(env(safe-area-inset-left, 0px), 1rem);
|
|
24
|
+
transform-origin: top left;
|
|
39
25
|
}
|
|
40
26
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
z-index: 10000;
|
|
27
|
+
.vyrn-toast-bottom-right {
|
|
28
|
+
bottom: max(env(safe-area-inset-bottom, 0px), 1rem);
|
|
29
|
+
right: max(env(safe-area-inset-right, 0px), 1rem);
|
|
30
|
+
transform-origin: bottom right;
|
|
46
31
|
}
|
|
47
32
|
|
|
48
|
-
.vyrn-toast-
|
|
49
|
-
|
|
50
|
-
|
|
33
|
+
.vyrn-toast-bottom-left {
|
|
34
|
+
bottom: max(env(safe-area-inset-bottom, 0px), 1rem);
|
|
35
|
+
left: max(env(safe-area-inset-left, 0px), 1rem);
|
|
36
|
+
transform-origin: bottom left;
|
|
51
37
|
}
|
|
52
38
|
|
|
53
|
-
.vyrn-toast-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
/* Rest of the existing styles remain unchanged */
|
|
60
|
-
.vyrn-toast-icon {
|
|
61
|
-
flex-shrink: 0;
|
|
62
|
-
margin-right: 12px;
|
|
63
|
-
width: 20px;
|
|
64
|
-
height: 20px;
|
|
39
|
+
.vyrn-toast-top-center {
|
|
40
|
+
top: max(env(safe-area-inset-top, 0px), 1rem);
|
|
41
|
+
left: 50%;
|
|
42
|
+
transform: translateX(-50%);
|
|
43
|
+
transform-origin: top center;
|
|
65
44
|
}
|
|
66
45
|
|
|
67
|
-
.vyrn-toast-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
46
|
+
.vyrn-toast-bottom-center {
|
|
47
|
+
bottom: max(env(safe-area-inset-bottom, 0px), 1rem);
|
|
48
|
+
left: 50%;
|
|
49
|
+
transform: translateX(-50%);
|
|
50
|
+
transform-origin: bottom center;
|
|
71
51
|
}
|
|
72
52
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
53
|
+
/* Enhanced toast item styles */
|
|
54
|
+
.vyrn-toast {
|
|
55
|
+
pointer-events: auto;
|
|
56
|
+
position: relative;
|
|
57
|
+
margin-bottom: 0.75rem;
|
|
58
|
+
transform: translateZ(0);
|
|
59
|
+
backface-visibility: hidden;
|
|
60
|
+
-webkit-font-smoothing: subpixel-antialiased;
|
|
80
61
|
}
|
|
81
62
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
white-space: nowrap;
|
|
86
|
-
overflow: hidden;
|
|
87
|
-
text-overflow: ellipsis;
|
|
88
|
-
transition: white-space 0.2s ease;
|
|
63
|
+
/* Custom scrollbar for container */
|
|
64
|
+
.vyrn-toast-container::-webkit-scrollbar {
|
|
65
|
+
width: 6px;
|
|
89
66
|
}
|
|
90
67
|
|
|
91
|
-
.vyrn-toast-
|
|
92
|
-
|
|
93
|
-
margin-top: 4px;
|
|
94
|
-
opacity: 0.8;
|
|
95
|
-
max-height: 0;
|
|
96
|
-
overflow: hidden;
|
|
97
|
-
transition: max-height 0.3s ease, opacity 0.3s ease;
|
|
68
|
+
.vyrn-toast-container::-webkit-scrollbar-track {
|
|
69
|
+
background: transparent;
|
|
98
70
|
}
|
|
99
71
|
|
|
100
|
-
.vyrn-toast-
|
|
101
|
-
background:
|
|
102
|
-
border:
|
|
103
|
-
|
|
104
|
-
cursor: pointer;
|
|
105
|
-
opacity: 0.7;
|
|
106
|
-
transition: opacity 0.2s;
|
|
107
|
-
padding: 0;
|
|
108
|
-
display: flex;
|
|
109
|
-
align-items: center;
|
|
110
|
-
justify-content: center;
|
|
72
|
+
.vyrn-toast-container::-webkit-scrollbar-thumb {
|
|
73
|
+
background-color: rgba(0, 0, 0, 0.2);
|
|
74
|
+
border-radius: 3px;
|
|
75
|
+
border: 2px solid transparent;
|
|
111
76
|
}
|
|
112
77
|
|
|
113
|
-
|
|
78
|
+
/* Toast stacking effect */
|
|
79
|
+
.vyrn-toast-container > div {
|
|
80
|
+
transform: scale(1);
|
|
114
81
|
opacity: 1;
|
|
82
|
+
filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.1));
|
|
83
|
+
transition: all 0.2s cubic-bezier(0.68, -0.55, 0.265, 1.55);
|
|
115
84
|
}
|
|
116
85
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
padding: 4px 8px;
|
|
124
|
-
border-radius: 4px;
|
|
125
|
-
transition: background-color 0.2s;
|
|
86
|
+
/* Stacking animation for multiple toasts */
|
|
87
|
+
.vyrn-toast-container > div:not(:first-child) {
|
|
88
|
+
margin-top: -0.5rem;
|
|
89
|
+
transform: scale(0.95) translateY(5px);
|
|
90
|
+
opacity: 0.95;
|
|
91
|
+
z-index: -1;
|
|
126
92
|
}
|
|
127
93
|
|
|
128
|
-
.vyrn-toast-
|
|
129
|
-
|
|
94
|
+
.vyrn-toast-container > div:not(:first-child):not(:nth-child(2)) {
|
|
95
|
+
transform: scale(0.9) translateY(10px);
|
|
96
|
+
opacity: 0.9;
|
|
97
|
+
z-index: -2;
|
|
130
98
|
}
|
|
131
99
|
|
|
132
|
-
|
|
133
|
-
.vyrn-toast-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
.vyrn-toast-progress {
|
|
138
|
-
position: absolute;
|
|
139
|
-
bottom: 0;
|
|
140
|
-
left: 0;
|
|
141
|
-
height: 3px;
|
|
142
|
-
background-color: rgba(0, 0, 0, 0.2);
|
|
100
|
+
/* Hover effects for stacked toasts */
|
|
101
|
+
.vyrn-toast-container:hover > div:not(:first-child) {
|
|
102
|
+
transform: scale(0.98) translateY(0);
|
|
103
|
+
opacity: 1;
|
|
143
104
|
}
|
|
144
105
|
|
|
106
|
+
/* Mobile optimizations */
|
|
107
|
+
@media (max-width: 640px) {
|
|
108
|
+
.vyrn-toast-container {
|
|
109
|
+
max-width: calc(100vw - 2rem);
|
|
110
|
+
padding: 0.5rem;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
.vyrn-toast {
|
|
114
|
+
margin-bottom: 0.5rem;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/* Adjust positioning for mobile safe areas */
|
|
118
|
+
.vyrn-toast-bottom-center,
|
|
119
|
+
.vyrn-toast-bottom-left,
|
|
120
|
+
.vyrn-toast-bottom-right {
|
|
121
|
+
bottom: max(env(safe-area-inset-bottom, 0px), 0.5rem);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/* Reduced motion preferences */
|
|
126
|
+
@media (prefers-reduced-motion: reduce) {
|
|
127
|
+
.vyrn-toast-container > div {
|
|
128
|
+
transition: none;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/* Dark mode enhancements */
|
|
133
|
+
@media (prefers-color-scheme: dark) {
|
|
134
|
+
.vyrn-toast-container > div {
|
|
135
|
+
filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.3));
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/* Glass effect for modern browsers */
|
|
140
|
+
@supports (backdrop-filter: blur(10px)) {
|
|
141
|
+
.vyrn-toast-container::before {
|
|
142
|
+
content: '';
|
|
143
|
+
position: absolute;
|
|
144
|
+
inset: 0;
|
|
145
|
+
backdrop-filter: blur(8px);
|
|
146
|
+
-webkit-backdrop-filter: blur(8px);
|
|
147
|
+
z-index: -1;
|
|
148
|
+
opacity: 0;
|
|
149
|
+
transition: opacity 0.3s ease;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
.vyrn-toast-container:hover::before {
|
|
153
|
+
opacity: 1;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/* Animation keyframes for enter/exit */
|
|
145
158
|
@keyframes vyrnSlideIn {
|
|
146
|
-
from {
|
|
147
|
-
|
|
159
|
+
from {
|
|
160
|
+
transform: translateY(20px) scale(0.95);
|
|
161
|
+
opacity: 0;
|
|
162
|
+
}
|
|
163
|
+
to {
|
|
164
|
+
transform: translateY(0) scale(1);
|
|
165
|
+
opacity: 1;
|
|
166
|
+
}
|
|
148
167
|
}
|
|
149
168
|
|
|
150
|
-
@keyframes
|
|
151
|
-
from {
|
|
152
|
-
|
|
169
|
+
@keyframes vyrnSlideOut {
|
|
170
|
+
from {
|
|
171
|
+
transform: translateY(0) scale(1);
|
|
172
|
+
opacity: 1;
|
|
173
|
+
}
|
|
174
|
+
to {
|
|
175
|
+
transform: translateY(-20px) scale(0.95);
|
|
176
|
+
opacity: 0;
|
|
177
|
+
}
|
|
153
178
|
}
|
|
154
179
|
|
|
155
|
-
|
|
156
|
-
.vyrn-toast-
|
|
180
|
+
/* Toast animations */
|
|
181
|
+
.vyrn-toast-enter {
|
|
182
|
+
animation: vyrnSlideIn 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
.vyrn-toast-exit {
|
|
186
|
+
animation: vyrnSlideOut 0.2s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards;
|
|
187
|
+
}
|