aura-toast 1.5.0 → 1.6.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/aura-toast.cjs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var yt=Object.defineProperty;var mt=(a,r,i)=>r in a?yt(a,r,{enumerable:!0,configurable:!0,writable:!0,value:i}):a[r]=i;var W=(a,r,i)=>(mt(a,typeof r!="symbol"?r+"":r,i),i);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const D=require("
|
|
1
|
+
"use strict";var yt=Object.defineProperty;var mt=(a,r,i)=>r in a?yt(a,r,{enumerable:!0,configurable:!0,writable:!0,value:i}):a[r]=i;var W=(a,r,i)=>(mt(a,typeof r!="symbol"?r+"":r,i),i);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const D=require("react"),Fe=5;class gt{constructor(){W(this,"state",[]);W(this,"listeners",new Set);W(this,"timeouts",new Map);W(this,"startTimes",new Map);W(this,"remainingDurations",new Map)}getState(){return this.state}subscribe(r){return this.listeners.add(r),()=>this.listeners.delete(r)}notify(){this.listeners.forEach(r=>r(this.state))}isDuplicate(r){return this.state.some(i=>i.title===r.title&&(i.type||"info")===(r.type||"info")&&i.description===r.description&&i.glassy===r.glassy)}show(r){if(this.isDuplicate(r)){const h=this.state.find(x=>x.title===r.title&&(x.type||"info")===(r.type||"info")&&x.description===r.description&&x.glassy===r.glassy);if(h&&h.id){const x=r.duration??4e3;x>0&&(this.startTimes.set(h.id,Date.now()),this.remainingDurations.set(h.id,x),this.startTimer(h.id,x))}return}const i=r.id||Math.random().toString(36).substring(2,9),c=r.duration??4e3,E={...r,id:i,type:r.type||"info",duration:c};if(this.state=[E,...this.state],this.state.length>Fe){const h=this.state[this.state.length-1];h&&h.id&&this.clearTimerData(h.id),this.state=this.state.slice(0,Fe)}this.notify(),c>0&&(this.startTimes.set(i,Date.now()),this.remainingDurations.set(i,c),this.startTimer(i,c))}startTimer(r,i){this.timeouts.has(r)&&clearTimeout(this.timeouts.get(r));const c=setTimeout(()=>{this.dismiss(r)},i);this.timeouts.set(r,c)}clearTimerData(r){this.timeouts.has(r)&&(clearTimeout(this.timeouts.get(r)),this.timeouts.delete(r)),this.startTimes.delete(r),this.remainingDurations.delete(r)}pause(){this.state.forEach(r=>{const i=r.id;if(this.timeouts.has(i)&&this.startTimes.has(i)){clearTimeout(this.timeouts.get(i)),this.timeouts.delete(i);const c=this.startTimes.get(i),E=Date.now()-c,h=this.remainingDurations.get(i)||0;this.remainingDurations.set(i,Math.max(0,h-E)),this.startTimes.delete(i)}})}resume(){this.state.forEach(r=>{const i=r.id,c=this.remainingDurations.get(i);!this.timeouts.has(i)&&c!==void 0&&c>0&&(this.startTimes.set(i,Date.now()),this.startTimer(i,c))})}dismiss(r){r?(this.clearTimerData(r),this.state=this.state.filter(i=>i.id!==r)):(this.timeouts.forEach(i=>clearTimeout(i)),this.timeouts.clear(),this.startTimes.clear(),this.remainingDurations.clear(),this.state=[]),this.notify()}}const w=new gt,fe={success:(a,r)=>{const i=typeof a=="string"?{...r,title:a}:{...r,...a};return w.show({...i,type:"success"})},error:(a,r)=>{const i=typeof a=="string"?{...r,title:a}:{...r,...a};return w.show({...i,type:"error"})},info:(a,r)=>{const i=typeof a=="string"?{...r,title:a}:{...r,...a};return w.show({...i,type:"info"})},warning:(a,r)=>{const i=typeof a=="string"?{...r,title:a}:{...r,...a};return w.show({...i,type:"warning"})},promise:(a,r,i)=>{const c=(i==null?void 0:i.id)||Math.random().toString(36).substring(2,9),E=typeof r.loading=="string"?{...i,title:r.loading}:{...i,...r.loading};return w.show({...E,id:c,type:"loading",duration:0}),a.then(()=>{w.dismiss(c);const h=typeof r.success=="string"?{...i,title:r.success}:{...i,...r.success};w.show({...h,id:c,type:"success"})}).catch(()=>{w.dismiss(c);const h=typeof r.error=="string"?{...i,title:r.error}:{...i,...r.error};w.show({...h,id:c,type:"error"})}),a},dismiss:a=>w.dismiss(a),pause:()=>w.pause(),resume:()=>w.resume()};var de={exports:{}},V={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* react-jsx-runtime.production.min.js
|
|
4
4
|
*
|
package/dist/aura-toast.es.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var mt = Object.defineProperty;
|
|
2
2
|
var gt = (a, r, i) => r in a ? mt(a, r, { enumerable: !0, configurable: !0, writable: !0, value: i }) : a[r] = i;
|
|
3
3
|
var F = (a, r, i) => (gt(a, typeof r != "symbol" ? r + "" : r, i), i);
|
|
4
|
-
import de, { useState as G, useEffect as Ye } from "
|
|
4
|
+
import de, { useState as G, useEffect as Ye } from "react";
|
|
5
5
|
const Fe = 5;
|
|
6
6
|
class bt {
|
|
7
7
|
constructor() {
|
package/dist/index.d.ts
CHANGED
package/dist/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { default as React } from '
|
|
1
|
+
import { default as React } from 'react';
|
|
2
2
|
|
|
3
3
|
export type ToastType = 'success' | 'error' | 'info' | 'warning' | 'loading';
|
|
4
4
|
export type ToastPosition = 'top-right' | 'top-left' | 'bottom-left' | 'bottom-right' | 'top-center' | 'bottom-center';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aura-toast",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
4
4
|
"homepage": "https://damicode18.github.io/aura-toast/",
|
|
5
5
|
"description": "Premium React toast notifications with glassmorphism design. Lightweight, customizable, and enforces a single-toast constraint for clean UI.",
|
|
6
6
|
"main": "dist/aura-toast.cjs.js",
|