aio-popup 3.0.20 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.css +216 -165
- package/index.js +2 -2
- package/package.json +1 -1
package/index.css
CHANGED
|
@@ -8,95 +8,114 @@
|
|
|
8
8
|
align-items: center;
|
|
9
9
|
justify-content: center;
|
|
10
10
|
z-index: 10000;
|
|
11
|
-
background:rgba(0,0,0,0.1);
|
|
12
|
-
transition:0.3s;
|
|
11
|
+
background: rgba(0, 0, 0, 0.1);
|
|
12
|
+
transition: 0.3s;
|
|
13
13
|
pointer-events: all;
|
|
14
14
|
}
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
|
|
16
|
+
.aio-popup.not-mounted {
|
|
17
|
+
transition: 0.3s;
|
|
17
18
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
|
|
20
|
+
.aio-popup-position-fullscreen>.aio-popup.not-mounted {
|
|
21
|
+
transform: scale(0);
|
|
22
|
+
|
|
21
23
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
+
|
|
25
|
+
.aio-popup-position-popover>.aio-popup.not-mounted {
|
|
26
|
+
opacity: 0;
|
|
24
27
|
}
|
|
25
|
-
|
|
26
|
-
|
|
28
|
+
|
|
29
|
+
.aio-popup-position-top>.aio-popup.not-mounted {
|
|
30
|
+
top: -500px;
|
|
27
31
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
32
|
+
|
|
33
|
+
.aio-popup-position-bottom>.aio-popup.not-mounted {
|
|
34
|
+
bottom: -500px;
|
|
35
|
+
opacity: 0;
|
|
31
36
|
}
|
|
32
|
-
|
|
33
|
-
|
|
37
|
+
|
|
38
|
+
.aio-popup-position-right>.aio-popup.not-mounted {
|
|
39
|
+
right: -500px;
|
|
34
40
|
}
|
|
35
|
-
|
|
36
|
-
|
|
41
|
+
|
|
42
|
+
.aio-popup-position-left>.aio-popup.not-mounted {
|
|
43
|
+
left: -500px;
|
|
37
44
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
45
|
+
|
|
46
|
+
.aio-popup-position-center>.aio-popup.not-mounted {
|
|
47
|
+
transform: translateY(500px);
|
|
48
|
+
opacity: 0;
|
|
41
49
|
}
|
|
42
50
|
|
|
43
|
-
.aio-popup-position-fullscreen
|
|
44
|
-
|
|
45
|
-
|
|
51
|
+
.aio-popup-position-fullscreen>.aio-popup {
|
|
52
|
+
width: 100%;
|
|
53
|
+
height: 100%;
|
|
46
54
|
}
|
|
47
|
-
|
|
48
|
-
|
|
55
|
+
|
|
56
|
+
.aio-popup-position-popover {
|
|
57
|
+
opacity: 1;
|
|
49
58
|
}
|
|
50
|
-
|
|
59
|
+
|
|
60
|
+
.aio-popup-position-top {
|
|
51
61
|
align-items: flex-start;
|
|
52
62
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
63
|
+
|
|
64
|
+
.aio-popup-position-top>.aio-popup {
|
|
65
|
+
width: 100%;
|
|
66
|
+
max-height: 90vh;
|
|
67
|
+
top: 0;
|
|
57
68
|
}
|
|
58
|
-
|
|
69
|
+
|
|
70
|
+
.aio-popup-position-bottom {
|
|
59
71
|
align-items: flex-end;
|
|
60
72
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
73
|
+
|
|
74
|
+
.aio-popup-position-bottom>.aio-popup {
|
|
75
|
+
width: 100%;
|
|
76
|
+
max-height: 90vh;
|
|
77
|
+
bottom: 0;
|
|
78
|
+
opacity: 1;
|
|
66
79
|
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
80
|
+
|
|
81
|
+
.aio-popup-backdrop.not-mounted {
|
|
82
|
+
background: none !important;
|
|
83
|
+
transition: 0.3s;
|
|
70
84
|
}
|
|
71
|
-
|
|
72
|
-
|
|
85
|
+
|
|
86
|
+
.aio-popup-position-right {
|
|
87
|
+
justify-content: right;
|
|
73
88
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
89
|
+
|
|
90
|
+
.aio-popup-position-right .aio-popup {
|
|
91
|
+
height: 100%;
|
|
92
|
+
max-width: 90vh;
|
|
93
|
+
right: 0;
|
|
78
94
|
}
|
|
79
|
-
|
|
80
|
-
|
|
95
|
+
|
|
96
|
+
.aio-popup-position-left {
|
|
97
|
+
justify-content: left;
|
|
81
98
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
99
|
+
|
|
100
|
+
.aio-popup-position-left>.aio-popup {
|
|
101
|
+
height: 100%;
|
|
102
|
+
max-width: 90vh;
|
|
103
|
+
left: 0;
|
|
86
104
|
}
|
|
87
|
-
|
|
105
|
+
|
|
106
|
+
.aio-popup-position-center>.aio-popup {
|
|
88
107
|
max-width: 100vw;
|
|
89
|
-
width:fit-content;
|
|
90
|
-
opacity:1;
|
|
91
|
-
max-height:100vh;
|
|
108
|
+
width: fit-content;
|
|
109
|
+
opacity: 1;
|
|
110
|
+
max-height: 100vh;
|
|
92
111
|
}
|
|
93
112
|
|
|
94
113
|
.aio-popup {
|
|
95
114
|
border-radius: 4px;
|
|
96
|
-
font-size:14px;
|
|
97
|
-
transition:0.3s;
|
|
98
|
-
max-width:100vw;
|
|
99
|
-
max-height:100vh;
|
|
115
|
+
font-size: 14px;
|
|
116
|
+
transition: 0.3s;
|
|
117
|
+
max-width: 100vw;
|
|
118
|
+
max-height: 100vh;
|
|
100
119
|
pointer-events: auto;
|
|
101
120
|
}
|
|
102
121
|
|
|
@@ -105,42 +124,48 @@
|
|
|
105
124
|
}
|
|
106
125
|
|
|
107
126
|
.aio-popup-header {
|
|
108
|
-
border-bottom:1px solid #e7e9ec;
|
|
109
|
-
background
|
|
127
|
+
border-bottom: 1px solid #e7e9ec;
|
|
128
|
+
background: #fff;
|
|
110
129
|
color: #323130;
|
|
111
|
-
padding:6px 12px;
|
|
130
|
+
padding: 6px 12px;
|
|
112
131
|
font-size: 16px;
|
|
113
132
|
font-weight: bold;
|
|
114
|
-
min-height:48px;
|
|
133
|
+
min-height: 48px;
|
|
115
134
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
135
|
+
|
|
136
|
+
.aio-popup-subtitle {
|
|
137
|
+
font-size: 85%;
|
|
138
|
+
opacity: 0.5;
|
|
119
139
|
}
|
|
140
|
+
|
|
120
141
|
.aio-popup-body {
|
|
121
|
-
background
|
|
142
|
+
background: #fff;
|
|
122
143
|
flex: 1;
|
|
123
144
|
width: 100%;
|
|
124
|
-
overflow-y:auto;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
145
|
+
overflow-y: auto;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
.aio-popup-footer {
|
|
149
|
+
background: #fff;
|
|
150
|
+
padding: 12px;
|
|
151
|
+
width: 100%;
|
|
152
|
+
gap: 12px;
|
|
153
|
+
display: flex;
|
|
154
|
+
border-top: 1px solid #f2f4f7;
|
|
133
155
|
justify-content: flex-end;
|
|
134
156
|
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
157
|
+
|
|
158
|
+
.aio-popup-header-button {
|
|
159
|
+
padding: 0 6px;
|
|
160
|
+
background: none;
|
|
161
|
+
border: none;
|
|
162
|
+
cursor: pointer;
|
|
140
163
|
}
|
|
141
|
-
|
|
142
|
-
|
|
164
|
+
|
|
165
|
+
.aio-popup-header-close-button {
|
|
166
|
+
width: 36px;
|
|
143
167
|
}
|
|
168
|
+
|
|
144
169
|
.aio-popup-footer-button {
|
|
145
170
|
height: 30px;
|
|
146
171
|
background: dodgerblue;
|
|
@@ -150,10 +175,11 @@
|
|
|
150
175
|
font-family: inherit;
|
|
151
176
|
border-radius: 4px;
|
|
152
177
|
}
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
178
|
+
|
|
179
|
+
.aio-popup-footer-button:disabled {
|
|
180
|
+
opacity: 0.4;
|
|
181
|
+
background: #ddd;
|
|
182
|
+
cursor: not-allowed;
|
|
157
183
|
}
|
|
158
184
|
|
|
159
185
|
.aio-popup-blur {
|
|
@@ -185,21 +211,25 @@
|
|
|
185
211
|
max-width: 360px;
|
|
186
212
|
border-radius: 4px;
|
|
187
213
|
box-shadow: 5px 8px 11px 0 rgb(0 0 0 / 17%);
|
|
188
|
-
display:flex;
|
|
214
|
+
display: flex;
|
|
189
215
|
flex-direction: column;
|
|
190
|
-
overflow:hidden;
|
|
216
|
+
overflow: hidden;
|
|
191
217
|
}
|
|
192
|
-
|
|
193
|
-
|
|
218
|
+
|
|
219
|
+
.aio-popup-alert-error .aio-popup-alert-header svg {
|
|
220
|
+
fill: red;
|
|
194
221
|
}
|
|
195
|
-
|
|
196
|
-
|
|
222
|
+
|
|
223
|
+
.aio-popup-alert-warning .aio-popup-alert-header svg {
|
|
224
|
+
fill: orange;
|
|
197
225
|
}
|
|
198
|
-
|
|
199
|
-
|
|
226
|
+
|
|
227
|
+
.aio-popup-alert-info .aio-popup-alert-header svg {
|
|
228
|
+
fill: dodgerblue;
|
|
200
229
|
}
|
|
201
|
-
|
|
202
|
-
|
|
230
|
+
|
|
231
|
+
.aio-popup-alert-success .aio-popup-alert-header svg {
|
|
232
|
+
fill: green;
|
|
203
233
|
}
|
|
204
234
|
|
|
205
235
|
.aio-popup-alert-header {
|
|
@@ -212,8 +242,8 @@
|
|
|
212
242
|
|
|
213
243
|
.aio-popup-alert-body {
|
|
214
244
|
padding: 0 12px;
|
|
215
|
-
max-height:400px;
|
|
216
|
-
overflow-y:auto;
|
|
245
|
+
max-height: 400px;
|
|
246
|
+
overflow-y: auto;
|
|
217
247
|
}
|
|
218
248
|
|
|
219
249
|
.aio-popup-alert-text {
|
|
@@ -243,7 +273,7 @@
|
|
|
243
273
|
height: 3px;
|
|
244
274
|
width: calc(100% - 24px);
|
|
245
275
|
left: 12px;
|
|
246
|
-
bottom:0;
|
|
276
|
+
bottom: 0;
|
|
247
277
|
}
|
|
248
278
|
|
|
249
279
|
.aio-popup-time-bar {
|
|
@@ -252,18 +282,23 @@
|
|
|
252
282
|
height: 100%;
|
|
253
283
|
left: 0;
|
|
254
284
|
}
|
|
255
|
-
|
|
256
|
-
|
|
285
|
+
|
|
286
|
+
.aio-popup-alert-error .aio-popup-time-bar {
|
|
287
|
+
background: red;
|
|
257
288
|
}
|
|
258
|
-
|
|
259
|
-
|
|
289
|
+
|
|
290
|
+
.aio-popup-alert-warning .aio-popup-time-bar {
|
|
291
|
+
background: orange;
|
|
260
292
|
}
|
|
261
|
-
|
|
262
|
-
|
|
293
|
+
|
|
294
|
+
.aio-popup-alert-info .aio-popup-time-bar {
|
|
295
|
+
background: dodgerblue;
|
|
263
296
|
}
|
|
264
|
-
|
|
265
|
-
|
|
297
|
+
|
|
298
|
+
.aio-popup-alert-success .aio-popup-time-bar {
|
|
299
|
+
background: green;
|
|
266
300
|
}
|
|
301
|
+
|
|
267
302
|
.aio-popup-alert-footer button {
|
|
268
303
|
border: none;
|
|
269
304
|
font-family: inherit;
|
|
@@ -275,104 +310,120 @@
|
|
|
275
310
|
border-radius: 3px;
|
|
276
311
|
}
|
|
277
312
|
|
|
278
|
-
.aio-popup-snakebar-item-container{
|
|
279
|
-
font-size:12px;
|
|
313
|
+
.aio-popup-snakebar-item-container {
|
|
314
|
+
font-size: 12px;
|
|
280
315
|
height: fit-content;
|
|
281
316
|
color: #fff;
|
|
282
317
|
width: 100%;
|
|
283
318
|
left: 0;
|
|
284
319
|
position: fixed;
|
|
285
320
|
transition: 0.2s;
|
|
286
|
-
padding:0 24px;
|
|
287
|
-
display:flex;
|
|
321
|
+
padding: 0 24px;
|
|
322
|
+
display: flex;
|
|
288
323
|
align-items: center;
|
|
289
324
|
box-sizing: border-box;
|
|
290
325
|
justify-content: center;
|
|
291
|
-
z-index:1000000;
|
|
326
|
+
z-index: 1000000;
|
|
292
327
|
}
|
|
293
|
-
|
|
328
|
+
|
|
329
|
+
.aio-popup-snakebar-item {
|
|
294
330
|
background: rgb(24 28 41 / 95%);
|
|
295
|
-
padding:12px;
|
|
296
|
-
right:100%;
|
|
331
|
+
padding: 12px;
|
|
332
|
+
right: 100%;
|
|
297
333
|
position: relative;
|
|
298
|
-
width:100%;
|
|
334
|
+
width: 100%;
|
|
299
335
|
height: fit-content;
|
|
300
336
|
box-sizing: border-box;
|
|
301
337
|
display: flex;
|
|
302
338
|
align-items: center;
|
|
303
339
|
transition: 0.2s;
|
|
304
|
-
overflow:hidden;
|
|
340
|
+
overflow: hidden;
|
|
305
341
|
}
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
342
|
+
|
|
343
|
+
.aio-popup-snakebar-item-container.mounted .aio-popup-snakebar-item {
|
|
344
|
+
transition: 0.5s;
|
|
345
|
+
right: 0;
|
|
309
346
|
}
|
|
310
|
-
|
|
311
|
-
|
|
347
|
+
|
|
348
|
+
.aio-popup-snakebar-item-text {
|
|
349
|
+
flex: 1;
|
|
312
350
|
}
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
351
|
+
|
|
352
|
+
.aio-popup-snakebar-item-subtext {
|
|
353
|
+
font-size: 85%;
|
|
354
|
+
opacity: 0.67;
|
|
316
355
|
}
|
|
317
|
-
|
|
318
|
-
|
|
356
|
+
|
|
357
|
+
.aio-popup-snakebar-item-text svg {
|
|
358
|
+
flex: 1;
|
|
319
359
|
}
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
360
|
+
|
|
361
|
+
.aio-popup-snakebar-item-remove {
|
|
362
|
+
display: flex;
|
|
363
|
+
align-items: center;
|
|
323
364
|
justify-content: center;
|
|
324
365
|
border-radius: 100%;
|
|
325
366
|
}
|
|
326
|
-
|
|
367
|
+
|
|
368
|
+
.aio-popup-snakebar-item-icon {
|
|
327
369
|
display: flex;
|
|
328
370
|
align-items: center;
|
|
329
371
|
justify-content: center;
|
|
330
|
-
margin-inline-end:6px;
|
|
331
|
-
border-radius:100%;
|
|
332
|
-
padding:3px;
|
|
372
|
+
margin-inline-end: 6px;
|
|
373
|
+
border-radius: 100%;
|
|
374
|
+
padding: 3px;
|
|
333
375
|
}
|
|
334
|
-
|
|
335
|
-
|
|
376
|
+
|
|
377
|
+
.aio-popup-snakebar-item-success .aio-popup-snakebar-item-icon {
|
|
378
|
+
color: #5ba427;
|
|
336
379
|
}
|
|
337
|
-
|
|
338
|
-
|
|
380
|
+
|
|
381
|
+
.aio-popup-snakebar-item-error .aio-popup-snakebar-item-icon {
|
|
382
|
+
color: #e83232;
|
|
339
383
|
}
|
|
340
|
-
|
|
341
|
-
|
|
384
|
+
|
|
385
|
+
.aio-popup-snakebar-item-warning .aio-popup-snakebar-item-icon {
|
|
386
|
+
color: #ffb300;
|
|
342
387
|
}
|
|
343
|
-
|
|
344
|
-
|
|
388
|
+
|
|
389
|
+
.aio-popup-snakebar-item-info .aio-popup-snakebar-item-icon {
|
|
390
|
+
color: #00bcff;
|
|
345
391
|
}
|
|
346
392
|
|
|
347
|
-
.aio-popup-snakebar-item-container .aio-popup-snakebar-bar{
|
|
348
|
-
position:absolute;
|
|
349
|
-
left:0;
|
|
350
|
-
bottom:2px;
|
|
351
|
-
width:0%;
|
|
352
|
-
height:3px;
|
|
393
|
+
.aio-popup-snakebar-item-container .aio-popup-snakebar-bar {
|
|
394
|
+
position: absolute;
|
|
395
|
+
left: 0;
|
|
396
|
+
bottom: 2px;
|
|
397
|
+
width: 0%;
|
|
398
|
+
height: 3px;
|
|
353
399
|
}
|
|
354
|
-
|
|
355
|
-
|
|
400
|
+
|
|
401
|
+
.aio-popup-snakebar-item-container.mounted .aio-popup-snakebar-bar {
|
|
402
|
+
width: 100%;
|
|
356
403
|
}
|
|
404
|
+
|
|
357
405
|
/* .aio-popup-snakebar-container.mounted .aio-popup-snakebar-bar{
|
|
358
406
|
width:50%;
|
|
359
407
|
} */
|
|
360
408
|
|
|
361
|
-
.aio-popup-snakebar-item-success .aio-popup-snakebar-bar{
|
|
362
|
-
background
|
|
409
|
+
.aio-popup-snakebar-item-success .aio-popup-snakebar-bar {
|
|
410
|
+
background: #5ba427;
|
|
363
411
|
}
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
.aio-popup-snakebar-item-warning .aio-popup-snakebar-bar{
|
|
368
|
-
background:#ffb300;
|
|
412
|
+
|
|
413
|
+
.aio-popup-snakebar-item-error .aio-popup-snakebar-bar {
|
|
414
|
+
background: #e83232;
|
|
369
415
|
}
|
|
370
|
-
|
|
371
|
-
|
|
416
|
+
|
|
417
|
+
.aio-popup-snakebar-item-warning .aio-popup-snakebar-bar {
|
|
418
|
+
background: #ffb300;
|
|
372
419
|
}
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
background:none;
|
|
420
|
+
|
|
421
|
+
.aio-popup-snakebar-item-info .aio-popup-snakebar-bar {
|
|
422
|
+
background: #00bcff;
|
|
377
423
|
}
|
|
378
424
|
|
|
425
|
+
.aio-popup-snakebar-item-action {
|
|
426
|
+
color: dodgerblue;
|
|
427
|
+
border: none;
|
|
428
|
+
background: none;
|
|
429
|
+
}
|
package/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
function _defineProperty(t,e,o){return(e=_toPropertyKey(e))in t?Object.defineProperty(t,e,{value:o,enumerable:!0,configurable:!0,writable:!0}):t[e]=o,t}function _toPropertyKey(t){var e=_toPrimitive(t,"string");return"symbol"==typeof e?e:String(e)}function _toPrimitive(t,e){if("object"!=typeof t||null===t)return t;var o=t[Symbol.toPrimitive];if(void 0!==o){var i=o.call(t,e||"default");if("object"!=typeof i)return i;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}import t,{Component as e,createRef as o,useEffect as i}from"react";import*as s from"react-dom/server";import{Icon as r}from"@mdi/react";import{mdiClose as a,mdiChevronRight as l,mdiChevronLeft as n}from"@mdi/js";import p from"react-virtual-dom";import d from"jquery";import"./index.css";import{jsx as h}from"react/jsx-runtime";import{Fragment as m}from"react/jsx-runtime";import{jsxs as u}from"react/jsx-runtime";export default class _{constructor(t={}){_defineProperty(this,"render",()=>u(m,{children:[h(Popups,{rtl:this.rtl,getActions:({addModal:t,removeModal:e,getModals:o})=>{this._addModal=t,this._removeModal=e,this._getModals=o}}),h(AIOSnackeBar,{rtl:this.rtl,getActions:({add:t})=>{this._addSnakebar=t}})]})),_defineProperty(this,"getModals",()=>this._getModals()),_defineProperty(this,"addModal",(t={},e=!0)=>{void 0===t.id&&(t.id="popup"+Math.round(1e6*Math.random())),this._addModal(t,e)}),_defineProperty(this,"addConfirm",t=>{let{title:e,subtitle:o,text:i,buttons:s}=t,r={position:"center",attrs:{className:"aio-popup-confirm"},header:{title:e,subtitle:o},backdrop:{attrs:{className:"rsa-backdrop"}},body:{render:()=>i},footer:{buttons:s}};this.addModal(r)}),_defineProperty(this,"addPrompt",t=>{let{title:e,subtitle:o,text:i,submitText:s="تایید",canselText:r="بستن",onSubmit:a}=t,l={position:"center",attrs:{className:"aio-popup-prompt"},state:{temp:""},header:{title:e,subtitle:o},backdrop:{attrs:{className:"rsa-backdrop"}},body:{render:({state:t,setState:e})=>h("textarea",{placeholder:i,value:t.temp,onChange:t=>e({temp:t.target.value})})},footer:{buttons:[[r,{onClick:()=>this.removeModal()}],[s,({state:t,setState:e})=>({onClick:async({state:t})=>{!1!==await a(t.temp)?this.removeModal():e({temp:""})},disabled:!t.temp,className:"active"})]]}};this.addModal(l)}),_defineProperty(this,"removeModal",(t,e=!0)=>{this._removeModal&&this._removeModal(t,e)}),_defineProperty(this,"addAlert",(t={})=>{let{icon:e,type:o="",text:i="",subtext:s="",time:r=10,className:a,closeText:l="بستن"}=t;Alert({icon:e,type:o,text:i,subtext:s,time:r,className:a,closeText:l})}),_defineProperty(this,"addSnakebar",(t={})=>{let{text:e,index:o,type:i,subtext:s,action:r={},time:a=6,rtl:l}=t;this._addSnakebar({text:e,index:o,type:i,subtext:s,action:r,time:a,rtl:l})}),this.rtl=t.rtl}};class Popups extends e{constructor(t){super(t),this.dom=o();let{getActions:e=()=>{}}=t;this.state={modals:[]},e({removeModal:this.removeModal.bind(this),addModal:this.addModal.bind(this),getModals:()=>[...this.state.modals]})}change(t){let{onChange:e=()=>{}}=this.props;for(let o in t)this.state[o]=t[o];this.setState(t,()=>e({...this.state}))}addModal(t,e=!0){if("object"!=typeof t){console.error("aio-popup => addModal modal parameter to add is not an object");return}if(void 0===t.id){console.error("aio-popup => addModal missing modal id property");return}let{modals:o}=this.state,i=o.filter(({id:e})=>e!==t.id);i.push({...t,mounted:"popover"!==t.position&&!e}),this.change({modals:i})}async removeModal(t="last",e=!0){if("all"===t)this.change({modals:[]});else{let{modals:o}=this.state;if(!o.length)return;"last"===t&&(t=o[o.length-1].id),this.mount(t,!1),setTimeout(()=>{let{modals:e}=this.state,o=e.find(e=>e.id===t);o&&(o.onClose&&o.onClose(),this.change({modals:e.filter(e=>e.id!==t)}))},e?300:0)}}mount(t="last",e){try{let{modals:o}=this.state;"last"===t&&(t=o[o.length-1].id);let i=o.map(o=>o.id===t?{...o,mounted:e}:o);this.change({modals:i})}catch{return}}getModals(){let{modals:t}=this.state;return t.length?t.map((e,o)=>{let{popover:i,position:s,text:r,onSubmit:a,rtl:l=this.props.rtl,attrs:n={},backdrop:p,header:d,state:m,footer:u,closeType:_,body:c,id:$,mounted:g}=e;return h(Popup,{id:$,backdrop:p,footer:u,text:r,onSubmit:a,header:d,popover:i,state:m,position:s,rtl:l,attrs:n,closeType:_,body:c,index:o,isLast:o===t.length-1,mounted:g,onClose:()=>this.removeModal($),removeModal:this.removeModal.bind(this),onMount:()=>this.mount($,!0)},$)}):null}render(){return h(m,{children:this.getModals()})}}class Popup extends e{constructor(t){super(t),this.dom=o(),this.backdropDom=o(),this.state={popoverStyle:void 0,state:t.state}}async onClose(t){let{onClose:e}=this.props;e(t)}componentWillUnmount(){d(window).unbind("click",this.handleBackClick)}updatePopoverStyle(){let{position:t}=this.props;if("popover"===t){let e=this.getPopoverStyle();JSON.stringify(e)!==JSON.stringify(this.state.popoverStyle)&&this.setState({popoverStyle:e})}}componentDidMount(){let{popover:t={},position:e}=this.props;if(setTimeout(()=>{let{mounted:t,onMount:o}=this.props;this.setState({popoverStyle:"popover"===e?this.getPopoverStyle():{}}),t||o()},0),t.getTarget){this.dui="a"+Math.round(1e7*Math.random());t.getTarget().attr("data-uniq-id",this.dui)}d(window).unbind("click",this.handleBackClick),d(window).bind("click",d.proxy(this.handleBackClick,this))}handleBackClick(t){if(!this.dui)return;let{position:e="fullscreen"}=this.props,o=d(t.target);"popover"===e&&o.attr("data-uniq-id")!==this.dui&&!o.parents(`[data-uniq-id=${this.dui}]`).length&&this.onClose()}header_layout(){let{rtl:t,header:e}=this.props;if("object"!=typeof e)return!1;let{state:o}=this.state;return{html:h(ModalHeader,{rtl:t,header:e,handleClose:t=>this.onClose(t),state:o,setState:t=>this.setState({state:t})}),className:"of-visible"}}body_layout(){let{body:t={}}=this.props,{state:e}=this.state;return{flex:1,html:h(ModalBody,{body:t,state:e,setState:t=>this.setState({state:t}),handleClose:this.onClose.bind(this),updatePopoverStyle:()=>this.updatePopoverStyle()})}}footer_layout(){let{closeText:t,submitText:e,onSubmit:o,footer:i,type:s}=this.props,{state:r}=this.state,a=this.onClose.bind(this);return{html:h(ModalFooter,{closeText:t,submitText:e,onSubmit:o,footer:i,type:s,handleClose:a,state:r,setState:t=>this.setState({state:t})})}}getBackDropClassName(){let{rtl:t,position:e="fullscreen",backdrop:o,mounted:i}=this.props,s="aio-popup-backdrop";return o&&o.attrs&&o.attrs.className&&(s+=" "+o.attrs.className),s+=` aio-popup-position-${e}`,s+=t?" rtl":" ltr",i||(s+=" not-mounted"),s}backClick(t){if(this.isDown)return;t.stopPropagation();let e=d(t.target),{backdrop:o={}}=this.props;!1!==o.close&&e.hasClass("aio-popup-backdrop")&&this.onClose()}getPopoverStyle(){let{popover:t={},rtl:e,attrs:o={}}=this.props,{getTarget:i,pageSelector:s,fitHorizontal:r,fixStyle:a=t=>t}=t;if(!i)return{};let l=i();if(!l||!l.length)return{};let n=d(this.dom.current);return{...Align(n,l,{fixStyle:a,pageSelector:s,fitHorizontal:r,style:o.style,rtl:e}),position:"absolute"}}keyDown(t){let{isLast:e,removeModal:o}=this.props;if(e)27===t.keyCode&&o()}mouseUp(){setTimeout(()=>this.isDown=!1,0)}mouseDown(t){d(window).unbind("mouseup",this.mouseUp),d(window).bind("mouseup",d.proxy(this.mouseUp,this)),this.isDown=!0}render(){let{rtl:t,attrs:e={},backdrop:o={},mounted:i}=this.props,{popoverStyle:s}=this.state,r={...o?o.attrs:{},className:this.getBackDropClassName(),onClick:!1===o?void 0:t=>this.backClick(t)},a={...s,...e.style,flex:"none"},l="aio-popup"+(t?" rtl":" ltr")+(i?"":" not-mounted")+(e.className?" "+e.className:""),n="ontouchstart"in document.documentElement?"onTouchStart":"onMouseDown";return h("div",{...r,ref:this.backdropDom,onKeyDown:this.keyDown.bind(this),tabIndex:0,children:h(p,{layout:{attrs:{...e,ref:this.dom,style:void 0,className:void 0,"data-uniq-id":this.dui,[n]:this.mouseDown.bind(this)},className:l,style:a,column:[this.header_layout(),this.body_layout(),this.footer_layout()]}})})}}function ModalHeader({rtl:t,header:e,handleClose:o,state:i,setState:s}){if("object"!=typeof e)return null;let{title:d,subtitle:m,buttons:u=[],onClose:_,backButton:c,attrs:$={}}=e;function g(){_?_({state:i,setState:s}):o({state:i,setState:s})}let f="aio-popup-header"+($.className?" "+$.className:""),v=$.style;return h(p,{layout:{attrs:$,className:f,style:v,row:[function e(){if(!c||!1===_)return!1;let o,i;return t?(o=l,i={marginLeft:12}):(o=n,i={marginRight:12}),{html:h(r,{path:o,size:1}),align:"vh",onClick:()=>g(),style:i}}(),!!d&&(m?{flex:1,align:"v",column:[{html:d,className:"aio-popup-title"},{html:m,className:"aio-popup-subtitle"}]}:{flex:1,align:"v",html:d,className:"aio-popup-title"}),!!u.length&&{gap:6,align:"vh",row:()=>u.map(([t,e={}])=>{let{onClick:r=()=>{},className:a}=e,l={...e};return l.className="aio-popup-header-button"+(a?" "+a:""),l.onClick=()=>r({close:o,state:i,setState:s}),{html:h("button",{...l,children:t}),align:"vh"}})},!c&&!1!==_&&{html:h(r,{path:a,size:.8}),align:"vh",onClick:()=>g(),className:"aio-popup-header-close-button"}]}})}function ModalBody(t){let{handleClose:e,body:o,updatePopoverStyle:s,state:r,setState:a}=t,{render:l,attrs:n={}}=o,p="function"==typeof l?l({close:e,state:r,setState:a}):l;return i(()=>{s()},[p]),h("div",{...n,className:"aio-popup-body"+(n.className?" "+n.className:""),children:"function"==typeof l&&p})}function ModalFooter({footer:t,handleClose:e,state:o,setState:i}){if("object"!=typeof t)return null;let{attrs:s={},buttons:r=[]}=t,a;return h("div",{className:"aio-popup-footer"+(s.className?" "+s.className:""),style:s.style,children:r.length?r.map(([t,s={}])=>{let r="function"==typeof s?{...s({state:o,setState:i})}:{...s},{onClick:a=()=>{},className:l}=r;return r.className="aio-popup-footer-button"+(l?" "+l:""),r.onClick=()=>a({close:e,state:o,setState:i}),h("button",{...r,children:t})}):null})}function Alert(t={}){let{icon:e,type:o,text:i,subtext:r,time:a,className:l,closeText:n}=t,p={time:0,getId:()=>"aa"+Math.round(1e8*Math.random()),getBarRender:()=>`<div class='aio-popup-time-bar' style="width:${p.time}%;"></div>`,updateBarRender(){d(`.aio-popup-alert-container.${p.id} .aio-popup-time`).html(p.getBarRender())},getRender:()=>`
|
|
1
|
+
function _defineProperty(t,e,o){return(e=_toPropertyKey(e))in t?Object.defineProperty(t,e,{value:o,enumerable:!0,configurable:!0,writable:!0}):t[e]=o,t}function _toPropertyKey(t){var e=_toPrimitive(t,"string");return"symbol"==typeof e?e:String(e)}function _toPrimitive(t,e){if("object"!=typeof t||null===t)return t;var o=t[Symbol.toPrimitive];if(void 0!==o){var i=o.call(t,e||"default");if("object"!=typeof i)return i;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}import t,{Component as e,createRef as o,useEffect as i}from"react";import*as s from"react-dom/server";import{Icon as r}from"@mdi/react";import{mdiClose as a,mdiChevronRight as l,mdiChevronLeft as n}from"@mdi/js";import p from"react-virtual-dom";import d from"jquery";import"./index.css";import{jsx as h}from"react/jsx-runtime";import{Fragment as m}from"react/jsx-runtime";import{jsxs as u}from"react/jsx-runtime";export default class c{constructor(t={}){_defineProperty(this,"render",()=>u(m,{children:[h(Popups,{rtl:this.rtl,getActions:({addModal:t,removeModal:e,getModals:o})=>{this._addModal=t,this._removeModal=e,this._getModals=o}}),h(AIOSnackeBar,{rtl:this.rtl,getActions:({add:t})=>{this._addSnakebar=t}})]})),_defineProperty(this,"getModals",()=>this._getModals()),_defineProperty(this,"addModal",(t={},e=!0)=>{void 0===t.id&&(t.id="popup"+Math.round(1e6*Math.random())),this._addModal(t,e)}),_defineProperty(this,"addConfirm",t=>{let{title:e,subtitle:o,text:i,submitText:s="بله",canselText:r="خیر",onSubmit:a,onCansel:l=()=>{}}=t,n={position:"center",attrs:{className:"aio-popup-confirm"},header:{title:e,subtitle:o},backdrop:{attrs:{className:"rsa-backdrop"}},body:{render:()=>i},footer:{buttons:[[r,{onClick:()=>{l(),this.removeModal()}}],[s,{onClick:async()=>{!1!==await a()&&this.removeModal()},className:"active"}]]}};this.addModal(n)}),_defineProperty(this,"addPrompt",t=>{let{title:e,subtitle:o,text:i,submitText:s="تایید",canselText:r="بستن",onSubmit:a,onCansel:l=()=>{}}=t,n={position:"center",attrs:{className:"aio-popup-prompt"},state:{temp:""},header:{title:e,subtitle:o},backdrop:{attrs:{className:"rsa-backdrop"}},body:{render:({state:t,setState:e})=>h("textarea",{placeholder:i,value:t.temp,onChange:t=>e({temp:t.target.value})})},footer:{buttons:[[r,{onClick:()=>{l(),this.removeModal()}}],[s,({state:t,setState:e})=>({onClick:async({state:t})=>{!1!==await a(t.temp)?this.removeModal():e({temp:""})},disabled:!t.temp,className:"active"})]]}};this.addModal(n)}),_defineProperty(this,"removeModal",(t,e=!0)=>{this._removeModal&&this._removeModal(t,e)}),_defineProperty(this,"addAlert",(t={})=>{let{icon:e,type:o="",text:i="",subtext:s="",time:r=10,className:a,closeText:l="بستن"}=t;Alert({icon:e,type:o,text:i,subtext:s,time:r,className:a,closeText:l})}),_defineProperty(this,"addSnakebar",(t={})=>{let{text:e,index:o,type:i,subtext:s,action:r={},time:a=6,rtl:l,onClose:n}=t;this._addSnakebar({text:e,index:o,type:i,subtext:s,action:r,time:a,rtl:l,onClose:n})}),this.rtl=t.rtl}};class Popups extends e{constructor(t){super(t),this.dom=o();let{getActions:e=()=>{}}=t;this.state={modals:[]},e({removeModal:this.removeModal.bind(this),addModal:this.addModal.bind(this),getModals:()=>[...this.state.modals]})}change(t){let{onChange:e=()=>{}}=this.props;for(let o in t)this.state[o]=t[o];this.setState(t,()=>e({...this.state}))}addModal(t,e=!0){if("object"!=typeof t){console.error("aio-popup => addModal modal parameter to add is not an object");return}if(void 0===t.id){console.error("aio-popup => addModal missing modal id property");return}let{modals:o}=this.state,i=o.filter(({id:e})=>e!==t.id);i.push({...t,mounted:"popover"!==t.position&&!e}),this.change({modals:i})}async removeModal(t="last",e=!0){if("all"===t)this.change({modals:[]});else{let{modals:o}=this.state;if(!o.length)return;"last"===t&&(t=o[o.length-1].id),this.mount(t,!1),setTimeout(()=>{let{modals:e}=this.state,o=e.find(e=>e.id===t);o&&(o.onClose&&o.onClose(),this.change({modals:e.filter(e=>e.id!==t)}))},e?300:0)}}mount(t="last",e){try{let{modals:o}=this.state;"last"===t&&(t=o[o.length-1].id);let i=o.map(o=>o.id===t?{...o,mounted:e}:o);this.change({modals:i})}catch{return}}getModals(){let{modals:t}=this.state;return t.length?t.map((e,o)=>{let{popover:i,position:s,text:r,onSubmit:a,rtl:l=this.props.rtl,attrs:n={},backdrop:p,header:d,state:m,footer:u,closeType:c,body:_,id:$,mounted:f}=e;return h(Popup,{id:$,backdrop:p,footer:u,text:r,onSubmit:a,header:d,popover:i,state:m,position:s,rtl:l,attrs:n,closeType:c,body:_,index:o,isLast:o===t.length-1,mounted:f,onClose:()=>this.removeModal($),removeModal:this.removeModal.bind(this),onMount:()=>this.mount($,!0)},$)}):null}render(){return h(m,{children:this.getModals()})}}class Popup extends e{constructor(t){super(t),this.dom=o(),this.backdropDom=o(),this.state={popoverStyle:void 0,state:t.state}}async onClose(t){let{onClose:e}=this.props;e(t)}componentWillUnmount(){d(window).unbind("click",this.handleBackClick)}updatePopoverStyle(){let{position:t}=this.props;if("popover"===t){let e=this.getPopoverStyle();JSON.stringify(e)!==JSON.stringify(this.state.popoverStyle)&&this.setState({popoverStyle:e})}}componentDidMount(){let{popover:t={},position:e}=this.props;if(setTimeout(()=>{let{mounted:t,onMount:o}=this.props;this.setState({popoverStyle:"popover"===e?this.getPopoverStyle():{}}),t||o()},0),t.getTarget){this.dui="a"+Math.round(1e7*Math.random());t.getTarget().attr("data-uniq-id",this.dui)}d(window).unbind("click",this.handleBackClick),d(window).bind("click",d.proxy(this.handleBackClick,this))}handleBackClick(t){if(!this.dui)return;let{position:e="fullscreen"}=this.props,o=d(t.target);"popover"===e&&o.attr("data-uniq-id")!==this.dui&&!o.parents(`[data-uniq-id=${this.dui}]`).length&&this.onClose()}header_layout(){let{rtl:t,header:e}=this.props;if("object"!=typeof e)return!1;let{state:o}=this.state;return{html:h(ModalHeader,{rtl:t,header:e,handleClose:t=>this.onClose(t),state:o,setState:t=>this.setState({state:t})}),className:"of-visible"}}body_layout(){let{body:t={}}=this.props,{state:e}=this.state;return{flex:1,html:h(ModalBody,{body:t,state:e,setState:t=>this.setState({state:t}),handleClose:this.onClose.bind(this),updatePopoverStyle:()=>this.updatePopoverStyle()})}}footer_layout(){let{closeText:t,submitText:e,onSubmit:o,footer:i,type:s}=this.props,{state:r}=this.state,a=this.onClose.bind(this);return{html:h(ModalFooter,{closeText:t,submitText:e,onSubmit:o,footer:i,type:s,handleClose:a,state:r,setState:t=>this.setState({state:t})})}}getBackDropClassName(){let{rtl:t,position:e="fullscreen",backdrop:o,mounted:i}=this.props,s="aio-popup-backdrop";return o&&o.attrs&&o.attrs.className&&(s+=" "+o.attrs.className),s+=` aio-popup-position-${e}`,s+=t?" rtl":" ltr",i||(s+=" not-mounted"),s}backClick(t){if(this.isDown)return;t.stopPropagation();let e=d(t.target),{backdrop:o={}}=this.props;!1!==o.close&&e.hasClass("aio-popup-backdrop")&&this.onClose()}getPopoverStyle(){let{popover:t={},rtl:e,attrs:o={}}=this.props,{getTarget:i,pageSelector:s,fitHorizontal:r,fixStyle:a=t=>t}=t;if(!i)return{};let l=i();if(!l||!l.length)return{};let n=d(this.dom.current);return{...Align(n,l,{fixStyle:a,pageSelector:s,fitHorizontal:r,style:o.style,rtl:e}),position:"absolute"}}keyDown(t){let{isLast:e,removeModal:o}=this.props;if(e)27===t.keyCode&&o()}mouseUp(){setTimeout(()=>this.isDown=!1,0)}mouseDown(t){d(window).unbind("mouseup",this.mouseUp),d(window).bind("mouseup",d.proxy(this.mouseUp,this)),this.isDown=!0}render(){let{rtl:t,attrs:e={},backdrop:o={},mounted:i}=this.props,{popoverStyle:s}=this.state,r={...o?o.attrs:{},className:this.getBackDropClassName(),onClick:!1===o?void 0:t=>this.backClick(t)},a={...s,...e.style,flex:"none"},l="aio-popup"+(t?" rtl":" ltr")+(i?"":" not-mounted")+(e.className?" "+e.className:""),n="ontouchstart"in document.documentElement?"onTouchStart":"onMouseDown";return h("div",{...r,ref:this.backdropDom,onKeyDown:this.keyDown.bind(this),tabIndex:0,children:h(p,{layout:{attrs:{...e,ref:this.dom,style:void 0,className:void 0,"data-uniq-id":this.dui,[n]:this.mouseDown.bind(this)},className:l,style:a,column:[this.header_layout(),this.body_layout(),this.footer_layout()]}})})}}function ModalHeader({rtl:t,header:e,handleClose:o,state:i,setState:s}){if("object"!=typeof e)return null;let{title:d,subtitle:m,buttons:u=[],onClose:c,backButton:_,attrs:$={}}=e;function f(){c?c({state:i,setState:s}):o({state:i,setState:s})}let g="aio-popup-header"+($.className?" "+$.className:""),v=$.style;return h(p,{layout:{attrs:$,className:g,style:v,row:[function e(){if(!_||!1===c)return!1;let o,i;return t?(o=l,i={marginLeft:12}):(o=n,i={marginRight:12}),{html:h(r,{path:o,size:1}),align:"vh",onClick:()=>f(),style:i}}(),!!d&&(m?{flex:1,align:"v",column:[{html:d,className:"aio-popup-title"},{html:m,className:"aio-popup-subtitle"}]}:{flex:1,align:"v",html:d,className:"aio-popup-title"}),!!u.length&&{gap:6,align:"vh",row:()=>u.map(([t,e={}])=>{let{onClick:r=()=>{},className:a}=e,l={...e};return l.className="aio-popup-header-button"+(a?" "+a:""),l.onClick=()=>r({close:o,state:i,setState:s}),{html:h("button",{...l,children:t}),align:"vh"}})},!_&&!1!==c&&{html:h(r,{path:a,size:.8}),align:"vh",onClick:()=>f(),className:"aio-popup-header-close-button"}]}})}function ModalBody(t){let{handleClose:e,body:o,updatePopoverStyle:s,state:r,setState:a}=t,{render:l,attrs:n={}}=o,p="function"==typeof l?l({close:e,state:r,setState:a}):l;return i(()=>{s()},[p]),h("div",{...n,className:"aio-popup-body"+(n.className?" "+n.className:""),children:"function"==typeof l&&p})}function ModalFooter({footer:t,handleClose:e,state:o,setState:i}){if("object"!=typeof t)return null;let{attrs:s={},buttons:r=[]}=t,a;return h("div",{className:"aio-popup-footer"+(s.className?" "+s.className:""),style:s.style,children:r.length?r.map(([t,s={}])=>{let r="function"==typeof s?{...s({state:o,setState:i})}:{...s},{onClick:a=()=>{},className:l}=r;return r.className="aio-popup-footer-button"+(l?" "+l:""),r.onClick=()=>a({close:e,state:o,setState:i}),h("button",{...r,children:t})}):null})}function Alert(t={}){let{icon:e,type:o,text:i,subtext:r,time:a,className:l,closeText:n}=t,p={time:0,getId:()=>"aa"+Math.round(1e8*Math.random()),getBarRender:()=>`<div class='aio-popup-time-bar' style="width:${p.time}%;"></div>`,updateBarRender(){d(`.aio-popup-alert-container.${p.id} .aio-popup-time`).html(p.getBarRender())},getRender:()=>`
|
|
2
2
|
<div class='aio-popup-alert-container ${p.id}${l?"aio-popup"+l:""}'>
|
|
3
3
|
<div class='aio-popup-alert aio-popup-alert-${o}'>
|
|
4
4
|
<div class='aio-popup-alert-header'>${p.getIcon()}</div>
|
|
@@ -12,4 +12,4 @@ function _defineProperty(t,e,o){return(e=_toPropertyKey(e))in t?Object.definePro
|
|
|
12
12
|
<div class='aio-popup-time'></div>
|
|
13
13
|
</div>
|
|
14
14
|
</div>
|
|
15
|
-
`,close(){d("."+p.id).remove()},getIcon:()=>!1===e?"":e||({error:'<svg viewBox="0 0 24 24" role="presentation" style="width: 4.5rem; height: 4.5rem;"><path d="M19,6.41L17.59,5L12,10.59L6.41,5L5,6.41L10.59,12L5,17.59L6.41,19L12,13.41L17.59,19L19,17.59L13.41,12L19,6.41Z"></path></svg>',warning:'<svg viewBox="0 0 24 24" role="presentation" style="width: 4.5rem; height: 4.5rem;"><path d="M12,2L1,21H23M12,6L19.53,19H4.47M11,10V14H13V10M11,16V18H13V16"></path></svg>',info:'<svg viewBox="0 0 24 24" role="presentation" style="width: 4.5rem; height: 4.5rem;"><path d="M11,9H13V7H11M12,20C7.59,20 4,16.41 4,12C4,7.59 7.59,4 12,4C16.41,4 20,7.59 20,12C20,16.41 16.41,20 12,20M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2M11,17H13V11H11V17Z"></path></svg>',success:'<svg viewBox="0 0 24 24" role="presentation" style="width: 4.5rem; height: 4.5rem;"><path d="M12 2C6.5 2 2 6.5 2 12S6.5 22 12 22 22 17.5 22 12 17.5 2 12 2M12 20C7.59 20 4 16.41 4 12S7.59 4 12 4 20 7.59 20 12 16.41 20 12 20M16.59 7.58L10 14.17L7.41 11.59L6 13L10 17L18 9L16.59 7.58Z"></path></svg>'})[o]||"",startTimer(){setTimeout(()=>{if(p.time>=100){p.time=100,p.close();return}p.time+=2,p.updateBarRender(),p.startTimer()},a/50*1e3)},render(){d("body").append(p.getRender()),d("button."+p.id).off("click",p.close),d("button."+p.id).on("click",p.close)}};p.id=p.getId(),p.render(),a&&p.startTimer()}class AIOSnackeBar extends e{constructor(t){super(t),this.state={items:[]},t.getActions({add:this.add.bind(this)})}add(t){let{items:e}=this.state;this.setState({items:e.concat({...t,id:"a"+Math.round(1e9*Math.random())})})}remove(t){let{items:e}=this.state;this.setState({items:e.filter((e,o)=>e.id!==t)})}render(){let{items:t}=this.state,{rtl:e=!1}=this.props;return h(m,{children:t.map((t,o)=>h(SnackebarItem,{rtl:e,...t,index:o,onRemove:t=>this.remove(t)},t.id))})}}class SnackebarItem extends e{constructor(t){super(t),this.state={mounted:!1,timer:0,bottom:0}}componentDidMount(){let{time:t=8}=this.props;setTimeout(()=>this.setState({mounted:!0}),0),setTimeout(()=>this.remove(),1e3*t)}remove(){let{onRemove:
|
|
15
|
+
`,close(){d("."+p.id).remove()},getIcon:()=>!1===e?"":e||({error:'<svg viewBox="0 0 24 24" role="presentation" style="width: 4.5rem; height: 4.5rem;"><path d="M19,6.41L17.59,5L12,10.59L6.41,5L5,6.41L10.59,12L5,17.59L6.41,19L12,13.41L17.59,19L19,17.59L13.41,12L19,6.41Z"></path></svg>',warning:'<svg viewBox="0 0 24 24" role="presentation" style="width: 4.5rem; height: 4.5rem;"><path d="M12,2L1,21H23M12,6L19.53,19H4.47M11,10V14H13V10M11,16V18H13V16"></path></svg>',info:'<svg viewBox="0 0 24 24" role="presentation" style="width: 4.5rem; height: 4.5rem;"><path d="M11,9H13V7H11M12,20C7.59,20 4,16.41 4,12C4,7.59 7.59,4 12,4C16.41,4 20,7.59 20,12C20,16.41 16.41,20 12,20M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2M11,17H13V11H11V17Z"></path></svg>',success:'<svg viewBox="0 0 24 24" role="presentation" style="width: 4.5rem; height: 4.5rem;"><path d="M12 2C6.5 2 2 6.5 2 12S6.5 22 12 22 22 17.5 22 12 17.5 2 12 2M12 20C7.59 20 4 16.41 4 12S7.59 4 12 4 20 7.59 20 12 16.41 20 12 20M16.59 7.58L10 14.17L7.41 11.59L6 13L10 17L18 9L16.59 7.58Z"></path></svg>'})[o]||"",startTimer(){setTimeout(()=>{if(p.time>=100){p.time=100,p.close();return}p.time+=2,p.updateBarRender(),p.startTimer()},a/50*1e3)},render(){d("body").append(p.getRender()),d("button."+p.id).off("click",p.close),d("button."+p.id).on("click",p.close)}};p.id=p.getId(),p.render(),a&&p.startTimer()}class AIOSnackeBar extends e{constructor(t){super(t),this.state={items:[]},t.getActions({add:this.add.bind(this)})}add(t){let{items:e}=this.state;this.setState({items:e.concat({...t,id:"a"+Math.round(1e9*Math.random())})})}remove(t){let{items:e}=this.state;this.setState({items:e.filter((e,o)=>e.id!==t)})}render(){let{items:t}=this.state,{rtl:e=!1}=this.props;return h(m,{children:t.map((t,o)=>h(SnackebarItem,{rtl:e,...t,index:o,onRemove:t=>this.remove(t)},t.id))})}}class SnackebarItem extends e{constructor(t){super(t),this.state={mounted:!1,timer:0,bottom:0}}componentDidMount(){let{time:t=8}=this.props;setTimeout(()=>this.setState({mounted:!0}),0),setTimeout(()=>this.remove(),1e3*t)}remove(t){let{onRemove:e,id:o}=this.props;this.setState({mounted:!1}),setTimeout(()=>{e(o),"function"==typeof t&&t()},200)}info_svg(){return h("svg",{viewBox:"0 0 24 24",role:"presentation",style:{width:"1.2rem",height:"1.2rem"},children:h("path",{d:"M11,9H13V7H11M12,20C7.59,20 4,16.41 4,12C4,7.59 7.59,4 12,4C16.41,4 20,7.59 20,12C20,16.41 16.41,20 12,20M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2M11,17H13V11H11V17Z",style:{fill:"currentcolor"}})})}success_svg(){return h("svg",{viewBox:"0 0 24 24",role:"presentation",style:{width:"1.2rem",height:"1.2rem"},children:h("path",{d:"M12 2C6.5 2 2 6.5 2 12S6.5 22 12 22 22 17.5 22 12 17.5 2 12 2M12 20C7.59 20 4 16.41 4 12S7.59 4 12 4 20 7.59 20 12 16.41 20 12 20M16.59 7.58L10 14.17L7.41 11.59L6 13L10 17L18 9L16.59 7.58Z",style:{fill:"currentcolor"}})})}getSvg(t){return"error"===t||"warning"===t||"info"===t?this.info_svg():this.success_svg()}getBottom(t){let e=d(".aio-popup-snakebar-item-container"),o=12;for(let i=0;i<t;i++)o+=e.eq(i).height()+6;return o}render(){let{mounted:t}=this.state,{text:e,index:o,type:i,subtext:s,action:r,time:a,rtl:l,onClose:n}=this.props,p=this.getBottom(o);return h("div",{onClick:!1===n?void 0:()=>this.remove(n),className:"aio-popup-snakebar-item-container"+(t?" mounted":""),style:{bottom:p,direction:l?"rtl":void 0},children:u("div",{className:`aio-popup-snakebar-item aio-popup-snakebar-item-${i}`,children:[h("div",{className:"aio-popup-snakebar-item-icon",children:this.getSvg(i)}),u("div",{className:"aio-popup-snakebar-item-text",children:[h("div",{style:{textAlign:l?"right":"left"},children:e}),!!s&&h("div",{className:"aio-popup-snakebar-item-subtext",children:s})]}),!!r.text&&h("button",{className:"aio-popup-snakebar-item-action",onClick:t=>{t.stopPropagation(),r.onClick(),this.remove()},children:r.text}),h("div",{className:"aio-popup-snakebar-bar",style:{transition:`${a}s linear`,right:l?0:"unset",left:l?"unset":0}})]})})}}function Align(t,e,o={}){let{fitHorizontal:i,style:s,fixStyle:r=t=>t,pageSelector:a,rtl:l}=o,n={getDomLimit(t,e){let o=t.offset(),i=o.left-window.pageXOffset,s=o.top-window.pageYOffset;if(a&&"page"!==e){let r=d(a);try{let{left:l,top:n}=r.offset();i-=l,s-=n}catch{}}let p=t.outerWidth(),h=t.outerHeight(),m=i+p,u=s+h;return{left:i,top:s,right:m,bottom:u,width:p,height:h}},getPageLimit(t){let e=a?d(a):void 0;e=Array.isArray(e)&&0===e.length?void 0:e;let o=window.innerWidth,i=window.innerHeight,s=e?n.getDomLimit(e,"page"):{left:0,top:0,right:o,bottom:i};return s.left<0&&(s.left=0),s.right>o&&(s.right=o),s.top<0&&(s.top=0),s.bottom>i&&(s.bottom=i),s},align(){let o=n.getPageLimit(t),a=n.getDomLimit(e,"target"),p=n.getDomLimit(t,"popover");p.top=a.bottom,p.bottom=p.top+p.height,i?(p.width=a.width,p.left=a.left,p.right=a.left+a.width):l?(p.right=a.right,p.left=p.right-p.width,p.left<o.left&&(p.left=o.left)):(p.left=a.left,p.right=p.left+p.width,p.right>o.right&&(p.left=o.right-p.width)),p.bottom>o.bottom?p.height>a.top-o.top?p.top=o.bottom-p.height:p.top=a.top-p.height:p.top=a.bottom;let d;p.height>o.bottom-o.top&&(p.top=6,p.bottom=void 0,p.height=o.bottom-o.top-12,d="auto");let h={left:p.left,top:p.top,width:p.width,overflowY:d,...s};return r(h,{targetLimit:a,pageLimit:o})}};return n.align()}
|