@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
|
@@ -1,190 +0,0 @@
|
|
|
1
|
-
import {Context, toCss as contextCss} from "../Context.js";
|
|
2
|
-
import {DialogResult} from "../DialogResult.js";
|
|
3
|
-
import {Variant, toCss as variantCss} from "../Variant.js";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Represents a dialog box button.
|
|
7
|
-
*/
|
|
8
|
-
export interface IDialogButton {
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* A contextual modifier.
|
|
12
|
-
*/
|
|
13
|
-
context?: Context|null;
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* The button icon.
|
|
17
|
-
*/
|
|
18
|
-
icon?: string|null;
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* The button label.
|
|
22
|
-
*/
|
|
23
|
-
label?: string;
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* The button value.
|
|
27
|
-
*/
|
|
28
|
-
value?: DialogResult;
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* A tone variant.
|
|
32
|
-
*/
|
|
33
|
-
variant?: Variant|null;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Represents a dialog box button.
|
|
38
|
-
*/
|
|
39
|
-
export class DialogButton extends HTMLElement {
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* The list of observed attributes.
|
|
43
|
-
*/
|
|
44
|
-
static readonly observedAttributes = ["context", "icon", "label", "value", "variant"];
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Registers the component.
|
|
48
|
-
*/
|
|
49
|
-
static {
|
|
50
|
-
customElements.define("dialog-button", this);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* A contextual modifier.
|
|
55
|
-
*/
|
|
56
|
-
get context(): Context|null {
|
|
57
|
-
const value = this.getAttribute("context") as Context;
|
|
58
|
-
return Object.values(Context).includes(value) ? value : null;
|
|
59
|
-
}
|
|
60
|
-
set context(value: Context|null) {
|
|
61
|
-
if (value) this.setAttribute("context", value);
|
|
62
|
-
else this.removeAttribute("context");
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* The button icon.
|
|
67
|
-
*/
|
|
68
|
-
get icon(): string|null {
|
|
69
|
-
const value = this.getAttribute("icon") ?? "";
|
|
70
|
-
return value.trim() || null;
|
|
71
|
-
}
|
|
72
|
-
set icon(value: string|null) {
|
|
73
|
-
if (value) this.setAttribute("icon", value);
|
|
74
|
-
else this.removeAttribute("icon");
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* The button label.
|
|
79
|
-
*/
|
|
80
|
-
get label(): string {
|
|
81
|
-
return (this.getAttribute("label") ?? "").trim();
|
|
82
|
-
}
|
|
83
|
-
set label(value: string) {
|
|
84
|
-
this.setAttribute("label", value);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* The button value.
|
|
89
|
-
*/
|
|
90
|
-
get value(): DialogResult {
|
|
91
|
-
const value = this.getAttribute("value") as DialogResult;
|
|
92
|
-
return Object.values(DialogResult).includes(value) ? value : DialogResult.None;
|
|
93
|
-
}
|
|
94
|
-
set value(value: DialogResult) {
|
|
95
|
-
this.setAttribute("value", value);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* A tone variant.
|
|
100
|
-
*/
|
|
101
|
-
get variant(): Variant|null {
|
|
102
|
-
const value = this.getAttribute("variant") as Variant;
|
|
103
|
-
return Object.values(Variant).includes(value) ? value : null;
|
|
104
|
-
}
|
|
105
|
-
set variant(value: Variant|null) {
|
|
106
|
-
if (value) this.setAttribute("variant", value);
|
|
107
|
-
else this.removeAttribute("variant");
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* Method invoked when an attribute has been changed.
|
|
112
|
-
* @param attribute The attribute name.
|
|
113
|
-
* @param oldValue The previous attribute value.
|
|
114
|
-
* @param newValue The new attribute value.
|
|
115
|
-
*/
|
|
116
|
-
attributeChangedCallback(attribute: string, oldValue: string|null, newValue: string|null): void {
|
|
117
|
-
if (newValue != oldValue) switch (attribute) {
|
|
118
|
-
case "context": this.#updateContext(Object.values(Context).includes(newValue as Context) ? newValue as Context : null); break;
|
|
119
|
-
case "icon": this.#updateIcon(newValue); break;
|
|
120
|
-
case "label": this.#updateLabel(newValue ?? ""); break;
|
|
121
|
-
case "value": this.#updateValue(Object.values(DialogResult).includes(newValue as DialogResult) ? newValue as DialogResult : DialogResult.None); break;
|
|
122
|
-
case "variant": this.#updateVariant(Object.values(Variant).includes(newValue as Variant) ? newValue as Variant : null); break;
|
|
123
|
-
// No default
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
/**
|
|
128
|
-
* Updates the contextual modifier.
|
|
129
|
-
* @param value The new value.
|
|
130
|
-
*/
|
|
131
|
-
#updateContext(value: Context|null): void {
|
|
132
|
-
const {classList} = this.querySelector("button")!;
|
|
133
|
-
classList.remove(...Object.values(Context).map(context => `btn-${contextCss(context)}`));
|
|
134
|
-
if (value) classList.add(`btn-${contextCss(value)}`);
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
/**
|
|
138
|
-
* Updates the button icon.
|
|
139
|
-
* @param value The new value.
|
|
140
|
-
*/
|
|
141
|
-
#updateIcon(value: string|null): void {
|
|
142
|
-
const element = this.querySelector<HTMLElement>(".icon")!;
|
|
143
|
-
const icon = (value ?? "").trim();
|
|
144
|
-
element.textContent = icon;
|
|
145
|
-
element.hidden = !icon;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
/**
|
|
149
|
-
* Updates the button label.
|
|
150
|
-
* @param value The new value.
|
|
151
|
-
*/
|
|
152
|
-
#updateLabel(value: string): void {
|
|
153
|
-
const element = this.querySelector("span")!;
|
|
154
|
-
const label = value.trim();
|
|
155
|
-
element.textContent = label;
|
|
156
|
-
element.hidden = !label;
|
|
157
|
-
this.querySelector(".icon")!.classList.toggle("me-1", !element.hidden);
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
/**
|
|
161
|
-
* Updates the button value.
|
|
162
|
-
* @param value The new value.
|
|
163
|
-
*/
|
|
164
|
-
#updateValue(value: DialogResult): void {
|
|
165
|
-
this.querySelector("button")!.value = value;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
/**
|
|
169
|
-
* Updates the tone variant.
|
|
170
|
-
* @param value The new value.
|
|
171
|
-
*/
|
|
172
|
-
#updateVariant(value: Variant|null): void {
|
|
173
|
-
const {classList} = this.querySelector("button")!;
|
|
174
|
-
classList.remove(...Object.values(Variant).map(variant => `btn-${variantCss(variant)}`));
|
|
175
|
-
if (value) classList.add(`btn-${variantCss(value)}`);
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
/**
|
|
180
|
-
* Declaration merging.
|
|
181
|
-
*/
|
|
182
|
-
declare global {
|
|
183
|
-
|
|
184
|
-
/**
|
|
185
|
-
* The map of HTML tag names.
|
|
186
|
-
*/
|
|
187
|
-
interface HTMLElementTagNameMap {
|
|
188
|
-
"dialog-button": DialogButton;
|
|
189
|
-
}
|
|
190
|
-
}
|