vue-toasts-lite 0.1.1 → 0.1.3

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/LICENSE CHANGED
@@ -20,3 +20,4 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
20
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
21
  SOFTWARE.
22
22
 
23
+
package/README.md CHANGED
@@ -20,21 +20,14 @@ A lightweight toast notifications library for Vue 3.
20
20
  - 🎯 Promise support
21
21
  - 🖱️ Pause on hover
22
22
 
23
- ## Installation
23
+ ## Quick Start
24
24
 
25
+ ### 1. Install the package:
25
26
  ```bash
26
27
  npm install vue-toasts-lite
27
28
  ```
28
29
 
29
- ## Quick Start
30
-
31
- **Three steps to start using toasts:**
32
-
33
- 1. Install the package
34
- 2. Add `ToastsLiteProvider` to your app
35
- 3. Call `toasts.success()` from anywhere
36
-
37
- ### 1. Add the provider to your `App.vue`:
30
+ ### 2. Add `ToastsLiteProvider` & `vue-toasts-lite/style.css` to app:
38
31
 
39
32
  ```vue
40
33
  <script setup>
@@ -50,7 +43,7 @@ import 'vue-toasts-lite/style.css'
50
43
  </template>
51
44
  ```
52
45
 
53
- ### 2. Use anywhere in your app:
46
+ ### 3. Use anywhere in your app:
54
47
 
55
48
  ```vue
56
49
  <script setup>
@@ -129,14 +122,6 @@ await toasts.promise(
129
122
  )
130
123
  ```
131
124
 
132
- ### Custom Controller
133
-
134
- ```js
135
- import { ToastsController } from 'vue-toasts-lite'
136
-
137
- const notifications = new ToastsController()
138
- notifications.success('Hello!')
139
- ```
140
125
 
141
126
  ## Styling
142
127
 
package/dist/index.d.ts CHANGED
@@ -3,9 +3,9 @@ import { ComponentProvideOptions } from 'vue';
3
3
  import { DefineComponent } from 'vue';
4
4
  import { PublicProps } from 'vue';
5
5
 
6
- export declare type Id = string;
6
+ declare type Id = string;
7
7
 
