@cedx/ui 0.8.0 → 0.10.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.
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Represents information relevant to the pagination of data items.
3
+ */
4
+ export declare class Pagination {
5
+ #private;
6
+ /**
7
+ * Creates a new pagination.
8
+ * @param options An object providing values to initialize this instance.
9
+ */
10
+ constructor(options?: PaginationOptions);
11
+ /**
12
+ * The current page index.
13
+ */
14
+ get currentPageIndex(): number;
15
+ set currentPageIndex(value: number);
16
+ /**
17
+ * Value indicating whether a next page exists.
18
+ */
19
+ get hasNextPage(): boolean;
20
+ /**
21
+ * Value indicating whether a previous page exists.
22
+ */
23
+ get hasPreviousPage(): boolean;
24
+ /**
25
+ * The number of items per page.
26
+ */
27
+ get itemsPerPage(): number;
28
+ set itemsPerPage(value: number);
29
+ /**
30
+ * The last page index.
31
+ */
32
+ get lastPageIndex(): number;
33
+ /**
34
+ * The data limit.
35
+ */
36
+ get limit(): number;
37
+ /**
38
+ * The data offset.
39
+ */
40
+ get offset(): number;
41
+ /**
42
+ * The total number of items.
43
+ */
44
+ get totalItemCount(): number;
45
+ set totalItemCount(value: number);
46
+ }
47
+ /**
48
+ * Defines the options of a {@link Pagination} instance.
49
+ */
50
+ export type PaginationOptions = Partial<{
51
+ /**
52
+ * The current page index.
53
+ */
54
+ currentPageIndex: number;
55
+ /**
56
+ * The number of items per page.
57
+ */
58
+ itemsPerPage: number;
59
+ /**
60
+ * The total number of items.
61
+ */
62
+ totalItemCount: number;
63
+ }>;
64
+ //# sourceMappingURL=Pagination.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Pagination.d.ts","sourceRoot":"","sources":["../Sources/Client/Pagination.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,UAAU;;IAiBtB;;;OAGG;gBACS,OAAO,GAAE,iBAAsB;IAM3C;;OAEG;IACH,IAAI,gBAAgB,IAAI,MAAM,CAE7B;IACD,IAAI,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAEjC;IAED;;OAEG;IACH,IAAI,WAAW,IAAI,OAAO,CAEzB;IAED;;OAEG;IACH,IAAI,eAAe,IAAI,OAAO,CAE7B;IAED;;OAEG;IACH,IAAI,YAAY,IAAI,MAAM,CAEzB;IACD,IAAI,YAAY,CAAC,KAAK,EAAE,MAAM,EAE7B;IAED;;OAEG;IACH,IAAI,aAAa,IAAI,MAAM,CAE1B;IAED;;OAEG;IACH,IAAI,KAAK,IAAI,MAAM,CAElB;IAED;;OAEG;IACH,IAAI,MAAM,IAAI,MAAM,CAEnB;IAED;;OAEG;IACH,IAAI,cAAc,IAAI,MAAM,CAE3B;IACD,IAAI,cAAc,CAAC,KAAK,EAAE,MAAM,EAE/B;CACD;AAED;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG,OAAO,CAAC;IAEvC;;OAEG;IACH,gBAAgB,EAAE,MAAM,CAAC;IAEzB;;OAEG;IACH,YAAY,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,cAAc,EAAE,MAAM,CAAC;CACvB,CAAC,CAAC"}
@@ -0,0 +1,83 @@
1
+ /**
2
+ * Represents information relevant to the pagination of data items.
3
+ */
4
+ export class Pagination {
5
+ /**
6
+ * The current page index.
7
+ */
8
+ #currentPageIndex;
9
+ /**
10
+ * The number of items per page.
11
+ */
12
+ #itemsPerPage;
13
+ /**
14
+ * The total number of items.
15
+ */
16
+ #totalItemCount;
17
+ /**
18
+ * Creates a new pagination.
19
+ * @param options An object providing values to initialize this instance.
20
+ */
21
+ constructor(options = {}) {
22
+ this.currentPageIndex = options.currentPageIndex ?? 0;
23
+ this.itemsPerPage = options.itemsPerPage ?? 25;
24
+ this.totalItemCount = options.totalItemCount ?? 0;
25
+ }
26
+ /**
27
+ * The current page index.
28
+ */
29
+ get currentPageIndex() {
30
+ return this.#currentPageIndex;
31
+ }
32
+ set currentPageIndex(value) {
33
+ this.#currentPageIndex = Math.max(0, value);
34
+ }
35
+ /**
36
+ * Value indicating whether a next page exists.
37
+ */
38
+ get hasNextPage() {
39
+ return this.#currentPageIndex < this.lastPageIndex;
40
+ }
41
+ /**
42
+ * Value indicating whether a previous page exists.
43
+ */
44
+ get hasPreviousPage() {
45
+ return this.#currentPageIndex > 0;
46
+ }
47
+ /**
48
+ * The number of items per page.
49
+ */
50
+ get itemsPerPage() {
51
+ return this.#itemsPerPage;
52
+ }
53
+ set itemsPerPage(value) {
54
+ this.#itemsPerPage = Math.max(1, Math.min(1000, value));
55
+ }
56
+ /**
57
+ * The last page index.
58
+ */
59
+ get lastPageIndex() {
60
+ return this.#totalItemCount > 0 ? Math.ceil(this.#totalItemCount / this.#itemsPerPage) - 1 : 0;
61
+ }
62
+ /**
63
+ * The data limit.
64
+ */
65
+ get limit() {
66
+ return this.#itemsPerPage;
67
+ }
68
+ /**
69
+ * The data offset.
70
+ */
71
+ get offset() {
72
+ return this.#currentPageIndex * this.#itemsPerPage;
73
+ }
74
+ /**
75
+ * The total number of items.
76
+ */
77
+ get totalItemCount() {
78
+ return this.#totalItemCount;
79
+ }
80
+ set totalItemCount(value) {
81
+ this.#totalItemCount = Math.max(0, value);
82
+ }
83
+ }
@@ -0,0 +1,116 @@
1
+ /**
2
+ * Represents information relevant to the pagination of data items.
3
+ */
4
+ export class Pagination {
5
+
6
+ /**
7
+ * The current page index.
8
+ */
9
+ #currentPageIndex!: number;
10
+
11
+ /**
12
+ * The number of items per page.
13
+ */
14
+ #itemsPerPage!: number;
15
+
16
+ /**
17
+ * The total number of items.
18
+ */
19
+ #totalItemCount!: number;
20
+
21
+ /**
22
+ * Creates a new pagination.
23
+ * @param options An object providing values to initialize this instance.
24
+ */
25
+ constructor(options: PaginationOptions = {}) {
26
+ this.currentPageIndex = options.currentPageIndex ?? 0;
27
+ this.itemsPerPage = options.itemsPerPage ?? 25;
28
+ this.totalItemCount = options.totalItemCount ?? 0;
29
+ }
30
+
31
+ /**
32
+ * The current page index.
33
+ */
34
+ get currentPageIndex(): number {
35
+ return this.#currentPageIndex;
36
+ }
37
+ set currentPageIndex(value: number) {
38
+ this.#currentPageIndex = Math.max(0, value);
39
+ }
40
+
41
+ /**
42
+ * Value indicating whether a next page exists.
43
+ */
44
+ get hasNextPage(): boolean {
45
+ return this.#currentPageIndex < this.lastPageIndex;
46
+ }
47
+
48
+ /**
49
+ * Value indicating whether a previous page exists.
50
+ */
51
+ get hasPreviousPage(): boolean {
52
+ return this.#currentPageIndex > 0;
53
+ }
54
+
55
+ /**
56
+ * The number of items per page.
57
+ */
58
+ get itemsPerPage(): number {
59
+ return this.#itemsPerPage;
60
+ }
61
+ set itemsPerPage(value: number) {
62
+ this.#itemsPerPage = Math.max(1, Math.min(1000, value));
63
+ }
64
+
65
+ /**
66
+ * The last page index.
67
+ */
68
+ get lastPageIndex(): number {
69
+ return this.#totalItemCount > 0 ? Math.ceil(this.#totalItemCount / this.#itemsPerPage) - 1 : 0;
70
+ }
71
+
72
+ /**
73
+ * The data limit.
74
+ */
75
+ get limit(): number {
76
+ return this.#itemsPerPage;
77
+ }
78
+
79
+ /**
80
+ * The data offset.
81
+ */
82
+ get offset(): number {
83
+ return this.#currentPageIndex * this.#itemsPerPage;
84
+ }
85
+
86
+ /**
87
+ * The total number of items.
88
+ */
89
+ get totalItemCount(): number {
90
+ return this.#totalItemCount;
91
+ }
92
+ set totalItemCount(value: number) {
93
+ this.#totalItemCount = Math.max(0, value);
94
+ }
95
+ }
96
+
97
+ /**
98
+ * Defines the options of a {@link Pagination} instance.
99
+ */
100
+ export type PaginationOptions = Partial<{
101
+
102
+ /**
103
+ * The current page index.
104
+ */
105
+ currentPageIndex: number;
106
+
107
+ /**
108
+ * The number of items per page.
109
+ */
110
+ itemsPerPage: number;
111
+
112
+ /**
113
+ * The total number of items.
114
+ */
115
+ totalItemCount: number;
116
+ }>;
package/package.json CHANGED
@@ -7,7 +7,7 @@
7
7
  "name": "@cedx/ui",
8
8
  "repository": "CedX/UI",
9
9
  "type": "module",
10
- "version": "0.8.0",
10
+ "version": "0.10.0",
11
11
  "allowScripts": {
12
12
  "esbuild": true,
13
13
  "playwright-firefox": true
@@ -17,7 +17,7 @@
17
17
  "@types/bootstrap": "^5.2.11",
18
18
  "@types/chai": "^5.2.3",
19
19
  "@types/mocha": "^10.0.10",
20
- "@types/node": "^25.9.3",
20
+ "@types/node": "^26.0.0",
21
21
  "@types/serve-handler": "^6.1.4",
22
22
  "bootstrap": "^5.3.8",
23
23
  "chai": "^6.2.2",