@cedx/base 0.7.0 → 0.9.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/FileExtensions.js +1 -1
- 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/UI/Components/LoadingIndicator.d.ts +8 -0
- package/lib/UI/Components/LoadingIndicator.d.ts.map +1 -1
- package/lib/UI/Components/LoadingIndicator.js +16 -4
- package/lib/UI/Components/OfflineIndicator.d.ts +7 -2
- package/lib/UI/Components/OfflineIndicator.d.ts.map +1 -1
- package/lib/UI/Components/OfflineIndicator.js +16 -6
- package/lib/UI/Components/TabActivator.d.ts +45 -0
- package/lib/UI/Components/TabActivator.d.ts.map +1 -0
- package/lib/UI/Components/TabActivator.js +67 -0
- package/lib/UI/Components/ThemeDropdown.d.ts +0 -8
- package/lib/UI/Components/ThemeDropdown.d.ts.map +1 -1
- package/lib/UI/Components/ThemeDropdown.js +10 -20
- 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/StorageArea.d.ts +18 -0
- package/lib/UI/StorageArea.d.ts.map +1 -0
- package/lib/UI/StorageArea.js +13 -0
- package/package.json +2 -5
- package/src/Client/FileExtensions.ts +1 -1
- package/src/Client/Hosting/Environment.ts +25 -0
- package/src/Client/Hosting/HostEnvironment.ts +86 -0
- package/src/Client/Hosting/tsconfig.json +13 -0
- package/src/Client/UI/Components/LoadingIndicator.ts +18 -4
- package/src/Client/UI/Components/OfflineIndicator.ts +19 -6
- package/src/Client/UI/Components/TabActivator.ts +87 -0
- package/src/Client/UI/Components/ThemeDropdown.ts +9 -21
- package/src/Client/UI/FormExtensions.ts +55 -0
- package/src/Client/UI/StorageArea.ts +20 -0
- package/src/Client/UI/tsconfig.json +1 -4
- package/src/Client/tsconfig.json +1 -0
- package/lib/Net/Http/HttpClient.d.ts +0 -83
- package/lib/Net/Http/HttpClient.d.ts.map +0 -1
- package/lib/Net/Http/HttpClient.js +0 -104
- package/lib/Net/Http/HttpRequestError.d.ts +0 -33
- package/lib/Net/Http/HttpRequestError.d.ts.map +0 -1
- package/lib/Net/Http/HttpRequestError.js +0 -66
- package/src/Client/Net/Http/HttpClient.ts +0 -145
- package/src/Client/Net/Http/HttpRequestError.ts +0 -75
package/package.json
CHANGED
|
@@ -7,13 +7,13 @@
|
|
|
7
7
|
"name": "@cedx/base",
|
|
8
8
|
"repository": "cedx/base",
|
|
9
9
|
"type": "module",
|
|
10
|
-
"version": "0.
|
|
10
|
+
"version": "0.9.0",
|
|
11
11
|
"devDependencies": {
|
|
12
12
|
"@playwright/browser-chromium": "^1.54.2",
|
|
13
13
|
"@types/bootstrap": "^5.2.10",
|
|
14
14
|
"@types/chai": "^5.2.2",
|
|
15
15
|
"@types/mocha": "^10.0.10",
|
|
16
|
-
"@types/node": "^24.
|
|
16
|
+
"@types/node": "^24.3.0",
|
|
17
17
|
"@types/serve-handler": "^6.1.4",
|
|
18
18
|
"chai": "^5.2.1",
|
|
19
19
|
"esbuild": "^0.25.9",
|
|
@@ -38,9 +38,6 @@
|
|
|
38
38
|
"lib/",
|
|
39
39
|
"src/Client/"
|
|
40
40
|
],
|
|
41
|
-
"imports": {
|
|
42
|
-
"#Base/*.js": "./lib/*.js"
|
|
43
|
-
},
|
|
44
41
|
"keywords": [
|
|
45
42
|
"belin",
|
|
46
43
|
"core",
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Commonly used environment names.
|
|
3
|
+
*/
|
|
4
|
+
export const Environment = Object.freeze({
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Specifies the development environment.
|
|
8
|
+
*/
|
|
9
|
+
Development: "Development",
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Specifies the production environment.
|
|
13
|
+
*/
|
|
14
|
+
Production: "Production",
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Specifies the staging environment.
|
|
18
|
+
*/
|
|
19
|
+
Staging: "Staging"
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Commonly used environment names.
|
|
24
|
+
*/
|
|
25
|
+
export type Environment = typeof Environment[keyof typeof Environment];
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import {Environment} from "./Environment.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Provides information about the hosting environment an application is running in.
|
|
5
|
+
*/
|
|
6
|
+
export class HostEnvironment {
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* The name of the application.
|
|
10
|
+
*/
|
|
11
|
+
readonly applicationName: string;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* The path to the directory that contains the application content files.
|
|
15
|
+
*/
|
|
16
|
+
readonly contentRootPath: string;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* The name of the environment.
|
|
20
|
+
*/
|
|
21
|
+
readonly environmentName: string;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Creates a new host environment.
|
|
25
|
+
* @param options An object providing values to initialize this instance.
|
|
26
|
+
*/
|
|
27
|
+
constructor(options: HostEnvironmentOptions = {}) {
|
|
28
|
+
this.applicationName = options.applicationName ?? document.head.querySelector<HTMLMetaElement>('meta[name="application-name"]')?.content ?? location.hostname;
|
|
29
|
+
this.contentRootPath = options.contentRootPath ?? document.head.querySelector("base")?.getAttribute("href") ?? "/";
|
|
30
|
+
this.environmentName = options.environmentName ?? Environment.Production;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Checks if the current environment name is {@link Environment.Development}.
|
|
35
|
+
* @returns `true` if the environment name is {@link Environment.Development}, otherwise `false`.
|
|
36
|
+
*/
|
|
37
|
+
get isDevelopment(): boolean {
|
|
38
|
+
return this.isEnvironment(Environment.Development);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Checks if the current environment name is {@link Environment.Production}.
|
|
43
|
+
* @returns `true` if the environment name is {@link Environment.Production}, otherwise `false`.
|
|
44
|
+
*/
|
|
45
|
+
get isProduction(): boolean {
|
|
46
|
+
return this.isEnvironment(Environment.Production);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Checks if the current environment name is {@link Environment.Staging}.
|
|
51
|
+
* @returns `true` if the environment name is {@link Environment.Staging}, otherwise `false`.
|
|
52
|
+
*/
|
|
53
|
+
get isStaging(): boolean {
|
|
54
|
+
return this.isEnvironment(Environment.Staging);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Compares the current host environment name against the specified value.
|
|
59
|
+
* @param environmentName The environment name to validate against.
|
|
60
|
+
* @returns `true` if the specified name is the same as the current environment, otherwise `false`.
|
|
61
|
+
*/
|
|
62
|
+
isEnvironment(environmentName: string): boolean {
|
|
63
|
+
return this.environmentName == environmentName;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Defines the options of a {@link HostEnvironment} instance.
|
|
69
|
+
*/
|
|
70
|
+
export type HostEnvironmentOptions = Partial<{
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* The name of the application.
|
|
74
|
+
*/
|
|
75
|
+
applicationName: string;
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* The path to the directory that contains the application content files.
|
|
79
|
+
*/
|
|
80
|
+
contentRootPath: string;
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* The name of the environment.
|
|
84
|
+
*/
|
|
85
|
+
environmentName: string;
|
|
86
|
+
}>;
|
|
@@ -0,0 +1,13 @@
|
|
|
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/Hosting",
|
|
10
|
+
"rootDir": ".",
|
|
11
|
+
"tsBuildInfoFile": "../../../var/Hosting.tsbuildinfo"
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -15,13 +15,28 @@ export class LoadingIndicator extends HTMLElement {
|
|
|
15
15
|
customElements.define("loading-indicator", this);
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
+
/**
|
|
19
|
+
* Hides this component.
|
|
20
|
+
*/
|
|
21
|
+
hide(): void {
|
|
22
|
+
this.hidden = true;
|
|
23
|
+
document.body.classList.remove("loading");
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Shows this component.
|
|
28
|
+
*/
|
|
29
|
+
show(): void {
|
|
30
|
+
this.hidden = false;
|
|
31
|
+
document.body.classList.add("loading");
|
|
32
|
+
}
|
|
33
|
+
|
|
18
34
|
/**
|
|
19
35
|
* Starts the loading indicator.
|
|
20
36
|
*/
|
|
21
37
|
start(): void {
|
|
22
38
|
this.#requestCount++;
|
|
23
|
-
this.
|
|
24
|
-
document.body.classList.add("loading");
|
|
39
|
+
this.show();
|
|
25
40
|
}
|
|
26
41
|
|
|
27
42
|
/**
|
|
@@ -32,8 +47,7 @@ export class LoadingIndicator extends HTMLElement {
|
|
|
32
47
|
this.#requestCount--;
|
|
33
48
|
if (options.force || this.#requestCount <= 0) {
|
|
34
49
|
this.#requestCount = 0;
|
|
35
|
-
this.
|
|
36
|
-
document.body.classList.remove("loading");
|
|
50
|
+
this.hide();
|
|
37
51
|
}
|
|
38
52
|
}
|
|
39
53
|
}
|
|
@@ -8,7 +8,7 @@ export class OfflineIndicator extends HTMLElement {
|
|
|
8
8
|
*/
|
|
9
9
|
constructor() {
|
|
10
10
|
super();
|
|
11
|
-
this
|
|
11
|
+
this.#updateHiddenState();
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
/**
|
|
@@ -22,22 +22,35 @@ export class OfflineIndicator extends HTMLElement {
|
|
|
22
22
|
* Method invoked when this component is connected.
|
|
23
23
|
*/
|
|
24
24
|
connectedCallback(): void {
|
|
25
|
-
for (const event of ["online", "offline"]) addEventListener(event, this);
|
|
25
|
+
for (const event of ["online", "offline"]) addEventListener(event, this.#updateHiddenState);
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
29
|
* Method invoked when this component is disconnected.
|
|
30
30
|
*/
|
|
31
31
|
disconnectedCallback(): void {
|
|
32
|
-
for (const event of ["online", "offline"]) removeEventListener(event, this);
|
|
32
|
+
for (const event of ["online", "offline"]) removeEventListener(event, this.#updateHiddenState);
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
|
-
*
|
|
36
|
+
* Hides this component.
|
|
37
37
|
*/
|
|
38
|
-
|
|
39
|
-
this.hidden =
|
|
38
|
+
hide(): void {
|
|
39
|
+
this.hidden = true;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Shows this component.
|
|
44
|
+
*/
|
|
45
|
+
show(): void {
|
|
46
|
+
this.hidden = false;
|
|
40
47
|
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Updates the hidden state of this component according to the {@link navigator.onLine} property.
|
|
51
|
+
*/
|
|
52
|
+
readonly #updateHiddenState: () => void = () =>
|
|
53
|
+
this.hidden = navigator.onLine;
|
|
41
54
|
}
|
|
42
55
|
|
|
43
56
|
/**
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import {Tab} from "bootstrap";
|
|
2
|
+
import {StorageArea} from "../StorageArea.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* A component that activates a tab, based on its index saved in the web storage.
|
|
6
|
+
*/
|
|
7
|
+
export class TabActivator extends HTMLElement {
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Registers the component.
|
|
11
|
+
*/
|
|
12
|
+
static {
|
|
13
|
+
customElements.define("tab-activator", this);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* The one-based index of the active tab.
|
|
18
|
+
*/
|
|
19
|
+
get activeTabIndex(): number {
|
|
20
|
+
const index = Number.parseInt(this.storage.getItem(this.storageKey) ?? "1");
|
|
21
|
+
return Math.max(1, Math.min(this.tabs.length, Number.isNaN(index) ? 1 : index));
|
|
22
|
+
}
|
|
23
|
+
set activeTabIndex(value: number) {
|
|
24
|
+
this.storage.setItem(this.storageKey, value.toString());
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* The storage object corresponding to the current {@link storageArea}.
|
|
29
|
+
*/
|
|
30
|
+
get storage(): globalThis.Storage {
|
|
31
|
+
return this.storageArea == StorageArea.Local ? localStorage : sessionStorage;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* The storage area to use.
|
|
36
|
+
*/
|
|
37
|
+
get storageArea(): StorageArea {
|
|
38
|
+
const value = this.getAttribute("storagearea") as StorageArea;
|
|
39
|
+
return Object.values(StorageArea).includes(value) ? value : StorageArea.Session;
|
|
40
|
+
}
|
|
41
|
+
set storageArea(value: StorageArea) {
|
|
42
|
+
this.setAttribute("storagearea", value);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* The key of the storage entry providing the active tab index.
|
|
47
|
+
*/
|
|
48
|
+
get storageKey(): string {
|
|
49
|
+
const value = this.getAttribute("storagekey") ?? "";
|
|
50
|
+
return value.trim() || "ActiveTabIndex";
|
|
51
|
+
}
|
|
52
|
+
set storageKey(value: string) {
|
|
53
|
+
this.setAttribute("storagekey", value);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* The tab list.
|
|
58
|
+
*/
|
|
59
|
+
get tabs(): NodeListOf<HTMLButtonElement> {
|
|
60
|
+
return this.querySelectorAll(".nav-tabs button");
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Method invoked when this component is connected.
|
|
65
|
+
*/
|
|
66
|
+
connectedCallback(): void {
|
|
67
|
+
const {activeTabIndex, tabs} = this;
|
|
68
|
+
for (let index = 1; index <= tabs.length; index++) {
|
|
69
|
+
const tab = tabs.item(index - 1);
|
|
70
|
+
tab.addEventListener("click", () => this.activeTabIndex = index);
|
|
71
|
+
if (index == activeTabIndex) Tab.getOrCreateInstance(tab).show();
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Declaration merging.
|
|
78
|
+
*/
|
|
79
|
+
declare global {
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* The map of HTML tag names.
|
|
83
|
+
*/
|
|
84
|
+
interface HTMLElementTagNameMap {
|
|
85
|
+
"tab-activator": TabActivator;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
@@ -16,14 +16,6 @@ export class ThemeDropdown extends HTMLElement {
|
|
|
16
16
|
*/
|
|
17
17
|
readonly #mediaQuery = matchMedia("(prefers-color-scheme: dark)");
|
|
18
18
|
|
|
19
|
-
/**
|
|
20
|
-
* Creates a new theme dropdown.
|
|
21
|
-
*/
|
|
22
|
-
constructor() {
|
|
23
|
-
super();
|
|
24
|
-
for (const button of this.querySelectorAll("button")) button.addEventListener("click", this.#setTheme.bind(this));
|
|
25
|
-
}
|
|
26
|
-
|
|
27
19
|
/**
|
|
28
20
|
* Registers the component.
|
|
29
21
|
*/
|
|
@@ -110,7 +102,9 @@ export class ThemeDropdown extends HTMLElement {
|
|
|
110
102
|
* Method invoked when this component is connected.
|
|
111
103
|
*/
|
|
112
104
|
connectedCallback(): void {
|
|
113
|
-
this
|
|
105
|
+
for (const button of this.querySelectorAll("button")) button.addEventListener("click", this.#setTheme);
|
|
106
|
+
this.#mediaQuery.addEventListener("change", this.#applyTheme);
|
|
107
|
+
|
|
114
108
|
const appTheme = localStorage.getItem(this.storageKey) as AppTheme|null;
|
|
115
109
|
if (appTheme) this.setAttribute("apptheme", appTheme);
|
|
116
110
|
}
|
|
@@ -119,34 +113,28 @@ export class ThemeDropdown extends HTMLElement {
|
|
|
119
113
|
* Method invoked when this component is disconnected.
|
|
120
114
|
*/
|
|
121
115
|
disconnectedCallback(): void {
|
|
122
|
-
this
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* Handles the events.
|
|
127
|
-
*/
|
|
128
|
-
handleEvent(): void {
|
|
129
|
-
this.#applyTheme();
|
|
116
|
+
for (const button of this.querySelectorAll("button")) button.removeEventListener("click", this.#setTheme);
|
|
117
|
+
this.#mediaQuery.removeEventListener("change", this.#applyTheme);
|
|
130
118
|
}
|
|
131
119
|
|
|
132
120
|
/**
|
|
133
121
|
* Applies the application theme to the document.
|
|
134
122
|
*/
|
|
135
|
-
|
|
123
|
+
readonly #applyTheme: () => void = () => {
|
|
136
124
|
const {appTheme} = this;
|
|
137
125
|
const bsTheme = appTheme == AppTheme.System ? (this.#mediaQuery.matches ? AppTheme.Dark : AppTheme.Light) : appTheme;
|
|
138
126
|
document.documentElement.dataset.bsTheme = bsTheme.toLowerCase();
|
|
139
|
-
}
|
|
127
|
+
};
|
|
140
128
|
|
|
141
129
|
/**
|
|
142
130
|
* Changes the current application theme.
|
|
143
131
|
* @param event The dispatched event.
|
|
144
132
|
*/
|
|
145
|
-
#setTheme(event: Event)
|
|
133
|
+
readonly #setTheme: (event: Event) => void = event => {
|
|
146
134
|
event.preventDefault();
|
|
147
135
|
const button = (event.target as HTMLElement).closest("button")!;
|
|
148
136
|
this.appTheme = button.dataset.theme! as AppTheme;
|
|
149
|
-
}
|
|
137
|
+
};
|
|
150
138
|
}
|
|
151
139
|
|
|
152
140
|
/**
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The types of form controls that are not text inputs.
|
|
3
|
+
*/
|
|
4
|
+
const nonTextualTypes = new Set<string>(["button", "checkbox", "file", "hidden", "image", "password", "radio", "range", "reset", "submit"]);
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Represents a form control.
|
|
8
|
+
*/
|
|
9
|
+
export type FormControl = HTMLInputElement|HTMLSelectElement|HTMLTextAreaElement;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Gets all controls belonging to the specified form.
|
|
13
|
+
* @param form The form element.
|
|
14
|
+
* @returns The controls belonging to the specified form.
|
|
15
|
+
*/
|
|
16
|
+
export function getFormControls(form: HTMLFormElement): FormControl[] {
|
|
17
|
+
return Array.from(form.elements).filter(isFormControl);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Returns the first invalid control from the specified form.
|
|
22
|
+
* @param form The form element.
|
|
23
|
+
* @returns The first invalid control, or `null` if all controls are valid.
|
|
24
|
+
*/
|
|
25
|
+
export function invalidControl(form: HTMLFormElement): FormControl|null {
|
|
26
|
+
return form.querySelector(":not(fieldset):invalid");
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Returns a value indicating whether the specified element is a form control.
|
|
31
|
+
* @param element The element to check.
|
|
32
|
+
* @returns `true` if the specified element is a form control, otherwise `false`.
|
|
33
|
+
*/
|
|
34
|
+
export function isFormControl(element: Element): element is FormControl {
|
|
35
|
+
return element instanceof HTMLInputElement || element instanceof HTMLSelectElement || element instanceof HTMLTextAreaElement;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Resets the validity of the specified element.
|
|
40
|
+
* @param element The element to process.
|
|
41
|
+
*/
|
|
42
|
+
export function resetValidity(element: Element): void {
|
|
43
|
+
if (element instanceof HTMLFormElement) getFormControls(element).forEach(control => control.setCustomValidity(""));
|
|
44
|
+
else if (isFormControl(element)) element.setCustomValidity("");
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Removes whitespace from both ends of the value of the specified element.
|
|
49
|
+
* @param element The element to process.
|
|
50
|
+
*/
|
|
51
|
+
export function trimControl(element: Element): void {
|
|
52
|
+
if (element instanceof HTMLFormElement) getFormControls(element).forEach(trimControl);
|
|
53
|
+
else if (element instanceof HTMLInputElement && !nonTextualTypes.has(element.type)) element.value = element.value.trim();
|
|
54
|
+
else if (element instanceof HTMLTextAreaElement) element.value = element.value.trim();
|
|
55
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Identifies the web storage area.
|
|
3
|
+
*/
|
|
4
|
+
export const StorageArea = Object.freeze({
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Indicates the local storage.
|
|
8
|
+
*/
|
|
9
|
+
Local: "Local",
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Indicates the session storage.
|
|
13
|
+
*/
|
|
14
|
+
Session: "Session"
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Identifies the web storage area.
|
|
19
|
+
*/
|
|
20
|
+
export type StorageArea = typeof StorageArea[keyof typeof StorageArea];
|
package/src/Client/tsconfig.json
CHANGED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Performs HTTP requests.
|
|
3
|
-
*/
|
|
4
|
-
export declare class HttpClient {
|
|
5
|
-
#private;
|
|
6
|
-
/**
|
|
7
|
-
* The base URL of the remote service.
|
|
8
|
-
*/
|
|
9
|
-
readonly baseAddress: URL;
|
|
10
|
-
/**
|
|
11
|
-
* Creates a new HTTP client.
|
|
12
|
-
* @param options An object providing values to initialize this instance.
|
|
13
|
-
*/
|
|
14
|
-
constructor(options?: HttpClientOptions);
|
|
15
|
-
/**
|
|
16
|
-
* Performs a DELETE request.
|
|
17
|
-
* @param url The URL of the resource to fetch.
|
|
18
|
-
* @param options The request options.
|
|
19
|
-
* @returns The server response.
|
|
20
|
-
*/
|
|
21
|
-
delete(url?: string | URL, options?: RequestInit): Promise<Response>;
|
|
22
|
-
/**
|
|
23
|
-
* Performs a GET request.
|
|
24
|
-
* @param url The URL of the resource to fetch.
|
|
25
|
-
* @param options The request options.
|
|
26
|
-
* @returns The server response.
|
|
27
|
-
*/
|
|
28
|
-
get(url?: string | URL, options?: RequestInit): Promise<Response>;
|
|
29
|
-
/**
|
|
30
|
-
* Performs a PATCH request.
|
|
31
|
-
* @param url The URL of the resource to fetch.
|
|
32
|
-
* @param body The request body.
|
|
33
|
-
* @param options The request options.
|
|
34
|
-
* @returns The server response.
|
|
35
|
-
*/
|
|
36
|
-
patch(url?: string | URL, body?: unknown, options?: RequestInit): Promise<Response>;
|
|
37
|
-
/**
|
|
38
|
-
* Performs a POST request.
|
|
39
|
-
* @param url The URL of the resource to fetch.
|
|
40
|
-
* @param body The request body.
|
|
41
|
-
* @param options The request options.
|
|
42
|
-
* @returns The server response.
|
|
43
|
-
*/
|
|
44
|
-
post(url?: string | URL, body?: unknown, options?: RequestInit): Promise<Response>;
|
|
45
|
-
/**
|
|
46
|
-
* Performs a PUT request.
|
|
47
|
-
* @param url The URL of the resource to fetch.
|
|
48
|
-
* @param body The request body.
|
|
49
|
-
* @param options The request options.
|
|
50
|
-
* @returns The server response.
|
|
51
|
-
*/
|
|
52
|
-
put(url?: string | URL, body?: unknown, options?: RequestInit): Promise<Response>;
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Defines the options of a {@link HttpClient} instance.
|
|
56
|
-
*/
|
|
57
|
-
export type HttpClientOptions = Partial<{
|
|
58
|
-
/**
|
|
59
|
-
* The base URL of the remote service.
|
|
60
|
-
*/
|
|
61
|
-
baseUrl: string | URL;
|
|
62
|
-
/**
|
|
63
|
-
* The function returning the component used as loading indicator.
|
|
64
|
-
*/
|
|
65
|
-
loadingIndicator: () => ILoadingIndicator | null;
|
|
66
|
-
}>;
|
|
67
|
-
/**
|
|
68
|
-
* A component that shows up when an HTTP request starts, and hides when all concurrent HTTP requests are completed.
|
|
69
|
-
*/
|
|
70
|
-
export interface ILoadingIndicator {
|
|
71
|
-
/**
|
|
72
|
-
* Starts the loading indicator.
|
|
73
|
-
*/
|
|
74
|
-
start: () => void;
|
|
75
|
-
/**
|
|
76
|
-
* Stops the loading indicator.
|
|
77
|
-
* @param options Value indicating whether to force the loading indicator to stop.
|
|
78
|
-
*/
|
|
79
|
-
stop: (options?: {
|
|
80
|
-
force?: boolean;
|
|
81
|
-
}) => void;
|
|
82
|
-
}
|
|
83
|
-
//# sourceMappingURL=HttpClient.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"HttpClient.d.ts","sourceRoot":"","sources":["../../../src/Client/Net/Http/HttpClient.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,qBAAa,UAAU;;IAEtB;;OAEG;IACH,QAAQ,CAAC,WAAW,EAAE,GAAG,CAAC;IAO1B;;;OAGG;gBACS,OAAO,GAAE,iBAAsB;IAM3C;;;;;OAKG;IACH,MAAM,CAAC,GAAG,CAAC,EAAE,MAAM,GAAC,GAAG,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,QAAQ,CAAC;IAIlE;;;;;OAKG;IACH,GAAG,CAAC,GAAG,CAAC,EAAE,MAAM,GAAC,GAAG,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,QAAQ,CAAC;IAI/D;;;;;;OAMG;IACH,KAAK,CAAC,GAAG,CAAC,EAAE,MAAM,GAAC,GAAG,EAAE,IAAI,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,QAAQ,CAAC;IAIjF;;;;;;OAMG;IACH,IAAI,CAAC,GAAG,CAAC,EAAE,MAAM,GAAC,GAAG,EAAE,IAAI,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,QAAQ,CAAC;IAIhF;;;;;;OAMG;IACH,GAAG,CAAC,GAAG,CAAC,EAAE,MAAM,GAAC,GAAG,EAAE,IAAI,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,QAAQ,CAAC;CAiC/E;AAED;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG,OAAO,CAAC;IAEvC;;OAEG;IACH,OAAO,EAAE,MAAM,GAAC,GAAG,CAAC;IAEpB;;OAEG;IACH,gBAAgB,EAAE,MAAM,iBAAiB,GAAC,IAAI,CAAC;CAC/C,CAAC,CAAC;AAEH;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAEjC;;OAEG;IACH,KAAK,EAAE,MAAM,IAAI,CAAC;IAElB;;;OAGG;IACH,IAAI,EAAE,CAAC,OAAO,CAAC,EAAE;QAAC,KAAK,CAAC,EAAE,OAAO,CAAA;KAAC,KAAK,IAAI,CAAC;CAC5C"}
|