juice-toast 1.4.0 โ 1.4.2
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/API.md +188 -150
- package/CHANGELOG.md +7 -2
- package/EoL.md +42 -12
- package/LICENSE.md +1 -1
- package/README.md +297 -123
- package/dist/juice-toast.d.ts +150 -0
- package/dist/juice-toast.esm.js +94 -7
- package/dist/juice-toast.umd.js +113 -16
- package/package.json +11 -10
package/API.md
CHANGED
|
@@ -1,273 +1,311 @@
|
|
|
1
|
-
#
|
|
1
|
+
# JuiceToast API Documentation
|
|
2
2
|
|
|
3
|
-
JuiceToast is a lightweight,
|
|
3
|
+
JuiceToast is a lightweight, customizable toast notification library with support for:
|
|
4
|
+
|
|
5
|
+
- Priority queue system
|
|
6
|
+
- Promise handling
|
|
7
|
+
- Theming
|
|
8
|
+
- Plugin system
|
|
9
|
+
- Grouping
|
|
10
|
+
- Swipe-to-dismiss
|
|
11
|
+
- Progress bar
|
|
12
|
+
- Sound support
|
|
13
|
+
- Avatar & Icon support
|
|
4
14
|
|
|
5
15
|
---
|
|
6
16
|
|
|
7
|
-
|
|
17
|
+
# Installation
|
|
8
18
|
|
|
9
19
|
```bash
|
|
10
20
|
npm install juice-toast
|
|
11
21
|
```
|
|
12
22
|
|
|
23
|
+
# ESM
|
|
24
|
+
|
|
13
25
|
```js
|
|
14
|
-
import juiceToast from "juice-toast";
|
|
26
|
+
import juiceToast from "https://cdn.jsdelivr.net/npm/juice-toast/dist/juice-toast.esm.js";
|
|
15
27
|
```
|
|
16
28
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
## ๐ Quick Start
|
|
20
|
-
|
|
21
|
-
```js
|
|
22
|
-
juiceToast.setup({
|
|
23
|
-
duration: 3000,
|
|
24
|
-
maxVisible: 3,
|
|
25
|
-
glassUI: true
|
|
26
|
-
});
|
|
29
|
+
# UMD
|
|
27
30
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
message: "Data saved successfully"
|
|
31
|
-
});
|
|
31
|
+
```html
|
|
32
|
+
<script src="https://cdn.jsdelivr.net/npm/juice-toast/dist/juice-toast.umd.js"></script>
|
|
32
33
|
```
|
|
33
34
|
|
|
34
35
|
---
|
|
35
36
|
|
|
36
|
-
|
|
37
|
+
# Basic Usage
|
|
37
38
|
|
|
38
39
|
```js
|
|
39
|
-
juiceToast.
|
|
40
|
+
juiceToast.success("Success message");
|
|
41
|
+
juiceToast.error("Error message");
|
|
42
|
+
juiceToast.info("Information");
|
|
43
|
+
juiceToast.warning("Warning message");
|
|
44
|
+
juiceToast.loading("Loading...");
|
|
40
45
|
```
|
|
41
46
|
|
|
42
|
-
### Options
|
|
43
|
-
|
|
44
|
-
| Option | Type | Default | Description |
|
|
45
|
-
| ---------------- | ---------------- | ------- | ------------------------------- |
|
|
46
|
-
| `duration` | number | `2500` | Toast display duration (ms) |
|
|
47
|
-
| `maxVisible` | number | `3` | Max visible toasts per position |
|
|
48
|
-
| `glassUI` | boolean | number | `0` | Enable glass effect (0โ100) |
|
|
49
|
-
| `playSound` | string | null | `null` | Global sound file |
|
|
50
|
-
| `injectCSS` | boolean | `true` | Auto inject base CSS |
|
|
51
|
-
| `css` | string | null | `null` | Custom CSS override |
|
|
52
|
-
| `swipeThreshold` | number | `60` | Swipe distance to dismiss |
|
|
53
|
-
| `dev` | boolean | `false` | Enable console warnings |
|
|
54
|
-
|
|
55
47
|
---
|
|
56
48
|
|
|
57
|
-
|
|
49
|
+
# Global Configuration
|
|
58
50
|
|
|
59
|
-
|
|
51
|
+
## `juiceToast.setup(options)`
|
|
52
|
+
|
|
53
|
+
Configure global defaults.
|
|
60
54
|
|
|
61
55
|
```js
|
|
62
|
-
juiceToast.
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
56
|
+
juiceToast.setup({
|
|
57
|
+
duration: 3000,
|
|
58
|
+
maxVisible: 5,
|
|
59
|
+
swipeThreshold: 80,
|
|
60
|
+
injectCSS: true,
|
|
61
|
+
dev: true
|
|
62
|
+
});
|
|
67
63
|
```
|
|
68
64
|
|
|
69
|
-
|
|
65
|
+
### Options
|
|
66
|
+
|
|
67
|
+
| Option | Type | Default | Description |
|
|
68
|
+
|--------|------|----------|-------------|
|
|
69
|
+
| duration | number | 2500 | Default auto-dismiss duration (ms) |
|
|
70
|
+
| maxVisible | number | 3 | Maximum visible toasts per position |
|
|
71
|
+
| swipeThreshold | number | 60 | Swipe distance required to dismiss |
|
|
72
|
+
| injectCSS | boolean | true | Automatically inject base CSS |
|
|
73
|
+
| css | string | internal | Custom CSS override |
|
|
74
|
+
| dev | boolean | false | Enable debug logs |
|
|
75
|
+
| playSound | string | null | Sound URL |
|
|
70
76
|
|
|
71
77
|
---
|
|
72
78
|
|
|
73
|
-
|
|
79
|
+
# Toast Methods
|
|
74
80
|
|
|
75
|
-
|
|
81
|
+
Each toast type can accept:
|
|
76
82
|
|
|
77
83
|
```js
|
|
78
|
-
|
|
79
|
-
title: "Title",
|
|
80
|
-
message: "Message",
|
|
81
|
-
duration: 3000
|
|
82
|
-
}
|
|
84
|
+
juiceToast.success(options)
|
|
83
85
|
```
|
|
84
86
|
|
|
85
|
-
|
|
87
|
+
Or shortcut:
|
|
86
88
|
|
|
87
89
|
```js
|
|
88
|
-
|
|
89
|
-
theme: "dark",
|
|
90
|
-
bg: "#333",
|
|
91
|
-
color: "#fff",
|
|
92
|
-
border: "1px solid #000",
|
|
93
|
-
size: "sm" | "md" | "lg",
|
|
94
|
-
compact: true
|
|
95
|
-
}
|
|
90
|
+
juiceToast.success("Message")
|
|
96
91
|
```
|
|
97
92
|
|
|
98
93
|
---
|
|
99
94
|
|
|
100
|
-
|
|
95
|
+
# Toast Options
|
|
96
|
+
|
|
97
|
+
| Option | Type | Description |
|
|
98
|
+
|--------|------|-------------|
|
|
99
|
+
| message | string | Main text |
|
|
100
|
+
| title | string | Toast title |
|
|
101
|
+
| html | string | Render sanitized HTML |
|
|
102
|
+
| duration | number | Auto close duration |
|
|
103
|
+
| position | string | Toast position |
|
|
104
|
+
| theme | string | Theme name |
|
|
105
|
+
| icon | string | Icon class |
|
|
106
|
+
| iconPack | string | Icon library prefix |
|
|
107
|
+
| iconAnim | string | Icon animation class |
|
|
108
|
+
| iconSize | string | Icon font size |
|
|
109
|
+
| avatar | string | Avatar image URL |
|
|
110
|
+
| avatarAlt | string | Avatar alt text |
|
|
111
|
+
| avatarPosition | left/right/top | Avatar position |
|
|
112
|
+
| closable | boolean | Show close button |
|
|
113
|
+
| progress | boolean | Show progress bar |
|
|
114
|
+
| progressColor | string | Custom progress color |
|
|
115
|
+
| actions | array | Custom buttons |
|
|
116
|
+
| undo | function | Undo callback |
|
|
117
|
+
| undoTimeout | number | Timeout before auto-close |
|
|
118
|
+
| groupId | string | Group multiple toasts |
|
|
119
|
+
| dedupeKey | string | Prevent duplicate toasts |
|
|
120
|
+
| priority | low/normal/high/urgent | Priority queue level |
|
|
121
|
+
| playSound | string | Override sound |
|
|
101
122
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
enterAnimation: "pop" | "bounce" | "shake" | "wiggle" | "pulse" | "spin"
|
|
106
|
-
}
|
|
107
|
-
```
|
|
123
|
+
---
|
|
124
|
+
|
|
125
|
+
# Positions
|
|
108
126
|
|
|
109
|
-
|
|
127
|
+
Available positions:
|
|
128
|
+
|
|
129
|
+
- `top-left`
|
|
130
|
+
- `top-right`
|
|
131
|
+
- `bottom-left`
|
|
132
|
+
- `bottom-right`
|
|
133
|
+
- `top-center`
|
|
134
|
+
- `bottom-center`
|
|
135
|
+
|
|
136
|
+
Default: `bottom-right`
|
|
110
137
|
|
|
111
138
|
---
|
|
112
139
|
|
|
113
|
-
|
|
140
|
+
# Themes
|
|
141
|
+
|
|
142
|
+
Built-in themes:
|
|
143
|
+
|
|
144
|
+
- `dark`
|
|
145
|
+
- `light`
|
|
146
|
+
- `glass`
|
|
147
|
+
|
|
148
|
+
## Define Custom Theme
|
|
114
149
|
|
|
115
150
|
```js
|
|
116
|
-
{
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
151
|
+
juiceToast.defineTheme("custom", {
|
|
152
|
+
bg: "#111",
|
|
153
|
+
color: "#fff",
|
|
154
|
+
border: "1px solid #333"
|
|
155
|
+
});
|
|
120
156
|
```
|
|
121
157
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
## ๐ Position / Placement
|
|
158
|
+
## Set Theme
|
|
125
159
|
|
|
126
160
|
```js
|
|
127
|
-
|
|
128
|
-
position: "top-left" |
|
|
129
|
-
"top-right" |
|
|
130
|
-
"top-center" |
|
|
131
|
-
"bottom-left" |
|
|
132
|
-
"bottom-right" |
|
|
133
|
-
"bottom-center"
|
|
134
|
-
}
|
|
161
|
+
juiceToast.setTheme("custom");
|
|
135
162
|
```
|
|
136
163
|
|
|
137
164
|
---
|
|
138
165
|
|
|
139
|
-
|
|
166
|
+
# Custom Toast Types
|
|
167
|
+
|
|
168
|
+
## `juiceToast.addType(name, config)`
|
|
140
169
|
|
|
141
170
|
```js
|
|
142
|
-
{
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
}
|
|
171
|
+
juiceToast.addType("custom", {
|
|
172
|
+
bg: "#9333ea",
|
|
173
|
+
icon: "fa-star",
|
|
174
|
+
duration: 5000
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
juiceToast.custom("Hello!");
|
|
150
178
|
```
|
|
151
179
|
|
|
152
180
|
---
|
|
153
181
|
|
|
154
|
-
|
|
182
|
+
# Promise Toast
|
|
183
|
+
|
|
184
|
+
## `juiceToast.promise(promise, options)`
|
|
155
185
|
|
|
156
186
|
```js
|
|
157
|
-
{
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
]
|
|
165
|
-
}
|
|
187
|
+
juiceToast.promise(fetch("/api"), {
|
|
188
|
+
loading: "Loading...",
|
|
189
|
+
success: "Success!",
|
|
190
|
+
error: "Failed",
|
|
191
|
+
timeout: 5000,
|
|
192
|
+
timeoutMessage: "Request timeout"
|
|
193
|
+
});
|
|
166
194
|
```
|
|
167
195
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
## โณ Progress Bar
|
|
196
|
+
### Returns
|
|
171
197
|
|
|
172
198
|
```js
|
|
173
199
|
{
|
|
174
|
-
|
|
175
|
-
progressColor: "rgba(255,255,255,.7)"
|
|
200
|
+
cancel: Function
|
|
176
201
|
}
|
|
177
202
|
```
|
|
178
203
|
|
|
179
204
|
---
|
|
180
205
|
|
|
181
|
-
|
|
206
|
+
# Plugin System
|
|
207
|
+
|
|
208
|
+
## `juiceToast.use(pluginFunction)`
|
|
182
209
|
|
|
183
210
|
```js
|
|
184
|
-
{
|
|
185
|
-
|
|
186
|
-
}
|
|
211
|
+
juiceToast.use(({ toast, cfg, type, root }) => {
|
|
212
|
+
console.log("Toast created:", type);
|
|
213
|
+
});
|
|
187
214
|
```
|
|
188
215
|
|
|
189
|
-
Supported formats: `.mp3`, `.wav`, `.ogg`, `.opus`, `.aiff`, `.wma`
|
|
190
|
-
|
|
191
216
|
---
|
|
192
217
|
|
|
193
|
-
|
|
218
|
+
# Queue Management
|
|
219
|
+
|
|
220
|
+
## Clear Queue
|
|
194
221
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
222
|
+
```js
|
|
223
|
+
juiceToast.clear();
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
## Destroy All Toast Roots
|
|
198
227
|
|
|
199
228
|
```js
|
|
200
|
-
|
|
229
|
+
juiceToast.destroy();
|
|
201
230
|
```
|
|
202
231
|
|
|
203
232
|
---
|
|
204
233
|
|
|
205
|
-
|
|
234
|
+
# Advanced Features
|
|
206
235
|
|
|
207
|
-
|
|
208
|
-
* `aria-live="polite"`
|
|
209
|
-
* Keyboard focusable
|
|
210
|
-
* Reduced motion support
|
|
236
|
+
## Priority Queue
|
|
211
237
|
|
|
212
|
-
|
|
238
|
+
Available priorities:
|
|
239
|
+
|
|
240
|
+
- `low`
|
|
241
|
+
- `normal`
|
|
242
|
+
- `high`
|
|
243
|
+
- `urgent`
|
|
213
244
|
|
|
214
|
-
|
|
245
|
+
Example:
|
|
215
246
|
|
|
216
247
|
```js
|
|
217
|
-
juiceToast.
|
|
218
|
-
|
|
248
|
+
juiceToast.success({
|
|
249
|
+
message: "Important",
|
|
250
|
+
priority: "urgent"
|
|
219
251
|
});
|
|
220
252
|
```
|
|
221
253
|
|
|
222
254
|
---
|
|
223
255
|
|
|
224
|
-
##
|
|
256
|
+
## Grouped Toast
|
|
225
257
|
|
|
226
258
|
```js
|
|
227
|
-
juiceToast.
|
|
228
|
-
|
|
229
|
-
|
|
259
|
+
juiceToast.info({
|
|
260
|
+
message: "Grouped",
|
|
261
|
+
groupId: "network"
|
|
230
262
|
});
|
|
231
|
-
|
|
232
|
-
juiceToast.setTheme("ocean");
|
|
233
263
|
```
|
|
234
264
|
|
|
235
265
|
---
|
|
236
266
|
|
|
237
|
-
##
|
|
267
|
+
## Action Buttons
|
|
238
268
|
|
|
239
269
|
```js
|
|
240
|
-
juiceToast.
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
270
|
+
juiceToast.success({
|
|
271
|
+
message: "Saved",
|
|
272
|
+
actions: [
|
|
273
|
+
{
|
|
274
|
+
label: "Undo",
|
|
275
|
+
onClick: () => console.log("Undo"),
|
|
276
|
+
closeOnClick: true
|
|
277
|
+
}
|
|
278
|
+
]
|
|
244
279
|
});
|
|
245
|
-
|
|
246
|
-
juiceToast.custom("Hello World");
|
|
247
280
|
```
|
|
248
281
|
|
|
249
282
|
---
|
|
250
283
|
|
|
251
|
-
|
|
252
|
-
```js
|
|
253
|
-
juiceToast.setup({
|
|
254
|
-
image: { bgImage: "https://cdn.kyrt.my.id/image/ts-logo-128.svg" }
|
|
255
|
-
});
|
|
284
|
+
# Accessibility
|
|
256
285
|
|
|
257
|
-
|
|
258
|
-
|
|
286
|
+
- Uses `role="status"`
|
|
287
|
+
- Keyboard focus support
|
|
288
|
+
- Pause on hover & focus
|
|
289
|
+
- Swipe support (touch & mouse)
|
|
259
290
|
|
|
260
291
|
---
|
|
261
292
|
|
|
262
|
-
|
|
293
|
+
# Internal Defaults
|
|
263
294
|
|
|
264
295
|
```js
|
|
265
|
-
|
|
266
|
-
|
|
296
|
+
{
|
|
297
|
+
duration: 2500,
|
|
298
|
+
maxVisible: 3,
|
|
299
|
+
swipeThreshold: 60,
|
|
300
|
+
glassUI: 0,
|
|
301
|
+
playSound: null,
|
|
302
|
+
dev: false,
|
|
303
|
+
injectCSS: true
|
|
304
|
+
}
|
|
267
305
|
```
|
|
268
306
|
|
|
269
307
|
---
|
|
270
308
|
|
|
271
|
-
|
|
309
|
+
# License
|
|
272
310
|
|
|
273
|
-
MIT License
|
|
311
|
+
MIT License
|
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
## v1.4.
|
|
1
|
+
## v1.4.2
|
|
2
|
+
- Add modal
|
|
3
|
+
- Bug fixes
|
|
4
|
+
- improve documentation
|
|
5
|
+
|
|
6
|
+
v1.4.0 / v1.4.1
|
|
2
7
|
- Add Smart Queue
|
|
3
8
|
- Bugs fixed & Logic fixes
|
|
4
9
|
- Fix the toast speed
|
|
@@ -8,7 +13,7 @@
|
|
|
8
13
|
|
|
9
14
|
v1.3.4
|
|
10
15
|
- Bug Fixes
|
|
11
|
-
- Add
|
|
16
|
+
- Add Avatar
|
|
12
17
|
|
|
13
18
|
v1.3.3
|
|
14
19
|
- Bug Fixes on Closeable Toast & Logic
|
package/EoL.md
CHANGED
|
@@ -1,12 +1,42 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
|
12
|
-
|
|
1
|
+
# End of Life (EoL) & End of Support (EoS) Notice
|
|
2
|
+
|
|
3
|
+
This document outlines versions that are no longer maintained.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## ๐ด End of Life (EoL)
|
|
8
|
+
|
|
9
|
+
The following versions are fully discontinued and **should not be used in production**.
|
|
10
|
+
|
|
11
|
+
| Version | Affected Target | Replacement | Reason |
|
|
12
|
+
|----------|----------------|------------|--------|
|
|
13
|
+
| 1.4.0 | Distribution files | 1.4.1 | Distribution files were unintentionally identical to v1.3.4 |
|
|
14
|
+
| 1.2.0-rc.2026 | UMD build | ^1.3.0 | UMD distribution was removed to simplify maintenance and reduce build complexity |
|
|
15
|
+
| 0.0.0-next.1202026 | Pre-release tag | 0.0.1-next.1202026 or stable releases | Versioning structure became inconsistent and difficult to maintain |
|
|
16
|
+
| 1.0.0 | Entire release | ^1.2.0 | Deprecated due to legacy architecture that does not meet current stability and performance standards |
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## ๐ก End of Support (EoS)
|
|
21
|
+
|
|
22
|
+
The following versions remain functional but **will no longer receive updates, fixes, or improvements**.
|
|
23
|
+
|
|
24
|
+
| Version Range | Replacement | Notes |
|
|
25
|
+
|---------------|------------|-------|
|
|
26
|
+
| 1.3.x | 1.3.4 (LTS) or ^1.4.x | Maintenance has ended for this minor series |
|
|
27
|
+
| 1.2.1 | ^1.3.0 | Superseded by newer improvements and fixes |
|
|
28
|
+
| 1.1.0 | ^1.2.0 | Maintenance discontinued |
|
|
29
|
+
| 0.0.1-next.1202026 | Release Candidate or stable releases | Pre-release cycle has ended |
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## ๐ Recommendation
|
|
34
|
+
|
|
35
|
+
Users are strongly encouraged to upgrade to the latest stable version to ensure:
|
|
36
|
+
|
|
37
|
+
- Improved performance
|
|
38
|
+
- Ongoing security updates
|
|
39
|
+
- Bug fixes and stability improvements
|
|
40
|
+
- Better long-term compatibility
|
|
41
|
+
|
|
42
|
+
For migration guidance, please refer to the official documentation or release notes.
|