@cedx/ui 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.
- package/Distributable/Bootstrap.d.ts +11 -0
- package/Distributable/Bootstrap.d.ts.map +1 -0
- package/Distributable/Bootstrap.js +17 -0
- package/Distributable/Components/MenuActivator.d.ts.map +1 -1
- package/Distributable/Components/MenuActivator.js +3 -1
- package/Distributable/Scenario.d.ts +18 -0
- package/Distributable/Scenario.d.ts.map +1 -0
- package/Distributable/Scenario.js +13 -0
- package/Distributable/Sort.d.ts +148 -0
- package/Distributable/Sort.d.ts.map +1 -0
- package/Distributable/Sort.js +214 -0
- package/Sources/Client/Bootstrap.ts +17 -0
- package/Sources/Client/Components/MenuActivator.ts +4 -1
- package/Sources/Client/Scenario.ts +20 -0
- package/Sources/Client/Sort.ts +243 -0
- package/package.json +1 -1
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Disposes all popovers attached to the specified element.
|
|
3
|
+
* @param element The source element.
|
|
4
|
+
*/
|
|
5
|
+
export declare function disposePopovers(element: Element): void;
|
|
6
|
+
/**
|
|
7
|
+
* Disposes all tooltips attached to the specified element.
|
|
8
|
+
* @param element The source element.
|
|
9
|
+
*/
|
|
10
|
+
export declare function disposeTooltips(element: Element): void;
|
|
11
|
+
//# sourceMappingURL=Bootstrap.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Bootstrap.d.ts","sourceRoot":"","sources":["../Sources/Client/Bootstrap.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAEtD;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAEtD"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Popover, Tooltip } from "bootstrap";
|
|
2
|
+
/**
|
|
3
|
+
* Disposes all popovers attached to the specified element.
|
|
4
|
+
* @param element The source element.
|
|
5
|
+
*/
|
|
6
|
+
export function disposePopovers(element) {
|
|
7
|
+
for (const node of element.querySelectorAll('[data-bs-toggle="popover"]'))
|
|
8
|
+
Popover.getInstance(node)?.dispose();
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Disposes all tooltips attached to the specified element.
|
|
12
|
+
* @param element The source element.
|
|
13
|
+
*/
|
|
14
|
+
export function disposeTooltips(element) {
|
|
15
|
+
for (const node of element.querySelectorAll('[data-bs-toggle="tooltip"]'))
|
|
16
|
+
Tooltip.getInstance(node)?.dispose();
|
|
17
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MenuActivator.d.ts","sourceRoot":"","sources":["../../Sources/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;
|
|
1
|
+
{"version":3,"file":"MenuActivator.d.ts","sourceRoot":"","sources":["../../Sources/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;CAiB5B;AAED;;GAEG;AACH,OAAO,CAAC,MAAM,CAAC;IAEd;;OAEG;IACH,UAAU,qBAAqB;QAC9B,gBAAgB,EAAE,aAAa,CAAC;KAChC;CACD"}
|
|
@@ -33,8 +33,10 @@ export class MenuActivator extends HTMLElement {
|
|
|
33
33
|
#update() {
|
|
34
34
|
for (const element of this.querySelectorAll(".active"))
|
|
35
35
|
element.classList.remove("active");
|
|
36
|
+
const { origin, pathname } = new URL(location.href);
|
|
37
|
+
const href = `${origin}${pathname}`;
|
|
36
38
|
for (const anchor of this.querySelectorAll("a"))
|
|
37
|
-
if (anchor.href ==
|
|
39
|
+
if (anchor.href == href) {
|
|
38
40
|
anchor.classList.add("active");
|
|
39
41
|
anchor.closest(".dropdown")?.querySelector(".dropdown-toggle")?.classList.add("active");
|
|
40
42
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Defines the scenario used in data validation.
|
|
3
|
+
*/
|
|
4
|
+
export declare const Scenario: Readonly<{
|
|
5
|
+
/**
|
|
6
|
+
* A scenario in which the underlying model is created.
|
|
7
|
+
*/
|
|
8
|
+
Creation: "Creation";
|
|
9
|
+
/**
|
|
10
|
+
* A scenario in which the underlying model is updated.
|
|
11
|
+
*/
|
|
12
|
+
Update: "Update";
|
|
13
|
+
}>;
|
|
14
|
+
/**
|
|
15
|
+
* Defines the scenario used in data validation.
|
|
16
|
+
*/
|
|
17
|
+
export type Scenario = typeof Scenario[keyof typeof Scenario];
|
|
18
|
+
//# sourceMappingURL=Scenario.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Scenario.d.ts","sourceRoot":"","sources":["../Sources/Client/Scenario.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,QAAQ;IAEpB;;OAEG;;IAGH;;OAEG;;EAEF,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,QAAQ,GAAG,OAAO,QAAQ,CAAC,MAAM,OAAO,QAAQ,CAAC,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Defines the scenario used in data validation.
|
|
3
|
+
*/
|
|
4
|
+
export const Scenario = Object.freeze({
|
|
5
|
+
/**
|
|
6
|
+
* A scenario in which the underlying model is created.
|
|
7
|
+
*/
|
|
8
|
+
Creation: "Creation",
|
|
9
|
+
/**
|
|
10
|
+
* A scenario in which the underlying model is updated.
|
|
11
|
+
*/
|
|
12
|
+
Update: "Update"
|
|
13
|
+
});
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Specifies the direction of a sorted property.
|
|
3
|
+
*/
|
|
4
|
+
export declare const SortDirection: Readonly<{
|
|
5
|
+
/**
|
|
6
|
+
* The sort is ascending.
|
|
7
|
+
*/
|
|
8
|
+
Ascending: "Ascending";
|
|
9
|
+
/**
|
|
10
|
+
* The sort is descending.
|
|
11
|
+
*/
|
|
12
|
+
Descending: "Descending";
|
|
13
|
+
}>;
|
|
14
|
+
/**
|
|
15
|
+
* Specifies the direction of a sorted property.
|
|
16
|
+
*/
|
|
17
|
+
export type SortDirection = typeof SortDirection[keyof typeof SortDirection];
|
|
18
|
+
/**
|
|
19
|
+
* Holds the name of a property and the direction to sort by.
|
|
20
|
+
*/
|
|
21
|
+
export type SortedProperty = [string, SortDirection];
|
|
22
|
+
/**
|
|
23
|
+
* Represents information relevant to the sorting of data items.
|
|
24
|
+
*/
|
|
25
|
+
export declare class Sort implements Iterable<SortedProperty> {
|
|
26
|
+
#private;
|
|
27
|
+
/**
|
|
28
|
+
* Creates new sort.
|
|
29
|
+
* @param properties The list of properties to be sorted.
|
|
30
|
+
*/
|
|
31
|
+
constructor(properties?: SortedProperty[]);
|
|
32
|
+
/**
|
|
33
|
+
* The list of sort properties.
|
|
34
|
+
*/
|
|
35
|
+
get keys(): string[];
|
|
36
|
+
/**
|
|
37
|
+
* The number of properties in this sort.
|
|
38
|
+
*/
|
|
39
|
+
get length(): number;
|
|
40
|
+
/**
|
|
41
|
+
* Creates a new sort from the specified property and direction.
|
|
42
|
+
* @param property The property name.
|
|
43
|
+
* @param direction The sort direction.
|
|
44
|
+
* @returns The sort corresponding to the property and direction.
|
|
45
|
+
*/
|
|
46
|
+
static of(property: string, direction?: SortDirection): Sort;
|
|
47
|
+
/**
|
|
48
|
+
* Creates a new sort from the specified string.
|
|
49
|
+
* @param value A string representing a sort.
|
|
50
|
+
* @returns The sort corresponding to the specified string.
|
|
51
|
+
*/
|
|
52
|
+
static parse(value: string): Sort;
|
|
53
|
+
/**
|
|
54
|
+
* Returns a new iterator that allows iterating the entries of this sort.
|
|
55
|
+
* @returns An iterator over the sort properties.
|
|
56
|
+
*/
|
|
57
|
+
[Symbol.iterator](): Iterator<SortedProperty>;
|
|
58
|
+
/**
|
|
59
|
+
* Appends the specified property to this sort.
|
|
60
|
+
* @param property The property name.
|
|
61
|
+
* @param direction The sort direction.
|
|
62
|
+
* @throws `Error` when a property with the same name already exists.
|
|
63
|
+
*/
|
|
64
|
+
add(property: string, direction: SortDirection): void;
|
|
65
|
+
/**
|
|
66
|
+
* Removes all properties from this sort.
|
|
67
|
+
*/
|
|
68
|
+
clear(): void;
|
|
69
|
+
/**
|
|
70
|
+
* Compares the specified objects, according to the current sort properties.
|
|
71
|
+
* @param x The first object to compare.
|
|
72
|
+
* @param y The second object to compare.
|
|
73
|
+
* @returns A value indicating the relationship between the two objects.
|
|
74
|
+
*/
|
|
75
|
+
compare(x: object, y: object): number;
|
|
76
|
+
/**
|
|
77
|
+
* Returns a value indicating whether the specified property exists in this sort.
|
|
78
|
+
* @param property The property name.
|
|
79
|
+
* @returns `true` if the specified property exists in this sort, otherwise `false`.
|
|
80
|
+
*/
|
|
81
|
+
containsKey(property: string): boolean;
|
|
82
|
+
/**
|
|
83
|
+
* Gets the direction associated with the specified property.
|
|
84
|
+
* @param property The property name.
|
|
85
|
+
* @returns The direction associated with the specified property, or `null` if the property doesn't exist.
|
|
86
|
+
*/
|
|
87
|
+
get(property: string): SortDirection | null;
|
|
88
|
+
/**
|
|
89
|
+
* Gets the sorted property at the specified index.
|
|
90
|
+
* @param index The position in this sort.
|
|
91
|
+
* @returns The sorted property at the specified index, or `null` if it doesn't exist.
|
|
92
|
+
*/
|
|
93
|
+
getAt(index: number): SortedProperty | null;
|
|
94
|
+
/**
|
|
95
|
+
* Gets the icon corresponding to the specified property.
|
|
96
|
+
* @param property The property name.
|
|
97
|
+
* @returns The icon corresponding to the specified property.
|
|
98
|
+
*/
|
|
99
|
+
getIcon(property: string): string;
|
|
100
|
+
/**
|
|
101
|
+
* Gets the index of the specified property in the underlying list.
|
|
102
|
+
* @param property The property name.
|
|
103
|
+
* @returns The index of the specified property, or `-1` if the property is not found.
|
|
104
|
+
*/
|
|
105
|
+
indexOf(property: string): number;
|
|
106
|
+
/**
|
|
107
|
+
* Inserts the specified property into this sort at the specified index.
|
|
108
|
+
* @param index The position in this sort.
|
|
109
|
+
* @param property The property name.
|
|
110
|
+
* @param direction The sort direction.
|
|
111
|
+
*/
|
|
112
|
+
insert(index: number, property: string, direction: SortDirection): void;
|
|
113
|
+
/**
|
|
114
|
+
* Removes the specified property from this sort.
|
|
115
|
+
* @param property The property name.
|
|
116
|
+
*/
|
|
117
|
+
remove(property: string): void;
|
|
118
|
+
/**
|
|
119
|
+
* Removes the sorted property at the specified index.
|
|
120
|
+
* @param index The position in this sort.
|
|
121
|
+
*/
|
|
122
|
+
removeAt(index: number): void;
|
|
123
|
+
/**
|
|
124
|
+
* Sets the direction of the specified property.
|
|
125
|
+
* @param property The property name.
|
|
126
|
+
* @param direction The sort direction.
|
|
127
|
+
*/
|
|
128
|
+
set(property: string, direction: SortDirection): void;
|
|
129
|
+
/**
|
|
130
|
+
* Sets the sorted property at the specified index.
|
|
131
|
+
* @param index The position in this sort.
|
|
132
|
+
* @param property The property name.
|
|
133
|
+
* @param direction The sort direction.
|
|
134
|
+
* @throws `Error` when a property with the same name already exists at a different index.
|
|
135
|
+
*/
|
|
136
|
+
setAt(index: number, property: string, direction: SortDirection): void;
|
|
137
|
+
/**
|
|
138
|
+
* Returns a JSON representation of this object.
|
|
139
|
+
* @returns The JSON representation of this object.
|
|
140
|
+
*/
|
|
141
|
+
toJSON(): string;
|
|
142
|
+
/**
|
|
143
|
+
* Returns a string representation of this object.
|
|
144
|
+
* @returns The string representation of this object.
|
|
145
|
+
*/
|
|
146
|
+
toString(): string;
|
|
147
|
+
}
|
|
148
|
+
//# sourceMappingURL=Sort.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Sort.d.ts","sourceRoot":"","sources":["../Sources/Client/Sort.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,aAAa;IAEzB;;OAEG;;IAGH;;OAEG;;EAEF,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,OAAO,aAAa,CAAC,MAAM,OAAO,aAAa,CAAC,CAAC;AAE7E;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;AAErD;;GAEG;AACH,qBAAa,IAAK,YAAW,QAAQ,CAAC,cAAc,CAAC;;IAOpD;;;OAGG;gBACS,UAAU,GAAE,cAAc,EAAO;IAI7C;;OAEG;IACH,IAAI,IAAI,IAAI,MAAM,EAAE,CAEnB;IAED;;OAEG;IACH,IAAI,MAAM,IAAI,MAAM,CAEnB;IAED;;;;;OAKG;IACH,MAAM,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,GAAE,aAAuC,GAAG,IAAI;IAIrF;;;;OAIG;IACH,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAOjC;;;OAGG;IACH,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,QAAQ,CAAC,cAAc,CAAC;IAI7C;;;;;OAKG;IACH,GAAG,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,aAAa,GAAG,IAAI;IAKrD;;OAEG;IACH,KAAK,IAAI,IAAI;IAIb;;;;;OAKG;IACH,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM;IAWrC;;;;OAIG;IACH,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO;IAItC;;;;OAIG;IACH,GAAG,CAAC,QAAQ,EAAE,MAAM,GAAG,aAAa,GAAC,IAAI;IAKzC;;;;OAIG;IACH,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,cAAc,GAAC,IAAI;IAIzC;;;;OAIG;IACH,OAAO,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM;IAQjC;;;;OAIG;IACH,OAAO,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM;IAKjC;;;;;OAKG;IACH,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,aAAa,GAAG,IAAI;IAIvE;;;OAGG;IACH,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IAI9B;;;OAGG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAI7B;;;;OAIG;IACH,GAAG,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,aAAa,GAAG,IAAI;IASrD;;;;;;OAMG;IACH,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,aAAa,GAAG,IAAI;IAMtE;;;OAGG;IACH,MAAM,IAAI,MAAM;IAIhB;;;OAGG;IACH,QAAQ,IAAI,MAAM;CAGlB"}
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Specifies the direction of a sorted property.
|
|
3
|
+
*/
|
|
4
|
+
export const SortDirection = Object.freeze({
|
|
5
|
+
/**
|
|
6
|
+
* The sort is ascending.
|
|
7
|
+
*/
|
|
8
|
+
Ascending: "Ascending",
|
|
9
|
+
/**
|
|
10
|
+
* The sort is descending.
|
|
11
|
+
*/
|
|
12
|
+
Descending: "Descending"
|
|
13
|
+
});
|
|
14
|
+
/**
|
|
15
|
+
* Represents information relevant to the sorting of data items.
|
|
16
|
+
*/
|
|
17
|
+
export class Sort {
|
|
18
|
+
/**
|
|
19
|
+
* The list of sort properties.
|
|
20
|
+
*/
|
|
21
|
+
#properties;
|
|
22
|
+
/**
|
|
23
|
+
* Creates new sort.
|
|
24
|
+
* @param properties The list of properties to be sorted.
|
|
25
|
+
*/
|
|
26
|
+
constructor(properties = []) {
|
|
27
|
+
this.#properties = properties;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* The list of sort properties.
|
|
31
|
+
*/
|
|
32
|
+
get keys() {
|
|
33
|
+
return this.#properties.map(item => item[0]);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* The number of properties in this sort.
|
|
37
|
+
*/
|
|
38
|
+
get length() {
|
|
39
|
+
return this.#properties.length;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Creates a new sort from the specified property and direction.
|
|
43
|
+
* @param property The property name.
|
|
44
|
+
* @param direction The sort direction.
|
|
45
|
+
* @returns The sort corresponding to the property and direction.
|
|
46
|
+
*/
|
|
47
|
+
static of(property, direction = SortDirection.Ascending) {
|
|
48
|
+
return new this([[property, direction]]);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Creates a new sort from the specified string.
|
|
52
|
+
* @param value A string representing a sort.
|
|
53
|
+
* @returns The sort corresponding to the specified string.
|
|
54
|
+
*/
|
|
55
|
+
static parse(value) {
|
|
56
|
+
return new this((value ? value.split(",") : []).map(token => {
|
|
57
|
+
const direction = token.startsWith("-") ? SortDirection.Descending : SortDirection.Ascending;
|
|
58
|
+
return [direction == SortDirection.Ascending ? token : token.slice(1), direction];
|
|
59
|
+
}));
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Returns a new iterator that allows iterating the entries of this sort.
|
|
63
|
+
* @returns An iterator over the sort properties.
|
|
64
|
+
*/
|
|
65
|
+
[Symbol.iterator]() {
|
|
66
|
+
return this.#properties[Symbol.iterator]();
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Appends the specified property to this sort.
|
|
70
|
+
* @param property The property name.
|
|
71
|
+
* @param direction The sort direction.
|
|
72
|
+
* @throws `Error` when a property with the same name already exists.
|
|
73
|
+
*/
|
|
74
|
+
add(property, direction) {
|
|
75
|
+
if (this.containsKey(property))
|
|
76
|
+
throw new Error("A property with the same name already exists.");
|
|
77
|
+
this.#properties.push([property, direction]);
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Removes all properties from this sort.
|
|
81
|
+
*/
|
|
82
|
+
clear() {
|
|
83
|
+
this.#properties = [];
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Compares the specified objects, according to the current sort properties.
|
|
87
|
+
* @param x The first object to compare.
|
|
88
|
+
* @param y The second object to compare.
|
|
89
|
+
* @returns A value indicating the relationship between the two objects.
|
|
90
|
+
*/
|
|
91
|
+
compare(x, y) {
|
|
92
|
+
for (const [property, direction] of this.#properties) {
|
|
93
|
+
const xAttr = Reflect.get(x, property); // eslint-disable-line @typescript-eslint/no-unsafe-assignment
|
|
94
|
+
const yAttr = Reflect.get(y, property); // eslint-disable-line @typescript-eslint/no-unsafe-assignment
|
|
95
|
+
const value = xAttr > yAttr ? 1 : (xAttr < yAttr ? -1 : 0);
|
|
96
|
+
if (value)
|
|
97
|
+
return direction == SortDirection.Ascending ? value : -value;
|
|
98
|
+
}
|
|
99
|
+
return 0;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Returns a value indicating whether the specified property exists in this sort.
|
|
103
|
+
* @param property The property name.
|
|
104
|
+
* @returns `true` if the specified property exists in this sort, otherwise `false`.
|
|
105
|
+
*/
|
|
106
|
+
containsKey(property) {
|
|
107
|
+
return this.#properties.some(([key]) => key == property);
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Gets the direction associated with the specified property.
|
|
111
|
+
* @param property The property name.
|
|
112
|
+
* @returns The direction associated with the specified property, or `null` if the property doesn't exist.
|
|
113
|
+
*/
|
|
114
|
+
get(property) {
|
|
115
|
+
for (const [key, direction] of this.#properties)
|
|
116
|
+
if (key == property)
|
|
117
|
+
return direction;
|
|
118
|
+
return null;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Gets the sorted property at the specified index.
|
|
122
|
+
* @param index The position in this sort.
|
|
123
|
+
* @returns The sorted property at the specified index, or `null` if it doesn't exist.
|
|
124
|
+
*/
|
|
125
|
+
getAt(index) {
|
|
126
|
+
return this.#properties.at(index) ?? null;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Gets the icon corresponding to the specified property.
|
|
130
|
+
* @param property The property name.
|
|
131
|
+
* @returns The icon corresponding to the specified property.
|
|
132
|
+
*/
|
|
133
|
+
getIcon(property) {
|
|
134
|
+
switch (this.get(property)) {
|
|
135
|
+
case SortDirection.Ascending: return "arrow_upward";
|
|
136
|
+
case SortDirection.Descending: return "arrow_downward";
|
|
137
|
+
default: return "swap_vert";
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Gets the index of the specified property in the underlying list.
|
|
142
|
+
* @param property The property name.
|
|
143
|
+
* @returns The index of the specified property, or `-1` if the property is not found.
|
|
144
|
+
*/
|
|
145
|
+
indexOf(property) {
|
|
146
|
+
for (const [index, [key]] of this.#properties.entries())
|
|
147
|
+
if (key == property)
|
|
148
|
+
return index;
|
|
149
|
+
return -1;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Inserts the specified property into this sort at the specified index.
|
|
153
|
+
* @param index The position in this sort.
|
|
154
|
+
* @param property The property name.
|
|
155
|
+
* @param direction The sort direction.
|
|
156
|
+
*/
|
|
157
|
+
insert(index, property, direction) {
|
|
158
|
+
this.#properties.splice(index, 0, [property, direction]);
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Removes the specified property from this sort.
|
|
162
|
+
* @param property The property name.
|
|
163
|
+
*/
|
|
164
|
+
remove(property) {
|
|
165
|
+
this.#properties = this.#properties.filter(([key]) => key != property);
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Removes the sorted property at the specified index.
|
|
169
|
+
* @param index The position in this sort.
|
|
170
|
+
*/
|
|
171
|
+
removeAt(index) {
|
|
172
|
+
this.#properties.splice(index, 1);
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Sets the direction of the specified property.
|
|
176
|
+
* @param property The property name.
|
|
177
|
+
* @param direction The sort direction.
|
|
178
|
+
*/
|
|
179
|
+
set(property, direction) {
|
|
180
|
+
for (const [index, [key]] of this.#properties.entries())
|
|
181
|
+
if (key == property) {
|
|
182
|
+
this.#properties[index] = [key, direction];
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
this.add(property, direction);
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Sets the sorted property at the specified index.
|
|
189
|
+
* @param index The position in this sort.
|
|
190
|
+
* @param property The property name.
|
|
191
|
+
* @param direction The sort direction.
|
|
192
|
+
* @throws `Error` when a property with the same name already exists at a different index.
|
|
193
|
+
*/
|
|
194
|
+
setAt(index, property, direction) {
|
|
195
|
+
const existingIndex = this.indexOf(property);
|
|
196
|
+
if (existingIndex >= 0 && existingIndex != index)
|
|
197
|
+
throw new Error("A property with the same name already exists at a different index.");
|
|
198
|
+
this.#properties[index] = [property, direction];
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Returns a JSON representation of this object.
|
|
202
|
+
* @returns The JSON representation of this object.
|
|
203
|
+
*/
|
|
204
|
+
toJSON() {
|
|
205
|
+
return this.toString();
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Returns a string representation of this object.
|
|
209
|
+
* @returns The string representation of this object.
|
|
210
|
+
*/
|
|
211
|
+
toString() {
|
|
212
|
+
return this.#properties.map(([property, direction]) => `${direction == SortDirection.Descending ? "-" : ""}${property}`).join(",");
|
|
213
|
+
}
|
|
214
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import {Popover, Tooltip} from "bootstrap";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Disposes all popovers attached to the specified element.
|
|
5
|
+
* @param element The source element.
|
|
6
|
+
*/
|
|
7
|
+
export function disposePopovers(element: Element): void {
|
|
8
|
+
for (const node of element.querySelectorAll('[data-bs-toggle="popover"]')) Popover.getInstance(node)?.dispose();
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Disposes all tooltips attached to the specified element.
|
|
13
|
+
* @param element The source element.
|
|
14
|
+
*/
|
|
15
|
+
export function disposeTooltips(element: Element): void {
|
|
16
|
+
for (const node of element.querySelectorAll('[data-bs-toggle="tooltip"]')) Tooltip.getInstance(node)?.dispose();
|
|
17
|
+
}
|
|
@@ -37,7 +37,10 @@ export class MenuActivator extends HTMLElement {
|
|
|
37
37
|
*/
|
|
38
38
|
#update(): void {
|
|
39
39
|
for (const element of this.querySelectorAll(".active")) element.classList.remove("active");
|
|
40
|
-
|
|
40
|
+
|
|
41
|
+
const {origin, pathname} = new URL(location.href);
|
|
42
|
+
const href = `${origin}${pathname}`;
|
|
43
|
+
for (const anchor of this.querySelectorAll("a")) if (anchor.href == href) {
|
|
41
44
|
anchor.classList.add("active");
|
|
42
45
|
anchor.closest(".dropdown")?.querySelector(".dropdown-toggle")?.classList.add("active");
|
|
43
46
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Defines the scenario used in data validation.
|
|
3
|
+
*/
|
|
4
|
+
export const Scenario = Object.freeze({
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A scenario in which the underlying model is created.
|
|
8
|
+
*/
|
|
9
|
+
Creation: "Creation",
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* A scenario in which the underlying model is updated.
|
|
13
|
+
*/
|
|
14
|
+
Update: "Update"
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Defines the scenario used in data validation.
|
|
19
|
+
*/
|
|
20
|
+
export type Scenario = typeof Scenario[keyof typeof Scenario];
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Specifies the direction of a sorted property.
|
|
3
|
+
*/
|
|
4
|
+
export const SortDirection = Object.freeze({
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The sort is ascending.
|
|
8
|
+
*/
|
|
9
|
+
Ascending: "Ascending",
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* The sort is descending.
|
|
13
|
+
*/
|
|
14
|
+
Descending: "Descending"
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Specifies the direction of a sorted property.
|
|
19
|
+
*/
|
|
20
|
+
export type SortDirection = typeof SortDirection[keyof typeof SortDirection];
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Holds the name of a property and the direction to sort by.
|
|
24
|
+
*/
|
|
25
|
+
export type SortedProperty = [string, SortDirection];
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Represents information relevant to the sorting of data items.
|
|
29
|
+
*/
|
|
30
|
+
export class Sort implements Iterable<SortedProperty> {
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* The list of sort properties.
|
|
34
|
+
*/
|
|
35
|
+
#properties: SortedProperty[];
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Creates new sort.
|
|
39
|
+
* @param properties The list of properties to be sorted.
|
|
40
|
+
*/
|
|
41
|
+
constructor(properties: SortedProperty[] = []) {
|
|
42
|
+
this.#properties = properties;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* The list of sort properties.
|
|
47
|
+
*/
|
|
48
|
+
get keys(): string[] {
|
|
49
|
+
return this.#properties.map(item => item[0]);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* The number of properties in this sort.
|
|
54
|
+
*/
|
|
55
|
+
get length(): number {
|
|
56
|
+
return this.#properties.length;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Creates a new sort from the specified property and direction.
|
|
61
|
+
* @param property The property name.
|
|
62
|
+
* @param direction The sort direction.
|
|
63
|
+
* @returns The sort corresponding to the property and direction.
|
|
64
|
+
*/
|
|
65
|
+
static of(property: string, direction: SortDirection = SortDirection.Ascending): Sort {
|
|
66
|
+
return new this([[property, direction]]);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Creates a new sort from the specified string.
|
|
71
|
+
* @param value A string representing a sort.
|
|
72
|
+
* @returns The sort corresponding to the specified string.
|
|
73
|
+
*/
|
|
74
|
+
static parse(value: string): Sort {
|
|
75
|
+
return new this((value ? value.split(",") : []).map(token => {
|
|
76
|
+
const direction = token.startsWith("-") ? SortDirection.Descending : SortDirection.Ascending;
|
|
77
|
+
return [direction == SortDirection.Ascending ? token : token.slice(1), direction];
|
|
78
|
+
}));
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Returns a new iterator that allows iterating the entries of this sort.
|
|
83
|
+
* @returns An iterator over the sort properties.
|
|
84
|
+
*/
|
|
85
|
+
[Symbol.iterator](): Iterator<SortedProperty> {
|
|
86
|
+
return this.#properties[Symbol.iterator]();
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Appends the specified property to this sort.
|
|
91
|
+
* @param property The property name.
|
|
92
|
+
* @param direction The sort direction.
|
|
93
|
+
* @throws `Error` when a property with the same name already exists.
|
|
94
|
+
*/
|
|
95
|
+
add(property: string, direction: SortDirection): void {
|
|
96
|
+
if (this.containsKey(property)) throw new Error("A property with the same name already exists.");
|
|
97
|
+
this.#properties.push([property, direction]);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Removes all properties from this sort.
|
|
102
|
+
*/
|
|
103
|
+
clear(): void {
|
|
104
|
+
this.#properties = [];
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Compares the specified objects, according to the current sort properties.
|
|
109
|
+
* @param x The first object to compare.
|
|
110
|
+
* @param y The second object to compare.
|
|
111
|
+
* @returns A value indicating the relationship between the two objects.
|
|
112
|
+
*/
|
|
113
|
+
compare(x: object, y: object): number {
|
|
114
|
+
for (const [property, direction] of this.#properties) {
|
|
115
|
+
const xAttr = Reflect.get(x, property); // eslint-disable-line @typescript-eslint/no-unsafe-assignment
|
|
116
|
+
const yAttr = Reflect.get(y, property); // eslint-disable-line @typescript-eslint/no-unsafe-assignment
|
|
117
|
+
const value = xAttr > yAttr ? 1 : (xAttr < yAttr ? -1 : 0);
|
|
118
|
+
if (value) return direction == SortDirection.Ascending ? value : -value;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
return 0;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Returns a value indicating whether the specified property exists in this sort.
|
|
126
|
+
* @param property The property name.
|
|
127
|
+
* @returns `true` if the specified property exists in this sort, otherwise `false`.
|
|
128
|
+
*/
|
|
129
|
+
containsKey(property: string): boolean {
|
|
130
|
+
return this.#properties.some(([key]) => key == property);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Gets the direction associated with the specified property.
|
|
135
|
+
* @param property The property name.
|
|
136
|
+
* @returns The direction associated with the specified property, or `null` if the property doesn't exist.
|
|
137
|
+
*/
|
|
138
|
+
get(property: string): SortDirection|null {
|
|
139
|
+
for (const [key, direction] of this.#properties) if (key == property) return direction;
|
|
140
|
+
return null;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Gets the sorted property at the specified index.
|
|
145
|
+
* @param index The position in this sort.
|
|
146
|
+
* @returns The sorted property at the specified index, or `null` if it doesn't exist.
|
|
147
|
+
*/
|
|
148
|
+
getAt(index: number): SortedProperty|null {
|
|
149
|
+
return this.#properties.at(index) ?? null;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Gets the icon corresponding to the specified property.
|
|
154
|
+
* @param property The property name.
|
|
155
|
+
* @returns The icon corresponding to the specified property.
|
|
156
|
+
*/
|
|
157
|
+
getIcon(property: string): string {
|
|
158
|
+
switch (this.get(property)) {
|
|
159
|
+
case SortDirection.Ascending: return "arrow_upward";
|
|
160
|
+
case SortDirection.Descending: return "arrow_downward";
|
|
161
|
+
default: return "swap_vert";
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Gets the index of the specified property in the underlying list.
|
|
167
|
+
* @param property The property name.
|
|
168
|
+
* @returns The index of the specified property, or `-1` if the property is not found.
|
|
169
|
+
*/
|
|
170
|
+
indexOf(property: string): number {
|
|
171
|
+
for (const [index, [key]] of this.#properties.entries()) if (key == property) return index;
|
|
172
|
+
return -1;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Inserts the specified property into this sort at the specified index.
|
|
177
|
+
* @param index The position in this sort.
|
|
178
|
+
* @param property The property name.
|
|
179
|
+
* @param direction The sort direction.
|
|
180
|
+
*/
|
|
181
|
+
insert(index: number, property: string, direction: SortDirection): void {
|
|
182
|
+
this.#properties.splice(index, 0, [property, direction]);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Removes the specified property from this sort.
|
|
187
|
+
* @param property The property name.
|
|
188
|
+
*/
|
|
189
|
+
remove(property: string): void {
|
|
190
|
+
this.#properties = this.#properties.filter(([key]) => key != property);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Removes the sorted property at the specified index.
|
|
195
|
+
* @param index The position in this sort.
|
|
196
|
+
*/
|
|
197
|
+
removeAt(index: number): void {
|
|
198
|
+
this.#properties.splice(index, 1);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Sets the direction of the specified property.
|
|
203
|
+
* @param property The property name.
|
|
204
|
+
* @param direction The sort direction.
|
|
205
|
+
*/
|
|
206
|
+
set(property: string, direction: SortDirection): void {
|
|
207
|
+
for (const [index, [key]] of this.#properties.entries()) if (key == property) {
|
|
208
|
+
this.#properties[index] = [key, direction];
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
this.add(property, direction);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* Sets the sorted property at the specified index.
|
|
217
|
+
* @param index The position in this sort.
|
|
218
|
+
* @param property The property name.
|
|
219
|
+
* @param direction The sort direction.
|
|
220
|
+
* @throws `Error` when a property with the same name already exists at a different index.
|
|
221
|
+
*/
|
|
222
|
+
setAt(index: number, property: string, direction: SortDirection): void {
|
|
223
|
+
const existingIndex = this.indexOf(property);
|
|
224
|
+
if (existingIndex >= 0 && existingIndex != index) throw new Error("A property with the same name already exists at a different index.");
|
|
225
|
+
this.#properties[index] = [property, direction];
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Returns a JSON representation of this object.
|
|
230
|
+
* @returns The JSON representation of this object.
|
|
231
|
+
*/
|
|
232
|
+
toJSON(): string {
|
|
233
|
+
return this.toString();
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* Returns a string representation of this object.
|
|
238
|
+
* @returns The string representation of this object.
|
|
239
|
+
*/
|
|
240
|
+
toString(): string {
|
|
241
|
+
return this.#properties.map(([property, direction]) => `${direction == SortDirection.Descending ? "-" : ""}${property}`).join(",");
|
|
242
|
+
}
|
|
243
|
+
}
|