8
- export declare interface Toast {
8
+ declare interface IToastsController {
9
9
  add: (options: ToastOptions) => Id;
10
10
  update: (id: Id, options: ToastOptions) => Id;
11
11
  success: (message: string, options?: ToastSimpleOptions) => Id;
@@ -15,107 +15,296 @@ export declare interface Toast {
15
15
  promise: <T>(promise: Promise<T>, options: ToastPromiseOptions) => Promise<Id>;
16
16
  remove: (id?: Id) => void;
17
17
  clear: () => void;
18
- onToastsListChange: (callback: (toasts: ToastProps[]) => void) => () => void;
18
+ onToastsListChange: (callback: (toasts: Toast[]) => void) => () => void;
19
19
  }
20
20
 
21
- export declare type ToastOptions = Partial<ToastProps>;
21
+ declare type Toast = {
22
+ /**
23
+ * Unique identifier for the toast.
24
+ * Auto-generated if not provided when creating a toast.
25
+ */
26
+ id: Id;
27
+ /**
28
+ * Visual type of the toast notification.
29
+ * Determines the icon and color scheme.
30
+ * @default "success"
31
+ */
32
+ type: ToastType;
33
+ /**
34
+ * Text content displayed in the toast.
35
+ * @default "Hello from Toasts Lite"
36
+ */
37
+ message: string;
38
+ /**
39
+ * Whether the toast should automatically close after {@link duration} milliseconds.
40
+ * @default true
41
+ */
42
+ autoClose: boolean;
43
+ /**
44
+ * Time in milliseconds before the toast auto-closes.
45
+ * Only applies when {@link autoClose} is `true`.
46
+ * @default 3000
47
+ */
48
+ duration: number;
49
+ /**
50
+ * Position of the toast on the screen.
51
+ * @default "top-center"
52
+ */
53
+ position?: ToastPosition;
54
+ };
55
+
56
+ export declare type ToastOptions = Partial<Toast>;
22
57
 
23
58
  export declare type ToastPosition = "top-left" | "top-center" | "top-right" | "bottom-left" | "bottom-center" | "bottom-right" | "middle-center";
24
59
 
25
60
  export declare type ToastPromiseOptions = {
61
+ /** Message displayed while the promise is pending */
26
62
  loading: string;
63
+ /** Message displayed when the promise resolves successfully */
27
64
  success: string;
65
+ /** Message displayed when the promise rejects */
28
66
  error: string;
67
+ /** Optional position for the toast on the screen */
29
68
  position?: ToastPosition;
69
+ /** Optional custom ID for the toast */
30
70
  id?: Id;
31
71
  };
32
72
 
33
- export declare type ToastProps = {
34
- /** toast id */
35
- id: Id;
36
- /** toast type */
37
- type: ToastType;
38
- /** toast message */
39
- message: string;
40
- /** auto close the toast */
41
- autoClose: boolean;
42
- /** duration in milliseconds */
43
- duration: number;
44
- /** Position of the toast on the screen. */
45
- position?: ToastPosition;
46
- };
47
-
73
+ /**
74
+ * Main toast controller instance.
75
+ * @example
76
+ * ```ts
77
+ * import { toasts } from 'vue-toasts-lite'
78
+ *
79
+ * toasts.success('Hello, World!')
80
+ * ```
81
+ */
48
82
  export declare const toasts: ToastsController;
49
83
 
50
- export declare class ToastsController implements Toast {
84
+ declare class ToastsController implements IToastsController {
51
85
  private counter;
52
86
  private toasts;
53
87
  constructor();
54
- get toastList(): ToastProps[];
55
- onToastsListChange(callback: (toasts: ToastProps[]) => void): () => void;
56
- private ID;
57
- private addOrUpdate;
58
88
  /**
59
- * Add a toast
60
- * @param options - The options for the toast
61
- * @returns The id of the toast
89
+ * Returns an array of all currently active toasts.
90
+ * @description Useful for debugging or external monitoring
91
+ *
92
+ * @returns Array of toast properties for all active toasts
93
+ */
94
+ get toastList(): Toast[];
95
+ /**
96
+ * Subscribes to changes in the toast list.
97
+ *
98
+ * @param callback - Function called whenever toasts are added, updated, or removed
99
+ * @returns Unsubscribe function to stop listening for changes
100
+ *
101
+ * @example
102
+ * ```ts
103
+ * const unsubscribe = toasts.onToastsListChange((toastsList) => {
104
+ * console.log('Toasts updated:', toastsList)
105
+ * })
106
+ *
107
+ * // Later, to stop listening:
108
+ * unsubscribe()
109
+ * ```
110
+ */
111
+ onToastsListChange(callback: (toasts: Toast[]) => void): () => void;
112
+ /**
113
+ * Creates a toast notification with custom options. If toast with the same ID already exists, it will be updated.
114
+ * @description Use this method when you need full control over toast configuration.
115
+ * @description For simpler use cases, consider using {@link success}, {@link error}, {@link warn}, or {@link loading} methods.
116
+ *
117
+ * @param options - Configuration options for the toast
118
+ * @returns Unique identifier of the created toast
119
+ *
120
+ * @example
121
+ * ```ts
122
+ * // Create a custom toast
123
+ * const id = toasts.add({
124
+ * type: 'success',
125
+ * message: 'Custom notification',
126
+ * duration: 5000,
127
+ * position: 'top-right',
128
+ * autoClose: true
129
+ * })
130
+ *
131
+ * // Create with custom ID for later reference
132
+ * toasts.add({ id: 'my-toast', type: 'loading', message: 'Processing...' })
133
+ * ```
62
134
  */
63
135
  add(options: ToastOptions): string;
64
136
  /**
65
- * Update a toast by id
66
- * @param id - The id of the toast to update
67
- * @param options - The options for the toast
68
- * @returns The id of the toast
137
+ * Updates an existing toast notification by its ID.
138
+ * @description Useful for changing the content or appearance of a toast that is already displayed, such as updating a loading toast to show success or error state.
139
+ *
140
+ * @param id - Unique identifier of the toast to update
141
+ * @param options - New configuration options to apply
142
+ * @returns The same toast ID
143
+ *
144
+ * @example
145
+ * ```ts
146
+ * // Create a loading toast
147
+ * const id = toasts.loading('Uploading file...')
148
+ *
149
+ * // Later, update it to show success
150
+ * toasts.update(id, { type: 'success', message: 'File uploaded!' })
151
+ * ```
69
152
  */
70
153
  update(id: Id, options: ToastOptions): string;
71
154
  /**
72
- * Remove a toast by id
73
- * If no id is provided, all current toasts will be removed
74
- * @param id - The id of the toast to remove
155
+ * Removes a toast notification from the screen.
156
+ * @description If no ID is provided, all currently visible toasts will be removed. If the specified ID doesn't exist, this method does nothing.
157
+ *
158
+ * @param id - Optional unique identifier of the toast to remove.
159
+ * If omitted, all toasts are removed.
160
+ *
161
+ * @example
162
+ * ```ts
163
+ * // Remove a specific toast
164
+ * const id = toasts.success('Hello!')
165
+ * toasts.remove(id)
166
+ *
167
+ * // Remove all toasts
168
+ * toasts.remove()
169
+ * ```
170
+ *
171
+ * @see {@link clear} for explicitly removing all toasts
75
172
  */
76
173
  remove(id?: Id): void;
77
174
  /**
78
- * Remove all current toasts
175
+ * Removes all currently visible toast notifications.
176
+ *
177
+ * @example
178
+ * ```ts
179
+ * // Clear all toasts on route change
180
+ * router.beforeEach(() => {
181
+ * toasts.clear()
182
+ * })
183
+ * ```
79
184
  */
80
185
  clear(): void;
81
186
  /**
82
- * Add a success toast
83
- * @param message - The message to display in the toast
84
- * @param options - The options for the toast
85
- * @returns The id of the toast
187
+ * Displays a **success** toast notification.
188
+ *
189
+ * @param message - Text content to display in the toast
190
+ * @param options - Optional configuration (position, duration, autoClose, id)
191
+ * @returns Unique identifier of the created toast
192
+ *
193
+ * @example
194
+ * ```ts
195
+ * // Simple success message
196
+ * toasts.success('Changes saved successfully!')
197
+ *
198
+ * // With custom options
199
+ * toasts.success('Profile updated', {
200
+ * duration: 5000,
201
+ * position: 'bottom-center'
202
+ * })
203
+ * ```
86
204
  */
87
205
  success(message: string, options?: Omit<ToastSimpleOptions, "type">): string;
88
206
  /**
89
- * Add an error toast
90
- * @param message - The message to display in the toast
91
- * @param options - The options for the toast
92
- * @returns The id of the toast
207
+ * Displays an **error** toast notification.
208
+ *
209
+ * @param message - Text content to display in the toast
210
+ * @param options - Optional configuration (position, duration, autoClose, id)
211
+ * @returns Unique identifier of the created toast
212
+ *
213
+ * @example
214
+ * ```ts
215
+ * // Simple error message
216
+ * toasts.error('Failed to save changes')
217
+ *
218
+ * // Non-auto-closing error
219
+ * toasts.error('Critical error occurred', { autoClose: false })
220
+ * ```
93
221
  */
94
222
  error(message: string, options?: Omit<ToastSimpleOptions, "type">): string;
95
223
  /**
96
- * Add a warning toast
97
- * @param message - The message to display in the toast
98
- * @param options - The options for the toast
99
- * @returns The id of the toast
224
+ * Displays a **warning** toast notification.
225
+ *
226
+ * @param message - Text content to display in the toast
227
+ * @param options - Optional configuration (position, duration, autoClose, id)
228
+ * @returns Unique identifier of the created toast
229
+ *
230
+ * @example
231
+ * ```ts
232
+ * // Simple warning message
233
+ * toasts.warn('Your session will expire soon')
234
+ *
235
+ * // With longer duration
236
+ * toasts.warn('Unsaved changes detected', { duration: 10000 })
237
+ * ```
100
238
  */
101
239
  warn(message: string, options?: Omit<ToastSimpleOptions, "type">): string;
102
240
  /**
103
- * Add a loading toast
104
- * @param message - The message to display in the toast
105
- * @param options - The options for the toast
106
- * @returns The id of the toast
241
+ * Displays a **loading** toast notification.
242
+ *
243
+ * Loading toasts are typically used as placeholders while
244
+ * an async operation is in progress.
245
+ *
246
+ * @param message - Text content to display in the toast
247
+ * @param options - Optional configuration (position, duration, autoClose, id)
248
+ * @returns Unique identifier of the created toast
249
+ *
250
+ * @example
251
+ * ```ts
252
+ * // Manual loading state management
253
+ * const id = toasts.loading('Saving...')
254
+ *
255
+ * try {
256
+ * await saveData()
257
+ * toasts.update(id, { type: 'success', message: 'Saved!' })
258
+ * } catch {
259
+ * toasts.update(id, { type: 'error', message: 'Save failed' })
260
+ * }
261
+ * ```
262
+ *
263
+ * @see {@link promise} for automatic promise-based state management
107
264
  */
108
265
  loading(message: string, options?: Omit<ToastSimpleOptions, "type">): string;
109
266
  /**
110
- * Add a promise toast
111
- * @param promise - The promise to display in the toast
112
- * @param options - The options for the toast
113
- * @returns The id of the toast
267
+ * Displays a **promise** toast that automatically updates based on promise resolution.
268
+ *
269
+ * Shows a loading toast while the promise is pending, then automatically
270
+ * transitions to success or error state based on the promise outcome.
271
+ *
272
+ * @template T - Type of the promise result
273
+ * @param promise - The promise to track
274
+ * @param options - Messages for each state and optional positioning
275
+ * @param options.loading - Message to show while promise is pending
276
+ * @param options.success - Message to show when promise resolves
277
+ * @param options.error - Message to show when promise rejects
278
+ * @param options.position - Optional toast position on screen
279
+ * @param options.id - Optional custom ID for the toast
280
+ * @returns Promise that resolves to the toast ID
281
+ * @throws Error with the error message if the promise rejects
282
+ *
283
+ * @example
284
+ * ```ts
285
+ * // Basic usage
286
+ * await toasts.promise(fetchUserData(), {
287
+ * loading: 'Loading user data...',
288
+ * success: 'User data loaded!',
289
+ * error: 'Failed to load user data'
290
+ * })
291
+ *
292
+ * // With custom position
293
+ * await toasts.promise(uploadFile(file), {
294
+ * loading: 'Uploading...',
295
+ * success: 'File uploaded successfully!',
296
+ * error: 'Upload failed',
297
+ * position: 'bottom-right'
298
+ * })
299
+ * ```
114
300
  */
115
301
  promise<T>(promise: Promise<T>, options: ToastPromiseOptions): Promise<string>;
302
+ private ID;
303
+ private addOrUpdate;
304
+ private mergeWithDefaultOptions;
116
305
  }
117
306
 
118
- export declare type ToastSimpleOptions = Partial<Omit<ToastProps, "message">>;
307
+ export declare type ToastSimpleOptions = Partial<Omit<Toast, "message">>;
119
308
 
120
309
  export declare const ToastsLiteProvider: DefineComponent<{}, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>;
121
310
 
package/dist/index.js CHANGED
@@ -1,57 +1,11 @@
1
- var L = Object.defineProperty;
2
- var M = (a, t, e) => t in a ? L(a, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : a[t] = e;
3
- var f = (a, t, e) => M(a, typeof t != "symbol" ? t + "" : t, e);
4
- import { defineComponent as w, ref as h, watchEffect as O, createElementBlock as m, openBlock as d, withModifiers as E, normalizeStyle as $, createCommentVNode as U, createElementVNode as v, normalizeClass as C, toDisplayString as D, computed as k, onBeforeUpdate as x, createBlock as g, Teleport as B, Fragment as b, renderList as T, createVNode as P, TransitionGroup as A, withCtx as I, unref as N } from "vue";
5
- const S = {
6
- key: 0,
7
- class: "toasts-lite__icon"
8
- }, V = { class: "toasts-lite__content" }, z = { class: "toasts-lite__content-message" }, F = /* @__PURE__ */ w({
9
- __name: "ToastsLiteItem",
10
- props: {
11
- id: {},
12
- type: {},
13
- message: {},
14
- autoClose: { type: Boolean },
15
- duration: {},
16
- position: {}
17
- },
18
- emits: ["close"],
19
- setup(a, { expose: t, emit: e }) {
20
- const o = a, n = e, i = h(null), p = h(0), c = h(0);
21
- function s() {
22
- i.value && clearTimeout(i.value), n("close");
23
- }
24
- function r() {
25
- i.value && (clearTimeout(i.value), i.value = null, c.value = o.duration - (Date.now() - p.value));
26
- }
27
- function u() {
28
- !i.value && c.value > 0 && (i.value = setTimeout(s, c.value));
29
- }
30
- return O(() => {
31
- i.value && (clearTimeout(i.value), i.value = null), o.autoClose && (p.value = Date.now(), c.value = o.duration, i.value = setTimeout(s, o.duration));
32
- }), t({
33
- pause: r,
34
- resume: u
35
- }), (l, _) => (d(), m("div", {
36
- class: "toasts-lite__toast",
37
- style: $(`--toast-duration: ${a.duration}s;`),
38
- onClick: E(s, ["prevent"])
39
- }, [
40
- ["success", "error", "loading", "warn"].includes(a.type) ? (d(), m("div", S, [
41
- v("div", {
42
- class: C(`toasts-lite__${a.type}`)
43
- }, null, 2)
44
- ])) : U("", !0),
45
- v("div", V, [
46
- v("div", z, D(a.message), 1)
47
- ])
48
- ], 4));
49
- }
50
- });
51
- class R extends Map {
1
+ var M = Object.defineProperty;
2
+ var $ = (r, t, e) => t in r ? M(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
3
+ var v = (r, t, e) => $(r, typeof t != "symbol" ? t + "" : t, e);
4
+ import { ref as h, defineComponent as O, watch as L, onMounted as U, onUnmounted as k, createElementBlock as g, openBlock as d, withModifiers as A, normalizeStyle as E, createCommentVNode as x, createElementVNode as p, normalizeClass as D, toDisplayString as B, computed as P, createBlock as y, Teleport as I, Fragment as b, renderList as T, unref as m, createVNode as N, TransitionGroup as R, withCtx as S } from "vue";
5
+ class V extends Map {
52
6
  constructor() {
53
7
  super(...arguments);
54
- f(this, "subscribers", []);
8
+ v(this, "subscribers", []);
55
9
  }
56
10
  set(e, o) {
57
11
  return super.set(e, o), this.notify(), this;
@@ -72,108 +26,251 @@ class R extends Map {
72
26
  this.subscribers.forEach((e) => e(Array.from(this.values())));
73
27
  }
74
28
  }
75
- const j = {
29
+ const w = {
76
30
  type: "success",
77
31
  message: "Hello from Toasts Lite",
78
32
  autoClose: !0,
79
33
  duration: 3e3,
80
34
  position: "top-center"
81
35
  };
82
- class G {
36
+ class j {
83
37
  constructor() {
84
- f(this, "counter", 0);
85
- f(this, "toasts");
86
- this.toasts = new R();
38
+ v(this, "counter", 0);
39
+ v(this, "toasts");
40
+ this.toasts = new V();
87
41
  }
42
+ /**
43
+ * Returns an array of all currently active toasts.
44
+ * @description Useful for debugging or external monitoring
45
+ *
46
+ * @returns Array of toast properties for all active toasts
47
+ */
88
48
  get toastList() {
89
49
  return Array.from(this.toasts.values());
90
50
  }
51
+ /**
52
+ * Subscribes to changes in the toast list.
53
+ *
54
+ * @param callback - Function called whenever toasts are added, updated, or removed
55
+ * @returns Unsubscribe function to stop listening for changes
56
+ *
57
+ * @example
58
+ * ```ts
59
+ * const unsubscribe = toasts.onToastsListChange((toastsList) => {
60
+ * console.log('Toasts updated:', toastsList)
61
+ * })
62
+ *
63
+ * // Later, to stop listening:
64
+ * unsubscribe()
65
+ * ```
66
+ */
91
67
  onToastsListChange(t) {
92
68
  return this.toasts.subscribe(t);
93
69
  }
94
- ID() {
95
- return `toast:${Date.now().toString(16)}-${this.counter++}`;
96
- }
97
- addOrUpdate(t) {
98
- let { id: e = this.ID(), ...o } = t;
99
- if (this.toasts.has(e)) {
100
- const n = this.toasts.get(e);
101
- return Object.assign(n, o), this.toasts.set(e, n), e;
102
- }
103
- return this.toasts.set(e, { id: e, ...j, ...o }), e;
104
- }
105
70
  /**
106
- * Add a toast
107
- * @param options - The options for the toast
108
- * @returns The id of the toast
71
+ * Creates a toast notification with custom options. If toast with the same ID already exists, it will be updated.
72
+ * @description Use this method when you need full control over toast configuration.
73
+ * @description For simpler use cases, consider using {@link success}, {@link error}, {@link warn}, or {@link loading} methods.
74
+ *
75
+ * @param options - Configuration options for the toast
76
+ * @returns Unique identifier of the created toast
77
+ *
78
+ * @example
79
+ * ```ts
80
+ * // Create a custom toast
81
+ * const id = toasts.add({
82
+ * type: 'success',
83
+ * message: 'Custom notification',
84
+ * duration: 5000,
85
+ * position: 'top-right',
86
+ * autoClose: true
87
+ * })
88
+ *
89
+ * // Create with custom ID for later reference
90
+ * toasts.add({ id: 'my-toast', type: 'loading', message: 'Processing...' })
91
+ * ```
109
92
  */
110
93
  add(t) {
111
94
  return this.addOrUpdate(t);
112
95
  }
113
96
  /**
114
- * Update a toast by id
115
- * @param id - The id of the toast to update
116
- * @param options - The options for the toast
117
- * @returns The id of the toast
97
+ * Updates an existing toast notification by its ID.
98
+ * @description Useful for changing the content or appearance of a toast that is already displayed, such as updating a loading toast to show success or error state.
99
+ *
100
+ * @param id - Unique identifier of the toast to update
101
+ * @param options - New configuration options to apply
102
+ * @returns The same toast ID
103
+ *
104
+ * @example
105
+ * ```ts
106
+ * // Create a loading toast
107
+ * const id = toasts.loading('Uploading file...')
108
+ *
109
+ * // Later, update it to show success
110
+ * toasts.update(id, { type: 'success', message: 'File uploaded!' })
111
+ * ```
118
112
  */
119
113
  update(t, e) {
120
114
  return this.addOrUpdate({ ...e, id: t });
121
115
  }
122
116
  /**
123
- * Remove a toast by id
124
- * If no id is provided, all current toasts will be removed
125
- * @param id - The id of the toast to remove
117
+ * Removes a toast notification from the screen.
118
+ * @description If no ID is provided, all currently visible toasts will be removed. If the specified ID doesn't exist, this method does nothing.
119
+ *
120
+ * @param id - Optional unique identifier of the toast to remove.
121
+ * If omitted, all toasts are removed.
122
+ *
123
+ * @example
124
+ * ```ts
125
+ * // Remove a specific toast
126
+ * const id = toasts.success('Hello!')
127
+ * toasts.remove(id)
128
+ *
129
+ * // Remove all toasts
130
+ * toasts.remove()
131
+ * ```
132
+ *
133
+ * @see {@link clear} for explicitly removing all toasts
126
134
  */
127
135
  remove(t) {
128
136
  t && !this.toasts.has(t) || (t ? this.toasts.delete(t) : this.clear());
129
137
  }
130
138
  /**
131
- * Remove all current toasts
139
+ * Removes all currently visible toast notifications.
140
+ *
141
+ * @example
142
+ * ```ts
143
+ * // Clear all toasts on route change
144
+ * router.beforeEach(() => {
145
+ * toasts.clear()
146
+ * })
147
+ * ```
132
148
  */
133
149
  clear() {
134
150
  this.toasts.clear();
135
151
  }
136
152
  /**
137
- * Add a success toast
138
- * @param message - The message to display in the toast
139
- * @param options - The options for the toast
140
- * @returns The id of the toast
153
+ * Displays a **success** toast notification.
154
+ *
155
+ * @param message - Text content to display in the toast
156
+ * @param options - Optional configuration (position, duration, autoClose, id)
157
+ * @returns Unique identifier of the created toast
158
+ *
159
+ * @example
160
+ * ```ts
161
+ * // Simple success message
162
+ * toasts.success('Changes saved successfully!')
163
+ *
164
+ * // With custom options
165
+ * toasts.success('Profile updated', {
166
+ * duration: 5000,
167
+ * position: 'bottom-center'
168
+ * })
169
+ * ```
141
170
  */
142
171
  success(t, e) {
143
172
  return this.addOrUpdate({ ...e, message: t, type: "success" });
144
173
  }
145
174
  /**
146
- * Add an error toast
147
- * @param message - The message to display in the toast
148
- * @param options - The options for the toast
149
- * @returns The id of the toast
175
+ * Displays an **error** toast notification.
176
+ *
177
+ * @param message - Text content to display in the toast
178
+ * @param options - Optional configuration (position, duration, autoClose, id)
179
+ * @returns Unique identifier of the created toast
180
+ *
181
+ * @example
182
+ * ```ts
183
+ * // Simple error message
184
+ * toasts.error('Failed to save changes')
185
+ *
186
+ * // Non-auto-closing error
187
+ * toasts.error('Critical error occurred', { autoClose: false })
188
+ * ```
150
189
  */
151
190
  error(t, e) {
152
191
  return this.addOrUpdate({ ...e, message: t, type: "error" });
153
192
  }
154
193
  /**
155
- * Add a warning toast
156
- * @param message - The message to display in the toast
157
- * @param options - The options for the toast
158
- * @returns The id of the toast
194
+ * Displays a **warning** toast notification.
195
+ *
196
+ * @param message - Text content to display in the toast
197
+ * @param options - Optional configuration (position, duration, autoClose, id)
198
+ * @returns Unique identifier of the created toast
199
+ *
200
+ * @example
201
+ * ```ts
202
+ * // Simple warning message
203
+ * toasts.warn('Your session will expire soon')
204
+ *
205
+ * // With longer duration
206
+ * toasts.warn('Unsaved changes detected', { duration: 10000 })
207
+ * ```
159
208
  */
160
209
  warn(t, e) {
161
210
  return this.addOrUpdate({ ...e, message: t, type: "warn" });
162
211
  }
163
212
  /**
164
- * Add a loading toast
165
- * @param message - The message to display in the toast
166
- * @param options - The options for the toast
167
- * @returns The id of the toast
213
+ * Displays a **loading** toast notification.
214
+ *
215
+ * Loading toasts are typically used as placeholders while
216
+ * an async operation is in progress.
217
+ *
218
+ * @param message - Text content to display in the toast
219
+ * @param options - Optional configuration (position, duration, autoClose, id)
220
+ * @returns Unique identifier of the created toast
221
+ *
222
+ * @example
223
+ * ```ts
224
+ * // Manual loading state management
225
+ * const id = toasts.loading('Saving...')
226
+ *
227
+ * try {
228
+ * await saveData()
229
+ * toasts.update(id, { type: 'success', message: 'Saved!' })
230
+ * } catch {
231
+ * toasts.update(id, { type: 'error', message: 'Save failed' })
232
+ * }
233
+ * ```
234
+ *
235
+ * @see {@link promise} for automatic promise-based state management
168
236
  */
169
237
  loading(t, e) {
170
238
  return this.addOrUpdate({ ...e, message: t, type: "loading" });
171
239
  }
172
240
  /**
173
- * Add a promise toast
174
- * @param promise - The promise to display in the toast
175
- * @param options - The options for the toast
176
- * @returns The id of the toast
241
+ * Displays a **promise** toast that automatically updates based on promise resolution.
242
+ *
243
+ * Shows a loading toast while the promise is pending, then automatically
244
+ * transitions to success or error state based on the promise outcome.
245
+ *
246
+ * @template T - Type of the promise result
247
+ * @param promise - The promise to track
248
+ * @param options - Messages for each state and optional positioning
249
+ * @param options.loading - Message to show while promise is pending
250
+ * @param options.success - Message to show when promise resolves
251
+ * @param options.error - Message to show when promise rejects
252
+ * @param options.position - Optional toast position on screen
253
+ * @param options.id - Optional custom ID for the toast
254
+ * @returns Promise that resolves to the toast ID
255
+ * @throws Error with the error message if the promise rejects
256
+ *
257
+ * @example
258
+ * ```ts
259
+ * // Basic usage
260
+ * await toasts.promise(fetchUserData(), {
261
+ * loading: 'Loading user data...',
262
+ * success: 'User data loaded!',
263
+ * error: 'Failed to load user data'
264
+ * })
265
+ *
266
+ * // With custom position
267
+ * await toasts.promise(uploadFile(file), {
268
+ * loading: 'Uploading...',
269
+ * success: 'File uploaded successfully!',
270
+ * error: 'Upload failed',
271
+ * position: 'bottom-right'
272
+ * })
273
+ * ```
177
274
  */
178
275
  async promise(t, e) {
179
276
  const o = this.loading(e.loading, { position: e.position, id: e.id });
@@ -183,75 +280,153 @@ class G {
183
280
  throw this.error(e.error, { position: e.position, id: o }), new Error(e.error);
184
281
  }
185
282
  }
283
+ ID() {
284
+ return `toast:${Date.now().toString(16)}-${this.counter++}`;
285
+ }
286
+ addOrUpdate(t) {
287
+ let { id: e = this.ID(), ...o } = t;
288
+ if (this.toasts.has(e)) {
289
+ const n = this.toasts.get(e);
290
+ return Object.assign(n, o), this.toasts.set(e, n), e;
291
+ }
292
+ return this.toasts.set(e, { ...this.mergeWithDefaultOptions(o), id: e }), e;
293
+ }
294
+ mergeWithDefaultOptions(t) {
295
+ const e = Object.assign({}, w);
296
+ for (let o in w) {
297
+ const n = o, s = t[n];
298
+ s != null && (e[n] = s);
299
+ }
300
+ return e;
301
+ }
186
302
  }
187
- const y = new G(), H = ["onMouseenter", "onMouseleave"], K = /* @__PURE__ */ w({
188
- __name: "ToastsLiteProvider",
189
- setup(a) {
190
- const t = [
191
- "top-left",
192
- "top-center",
193
- "top-right",
194
- "middle-center",
195
- "bottom-left",
196
- "bottom-center",
197
- "bottom-right"
198
- ], e = h(y.toastList);
199
- y.onToastsListChange((s) => {
200
- e.value = s;
201
- });
202
- const o = k(() => {
203
- const s = /* @__PURE__ */ new Map();
204
- return e.value.forEach((r) => {
205
- const u = r.position || "top-center";
206
- s.has(u) || s.set(u, []), s.get(u).push(r);
207
- }), s;
208
- }), n = h({});
209
- x(() => {
210
- for (const s of t)
211
- n.value[s] = [];
212
- });
213
- function i(s) {
214
- n.value[s] && n.value[s].forEach((r) => r == null ? void 0 : r.pause());
303
+ const C = new j();
304
+ function z() {
305
+ const r = h(/* @__PURE__ */ new Map());
306
+ function t(n, s, a) {
307
+ r.value.has(n) || r.value.set(n, []);
308
+ const i = r.value.get(n);
309
+ a && "pause" in a && "resume" in a && (i[s] = a);
310
+ }
311
+ function e(n) {
312
+ var s;
313
+ (s = r.value.get(n)) == null || s.forEach((a) => a == null ? void 0 : a.pause());
314
+ }
315
+ function o(n) {
316
+ var s;
317
+ (s = r.value.get(n)) == null || s.forEach((a) => a == null ? void 0 : a.resume());
318
+ }
319
+ return {
320
+ setRef: t,
321
+ pauseAll: e,
322
+ resumeAll: o
323
+ };
324
+ }
325
+ const F = {
326
+ key: 0,
327
+ class: "toasts-lite__icon"
328
+ }, W = { class: "toasts-lite__content" }, G = { class: "toasts-lite__content-message" }, H = /* @__PURE__ */ O({
329
+ __name: "ToastsLiteItem",
330
+ props: {
331
+ id: {},
332
+ type: {},
333
+ message: {},
334
+ autoClose: { type: Boolean },
335
+ duration: {},
336
+ position: {}
337
+ },
338
+ emits: ["close"],
339
+ setup(r, { expose: t, emit: e }) {
340
+ const o = r, n = e, s = h(null), a = h(0), i = h(0);
341
+ function c() {
342
+ s.value && clearTimeout(s.value), n("close");
343
+ }
344
+ function u() {
345
+ s.value && (clearTimeout(s.value), s.value = null, i.value = o.duration - (Date.now() - a.value));
215
346
  }
216
- function p(s) {
217
- n.value[s] && n.value[s].forEach((r) => r == null ? void 0 : r.resume());
347
+ function l() {
348
+ !s.value && i.value > 0 && (a.value = Date.now(), s.value = setTimeout(c, i.value));
218
349
  }
219
- function c(s, r) {
220
- n.value[s] || (n.value[s] = []), r && "pause" in r && "resume" in r && n.value[s].push(r);
350
+ function f() {
351
+ s.value && (clearTimeout(s.value), s.value = null), o.autoClose && (a.value = Date.now(), i.value = o.duration, s.value = setTimeout(c, o.duration));
221
352
  }
222
- return (s, r) => (d(), g(B, { to: "body" }, [
223
- (d(), m(b, null, T(t, (u) => v("div", {
353
+ return L(
354
+ () => [o.autoClose, o.duration],
355
+ () => {
356
+ f();
357
+ }
358
+ ), U(() => {
359
+ f();
360
+ }), k(() => {
361
+ s.value && clearTimeout(s.value);
362
+ }), t({
363
+ pause: u,
364
+ resume: l
365
+ }), (_, J) => (d(), g("div", {
366
+ class: "toasts-lite__toast",
367
+ style: E(`--toast-duration: ${r.duration}s;`),
368
+ onClick: A(c, ["prevent"])
369
+ }, [
370
+ ["success", "error", "loading", "warn"].includes(r.type) ? (d(), g("div", F, [
371
+ p("div", {
372
+ class: D(`toasts-lite__${r.type}`)
373
+ }, null, 2)
374
+ ])) : x("", !0),
375
+ p("div", W, [
376
+ p("div", G, B(r.message), 1)
377
+ ])
378
+ ], 4));
379
+ }
380
+ }), q = ["onMouseenter", "onMouseleave"], X = /* @__PURE__ */ O({
381
+ __name: "ToastsLiteProvider",
382
+ setup(r) {
383
+ const t = ["top-left", "top-center", "top-right", "middle-center", "bottom-left", "bottom-center", "bottom-right"], e = h([]), { setRef: o, pauseAll: n, resumeAll: s } = z();
384
+ C.onToastsListChange((i) => {
385
+ e.value = i;
386
+ });
387
+ const a = P(() => {
388
+ const i = /* @__PURE__ */ new Map();
389
+ return e.value.forEach((c) => {
390
+ const u = c.position || "top-center";
391
+ i.has(u) || i.set(u, []), i.get(u).push(c);
392
+ }), i;
393
+ });
394
+ return (i, c) => (d(), y(I, { to: "body" }, [
395
+ (d(), g(b, null, T(t, (u) => p("div", {
224
396
  key: u,
225
- class: C(["toasts-lite__toast-container", `toasts-lite__${u}`]),
226
- onMouseenter: (l) => i(u),
227
- onMouseleave: (l) => p(u)
397
+ class: D(["toasts-lite__toast-container", `toasts-lite__${u}`])
228
398
  }, [
229
- P(A, {
230
- name: "toasts-lite",
231
- appear: ""
232
- }, {
233
- default: I(() => [
234
- (d(!0), m(b, null, T(o.value.get(u) || [], (l) => (d(), g(F, {
235
- id: l.id,
236
- ref_for: !0,
237
- ref: (_) => c(u, _),
238
- key: l.id,
239
- type: l.type,
240
- message: l.message,
241
- "auto-close": l.autoClose,
242
- duration: l.duration,
243
- position: l.position,
244
- onClose: (_) => N(y).remove(l.id)
245
- }, null, 8, ["id", "type", "message", "auto-close", "duration", "position", "onClose"]))), 128))
246
- ]),
247
- _: 2
248
- }, 1024)
249
- ], 42, H)), 64))
399
+ p("div", {
400
+ class: "toasts-lite__toast-wrapper",
401
+ onMouseenter: (l) => m(n)(u),
402
+ onMouseleave: (l) => m(s)(u)
403
+ }, [
404
+ N(R, {
405
+ name: "toasts-lite",
406
+ appear: ""
407
+ }, {
408
+ default: S(() => [
409
+ (d(!0), g(b, null, T(a.value.get(u) || [], (l, f) => (d(), y(H, {
410
+ id: l.id,
411
+ ref_for: !0,
412
+ ref: (_) => m(o)(u, f, _),
413
+ key: l.id,
414
+ type: l.type,
415
+ message: l.message,
416
+ "auto-close": l.autoClose,
417
+ duration: l.duration,
418
+ position: l.position,
419
+ onClose: (_) => m(C).remove(l.id)
420
+ }, null, 8, ["id", "type", "message", "auto-close", "duration", "position", "onClose"]))), 128))
421
+ ]),
422
+ _: 2
423
+ }, 1024)
424
+ ], 40, q)
425
+ ], 2)), 64))
250
426
  ]));
251
427
  }
252
428
  });
253
429
  export {
254
- G as ToastsController,
255
- K as ToastsLiteProvider,
256
- y as toasts
430
+ X as ToastsLiteProvider,
431
+ C as toasts
257
432
  };
package/dist/style.css CHANGED
@@ -1 +1 @@
1
- :root{--toasts-lite-font-family: var(--tl-font-family, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif);--toasts-lite-bg: var(--tl-bg, hsl(0, 0%, 100%));--toasts-lite-text: var(--tl-text, hsl(0, 0%, 20%));--toasts-lite-border: var(--tl-border, hsl(0, 0%, 85%));--toasts-lite-shadow: var(--tl-shadow, hsla(0, 0%, 0%, .1));--toasts-lite-success: var(--tl-success, hsl(145, 63%, 42%));--toasts-lite-error: var(--tl-error, hsl(0, 79%, 63%));--toasts-lite-warn: var(--tl-warn, hsl(45, 100%, 51%));--toasts-lite-icon-color: var(--tl-icon-color, hsl(0, 0%, 100%));--toasts-lite-loading-border-main: var(--tl-loading-border, hsl(0, 0%, 15%));--toasts-lite-loading-border-bg: var(--tl-loading-bg, hsl(0, 0%, 98%))}@keyframes scaleAnimation{0%{transform:scale(0);opacity:0}to{transform:scale(1);opacity:1}}@keyframes loadingRotate{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.toasts-lite-enter-active,.toasts-lite-leave-active{transition:opacity .3s ease,transform .3s ease}.toasts-lite-enter-from,.toasts-lite-leave-to{opacity:0;transform:translateY(-10px)}.toasts-lite__toast-container{position:fixed;z-index:9999;margin:10px;overflow:visible;display:flex;flex-direction:column;align-items:center;padding-top:12px;gap:12px;pointer-events:none}.toasts-lite__toast{font-family:var(--toasts-lite-font-family);display:flex;justify-content:center;align-items:center;background:var(--toasts-lite-bg);color:var(--toasts-lite-text);border:1px solid var(--toasts-lite-border);box-shadow:var(--toasts-lite-shadow) 0 0 10px;min-width:100px;max-width:1200px;padding:10px 20px;border-radius:8px;cursor:pointer;pointer-events:auto;text-overflow:ellipsis}.toasts-lite__icon{margin-right:12px}.toasts-lite__top-left{top:0;left:0}.toasts-lite__top-center{top:0;left:50%;transform:translate(-50%);min-width:80vw}.toasts-lite__top-right{top:0;right:0}.toasts-lite__bottom-left{bottom:0;left:0}.toasts-lite__bottom-center{bottom:0;left:50%;transform:translate(-50%)}.toasts-lite__bottom-right{bottom:0;right:0}.toasts-lite__middle-center{top:50%;left:50%;transform:translate(-50%,-50%)}.toasts-lite__success{width:20px;height:20px;border-radius:10px;background-color:var(--toasts-lite-success);position:relative;opacity:0;animation:scaleAnimation .3s cubic-bezier(.75,.885,.32,1.275) forwards;animation-delay:.1s}.toasts-lite__success:after{content:"";position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);width:12px;height:12px;mask-image:url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="3" stroke="black"><path stroke-linecap="round" stroke-linejoin="round" d="m4.5 12.75 6 6 9-13.5" /></svg>');-webkit-mask-image:url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="3" stroke="black"><path stroke-linecap="round" stroke-linejoin="round" d="m4.5 12.75 6 6 9-13.5" /></svg>');background-color:var(--toasts-lite-icon-color);background-size:100%;background-position:center;background-repeat:no-repeat}.toasts-lite__error{width:20px;height:20px;border-radius:10px;background-color:var(--toasts-lite-error);position:relative;opacity:0;animation:scaleAnimation .3s cubic-bezier(.75,.885,.32,1.275) forwards;animation-delay:.1s}.toasts-lite__error:after{content:"";position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);width:12px;height:12px;mask-image:url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="4" stroke="black"><path stroke-linecap="round" stroke-linejoin="round" d="M6 6l12 12M18 6l-12 12" /></svg>');-webkit-mask-image:url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="4" stroke="black"><path stroke-linecap="round" stroke-linejoin="round" d="M6 6l12 12M18 6l-12 12" /></svg>');background-color:var(--toasts-lite-icon-color);background-size:100%;background-position:center;background-repeat:no-repeat}.toasts-lite__warn{width:20px;height:20px;border-radius:10px;background-color:var(--toasts-lite-warn);position:relative;opacity:0;animation:scaleAnimation .3s cubic-bezier(.75,.885,.32,1.275) forwards;animation-delay:.1s}.toasts-lite__warn:after{content:"";position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);width:12px;height:12px;mask-image:url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="5" stroke="currentColor" ><path stroke-linecap="round" stroke-linejoin="round" d="M5 12h14" /></svg>');-webkit-mask-image:url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="5" stroke="currentColor" ><path stroke-linecap="round" stroke-linejoin="round" d="M5 12h14" /></svg>');background-color:var(--toasts-lite-icon-color);background-size:100%;background-position:center;background-repeat:no-repeat}.toasts-lite__loading{width:20px;height:20px;box-sizing:border-box;border:2px solid;border-radius:100%;border-color:var(--toasts-lite-loading-border-main);border-right-color:var(--toasts-lite-loading-border-bg);animation:loadingRotate 1s linear infinite}
1
+ :root{--toasts-lite-font-family: var(--tl-font-family, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif);--toasts-lite-bg: var(--tl-bg, hsl(0, 0%, 100%));--toasts-lite-text: var(--tl-text, hsl(0, 0%, 20%));--toasts-lite-border: var(--tl-border, hsl(0, 0%, 85%));--toasts-lite-shadow: var(--tl-shadow, hsla(0, 0%, 0%, .1));--toasts-lite-success: var(--tl-success, hsl(145, 63%, 42%));--toasts-lite-error: var(--tl-error, hsl(0, 79%, 63%));--toasts-lite-warn: var(--tl-warn, hsl(45, 100%, 51%));--toasts-lite-icon-color: var(--tl-icon-color, hsl(0, 0%, 100%));--toasts-lite-loading-border-main: var(--tl-loading-border, hsl(0, 0%, 15%));--toasts-lite-loading-border-bg: var(--tl-loading-bg, hsl(0, 0%, 98%))}@keyframes scaleAnimation{0%{transform:scale(0);opacity:0}to{transform:scale(1);opacity:1}}@keyframes loadingRotate{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.toasts-lite-enter-active,.toasts-lite-leave-active{transition:opacity .3s ease,transform .3s ease}.toasts-lite-enter-from,.toasts-lite-leave-to{opacity:0;transform:translateY(-10px)}.toasts-lite__toast-container{position:fixed;z-index:9999;margin:10px;overflow:visible;display:flex;flex-direction:column;align-items:center;padding-top:12px;pointer-events:none}.toasts-lite__toast-wrapper{display:flex;flex-direction:column;align-items:center;gap:12px;pointer-events:auto}.toasts-lite__toast{font-family:var(--toasts-lite-font-family);display:flex;justify-content:center;align-items:center;background:var(--toasts-lite-bg);color:var(--toasts-lite-text);border:1px solid var(--toasts-lite-border);box-shadow:var(--toasts-lite-shadow) 0 0 10px;min-width:100px;max-width:1200px;padding:10px 20px;border-radius:8px;cursor:pointer;pointer-events:auto;text-overflow:ellipsis}.toasts-lite__icon{margin-right:12px}.toasts-lite__top-left{top:0;left:0}.toasts-lite__top-center{top:0;left:50%;transform:translate(-50%);min-width:80vw}.toasts-lite__top-right{top:0;right:0}.toasts-lite__bottom-left{bottom:0;left:0}.toasts-lite__bottom-center{bottom:0;left:50%;transform:translate(-50%)}.toasts-lite__bottom-right{bottom:0;right:0}.toasts-lite__middle-center{top:50%;left:50%;transform:translate(-50%,-50%)}.toasts-lite__success{width:20px;height:20px;border-radius:10px;background-color:var(--toasts-lite-success);position:relative;opacity:0;animation:scaleAnimation .3s cubic-bezier(.75,.885,.32,1.275) forwards;animation-delay:.1s}.toasts-lite__success:after{content:"";position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);width:12px;height:12px;mask-image:url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="3" stroke="black"><path stroke-linecap="round" stroke-linejoin="round" d="m4.5 12.75 6 6 9-13.5" /></svg>');-webkit-mask-image:url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="3" stroke="black"><path stroke-linecap="round" stroke-linejoin="round" d="m4.5 12.75 6 6 9-13.5" /></svg>');background-color:var(--toasts-lite-icon-color);background-size:100%;background-position:center;background-repeat:no-repeat}.toasts-lite__error{width:20px;height:20px;border-radius:10px;background-color:var(--toasts-lite-error);position:relative;opacity:0;animation:scaleAnimation .3s cubic-bezier(.75,.885,.32,1.275) forwards;animation-delay:.1s}.toasts-lite__error:after{content:"";position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);width:12px;height:12px;mask-image:url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="4" stroke="black"><path stroke-linecap="round" stroke-linejoin="round" d="M6 6l12 12M18 6l-12 12" /></svg>');-webkit-mask-image:url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="4" stroke="black"><path stroke-linecap="round" stroke-linejoin="round" d="M6 6l12 12M18 6l-12 12" /></svg>');background-color:var(--toasts-lite-icon-color);background-size:100%;background-position:center;background-repeat:no-repeat}.toasts-lite__warn{width:20px;height:20px;border-radius:10px;background-color:var(--toasts-lite-warn);position:relative;opacity:0;animation:scaleAnimation .3s cubic-bezier(.75,.885,.32,1.275) forwards;animation-delay:.1s}.toasts-lite__warn:after{content:"";position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);width:12px;height:12px;mask-image:url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="5" stroke="currentColor" ><path stroke-linecap="round" stroke-linejoin="round" d="M5 12h14" /></svg>');-webkit-mask-image:url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="5" stroke="currentColor" ><path stroke-linecap="round" stroke-linejoin="round" d="M5 12h14" /></svg>');background-color:var(--toasts-lite-icon-color);background-size:100%;background-position:center;background-repeat:no-repeat}.toasts-lite__loading{width:20px;height:20px;box-sizing:border-box;border:2px solid;border-radius:100%;border-color:var(--toasts-lite-loading-border-main);border-right-color:var(--toasts-lite-loading-border-bg);animation:loadingRotate 1s linear infinite}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue-toasts-lite",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "type": "module",
5
5
  "types": "./dist/index.d.ts",
6
6
  "author": "scheron",
@@ -10,7 +10,7 @@
10
10
  },
11
11
  "license": "MIT",
12
12
  "description": "Lightweight toast notifications for Vue 3",
13
- "keywords": [ "vue", "toast", "notification", "vue3" ],
13
+ "keywords": ["vue", "toast", "notification", "vue3"],
14
14
  "files": [
15
15
  "dist"
16
16
  ],
@@ -25,6 +25,10 @@
25
25
  },
26
26
  "scripts": {
27
27
  "dev": "vite",
28
+ "format": "prettier --write src/",
29
+ "format:example": "prettier --write example/",
30
+ "format:all": "bun run format && bun run format:example",
31
+ "typecheck": "vue-tsc",
28
32
  "build": "vite build",
29
33
  "build:example": "cd example && bun run build",
30
34
  "preview": "vite preview"
@@ -33,11 +37,14 @@
33
37
  "vue": "^3.0.0"
34
38
  },
35
39
  "devDependencies": {
40
+ "@ianvs/prettier-plugin-sort-imports": "^4.7.0",
36
41
  "@types/node": "^25.0.8",
37
42
  "@vitejs/plugin-vue": "^5.0.0",
43
+ "prettier": "^3.8.0",
38
44
  "typescript": "^5.8.3",
39
45
  "vite": "^5.0.0",
40
46
  "vite-plugin-dts": "^4.5.4",
41
- "vue": "^3.0.0"
47
+ "vue": "^3.0.0",
48
+ "vue-tsc": "^3.2.2"
42
49
  }
43
50
  }