@starasia/toast 1.0.3 → 3.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/dist/toast.es.js +192 -192
- package/dist/toast.umd.js +121 -125
- package/package.json +6 -6
package/dist/toast.es.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import
|
|
1
|
+
import { jsx as s, jsxs as x } from "react/jsx-runtime";
|
|
2
|
+
import b, { useState as p, useRef as k, useEffect as v } from "react";
|
|
3
3
|
import C from "react-dom";
|
|
4
4
|
const L = `@import url("https://fonts.googleapis.com/css2?family=Poppins&display=swap");
|
|
5
5
|
|
|
@@ -11,185 +11,181 @@ const L = `@import url("https://fonts.googleapis.com/css2?family=Poppins&display
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
:root {
|
|
14
|
-
/*
|
|
15
|
-
--
|
|
14
|
+
/* solid default (dark bg) */
|
|
15
|
+
--sa-toast-solid-bg-default: var(--sa-text-bolder, #1e1f21);
|
|
16
|
+
--sa-toast-solid-text-default: var(--sa-text-primary-inverse, #ffffff);
|
|
17
|
+
--sa-toast-solid-border-default: var(--sa-border-subtle, #0b120e24);
|
|
16
18
|
|
|
17
|
-
/*
|
|
18
|
-
--
|
|
19
|
-
--
|
|
20
|
-
--
|
|
19
|
+
/* outline default */
|
|
20
|
+
--sa-toast-outline-bg-default: var(--sa-background-primary, #ffffff);
|
|
21
|
+
--sa-toast-outline-text-default: var(--sa-text-primary, #292a2e);
|
|
22
|
+
--sa-toast-outline-border-default: var(--sa-border-subtle, #0b120e24);
|
|
23
|
+
--sa-toast-outline-progress-default: var(--sa-text-bolder, #1e1f21);
|
|
21
24
|
|
|
22
|
-
/*
|
|
23
|
-
--
|
|
24
|
-
--
|
|
25
|
-
--
|
|
26
|
-
--
|
|
25
|
+
/* outline danger */
|
|
26
|
+
--sa-toast-outline-bg-danger: var(--sa-background-error-subtlest, #fff0f3);
|
|
27
|
+
--sa-toast-outline-text-danger: var(--sa-background-error, #c9184a);
|
|
28
|
+
--sa-toast-outline-border-danger: var(--sa-color-error-100, #ffccd5);
|
|
29
|
+
--sa-toast-outline-progress-danger: var(--sa-background-error, #c9184a);
|
|
27
30
|
|
|
28
|
-
/*
|
|
29
|
-
--
|
|
30
|
-
--
|
|
31
|
-
--
|
|
32
|
-
--starasia-ui-outline-progress-danger: rgba(201, 24, 74, 1);
|
|
31
|
+
/* solid danger */
|
|
32
|
+
--sa-toast-solid-bg-danger: var(--sa-background-error, #c9184a);
|
|
33
|
+
--sa-toast-solid-text-danger: var(--sa-color-error-50, #fff0f3);
|
|
34
|
+
--sa-toast-solid-border-danger: var(--sa-background-error, #c9184a);
|
|
33
35
|
|
|
34
|
-
/*
|
|
35
|
-
--
|
|
36
|
-
--
|
|
37
|
-
--
|
|
36
|
+
/* outline success */
|
|
37
|
+
--sa-toast-outline-bg-success: var(--sa-background-success-subtlest, #ecfff6);
|
|
38
|
+
--sa-toast-outline-text-success: var(--sa-background-success, #28ac6e);
|
|
39
|
+
--sa-toast-outline-border-success: var(--sa-color-success-200, #97e6c1);
|
|
40
|
+
--sa-toast-outline-progress-success: var(--sa-background-success, #28ac6e);
|
|
38
41
|
|
|
39
|
-
/*
|
|
40
|
-
--
|
|
41
|
-
--
|
|
42
|
-
--
|
|
43
|
-
--starasia-ui-outline-progress-success: rgba(40, 172, 110, 1);
|
|
42
|
+
/* solid success */
|
|
43
|
+
--sa-toast-solid-bg-success: var(--sa-background-success, #28ac6e);
|
|
44
|
+
--sa-toast-solid-text-success: var(--sa-color-success-50, #ecfff6);
|
|
45
|
+
--sa-toast-solid-border-success: var(--sa-background-success, #28ac6e);
|
|
44
46
|
|
|
45
|
-
/*
|
|
46
|
-
--
|
|
47
|
-
--
|
|
48
|
-
--
|
|
47
|
+
/* outline info */
|
|
48
|
+
--sa-toast-outline-bg-info: var(--sa-background-info-subtlest, #effaff);
|
|
49
|
+
--sa-toast-outline-text-info: var(--sa-background-info, #0090d4);
|
|
50
|
+
--sa-toast-outline-border-info: var(--sa-color-info-200, #b6eaff);
|
|
51
|
+
--sa-toast-outline-progress-info: var(--sa-background-info, #0090d4);
|
|
49
52
|
|
|
50
|
-
/*
|
|
51
|
-
--
|
|
52
|
-
--
|
|
53
|
-
--
|
|
54
|
-
--starasia-ui-outline-progress-info: rgba(25, 118, 210, 1);
|
|
53
|
+
/* solid info */
|
|
54
|
+
--sa-toast-solid-bg-info: var(--sa-background-info, #0090d4);
|
|
55
|
+
--sa-toast-solid-text-info: var(--sa-color-info-50, #effaff);
|
|
56
|
+
--sa-toast-solid-border-info: var(--sa-background-info, #0090d4);
|
|
55
57
|
|
|
56
|
-
/*
|
|
57
|
-
--
|
|
58
|
-
--
|
|
59
|
-
--
|
|
58
|
+
/* outline warning */
|
|
59
|
+
--sa-toast-outline-bg-warning: var(--sa-background-warning-subtlest, #fef2e6);
|
|
60
|
+
--sa-toast-outline-text-warning: var(--sa-text-primary, #292a2e);
|
|
61
|
+
--sa-toast-outline-border-warning: var(--sa-color-warning-200, #f4c583);
|
|
62
|
+
--sa-toast-outline-progress-warning: var(--sa-color-warning-400, #ed9f30);
|
|
60
63
|
|
|
61
|
-
/*
|
|
62
|
-
--
|
|
63
|
-
--
|
|
64
|
-
--
|
|
65
|
-
--starasia-ui-outline-progress-warning: rgba(237, 159, 48, 1);
|
|
64
|
+
/* solid warning */
|
|
65
|
+
--sa-toast-solid-bg-warning: var(--sa-color-warning-400, #ed9f30);
|
|
66
|
+
--sa-toast-solid-text-warning: var(--sa-background-primary, #ffffff);
|
|
67
|
+
--sa-toast-solid-border-warning: var(--sa-color-warning-400, #ed9f30);
|
|
66
68
|
|
|
67
|
-
|
|
68
|
-
--starasia-ui-solid-background-warning: rgba(237, 159, 48, 1);
|
|
69
|
-
--starasia-ui-solid-color-warning: var(--starasia-ui-toast-color-white);
|
|
70
|
-
--starasia-ui-solid-border-warning: rgba(237, 159, 48, 1);
|
|
71
|
-
|
|
72
|
-
/* height */
|
|
73
|
-
--starasia-ui-h-0-5: 0.125rem; /* 2px */
|
|
69
|
+
--sa-toast-h-progress: 0.125rem;
|
|
74
70
|
}
|
|
75
71
|
/* styling for container */
|
|
76
|
-
.
|
|
72
|
+
.sa-toast-container {
|
|
77
73
|
display: flex;
|
|
78
74
|
flex-direction: column;
|
|
79
|
-
gap: var(--
|
|
80
|
-
padding: var(--
|
|
75
|
+
gap: var(--sa-spacing-xs, 4px);
|
|
76
|
+
padding: var(--sa-spacing-sm, 8px);
|
|
81
77
|
position: fixed;
|
|
82
78
|
max-height: 100vh;
|
|
83
79
|
overflow: auto;
|
|
84
80
|
z-index: 99999;
|
|
85
81
|
}
|
|
86
|
-
.
|
|
82
|
+
.sa-toast-container-bottom-right {
|
|
87
83
|
bottom: 0;
|
|
88
84
|
right: 0;
|
|
89
85
|
}
|
|
90
|
-
.
|
|
86
|
+
.sa-toast-container-bottom-left {
|
|
91
87
|
bottom: 0;
|
|
92
88
|
left: 0;
|
|
93
89
|
}
|
|
94
|
-
.
|
|
90
|
+
.sa-toast-container-bottom-center {
|
|
95
91
|
bottom: 0;
|
|
96
92
|
left: 50%;
|
|
97
93
|
transform: translateX(-50%);
|
|
98
94
|
}
|
|
99
|
-
.
|
|
95
|
+
.sa-toast-container-top-right {
|
|
100
96
|
top: 0;
|
|
101
97
|
right: 0;
|
|
102
98
|
}
|
|
103
|
-
.
|
|
99
|
+
.sa-toast-container-top-left {
|
|
104
100
|
top: 0;
|
|
105
101
|
left: 0;
|
|
106
102
|
}
|
|
107
|
-
.
|
|
103
|
+
.sa-toast-container-top-center {
|
|
108
104
|
top: 0;
|
|
109
105
|
left: 50%;
|
|
110
106
|
transform: translateX(-50%);
|
|
111
107
|
}
|
|
112
108
|
/* styling for */
|
|
113
|
-
.
|
|
114
|
-
padding: var(--
|
|
109
|
+
.sa-toast-item-container {
|
|
110
|
+
padding: var(--sa-spacing-lg, 16px);
|
|
115
111
|
width: max-content;
|
|
116
|
-
border-radius: var(--
|
|
112
|
+
border-radius: var(--sa-radii-md, 6px);
|
|
117
113
|
display: flex;
|
|
118
114
|
align-items: center;
|
|
119
|
-
gap: var(--
|
|
120
|
-
border: var(--
|
|
121
|
-
font-size: var(--
|
|
115
|
+
gap: var(--sa-spacing-sm, 8px);
|
|
116
|
+
border: var(--sa-border, 1px) solid transparent;
|
|
117
|
+
font-size: var(--sa-font-size-md, 14px);
|
|
122
118
|
position: relative;
|
|
123
119
|
overflow: hidden;
|
|
124
120
|
width: 100%;
|
|
125
121
|
}
|
|
126
122
|
/* DEFAULT TOAST */
|
|
127
|
-
.
|
|
128
|
-
background-color: var(--
|
|
129
|
-
color: var(--
|
|
130
|
-
border-color: var(--
|
|
123
|
+
.sa-toast-item-container-solid-default {
|
|
124
|
+
background-color: var(--sa-toast-solid-bg-default);
|
|
125
|
+
color: var(--sa-toast-solid-text-default);
|
|
126
|
+
border-color: var(--sa-toast-solid-border-default);
|
|
131
127
|
}
|
|
132
128
|
|
|
133
|
-
.
|
|
134
|
-
background-color: var(--
|
|
135
|
-
color: var(--
|
|
136
|
-
border-color: var(--
|
|
129
|
+
.sa-toast-item-container-outline-default {
|
|
130
|
+
background-color: var(--sa-toast-outline-bg-default);
|
|
131
|
+
color: var(--sa-toast-outline-text-default);
|
|
132
|
+
border-color: var(--sa-toast-outline-border-default);
|
|
137
133
|
}
|
|
138
134
|
|
|
139
135
|
/* DEFAULT DANGER */
|
|
140
|
-
.
|
|
141
|
-
background-color: var(--
|
|
142
|
-
color: var(--
|
|
143
|
-
border-color: var(--
|
|
136
|
+
.sa-toast-item-container-outline-danger {
|
|
137
|
+
background-color: var(--sa-toast-outline-bg-danger);
|
|
138
|
+
color: var(--sa-toast-outline-text-danger);
|
|
139
|
+
border-color: var(--sa-toast-outline-border-danger);
|
|
144
140
|
}
|
|
145
141
|
|
|
146
|
-
.
|
|
147
|
-
background-color: var(--
|
|
148
|
-
color: var(--
|
|
149
|
-
border-color: var(--
|
|
142
|
+
.sa-toast-item-container-solid-danger {
|
|
143
|
+
background-color: var(--sa-toast-solid-bg-danger);
|
|
144
|
+
color: var(--sa-toast-solid-text-danger);
|
|
145
|
+
border-color: var(--sa-toast-solid-border-danger);
|
|
150
146
|
}
|
|
151
147
|
|
|
152
148
|
/* DEFAULT SUCCESS */
|
|
153
|
-
.
|
|
154
|
-
background-color: var(--
|
|
155
|
-
color: var(--
|
|
156
|
-
border-color: var(--
|
|
149
|
+
.sa-toast-item-container-outline-success {
|
|
150
|
+
background-color: var(--sa-toast-outline-bg-success);
|
|
151
|
+
color: var(--sa-toast-outline-text-success);
|
|
152
|
+
border-color: var(--sa-toast-outline-border-success);
|
|
157
153
|
}
|
|
158
154
|
|
|
159
|
-
.
|
|
160
|
-
background-color: var(--
|
|
161
|
-
color: var(--
|
|
162
|
-
border-color: var(--
|
|
155
|
+
.sa-toast-item-container-solid-success {
|
|
156
|
+
background-color: var(--sa-toast-solid-bg-success);
|
|
157
|
+
color: var(--sa-toast-solid-text-success);
|
|
158
|
+
border-color: var(--sa-toast-solid-border-success);
|
|
163
159
|
}
|
|
164
160
|
|
|
165
161
|
/* DEFAULT INFO */
|
|
166
|
-
.
|
|
167
|
-
background-color: var(--
|
|
168
|
-
color: var(--
|
|
169
|
-
border-color: var(--
|
|
162
|
+
.sa-toast-item-container-outline-info {
|
|
163
|
+
background-color: var(--sa-toast-outline-bg-info);
|
|
164
|
+
color: var(--sa-toast-outline-text-info);
|
|
165
|
+
border-color: var(--sa-toast-outline-border-info);
|
|
170
166
|
}
|
|
171
167
|
|
|
172
|
-
.
|
|
173
|
-
background-color: var(--
|
|
174
|
-
color: var(--
|
|
175
|
-
border-color: var(--
|
|
168
|
+
.sa-toast-item-container-solid-info {
|
|
169
|
+
background-color: var(--sa-toast-solid-bg-info);
|
|
170
|
+
color: var(--sa-toast-solid-text-info);
|
|
171
|
+
border-color: var(--sa-toast-solid-border-info);
|
|
176
172
|
}
|
|
177
173
|
/* DEFAULT WARNING */
|
|
178
|
-
.
|
|
179
|
-
background-color: var(--
|
|
180
|
-
color: var(--
|
|
181
|
-
border-color: var(--
|
|
174
|
+
.sa-toast-item-container-outline-warning {
|
|
175
|
+
background-color: var(--sa-toast-outline-bg-warning);
|
|
176
|
+
color: var(--sa-toast-outline-text-warning);
|
|
177
|
+
border-color: var(--sa-toast-outline-border-warning);
|
|
182
178
|
}
|
|
183
179
|
|
|
184
|
-
.
|
|
185
|
-
background-color: var(--
|
|
186
|
-
color: var(--
|
|
187
|
-
border-color: var(--
|
|
180
|
+
.sa-toast-item-container-solid-warning {
|
|
181
|
+
background-color: var(--sa-toast-solid-bg-warning);
|
|
182
|
+
color: var(--sa-toast-solid-text-warning);
|
|
183
|
+
border-color: var(--sa-toast-solid-border-warning);
|
|
188
184
|
}
|
|
189
185
|
|
|
190
186
|
/* PROGRESS BAR */
|
|
191
|
-
.
|
|
192
|
-
height: var(--
|
|
187
|
+
.sa-toast-item-progress {
|
|
188
|
+
height: var(--sa-toast-h-progress);
|
|
193
189
|
width: 100%;
|
|
194
190
|
position: absolute;
|
|
195
191
|
bottom: 0;
|
|
@@ -198,39 +194,39 @@ const L = `@import url("https://fonts.googleapis.com/css2?family=Poppins&display
|
|
|
198
194
|
animation: progressBarr 5s linear forwards;
|
|
199
195
|
}
|
|
200
196
|
|
|
201
|
-
.
|
|
202
|
-
background-color: var(--
|
|
197
|
+
.sa-toast-item-progress-outline-default {
|
|
198
|
+
background-color: var(--sa-toast-outline-progress-default);
|
|
203
199
|
}
|
|
204
|
-
.
|
|
205
|
-
background-color: var(--
|
|
200
|
+
.sa-toast-item-progress-outline-info {
|
|
201
|
+
background-color: var(--sa-toast-outline-progress-info);
|
|
206
202
|
}
|
|
207
|
-
.
|
|
208
|
-
background-color: var(--
|
|
203
|
+
.sa-toast-item-progress-outline-success {
|
|
204
|
+
background-color: var(--sa-toast-outline-progress-success);
|
|
209
205
|
}
|
|
210
|
-
.
|
|
211
|
-
background-color: var(--
|
|
206
|
+
.sa-toast-item-progress-outline-danger {
|
|
207
|
+
background-color: var(--sa-toast-outline-progress-danger);
|
|
212
208
|
}
|
|
213
|
-
.
|
|
214
|
-
background-color: var(--
|
|
209
|
+
.sa-toast-item-progress-outline-warning {
|
|
210
|
+
background-color: var(--sa-toast-outline-progress-warning);
|
|
215
211
|
}
|
|
216
212
|
|
|
217
213
|
/* animation */
|
|
218
|
-
.
|
|
214
|
+
.sa-toast-item-container-animation-bottom-right {
|
|
219
215
|
animation: bottomRight 0.375s;
|
|
220
216
|
}
|
|
221
|
-
.
|
|
217
|
+
.sa-toast-item-container-animation-bottom-left {
|
|
222
218
|
animation: bottomLeft 0.375s;
|
|
223
219
|
}
|
|
224
|
-
.
|
|
220
|
+
.sa-toast-item-container-animation-bottom-center {
|
|
225
221
|
animation: bottomCenter 0.375s;
|
|
226
222
|
}
|
|
227
|
-
.
|
|
223
|
+
.sa-toast-item-container-animation-top-left {
|
|
228
224
|
animation: topLeft 0.375s;
|
|
229
225
|
}
|
|
230
|
-
.
|
|
226
|
+
.sa-toast-item-container-animation-top-right {
|
|
231
227
|
animation: topRight 0.375s;
|
|
232
228
|
}
|
|
233
|
-
.
|
|
229
|
+
.sa-toast-item-container-animation-top-center {
|
|
234
230
|
animation: topCenter 0.375s;
|
|
235
231
|
}
|
|
236
232
|
|
|
@@ -306,120 +302,124 @@ const L = `@import url("https://fonts.googleapis.com/css2?family=Poppins&display
|
|
|
306
302
|
let E = 1;
|
|
307
303
|
class T {
|
|
308
304
|
constructor() {
|
|
309
|
-
this.subscribe = (
|
|
310
|
-
const
|
|
311
|
-
this.subscribers.splice(
|
|
312
|
-
}), this.publish = (
|
|
313
|
-
this.subscribers.forEach((
|
|
314
|
-
}, this.addToast = (
|
|
315
|
-
this.publish(
|
|
316
|
-
}, this.create = (
|
|
317
|
-
const { message:
|
|
318
|
-
return this.addToast({ title:
|
|
319
|
-
}, this.dismiss = (
|
|
305
|
+
this.subscribe = (t) => (this.subscribers.push(t), () => {
|
|
306
|
+
const a = this.subscribers.indexOf(t);
|
|
307
|
+
this.subscribers.splice(a, 1);
|
|
308
|
+
}), this.publish = (t) => {
|
|
309
|
+
this.subscribers.forEach((a) => a(t));
|
|
310
|
+
}, this.addToast = (t) => {
|
|
311
|
+
this.publish(t), this.toasts = [...this.toasts, t];
|
|
312
|
+
}, this.create = (t) => {
|
|
313
|
+
const { message: a, type: e } = t, o = E++;
|
|
314
|
+
return this.addToast({ title: a, type: e, id: o }), o;
|
|
315
|
+
}, this.dismiss = (t) => (this.subscribers.forEach((a) => a({ id: t, dismiss: !0 })), t), this.danger = (t) => this.create({ message: t, type: "danger" }), this.warning = (t) => this.create({ message: t, type: "warning" }), this.success = (t) => this.create({ type: "success", message: t }), this.info = (t) => this.create({ type: "info", message: t }), this.default = (t) => this.create({ type: "default", message: t }), this.subscribers = [], this.toasts = [];
|
|
320
316
|
}
|
|
321
317
|
}
|
|
322
|
-
const
|
|
323
|
-
success:
|
|
324
|
-
info:
|
|
325
|
-
default:
|
|
326
|
-
danger:
|
|
327
|
-
warning:
|
|
328
|
-
}),
|
|
329
|
-
if (!document.getElementById(
|
|
330
|
-
const
|
|
331
|
-
|
|
318
|
+
const r = new T(), D = Object.assign({
|
|
319
|
+
success: r.success,
|
|
320
|
+
info: r.info,
|
|
321
|
+
default: r.default,
|
|
322
|
+
danger: r.danger,
|
|
323
|
+
warning: r.warning
|
|
324
|
+
}), h = "sa-toast-styles", S = (n) => {
|
|
325
|
+
if (!document.getElementById(h)) {
|
|
326
|
+
const t = document.createElement("style");
|
|
327
|
+
t.id = h, t.textContent = n, document.head.appendChild(t);
|
|
332
328
|
}
|
|
333
329
|
};
|
|
334
330
|
S(L);
|
|
335
331
|
const N = ({
|
|
336
332
|
type: n = "outline",
|
|
337
|
-
direction:
|
|
333
|
+
direction: t = "bottom-right"
|
|
338
334
|
}) => {
|
|
339
|
-
const [
|
|
340
|
-
return
|
|
341
|
-
if (
|
|
342
|
-
|
|
335
|
+
const [a, e] = b.useState([]);
|
|
336
|
+
return b.useEffect(() => r.subscribe((o) => {
|
|
337
|
+
if (o.dismiss) {
|
|
338
|
+
e((i) => i.filter((d) => d.id !== o.id));
|
|
343
339
|
return;
|
|
344
340
|
}
|
|
345
341
|
setTimeout(() => {
|
|
346
342
|
C.flushSync(() => {
|
|
347
|
-
|
|
343
|
+
e((i) => [o, ...i]);
|
|
348
344
|
});
|
|
349
345
|
});
|
|
350
|
-
}), []), /* @__PURE__ */
|
|
346
|
+
}), []), /* @__PURE__ */ s(
|
|
351
347
|
"div",
|
|
352
348
|
{
|
|
353
|
-
className: `
|
|
354
|
-
children:
|
|
349
|
+
className: `sa-toast-container sa-toast-container-${t}`,
|
|
350
|
+
children: a.map((o) => /* @__PURE__ */ s(
|
|
355
351
|
R,
|
|
356
352
|
{
|
|
357
|
-
data:
|
|
353
|
+
data: o,
|
|
358
354
|
type: n,
|
|
359
|
-
direction:
|
|
355
|
+
direction: t
|
|
360
356
|
},
|
|
361
|
-
|
|
357
|
+
o.id
|
|
362
358
|
))
|
|
363
359
|
}
|
|
364
360
|
);
|
|
365
|
-
}, R = ({ data: n, type:
|
|
366
|
-
const [
|
|
367
|
-
const
|
|
368
|
-
|
|
361
|
+
}, R = ({ data: n, type: t = "solid", direction: a = "bottom-right" }) => {
|
|
362
|
+
const [e, o] = p(null), [i, d] = p(!1), l = k(null), f = () => {
|
|
363
|
+
const c = setTimeout(() => {
|
|
364
|
+
g();
|
|
369
365
|
}, 5e3);
|
|
370
|
-
|
|
371
|
-
},
|
|
372
|
-
|
|
373
|
-
},
|
|
374
|
-
|
|
366
|
+
o(c);
|
|
367
|
+
}, u = () => {
|
|
368
|
+
e && (clearTimeout(e), o(null));
|
|
369
|
+
}, g = () => {
|
|
370
|
+
r.dismiss(n.id);
|
|
375
371
|
};
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
}), [
|
|
379
|
-
const
|
|
380
|
-
|
|
372
|
+
v(() => (i ? u() : f(), () => {
|
|
373
|
+
u();
|
|
374
|
+
}), [i]), v(() => {
|
|
375
|
+
const c = l.current, m = () => {
|
|
376
|
+
g();
|
|
381
377
|
};
|
|
382
|
-
return
|
|
383
|
-
|
|
378
|
+
return c && c.addEventListener("animationend", m), () => {
|
|
379
|
+
c && c.removeEventListener("animationend", m);
|
|
384
380
|
};
|
|
385
381
|
}, []);
|
|
386
382
|
const y = () => {
|
|
387
|
-
|
|
383
|
+
d(!0), u(), l.current && (l.current.style.animationPlayState = "paused");
|
|
388
384
|
}, w = () => {
|
|
389
|
-
|
|
385
|
+
d(!1), f(), l.current && (l.current.style.animationPlayState = "running");
|
|
390
386
|
};
|
|
391
|
-
return /* @__PURE__ */
|
|
387
|
+
return /* @__PURE__ */ x(
|
|
392
388
|
"div",
|
|
393
389
|
{
|
|
394
|
-
className:
|
|
390
|
+
className: [
|
|
391
|
+
"sa-toast-item-container",
|
|
392
|
+
(n == null ? void 0 : n.type) && `sa-toast-item-container-${t}-${n.type}`,
|
|
393
|
+
`sa-toast-item-container-animation-${a}`
|
|
394
|
+
].filter(Boolean).join(" "),
|
|
395
395
|
onMouseEnter: y,
|
|
396
396
|
onMouseLeave: w,
|
|
397
397
|
children: [
|
|
398
|
-
/* @__PURE__ */
|
|
399
|
-
/* @__PURE__ */
|
|
400
|
-
/* @__PURE__ */
|
|
398
|
+
/* @__PURE__ */ s("div", { style: { display: "flex" }, children: n.type === "success" ? /* @__PURE__ */ s(M, { style: { color: "inherit" } }) : /* @__PURE__ */ s(I, { style: { color: "inherit" } }) }),
|
|
399
|
+
/* @__PURE__ */ s("div", { style: { flex: 1 }, children: n.title }),
|
|
400
|
+
/* @__PURE__ */ s(
|
|
401
401
|
"div",
|
|
402
402
|
{
|
|
403
403
|
style: { display: "flex", cursor: "pointer" },
|
|
404
|
-
onClick: () =>
|
|
405
|
-
children: /* @__PURE__ */
|
|
404
|
+
onClick: () => r.dismiss(n.id),
|
|
405
|
+
children: /* @__PURE__ */ s(B, { style: { color: "inherit" } })
|
|
406
406
|
}
|
|
407
407
|
),
|
|
408
|
-
|
|
408
|
+
t === "outline" ? /* @__PURE__ */ s(
|
|
409
409
|
"div",
|
|
410
410
|
{
|
|
411
411
|
ref: l,
|
|
412
|
-
className: `
|
|
412
|
+
className: `sa-toast-item-progress sa-toast-item-progress-outline-${n.type}`,
|
|
413
413
|
style: {
|
|
414
414
|
animation: "progressBarr 5s linear forwards",
|
|
415
|
-
animationPlayState:
|
|
415
|
+
animationPlayState: i ? "paused" : "running"
|
|
416
416
|
}
|
|
417
417
|
}
|
|
418
418
|
) : null
|
|
419
419
|
]
|
|
420
420
|
}
|
|
421
421
|
);
|
|
422
|
-
}, I = (n) => /* @__PURE__ */
|
|
422
|
+
}, I = (n) => /* @__PURE__ */ s(
|
|
423
423
|
"svg",
|
|
424
424
|
{
|
|
425
425
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -428,7 +428,7 @@ const N = ({
|
|
|
428
428
|
viewBox: "0 0 24 24",
|
|
429
429
|
fill: "none",
|
|
430
430
|
...n,
|
|
431
|
-
children: /* @__PURE__ */
|
|
431
|
+
children: /* @__PURE__ */ s(
|
|
432
432
|
"path",
|
|
433
433
|
{
|
|
434
434
|
d: "M12 7.01001V7.00002M12 17L12 10M21 12C21 16.9706 16.9706 21 12 21C7.02944 21 3 16.9706 3 12C3 7.02944 7.02944 3 12 3C16.9706 3 21 7.02944 21 12Z",
|
|
@@ -440,7 +440,7 @@ const N = ({
|
|
|
440
440
|
}
|
|
441
441
|
)
|
|
442
442
|
}
|
|
443
|
-
), M = (n) => /* @__PURE__ */
|
|
443
|
+
), M = (n) => /* @__PURE__ */ s(
|
|
444
444
|
"svg",
|
|
445
445
|
{
|
|
446
446
|
width: "20",
|
|
@@ -449,7 +449,7 @@ const N = ({
|
|
|
449
449
|
fill: "none",
|
|
450
450
|
xmlns: "http://www.w3.org/2000/svg",
|
|
451
451
|
...n,
|
|
452
|
-
children: /* @__PURE__ */
|
|
452
|
+
children: /* @__PURE__ */ s("g", { id: "Curved/Basic-actions-and-state", children: /* @__PURE__ */ s(
|
|
453
453
|
"path",
|
|
454
454
|
{
|
|
455
455
|
id: "shape",
|
|
@@ -461,7 +461,7 @@ const N = ({
|
|
|
461
461
|
}
|
|
462
462
|
) })
|
|
463
463
|
}
|
|
464
|
-
),
|
|
464
|
+
), B = (n) => /* @__PURE__ */ s(
|
|
465
465
|
"svg",
|
|
466
466
|
{
|
|
467
467
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -470,7 +470,7 @@ const N = ({
|
|
|
470
470
|
viewBox: "0 0 24 24",
|
|
471
471
|
fill: "none",
|
|
472
472
|
...n,
|
|
473
|
-
children: /* @__PURE__ */
|
|
473
|
+
children: /* @__PURE__ */ s(
|
|
474
474
|
"path",
|
|
475
475
|
{
|
|
476
476
|
d: "M19 5L5 19M5.00003 5L19 19",
|
package/dist/toast.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(r,n){typeof exports=="object"&&typeof module<"u"?n(exports,require("react/jsx-runtime"),require("react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react","react-dom"],n):(r=typeof globalThis<"u"?globalThis:r||self,n(r.Toast={},r.jsxRuntime,r.React,r.ReactDOM))})(this,function(r,n,i,h){"use strict";const y=`@import url("https://fonts.googleapis.com/css2?family=Poppins&display=swap");
|
|
2
2
|
|
|
3
3
|
* {
|
|
4
4
|
margin: 0;
|
|
@@ -8,185 +8,181 @@
|
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
:root {
|
|
11
|
-
/*
|
|
12
|
-
--
|
|
11
|
+
/* solid default (dark bg) */
|
|
12
|
+
--sa-toast-solid-bg-default: var(--sa-text-bolder, #1e1f21);
|
|
13
|
+
--sa-toast-solid-text-default: var(--sa-text-primary-inverse, #ffffff);
|
|
14
|
+
--sa-toast-solid-border-default: var(--sa-border-subtle, #0b120e24);
|
|
13
15
|
|
|
14
|
-
/*
|
|
15
|
-
--
|
|
16
|
-
--
|
|
17
|
-
--
|
|
16
|
+
/* outline default */
|
|
17
|
+
--sa-toast-outline-bg-default: var(--sa-background-primary, #ffffff);
|
|
18
|
+
--sa-toast-outline-text-default: var(--sa-text-primary, #292a2e);
|
|
19
|
+
--sa-toast-outline-border-default: var(--sa-border-subtle, #0b120e24);
|
|
20
|
+
--sa-toast-outline-progress-default: var(--sa-text-bolder, #1e1f21);
|
|
18
21
|
|
|
19
|
-
/*
|
|
20
|
-
--
|
|
21
|
-
--
|
|
22
|
-
--
|
|
23
|
-
--
|
|
22
|
+
/* outline danger */
|
|
23
|
+
--sa-toast-outline-bg-danger: var(--sa-background-error-subtlest, #fff0f3);
|
|
24
|
+
--sa-toast-outline-text-danger: var(--sa-background-error, #c9184a);
|
|
25
|
+
--sa-toast-outline-border-danger: var(--sa-color-error-100, #ffccd5);
|
|
26
|
+
--sa-toast-outline-progress-danger: var(--sa-background-error, #c9184a);
|
|
24
27
|
|
|
25
|
-
/*
|
|
26
|
-
--
|
|
27
|
-
--
|
|
28
|
-
--
|
|
29
|
-
--starasia-ui-outline-progress-danger: rgba(201, 24, 74, 1);
|
|
28
|
+
/* solid danger */
|
|
29
|
+
--sa-toast-solid-bg-danger: var(--sa-background-error, #c9184a);
|
|
30
|
+
--sa-toast-solid-text-danger: var(--sa-color-error-50, #fff0f3);
|
|
31
|
+
--sa-toast-solid-border-danger: var(--sa-background-error, #c9184a);
|
|
30
32
|
|
|
31
|
-
/*
|
|
32
|
-
--
|
|
33
|
-
--
|
|
34
|
-
--
|
|
33
|
+
/* outline success */
|
|
34
|
+
--sa-toast-outline-bg-success: var(--sa-background-success-subtlest, #ecfff6);
|
|
35
|
+
--sa-toast-outline-text-success: var(--sa-background-success, #28ac6e);
|
|
36
|
+
--sa-toast-outline-border-success: var(--sa-color-success-200, #97e6c1);
|
|
37
|
+
--sa-toast-outline-progress-success: var(--sa-background-success, #28ac6e);
|
|
35
38
|
|
|
36
|
-
/*
|
|
37
|
-
--
|
|
38
|
-
--
|
|
39
|
-
--
|
|
40
|
-
--starasia-ui-outline-progress-success: rgba(40, 172, 110, 1);
|
|
39
|
+
/* solid success */
|
|
40
|
+
--sa-toast-solid-bg-success: var(--sa-background-success, #28ac6e);
|
|
41
|
+
--sa-toast-solid-text-success: var(--sa-color-success-50, #ecfff6);
|
|
42
|
+
--sa-toast-solid-border-success: var(--sa-background-success, #28ac6e);
|
|
41
43
|
|
|
42
|
-
/*
|
|
43
|
-
--
|
|
44
|
-
--
|
|
45
|
-
--
|
|
44
|
+
/* outline info */
|
|
45
|
+
--sa-toast-outline-bg-info: var(--sa-background-info-subtlest, #effaff);
|
|
46
|
+
--sa-toast-outline-text-info: var(--sa-background-info, #0090d4);
|
|
47
|
+
--sa-toast-outline-border-info: var(--sa-color-info-200, #b6eaff);
|
|
48
|
+
--sa-toast-outline-progress-info: var(--sa-background-info, #0090d4);
|
|
46
49
|
|
|
47
|
-
/*
|
|
48
|
-
--
|
|
49
|
-
--
|
|
50
|
-
--
|
|
51
|
-
--starasia-ui-outline-progress-info: rgba(25, 118, 210, 1);
|
|
50
|
+
/* solid info */
|
|
51
|
+
--sa-toast-solid-bg-info: var(--sa-background-info, #0090d4);
|
|
52
|
+
--sa-toast-solid-text-info: var(--sa-color-info-50, #effaff);
|
|
53
|
+
--sa-toast-solid-border-info: var(--sa-background-info, #0090d4);
|
|
52
54
|
|
|
53
|
-
/*
|
|
54
|
-
--
|
|
55
|
-
--
|
|
56
|
-
--
|
|
55
|
+
/* outline warning */
|
|
56
|
+
--sa-toast-outline-bg-warning: var(--sa-background-warning-subtlest, #fef2e6);
|
|
57
|
+
--sa-toast-outline-text-warning: var(--sa-text-primary, #292a2e);
|
|
58
|
+
--sa-toast-outline-border-warning: var(--sa-color-warning-200, #f4c583);
|
|
59
|
+
--sa-toast-outline-progress-warning: var(--sa-color-warning-400, #ed9f30);
|
|
57
60
|
|
|
58
|
-
/*
|
|
59
|
-
--
|
|
60
|
-
--
|
|
61
|
-
--
|
|
62
|
-
--starasia-ui-outline-progress-warning: rgba(237, 159, 48, 1);
|
|
61
|
+
/* solid warning */
|
|
62
|
+
--sa-toast-solid-bg-warning: var(--sa-color-warning-400, #ed9f30);
|
|
63
|
+
--sa-toast-solid-text-warning: var(--sa-background-primary, #ffffff);
|
|
64
|
+
--sa-toast-solid-border-warning: var(--sa-color-warning-400, #ed9f30);
|
|
63
65
|
|
|
64
|
-
|
|
65
|
-
--starasia-ui-solid-background-warning: rgba(237, 159, 48, 1);
|
|
66
|
-
--starasia-ui-solid-color-warning: var(--starasia-ui-toast-color-white);
|
|
67
|
-
--starasia-ui-solid-border-warning: rgba(237, 159, 48, 1);
|
|
68
|
-
|
|
69
|
-
/* height */
|
|
70
|
-
--starasia-ui-h-0-5: 0.125rem; /* 2px */
|
|
66
|
+
--sa-toast-h-progress: 0.125rem;
|
|
71
67
|
}
|
|
72
68
|
/* styling for container */
|
|
73
|
-
.
|
|
69
|
+
.sa-toast-container {
|
|
74
70
|
display: flex;
|
|
75
71
|
flex-direction: column;
|
|
76
|
-
gap: var(--
|
|
77
|
-
padding: var(--
|
|
72
|
+
gap: var(--sa-spacing-xs, 4px);
|
|
73
|
+
padding: var(--sa-spacing-sm, 8px);
|
|
78
74
|
position: fixed;
|
|
79
75
|
max-height: 100vh;
|
|
80
76
|
overflow: auto;
|
|
81
77
|
z-index: 99999;
|
|
82
78
|
}
|
|
83
|
-
.
|
|
79
|
+
.sa-toast-container-bottom-right {
|
|
84
80
|
bottom: 0;
|
|
85
81
|
right: 0;
|
|
86
82
|
}
|
|
87
|
-
.
|
|
83
|
+
.sa-toast-container-bottom-left {
|
|
88
84
|
bottom: 0;
|
|
89
85
|
left: 0;
|
|
90
86
|
}
|
|
91
|
-
.
|
|
87
|
+
.sa-toast-container-bottom-center {
|
|
92
88
|
bottom: 0;
|
|
93
89
|
left: 50%;
|
|
94
90
|
transform: translateX(-50%);
|
|
95
91
|
}
|
|
96
|
-
.
|
|
92
|
+
.sa-toast-container-top-right {
|
|
97
93
|
top: 0;
|
|
98
94
|
right: 0;
|
|
99
95
|
}
|
|
100
|
-
.
|
|
96
|
+
.sa-toast-container-top-left {
|
|
101
97
|
top: 0;
|
|
102
98
|
left: 0;
|
|
103
99
|
}
|
|
104
|
-
.
|
|
100
|
+
.sa-toast-container-top-center {
|
|
105
101
|
top: 0;
|
|
106
102
|
left: 50%;
|
|
107
103
|
transform: translateX(-50%);
|
|
108
104
|
}
|
|
109
105
|
/* styling for */
|
|
110
|
-
.
|
|
111
|
-
padding: var(--
|
|
106
|
+
.sa-toast-item-container {
|
|
107
|
+
padding: var(--sa-spacing-lg, 16px);
|
|
112
108
|
width: max-content;
|
|
113
|
-
border-radius: var(--
|
|
109
|
+
border-radius: var(--sa-radii-md, 6px);
|
|
114
110
|
display: flex;
|
|
115
111
|
align-items: center;
|
|
116
|
-
gap: var(--
|
|
117
|
-
border: var(--
|
|
118
|
-
font-size: var(--
|
|
112
|
+
gap: var(--sa-spacing-sm, 8px);
|
|
113
|
+
border: var(--sa-border, 1px) solid transparent;
|
|
114
|
+
font-size: var(--sa-font-size-md, 14px);
|
|
119
115
|
position: relative;
|
|
120
116
|
overflow: hidden;
|
|
121
117
|
width: 100%;
|
|
122
118
|
}
|
|
123
119
|
/* DEFAULT TOAST */
|
|
124
|
-
.
|
|
125
|
-
background-color: var(--
|
|
126
|
-
color: var(--
|
|
127
|
-
border-color: var(--
|
|
120
|
+
.sa-toast-item-container-solid-default {
|
|
121
|
+
background-color: var(--sa-toast-solid-bg-default);
|
|
122
|
+
color: var(--sa-toast-solid-text-default);
|
|
123
|
+
border-color: var(--sa-toast-solid-border-default);
|
|
128
124
|
}
|
|
129
125
|
|
|
130
|
-
.
|
|
131
|
-
background-color: var(--
|
|
132
|
-
color: var(--
|
|
133
|
-
border-color: var(--
|
|
126
|
+
.sa-toast-item-container-outline-default {
|
|
127
|
+
background-color: var(--sa-toast-outline-bg-default);
|
|
128
|
+
color: var(--sa-toast-outline-text-default);
|
|
129
|
+
border-color: var(--sa-toast-outline-border-default);
|
|
134
130
|
}
|
|
135
131
|
|
|
136
132
|
/* DEFAULT DANGER */
|
|
137
|
-
.
|
|
138
|
-
background-color: var(--
|
|
139
|
-
color: var(--
|
|
140
|
-
border-color: var(--
|
|
133
|
+
.sa-toast-item-container-outline-danger {
|
|
134
|
+
background-color: var(--sa-toast-outline-bg-danger);
|
|
135
|
+
color: var(--sa-toast-outline-text-danger);
|
|
136
|
+
border-color: var(--sa-toast-outline-border-danger);
|
|
141
137
|
}
|
|
142
138
|
|
|
143
|
-
.
|
|
144
|
-
background-color: var(--
|
|
145
|
-
color: var(--
|
|
146
|
-
border-color: var(--
|
|
139
|
+
.sa-toast-item-container-solid-danger {
|
|
140
|
+
background-color: var(--sa-toast-solid-bg-danger);
|
|
141
|
+
color: var(--sa-toast-solid-text-danger);
|
|
142
|
+
border-color: var(--sa-toast-solid-border-danger);
|
|
147
143
|
}
|
|
148
144
|
|
|
149
145
|
/* DEFAULT SUCCESS */
|
|
150
|
-
.
|
|
151
|
-
background-color: var(--
|
|
152
|
-
color: var(--
|
|
153
|
-
border-color: var(--
|
|
146
|
+
.sa-toast-item-container-outline-success {
|
|
147
|
+
background-color: var(--sa-toast-outline-bg-success);
|
|
148
|
+
color: var(--sa-toast-outline-text-success);
|
|
149
|
+
border-color: var(--sa-toast-outline-border-success);
|
|
154
150
|
}
|
|
155
151
|
|
|
156
|
-
.
|
|
157
|
-
background-color: var(--
|
|
158
|
-
color: var(--
|
|
159
|
-
border-color: var(--
|
|
152
|
+
.sa-toast-item-container-solid-success {
|
|
153
|
+
background-color: var(--sa-toast-solid-bg-success);
|
|
154
|
+
color: var(--sa-toast-solid-text-success);
|
|
155
|
+
border-color: var(--sa-toast-solid-border-success);
|
|
160
156
|
}
|
|
161
157
|
|
|
162
158
|
/* DEFAULT INFO */
|
|
163
|
-
.
|
|
164
|
-
background-color: var(--
|
|
165
|
-
color: var(--
|
|
166
|
-
border-color: var(--
|
|
159
|
+
.sa-toast-item-container-outline-info {
|
|
160
|
+
background-color: var(--sa-toast-outline-bg-info);
|
|
161
|
+
color: var(--sa-toast-outline-text-info);
|
|
162
|
+
border-color: var(--sa-toast-outline-border-info);
|
|
167
163
|
}
|
|
168
164
|
|
|
169
|
-
.
|
|
170
|
-
background-color: var(--
|
|
171
|
-
color: var(--
|
|
172
|
-
border-color: var(--
|
|
165
|
+
.sa-toast-item-container-solid-info {
|
|
166
|
+
background-color: var(--sa-toast-solid-bg-info);
|
|
167
|
+
color: var(--sa-toast-solid-text-info);
|
|
168
|
+
border-color: var(--sa-toast-solid-border-info);
|
|
173
169
|
}
|
|
174
170
|
/* DEFAULT WARNING */
|
|
175
|
-
.
|
|
176
|
-
background-color: var(--
|
|
177
|
-
color: var(--
|
|
178
|
-
border-color: var(--
|
|
171
|
+
.sa-toast-item-container-outline-warning {
|
|
172
|
+
background-color: var(--sa-toast-outline-bg-warning);
|
|
173
|
+
color: var(--sa-toast-outline-text-warning);
|
|
174
|
+
border-color: var(--sa-toast-outline-border-warning);
|
|
179
175
|
}
|
|
180
176
|
|
|
181
|
-
.
|
|
182
|
-
background-color: var(--
|
|
183
|
-
color: var(--
|
|
184
|
-
border-color: var(--
|
|
177
|
+
.sa-toast-item-container-solid-warning {
|
|
178
|
+
background-color: var(--sa-toast-solid-bg-warning);
|
|
179
|
+
color: var(--sa-toast-solid-text-warning);
|
|
180
|
+
border-color: var(--sa-toast-solid-border-warning);
|
|
185
181
|
}
|
|
186
182
|
|
|
187
183
|
/* PROGRESS BAR */
|
|
188
|
-
.
|
|
189
|
-
height: var(--
|
|
184
|
+
.sa-toast-item-progress {
|
|
185
|
+
height: var(--sa-toast-h-progress);
|
|
190
186
|
width: 100%;
|
|
191
187
|
position: absolute;
|
|
192
188
|
bottom: 0;
|
|
@@ -195,39 +191,39 @@
|
|
|
195
191
|
animation: progressBarr 5s linear forwards;
|
|
196
192
|
}
|
|
197
193
|
|
|
198
|
-
.
|
|
199
|
-
background-color: var(--
|
|
194
|
+
.sa-toast-item-progress-outline-default {
|
|
195
|
+
background-color: var(--sa-toast-outline-progress-default);
|
|
200
196
|
}
|
|
201
|
-
.
|
|
202
|
-
background-color: var(--
|
|
197
|
+
.sa-toast-item-progress-outline-info {
|
|
198
|
+
background-color: var(--sa-toast-outline-progress-info);
|
|
203
199
|
}
|
|
204
|
-
.
|
|
205
|
-
background-color: var(--
|
|
200
|
+
.sa-toast-item-progress-outline-success {
|
|
201
|
+
background-color: var(--sa-toast-outline-progress-success);
|
|
206
202
|
}
|
|
207
|
-
.
|
|
208
|
-
background-color: var(--
|
|
203
|
+
.sa-toast-item-progress-outline-danger {
|
|
204
|
+
background-color: var(--sa-toast-outline-progress-danger);
|
|
209
205
|
}
|
|
210
|
-
.
|
|
211
|
-
background-color: var(--
|
|
206
|
+
.sa-toast-item-progress-outline-warning {
|
|
207
|
+
background-color: var(--sa-toast-outline-progress-warning);
|
|
212
208
|
}
|
|
213
209
|
|
|
214
210
|
/* animation */
|
|
215
|
-
.
|
|
211
|
+
.sa-toast-item-container-animation-bottom-right {
|
|
216
212
|
animation: bottomRight 0.375s;
|
|
217
213
|
}
|
|
218
|
-
.
|
|
214
|
+
.sa-toast-item-container-animation-bottom-left {
|
|
219
215
|
animation: bottomLeft 0.375s;
|
|
220
216
|
}
|
|
221
|
-
.
|
|
217
|
+
.sa-toast-item-container-animation-bottom-center {
|
|
222
218
|
animation: bottomCenter 0.375s;
|
|
223
219
|
}
|
|
224
|
-
.
|
|
220
|
+
.sa-toast-item-container-animation-top-left {
|
|
225
221
|
animation: topLeft 0.375s;
|
|
226
222
|
}
|
|
227
|
-
.
|
|
223
|
+
.sa-toast-item-container-animation-top-right {
|
|
228
224
|
animation: topRight 0.375s;
|
|
229
225
|
}
|
|
230
|
-
.
|
|
226
|
+
.sa-toast-item-container-animation-top-center {
|
|
231
227
|
animation: topCenter 0.375s;
|
|
232
228
|
}
|
|
233
229
|
|
|
@@ -299,4 +295,4 @@
|
|
|
299
295
|
width: 0px;
|
|
300
296
|
}
|
|
301
297
|
}
|
|
302
|
-
`;let
|
|
298
|
+
`;let x=1;class w{constructor(){this.subscribe=t=>(this.subscribers.push(t),()=>{const a=this.subscribers.indexOf(t);this.subscribers.splice(a,1)}),this.publish=t=>{this.subscribers.forEach(a=>a(t))},this.addToast=t=>{this.publish(t),this.toasts=[...this.toasts,t]},this.create=t=>{const{message:a,type:c}=t,o=x++;return this.addToast({title:a,type:c,id:o}),o},this.dismiss=t=>(this.subscribers.forEach(a=>a({id:t,dismiss:!0})),t),this.danger=t=>this.create({message:t,type:"danger"}),this.warning=t=>this.create({message:t,type:"warning"}),this.success=t=>this.create({type:"success",message:t}),this.info=t=>this.create({type:"info",message:t}),this.default=t=>this.create({type:"default",message:t}),this.subscribers=[],this.toasts=[]}}const e=new w,k=Object.assign({success:e.success,info:e.info,default:e.default,danger:e.danger,warning:e.warning}),b="sa-toast-styles";(s=>{if(!document.getElementById(b)){const t=document.createElement("style");t.id=b,t.textContent=s,document.head.appendChild(t)}})(y);const C=({type:s="outline",direction:t="bottom-right"})=>{const[a,c]=i.useState([]);return i.useEffect(()=>e.subscribe(o=>{if(o.dismiss){c(l=>l.filter(f=>f.id!==o.id));return}setTimeout(()=>{h.flushSync(()=>{c(l=>[o,...l])})})}),[]),n.jsx("div",{className:`sa-toast-container sa-toast-container-${t}`,children:a.map(o=>n.jsx(T,{data:o,type:s,direction:t},o.id))})},T=({data:s,type:t="solid",direction:a="bottom-right"})=>{const[c,o]=i.useState(null),[l,f]=i.useState(!1),d=i.useRef(null),m=()=>{const u=setTimeout(()=>{p()},5e3);o(u)},g=()=>{c&&(clearTimeout(c),o(null))},p=()=>{e.dismiss(s.id)};i.useEffect(()=>(l?g():m(),()=>{g()}),[l]),i.useEffect(()=>{const u=d.current,v=()=>{p()};return u&&u.addEventListener("animationend",v),()=>{u&&u.removeEventListener("animationend",v)}},[]);const j=()=>{f(!0),g(),d.current&&(d.current.style.animationPlayState="paused")},M=()=>{f(!1),m(),d.current&&(d.current.style.animationPlayState="running")};return n.jsxs("div",{className:["sa-toast-item-container",(s==null?void 0:s.type)&&`sa-toast-item-container-${t}-${s.type}`,`sa-toast-item-container-animation-${a}`].filter(Boolean).join(" "),onMouseEnter:j,onMouseLeave:M,children:[n.jsx("div",{style:{display:"flex"},children:s.type==="success"?n.jsx(E,{style:{color:"inherit"}}):n.jsx(L,{style:{color:"inherit"}})}),n.jsx("div",{style:{flex:1},children:s.title}),n.jsx("div",{style:{display:"flex",cursor:"pointer"},onClick:()=>e.dismiss(s.id),children:n.jsx(S,{style:{color:"inherit"}})}),t==="outline"?n.jsx("div",{ref:d,className:`sa-toast-item-progress sa-toast-item-progress-outline-${s.type}`,style:{animation:"progressBarr 5s linear forwards",animationPlayState:l?"paused":"running"}}):null]})},L=s=>n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",...s,children:n.jsx("path",{d:"M12 7.01001V7.00002M12 17L12 10M21 12C21 16.9706 16.9706 21 12 21C7.02944 21 3 16.9706 3 12C3 7.02944 7.02944 3 12 3C16.9706 3 21 7.02944 21 12Z",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",cursor:"pointer"})}),E=s=>n.jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",...s,children:n.jsx("g",{id:"Curved/Basic-actions-and-state",children:n.jsx("path",{id:"shape",d:"M14.1667 7.5L8.33332 13.3333L5.83328 10.8333M17.5 10C17.5 14.1421 14.1421 17.5 10 17.5C5.85786 17.5 2.5 14.1421 2.5 10C2.5 5.85786 5.85786 2.5 10 2.5C14.1421 2.5 17.5 5.85786 17.5 10Z",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),S=s=>n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",...s,children:n.jsx("path",{d:"M19 5L5 19M5.00003 5L19 19",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})});r.ToastContainer=C,r.toast=k,Object.defineProperty(r,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@starasia/toast",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "toast component for starasia UI",
|
|
5
5
|
"author": "Prawito Hudoro",
|
|
6
6
|
"main": "dist/toast.umd.js",
|
|
@@ -12,10 +12,6 @@
|
|
|
12
12
|
"dist/*.map",
|
|
13
13
|
"dist/*.css"
|
|
14
14
|
],
|
|
15
|
-
"scripts": {
|
|
16
|
-
"dev": "vite --config vite.config.ts --port 3000",
|
|
17
|
-
"build": "vite build --config vite.config.ts"
|
|
18
|
-
},
|
|
19
15
|
"keywords": [],
|
|
20
16
|
"license": "ISC",
|
|
21
17
|
"type": "module",
|
|
@@ -37,5 +33,9 @@
|
|
|
37
33
|
"react-dom": "^18.2.0",
|
|
38
34
|
"@types/react": "^18.2.55",
|
|
39
35
|
"@types/react-dom": "^18.2.19"
|
|
36
|
+
},
|
|
37
|
+
"scripts": {
|
|
38
|
+
"dev": "vite --config vite.config.ts --port 3000",
|
|
39
|
+
"build": "vite build --config vite.config.ts"
|
|
40
40
|
}
|
|
41
|
-
}
|
|
41
|
+
}
|