1
1
( function ( ) { "use strict" ; var o ; try { if ( typeof document < "u" ) { var e = document . createElement ( "style" ) ; e . nonce = ( o = document . head . querySelector ( "meta[property=csp-nonce]" ) ) == null ?void 0 :o . content , e . appendChild ( document . createTextNode ( ".vue-notification-group{display:block;position:fixed;z-index:5000}.vue-notification-wrapper{display:block;overflow:hidden;width:100%;margin:0;padding:0}.notification-title{font-weight:600}.vue-notification-template{display:block;box-sizing:border-box;background:#fff;text-align:left}.vue-notification{display:block;box-sizing:border-box;text-align:left;font-size:12px;padding:10px;margin:0 5px 5px;color:#fff;background:#44a4fc;border-left:5px solid #187FE7}.vue-notification.warn{background:#ffb648;border-left-color:#f48a06}.vue-notification.error{background:#e54d42;border-left-color:#b82e24}.vue-notification.success{background:#68cd86;border-left-color:#42a85f}.vn-fade-enter-active,.vn-fade-leave-active,.vn-fade-move{transition:all .5s}.vn-fade-enter-from,.vn-fade-leave-to{opacity:0}" ) ) , document . head . appendChild ( e ) } } catch ( n ) { console . error ( "vite-plugin-css-injected-by-js" , n ) } } ) ( ) ;
2
- import { defineComponent as Z , ref as M , computed as y , onMounted as tt , createVNode as l , TransitionGroup as et , mergeProps as nt , Fragment as k , isVNode as it } from "vue" ;
3
- const j = /* @__PURE__ */ new Map ( ) ;
4
- class ot {
5
- constructor ( i , o , a ) {
6
- this . remaining = o , this . callback = i , this . notifyItem = a , this . resume ( ) ;
7
- }
8
- pause ( ) {
9
- clearTimeout ( this . notifyItem . timer ) , this . remaining -= Date . now ( ) - this . start ;
10
- }
11
- resume ( ) {
12
- this . start = Date . now ( ) , clearTimeout ( this . notifyItem . timer ) , this . notifyItem . timer = setTimeout ( this . callback , this . remaining ) ;
13
- }
14
- }
15
- function at ( t ) {
16
- return { all : t = t || /* @__PURE__ */ new Map ( ) , on : function ( i , o ) {
17
- var a = t . get ( i ) ;
18
- a ? a . push ( o ) : t . set ( i , [ o ] ) ;
19
- } , off : function ( i , o ) {
20
- var a = t . get ( i ) ;
21
- a && ( o ? a . splice ( a . indexOf ( o ) >>> 0 , 1 ) : t . set ( i , [ ] ) ) ;
22
- } , emit : function ( i , o ) {
23
- var a = t . get ( i ) ;
2
+ import { defineComponent as U , ref as X , computed as g , onMounted as Z , createVNode as l , TransitionGroup as tt , mergeProps as et , Fragment as $ , isVNode as nt } from "vue" ;
3
+ const R = /* @__PURE__ */ new Map ( ) ;
4
+ function ot ( t ) {
5
+ return { all : t = t || /* @__PURE__ */ new Map ( ) , on : function ( o , i ) {
6
+ var a = t . get ( o ) ;
7
+ a ? a . push ( i ) : t . set ( o , [ i ] ) ;
8
+ } , off : function ( o , i ) {
9
+ var a = t . get ( o ) ;
10
+ a && ( i ? a . splice ( a . indexOf ( i ) >>> 0 , 1 ) : t . set ( o , [ ] ) ) ;
11
+ } , emit : function ( o , i ) {
12
+ var a = t . get ( o ) ;
24
13
a && a . slice ( ) . map ( function ( r ) {
25
- r ( o ) ;
14
+ r ( i ) ;
26
15
} ) , ( a = t . get ( "*" ) ) && a . slice ( ) . map ( function ( r ) {
27
- r ( i , o ) ;
16
+ r ( o , i ) ;
28
17
} ) ;
29
18
} } ;
30
19
}
31
- const h = at ( ) , b = "[-+]?[0-9]*.?[0-9]+" , H = [
20
+ const v = ot ( ) , T = "[-+]?[0-9]*.?[0-9]+" , M = [
32
21
{
33
22
name : "px" ,
34
- regexp : new RegExp ( `^${ b } px$` )
23
+ regexp : new RegExp ( `^${ T } px$` )
35
24
} ,
36
25
{
37
26
name : "%" ,
38
- regexp : new RegExp ( `^${ b } %$` )
27
+ regexp : new RegExp ( `^${ T } %$` )
39
28
} ,
40
29
/**
41
30
* Fallback option
42
31
* If no suffix specified, assigning "px"
43
32
*/
44
33
{
45
34
name : "px" ,
46
- regexp : new RegExp ( `^${ b } $` )
35
+ regexp : new RegExp ( `^${ T } $` )
47
36
}
48
- ] , st = ( t ) => {
37
+ ] , it = ( t ) => {
49
38
if ( t === "auto" )
50
39
return {
51
40
type : t ,
52
41
value : 0
53
42
} ;
54
- for ( let i = 0 ; i < H . length ; i ++ ) {
55
- const o = H [ i ] ;
56
- if ( o . regexp . test ( t ) )
43
+ for ( let o = 0 ; o < M . length ; o ++ ) {
44
+ const i = M [ o ] ;
45
+ if ( i . regexp . test ( t ) )
57
46
return {
58
- type : o . name ,
47
+ type : i . name ,
59
48
value : parseFloat ( t )
60
49
} ;
61
50
}
62
51
return {
63
52
type : "" ,
64
53
value : t
65
54
} ;
66
- } , rt = ( t ) => {
55
+ } , at = ( t ) => {
67
56
switch ( typeof t ) {
68
57
case "number" :
69
58
return { type : "px" , value : t } ;
70
59
case "string" :
71
- return st ( t ) ;
60
+ return it ( t ) ;
72
61
default :
73
62
return { type : "" , value : t } ;
74
63
}
75
- } , R = {
64
+ } , H = {
76
65
x : /* @__PURE__ */ new Set ( [ "left" , "center" , "right" ] ) ,
77
66
y : /* @__PURE__ */ new Set ( [ "top" , "bottom" ] )
78
- } , lt = /* @__PURE__ */ ( ( t ) => ( ) => t ++ ) ( 0 ) , ct = ( t ) => typeof t != "string" ? [ ] : t . split ( / \s + / gi) . filter ( Boolean ) , ut = ( t ) => {
79
- typeof t == "string" && ( t = ct ( t ) ) ;
80
- let i = null , o = null ;
67
+ } , st = /* @__PURE__ */ ( ( t ) => ( ) => t ++ ) ( 0 ) , rt = ( t ) => typeof t != "string" ? [ ] : t . split ( / \s + / gi) . filter ( Boolean ) , lt = ( t ) => {
68
+ typeof t == "string" && ( t = rt ( t ) ) ;
69
+ let o = null , i = null ;
81
70
return t . forEach ( ( a ) => {
82
- R . y . has ( a ) && ( o = a ) , R . x . has ( a ) && ( i = a ) ;
83
- } ) , { x : i , y : o } ;
84
- } , T = {
71
+ H . y . has ( a ) && ( i = a ) , H . x . has ( a ) && ( o = a ) ;
72
+ } ) , { x : o , y : i } ;
73
+ } , b = {
85
74
position : [ "top" , "right" ] ,
86
75
cssAnimation : "vn-fade" ,
87
76
velocityAnimation : {
@@ -94,14 +83,25 @@ const h = at(), b = "[-+]?[0-9]*.?[0-9]+", H = [
94
83
opacity : [ 0 , 1 ]
95
84
}
96
85
}
86
+ } , ct = ( t , o ) => {
87
+ let i , a , r = o ;
88
+ const y = ( ) => {
89
+ a = Date . now ( ) , i = setTimeout ( t , r ) ;
90
+ } , m = ( ) => {
91
+ clearTimeout ( i ) , r -= Date . now ( ) - a ;
92
+ } ;
93
+ return y ( ) , {
94
+ start : y ,
95
+ stop : m
96
+ } ;
97
97
} ;
98
- function ft ( t ) {
99
- return typeof t == "function" || Object . prototype . toString . call ( t ) === "[object Object]" && ! it ( t ) ;
98
+ function ut ( t ) {
99
+ return typeof t == "function" || Object . prototype . toString . call ( t ) === "[object Object]" && ! nt ( t ) ;
100
100
}
101
- const g = {
101
+ const x = {
102
102
IDLE : 0 ,
103
103
DESTROYED : 2
104
- } , dt = /* @__PURE__ */ Z ( {
104
+ } , ft = /* @__PURE__ */ U ( {
105
105
// eslint-disable-next-line vue/multi-word-component-names
106
106
name : "notifications" ,
107
107
props : {
@@ -123,7 +123,7 @@ const g = {
123
123
} ,
124
124
position : {
125
125
type : [ String , Array ] ,
126
- default : ( ) => T . position
126
+ default : ( ) => b . position
127
127
} ,
128
128
classes : {
129
129
type : [ String , Array ] ,
@@ -139,12 +139,12 @@ const g = {
139
139
animation : {
140
140
type : Object ,
141
141
default ( ) {
142
- return T . velocityAnimation ;
142
+ return b . velocityAnimation ;
143
143
}
144
144
} ,
145
145
animationName : {
146
146
type : String ,
147
- default : T . cssAnimation
147
+ default : b . cssAnimation
148
148
} ,
149
149
speed : {
150
150
type : Number ,
@@ -190,126 +190,127 @@ const g = {
190
190
} ,
191
191
slots : Object ,
192
192
setup : ( t , {
193
- emit : i ,
194
- slots : o ,
193
+ emit : o ,
194
+ slots : i ,
195
195
expose : a
196
196
} ) => {
197
- const r = M ( [ ] ) , x = M ( null ) , D = j . get ( "velocity" ) , v = y ( ( ) => t . animationType === "velocity" ) , c = y ( ( ) => r . value . filter ( ( e ) => e . state !== g . DESTROYED ) ) , S = y ( ( ) => rt ( t . width ) ) , N = y ( ( ) => {
197
+ const r = X ( [ ] ) , y = R . get ( "velocity" ) , m = g ( ( ) => t . animationType === "velocity" ) , c = g ( ( ) => r . value . filter ( ( e ) => e . state !== x . DESTROYED ) ) , D = g ( ( ) => at ( t . width ) ) , S = g ( ( ) => {
198
198
const {
199
199
x : e ,
200
200
y : n
201
- } = ut ( t . position ) , s = S . value . value , u = S . value . type , p = {
201
+ } = lt ( t . position ) , s = D . value . value , u = D . value . type , p = {
202
202
width : s + u
203
203
} ;
204
204
return n && ( p [ n ] = "0px" ) , e && ( e === "center" ? p . left = `calc(50% - ${ + s / 2 } ${ u } )` : p [ e ] = "0px" ) , p ;
205
- } ) , B = y ( ( ) => v . value ? {
206
- onEnter : q ,
207
- onLeave : z ,
208
- onAfterLeave : w
209
- } : { } ) , C = ( e ) => {
210
- i ( "click" , e ) , t . closeOnClick && d ( e ) ;
211
- } , L = ( ) => {
212
- var e ;
213
- t . pauseOnHover && ( ( e = x . value ) == null || e . pause ( ) ) ;
214
- } , P = ( ) => {
215
- var e ;
216
- t . pauseOnHover && ( ( e = x . value ) == null || e . resume ( ) ) ;
217
- } , Y = ( e = { } ) => {
205
+ } ) , j = g ( ( ) => m . value ? {
206
+ onEnter : G ,
207
+ onLeave : W ,
208
+ onAfterLeave : O
209
+ } : { } ) , B = ( e ) => {
210
+ o ( "click" , e ) , t . closeOnClick && d ( e ) ;
211
+ } , L = ( e ) => {
212
+ var n ;
213
+ t . pauseOnHover && ( ( n = e . timer ) == null || n . stop ( ) ) ;
214
+ } , k = ( e ) => {
215
+ var n ;
216
+ t . pauseOnHover && ( ( n = e . timer ) == null || n . start ( ) ) ;
217
+ } , C = ( e = { } ) => {
218
218
if ( e . group || ( e . group = "" ) , e . data || ( e . data = { } ) , t . group !== e . group )
219
219
return ;
220
220
if ( e . clean || e . clear ) {
221
- W ( ) ;
221
+ F ( ) ;
222
222
return ;
223
223
}
224
224
const n = typeof e . duration == "number" ? e . duration : t . duration , s = typeof e . speed == "number" ? e . speed : t . speed , u = typeof e . ignoreDuplicates == "boolean" ? e . ignoreDuplicates : t . ignoreDuplicates , {
225
225
title : p ,
226
- text : J ,
227
- type : K ,
228
- data : Q ,
229
- id : U
226
+ text : q ,
227
+ type : z ,
228
+ data : J ,
229
+ id : K
230
230
} = e , f = {
231
- id : U || lt ( ) ,
231
+ id : K || st ( ) ,
232
232
title : p ,
233
- text : J ,
234
- type : K ,
235
- state : g . IDLE ,
233
+ text : q ,
234
+ type : z ,
235
+ state : x . IDLE ,
236
236
speed : s ,
237
237
length : n + 2 * s ,
238
- data : Q ,
238
+ data : J ,
239
239
duplicates : 0
240
240
} ;
241
- n >= 0 && ( x . value = new ot ( ( ) => d ( f ) , f . length , f ) ) ;
242
- const I = "bottom" in N . value , X = t . reverse ? ! I : I ;
243
- let m = - 1 ;
244
- const A = c . value . find ( ( $ ) => $ . title === e . title && $ . text === e . text ) ;
241
+ n >= 0 && ( f . timer = ct ( ( ) => d ( f ) , f . length ) ) ;
242
+ const w = "bottom" in S . value , Q = t . reverse ? ! w : w ;
243
+ let h = - 1 ;
244
+ const A = c . value . find ( ( I ) => I . title === e . title && I . text === e . text ) ;
245
245
if ( u && A ) {
246
246
A . duplicates ++ ;
247
247
return ;
248
248
}
249
- X ? ( r . value . push ( f ) , i ( "start" , f ) , c . value . length > t . max && ( m = 0 ) ) : ( r . value . unshift ( f ) , i ( "start" , f ) , c . value . length > t . max && ( m = c . value . length - 1 ) ) , m !== - 1 && d ( c . value [ m ] ) ;
250
- } , V = ( e ) => {
251
- G ( e ) ;
252
- } , _ = ( e ) => [ "vue-notification-template" , t . classes , e . type || "" ] , F = ( e ) => v . value ? void 0 : {
249
+ Q ? ( r . value . push ( f ) , o ( "start" , f ) , c . value . length > t . max && ( h = 0 ) ) : ( r . value . unshift ( f ) , o ( "start" , f ) , c . value . length > t . max && ( h = c . value . length - 1 ) ) , h !== - 1 && d ( c . value [ h ] ) ;
250
+ } , P = ( e ) => {
251
+ _ ( e ) ;
252
+ } , Y = ( e ) => [ "vue-notification-template" , t . classes , e . type || "" ] , V = ( e ) => m . value ? void 0 : {
253
253
transition : `all ${ e . speed } ms`
254
254
} , d = ( e ) => {
255
- clearTimeout ( e . timer ) , e . state = g . DESTROYED , w ( ) , i ( "destroy" , e ) ;
256
- } , G = ( e ) => {
255
+ var n ;
256
+ ( n = e . timer ) == null || n . stop ( ) , e . state = x . DESTROYED , O ( ) , o ( "destroy" , e ) ;
257
+ } , _ = ( e ) => {
257
258
const n = r . value . find ( ( s ) => s . id === e ) ;
258
259
n && d ( n ) ;
259
- } , W = ( ) => {
260
+ } , F = ( ) => {
260
261
c . value . forEach ( d ) ;
261
- } , O = ( e , n ) => {
262
+ } , N = ( e , n ) => {
262
263
var u ;
263
264
const s = ( u = t . animation ) == null ? void 0 : u [ e ] ;
264
265
return typeof s == "function" ? s ( n ) : s ;
265
- } , q = ( e , n ) => {
266
- const s = O ( "enter" , e ) ;
267
- D ( e , s , {
266
+ } , G = ( e , n ) => {
267
+ const s = N ( "enter" , e ) ;
268
+ y ( e , s , {
268
269
duration : t . speed ,
269
270
complete : n
270
271
} ) ;
271
- } , z = ( e , n ) => {
272
- const s = O ( "leave" , e ) ;
273
- D ( e , s , {
272
+ } , W = ( e , n ) => {
273
+ const s = N ( "leave" , e ) ;
274
+ y ( e , s , {
274
275
duration : t . speed ,
275
276
complete : n
276
277
} ) ;
277
278
} ;
278
- function w ( ) {
279
- r . value = r . value . filter ( ( e ) => e . state !== g . DESTROYED ) ;
279
+ function O ( ) {
280
+ r . value = r . value . filter ( ( e ) => e . state !== x . DESTROYED ) ;
280
281
}
281
- return tt ( ( ) => {
282
- h . on ( "add" , Y ) , h . on ( "close" , V ) ;
282
+ return Z ( ( ) => {
283
+ v . on ( "add" , C ) , v . on ( "close" , P ) ;
283
284
} ) , ( ) => {
284
285
let e ;
285
286
return l ( "div" , {
286
287
class : "vue-notification-group" ,
287
- style : N . value
288
- } , [ l ( et , nt ( B . value , {
288
+ style : S . value
289
+ } , [ l ( tt , et ( j . value , {
289
290
tag : "div" ,
290
- css : ! v . value ,
291
+ css : ! m . value ,
291
292
name : t . animationName
292
- } ) , ft ( e = c . value . map ( ( n ) => l ( "div" , {
293
+ } ) , ut ( e = c . value . map ( ( n ) => l ( "div" , {
293
294
key : n . id ,
294
295
class : "vue-notification-wrapper" ,
295
- style : F ( n ) ,
296
+ style : V ( n ) ,
296
297
"data-id" : n . id ,
297
- onMouseenter : L ,
298
- onMouseleave : P
299
- } , [ o . body ? o . body ( {
298
+ onMouseenter : ( ) => L ( n ) ,
299
+ onMouseleave : ( ) => k ( n )
300
+ } , [ i . body ? i . body ( {
300
301
item : n ,
301
302
class : [ t . classes , n . type ] ,
302
303
close : ( ) => d ( n )
303
304
} ) : l ( "div" , {
304
- class : _ ( n ) ,
305
- onClick : ( ) => C ( n )
306
- } , [ t . dangerouslySetInnerHtml ? l ( k , null , [ n . title ? l ( "div" , {
305
+ class : Y ( n ) ,
306
+ onClick : ( ) => B ( n )
307
+ } , [ t . dangerouslySetInnerHtml ? l ( $ , null , [ n . title ? l ( "div" , {
307
308
class : "notification-title" ,
308
309
innerHTML : n . title
309
310
} , null ) : null , l ( "div" , {
310
311
class : "notification-content" ,
311
312
innerHTML : n . text
312
- } , null ) ] ) : l ( k , null , [ n . title ? l ( "div" , {
313
+ } , null ) ] ) : l ( $ , null , [ n . title ? l ( "div" , {
313
314
class : "notification-title"
314
315
} , [ n . title ] ) : null , l ( "div" , {
315
316
class : "notification-content"
@@ -319,23 +320,23 @@ const g = {
319
320
} ;
320
321
}
321
322
} ) , E = ( t ) => {
322
- typeof t == "string" && ( t = { title : "" , text : t } ) , typeof t == "object" && h . emit ( "add" , t ) ;
323
+ typeof t == "string" && ( t = { title : "" , text : t } ) , typeof t == "object" && v . emit ( "add" , t ) ;
323
324
} ;
324
325
E . close = ( t ) => {
325
- h . emit ( "close" , t ) ;
326
+ v . emit ( "close" , t ) ;
326
327
} ;
327
- const gt = ( ) => ( { notify : E } ) , pt = "Notifications" ;
328
- function yt ( t , i = { } ) {
329
- Object . entries ( i ) . forEach ( ( a ) => j . set ( ...a ) ) ;
330
- const o = i . name || "notify" ;
331
- t . config . globalProperties [ "$" + o ] = E , t . component ( i . componentName || pt , dt ) ;
328
+ const mt = ( ) => ( { notify : E } ) , dt = "Notifications" ;
329
+ function pt ( t , o = { } ) {
330
+ Object . entries ( o ) . forEach ( ( a ) => R . set ( ...a ) ) ;
331
+ const i = o . name || "notify" ;
332
+ t . config . globalProperties [ "$" + i ] = E , t . component ( o . componentName || dt , ft ) ;
332
333
}
333
- const ht = {
334
- install : yt
334
+ const gt = {
335
+ install : pt
335
336
} ;
336
337
export {
337
- dt as Notifications ,
338
- ht as default ,
338
+ ft as Notifications ,
339
+ gt as default ,
339
340
E as notify ,
340
- gt as useNotification
341
+ mt as useNotification
341
342
} ;
0 commit comments