@tenedev/toast 1.0.0 → 1.0.1
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/toast.js +1 -1
- package/dist/toast.js.map +1 -1
- package/dist/toast.mjs +1 -1
- package/dist/toast.mjs.map +1 -1
- package/package.json +1 -1
package/dist/toast.mjs
CHANGED
@@ -16,5 +16,5 @@ import{jsx as t,Fragment as e,jsxs as n}from"react/jsx-runtime";import*as i from
|
|
16
16
|
*
|
17
17
|
* This source code is licensed under the ISC license.
|
18
18
|
* See the LICENSE file in the root directory of this source tree.
|
19
|
-
*/function ja(e){var i=e.position,s=void 0===i?"bottom-right":i,r=e.closeButton,a=void 0!==r&&r,l=e.gap,c=void 0===l?
|
19
|
+
*/function ja(e){var i=e.position,s=void 0===i?"bottom-right":i,r=e.closeButton,a=void 0!==r&&r,l=e.gap,c=void 0===l?5:l,d=e.duration,p=void 0===d?4e3:d,m=e.richColors,v=void 0!==m&&m,g=f([]),y=g[0],x=g[1],P=o(new Map),T=u((function(t){x((function(e){return e.filter((function(e){return e.id!==t}))})),P.current.has(t)&&(clearTimeout(P.current.get(t)),P.current.delete(t))}),[]),b=u((function(t,e){var n=Date.now();x((function(i){return w(w([],i,!0),[{id:n,message:t,description:null==e?void 0:e.description,type:null==e?void 0:e.type}],!1)}));var i=setTimeout((function(){T(n)}),p);P.current.set(n,i)}),[T]);h((function(){return S.setAddToast(b),function(){P.current.forEach((function(t){return clearTimeout(t)})),P.current.clear(),x([])}}),[b]);var A={top:{initial:{y:"-50%",opacity:0},exit:{y:"-50%",opacity:0},animate:{y:0,opacity:1}},bottom:{initial:{y:"50%",opacity:0},exit:{y:"50%",opacity:0},animate:{y:0,opacity:1}}},E=s.includes("top")?A.top:A.bottom,V=function(t,e){if(!t)return"";return{success:"text-green-500",error:"text-red-500",info:"text-blue-500",warning:"text-yellow-500"}[e]||""},M=function(e){switch(e){case"success":return t(ka,{className:"mr-2 w-5"});case"error":return t(Da,{className:"mr-2 w-5"});case"info":return t(Ra,{className:"mr-2 w-5"});case"warning":return t(La,{className:"mr-2 w-5"});default:return null}};return t("div",{style:{gap:"".concat(c,"px"),zIndex:1e3},className:"fixed mx-auto flex w-full min-w-[5%] flex-col sm:max-w-[50%] md:max-w-[30%] ".concat({"top-left":"top-2 left-2","top-mid":"top-2 left-1/2 -translate-x-1/2","top-right":"top-2 right-2","bottom-left":"bottom-2 left-4 flex-col-reverse","bottom-mid":"bottom-2 left-1/2 -translate-x-1/2 flex-col-reverse","bottom-right":"bottom-2 right-2 flex-col-reverse"}[s]),children:t(O,{children:y.slice().reverse().map((function(e){return n(Aa.div,{initial:E.initial,exit:E.exit,animate:E.animate,transition:{type:"spring",duration:.5,stiffness:200,damping:20},className:"relative flex min-h-14 flex-col content-center justify-center rounded-lg border border-zinc-700 p-2 font-medium ".concat(e.type?V(v,e.type):"bg-[#F5F5F5]"),children:[a&&t("span",{className:"absolute top-1 right-0 cursor-pointer text-black",onClick:function(){return T(e.id)},children:t(Ba,{className:"w-5"})}),n("div",{className:"flex items-center",children:[e.type&&M(e.type),e.message]})]},e.id)}))})})}export{ja as Toaster,S as toast};
|
20
20
|
//# sourceMappingURL=toast.mjs.map
|