@t007/toast 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,528 @@
1
+ :where(:root) {
2
+ --t007-toast-font-family: inherit;
3
+ --t007-toast-info-color: #3498db;
4
+ --t007-toast-success-color: #27ae60;
5
+ --t007-toast-error-color: #e74c3c;
6
+ --t007-toast-warning-color: #f1c40f;
7
+ --t007-toast-background: rgb(from black r g b/.4);
8
+ --t007-toast-background-blur: 10px;
9
+ --t007-toast-animation-duration: 250ms;
10
+ --t007-toast-animation-timing-function: cubic-bezier(0.68, -0.55, 0.27, 1.55);
11
+ --t007-toast-container-position: fixed;
12
+ --t007-toast-border: unset;
13
+ --t007-toast-box-shadow: 0 2px 4px rgba(0, 0, 0, 0.06), 0 6px 16px rgba(0, 0, 0, 0.08);
14
+ --t007-toast-icon-line-height: 1.25;
15
+ --t007-toast-image-background: black;
16
+ --t007-toast-text-stroke: 0.15px rgba(0, 0, 0, 0.35);
17
+ --t007-toast-text-shadow: 0px 0px 2px rgba(0, 0, 0, 0.5);
18
+ --t007-toast-max-lines: 7;
19
+ --t007-toast-action-button-border: none;
20
+ --t007-toast-action-button-font-weight: 500;
21
+ --t007-toast-x-color: red;
22
+ }
23
+
24
+ :where(:root, .t007-toast) {
25
+ --t007-toast-type-color: whitesmoke;
26
+ --t007-toast-focus-visible-color: var(--t007-toast-font-color);
27
+ --t007-toast-focus-visible-outline: 2px solid var(--t007-toast-focus-visible-color);
28
+ --t007-toast-progress-background: var(--t007-toast-type-color);
29
+ --t007-toast-progress-backdrop-background: rgb(from var(--t007-toast-type-color) r g b / 0);
30
+ --t007-toast-font-color: var(--t007-toast-type-color);
31
+ --t007-toast-action-button-color: var(--t007-toast-font-color);
32
+ --t007-toast-action-button-active-color: var(--t007-toast-action-button-color);
33
+ --t007-toast-action-button-background: rgba(from currentColor r g b / 0.1);
34
+ --t007-toast-action-button-active-background: rgba(from currentColor r g b / 0.2);
35
+ }
36
+
37
+ :where(:root, .t007-toast-container) {
38
+ --t007-toast-unit: 1rem;
39
+ --t007-toast-container-margin-top: calc(var(--t007-toast-unit) / 2);
40
+ --t007-toast-container-margin-bottom: calc(var(--t007-toast-unit) / 2);
41
+ --t007-toast-container-margin-left: calc(var(--t007-toast-unit) / 2);
42
+ --t007-toast-container-margin-right: calc(var(--t007-toast-unit) / 2);
43
+ --t007-toast-container-gap: calc(var(--t007-toast-unit) / 2);
44
+ --t007-toast-min-width: unset;
45
+ --t007-toast-width: calc(var(--t007-toast-unit) * 20);
46
+ --t007-toast-max-width: 100%;
47
+ --t007-toast-min-height: 4.25rem;
48
+ --t007-toast-height: fit-content;
49
+ --t007-toast-max-height: calc(var(--t007-toast-unit) * 8.5);
50
+ --t007-toast-padding: calc(var(--t007-toast-unit) / 2.25);
51
+ --t007-toast-smart-padding-left: calc(var(--t007-toast-padding) * 2.25);
52
+ --t007-toast-smart-padding-right: calc(var(--t007-toast-smart-padding-left) - (var(--t007-toast-action-button-padding-inline) / 2));
53
+ --t007-toast-gap: var(--t007-toast-padding);
54
+ --t007-toast-border-radius: calc(var(--t007-toast-unit) / 3);
55
+ --t007-toast-progress-height: calc(var(--t007-toast-unit) / 5);
56
+ --t007-toast-image-width: calc(var(--t007-toast-unit) * 3.5);
57
+ --t007-toast-image-height: calc(var(--t007-toast-unit) * 3.5);
58
+ --t007-toast-image-border-radius: calc(var(--t007-toast-border-radius) - (var(--t007-toast-padding) / 2));
59
+ --t007-toast-image-object-fit: cover;
60
+ --t007-toast-actions-container-width: 65%;
61
+ --t007-toast-actions-container-max-width: fit-content;
62
+ --t007-toast-actions-container-gap: calc(var(--t007-toast-unit) / 4);
63
+ --t007-toast-action-button-font-size: calc(var(--t007-toast-font-size) / 1.1);
64
+ --t007-toast-action-button-padding-inline: calc(var(--t007-toast-unit) / 2.2);
65
+ --t007-toast-action-button-padding-block: calc(var(--t007-toast-unit) / 3.3);
66
+ --t007-toast-action-button-border-radius: calc(((var(--t007-toast-action-button-padding-block) * 2) + var(--t007-toast-font-size)) / 2);
67
+ --t007-toast-icon-width: calc(var(--t007-toast-unit) * 1.4);
68
+ --t007-toast-icon-height: calc(var(--t007-toast-unit) * 1.4);
69
+ --t007-toast-icon-font-size: calc(var(--t007-toast-icon-height) * 0.8);
70
+ --t007-toast-font-size: calc(var(--t007-toast-unit) / 1.05);
71
+ --t007-toast-font-weight: inherit;
72
+ --t007-toast-x-size: calc(var(--t007-toast-unit) * 1.75);
73
+ }
74
+
75
+ @keyframes t007-x-slide-bounce-in {
76
+ from {
77
+ transform: translateX(var(--t-from));
78
+ }
79
+ 50% {
80
+ transform: translateX(var(--t-bounce));
81
+ }
82
+ to {
83
+ transform: translateX(var(--t-to));
84
+ }
85
+ }
86
+ @keyframes t007-x-slide-bounce-out {
87
+ from {
88
+ transform: translateX(var(--t-to));
89
+ }
90
+ 50% {
91
+ transform: translateX(var(--t-bounce));
92
+ }
93
+ to {
94
+ transform: translateX(var(--t-from));
95
+ }
96
+ }
97
+ @keyframes t007-y-slide-bounce-in {
98
+ from {
99
+ transform: translateY(var(--t-from));
100
+ }
101
+ 50% {
102
+ transform: translateY(var(--t-bounce));
103
+ }
104
+ to {
105
+ transform: translateY(var(--t-to));
106
+ }
107
+ }
108
+ @keyframes t007-y-slide-bounce-out {
109
+ from {
110
+ transform: translateY(var(--t-to));
111
+ }
112
+ 50% {
113
+ transform: translateY(var(--t-bounce));
114
+ }
115
+ to {
116
+ transform: translateY(var(--t-from));
117
+ }
118
+ }
119
+ @keyframes t007-fade-in {
120
+ from {
121
+ opacity: 0;
122
+ }
123
+ }
124
+ @keyframes t007-fade-out {
125
+ to {
126
+ opacity: 0;
127
+ }
128
+ }
129
+ @keyframes t007-zoom-in {
130
+ from {
131
+ transform: scale(0);
132
+ opacity: 0;
133
+ }
134
+ }
135
+ @keyframes t007-zoom-out {
136
+ to {
137
+ transform: scale(0);
138
+ opacity: 0;
139
+ }
140
+ }
141
+ @keyframes t007-icon-expand {
142
+ from {
143
+ transform: scale(0);
144
+ opacity: 0;
145
+ }
146
+ }
147
+ @keyframes t007-icon-handwave {
148
+ 0% {
149
+ transform: rotate(0deg) scale(1) translateZ(0);
150
+ }
151
+ 5% {
152
+ transform: rotate(15deg) scale(1.05) translate(1px, -1px) perspective(300px) rotateY(5deg);
153
+ }
154
+ 10% {
155
+ transform: rotate(-10deg) scale(0.98) translate(-1px, 2px) perspective(300px) rotateX(2deg);
156
+ }
157
+ 15% {
158
+ transform: rotate(12deg) scale(1.04) translate(2px, -1px) perspective(300px) rotateY(-3deg);
159
+ }
160
+ 20% {
161
+ transform: rotate(-8deg) scale(0.97) translate(-2px, 1px) perspective(300px) rotateX(-2deg);
162
+ }
163
+ 25% {
164
+ transform: rotate(10deg) scale(1.02) translate(1px, -1px);
165
+ }
166
+ 30% {
167
+ transform: rotate(-6deg) scale(0.99);
168
+ }
169
+ 35% {
170
+ transform: rotate(8deg);
171
+ }
172
+ 40% {
173
+ transform: rotate(-4deg);
174
+ }
175
+ 45% {
176
+ transform: rotate(4deg);
177
+ }
178
+ 50% {
179
+ transform: rotate(-2deg);
180
+ }
181
+ 55% {
182
+ transform: rotate(2deg);
183
+ }
184
+ 60% {
185
+ transform: rotate(-1deg);
186
+ }
187
+ 65% {
188
+ transform: rotate(1deg);
189
+ }
190
+ 70% {
191
+ transform: rotate(0deg) scale(1);
192
+ }
193
+ 100% {
194
+ transform: rotate(0deg) scale(1) translateZ(0);
195
+ }
196
+ }
197
+
198
+ .t007-toast-container,
199
+ .t007-toast-container *,
200
+ .t007-toast-container *::after,
201
+ .t007-toast-container *::before {
202
+ box-sizing: border-box;
203
+ font-family: var(--t007-toast-font-family);
204
+ }
205
+
206
+ .t007-toast-container *:focus-visible {
207
+ outline: var(--t007-toast-focus-visible-outline);
208
+ outline-offset: calc(var(--t007-toast-unit) / 7.5);
209
+ }
210
+
211
+ .t007-toast-container {
212
+ position: var(--t007-toast-container-position);
213
+ margin-top: var(--t007-toast-container-margin-top);
214
+ margin-bottom: var(--t007-toast-container-margin-bottom);
215
+ margin-left: var(--t007-toast-container-margin-left);
216
+ margin-right: var(--t007-toast-container-margin-right);
217
+ max-width: calc(100% - var(--t007-toast-container-margin-left) - var(--t007-toast-container-margin-right));
218
+ /* remove next block to clip container viewport, clips sliding too */
219
+ /* max-height: calc(100% - var(--t007-toast-container-margin-top) - var(--t007-toast-container-margin-bottom));
220
+ overflow: hidden; */
221
+ display: flex;
222
+ flex-direction: column;
223
+ gap: var(--t007-toast-container-gap);
224
+ z-index: 2147483647;
225
+ contain: layout;
226
+ }
227
+
228
+ .t007-toast-container *:disabled {
229
+ filter: grayscale(100%);
230
+ cursor: not-allowed;
231
+ }
232
+
233
+ .t007-toast-container[data-position^="top-"] {
234
+ top: 0;
235
+ }
236
+ .t007-toast-container[data-position^="bottom-"] {
237
+ bottom: 0;
238
+ }
239
+ .t007-toast-container[data-position^="center-"] {
240
+ top: 50%;
241
+ transform: translateY(-50%);
242
+ margin-block: 0;
243
+ }
244
+ .t007-toast-container[data-position$="-right"] {
245
+ right: 0;
246
+ }
247
+ .t007-toast-container[data-position$="-left"] {
248
+ left: 0;
249
+ }
250
+ .t007-toast-container[data-position$="-center"] {
251
+ left: 50%;
252
+ translate: -50%;
253
+ margin-inline: 0;
254
+ }
255
+
256
+ .t007-toast {
257
+ position: relative;
258
+ flex-shrink: 0;
259
+ display: flex;
260
+ align-items: center;
261
+ gap: var(--t007-toast-gap);
262
+ min-width: var(--t007-toast-min-width);
263
+ width: var(--t007-toast-width);
264
+ max-width: var(--t007-toast-max-width);
265
+ min-height: var(--t007-toast-min-height);
266
+ height: var(--t007-toast-height);
267
+ max-height: var(--t007-toast-max-height);
268
+ padding: var(--t007-toast-padding);
269
+ color: var(--t007-toast-font-color);
270
+ text-align: left;
271
+ font-size: var(--t007-toast-font-size);
272
+ font-weight: var(--t007-toast-font-weight);
273
+ -webkit-text-stroke: var(--t007-toast-text-stroke);
274
+ text-shadow: var(--t007-toast-text-shadow);
275
+ background: var(--t007-toast-background);
276
+ border: var(--t007-toast-border);
277
+ border-radius: var(--t007-toast-border-radius);
278
+ box-shadow: var(--t007-toast-box-shadow);
279
+ -webkit-backdrop-filter: blur(var(--t007-toast-background-blur));
280
+ backdrop-filter: blur(var(--t007-toast-background-blur));
281
+ overflow: hidden;
282
+ will-change: transform, opacity;
283
+ transition:
284
+ transform 300ms ease,
285
+ opacity 300ms ease;
286
+ animation-timing-function: var(--t007-toast-animation-timing-function);
287
+ animation-fill-mode: forwards;
288
+ animation-duration: var(--t007-toast-animation-duration);
289
+ touch-action: none;
290
+ }
291
+
292
+ .t007-toast:not(:has(.t007-toast-image, .t007-toast-icon:not(:empty))):has(.t007-toast-body) {
293
+ padding-left: max(var(--t007-toast-padding), var(--t007-toast-smart-padding-left));
294
+ }
295
+
296
+ .t007-toast:not(:has(.t007-toast-cancel-button)) {
297
+ padding-right: max(var(--t007-toast-padding), var(--t007-toast-smart-padding-right));
298
+ }
299
+
300
+ .t007-toast:is([data-drag-to-close="mouse"], [data-drag-to-close="true"]) {
301
+ cursor: grab;
302
+ }
303
+ .t007-toast:is([data-drag-to-close="mouse"], [data-drag-to-close="true"]):active {
304
+ cursor: grabbing;
305
+ }
306
+
307
+ .t007-toast[data-animation^="slide"] {
308
+ --t-to: 0;
309
+ }
310
+
311
+ .t007-toast[data-animation="slide-left"] {
312
+ --t-from: 100%;
313
+ --t-bounce: -0%;
314
+ }
315
+ .t007-toast[data-animation="slide-right"] {
316
+ --t-from: -100%;
317
+ --t-bounce: 10%;
318
+ }
319
+ .t007-toast[data-animation="slide-up"] {
320
+ --t-from: 100%;
321
+ --t-bounce: -10%;
322
+ }
323
+ .t007-toast[data-animation="slide-down"] {
324
+ --t-from: -100%;
325
+ --t-bounce: 10%;
326
+ }
327
+
328
+ .t007-toast:is([data-animation="slide-left"], [data-animation="slide-right"]) {
329
+ animation-name: t007-x-slide-bounce-out;
330
+ }
331
+ .t007-toast:is([data-animation="slide-left"], [data-animation="slide-right"]).t007-toast-show {
332
+ animation-name: t007-x-slide-bounce-in;
333
+ }
334
+
335
+ .t007-toast:is([data-animation="slide-up"], [data-animation="slide-down"]) {
336
+ animation-name: t007-y-slide-bounce-out;
337
+ }
338
+ .t007-toast:is([data-animation="slide-up"], [data-animation="slide-down"]).t007-toast-show {
339
+ animation-name: t007-y-slide-bounce-in;
340
+ }
341
+
342
+ .t007-toast[data-animation="fade"] {
343
+ animation-name: t007-fade-out;
344
+ }
345
+ .t007-toast[data-animation="fade"].t007-toast-show {
346
+ animation-name: t007-fade-in;
347
+ }
348
+
349
+ .t007-toast[data-animation="zoom"] {
350
+ animation-name: t007-zoom-out;
351
+ }
352
+ .t007-toast[data-animation="zoom"].t007-toast-show {
353
+ animation-name: t007-zoom-in;
354
+ }
355
+
356
+ .t007-toast:is(.info, .success, .error, .warning) {
357
+ --t007-toast-font-color: var(--t007-toast-type-color);
358
+ --t007-toast-progress-background: var(--t007-toast-type-color);
359
+ --t007-toast-progress-backdrop-background: rgb(from var(--t007-toast-type-color) r g b/0);
360
+ }
361
+
362
+ .t007-toast.info {
363
+ --t007-toast-type-color: var(--t007-toast-info-color);
364
+ }
365
+ .t007-toast.success {
366
+ --t007-toast-type-color: var(--t007-toast-success-color);
367
+ }
368
+ .t007-toast.error {
369
+ --t007-toast-type-color: var(--t007-toast-error-color);
370
+ }
371
+ .t007-toast.warning {
372
+ --t007-toast-type-color: var(--t007-toast-warning-color);
373
+ }
374
+
375
+ .t007-toast.progress::before,
376
+ .t007-toast.progress::after {
377
+ content: "";
378
+ position: absolute;
379
+ bottom: 0;
380
+ left: 0;
381
+ height: var(--t007-toast-progress-height);
382
+ transition: width ease;
383
+ }
384
+
385
+ .t007-toast.progress::before {
386
+ width: calc(var(--progress, 0) * 100%);
387
+ background: var(--t007-toast-progress-background);
388
+ }
389
+
390
+ .t007-toast.progress::after {
391
+ width: 100%;
392
+ background: var(--t007-toast-progress-backdrop-background);
393
+ }
394
+
395
+ .t007-toast-image-wrapper {
396
+ position: relative;
397
+ flex: 0 0 var(--t007-toast-image-width);
398
+ width: var(--t007-toast-image-width);
399
+ height: var(--t007-toast-image-height);
400
+ border-radius: var(--t007-toast-image-border-radius);
401
+ overflow: hidden;
402
+ }
403
+
404
+ .t007-toast-image-wrapper:not(:has(.t007-toast-image)) {
405
+ flex: 0 0 var(--t007-toast-icon-width);
406
+ width: var(--t007-toast-icon-width);
407
+ height: var(--t007-toast-icon-height);
408
+ margin-left: calc(var(--t007-toast-unit) / 5);
409
+ background: transparent;
410
+ border-radius: 0;
411
+ overflow: visible;
412
+ }
413
+
414
+ .t007-toast-image-wrapper:not(:has(.t007-toast-image, .t007-toast-icon:not(:empty))) {
415
+ display: none;
416
+ }
417
+
418
+ .t007-toast-icon {
419
+ position: absolute;
420
+ inset: 0;
421
+ margin: auto;
422
+ display: flex;
423
+ justify-content: center;
424
+ align-items: center;
425
+ font-size: var(--t007-toast-icon-font-size);
426
+ line-height: var(--t007-toast-icon-line-height);
427
+ }
428
+ .t007-toast-icon:where(:not(.t007-toast-loader)) {
429
+ animation: t007-icon-expand 300ms ease;
430
+ }
431
+ .t007-toast-icon[data-icon="👋"] {
432
+ transform-origin: bottom center;
433
+ animation: t007-icon-handwave 1800ms ease-in-out 2 1000ms; /* just a progressive enhancement surprise */
434
+ will-change: transform;
435
+ }
436
+
437
+ .t007-toast .t007-toast-icon > svg {
438
+ width: var(--t007-toast-icon-width);
439
+ height: var(--t007-toast-icon-height);
440
+ }
441
+
442
+ .t007-toast-image-wrapper .t007-toast-image {
443
+ min-height: 100%;
444
+ height: 100%;
445
+ min-width: 100%;
446
+ width: 100%;
447
+ object-fit: var(--t007-toast-image-object-fit);
448
+ background: var(--t007-toast-no-image-background);
449
+ }
450
+
451
+ .t007-toast-image-wrapper [data-loaded="true"] {
452
+ background: var(--t007-toast-image-background);
453
+ }
454
+
455
+ .t007-toast-body {
456
+ flex-grow: 1;
457
+ height: fit-content;
458
+ border-radius: calc(var(--t007-toast-unit) / 5);
459
+ padding: calc(var(--t007-toast-unit) / 7.5);
460
+ overflow: hidden;
461
+ }
462
+
463
+ .t007-toast-body-text {
464
+ display: -webkit-box;
465
+ -webkit-box-orient: vertical;
466
+ -webkit-line-clamp: var(--t007-toast-max-lines);
467
+ line-clamp: var(--t007-toast-max-lines);
468
+ margin: 0;
469
+ z-index: 1;
470
+ }
471
+
472
+ .t007-toast-actions-wrapper {
473
+ width: var(--t007-toast-actions-container-width);
474
+ max-width: var(--t007-toast-actions-container-max-width);
475
+ display: flex;
476
+ justify-content: center;
477
+ flex-wrap: wrap;
478
+ gap: var(--t007-toast-actions-container-gap);
479
+ }
480
+
481
+ .t007-toast-action-button {
482
+ display: flex;
483
+ justify-content: center;
484
+ align-items: center;
485
+ color: var(--t007-toast-action-button-color);
486
+ font-size: var(--t007-toast-action-button-font-size);
487
+ font-weight: var(--t007-toast-action-button-font-weight);
488
+ padding-block: var(--t007-toast-action-button-padding-block);
489
+ padding-inline: var(--t007-toast-action-button-padding-inline);
490
+ background: var(--t007-toast-action-button-background);
491
+ border: var(--t007-toast-action-button-border);
492
+ border-radius: var(--t007-toast-action-button-border-radius);
493
+ opacity: 0.9;
494
+ transition:
495
+ opacity 200ms ease,
496
+ color 200ms ease,
497
+ background-color 200ms ease;
498
+ }
499
+
500
+ .t007-toast-action-button:is(:hover, :focus-visible) {
501
+ cursor: pointer;
502
+ opacity: 1;
503
+ color: var(--t007-toast-action-button-active-color);
504
+ background: var(--t007-toast-action-button-active-background);
505
+ }
506
+
507
+ .t007-toast-cancel-button {
508
+ display: flex;
509
+ align-self: start;
510
+ background: none;
511
+ padding: 0;
512
+ border: none;
513
+ line-height: 0.65;
514
+ color: var(--t007-toast-x-color);
515
+ font-size: var(--t007-toast-x-size);
516
+ opacity: 0.6;
517
+ }
518
+
519
+ .t007-toast-cancel-button:is(:hover, :focus-visible) {
520
+ cursor: pointer;
521
+ opacity: 1;
522
+ }
523
+
524
+ @media (max-width: 36rem) {
525
+ :where(:root) {
526
+ --t007-toast-unit: 0.9rem;
527
+ }
528
+ }
@@ -0,0 +1,147 @@
1
+ import "@t007/utils";
2
+
3
+ export type ToastType = "info" | "success" | "error" | "warning";
4
+ export type ToastPosition =
5
+ | "top-left"
6
+ | "top-center"
7
+ | "top-right"
8
+ | "bottom-left"
9
+ | "bottom-center"
10
+ | "bottom-right"
11
+ | "center-left"
12
+ | "center-center"
13
+ | "center-right";
14
+ export type ToastAnimation =
15
+ | "fade"
16
+ | "zoom"
17
+ | "slide"
18
+ | "slide-left"
19
+ | "slide-right"
20
+ | "slide-up"
21
+ | "slide-down"
22
+ | boolean;
23
+ export type ToastDragDir =
24
+ | "x"
25
+ | "y"
26
+ | "xy"
27
+ | "x|y"
28
+ | "x||y"
29
+ | "x+"
30
+ | "x-"
31
+ | "y+"
32
+ | "y-"
33
+ | "xy+"
34
+ | "xy-"
35
+ | "x|y+"
36
+ | "x|y-"
37
+ | "x||y+"
38
+ | "x||y-";
39
+
40
+ export interface ToastOptions {
41
+ id?: string;
42
+ idPrefix?: string;
43
+ delay?: number | null;
44
+ rootElement?: HTMLElement;
45
+ render?: string | (() => string);
46
+ bodyHTML?: string | (() => string);
47
+ type?: ToastType;
48
+ icon?: string | boolean;
49
+ image?: string | false;
50
+ autoClose?: number | boolean;
51
+ position?: ToastPosition;
52
+ isLoading?: boolean | string;
53
+ closeButton?: boolean;
54
+ closeOnClick?: boolean;
55
+ hideProgressBar?: boolean;
56
+ pauseOnHover?: boolean;
57
+ pauseOnFocusLoss?: boolean;
58
+ dragToClose?: boolean | "mouse" | "pen" | "touch";
59
+ dragToClosePercent?: number | { x?: number; y?: number };
60
+ dragToCloseDir?: ToastDragDir;
61
+ renotify?: boolean;
62
+ tag?: string | number;
63
+ vibrate?: boolean | number[];
64
+ animation?: ToastAnimation;
65
+ newestOnTop?: boolean;
66
+ maxToasts?: number;
67
+ actions?: Record<string, (e: MouseEvent, toast: ToastInstance) => void>;
68
+ onClose?: (timeElapsed?: boolean | false) => void;
69
+ onTimeUpdate?: (timeVisible: number) => void;
70
+ [key: string]: any; // To allow arbitrary overrides internally if needed
71
+ }
72
+
73
+ export interface ToastInstance {
74
+ id: string;
75
+ opts: ToastOptions;
76
+ queue: number[];
77
+ destroyed: boolean;
78
+ toastElement: HTMLElement;
79
+ init(): void;
80
+ update(options: ToastOptions): string;
81
+ play(): void;
82
+ pause(): void;
83
+ _remove(manner?: "smooth" | "instant", timeElapsed?: boolean): void;
84
+ }
85
+
86
+ export interface ToastPromiseState<T = any> extends Omit<ToastOptions, "render" | "bodyHTML"> {
87
+ render?: string | ((response: T) => string);
88
+ bodyHTML?: string | ((response: T) => string);
89
+ }
90
+
91
+ export interface ToastPromiseConfig<T = any> {
92
+ pending?: string | ToastOptions;
93
+ success?: string | ToastPromiseState<T>;
94
+ error?: string | ToastPromiseState<any>;
95
+ }
96
+
97
+ export interface Toast {
98
+ (render?: string, options?: ToastOptions): string;
99
+ update(id: string, options: ToastOptions): string | false;
100
+ info(render?: string, options?: ToastOptions): string;
101
+ success(render?: string, options?: ToastOptions): string;
102
+ warn(render?: string, options?: ToastOptions): string;
103
+ error(render?: string, options?: ToastOptions): string;
104
+ loading(render?: string, options?: ToastOptions): string;
105
+ promise<T>(promise: Promise<T>, options?: ToastPromiseConfig<T>): Promise<T>;
106
+ dismiss(id?: string, manner?: "smooth" | "instant", timeElapsed?: boolean): void;
107
+ dismissAll(idPrefix?: string): void;
108
+ doForAll(action: string, options?: any, idPrefix?: string): void;
109
+ getAll(idPrefix?: string): ToastInstance[];
110
+ }
111
+
112
+ export interface Toasting {
113
+ update(base: Toast, id: string, options: ToastOptions): boolean | string;
114
+ message(base: Toast, defaults: () => ToastOptions, action: string): void;
115
+ loading(base: Toast, renderOrId: string, options?: ToastOptions): string;
116
+ promise<T>(base: Toast, promise: Promise<T>, config?: ToastPromiseConfig<T>): Promise<T>;
117
+ dismiss(base: Toast, id?: string, manner?: string, timeElapsed?: boolean): void;
118
+ dismissAll(base: Toast, idPrefix?: string): void;
119
+ doForAll(base: Toast, action: string, options?: any, idPrefix?: string): void;
120
+ getAll(base: Toast, idPrefix?: string): ToastInstance[];
121
+ }
122
+
123
+ // BUNDLE EXPORTS & GLOBAL DECLARATIONS
124
+ export const toasting: Toasting;
125
+ export function toaster(defOptions?: ToastOptions, idPrefix?: string): Toast;
126
+ declare const toast: Toast;
127
+ export default toast;
128
+
129
+ declare global {
130
+ interface T007Namespace {
131
+ toast: Toast;
132
+ toasting: Toasting;
133
+ toaster: typeof toaster;
134
+ toasts: Map<string, ToastInstance>;
135
+ TOAST_DEFAULT_OPTIONS: ToastOptions;
136
+ TOAST_DURATIONS: Record<ToastType, number>;
137
+ TOAST_VIBRATIONS: Record<ToastType, number[]>;
138
+ TOAST_ICONS: Record<ToastType | "loading", string>;
139
+ }
140
+
141
+ interface Window {
142
+ T007_TOAST_CSS_SRC?: string;
143
+ T007_TOAST_JS_SRC?: string;
144
+
145
+ Toast?: Toast;
146
+ }
147
+ }