@cedx/base 0.5.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.
Files changed (131) hide show
  1. package/ReadMe.md +1 -1
  2. package/lib/Data/PaginatedList.d.ts +35 -0
  3. package/lib/Data/PaginatedList.d.ts.map +1 -0
  4. package/lib/Data/PaginatedList.js +28 -0
  5. package/lib/Data/Pagination.d.ts +74 -0
  6. package/lib/Data/Pagination.d.ts.map +1 -0
  7. package/lib/Data/Pagination.js +101 -0
  8. package/lib/Data/Sort.d.ts +25 -23
  9. package/lib/Data/Sort.d.ts.map +1 -1
  10. package/lib/Data/Sort.js +37 -33
  11. package/lib/{Date.d.ts → DateExtensions.d.ts} +1 -1
  12. package/lib/DateExtensions.d.ts.map +1 -0
  13. package/lib/{Html/File.d.ts → FileExtensions.d.ts} +4 -11
  14. package/lib/FileExtensions.d.ts.map +1 -0
  15. package/lib/{Html/File.js → FileExtensions.js} +3 -12
  16. package/lib/{Http → Net/Http}/HttpClient.d.ts +17 -2
  17. package/lib/Net/Http/HttpClient.d.ts.map +1 -0
  18. package/lib/{Http → Net/Http}/HttpClient.js +17 -15
  19. package/lib/Net/Http/HttpMethod.d.ts +46 -0
  20. package/lib/Net/Http/HttpMethod.d.ts.map +1 -0
  21. package/lib/Net/Http/HttpMethod.js +41 -0
  22. package/lib/Net/Http/HttpRequestError.d.ts +33 -0
  23. package/lib/Net/Http/HttpRequestError.d.ts.map +1 -0
  24. package/lib/{Http/HttpError.js → Net/Http/HttpRequestError.js} +16 -16
  25. package/lib/Net/Http/StatusCode.d.ts +122 -0
  26. package/lib/Net/Http/StatusCode.d.ts.map +1 -0
  27. package/lib/Net/Http/StatusCode.js +117 -0
  28. package/lib/Net/Mime/DispositionType.d.ts +18 -0
  29. package/lib/Net/Mime/DispositionType.d.ts.map +1 -0
  30. package/lib/Net/Mime/DispositionType.js +13 -0
  31. package/lib/Net/Mime/MediaType.d.ts +151 -0
  32. package/lib/Net/Mime/MediaType.d.ts.map +1 -0
  33. package/lib/Net/Mime/MediaType.js +150 -0
  34. package/lib/{Number.d.ts → NumberExtensions.d.ts} +1 -1
  35. package/lib/NumberExtensions.d.ts.map +1 -0
  36. package/lib/{String.d.ts → StringExtensions.d.ts} +1 -1
  37. package/lib/StringExtensions.d.ts.map +1 -0
  38. package/lib/{Html → UI}/AppTheme.d.ts +3 -3
  39. package/lib/UI/AppTheme.d.ts.map +1 -0
  40. package/lib/{Html → UI}/AppTheme.js +3 -3
  41. package/lib/UI/Components/ComponentBase.d.ts +24 -0
  42. package/lib/UI/Components/ComponentBase.d.ts.map +1 -0
  43. package/lib/UI/Components/ComponentBase.js +29 -0
  44. package/lib/UI/{LoadingIndicator.d.ts → Components/LoadingIndicator.d.ts} +1 -2
  45. package/lib/UI/Components/LoadingIndicator.d.ts.map +1 -0
  46. package/lib/UI/{MenuActivator.d.ts → Components/MenuActivator.d.ts} +1 -1
  47. package/lib/UI/Components/MenuActivator.d.ts.map +1 -0
  48. package/lib/UI/{MenuActivator.js → Components/MenuActivator.js} +1 -1
  49. package/lib/UI/Components/OfflineIndicator.d.ts.map +1 -0
  50. package/lib/UI/Components/ThemeDropdown.d.ts +67 -0
  51. package/lib/UI/Components/ThemeDropdown.d.ts.map +1 -0
  52. package/lib/UI/Components/ThemeDropdown.js +140 -0
  53. package/lib/UI/Context.d.ts.map +1 -0
  54. package/lib/UI/MenuAlignment.d.ts +18 -0
  55. package/lib/UI/MenuAlignment.d.ts.map +1 -0
  56. package/lib/UI/MenuAlignment.js +13 -0
  57. package/lib/{Html → UI}/ViewportScroller.d.ts +1 -1
  58. package/lib/UI/ViewportScroller.d.ts.map +1 -0
  59. package/lib/{Html → UI}/ViewportScroller.js +6 -6
  60. package/package.json +7 -8
  61. package/src/Client/Data/PaginatedList.ts +47 -0
  62. package/src/Client/Data/Pagination.ts +136 -0
  63. package/src/Client/Data/Sort.ts +40 -35
  64. package/src/Client/Data/tsconfig.json +1 -1
  65. package/src/Client/{Html/File.ts → FileExtensions.ts} +3 -13
  66. package/src/Client/{Http → Net/Http}/HttpClient.ts +32 -14
  67. package/src/Client/Net/Http/HttpMethod.ts +55 -0
  68. package/src/Client/{Http/HttpError.ts → Net/Http/HttpRequestError.ts} +17 -17
  69. package/src/Client/Net/Http/StatusCode.ts +150 -0
  70. package/src/Client/Net/Mime/DispositionType.ts +20 -0
  71. package/src/Client/Net/Mime/MediaType.ts +185 -0
  72. package/src/Client/{Abstractions → Net}/tsconfig.json +3 -3
  73. package/src/Client/{Html → UI}/AppTheme.ts +3 -3
  74. package/src/Client/UI/Components/ComponentBase.ts +34 -0
  75. package/src/Client/UI/{LoadingIndicator.ts → Components/LoadingIndicator.ts} +1 -3
  76. package/src/Client/UI/{MenuActivator.ts → Components/MenuActivator.ts} +1 -1
  77. package/src/Client/UI/Components/ThemeDropdown.ts +163 -0
  78. package/src/Client/UI/MenuAlignment.ts +20 -0
  79. package/src/Client/{Html → UI}/ViewportScroller.ts +6 -6
  80. package/src/Client/UI/tsconfig.json +2 -3
  81. package/src/Client/tsconfig.json +1 -4
  82. package/lib/Abstractions/ILoadingIndicator.d.ts +0 -17
  83. package/lib/Abstractions/ILoadingIndicator.d.ts.map +0 -1
  84. package/lib/Abstractions/ILoadingIndicator.js +0 -1
  85. package/lib/Date.d.ts.map +0 -1
  86. package/lib/DependencyInjection/Container.d.ts +0 -43
  87. package/lib/DependencyInjection/Container.d.ts.map +0 -1
  88. package/lib/DependencyInjection/Container.js +0 -65
  89. package/lib/Html/AppTheme.d.ts.map +0 -1
  90. package/lib/Html/Context.d.ts.map +0 -1
  91. package/lib/Html/File.d.ts.map +0 -1
  92. package/lib/Html/ViewportScroller.d.ts.map +0 -1
  93. package/lib/Http/HttpClient.d.ts.map +0 -1
  94. package/lib/Http/HttpError.d.ts +0 -33
  95. package/lib/Http/HttpError.d.ts.map +0 -1
  96. package/lib/Http/StatusCodes.d.ts +0 -114
  97. package/lib/Http/StatusCodes.d.ts.map +0 -1
  98. package/lib/Http/StatusCodes.js +0 -109
  99. package/lib/Number.d.ts.map +0 -1
  100. package/lib/String.d.ts.map +0 -1
  101. package/lib/UI/ActionBar.d.ts +0 -25
  102. package/lib/UI/ActionBar.d.ts.map +0 -1
  103. package/lib/UI/ActionBar.js +0 -25
  104. package/lib/UI/LoadingIndicator.d.ts.map +0 -1
  105. package/lib/UI/MenuActivator.d.ts.map +0 -1
  106. package/lib/UI/OfflineIndicator.d.ts.map +0 -1
  107. package/lib/UI/ThemeDropdown.d.ts +0 -34
  108. package/lib/UI/ThemeDropdown.d.ts.map +0 -1
  109. package/lib/UI/ThemeDropdown.js +0 -71
  110. package/src/Client/Abstractions/ILoadingIndicator.ts +0 -16
  111. package/src/Client/Data/Pagination.new +0 -130
  112. package/src/Client/DependencyInjection/Container.ts +0 -75
  113. package/src/Client/DependencyInjection/tsconfig.json +0 -13
  114. package/src/Client/Html/tsconfig.json +0 -16
  115. package/src/Client/Http/StatusCodes.ts +0 -140
  116. package/src/Client/Http/tsconfig.json +0 -16
  117. package/src/Client/UI/ActionBar.ts +0 -41
  118. package/src/Client/UI/ThemeDropdown.ts +0 -94
  119. /package/lib/{Date.js → DateExtensions.js} +0 -0
  120. /package/lib/{Number.js → NumberExtensions.js} +0 -0
  121. /package/lib/{String.js → StringExtensions.js} +0 -0
  122. /package/lib/UI/{LoadingIndicator.js → Components/LoadingIndicator.js} +0 -0
  123. /package/lib/UI/{OfflineIndicator.d.ts → Components/OfflineIndicator.d.ts} +0 -0
  124. /package/lib/UI/{OfflineIndicator.js → Components/OfflineIndicator.js} +0 -0
  125. /package/lib/{Html → UI}/Context.d.ts +0 -0
  126. /package/lib/{Html → UI}/Context.js +0 -0
  127. /package/src/Client/{Date.ts → DateExtensions.ts} +0 -0
  128. /package/src/Client/{Number.ts → NumberExtensions.ts} +0 -0
  129. /package/src/Client/{String.ts → StringExtensions.ts} +0 -0
  130. /package/src/Client/UI/{OfflineIndicator.ts → Components/OfflineIndicator.ts} +0 -0
  131. /package/src/Client/{Html → UI}/Context.ts +0 -0
