@abpjs/theme-shared 1.0.0 → 2.0.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/dist/components/confirmation/Confirmation.d.ts +2 -0
- package/dist/components/loader-bar/LoaderBar.d.ts +13 -1
- package/dist/components/toast/Toast.d.ts +11 -1
- package/dist/constants/styles.d.ts +6 -1
- package/dist/contexts/confirmation.context.d.ts +79 -25
- package/dist/contexts/toaster.context.d.ts +89 -18
- package/dist/index.d.ts +20 -1
- package/dist/index.js +246 -77
- package/dist/index.mjs +264 -91
- package/dist/models/common.d.ts +42 -0
- package/dist/models/confirmation.d.ts +40 -7
- package/dist/models/index.d.ts +1 -0
- package/dist/models/toaster.d.ts +56 -10
- package/package.json +6 -5
package/dist/index.mjs
CHANGED
|
@@ -36,25 +36,114 @@ var DEFAULT_STYLES = `
|
|
|
36
36
|
top: 18px;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
.
|
|
40
|
-
|
|
39
|
+
.navbar .dropdown-menu {
|
|
40
|
+
min-width: 215px;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
.
|
|
43
|
+
.ui-table-scrollable-body::-webkit-scrollbar {
|
|
44
|
+
height: 5px !important;
|
|
45
|
+
width: 5px !important;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.ui-table-scrollable-body::-webkit-scrollbar-track {
|
|
49
|
+
background: #ddd;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.ui-table-scrollable-body::-webkit-scrollbar-thumb {
|
|
53
|
+
background: #8a8686;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.abp-ellipsis-inline {
|
|
44
57
|
display: inline-block;
|
|
45
58
|
overflow: hidden;
|
|
46
59
|
text-overflow: ellipsis;
|
|
47
60
|
white-space: nowrap;
|
|
48
61
|
}
|
|
49
62
|
|
|
63
|
+
.abp-ellipsis {
|
|
64
|
+
overflow: hidden !important;
|
|
65
|
+
text-overflow: ellipsis;
|
|
66
|
+
white-space: nowrap;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.ui-widget-overlay {
|
|
70
|
+
z-index: 1000;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.color-white {
|
|
74
|
+
color: #FFF !important;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.custom-checkbox > label {
|
|
78
|
+
cursor: pointer;
|
|
79
|
+
}
|
|
80
|
+
|
|
50
81
|
/* <animations */
|
|
51
82
|
|
|
52
83
|
.fade-in-top {
|
|
53
|
-
animation: fadeInTop 0.
|
|
84
|
+
animation: fadeInTop 0.2s ease-in-out;
|
|
54
85
|
}
|
|
55
86
|
|
|
56
87
|
.fade-out-top {
|
|
57
|
-
animation: fadeOutTop 0.
|
|
88
|
+
animation: fadeOutTop 0.2s ease-in-out;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.abp-collapsed-height {
|
|
92
|
+
-moz-transition: max-height linear 0.35s;
|
|
93
|
+
-ms-transition: max-height linear 0.35s;
|
|
94
|
+
-o-transition: max-height linear 0.35s;
|
|
95
|
+
-webkit-transition: max-height linear 0.35s;
|
|
96
|
+
overflow:hidden;
|
|
97
|
+
transition:max-height 0.35s linear;
|
|
98
|
+
height:auto;
|
|
99
|
+
max-height: 0;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.abp-mh-25 {
|
|
103
|
+
max-height: 25vh;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.abp-mh-50 {
|
|
107
|
+
transition:max-height 0.65s linear;
|
|
108
|
+
max-height: 50vh;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
.abp-mh-75 {
|
|
112
|
+
transition:max-height 0.85s linear;
|
|
113
|
+
max-height: 75vh;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
.abp-mh-100 {
|
|
117
|
+
transition:max-height 1s linear;
|
|
118
|
+
max-height: 100vh;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/* Sorting icon styles - @since 2.0.0 */
|
|
122
|
+
[class^="sorting"] {
|
|
123
|
+
opacity: .3;
|
|
124
|
+
cursor: pointer;
|
|
125
|
+
}
|
|
126
|
+
[class^="sorting"]:before {
|
|
127
|
+
right: 0.5rem;
|
|
128
|
+
content: "\u2191";
|
|
129
|
+
}
|
|
130
|
+
[class^="sorting"]:after {
|
|
131
|
+
right: 0.5rem;
|
|
132
|
+
content: "\u2193";
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
.sorting_desc {
|
|
136
|
+
opacity: 1;
|
|
137
|
+
}
|
|
138
|
+
.sorting_desc:before {
|
|
139
|
+
opacity: .3;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
.sorting_asc {
|
|
143
|
+
opacity: 1;
|
|
144
|
+
}
|
|
145
|
+
.sorting_asc:after {
|
|
146
|
+
opacity: .3;
|
|
58
147
|
}
|
|
59
148
|
|
|
60
149
|
@keyframes fadeInTop {
|
|
@@ -64,7 +153,7 @@ var DEFAULT_STYLES = `
|
|
|
64
153
|
}
|
|
65
154
|
|
|
66
155
|
to {
|
|
67
|
-
transform: translateY(
|
|
156
|
+
transform: translateY(0px);
|
|
68
157
|
opacity: 1;
|
|
69
158
|
}
|
|
70
159
|
}
|
|
@@ -104,37 +193,41 @@ import {
|
|
|
104
193
|
useCallback,
|
|
105
194
|
useState,
|
|
106
195
|
useRef,
|
|
107
|
-
useMemo
|
|
196
|
+
useMemo,
|
|
197
|
+
useEffect
|
|
108
198
|
} from "react";
|
|
109
199
|
import { jsx } from "react/jsx-runtime";
|
|
110
200
|
var ToasterContext = createContext(null);
|
|
111
201
|
var toastCounter = 0;
|
|
112
202
|
function generateId() {
|
|
113
203
|
toastCounter += 1;
|
|
114
|
-
return
|
|
204
|
+
return toastCounter;
|
|
115
205
|
}
|
|
116
206
|
var DEFAULT_LIFE = 5e3;
|
|
117
207
|
function ToasterProvider({ children }) {
|
|
118
208
|
const [toasts, setToasts] = useState([]);
|
|
119
|
-
const
|
|
209
|
+
const subscribersRef = useRef(/* @__PURE__ */ new Set());
|
|
210
|
+
useEffect(() => {
|
|
211
|
+
subscribersRef.current.forEach((subscriber) => {
|
|
212
|
+
subscriber(toasts);
|
|
213
|
+
});
|
|
214
|
+
}, [toasts]);
|
|
120
215
|
const remove = useCallback((id) => {
|
|
121
216
|
setToasts((prev) => prev.filter((t) => t.id !== id));
|
|
122
|
-
const resolver = resolversRef.current.get(id);
|
|
123
|
-
if (resolver) {
|
|
124
|
-
resolver(Toaster.Status.dismiss);
|
|
125
|
-
resolversRef.current.delete(id);
|
|
126
|
-
}
|
|
127
217
|
}, []);
|
|
128
218
|
const show = useCallback(
|
|
129
|
-
(message, title, severity, options) => {
|
|
130
|
-
const id = options?.id
|
|
219
|
+
(message, title, severity = "info", options) => {
|
|
220
|
+
const id = typeof options?.id === "number" ? options.id : generateId();
|
|
131
221
|
const life = options?.sticky ? void 0 : options?.life ?? DEFAULT_LIFE;
|
|
132
222
|
const toast = {
|
|
133
223
|
id,
|
|
134
224
|
message,
|
|
135
225
|
title,
|
|
136
226
|
severity,
|
|
137
|
-
|
|
227
|
+
options: {
|
|
228
|
+
...options,
|
|
229
|
+
id
|
|
230
|
+
}
|
|
138
231
|
};
|
|
139
232
|
setToasts((prev) => [...prev, toast]);
|
|
140
233
|
if (life) {
|
|
@@ -142,9 +235,7 @@ function ToasterProvider({ children }) {
|
|
|
142
235
|
remove(id);
|
|
143
236
|
}, life);
|
|
144
237
|
}
|
|
145
|
-
return
|
|
146
|
-
resolversRef.current.set(id, resolve);
|
|
147
|
-
});
|
|
238
|
+
return id;
|
|
148
239
|
},
|
|
149
240
|
[remove]
|
|
150
241
|
);
|
|
@@ -157,44 +248,40 @@ function ToasterProvider({ children }) {
|
|
|
157
248
|
[show]
|
|
158
249
|
);
|
|
159
250
|
const warn = useCallback(
|
|
160
|
-
(message, title, options) => show(message, title, "
|
|
251
|
+
(message, title, options) => show(message, title, "warning", options),
|
|
161
252
|
[show]
|
|
162
253
|
);
|
|
163
254
|
const error = useCallback(
|
|
164
255
|
(message, title, options) => show(message, title, "error", options),
|
|
165
256
|
[show]
|
|
166
257
|
);
|
|
167
|
-
const
|
|
168
|
-
(messages) => {
|
|
169
|
-
messages.forEach((msg) => {
|
|
170
|
-
show(msg.message, msg.title, msg.severity, msg);
|
|
171
|
-
});
|
|
172
|
-
},
|
|
173
|
-
[show]
|
|
174
|
-
);
|
|
175
|
-
const clear = useCallback((status) => {
|
|
258
|
+
const clear = useCallback((key) => {
|
|
176
259
|
setToasts((prev) => {
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
resolver(status ?? Toaster.Status.dismiss);
|
|
181
|
-
resolversRef.current.delete(toast.id);
|
|
182
|
-
}
|
|
183
|
-
});
|
|
260
|
+
if (key) {
|
|
261
|
+
return prev.filter((toast) => toast.options?.containerKey !== key);
|
|
262
|
+
}
|
|
184
263
|
return [];
|
|
185
264
|
});
|
|
186
265
|
}, []);
|
|
266
|
+
const subscribe = useCallback((subscriber) => {
|
|
267
|
+
subscribersRef.current.add(subscriber);
|
|
268
|
+
subscriber(toasts);
|
|
269
|
+
return () => {
|
|
270
|
+
subscribersRef.current.delete(subscriber);
|
|
271
|
+
};
|
|
272
|
+
}, [toasts]);
|
|
187
273
|
const service = useMemo(
|
|
188
274
|
() => ({
|
|
189
275
|
info,
|
|
190
276
|
success,
|
|
191
277
|
warn,
|
|
192
278
|
error,
|
|
193
|
-
|
|
279
|
+
show,
|
|
280
|
+
remove,
|
|
194
281
|
clear,
|
|
195
|
-
|
|
282
|
+
subscribe
|
|
196
283
|
}),
|
|
197
|
-
[info, success, warn, error,
|
|
284
|
+
[info, success, warn, error, show, remove, clear, subscribe]
|
|
198
285
|
);
|
|
199
286
|
const value = useMemo(
|
|
200
287
|
() => ({ service, toasts }),
|
|
@@ -231,7 +318,8 @@ import {
|
|
|
231
318
|
useCallback as useCallback2,
|
|
232
319
|
useState as useState2,
|
|
233
320
|
useRef as useRef2,
|
|
234
|
-
useMemo as useMemo2
|
|
321
|
+
useMemo as useMemo2,
|
|
322
|
+
useEffect as useEffect2
|
|
235
323
|
} from "react";
|
|
236
324
|
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
237
325
|
var ConfirmationContext = createContext2(null);
|
|
@@ -241,6 +329,13 @@ function generateId2() {
|
|
|
241
329
|
function ConfirmationProvider({ children }) {
|
|
242
330
|
const [confirmation, setConfirmation] = useState2(null);
|
|
243
331
|
const resolverRef = useRef2(null);
|
|
332
|
+
const subscribersRef = useRef2(/* @__PURE__ */ new Set());
|
|
333
|
+
const escapeListenerRef = useRef2(false);
|
|
334
|
+
useEffect2(() => {
|
|
335
|
+
subscribersRef.current.forEach((subscriber) => {
|
|
336
|
+
subscriber(confirmation);
|
|
337
|
+
});
|
|
338
|
+
}, [confirmation]);
|
|
244
339
|
const respond = useCallback2((status) => {
|
|
245
340
|
if (resolverRef.current) {
|
|
246
341
|
resolverRef.current(status);
|
|
@@ -248,20 +343,34 @@ function ConfirmationProvider({ children }) {
|
|
|
248
343
|
}
|
|
249
344
|
setConfirmation(null);
|
|
250
345
|
}, []);
|
|
346
|
+
useEffect2(() => {
|
|
347
|
+
if (!escapeListenerRef.current) return;
|
|
348
|
+
const handleEscape = (event) => {
|
|
349
|
+
if (event.key === "Escape" && confirmation && confirmation.options?.closable !== false) {
|
|
350
|
+
respond(Toaster.Status.dismiss);
|
|
351
|
+
}
|
|
352
|
+
};
|
|
353
|
+
document.addEventListener("keydown", handleEscape);
|
|
354
|
+
return () => {
|
|
355
|
+
document.removeEventListener("keydown", handleEscape);
|
|
356
|
+
};
|
|
357
|
+
}, [confirmation, respond]);
|
|
251
358
|
const show = useCallback2(
|
|
252
|
-
(message, title, severity, options = {}) => {
|
|
359
|
+
(message, title, severity = "neutral", options = {}) => {
|
|
253
360
|
if (resolverRef.current) {
|
|
254
361
|
resolverRef.current(Toaster.Status.dismiss);
|
|
255
362
|
}
|
|
256
363
|
const id = options.id?.toString() || generateId2();
|
|
257
|
-
const
|
|
258
|
-
id,
|
|
364
|
+
const dialogData = {
|
|
259
365
|
message,
|
|
260
366
|
title,
|
|
261
367
|
severity,
|
|
262
|
-
options
|
|
368
|
+
options: {
|
|
369
|
+
...options,
|
|
370
|
+
id
|
|
371
|
+
}
|
|
263
372
|
};
|
|
264
|
-
setConfirmation(
|
|
373
|
+
setConfirmation(dialogData);
|
|
265
374
|
return new Promise((resolve) => {
|
|
266
375
|
resolverRef.current = resolve;
|
|
267
376
|
});
|
|
@@ -277,7 +386,7 @@ function ConfirmationProvider({ children }) {
|
|
|
277
386
|
[show]
|
|
278
387
|
);
|
|
279
388
|
const warn = useCallback2(
|
|
280
|
-
(message, title, options) => show(message, title, "
|
|
389
|
+
(message, title, options) => show(message, title, "warning", options),
|
|
281
390
|
[show]
|
|
282
391
|
);
|
|
283
392
|
const error = useCallback2(
|
|
@@ -290,15 +399,28 @@ function ConfirmationProvider({ children }) {
|
|
|
290
399
|
},
|
|
291
400
|
[respond]
|
|
292
401
|
);
|
|
402
|
+
const listenToEscape = useCallback2(() => {
|
|
403
|
+
escapeListenerRef.current = true;
|
|
404
|
+
}, []);
|
|
405
|
+
const subscribe = useCallback2((subscriber) => {
|
|
406
|
+
subscribersRef.current.add(subscriber);
|
|
407
|
+
subscriber(confirmation);
|
|
408
|
+
return () => {
|
|
409
|
+
subscribersRef.current.delete(subscriber);
|
|
410
|
+
};
|
|
411
|
+
}, [confirmation]);
|
|
293
412
|
const service = useMemo2(
|
|
294
413
|
() => ({
|
|
295
414
|
info,
|
|
296
415
|
success,
|
|
297
416
|
warn,
|
|
298
417
|
error,
|
|
299
|
-
|
|
418
|
+
show,
|
|
419
|
+
clear,
|
|
420
|
+
listenToEscape,
|
|
421
|
+
subscribe
|
|
300
422
|
}),
|
|
301
|
-
[info, success, warn, error, clear]
|
|
423
|
+
[info, success, warn, error, show, clear, listenToEscape, subscribe]
|
|
302
424
|
);
|
|
303
425
|
const value = useMemo2(
|
|
304
426
|
() => ({ service, confirmation, respond }),
|
|
@@ -411,7 +533,7 @@ function isHttpErrorResponse(error) {
|
|
|
411
533
|
}
|
|
412
534
|
|
|
413
535
|
// src/components/toast/Toast.tsx
|
|
414
|
-
import { useEffect, useRef as useRef3, useMemo as useMemo3 } from "react";
|
|
536
|
+
import { useEffect as useEffect3, useRef as useRef3, useMemo as useMemo3 } from "react";
|
|
415
537
|
import {
|
|
416
538
|
Toaster as ChakraToaster,
|
|
417
539
|
Portal,
|
|
@@ -427,9 +549,15 @@ import {
|
|
|
427
549
|
CheckCircle,
|
|
428
550
|
Info,
|
|
429
551
|
AlertTriangle,
|
|
430
|
-
XCircle
|
|
552
|
+
XCircle,
|
|
553
|
+
Circle
|
|
431
554
|
} from "lucide-react";
|
|
432
555
|
import { jsx as jsx3, jsxs } from "react/jsx-runtime";
|
|
556
|
+
function resolveLocalizationParam(param) {
|
|
557
|
+
if (param === void 0) return void 0;
|
|
558
|
+
if (typeof param === "string") return param;
|
|
559
|
+
return param.defaultValue || param.key;
|
|
560
|
+
}
|
|
433
561
|
function SeverityIcon({ severity }) {
|
|
434
562
|
const iconProps = { size: 20 };
|
|
435
563
|
switch (severity) {
|
|
@@ -437,10 +565,13 @@ function SeverityIcon({ severity }) {
|
|
|
437
565
|
return /* @__PURE__ */ jsx3(CheckCircle, { ...iconProps, color: "var(--chakra-colors-green-500)" });
|
|
438
566
|
case "info":
|
|
439
567
|
return /* @__PURE__ */ jsx3(Info, { ...iconProps, color: "var(--chakra-colors-blue-500)" });
|
|
440
|
-
case "
|
|
568
|
+
case "warning":
|
|
441
569
|
return /* @__PURE__ */ jsx3(AlertTriangle, { ...iconProps, color: "var(--chakra-colors-yellow-500)" });
|
|
442
570
|
case "error":
|
|
443
571
|
return /* @__PURE__ */ jsx3(XCircle, { ...iconProps, color: "var(--chakra-colors-red-500)" });
|
|
572
|
+
case "neutral":
|
|
573
|
+
default:
|
|
574
|
+
return /* @__PURE__ */ jsx3(Circle, { ...iconProps, color: "var(--chakra-colors-gray-500)" });
|
|
444
575
|
}
|
|
445
576
|
}
|
|
446
577
|
function getSeverityColorPalette(severity) {
|
|
@@ -449,10 +580,13 @@ function getSeverityColorPalette(severity) {
|
|
|
449
580
|
return "green";
|
|
450
581
|
case "info":
|
|
451
582
|
return "blue";
|
|
452
|
-
case "
|
|
583
|
+
case "warning":
|
|
453
584
|
return "yellow";
|
|
454
585
|
case "error":
|
|
455
586
|
return "red";
|
|
587
|
+
case "neutral":
|
|
588
|
+
default:
|
|
589
|
+
return "gray";
|
|
456
590
|
}
|
|
457
591
|
}
|
|
458
592
|
function getSeverityBg(severity) {
|
|
@@ -461,10 +595,13 @@ function getSeverityBg(severity) {
|
|
|
461
595
|
return "green.50";
|
|
462
596
|
case "info":
|
|
463
597
|
return "blue.50";
|
|
464
|
-
case "
|
|
598
|
+
case "warning":
|
|
465
599
|
return "yellow.50";
|
|
466
600
|
case "error":
|
|
467
601
|
return "red.50";
|
|
602
|
+
case "neutral":
|
|
603
|
+
default:
|
|
604
|
+
return "gray.50";
|
|
468
605
|
}
|
|
469
606
|
}
|
|
470
607
|
function getSeverityBorderColor(severity) {
|
|
@@ -473,10 +610,13 @@ function getSeverityBorderColor(severity) {
|
|
|
473
610
|
return "green.200";
|
|
474
611
|
case "info":
|
|
475
612
|
return "blue.200";
|
|
476
|
-
case "
|
|
613
|
+
case "warning":
|
|
477
614
|
return "yellow.200";
|
|
478
615
|
case "error":
|
|
479
616
|
return "red.200";
|
|
617
|
+
case "neutral":
|
|
618
|
+
default:
|
|
619
|
+
return "gray.200";
|
|
480
620
|
}
|
|
481
621
|
}
|
|
482
622
|
function mapSeverityToType(severity) {
|
|
@@ -485,10 +625,13 @@ function mapSeverityToType(severity) {
|
|
|
485
625
|
return "success";
|
|
486
626
|
case "info":
|
|
487
627
|
return "info";
|
|
488
|
-
case "
|
|
628
|
+
case "warning":
|
|
489
629
|
return "warning";
|
|
490
630
|
case "error":
|
|
491
631
|
return "error";
|
|
632
|
+
case "neutral":
|
|
633
|
+
default:
|
|
634
|
+
return "info";
|
|
492
635
|
}
|
|
493
636
|
}
|
|
494
637
|
function getPlacement(position) {
|
|
@@ -520,31 +663,38 @@ function getToaster(placement) {
|
|
|
520
663
|
}
|
|
521
664
|
return toasterCache.get(placement);
|
|
522
665
|
}
|
|
523
|
-
function ToastContainer({ position = "bottom-right" }) {
|
|
666
|
+
function ToastContainer({ position = "bottom-right", containerKey }) {
|
|
524
667
|
const { toasts, service } = useToasterContext();
|
|
525
668
|
const { t } = useLocalization();
|
|
526
669
|
const displayedToastsRef = useRef3(/* @__PURE__ */ new Set());
|
|
527
670
|
const placement = useMemo3(() => getPlacement(position), [position]);
|
|
528
671
|
const toaster = useMemo3(() => getToaster(placement), [placement]);
|
|
529
|
-
|
|
530
|
-
|
|
672
|
+
const filteredToasts = useMemo3(() => {
|
|
673
|
+
if (!containerKey) return toasts;
|
|
674
|
+
return toasts.filter((toast) => toast.options?.containerKey === containerKey);
|
|
675
|
+
}, [toasts, containerKey]);
|
|
676
|
+
useEffect3(() => {
|
|
677
|
+
const newToasts = filteredToasts.filter((toast) => !displayedToastsRef.current.has(toast.id));
|
|
531
678
|
newToasts.forEach((toast) => {
|
|
532
679
|
displayedToastsRef.current.add(toast.id);
|
|
680
|
+
const messageStr = resolveLocalizationParam(toast.message) || "";
|
|
533
681
|
const localizedMessage = t(
|
|
534
|
-
|
|
535
|
-
...toast.messageLocalizationParams || []
|
|
682
|
+
messageStr,
|
|
683
|
+
...toast.options?.messageLocalizationParams || []
|
|
536
684
|
);
|
|
537
|
-
const
|
|
685
|
+
const titleStr = resolveLocalizationParam(toast.title);
|
|
686
|
+
const localizedTitle = titleStr ? t(titleStr, ...toast.options?.titleLocalizationParams || []) : void 0;
|
|
687
|
+
const severity = toast.severity || "info";
|
|
538
688
|
requestAnimationFrame(() => {
|
|
539
689
|
toaster.create({
|
|
540
|
-
id: toast.id,
|
|
690
|
+
id: String(toast.id),
|
|
541
691
|
title: localizedTitle,
|
|
542
692
|
description: localizedMessage,
|
|
543
|
-
type: mapSeverityToType(
|
|
544
|
-
duration: toast.sticky ? void 0 : toast.life || 5e3,
|
|
693
|
+
type: mapSeverityToType(severity),
|
|
694
|
+
duration: toast.options?.sticky ? void 0 : toast.options?.life || 5e3,
|
|
545
695
|
meta: {
|
|
546
|
-
closable: toast.closable !== false,
|
|
547
|
-
severity
|
|
696
|
+
closable: toast.options?.closable !== false,
|
|
697
|
+
severity
|
|
548
698
|
},
|
|
549
699
|
onStatusChange: (details) => {
|
|
550
700
|
if (details.status === "unmounted") {
|
|
@@ -555,7 +705,7 @@ function ToastContainer({ position = "bottom-right" }) {
|
|
|
555
705
|
});
|
|
556
706
|
});
|
|
557
707
|
});
|
|
558
|
-
}, [
|
|
708
|
+
}, [filteredToasts, t, service, toaster]);
|
|
559
709
|
return /* @__PURE__ */ jsx3(Portal, { children: /* @__PURE__ */ jsx3(ChakraToaster, { toaster, insetInline: { mdDown: "4" }, children: (toast) => {
|
|
560
710
|
const severity = toast.meta?.severity || "info";
|
|
561
711
|
const closable = toast.meta?.closable !== false;
|
|
@@ -595,9 +745,20 @@ import {
|
|
|
595
745
|
CheckCircle as CheckCircle2,
|
|
596
746
|
Info as Info2,
|
|
597
747
|
AlertTriangle as AlertTriangle2,
|
|
598
|
-
XCircle as XCircle2
|
|
748
|
+
XCircle as XCircle2,
|
|
749
|
+
Circle as Circle2
|
|
599
750
|
} from "lucide-react";
|
|
600
751
|
import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
752
|
+
function resolveLocalizationParam2(param) {
|
|
753
|
+
if (param === void 0) return void 0;
|
|
754
|
+
if (typeof param === "string") return param;
|
|
755
|
+
return param.defaultValue || param.key;
|
|
756
|
+
}
|
|
757
|
+
function getLocalizationKey(param) {
|
|
758
|
+
if (param === void 0) return void 0;
|
|
759
|
+
if (typeof param === "string") return param;
|
|
760
|
+
return param.key;
|
|
761
|
+
}
|
|
601
762
|
function SeverityIcon2({ severity }) {
|
|
602
763
|
const iconProps = { size: 24 };
|
|
603
764
|
switch (severity) {
|
|
@@ -605,10 +766,13 @@ function SeverityIcon2({ severity }) {
|
|
|
605
766
|
return /* @__PURE__ */ jsx4(CheckCircle2, { ...iconProps, color: "var(--chakra-colors-green-500)" });
|
|
606
767
|
case "info":
|
|
607
768
|
return /* @__PURE__ */ jsx4(Info2, { ...iconProps, color: "var(--chakra-colors-blue-500)" });
|
|
608
|
-
case "
|
|
769
|
+
case "warning":
|
|
609
770
|
return /* @__PURE__ */ jsx4(AlertTriangle2, { ...iconProps, color: "var(--chakra-colors-yellow-500)" });
|
|
610
771
|
case "error":
|
|
611
772
|
return /* @__PURE__ */ jsx4(XCircle2, { ...iconProps, color: "var(--chakra-colors-red-500)" });
|
|
773
|
+
case "neutral":
|
|
774
|
+
default:
|
|
775
|
+
return /* @__PURE__ */ jsx4(Circle2, { ...iconProps, color: "var(--chakra-colors-gray-500)" });
|
|
612
776
|
}
|
|
613
777
|
}
|
|
614
778
|
function getSeverityColorPalette2(severity) {
|
|
@@ -617,10 +781,13 @@ function getSeverityColorPalette2(severity) {
|
|
|
617
781
|
return "green";
|
|
618
782
|
case "info":
|
|
619
783
|
return "blue";
|
|
620
|
-
case "
|
|
784
|
+
case "warning":
|
|
621
785
|
return "yellow";
|
|
622
786
|
case "error":
|
|
623
787
|
return "red";
|
|
788
|
+
case "neutral":
|
|
789
|
+
default:
|
|
790
|
+
return "gray";
|
|
624
791
|
}
|
|
625
792
|
}
|
|
626
793
|
function ConfirmationDialog({ className }) {
|
|
@@ -630,14 +797,18 @@ function ConfirmationDialog({ className }) {
|
|
|
630
797
|
if (!confirmation) {
|
|
631
798
|
return null;
|
|
632
799
|
}
|
|
633
|
-
const { message, title, severity, options } = confirmation;
|
|
800
|
+
const { message, title, severity = "neutral", options } = confirmation;
|
|
801
|
+
const messageStr = resolveLocalizationParam2(message) || "";
|
|
634
802
|
const localizedMessage = t(
|
|
635
|
-
|
|
636
|
-
...options
|
|
803
|
+
messageStr,
|
|
804
|
+
...options?.messageLocalizationParams || []
|
|
637
805
|
);
|
|
638
|
-
const
|
|
639
|
-
const
|
|
640
|
-
const
|
|
806
|
+
const titleStr = resolveLocalizationParam2(title);
|
|
807
|
+
const localizedTitle = titleStr ? t(titleStr, ...options?.titleLocalizationParams || []) : void 0;
|
|
808
|
+
const yesKey = getLocalizationKey(options?.yesText);
|
|
809
|
+
const cancelKey = getLocalizationKey(options?.cancelText);
|
|
810
|
+
const yesCopy = yesKey ? t(yesKey) : t("AbpUi::Yes");
|
|
811
|
+
const cancelCopy = cancelKey ? t(cancelKey) : t("AbpUi::Cancel");
|
|
641
812
|
const handleConfirm = () => {
|
|
642
813
|
respond(Toaster.Status.confirm);
|
|
643
814
|
};
|
|
@@ -648,7 +819,7 @@ function ConfirmationDialog({ className }) {
|
|
|
648
819
|
respond(Toaster.Status.dismiss);
|
|
649
820
|
};
|
|
650
821
|
const handleOpenChange = (details) => {
|
|
651
|
-
if (!details.open) {
|
|
822
|
+
if (!details.open && options?.closable !== false) {
|
|
652
823
|
handleDismiss();
|
|
653
824
|
}
|
|
654
825
|
};
|
|
@@ -669,7 +840,7 @@ function ConfirmationDialog({ className }) {
|
|
|
669
840
|
] }) }),
|
|
670
841
|
/* @__PURE__ */ jsx4(Dialog.Body, { children: /* @__PURE__ */ jsx4(Text, { color: "gray.600", children: localizedMessage }) }),
|
|
671
842
|
/* @__PURE__ */ jsx4(Dialog.Footer, { children: /* @__PURE__ */ jsxs2(Flex2, { gap: 3, children: [
|
|
672
|
-
!options
|
|
843
|
+
!options?.hideCancelBtn && /* @__PURE__ */ jsx4(
|
|
673
844
|
Button,
|
|
674
845
|
{
|
|
675
846
|
ref: cancelRef,
|
|
@@ -678,7 +849,7 @@ function ConfirmationDialog({ className }) {
|
|
|
678
849
|
children: cancelCopy
|
|
679
850
|
}
|
|
680
851
|
),
|
|
681
|
-
!options
|
|
852
|
+
!options?.hideYesBtn && /* @__PURE__ */ jsx4(
|
|
682
853
|
Button,
|
|
683
854
|
{
|
|
684
855
|
colorPalette: getSeverityColorPalette2(severity),
|
|
@@ -727,26 +898,28 @@ function ErrorComponent({
|
|
|
727
898
|
}
|
|
728
899
|
|
|
729
900
|
// src/components/loader-bar/LoaderBar.tsx
|
|
730
|
-
import { useEffect as
|
|
901
|
+
import { useEffect as useEffect4, useRef as useRef5, useState as useState4 } from "react";
|
|
731
902
|
import { useLoader } from "@abpjs/core";
|
|
732
903
|
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
733
904
|
function LoaderBar({
|
|
734
905
|
containerClass = "abp-loader-bar",
|
|
735
906
|
progressClass = "abp-progress",
|
|
736
|
-
filter
|
|
907
|
+
filter,
|
|
908
|
+
intervalPeriod = 300,
|
|
909
|
+
stopDelay = 400
|
|
737
910
|
}) {
|
|
738
911
|
const { loading } = useLoader();
|
|
739
912
|
const [isLoading, setIsLoading] = useState4(false);
|
|
740
913
|
const [progressLevel, setProgressLevel] = useState4(0);
|
|
741
914
|
const intervalRef = useRef5(null);
|
|
742
|
-
|
|
915
|
+
useEffect4(() => {
|
|
743
916
|
if (loading) {
|
|
744
917
|
startLoading();
|
|
745
918
|
} else {
|
|
746
919
|
stopLoading();
|
|
747
920
|
}
|
|
748
921
|
}, [loading]);
|
|
749
|
-
|
|
922
|
+
useEffect4(() => {
|
|
750
923
|
return () => {
|
|
751
924
|
if (intervalRef.current) {
|
|
752
925
|
clearInterval(intervalRef.current);
|
|
@@ -770,7 +943,7 @@ function LoaderBar({
|
|
|
770
943
|
}
|
|
771
944
|
return prev + 10;
|
|
772
945
|
});
|
|
773
|
-
},
|
|
946
|
+
}, intervalPeriod);
|
|
774
947
|
};
|
|
775
948
|
const stopLoading = () => {
|
|
776
949
|
setProgressLevel(100);
|
|
@@ -781,7 +954,7 @@ function LoaderBar({
|
|
|
781
954
|
setTimeout(() => {
|
|
782
955
|
setIsLoading(false);
|
|
783
956
|
setProgressLevel(0);
|
|
784
|
-
},
|
|
957
|
+
}, stopDelay);
|
|
785
958
|
};
|
|
786
959
|
if (!isLoading && progressLevel === 0) {
|
|
787
960
|
return null;
|
|
@@ -1086,7 +1259,7 @@ function FormField({
|
|
|
1086
1259
|
}
|
|
1087
1260
|
|
|
1088
1261
|
// src/components/change-password/ChangePassword.tsx
|
|
1089
|
-
import { useEffect as
|
|
1262
|
+
import { useEffect as useEffect5 } from "react";
|
|
1090
1263
|
import {
|
|
1091
1264
|
Button as Button5,
|
|
1092
1265
|
VStack as VStack2,
|
|
@@ -1118,7 +1291,7 @@ function ChangePassword({
|
|
|
1118
1291
|
}
|
|
1119
1292
|
});
|
|
1120
1293
|
const newPassword = watch("newPassword");
|
|
1121
|
-
|
|
1294
|
+
useEffect5(() => {
|
|
1122
1295
|
if (visible) {
|
|
1123
1296
|
reset();
|
|
1124
1297
|
}
|
|
@@ -1238,7 +1411,7 @@ function ChangePassword({
|
|
|
1238
1411
|
}
|
|
1239
1412
|
|
|
1240
1413
|
// src/components/profile/Profile.tsx
|
|
1241
|
-
import { useEffect as
|
|
1414
|
+
import { useEffect as useEffect6 } from "react";
|
|
1242
1415
|
import {
|
|
1243
1416
|
Button as Button6,
|
|
1244
1417
|
VStack as VStack3,
|
|
@@ -1272,13 +1445,13 @@ function Profile({
|
|
|
1272
1445
|
}
|
|
1273
1446
|
});
|
|
1274
1447
|
const modalBusy = isSubmitting || loading;
|
|
1275
|
-
|
|
1448
|
+
useEffect6(() => {
|
|
1276
1449
|
if (visible) {
|
|
1277
1450
|
fetchProfile().then(() => {
|
|
1278
1451
|
});
|
|
1279
1452
|
}
|
|
1280
1453
|
}, [visible, fetchProfile]);
|
|
1281
|
-
|
|
1454
|
+
useEffect6(() => {
|
|
1282
1455
|
if (profile) {
|
|
1283
1456
|
reset({
|
|
1284
1457
|
userName: profile.userName || "",
|