@cedx/ui 0.1.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 (108) hide show
  1. package/License.md +20 -0
  2. package/ReadMe.md +17 -0
  3. package/lib/Alignment.d.ts +22 -0
  4. package/lib/Alignment.d.ts.map +1 -0
  5. package/lib/Alignment.js +17 -0
  6. package/lib/AppTheme.d.ts +34 -0
  7. package/lib/AppTheme.d.ts.map +1 -0
  8. package/lib/AppTheme.js +41 -0
  9. package/lib/Components/BackButton.d.ts +27 -0
  10. package/lib/Components/BackButton.d.ts.map +1 -0
  11. package/lib/Components/BackButton.js +29 -0
  12. package/lib/Components/DialogBox.d.ts +151 -0
  13. package/lib/Components/DialogBox.d.ts.map +1 -0
  14. package/lib/Components/DialogBox.js +268 -0
  15. package/lib/Components/FullScreenToggler.d.ts +42 -0
  16. package/lib/Components/FullScreenToggler.d.ts.map +1 -0
  17. package/lib/Components/FullScreenToggler.js +103 -0
  18. package/lib/Components/KeyboardAccelerator.d.ts +36 -0
  19. package/lib/Components/KeyboardAccelerator.d.ts.map +1 -0
  20. package/lib/Components/KeyboardAccelerator.js +78 -0
  21. package/lib/Components/LoadingIndicator.d.ts +58 -0
  22. package/lib/Components/LoadingIndicator.d.ts.map +1 -0
  23. package/lib/Components/LoadingIndicator.js +93 -0
  24. package/lib/Components/MenuActivator.d.ts +26 -0
  25. package/lib/Components/MenuActivator.d.ts.map +1 -0
  26. package/lib/Components/MenuActivator.js +42 -0
  27. package/lib/Components/OfflineIndicator.d.ts +59 -0
  28. package/lib/Components/OfflineIndicator.d.ts.map +1 -0
  29. package/lib/Components/OfflineIndicator.js +106 -0
  30. package/lib/Components/TabActivator.d.ts +49 -0
  31. package/lib/Components/TabActivator.d.ts.map +1 -0
  32. package/lib/Components/TabActivator.js +70 -0
  33. package/lib/Components/ThemeDropdown.d.ts +86 -0
  34. package/lib/Components/ThemeDropdown.d.ts.map +1 -0
  35. package/lib/Components/ThemeDropdown.js +207 -0
  36. package/lib/Components/Toast.d.ts +94 -0
  37. package/lib/Components/Toast.d.ts.map +1 -0
  38. package/lib/Components/Toast.js +284 -0
  39. package/lib/Components/Toaster.d.ts +119 -0
  40. package/lib/Components/Toaster.d.ts.map +1 -0
  41. package/lib/Components/Toaster.js +153 -0
  42. package/lib/Components/TypeAhead.d.ts +53 -0
  43. package/lib/Components/TypeAhead.d.ts.map +1 -0
  44. package/lib/Components/TypeAhead.js +138 -0
  45. package/lib/Context.d.ts +38 -0
  46. package/lib/Context.d.ts.map +1 -0
  47. package/lib/Context.js +42 -0
  48. package/lib/DialogResult.d.ts +30 -0
  49. package/lib/DialogResult.d.ts.map +1 -0
  50. package/lib/DialogResult.js +29 -0
  51. package/lib/File.d.ts +25 -0
  52. package/lib/File.d.ts.map +1 -0
  53. package/lib/File.js +66 -0
  54. package/lib/Form.d.ts +33 -0
  55. package/lib/Form.d.ts.map +1 -0
  56. package/lib/Form.js +50 -0
  57. package/lib/Htmx.d.ts +12 -0
  58. package/lib/Htmx.d.ts.map +1 -0
  59. package/lib/Htmx.js +2 -0
  60. package/lib/KeyboardModifiers.d.ts +26 -0
  61. package/lib/KeyboardModifiers.d.ts.map +1 -0
  62. package/lib/KeyboardModifiers.js +25 -0
  63. package/lib/Position.d.ts +52 -0
  64. package/lib/Position.d.ts.map +1 -0
  65. package/lib/Position.js +59 -0
  66. package/lib/Size.d.ts +40 -0
  67. package/lib/Size.d.ts.map +1 -0
  68. package/lib/Size.js +44 -0
  69. package/lib/StorageArea.d.ts +18 -0
  70. package/lib/StorageArea.d.ts.map +1 -0
  71. package/lib/StorageArea.js +13 -0
  72. package/lib/Tags.d.ts +15 -0
  73. package/lib/Tags.d.ts.map +1 -0
  74. package/lib/Tags.js +48 -0
  75. package/lib/Variant.d.ts +36 -0
  76. package/lib/Variant.d.ts.map +1 -0
  77. package/lib/Variant.js +31 -0
  78. package/lib/ViewportScroller.d.ts +49 -0
  79. package/lib/ViewportScroller.d.ts.map +1 -0
  80. package/lib/ViewportScroller.js +69 -0
  81. package/package.json +58 -0
  82. package/src/Client/Alignment.ts +25 -0
  83. package/src/Client/AppTheme.ts +51 -0
  84. package/src/Client/Components/BackButton.ts +45 -0
  85. package/src/Client/Components/DialogBox.ts +344 -0
  86. package/src/Client/Components/FullScreenToggler.ts +122 -0
  87. package/src/Client/Components/KeyboardAccelerator.ts +97 -0
  88. package/src/Client/Components/LoadingIndicator.ts +113 -0
  89. package/src/Client/Components/MenuActivator.ts +58 -0
  90. package/src/Client/Components/OfflineIndicator.ts +125 -0
  91. package/src/Client/Components/TabActivator.ts +93 -0
  92. package/src/Client/Components/ThemeDropdown.ts +235 -0
  93. package/src/Client/Components/Toast.ts +319 -0
  94. package/src/Client/Components/Toaster.ts +224 -0
  95. package/src/Client/Components/TypeAhead.ts +153 -0
  96. package/src/Client/Context.ts +53 -0
  97. package/src/Client/DialogResult.ts +35 -0
  98. package/src/Client/File.ts +73 -0
  99. package/src/Client/Form.ts +55 -0
  100. package/src/Client/Htmx.ts +13 -0
  101. package/src/Client/KeyboardModifiers.ts +30 -0
  102. package/src/Client/Position.ts +74 -0
  103. package/src/Client/Size.ts +56 -0
  104. package/src/Client/StorageArea.ts +20 -0
  105. package/src/Client/Tags.ts +58 -0
  106. package/src/Client/Variant.ts +42 -0
  107. package/src/Client/ViewportScroller.ts +89 -0
  108. package/src/Client/tsconfig.json +19 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FullScreenToggler.d.ts","sourceRoot":"","sources":["../../src/Client/Components/FullScreenToggler.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,iBAAkB,SAAQ,WAAW;;IAwBjD;;OAEG;IACH,IAAI,MAAM,IAAI,MAAM,CAGnB;IACD,IAAI,MAAM,CAAC,KAAK,EAAE,MAAM,EAEvB;IAED;;OAEG;IACH,IAAI,QAAQ,IAAI,OAAO,CAEtB;IACD,IAAI,QAAQ,CAAC,KAAK,EAAE,OAAO,EAE1B;IAED;;OAEG;IACH,iBAAiB,IAAI,IAAI;IAOzB;;OAEG;IACH,oBAAoB,IAAI,IAAI;IAI5B;;;;OAIG;IACG,gBAAgB,CAAC,KAAK,CAAC,EAAE,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC;CAsCpD;AAED;;GAEG;AACH,OAAO,CAAC,MAAM,CAAC;IAEd;;OAEG;IACH,UAAU,qBAAqB;QAC9B,oBAAoB,EAAE,iBAAiB,CAAC;KACxC;CACD"}
