@cedx/base 0.6.0 → 0.8.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} +4 -13
- package/lib/Hosting/Environment.d.ts +22 -0
- package/lib/Hosting/Environment.d.ts.map +1 -0
- package/lib/Hosting/Environment.js +17 -0
- package/lib/Hosting/HostEnvironment.d.ts +61 -0
- package/lib/Hosting/HostEnvironment.d.ts.map +1 -0
- package/lib/Hosting/HostEnvironment.js +56 -0
- 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/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/FormExtensions.d.ts +33 -0
- package/lib/UI/FormExtensions.d.ts.map +1 -0
- package/lib/UI/FormExtensions.js +50 -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 -10
- 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} +4 -14
- package/src/Client/Hosting/Environment.ts +25 -0
- package/src/Client/Hosting/HostEnvironment.ts +86 -0
- package/src/Client/{Abstractions → Hosting}/tsconfig.json +3 -3
- package/src/Client/Net/Http/HttpMethod.ts +55 -0
- 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/{DependencyInjection → 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/FormExtensions.ts +55 -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 -6
- package/src/Client/tsconfig.json +2 -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 +0 -68
- package/lib/Http/HttpClient.d.ts.map +0 -1
- package/lib/Http/HttpClient.js +0 -102
- package/lib/Http/HttpError.d.ts +0 -33
- package/lib/Http/HttpError.d.ts.map +0 -1
- package/lib/Http/HttpError.js +0 -66
- 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/Html/tsconfig.json +0 -16
- package/src/Client/Http/HttpClient.ts +0 -127
- package/src/Client/Http/HttpError.ts +0 -75
- 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/Http/StatusCodes.js
DELETED
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Provides common HTTP status codes.
|
|
3
|
-
*/
|
|
4
|
-
export const StatusCodes = Object.freeze({
|
|
5
|
-
/**
|
|
6
|
-
* The `OK` status.
|
|
7
|
-
*/
|
|
8
|
-
OK: 200,
|
|
9
|
-
/**
|
|
10
|
-
* The `Created` status.
|
|
11
|
-
*/
|
|
12
|
-
Created: 201,
|
|
13
|
-
/**
|
|
14
|
-
* The `No Content` status.
|
|
15
|
-
*/
|
|
16
|
-
NoContent: 204,
|
|
17
|
-
/**
|
|
18
|
-
* The `Moved Permanently` status.
|
|
19
|
-
*/
|
|
20
|
-
MovedPermanently: 301,
|
|
21
|
-
/**
|
|
22
|
-
* The `Found` status.
|
|
23
|
-
*/
|
|
24
|
-
Found: 302,
|
|
25
|
-
/**
|
|
26
|
-
* The `Not Modified` status.
|
|
27
|
-
*/
|
|
28
|
-
NotModified: 304,
|
|
29
|
-
/**
|
|
30
|
-
* The `Bad Request` status.
|
|
31
|
-
*/
|
|
32
|
-
BadRequest: 400,
|
|
33
|
-
/**
|
|
34
|
-
* The `Unauthorized` status.
|
|
35
|
-
*/
|
|
36
|
-
Unauthorized: 401,
|
|
37
|
-
/**
|
|
38
|
-
* The `Payment Required` status.
|
|
39
|
-
*/
|
|
40
|
-
PaymentRequired: 402,
|
|
41
|
-
/**
|
|
42
|
-
* The `Forbidden` status.
|
|
43
|
-
*/
|
|
44
|
-
Forbidden: 403,
|
|
45
|
-
/**
|
|
46
|
-
* The `Not Found` status.
|
|
47
|
-
*/
|
|
48
|
-
NotFound: 404,
|
|
49
|
-
/**
|
|
50
|
-
* The `Method Not Allowed` status.
|
|
51
|
-
*/
|
|
52
|
-
MethodNotAllowed: 405,
|
|
53
|
-
/**
|
|
54
|
-
* The `Not Acceptable` status.
|
|
55
|
-
*/
|
|
56
|
-
NotAcceptable: 406,
|
|
57
|
-
/**
|
|
58
|
-
* The `Request Timeout` status.
|
|
59
|
-
*/
|
|
60
|
-
RequestTimeout: 408,
|
|
61
|
-
/**
|
|
62
|
-
* The `Conflict` status.
|
|
63
|
-
*/
|
|
64
|
-
Conflict: 409,
|
|
65
|
-
/**
|
|
66
|
-
* The `Payload Too Large` status.
|
|
67
|
-
*/
|
|
68
|
-
PayloadTooLarge: 413,
|
|
69
|
-
/**
|
|
70
|
-
* The `Unsupported Media Type` status.
|
|
71
|
-
*/
|
|
72
|
-
UnsupportedMediaType: 415,
|
|
73
|
-
/**
|
|
74
|
-
* The `Page Expired` status.
|
|
75
|
-
*/
|
|
76
|
-
PageExpired: 419,
|
|
77
|
-
/**
|
|
78
|
-
* The `Unprocessable Content` status.
|
|
79
|
-
*/
|
|
80
|
-
UnprocessableContent: 422,
|
|
81
|
-
/**
|
|
82
|
-
* The `Too Many Requests` status.
|
|
83
|
-
*/
|
|
84
|
-
TooManyRequests: 429,
|
|
85
|
-
/**
|
|
86
|
-
* The `Internal Server Error` status.
|
|
87
|
-
*/
|
|
88
|
-
InternalServerError: 500,
|
|
89
|
-
/**
|
|
90
|
-
* The `Not Implemented` status.
|
|
91
|
-
*/
|
|
92
|
-
NotImplemented: 501,
|
|
93
|
-
/**
|
|
94
|
-
* The `Bad Gateway` status.
|
|
95
|
-
*/
|
|
96
|
-
BadGateway: 502,
|
|
97
|
-
/**
|
|
98
|
-
* The `Service Unavailable` status.
|
|
99
|
-
*/
|
|
100
|
-
ServiceUnavailable: 503,
|
|
101
|
-
/**
|
|
102
|
-
* The `Gateway Timeout` status.
|
|
103
|
-
*/
|
|
104
|
-
GatewayTimeout: 504,
|
|
105
|
-
/**
|
|
106
|
-
* The `Bandwidth Limit Exceeded` status
|
|
107
|
-
*/
|
|
108
|
-
BandwidthLimitExceeded: 509
|
|
109
|
-
});
|
package/lib/Number.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Number.d.ts","sourceRoot":"","sources":["../src/Client/Number.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,SAAI,GAAG,MAAM,CAG1D"}
|
package/lib/String.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"String.d.ts","sourceRoot":"","sources":["../src/Client/String.ts"],"names":[],"mappings":"AAWA;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,GAAE,IAAI,CAAC,MAAM,GAAC,MAA2B,GAAG,MAAM,CAEjG;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEjD;AAED;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE7C;AAED;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,SAAI,GAAG,MAAM,EAAE,CAE9D;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE/C;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,CAG5C;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAG1E;AAED;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,SAAQ,GAAG,MAAM,CAEhF;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE/C"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Component.d.ts","sourceRoot":"","sources":["../../src/Client/UI/Component.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAE,KAAK,cAAc,EAAC,MAAM,KAAK,CAAC;AAEpD;;GAEG;AACH,8BAAsB,SAAU,SAAQ,UAAU;;IAEjD;;OAEG;IACH,OAAgB,MAAM,EAAE,cAAc,CAAiC;IAOvE;;;OAGG;gBACS,OAAO,GAAE;QAAC,UAAU,CAAC,EAAE,OAAO,CAAA;KAAM;IAKhD;;;OAGG;cACgB,gBAAgB,IAAI,gBAAgB,GAAC,WAAW;CAGnE"}
|
package/lib/UI/Component.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { LitElement } from "lit";
|
|
2
|
-
/**
|
|
3
|
-
* The optional base class for UI components. Alternatively, components may extend {@link LitElement} directly.
|
|
4
|
-
*/
|
|
5
|
-
export class Component extends LitElement {
|
|
6
|
-
/**
|
|
7
|
-
* The component styles.
|
|
8
|
-
*/
|
|
9
|
-
static styles = [document.adoptedStyleSheets];
|
|
10
|
-
/**
|
|
11
|
-
* Value indicating whether this component uses a shadow root.
|
|
12
|
-
*/
|
|
13
|
-
#useShadowRoot;
|
|
14
|
-
/**
|
|
15
|
-
* Creates a new component.
|
|
16
|
-
* @param options Value indicating whether this component uses a shadow root.
|
|
17
|
-
*/
|
|
18
|
-
constructor(options = {}) {
|
|
19
|
-
super();
|
|
20
|
-
this.#useShadowRoot = options.shadowRoot ?? false;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Returns the node into which this component should render.
|
|
24
|
-
* @returns The node into which this component should render.
|
|
25
|
-
*/
|
|
26
|
-
createRenderRoot() {
|
|
27
|
-
return this.#useShadowRoot ? super.createRenderRoot() : this;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"LoadingIndicator.d.ts","sourceRoot":"","sources":["../../src/Client/UI/LoadingIndicator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,iBAAiB,EAAC,MAAM,oCAAoC,CAAC;AAE1E;;GAEG;AACH,qBAAa,gBAAiB,SAAQ,WAAY,YAAW,iBAAiB;;IAc7E;;OAEG;IACH,KAAK,IAAI,IAAI;IAMb;;;OAGG;IACH,IAAI,CAAC,OAAO,GAAE;QAAC,KAAK,CAAC,EAAE,OAAO,CAAA;KAAM,GAAG,IAAI;CAQ3C;AAED;;GAEG;AACH,OAAO,CAAC,MAAM,CAAC;IAEd;;OAEG;IACH,UAAU,qBAAqB;QAC9B,mBAAmB,EAAE,gBAAgB,CAAC;KACtC;CACD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"MenuActivator.d.ts","sourceRoot":"","sources":["../../src/Client/UI/MenuActivator.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,aAAc,SAAQ,WAAW;IAS7C;;OAEG;IACH,iBAAiB,IAAI,IAAI;CAQzB;AAED;;GAEG;AACH,OAAO,CAAC,MAAM,CAAC;IAEd;;OAEG;IACH,UAAU,qBAAqB;QAC9B,gBAAgB,EAAE,aAAa,CAAC;KAChC;CACD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"OfflineIndicator.d.ts","sourceRoot":"","sources":["../../src/Client/UI/OfflineIndicator.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,gBAAiB,SAAQ,WAAW;IAEhD;;OAEG;;IAaH;;OAEG;IACH,iBAAiB,IAAI,IAAI;IAIzB;;OAEG;IACH,oBAAoB,IAAI,IAAI;IAI5B;;OAEG;IACH,WAAW,IAAI,IAAI;CAGnB;AAED;;GAEG;AACH,OAAO,CAAC,MAAM,CAAC;IAEd;;OAEG;IACH,UAAU,qBAAqB;QAC9B,mBAAmB,EAAE,gBAAgB,CAAC;KACtC;CACD"}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { AppTheme } from "#Html/AppTheme.js";
|
|
2
|
-
/**
|
|
3
|
-
* A dropdown menu for switching the application theme.
|
|
4
|
-
*/
|
|
5
|
-
export declare class ThemeDropdown extends HTMLElement {
|
|
6
|
-
#private;
|
|
7
|
-
/**
|
|
8
|
-
* Creates a new theme dropdown.
|
|
9
|
-
*/
|
|
10
|
-
constructor();
|
|
11
|
-
/**
|
|
12
|
-
* The current application theme.
|
|
13
|
-
*/
|
|
14
|
-
get theme(): AppTheme;
|
|
15
|
-
set theme(value: AppTheme);
|
|
16
|
-
/**
|
|
17
|
-
* Method invoked when this component is connected.
|
|
18
|
-
*/
|
|
19
|
-
connectedCallback(): void;
|
|
20
|
-
/**
|
|
21
|
-
* Method invoked when this component is disconnected.
|
|
22
|
-
*/
|
|
23
|
-
disconnectedCallback(): void;
|
|
24
|
-
/**
|
|
25
|
-
* Handles the events.
|
|
26
|
-
*/
|
|
27
|
-
handleEvent(): void;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Declaration merging.
|
|
31
|
-
*/
|
|
32
|
-
declare global {
|
|
33
|
-
/**
|
|
34
|
-
* The map of HTML tag names.
|
|
35
|
-
*/
|
|
36
|
-
interface HTMLElementTagNameMap {
|
|
37
|
-
"theme-dropdown": ThemeDropdown;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
//# sourceMappingURL=ThemeDropdown.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ThemeDropdown.d.ts","sourceRoot":"","sources":["../../src/Client/UI/ThemeDropdown.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAU,MAAM,mBAAmB,CAAC;AAEpD;;GAEG;AACH,qBAAa,aAAc,SAAQ,WAAW;;IAiB7C;;OAEG;;IAeH;;OAEG;IACH,IAAI,KAAK,IAAI,QAAQ,CAEpB;IACD,IAAI,KAAK,CAAC,KAAK,EAAE,QAAQ,EAGxB;IAED;;OAEG;IACH,iBAAiB,IAAI,IAAI;IAKzB;;OAEG;IACH,oBAAoB,IAAI,IAAI;IAI5B;;OAEG;IACH,WAAW,IAAI,IAAI;CAsBnB;AAED;;GAEG;AACH,OAAO,CAAC,MAAM,CAAC;IAEd;;OAEG;IACH,UAAU,qBAAqB;QAC9B,gBAAgB,EAAE,aAAa,CAAC;KAChC;CACD"}
|
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,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,127 +0,0 @@
|
|
|
1
|
-
import type {ILoadingIndicator} from "#Abstractions/ILoadingIndicator.js";
|
|
2
|
-
import {HttpError} from "./HttpError.js";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Performs HTTP requests.
|
|
6
|
-
*/
|
|
7
|
-
export class HttpClient {
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* The base URL of the remote service.
|
|
11
|
-
*/
|
|
12
|
-
readonly baseUrl: URL;
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* The function returning the component used as loading indicator.
|
|
16
|
-
*/
|
|
17
|
-
readonly #loadingIndicator: () => ILoadingIndicator|null;
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Creates a new HTTP client.
|
|
21
|
-
* @param options An object providing values to initialize this instance.
|
|
22
|
-
*/
|
|
23
|
-
constructor(options: HttpClientOptions = {}) {
|
|
24
|
-
const url = options.baseUrl ? (options.baseUrl instanceof URL ? options.baseUrl.href : options.baseUrl) : document.baseURI;
|
|
25
|
-
this.baseUrl = new URL(url.endsWith("/") ? url : `${url}/`);
|
|
26
|
-
this.#loadingIndicator = options.loadingIndicator ?? (() => document.body.querySelector("loading-indicator") as ILoadingIndicator|null);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Performs a DELETE request.
|
|
31
|
-
* @param url The URL of the resource to fetch.
|
|
32
|
-
* @param options The request options.
|
|
33
|
-
* @returns The server response.
|
|
34
|
-
*/
|
|
35
|
-
delete(url?: string|URL, options?: RequestInit): Promise<Response> {
|
|
36
|
-
return this.#fetch("DELETE", url, null, options);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Performs a GET request.
|
|
41
|
-
* @param url The URL of the resource to fetch.
|
|
42
|
-
* @param options The request options.
|
|
43
|
-
* @returns The server response.
|
|
44
|
-
*/
|
|
45
|
-
get(url?: string|URL, options?: RequestInit): Promise<Response> {
|
|
46
|
-
return this.#fetch("GET", url, null, options);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Performs a PATCH request.
|
|
51
|
-
* @param url The URL of the resource to fetch.
|
|
52
|
-
* @param body The request body.
|
|
53
|
-
* @param options The request options.
|
|
54
|
-
* @returns The server response.
|
|
55
|
-
*/
|
|
56
|
-
patch(url?: string|URL, body?: unknown, options?: RequestInit): Promise<Response> {
|
|
57
|
-
return this.#fetch("PATCH", url, body, options);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Performs a POST request.
|
|
62
|
-
* @param url The URL of the resource to fetch.
|
|
63
|
-
* @param body The request body.
|
|
64
|
-
* @param options The request options.
|
|
65
|
-
* @returns The server response.
|
|
66
|
-
*/
|
|
67
|
-
post(url?: string|URL, body?: unknown, options?: RequestInit): Promise<Response> {
|
|
68
|
-
return this.#fetch("POST", url, body, options);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* Performs a PUT request.
|
|
73
|
-
* @param url The URL of the resource to fetch.
|
|
74
|
-
* @param body The request body.
|
|
75
|
-
* @param options The request options.
|
|
76
|
-
* @returns The server response.
|
|
77
|
-
*/
|
|
78
|
-
put(url?: string|URL, body?: unknown, options?: RequestInit): Promise<Response> {
|
|
79
|
-
return this.#fetch("PUT", url, body, options);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Performs a custom HTTP request.
|
|
84
|
-
* @param method The HTTP method.
|
|
85
|
-
* @param url The URL of the resource to fetch.
|
|
86
|
-
* @param body The request body.
|
|
87
|
-
* @param options The request options.
|
|
88
|
-
* @returns The server response.
|
|
89
|
-
*/
|
|
90
|
-
async #fetch(method: string, url: string|URL = "", body: unknown = null, options: RequestInit = {}): Promise<Response> {
|
|
91
|
-
const headers = new Headers(options.headers);
|
|
92
|
-
if (!headers.has("accept")) headers.set("accept", "application/json");
|
|
93
|
-
|
|
94
|
-
if (body && !(body instanceof Blob || body instanceof FormData || body instanceof URLSearchParams)) {
|
|
95
|
-
if (typeof body != "string") body = JSON.stringify(body);
|
|
96
|
-
if (!headers.has("content-type")) headers.set("content-type", "application/json");
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
const loadingIndicator = this.#loadingIndicator();
|
|
100
|
-
try {
|
|
101
|
-
loadingIndicator?.start();
|
|
102
|
-
const request = new Request(new URL(url, this.baseUrl), {...options, method, headers, body} as RequestInit);
|
|
103
|
-
const response = await fetch(request);
|
|
104
|
-
if (!response.ok) throw new HttpError(response);
|
|
105
|
-
return response;
|
|
106
|
-
}
|
|
107
|
-
finally {
|
|
108
|
-
loadingIndicator?.stop();
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
* Defines the options of a {@link HttpClient} instance.
|
|
115
|
-
*/
|
|
116
|
-
export type HttpClientOptions = Partial<{
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* The base URL of the remote service.
|
|
120
|
-
*/
|
|
121
|
-
baseUrl: string|URL;
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* The function returning the component used as loading indicator.
|
|
125
|
-
*/
|
|
126
|
-
loadingIndicator: () => ILoadingIndicator|null;
|
|
127
|
-
}>;
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import {StatusCodes} from "./StatusCodes.js";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* An object thrown when an HTTP error occurs.
|
|
5
|
-
*/
|
|
6
|
-
export class HttpError extends globalThis.Error {
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* The validation errors.
|
|
10
|
-
*/
|
|
11
|
-
#validationErrors: Map<string, string>|null = null;
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Creates a new HTTP error.
|
|
15
|
-
* @param response The server response.
|
|
16
|
-
*/
|
|
17
|
-
constructor(response: Response) {
|
|
18
|
-
super(`${response.status} ${response.statusText}`, {cause: response});
|
|
19
|
-
this.name = "HttpError";
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* The server response.
|
|
24
|
-
*/
|
|
25
|
-
override get cause(): Response {
|
|
26
|
-
return super.cause as Response;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Value indicating whether the response's status code is between 400 and 499.
|
|
31
|
-
*/
|
|
32
|
-
get isClientError(): boolean {
|
|
33
|
-
const {status} = this;
|
|
34
|
-
return status >= 400 && status < 500;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Value indicating whether the response's status code is between 500 and 599.
|
|
39
|
-
*/
|
|
40
|
-
get isServerError(): boolean {
|
|
41
|
-
const {status} = this;
|
|
42
|
-
return status >= 500 && status < 600;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* The response's status code.
|
|
47
|
-
*/
|
|
48
|
-
get status(): StatusCodes {
|
|
49
|
-
return this.cause.status as StatusCodes;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* The validation errors.
|
|
54
|
-
*/
|
|
55
|
-
get validationErrors(): Promise<Map<string, string>> {
|
|
56
|
-
return this.#validationErrors
|
|
57
|
-
? Promise.resolve(this.#validationErrors)
|
|
58
|
-
: this.#parseValidationErrors().then(errors => this.#validationErrors = errors);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Parses the validation errors returned in the body of the specified response.
|
|
63
|
-
* @returns The validation errors provided by the response body.
|
|
64
|
-
*/
|
|
65
|
-
async #parseValidationErrors(): Promise<Map<string, string>> {
|
|
66
|
-
try {
|
|
67
|
-
const statuses = new Set<StatusCodes>([StatusCodes.BadRequest, StatusCodes.UnprocessableContent]);
|
|
68
|
-
const ignoreBody = this.cause.bodyUsed || !statuses.has(this.status);
|
|
69
|
-
return new Map(ignoreBody ? [] : Object.entries(await this.cause.json() as Record<string, string>));
|
|
70
|
-
}
|
|
71
|
-
catch {
|
|
72
|
-
return new Map;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|