@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.js
CHANGED
|
@@ -38,6 +38,7 @@ __export(index_exports, {
|
|
|
38
38
|
ChakraDialog: () => import_react11.Dialog,
|
|
39
39
|
ChangePassword: () => ChangePassword,
|
|
40
40
|
Checkbox: () => Checkbox,
|
|
41
|
+
Confirmation: () => Confirmation,
|
|
41
42
|
ConfirmationDialog: () => ConfirmationDialog,
|
|
42
43
|
ConfirmationProvider: () => ConfirmationProvider,
|
|
43
44
|
DEFAULT_STYLES: () => DEFAULT_STYLES,
|
|
@@ -84,6 +85,17 @@ var Toaster;
|
|
|
84
85
|
})(Status = Toaster2.Status || (Toaster2.Status = {}));
|
|
85
86
|
})(Toaster || (Toaster = {}));
|
|
86
87
|
|
|
88
|
+
// src/models/confirmation.ts
|
|
89
|
+
var Confirmation;
|
|
90
|
+
((Confirmation2) => {
|
|
91
|
+
let Status;
|
|
92
|
+
((Status2) => {
|
|
93
|
+
Status2["confirm"] = "confirm";
|
|
94
|
+
Status2["reject"] = "reject";
|
|
95
|
+
Status2["dismiss"] = "dismiss";
|
|
96
|
+
})(Status = Confirmation2.Status || (Confirmation2.Status = {}));
|
|
97
|
+
})(Confirmation || (Confirmation = {}));
|
|
98
|
+
|
|
87
99
|
// src/constants/styles.ts
|
|
88
100
|
var DEFAULT_STYLES = `
|
|
89
101
|
.is-invalid .form-control {
|
|
@@ -111,25 +123,114 @@ var DEFAULT_STYLES = `
|
|
|
111
123
|
top: 18px;
|
|
112
124
|
}
|
|
113
125
|
|
|
114
|
-
.
|
|
115
|
-
|
|
126
|
+
.navbar .dropdown-menu {
|
|
127
|
+
min-width: 215px;
|
|
116
128
|
}
|
|
117
129
|
|
|
118
|
-
.
|
|
130
|
+
.ui-table-scrollable-body::-webkit-scrollbar {
|
|
131
|
+
height: 5px !important;
|
|
132
|
+
width: 5px !important;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
.ui-table-scrollable-body::-webkit-scrollbar-track {
|
|
136
|
+
background: #ddd;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
.ui-table-scrollable-body::-webkit-scrollbar-thumb {
|
|
140
|
+
background: #8a8686;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
.abp-ellipsis-inline {
|
|
119
144
|
display: inline-block;
|
|
120
145
|
overflow: hidden;
|
|
121
146
|
text-overflow: ellipsis;
|
|
122
147
|
white-space: nowrap;
|
|
123
148
|
}
|
|
124
149
|
|
|
150
|
+
.abp-ellipsis {
|
|
151
|
+
overflow: hidden !important;
|
|
152
|
+
text-overflow: ellipsis;
|
|
153
|
+
white-space: nowrap;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
.ui-widget-overlay {
|
|
157
|
+
z-index: 1000;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
.color-white {
|
|
161
|
+
color: #FFF !important;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
.custom-checkbox > label {
|
|
165
|
+
cursor: pointer;
|
|
166
|
+
}
|
|
167
|
+
|
|
125
168
|
/* <animations */
|
|
126
169
|
|
|
127
170
|
.fade-in-top {
|
|
128
|
-
animation: fadeInTop 0.
|
|
171
|
+
animation: fadeInTop 0.2s ease-in-out;
|
|
129
172
|
}
|
|
130
173
|
|
|
131
174
|
.fade-out-top {
|
|
132
|
-
animation: fadeOutTop 0.
|
|
175
|
+
animation: fadeOutTop 0.2s ease-in-out;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
.abp-collapsed-height {
|
|
179
|
+
-moz-transition: max-height linear 0.35s;
|
|
180
|
+
-ms-transition: max-height linear 0.35s;
|
|
181
|
+
-o-transition: max-height linear 0.35s;
|
|
182
|
+
-webkit-transition: max-height linear 0.35s;
|
|
183
|
+
overflow:hidden;
|
|
184
|
+
transition:max-height 0.35s linear;
|
|
185
|
+
height:auto;
|
|
186
|
+
max-height: 0;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
.abp-mh-25 {
|
|
190
|
+
max-height: 25vh;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
.abp-mh-50 {
|
|
194
|
+
transition:max-height 0.65s linear;
|
|
195
|
+
max-height: 50vh;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
.abp-mh-75 {
|
|
199
|
+
transition:max-height 0.85s linear;
|
|
200
|
+
max-height: 75vh;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
.abp-mh-100 {
|
|
204
|
+
transition:max-height 1s linear;
|
|
205
|
+
max-height: 100vh;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/* Sorting icon styles - @since 2.0.0 */
|
|
209
|
+
[class^="sorting"] {
|
|
210
|
+
opacity: .3;
|
|
211
|
+
cursor: pointer;
|
|
212
|
+
}
|
|
213
|
+
[class^="sorting"]:before {
|
|
214
|
+
right: 0.5rem;
|
|
215
|
+
content: "\u2191";
|
|
216
|
+
}
|
|
217
|
+
[class^="sorting"]:after {
|
|
218
|
+
right: 0.5rem;
|
|
219
|
+
content: "\u2193";
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
.sorting_desc {
|
|
223
|
+
opacity: 1;
|
|
224
|
+
}
|
|
225
|
+
.sorting_desc:before {
|
|
226
|
+
opacity: .3;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
.sorting_asc {
|
|
230
|
+
opacity: 1;
|
|
231
|
+
}
|
|
232
|
+
.sorting_asc:after {
|
|
233
|
+
opacity: .3;
|
|
133
234
|
}
|
|
134
235
|
|
|
135
236
|
@keyframes fadeInTop {
|
|
@@ -139,7 +240,7 @@ var DEFAULT_STYLES = `
|
|
|
139
240
|
}
|
|
140
241
|
|
|
141
242
|
to {
|
|
142
|
-
transform: translateY(
|
|
243
|
+
transform: translateY(0px);
|
|
143
244
|
opacity: 1;
|
|
144
245
|
}
|
|
145
246
|
}
|
|
@@ -179,37 +280,33 @@ var ToasterContext = (0, import_react.createContext)(null);
|
|
|
179
280
|
var toastCounter = 0;
|
|
180
281
|
function generateId() {
|
|
181
282
|
toastCounter += 1;
|
|
182
|
-
return
|
|
283
|
+
return toastCounter;
|
|
183
284
|
}
|
|
184
285
|
var DEFAULT_LIFE = 5e3;
|
|
185
|
-
function resolveLocalizationParam(param) {
|
|
186
|
-
if (param === void 0) return void 0;
|
|
187
|
-
if (typeof param === "string") return param;
|
|
188
|
-
return param.defaultValue || param.key;
|
|
189
|
-
}
|
|
190
286
|
function ToasterProvider({ children }) {
|
|
191
287
|
const [toasts, setToasts] = (0, import_react.useState)([]);
|
|
192
|
-
const
|
|
288
|
+
const subscribersRef = (0, import_react.useRef)(/* @__PURE__ */ new Set());
|
|
289
|
+
(0, import_react.useEffect)(() => {
|
|
290
|
+
subscribersRef.current.forEach((subscriber) => {
|
|
291
|
+
subscriber(toasts);
|
|
292
|
+
});
|
|
293
|
+
}, [toasts]);
|
|
193
294
|
const remove = (0, import_react.useCallback)((id) => {
|
|
194
295
|
setToasts((prev) => prev.filter((t) => t.id !== id));
|
|
195
|
-
const resolver = resolversRef.current.get(id);
|
|
196
|
-
if (resolver) {
|
|
197
|
-
resolver(Toaster.Status.dismiss);
|
|
198
|
-
resolversRef.current.delete(id);
|
|
199
|
-
}
|
|
200
296
|
}, []);
|
|
201
297
|
const show = (0, import_react.useCallback)(
|
|
202
|
-
(message, title, severity, options) => {
|
|
203
|
-
const id = options?.id
|
|
298
|
+
(message, title, severity = "info", options) => {
|
|
299
|
+
const id = typeof options?.id === "number" ? options.id : generateId();
|
|
204
300
|
const life = options?.sticky ? void 0 : options?.life ?? DEFAULT_LIFE;
|
|
205
|
-
const resolvedMessage = resolveLocalizationParam(message) || "";
|
|
206
|
-
const resolvedTitle = resolveLocalizationParam(title);
|
|
207
301
|
const toast = {
|
|
208
302
|
id,
|
|
209
|
-
message
|
|
210
|
-
title
|
|
303
|
+
message,
|
|
304
|
+
title,
|
|
211
305
|
severity,
|
|
212
|
-
|
|
306
|
+
options: {
|
|
307
|
+
...options,
|
|
308
|
+
id
|
|
309
|
+
}
|
|
213
310
|
};
|
|
214
311
|
setToasts((prev) => [...prev, toast]);
|
|
215
312
|
if (life) {
|
|
@@ -217,9 +314,7 @@ function ToasterProvider({ children }) {
|
|
|
217
314
|
remove(id);
|
|
218
315
|
}, life);
|
|
219
316
|
}
|
|
220
|
-
return
|
|
221
|
-
resolversRef.current.set(id, resolve);
|
|
222
|
-
});
|
|
317
|
+
return id;
|
|
223
318
|
},
|
|
224
319
|
[remove]
|
|
225
320
|
);
|
|
@@ -232,44 +327,40 @@ function ToasterProvider({ children }) {
|
|
|
232
327
|
[show]
|
|
233
328
|
);
|
|
234
329
|
const warn = (0, import_react.useCallback)(
|
|
235
|
-
(message, title, options) => show(message, title, "
|
|
330
|
+
(message, title, options) => show(message, title, "warning", options),
|
|
236
331
|
[show]
|
|
237
332
|
);
|
|
238
333
|
const error = (0, import_react.useCallback)(
|
|
239
334
|
(message, title, options) => show(message, title, "error", options),
|
|
240
335
|
[show]
|
|
241
336
|
);
|
|
242
|
-
const
|
|
243
|
-
(messages) => {
|
|
244
|
-
messages.forEach((msg) => {
|
|
245
|
-
show(msg.message, msg.title, msg.severity, msg);
|
|
246
|
-
});
|
|
247
|
-
},
|
|
248
|
-
[show]
|
|
249
|
-
);
|
|
250
|
-
const clear = (0, import_react.useCallback)((status) => {
|
|
337
|
+
const clear = (0, import_react.useCallback)((key) => {
|
|
251
338
|
setToasts((prev) => {
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
resolver(status ?? Toaster.Status.dismiss);
|
|
256
|
-
resolversRef.current.delete(toast.id);
|
|
257
|
-
}
|
|
258
|
-
});
|
|
339
|
+
if (key) {
|
|
340
|
+
return prev.filter((toast) => toast.options?.containerKey !== key);
|
|
341
|
+
}
|
|
259
342
|
return [];
|
|
260
343
|
});
|
|
261
344
|
}, []);
|
|
345
|
+
const subscribe = (0, import_react.useCallback)((subscriber) => {
|
|
346
|
+
subscribersRef.current.add(subscriber);
|
|
347
|
+
subscriber(toasts);
|
|
348
|
+
return () => {
|
|
349
|
+
subscribersRef.current.delete(subscriber);
|
|
350
|
+
};
|
|
351
|
+
}, [toasts]);
|
|
262
352
|
const service = (0, import_react.useMemo)(
|
|
263
353
|
() => ({
|
|
264
354
|
info,
|
|
265
355
|
success,
|
|
266
356
|
warn,
|
|
267
357
|
error,
|
|
268
|
-
|
|
358
|
+
show,
|
|
359
|
+
remove,
|
|
269
360
|
clear,
|
|
270
|
-
|
|
361
|
+
subscribe
|
|
271
362
|
}),
|
|
272
|
-
[info, success, warn, error,
|
|
363
|
+
[info, success, warn, error, show, remove, clear, subscribe]
|
|
273
364
|
);
|
|
274
365
|
const value = (0, import_react.useMemo)(
|
|
275
366
|
() => ({ service, toasts }),
|
|
@@ -309,6 +400,13 @@ function generateId2() {
|
|
|
309
400
|
function ConfirmationProvider({ children }) {
|
|
310
401
|
const [confirmation, setConfirmation] = (0, import_react2.useState)(null);
|
|
311
402
|
const resolverRef = (0, import_react2.useRef)(null);
|
|
403
|
+
const subscribersRef = (0, import_react2.useRef)(/* @__PURE__ */ new Set());
|
|
404
|
+
const escapeListenerRef = (0, import_react2.useRef)(false);
|
|
405
|
+
(0, import_react2.useEffect)(() => {
|
|
406
|
+
subscribersRef.current.forEach((subscriber) => {
|
|
407
|
+
subscriber(confirmation);
|
|
408
|
+
});
|
|
409
|
+
}, [confirmation]);
|
|
312
410
|
const respond = (0, import_react2.useCallback)((status) => {
|
|
313
411
|
if (resolverRef.current) {
|
|
314
412
|
resolverRef.current(status);
|
|
@@ -316,20 +414,34 @@ function ConfirmationProvider({ children }) {
|
|
|
316
414
|
}
|
|
317
415
|
setConfirmation(null);
|
|
318
416
|
}, []);
|
|
417
|
+
(0, import_react2.useEffect)(() => {
|
|
418
|
+
if (!escapeListenerRef.current) return;
|
|
419
|
+
const handleEscape = (event) => {
|
|
420
|
+
if (event.key === "Escape" && confirmation && confirmation.options?.closable !== false) {
|
|
421
|
+
respond(Confirmation.Status.dismiss);
|
|
422
|
+
}
|
|
423
|
+
};
|
|
424
|
+
document.addEventListener("keydown", handleEscape);
|
|
425
|
+
return () => {
|
|
426
|
+
document.removeEventListener("keydown", handleEscape);
|
|
427
|
+
};
|
|
428
|
+
}, [confirmation, respond]);
|
|
319
429
|
const show = (0, import_react2.useCallback)(
|
|
320
|
-
(message, title, severity, options = {}) => {
|
|
430
|
+
(message, title, severity = "neutral", options = {}) => {
|
|
321
431
|
if (resolverRef.current) {
|
|
322
|
-
resolverRef.current(
|
|
432
|
+
resolverRef.current(Confirmation.Status.dismiss);
|
|
323
433
|
}
|
|
324
434
|
const id = options.id?.toString() || generateId2();
|
|
325
|
-
const
|
|
326
|
-
id,
|
|
435
|
+
const dialogData = {
|
|
327
436
|
message,
|
|
328
437
|
title,
|
|
329
438
|
severity,
|
|
330
|
-
options
|
|
439
|
+
options: {
|
|
440
|
+
...options,
|
|
441
|
+
id
|
|
442
|
+
}
|
|
331
443
|
};
|
|
332
|
-
setConfirmation(
|
|
444
|
+
setConfirmation(dialogData);
|
|
333
445
|
return new Promise((resolve) => {
|
|
334
446
|
resolverRef.current = resolve;
|
|
335
447
|
});
|
|
@@ -345,7 +457,7 @@ function ConfirmationProvider({ children }) {
|
|
|
345
457
|
[show]
|
|
346
458
|
);
|
|
347
459
|
const warn = (0, import_react2.useCallback)(
|
|
348
|
-
(message, title, options) => show(message, title, "
|
|
460
|
+
(message, title, options) => show(message, title, "warning", options),
|
|
349
461
|
[show]
|
|
350
462
|
);
|
|
351
463
|
const error = (0, import_react2.useCallback)(
|
|
@@ -354,19 +466,32 @@ function ConfirmationProvider({ children }) {
|
|
|
354
466
|
);
|
|
355
467
|
const clear = (0, import_react2.useCallback)(
|
|
356
468
|
(status) => {
|
|
357
|
-
respond(status ??
|
|
469
|
+
respond(status ?? Confirmation.Status.dismiss);
|
|
358
470
|
},
|
|
359
471
|
[respond]
|
|
360
472
|
);
|
|
473
|
+
const listenToEscape = (0, import_react2.useCallback)(() => {
|
|
474
|
+
escapeListenerRef.current = true;
|
|
475
|
+
}, []);
|
|
476
|
+
const subscribe = (0, import_react2.useCallback)((subscriber) => {
|
|
477
|
+
subscribersRef.current.add(subscriber);
|
|
478
|
+
subscriber(confirmation);
|
|
479
|
+
return () => {
|
|
480
|
+
subscribersRef.current.delete(subscriber);
|
|
481
|
+
};
|
|
482
|
+
}, [confirmation]);
|
|
361
483
|
const service = (0, import_react2.useMemo)(
|
|
362
484
|
() => ({
|
|
363
485
|
info,
|
|
364
486
|
success,
|
|
365
487
|
warn,
|
|
366
488
|
error,
|
|
367
|
-
|
|
489
|
+
show,
|
|
490
|
+
clear,
|
|
491
|
+
listenToEscape,
|
|
492
|
+
subscribe
|
|
368
493
|
}),
|
|
369
|
-
[info, success, warn, error, clear]
|
|
494
|
+
[info, success, warn, error, show, clear, listenToEscape, subscribe]
|
|
370
495
|
);
|
|
371
496
|
const value = (0, import_react2.useMemo)(
|
|
372
497
|
() => ({ service, confirmation, respond }),
|
|
@@ -484,6 +609,11 @@ var import_react5 = require("@chakra-ui/react");
|
|
|
484
609
|
var import_core = require("@abpjs/core");
|
|
485
610
|
var import_lucide_react = require("lucide-react");
|
|
486
611
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
612
|
+
function resolveLocalizationParam(param) {
|
|
613
|
+
if (param === void 0) return void 0;
|
|
614
|
+
if (typeof param === "string") return param;
|
|
615
|
+
return param.defaultValue || param.key;
|
|
616
|
+
}
|
|
487
617
|
function SeverityIcon({ severity }) {
|
|
488
618
|
const iconProps = { size: 20 };
|
|
489
619
|
switch (severity) {
|
|
@@ -491,10 +621,13 @@ function SeverityIcon({ severity }) {
|
|
|
491
621
|
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_lucide_react.CheckCircle, { ...iconProps, color: "var(--chakra-colors-green-500)" });
|
|
492
622
|
case "info":
|
|
493
623
|
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_lucide_react.Info, { ...iconProps, color: "var(--chakra-colors-blue-500)" });
|
|
494
|
-
case "
|
|
624
|
+
case "warning":
|
|
495
625
|
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_lucide_react.AlertTriangle, { ...iconProps, color: "var(--chakra-colors-yellow-500)" });
|
|
496
626
|
case "error":
|
|
497
627
|
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_lucide_react.XCircle, { ...iconProps, color: "var(--chakra-colors-red-500)" });
|
|
628
|
+
case "neutral":
|
|
629
|
+
default:
|
|
630
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_lucide_react.Circle, { ...iconProps, color: "var(--chakra-colors-gray-500)" });
|
|
498
631
|
}
|
|
499
632
|
}
|
|
500
633
|
function getSeverityColorPalette(severity) {
|
|
@@ -503,10 +636,13 @@ function getSeverityColorPalette(severity) {
|
|
|
503
636
|
return "green";
|
|
504
637
|
case "info":
|
|
505
638
|
return "blue";
|
|
506
|
-
case "
|
|
639
|
+
case "warning":
|
|
507
640
|
return "yellow";
|
|
508
641
|
case "error":
|
|
509
642
|
return "red";
|
|
643
|
+
case "neutral":
|
|
644
|
+
default:
|
|
645
|
+
return "gray";
|
|
510
646
|
}
|
|
511
647
|
}
|
|
512
648
|
function getSeverityBg(severity) {
|
|
@@ -515,10 +651,13 @@ function getSeverityBg(severity) {
|
|
|
515
651
|
return "green.50";
|
|
516
652
|
case "info":
|
|
517
653
|
return "blue.50";
|
|
518
|
-
case "
|
|
654
|
+
case "warning":
|
|
519
655
|
return "yellow.50";
|
|
520
656
|
case "error":
|
|
521
657
|
return "red.50";
|
|
658
|
+
case "neutral":
|
|
659
|
+
default:
|
|
660
|
+
return "gray.50";
|
|
522
661
|
}
|
|
523
662
|
}
|
|
524
663
|
function getSeverityBorderColor(severity) {
|
|
@@ -527,10 +666,13 @@ function getSeverityBorderColor(severity) {
|
|
|
527
666
|
return "green.200";
|
|
528
667
|
case "info":
|
|
529
668
|
return "blue.200";
|
|
530
|
-
case "
|
|
669
|
+
case "warning":
|
|
531
670
|
return "yellow.200";
|
|
532
671
|
case "error":
|
|
533
672
|
return "red.200";
|
|
673
|
+
case "neutral":
|
|
674
|
+
default:
|
|
675
|
+
return "gray.200";
|
|
534
676
|
}
|
|
535
677
|
}
|
|
536
678
|
function mapSeverityToType(severity) {
|
|
@@ -539,10 +681,13 @@ function mapSeverityToType(severity) {
|
|
|
539
681
|
return "success";
|
|
540
682
|
case "info":
|
|
541
683
|
return "info";
|
|
542
|
-
case "
|
|
684
|
+
case "warning":
|
|
543
685
|
return "warning";
|
|
544
686
|
case "error":
|
|
545
687
|
return "error";
|
|
688
|
+
case "neutral":
|
|
689
|
+
default:
|
|
690
|
+
return "info";
|
|
546
691
|
}
|
|
547
692
|
}
|
|
548
693
|
function getPlacement(position) {
|
|
@@ -574,31 +719,38 @@ function getToaster(placement) {
|
|
|
574
719
|
}
|
|
575
720
|
return toasterCache.get(placement);
|
|
576
721
|
}
|
|
577
|
-
function ToastContainer({ position = "bottom-right" }) {
|
|
722
|
+
function ToastContainer({ position = "bottom-right", containerKey }) {
|
|
578
723
|
const { toasts, service } = useToasterContext();
|
|
579
724
|
const { t } = (0, import_core.useLocalization)();
|
|
580
725
|
const displayedToastsRef = (0, import_react4.useRef)(/* @__PURE__ */ new Set());
|
|
581
726
|
const placement = (0, import_react4.useMemo)(() => getPlacement(position), [position]);
|
|
582
727
|
const toaster = (0, import_react4.useMemo)(() => getToaster(placement), [placement]);
|
|
728
|
+
const filteredToasts = (0, import_react4.useMemo)(() => {
|
|
729
|
+
if (!containerKey) return toasts;
|
|
730
|
+
return toasts.filter((toast) => toast.options?.containerKey === containerKey);
|
|
731
|
+
}, [toasts, containerKey]);
|
|
583
732
|
(0, import_react4.useEffect)(() => {
|
|
584
|
-
const newToasts =
|
|
733
|
+
const newToasts = filteredToasts.filter((toast) => !displayedToastsRef.current.has(toast.id));
|
|
585
734
|
newToasts.forEach((toast) => {
|
|
586
735
|
displayedToastsRef.current.add(toast.id);
|
|
736
|
+
const messageStr = resolveLocalizationParam(toast.message) || "";
|
|
587
737
|
const localizedMessage = t(
|
|
588
|
-
|
|
589
|
-
...toast.messageLocalizationParams || []
|
|
738
|
+
messageStr,
|
|
739
|
+
...toast.options?.messageLocalizationParams || []
|
|
590
740
|
);
|
|
591
|
-
const
|
|
741
|
+
const titleStr = resolveLocalizationParam(toast.title);
|
|
742
|
+
const localizedTitle = titleStr ? t(titleStr, ...toast.options?.titleLocalizationParams || []) : void 0;
|
|
743
|
+
const severity = toast.severity || "info";
|
|
592
744
|
requestAnimationFrame(() => {
|
|
593
745
|
toaster.create({
|
|
594
|
-
id: toast.id,
|
|
746
|
+
id: String(toast.id),
|
|
595
747
|
title: localizedTitle,
|
|
596
748
|
description: localizedMessage,
|
|
597
|
-
type: mapSeverityToType(
|
|
598
|
-
duration: toast.sticky ? void 0 : toast.life || 5e3,
|
|
749
|
+
type: mapSeverityToType(severity),
|
|
750
|
+
duration: toast.options?.sticky ? void 0 : toast.options?.life || 5e3,
|
|
599
751
|
meta: {
|
|
600
|
-
closable: toast.closable !== false,
|
|
601
|
-
severity
|
|
752
|
+
closable: toast.options?.closable !== false,
|
|
753
|
+
severity
|
|
602
754
|
},
|
|
603
755
|
onStatusChange: (details) => {
|
|
604
756
|
if (details.status === "unmounted") {
|
|
@@ -609,7 +761,7 @@ function ToastContainer({ position = "bottom-right" }) {
|
|
|
609
761
|
});
|
|
610
762
|
});
|
|
611
763
|
});
|
|
612
|
-
}, [
|
|
764
|
+
}, [filteredToasts, t, service, toaster]);
|
|
613
765
|
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react5.Portal, { children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react5.Toaster, { toaster, insetInline: { mdDown: "4" }, children: (toast) => {
|
|
614
766
|
const severity = toast.meta?.severity || "info";
|
|
615
767
|
const closable = toast.meta?.closable !== false;
|
|
@@ -641,6 +793,11 @@ var import_react7 = require("@chakra-ui/react");
|
|
|
641
793
|
var import_core2 = require("@abpjs/core");
|
|
642
794
|
var import_lucide_react2 = require("lucide-react");
|
|
643
795
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
796
|
+
function resolveLocalizationParam2(param) {
|
|
797
|
+
if (param === void 0) return void 0;
|
|
798
|
+
if (typeof param === "string") return param;
|
|
799
|
+
return param.defaultValue || param.key;
|
|
800
|
+
}
|
|
644
801
|
function getLocalizationKey(param) {
|
|
645
802
|
if (param === void 0) return void 0;
|
|
646
803
|
if (typeof param === "string") return param;
|
|
@@ -653,10 +810,13 @@ function SeverityIcon2({ severity }) {
|
|
|
653
810
|
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_lucide_react2.CheckCircle, { ...iconProps, color: "var(--chakra-colors-green-500)" });
|
|
654
811
|
case "info":
|
|
655
812
|
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_lucide_react2.Info, { ...iconProps, color: "var(--chakra-colors-blue-500)" });
|
|
656
|
-
case "
|
|
813
|
+
case "warning":
|
|
657
814
|
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_lucide_react2.AlertTriangle, { ...iconProps, color: "var(--chakra-colors-yellow-500)" });
|
|
658
815
|
case "error":
|
|
659
816
|
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_lucide_react2.XCircle, { ...iconProps, color: "var(--chakra-colors-red-500)" });
|
|
817
|
+
case "neutral":
|
|
818
|
+
default:
|
|
819
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_lucide_react2.Circle, { ...iconProps, color: "var(--chakra-colors-gray-500)" });
|
|
660
820
|
}
|
|
661
821
|
}
|
|
662
822
|
function getSeverityColorPalette2(severity) {
|
|
@@ -665,10 +825,13 @@ function getSeverityColorPalette2(severity) {
|
|
|
665
825
|
return "green";
|
|
666
826
|
case "info":
|
|
667
827
|
return "blue";
|
|
668
|
-
case "
|
|
828
|
+
case "warning":
|
|
669
829
|
return "yellow";
|
|
670
830
|
case "error":
|
|
671
831
|
return "red";
|
|
832
|
+
case "neutral":
|
|
833
|
+
default:
|
|
834
|
+
return "gray";
|
|
672
835
|
}
|
|
673
836
|
}
|
|
674
837
|
function ConfirmationDialog({ className }) {
|
|
@@ -678,27 +841,29 @@ function ConfirmationDialog({ className }) {
|
|
|
678
841
|
if (!confirmation) {
|
|
679
842
|
return null;
|
|
680
843
|
}
|
|
681
|
-
const { message, title, severity, options } = confirmation;
|
|
844
|
+
const { message, title, severity = "neutral", options } = confirmation;
|
|
845
|
+
const messageStr = resolveLocalizationParam2(message) || "";
|
|
682
846
|
const localizedMessage = t(
|
|
683
|
-
|
|
684
|
-
...options
|
|
847
|
+
messageStr,
|
|
848
|
+
...options?.messageLocalizationParams || []
|
|
685
849
|
);
|
|
686
|
-
const
|
|
687
|
-
const
|
|
688
|
-
const
|
|
850
|
+
const titleStr = resolveLocalizationParam2(title);
|
|
851
|
+
const localizedTitle = titleStr ? t(titleStr, ...options?.titleLocalizationParams || []) : void 0;
|
|
852
|
+
const yesKey = getLocalizationKey(options?.yesText);
|
|
853
|
+
const cancelKey = getLocalizationKey(options?.cancelText);
|
|
689
854
|
const yesCopy = yesKey ? t(yesKey) : t("AbpUi::Yes");
|
|
690
855
|
const cancelCopy = cancelKey ? t(cancelKey) : t("AbpUi::Cancel");
|
|
691
856
|
const handleConfirm = () => {
|
|
692
|
-
respond(
|
|
857
|
+
respond(Confirmation.Status.confirm);
|
|
693
858
|
};
|
|
694
859
|
const handleCancel = () => {
|
|
695
|
-
respond(
|
|
860
|
+
respond(Confirmation.Status.reject);
|
|
696
861
|
};
|
|
697
862
|
const handleDismiss = () => {
|
|
698
|
-
respond(
|
|
863
|
+
respond(Confirmation.Status.dismiss);
|
|
699
864
|
};
|
|
700
865
|
const handleOpenChange = (details) => {
|
|
701
|
-
if (!details.open) {
|
|
866
|
+
if (!details.open && options?.closable !== false) {
|
|
702
867
|
handleDismiss();
|
|
703
868
|
}
|
|
704
869
|
};
|
|
@@ -719,7 +884,7 @@ function ConfirmationDialog({ className }) {
|
|
|
719
884
|
] }) }),
|
|
720
885
|
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react7.Dialog.Body, { children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react7.Text, { color: "gray.600", children: localizedMessage }) }),
|
|
721
886
|
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react7.Dialog.Footer, { children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_react7.Flex, { gap: 3, children: [
|
|
722
|
-
!options
|
|
887
|
+
!options?.hideCancelBtn && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
723
888
|
import_react7.Button,
|
|
724
889
|
{
|
|
725
890
|
ref: cancelRef,
|
|
@@ -728,7 +893,7 @@ function ConfirmationDialog({ className }) {
|
|
|
728
893
|
children: cancelCopy
|
|
729
894
|
}
|
|
730
895
|
),
|
|
731
|
-
!options
|
|
896
|
+
!options?.hideYesBtn && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
732
897
|
import_react7.Button,
|
|
733
898
|
{
|
|
734
899
|
colorPalette: getSeverityColorPalette2(severity),
|
|
@@ -1887,6 +2052,7 @@ function injectThemeSharedStyles() {
|
|
|
1887
2052
|
ChakraDialog,
|
|
1888
2053
|
ChangePassword,
|
|
1889
2054
|
Checkbox,
|
|
2055
|
+
Confirmation,
|
|
1890
2056
|
ConfirmationDialog,
|
|
1891
2057
|
ConfirmationProvider,
|
|
1892
2058
|
DEFAULT_STYLES,
|