@@ -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,25 +0,0 @@
1
- /**
2
- * An action bar located under the navigation bar.
3
- */
4
- export declare class ActionBar extends HTMLElement {
5
- /**
6
- * Method invoked when this component is connected.
7
- */
8
- connectedCallback(): void;
9
- /**
10
- * Method invoked when this component is disconnected.
11
- */
12
- disconnectedCallback(): void;
13
- }
14
- /**
15
- * Declaration merging.
16
- */
17
- declare global {
18
- /**
19
- * The map of HTML tag names.
20
- */
21
- interface HTMLElementTagNameMap {
22
- "action-bar": ActionBar;
23
- }
24
- }
25
- //# sourceMappingURL=ActionBar.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ActionBar.d.ts","sourceRoot":"","sources":["../../src/Client/UI/ActionBar.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,SAAU,SAAQ,WAAW;IASzC;;OAEG;IACH,iBAAiB,IAAI,IAAI;IAMzB;;OAEG;IACH,oBAAoB,IAAI,IAAI;CAG5B;AAED;;GAEG;AACH,OAAO,CAAC,MAAM,CAAC;IAEd;;OAEG;IACH,UAAU,qBAAqB;QAC9B,YAAY,EAAE,SAAS,CAAC;KACxB;CACD"}
@@ -1,25 +0,0 @@
1
- /**
2
- * An action bar located under the navigation bar.
3
- */
4
- export class ActionBar extends HTMLElement {
5
- /**
6
- * Registers the component.
7
- */
8
- static {
9
- customElements.define("action-bar", this);
10
- }
11
- /**
12
- * Method invoked when this component is connected.
13
- */
14
- connectedCallback() {
15
- const navbarHeight = parseInt(getComputedStyle(document.documentElement).getPropertyValue("--navbar-height"));
16
- const mainOffset = this.offsetHeight + (Number.isNaN(navbarHeight) ? 0 : navbarHeight);
17
- document.documentElement.style.setProperty("--main-offset", `${mainOffset}px`);
18
- }
19
- /**
20
- * Method invoked when this component is disconnected.
21
- */
22
- disconnectedCallback() {
23
- document.documentElement.style.removeProperty("--main-offset");
24
- }
25
- }
@@ -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,34 +0,0 @@
1
- /**
2
- * A dropdown menu for switching the application theme.
3
- */
4
- export declare class ThemeDropdown extends HTMLElement {
5
- #private;
6
- /**
7
- * Creates a new theme dropdown.
8
- */
9
- constructor();
10
- /**
11
- * Method invoked when this component is connected.
12
- */
13
- connectedCallback(): void;
14
- /**
15
- * Method invoked when this component is disconnected.
16
- */
17
- disconnectedCallback(): void;
18
- /**
19
- * Handles the events.
20
- */
21
- handleEvent(): void;
22
- }
23
- /**
24
- * Declaration merging.
25
- */
26
- declare global {
27
- /**
28
- * The map of HTML tag names.
29
- */
30
- interface HTMLElementTagNameMap {
31
- "theme-dropdown": ThemeDropdown;
32
- }
33
- }
34
- //# sourceMappingURL=ThemeDropdown.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ThemeDropdown.d.ts","sourceRoot":"","sources":["../../src/Client/UI/ThemeDropdown.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,qBAAa,aAAc,SAAQ,WAAW;;IAiB7C;;OAEG;;IAeH;;OAEG;IACH,iBAAiB,IAAI,IAAI;IAKzB;;OAEG;IACH,oBAAoB,IAAI,IAAI;IAI5B;;OAEG;IACH,WAAW,IAAI,IAAI;CAuBnB;AAED;;GAEG;AACH,OAAO,CAAC,MAAM,CAAC;IAEd;;OAEG;IACH,UAAU,qBAAqB;QAC9B,gBAAgB,EAAE,aAAa,CAAC;KAChC;CACD"}
@@ -1,71 +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
- * Method invoked when this component is connected.
36
- */
37
- connectedCallback() {
38
- this.#mediaQuery.addEventListener("change", this);
39
- this.#applyTheme();
40
- }
41
- /**
42
- * Method invoked when this component is disconnected.
43
- */
44
- disconnectedCallback() {
45
- this.#mediaQuery.removeEventListener("change", this);
46
- }
47
- /**
48
- * Handles the events.
49
- */
50
- handleEvent() {
51
- this.#applyTheme();
52
- }
53
- /**
54
- * Applies the theme to the document.
55
- */
56
- #applyTheme() {
57
- const theme = this.#theme == AppTheme.System ? (this.#mediaQuery.matches ? AppTheme.Dark : AppTheme.Light) : this.#theme;
58
- document.documentElement.dataset.bsTheme = theme.toLowerCase();
59
- this.querySelector(".dropdown-toggle > .icon").textContent = getIcon(this.#theme);
60
- this.querySelector(`button[data-theme="${this.#theme}"]`).appendChild(this.querySelector(".dropdown-item > .icon"));
61
- }
62
- /**
63
- * Changes the current theme.
64
- * @param event The dispatched event.
65
- */
66
- #setTheme(event) {
67
- const button = event.target.closest("button");
68
- localStorage.setItem(this.#storageKey, this.#theme = button.dataset.theme);
69
- this.#applyTheme();
70
- }
71
- }
@@ -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,130 +0,0 @@
1
- /**
2
- * Represents information relevant to the pagination of data items.
3
- */
4
- export class Pagination {
5
-
6
- /**
7
- * The current page number.
8
- */
9
- currentPage: number;
10
-
11
- /**
12
- * The number of items per page.
13
- */
14
- itemsPerPage: number;
15
-
16
- /**
17
- * The total number of items.
18
- */
19
- totalItemCount: number;
20
-
21
- /**
22
- * Creates a new pagination.
23
- * @param options An object providing values to initialize this instance.
24
- */
25
- constructor(options: PaginationOptions = {}) {
26
- this.currentPage = Math.max(1, options.currentPage ?? 1);
27
- this.itemsPerPage = Math.max(1, Math.min(1000, options.itemsPerPage ?? 25));
28
- this.totalItemCount = Math.max(0, options.totalItemCount ?? 0);
29
- }
30
-
31
- /**
32
- * The last page number.
33
- */
34
- get lastPage(): number {
35
- return Math.ceil(this.totalItemCount / this.itemsPerPage);
36
- }
37
-
38
- /**
39
- * The data limit.
40
- */
41
- get limit(): number {
42
- return this.itemsPerPage;
43
- }
44
-
45
- /**
46
- * The data offset.
47
- */
48
- get offset(): number {
49
- return (this.currentPage - 1) * this.itemsPerPage;
50
- }
51
-
52
- /**
53
- * The search parameters corresponding to this object.
54
- */
55
- get searchParams(): URLSearchParams {
56
- return new URLSearchParams({page: this.currentPage.toString(), perPage: this.itemsPerPage.toString()});
57
- }
58
-
59
- /**
60
- * Creates a new pagination from the HTTP headers of the specified response.
61
- * @param response A server response.
62
- * @returns The pagination corresponding to the HTTP headers of the specified response.
63
- */
64
- static fromResponse(response: Response): Pagination {
65
- return new this({
66
- currentPage: Number(response.headers.get("X-Pagination-Current-Page") ?? "1"),
67
- itemsPerPage: Number(response.headers.get("X-Pagination-Per-Page") ?? "25"),
68
- totalItemCount: Number(response.headers.get("X-Pagination-Total-Count") ?? "0")
69
- });
70
- }
71
- }
72
-
73
- /**
74
- * Defines the options of a {@link Pagination} instance.
75
- */
76
- export type PaginationOptions = Partial<Pick<Pagination, "currentPage"|"itemsPerPage"|"totalItemCount">>;
77
-
78
- /**
79
- * A list with information relevant to the pagination of its items.
80
- */
81
- export class PaginatedList<T> implements Iterable<T, void, void> {
82
-
83
- /**
84
- * The list items.
85
- */
86
- items: T[];
87
-
88
- /**
89
- * The information relevant to the pagination of the list items.
90
- */
91
- pagination: Pagination;
92
-
93
- /**
94
- * Creates a new paginated list.
95
- * @param options An object providing values to initialize this instance.
96
- */
97
- constructor(options: PaginatedListOptions<T> = {}) {
98
- this.items = options.items ?? [];
99
- this.pagination = options.pagination ?? new Pagination;
100
- }
101
-
102
- /**
103
- * The number of items in this list.
104
- */
105
- get length(): number {
106
- return this.items.length;
107
- }
108
-
109
- /**
110
- * Creates an empty paginated list.
111
- * @param itemsPerPage The number of items per page.
112
- * @returns An empty paginated list with the specified number of items per page.
113
- */
114
- static empty<T>(itemsPerPage: number): PaginatedList<T> {
115
- return new this({pagination: new Pagination({itemsPerPage})});
116
- }
117
-
118
- /**
119
- * Returns a new iterator that allows iterating the items of this list.
120
- * @returns An iterator over the items of this list.
121
- */
122
- *[Symbol.iterator](): Generator<T, void, void> {
123
- for (const item of this.items) yield item;
124
- }
125
- }
126
-
127
- /**
128
- * Defines the options of a {@link PaginatedList} instance.
129
- */
130
- export type PaginatedListOptions<T> = Partial<Pick<PaginatedList<T>, "items"|"pagination">>;
@@ -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,41 +0,0 @@
1
- /**
2
- * An action bar located under the navigation bar.
3
- */
4
- export class ActionBar extends HTMLElement {
5
-
6
- /**
7
- * Registers the component.
8
- */
9
- static {
10
- customElements.define("action-bar", this);
11
- }
12
-
13
- /**
14
- * Method invoked when this component is connected.
15
- */
16
- connectedCallback(): void {
17
- const navbarHeight = parseInt(getComputedStyle(document.documentElement).getPropertyValue("--navbar-height"));
18
- const mainOffset = this.offsetHeight + (Number.isNaN(navbarHeight) ? 0 : navbarHeight);
19
- document.documentElement.style.setProperty("--main-offset", `${mainOffset}px`);
20
- }
21
-
22
- /**
23
- * Method invoked when this component is disconnected.
24
- */
25
- disconnectedCallback(): void {
26
- document.documentElement.style.removeProperty("--main-offset");
27
- }
28
- }
29
-
30
- /**
31
- * Declaration merging.
32
- */
33
- declare global {
34
-
35
- /**
36
- * The map of HTML tag names.
37
- */
38
- interface HTMLElementTagNameMap {
39
- "action-bar": ActionBar;
40
- }
41
- }