@cedx/base 0.21.1 → 0.23.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/BackButton.d.ts +2 -1
- package/lib/UI/Components/BackButton.d.ts.map +1 -1
- package/lib/UI/Components/BackButton.js +10 -2
- package/lib/UI/Components/DialogBox.d.ts +39 -23
- package/lib/UI/Components/DialogBox.d.ts.map +1 -1
- package/lib/UI/Components/DialogBox.js +48 -70
- package/lib/UI/Components/FullScreenToggler.d.ts +46 -0
- package/lib/UI/Components/FullScreenToggler.d.ts.map +1 -0
- package/lib/UI/Components/FullScreenToggler.js +109 -0
- package/lib/UI/Components/ThemeDropdown.js +3 -3
- package/lib/UI/Components/Toast.d.ts +0 -37
- package/lib/UI/Components/Toast.d.ts.map +1 -1
- package/lib/UI/Components/Toast.js +4 -4
- package/lib/UI/Components/Toaster.d.ts +39 -3
- package/lib/UI/Components/Toaster.d.ts.map +1 -1
- package/lib/UI/Components/Toaster.js +10 -5
- package/lib/UI/DialogResult.d.ts +2 -10
- package/lib/UI/DialogResult.d.ts.map +1 -1
- package/lib/UI/DialogResult.js +3 -11
- package/lib/UI/Tag.js +10 -6
- package/lib/UI/Variant.d.ts +12 -8
- package/lib/UI/Variant.d.ts.map +1 -1
- package/lib/UI/Variant.js +10 -8
- package/package.json +1 -1
- package/src/Client/UI/Components/BackButton.ts +11 -2
- package/src/Client/UI/Components/DialogBox.ts +79 -97
- package/src/Client/UI/Components/FullScreenToggler.ts +127 -0
- package/src/Client/UI/Components/ThemeDropdown.ts +3 -3
- package/src/Client/UI/Components/Toast.ts +4 -50
- package/src/Client/UI/Components/Toaster.ts +51 -14
- package/src/Client/UI/DialogResult.ts +3 -13
- package/src/Client/UI/Tag.ts +10 -4
- package/src/Client/UI/Variant.ts +11 -8
- package/lib/UI/Components/DialogButton.d.ts +0 -82
- package/lib/UI/Components/DialogButton.d.ts.map +0 -1
- package/lib/UI/Components/DialogButton.js +0 -151
- package/src/Client/UI/Components/DialogButton.ts +0 -190
package/ReadMe.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# Cédric Belin's Base
|
|
2
|
-
   
