@abpjs/theme-shared 1.1.0 → 2.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/dist/components/confirmation/Confirmation.d.ts +3 -0
- package/dist/components/toast/Toast.d.ts +11 -1
- package/dist/constants/styles.d.ts +6 -1
- package/dist/contexts/confirmation.context.d.ts +92 -29
- package/dist/contexts/toaster.context.d.ts +88 -19
- package/dist/index.d.ts +14 -1
- package/dist/index.js +254 -88
- package/dist/index.mjs +271 -102
- package/dist/models/confirmation.d.ts +48 -19
- package/dist/models/toaster.d.ts +60 -10
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -9,6 +9,17 @@ var Toaster;
|
|
|
9
9
|
})(Status = Toaster2.Status || (Toaster2.Status = {}));
|
|
10
10
|
})(Toaster || (Toaster = {}));
|
|
11
11
|
|
|
12
|
+
// src/models/confirmation.ts
|
|
13
|
+
var Confirmation;
|
|
14
|
+
((Confirmation2) => {
|
|
15
|
+
let Status;
|
|
16
|
+
((Status2) => {
|
|
17
|
+
Status2["confirm"] = "confirm";
|
|
18
|
+
Status2["reject"] = "reject";
|
|
19
|
+
Status2["dismiss"] = "dismiss";
|
|
20
|
+
})(Status = Confirmation2.Status || (Confirmation2.Status = {}));
|
|
21
|
+
})(Confirmation || (Confirmation = {}));
|
|
22
|
+
|
|
12
23
|
// src/constants/styles.ts
|
|
13
24
|
var DEFAULT_STYLES = `
|
|
14
25
|
.is-invalid .form-control {
|
|
@@ -36,25 +47,114 @@ var DEFAULT_STYLES = `
|
|
|
36
47
|
top: 18px;
|
|
37
48
|
}
|
|
38
49
|
|
|
39
|
-
.
|
|
40
|
-
|
|
50
|
+
.navbar .dropdown-menu {
|
|
51
|
+
min-width: 215px;
|
|
41
52
|
}
|
|
42
53
|
|
|
43
|
-
.
|
|
54
|
+
.ui-table-scrollable-body::-webkit-scrollbar {
|
|
55
|
+
height: 5px !important;
|
|
56
|
+
width: 5px !important;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.ui-table-scrollable-body::-webkit-scrollbar-track {
|
|
60
|
+
background: #ddd;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.ui-table-scrollable-body::-webkit-scrollbar-thumb {
|
|
64
|
+
background: #8a8686;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.abp-ellipsis-inline {
|
|
44
68
|
display: inline-block;
|
|
45
69
|
overflow: hidden;
|
|
46
70
|
text-overflow: ellipsis;
|
|
47
71
|
white-space: nowrap;
|
|
48
72
|
}
|
|
49
73
|
|
|
74
|
+
.abp-ellipsis {
|
|
75
|
+
overflow: hidden !important;
|
|
76
|
+
text-overflow: ellipsis;
|
|
77
|
+
white-space: nowrap;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.ui-widget-overlay {
|
|
81
|
+
z-index: 1000;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.color-white {
|
|
85
|
+
color: #FFF !important;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.custom-checkbox > label {
|
|
89
|
+
cursor: pointer;
|
|
90
|
+
}
|
|
91
|
+
|
|
50
92
|
/* <animations */
|
|
51
93
|
|
|
52
94
|
.fade-in-top {
|
|
53
|
-
animation: fadeInTop 0.
|
|
95
|
+
animation: fadeInTop 0.2s ease-in-out;
|
|
54
96
|
}
|
|
55
97
|
|
|
56
98
|
.fade-out-top {
|
|
57
|
-
animation: fadeOutTop 0.
|
|
99
|
+
animation: fadeOutTop 0.2s ease-in-out;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.abp-collapsed-height {
|
|
103
|
+
-moz-transition: max-height linear 0.35s;
|
|
104
|
+
-ms-transition: max-height linear 0.35s;
|
|
105
|
+
-o-transition: max-height linear 0.35s;
|
|
106
|
+
-webkit-transition: max-height linear 0.35s;
|
|
107
|
+
overflow:hidden;
|
|
108
|
+
transition:max-height 0.35s linear;
|
|
109
|
+
height:auto;
|
|
110
|
+
max-height: 0;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
.abp-mh-25 {
|
|
114
|
+
max-height: 25vh;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.abp-mh-50 {
|
|
118
|
+
transition:max-height 0.65s linear;
|
|
119
|
+
max-height: 50vh;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
.abp-mh-75 {
|
|
123
|
+
transition:max-height 0.85s linear;
|
|
124
|
+
max-height: 75vh;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
.abp-mh-100 {
|
|
128
|
+
transition:max-height 1s linear;
|
|
129
|
+
max-height: 100vh;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/* Sorting icon styles - @since 2.0.0 */
|
|
133
|
+
[class^="sorting"] {
|
|
134
|
+
opacity: .3;
|
|
135
|
+
cursor: pointer;
|
|
136
|
+
}
|
|
137
|
+
[class^="sorting"]:before {
|
|
138
|
+
right: 0.5rem;
|
|
139
|
+
content: "\u2191";
|
|
140
|
+
}
|
|
141
|
+
[class^="sorting"]:after {
|
|
142
|
+
right: 0.5rem;
|
|
143
|
+
content: "\u2193";
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
.sorting_desc {
|
|
147
|
+
opacity: 1;
|
|
148
|
+
}
|
|
149
|
+
.sorting_desc:before {
|
|
150
|
+
opacity: .3;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
.sorting_asc {
|
|
154
|
+
opacity: 1;
|
|
155
|
+
}
|
|
156
|
+
.sorting_asc:after {
|
|
157
|
+
opacity: .3;
|
|
58
158
|
}
|
|
59
159
|
|
|
60
160
|
@keyframes fadeInTop {
|
|
@@ -64,7 +164,7 @@ var DEFAULT_STYLES = `
|
|
|
64
164
|
}
|
|
65
165
|
|
|
66
166
|
to {
|
|
67
|
-
transform: translateY(
|
|
167
|
+
transform: translateY(0px);
|
|
68
168
|
opacity: 1;
|
|
69
169
|
}
|
|
70
170
|
}
|
|
@@ -104,44 +204,41 @@ import {
|
|
|
104
204
|
useCallback,
|
|
105
205
|
useState,
|
|
106
206
|
useRef,
|
|
107
|
-
useMemo
|
|
207
|
+
useMemo,
|
|
208
|
+
useEffect
|
|
108
209
|
} from "react";
|
|
109
210
|
import { jsx } from "react/jsx-runtime";
|
|
110
211
|
var ToasterContext = createContext(null);
|
|
111
212
|
var toastCounter = 0;
|
|
112
213
|
function generateId() {
|
|
113
214
|
toastCounter += 1;
|
|
114
|
-
return
|
|
215
|
+
return toastCounter;
|
|
115
216
|
}
|
|
116
217
|
var DEFAULT_LIFE = 5e3;
|
|
117
|
-
function resolveLocalizationParam(param) {
|
|
118
|
-
if (param === void 0) return void 0;
|
|
119
|
-
if (typeof param === "string") return param;
|
|
120
|
-
return param.defaultValue || param.key;
|
|
121
|
-
}
|
|
122
218
|
function ToasterProvider({ children }) {
|
|
123
219
|
const [toasts, setToasts] = useState([]);
|
|
124
|
-
const
|
|
220
|
+
const subscribersRef = useRef(/* @__PURE__ */ new Set());
|
|
221
|
+
useEffect(() => {
|
|
222
|
+
subscribersRef.current.forEach((subscriber) => {
|
|
223
|
+
subscriber(toasts);
|
|
224
|
+
});
|
|
225
|
+
}, [toasts]);
|
|
125
226
|
const remove = useCallback((id) => {
|
|
126
227
|
setToasts((prev) => prev.filter((t) => t.id !== id));
|
|
127
|
-
const resolver = resolversRef.current.get(id);
|
|
128
|
-
if (resolver) {
|
|
129
|
-
resolver(Toaster.Status.dismiss);
|
|
130
|
-
resolversRef.current.delete(id);
|
|
131
|
-
}
|
|
132
228
|
}, []);
|
|
133
229
|
const show = useCallback(
|
|
134
|
-
(message, title, severity, options) => {
|
|
135
|
-
const id = options?.id
|
|
230
|
+
(message, title, severity = "info", options) => {
|
|
231
|
+
const id = typeof options?.id === "number" ? options.id : generateId();
|
|
136
232
|
const life = options?.sticky ? void 0 : options?.life ?? DEFAULT_LIFE;
|
|
137
|
-
const resolvedMessage = resolveLocalizationParam(message) || "";
|
|
138
|
-
const resolvedTitle = resolveLocalizationParam(title);
|
|
139
233
|
const toast = {
|
|
140
234
|
id,
|
|
141
|
-
message
|
|
142
|
-
title
|
|
235
|
+
message,
|
|
236
|
+
title,
|
|
143
237
|
severity,
|
|
144
|
-
|
|
238
|
+
options: {
|
|
239
|
+
...options,
|
|
240
|
+
id
|
|
241
|
+
}
|
|
145
242
|
};
|
|
146
243
|
setToasts((prev) => [...prev, toast]);
|
|
147
244
|
if (life) {
|
|
@@ -149,9 +246,7 @@ function ToasterProvider({ children }) {
|
|
|
149
246
|
remove(id);
|
|
150
247
|
}, life);
|
|
151
248
|
}
|
|
152
|
-
return
|
|
153
|
-
resolversRef.current.set(id, resolve);
|
|
154
|
-
});
|
|
249
|
+
return id;
|
|
155
250
|
},
|
|
156
251
|
[remove]
|
|
157
252
|
);
|
|
@@ -164,44 +259,40 @@ function ToasterProvider({ children }) {
|
|
|
164
259
|
[show]
|
|
165
260
|
);
|
|
166
261
|
const warn = useCallback(
|
|
167
|
-
(message, title, options) => show(message, title, "
|
|
262
|
+
(message, title, options) => show(message, title, "warning", options),
|
|
168
263
|
[show]
|
|
169
264
|
);
|
|
170
265
|
const error = useCallback(
|
|
171
266
|
(message, title, options) => show(message, title, "error", options),
|
|
172
267
|
[show]
|
|
173
268
|
);
|
|
174
|
-
const
|
|
175
|
-
(messages) => {
|
|
176
|
-
messages.forEach((msg) => {
|
|
177
|
-
show(msg.message, msg.title, msg.severity, msg);
|
|
178
|
-
});
|
|
179
|
-
},
|
|
180
|
-
[show]
|
|
181
|
-
);
|
|
182
|
-
const clear = useCallback((status) => {
|
|
269
|
+
const clear = useCallback((key) => {
|
|
183
270
|
setToasts((prev) => {
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
resolver(status ?? Toaster.Status.dismiss);
|
|
188
|
-
resolversRef.current.delete(toast.id);
|
|
189
|
-
}
|
|
190
|
-
});
|
|
271
|
+
if (key) {
|
|
272
|
+
return prev.filter((toast) => toast.options?.containerKey !== key);
|
|
273
|
+
}
|
|
191
274
|
return [];
|
|
192
275
|
});
|
|
193
276
|
}, []);
|
|
277
|
+
const subscribe = useCallback((subscriber) => {
|
|
278
|
+
subscribersRef.current.add(subscriber);
|
|
279
|
+
subscriber(toasts);
|
|
280
|
+
return () => {
|
|
281
|
+
subscribersRef.current.delete(subscriber);
|
|
282
|
+
};
|
|
283
|
+
}, [toasts]);
|
|
194
284
|
const service = useMemo(
|
|
195
285
|
() => ({
|
|
196
286
|
info,
|
|
197
287
|
success,
|
|
198
288
|
warn,
|
|
199
289
|
error,
|
|
200
|
-
|
|
290
|
+
show,
|
|
291
|
+
remove,
|
|
201
292
|
clear,
|
|
202
|
-
|
|
293
|
+
subscribe
|
|
203
294
|
}),
|
|
204
|
-
[info, success, warn, error,
|
|
295
|
+
[info, success, warn, error, show, remove, clear, subscribe]
|
|
205
296
|
);
|
|
206
297
|
const value = useMemo(
|
|
207
298
|
() => ({ service, toasts }),
|
|
@@ -238,7 +329,8 @@ import {
|
|
|
238
329
|
useCallback as useCallback2,
|
|
239
330
|
useState as useState2,
|
|
240
331
|
useRef as useRef2,
|
|
241
|
-
useMemo as useMemo2
|
|
332
|
+
useMemo as useMemo2,
|
|
333
|
+
useEffect as useEffect2
|
|
242
334
|
} from "react";
|
|
243
335
|
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
244
336
|
var ConfirmationContext = createContext2(null);
|
|
@@ -248,6 +340,13 @@ function generateId2() {
|
|
|
248
340
|
function ConfirmationProvider({ children }) {
|
|
249
341
|
const [confirmation, setConfirmation] = useState2(null);
|
|
250
342
|
const resolverRef = useRef2(null);
|
|
343
|
+
const subscribersRef = useRef2(/* @__PURE__ */ new Set());
|
|
344
|
+
const escapeListenerRef = useRef2(false);
|
|
345
|
+
useEffect2(() => {
|
|
346
|
+
subscribersRef.current.forEach((subscriber) => {
|
|
347
|
+
subscriber(confirmation);
|
|
348
|
+
});
|
|
349
|
+
}, [confirmation]);
|
|
251
350
|
const respond = useCallback2((status) => {
|
|
252
351
|
if (resolverRef.current) {
|
|
253
352
|
resolverRef.current(status);
|
|
@@ -255,20 +354,34 @@ function ConfirmationProvider({ children }) {
|
|
|
255
354
|
}
|
|
256
355
|
setConfirmation(null);
|
|
257
356
|
}, []);
|
|
357
|
+
useEffect2(() => {
|
|
358
|
+
if (!escapeListenerRef.current) return;
|
|
359
|
+
const handleEscape = (event) => {
|
|
360
|
+
if (event.key === "Escape" && confirmation && confirmation.options?.closable !== false) {
|
|
361
|
+
respond(Confirmation.Status.dismiss);
|
|
362
|
+
}
|
|
363
|
+
};
|
|
364
|
+
document.addEventListener("keydown", handleEscape);
|
|
365
|
+
return () => {
|
|
366
|
+
document.removeEventListener("keydown", handleEscape);
|
|
367
|
+
};
|
|
368
|
+
}, [confirmation, respond]);
|
|
258
369
|
const show = useCallback2(
|
|
259
|
-
(message, title, severity, options = {}) => {
|
|
370
|
+
(message, title, severity = "neutral", options = {}) => {
|
|
260
371
|
if (resolverRef.current) {
|
|
261
|
-
resolverRef.current(
|
|
372
|
+
resolverRef.current(Confirmation.Status.dismiss);
|
|
262
373
|
}
|
|
263
374
|
const id = options.id?.toString() || generateId2();
|
|
264
|
-
const
|
|
265
|
-
id,
|
|
375
|
+
const dialogData = {
|
|
266
376
|
message,
|
|
267
377
|
title,
|
|
268
378
|
severity,
|
|
269
|
-
options
|
|
379
|
+
options: {
|
|
380
|
+
...options,
|
|
381
|
+
id
|
|
382
|
+
}
|
|
270
383
|
};
|
|
271
|
-
setConfirmation(
|
|
384
|
+
setConfirmation(dialogData);
|
|
272
385
|
return new Promise((resolve) => {
|
|
273
386
|
resolverRef.current = resolve;
|
|
274
387
|
});
|
|
@@ -284,7 +397,7 @@ function ConfirmationProvider({ children }) {
|
|
|
284
397
|
[show]
|
|
285
398
|
);
|
|
286
399
|
const warn = useCallback2(
|
|
287
|
-
(message, title, options) => show(message, title, "
|
|
400
|
+
(message, title, options) => show(message, title, "warning", options),
|
|
288
401
|
[show]
|
|
289
402
|
);
|
|
290
403
|
const error = useCallback2(
|
|
@@ -293,19 +406,32 @@ function ConfirmationProvider({ children }) {
|
|
|
293
406
|
);
|
|
294
407
|
const clear = useCallback2(
|
|
295
408
|
(status) => {
|
|
296
|
-
respond(status ??
|
|
409
|
+
respond(status ?? Confirmation.Status.dismiss);
|
|
297
410
|
},
|
|
298
411
|
[respond]
|
|
299
412
|
);
|
|
413
|
+
const listenToEscape = useCallback2(() => {
|
|
414
|
+
escapeListenerRef.current = true;
|
|
415
|
+
}, []);
|
|
416
|
+
const subscribe = useCallback2((subscriber) => {
|
|
417
|
+
subscribersRef.current.add(subscriber);
|
|
418
|
+
subscriber(confirmation);
|
|
419
|
+
return () => {
|
|
420
|
+
subscribersRef.current.delete(subscriber);
|
|
421
|
+
};
|
|
422
|
+
}, [confirmation]);
|
|
300
423
|
const service = useMemo2(
|
|
301
424
|
() => ({
|
|
302
425
|
info,
|
|
303
426
|
success,
|
|
304
427
|
warn,
|
|
305
428
|
error,
|
|
306
|
-
|
|
429
|
+
show,
|
|
430
|
+
clear,
|
|
431
|
+
listenToEscape,
|
|
432
|
+
subscribe
|
|
307
433
|
}),
|
|
308
|
-
[info, success, warn, error, clear]
|
|
434
|
+
[info, success, warn, error, show, clear, listenToEscape, subscribe]
|
|
309
435
|
);
|
|
310
436
|
const value = useMemo2(
|
|
311
437
|
() => ({ service, confirmation, respond }),
|
|
@@ -418,7 +544,7 @@ function isHttpErrorResponse(error) {
|
|
|
418
544
|
}
|
|
419
545
|
|
|
420
546
|
// src/components/toast/Toast.tsx
|
|
421
|
-
import { useEffect, useRef as useRef3, useMemo as useMemo3 } from "react";
|
|
547
|
+
import { useEffect as useEffect3, useRef as useRef3, useMemo as useMemo3 } from "react";
|
|
422
548
|
import {
|
|
423
549
|
Toaster as ChakraToaster,
|
|
424
550
|
Portal,
|
|
@@ -434,9 +560,15 @@ import {
|
|
|
434
560
|
CheckCircle,
|
|
435
561
|
Info,
|
|
436
562
|
AlertTriangle,
|
|
437
|
-
XCircle
|
|
563
|
+
XCircle,
|
|
564
|
+
Circle
|
|
438
565
|
} from "lucide-react";
|
|
439
566
|
import { jsx as jsx3, jsxs } from "react/jsx-runtime";
|
|
567
|
+
function resolveLocalizationParam(param) {
|
|
568
|
+
if (param === void 0) return void 0;
|
|
569
|
+
if (typeof param === "string") return param;
|
|
570
|
+
return param.defaultValue || param.key;
|
|
571
|
+
}
|
|
440
572
|
function SeverityIcon({ severity }) {
|
|
441
573
|
const iconProps = { size: 20 };
|
|
442
574
|
switch (severity) {
|
|
@@ -444,10 +576,13 @@ function SeverityIcon({ severity }) {
|
|
|
444
576
|
return /* @__PURE__ */ jsx3(CheckCircle, { ...iconProps, color: "var(--chakra-colors-green-500)" });
|
|
445
577
|
case "info":
|
|
446
578
|
return /* @__PURE__ */ jsx3(Info, { ...iconProps, color: "var(--chakra-colors-blue-500)" });
|
|
447
|
-
case "
|
|
579
|
+
case "warning":
|
|
448
580
|
return /* @__PURE__ */ jsx3(AlertTriangle, { ...iconProps, color: "var(--chakra-colors-yellow-500)" });
|
|
449
581
|
case "error":
|
|
450
582
|
return /* @__PURE__ */ jsx3(XCircle, { ...iconProps, color: "var(--chakra-colors-red-500)" });
|
|
583
|
+
case "neutral":
|
|
584
|
+
default:
|
|
585
|
+
return /* @__PURE__ */ jsx3(Circle, { ...iconProps, color: "var(--chakra-colors-gray-500)" });
|
|
451
586
|
}
|
|
452
587
|
}
|
|
453
588
|
function getSeverityColorPalette(severity) {
|
|
@@ -456,10 +591,13 @@ function getSeverityColorPalette(severity) {
|
|
|
456
591
|
return "green";
|
|
457
592
|
case "info":
|
|
458
593
|
return "blue";
|
|
459
|
-
case "
|
|
594
|
+
case "warning":
|
|
460
595
|
return "yellow";
|
|
461
596
|
case "error":
|
|
462
597
|
return "red";
|
|
598
|
+
case "neutral":
|
|
599
|
+
default:
|
|
600
|
+
return "gray";
|
|
463
601
|
}
|
|
464
602
|
}
|
|
465
603
|
function getSeverityBg(severity) {
|
|
@@ -468,10 +606,13 @@ function getSeverityBg(severity) {
|
|
|
468
606
|
return "green.50";
|
|
469
607
|
case "info":
|
|
470
608
|
return "blue.50";
|
|
471
|
-
case "
|
|
609
|
+
case "warning":
|
|
472
610
|
return "yellow.50";
|
|
473
611
|
case "error":
|
|
474
612
|
return "red.50";
|
|
613
|
+
case "neutral":
|
|
614
|
+
default:
|
|
615
|
+
return "gray.50";
|
|
475
616
|
}
|
|
476
617
|
}
|
|
477
618
|
function getSeverityBorderColor(severity) {
|
|
@@ -480,10 +621,13 @@ function getSeverityBorderColor(severity) {
|
|
|
480
621
|
return "green.200";
|
|
481
622
|
case "info":
|
|
482
623
|
return "blue.200";
|
|
483
|
-
case "
|
|
624
|
+
case "warning":
|
|
484
625
|
return "yellow.200";
|
|
485
626
|
case "error":
|
|
486
627
|
return "red.200";
|
|
628
|
+
case "neutral":
|
|
629
|
+
default:
|
|
630
|
+
return "gray.200";
|
|
487
631
|
}
|
|
488
632
|
}
|
|
489
633
|
function mapSeverityToType(severity) {
|
|
@@ -492,10 +636,13 @@ function mapSeverityToType(severity) {
|
|
|
492
636
|
return "success";
|
|
493
637
|
case "info":
|
|
494
638
|
return "info";
|
|
495
|
-
case "
|
|
639
|
+
case "warning":
|
|
496
640
|
return "warning";
|
|
497
641
|
case "error":
|
|
498
642
|
return "error";
|
|
643
|
+
case "neutral":
|
|
644
|
+
default:
|
|
645
|
+
return "info";
|
|
499
646
|
}
|
|
500
647
|
}
|
|
501
648
|
function getPlacement(position) {
|
|
@@ -527,31 +674,38 @@ function getToaster(placement) {
|
|
|
527
674
|
}
|
|
528
675
|
return toasterCache.get(placement);
|
|
529
676
|
}
|
|
530
|
-
function ToastContainer({ position = "bottom-right" }) {
|
|
677
|
+
function ToastContainer({ position = "bottom-right", containerKey }) {
|
|
531
678
|
const { toasts, service } = useToasterContext();
|
|
532
679
|
const { t } = useLocalization();
|
|
533
680
|
const displayedToastsRef = useRef3(/* @__PURE__ */ new Set());
|
|
534
681
|
const placement = useMemo3(() => getPlacement(position), [position]);
|
|
535
682
|
const toaster = useMemo3(() => getToaster(placement), [placement]);
|
|
536
|
-
|
|
537
|
-
|
|
683
|
+
const filteredToasts = useMemo3(() => {
|
|
684
|
+
if (!containerKey) return toasts;
|
|
685
|
+
return toasts.filter((toast) => toast.options?.containerKey === containerKey);
|
|
686
|
+
}, [toasts, containerKey]);
|
|
687
|
+
useEffect3(() => {
|
|
688
|
+
const newToasts = filteredToasts.filter((toast) => !displayedToastsRef.current.has(toast.id));
|
|
538
689
|
newToasts.forEach((toast) => {
|
|
539
690
|
displayedToastsRef.current.add(toast.id);
|
|
691
|
+
const messageStr = resolveLocalizationParam(toast.message) || "";
|
|
540
692
|
const localizedMessage = t(
|
|
541
|
-
|
|
542
|
-
...toast.messageLocalizationParams || []
|
|
693
|
+
messageStr,
|
|
694
|
+
...toast.options?.messageLocalizationParams || []
|
|
543
695
|
);
|
|
544
|
-
const
|
|
696
|
+
const titleStr = resolveLocalizationParam(toast.title);
|
|
697
|
+
const localizedTitle = titleStr ? t(titleStr, ...toast.options?.titleLocalizationParams || []) : void 0;
|
|
698
|
+
const severity = toast.severity || "info";
|
|
545
699
|
requestAnimationFrame(() => {
|
|
546
700
|
toaster.create({
|
|
547
|
-
id: toast.id,
|
|
701
|
+
id: String(toast.id),
|
|
548
702
|
title: localizedTitle,
|
|
549
703
|
description: localizedMessage,
|
|
550
|
-
type: mapSeverityToType(
|
|
551
|
-
duration: toast.sticky ? void 0 : toast.life || 5e3,
|
|
704
|
+
type: mapSeverityToType(severity),
|
|
705
|
+
duration: toast.options?.sticky ? void 0 : toast.options?.life || 5e3,
|
|
552
706
|
meta: {
|
|
553
|
-
closable: toast.closable !== false,
|
|
554
|
-
severity
|
|
707
|
+
closable: toast.options?.closable !== false,
|
|
708
|
+
severity
|
|
555
709
|
},
|
|
556
710
|
onStatusChange: (details) => {
|
|
557
711
|
if (details.status === "unmounted") {
|
|
@@ -562,7 +716,7 @@ function ToastContainer({ position = "bottom-right" }) {
|
|
|
562
716
|
});
|
|
563
717
|
});
|
|
564
718
|
});
|
|
565
|
-
}, [
|
|
719
|
+
}, [filteredToasts, t, service, toaster]);
|
|
566
720
|
return /* @__PURE__ */ jsx3(Portal, { children: /* @__PURE__ */ jsx3(ChakraToaster, { toaster, insetInline: { mdDown: "4" }, children: (toast) => {
|
|
567
721
|
const severity = toast.meta?.severity || "info";
|
|
568
722
|
const closable = toast.meta?.closable !== false;
|
|
@@ -602,9 +756,15 @@ import {
|
|
|
602
756
|
CheckCircle as CheckCircle2,
|
|
603
757
|
Info as Info2,
|
|
604
758
|
AlertTriangle as AlertTriangle2,
|
|
605
|
-
XCircle as XCircle2
|
|
759
|
+
XCircle as XCircle2,
|
|
760
|
+
Circle as Circle2
|
|
606
761
|
} from "lucide-react";
|
|
607
762
|
import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
763
|
+
function resolveLocalizationParam2(param) {
|
|
764
|
+
if (param === void 0) return void 0;
|
|
765
|
+
if (typeof param === "string") return param;
|
|
766
|
+
return param.defaultValue || param.key;
|
|
767
|
+
}
|
|
608
768
|
function getLocalizationKey(param) {
|
|
609
769
|
if (param === void 0) return void 0;
|
|
610
770
|
if (typeof param === "string") return param;
|
|
@@ -617,10 +777,13 @@ function SeverityIcon2({ severity }) {
|
|
|
617
777
|
return /* @__PURE__ */ jsx4(CheckCircle2, { ...iconProps, color: "var(--chakra-colors-green-500)" });
|
|
618
778
|
case "info":
|
|
619
779
|
return /* @__PURE__ */ jsx4(Info2, { ...iconProps, color: "var(--chakra-colors-blue-500)" });
|
|
620
|
-
case "
|
|
780
|
+
case "warning":
|
|
621
781
|
return /* @__PURE__ */ jsx4(AlertTriangle2, { ...iconProps, color: "var(--chakra-colors-yellow-500)" });
|
|
622
782
|
case "error":
|
|
623
783
|
return /* @__PURE__ */ jsx4(XCircle2, { ...iconProps, color: "var(--chakra-colors-red-500)" });
|
|
784
|
+
case "neutral":
|
|
785
|
+
default:
|
|
786
|
+
return /* @__PURE__ */ jsx4(Circle2, { ...iconProps, color: "var(--chakra-colors-gray-500)" });
|
|
624
787
|
}
|
|
625
788
|
}
|
|
626
789
|
function getSeverityColorPalette2(severity) {
|
|
@@ -629,10 +792,13 @@ function getSeverityColorPalette2(severity) {
|
|
|
629
792
|
return "green";
|
|
630
793
|
case "info":
|
|
631
794
|
return "blue";
|
|
632
|
-
case "
|
|
795
|
+
case "warning":
|
|
633
796
|
return "yellow";
|
|
634
797
|
case "error":
|
|
635
798
|
return "red";
|
|
799
|
+
case "neutral":
|
|
800
|
+
default:
|
|
801
|
+
return "gray";
|
|
636
802
|
}
|
|
637
803
|
}
|
|
638
804
|
function ConfirmationDialog({ className }) {
|
|
@@ -642,27 +808,29 @@ function ConfirmationDialog({ className }) {
|
|
|
642
808
|
if (!confirmation) {
|
|
643
809
|
return null;
|
|
644
810
|
}
|
|
645
|
-
const { message, title, severity, options } = confirmation;
|
|
811
|
+
const { message, title, severity = "neutral", options } = confirmation;
|
|
812
|
+
const messageStr = resolveLocalizationParam2(message) || "";
|
|
646
813
|
const localizedMessage = t(
|
|
647
|
-
|
|
648
|
-
...options
|
|
814
|
+
messageStr,
|
|
815
|
+
...options?.messageLocalizationParams || []
|
|
649
816
|
);
|
|
650
|
-
const
|
|
651
|
-
const
|
|
652
|
-
const
|
|
817
|
+
const titleStr = resolveLocalizationParam2(title);
|
|
818
|
+
const localizedTitle = titleStr ? t(titleStr, ...options?.titleLocalizationParams || []) : void 0;
|
|
819
|
+
const yesKey = getLocalizationKey(options?.yesText);
|
|
820
|
+
const cancelKey = getLocalizationKey(options?.cancelText);
|
|
653
821
|
const yesCopy = yesKey ? t(yesKey) : t("AbpUi::Yes");
|
|
654
822
|
const cancelCopy = cancelKey ? t(cancelKey) : t("AbpUi::Cancel");
|
|
655
823
|
const handleConfirm = () => {
|
|
656
|
-
respond(
|
|
824
|
+
respond(Confirmation.Status.confirm);
|
|
657
825
|
};
|
|
658
826
|
const handleCancel = () => {
|
|
659
|
-
respond(
|
|
827
|
+
respond(Confirmation.Status.reject);
|
|
660
828
|
};
|
|
661
829
|
const handleDismiss = () => {
|
|
662
|
-
respond(
|
|
830
|
+
respond(Confirmation.Status.dismiss);
|
|
663
831
|
};
|
|
664
832
|
const handleOpenChange = (details) => {
|
|
665
|
-
if (!details.open) {
|
|
833
|
+
if (!details.open && options?.closable !== false) {
|
|
666
834
|
handleDismiss();
|
|
667
835
|
}
|
|
668
836
|
};
|
|
@@ -683,7 +851,7 @@ function ConfirmationDialog({ className }) {
|
|
|
683
851
|
] }) }),
|
|
684
852
|
/* @__PURE__ */ jsx4(Dialog.Body, { children: /* @__PURE__ */ jsx4(Text, { color: "gray.600", children: localizedMessage }) }),
|
|
685
853
|
/* @__PURE__ */ jsx4(Dialog.Footer, { children: /* @__PURE__ */ jsxs2(Flex2, { gap: 3, children: [
|
|
686
|
-
!options
|
|
854
|
+
!options?.hideCancelBtn && /* @__PURE__ */ jsx4(
|
|
687
855
|
Button,
|
|
688
856
|
{
|
|
689
857
|
ref: cancelRef,
|
|
@@ -692,7 +860,7 @@ function ConfirmationDialog({ className }) {
|
|
|
692
860
|
children: cancelCopy
|
|
693
861
|
}
|
|
694
862
|
),
|
|
695
|
-
!options
|
|
863
|
+
!options?.hideYesBtn && /* @__PURE__ */ jsx4(
|
|
696
864
|
Button,
|
|
697
865
|
{
|
|
698
866
|
colorPalette: getSeverityColorPalette2(severity),
|
|
@@ -741,7 +909,7 @@ function ErrorComponent({
|
|
|
741
909
|
}
|
|
742
910
|
|
|
743
911
|
// src/components/loader-bar/LoaderBar.tsx
|
|
744
|
-
import { useEffect as
|
|
912
|
+
import { useEffect as useEffect4, useRef as useRef5, useState as useState4 } from "react";
|
|
745
913
|
import { useLoader } from "@abpjs/core";
|
|
746
914
|
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
747
915
|
function LoaderBar({
|
|
@@ -755,14 +923,14 @@ function LoaderBar({
|
|
|
755
923
|
const [isLoading, setIsLoading] = useState4(false);
|
|
756
924
|
const [progressLevel, setProgressLevel] = useState4(0);
|
|
757
925
|
const intervalRef = useRef5(null);
|
|
758
|
-
|
|
926
|
+
useEffect4(() => {
|
|
759
927
|
if (loading) {
|
|
760
928
|
startLoading();
|
|
761
929
|
} else {
|
|
762
930
|
stopLoading();
|
|
763
931
|
}
|
|
764
932
|
}, [loading]);
|
|
765
|
-
|
|
933
|
+
useEffect4(() => {
|
|
766
934
|
return () => {
|
|
767
935
|
if (intervalRef.current) {
|
|
768
936
|
clearInterval(intervalRef.current);
|
|
@@ -1102,7 +1270,7 @@ function FormField({
|
|
|
1102
1270
|
}
|
|
1103
1271
|
|
|
1104
1272
|
// src/components/change-password/ChangePassword.tsx
|
|
1105
|
-
import { useEffect as
|
|
1273
|
+
import { useEffect as useEffect5 } from "react";
|
|
1106
1274
|
import {
|
|
1107
1275
|
Button as Button5,
|
|
1108
1276
|
VStack as VStack2,
|
|
@@ -1134,7 +1302,7 @@ function ChangePassword({
|
|
|
1134
1302
|
}
|
|
1135
1303
|
});
|
|
1136
1304
|
const newPassword = watch("newPassword");
|
|
1137
|
-
|
|
1305
|
+
useEffect5(() => {
|
|
1138
1306
|
if (visible) {
|
|
1139
1307
|
reset();
|
|
1140
1308
|
}
|
|
@@ -1254,7 +1422,7 @@ function ChangePassword({
|
|
|
1254
1422
|
}
|
|
1255
1423
|
|
|
1256
1424
|
// src/components/profile/Profile.tsx
|
|
1257
|
-
import { useEffect as
|
|
1425
|
+
import { useEffect as useEffect6 } from "react";
|
|
1258
1426
|
import {
|
|
1259
1427
|
Button as Button6,
|
|
1260
1428
|
VStack as VStack3,
|
|
@@ -1288,13 +1456,13 @@ function Profile({
|
|
|
1288
1456
|
}
|
|
1289
1457
|
});
|
|
1290
1458
|
const modalBusy = isSubmitting || loading;
|
|
1291
|
-
|
|
1459
|
+
useEffect6(() => {
|
|
1292
1460
|
if (visible) {
|
|
1293
1461
|
fetchProfile().then(() => {
|
|
1294
1462
|
});
|
|
1295
1463
|
}
|
|
1296
1464
|
}, [visible, fetchProfile]);
|
|
1297
|
-
|
|
1465
|
+
useEffect6(() => {
|
|
1298
1466
|
if (profile) {
|
|
1299
1467
|
reset({
|
|
1300
1468
|
userName: profile.userName || "",
|
|
@@ -1869,6 +2037,7 @@ export {
|
|
|
1869
2037
|
Dialog2 as ChakraDialog,
|
|
1870
2038
|
ChangePassword,
|
|
1871
2039
|
Checkbox,
|
|
2040
|
+
Confirmation,
|
|
1872
2041
|
ConfirmationDialog,
|
|
1873
2042
|
ConfirmationProvider,
|
|
1874
2043
|
DEFAULT_STYLES,
|