rojeru-toast 1.0.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/LICENCE +21 -0
- package/README.md +318 -0
- package/dist/rojeru-toast.css +460 -0
- package/dist/rojeru-toast.esm.js +1 -0
- package/dist/rojeru-toast.js +1 -0
- package/dist/rojeru-toast.min.css +1 -0
- package/dist/rojeru-toast.min.js +1 -0
- package/package.json +55 -0
- package/src/index.js +569 -0
- package/src/styles.css +457 -0
|
@@ -0,0 +1,460 @@
|
|
|
1
|
+
|
|
2
|
+
/* Tu CSS completo aquí - copia todo el CSS que ya tienes */
|
|
3
|
+
/**
|
|
4
|
+
* Autor: Rogelio Urieta Camacho
|
|
5
|
+
* Alias: RojeruSan
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* rojeru-toast.css - Estilos modernos para la librería de mensajes toast
|
|
9
|
+
* @version 2.6.0
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* MIT License
|
|
13
|
+
*
|
|
14
|
+
* Copyright (c) 2025 Rogelio Urieta Camacho (RojeruSan)
|
|
15
|
+
*
|
|
16
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
17
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
18
|
+
* in the Software without restriction, including without limitation the rights
|
|
19
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
20
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
21
|
+
* furnished to do so, subject to the following conditions:
|
|
22
|
+
*
|
|
23
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
24
|
+
* copies or substantial portions of the Software.
|
|
25
|
+
*
|
|
26
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
27
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
28
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
29
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
30
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
31
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
32
|
+
* SOFTWARE.
|
|
33
|
+
*/
|
|
34
|
+
.rojeru-toast-container {
|
|
35
|
+
position: fixed;
|
|
36
|
+
z-index: 10000;
|
|
37
|
+
pointer-events: none;
|
|
38
|
+
display: flex;
|
|
39
|
+
flex-direction: column;
|
|
40
|
+
gap: 12px;
|
|
41
|
+
max-width: 420px;
|
|
42
|
+
padding: 20px;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.rojeru-toast-container.top-right {
|
|
46
|
+
top: 0;
|
|
47
|
+
right: 0;
|
|
48
|
+
align-items: flex-end;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.rojeru-toast-container.top-left {
|
|
52
|
+
top: 0;
|
|
53
|
+
left: 0;
|
|
54
|
+
align-items: flex-start;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.rojeru-toast-container.top-center {
|
|
58
|
+
top: 0;
|
|
59
|
+
left: 50%;
|
|
60
|
+
transform: translateX(-50%);
|
|
61
|
+
align-items: center;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.rojeru-toast-container.bottom-right {
|
|
65
|
+
bottom: 0;
|
|
66
|
+
right: 0;
|
|
67
|
+
align-items: flex-end;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.rojeru-toast-container.bottom-left {
|
|
71
|
+
bottom: 0;
|
|
72
|
+
left: 0;
|
|
73
|
+
align-items: flex-start;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.rojeru-toast-container.bottom-center {
|
|
77
|
+
bottom: 0;
|
|
78
|
+
left: 50%;
|
|
79
|
+
transform: translateX(-50%);
|
|
80
|
+
align-items: center;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.rojeru-toast {
|
|
84
|
+
pointer-events: all;
|
|
85
|
+
padding: 16px 20px;
|
|
86
|
+
border-radius: 12px;
|
|
87
|
+
backdrop-filter: blur(10px);
|
|
88
|
+
-webkit-backdrop-filter: blur(10px);
|
|
89
|
+
font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
|
90
|
+
font-size: 14px;
|
|
91
|
+
font-weight: 500;
|
|
92
|
+
line-height: 1.5;
|
|
93
|
+
max-width: 380px;
|
|
94
|
+
display: flex;
|
|
95
|
+
align-items: flex-start;
|
|
96
|
+
gap: 12px;
|
|
97
|
+
transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
|
|
98
|
+
position: relative;
|
|
99
|
+
overflow: hidden;
|
|
100
|
+
border: 1px solid;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.rojeru-toast.rojeru-toast-clickable {
|
|
104
|
+
cursor: pointer;
|
|
105
|
+
transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.rojeru-toast.rojeru-toast-clickable:hover {
|
|
109
|
+
transform: translateY(-2px);
|
|
110
|
+
box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
.rojeru-toast.rojeru-toast-clickable:active {
|
|
114
|
+
transform: translateY(0);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.rojeru-toast::before {
|
|
118
|
+
content: '';
|
|
119
|
+
position: absolute;
|
|
120
|
+
top: 0;
|
|
121
|
+
left: 0;
|
|
122
|
+
right: 0;
|
|
123
|
+
height: 1px;
|
|
124
|
+
background: linear-gradient(90deg, transparent, currentColor, transparent);
|
|
125
|
+
opacity: 0.3;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
.rojeru-toast.hiding {
|
|
129
|
+
transform: scale(0.9) translateX(100px);
|
|
130
|
+
opacity: 0;
|
|
131
|
+
pointer-events: none;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/* Light Theme */
|
|
135
|
+
.rojeru-toast.light {
|
|
136
|
+
background: rgba(255, 255, 255, 0.95);
|
|
137
|
+
color: #1a1a1a;
|
|
138
|
+
border-color: rgba(0, 0, 0, 0.1);
|
|
139
|
+
box-shadow:
|
|
140
|
+
0 8px 32px rgba(0, 0, 0, 0.1),
|
|
141
|
+
0 2px 8px rgba(0, 0, 0, 0.05),
|
|
142
|
+
inset 0 1px 0 rgba(255, 255, 255, 0.8);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
.rojeru-toast.light.info { color: #0066CC; }
|
|
146
|
+
.rojeru-toast.light.success { color: #00A86B; }
|
|
147
|
+
.rojeru-toast.light.warning { color: #FF6B00; }
|
|
148
|
+
.rojeru-toast.light.error { color: #FF3B30; }
|
|
149
|
+
.rojeru-toast.light.loading { color: #666666; }
|
|
150
|
+
|
|
151
|
+
/* Dark Theme */
|
|
152
|
+
.rojeru-toast.dark {
|
|
153
|
+
background: rgba(28, 28, 30, 0.95);
|
|
154
|
+
color: #ffffff;
|
|
155
|
+
border-color: rgba(255, 255, 255, 0.1);
|
|
156
|
+
box-shadow:
|
|
157
|
+
0 8px 32px rgba(0, 0, 0, 0.3),
|
|
158
|
+
0 2px 8px rgba(0, 0, 0, 0.2),
|
|
159
|
+
inset 0 1px 0 rgba(255, 255, 255, 0.1);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
.rojeru-toast.dark.info { color: #5AC8FA; }
|
|
163
|
+
.rojeru-toast.dark.success { color: #30D158; }
|
|
164
|
+
.rojeru-toast.dark.warning { color: #FF9F0A; }
|
|
165
|
+
.rojeru-toast.dark.error { color: #FF453A; }
|
|
166
|
+
.rojeru-toast.dark.loading { color: #8E8E93; }
|
|
167
|
+
|
|
168
|
+
/* Colored Theme - Mejorado para mejor contraste */
|
|
169
|
+
.rojeru-toast.colored {
|
|
170
|
+
color: white;
|
|
171
|
+
border: none;
|
|
172
|
+
box-shadow:
|
|
173
|
+
0 8px 32px rgba(0, 0, 0, 0.25),
|
|
174
|
+
0 4px 16px rgba(0, 0, 0, 0.15);
|
|
175
|
+
text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
.rojeru-toast.colored.info {
|
|
179
|
+
background: linear-gradient(135deg, #0055AA, #0077CC);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
.rojeru-toast.colored.success {
|
|
183
|
+
background: linear-gradient(135deg, #008755, #00AA66);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
.rojeru-toast.colored.warning {
|
|
187
|
+
background: linear-gradient(135deg, #CC5500, #EE7700);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
.rojeru-toast.colored.error {
|
|
191
|
+
background: linear-gradient(135deg, #CC2200, #EE4422);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
.rojeru-toast.light.loading.info { color: #0066CC; }
|
|
195
|
+
.rojeru-toast.light.loading.success { color: #00A86B; }
|
|
196
|
+
.rojeru-toast.light.loading.warning { color: #FF6B00; }
|
|
197
|
+
.rojeru-toast.light.loading.error { color: #FF3B30; }
|
|
198
|
+
|
|
199
|
+
/* Dark Theme - Loading con tipos específicos */
|
|
200
|
+
.rojeru-toast.dark.loading.info { color: #5AC8FA; }
|
|
201
|
+
.rojeru-toast.dark.loading.success { color: #30D158; }
|
|
202
|
+
.rojeru-toast.dark.loading.warning { color: #FF9F0A; }
|
|
203
|
+
.rojeru-toast.dark.loading.error { color: #FF453A; }
|
|
204
|
+
|
|
205
|
+
/* Colored Theme - Loading con tipos específicos */
|
|
206
|
+
.rojeru-toast.colored.loading.info {
|
|
207
|
+
background: linear-gradient(135deg, #0055AA, #0077CC);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
.rojeru-toast.colored.loading.success {
|
|
211
|
+
background: linear-gradient(135deg, #008755, #00AA66);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
.rojeru-toast.colored.loading.warning {
|
|
215
|
+
background: linear-gradient(135deg, #CC5500, #EE7700);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
.rojeru-toast.colored.loading.error {
|
|
219
|
+
background: linear-gradient(135deg, #CC2200, #EE4422);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
.rojeru-toast.colored::before {
|
|
223
|
+
background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
.rojeru-toast.colored .rojeru-toast-close {
|
|
227
|
+
background: rgba(255, 255, 255, 0.25);
|
|
228
|
+
color: white;
|
|
229
|
+
text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
.rojeru-toast.colored .rojeru-toast-close:hover {
|
|
233
|
+
background: rgba(255, 255, 255, 0.35);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
.rojeru-toast.colored .rojeru-toast-progress {
|
|
237
|
+
background: rgba(255, 255, 255, 0.6);
|
|
238
|
+
box-shadow: 0 0 8px rgba(255, 255, 255, 0.3);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/* Icono de loading animado */
|
|
242
|
+
.rojeru-toast-loading-icon {
|
|
243
|
+
animation: rojeru-toast-spin 1s linear infinite;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
@keyframes rojeru-toast-spin {
|
|
247
|
+
0% {
|
|
248
|
+
transform: rotate(0deg);
|
|
249
|
+
}
|
|
250
|
+
100% {
|
|
251
|
+
transform: rotate(360deg);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
.rojeru-toast-icon {
|
|
256
|
+
width: 20px;
|
|
257
|
+
height: 20px;
|
|
258
|
+
flex-shrink: 0;
|
|
259
|
+
margin-top: 1px;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
.rojeru-toast-icon svg {
|
|
263
|
+
width: 100%;
|
|
264
|
+
height: 100%;
|
|
265
|
+
display: block;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
.rojeru-toast-content {
|
|
269
|
+
flex: 1;
|
|
270
|
+
padding-right: 8px;
|
|
271
|
+
display: flex;
|
|
272
|
+
flex-direction: column;
|
|
273
|
+
gap: 2px;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
.rojeru-toast-title {
|
|
277
|
+
font-weight: 600;
|
|
278
|
+
font-size: 15px;
|
|
279
|
+
display: block;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
.rojeru-toast-message {
|
|
283
|
+
opacity: 0.95;
|
|
284
|
+
font-weight: 400;
|
|
285
|
+
line-height: 1.4;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
/* Mejor contraste para tema colored */
|
|
289
|
+
.rojeru-toast.colored .rojeru-toast-title {
|
|
290
|
+
opacity: 0.95;
|
|
291
|
+
font-weight: 700;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
.rojeru-toast.colored .rojeru-toast-message {
|
|
295
|
+
opacity: 0.9;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
/* Estilos para toast simples (sin título) */
|
|
299
|
+
.rojeru-toast:not(:has(.rojeru-toast-title)) .rojeru-toast-content {
|
|
300
|
+
gap: 0;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
.rojeru-toast:not(:has(.rojeru-toast-title)) .rojeru-toast-message {
|
|
304
|
+
margin-top: 1px;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
.rojeru-toast-close {
|
|
308
|
+
background: rgba(0, 0, 0, 0.1);
|
|
309
|
+
border: none;
|
|
310
|
+
width: 24px;
|
|
311
|
+
height: 24px;
|
|
312
|
+
border-radius: 6px;
|
|
313
|
+
cursor: pointer;
|
|
314
|
+
opacity: 0.7;
|
|
315
|
+
display: flex;
|
|
316
|
+
align-items: center;
|
|
317
|
+
justify-content: center;
|
|
318
|
+
transition: all 0.2s ease;
|
|
319
|
+
flex-shrink: 0;
|
|
320
|
+
margin-top: -2px;
|
|
321
|
+
font-size: 16px;
|
|
322
|
+
font-weight: bold;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
.rojeru-toast-close:hover {
|
|
326
|
+
opacity: 1;
|
|
327
|
+
background: rgba(0, 0, 0, 0.15);
|
|
328
|
+
transform: scale(1.1);
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
.rojeru-toast.dark .rojeru-toast-close {
|
|
332
|
+
background: rgba(255, 255, 255, 0.15);
|
|
333
|
+
color: #ffffff;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
.rojeru-toast.dark .rojeru-toast-close:hover {
|
|
337
|
+
background: rgba(255, 255, 255, 0.25);
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
.rojeru-toast-progress {
|
|
341
|
+
position: absolute;
|
|
342
|
+
bottom: 0;
|
|
343
|
+
left: 0;
|
|
344
|
+
height: 3px;
|
|
345
|
+
background: currentColor;
|
|
346
|
+
opacity: 0.3;
|
|
347
|
+
width: 100%;
|
|
348
|
+
transform-origin: left;
|
|
349
|
+
transform: scaleX(1);
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
/* Animations */
|
|
353
|
+
.rojeru-toast.slide {
|
|
354
|
+
animation: rojeru-toast-slide-in 0.5s cubic-bezier(0.16, 1, 0.3, 1);
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
.rojeru-toast.fade {
|
|
358
|
+
animation: rojeru-toast-fade-in 0.4s ease-out;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
.rojeru-toast.scale {
|
|
362
|
+
animation: rojeru-toast-scale-in 0.3s cubic-bezier(0.16, 1, 0.3, 1);
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
@keyframes rojeru-toast-slide-in {
|
|
366
|
+
from {
|
|
367
|
+
transform: translateX(100%);
|
|
368
|
+
opacity: 0;
|
|
369
|
+
}
|
|
370
|
+
to {
|
|
371
|
+
transform: translateX(0);
|
|
372
|
+
opacity: 1;
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
@keyframes rojeru-toast-slide-in-left {
|
|
377
|
+
from {
|
|
378
|
+
transform: translateX(-100%);
|
|
379
|
+
opacity: 0;
|
|
380
|
+
}
|
|
381
|
+
to {
|
|
382
|
+
transform: translateX(0);
|
|
383
|
+
opacity: 1;
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
@keyframes rojeru-toast-fade-in {
|
|
388
|
+
from {
|
|
389
|
+
opacity: 0;
|
|
390
|
+
transform: translateY(-20px);
|
|
391
|
+
}
|
|
392
|
+
to {
|
|
393
|
+
opacity: 1;
|
|
394
|
+
transform: translateY(0);
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
@keyframes rojeru-toast-scale-in {
|
|
399
|
+
from {
|
|
400
|
+
opacity: 0;
|
|
401
|
+
transform: scale(0.8);
|
|
402
|
+
}
|
|
403
|
+
to {
|
|
404
|
+
opacity: 1;
|
|
405
|
+
transform: scale(1);
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
/* Nuevas animaciones para actualización */
|
|
410
|
+
@keyframes rojeru-toast-update {
|
|
411
|
+
0% {
|
|
412
|
+
transform: scale(1);
|
|
413
|
+
}
|
|
414
|
+
50% {
|
|
415
|
+
transform: scale(1.02);
|
|
416
|
+
}
|
|
417
|
+
100% {
|
|
418
|
+
transform: scale(1);
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
@keyframes rojeru-toast-type-change {
|
|
423
|
+
0% {
|
|
424
|
+
transform: scale(1);
|
|
425
|
+
opacity: 1;
|
|
426
|
+
}
|
|
427
|
+
50% {
|
|
428
|
+
transform: scale(0.95);
|
|
429
|
+
opacity: 0.7;
|
|
430
|
+
}
|
|
431
|
+
100% {
|
|
432
|
+
transform: scale(1);
|
|
433
|
+
opacity: 1;
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
/* Responsive */
|
|
438
|
+
@media (max-width: 768px) {
|
|
439
|
+
.rojeru-toast-container {
|
|
440
|
+
max-width: 100vw;
|
|
441
|
+
padding: 10px;
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
.rojeru-toast {
|
|
445
|
+
max-width: calc(100vw - 20px);
|
|
446
|
+
font-size: 15px;
|
|
447
|
+
padding: 14px 16px;
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
.rojeru-toast-container.top-center,
|
|
451
|
+
.rojeru-toast-container.bottom-center {
|
|
452
|
+
width: 100%;
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
.rojeru-toast-icon {
|
|
456
|
+
width: 18px;
|
|
457
|
+
height: 18px;
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
class t{constructor(){this.defaultOptions={duration:3e3,position:"top-right",type:"info",dismissible:!0,pauseOnHover:!0,theme:"light",animation:"slide",closeOnClick:!1},this.container=null,this.toastInstances=new Map,this.stylesInjected=!1,this.init()}init(){this.createContainer(),this.injectStyles()}injectStyles(){if(this.stylesInjected||document.querySelector("#rojeru-toast-styles"))return void(this.stylesInjected=!0);const t=document.createElement("link");t.id="rojeru-toast-styles",t.rel="stylesheet",t.href="https://cdn.jsdelivr.net/npm/rojeru-toast@latest/dist/rojeru-toast.min.css",t.onerror=()=>{console.warn("No se pudieron cargar los estilos CSS desde CDN. Los estilos se inyectarán inline."),this.injectInlineStyles()},document.head.appendChild(t),this.stylesInjected=!0}injectInlineStyles(){if(document.querySelector("#rojeru-toast-inline-styles"))return;const t=document.createElement("style");t.id="rojeru-toast-inline-styles",t.textContent="\n .rojeru-toast-container {\n position: fixed;\n z-index: 10000;\n pointer-events: none;\n display: flex;\n flex-direction: column;\n gap: 12px;\n max-width: 420px;\n padding: 20px;\n }\n .rojeru-toast-container.top-right { top: 0; right: 0; align-items: flex-end; }\n .rojeru-toast-container.top-left { top: 0; left: 0; align-items: flex-start; }\n .rojeru-toast-container.top-center { top: 0; left: 50%; transform: translateX(-50%); align-items: center; }\n .rojeru-toast-container.bottom-right { bottom: 0; right: 0; align-items: flex-end; }\n .rojeru-toast-container.bottom-left { bottom: 0; left: 0; align-items: flex-start; }\n .rojeru-toast-container.bottom-center { bottom: 0; left: 50%; transform: translateX(-50%); align-items: center; }\n .rojeru-toast {\n pointer-events: all;\n padding: 16px 20px;\n border-radius: 12px;\n backdrop-filter: blur(10px);\n -webkit-backdrop-filter: blur(10px);\n font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n font-size: 14px;\n font-weight: 500;\n line-height: 1.5;\n max-width: 380px;\n display: flex;\n align-items: flex-start;\n gap: 12px;\n transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);\n position: relative;\n overflow: hidden;\n border: 1px solid;\n }\n .rojeru-toast.rojeru-toast-clickable { cursor: pointer; transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1); }\n .rojeru-toast.rojeru-toast-clickable:hover { transform: translateY(-2px); box-shadow: 0 12px 40px rgba(0,0,0,0.15); }\n .rojeru-toast.rojeru-toast-clickable:active { transform: translateY(0); }\n .rojeru-toast::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 1px; background: linear-gradient(90deg, transparent, currentColor, transparent); opacity: 0.3; }\n .rojeru-toast.hiding { transform: scale(0.9) translateX(100px); opacity: 0; pointer-events: none; }\n .rojeru-toast.light { background: rgba(255,255,255,0.95); color: #1a1a1a; border-color: rgba(0,0,0,0.1); box-shadow: 0 8px 32px rgba(0,0,0,0.1), 0 2px 8px rgba(0,0,0,0.05), inset 0 1px 0 rgba(255,255,255,0.8); }\n .rojeru-toast.light.info { color: #0066CC; } .rojeru-toast.light.success { color: #00A86B; } .rojeru-toast.light.warning { color: #FF6B00; } .rojeru-toast.light.error { color: #FF3B30; } .rojeru-toast.light.loading { color: #666666; }\n .rojeru-toast.dark { background: rgba(28,28,30,0.95); color: #ffffff; border-color: rgba(255,255,255,0.1); box-shadow: 0 8px 32px rgba(0,0,0,0.3), 0 2px 8px rgba(0,0,0,0.2), inset 0 1px 0 rgba(255,255,255,0.1); }\n .rojeru-toast.dark.info { color: #5AC8FA; } .rojeru-toast.dark.success { color: #30D158; } .rojeru-toast.dark.warning { color: #FF9F0A; } .rojeru-toast.dark.error { color: #FF453A; } .rojeru-toast.dark.loading { color: #8E8E93; }\n .rojeru-toast.colored { color: white; border: none; box-shadow: 0 8px 32px rgba(0,0,0,0.25), 0 4px 16px rgba(0,0,0,0.15); text-shadow: 0 1px 2px rgba(0,0,0,0.1); }\n .rojeru-toast.colored.info { background: linear-gradient(135deg, #0055AA, #0077CC); }\n .rojeru-toast.colored.success { background: linear-gradient(135deg, #008755, #00AA66); }\n .rojeru-toast.colored.warning { background: linear-gradient(135deg, #CC5500, #EE7700); }\n .rojeru-toast.colored.error { background: linear-gradient(135deg, #CC2200, #EE4422); }\n .rojeru-toast-colored::before { background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent); }\n .rojeru-toast-colored .rojeru-toast-close { background: rgba(255,255,255,0.25); color: white; text-shadow: 0 1px 2px rgba(0,0,0,0.2); }\n .rojeru-toast-colored .rojeru-toast-close:hover { background: rgba(255,255,255,0.35); }\n .rojeru-toast-colored .rojeru-toast-progress { background: rgba(255,255,255,0.6); box-shadow: 0 0 8px rgba(255,255,255,0.3); }\n .rojeru-toast-loading-icon { animation: rojeru-toast-spin 1s linear infinite; }\n @keyframes rojeru-toast-spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }\n .rojeru-toast-icon { width: 20px; height: 20px; flex-shrink: 0; margin-top: 1px; }\n .rojeru-toast-icon svg { width: 100%; height: 100%; display: block; }\n .rojeru-toast-content { flex: 1; padding-right: 8px; display: flex; flex-direction: column; gap: 2px; }\n .rojeru-toast-title { font-weight: 600; font-size: 15px; display: block; }\n .rojeru-toast-message { opacity: 0.95; font-weight: 400; line-height: 1.4; }\n .rojeru-toast.colored .rojeru-toast-title { opacity: 0.95; font-weight: 700; }\n .rojeru-toast.colored .rojeru-toast-message { opacity: 0.9; }\n .rojeru-toast:not(:has(.rojeru-toast-title)) .rojeru-toast-content { gap: 0; }\n .rojeru-toast:not(:has(.rojeru-toast-title)) .rojeru-toast-message { margin-top: 1px; }\n .rojeru-toast-close { background: rgba(0,0,0,0.1); border: none; width: 24px; height: 24px; border-radius: 6px; cursor: pointer; opacity: 0.7; display: flex; align-items: center; justify-content: center; transition: all 0.2s ease; flex-shrink: 0; margin-top: -2px; font-size: 16px; font-weight: bold; }\n .rojeru-toast-close:hover { opacity: 1; background: rgba(0,0,0,0.15); transform: scale(1.1); }\n .rojeru-toast.dark .rojeru-toast-close { background: rgba(255,255,255,0.15); color: #ffffff; }\n .rojeru-toast.dark .rojeru-toast-close:hover { background: rgba(255,255,255,0.25); }\n .rojeru-toast-progress { position: absolute; bottom: 0; left: 0; height: 3px; background: currentColor; opacity: 0.3; width: 100%; transform-origin: left; transform: scaleX(1); }\n .rojeru-toast.slide { animation: rojeru-toast-slide-in 0.5s cubic-bezier(0.16, 1, 0.3, 1); }\n .rojeru-toast.fade { animation: rojeru-toast-fade-in 0.4s ease-out; }\n .rojeru-toast.scale { animation: rojeru-toast-scale-in 0.3s cubic-bezier(0.16, 1, 0.3, 1); }\n @keyframes rojeru-toast-slide-in { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }\n @keyframes rojeru-toast-slide-in-left { from { transform: translateX(-100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }\n @keyframes rojeru-toast-fade-in { from { opacity: 0; transform: translateY(-20px); } to { opacity: 1; transform: translateY(0); } }\n @keyframes rojeru-toast-scale-in { from { opacity: 0; transform: scale(0.8); } to { opacity: 1; transform: scale(1); } }\n @keyframes rojeru-toast-update { 0% { transform: scale(1); } 50% { transform: scale(1.02); } 100% { transform: scale(1); } }\n @keyframes rojeru-toast-type-change { 0% { transform: scale(1); opacity: 1; } 50% { transform: scale(0.95); opacity: 0.7; } 100% { transform: scale(1); opacity: 1; } }\n @media (max-width: 768px) {\n .rojeru-toast-container { max-width: 100vw; padding: 10px; }\n .rojeru-toast { max-width: calc(100vw - 20px); font-size: 15px; padding: 14px 16px; }\n .rojeru-toast-container.top-center, .rojeru-toast-container.bottom-center { width: 100%; }\n .rojeru-toast-icon { width: 18px; height: 18px; }\n }\n ",document.head.appendChild(t)}createContainer(){const t=document.querySelector(".rojeru-toast-container");t&&t.remove(),this.container=document.createElement("div"),this.container.className="rojeru-toast-container",document.body.appendChild(this.container)}getIcon(t){const e={info:'<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><circle cx="12" cy="12" r="10" stroke="currentColor" stroke-width="2"/><path d="M12 16V12" stroke="currentColor" stroke-width="2" stroke-linecap="round"/><circle cx="12" cy="8" r="1" fill="currentColor"/></svg>',success:'<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><circle cx="12" cy="12" r="10" stroke="currentColor" stroke-width="2"/><path d="M8 12L11 15L16 9" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>',warning:'<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M12 9V13" stroke="currentColor" stroke-width="2" stroke-linecap="round"/><path d="M12 17H12.01" stroke="currentColor" stroke-width="2" stroke-linecap="round"/><path d="M10.29 3.86L1.82 18C1.645 18.302 1.553 18.649 1.553 19C1.553 19.351 1.645 19.698 1.82 20C2.08 20.47 2.591 20.79 3.17 20.79H20.83C21.409 20.79 21.92 20.47 22.18 20C22.355 19.698 22.447 19.351 22.447 19C22.447 18.649 22.355 18.302 22.18 18L13.71 3.86C13.45 3.39 12.939 3.07 12.36 3.07C11.781 3.07 11.27 3.39 11.01 3.86V3.86Z" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>',error:'<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><circle cx="12" cy="12" r="10" stroke="currentColor" stroke-width="2"/><path d="M15 9L9 15" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M9 9L15 15" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>',loading:'<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="rojeru-toast-loading-icon"><circle cx="12" cy="12" r="10" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-dasharray="31.4 31.4" opacity="0.3"/><circle cx="12" cy="12" r="10" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-dasharray="15.7 31.4"/></svg>'};return e[t]||e.info}show(t,e,o={}){const r={...this.defaultOptions,...o};void 0===e&&"string"==typeof t&&(e=t,t=null),this.updateContainerPosition(r.position);const n=document.createElement("div");if("loading"===r.type){const t=r.loadingType||"info";n.className=`rojeru-toast ${r.theme} loading ${t} ${r.animation}`}else n.className=`rojeru-toast ${r.theme} ${r.type} ${r.animation}`;const s="loading"===r.type?"loading":r.type,a=this.getIcon(s),i=t&&""!==t;n.innerHTML=`\n <div class="rojeru-toast-icon">${a}</div>\n <div class="rojeru-toast-content">\n ${i?`<span class="rojeru-toast-title">${t}</span>`:""}\n <span class="rojeru-toast-message">${e}</span>\n </div>\n ${r.dismissible&&"loading"!==r.type?'<button class="rojeru-toast-close" aria-label="Cerrar">×</button>':""}\n ${r.duration>0&&"loading"!==r.type?'<div class="rojeru-toast-progress"></div>':""}\n `,"loading"===r.type&&(r.dismissible=!1,r.closeOnClick=!1),!r.dismissible&&0===r.duration&&r.closeOnClick&&n.classList.add("rojeru-toast-clickable"),this.addSlideAnimation(n,r.position),this.container.appendChild(n);const l="toast-"+Date.now()+"-"+Math.random().toString(36).substr(2,9);n.setAttribute("data-toast-id",l);let c=null;if(r.duration>0&&"loading"!==r.type){const t=n.querySelector(".rojeru-toast-progress");t&&setTimeout(()=>{t.style.transition=`transform ${r.duration}ms linear`,t.style.transform="scaleX(0)"},50),c=setTimeout(()=>{this.hide(n)},r.duration)}if(r.dismissible&&"loading"!==r.type){n.querySelector(".rojeru-toast-close").addEventListener("click",()=>{c&&clearTimeout(c),this.hide(n)})}if(r.closeOnClick&&"loading"!==r.type&&(n.style.cursor="pointer",n.addEventListener("click",t=>{t.target.closest(".rojeru-toast-close")||(c&&clearTimeout(c),this.hide(n))})),r.pauseOnHover&&r.duration>0&&"loading"!==r.type){let t=r.duration,e=Date.now();n.addEventListener("mouseenter",()=>{if(c){clearTimeout(c),c=null;const o=Date.now()-e;t=r.duration-o;const s=n.querySelector(".rojeru-toast-progress");if(s){const t=window.getComputedStyle(s),e=new DOMMatrixReadOnly(t.transform).m11;s.style.transition="none",s.style.transform=`scaleX(${e})`}}}),n.addEventListener("mouseleave",()=>{if(!c&&t>0){e=Date.now();const o=n.querySelector(".rojeru-toast-progress");if(o){const e=window.getComputedStyle(o);new DOMMatrixReadOnly(e.transform).m11;const r=t;o.style.transition=`transform ${r}ms linear`,o.style.transform="scaleX(0)"}c=setTimeout(()=>{this.hide(n)},t)}})}const d={hide:()=>{c&&clearTimeout(c),this.hide(n)},update:(t,e,o={})=>this.updateToast(n,t,e,o),changeType:(t,e=null,o=null)=>this.changeToastType(n,t,e,o),complete:(t=null,e={})=>{if(n.classList.contains("loading")){const o=t||"Proceso completado",r=e.type||"success";return this.changeToastType(n,r,o)}return this},getId:()=>l,element:n};return this.toastInstances.set(l,d),d}updateToast(t,e,o,r={}){if(void 0===o&&"string"==typeof e&&(o=e,e=null),r.type)return void this.changeToastType(t,r.type,o,e);const n=t.querySelector(".rojeru-toast-title"),s=t.querySelector(".rojeru-toast-message");return n&&(e?(n.textContent=e,n.style.display="block"):n.style.display="none"),s&&null!==o&&(s.innerHTML=o),r.theme&&(t.classList.remove("light","dark","colored"),t.classList.add(r.theme)),t.style.animation="none",setTimeout(()=>{t.style.animation="rojeru-toast-update 0.3s ease-out"},10),this.toastInstances.get(t.getAttribute("data-toast-id"))}changeToastType(t,e,o=null,r=null){if(t.classList.remove("info","success","warning","error","loading"),"loading"===e){const e="info";t.classList.add("loading",e)}else t.classList.add(e);const n=t.querySelector(".rojeru-toast-icon");if(n){const t="loading"===e?"loading":e;n.innerHTML=this.getIcon(t)}if("loading"!==e){if(!t.querySelector(".rojeru-toast-close")&&this.defaultOptions.dismissible){const e=document.createElement("button");e.className="rojeru-toast-close",e.setAttribute("aria-label","Cerrar"),e.innerHTML="×",e.addEventListener("click",()=>{this.hide(t)}),t.appendChild(e)}const e=t.querySelector(".rojeru-toast-progress");e&&e.remove()}else{const e=t.querySelector(".rojeru-toast-close");e&&e.remove();const o=t.querySelector(".rojeru-toast-progress");o&&o.remove()}if(null!==o){const e=t.querySelector(".rojeru-toast-message");e&&(e.innerHTML=o)}if(null!==r){const e=t.querySelector(".rojeru-toast-title");e&&(r?(e.textContent=r,e.style.display="block"):e.style.display="none")}return t.style.animation="none",setTimeout(()=>{t.style.animation="rojeru-toast-type-change 0.4s ease-out"},10),this.toastInstances.get(t.getAttribute("data-toast-id"))}addSlideAnimation(t,e){const o=e.includes("left");e.includes("top");e.includes("center")?t.style.animation="rojeru-toast-fade-in 0.4s ease-out":o&&(t.style.animation="rojeru-toast-slide-in-left 0.5s cubic-bezier(0.16, 1, 0.3, 1)")}updateContainerPosition(t){this.container.className=`rojeru-toast-container ${t}`}hide(t){if(t&&t.parentNode){const e=t.getAttribute("data-toast-id");this.toastInstances.delete(e),t.classList.add("hiding"),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t)},400)}}hideById(t){const e=this.toastInstances.get(t);e&&e.hide()}hideLast(){const t=Array.from(this.container.querySelectorAll(".rojeru-toast"));t.length>0&&this.hide(t[t.length-1])}hideByType(t){this.container.querySelectorAll(`.rojeru-toast.${t}`).forEach(t=>{this.hide(t)})}info(t,e={}){return this.show(null,t,{...e,type:"info"})}success(t,e={}){return this.show(null,t,{...e,type:"success"})}warning(t,e={}){return this.show(null,t,{...e,type:"warning"})}error(t,e={}){return this.show(null,t,{...e,type:"error"})}loading(t,e={}){const o=e.loadingType||"info";return this.show(null,t,{...e,type:"loading",loadingType:o,dismissible:!1,duration:0})}withTitle(t,e,o={}){return this.show(t,e,o)}clear(){this.container.querySelectorAll(".rojeru-toast").forEach(t=>{this.hide(t)}),this.toastInstances.clear()}}"undefined"!=typeof window&&(window.RojeruToast=t,window.rojeruToast=new t),"undefined"!=typeof module&&module.exports&&(module.exports=t,module.exports.default=t);export{t as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).RojeruToast=e()}(this,function(){"use strict";class t{constructor(){this.defaultOptions={duration:3e3,position:"top-right",type:"info",dismissible:!0,pauseOnHover:!0,theme:"light",animation:"slide",closeOnClick:!1},this.container=null,this.toastInstances=new Map,this.stylesInjected=!1,this.init()}init(){this.createContainer(),this.injectStyles()}injectStyles(){if(this.stylesInjected||document.querySelector("#rojeru-toast-styles"))return void(this.stylesInjected=!0);const t=document.createElement("link");t.id="rojeru-toast-styles",t.rel="stylesheet",t.href="https://cdn.jsdelivr.net/npm/rojeru-toast@latest/dist/rojeru-toast.min.css",t.onerror=()=>{console.warn("No se pudieron cargar los estilos CSS desde CDN. Los estilos se inyectarán inline."),this.injectInlineStyles()},document.head.appendChild(t),this.stylesInjected=!0}injectInlineStyles(){if(document.querySelector("#rojeru-toast-inline-styles"))return;const t=document.createElement("style");t.id="rojeru-toast-inline-styles",t.textContent="\n .rojeru-toast-container {\n position: fixed;\n z-index: 10000;\n pointer-events: none;\n display: flex;\n flex-direction: column;\n gap: 12px;\n max-width: 420px;\n padding: 20px;\n }\n .rojeru-toast-container.top-right { top: 0; right: 0; align-items: flex-end; }\n .rojeru-toast-container.top-left { top: 0; left: 0; align-items: flex-start; }\n .rojeru-toast-container.top-center { top: 0; left: 50%; transform: translateX(-50%); align-items: center; }\n .rojeru-toast-container.bottom-right { bottom: 0; right: 0; align-items: flex-end; }\n .rojeru-toast-container.bottom-left { bottom: 0; left: 0; align-items: flex-start; }\n .rojeru-toast-container.bottom-center { bottom: 0; left: 50%; transform: translateX(-50%); align-items: center; }\n .rojeru-toast {\n pointer-events: all;\n padding: 16px 20px;\n border-radius: 12px;\n backdrop-filter: blur(10px);\n -webkit-backdrop-filter: blur(10px);\n font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n font-size: 14px;\n font-weight: 500;\n line-height: 1.5;\n max-width: 380px;\n display: flex;\n align-items: flex-start;\n gap: 12px;\n transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);\n position: relative;\n overflow: hidden;\n border: 1px solid;\n }\n .rojeru-toast.rojeru-toast-clickable { cursor: pointer; transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1); }\n .rojeru-toast.rojeru-toast-clickable:hover { transform: translateY(-2px); box-shadow: 0 12px 40px rgba(0,0,0,0.15); }\n .rojeru-toast.rojeru-toast-clickable:active { transform: translateY(0); }\n .rojeru-toast::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 1px; background: linear-gradient(90deg, transparent, currentColor, transparent); opacity: 0.3; }\n .rojeru-toast.hiding { transform: scale(0.9) translateX(100px); opacity: 0; pointer-events: none; }\n .rojeru-toast.light { background: rgba(255,255,255,0.95); color: #1a1a1a; border-color: rgba(0,0,0,0.1); box-shadow: 0 8px 32px rgba(0,0,0,0.1), 0 2px 8px rgba(0,0,0,0.05), inset 0 1px 0 rgba(255,255,255,0.8); }\n .rojeru-toast.light.info { color: #0066CC; } .rojeru-toast.light.success { color: #00A86B; } .rojeru-toast.light.warning { color: #FF6B00; } .rojeru-toast.light.error { color: #FF3B30; } .rojeru-toast.light.loading { color: #666666; }\n .rojeru-toast.dark { background: rgba(28,28,30,0.95); color: #ffffff; border-color: rgba(255,255,255,0.1); box-shadow: 0 8px 32px rgba(0,0,0,0.3), 0 2px 8px rgba(0,0,0,0.2), inset 0 1px 0 rgba(255,255,255,0.1); }\n .rojeru-toast.dark.info { color: #5AC8FA; } .rojeru-toast.dark.success { color: #30D158; } .rojeru-toast.dark.warning { color: #FF9F0A; } .rojeru-toast.dark.error { color: #FF453A; } .rojeru-toast.dark.loading { color: #8E8E93; }\n .rojeru-toast.colored { color: white; border: none; box-shadow: 0 8px 32px rgba(0,0,0,0.25), 0 4px 16px rgba(0,0,0,0.15); text-shadow: 0 1px 2px rgba(0,0,0,0.1); }\n .rojeru-toast.colored.info { background: linear-gradient(135deg, #0055AA, #0077CC); }\n .rojeru-toast.colored.success { background: linear-gradient(135deg, #008755, #00AA66); }\n .rojeru-toast.colored.warning { background: linear-gradient(135deg, #CC5500, #EE7700); }\n .rojeru-toast.colored.error { background: linear-gradient(135deg, #CC2200, #EE4422); }\n .rojeru-toast-colored::before { background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent); }\n .rojeru-toast-colored .rojeru-toast-close { background: rgba(255,255,255,0.25); color: white; text-shadow: 0 1px 2px rgba(0,0,0,0.2); }\n .rojeru-toast-colored .rojeru-toast-close:hover { background: rgba(255,255,255,0.35); }\n .rojeru-toast-colored .rojeru-toast-progress { background: rgba(255,255,255,0.6); box-shadow: 0 0 8px rgba(255,255,255,0.3); }\n .rojeru-toast-loading-icon { animation: rojeru-toast-spin 1s linear infinite; }\n @keyframes rojeru-toast-spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }\n .rojeru-toast-icon { width: 20px; height: 20px; flex-shrink: 0; margin-top: 1px; }\n .rojeru-toast-icon svg { width: 100%; height: 100%; display: block; }\n .rojeru-toast-content { flex: 1; padding-right: 8px; display: flex; flex-direction: column; gap: 2px; }\n .rojeru-toast-title { font-weight: 600; font-size: 15px; display: block; }\n .rojeru-toast-message { opacity: 0.95; font-weight: 400; line-height: 1.4; }\n .rojeru-toast.colored .rojeru-toast-title { opacity: 0.95; font-weight: 700; }\n .rojeru-toast.colored .rojeru-toast-message { opacity: 0.9; }\n .rojeru-toast:not(:has(.rojeru-toast-title)) .rojeru-toast-content { gap: 0; }\n .rojeru-toast:not(:has(.rojeru-toast-title)) .rojeru-toast-message { margin-top: 1px; }\n .rojeru-toast-close { background: rgba(0,0,0,0.1); border: none; width: 24px; height: 24px; border-radius: 6px; cursor: pointer; opacity: 0.7; display: flex; align-items: center; justify-content: center; transition: all 0.2s ease; flex-shrink: 0; margin-top: -2px; font-size: 16px; font-weight: bold; }\n .rojeru-toast-close:hover { opacity: 1; background: rgba(0,0,0,0.15); transform: scale(1.1); }\n .rojeru-toast.dark .rojeru-toast-close { background: rgba(255,255,255,0.15); color: #ffffff; }\n .rojeru-toast.dark .rojeru-toast-close:hover { background: rgba(255,255,255,0.25); }\n .rojeru-toast-progress { position: absolute; bottom: 0; left: 0; height: 3px; background: currentColor; opacity: 0.3; width: 100%; transform-origin: left; transform: scaleX(1); }\n .rojeru-toast.slide { animation: rojeru-toast-slide-in 0.5s cubic-bezier(0.16, 1, 0.3, 1); }\n .rojeru-toast.fade { animation: rojeru-toast-fade-in 0.4s ease-out; }\n .rojeru-toast.scale { animation: rojeru-toast-scale-in 0.3s cubic-bezier(0.16, 1, 0.3, 1); }\n @keyframes rojeru-toast-slide-in { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }\n @keyframes rojeru-toast-slide-in-left { from { transform: translateX(-100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }\n @keyframes rojeru-toast-fade-in { from { opacity: 0; transform: translateY(-20px); } to { opacity: 1; transform: translateY(0); } }\n @keyframes rojeru-toast-scale-in { from { opacity: 0; transform: scale(0.8); } to { opacity: 1; transform: scale(1); } }\n @keyframes rojeru-toast-update { 0% { transform: scale(1); } 50% { transform: scale(1.02); } 100% { transform: scale(1); } }\n @keyframes rojeru-toast-type-change { 0% { transform: scale(1); opacity: 1; } 50% { transform: scale(0.95); opacity: 0.7; } 100% { transform: scale(1); opacity: 1; } }\n @media (max-width: 768px) {\n .rojeru-toast-container { max-width: 100vw; padding: 10px; }\n .rojeru-toast { max-width: calc(100vw - 20px); font-size: 15px; padding: 14px 16px; }\n .rojeru-toast-container.top-center, .rojeru-toast-container.bottom-center { width: 100%; }\n .rojeru-toast-icon { width: 18px; height: 18px; }\n }\n ",document.head.appendChild(t)}createContainer(){const t=document.querySelector(".rojeru-toast-container");t&&t.remove(),this.container=document.createElement("div"),this.container.className="rojeru-toast-container",document.body.appendChild(this.container)}getIcon(t){const e={info:'<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><circle cx="12" cy="12" r="10" stroke="currentColor" stroke-width="2"/><path d="M12 16V12" stroke="currentColor" stroke-width="2" stroke-linecap="round"/><circle cx="12" cy="8" r="1" fill="currentColor"/></svg>',success:'<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><circle cx="12" cy="12" r="10" stroke="currentColor" stroke-width="2"/><path d="M8 12L11 15L16 9" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>',warning:'<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M12 9V13" stroke="currentColor" stroke-width="2" stroke-linecap="round"/><path d="M12 17H12.01" stroke="currentColor" stroke-width="2" stroke-linecap="round"/><path d="M10.29 3.86L1.82 18C1.645 18.302 1.553 18.649 1.553 19C1.553 19.351 1.645 19.698 1.82 20C2.08 20.47 2.591 20.79 3.17 20.79H20.83C21.409 20.79 21.92 20.47 22.18 20C22.355 19.698 22.447 19.351 22.447 19C22.447 18.649 22.355 18.302 22.18 18L13.71 3.86C13.45 3.39 12.939 3.07 12.36 3.07C11.781 3.07 11.27 3.39 11.01 3.86V3.86Z" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>',error:'<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><circle cx="12" cy="12" r="10" stroke="currentColor" stroke-width="2"/><path d="M15 9L9 15" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M9 9L15 15" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>',loading:'<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="rojeru-toast-loading-icon"><circle cx="12" cy="12" r="10" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-dasharray="31.4 31.4" opacity="0.3"/><circle cx="12" cy="12" r="10" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-dasharray="15.7 31.4"/></svg>'};return e[t]||e.info}show(t,e,o={}){const r={...this.defaultOptions,...o};void 0===e&&"string"==typeof t&&(e=t,t=null),this.updateContainerPosition(r.position);const n=document.createElement("div");if("loading"===r.type){const t=r.loadingType||"info";n.className=`rojeru-toast ${r.theme} loading ${t} ${r.animation}`}else n.className=`rojeru-toast ${r.theme} ${r.type} ${r.animation}`;const s="loading"===r.type?"loading":r.type,a=this.getIcon(s),i=t&&""!==t;n.innerHTML=`\n <div class="rojeru-toast-icon">${a}</div>\n <div class="rojeru-toast-content">\n ${i?`<span class="rojeru-toast-title">${t}</span>`:""}\n <span class="rojeru-toast-message">${e}</span>\n </div>\n ${r.dismissible&&"loading"!==r.type?'<button class="rojeru-toast-close" aria-label="Cerrar">×</button>':""}\n ${r.duration>0&&"loading"!==r.type?'<div class="rojeru-toast-progress"></div>':""}\n `,"loading"===r.type&&(r.dismissible=!1,r.closeOnClick=!1),!r.dismissible&&0===r.duration&&r.closeOnClick&&n.classList.add("rojeru-toast-clickable"),this.addSlideAnimation(n,r.position),this.container.appendChild(n);const l="toast-"+Date.now()+"-"+Math.random().toString(36).substr(2,9);n.setAttribute("data-toast-id",l);let c=null;if(r.duration>0&&"loading"!==r.type){const t=n.querySelector(".rojeru-toast-progress");t&&setTimeout(()=>{t.style.transition=`transform ${r.duration}ms linear`,t.style.transform="scaleX(0)"},50),c=setTimeout(()=>{this.hide(n)},r.duration)}if(r.dismissible&&"loading"!==r.type){n.querySelector(".rojeru-toast-close").addEventListener("click",()=>{c&&clearTimeout(c),this.hide(n)})}if(r.closeOnClick&&"loading"!==r.type&&(n.style.cursor="pointer",n.addEventListener("click",t=>{t.target.closest(".rojeru-toast-close")||(c&&clearTimeout(c),this.hide(n))})),r.pauseOnHover&&r.duration>0&&"loading"!==r.type){let t=r.duration,e=Date.now();n.addEventListener("mouseenter",()=>{if(c){clearTimeout(c),c=null;const o=Date.now()-e;t=r.duration-o;const s=n.querySelector(".rojeru-toast-progress");if(s){const t=window.getComputedStyle(s),e=new DOMMatrixReadOnly(t.transform).m11;s.style.transition="none",s.style.transform=`scaleX(${e})`}}}),n.addEventListener("mouseleave",()=>{if(!c&&t>0){e=Date.now();const o=n.querySelector(".rojeru-toast-progress");if(o){const e=window.getComputedStyle(o);new DOMMatrixReadOnly(e.transform).m11;const r=t;o.style.transition=`transform ${r}ms linear`,o.style.transform="scaleX(0)"}c=setTimeout(()=>{this.hide(n)},t)}})}const d={hide:()=>{c&&clearTimeout(c),this.hide(n)},update:(t,e,o={})=>this.updateToast(n,t,e,o),changeType:(t,e=null,o=null)=>this.changeToastType(n,t,e,o),complete:(t=null,e={})=>{if(n.classList.contains("loading")){const o=t||"Proceso completado",r=e.type||"success";return this.changeToastType(n,r,o)}return this},getId:()=>l,element:n};return this.toastInstances.set(l,d),d}updateToast(t,e,o,r={}){if(void 0===o&&"string"==typeof e&&(o=e,e=null),r.type)return void this.changeToastType(t,r.type,o,e);const n=t.querySelector(".rojeru-toast-title"),s=t.querySelector(".rojeru-toast-message");return n&&(e?(n.textContent=e,n.style.display="block"):n.style.display="none"),s&&null!==o&&(s.innerHTML=o),r.theme&&(t.classList.remove("light","dark","colored"),t.classList.add(r.theme)),t.style.animation="none",setTimeout(()=>{t.style.animation="rojeru-toast-update 0.3s ease-out"},10),this.toastInstances.get(t.getAttribute("data-toast-id"))}changeToastType(t,e,o=null,r=null){if(t.classList.remove("info","success","warning","error","loading"),"loading"===e){const e="info";t.classList.add("loading",e)}else t.classList.add(e);const n=t.querySelector(".rojeru-toast-icon");if(n){const t="loading"===e?"loading":e;n.innerHTML=this.getIcon(t)}if("loading"!==e){if(!t.querySelector(".rojeru-toast-close")&&this.defaultOptions.dismissible){const e=document.createElement("button");e.className="rojeru-toast-close",e.setAttribute("aria-label","Cerrar"),e.innerHTML="×",e.addEventListener("click",()=>{this.hide(t)}),t.appendChild(e)}const e=t.querySelector(".rojeru-toast-progress");e&&e.remove()}else{const e=t.querySelector(".rojeru-toast-close");e&&e.remove();const o=t.querySelector(".rojeru-toast-progress");o&&o.remove()}if(null!==o){const e=t.querySelector(".rojeru-toast-message");e&&(e.innerHTML=o)}if(null!==r){const e=t.querySelector(".rojeru-toast-title");e&&(r?(e.textContent=r,e.style.display="block"):e.style.display="none")}return t.style.animation="none",setTimeout(()=>{t.style.animation="rojeru-toast-type-change 0.4s ease-out"},10),this.toastInstances.get(t.getAttribute("data-toast-id"))}addSlideAnimation(t,e){const o=e.includes("left");e.includes("top");e.includes("center")?t.style.animation="rojeru-toast-fade-in 0.4s ease-out":o&&(t.style.animation="rojeru-toast-slide-in-left 0.5s cubic-bezier(0.16, 1, 0.3, 1)")}updateContainerPosition(t){this.container.className=`rojeru-toast-container ${t}`}hide(t){if(t&&t.parentNode){const e=t.getAttribute("data-toast-id");this.toastInstances.delete(e),t.classList.add("hiding"),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t)},400)}}hideById(t){const e=this.toastInstances.get(t);e&&e.hide()}hideLast(){const t=Array.from(this.container.querySelectorAll(".rojeru-toast"));t.length>0&&this.hide(t[t.length-1])}hideByType(t){this.container.querySelectorAll(`.rojeru-toast.${t}`).forEach(t=>{this.hide(t)})}info(t,e={}){return this.show(null,t,{...e,type:"info"})}success(t,e={}){return this.show(null,t,{...e,type:"success"})}warning(t,e={}){return this.show(null,t,{...e,type:"warning"})}error(t,e={}){return this.show(null,t,{...e,type:"error"})}loading(t,e={}){const o=e.loadingType||"info";return this.show(null,t,{...e,type:"loading",loadingType:o,dismissible:!1,duration:0})}withTitle(t,e,o={}){return this.show(t,e,o)}clear(){this.container.querySelectorAll(".rojeru-toast").forEach(t=>{this.hide(t)}),this.toastInstances.clear()}}return"undefined"!=typeof window&&(window.RojeruToast=t,window.rojeruToast=new t),"undefined"!=typeof module&&module.exports&&(module.exports=t,module.exports.default=t),t});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.rojeru-toast-container{position:fixed;z-index:10000;pointer-events:none;display:flex;flex-direction:column;gap:12px;max-width:420px;padding:20px}.rojeru-toast-container.top-right{top:0;right:0;align-items:flex-end}.rojeru-toast-container.top-left{top:0;left:0;align-items:flex-start}.rojeru-toast-container.top-center{top:0;left:50%;transform:translateX(-50%);align-items:center}.rojeru-toast-container.bottom-right{bottom:0;right:0;align-items:flex-end}.rojeru-toast-container.bottom-left{bottom:0;left:0;align-items:flex-start}.rojeru-toast-container.bottom-center{bottom:0;left:50%;transform:translateX(-50%);align-items:center}.rojeru-toast{pointer-events:all;padding:16px 20px;border-radius:12px;backdrop-filter:blur(10px);-webkit-backdrop-filter:blur(10px);font-family:Inter,-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif;font-size:14px;font-weight:500;line-height:1.5;max-width:380px;display:flex;align-items:flex-start;gap:12px;transition:all .4s cubic-bezier(.16, 1, .3, 1);position:relative;overflow:hidden;border:1px solid}.rojeru-toast.rojeru-toast-clickable{cursor:pointer;transition:all .3s cubic-bezier(.16, 1, .3, 1)}.rojeru-toast.rojeru-toast-clickable:hover{transform:translateY(-2px);box-shadow:0 12px 40px rgba(0,0,0,.15)}.rojeru-toast.rojeru-toast-clickable:active{transform:translateY(0)}.rojeru-toast::before{content:'';position:absolute;top:0;left:0;right:0;height:1px;background:linear-gradient(90deg,transparent,currentColor,transparent);opacity:.3}.rojeru-toast.hiding{transform:scale(.9) translateX(100px);opacity:0;pointer-events:none}.rojeru-toast.light{background:rgba(255,255,255,.95);color:#1a1a1a;border-color:rgba(0,0,0,.1);box-shadow:0 8px 32px rgba(0,0,0,.1),0 2px 8px rgba(0,0,0,.05),inset 0 1px 0 rgba(255,255,255,.8)}.rojeru-toast.light.info{color:#06c}.rojeru-toast.light.success{color:#00a86b}.rojeru-toast.light.warning{color:#ff6b00}.rojeru-toast.light.error{color:#ff3b30}.rojeru-toast.light.loading{color:#666}.rojeru-toast.dark{background:rgba(28,28,30,.95);color:#fff;border-color:rgba(255,255,255,.1);box-shadow:0 8px 32px rgba(0,0,0,.3),0 2px 8px rgba(0,0,0,.2),inset 0 1px 0 rgba(255,255,255,.1)}.rojeru-toast.dark.info{color:#5ac8fa}.rojeru-toast.dark.success{color:#30d158}.rojeru-toast.dark.warning{color:#ff9f0a}.rojeru-toast.dark.error{color:#ff453a}.rojeru-toast.dark.loading{color:#8e8e93}.rojeru-toast.colored{color:#fff;border:none;box-shadow:0 8px 32px rgba(0,0,0,.25),0 4px 16px rgba(0,0,0,.15);text-shadow:0 1px 2px rgba(0,0,0,.1)}.rojeru-toast.colored.info{background:linear-gradient(135deg,#05a,#07c)}.rojeru-toast.colored.success{background:linear-gradient(135deg,#008755,#0a6)}.rojeru-toast.colored.warning{background:linear-gradient(135deg,#c50,#e70)}.rojeru-toast.colored.error{background:linear-gradient(135deg,#c20,#e42)}.rojeru-toast.light.loading.info{color:#06c}.rojeru-toast.light.loading.success{color:#00a86b}.rojeru-toast.light.loading.warning{color:#ff6b00}.rojeru-toast.light.loading.error{color:#ff3b30}.rojeru-toast.dark.loading.info{color:#5ac8fa}.rojeru-toast.dark.loading.success{color:#30d158}.rojeru-toast.dark.loading.warning{color:#ff9f0a}.rojeru-toast.dark.loading.error{color:#ff453a}.rojeru-toast.colored.loading.info{background:linear-gradient(135deg,#05a,#07c)}.rojeru-toast.colored.loading.success{background:linear-gradient(135deg,#008755,#0a6)}.rojeru-toast.colored.loading.warning{background:linear-gradient(135deg,#c50,#e70)}.rojeru-toast.colored.loading.error{background:linear-gradient(135deg,#c20,#e42)}.rojeru-toast.colored::before{background:linear-gradient(90deg,transparent,rgba(255,255,255,.4),transparent)}.rojeru-toast.colored .rojeru-toast-close{background:rgba(255,255,255,.25);color:#fff;text-shadow:0 1px 2px rgba(0,0,0,.2)}.rojeru-toast.colored .rojeru-toast-close:hover{background:rgba(255,255,255,.35)}.rojeru-toast.colored .rojeru-toast-progress{background:rgba(255,255,255,.6);box-shadow:0 0 8px rgba(255,255,255,.3)}.rojeru-toast-loading-icon{animation:rojeru-toast-spin 1s linear infinite}@keyframes rojeru-toast-spin{0%{transform:rotate(0)}100%{transform:rotate(360deg)}}.rojeru-toast-icon{width:20px;height:20px;flex-shrink:0;margin-top:1px}.rojeru-toast-icon svg{width:100%;height:100%;display:block}.rojeru-toast-content{flex:1;padding-right:8px;display:flex;flex-direction:column;gap:2px}.rojeru-toast-title{font-weight:600;font-size:15px;display:block}.rojeru-toast-message{opacity:.95;font-weight:400;line-height:1.4}.rojeru-toast.colored .rojeru-toast-title{opacity:.95;font-weight:700}.rojeru-toast.colored .rojeru-toast-message{opacity:.9}.rojeru-toast:not(:has(.rojeru-toast-title)) .rojeru-toast-content{gap:0}.rojeru-toast:not(:has(.rojeru-toast-title)) .rojeru-toast-message{margin-top:1px}.rojeru-toast-close{background:rgba(0,0,0,.1);border:none;width:24px;height:24px;border-radius:6px;cursor:pointer;opacity:.7;display:flex;align-items:center;justify-content:center;transition:all .2s ease;flex-shrink:0;margin-top:-2px;font-size:16px;font-weight:700}.rojeru-toast-close:hover{opacity:1;background:rgba(0,0,0,.15);transform:scale(1.1)}.rojeru-toast.dark .rojeru-toast-close{background:rgba(255,255,255,.15);color:#fff}.rojeru-toast.dark .rojeru-toast-close:hover{background:rgba(255,255,255,.25)}.rojeru-toast-progress{position:absolute;bottom:0;left:0;height:3px;background:currentColor;opacity:.3;width:100%;transform-origin:left;transform:scaleX(1)}.rojeru-toast.slide{animation:rojeru-toast-slide-in .5s cubic-bezier(.16,1,.3,1)}.rojeru-toast.fade{animation:rojeru-toast-fade-in .4s ease-out}.rojeru-toast.scale{animation:rojeru-toast-scale-in .3s cubic-bezier(.16,1,.3,1)}@keyframes rojeru-toast-slide-in{from{transform:translateX(100%);opacity:0}to{transform:translateX(0);opacity:1}}@keyframes rojeru-toast-slide-in-left{from{transform:translateX(-100%);opacity:0}to{transform:translateX(0);opacity:1}}@keyframes rojeru-toast-fade-in{from{opacity:0;transform:translateY(-20px)}to{opacity:1;transform:translateY(0)}}@keyframes rojeru-toast-scale-in{from{opacity:0;transform:scale(.8)}to{opacity:1;transform:scale(1)}}@keyframes rojeru-toast-update{0%{transform:scale(1)}50%{transform:scale(1.02)}100%{transform:scale(1)}}@keyframes rojeru-toast-type-change{0%{transform:scale(1);opacity:1}50%{transform:scale(.95);opacity:.7}100%{transform:scale(1);opacity:1}}@media (max-width:768px){.rojeru-toast-container{max-width:100vw;padding:10px}.rojeru-toast{max-width:calc(100vw - 20px);font-size:15px;padding:14px 16px}.rojeru-toast-container.bottom-center,.rojeru-toast-container.top-center{width:100%}.rojeru-toast-icon{width:18px;height:18px}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).RojeruToast=e()}(this,function(){"use strict";class t{constructor(){this.defaultOptions={duration:3e3,position:"top-right",type:"info",dismissible:!0,pauseOnHover:!0,theme:"light",animation:"slide",closeOnClick:!1},this.container=null,this.toastInstances=new Map,this.stylesInjected=!1,this.init()}init(){this.createContainer(),this.injectStyles()}injectStyles(){if(this.stylesInjected||document.querySelector("#rojeru-toast-styles"))return void(this.stylesInjected=!0);const t=document.createElement("link");t.id="rojeru-toast-styles",t.rel="stylesheet",t.href="https://cdn.jsdelivr.net/npm/rojeru-toast@latest/dist/rojeru-toast.min.css",t.onerror=()=>{console.warn("No se pudieron cargar los estilos CSS desde CDN. Los estilos se inyectarán inline."),this.injectInlineStyles()},document.head.appendChild(t),this.stylesInjected=!0}injectInlineStyles(){if(document.querySelector("#rojeru-toast-inline-styles"))return;const t=document.createElement("style");t.id="rojeru-toast-inline-styles",t.textContent="\n .rojeru-toast-container {\n position: fixed;\n z-index: 10000;\n pointer-events: none;\n display: flex;\n flex-direction: column;\n gap: 12px;\n max-width: 420px;\n padding: 20px;\n }\n .rojeru-toast-container.top-right { top: 0; right: 0; align-items: flex-end; }\n .rojeru-toast-container.top-left { top: 0; left: 0; align-items: flex-start; }\n .rojeru-toast-container.top-center { top: 0; left: 50%; transform: translateX(-50%); align-items: center; }\n .rojeru-toast-container.bottom-right { bottom: 0; right: 0; align-items: flex-end; }\n .rojeru-toast-container.bottom-left { bottom: 0; left: 0; align-items: flex-start; }\n .rojeru-toast-container.bottom-center { bottom: 0; left: 50%; transform: translateX(-50%); align-items: center; }\n .rojeru-toast {\n pointer-events: all;\n padding: 16px 20px;\n border-radius: 12px;\n backdrop-filter: blur(10px);\n -webkit-backdrop-filter: blur(10px);\n font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n font-size: 14px;\n font-weight: 500;\n line-height: 1.5;\n max-width: 380px;\n display: flex;\n align-items: flex-start;\n gap: 12px;\n transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);\n position: relative;\n overflow: hidden;\n border: 1px solid;\n }\n .rojeru-toast.rojeru-toast-clickable { cursor: pointer; transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1); }\n .rojeru-toast.rojeru-toast-clickable:hover { transform: translateY(-2px); box-shadow: 0 12px 40px rgba(0,0,0,0.15); }\n .rojeru-toast.rojeru-toast-clickable:active { transform: translateY(0); }\n .rojeru-toast::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 1px; background: linear-gradient(90deg, transparent, currentColor, transparent); opacity: 0.3; }\n .rojeru-toast.hiding { transform: scale(0.9) translateX(100px); opacity: 0; pointer-events: none; }\n .rojeru-toast.light { background: rgba(255,255,255,0.95); color: #1a1a1a; border-color: rgba(0,0,0,0.1); box-shadow: 0 8px 32px rgba(0,0,0,0.1), 0 2px 8px rgba(0,0,0,0.05), inset 0 1px 0 rgba(255,255,255,0.8); }\n .rojeru-toast.light.info { color: #0066CC; } .rojeru-toast.light.success { color: #00A86B; } .rojeru-toast.light.warning { color: #FF6B00; } .rojeru-toast.light.error { color: #FF3B30; } .rojeru-toast.light.loading { color: #666666; }\n .rojeru-toast.dark { background: rgba(28,28,30,0.95); color: #ffffff; border-color: rgba(255,255,255,0.1); box-shadow: 0 8px 32px rgba(0,0,0,0.3), 0 2px 8px rgba(0,0,0,0.2), inset 0 1px 0 rgba(255,255,255,0.1); }\n .rojeru-toast.dark.info { color: #5AC8FA; } .rojeru-toast.dark.success { color: #30D158; } .rojeru-toast.dark.warning { color: #FF9F0A; } .rojeru-toast.dark.error { color: #FF453A; } .rojeru-toast.dark.loading { color: #8E8E93; }\n .rojeru-toast.colored { color: white; border: none; box-shadow: 0 8px 32px rgba(0,0,0,0.25), 0 4px 16px rgba(0,0,0,0.15); text-shadow: 0 1px 2px rgba(0,0,0,0.1); }\n .rojeru-toast.colored.info { background: linear-gradient(135deg, #0055AA, #0077CC); }\n .rojeru-toast.colored.success { background: linear-gradient(135deg, #008755, #00AA66); }\n .rojeru-toast.colored.warning { background: linear-gradient(135deg, #CC5500, #EE7700); }\n .rojeru-toast.colored.error { background: linear-gradient(135deg, #CC2200, #EE4422); }\n .rojeru-toast-colored::before { background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent); }\n .rojeru-toast-colored .rojeru-toast-close { background: rgba(255,255,255,0.25); color: white; text-shadow: 0 1px 2px rgba(0,0,0,0.2); }\n .rojeru-toast-colored .rojeru-toast-close:hover { background: rgba(255,255,255,0.35); }\n .rojeru-toast-colored .rojeru-toast-progress { background: rgba(255,255,255,0.6); box-shadow: 0 0 8px rgba(255,255,255,0.3); }\n .rojeru-toast-loading-icon { animation: rojeru-toast-spin 1s linear infinite; }\n @keyframes rojeru-toast-spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }\n .rojeru-toast-icon { width: 20px; height: 20px; flex-shrink: 0; margin-top: 1px; }\n .rojeru-toast-icon svg { width: 100%; height: 100%; display: block; }\n .rojeru-toast-content { flex: 1; padding-right: 8px; display: flex; flex-direction: column; gap: 2px; }\n .rojeru-toast-title { font-weight: 600; font-size: 15px; display: block; }\n .rojeru-toast-message { opacity: 0.95; font-weight: 400; line-height: 1.4; }\n .rojeru-toast.colored .rojeru-toast-title { opacity: 0.95; font-weight: 700; }\n .rojeru-toast.colored .rojeru-toast-message { opacity: 0.9; }\n .rojeru-toast:not(:has(.rojeru-toast-title)) .rojeru-toast-content { gap: 0; }\n .rojeru-toast:not(:has(.rojeru-toast-title)) .rojeru-toast-message { margin-top: 1px; }\n .rojeru-toast-close { background: rgba(0,0,0,0.1); border: none; width: 24px; height: 24px; border-radius: 6px; cursor: pointer; opacity: 0.7; display: flex; align-items: center; justify-content: center; transition: all 0.2s ease; flex-shrink: 0; margin-top: -2px; font-size: 16px; font-weight: bold; }\n .rojeru-toast-close:hover { opacity: 1; background: rgba(0,0,0,0.15); transform: scale(1.1); }\n .rojeru-toast.dark .rojeru-toast-close { background: rgba(255,255,255,0.15); color: #ffffff; }\n .rojeru-toast.dark .rojeru-toast-close:hover { background: rgba(255,255,255,0.25); }\n .rojeru-toast-progress { position: absolute; bottom: 0; left: 0; height: 3px; background: currentColor; opacity: 0.3; width: 100%; transform-origin: left; transform: scaleX(1); }\n .rojeru-toast.slide { animation: rojeru-toast-slide-in 0.5s cubic-bezier(0.16, 1, 0.3, 1); }\n .rojeru-toast.fade { animation: rojeru-toast-fade-in 0.4s ease-out; }\n .rojeru-toast.scale { animation: rojeru-toast-scale-in 0.3s cubic-bezier(0.16, 1, 0.3, 1); }\n @keyframes rojeru-toast-slide-in { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }\n @keyframes rojeru-toast-slide-in-left { from { transform: translateX(-100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }\n @keyframes rojeru-toast-fade-in { from { opacity: 0; transform: translateY(-20px); } to { opacity: 1; transform: translateY(0); } }\n @keyframes rojeru-toast-scale-in { from { opacity: 0; transform: scale(0.8); } to { opacity: 1; transform: scale(1); } }\n @keyframes rojeru-toast-update { 0% { transform: scale(1); } 50% { transform: scale(1.02); } 100% { transform: scale(1); } }\n @keyframes rojeru-toast-type-change { 0% { transform: scale(1); opacity: 1; } 50% { transform: scale(0.95); opacity: 0.7; } 100% { transform: scale(1); opacity: 1; } }\n @media (max-width: 768px) {\n .rojeru-toast-container { max-width: 100vw; padding: 10px; }\n .rojeru-toast { max-width: calc(100vw - 20px); font-size: 15px; padding: 14px 16px; }\n .rojeru-toast-container.top-center, .rojeru-toast-container.bottom-center { width: 100%; }\n .rojeru-toast-icon { width: 18px; height: 18px; }\n }\n ",document.head.appendChild(t)}createContainer(){const t=document.querySelector(".rojeru-toast-container");t&&t.remove(),this.container=document.createElement("div"),this.container.className="rojeru-toast-container",document.body.appendChild(this.container)}getIcon(t){const e={info:'<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><circle cx="12" cy="12" r="10" stroke="currentColor" stroke-width="2"/><path d="M12 16V12" stroke="currentColor" stroke-width="2" stroke-linecap="round"/><circle cx="12" cy="8" r="1" fill="currentColor"/></svg>',success:'<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><circle cx="12" cy="12" r="10" stroke="currentColor" stroke-width="2"/><path d="M8 12L11 15L16 9" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>',warning:'<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M12 9V13" stroke="currentColor" stroke-width="2" stroke-linecap="round"/><path d="M12 17H12.01" stroke="currentColor" stroke-width="2" stroke-linecap="round"/><path d="M10.29 3.86L1.82 18C1.645 18.302 1.553 18.649 1.553 19C1.553 19.351 1.645 19.698 1.82 20C2.08 20.47 2.591 20.79 3.17 20.79H20.83C21.409 20.79 21.92 20.47 22.18 20C22.355 19.698 22.447 19.351 22.447 19C22.447 18.649 22.355 18.302 22.18 18L13.71 3.86C13.45 3.39 12.939 3.07 12.36 3.07C11.781 3.07 11.27 3.39 11.01 3.86V3.86Z" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>',error:'<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><circle cx="12" cy="12" r="10" stroke="currentColor" stroke-width="2"/><path d="M15 9L9 15" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M9 9L15 15" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>',loading:'<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="rojeru-toast-loading-icon"><circle cx="12" cy="12" r="10" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-dasharray="31.4 31.4" opacity="0.3"/><circle cx="12" cy="12" r="10" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-dasharray="15.7 31.4"/></svg>'};return e[t]||e.info}show(t,e,o={}){const r={...this.defaultOptions,...o};void 0===e&&"string"==typeof t&&(e=t,t=null),this.updateContainerPosition(r.position);const n=document.createElement("div");if("loading"===r.type){const t=r.loadingType||"info";n.className=`rojeru-toast ${r.theme} loading ${t} ${r.animation}`}else n.className=`rojeru-toast ${r.theme} ${r.type} ${r.animation}`;const s="loading"===r.type?"loading":r.type,a=this.getIcon(s),i=t&&""!==t;n.innerHTML=`\n <div class="rojeru-toast-icon">${a}</div>\n <div class="rojeru-toast-content">\n ${i?`<span class="rojeru-toast-title">${t}</span>`:""}\n <span class="rojeru-toast-message">${e}</span>\n </div>\n ${r.dismissible&&"loading"!==r.type?'<button class="rojeru-toast-close" aria-label="Cerrar">×</button>':""}\n ${r.duration>0&&"loading"!==r.type?'<div class="rojeru-toast-progress"></div>':""}\n `,"loading"===r.type&&(r.dismissible=!1,r.closeOnClick=!1),!r.dismissible&&0===r.duration&&r.closeOnClick&&n.classList.add("rojeru-toast-clickable"),this.addSlideAnimation(n,r.position),this.container.appendChild(n);const l="toast-"+Date.now()+"-"+Math.random().toString(36).substr(2,9);n.setAttribute("data-toast-id",l);let c=null;if(r.duration>0&&"loading"!==r.type){const t=n.querySelector(".rojeru-toast-progress");t&&setTimeout(()=>{t.style.transition=`transform ${r.duration}ms linear`,t.style.transform="scaleX(0)"},50),c=setTimeout(()=>{this.hide(n)},r.duration)}if(r.dismissible&&"loading"!==r.type&&n.querySelector(".rojeru-toast-close").addEventListener("click",()=>{c&&clearTimeout(c),this.hide(n)}),r.closeOnClick&&"loading"!==r.type&&(n.style.cursor="pointer",n.addEventListener("click",t=>{t.target.closest(".rojeru-toast-close")||(c&&clearTimeout(c),this.hide(n))})),r.pauseOnHover&&r.duration>0&&"loading"!==r.type){let t=r.duration,e=Date.now();n.addEventListener("mouseenter",()=>{if(c){clearTimeout(c),c=null;const o=Date.now()-e;t=r.duration-o;const s=n.querySelector(".rojeru-toast-progress");if(s){const t=window.getComputedStyle(s),e=new DOMMatrixReadOnly(t.transform).m11;s.style.transition="none",s.style.transform=`scaleX(${e})`}}}),n.addEventListener("mouseleave",()=>{if(!c&&t>0){e=Date.now();const o=n.querySelector(".rojeru-toast-progress");if(o){const e=window.getComputedStyle(o);new DOMMatrixReadOnly(e.transform).m11;const r=t;o.style.transition=`transform ${r}ms linear`,o.style.transform="scaleX(0)"}c=setTimeout(()=>{this.hide(n)},t)}})}const d={hide:()=>{c&&clearTimeout(c),this.hide(n)},update:(t,e,o={})=>this.updateToast(n,t,e,o),changeType:(t,e=null,o=null)=>this.changeToastType(n,t,e,o),complete:(t=null,e={})=>{if(n.classList.contains("loading")){const o=t||"Proceso completado",r=e.type||"success";return this.changeToastType(n,r,o)}return this},getId:()=>l,element:n};return this.toastInstances.set(l,d),d}updateToast(t,e,o,r={}){if(void 0===o&&"string"==typeof e&&(o=e,e=null),r.type)return void this.changeToastType(t,r.type,o,e);const n=t.querySelector(".rojeru-toast-title"),s=t.querySelector(".rojeru-toast-message");return n&&(e?(n.textContent=e,n.style.display="block"):n.style.display="none"),s&&null!==o&&(s.innerHTML=o),r.theme&&(t.classList.remove("light","dark","colored"),t.classList.add(r.theme)),t.style.animation="none",setTimeout(()=>{t.style.animation="rojeru-toast-update 0.3s ease-out"},10),this.toastInstances.get(t.getAttribute("data-toast-id"))}changeToastType(t,e,o=null,r=null){if(t.classList.remove("info","success","warning","error","loading"),"loading"===e){const e="info";t.classList.add("loading",e)}else t.classList.add(e);const n=t.querySelector(".rojeru-toast-icon");if(n){const t="loading"===e?"loading":e;n.innerHTML=this.getIcon(t)}if("loading"!==e){if(!t.querySelector(".rojeru-toast-close")&&this.defaultOptions.dismissible){const e=document.createElement("button");e.className="rojeru-toast-close",e.setAttribute("aria-label","Cerrar"),e.innerHTML="×",e.addEventListener("click",()=>{this.hide(t)}),t.appendChild(e)}const e=t.querySelector(".rojeru-toast-progress");e&&e.remove()}else{const e=t.querySelector(".rojeru-toast-close");e&&e.remove();const o=t.querySelector(".rojeru-toast-progress");o&&o.remove()}if(null!==o){const e=t.querySelector(".rojeru-toast-message");e&&(e.innerHTML=o)}if(null!==r){const e=t.querySelector(".rojeru-toast-title");e&&(r?(e.textContent=r,e.style.display="block"):e.style.display="none")}return t.style.animation="none",setTimeout(()=>{t.style.animation="rojeru-toast-type-change 0.4s ease-out"},10),this.toastInstances.get(t.getAttribute("data-toast-id"))}addSlideAnimation(t,e){const o=e.includes("left");e.includes("top"),e.includes("center")?t.style.animation="rojeru-toast-fade-in 0.4s ease-out":o&&(t.style.animation="rojeru-toast-slide-in-left 0.5s cubic-bezier(0.16, 1, 0.3, 1)")}updateContainerPosition(t){this.container.className=`rojeru-toast-container ${t}`}hide(t){if(t&&t.parentNode){const e=t.getAttribute("data-toast-id");this.toastInstances.delete(e),t.classList.add("hiding"),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t)},400)}}hideById(t){const e=this.toastInstances.get(t);e&&e.hide()}hideLast(){const t=Array.from(this.container.querySelectorAll(".rojeru-toast"));t.length>0&&this.hide(t[t.length-1])}hideByType(t){this.container.querySelectorAll(`.rojeru-toast.${t}`).forEach(t=>{this.hide(t)})}info(t,e={}){return this.show(null,t,{...e,type:"info"})}success(t,e={}){return this.show(null,t,{...e,type:"success"})}warning(t,e={}){return this.show(null,t,{...e,type:"warning"})}error(t,e={}){return this.show(null,t,{...e,type:"error"})}loading(t,e={}){const o=e.loadingType||"info";return this.show(null,t,{...e,type:"loading",loadingType:o,dismissible:!1,duration:0})}withTitle(t,e,o={}){return this.show(t,e,o)}clear(){this.container.querySelectorAll(".rojeru-toast").forEach(t=>{this.hide(t)}),this.toastInstances.clear()}}return"undefined"!=typeof window&&(window.RojeruToast=t,window.rojeruToast=new t),"undefined"!=typeof module&&module.exports&&(module.exports=t,module.exports.default=t),t});
|
package/package.json
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "rojeru-toast",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Librería moderna de mensajes toast para aplicaciones web, compatible con todos los frameworks y HTML puro",
|
|
5
|
+
"main": "dist/rojeru-toast.js",
|
|
6
|
+
"module": "src/index.js",
|
|
7
|
+
"style": "dist/rojeru-toast.css",
|
|
8
|
+
"types": "dist/index.d.ts",
|
|
9
|
+
"scripts": {
|
|
10
|
+
"build": "npm run build:js && npm run build:css",
|
|
11
|
+
"build:js": "rollup -c",
|
|
12
|
+
"build:css": "node scripts/build-css.js",
|
|
13
|
+
"minify:js": "terser dist/rojeru-toast.js -o dist/rojeru-toast.min.js --compress --mangle",
|
|
14
|
+
"minify:css": "cleancss -o dist/rojeru-toast.min.css dist/rojeru-toast.css",
|
|
15
|
+
"prepublishOnly": "npm run build && npm run minify:js && npm run minify:css",
|
|
16
|
+
"dev": "nodemon --watch src --ext js,css --exec 'npm run build'"
|
|
17
|
+
},
|
|
18
|
+
"keywords": [
|
|
19
|
+
"toast",
|
|
20
|
+
"notification",
|
|
21
|
+
"alert",
|
|
22
|
+
"message",
|
|
23
|
+
"popup",
|
|
24
|
+
"ui",
|
|
25
|
+
"javascript",
|
|
26
|
+
"vanilla",
|
|
27
|
+
"react",
|
|
28
|
+
"vue",
|
|
29
|
+
"angular",
|
|
30
|
+
"svelte"
|
|
31
|
+
],
|
|
32
|
+
"author": "Rogelio Urieta Camacho <rogelio.urieta@email.com>",
|
|
33
|
+
"license": "MIT",
|
|
34
|
+
"repository": {
|
|
35
|
+
"type": "git",
|
|
36
|
+
"url": "https://github.com/rojerusan/rojeru-toast.git"
|
|
37
|
+
},
|
|
38
|
+
"bugs": {
|
|
39
|
+
"url": "https://github.com/rojerusan/rojeru-toast/issues"
|
|
40
|
+
},
|
|
41
|
+
"homepage": "https://github.com/rojerusan/rojeru-toast#readme",
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@rollup/plugin-terser": "^0.4.0",
|
|
44
|
+
"clean-css-cli": "^5.6.2",
|
|
45
|
+
"nodemon": "^3.0.1",
|
|
46
|
+
"rollup": "^4.0.0",
|
|
47
|
+
"terser": "^5.19.0"
|
|
48
|
+
},
|
|
49
|
+
"files": [
|
|
50
|
+
"dist",
|
|
51
|
+
"src",
|
|
52
|
+
"README.md",
|
|
53
|
+
"LICENSE"
|
|
54
|
+
]
|
|
55
|
+
}
|