@cedx/base 0.30.0 → 0.32.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 (53) hide show
  1. package/ReadMe.md +1 -1
  2. package/lib/Date.d.ts.map +1 -1
  3. package/lib/DateRange.d.ts +106 -0
  4. package/lib/DateRange.d.ts.map +1 -0
  5. package/lib/DateRange.js +136 -0
  6. package/lib/File.d.ts.map +1 -1
  7. package/lib/Number.d.ts.map +1 -1
  8. package/lib/String.d.ts +7 -4
  9. package/lib/String.d.ts.map +1 -1
  10. package/lib/String.js +7 -6
  11. package/lib/TimeSpan.d.ts.map +1 -1
  12. package/lib/UI/Components/BackButton.d.ts +1 -1
  13. package/lib/UI/Components/BackButton.d.ts.map +1 -1
  14. package/lib/UI/Components/BackButton.js +3 -3
  15. package/lib/UI/Components/DialogBox.js +5 -5
  16. package/lib/UI/Components/FullScreenToggler.d.ts +1 -1
  17. package/lib/UI/Components/FullScreenToggler.d.ts.map +1 -1
  18. package/lib/UI/Components/FullScreenToggler.js +10 -7
  19. package/lib/UI/Components/KeyboardAccelerator.d.ts.map +1 -1
  20. package/lib/UI/Components/KeyboardAccelerator.js +6 -2
  21. package/lib/UI/Components/LoadingIndicator.d.ts +4 -0
  22. package/lib/UI/Components/LoadingIndicator.d.ts.map +1 -1
  23. package/lib/UI/Components/LoadingIndicator.js +6 -0
  24. package/lib/UI/Components/MenuActivator.d.ts.map +1 -1
  25. package/lib/UI/Components/MenuActivator.js +7 -4
  26. package/lib/UI/Components/OfflineIndicator.d.ts +4 -0
  27. package/lib/UI/Components/OfflineIndicator.d.ts.map +1 -1
  28. package/lib/UI/Components/OfflineIndicator.js +12 -3
  29. package/lib/UI/Components/TabActivator.d.ts.map +1 -1
  30. package/lib/UI/Components/ThemeDropdown.d.ts.map +1 -1
  31. package/lib/UI/Components/ThemeDropdown.js +9 -5
  32. package/lib/UI/Components/Toast.d.ts.map +1 -1
  33. package/lib/UI/Components/Toast.js +7 -5
  34. package/lib/UI/Components/Toaster.d.ts.map +1 -1
  35. package/package.json +6 -6
  36. package/src/Client/Base/DateRange.ts +173 -0
  37. package/src/Client/{String.ts → Base/String.ts} +7 -6
  38. package/src/Client/Base/tsconfig.json +2 -2
  39. package/src/Client/UI/Components/BackButton.ts +3 -3
  40. package/src/Client/UI/Components/DialogBox.ts +5 -5
  41. package/src/Client/UI/Components/FullScreenToggler.ts +11 -7
  42. package/src/Client/UI/Components/KeyboardAccelerator.ts +7 -2
  43. package/src/Client/UI/Components/LoadingIndicator.ts +7 -0
  44. package/src/Client/UI/Components/MenuActivator.ts +8 -4
  45. package/src/Client/UI/Components/OfflineIndicator.ts +14 -2
  46. package/src/Client/UI/Components/TabActivator.ts +1 -0
  47. package/src/Client/UI/Components/ThemeDropdown.ts +10 -6
  48. package/src/Client/UI/Components/Toast.ts +8 -6
  49. package/src/Client/UI/Components/Toaster.ts +1 -2
  50. /package/src/Client/{Date.ts → Base/Date.ts} +0 -0
  51. /package/src/Client/{File.ts → Base/File.ts} +0 -0
  52. /package/src/Client/{Number.ts → Base/Number.ts} +0 -0
  53. /package/src/Client/{TimeSpan.ts → Base/TimeSpan.ts} +0 -0
package/ReadMe.md CHANGED
@@ -1,5 +1,5 @@
1
1
  # Cédric Belin's Base
