@uxland/primary-shell 7.35.1 → 7.35.2
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/{component-Bz7NzBsL.js → component-C0H3AM4N.js} +2 -2
- package/dist/{component-Bz7NzBsL.js.map → component-C0H3AM4N.js.map} +1 -1
- package/dist/{index-umjRq-RK.js → index-CI2A4nGX.js} +14 -6
- package/dist/index-CI2A4nGX.js.map +1 -0
- package/dist/index.js +1 -1
- package/dist/index.umd.cjs +1 -1
- package/dist/index.umd.cjs.map +1 -1
- package/dist/primary/shell/src/UI/internal-views/common-nav-menu.d.ts +1 -1
- package/dist/primary/shell/src/api/notification-service/notification.service-impl.d.ts +2 -0
- package/dist/primary/shell/src/handle-plugins.d.ts +1 -1
- package/package.json +1 -1
- package/src/api/notification-service/notification-service-impl.test.ts +27 -0
- package/src/api/notification-service/notification.service-impl.ts +29 -5
- package/dist/index-umjRq-RK.js.map +0 -1
|
@@ -29,7 +29,7 @@ export declare const commonNavMenuItems: {
|
|
|
29
29
|
label: string;
|
|
30
30
|
type: string;
|
|
31
31
|
sortHint: string;
|
|
32
|
-
callbackFn: () =>
|
|
32
|
+
callbackFn: () => any;
|
|
33
33
|
}[];
|
|
34
34
|
export declare const registerNavMenuViews: (views: MenuItemConfig[]) => void;
|
|
35
35
|
export declare const registerCommunicationNavMenu: () => void;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { PrimariaNotificationService } from './notification-service';
|
|
2
2
|
export declare class PrimariaNotificationServiceImpl extends PrimariaNotificationService {
|
|
3
|
+
private getOrCreateContainer;
|
|
4
|
+
private removeContainerIfEmpty;
|
|
3
5
|
private notify;
|
|
4
6
|
info(message: string, duration?: number): void;
|
|
5
7
|
warning(message: string, duration?: number): void;
|
|
@@ -13,5 +13,5 @@ interface PrimariaBootstrappedPlugin extends BootstrappedPlugin<PrimariaApi> {
|
|
|
13
13
|
}
|
|
14
14
|
export declare const bootstrapPlugins: (plugins: PluginDefinition[], startup?: PrimariaStartupPlugin) => Promise<void>;
|
|
15
15
|
export declare const handleStartupPlugin: (plugins: PrimariaBootstrappedPlugin[], startupPlugin?: PrimariaStartupPlugin) => void;
|
|
16
|
-
export declare const disposePlugins: () => Promise<
|
|
16
|
+
export declare const disposePlugins: () => Promise<any>;
|
|
17
17
|
export type Plugin = PluginType<PrimariaApi>;
|
package/package.json
CHANGED
|
@@ -37,6 +37,13 @@ describe("PrimariaNotificationServiceImpl", () => {
|
|
|
37
37
|
assertToast(state, message);
|
|
38
38
|
});
|
|
39
39
|
|
|
40
|
+
it("should create a container for toasts", () => {
|
|
41
|
+
service.info("Test");
|
|
42
|
+
const container = document.getElementById("primaria-toast-container");
|
|
43
|
+
expect(container).not.toBeNull();
|
|
44
|
+
expect(container?.style.position).toBe("fixed");
|
|
45
|
+
});
|
|
46
|
+
|
|
40
47
|
it("should remove the toast after the duration", () => {
|
|
41
48
|
service.info("Temporary toast", 2000);
|
|
42
49
|
|
|
@@ -53,4 +60,24 @@ describe("PrimariaNotificationServiceImpl", () => {
|
|
|
53
60
|
toast = document.querySelector("dss-toast") as HTMLElement;
|
|
54
61
|
expect(toast).toBeNull();
|
|
55
62
|
});
|
|
63
|
+
|
|
64
|
+
it("should remove the container when all toasts are dismissed", () => {
|
|
65
|
+
service.info("Toast 1", 1000);
|
|
66
|
+
|
|
67
|
+
vi.advanceTimersByTime(1000);
|
|
68
|
+
vi.advanceTimersByTime(300);
|
|
69
|
+
|
|
70
|
+
const container = document.getElementById("primaria-toast-container");
|
|
71
|
+
expect(container).toBeNull();
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it("should stack multiple toasts in the same container", () => {
|
|
75
|
+
service.info("Toast 1");
|
|
76
|
+
service.warning("Toast 2");
|
|
77
|
+
service.error("Toast 3");
|
|
78
|
+
|
|
79
|
+
const container = document.getElementById("primaria-toast-container");
|
|
80
|
+
const toasts = container?.querySelectorAll("dss-toast");
|
|
81
|
+
expect(toasts?.length).toBe(3);
|
|
82
|
+
});
|
|
56
83
|
});
|
|
@@ -1,12 +1,33 @@
|
|
|
1
1
|
import { PrimariaNotificationService } from "./notification-service";
|
|
2
2
|
|
|
3
|
+
const CONTAINER_ID = "primaria-toast-container";
|
|
4
|
+
|
|
3
5
|
export class PrimariaNotificationServiceImpl extends PrimariaNotificationService {
|
|
6
|
+
private getOrCreateContainer(): HTMLElement {
|
|
7
|
+
let container = document.getElementById(CONTAINER_ID);
|
|
8
|
+
if (!container) {
|
|
9
|
+
container = document.createElement("div");
|
|
10
|
+
container.id = CONTAINER_ID;
|
|
11
|
+
container.style.cssText =
|
|
12
|
+
"position:fixed;bottom:var(--dss-spacing-xxs,8px);left:var(--dss-spacing-xxs,8px);display:flex;flex-direction:column-reverse;gap:var(--dss-spacing-xs,4px);z-index:999;pointer-events:none;";
|
|
13
|
+
document.body.appendChild(container);
|
|
14
|
+
}
|
|
15
|
+
return container;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
private removeContainerIfEmpty(container: HTMLElement): void {
|
|
19
|
+
if (container.childElementCount === 0) {
|
|
20
|
+
container.remove();
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
4
24
|
private notify(
|
|
5
25
|
message: string,
|
|
6
26
|
state: "info" | "warning" | "error" | "success",
|
|
7
27
|
duration = 3000,
|
|
8
28
|
): void {
|
|
9
|
-
|
|
29
|
+
const container = this.getOrCreateContainer();
|
|
30
|
+
|
|
10
31
|
const toast = document.createElement("dss-toast");
|
|
11
32
|
toast.setAttribute("isshow", "true");
|
|
12
33
|
toast.setAttribute("state", state);
|
|
@@ -14,16 +35,19 @@ export class PrimariaNotificationServiceImpl extends PrimariaNotificationService
|
|
|
14
35
|
toast.setAttribute("text", message);
|
|
15
36
|
toast.setAttribute("hasicon", "true");
|
|
16
37
|
toast.setAttribute("duration", duration.toString());
|
|
38
|
+
toast.style.position = "relative";
|
|
39
|
+
toast.style.bottom = "auto";
|
|
40
|
+
toast.style.left = "auto";
|
|
41
|
+
toast.style.pointerEvents = "auto";
|
|
17
42
|
|
|
18
|
-
|
|
19
|
-
document.body.appendChild(toast);
|
|
43
|
+
container.appendChild(toast);
|
|
20
44
|
|
|
21
|
-
// Remover después del tiempo de duración
|
|
22
45
|
setTimeout(() => {
|
|
23
46
|
toast.setAttribute("isshow", "false");
|
|
24
47
|
setTimeout(() => {
|
|
25
48
|
toast.remove();
|
|
26
|
-
|
|
49
|
+
this.removeContainerIfEmpty(container);
|
|
50
|
+
}, 300);
|
|
27
51
|
}, duration);
|
|
28
52
|
}
|
|
29
53
|
|