|
|
3
3
|
|
|
4
4
|
Base library by [Cédric Belin](https://cedric-belin.fr), full stack developer,
|
|
5
5
|
implemented in [C#](https://learn.microsoft.com/en-us/dotnet/csharp) and [TypeScript](https://www.typescriptlang.org).
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* A component that moves back
|
|
2
|
+
* A component that moves back in the session history when clicked.
|
|
3
3
|
*/
|
|
4
4
|
export declare class BackButton extends HTMLElement {
|
|
5
|
+
#private;
|
|
5
6
|
/**
|
|
6
7
|
* Creates a new back button.
|
|
7
8
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BackButton.d.ts","sourceRoot":"","sources":["../../../src/Client/UI/Components/BackButton.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,UAAW,SAAQ,WAAW
|
|
1
|
+
{"version":3,"file":"BackButton.d.ts","sourceRoot":"","sources":["../../../src/Client/UI/Components/BackButton.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,UAAW,SAAQ,WAAW;;IAE1C;;OAEG;;IAaH;;OAEG;IACH,IAAI,KAAK,IAAI,MAAM,CAGlB;IACD,IAAI,KAAK,CAAC,KAAK,EAAE,MAAM,EAEtB;CAUD;AAED;;GAEG;AACH,OAAO,CAAC,MAAM,CAAC;IAEd;;OAEG;IACH,UAAU,qBAAqB;QAC9B,aAAa,EAAE,UAAU,CAAC;KAC1B;CACD"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* A component that moves back
|
|
2
|
+
* A component that moves back in the session history when clicked.
|
|
3
3
|
*/
|
|
4
4
|
export class BackButton extends HTMLElement {
|
|
5
5
|
/**
|
|
@@ -7,7 +7,7 @@ export class BackButton extends HTMLElement {
|
|
|
7
7
|
*/
|
|
8
8
|
constructor() {
|
|
9
9
|
super();
|
|
10
|
-
this.addEventListener("click",
|
|
10
|
+
this.addEventListener("click", this.#goBack.bind(this));
|
|
11
11
|
}
|
|
12
12
|
/**
|
|
13
13
|
* Registers the component.
|
|
@@ -25,4 +25,12 @@ export class BackButton extends HTMLElement {
|
|
|
25
25
|
set steps(value) {
|
|
26
26
|
this.setAttribute("steps", value.toString());
|
|
27
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* Moves back in the session history.
|
|
30
|
+
* @param event The dispatched event.
|
|
31
|
+
*/
|
|
32
|
+
#goBack(event) {
|
|
33
|
+
event.preventDefault();
|
|
34
|
+
history.go(-this.steps);
|
|
35
|
+
}
|
|
28
36
|
}
|
|
@@ -1,10 +1,30 @@
|
|
|
1
1
|
import { type Context } from "../Context.js";
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import { Variant } from "../Variant.js";
|
|
3
|
+
/**
|
|
4
|
+
* Represents a dialog box button.
|
|
5
|
+
*/
|
|
6
|
+
export interface IDialogButton {
|
|
7
|
+
/**
|
|
8
|
+
* The button icon.
|
|
9
|
+
*/
|
|
10
|
+
icon?: string;
|
|
11
|
+
/**
|
|
12
|
+
* The button label.
|
|
13
|
+
*/
|
|
14
|
+
label?: string;
|
|
15
|
+
/**
|
|
16
|
+
* The button value.
|
|
17
|
+
*/
|
|
18
|
+
value?: string;
|
|
19
|
+
/**
|
|
20
|
+
* A tone variant.
|
|
21
|
+
*/
|
|
22
|
+
variant?: Context | Variant;
|
|
23
|
+
}
|
|
4
24
|
/**
|
|
5
25
|
* Represents a message to display in a dialog box.
|
|
6
26
|
*/
|
|
7
|
-
export interface
|
|
27
|
+
export interface IDialogMessage {
|
|
8
28
|
/**
|
|
9
29
|
* The child content displayed in the body.
|
|
10
30
|
*/
|
|
@@ -64,6 +84,10 @@ export declare class DialogBox extends HTMLElement {
|
|
|
64
84
|
*/
|
|
65
85
|
get open(): boolean;
|
|
66
86
|
set open(value: boolean);
|
|
87
|
+
/**
|
|
88
|
+
* The dialog result.
|
|
89
|
+
*/
|
|
90
|
+
get result(): string;
|
|
67
91
|
/**
|
|
68
92
|
* Value indicating whether the body is scrollable.
|
|
69
93
|
*/
|
|
@@ -77,26 +101,27 @@ export declare class DialogBox extends HTMLElement {
|
|
|
77
101
|
*/
|
|
78
102
|
attributeChangedCallback(attribute: string, oldValue: string | null, newValue: string | null): void;
|
|
79
103
|
/**
|
|
80
|
-
* Shows an alert message with an "OK" button.
|
|
104
|
+
* Shows an alert message with an "OK" button by default.
|
|
81
105
|
* @param context The contextual modifier.
|
|
82
106
|
* @param caption The title displayed in the header.
|
|
83
|
-
* @param
|
|
84
|
-
* @
|
|
107
|
+
* @param message The child content displayed in the body.
|
|
108
|
+
* @param buttons The buttons displayed in the footer.
|
|
109
|
+
* @returns The dialog result.
|
|
85
110
|
*/
|
|
86
|
-
alert(context: Context, caption: string,
|
|
111
|
+
alert(context: Context, caption: string, message: DocumentFragment, buttons?: IDialogButton[]): Promise<string>;
|
|
87
112
|
/**
|
|
88
113
|
* Closes this dialog box.
|
|
89
|
-
* @param result The dialog
|
|
114
|
+
* @param result The dialog result.
|
|
90
115
|
*/
|
|
91
|
-
close(result?:
|
|
116
|
+
close(result?: string): void;
|
|
92
117
|
/**
|
|
93
118
|
* Shows a confirmation message with two buttons, "OK" and "Cancel".
|
|
94
119
|
* @param context The contextual modifier.
|
|
95
120
|
* @param caption The title displayed in the header.
|
|
96
|
-
* @param
|
|
97
|
-
* @returns The dialog
|
|
121
|
+
* @param message The child content displayed in the body.
|
|
122
|
+
* @returns The dialog result.
|
|
98
123
|
*/
|
|
99
|
-
confirm(context: Context, caption: string,
|
|
124
|
+
confirm(context: Context, caption: string, message: DocumentFragment): Promise<string>;
|
|
100
125
|
/**
|
|
101
126
|
* Method invoked when this component is connected.
|
|
102
127
|
*/
|
|
@@ -108,18 +133,9 @@ export declare class DialogBox extends HTMLElement {
|
|
|
108
133
|
/**
|
|
109
134
|
* Shows a message.
|
|
110
135
|
* @param message The message to show.
|
|
111
|
-
* @returns The dialog
|
|
112
|
-
*/
|
|
113
|
-
show(message?: IMessage): Promise<DialogResult>;
|
|
114
|
-
/**
|
|
115
|
-
* Shows a message.
|
|
116
|
-
* @param context The contextual modifier.
|
|
117
|
-
* @param caption The title displayed in the header.
|
|
118
|
-
* @param body The child content displayed in the body.
|
|
119
|
-
* @param buttons The buttons displayed in the footer.
|
|
120
|
-
* @returns The dialog box result.
|
|
136
|
+
* @returns The dialog result.
|
|
121
137
|
*/
|
|
122
|
-
show(
|
|
138
|
+
show(message?: IDialogMessage | null): Promise<string>;
|
|
123
139
|
}
|
|
124
140
|
/**
|
|
125
141
|
* Declaration merging.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DialogBox.d.ts","sourceRoot":"","sources":["../../../src/Client/UI/Components/DialogBox.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,KAAK,OAAO,
|
|
1
|
+
{"version":3,"file":"DialogBox.d.ts","sourceRoot":"","sources":["../../../src/Client/UI/Components/DialogBox.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,KAAK,OAAO,EAA+B,MAAM,eAAe,CAAC;AAGzE,OAAO,EAAC,OAAO,EAAsB,MAAM,eAAe,CAAC;AAE3D;;GAEG;AACH,MAAM,WAAW,aAAa;IAE7B;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,GAAC,OAAO,CAAC;CAC1B;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAE9B;;OAEG;IACH,IAAI,EAAE,gBAAgB,CAAC;IAEvB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,MAAM,CAAC,EAAE,gBAAgB,CAAC;CAC1B;AAED;;GAEG;AACH,qBAAa,SAAU,SAAQ,WAAW;;IAEzC;;OAEG;IACH,MAAM,CAAC,QAAQ,CAAC,kBAAkB,WAA0D;IAiB5F;;OAEG;;IAeH;;OAEG;IACH,IAAI,IAAI,CAAC,KAAK,EAAE,gBAAgB,EAE/B;IAED;;OAEG;IACH,IAAI,OAAO,IAAI,MAAM,CAEpB;IACD,IAAI,OAAO,CAAC,KAAK,EAAE,MAAM,EAExB;IAED;;OAEG;IACH,IAAI,QAAQ,IAAI,OAAO,CAEtB;IACD,IAAI,QAAQ,CAAC,KAAK,EAAE,OAAO,EAE1B;IAED;;OAEG;IACH,IAAI,IAAI,IAAI,OAAO,CAElB;IACD,IAAI,IAAI,CAAC,KAAK,EAAE,OAAO,EAEtB;IAED;;OAEG;IACH,IAAI,MAAM,CAAC,KAAK,EAAE,gBAAgB,EAIjC;IAED;;OAEG;IACH,IAAI,KAAK,IAAI,OAAO,CAEnB;IACD,IAAI,KAAK,CAAC,KAAK,EAAE,OAAO,EAEvB;IAED;;OAEG;IACH,IAAI,IAAI,IAAI,OAAO,CAElB;IACD,IAAI,IAAI,CAAC,KAAK,EAAE,OAAO,EAEtB;IAED;;OAEG;IACH,IAAI,MAAM,IAAI,MAAM,CAEnB;IAED;;OAEG;IACH,IAAI,UAAU,IAAI,OAAO,CAExB;IACD,IAAI,UAAU,CAAC,KAAK,EAAE,OAAO,EAE5B;IAED;;;;;OAKG;IACH,wBAAwB,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAC,IAAI,EAAE,QAAQ,EAAE,MAAM,GAAC,IAAI,GAAG,IAAI;IAW/F;;;;;;;OAOG;IACH,KAAK,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,gBAAgB,EAAE,OAAO,GAAE,aAAa,EAAO,GAAG,OAAO,CAAC,MAAM,CAAC;IAoBnH;;;OAGG;IACH,KAAK,CAAC,MAAM,GAAE,MAA0B,GAAG,IAAI;IAK/C;;;;;;OAMG;IACH,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,MAAM,CAAC;IAOtF;;OAEG;IACH,iBAAiB,IAAI,IAAI;IAKzB;;OAEG;IACH,oBAAoB,IAAI,IAAI;IAI5B;;;;OAIG;IACH,IAAI,CAAC,OAAO,GAAE,cAAc,GAAC,IAAW,GAAG,OAAO,CAAC,MAAM,CAAC;CAgE1D;AAED;;GAEG;AACH,OAAO,CAAC,MAAM,CAAC;IAEd;;OAEG;IACH,UAAU,qBAAqB;QAC9B,YAAY,EAAE,SAAS,CAAC;KACxB;CACD"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Modal } from "bootstrap";
|
|
2
|
-
import {
|
|
2
|
+
import { toCss as contextCss, getIcon } from "../Context.js";
|
|
3
3
|
import { DialogResult } from "../DialogResult.js";
|
|
4
4
|
import { html } from "../Tag.js";
|
|
5
|
-
import { Variant } from "../Variant.js";
|
|
5
|
+
import { Variant, toCss as variantCss } from "../Variant.js";
|
|
6
6
|
/**
|
|
7
7
|
* Displays a dialog box, which presents a message to the user.
|
|
8
8
|
*/
|
|
@@ -11,20 +11,16 @@ export class DialogBox extends HTMLElement {
|
|
|
11
11
|
* The list of observed attributes.
|
|
12
12
|
*/
|
|
13
13
|
static observedAttributes = ["caption", "centered", "fade", "modal", "scrollable"];
|
|
14
|
-
/**
|
|
15
|
-
* The template for a button.
|
|
16
|
-
*/
|
|
17
|
-
#buttonTemplate = this.querySelector("template").content;
|
|
18
14
|
/**
|
|
19
15
|
* The underlying Bootstrap modal.
|
|
20
16
|
*/
|
|
21
17
|
#modal;
|
|
22
18
|
/**
|
|
23
|
-
* The function invoked to
|
|
19
|
+
* The function invoked to resolve the dialog result.
|
|
24
20
|
*/
|
|
25
|
-
#resolve
|
|
21
|
+
#resolve;
|
|
26
22
|
/**
|
|
27
|
-
* The dialog result.
|
|
23
|
+
* The promise providing the dialog result.
|
|
28
24
|
*/
|
|
29
25
|
#result = DialogResult.None;
|
|
30
26
|
/**
|
|
@@ -32,10 +28,10 @@ export class DialogBox extends HTMLElement {
|
|
|
32
28
|
*/
|
|
33
29
|
constructor() {
|
|
34
30
|
super();
|
|
35
|
-
this.firstElementChild.addEventListener("
|
|
36
|
-
this.querySelector(".btn-close").addEventListener("click", this.#close);
|
|
31
|
+
this.firstElementChild.addEventListener("hide.bs.modal", () => this.#resolve(this.#result));
|
|
32
|
+
this.querySelector(".btn-close").addEventListener("click", this.#close.bind(this));
|
|
37
33
|
for (const button of this.querySelectorAll(".modal-footer button"))
|
|
38
|
-
button.addEventListener("click", this.#close);
|
|
34
|
+
button.addEventListener("click", this.#close.bind(this));
|
|
39
35
|
}
|
|
40
36
|
/**
|
|
41
37
|
* Registers the component.
|
|
@@ -102,6 +98,12 @@ export class DialogBox extends HTMLElement {
|
|
|
102
98
|
set open(value) {
|
|
103
99
|
this.toggleAttribute("open", value);
|
|
104
100
|
}
|
|
101
|
+
/**
|
|
102
|
+
* The dialog result.
|
|
103
|
+
*/
|
|
104
|
+
get result() {
|
|
105
|
+
return this.#result;
|
|
106
|
+
}
|
|
105
107
|
/**
|
|
106
108
|
* Value indicating whether the body is scrollable.
|
|
107
109
|
*/
|
|
@@ -139,20 +141,35 @@ export class DialogBox extends HTMLElement {
|
|
|
139
141
|
}
|
|
140
142
|
}
|
|
141
143
|
/**
|
|
142
|
-
* Shows an alert message with an "OK" button.
|
|
144
|
+
* Shows an alert message with an "OK" button by default.
|
|
143
145
|
* @param context The contextual modifier.
|
|
144
146
|
* @param caption The title displayed in the header.
|
|
145
|
-
* @param
|
|
146
|
-
* @
|
|
147
|
+
* @param message The child content displayed in the body.
|
|
148
|
+
* @param buttons The buttons displayed in the footer.
|
|
149
|
+
* @returns The dialog result.
|
|
147
150
|
*/
|
|
148
|
-
alert(context, caption,
|
|
149
|
-
return this.show(
|
|
150
|
-
|
|
151
|
-
|
|
151
|
+
alert(context, caption, message, buttons = []) {
|
|
152
|
+
return this.show({
|
|
153
|
+
caption,
|
|
154
|
+
body: html `
|
|
155
|
+
<div class="d-flex gap-2">
|
|
156
|
+
<i class="icon icon-fill fs-1 text-${contextCss(context)}"> ${getIcon(context)}</i>
|
|
157
|
+
<div class="flex-grow-1">${message}</div>
|
|
158
|
+
</div>
|
|
159
|
+
`,
|
|
160
|
+
footer: html `
|
|
161
|
+
${(buttons.length ? buttons : [{ label: "OK", value: DialogResult.OK, variant: Variant.Primary }]).map(button => html `
|
|
162
|
+
<button class="btn btn-${variantCss(button.variant ?? Variant.Primary)}" type="button" value="${button.value ?? DialogResult.None}">
|
|
163
|
+
${button.icon ? html `<i class="icon ${button.label ? "me-1" : ""}">${button.icon}</i>` : ""}
|
|
164
|
+
${button.label}
|
|
165
|
+
</button>
|
|
166
|
+
`)}
|
|
167
|
+
`
|
|
168
|
+
});
|
|
152
169
|
}
|
|
153
170
|
/**
|
|
154
171
|
* Closes this dialog box.
|
|
155
|
-
* @param result The dialog
|
|
172
|
+
* @param result The dialog result.
|
|
156
173
|
*/
|
|
157
174
|
close(result = DialogResult.None) {
|
|
158
175
|
this.#result = result;
|
|
@@ -162,11 +179,11 @@ export class DialogBox extends HTMLElement {
|
|
|
162
179
|
* Shows a confirmation message with two buttons, "OK" and "Cancel".
|
|
163
180
|
* @param context The contextual modifier.
|
|
164
181
|
* @param caption The title displayed in the header.
|
|
165
|
-
* @param
|
|
166
|
-
* @returns The dialog
|
|
182
|
+
* @param message The child content displayed in the body.
|
|
183
|
+
* @returns The dialog result.
|
|
167
184
|
*/
|
|
168
|
-
confirm(context, caption,
|
|
169
|
-
return this.
|
|
185
|
+
confirm(context, caption, message) {
|
|
186
|
+
return this.alert(context, caption, message, [
|
|
170
187
|
{ label: "OK", value: DialogResult.OK, variant: Variant.Primary },
|
|
171
188
|
{ label: "Annuler", value: DialogResult.Cancel, variant: Variant.Secondary }
|
|
172
189
|
]);
|
|
@@ -187,22 +204,14 @@ export class DialogBox extends HTMLElement {
|
|
|
187
204
|
}
|
|
188
205
|
/**
|
|
189
206
|
* Shows a message.
|
|
190
|
-
* @param message The message to show
|
|
191
|
-
* @
|
|
192
|
-
* @param body The child content displayed in the body.
|
|
193
|
-
* @param buttons The buttons displayed in the footer.
|
|
194
|
-
* @returns The dialog box result.
|
|
207
|
+
* @param message The message to show.
|
|
208
|
+
* @returns The dialog result.
|
|
195
209
|
*/
|
|
196
|
-
show(message = null
|
|
197
|
-
if (typeof message == "string") {
|
|
198
|
-
const footer = document.createDocumentFragment();
|
|
199
|
-
footer.append(...buttons.map(button => this.#createButton(button)));
|
|
200
|
-
message = { body, caption, footer };
|
|
201
|
-
}
|
|
210
|
+
show(message = null) {
|
|
202
211
|
if (message) {
|
|
203
212
|
const footer = message.footer ?? document.createDocumentFragment();
|
|
204
213
|
for (const button of footer.querySelectorAll("button"))
|
|
205
|
-
button.addEventListener("click", this.#close);
|
|
214
|
+
button.addEventListener("click", this.#close.bind(this));
|
|
206
215
|
this.body = message.body;
|
|
207
216
|
this.caption = message.caption;
|
|
208
217
|
this.footer = footer;
|
|
@@ -217,40 +226,9 @@ export class DialogBox extends HTMLElement {
|
|
|
217
226
|
* Closes this dialog box.
|
|
218
227
|
* @param event The dispatched event.
|
|
219
228
|
*/
|
|
220
|
-
#close
|
|
221
|
-
|
|
222
|
-
this.close(
|
|
223
|
-
};
|
|
224
|
-
/**
|
|
225
|
-
* Creates the component instance corresponding to the specified button.
|
|
226
|
-
* @param button An object describing the appearance of the button.
|
|
227
|
-
* @returns The component instance corresponding to the specified button.
|
|
228
|
-
*/
|
|
229
|
-
#createButton(button) {
|
|
230
|
-
const element = document.createElement("dialog-button");
|
|
231
|
-
const childContent = this.#buttonTemplate.cloneNode(true).querySelector("button");
|
|
232
|
-
childContent.addEventListener("click", this.#close);
|
|
233
|
-
element.appendChild(childContent);
|
|
234
|
-
element.context = button.context ?? null;
|
|
235
|
-
element.icon = button.icon ?? null;
|
|
236
|
-
element.label = button.label ?? "";
|
|
237
|
-
element.value = button.value ?? DialogResult.None;
|
|
238
|
-
element.variant = button.variant ?? null;
|
|
239
|
-
return element;
|
|
240
|
-
}
|
|
241
|
-
/**
|
|
242
|
-
* Gets the body template corresponding to the specified context and message.
|
|
243
|
-
* @param context The contextual modifier.
|
|
244
|
-
* @param message The child content displayed in the body.
|
|
245
|
-
* @returns The body template corresponding to the specified context and message.
|
|
246
|
-
*/
|
|
247
|
-
#getBodyTemplate(context, message) {
|
|
248
|
-
return html `
|
|
249
|
-
<div class="d-flex gap-2">
|
|
250
|
-
<i class="icon icon-fill fs-1 text-${toCss(context)}"> ${getIcon(context)}</i>
|
|
251
|
-
<div class="flex-grow-1">${message}</div>
|
|
252
|
-
</div>
|
|
253
|
-
`;
|
|
229
|
+
#close(event) {
|
|
230
|
+
event.preventDefault();
|
|
231
|
+
this.close(event.target.closest("button").value);
|
|
254
232
|
}
|
|
255
233
|
/**
|
|
256
234
|
* Updates the title displayed in the header.
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A component for toggling an element to full-screen.
|
|
3
|
+
*/
|
|
4
|
+
export declare class FullScreenToggler extends HTMLElement {
|
|
5
|
+
#private;
|
|
6
|
+
/**
|
|
7
|
+
* Creates a new full-screen toggler.
|
|
8
|
+
*/
|
|
9
|
+
constructor();
|
|
10
|
+
/**
|
|
11
|
+
* The CSS selector used to target the element.
|
|
12
|
+
*/
|
|
13
|
+
get target(): string;
|
|
14
|
+
set target(value: string);
|
|
15
|
+
/**
|
|
16
|
+
* Value indicating whether to prevent the device screen from dimming or locking when in full-screen mode.
|
|
17
|
+
*/
|
|
18
|
+
get wakeLock(): boolean;
|
|
19
|
+
set wakeLock(value: boolean);
|
|
20
|
+
/**
|
|
21
|
+
* Method invoked when this component is connected.
|
|
22
|
+
*/
|
|
23
|
+
connectedCallback(): void;
|
|
24
|
+
/**
|
|
25
|
+
* Method invoked when this component is disconnected.
|
|
26
|
+
*/
|
|
27
|
+
disconnectedCallback(): void;
|
|
28
|
+
/**
|
|
29
|
+
* Toggles the full-screen mode of the associated element.
|
|
30
|
+
* @param event The dispatched event.
|
|
31
|
+
* @returns Resolves when the full-screen mode has been toggled.
|
|
32
|
+
*/
|
|
33
|
+
toggleFullScreen(event?: Event): Promise<void>;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Declaration merging.
|
|
37
|
+
*/
|
|
38
|
+
declare global {
|
|
39
|
+
/**
|
|
40
|
+
* The map of HTML tag names.
|
|
41
|
+
*/
|
|
42
|
+
interface HTMLElementTagNameMap {
|
|
43
|
+
"fullscreen-toggler": FullScreenToggler;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=FullScreenToggler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FullScreenToggler.d.ts","sourceRoot":"","sources":["../../../src/Client/UI/Components/FullScreenToggler.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,iBAAkB,SAAQ,WAAW;;IAYjD;;OAEG;;IAaH;;OAEG;IACH,IAAI,MAAM,IAAI,MAAM,CAGnB;IACD,IAAI,MAAM,CAAC,KAAK,EAAE,MAAM,EAEvB;IAED;;OAEG;IACH,IAAI,QAAQ,IAAI,OAAO,CAEtB;IACD,IAAI,QAAQ,CAAC,KAAK,EAAE,OAAO,EAE1B;IAED;;OAEG;IACH,iBAAiB,IAAI,IAAI;IAMzB;;OAEG;IACH,oBAAoB,IAAI,IAAI;IAK5B;;;;OAIG;IACG,gBAAgB,CAAC,KAAK,CAAC,EAAE,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC;CAwCpD;AAED;;GAEG;AACH,OAAO,CAAC,MAAM,CAAC;IAEd;;OAEG;IACH,UAAU,qBAAqB;QAC9B,oBAAoB,EAAE,iBAAiB,CAAC;KACxC;CACD"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A component for toggling an element to full-screen.
|
|
3
|
+
*/
|
|
4
|
+
export class FullScreenToggler extends HTMLElement {
|
|
5
|
+
/**
|
|
6
|
+
* The associated element.
|
|
7
|
+
*/
|
|
8
|
+
#element = document.body;
|
|
9
|
+
/**
|
|
10
|
+
* The handle to the underlying platform wake lock.
|
|
11
|
+
*/
|
|
12
|
+
#sentinel = null;
|
|
13
|
+
/**
|
|
14
|
+
* Creates a new full-screen toggler.
|
|
15
|
+
*/
|
|
16
|
+
constructor() {
|
|
17
|
+
super();
|
|
18
|
+
this.addEventListener("click", this.toggleFullScreen.bind(this)); // eslint-disable-line @typescript-eslint/no-misused-promises
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Registers the component.
|
|
22
|
+
*/
|
|
23
|
+
static {
|
|
24
|
+
customElements.define("fullscreen-toggler", this);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* The CSS selector used to target the element.
|
|
28
|
+
*/
|
|
29
|
+
get target() {
|
|
30
|
+
const value = this.getAttribute("target") ?? "";
|
|
31
|
+
return value.trim() || "body";
|
|
32
|
+
}
|
|
33
|
+
set target(value) {
|
|
34
|
+
this.setAttribute("target", value);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Value indicating whether to prevent the device screen from dimming or locking when in full-screen mode.
|
|
38
|
+
*/
|
|
39
|
+
get wakeLock() {
|
|
40
|
+
return this.hasAttribute("wakeLock");
|
|
41
|
+
}
|
|
42
|
+
set wakeLock(value) {
|
|
43
|
+
this.toggleAttribute("target", value);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Method invoked when this component is connected.
|
|
47
|
+
*/
|
|
48
|
+
connectedCallback() {
|
|
49
|
+
document.addEventListener("visibilitychange", this.#onVisibilityChanged);
|
|
50
|
+
this.#element = document.querySelector(this.target) ?? document.body;
|
|
51
|
+
this.#element.addEventListener("fullscreenchange", this.#onFullScreenChanged);
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Method invoked when this component is disconnected.
|
|
55
|
+
*/
|
|
56
|
+
disconnectedCallback() {
|
|
57
|
+
document.removeEventListener("visibilitychange", this.#onVisibilityChanged);
|
|
58
|
+
this.#element.removeEventListener("fullscreenchange", this.#onFullScreenChanged);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Toggles the full-screen mode of the associated element.
|
|
62
|
+
* @param event The dispatched event.
|
|
63
|
+
* @returns Resolves when the full-screen mode has been toggled.
|
|
64
|
+
*/
|
|
65
|
+
async toggleFullScreen(event) {
|
|
66
|
+
event?.preventDefault();
|
|
67
|
+
if (document.fullscreenElement)
|
|
68
|
+
await document.exitFullscreen();
|
|
69
|
+
else
|
|
70
|
+
await this.#element.requestFullscreen();
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Acquires a new wake lock.
|
|
74
|
+
* @returns Resolves when the wake lock has been acquired.
|
|
75
|
+
*/
|
|
76
|
+
async #acquireWakeLock() {
|
|
77
|
+
if (this.#sentinel && !this.#sentinel.released)
|
|
78
|
+
return;
|
|
79
|
+
if (this.wakeLock)
|
|
80
|
+
this.#sentinel = await navigator.wakeLock.request();
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Acquires or releases the wake lock when the document enters or exits the full-screen mode.
|
|
84
|
+
* @param event The dispatched event.
|
|
85
|
+
*/
|
|
86
|
+
#onFullScreenChanged = () => {
|
|
87
|
+
if (document.fullscreenElement)
|
|
88
|
+
void this.#acquireWakeLock();
|
|
89
|
+
else
|
|
90
|
+
void this.#releaseWakeLock();
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* Eventually acquires a new wake lock when the document visibility has changed.
|
|
94
|
+
* @param event The dispatched event.
|
|
95
|
+
*/
|
|
96
|
+
#onVisibilityChanged = () => {
|
|
97
|
+
if (document.fullscreenElement && !document.hidden)
|
|
98
|
+
void this.#acquireWakeLock();
|
|
99
|
+
};
|
|
100
|
+
/**
|
|
101
|
+
* Releases the acquired wake lock.
|
|
102
|
+
* @returns Resolves when the wake lock has been released.
|
|
103
|
+
*/
|
|
104
|
+
async #releaseWakeLock() {
|
|
105
|
+
if (!this.#sentinel || this.#sentinel.released)
|
|
106
|
+
return;
|
|
107
|
+
await this.#sentinel.release();
|
|
108
|
+
}
|
|
109
|
+
}
|
|
@@ -23,7 +23,7 @@ export class ThemeDropdown extends HTMLElement {
|
|
|
23
23
|
constructor() {
|
|
24
24
|
super();
|
|
25
25
|
for (const button of this.querySelectorAll(".dropdown-menu button"))
|
|
26
|
-
button.addEventListener("click", this.#setAppTheme);
|
|
26
|
+
button.addEventListener("click", this.#setAppTheme.bind(this));
|
|
27
27
|
}
|
|
28
28
|
/**
|
|
29
29
|
* Registers the component.
|
|
@@ -139,11 +139,11 @@ export class ThemeDropdown extends HTMLElement {
|
|
|
139
139
|
* Changes the current application theme.
|
|
140
140
|
* @param event The dispatched event.
|
|
141
141
|
*/
|
|
142
|
-
#setAppTheme
|
|
142
|
+
#setAppTheme(event) {
|
|
143
143
|
event.preventDefault();
|
|
144
144
|
this.appTheme = event.target.closest("button").dataset.theme;
|
|
145
145
|
this.save();
|
|
146
|
-
}
|
|
146
|
+
}
|
|
147
147
|
/**
|
|
148
148
|
* Updates the alignment of the dropdown menu.
|
|
149
149
|
* @param value The new value.
|
|
@@ -1,41 +1,4 @@
|
|
|
1
1
|
import { Context } from "../Context.js";
|
|
2
|
-
/**
|
|
3
|
-
* Represents a notification.
|
|
4
|
-
*/
|
|
5
|
-
export interface IToast {
|
|
6
|
-
/**
|
|
7
|
-
* Value indicating whether to automatically hide the toast.
|
|
8
|
-
*/
|
|
9
|
-
autoHide?: boolean;
|
|
10
|
-
/**
|
|
11
|
-
* The child content displayed in the body.
|
|
12
|
-
*/
|
|
13
|
-
body: DocumentFragment;
|
|
14
|
-
/**
|
|
15
|
-
* The title displayed in the header.
|
|
16
|
-
*/
|
|
17
|
-
caption: string;
|
|
18
|
-
/**
|
|
19
|
-
* The default contextual modifier.
|
|
20
|
-
*/
|
|
21
|
-
context?: Context;
|
|
22
|
-
/**
|
|
23
|
-
* The culture used to format the relative time.
|
|
24
|
-
*/
|
|
25
|
-
culture?: Intl.Locale;
|
|
26
|
-
/**
|
|
27
|
-
* The delay, in milliseconds, to hide the toast.
|
|
28
|
-
*/
|
|
29
|
-
delay?: number;
|
|
30
|
-
/**
|
|
31
|
-
* Value indicating whether to apply a transition.
|
|
32
|
-
*/
|
|
33
|
-
fade?: boolean;
|
|
34
|
-
/**
|
|
35
|
-
* The icon displayed next to the caption.
|
|
36
|
-
*/
|
|
37
|
-
icon?: string | null;
|
|
38
|
-
}
|
|
39
2
|
/**
|
|
40
3
|
* Represents a notification.
|
|
41
4
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Toast.d.ts","sourceRoot":"","sources":["../../../src/Client/UI/Components/Toast.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,OAAO,EAAiB,MAAM,eAAe,CAAC;AAEtD;;GAEG;AACH,
|
|
1
|
+
{"version":3,"file":"Toast.d.ts","sourceRoot":"","sources":["../../../src/Client/UI/Components/Toast.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,OAAO,EAAiB,MAAM,eAAe,CAAC;AAEtD;;GAEG;AACH,qBAAa,KAAM,SAAQ,WAAW;;IAErC;;OAEG;IACH,MAAM,CAAC,QAAQ,CAAC,kBAAkB,WAA0E;IAkC5G;;OAEG;IACH,IAAI,QAAQ,IAAI,OAAO,CAEtB;IACD,IAAI,QAAQ,CAAC,KAAK,EAAE,OAAO,EAE1B;IAED;;OAEG;IACH,IAAI,IAAI,CAAC,KAAK,EAAE,gBAAgB,EAE/B;IAED;;OAEG;IACH,IAAI,OAAO,IAAI,MAAM,CAEpB;IACD,IAAI,OAAO,CAAC,KAAK,EAAE,MAAM,EAExB;IAED;;OAEG;IACH,IAAI,OAAO,IAAI,OAAO,CAGrB;IACD,IAAI,OAAO,CAAC,KAAK,EAAE,OAAO,EAEzB;IAED;;OAEG;IACH,IAAI,OAAO,IAAI,IAAI,CAAC,MAAM,CAGzB;IACD,IAAI,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,EAE7B;IAED;;OAEG;IACH,IAAI,KAAK,IAAI,MAAM,CAGlB;IACD,IAAI,KAAK,CAAC,KAAK,EAAE,MAAM,EAEtB;IAED;;OAEG;IACH,IAAI,WAAW,IAAI,MAAM,CAExB;IAED;;OAEG;IACH,IAAI,IAAI,IAAI,OAAO,CAElB;IACD,IAAI,IAAI,CAAC,KAAK,EAAE,OAAO,EAEtB;IAED;;OAEG;IACH,IAAI,IAAI,IAAI,MAAM,GAAC,IAAI,CAGtB;IACD,IAAI,IAAI,CAAC,KAAK,EAAE,MAAM,GAAC,IAAI,EAG1B;IAED;;OAEG;IACH,IAAI,IAAI,IAAI,OAAO,CAElB;IACD,IAAI,IAAI,CAAC,KAAK,EAAE,OAAO,EAEtB;IAED;;;;;OAKG;IACH,wBAAwB,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAC,IAAI,EAAE,QAAQ,EAAE,MAAM,GAAC,IAAI,GAAG,IAAI;IAa/F;;OAEG;IACH,KAAK,IAAI,IAAI;IAIb;;OAEG;IACH,iBAAiB,IAAI,IAAI;IASzB;;OAEG;IACH,oBAAoB,IAAI,IAAI;IAK5B;;OAEG;IACH,IAAI,IAAI,IAAI;CAwFZ;AAED;;GAEG;AACH,OAAO,CAAC,MAAM,CAAC;IAEd;;OAEG;IACH,UAAU,qBAAqB;QAC9B,cAAc,EAAE,KAAK,CAAC;KACtB;CACD"}
|
|
@@ -169,8 +169,8 @@ export class Toast extends HTMLElement {
|
|
|
169
169
|
*/
|
|
170
170
|
connectedCallback() {
|
|
171
171
|
const toast = this.firstElementChild;
|
|
172
|
-
toast.addEventListener("
|
|
173
|
-
toast.addEventListener("show.bs.toast", () => this.#timer = window.setInterval(this.#updateElapsedTime, 1_000));
|
|
172
|
+
toast.addEventListener("hide.bs.toast", () => clearInterval(this.#timer));
|
|
173
|
+
toast.addEventListener("show.bs.toast", () => this.#timer = window.setInterval(() => this.#updateElapsedTime(), 1_000));
|
|
174
174
|
this.#toast = new BootstrapToast(toast);
|
|
175
175
|
if (this.open)
|
|
176
176
|
this.show();
|
|
@@ -243,10 +243,10 @@ export class Toast extends HTMLElement {
|
|
|
243
243
|
/**
|
|
244
244
|
* Updates the label corresponding to the elapsed time.
|
|
245
245
|
*/
|
|
246
|
-
#updateElapsedTime
|
|
246
|
+
#updateElapsedTime() {
|
|
247
247
|
const { elapsedTime } = this;
|
|
248
248
|
this.querySelector(".toast-header small").textContent = elapsedTime > 0 ? this.#formatTime(elapsedTime / 1_000) : "";
|
|
249
|
-
}
|
|
249
|
+
}
|
|
250
250
|
/**
|
|
251
251
|
* Updates the value indicating whether to apply a transition.
|
|
252
252
|
* @param value The new value.
|