2
- ![.NET](https://badgen.net/badge/.net/%3E%3D9.0/green) ![Version](https://badgen.net/badge/project/v0.30.0/blue) ![Licence](https://badgen.net/badge/licence/MIT/blue)
2
+ ![.NET](https://badgen.net/badge/.net/%3E%3D9.0/green) ![Version](https://badgen.net/badge/project/v0.32.0/blue) ![Licence](https://badgen.net/badge/licence/MIT/blue)
3
3
 
4
4
  Base library by [Cédric Belin](https://cedric-belin.fr), full stack developer,
5
5
  implemented in [C#](https://learn.microsoft.com/en-us/dotnet/csharp) and [TypeScript](https://www.typescriptlang.org).
package/lib/Date.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"Date.d.ts","sourceRoot":"","sources":["../src/Client/Date.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,CAE3C;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAE9C;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,CAc1C;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,EAAE,CAqB9C;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAE7C;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAIhD;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAG9C;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAG7C;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAGhD;AAED;;;GAGG;AACH,wBAAgB,KAAK,IAAI,IAAI,CAI5B;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAE5C;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,GAAE;IAAC,WAAW,CAAC,EAAE,OAAO,CAAC;IAAC,WAAW,CAAC,EAAE,OAAO,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAM,GAAG,MAAM,CAM7H"}
1
+ {"version":3,"file":"Date.d.ts","sourceRoot":"","sources":["../src/Client/Base/Date.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,CAE3C;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAE9C;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,CAc1C;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,EAAE,CAqB9C;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAE7C;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAIhD;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAG9C;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAG7C;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAGhD;AAED;;;GAGG;AACH,wBAAgB,KAAK,IAAI,IAAI,CAI5B;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAE5C;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,GAAE;IAAC,WAAW,CAAC,EAAE,OAAO,CAAC;IAAC,WAAW,CAAC,EAAE,OAAO,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAM,GAAG,MAAM,CAM7H"}
@@ -0,0 +1,106 @@
1
+ /**
2
+ * Defines the type of a date range.
3
+ */
4
+ export declare const DateRangeType: Readonly<{
5
+ /**
6
+ * A custom date range.
7
+ */
8
+ Custom: "Custom";
9
+ /**
10
+ * A whole day.
11
+ */
12
+ Day: "Day";
13
+ /**
14
+ * A whole week.
15
+ */
16
+ Week: "Week";
17
+ /**
18
+ * A whole month.
19
+ */
20
+ Month: "Month";
21
+ /**
22
+ * A whole quarter.
23
+ */
24
+ Quarter: "Quarter";
25
+ /**
26
+ * A whole year.
27
+ */
28
+ Year: "Year";
29
+ }>;
30
+ /**
31
+ * Defines the type of a date range.
32
+ */
33
+ export type DateRangeType = typeof DateRangeType[keyof typeof DateRangeType];
34
+ /**
35
+ * Defines a date range.
36
+ */
37
+ export declare class DateRange {
38
+ /**
39
+ * The end date.
40
+ */
41
+ readonly end: Date;
42
+ /**
43
+ * The start date.
44
+ */
45
+ readonly start: Date;
46
+ /**
47
+ * The range type.
48
+ */
49
+ readonly type: DateRangeType;
50
+ /**
51
+ * Creates a new date range.
52
+ * @param start The start date.
53
+ * @param end The end date.
54
+ * @param type The range type.
55
+ */
56
+ constructor(start: Date, end: Date, type?: DateRangeType);
57
+ /**
58
+ * Creates a new date range from the specified JSON object.
59
+ * @param json A JSON object representing a date range.
60
+ * @returns The instance corresponding to the specified JSON object.
61
+ */
62
+ static fromJson(json: Record<string, any>): DateRange;
63
+ /**
64
+ * Creates a date range corresponding to the day including the specified date.
65
+ * @param date The date.
66
+ * @returns The date range corresponding to the day including the specified date.
67
+ */
68
+ static day(date: Date): DateRange;
69
+ /**
70
+ * Creates a date range corresponding to the month including the specified date.
71
+ * @param date The date.
72
+ * @returns The date range corresponding to the month including the specified date.
73
+ */
74
+ static month(date: Date): DateRange;
75
+ /**
76
+ * Creates a date range corresponding to the quarter including the specified date.
77
+ * @param date The date.
78
+ * @returns The date range corresponding to the quarter including the specified date.
79
+ */
80
+ static quarter(date: Date): DateRange;
81
+ /**
82
+ * Creates a date range corresponding to the week including the specified date.
83
+ * @param date The date.
84
+ * @returns The date range corresponding to the week including the specified date.
85
+ */
86
+ static week(date: Date): DateRange;
87
+ /**
88
+ * Creates a date range corresponding to the year including the specified date.
89
+ * @param date The date.
90
+ * @returns The date range corresponding to the year including the specified date.
91
+ */
92
+ static year(date: Date): DateRange;
93
+ /**
94
+ * Returns a value indicating whether this date range is equal to the specified date range.
95
+ * @param other The other date range to compare.
96
+ * @returns `true` if this date range is equal to the specified date range, otherwise `false`.
97
+ */
98
+ equals(other: DateRange): boolean;
99
+ /**
100
+ * The label corresponding to this date range.
101
+ * @param culture The current culture.
102
+ * @returns The label corresponding to this date range.
103
+ */
104
+ getLabel(culture?: Intl.Locale | string): string;
105
+ }
106
+ //# sourceMappingURL=DateRange.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DateRange.d.ts","sourceRoot":"","sources":["../src/Client/Base/DateRange.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,eAAO,MAAM,aAAa;IAEzB;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;EAEF,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,OAAO,aAAa,CAAC,MAAM,OAAO,aAAa,CAAC,CAAC;AAE7E;;GAEG;AACH,qBAAa,SAAS;IAErB;;OAEG;IACH,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC;IAEnB;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAC;IAErB;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;IAE7B;;;;;OAKG;gBACS,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,GAAE,aAAoC;IAM9E;;;;OAIG;IACH,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,SAAS;IAQrD;;;;OAIG;IACH,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,GAAG,SAAS;IAIjC;;;;OAIG;IACH,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,GAAG,SAAS;IAQnC;;;;OAIG;IACH,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,GAAG,SAAS;IAUrC;;;;OAIG;IACH,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,GAAG,SAAS;IAOlC;;;;OAIG;IACH,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,GAAG,SAAS;IAIlC;;;;OAIG;IACH,MAAM,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO;IAIjC;;;;OAIG;IACH,QAAQ,CAAC,OAAO,GAAE,IAAI,CAAC,MAAM,GAAC,MAA2B,GAAG,MAAM;CAWlE"}
@@ -0,0 +1,136 @@
1
+ import { atMidnight, daysInMonth, getQuarter, getWeekOfYear } from "./Date.js";
2
+ import { TimeSpan } from "./TimeSpan.js";
3
+ /**
4
+ * Defines the type of a date range.
5
+ */
6
+ export const DateRangeType = Object.freeze({
7
+ /**
8
+ * A custom date range.
9
+ */
10
+ Custom: "Custom",
11
+ /**
12
+ * A whole day.
13
+ */
14
+ Day: "Day",
15
+ /**
16
+ * A whole week.
17
+ */
18
+ Week: "Week",
19
+ /**
20
+ * A whole month.
21
+ */
22
+ Month: "Month",
23
+ /**
24
+ * A whole quarter.
25
+ */
26
+ Quarter: "Quarter",
27
+ /**
28
+ * A whole year.
29
+ */
30
+ Year: "Year"
31
+ });
32
+ /**
33
+ * Defines a date range.
34
+ */
35
+ export class DateRange {
36
+ /**
37
+ * The end date.
38
+ */
39
+ end;
40
+ /**
41
+ * The start date.
42
+ */
43
+ start;
44
+ /**
45
+ * The range type.
46
+ */
47
+ type;
48
+ /**
49
+ * Creates a new date range.
50
+ * @param start The start date.
51
+ * @param end The end date.
52
+ * @param type The range type.
53
+ */
54
+ constructor(start, end, type = DateRangeType.Custom) {
55
+ this.start = start;
56
+ this.end = end;
57
+ this.type = type;
58
+ }
59
+ /**
60
+ * Creates a new date range from the specified JSON object.
61
+ * @param json A JSON object representing a date range.
62
+ * @returns The instance corresponding to the specified JSON object.
63
+ */
64
+ static fromJson(json) {
65
+ return new this(new Date(typeof json.start == "string" ? json.start : Date.now()), new Date(typeof json.end == "string" ? json.end : Date.now()), Object.values(DateRangeType).includes(json.type) ? json.type : DateRangeType.Custom);
66
+ }
67
+ /**
68
+ * Creates a date range corresponding to the day including the specified date.
69
+ * @param date The date.
70
+ * @returns The date range corresponding to the day including the specified date.
71
+ */
72
+ static day(date) {
73
+ return new this(atMidnight(date), new Date(date.getFullYear(), date.getMonth(), date.getDate(), 23, 59, 59, 999), DateRangeType.Day);
74
+ }
75
+ /**
76
+ * Creates a date range corresponding to the month including the specified date.
77
+ * @param date The date.
78
+ * @returns The date range corresponding to the month including the specified date.
79
+ */
80
+ static month(date) {
81
+ return new this(new Date(date.getFullYear(), date.getMonth(), 1), new Date(date.getFullYear(), date.getMonth(), daysInMonth(date), 23, 59, 59, 999), DateRangeType.Month);
82
+ }
83
+ /**
84
+ * Creates a date range corresponding to the quarter including the specified date.
85
+ * @param date The date.
86
+ * @returns The date range corresponding to the quarter including the specified date.
87
+ */
88
+ static quarter(date) {
89
+ const firstMonth = (getQuarter(date) * 3) - 3;
90
+ const lastMonth = firstMonth + 2;
91
+ return new this(new Date(date.getFullYear(), firstMonth, 1), new Date(date.getFullYear(), lastMonth, daysInMonth(new Date(date.getFullYear(), lastMonth, 1)), 23, 59, 59, 999), DateRangeType.Quarter);
92
+ }
93
+ /**
94
+ * Creates a date range corresponding to the week including the specified date.
95
+ * @param date The date.
96
+ * @returns The date range corresponding to the week including the specified date.
97
+ */
98
+ static week(date) {
99
+ const delta = -((date.getDay() + 6) % 7);
100
+ const sunday = new Date(date.getTime() + ((delta + 6) * TimeSpan.MillisecondsPerDay));
101
+ sunday.setHours(23, 59, 59, 999);
102
+ return new this(atMidnight(new Date(date.getTime() + (delta * TimeSpan.MillisecondsPerDay))), sunday, DateRangeType.Week);
103
+ }
104
+ /**
105
+ * Creates a date range corresponding to the year including the specified date.
106
+ * @param date The date.
107
+ * @returns The date range corresponding to the year including the specified date.
108
+ */
109
+ static year(date) {
110
+ return new this(new Date(date.getFullYear(), 0, 1), new Date(date.getFullYear(), 11, 31, 23, 59, 59, 999), DateRangeType.Year);
111
+ }
112
+ /**
113
+ * Returns a value indicating whether this date range is equal to the specified date range.
114
+ * @param other The other date range to compare.
115
+ * @returns `true` if this date range is equal to the specified date range, otherwise `false`.
116
+ */
117
+ equals(other) {
118
+ return this.start.getTime() == other.start.getTime() && this.end.getTime() == other.end.getTime();
119
+ }
120
+ /**
121
+ * The label corresponding to this date range.
122
+ * @param culture The current culture.
123
+ * @returns The label corresponding to this date range.
124
+ */
125
+ getLabel(culture = navigator.language) {
126
+ const { start, end, type } = this;
127
+ switch (type) {
128
+ case DateRangeType.Day: return start.toLocaleString(culture, { dateStyle: "medium" });
129
+ case DateRangeType.Week: return `S${getWeekOfYear(start)} ${start.getFullYear()}`;
130
+ case DateRangeType.Month: return start.toLocaleString(culture, { month: "long", year: "numeric" });
131
+ case DateRangeType.Quarter: return `T${getQuarter(start)} ${start.getFullYear()}`;
132
+ case DateRangeType.Year: return start.getFullYear().toString();
133
+ default: return end.toLocaleString(culture, { dateStyle: "medium" });
134
+ }
135
+ }
136
+ }
package/lib/File.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"File.d.ts","sourceRoot":"","sources":["../src/Client/File.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,CAUzC;AAED;;;;GAIG;AACH,wBAAgB,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,GAAE;IAAC,MAAM,CAAC,EAAE,OAAO,CAAA;CAAM,GAAG,IAAI,CAkBvE;AAED;;;GAGG;AACH,wBAAgB,KAAK,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,CAatC;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,CAOlD"}
1
+ {"version":3,"file":"File.d.ts","sourceRoot":"","sources":["../src/Client/Base/File.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,CAUzC;AAED;;;;GAIG;AACH,wBAAgB,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,GAAE;IAAC,MAAM,CAAC,EAAE,OAAO,CAAA;CAAM,GAAG,IAAI,CAkBvE;AAED;;;GAGG;AACH,wBAAgB,KAAK,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,CAatC;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,CAOlD"}
@@ -1 +1 @@
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"}
1
+ {"version":3,"file":"Number.d.ts","sourceRoot":"","sources":["../src/Client/Base/Number.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,SAAI,GAAG,MAAM,CAG1D"}
package/lib/String.d.ts CHANGED
@@ -1,16 +1,19 @@
1
1
  /**
2
- * Converts the first character to uppercase.
2
+ * Converts the first character of the specified string to uppercase.
3
3
  * @param value The string to process.
4
- * @param locale The current locale.
4
+ * @param culture The current culture.
5
5
  * @returns The processed string.
6
6
  */
7
- export declare function capitalize(value: string, locale?: Intl.Locale | string): string;
7
+ export declare function capitalize(value: string, culture?: Intl.Locale | string): string;
8
8
  /**
9
9
  * Replaces all new lines in the specified value by HTML line breaks.
10
10
  * @param value The string to format.
11
+ * @param options Value indicating whether to use XHTML compatible line breaks.
11
12
  * @returns The formatted string.
12
13
  */
13
- export declare function newLineToBr(value: string): string;
14
+ export declare function newLineToBr(value: string, options?: {
15
+ xhtml?: boolean;
16
+ }): string;
14
17
  /**
15
18
  * Reverses the specified string.
16
19
  * @param value The string to reverse.
@@ -1 +1 @@
1
- {"version":3,"file":"String.d.ts","sourceRoot":"","sources":["../src/Client/String.ts"],"names":[],"mappings":"AAAA;;;;;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;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,SAAQ,GAAG,MAAM,CAEhF"}
1
+ {"version":3,"file":"String.d.ts","sourceRoot":"","sources":["../src/Client/Base/String.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,GAAE,IAAI,CAAC,MAAM,GAAC,MAA2B,GAAG,MAAM,CAElG;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,GAAE;IAAC,KAAK,CAAC,EAAE,OAAO,CAAA;CAAM,GAAG,MAAM,CAElF;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;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,SAAQ,GAAG,MAAM,CAEhF"}
package/lib/String.js CHANGED
@@ -1,19 +1,20 @@
1
1
  /**
2
- * Converts the first character to uppercase.
2
+ * Converts the first character of the specified string to uppercase.
3
3
  * @param value The string to process.
4
- * @param locale The current locale.
4
+ * @param culture The current culture.
5
5
  * @returns The processed string.
6
6
  */
7
- export function capitalize(value, locale = navigator.language) {
8
- return value.charAt(0).toLocaleUpperCase(locale) + value.slice(1);
7
+ export function capitalize(value, culture = navigator.language) {
8
+ return value.length == 0 ? "" : value.charAt(0).toLocaleUpperCase(culture) + value.slice(1);
9
9
  }
10
10
  /**
11
11
  * Replaces all new lines in the specified value by HTML line breaks.
12
12
  * @param value The string to format.
13
+ * @param options Value indicating whether to use XHTML compatible line breaks.
13
14
  * @returns The formatted string.
14
15
  */
15
- export function newLineToBr(value) {
16
- return value.split(/\r?\n/g).join("<br>");
16
+ export function newLineToBr(value, options = {}) {
17
+ return value.split(/\r?\n/g).join(options.xhtml ? "<br />" : "<br>");
17
18
  }
18
19
  /**
19
20
  * Reverses the specified string.
@@ -1 +1 @@
1
- {"version":3,"file":"TimeSpan.d.ts","sourceRoot":"","sources":["../src/Client/TimeSpan.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,QAAQ;IAEpB;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;EAEF,CAAC"}
1
+ {"version":3,"file":"TimeSpan.d.ts","sourceRoot":"","sources":["../src/Client/Base/TimeSpan.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,QAAQ;IAEpB;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;EAEF,CAAC"}
@@ -15,7 +15,7 @@ export declare class BackButton extends HTMLElement {
15
15
  * Moves back in the session history.
16
16
  * @param event The dispatched event.
17
17
  */
18
- goBack(event?: Event): void;
18
+ readonly goBack: (event?: Event) => void;
19
19
  }
20
20
  /**
21
21
  * Declaration merging.
@@ -1 +1 @@
1
- {"version":3,"file":"BackButton.d.ts","sourceRoot":"","sources":["../../../src/Client/UI/Components/BackButton.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,UAAW,SAAQ,WAAW;IAE1C;;OAEG;;IAaH;;OAEG;IACH,IAAI,KAAK,IAAI,MAAM,CAGlB;IACD,IAAI,KAAK,CAAC,KAAK,EAAE,MAAM,EAEtB;IAED;;;OAGG;IACH,MAAM,CAAC,KAAK,CAAC,EAAE,KAAK,GAAG,IAAI;CAI3B;AAED;;GAEG;AACH,OAAO,CAAC,MAAM,CAAC;IAEd;;OAEG;IACH,UAAU,qBAAqB;QAC9B,aAAa,EAAE,UAAU,CAAC;KAC1B;CACD"}
1
+ {"version":3,"file":"BackButton.d.ts","sourceRoot":"","sources":["../../../src/Client/UI/Components/BackButton.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,UAAW,SAAQ,WAAW;IAE1C;;OAEG;;IAaH;;OAEG;IACH,IAAI,KAAK,IAAI,MAAM,CAGlB;IACD,IAAI,KAAK,CAAC,KAAK,EAAE,MAAM,EAEtB;IAED;;;OAGG;IACH,QAAQ,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,KAAK,IAAI,CAGtC;CACF;AAED;;GAEG;AACH,OAAO,CAAC,MAAM,CAAC;IAEd;;OAEG;IACH,UAAU,qBAAqB;QAC9B,aAAa,EAAE,UAAU,CAAC;KAC1B;CACD"}
@@ -7,7 +7,7 @@ export class BackButton extends HTMLElement {
7
7
  */
8
8
  constructor() {
9
9
  super();
10
- this.addEventListener("click", this.goBack.bind(this), { capture: true });
10
+ this.addEventListener("click", this.goBack, { capture: true });
11
11
  }
12
12
  /**
13
13
  * Registers the component.
@@ -29,8 +29,8 @@ export class BackButton extends HTMLElement {
29
29
  * Moves back in the session history.
30
30
  * @param event The dispatched event.
31
31
  */
32
- goBack(event) {
32
+ goBack = event => {
33
33
  event?.stopPropagation();
34
34
  history.go(-this.steps);
35
- }
35
+ };
36
36
  }
@@ -29,9 +29,9 @@ export class DialogBox extends HTMLElement {
29
29
  constructor() {
30
30
  super();
31
31
  this.firstElementChild.addEventListener("hide.bs.modal", () => this.#resolve(this.#result));
32
- this.querySelector(".btn-close").addEventListener("click", this.#close.bind(this));
32
+ this.querySelector(".btn-close").addEventListener("click", this.#close);
33
33
  for (const button of this.querySelectorAll(".modal-footer button"))
34
- button.addEventListener("click", this.#close.bind(this));
34
+ button.addEventListener("click", this.#close);
35
35
  }
36
36
  /**
37
37
  * Registers the component.
@@ -211,7 +211,7 @@ export class DialogBox extends HTMLElement {
211
211
  if (message) {
212
212
  const footer = message.footer ?? document.createDocumentFragment();
213
213
  for (const button of footer.querySelectorAll("button"))
214
- button.addEventListener("click", this.#close.bind(this));
214
+ button.addEventListener("click", this.#close);
215
215
  this.body = message.body;
216
216
  this.caption = message.caption;
217
217
  this.footer = footer;
@@ -226,10 +226,10 @@ export class DialogBox extends HTMLElement {
226
226
  * Closes this dialog box.
227
227
  * @param event The dispatched event.
228
228
  */
229
- #close(event) {
229
+ #close = event => {
230
230
  event.preventDefault();
231
231
  this.close(event.currentTarget.value);
232
- }
232
+ };
233
233
  /**
234
234
  * Updates the title displayed in the header.
235
235
  * @param value The new value.
@@ -30,7 +30,7 @@ export declare class FullScreenToggler extends HTMLElement {
30
30
  * @param event The dispatched event.
31
31
  * @returns Completes when the full-screen mode has been toggled.
32
32
  */
33
- toggleFullScreen(event?: Event): Promise<void>;
33
+ readonly toggleFullScreen: (event?: Event) => Promise<void>;
34
34
  }
35
35
  /**
36
36
  * Declaration merging.
@@ -1 +1 @@
1
- {"version":3,"file":"FullScreenToggler.d.ts","sourceRoot":"","sources":["../../../src/Client/UI/Components/FullScreenToggler.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,iBAAkB,SAAQ,WAAW;;IAYjD;;OAEG;;IAaH;;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;IAMzB;;OAEG;IACH,oBAAoB,IAAI,IAAI;IAK5B;;;;OAIG;IACG,gBAAgB,CAAC,KAAK,CAAC,EAAE,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC;CAwCpD;AAED;;GAEG;AACH,OAAO,CAAC,MAAM,CAAC;IAEd;;OAEG;IACH,UAAU,qBAAqB;QAC9B,oBAAoB,EAAE,iBAAiB,CAAC;KACxC;CACD"}
1
+ {"version":3,"file":"FullScreenToggler.d.ts","sourceRoot":"","sources":["../../../src/Client/UI/Components/FullScreenToggler.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,iBAAkB,SAAQ,WAAW;;IAiBjD;;OAEG;;IAaH;;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;IAMzB;;OAEG;IACH,oBAAoB,IAAI,IAAI;IAI5B;;;;OAIG;IACH,QAAQ,CAAC,gBAAgB,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,KAAK,OAAO,CAAC,IAAI,CAAC,CAIzD;CAoCF;AAED;;GAEG;AACH,OAAO,CAAC,MAAM,CAAC;IAEd;;OAEG;IACH,UAAU,qBAAqB;QAC9B,oBAAoB,EAAE,iBAAiB,CAAC;KACxC;CACD"}
@@ -2,6 +2,10 @@
2
2
  * A component for toggling an element to full-screen.
3
3
  */
4
4
  export class FullScreenToggler extends HTMLElement {
5
+ /**
6
+ * The abort controller used to remove the event listeners.
7
+ */
8
+ #abortController = new AbortController;
5
9
  /**
6
10
  * The target element.
7
11
  */
@@ -15,7 +19,7 @@ export class FullScreenToggler extends HTMLElement {
15
19
  */
16
20
  constructor() {
17
21
  super();
18
- this.addEventListener("click", this.toggleFullScreen.bind(this), { capture: true }); // eslint-disable-line @typescript-eslint/no-misused-promises
22
+ this.addEventListener("click", this.toggleFullScreen, { capture: true }); // eslint-disable-line @typescript-eslint/no-misused-promises
19
23
  }
20
24
  /**
21
25
  * Registers the component.
@@ -46,29 +50,28 @@ export class FullScreenToggler extends HTMLElement {
46
50
  * Method invoked when this component is connected.
47
51
  */
48
52
  connectedCallback() {
49
- document.addEventListener("visibilitychange", this.#onVisibilityChanged);
53
+ document.addEventListener("visibilitychange", this.#onVisibilityChanged, { signal: this.#abortController.signal });
50
54
  this.#element = document.querySelector(this.target) ?? document.body;
51
- this.#element.addEventListener("fullscreenchange", this.#onFullScreenChanged);
55
+ this.#element.addEventListener("fullscreenchange", this.#onFullScreenChanged, { signal: this.#abortController.signal });
52
56
  }
53
57
  /**
54
58
  * Method invoked when this component is disconnected.
55
59
  */
56
60
  disconnectedCallback() {
57
- document.removeEventListener("visibilitychange", this.#onVisibilityChanged);
58
- this.#element.removeEventListener("fullscreenchange", this.#onFullScreenChanged);
61
+ this.#abortController.abort();
59
62
  }
60
63
  /**
61
64
  * Toggles the full-screen mode of the associated element.
62
65
  * @param event The dispatched event.
63
66
  * @returns Completes when the full-screen mode has been toggled.
64
67
  */
65
- async toggleFullScreen(event) {
68
+ toggleFullScreen = async (event) => {
66
69
  event?.stopPropagation();
67
70
  if (document.fullscreenElement)
68
71
  await document.exitFullscreen();
69
72
  else
70
73
  await this.#element.requestFullscreen();
71
- }
74
+ };
72
75
  /**
73
76
  * Acquires a new wake lock.
74
77
  * @returns Completes when the wake lock has been acquired.
@@ -1 +1 @@
1
- {"version":3,"file":"KeyboardAccelerator.d.ts","sourceRoot":"","sources":["../../../src/Client/UI/Components/KeyboardAccelerator.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,WAAW;;IAcnD;;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;IAIzB;;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"}
1
+ {"version":3,"file":"KeyboardAccelerator.d.ts","sourceRoot":"","sources":["../../../src/Client/UI/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;IAIzB;;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"}
@@ -3,6 +3,10 @@ import { KeyboardModifiers } from "../KeyboardModifiers.js";
3
3
  * Represents a shortcut key associated with an element.
4
4
  */
5
5
  export class KeyboardAccelerator extends HTMLElement {
6
+ /**
7
+ * The abort controller used to remove the event listeners.
8
+ */
9
+ #abortController = new AbortController;
6
10
  /**
7
11
  * The mapping between the modifier names and their values.
8
12
  */
@@ -40,13 +44,13 @@ export class KeyboardAccelerator extends HTMLElement {
40
44
  * Method invoked when this component is connected.
41
45
  */
42
46
  connectedCallback() {
43
- addEventListener("keyup", this.#activateChildContent, { capture: true });
47
+ addEventListener("keyup", this.#activateChildContent, { capture: true, signal: this.#abortController.signal });
44
48
  }
45
49
  /**
46
50
  * Method invoked when this component is disconnected.
47
51
  */
48
52
  disconnectedCallback() {
49
- removeEventListener("keyup", this.#activateChildContent, { capture: true });
53
+ this.#abortController.abort();
50
54
  }
51
55
  /**
52
56
  * Activates the child content when the specified keyboard event designates the same key and modifiers as this keyboard accelerator.
@@ -12,6 +12,10 @@ export declare class LoadingIndicator extends HTMLElement {
12
12
  */
13
13
  get fade(): boolean;
14
14
  set fade(value: boolean);
15
+ /**
16
+ * Value indicating whether this component is shown.
17
+ */
18
+ get isShown(): boolean;
15
19
  /**
16
20
  * Value indicating whether to initially show this component.
17
21
  */
@@ -1 +1 @@
1
- {"version":3,"file":"LoadingIndicator.d.ts","sourceRoot":"","sources":["../../../src/Client/UI/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,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;IAIzB;;;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"}
1
+ {"version":3,"file":"LoadingIndicator.d.ts","sourceRoot":"","sources":["../../../src/Client/UI/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;IAIzB;;;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"}
@@ -25,6 +25,12 @@ export class LoadingIndicator extends HTMLElement {
25
25
  set fade(value) {
26
26
  this.toggleAttribute("fade", value);
27
27
  }
28
+ /**
29
+ * Value indicating whether this component is shown.
30
+ */
31
+ get isShown() {
32
+ return this.classList.contains("show");
33
+ }
28
34
  /**
29
35
  * Value indicating whether to initially show this component.
30
36
  */
@@ -1 +1 @@
1
- {"version":3,"file":"MenuActivator.d.ts","sourceRoot":"","sources":["../../../src/Client/UI/Components/MenuActivator.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,aAAc,SAAQ,WAAW;;IAS7C;;OAEG;IACH,iBAAiB,IAAI,IAAI;IAMzB;;OAEG;IACH,oBAAoB,IAAI,IAAI;CAgB5B;AAED;;GAEG;AACH,OAAO,CAAC,MAAM,CAAC;IAEd;;OAEG;IACH,UAAU,qBAAqB;QAC9B,gBAAgB,EAAE,aAAa,CAAC;KAChC;CACD"}
1
+ {"version":3,"file":"MenuActivator.d.ts","sourceRoot":"","sources":["../../../src/Client/UI/Components/MenuActivator.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,aAAc,SAAQ,WAAW;;IAc7C;;OAEG;IACH,iBAAiB,IAAI,IAAI;IAMzB;;OAEG;IACH,oBAAoB,IAAI,IAAI;CAe5B;AAED;;GAEG;AACH,OAAO,CAAC,MAAM,CAAC;IAEd;;OAEG;IACH,UAAU,qBAAqB;QAC9B,gBAAgB,EAAE,aAAa,CAAC;KAChC;CACD"}
@@ -2,6 +2,10 @@
2
2
  * A component that activates the items of a menu, based on the current document URL.
3
3
  */
4
4
  export class MenuActivator extends HTMLElement {
5
+ /**
6
+ * The abort controller used to remove the event listeners.
7
+ */
8
+ #abortController = new AbortController;
5
9
  /**
6
10
  * Registers the component.
7
11
  */
@@ -13,15 +17,14 @@ export class MenuActivator extends HTMLElement {
13
17
  */
14
18
  connectedCallback() {
15
19
  this.#update();
16
- addEventListener("popstate", this.#update);
17
- document.body.addEventListener("htmx:afterRequest", this.#update);
20
+ addEventListener("popstate", this.#update, { signal: this.#abortController.signal });
21
+ document.body.addEventListener("htmx:afterRequest", this.#update, { signal: this.#abortController.signal });
18
22
  }
19
23
  /**
20
24
  * Method invoked when this component is disconnected.
21
25
  */
22
26
  disconnectedCallback() {
23
- removeEventListener("popstate", this.#update);
24
- document.body.removeEventListener("htmx:afterRequest", this.#update);
27
+ this.#abortController.abort();
25
28
  }
26
29
  /**
27
30
  * Updates this component.
@@ -12,6 +12,10 @@ export declare class OfflineIndicator extends HTMLElement {
12
12
  */
13
13
  get fade(): boolean;
14
14
  set fade(value: boolean);
15
+ /**
16
+ * Value indicating whether this component is shown.
17
+ */
18
+ get isShown(): boolean;
15
19
  /**
16
20
  * Value indicating whether to initially show this component.
17
21
  */
@@ -1 +1 @@
1
- {"version":3,"file":"OfflineIndicator.d.ts","sourceRoot":"","sources":["../../../src/Client/UI/Components/OfflineIndicator.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,gBAAiB,SAAQ,WAAW;;IAEhD;;OAEG;IACH,MAAM,CAAC,QAAQ,CAAC,kBAAkB,WAAY;IAS9C;;OAEG;IACH,IAAI,IAAI,IAAI,OAAO,CAElB;IACD,IAAI,IAAI,CAAC,KAAK,EAAE,OAAO,EAEtB;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;IAMzB;;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"}
1
+ {"version":3,"file":"OfflineIndicator.d.ts","sourceRoot":"","sources":["../../../src/Client/UI/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;IAMzB;;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"}
@@ -6,6 +6,10 @@ export class OfflineIndicator extends HTMLElement {
6
6
  * The list of observed attributes.
7
7
  */
8
8
  static observedAttributes = ["fade"];
9
+ /**
10
+ * The abort controller used to remove the event listeners.
11
+ */
12
+ #abortController = new AbortController;
9
13
  /**
10
14
  * Registers the component.
11
15
  */
@@ -21,6 +25,12 @@ export class OfflineIndicator extends HTMLElement {
21
25
  set fade(value) {
22
26
  this.toggleAttribute("fade", value);
23
27
  }
28
+ /**
29
+ * Value indicating whether this component is shown.
30
+ */
31
+ get isShown() {
32
+ return this.classList.contains("show");
33
+ }
24
34
  /**
25
35
  * Value indicating whether to initially show this component.
26
36
  */
@@ -50,7 +60,7 @@ export class OfflineIndicator extends HTMLElement {
50
60
  */
51
61
  connectedCallback() {
52
62
  for (const event of ["online", "offline"])
53
- addEventListener(event, this.#updateVisibility);
63
+ addEventListener(event, this.#updateVisibility, { signal: this.#abortController.signal });
54
64
  if (this.open)
55
65
  this.show();
56
66
  else
@@ -60,8 +70,7 @@ export class OfflineIndicator extends HTMLElement {
60
70
  * Method invoked when this component is disconnected.
61
71
  */
62
72
  disconnectedCallback() {
63
- for (const event of ["online", "offline"])
64
- removeEventListener(event, this.#updateVisibility);
73
+ this.#abortController.abort();
65
74
  }
66
75
  /**
67
76
  * Hides this offline indicator.