@cedx/base 0.17.0 → 0.18.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/ReadMe.md +1 -1
- package/lib/UI/Components/DialogButton.d.ts.map +1 -1
- package/lib/UI/Components/DialogButton.js +12 -3
- package/lib/UI/Components/MessageBox.d.ts +165 -0
- package/lib/UI/Components/MessageBox.d.ts.map +1 -0
- package/lib/UI/Components/MessageBox.js +320 -0
- package/lib/UI/Components/ThemeDropdown.d.ts.map +1 -1
- package/lib/UI/Components/Toast.d.ts.map +1 -1
- package/lib/UI/Components/Toast.js +31 -16
- package/lib/UI/Components/Toaster.d.ts +6 -2
- package/lib/UI/Components/Toaster.d.ts.map +1 -1
- package/lib/UI/Components/Toaster.js +19 -12
- package/package.json +2 -2
- package/src/Client/UI/Components/DialogButton.ts +6 -3
- package/src/Client/UI/Components/MessageBox.ts +417 -0
- package/src/Client/UI/Components/ThemeDropdown.ts +3 -9
- package/src/Client/UI/Components/Toast.ts +26 -15
- package/src/Client/UI/Components/Toaster.ts +27 -11
|
@@ -18,6 +18,14 @@ export class Toaster extends HTMLElement {
|
|
|
18
18
|
*/
|
|
19
19
|
readonly #toastTemplate: DocumentFragment = this.querySelector("template")!.content;
|
|
20
20
|
|
|
21
|
+
/**
|
|
22
|
+
* Creates a new toaster.
|
|
23
|
+
*/
|
|
24
|
+
constructor() {
|
|
25
|
+
super();
|
|
26
|
+
for (const toast of this.querySelectorAll("toaster-item")) toast.addEventListener("hidden.bs.toast", () => toast.remove());
|
|
27
|
+
}
|
|
28
|
+
|
|
21
29
|
/**
|
|
22
30
|
* Registers the component.
|
|
23
31
|
*/
|
|
@@ -86,7 +94,8 @@ export class Toaster extends HTMLElement {
|
|
|
86
94
|
return value.trim() || null;
|
|
87
95
|
}
|
|
88
96
|
set icon(value: string|null) {
|
|
89
|
-
this.
|
|
97
|
+
if (value) this.setAttribute("icon", value);
|
|
98
|
+
else this.removeAttribute("icon");
|
|
90
99
|
}
|
|
91
100
|
|
|
92
101
|
/**
|
|
@@ -108,9 +117,7 @@ export class Toaster extends HTMLElement {
|
|
|
108
117
|
*/
|
|
109
118
|
attributeChangedCallback(attribute: string, oldValue: string|null, newValue: string|null): void {
|
|
110
119
|
if (newValue != oldValue) switch (attribute) {
|
|
111
|
-
case "position":
|
|
112
|
-
this.#updatePosition(Object.values(Position).includes(newValue as Position) ? newValue as Position : Position.BottomEnd);
|
|
113
|
-
break;
|
|
120
|
+
case "position": this.#updatePosition(Object.values(Position).includes(newValue as Position) ? newValue as Position : Position.BottomEnd); break;
|
|
114
121
|
// No default
|
|
115
122
|
}
|
|
116
123
|
}
|
|
@@ -121,18 +128,27 @@ export class Toaster extends HTMLElement {
|
|
|
121
128
|
* @param caption The title displayed in the toast header.
|
|
122
129
|
* @param body The child content displayed in the toast body.
|
|
123
130
|
*/
|
|
124
|
-
|
|
125
|
-
this.show({context, caption, body});
|
|
126
|
-
}
|
|
131
|
+
show(context: Context, caption: string, body: DocumentFragment|string): void;
|
|
127
132
|
|
|
128
133
|
/**
|
|
129
|
-
* Shows
|
|
134
|
+
* Shows a toast.
|
|
130
135
|
* @param toast The toast to show.
|
|
131
136
|
*/
|
|
132
|
-
show(toast: IToast): void
|
|
137
|
+
show(toast: IToast): void;
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Shows a toast.
|
|
141
|
+
* @param toast The toast to show, or the contextual modifier.
|
|
142
|
+
* @param caption The title displayed in the toast header.
|
|
143
|
+
* @param body The child content displayed in the toast body.
|
|
144
|
+
*/
|
|
145
|
+
show(toast: IToast|Context, caption = "", body: DocumentFragment|string = ""): void {
|
|
146
|
+
if (typeof toast == "string") toast = {context: toast, caption, body};
|
|
147
|
+
|
|
133
148
|
const item = document.createElement("toaster-item");
|
|
134
|
-
|
|
135
|
-
|
|
149
|
+
const childContent = (this.#toastTemplate.cloneNode(true) as DocumentFragment).querySelector(".toast")!;
|
|
150
|
+
childContent.addEventListener("hidden.bs.toast", () => item.remove());
|
|
151
|
+
item.appendChild(childContent);
|
|
136
152
|
|
|
137
153
|
item.animation = toast.animation ?? this.animation;
|
|
138
154
|
item.autoHide = toast.autoHide ?? this.autoHide;
|