echo-toast 1.0.2 → 1.0.4
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/README.md +1 -1
- package/dist/echo-toast.css +2 -0
- package/dist/echo-toast.d.ts +0 -4
- package/dist/echo-toast.js +76 -113
- package/package.json +8 -4
package/README.md
CHANGED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
@keyframes echoLibEnterAnimation{0%{opacity:0}to{opacity:1}}@keyframes echoLibExitAnimation{0%{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.9)}}.echo-lib-enter{animation:.6s ease-out forwards echoLibEnterAnimation}.echo-lib-fade-out{animation:.5s forwards echoLibExitAnimation}
|
|
2
|
+
/*$vite$:1*/
|
package/dist/echo-toast.d.ts
CHANGED
|
@@ -17,10 +17,6 @@ declare interface IToast {
|
|
|
17
17
|
icon?: React.ElementType;
|
|
18
18
|
closeButton?: boolean;
|
|
19
19
|
border?: boolean;
|
|
20
|
-
duration?: {
|
|
21
|
-
animation?: number;
|
|
22
|
-
notification?: number;
|
|
23
|
-
};
|
|
24
20
|
swipe?: boolean;
|
|
25
21
|
swipeDirection?: 'left' | 'right';
|
|
26
22
|
deleteToast?: () => void;
|
package/dist/echo-toast.js
CHANGED
|
@@ -1,22 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { useEffect as s, useState as c } from "react";
|
|
1
|
+
import { Check as e, Info as t, LoaderCircle as n, ShieldAlert as r, X as i } from "lucide-react";
|
|
2
|
+
import { useEffect as a, useLayoutEffect as o, useRef as s, useState as c } from "react";
|
|
4
3
|
import { jsx as l, jsxs as u } from "react/jsx-runtime";
|
|
5
|
-
|
|
6
|
-
var d = Object.defineProperty, f = Object.getOwnPropertyDescriptor, p = Object.getOwnPropertyNames, m = Object.prototype.hasOwnProperty, h = (e, t) => {
|
|
7
|
-
let n = {};
|
|
8
|
-
for (var r in e) d(n, r, {
|
|
9
|
-
get: e[r],
|
|
10
|
-
enumerable: !0
|
|
11
|
-
});
|
|
12
|
-
return t || d(n, Symbol.toStringTag, { value: "Module" }), n;
|
|
13
|
-
}, g = (e, t, n, r) => {
|
|
14
|
-
if (t && typeof t == "object" || typeof t == "function") for (var i = p(t), a = 0, o = i.length, s; a < o; a++) s = i[a], !m.call(e, s) && s !== n && d(e, s, {
|
|
15
|
-
get: ((e) => t[e]).bind(null, s),
|
|
16
|
-
enumerable: !(r = f(t, s)) || r.enumerable
|
|
17
|
-
});
|
|
18
|
-
return e;
|
|
19
|
-
}, _ = (e, t, n) => (g(e, t, "default"), n && g(n, t, "default")), v = new class {
|
|
4
|
+
var d = new class {
|
|
20
5
|
observers = [];
|
|
21
6
|
counter = 0;
|
|
22
7
|
subscribe(e) {
|
|
@@ -30,15 +15,7 @@ var d = Object.defineProperty, f = Object.getOwnPropertyDescriptor, p = Object.g
|
|
|
30
15
|
id: this.counter
|
|
31
16
|
}));
|
|
32
17
|
}
|
|
33
|
-
}(),
|
|
34
|
-
m: () => e,
|
|
35
|
-
motion: () => t
|
|
36
|
-
});
|
|
37
|
-
import * as b from "framer-motion";
|
|
38
|
-
_(y, b);
|
|
39
|
-
//#endregion
|
|
40
|
-
//#region lib/static/static.ts
|
|
41
|
-
var x = {
|
|
18
|
+
}(), f = {
|
|
42
19
|
left: {
|
|
43
20
|
up: {
|
|
44
21
|
left: 16,
|
|
@@ -87,12 +64,12 @@ var x = {
|
|
|
87
64
|
bottom: 16
|
|
88
65
|
}
|
|
89
66
|
}
|
|
90
|
-
},
|
|
67
|
+
}, p = {
|
|
91
68
|
borderRadius: 8,
|
|
92
69
|
boxShadow: "0px 0px 4px #efefef",
|
|
93
70
|
maxWidth: "350px",
|
|
94
71
|
width: "calc(100vw - 40px)"
|
|
95
|
-
},
|
|
72
|
+
}, m = {
|
|
96
73
|
blank: {
|
|
97
74
|
backgroundColor: "#e5e7eb",
|
|
98
75
|
color: "#4b5563"
|
|
@@ -117,7 +94,7 @@ var x = {
|
|
|
117
94
|
backgroundColor: "#1e3a8a",
|
|
118
95
|
color: "white"
|
|
119
96
|
}
|
|
120
|
-
},
|
|
97
|
+
}, h = {
|
|
121
98
|
blank: {
|
|
122
99
|
backgroundColor: "#ffffff",
|
|
123
100
|
border: "1px solid #eeeff1"
|
|
@@ -142,115 +119,107 @@ var x = {
|
|
|
142
119
|
backgroundColor: "#dbeafe",
|
|
143
120
|
border: "1px solid #ddd6fe"
|
|
144
121
|
}
|
|
145
|
-
},
|
|
122
|
+
}, g = {
|
|
146
123
|
blank: "#1f2937",
|
|
147
124
|
loading: "#1f2937",
|
|
148
125
|
succesful: "#166534",
|
|
149
126
|
error: "#b91c1c",
|
|
150
127
|
warning: "#ea580c",
|
|
151
128
|
info: "#1e3a8a"
|
|
152
|
-
},
|
|
153
|
-
loading:
|
|
154
|
-
succesful:
|
|
155
|
-
error:
|
|
156
|
-
warning:
|
|
157
|
-
info:
|
|
129
|
+
}, _ = {
|
|
130
|
+
loading: n,
|
|
131
|
+
succesful: e,
|
|
132
|
+
error: i,
|
|
133
|
+
warning: r,
|
|
134
|
+
info: t,
|
|
158
135
|
blank: void 0
|
|
159
136
|
};
|
|
160
137
|
//#endregion
|
|
161
138
|
//#region lib/components/Toast.tsx
|
|
162
|
-
function
|
|
163
|
-
let [
|
|
164
|
-
...
|
|
165
|
-
...
|
|
139
|
+
function v({ type: e = "blank", label: t, icon: n, action: r, closeButton: d = !0, title: f, swipe: v = !0, swipeDirection: y = "right", deleteToast: b }) {
|
|
140
|
+
let x = s(null), S = s(null), [C, w] = c(0), [T, E] = c(!1), D = _[e] && e !== "blank" ? _[e] : n || void 0, O = {
|
|
141
|
+
...p,
|
|
142
|
+
...h[e]
|
|
143
|
+
}, k = (e) => {
|
|
144
|
+
e.currentTarget.setPointerCapture(e.pointerId), w(e.clientX);
|
|
166
145
|
};
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
let t = h - e.clientX;
|
|
191
|
-
Math.abs(t) > 100 && (t < 0 && p === "right" && m && m(), t > 0 && p === "left" && m && m());
|
|
192
|
-
} : void 0,
|
|
193
|
-
style: v,
|
|
146
|
+
function A() {
|
|
147
|
+
S?.current?.classList.remove("echo-lib-enter"), S?.current?.classList.add("echo-lib-fade-out"), E(!0), x.current && clearTimeout(x.current);
|
|
148
|
+
}
|
|
149
|
+
let j = (e) => {
|
|
150
|
+
let t = C - e.clientX;
|
|
151
|
+
Math.abs(t) > 100 && (t < 0 && y === "right" && A(), t > 0 && y === "left" && A());
|
|
152
|
+
};
|
|
153
|
+
o(() => {
|
|
154
|
+
S.current && S.current.classList.add("echo-lib-enter");
|
|
155
|
+
}, []), a(() => (x.current = setTimeout(() => {
|
|
156
|
+
S.current && (S.current.classList.remove("echo-lib-enter"), S.current.classList.add("echo-lib-fade-out"), E(!0));
|
|
157
|
+
}, 5e3), () => {
|
|
158
|
+
x.current && clearTimeout(x.current);
|
|
159
|
+
}), []);
|
|
160
|
+
function M() {
|
|
161
|
+
T && b();
|
|
162
|
+
}
|
|
163
|
+
return /* @__PURE__ */ l("section", {
|
|
164
|
+
onPointerDown: v ? k : void 0,
|
|
165
|
+
onPointerUp: v ? j : void 0,
|
|
166
|
+
onAnimationEnd: M,
|
|
167
|
+
style: O,
|
|
168
|
+
ref: S,
|
|
194
169
|
children: /* @__PURE__ */ u("section", {
|
|
195
170
|
style: {
|
|
196
171
|
position: "relative",
|
|
197
172
|
paddingLeft: "1rem",
|
|
198
173
|
paddingTop: "0.8rem",
|
|
199
|
-
paddingRight:
|
|
174
|
+
paddingRight: r ? d ? "2.5Arem" : "1rem" : "8rem",
|
|
200
175
|
paddingBottom: "0.8rem",
|
|
201
176
|
display: "flex",
|
|
202
177
|
alignItems: "center",
|
|
203
178
|
gap: 16
|
|
204
179
|
},
|
|
205
180
|
children: [
|
|
206
|
-
|
|
181
|
+
D && D !== void 0 && /* @__PURE__ */ l("section", {
|
|
207
182
|
style: {
|
|
208
183
|
display: "flex",
|
|
209
184
|
alignItems: "center"
|
|
210
185
|
},
|
|
211
|
-
|
|
212
|
-
transition: e === "loading" ? {
|
|
213
|
-
repeat: Infinity,
|
|
214
|
-
duration: 1,
|
|
215
|
-
ease: "linear"
|
|
216
|
-
} : {},
|
|
217
|
-
children: /* @__PURE__ */ l(_, {
|
|
186
|
+
children: /* @__PURE__ */ l(D, {
|
|
218
187
|
size: 18,
|
|
219
|
-
color:
|
|
188
|
+
color: g[e]
|
|
220
189
|
})
|
|
221
190
|
}),
|
|
222
191
|
/* @__PURE__ */ u("section", {
|
|
223
192
|
style: {
|
|
224
193
|
display: "flex",
|
|
225
|
-
flexDirection:
|
|
194
|
+
flexDirection: r ? "row" : "column",
|
|
226
195
|
alignItems: "center",
|
|
227
196
|
justifyContent: "space-between",
|
|
228
197
|
gap: 16
|
|
229
198
|
},
|
|
230
|
-
children: [/* @__PURE__ */ u("section", { children: [
|
|
199
|
+
children: [/* @__PURE__ */ u("section", { children: [f && /* @__PURE__ */ l("p", {
|
|
231
200
|
style: {
|
|
232
201
|
fontFamily: "Inter, system-ui, -apple-system, sans-serif",
|
|
233
202
|
fontSize: "0.9rem",
|
|
234
203
|
fontWeight: 700,
|
|
235
204
|
marginBottom: "4px",
|
|
236
205
|
marginTop: "0px",
|
|
237
|
-
color:
|
|
206
|
+
color: g[e]
|
|
238
207
|
},
|
|
239
|
-
children:
|
|
208
|
+
children: f
|
|
240
209
|
}), /* @__PURE__ */ l("p", {
|
|
241
210
|
style: {
|
|
242
211
|
fontFamily: "Inter, system-ui, -apple-system, sans-serif",
|
|
243
212
|
fontSize: "0.8rem",
|
|
244
213
|
marginTop: "0px",
|
|
245
214
|
marginBottom: "0px",
|
|
246
|
-
color:
|
|
215
|
+
color: g[e]
|
|
247
216
|
},
|
|
248
|
-
children:
|
|
249
|
-
})] }),
|
|
250
|
-
onClick:
|
|
217
|
+
children: t
|
|
218
|
+
})] }), r && /* @__PURE__ */ l("button", {
|
|
219
|
+
onClick: r.onClick,
|
|
251
220
|
style: {
|
|
252
221
|
border: "none",
|
|
253
|
-
backgroundColor:
|
|
222
|
+
backgroundColor: m[e].backgroundColor,
|
|
254
223
|
paddingTop: "0.4rem",
|
|
255
224
|
paddingBottom: "0.4rem",
|
|
256
225
|
paddingLeft: "0.8rem",
|
|
@@ -260,16 +229,16 @@ function D({ type: e = "blank", label: n, icon: r, action: i, closeButton: a = !
|
|
|
260
229
|
fontFamily: "Inter, system-ui, -apple-system, sans-serif",
|
|
261
230
|
cursor: "pointer",
|
|
262
231
|
fontWeight: 600,
|
|
263
|
-
color:
|
|
232
|
+
color: m[e].color
|
|
264
233
|
},
|
|
265
|
-
children:
|
|
234
|
+
children: r.label
|
|
266
235
|
})]
|
|
267
236
|
}),
|
|
268
|
-
|
|
237
|
+
d && /* @__PURE__ */ l("button", {
|
|
269
238
|
style: {
|
|
270
239
|
background: "transparent",
|
|
271
240
|
border: "0px",
|
|
272
|
-
color:
|
|
241
|
+
color: g[e],
|
|
273
242
|
position: "absolute",
|
|
274
243
|
top: 8,
|
|
275
244
|
right: 8,
|
|
@@ -277,9 +246,9 @@ function D({ type: e = "blank", label: n, icon: r, action: i, closeButton: a = !
|
|
|
277
246
|
zIndex: 10
|
|
278
247
|
},
|
|
279
248
|
onPointerDown: (e) => {
|
|
280
|
-
|
|
249
|
+
e.stopPropagation(), A();
|
|
281
250
|
},
|
|
282
|
-
children: /* @__PURE__ */ l(
|
|
251
|
+
children: /* @__PURE__ */ l(i, { size: 18 })
|
|
283
252
|
})
|
|
284
253
|
]
|
|
285
254
|
})
|
|
@@ -287,45 +256,39 @@ function D({ type: e = "blank", label: n, icon: r, action: i, closeButton: a = !
|
|
|
287
256
|
}
|
|
288
257
|
//#endregion
|
|
289
258
|
//#region lib/hooks/useToaster.tsx
|
|
290
|
-
function
|
|
259
|
+
function y(e) {
|
|
291
260
|
let [t, n] = c([]);
|
|
292
|
-
return
|
|
293
|
-
let t =
|
|
294
|
-
function
|
|
295
|
-
n((t) => t.filter((t) => t.id !== e.id))
|
|
261
|
+
return a(() => {
|
|
262
|
+
let t = e.subscribe((e) => {
|
|
263
|
+
function t() {
|
|
264
|
+
n((t) => t.filter((t) => t.id !== e.id));
|
|
296
265
|
}
|
|
297
|
-
n((
|
|
266
|
+
n((n) => [...n, {
|
|
298
267
|
...e,
|
|
299
|
-
deleteToast:
|
|
268
|
+
deleteToast: t
|
|
300
269
|
}]);
|
|
301
|
-
let i = setTimeout(() => {
|
|
302
|
-
r();
|
|
303
|
-
}, 5e3);
|
|
304
|
-
t.push(i);
|
|
305
270
|
});
|
|
306
271
|
return () => {
|
|
307
|
-
|
|
308
|
-
e && clearTimeout(e);
|
|
309
|
-
});
|
|
272
|
+
t();
|
|
310
273
|
};
|
|
311
274
|
}, [e]), t;
|
|
312
275
|
}
|
|
313
276
|
//#endregion
|
|
314
277
|
//#region lib/components/Toaster.tsx
|
|
315
|
-
function
|
|
316
|
-
let n =
|
|
278
|
+
function b({ positionX: e = "right", positionY: t = "bottom" }) {
|
|
279
|
+
let n = y(d);
|
|
317
280
|
return /* @__PURE__ */ l("section", {
|
|
318
281
|
style: {
|
|
319
282
|
position: "fixed",
|
|
320
283
|
display: "grid",
|
|
321
284
|
gap: 8,
|
|
322
|
-
...
|
|
285
|
+
...f[e][t]
|
|
323
286
|
},
|
|
324
|
-
children:
|
|
287
|
+
children: n.filter((e, t) => t < 5).map((e) => /* @__PURE__ */ l(v, { ...e }, e.id))
|
|
325
288
|
});
|
|
326
289
|
}
|
|
327
290
|
//#endregion
|
|
328
291
|
//#region lib/main.ts
|
|
329
|
-
var
|
|
292
|
+
var x = { notify: d.notify.bind(d) };
|
|
330
293
|
//#endregion
|
|
331
|
-
export {
|
|
294
|
+
export { b as Toaster, x as echo };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "echo-toast",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.4",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/echo-toast.js",
|
|
7
7
|
"module": "./dist/echo-toast.js",
|
|
@@ -11,17 +11,20 @@
|
|
|
11
11
|
"build": "tsc -b ./tsconfig.lib.json && vite build",
|
|
12
12
|
"lint": "eslint .",
|
|
13
13
|
"preview": "vite preview",
|
|
14
|
-
"prepublishOnly": "npm run build"
|
|
14
|
+
"prepublishOnly": "npm run build",
|
|
15
|
+
"storybook": "storybook dev -p 6006",
|
|
16
|
+
"build-storybook": "storybook build"
|
|
15
17
|
},
|
|
16
18
|
"peerDependencies": {
|
|
17
19
|
"lucide-react": "^1.3.0",
|
|
18
|
-
"motion": "^12.0.0",
|
|
19
20
|
"react": "^18.0.0 || ^19.0.0",
|
|
20
21
|
"react-dom": "^18.0.0 || ^19.0.0"
|
|
21
22
|
},
|
|
22
23
|
"devDependencies": {
|
|
23
24
|
"@eslint/js": "^10.0.1",
|
|
24
25
|
"@microsoft/api-extractor": "^7.58.7",
|
|
26
|
+
"@storybook/addon-docs": "^10.3.6",
|
|
27
|
+
"@storybook/react-vite": "^10.3.6",
|
|
25
28
|
"@types/node": "^24.12.2",
|
|
26
29
|
"@types/react": "^19.2.14",
|
|
27
30
|
"@types/react-dom": "^19.2.3",
|
|
@@ -29,11 +32,12 @@
|
|
|
29
32
|
"eslint": "^10.2.1",
|
|
30
33
|
"eslint-plugin-react-hooks": "^7.1.1",
|
|
31
34
|
"eslint-plugin-react-refresh": "^0.5.2",
|
|
35
|
+
"eslint-plugin-storybook": "^10.3.6",
|
|
32
36
|
"globals": "^17.5.0",
|
|
33
37
|
"lucide-react": "^1.3.0",
|
|
34
|
-
"motion": "^12.38.0",
|
|
35
38
|
"react": "^19.2.5",
|
|
36
39
|
"react-dom": "^19.2.5",
|
|
40
|
+
"storybook": "^10.3.6",
|
|
37
41
|
"typescript": "~6.0.2",
|
|
38
42
|
"typescript-eslint": "^8.58.2",
|
|
39
43
|
"unplugin-dts": "^1.0.0",
|