@cedx/base 0.6.0 → 0.7.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/Data/Pagination.d.ts +30 -13
- package/lib/Data/Pagination.d.ts.map +1 -1
- package/lib/Data/Pagination.js +39 -12
- package/lib/Data/Sort.d.ts +25 -23
- package/lib/Data/Sort.d.ts.map +1 -1
- package/lib/Data/Sort.js +37 -33
- package/lib/{Date.d.ts → DateExtensions.d.ts} +1 -1
- package/lib/DateExtensions.d.ts.map +1 -0
- package/lib/{Html/File.d.ts → FileExtensions.d.ts} +4 -11
- package/lib/FileExtensions.d.ts.map +1 -0
- package/lib/{Html/File.js → FileExtensions.js} +3 -12
- package/lib/{Http → Net/Http}/HttpClient.d.ts +17 -2
- package/lib/Net/Http/HttpClient.d.ts.map +1 -0
- package/lib/{Http → Net/Http}/HttpClient.js +17 -15
- package/lib/Net/Http/HttpMethod.d.ts +46 -0
- package/lib/Net/Http/HttpMethod.d.ts.map +1 -0
- package/lib/Net/Http/HttpMethod.js +41 -0
- package/lib/Net/Http/HttpRequestError.d.ts +33 -0
- package/lib/Net/Http/HttpRequestError.d.ts.map +1 -0
- package/lib/{Http/HttpError.js → Net/Http/HttpRequestError.js} +16 -16
- package/lib/Net/Http/StatusCode.d.ts +122 -0
- package/lib/Net/Http/StatusCode.d.ts.map +1 -0
- package/lib/Net/Http/StatusCode.js +117 -0
- package/lib/Net/Mime/DispositionType.d.ts +18 -0
- package/lib/Net/Mime/DispositionType.d.ts.map +1 -0
- package/lib/Net/Mime/DispositionType.js +13 -0
- package/lib/Net/Mime/MediaType.d.ts +151 -0
- package/lib/Net/Mime/MediaType.d.ts.map +1 -0
- package/lib/Net/Mime/MediaType.js +150 -0
- package/lib/{Number.d.ts → NumberExtensions.d.ts} +1 -1
- package/lib/NumberExtensions.d.ts.map +1 -0
- package/lib/{String.d.ts → StringExtensions.d.ts} +1 -1
- package/lib/StringExtensions.d.ts.map +1 -0
- package/lib/{Html → UI}/AppTheme.d.ts +3 -3
- package/lib/UI/AppTheme.d.ts.map +1 -0
- package/lib/{Html → UI}/AppTheme.js +3 -3
- package/lib/UI/{Component.d.ts → Components/ComponentBase.d.ts} +5 -5
- package/lib/UI/Components/ComponentBase.d.ts.map +1 -0
- package/lib/UI/Components/ComponentBase.js +29 -0
- package/lib/UI/{LoadingIndicator.d.ts → Components/LoadingIndicator.d.ts} +1 -2
- package/lib/UI/Components/LoadingIndicator.d.ts.map +1 -0
- package/lib/UI/Components/MenuActivator.d.ts.map +1 -0
- package/lib/UI/Components/OfflineIndicator.d.ts.map +1 -0
- package/lib/UI/Components/ThemeDropdown.d.ts +67 -0
- package/lib/UI/Components/ThemeDropdown.d.ts.map +1 -0
- package/lib/UI/Components/ThemeDropdown.js +140 -0
- package/lib/UI/Context.d.ts.map +1 -0
- package/lib/UI/MenuAlignment.d.ts +18 -0
- package/lib/UI/MenuAlignment.d.ts.map +1 -0
- package/lib/UI/MenuAlignment.js +13 -0
- package/lib/{Html → UI}/ViewportScroller.d.ts +1 -1
- package/lib/UI/ViewportScroller.d.ts.map +1 -0
- package/lib/{Html → UI}/ViewportScroller.js +6 -6
- package/package.json +5 -7
- package/src/Client/Data/Pagination.ts +59 -13
- package/src/Client/Data/Sort.ts +40 -35
- package/src/Client/Data/tsconfig.json +1 -1
- package/src/Client/{Html/File.ts → FileExtensions.ts} +3 -13
- package/src/Client/{Http → Net/Http}/HttpClient.ts +32 -14
- package/src/Client/Net/Http/HttpMethod.ts +55 -0
- package/src/Client/{Http/HttpError.ts → Net/Http/HttpRequestError.ts} +17 -17
- package/src/Client/Net/Http/StatusCode.ts +150 -0
- package/src/Client/Net/Mime/DispositionType.ts +20 -0
- package/src/Client/Net/Mime/MediaType.ts +185 -0
- package/src/Client/{Abstractions → Net}/tsconfig.json +3 -3
- package/src/Client/{Html → UI}/AppTheme.ts +3 -3
- package/src/Client/UI/Components/ComponentBase.ts +34 -0
- package/src/Client/UI/{LoadingIndicator.ts → Components/LoadingIndicator.ts} +1 -3
- package/src/Client/UI/Components/ThemeDropdown.ts +163 -0
- package/src/Client/UI/MenuAlignment.ts +20 -0
- package/src/Client/{Html → UI}/ViewportScroller.ts +6 -6
- package/src/Client/UI/tsconfig.json +2 -3
- package/src/Client/tsconfig.json +1 -4
- package/lib/Abstractions/ILoadingIndicator.d.ts +0 -17
- package/lib/Abstractions/ILoadingIndicator.d.ts.map +0 -1
- package/lib/Abstractions/ILoadingIndicator.js +0 -1
- package/lib/Date.d.ts.map +0 -1
- package/lib/DependencyInjection/Container.d.ts +0 -43
- package/lib/DependencyInjection/Container.d.ts.map +0 -1
- package/lib/DependencyInjection/Container.js +0 -65
- package/lib/Html/AppTheme.d.ts.map +0 -1
- package/lib/Html/Context.d.ts.map +0 -1
- package/lib/Html/File.d.ts.map +0 -1
- package/lib/Html/ViewportScroller.d.ts.map +0 -1
- package/lib/Http/HttpClient.d.ts.map +0 -1
- package/lib/Http/HttpError.d.ts +0 -33
- package/lib/Http/HttpError.d.ts.map +0 -1
- package/lib/Http/StatusCodes.d.ts +0 -114
- package/lib/Http/StatusCodes.d.ts.map +0 -1
- package/lib/Http/StatusCodes.js +0 -109
- package/lib/Number.d.ts.map +0 -1
- package/lib/String.d.ts.map +0 -1
- package/lib/UI/Component.d.ts.map +0 -1
- package/lib/UI/Component.js +0 -29
- package/lib/UI/LoadingIndicator.d.ts.map +0 -1
- package/lib/UI/MenuActivator.d.ts.map +0 -1
- package/lib/UI/OfflineIndicator.d.ts.map +0 -1
- package/lib/UI/ThemeDropdown.d.ts +0 -40
- package/lib/UI/ThemeDropdown.d.ts.map +0 -1
- package/lib/UI/ThemeDropdown.js +0 -80
- package/src/Client/Abstractions/ILoadingIndicator.ts +0 -16
- package/src/Client/DependencyInjection/Container.ts +0 -75
- package/src/Client/DependencyInjection/tsconfig.json +0 -13
- package/src/Client/Html/tsconfig.json +0 -16
- package/src/Client/Http/StatusCodes.ts +0 -140
- package/src/Client/Http/tsconfig.json +0 -16
- package/src/Client/UI/Component.ts +0 -34
- package/src/Client/UI/ThemeDropdown.ts +0 -104
- /package/lib/{Date.js → DateExtensions.js} +0 -0
- /package/lib/{Number.js → NumberExtensions.js} +0 -0
- /package/lib/{String.js → StringExtensions.js} +0 -0
- /package/lib/UI/{LoadingIndicator.js → Components/LoadingIndicator.js} +0 -0
- /package/lib/UI/{MenuActivator.d.ts → Components/MenuActivator.d.ts} +0 -0
- /package/lib/UI/{MenuActivator.js → Components/MenuActivator.js} +0 -0
- /package/lib/UI/{OfflineIndicator.d.ts → Components/OfflineIndicator.d.ts} +0 -0
- /package/lib/UI/{OfflineIndicator.js → Components/OfflineIndicator.js} +0 -0
- /package/lib/{Html → UI}/Context.d.ts +0 -0
- /package/lib/{Html → UI}/Context.js +0 -0
- /package/src/Client/{Date.ts → DateExtensions.ts} +0 -0
- /package/src/Client/{Number.ts → NumberExtensions.ts} +0 -0
- /package/src/Client/{String.ts → StringExtensions.ts} +0 -0
- /package/src/Client/UI/{MenuActivator.ts → Components/MenuActivator.ts} +0 -0
- /package/src/Client/UI/{OfflineIndicator.ts → Components/OfflineIndicator.ts} +0 -0
- /package/src/Client/{Html → UI}/Context.ts +0 -0
package/lib/UI/ThemeDropdown.js
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import { AppTheme, getIcon } from "#Html/AppTheme.js";
|
|
2
|
-
/**
|
|
3
|
-
* A dropdown menu for switching the application theme.
|
|
4
|
-
*/
|
|
5
|
-
export class ThemeDropdown extends HTMLElement {
|
|
6
|
-
/**
|
|
7
|
-
* The media query used to check the application theme.
|
|
8
|
-
*/
|
|
9
|
-
#mediaQuery = matchMedia("(prefers-color-scheme: dark)");
|
|
10
|
-
/**
|
|
11
|
-
* The key of the storage entry providing the saved theme mode.
|
|
12
|
-
*/
|
|
13
|
-
#storageKey = this.getAttribute("storageKey") ?? "AppTheme";
|
|
14
|
-
/**
|
|
15
|
-
* The current application theme.
|
|
16
|
-
*/
|
|
17
|
-
#theme;
|
|
18
|
-
/**
|
|
19
|
-
* Creates a new theme dropdown.
|
|
20
|
-
*/
|
|
21
|
-
constructor() {
|
|
22
|
-
super();
|
|
23
|
-
const theme = localStorage.getItem(this.#storageKey);
|
|
24
|
-
this.#theme = Object.values(AppTheme).includes(theme) ? theme : AppTheme.System;
|
|
25
|
-
for (const button of this.querySelectorAll("button"))
|
|
26
|
-
button.addEventListener("click", this.#setTheme.bind(this));
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Registers the component.
|
|
30
|
-
*/
|
|
31
|
-
static {
|
|
32
|
-
customElements.define("theme-dropdown", this);
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* The current application theme.
|
|
36
|
-
*/
|
|
37
|
-
get theme() {
|
|
38
|
-
return this.#theme;
|
|
39
|
-
}
|
|
40
|
-
set theme(value) {
|
|
41
|
-
localStorage.setItem(this.#storageKey, this.#theme = value);
|
|
42
|
-
this.#applyTheme();
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Method invoked when this component is connected.
|
|
46
|
-
*/
|
|
47
|
-
connectedCallback() {
|
|
48
|
-
this.#mediaQuery.addEventListener("change", this);
|
|
49
|
-
this.#applyTheme();
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Method invoked when this component is disconnected.
|
|
53
|
-
*/
|
|
54
|
-
disconnectedCallback() {
|
|
55
|
-
this.#mediaQuery.removeEventListener("change", this);
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Handles the events.
|
|
59
|
-
*/
|
|
60
|
-
handleEvent() {
|
|
61
|
-
this.#applyTheme();
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Applies the theme to the document.
|
|
65
|
-
*/
|
|
66
|
-
#applyTheme() {
|
|
67
|
-
const theme = this.#theme == AppTheme.System ? (this.#mediaQuery.matches ? AppTheme.Dark : AppTheme.Light) : this.#theme;
|
|
68
|
-
document.documentElement.dataset.bsTheme = theme.toLowerCase();
|
|
69
|
-
this.querySelector(".dropdown-toggle > .icon").textContent = getIcon(this.#theme);
|
|
70
|
-
this.querySelector(`button[data-theme="${this.#theme}"]`).appendChild(this.querySelector(".dropdown-item > .icon"));
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Changes the current theme.
|
|
74
|
-
* @param event The dispatched event.
|
|
75
|
-
*/
|
|
76
|
-
#setTheme(event) {
|
|
77
|
-
const button = event.target.closest("button");
|
|
78
|
-
this.theme = button.dataset.theme;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A component that shows up when an HTTP request starts, and hides when all concurrent HTTP requests are completed.
|
|
3
|
-
*/
|
|
4
|
-
export interface ILoadingIndicator {
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Starts the loading indicator.
|
|
8
|
-
*/
|
|
9
|
-
start: () => void;
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Stops the loading indicator.
|
|
13
|
-
* @param options Value indicating whether to force the loading indicator to stop.
|
|
14
|
-
*/
|
|
15
|
-
stop: (options?: {force?: boolean}) => void;
|
|
16
|
-
}
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Provides a dependency container.
|
|
3
|
-
*/
|
|
4
|
-
export class Container {
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* The registered factories.
|
|
8
|
-
*/
|
|
9
|
-
readonly #factories = new Map<ContainerToken, () => any>;
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* The registered services.
|
|
13
|
-
*/
|
|
14
|
-
readonly #services = new Map<ContainerToken, any>;
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Removes the service registered with the specified identifier.
|
|
18
|
-
* @param id The identification token.
|
|
19
|
-
*/
|
|
20
|
-
delete(id: ContainerToken): void {
|
|
21
|
-
this.#factories.delete(id);
|
|
22
|
-
this.#services.delete(id);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Gets the service registered with the specified identifier.
|
|
27
|
-
* @param id The identification token.
|
|
28
|
-
* @returns The instance of the service registered with the specified identifier.
|
|
29
|
-
* @throws `Error` if there is no factory registered with the specified identifier.
|
|
30
|
-
*/
|
|
31
|
-
get<T>(id: ContainerToken): T { // eslint-disable-line @typescript-eslint/no-unnecessary-type-parameters
|
|
32
|
-
if (!this.#services.has(id))
|
|
33
|
-
if (this.#factories.has(id)) this.set(id, this.#factories.get(id)!.call(this));
|
|
34
|
-
else if (typeof id == "function") this.set(id, Reflect.construct(id, []));
|
|
35
|
-
else throw Error("There is no factory registered with the specified identifier.");
|
|
36
|
-
|
|
37
|
-
return this.#services.get(id) as T;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Gets a value indicating whether this container has a service registered with the specified identifier.
|
|
42
|
-
* @param id The identification token.
|
|
43
|
-
* @returns `true` if a service registered with the specified identifier exists in this container, otherwise `false`.
|
|
44
|
-
*/
|
|
45
|
-
has(id: ContainerToken): boolean {
|
|
46
|
-
return this.#factories.has(id) || this.#services.has(id);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Registers a service factory with this container.
|
|
51
|
-
* @param id The identification token.
|
|
52
|
-
* @param factory The service factory.
|
|
53
|
-
* @returns This instance.
|
|
54
|
-
*/
|
|
55
|
-
register(id: ContainerToken, factory: () => unknown): this {
|
|
56
|
-
this.#factories.set(id, factory);
|
|
57
|
-
return this;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Registers a service instance with this container.
|
|
62
|
-
* @param id The identification token.
|
|
63
|
-
* @param service The service instance.
|
|
64
|
-
* @returns This instance.
|
|
65
|
-
*/
|
|
66
|
-
set(id: ContainerToken, service: unknown): this {
|
|
67
|
-
this.#services.set(id, service);
|
|
68
|
-
return this;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* A token identifying a service.
|
|
74
|
-
*/
|
|
75
|
-
export type ContainerToken = string|symbol|(new(...args: any[]) => any);
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "../../../tsconfig.json",
|
|
3
|
-
"include": ["*.ts"],
|
|
4
|
-
"compilerOptions": {
|
|
5
|
-
"composite": true,
|
|
6
|
-
"declaration": true,
|
|
7
|
-
"declarationMap": true,
|
|
8
|
-
"noEmit": false,
|
|
9
|
-
"outDir": "../../../lib/DependencyInjection",
|
|
10
|
-
"rootDir": ".",
|
|
11
|
-
"tsBuildInfoFile": "../../../var/DependencyInjection.tsbuildinfo"
|
|
12
|
-
}
|
|
13
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "../../../tsconfig.json",
|
|
3
|
-
"include": ["*.ts"],
|
|
4
|
-
"compilerOptions": {
|
|
5
|
-
"composite": true,
|
|
6
|
-
"declaration": true,
|
|
7
|
-
"declarationMap": true,
|
|
8
|
-
"noEmit": false,
|
|
9
|
-
"outDir": "../../../lib/Html",
|
|
10
|
-
"rootDir": ".",
|
|
11
|
-
"tsBuildInfoFile": "../../../var/Html.tsbuildinfo"
|
|
12
|
-
},
|
|
13
|
-
"references": [
|
|
14
|
-
{"path": "../Base/tsconfig.json"}
|
|
15
|
-
]
|
|
16
|
-
}
|
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Provides common HTTP status codes.
|
|
3
|
-
*/
|
|
4
|
-
export const StatusCodes = Object.freeze({
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* The `OK` status.
|
|
8
|
-
*/
|
|
9
|
-
OK: 200,
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* The `Created` status.
|
|
13
|
-
*/
|
|
14
|
-
Created: 201,
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* The `No Content` status.
|
|
18
|
-
*/
|
|
19
|
-
NoContent: 204,
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* The `Moved Permanently` status.
|
|
23
|
-
*/
|
|
24
|
-
MovedPermanently: 301,
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* The `Found` status.
|
|
28
|
-
*/
|
|
29
|
-
Found: 302,
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* The `Not Modified` status.
|
|
33
|
-
*/
|
|
34
|
-
NotModified: 304,
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* The `Bad Request` status.
|
|
38
|
-
*/
|
|
39
|
-
BadRequest: 400,
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* The `Unauthorized` status.
|
|
43
|
-
*/
|
|
44
|
-
Unauthorized: 401,
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* The `Payment Required` status.
|
|
48
|
-
*/
|
|
49
|
-
PaymentRequired: 402,
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* The `Forbidden` status.
|
|
53
|
-
*/
|
|
54
|
-
Forbidden: 403,
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* The `Not Found` status.
|
|
58
|
-
*/
|
|
59
|
-
NotFound: 404,
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* The `Method Not Allowed` status.
|
|
63
|
-
*/
|
|
64
|
-
MethodNotAllowed: 405,
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* The `Not Acceptable` status.
|
|
68
|
-
*/
|
|
69
|
-
NotAcceptable: 406,
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* The `Request Timeout` status.
|
|
73
|
-
*/
|
|
74
|
-
RequestTimeout: 408,
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* The `Conflict` status.
|
|
78
|
-
*/
|
|
79
|
-
Conflict: 409,
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* The `Payload Too Large` status.
|
|
83
|
-
*/
|
|
84
|
-
PayloadTooLarge: 413,
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* The `Unsupported Media Type` status.
|
|
88
|
-
*/
|
|
89
|
-
UnsupportedMediaType: 415,
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* The `Page Expired` status.
|
|
93
|
-
*/
|
|
94
|
-
PageExpired: 419,
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* The `Unprocessable Content` status.
|
|
98
|
-
*/
|
|
99
|
-
UnprocessableContent: 422,
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* The `Too Many Requests` status.
|
|
103
|
-
*/
|
|
104
|
-
TooManyRequests: 429,
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* The `Internal Server Error` status.
|
|
108
|
-
*/
|
|
109
|
-
InternalServerError: 500,
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* The `Not Implemented` status.
|
|
113
|
-
*/
|
|
114
|
-
NotImplemented: 501,
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* The `Bad Gateway` status.
|
|
118
|
-
*/
|
|
119
|
-
BadGateway: 502,
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* The `Service Unavailable` status.
|
|
123
|
-
*/
|
|
124
|
-
ServiceUnavailable: 503,
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* The `Gateway Timeout` status.
|
|
128
|
-
*/
|
|
129
|
-
GatewayTimeout: 504,
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* The `Bandwidth Limit Exceeded` status
|
|
133
|
-
*/
|
|
134
|
-
BandwidthLimitExceeded: 509
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
/**
|
|
138
|
-
* Provides common HTTP status codes.
|
|
139
|
-
*/
|
|
140
|
-
export type StatusCodes = typeof StatusCodes[keyof typeof StatusCodes];
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "../../../tsconfig.json",
|
|
3
|
-
"include": ["*.ts"],
|
|
4
|
-
"compilerOptions": {
|
|
5
|
-
"composite": true,
|
|
6
|
-
"declaration": true,
|
|
7
|
-
"declarationMap": true,
|
|
8
|
-
"noEmit": false,
|
|
9
|
-
"outDir": "../../../lib/Http",
|
|
10
|
-
"rootDir": ".",
|
|
11
|
-
"tsBuildInfoFile": "../../../var/Http.tsbuildinfo"
|
|
12
|
-
},
|
|
13
|
-
"references": [
|
|
14
|
-
{"path": "../Abstractions/tsconfig.json"}
|
|
15
|
-
]
|
|
16
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import {LitElement, type CSSResultGroup} from "lit";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* The optional base class for UI components. Alternatively, components may extend {@link LitElement} directly.
|
|
5
|
-
*/
|
|
6
|
-
export abstract class Component extends LitElement {
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* The component styles.
|
|
10
|
-
*/
|
|
11
|
-
static override styles: CSSResultGroup = [document.adoptedStyleSheets];
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Value indicating whether this component uses a shadow root.
|
|
15
|
-
*/
|
|
16
|
-
readonly #useShadowRoot: boolean;
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Creates a new component.
|
|
20
|
-
* @param options Value indicating whether this component uses a shadow root.
|
|
21
|
-
*/
|
|
22
|
-
constructor(options: {shadowRoot?: boolean} = {}) {
|
|
23
|
-
super();
|
|
24
|
-
this.#useShadowRoot = options.shadowRoot ?? false;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Returns the node into which this component should render.
|
|
29
|
-
* @returns The node into which this component should render.
|
|
30
|
-
*/
|
|
31
|
-
protected override createRenderRoot(): DocumentFragment|HTMLElement {
|
|
32
|
-
return this.#useShadowRoot ? super.createRenderRoot() : this;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import {AppTheme, getIcon} from "#Html/AppTheme.js";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* A dropdown menu for switching the application theme.
|
|
5
|
-
*/
|
|
6
|
-
export class ThemeDropdown extends HTMLElement {
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* The media query used to check the application theme.
|
|
10
|
-
*/
|
|
11
|
-
readonly #mediaQuery = matchMedia("(prefers-color-scheme: dark)");
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* The key of the storage entry providing the saved theme mode.
|
|
15
|
-
*/
|
|
16
|
-
readonly #storageKey = this.getAttribute("storageKey") ?? "AppTheme";
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* The current application theme.
|
|
20
|
-
*/
|
|
21
|
-
#theme: AppTheme;
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Creates a new theme dropdown.
|
|
25
|
-
*/
|
|
26
|
-
constructor() {
|
|
27
|
-
super();
|
|
28
|
-
const theme = localStorage.getItem(this.#storageKey) as AppTheme;
|
|
29
|
-
this.#theme = Object.values(AppTheme).includes(theme) ? theme : AppTheme.System;
|
|
30
|
-
for (const button of this.querySelectorAll("button")) button.addEventListener("click", this.#setTheme.bind(this));
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Registers the component.
|
|
35
|
-
*/
|
|
36
|
-
static {
|
|
37
|
-
customElements.define("theme-dropdown", this);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* The current application theme.
|
|
42
|
-
*/
|
|
43
|
-
get theme(): AppTheme {
|
|
44
|
-
return this.#theme;
|
|
45
|
-
}
|
|
46
|
-
set theme(value: AppTheme) {
|
|
47
|
-
localStorage.setItem(this.#storageKey, this.#theme = value);
|
|
48
|
-
this.#applyTheme();
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Method invoked when this component is connected.
|
|
53
|
-
*/
|
|
54
|
-
connectedCallback(): void {
|
|
55
|
-
this.#mediaQuery.addEventListener("change", this);
|
|
56
|
-
this.#applyTheme();
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Method invoked when this component is disconnected.
|
|
61
|
-
*/
|
|
62
|
-
disconnectedCallback(): void {
|
|
63
|
-
this.#mediaQuery.removeEventListener("change", this);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Handles the events.
|
|
68
|
-
*/
|
|
69
|
-
handleEvent(): void {
|
|
70
|
-
this.#applyTheme();
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Applies the theme to the document.
|
|
75
|
-
*/
|
|
76
|
-
#applyTheme(): void {
|
|
77
|
-
const theme = this.#theme == AppTheme.System ? (this.#mediaQuery.matches ? AppTheme.Dark : AppTheme.Light) : this.#theme;
|
|
78
|
-
document.documentElement.dataset.bsTheme = theme.toLowerCase();
|
|
79
|
-
this.querySelector(".dropdown-toggle > .icon")!.textContent = getIcon(this.#theme);
|
|
80
|
-
this.querySelector(`button[data-theme="${this.#theme}"]`)!.appendChild(this.querySelector(".dropdown-item > .icon")!);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Changes the current theme.
|
|
85
|
-
* @param event The dispatched event.
|
|
86
|
-
*/
|
|
87
|
-
#setTheme(event: Event): void {
|
|
88
|
-
const button = (event.target as HTMLElement).closest("button")!;
|
|
89
|
-
this.theme = button.dataset.theme as AppTheme;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* Declaration merging.
|
|
95
|
-
*/
|
|
96
|
-
declare global {
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* The map of HTML tag names.
|
|
100
|
-
*/
|
|
101
|
-
interface HTMLElementTagNameMap {
|
|
102
|
-
"theme-dropdown": ThemeDropdown;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|