@@ -0,0 +1,103 @@
1
+ /**
2
+ * A component for toggling an element to full-screen.
3
+ */
4
+ export class FullScreenToggler extends HTMLElement {
5
+ /**
6
+ * The abort controller used to remove the event listeners.
7
+ */
8
+ #abortController = null;
9
+ /**
10
+ * The target element.
11
+ */
12
+ #element = document.body;
13
+ /**
14
+ * The handle to the underlying platform wake lock.
15
+ */
16
+ #sentinel = null;
17
+ /**
18
+ * Registers the component.
19
+ */
20
+ static {
21
+ customElements.define("fullscreen-toggler", this);
22
+ }
23
+ /**
24
+ * The CSS selector specifying the target element.
25
+ */
26
+ get target() {
27
+ const value = this.getAttribute("target") ?? "";
28
+ return value.trim() || "body";
29
+ }
30
+ set target(value) {
31
+ this.setAttribute("target", value);
32
+ }
33
+ /**
34
+ * Value indicating whether to prevent the device screen from dimming or locking when in full-screen mode.
35
+ */
36
+ get wakeLock() {
37
+ return this.hasAttribute("wakeLock");
38
+ }
39
+ set wakeLock(value) {
40
+ this.toggleAttribute("wakeLock", value);
41
+ }
42
+ /**
43
+ * Method invoked when this component is connected.
44
+ */
45
+ connectedCallback() {
46
+ this.#abortController = new AbortController;
47
+ document.addEventListener("visibilitychange", () => this.#onVisibilityChanged(), { signal: this.#abortController.signal });
48
+ this.#element = document.querySelector(this.target) ?? document.body;
49
+ this.#element.addEventListener("fullscreenchange", () => this.#onFullScreenChanged(), { signal: this.#abortController.signal });
50
+ }
51
+ /**
52
+ * Method invoked when this component is disconnected.
53
+ */
54
+ disconnectedCallback() {
55
+ this.#abortController?.abort();
56
+ }
57
+ /**
58
+ * Toggles the full-screen mode of the associated element.
59
+ * @param event The dispatched event.
60
+ * @returns Completes when the full-screen mode has been toggled.
61
+ */
62
+ async toggleFullScreen(event) {
63
+ event?.preventDefault();
64
+ if (document.fullscreenElement)
65
+ await document.exitFullscreen();
66
+ else
67
+ await this.#element.requestFullscreen();
68
+ }
69
+ /**
70
+ * Acquires a new wake lock.
71
+ * @returns Completes when the wake lock has been acquired.
72
+ */
73
+ async #acquireWakeLock() {
74
+ if (this.wakeLock && (!this.#sentinel || this.#sentinel.released))
75
+ this.#sentinel = await navigator.wakeLock.request();
76
+ }
77
+ /**
78
+ * Acquires or releases the wake lock when the document enters or exits the full-screen mode.
79
+ * @param event The dispatched event.
80
+ */
81
+ #onFullScreenChanged() {
82
+ if (document.fullscreenElement)
83
+ void this.#acquireWakeLock();
84
+ else
85
+ void this.#releaseWakeLock();
86
+ }
87
+ /**
88
+ * Eventually acquires a new wake lock when the document visibility has changed.
89
+ * @param event The dispatched event.
90
+ */
91
+ #onVisibilityChanged() {
92
+ if (document.fullscreenElement && !document.hidden)
93
+ void this.#acquireWakeLock();
94
+ }
95
+ /**
96
+ * Releases the acquired wake lock.
97
+ * @returns Completes when the wake lock has been released.
98
+ */
99
+ async #releaseWakeLock() {
100
+ if (this.#sentinel && !this.#sentinel.released)
101
+ await this.#sentinel.release();
102
+ }
103
+ }
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Associates a shortcut key with its child content.
3
+ */
4
+ export declare class KeyboardAccelerator extends HTMLElement {
5
+ #private;
6
+ /**
7
+ * Identifies the key for the keyboard accelerator.
8
+ */
9
+ get key(): string;
10
+ set key(value: string);
11
+ /**
12
+ * Identifies the modifiers for the keyboard accelerator.
13
+ */
14
+ get modifiers(): number;
15
+ set modifiers(value: number);
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
+ /**
26
+ * Declaration merging.
27
+ */
28
+ declare global {
29
+ /**
30
+ * The map of HTML tag names.
31
+ */
32
+ interface HTMLElementTagNameMap {
33
+ "keyboard-accelerator": KeyboardAccelerator;
34
+ }
35
+ }
36
+ //# sourceMappingURL=KeyboardAccelerator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"KeyboardAccelerator.d.ts","sourceRoot":"","sources":["../../src/Client/Components/KeyboardAccelerator.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,WAAW;;IAmBnD;;OAEG;IACH,IAAI,GAAG,IAAI,MAAM,CAEhB;IACD,IAAI,GAAG,CAAC,KAAK,EAAE,MAAM,EAEpB;IAED;;OAEG;IACH,IAAI,SAAS,IAAI,MAAM,CAItB;IACD,IAAI,SAAS,CAAC,KAAK,EAAE,MAAM,EAK1B;IAED;;OAEG;IACH,iBAAiB,IAAI,IAAI;IAKzB;;OAEG;IACH,oBAAoB,IAAI,IAAI;CAuB5B;AAED;;GAEG;AACH,OAAO,CAAC,MAAM,CAAC;IAEd;;OAEG;IACH,UAAU,qBAAqB;QAC9B,sBAAsB,EAAE,mBAAmB,CAAC;KAC5C;CACD"}
@@ -0,0 +1,78 @@
1
+ import { KeyboardModifiers } from "../KeyboardModifiers.js";
2
+ /**
3
+ * Associates a shortcut key with its child content.
4
+ */
5
+ export class KeyboardAccelerator extends HTMLElement {
6
+ /**
7
+ * The mapping between the modifier names and their values.
8
+ */
9
+ static #modifiers = new Map(Object.entries(KeyboardModifiers).filter(([key]) => key != "None"));
10
+ /**
11
+ * The abort controller used to remove the event listeners.
12
+ */
13
+ #abortController = null;
14
+ /**
15
+ * Registers the component.
16
+ */
17
+ static {
18
+ customElements.define("keyboard-accelerator", this);
19
+ }
20
+ /**
21
+ * Identifies the key for the keyboard accelerator.
22
+ */
23
+ get key() {
24
+ return (this.getAttribute("key") ?? "").trim();
25
+ }
26
+ set key(value) {
27
+ this.setAttribute("key", value);
28
+ }
29
+ /**
30
+ * Identifies the modifiers for the keyboard accelerator.
31
+ */
32
+ get modifiers() {
33
+ return (this.getAttribute("modifiers") ?? "").split(",")
34
+ .map(value => value.trim())
35
+ .reduce((modifiers, value) => modifiers | (KeyboardAccelerator.#modifiers.get(value) ?? 0), KeyboardModifiers.None);
36
+ }
37
+ set modifiers(value) {
38
+ this.setAttribute("modifiers", !value ? "None" : KeyboardAccelerator.#modifiers.entries()
39
+ .filter(([, flag]) => (value & flag) != 0)
40
+ .map(([key]) => key)
41
+ .toArray().join(", "));
42
+ }
43
+ /**
44
+ * Method invoked when this component is connected.
45
+ */
46
+ connectedCallback() {
47
+ this.#abortController = new AbortController;
48
+ addEventListener("keyup", event => this.#activateChildContent(event), { signal: this.#abortController.signal });
49
+ }
50
+ /**
51
+ * Method invoked when this component is disconnected.
52
+ */
53
+ disconnectedCallback() {
54
+ this.#abortController?.abort();
55
+ }
56
+ /**
57
+ * Activates the child content when the specified keyboard event designates the same key and modifiers as this keyboard accelerator.
58
+ * @param event The dispatched event.
59
+ */
60
+ #activateChildContent(event) {
61
+ if (event.key != this.key)
62
+ return;
63
+ const { activeElement } = document;
64
+ if (activeElement instanceof HTMLInputElement || activeElement instanceof HTMLTextAreaElement)
65
+ return;
66
+ const { modifiers } = this;
67
+ if (!(modifiers & KeyboardModifiers.Ctrl) && event.ctrlKey)
68
+ return;
69
+ if (!(modifiers & KeyboardModifiers.Shift) && event.shiftKey)
70
+ return;
71
+ if (!(modifiers & KeyboardModifiers.Alt) && event.altKey)
72
+ return;
73
+ if (!(modifiers & KeyboardModifiers.Meta) && event.metaKey)
74
+ return;
75
+ event.preventDefault();
76
+ this.firstElementChild?.click();
77
+ }
78
+ }
@@ -0,0 +1,58 @@
1
+ /**
2
+ * A component that shows up when an HTTP request starts, and hides when all concurrent HTTP requests are completed.
3
+ */
4
+ export declare class LoadingIndicator extends HTMLElement {
5
+ #private;
6
+ /**
7
+ * The list of observed attributes.
8
+ */
9
+ static readonly observedAttributes: string[];
10
+ /**
11
+ * Value indicating whether to apply a transition.
12
+ */
13
+ get fade(): boolean;
14
+ set fade(value: boolean);
15
+ /**
16
+ * Value indicating whether this component is shown.
17
+ */
18
+ get isShown(): boolean;
19
+ /**
20
+ * Value indicating whether to initially show this component.
21
+ */
22
+ get open(): boolean;
23
+ set open(value: boolean);
24
+ /**
25
+ * Method invoked when an attribute has been changed.
26
+ * @param attribute The attribute name.
27
+ * @param oldValue The previous attribute value.
28
+ * @param newValue The new attribute value.
29
+ */
30
+ attributeChangedCallback(attribute: string, oldValue: string | null, newValue: string | null): void;
31
+ /**
32
+ * Method invoked when this component is connected.
33
+ */
34
+ connectedCallback(): void;
35
+ /**
36
+ * Hides this loading indicator.
37
+ * @param options Value indicating whether to force the loading indicator to hide.
38
+ */
39
+ hide(options?: {
40
+ force?: boolean;
41
+ }): void;
42
+ /**
43
+ * Shows this loading indicator.
44
+ */
45
+ show(): void;
46
+ }
47
+ /**
48
+ * Declaration merging.
49
+ */
50
+ declare global {
51
+ /**
52
+ * The map of HTML tag names.
53
+ */
54
+ interface HTMLElementTagNameMap {
55
+ "loading-indicator": LoadingIndicator;
56
+ }
57
+ }
58
+ //# sourceMappingURL=LoadingIndicator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LoadingIndicator.d.ts","sourceRoot":"","sources":["../../src/Client/Components/LoadingIndicator.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,gBAAiB,SAAQ,WAAW;;IAEhD;;OAEG;IACH,MAAM,CAAC,QAAQ,CAAC,kBAAkB,WAAY;IAc9C;;OAEG;IACH,IAAI,IAAI,IAAI,OAAO,CAElB;IACD,IAAI,IAAI,CAAC,KAAK,EAAE,OAAO,EAEtB;IAED;;OAEG;IACH,IAAI,OAAO,IAAI,OAAO,CAErB;IAED;;OAEG;IACH,IAAI,IAAI,IAAI,OAAO,CAElB;IACD,IAAI,IAAI,CAAC,KAAK,EAAE,OAAO,EAEtB;IAED;;;;;OAKG;IACH,wBAAwB,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAC,IAAI,EAAE,QAAQ,EAAE,MAAM,GAAC,IAAI,GAAG,IAAI;IAO/F;;OAEG;IACH,iBAAiB,IAAI,IAAI;IAKzB;;;OAGG;IACH,IAAI,CAAC,OAAO,GAAE;QAAC,KAAK,CAAC,EAAE,OAAO,CAAA;KAAM,GAAG,IAAI;IAS3C;;OAEG;IACH,IAAI,IAAI,IAAI;CAaZ;AAED;;GAEG;AACH,OAAO,CAAC,MAAM,CAAC;IAEd;;OAEG;IACH,UAAU,qBAAqB;QAC9B,mBAAmB,EAAE,gBAAgB,CAAC;KACtC;CACD"}
@@ -0,0 +1,93 @@
1
+ /**
2
+ * A component that shows up when an HTTP request starts, and hides when all concurrent HTTP requests are completed.
3
+ */
4
+ export class LoadingIndicator extends HTMLElement {
5
+ /**
6
+ * The list of observed attributes.
7
+ */
8
+ static observedAttributes = ["fade"];
9
+ /**
10
+ * The number of concurrent HTTP requests.
11
+ */
12
+ #requestCount = 0;
13
+ /**
14
+ * Registers the component.
15
+ */
16
+ static {
17
+ customElements.define("loading-indicator", this);
18
+ }
19
+ /**
20
+ * Value indicating whether to apply a transition.
21
+ */
22
+ get fade() {
23
+ return this.hasAttribute("fade");
24
+ }
25
+ set fade(value) {
26
+ this.toggleAttribute("fade", value);
27
+ }
28
+ /**
29
+ * Value indicating whether this component is shown.
30
+ */
31
+ get isShown() {
32
+ return this.classList.contains("show");
33
+ }
34
+ /**
35
+ * Value indicating whether to initially show this component.
36
+ */
37
+ get open() {
38
+ return this.hasAttribute("open");
39
+ }
40
+ set open(value) {
41
+ this.toggleAttribute("open", value);
42
+ }
43
+ /**
44
+ * Method invoked when an attribute has been changed.
45
+ * @param attribute The attribute name.
46
+ * @param oldValue The previous attribute value.
47
+ * @param newValue The new attribute value.
48
+ */
49
+ attributeChangedCallback(attribute, oldValue, newValue) {
50
+ if (newValue != oldValue)
51
+ switch (attribute) {
52
+ case "fade":
53
+ this.#updateFade(newValue != null);
54
+ break;
55
+ // No default
56
+ }
57
+ }
58
+ /**
59
+ * Method invoked when this component is connected.
60
+ */
61
+ connectedCallback() {
62
+ this.#requestCount = 0;
63
+ if (this.open)
64
+ this.show();
65
+ }
66
+ /**
67
+ * Hides this loading indicator.
68
+ * @param options Value indicating whether to force the loading indicator to hide.
69
+ */
70
+ hide(options = {}) {
71
+ this.#requestCount--;
72
+ if (this.#requestCount <= 0 || options.force) {
73
+ this.#requestCount = 0;
74
+ this.classList.add("hide");
75
+ this.classList.remove("show");
76
+ }
77
+ }
78
+ /**
79
+ * Shows this loading indicator.
80
+ */
81
+ show() {
82
+ this.#requestCount++;
83
+ this.classList.remove("hide");
84
+ this.classList.add("show");
85
+ }
86
+ /**
87
+ * Updates the value indicating whether to apply a transition.
88
+ * @param value The new value.
89
+ */
90
+ #updateFade(value) {
91
+ this.classList.toggle("fade", value);
92
+ }
93
+ }
@@ -0,0 +1,26 @@
1
+ /**
2
+ * A component that activates the items of a menu, based on the current document URL.
3
+ */
4
+ export declare class MenuActivator extends HTMLElement {
5
+ #private;
6
+ /**
7
+ * Method invoked when this component is connected.
8
+ */
9
+ connectedCallback(): void;
10
+ /**
11
+ * Method invoked when this component is disconnected.
12
+ */
13
+ disconnectedCallback(): void;
14
+ }
15
+ /**
16
+ * Declaration merging.
17
+ */
18
+ declare global {
19
+ /**
20
+ * The map of HTML tag names.
21
+ */
22
+ interface HTMLElementTagNameMap {
23
+ "menu-activator": MenuActivator;
24
+ }
25
+ }
26
+ //# sourceMappingURL=MenuActivator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MenuActivator.d.ts","sourceRoot":"","sources":["../../src/Client/Components/MenuActivator.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,aAAc,SAAQ,WAAW;;IAc7C;;OAEG;IACH,iBAAiB,IAAI,IAAI;IAOzB;;OAEG;IACH,oBAAoB,IAAI,IAAI;CAc5B;AAED;;GAEG;AACH,OAAO,CAAC,MAAM,CAAC;IAEd;;OAEG;IACH,UAAU,qBAAqB;QAC9B,gBAAgB,EAAE,aAAa,CAAC;KAChC;CACD"}
@@ -0,0 +1,42 @@
1
+ /**
2
+ * A component that activates the items of a menu, based on the current document URL.
3
+ */
4
+ export class MenuActivator extends HTMLElement {
5
+ /**
6
+ * The abort controller used to remove the event listeners.
7
+ */
8
+ #abortController = null;
9
+ /**
10
+ * Registers the component.
11
+ */
12
+ static {
13
+ customElements.define("menu-activator", this);
14
+ }
15
+ /**
16
+ * Method invoked when this component is connected.
17
+ */
18
+ connectedCallback() {
19
+ this.#abortController = new AbortController;
20
+ this.#update();
21
+ addEventListener("popstate", () => this.#update(), { signal: this.#abortController.signal });
22
+ document.body.addEventListener("htmx:pushedIntoHistory", () => this.#update(), { signal: this.#abortController.signal });
23
+ }
24
+ /**
25
+ * Method invoked when this component is disconnected.
26
+ */
27
+ disconnectedCallback() {
28
+ this.#abortController?.abort();
29
+ }
30
+ /**
31
+ * Updates this component.
32
+ */
33
+ #update() {
34
+ for (const element of this.querySelectorAll(".active"))
35
+ element.classList.remove("active");
36
+ for (const element of this.querySelectorAll("a"))
37
+ if (element.href == location.href) {
38
+ element.classList.add("active");
39
+ element.closest(".dropdown")?.querySelector(".dropdown-toggle")?.classList.add("active");
40
+ }
41
+ }
42
+ }
@@ -0,0 +1,59 @@
1
+ /**
2
+ * A component that shows up when the network is unavailable, and hides when connectivity is restored.
3
+ */
4
+ export declare class OfflineIndicator extends HTMLElement {
5
+ #private;
6
+ /**
7
+ * The list of observed attributes.
8
+ */
9
+ static readonly observedAttributes: string[];
10
+ /**
11
+ * Value indicating whether to apply a transition.
12
+ */
13
+ get fade(): boolean;
14
+ set fade(value: boolean);
15
+ /**
16
+ * Value indicating whether this component is shown.
17
+ */
18
+ get isShown(): boolean;
19
+ /**
20
+ * Value indicating whether to initially show this component.
21
+ */
22
+ get open(): boolean;
23
+ set open(value: boolean);
24
+ /**
25
+ * Method invoked when an attribute has been changed.
26
+ * @param attribute The attribute name.
27
+ * @param oldValue The previous attribute value.
28
+ * @param newValue The new attribute value.
29
+ */
30
+ attributeChangedCallback(attribute: string, oldValue: string | null, newValue: string | null): void;
31
+ /**
32
+ * Method invoked when this component is connected.
33
+ */
34
+ connectedCallback(): void;
35
+ /**
36
+ * Method invoked when this component is disconnected.
37
+ */
38
+ disconnectedCallback(): void;
39
+ /**
40
+ * Hides this offline indicator.
41
+ */
42
+ hide(): void;
43
+ /**
44
+ * Shows this offline indicator.
45
+ */
46
+ show(): void;
47
+ }
48
+ /**
49
+ * Declaration merging.
50
+ */
51
+ declare global {
52
+ /**
53
+ * The map of HTML tag names.
54
+ */
55
+ interface HTMLElementTagNameMap {
56
+ "offline-indicator": OfflineIndicator;
57
+ }
58
+ }
59
+ //# sourceMappingURL=OfflineIndicator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OfflineIndicator.d.ts","sourceRoot":"","sources":["../../src/Client/Components/OfflineIndicator.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,gBAAiB,SAAQ,WAAW;;IAEhD;;OAEG;IACH,MAAM,CAAC,QAAQ,CAAC,kBAAkB,WAAY;IAc9C;;OAEG;IACH,IAAI,IAAI,IAAI,OAAO,CAElB;IACD,IAAI,IAAI,CAAC,KAAK,EAAE,OAAO,EAEtB;IAED;;OAEG;IACH,IAAI,OAAO,IAAI,OAAO,CAErB;IAED;;OAEG;IACH,IAAI,IAAI,IAAI,OAAO,CAElB;IACD,IAAI,IAAI,CAAC,KAAK,EAAE,OAAO,EAEtB;IAED;;;;;OAKG;IACH,wBAAwB,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAC,IAAI,EAAE,QAAQ,EAAE,MAAM,GAAC,IAAI,GAAG,IAAI;IAO/F;;OAEG;IACH,iBAAiB,IAAI,IAAI;IAQzB;;OAEG;IACH,oBAAoB,IAAI,IAAI;IAI5B;;OAEG;IACH,IAAI,IAAI,IAAI;IAKZ;;OAEG;IACH,IAAI,IAAI,IAAI;CAoBZ;AAED;;GAEG;AACH,OAAO,CAAC,MAAM,CAAC;IAEd;;OAEG;IACH,UAAU,qBAAqB;QAC9B,mBAAmB,EAAE,gBAAgB,CAAC;KACtC;CACD"}
@@ -0,0 +1,106 @@
1
+ /**
2
+ * A component that shows up when the network is unavailable, and hides when connectivity is restored.
3
+ */
4
+ export class OfflineIndicator extends HTMLElement {
5
+ /**
6
+ * The list of observed attributes.
7
+ */
8
+ static observedAttributes = ["fade"];
9
+ /**
10
+ * The abort controller used to remove the event listeners.
11
+ */
12
+ #abortController = null;
13
+ /**
14
+ * Registers the component.
15
+ */
16
+ static {
17
+ customElements.define("offline-indicator", this);
18
+ }
19
+ /**
20
+ * Value indicating whether to apply a transition.
21
+ */
22
+ get fade() {
23
+ return this.hasAttribute("fade");
24
+ }
25
+ set fade(value) {
26
+ this.toggleAttribute("fade", value);
27
+ }
28
+ /**
29
+ * Value indicating whether this component is shown.
30
+ */
31
+ get isShown() {
32
+ return this.classList.contains("show");
33
+ }
34
+ /**
35
+ * Value indicating whether to initially show this component.
36
+ */
37
+ get open() {
38
+ return this.hasAttribute("open");
39
+ }
40
+ set open(value) {
41
+ this.toggleAttribute("open", value);
42
+ }
43
+ /**
44
+ * Method invoked when an attribute has been changed.
45
+ * @param attribute The attribute name.
46
+ * @param oldValue The previous attribute value.
47
+ * @param newValue The new attribute value.
48
+ */
49
+ attributeChangedCallback(attribute, oldValue, newValue) {
50
+ if (newValue != oldValue)
51
+ switch (attribute) {
52
+ case "fade":
53
+ this.#updateFade(newValue != null);
54
+ break;
55
+ // No default
56
+ }
57
+ }
58
+ /**
59
+ * Method invoked when this component is connected.
60
+ */
61
+ connectedCallback() {
62
+ this.#abortController = new AbortController;
63
+ for (const event of ["online", "offline"])
64
+ addEventListener(event, () => this.#updateVisibility(), { signal: this.#abortController.signal });
65
+ if (this.open)
66
+ this.show();
67
+ else
68
+ this.#updateVisibility();
69
+ }
70
+ /**
71
+ * Method invoked when this component is disconnected.
72
+ */
73
+ disconnectedCallback() {
74
+ this.#abortController?.abort();
75
+ }
76
+ /**
77
+ * Hides this offline indicator.
78
+ */
79
+ hide() {
80
+ this.classList.remove("show");
81
+ this.classList.add("hide");
82
+ }
83
+ /**
84
+ * Shows this offline indicator.
85
+ */
86
+ show() {
87
+ this.classList.remove("hide");
88
+ this.classList.add("show");
89
+ }
90
+ /**
91
+ * Updates the value indicating whether to apply a transition.
92
+ * @param value The new value.
93
+ */
94
+ #updateFade(value) {
95
+ this.classList.toggle("fade", value);
96
+ }
97
+ /**
98
+ * Updates the visibility of this component.
99
+ */
100
+ #updateVisibility() {
101
+ if (navigator.onLine)
102
+ this.hide();
103
+ else
104
+ this.show();
105
+ }
106
+ }
@@ -0,0 +1,49 @@
1
+ import { StorageArea } from "../StorageArea.js";
2
+ /**
3
+ * A component that activates a tab, based on its index saved in the web storage.
4
+ */
5
+ export declare class TabActivator extends HTMLElement {
6
+ /**
7
+ * Creates a new tab activator.
8
+ */
9
+ constructor();
10
+ /**
11
+ * The index of the active tab.
12
+ */
13
+ get activeTabIndex(): number;
14
+ set activeTabIndex(value: number);
15
+ /**
16
+ * The storage object corresponding to the current {@link storageArea}.
17
+ */
18
+ get storage(): globalThis.Storage;
19
+ /**
20
+ * The storage area to use.
21
+ */
22
+ get storageArea(): StorageArea;
23
+ set storageArea(value: StorageArea);
24
+ /**
25
+ * The key of the storage entry providing the active tab index.
26
+ */
27
+ get storageKey(): string;
28
+ set storageKey(value: string);
29
+ /**
30
+ * The tab list.
31
+ */
32
+ get tabs(): NodeListOf<HTMLElement>;
33
+ /**
34
+ * Method invoked when this component is connected.
35
+ */
36
+ connectedCallback(): void;
37
+ }
38
+ /**
39
+ * Declaration merging.
40
+ */
41
+ declare global {
42
+ /**
43
+ * The map of HTML tag names.
44
+ */
45
+ interface HTMLElementTagNameMap {
46
+ "tab-activator": TabActivator;
47
+ }
48
+ }
49
+ //# sourceMappingURL=TabActivator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TabActivator.d.ts","sourceRoot":"","sources":["../../src/Client/Components/TabActivator.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,WAAW,EAAC,MAAM,mBAAmB,CAAC;AAE9C;;GAEG;AACH,qBAAa,YAAa,SAAQ,WAAW;IAE5C;;OAEG;;IAgBH;;OAEG;IACH,IAAI,cAAc,IAAI,MAAM,CAG3B;IACD,IAAI,cAAc,CAAC,KAAK,EAAE,MAAM,EAE/B;IAED;;OAEG;IACH,IAAI,OAAO,IAAI,UAAU,CAAC,OAAO,CAEhC;IAED;;OAEG;IACH,IAAI,WAAW,IAAI,WAAW,CAG7B;IACD,IAAI,WAAW,CAAC,KAAK,EAAE,WAAW,EAEjC;IAED;;OAEG;IACH,IAAI,UAAU,IAAI,MAAM,CAGvB;IACD,IAAI,UAAU,CAAC,KAAK,EAAE,MAAM,EAE3B;IAED;;OAEG;IACH,IAAI,IAAI,IAAI,UAAU,CAAC,WAAW,CAAC,CAElC;IAED;;OAEG;IACH,iBAAiB,IAAI,IAAI;CAGzB;AAED;;GAEG;AACH,OAAO,CAAC,MAAM,CAAC;IAEd;;OAEG;IACH,UAAU,qBAAqB;QAC9B,eAAe,EAAE,YAAY,CAAC;KAC9B;CACD"}