vue-notifyr 0.1.2 → 0.1.4
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/index.cjs +93 -164
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/package.json +7 -2
- package/src/adapters/nuxt/index.ts +3 -1
package/dist/index.cjs
CHANGED
|
@@ -1,16 +1,11 @@
|
|
|
1
|
-
(function
|
|
2
|
-
typeof exports ===
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
? define(['exports', 'vue'], factory)
|
|
6
|
-
: ((global = typeof globalThis !== 'undefined' ? globalThis : global || self),
|
|
7
|
-
factory((global.VueNotifyr = {}), global.Vue));
|
|
8
|
-
})(this, function (exports2, vue) {
|
|
9
|
-
'use strict';
|
|
1
|
+
(function(global, factory) {
|
|
2
|
+
typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("vue"), require("nuxt/app")) : typeof define === "function" && define.amd ? define(["exports", "vue", "nuxt/app"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.VueNotifyr = {}, global.Vue, global.app));
|
|
3
|
+
})(this, function(exports2, vue, app) {
|
|
4
|
+
"use strict";
|
|
10
5
|
const DEFAULT_OPTIONS = {
|
|
11
|
-
position:
|
|
6
|
+
position: "top-center",
|
|
12
7
|
autoClose: 3e3,
|
|
13
|
-
progress: true
|
|
8
|
+
progress: true
|
|
14
9
|
};
|
|
15
10
|
class NotificationManager {
|
|
16
11
|
constructor() {
|
|
@@ -51,7 +46,7 @@
|
|
|
51
46
|
*/
|
|
52
47
|
setDefaults(opts) {
|
|
53
48
|
this.options = { ...this.options, ...opts };
|
|
54
|
-
this.emit(
|
|
49
|
+
this.emit("options-changed", this.options);
|
|
55
50
|
}
|
|
56
51
|
/**
|
|
57
52
|
* Show a notification.
|
|
@@ -60,17 +55,17 @@
|
|
|
60
55
|
* @param opts - Optional override options
|
|
61
56
|
*/
|
|
62
57
|
show(type, title, opts) {
|
|
63
|
-
const options = { ...this.options, ...
|
|
58
|
+
const options = { ...this.options, ...opts || {} };
|
|
64
59
|
const item = {
|
|
65
60
|
id: this.idCounter++,
|
|
66
61
|
type,
|
|
67
62
|
title,
|
|
68
63
|
options,
|
|
69
|
-
createdAt: Date.now()
|
|
64
|
+
createdAt: Date.now()
|
|
70
65
|
};
|
|
71
66
|
this.notifications.push(item);
|
|
72
|
-
this.emit(
|
|
73
|
-
if (options.autoClose !== false && typeof window !==
|
|
67
|
+
this.emit("notification-added", item);
|
|
68
|
+
if (options.autoClose !== false && typeof window !== "undefined") {
|
|
74
69
|
setTimeout(() => this.remove(item.id), options.autoClose);
|
|
75
70
|
}
|
|
76
71
|
}
|
|
@@ -82,7 +77,7 @@
|
|
|
82
77
|
const index = this.notifications.findIndex((n) => n.id === id);
|
|
83
78
|
if (index !== -1) {
|
|
84
79
|
const removed = this.notifications.splice(index, 1)[0];
|
|
85
|
-
this.emit(
|
|
80
|
+
this.emit("notification-removed", removed);
|
|
86
81
|
}
|
|
87
82
|
}
|
|
88
83
|
/**
|
|
@@ -91,7 +86,7 @@
|
|
|
91
86
|
clear() {
|
|
92
87
|
const removed = [...this.notifications];
|
|
93
88
|
this.notifications.splice(0);
|
|
94
|
-
this.emit(
|
|
89
|
+
this.emit("notifications-cleared", removed);
|
|
95
90
|
}
|
|
96
91
|
/**
|
|
97
92
|
* Get a copy of the current notifications.
|
|
@@ -113,7 +108,7 @@
|
|
|
113
108
|
* @param opts - Optional options
|
|
114
109
|
*/
|
|
115
110
|
success(title, opts) {
|
|
116
|
-
this.show(
|
|
111
|
+
this.show("success", title, opts);
|
|
117
112
|
}
|
|
118
113
|
/**
|
|
119
114
|
* Error notification shorthand.
|
|
@@ -121,7 +116,7 @@
|
|
|
121
116
|
* @param opts - Optional options
|
|
122
117
|
*/
|
|
123
118
|
error(title, opts) {
|
|
124
|
-
this.show(
|
|
119
|
+
this.show("error", title, opts);
|
|
125
120
|
}
|
|
126
121
|
/**
|
|
127
122
|
* Warning notification shorthand.
|
|
@@ -129,7 +124,7 @@
|
|
|
129
124
|
* @param opts - Optional options
|
|
130
125
|
*/
|
|
131
126
|
warning(title, opts) {
|
|
132
|
-
this.show(
|
|
127
|
+
this.show("warning", title, opts);
|
|
133
128
|
}
|
|
134
129
|
/**
|
|
135
130
|
* Info notification shorthand.
|
|
@@ -137,25 +132,25 @@
|
|
|
137
132
|
* @param opts - Optional options
|
|
138
133
|
*/
|
|
139
134
|
info(title, opts) {
|
|
140
|
-
this.show(
|
|
135
|
+
this.show("info", title, opts);
|
|
141
136
|
}
|
|
142
137
|
}
|
|
143
138
|
const notificationManager = new NotificationManager();
|
|
144
139
|
function createReactiveNotificationStore(manager = notificationManager) {
|
|
145
140
|
const store = vue.reactive({
|
|
146
141
|
notifications: manager.getNotifications(),
|
|
147
|
-
options: manager.getOptions()
|
|
142
|
+
options: manager.getOptions()
|
|
148
143
|
});
|
|
149
|
-
manager.on(
|
|
144
|
+
manager.on("notification-added", () => {
|
|
150
145
|
store.notifications = manager.getNotifications();
|
|
151
146
|
});
|
|
152
|
-
manager.on(
|
|
147
|
+
manager.on("notification-removed", () => {
|
|
153
148
|
store.notifications = manager.getNotifications();
|
|
154
149
|
});
|
|
155
|
-
manager.on(
|
|
150
|
+
manager.on("notifications-cleared", () => {
|
|
156
151
|
store.notifications = manager.getNotifications();
|
|
157
152
|
});
|
|
158
|
-
manager.on(
|
|
153
|
+
manager.on("options-changed", () => {
|
|
159
154
|
store.options = manager.getOptions();
|
|
160
155
|
});
|
|
161
156
|
return store;
|
|
@@ -172,37 +167,37 @@
|
|
|
172
167
|
clear: () => manager.clear(),
|
|
173
168
|
setDefaults: (opts) => manager.setDefaults(opts),
|
|
174
169
|
getNotifications: () => manager.getNotifications(),
|
|
175
|
-
getOptions: () => manager.getOptions()
|
|
170
|
+
getOptions: () => manager.getOptions()
|
|
176
171
|
};
|
|
177
172
|
}
|
|
178
173
|
function createVueNotificationPlugin$1(manager = notificationManager) {
|
|
179
174
|
return {
|
|
180
|
-
install(
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
}
|
|
175
|
+
install(app2) {
|
|
176
|
+
app2.config.globalProperties.$notificationManager = manager;
|
|
177
|
+
app2.provide("notificationManager", manager);
|
|
178
|
+
}
|
|
184
179
|
};
|
|
185
180
|
}
|
|
186
|
-
const _hoisted_1 = [
|
|
187
|
-
const _hoisted_2 = { class:
|
|
188
|
-
const _hoisted_3 = { class:
|
|
189
|
-
const _hoisted_4 = { class:
|
|
190
|
-
const _hoisted_5 = [
|
|
181
|
+
const _hoisted_1 = ["data-position"];
|
|
182
|
+
const _hoisted_2 = { class: "notification-content" };
|
|
183
|
+
const _hoisted_3 = { class: "notification-title" };
|
|
184
|
+
const _hoisted_4 = { class: "notification-close" };
|
|
185
|
+
const _hoisted_5 = ["onClick"];
|
|
191
186
|
const _sfc_main = /* @__PURE__ */ vue.defineComponent({
|
|
192
|
-
__name:
|
|
187
|
+
__name: "NotificationContainer",
|
|
193
188
|
setup(__props) {
|
|
194
189
|
const isClient = vue.ref(false);
|
|
195
|
-
if (typeof window !==
|
|
190
|
+
if (typeof window !== "undefined") {
|
|
196
191
|
isClient.value = true;
|
|
197
192
|
}
|
|
198
193
|
const groups = vue.computed(() => {
|
|
199
194
|
const map = {
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
195
|
+
"top-left": [],
|
|
196
|
+
"top-center": [],
|
|
197
|
+
"top-right": [],
|
|
198
|
+
"bottom-left": [],
|
|
199
|
+
"bottom-center": [],
|
|
200
|
+
"bottom-right": []
|
|
206
201
|
};
|
|
207
202
|
for (const notification of notificationStore.notifications) {
|
|
208
203
|
map[notification.options.position].push(notification);
|
|
@@ -213,133 +208,67 @@
|
|
|
213
208
|
notificationManager.remove(id);
|
|
214
209
|
}
|
|
215
210
|
return (_ctx, _cache) => {
|
|
216
|
-
return isClient.value
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
},
|
|
263
|
-
],
|
|
264
|
-
]),
|
|
265
|
-
'data-position': pos,
|
|
266
|
-
},
|
|
267
|
-
[
|
|
268
|
-
vue.createElementVNode('div', _hoisted_2, [
|
|
269
|
-
vue.createElementVNode(
|
|
270
|
-
'span',
|
|
271
|
-
_hoisted_3,
|
|
272
|
-
vue.toDisplayString(notification.title),
|
|
273
|
-
1
|
|
274
|
-
),
|
|
275
|
-
]),
|
|
276
|
-
notification.options.progress &&
|
|
277
|
-
notification.options.autoClose !== false
|
|
278
|
-
? (vue.openBlock(),
|
|
279
|
-
vue.createElementBlock(
|
|
280
|
-
'div',
|
|
281
|
-
{
|
|
282
|
-
key: 0,
|
|
283
|
-
class: 'notification-progress',
|
|
284
|
-
style: vue.normalizeStyle({
|
|
285
|
-
animationDuration:
|
|
286
|
-
(notification.options.autoClose || 0) + 'ms',
|
|
287
|
-
}),
|
|
288
|
-
},
|
|
289
|
-
null,
|
|
290
|
-
4
|
|
291
|
-
))
|
|
292
|
-
: vue.createCommentVNode('', true),
|
|
293
|
-
vue.createElementVNode('div', _hoisted_4, [
|
|
294
|
-
vue.createElementVNode(
|
|
295
|
-
'button',
|
|
296
|
-
{
|
|
297
|
-
type: 'button',
|
|
298
|
-
onClick: ($event) =>
|
|
299
|
-
removeNotification(notification.id),
|
|
300
|
-
'aria-label': 'Dismiss notification',
|
|
301
|
-
},
|
|
302
|
-
' × ',
|
|
303
|
-
8,
|
|
304
|
-
_hoisted_5
|
|
305
|
-
),
|
|
306
|
-
]),
|
|
307
|
-
],
|
|
308
|
-
10,
|
|
309
|
-
_hoisted_1
|
|
310
|
-
)
|
|
311
|
-
);
|
|
312
|
-
}),
|
|
313
|
-
128
|
|
314
|
-
)),
|
|
315
|
-
]),
|
|
316
|
-
_: 2,
|
|
317
|
-
},
|
|
318
|
-
1032,
|
|
319
|
-
['data-position']
|
|
320
|
-
)
|
|
321
|
-
);
|
|
322
|
-
}),
|
|
323
|
-
128
|
|
324
|
-
)),
|
|
325
|
-
]
|
|
326
|
-
))
|
|
327
|
-
: vue.createCommentVNode('', true);
|
|
211
|
+
return isClient.value ? (vue.openBlock(), vue.createBlock(vue.Teleport, {
|
|
212
|
+
key: 0,
|
|
213
|
+
to: "body"
|
|
214
|
+
}, [
|
|
215
|
+
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(groups.value, (items, pos) => {
|
|
216
|
+
return vue.openBlock(), vue.createBlock(vue.TransitionGroup, {
|
|
217
|
+
key: pos,
|
|
218
|
+
tag: "div",
|
|
219
|
+
name: "notification",
|
|
220
|
+
class: "notification-list",
|
|
221
|
+
"data-position": pos
|
|
222
|
+
}, {
|
|
223
|
+
default: vue.withCtx(() => [
|
|
224
|
+
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(items, (notification) => {
|
|
225
|
+
return vue.openBlock(), vue.createElementBlock("article", {
|
|
226
|
+
key: notification.id,
|
|
227
|
+
class: vue.normalizeClass(["notification", [
|
|
228
|
+
`notification-${notification.type}`,
|
|
229
|
+
{
|
|
230
|
+
"notification-auto-close": notification.options.progress && notification.options.autoClose !== false
|
|
231
|
+
}
|
|
232
|
+
]]),
|
|
233
|
+
"data-position": pos
|
|
234
|
+
}, [
|
|
235
|
+
vue.createElementVNode("div", _hoisted_2, [
|
|
236
|
+
vue.createElementVNode("span", _hoisted_3, vue.toDisplayString(notification.title), 1)
|
|
237
|
+
]),
|
|
238
|
+
notification.options.progress && notification.options.autoClose !== false ? (vue.openBlock(), vue.createElementBlock("div", {
|
|
239
|
+
key: 0,
|
|
240
|
+
class: "notification-progress",
|
|
241
|
+
style: vue.normalizeStyle({ animationDuration: (notification.options.autoClose || 0) + "ms" })
|
|
242
|
+
}, null, 4)) : vue.createCommentVNode("", true),
|
|
243
|
+
vue.createElementVNode("div", _hoisted_4, [
|
|
244
|
+
vue.createElementVNode("button", {
|
|
245
|
+
type: "button",
|
|
246
|
+
onClick: ($event) => removeNotification(notification.id),
|
|
247
|
+
"aria-label": "Dismiss notification"
|
|
248
|
+
}, " × ", 8, _hoisted_5)
|
|
249
|
+
])
|
|
250
|
+
], 10, _hoisted_1);
|
|
251
|
+
}), 128))
|
|
252
|
+
]),
|
|
253
|
+
_: 2
|
|
254
|
+
}, 1032, ["data-position"]);
|
|
255
|
+
}), 128))
|
|
256
|
+
])) : vue.createCommentVNode("", true);
|
|
328
257
|
};
|
|
329
|
-
}
|
|
258
|
+
}
|
|
330
259
|
});
|
|
331
260
|
function useNotification() {
|
|
332
261
|
return useNotificationManager();
|
|
333
262
|
}
|
|
334
|
-
defineNuxtPlugin((nuxtApp) => {
|
|
263
|
+
app.defineNuxtPlugin((nuxtApp) => {
|
|
335
264
|
nuxtApp.vueApp.use(createVueNotificationPlugin(notificationManager));
|
|
336
265
|
});
|
|
337
266
|
function createVueNotificationPlugin(manager) {
|
|
338
267
|
return {
|
|
339
|
-
install(
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
}
|
|
268
|
+
install(app2) {
|
|
269
|
+
app2.config.globalProperties.$notificationManager = manager;
|
|
270
|
+
app2.provide("notificationManager", manager);
|
|
271
|
+
}
|
|
343
272
|
};
|
|
344
273
|
}
|
|
345
274
|
exports2.NotificationContainer = _sfc_main;
|
|
@@ -350,6 +279,6 @@
|
|
|
350
279
|
exports2.notificationStore = notificationStore;
|
|
351
280
|
exports2.useNotification = useNotification;
|
|
352
281
|
exports2.useNotificationManager = useNotificationManager;
|
|
353
|
-
Object.defineProperty(exports2, Symbol.toStringTag, { value:
|
|
282
|
+
Object.defineProperty(exports2, Symbol.toStringTag, { value: "Module" });
|
|
354
283
|
});
|
|
355
284
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../src/core/notification-manager.ts","../src/adapters/vue/index.ts","../src/adapters/vue/NotificationContainer.vue","../src/composables/useNotification.ts","../src/adapters/nuxt/index.ts"],"sourcesContent":["import type { NotificationType, NotificationOptions, NotificationItem } from '../types';\n\nconst DEFAULT_OPTIONS: Required<NotificationOptions> = {\n position: 'top-center',\n autoClose: 3000,\n progress: true,\n};\n\nexport class NotificationManager {\n private notifications: NotificationItem[] = [];\n private options: Required<NotificationOptions> = { ...DEFAULT_OPTIONS };\n private listeners: { [event: string]: Function[] } = {};\n private idCounter = 1;\n\n /**\n * Subscribe to an event.\n * @param event - The event name ('notification-added', 'notification-removed', 'notifications-cleared', 'options-changed')\n * @param callback - The callback function\n */\n on(event: string, callback: Function): void {\n if (!this.listeners[event]) {\n this.listeners[event] = [];\n }\n this.listeners[event].push(callback);\n }\n\n /**\n * Unsubscribe from an event.\n * @param event - The event name\n * @param callback - The callback function to remove\n */\n off(event: string, callback: Function): void {\n if (this.listeners[event]) {\n this.listeners[event] = this.listeners[event].filter((cb) => cb !== callback);\n }\n }\n\n private emit(event: string, data?: any): void {\n if (this.listeners[event]) {\n this.listeners[event].forEach((callback) => callback(data));\n }\n }\n\n /**\n * Set default options for notifications.\n * @param opts - The options to set as defaults\n */\n setDefaults(opts: NotificationOptions): void {\n this.options = { ...this.options, ...opts };\n this.emit('options-changed', this.options);\n }\n\n /**\n * Show a notification.\n * @param type - The type of notification\n * @param title - The title/message of the notification\n * @param opts - Optional override options\n */\n show(type: NotificationType, title: string, opts?: NotificationOptions): void {\n const options = { ...this.options, ...(opts || {}) };\n const item: NotificationItem = {\n id: this.idCounter++,\n type,\n title,\n options,\n createdAt: Date.now(),\n };\n this.notifications.push(item);\n this.emit('notification-added', item);\n\n if (options.autoClose !== false && typeof window !== 'undefined') {\n setTimeout(() => this.remove(item.id), options.autoClose);\n }\n }\n\n /**\n * Remove a notification by ID.\n * @param id - The ID of the notification to remove\n */\n remove(id: number): void {\n const index = this.notifications.findIndex((n) => n.id === id);\n if (index !== -1) {\n const removed = this.notifications.splice(index, 1)[0];\n this.emit('notification-removed', removed);\n }\n }\n\n /**\n * Clear all notifications.\n */\n clear(): void {\n const removed = [...this.notifications];\n this.notifications.splice(0);\n this.emit('notifications-cleared', removed);\n }\n\n /**\n * Get a copy of the current notifications.\n * @returns Array of notification items\n */\n getNotifications(): NotificationItem[] {\n return [...this.notifications];\n }\n\n /**\n * Get the current default options.\n * @returns The default options\n */\n getOptions(): Required<NotificationOptions> {\n return { ...this.options };\n }\n\n /**\n * Success notification shorthand.\n * @param title - The title/message\n * @param opts - Optional options\n */\n success(title: string, opts?: NotificationOptions): void {\n this.show('success', title, opts);\n }\n\n /**\n * Error notification shorthand.\n * @param title - The title/message\n * @param opts - Optional options\n */\n error(title: string, opts?: NotificationOptions): void {\n this.show('error', title, opts);\n }\n\n /**\n * Warning notification shorthand.\n * @param title - The title/message\n * @param opts - Optional options\n */\n warning(title: string, opts?: NotificationOptions): void {\n this.show('warning', title, opts);\n }\n\n /**\n * Info notification shorthand.\n * @param title - The title/message\n * @param opts - Optional options\n */\n info(title: string, opts?: NotificationOptions): void {\n this.show('info', title, opts);\n }\n}\n\n// Default instance for convenience\nexport const notificationManager = new NotificationManager();\n","import { reactive, watchEffect } from 'vue';\nimport { NotificationManager, notificationManager } from '../../core/notification-manager';\nimport type { NotificationItem, NotificationOptions } from '../../types';\n\nexport interface ReactiveNotificationStore {\n notifications: NotificationItem[];\n options: NotificationOptions;\n}\n\n/**\n * Create a reactive store for Vue that syncs with the NotificationManager.\n * @param manager - The NotificationManager instance (optional, uses default if not provided)\n * @returns Reactive store\n */\nexport function createReactiveNotificationStore(\n manager: NotificationManager = notificationManager\n): ReactiveNotificationStore {\n const store = reactive({\n notifications: manager.getNotifications(),\n options: manager.getOptions(),\n });\n\n // Sync notifications\n manager.on('notification-added', () => {\n store.notifications = manager.getNotifications();\n });\n manager.on('notification-removed', () => {\n store.notifications = manager.getNotifications();\n });\n manager.on('notifications-cleared', () => {\n store.notifications = manager.getNotifications();\n });\n\n // Sync options\n manager.on('options-changed', () => {\n store.options = manager.getOptions();\n });\n\n return store;\n}\n\n// Default reactive store\nexport const notificationStore = createReactiveNotificationStore();\n\n// Vue composable\nexport function useNotificationManager(manager: NotificationManager = notificationManager) {\n return {\n success: (title: string, opts?: NotificationOptions) => manager.success(title, opts),\n error: (title: string, opts?: NotificationOptions) => manager.error(title, opts),\n warning: (title: string, opts?: NotificationOptions) => manager.warning(title, opts),\n info: (title: string, opts?: NotificationOptions) => manager.info(title, opts),\n show: (type: string, title: string, opts?: NotificationOptions) =>\n manager.show(type as any, title, opts),\n remove: (id: number) => manager.remove(id),\n clear: () => manager.clear(),\n setDefaults: (opts: NotificationOptions) => manager.setDefaults(opts),\n getNotifications: () => manager.getNotifications(),\n getOptions: () => manager.getOptions(),\n };\n}\n\n// Vue plugin\nexport function createVueNotificationPlugin(manager: NotificationManager = notificationManager) {\n return {\n install(app: any) {\n app.config.globalProperties.$notificationManager = manager;\n app.provide('notificationManager', manager);\n },\n };\n}\n","<script setup lang=\"ts\">\nimport { computed, ref } from 'vue';\nimport { notificationStore } from './index';\nimport { notificationManager } from '../../core/notification-manager';\nimport type { NotificationItem, NotificationPosition } from '../../types';\n\nconst isClient = ref(false);\n\nif (typeof window !== 'undefined') {\n isClient.value = true;\n}\n\nconst groups = computed<Record<NotificationPosition, NotificationItem[]>>(() => {\n const map: Record<NotificationPosition, NotificationItem[]> = {\n 'top-left': [],\n 'top-center': [],\n 'top-right': [],\n 'bottom-left': [],\n 'bottom-center': [],\n 'bottom-right': [],\n };\n for (const notification of notificationStore.notifications) {\n map[notification.options.position].push(notification);\n }\n return map;\n});\n\nfunction removeNotification(id: number) {\n notificationManager.remove(id);\n}\n</script>\n\n<template>\n <Teleport v-if=\"isClient\" to=\"body\">\n <TransitionGroup\n v-for=\"(items, pos) in groups\"\n :key=\"pos\"\n tag=\"div\"\n name=\"notification\"\n class=\"notification-list\"\n :data-position=\"pos\"\n >\n <article\n v-for=\"notification in items\"\n :key=\"notification.id\"\n class=\"notification\"\n :class=\"[\n `notification-${notification.type}`,\n {\n 'notification-auto-close':\n notification.options.progress && notification.options.autoClose !== false,\n },\n ]\"\n :data-position=\"pos\"\n >\n <div class=\"notification-content\">\n <span class=\"notification-title\">{{ notification.title }}</span>\n </div>\n\n <div\n v-if=\"notification.options.progress && notification.options.autoClose !== false\"\n class=\"notification-progress\"\n :style=\"{ animationDuration: (notification.options.autoClose || 0) + 'ms' }\"\n ></div>\n\n <div class=\"notification-close\">\n <button\n type=\"button\"\n @click=\"removeNotification(notification.id)\"\n aria-label=\"Dismiss notification\"\n >\n ×\n </button>\n </div>\n </article>\n </TransitionGroup>\n </Teleport>\n</template>\n","import { useNotificationManager } from '../adapters/vue';\n\n/**\n * Vue composable for notification management.\n * Provides a clean API to show notifications in Vue components.\n *\n * @returns Notification manager API\n */\nexport function useNotification() {\n return useNotificationManager();\n}\n","import { notificationManager } from '../../core/notification-manager';\n\n/**\n * Nuxt plugin for notification management.\n * Integrates the notification manager into Nuxt applications.\n */\nexport default defineNuxtPlugin((nuxtApp) => {\n nuxtApp.vueApp.use(createVueNotificationPlugin(notificationManager));\n});\n\n/**\n * Create Vue plugin for Nuxt (internal use).\n */\nfunction createVueNotificationPlugin(manager: any) {\n return {\n install(app: any) {\n app.config.globalProperties.$notificationManager = manager;\n app.provide('notificationManager', manager);\n },\n };\n}\n\n// Re-export Vue adapter functions for convenience\nexport { useNotificationManager, createReactiveNotificationStore, notificationStore } from '../vue';\n"],"names":["reactive","createVueNotificationPlugin","ref","computed","_createBlock","_Teleport","_openBlock","_createElementBlock","_Fragment","_renderList","_TransitionGroup","_createElementVNode","_toDisplayString","_normalizeStyle"],"mappings":";;;;AAEA,QAAM,kBAAiD;AAAA,IACrD,UAAU;AAAA,IACV,WAAW;AAAA,IACX,UAAU;AAAA,EACZ;AAAA,EAEO,MAAM,oBAAoB;AAAA,IAA1B,cAAA;AACL,WAAQ,gBAAoC,CAAA;AAC5C,WAAQ,UAAyC,EAAE,GAAG,gBAAA;AACtD,WAAQ,YAA6C,CAAA;AACrD,WAAQ,YAAY;AAAA,IAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAOpB,GAAG,OAAe,UAA0B;AAC1C,UAAI,CAAC,KAAK,UAAU,KAAK,GAAG;AAC1B,aAAK,UAAU,KAAK,IAAI,CAAA;AAAA,MAC1B;AACA,WAAK,UAAU,KAAK,EAAE,KAAK,QAAQ;AAAA,IACrC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAOA,IAAI,OAAe,UAA0B;AAC3C,UAAI,KAAK,UAAU,KAAK,GAAG;AACzB,aAAK,UAAU,KAAK,IAAI,KAAK,UAAU,KAAK,EAAE,OAAO,CAAC,OAAO,OAAO,QAAQ;AAAA,MAC9E;AAAA,IACF;AAAA,IAEQ,KAAK,OAAe,MAAkB;AAC5C,UAAI,KAAK,UAAU,KAAK,GAAG;AACzB,aAAK,UAAU,KAAK,EAAE,QAAQ,CAAC,aAAa,SAAS,IAAI,CAAC;AAAA,MAC5D;AAAA,IACF;AAAA;AAAA;AAAA;AAAA;AAAA,IAMA,YAAY,MAAiC;AAC3C,WAAK,UAAU,EAAE,GAAG,KAAK,SAAS,GAAG,KAAA;AACrC,WAAK,KAAK,mBAAmB,KAAK,OAAO;AAA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;;;;;;"}
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../src/core/notification-manager.ts","../src/adapters/vue/index.ts","../src/adapters/vue/NotificationContainer.vue","../src/composables/useNotification.ts","../src/adapters/nuxt/index.ts"],"sourcesContent":["import type { NotificationType, NotificationOptions, NotificationItem } from '../types';\n\nconst DEFAULT_OPTIONS: Required<NotificationOptions> = {\n position: 'top-center',\n autoClose: 3000,\n progress: true,\n};\n\nexport class NotificationManager {\n private notifications: NotificationItem[] = [];\n private options: Required<NotificationOptions> = { ...DEFAULT_OPTIONS };\n private listeners: { [event: string]: Function[] } = {};\n private idCounter = 1;\n\n /**\n * Subscribe to an event.\n * @param event - The event name ('notification-added', 'notification-removed', 'notifications-cleared', 'options-changed')\n * @param callback - The callback function\n */\n on(event: string, callback: Function): void {\n if (!this.listeners[event]) {\n this.listeners[event] = [];\n }\n this.listeners[event].push(callback);\n }\n\n /**\n * Unsubscribe from an event.\n * @param event - The event name\n * @param callback - The callback function to remove\n */\n off(event: string, callback: Function): void {\n if (this.listeners[event]) {\n this.listeners[event] = this.listeners[event].filter((cb) => cb !== callback);\n }\n }\n\n private emit(event: string, data?: any): void {\n if (this.listeners[event]) {\n this.listeners[event].forEach((callback) => callback(data));\n }\n }\n\n /**\n * Set default options for notifications.\n * @param opts - The options to set as defaults\n */\n setDefaults(opts: NotificationOptions): void {\n this.options = { ...this.options, ...opts };\n this.emit('options-changed', this.options);\n }\n\n /**\n * Show a notification.\n * @param type - The type of notification\n * @param title - The title/message of the notification\n * @param opts - Optional override options\n */\n show(type: NotificationType, title: string, opts?: NotificationOptions): void {\n const options = { ...this.options, ...(opts || {}) };\n const item: NotificationItem = {\n id: this.idCounter++,\n type,\n title,\n options,\n createdAt: Date.now(),\n };\n this.notifications.push(item);\n this.emit('notification-added', item);\n\n if (options.autoClose !== false && typeof window !== 'undefined') {\n setTimeout(() => this.remove(item.id), options.autoClose);\n }\n }\n\n /**\n * Remove a notification by ID.\n * @param id - The ID of the notification to remove\n */\n remove(id: number): void {\n const index = this.notifications.findIndex((n) => n.id === id);\n if (index !== -1) {\n const removed = this.notifications.splice(index, 1)[0];\n this.emit('notification-removed', removed);\n }\n }\n\n /**\n * Clear all notifications.\n */\n clear(): void {\n const removed = [...this.notifications];\n this.notifications.splice(0);\n this.emit('notifications-cleared', removed);\n }\n\n /**\n * Get a copy of the current notifications.\n * @returns Array of notification items\n */\n getNotifications(): NotificationItem[] {\n return [...this.notifications];\n }\n\n /**\n * Get the current default options.\n * @returns The default options\n */\n getOptions(): Required<NotificationOptions> {\n return { ...this.options };\n }\n\n /**\n * Success notification shorthand.\n * @param title - The title/message\n * @param opts - Optional options\n */\n success(title: string, opts?: NotificationOptions): void {\n this.show('success', title, opts);\n }\n\n /**\n * Error notification shorthand.\n * @param title - The title/message\n * @param opts - Optional options\n */\n error(title: string, opts?: NotificationOptions): void {\n this.show('error', title, opts);\n }\n\n /**\n * Warning notification shorthand.\n * @param title - The title/message\n * @param opts - Optional options\n */\n warning(title: string, opts?: NotificationOptions): void {\n this.show('warning', title, opts);\n }\n\n /**\n * Info notification shorthand.\n * @param title - The title/message\n * @param opts - Optional options\n */\n info(title: string, opts?: NotificationOptions): void {\n this.show('info', title, opts);\n }\n}\n\n// Default instance for convenience\nexport const notificationManager = new NotificationManager();\n","import { reactive, watchEffect } from 'vue';\nimport { NotificationManager, notificationManager } from '../../core/notification-manager';\nimport type { NotificationItem, NotificationOptions } from '../../types';\n\nexport interface ReactiveNotificationStore {\n notifications: NotificationItem[];\n options: NotificationOptions;\n}\n\n/**\n * Create a reactive store for Vue that syncs with the NotificationManager.\n * @param manager - The NotificationManager instance (optional, uses default if not provided)\n * @returns Reactive store\n */\nexport function createReactiveNotificationStore(\n manager: NotificationManager = notificationManager\n): ReactiveNotificationStore {\n const store = reactive({\n notifications: manager.getNotifications(),\n options: manager.getOptions(),\n });\n\n // Sync notifications\n manager.on('notification-added', () => {\n store.notifications = manager.getNotifications();\n });\n manager.on('notification-removed', () => {\n store.notifications = manager.getNotifications();\n });\n manager.on('notifications-cleared', () => {\n store.notifications = manager.getNotifications();\n });\n\n // Sync options\n manager.on('options-changed', () => {\n store.options = manager.getOptions();\n });\n\n return store;\n}\n\n// Default reactive store\nexport const notificationStore = createReactiveNotificationStore();\n\n// Vue composable\nexport function useNotificationManager(manager: NotificationManager = notificationManager) {\n return {\n success: (title: string, opts?: NotificationOptions) => manager.success(title, opts),\n error: (title: string, opts?: NotificationOptions) => manager.error(title, opts),\n warning: (title: string, opts?: NotificationOptions) => manager.warning(title, opts),\n info: (title: string, opts?: NotificationOptions) => manager.info(title, opts),\n show: (type: string, title: string, opts?: NotificationOptions) =>\n manager.show(type as any, title, opts),\n remove: (id: number) => manager.remove(id),\n clear: () => manager.clear(),\n setDefaults: (opts: NotificationOptions) => manager.setDefaults(opts),\n getNotifications: () => manager.getNotifications(),\n getOptions: () => manager.getOptions(),\n };\n}\n\n// Vue plugin\nexport function createVueNotificationPlugin(manager: NotificationManager = notificationManager) {\n return {\n install(app: any) {\n app.config.globalProperties.$notificationManager = manager;\n app.provide('notificationManager', manager);\n },\n };\n}\n","<script setup lang=\"ts\">\nimport { computed, ref } from 'vue';\nimport { notificationStore } from './index';\nimport { notificationManager } from '../../core/notification-manager';\nimport type { NotificationItem, NotificationPosition } from '../../types';\n\nconst isClient = ref(false);\n\nif (typeof window !== 'undefined') {\n isClient.value = true;\n}\n\nconst groups = computed<Record<NotificationPosition, NotificationItem[]>>(() => {\n const map: Record<NotificationPosition, NotificationItem[]> = {\n 'top-left': [],\n 'top-center': [],\n 'top-right': [],\n 'bottom-left': [],\n 'bottom-center': [],\n 'bottom-right': [],\n };\n for (const notification of notificationStore.notifications) {\n map[notification.options.position].push(notification);\n }\n return map;\n});\n\nfunction removeNotification(id: number) {\n notificationManager.remove(id);\n}\n</script>\n\n<template>\n <Teleport v-if=\"isClient\" to=\"body\">\n <TransitionGroup\n v-for=\"(items, pos) in groups\"\n :key=\"pos\"\n tag=\"div\"\n name=\"notification\"\n class=\"notification-list\"\n :data-position=\"pos\"\n >\n <article\n v-for=\"notification in items\"\n :key=\"notification.id\"\n class=\"notification\"\n :class=\"[\n `notification-${notification.type}`,\n {\n 'notification-auto-close':\n notification.options.progress && notification.options.autoClose !== false,\n },\n ]\"\n :data-position=\"pos\"\n >\n <div class=\"notification-content\">\n <span class=\"notification-title\">{{ notification.title }}</span>\n </div>\n\n <div\n v-if=\"notification.options.progress && notification.options.autoClose !== false\"\n class=\"notification-progress\"\n :style=\"{ animationDuration: (notification.options.autoClose || 0) + 'ms' }\"\n ></div>\n\n <div class=\"notification-close\">\n <button\n type=\"button\"\n @click=\"removeNotification(notification.id)\"\n aria-label=\"Dismiss notification\"\n >\n ×\n </button>\n </div>\n </article>\n </TransitionGroup>\n </Teleport>\n</template>\n","import { useNotificationManager } from '../adapters/vue';\n\n/**\n * Vue composable for notification management.\n * Provides a clean API to show notifications in Vue components.\n *\n * @returns Notification manager API\n */\nexport function useNotification() {\n return useNotificationManager();\n}\n","import { defineNuxtPlugin } from 'nuxt/app';\nimport type { NuxtApp } from 'nuxt/app';\nimport { notificationManager } from '../../core/notification-manager';\n\n/**\n * Nuxt plugin for notification management.\n * Integrates the notification manager into Nuxt applications.\n */\nexport default defineNuxtPlugin((nuxtApp: NuxtApp) => {\n nuxtApp.vueApp.use(createVueNotificationPlugin(notificationManager));\n});\n\n/**\n * Create Vue plugin for Nuxt (internal use).\n */\nfunction createVueNotificationPlugin(manager: any) {\n return {\n install(app: any) {\n app.config.globalProperties.$notificationManager = manager;\n app.provide('notificationManager', manager);\n },\n };\n}\n\n// Re-export Vue adapter functions for convenience\nexport { useNotificationManager, createReactiveNotificationStore, notificationStore } from '../vue';\n"],"names":["reactive","createVueNotificationPlugin","app","ref","computed","_createBlock","_Teleport","_openBlock","_createElementBlock","_Fragment","_renderList","_TransitionGroup","_createElementVNode","_toDisplayString","_normalizeStyle","defineNuxtPlugin"],"mappings":";;;;AAEA,QAAM,kBAAiD;AAAA,IACrD,UA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mDAAqE,aAAa,QAAQ,YAAY,aAAa,QAAQ,cAAS;AAAA,sBAAA;AAAA;oBAOxL,iBAAe;AAAA,kBAAA;oBAEhBI,IAAAA,mBAEM,OAFN,YAEM;AAAA,sBADJA,IAAAA,mBAAgE,QAAhE,YAAgEC,IAAAA,gBAA5B,aAAa,KAAK,GAAA,CAAA;AAAA,oBAAA;oBAIhD,aAAa,QAAQ,YAAY,aAAa,QAAQ,cAAS,0BADvEL,IAAAA,mBAIO,OAAA;AAAA;sBAFL,OAAM;AAAA,sBACL,OAAKM,IAAAA,eAAA,EAAA,oBAAwB,aAAa,QAAQ,aAAS,KAAA,KAAA,CAAA;AAAA,oBAAA;oBAG9DF,IAAAA,mBAQM,OARN,YAQM;AAAA,sBAPJA,IAAAA,mBAMS,UAAA;AAAA,wBALP,MAAK;AAAA,wBACJ,SAAK,CAAA,WAAE,mBAAmB,aAAa,EAAE;AAAA,wBAC1C,cAAW;AAAA,sBAAA,GACZ,OAED,GAAA,UAAA;AAAA,oBAAA;;;;;;;;;;;AChEH,WAAS,kBAAkB;AAChC,WAAO,uBAAA;AAAA,EACT;ACFeG,MAAAA,iBAAiB,CAAC,YAAqB;AACpD,YAAQ,OAAO,IAAI,4BAA4B,mBAAmB,CAAC;AAAA,EACrE,CAAC;AAKD,WAAS,4BAA4B,SAAc;AACjD,WAAO;AAAA,MACL,QAAQb,MAAU;AAChB,QAAAA,KAAI,OAAO,iBAAiB,uBAAuB;AACnD,QAAAA,KAAI,QAAQ,uBAAuB,OAAO;AAAA,MAC5C;AAAA,IAAA;AAAA,EAEJ;;;;;;;;;;;"}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { reactive, defineComponent, ref, computed, openBlock, createBlock, Teleport, createElementBlock, Fragment, renderList, TransitionGroup, withCtx, normalizeClass, createElementVNode, toDisplayString, normalizeStyle, createCommentVNode } from "vue";
|
|
2
|
+
import { defineNuxtPlugin } from "nuxt/app";
|
|
2
3
|
const DEFAULT_OPTIONS = {
|
|
3
4
|
position: "top-center",
|
|
4
5
|
autoClose: 3e3,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/core/notification-manager.ts","../src/adapters/vue/index.ts","../src/adapters/vue/NotificationContainer.vue","../src/composables/useNotification.ts","../src/adapters/nuxt/index.ts"],"sourcesContent":["import type { NotificationType, NotificationOptions, NotificationItem } from '../types';\n\nconst DEFAULT_OPTIONS: Required<NotificationOptions> = {\n position: 'top-center',\n autoClose: 3000,\n progress: true,\n};\n\nexport class NotificationManager {\n private notifications: NotificationItem[] = [];\n private options: Required<NotificationOptions> = { ...DEFAULT_OPTIONS };\n private listeners: { [event: string]: Function[] } = {};\n private idCounter = 1;\n\n /**\n * Subscribe to an event.\n * @param event - The event name ('notification-added', 'notification-removed', 'notifications-cleared', 'options-changed')\n * @param callback - The callback function\n */\n on(event: string, callback: Function): void {\n if (!this.listeners[event]) {\n this.listeners[event] = [];\n }\n this.listeners[event].push(callback);\n }\n\n /**\n * Unsubscribe from an event.\n * @param event - The event name\n * @param callback - The callback function to remove\n */\n off(event: string, callback: Function): void {\n if (this.listeners[event]) {\n this.listeners[event] = this.listeners[event].filter((cb) => cb !== callback);\n }\n }\n\n private emit(event: string, data?: any): void {\n if (this.listeners[event]) {\n this.listeners[event].forEach((callback) => callback(data));\n }\n }\n\n /**\n * Set default options for notifications.\n * @param opts - The options to set as defaults\n */\n setDefaults(opts: NotificationOptions): void {\n this.options = { ...this.options, ...opts };\n this.emit('options-changed', this.options);\n }\n\n /**\n * Show a notification.\n * @param type - The type of notification\n * @param title - The title/message of the notification\n * @param opts - Optional override options\n */\n show(type: NotificationType, title: string, opts?: NotificationOptions): void {\n const options = { ...this.options, ...(opts || {}) };\n const item: NotificationItem = {\n id: this.idCounter++,\n type,\n title,\n options,\n createdAt: Date.now(),\n };\n this.notifications.push(item);\n this.emit('notification-added', item);\n\n if (options.autoClose !== false && typeof window !== 'undefined') {\n setTimeout(() => this.remove(item.id), options.autoClose);\n }\n }\n\n /**\n * Remove a notification by ID.\n * @param id - The ID of the notification to remove\n */\n remove(id: number): void {\n const index = this.notifications.findIndex((n) => n.id === id);\n if (index !== -1) {\n const removed = this.notifications.splice(index, 1)[0];\n this.emit('notification-removed', removed);\n }\n }\n\n /**\n * Clear all notifications.\n */\n clear(): void {\n const removed = [...this.notifications];\n this.notifications.splice(0);\n this.emit('notifications-cleared', removed);\n }\n\n /**\n * Get a copy of the current notifications.\n * @returns Array of notification items\n */\n getNotifications(): NotificationItem[] {\n return [...this.notifications];\n }\n\n /**\n * Get the current default options.\n * @returns The default options\n */\n getOptions(): Required<NotificationOptions> {\n return { ...this.options };\n }\n\n /**\n * Success notification shorthand.\n * @param title - The title/message\n * @param opts - Optional options\n */\n success(title: string, opts?: NotificationOptions): void {\n this.show('success', title, opts);\n }\n\n /**\n * Error notification shorthand.\n * @param title - The title/message\n * @param opts - Optional options\n */\n error(title: string, opts?: NotificationOptions): void {\n this.show('error', title, opts);\n }\n\n /**\n * Warning notification shorthand.\n * @param title - The title/message\n * @param opts - Optional options\n */\n warning(title: string, opts?: NotificationOptions): void {\n this.show('warning', title, opts);\n }\n\n /**\n * Info notification shorthand.\n * @param title - The title/message\n * @param opts - Optional options\n */\n info(title: string, opts?: NotificationOptions): void {\n this.show('info', title, opts);\n }\n}\n\n// Default instance for convenience\nexport const notificationManager = new NotificationManager();\n","import { reactive, watchEffect } from 'vue';\nimport { NotificationManager, notificationManager } from '../../core/notification-manager';\nimport type { NotificationItem, NotificationOptions } from '../../types';\n\nexport interface ReactiveNotificationStore {\n notifications: NotificationItem[];\n options: NotificationOptions;\n}\n\n/**\n * Create a reactive store for Vue that syncs with the NotificationManager.\n * @param manager - The NotificationManager instance (optional, uses default if not provided)\n * @returns Reactive store\n */\nexport function createReactiveNotificationStore(\n manager: NotificationManager = notificationManager\n): ReactiveNotificationStore {\n const store = reactive({\n notifications: manager.getNotifications(),\n options: manager.getOptions(),\n });\n\n // Sync notifications\n manager.on('notification-added', () => {\n store.notifications = manager.getNotifications();\n });\n manager.on('notification-removed', () => {\n store.notifications = manager.getNotifications();\n });\n manager.on('notifications-cleared', () => {\n store.notifications = manager.getNotifications();\n });\n\n // Sync options\n manager.on('options-changed', () => {\n store.options = manager.getOptions();\n });\n\n return store;\n}\n\n// Default reactive store\nexport const notificationStore = createReactiveNotificationStore();\n\n// Vue composable\nexport function useNotificationManager(manager: NotificationManager = notificationManager) {\n return {\n success: (title: string, opts?: NotificationOptions) => manager.success(title, opts),\n error: (title: string, opts?: NotificationOptions) => manager.error(title, opts),\n warning: (title: string, opts?: NotificationOptions) => manager.warning(title, opts),\n info: (title: string, opts?: NotificationOptions) => manager.info(title, opts),\n show: (type: string, title: string, opts?: NotificationOptions) =>\n manager.show(type as any, title, opts),\n remove: (id: number) => manager.remove(id),\n clear: () => manager.clear(),\n setDefaults: (opts: NotificationOptions) => manager.setDefaults(opts),\n getNotifications: () => manager.getNotifications(),\n getOptions: () => manager.getOptions(),\n };\n}\n\n// Vue plugin\nexport function createVueNotificationPlugin(manager: NotificationManager = notificationManager) {\n return {\n install(app: any) {\n app.config.globalProperties.$notificationManager = manager;\n app.provide('notificationManager', manager);\n },\n };\n}\n","<script setup lang=\"ts\">\nimport { computed, ref } from 'vue';\nimport { notificationStore } from './index';\nimport { notificationManager } from '../../core/notification-manager';\nimport type { NotificationItem, NotificationPosition } from '../../types';\n\nconst isClient = ref(false);\n\nif (typeof window !== 'undefined') {\n isClient.value = true;\n}\n\nconst groups = computed<Record<NotificationPosition, NotificationItem[]>>(() => {\n const map: Record<NotificationPosition, NotificationItem[]> = {\n 'top-left': [],\n 'top-center': [],\n 'top-right': [],\n 'bottom-left': [],\n 'bottom-center': [],\n 'bottom-right': [],\n };\n for (const notification of notificationStore.notifications) {\n map[notification.options.position].push(notification);\n }\n return map;\n});\n\nfunction removeNotification(id: number) {\n notificationManager.remove(id);\n}\n</script>\n\n<template>\n <Teleport v-if=\"isClient\" to=\"body\">\n <TransitionGroup\n v-for=\"(items, pos) in groups\"\n :key=\"pos\"\n tag=\"div\"\n name=\"notification\"\n class=\"notification-list\"\n :data-position=\"pos\"\n >\n <article\n v-for=\"notification in items\"\n :key=\"notification.id\"\n class=\"notification\"\n :class=\"[\n `notification-${notification.type}`,\n {\n 'notification-auto-close':\n notification.options.progress && notification.options.autoClose !== false,\n },\n ]\"\n :data-position=\"pos\"\n >\n <div class=\"notification-content\">\n <span class=\"notification-title\">{{ notification.title }}</span>\n </div>\n\n <div\n v-if=\"notification.options.progress && notification.options.autoClose !== false\"\n class=\"notification-progress\"\n :style=\"{ animationDuration: (notification.options.autoClose || 0) + 'ms' }\"\n ></div>\n\n <div class=\"notification-close\">\n <button\n type=\"button\"\n @click=\"removeNotification(notification.id)\"\n aria-label=\"Dismiss notification\"\n >\n ×\n </button>\n </div>\n </article>\n </TransitionGroup>\n </Teleport>\n</template>\n","import { useNotificationManager } from '../adapters/vue';\n\n/**\n * Vue composable for notification management.\n * Provides a clean API to show notifications in Vue components.\n *\n * @returns Notification manager API\n */\nexport function useNotification() {\n return useNotificationManager();\n}\n","import { notificationManager } from '../../core/notification-manager';\n\n/**\n * Nuxt plugin for notification management.\n * Integrates the notification manager into Nuxt applications.\n */\nexport default defineNuxtPlugin((nuxtApp) => {\n nuxtApp.vueApp.use(createVueNotificationPlugin(notificationManager));\n});\n\n/**\n * Create Vue plugin for Nuxt (internal use).\n */\nfunction createVueNotificationPlugin(manager: any) {\n return {\n install(app: any) {\n app.config.globalProperties.$notificationManager = manager;\n app.provide('notificationManager', manager);\n },\n };\n}\n\n// Re-export Vue adapter functions for convenience\nexport { useNotificationManager, createReactiveNotificationStore, notificationStore } from '../vue';\n"],"names":["createVueNotificationPlugin","_createBlock","_Teleport","_openBlock","_createElementBlock","_Fragment","_renderList","_TransitionGroup","_createElementVNode","_toDisplayString","_normalizeStyle"],"mappings":";AAEA,MAAM,kBAAiD;AAAA,EACrD,UAAU;A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,QAAhE,YAAgEC,gBAA5B,aAAa,KAAK,GAAA,CAAA;AAAA,kBAAA;kBAIhD,aAAa,QAAQ,YAAY,aAAa,QAAQ,cAAS,sBADvEL,mBAIO,OAAA;AAAA;oBAFL,OAAM;AAAA,oBACL,OAAKM,eAAA,EAAA,oBAAwB,aAAa,QAAQ,aAAS,KAAA,KAAA,CAAA;AAAA,kBAAA;kBAG9DF,mBAQM,OARN,YAQM;AAAA,oBAPJA,mBAMS,UAAA;AAAA,sBALP,MAAK;AAAA,sBACJ,SAAK,CAAA,WAAE,mBAAmB,aAAa,EAAE;AAAA,sBAC1C,cAAW;AAAA,oBAAA,GACZ,OAED,GAAA,UAAA;AAAA,kBAAA;;;;;;;;;;;AChEH,SAAS,kBAAkB;AAChC,SAAO,uBAAA;AACT;ACJe,iBAAiB,CAAC,YAAY;AAC3C,UAAQ,OAAO,IAAI,4BAA4B,mBAAmB,CAAC;AACrE,CAAC;AAKD,SAAS,4BAA4B,SAAc;AACjD,SAAO;AAAA,IACL,QAAQ,KAAU;AAChB,UAAI,OAAO,iBAAiB,uBAAuB;AACnD,UAAI,QAAQ,uBAAuB,OAAO;AAAA,IAC5C;AAAA,EAAA;AAEJ;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/core/notification-manager.ts","../src/adapters/vue/index.ts","../src/adapters/vue/NotificationContainer.vue","../src/composables/useNotification.ts","../src/adapters/nuxt/index.ts"],"sourcesContent":["import type { NotificationType, NotificationOptions, NotificationItem } from '../types';\n\nconst DEFAULT_OPTIONS: Required<NotificationOptions> = {\n position: 'top-center',\n autoClose: 3000,\n progress: true,\n};\n\nexport class NotificationManager {\n private notifications: NotificationItem[] = [];\n private options: Required<NotificationOptions> = { ...DEFAULT_OPTIONS };\n private listeners: { [event: string]: Function[] } = {};\n private idCounter = 1;\n\n /**\n * Subscribe to an event.\n * @param event - The event name ('notification-added', 'notification-removed', 'notifications-cleared', 'options-changed')\n * @param callback - The callback function\n */\n on(event: string, callback: Function): void {\n if (!this.listeners[event]) {\n this.listeners[event] = [];\n }\n this.listeners[event].push(callback);\n }\n\n /**\n * Unsubscribe from an event.\n * @param event - The event name\n * @param callback - The callback function to remove\n */\n off(event: string, callback: Function): void {\n if (this.listeners[event]) {\n this.listeners[event] = this.listeners[event].filter((cb) => cb !== callback);\n }\n }\n\n private emit(event: string, data?: any): void {\n if (this.listeners[event]) {\n this.listeners[event].forEach((callback) => callback(data));\n }\n }\n\n /**\n * Set default options for notifications.\n * @param opts - The options to set as defaults\n */\n setDefaults(opts: NotificationOptions): void {\n this.options = { ...this.options, ...opts };\n this.emit('options-changed', this.options);\n }\n\n /**\n * Show a notification.\n * @param type - The type of notification\n * @param title - The title/message of the notification\n * @param opts - Optional override options\n */\n show(type: NotificationType, title: string, opts?: NotificationOptions): void {\n const options = { ...this.options, ...(opts || {}) };\n const item: NotificationItem = {\n id: this.idCounter++,\n type,\n title,\n options,\n createdAt: Date.now(),\n };\n this.notifications.push(item);\n this.emit('notification-added', item);\n\n if (options.autoClose !== false && typeof window !== 'undefined') {\n setTimeout(() => this.remove(item.id), options.autoClose);\n }\n }\n\n /**\n * Remove a notification by ID.\n * @param id - The ID of the notification to remove\n */\n remove(id: number): void {\n const index = this.notifications.findIndex((n) => n.id === id);\n if (index !== -1) {\n const removed = this.notifications.splice(index, 1)[0];\n this.emit('notification-removed', removed);\n }\n }\n\n /**\n * Clear all notifications.\n */\n clear(): void {\n const removed = [...this.notifications];\n this.notifications.splice(0);\n this.emit('notifications-cleared', removed);\n }\n\n /**\n * Get a copy of the current notifications.\n * @returns Array of notification items\n */\n getNotifications(): NotificationItem[] {\n return [...this.notifications];\n }\n\n /**\n * Get the current default options.\n * @returns The default options\n */\n getOptions(): Required<NotificationOptions> {\n return { ...this.options };\n }\n\n /**\n * Success notification shorthand.\n * @param title - The title/message\n * @param opts - Optional options\n */\n success(title: string, opts?: NotificationOptions): void {\n this.show('success', title, opts);\n }\n\n /**\n * Error notification shorthand.\n * @param title - The title/message\n * @param opts - Optional options\n */\n error(title: string, opts?: NotificationOptions): void {\n this.show('error', title, opts);\n }\n\n /**\n * Warning notification shorthand.\n * @param title - The title/message\n * @param opts - Optional options\n */\n warning(title: string, opts?: NotificationOptions): void {\n this.show('warning', title, opts);\n }\n\n /**\n * Info notification shorthand.\n * @param title - The title/message\n * @param opts - Optional options\n */\n info(title: string, opts?: NotificationOptions): void {\n this.show('info', title, opts);\n }\n}\n\n// Default instance for convenience\nexport const notificationManager = new NotificationManager();\n","import { reactive, watchEffect } from 'vue';\nimport { NotificationManager, notificationManager } from '../../core/notification-manager';\nimport type { NotificationItem, NotificationOptions } from '../../types';\n\nexport interface ReactiveNotificationStore {\n notifications: NotificationItem[];\n options: NotificationOptions;\n}\n\n/**\n * Create a reactive store for Vue that syncs with the NotificationManager.\n * @param manager - The NotificationManager instance (optional, uses default if not provided)\n * @returns Reactive store\n */\nexport function createReactiveNotificationStore(\n manager: NotificationManager = notificationManager\n): ReactiveNotificationStore {\n const store = reactive({\n notifications: manager.getNotifications(),\n options: manager.getOptions(),\n });\n\n // Sync notifications\n manager.on('notification-added', () => {\n store.notifications = manager.getNotifications();\n });\n manager.on('notification-removed', () => {\n store.notifications = manager.getNotifications();\n });\n manager.on('notifications-cleared', () => {\n store.notifications = manager.getNotifications();\n });\n\n // Sync options\n manager.on('options-changed', () => {\n store.options = manager.getOptions();\n });\n\n return store;\n}\n\n// Default reactive store\nexport const notificationStore = createReactiveNotificationStore();\n\n// Vue composable\nexport function useNotificationManager(manager: NotificationManager = notificationManager) {\n return {\n success: (title: string, opts?: NotificationOptions) => manager.success(title, opts),\n error: (title: string, opts?: NotificationOptions) => manager.error(title, opts),\n warning: (title: string, opts?: NotificationOptions) => manager.warning(title, opts),\n info: (title: string, opts?: NotificationOptions) => manager.info(title, opts),\n show: (type: string, title: string, opts?: NotificationOptions) =>\n manager.show(type as any, title, opts),\n remove: (id: number) => manager.remove(id),\n clear: () => manager.clear(),\n setDefaults: (opts: NotificationOptions) => manager.setDefaults(opts),\n getNotifications: () => manager.getNotifications(),\n getOptions: () => manager.getOptions(),\n };\n}\n\n// Vue plugin\nexport function createVueNotificationPlugin(manager: NotificationManager = notificationManager) {\n return {\n install(app: any) {\n app.config.globalProperties.$notificationManager = manager;\n app.provide('notificationManager', manager);\n },\n };\n}\n","<script setup lang=\"ts\">\nimport { computed, ref } from 'vue';\nimport { notificationStore } from './index';\nimport { notificationManager } from '../../core/notification-manager';\nimport type { NotificationItem, NotificationPosition } from '../../types';\n\nconst isClient = ref(false);\n\nif (typeof window !== 'undefined') {\n isClient.value = true;\n}\n\nconst groups = computed<Record<NotificationPosition, NotificationItem[]>>(() => {\n const map: Record<NotificationPosition, NotificationItem[]> = {\n 'top-left': [],\n 'top-center': [],\n 'top-right': [],\n 'bottom-left': [],\n 'bottom-center': [],\n 'bottom-right': [],\n };\n for (const notification of notificationStore.notifications) {\n map[notification.options.position].push(notification);\n }\n return map;\n});\n\nfunction removeNotification(id: number) {\n notificationManager.remove(id);\n}\n</script>\n\n<template>\n <Teleport v-if=\"isClient\" to=\"body\">\n <TransitionGroup\n v-for=\"(items, pos) in groups\"\n :key=\"pos\"\n tag=\"div\"\n name=\"notification\"\n class=\"notification-list\"\n :data-position=\"pos\"\n >\n <article\n v-for=\"notification in items\"\n :key=\"notification.id\"\n class=\"notification\"\n :class=\"[\n `notification-${notification.type}`,\n {\n 'notification-auto-close':\n notification.options.progress && notification.options.autoClose !== false,\n },\n ]\"\n :data-position=\"pos\"\n >\n <div class=\"notification-content\">\n <span class=\"notification-title\">{{ notification.title }}</span>\n </div>\n\n <div\n v-if=\"notification.options.progress && notification.options.autoClose !== false\"\n class=\"notification-progress\"\n :style=\"{ animationDuration: (notification.options.autoClose || 0) + 'ms' }\"\n ></div>\n\n <div class=\"notification-close\">\n <button\n type=\"button\"\n @click=\"removeNotification(notification.id)\"\n aria-label=\"Dismiss notification\"\n >\n ×\n </button>\n </div>\n </article>\n </TransitionGroup>\n </Teleport>\n</template>\n","import { useNotificationManager } from '../adapters/vue';\n\n/**\n * Vue composable for notification management.\n * Provides a clean API to show notifications in Vue components.\n *\n * @returns Notification manager API\n */\nexport function useNotification() {\n return useNotificationManager();\n}\n","import { defineNuxtPlugin } from 'nuxt/app';\nimport type { NuxtApp } from 'nuxt/app';\nimport { notificationManager } from '../../core/notification-manager';\n\n/**\n * Nuxt plugin for notification management.\n * Integrates the notification manager into Nuxt applications.\n */\nexport default defineNuxtPlugin((nuxtApp: NuxtApp) => {\n nuxtApp.vueApp.use(createVueNotificationPlugin(notificationManager));\n});\n\n/**\n * Create Vue plugin for Nuxt (internal use).\n */\nfunction createVueNotificationPlugin(manager: any) {\n return {\n install(app: any) {\n app.config.globalProperties.$notificationManager = manager;\n app.provide('notificationManager', manager);\n },\n };\n}\n\n// Re-export Vue adapter functions for convenience\nexport { useNotificationManager, createReactiveNotificationStore, notificationStore } from '../vue';\n"],"names":["createVueNotificationPlugin","_createBlock","_Teleport","_openBlock","_createElementBlock","_Fragment","_renderList","_TransitionGroup","_createElementVNode","_toDisplayString","_normalizeStyle"],"mappings":";;AAEA,MAAM,kBAAiD;AAAA,EACrD,UAAU;AAAA,EACV,WAAW;AAAA,EACX,UAAU;AACZ;AAEO,MAAM,oBAAoB;AAAA,EAA1B,cAAA;AACL,SAAQ,gBAAoC,CAAA;AAC5C,SAAQ,UAAyC,EAAE,GAAG,gBAAA;AACtD,SAAQ,YAA6C,CAAA;AACrD,SAAQ,YAAY;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOpB,GAAG,OAAe,UAA0B;AAC1C,QAAI,CAAC,KAAK,UAAU,KAAK,GAAG;AAC1B,WAAK,UAAU,KAAK,IAAI,CAAA;AAAA,IAC1B;AACA,SAAK,UAAU,KAAK,EAAE,KAAK,QAAQ;AAAA,EACrC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,IAAI,OAAe,UAA0B;AAC3C,QAAI,KAAK,UAAU,KAAK,GAAG;AACzB,WAAK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D,UAAQ,OAAO,IAAI,4BAA4B,mBAAmB,CAAC;AACrE,CAAC;AAKD,SAAS,4BAA4B,SAAc;AACjD,SAAO;AAAA,IACL,QAAQ,KAAU;AAChB,UAAI,OAAO,iBAAiB,uBAAuB;AACnD,UAAI,QAAQ,uBAAuB,OAAO;AAAA,IAC5C;AAAA,EAAA;AAEJ;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vue-notifyr",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "Framework-agnostic notification library with Vue, Nuxt, and Inertia support",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -30,11 +30,15 @@
|
|
|
30
30
|
"type-check": "tsc --noEmit"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
|
-
"vue": "^3.3.0"
|
|
33
|
+
"vue": "^3.3.0",
|
|
34
|
+
"nuxt": "^3.0.0"
|
|
34
35
|
},
|
|
35
36
|
"peerDependenciesMeta": {
|
|
36
37
|
"vue": {
|
|
37
38
|
"optional": true
|
|
39
|
+
},
|
|
40
|
+
"nuxt": {
|
|
41
|
+
"optional": true
|
|
38
42
|
}
|
|
39
43
|
},
|
|
40
44
|
"license": "MIT",
|
|
@@ -62,6 +66,7 @@
|
|
|
62
66
|
"@typescript-eslint/parser": "^6.0.0",
|
|
63
67
|
"@vitejs/plugin-vue": "^5.0.0",
|
|
64
68
|
"eslint": "^8.0.0",
|
|
69
|
+
"nuxt": "^3.0.0",
|
|
65
70
|
"prettier": "^3.0.0",
|
|
66
71
|
"typescript": "^5.0.0",
|
|
67
72
|
"vite": "^5.0.0",
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
+
import { defineNuxtPlugin } from 'nuxt/app';
|
|
2
|
+
import type { NuxtApp } from 'nuxt/app';
|
|
1
3
|
import { notificationManager } from '../../core/notification-manager';
|
|
2
4
|
|
|
3
5
|
/**
|
|
4
6
|
* Nuxt plugin for notification management.
|
|
5
7
|
* Integrates the notification manager into Nuxt applications.
|
|
6
8
|
*/
|
|
7
|
-
export default defineNuxtPlugin((nuxtApp) => {
|
|
9
|
+
export default defineNuxtPlugin((nuxtApp: NuxtApp) => {
|
|
8
10
|
nuxtApp.vueApp.use(createVueNotificationPlugin(notificationManager));
|
|
9
11
|
});
|
|
10
12
|
|