@cedx/ui 0.12.0 → 0.13.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.
@@ -43,6 +43,13 @@ export declare class Pagination {
43
43
  */
44
44
  get totalItemCount(): number;
45
45
  set totalItemCount(value: number);
46
+ /**
47
+ * Creates a new pagination from the specified query.
48
+ * @param query The search parameters providing the query.
49
+ * @param maxItemsPerPage The maximum number of items allowed per page.
50
+ * @returns The pagination corresponding to the specified query.
51
+ */
52
+ static fromQuery(query: URLSearchParams, maxItemsPerPage?: number): Pagination;
46
53
  }
47
54
  /**
48
55
  * Defines the options of a {@link Pagination} instance.
@@ -1 +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;;O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C,KAAK,EAAE,MAAM,EAE/B;IAED;;;;;OAKG;IACH,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,eAAe,EAAE,eAAe,SAAO,GAAG,UAAU;CAQ5E;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;AAEH;;GAEG;AACH,qBAAa,aAAa,CAAC,CAAC,CAAE,SAAQ,KAAK,CAAC,CAAC,CAAC;IAE7C;;OAEG;IACH,UAAU,EAAE,UAAU,CAAC;IAEvB;;;OAGG;gBACS,OAAO,GAAE,oBAAoB,CAAC,CAAC,CAAM;IAMjD;;;;OAIG;IACH,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,YAAY,EAAE,MAAM,GAAG,aAAa,CAAC,CAAC,CAAC;CAGvD;AAED;;GAEG;AACH,MAAM,MAAM,oBAAoB,CAAC,CAAC,IAAI,OAAO,CAAC;IAE7C;;OAEG;IACH,KAAK,EAAE,CAAC,EAAE,CAAC;IAEX;;OAEG;IACH,UAAU,EAAE,UAAU,CAAC;CACvB,CAAC,CAAC"}
@@ -80,6 +80,20 @@ export class Pagination {
80
80
  set totalItemCount(value) {
81
81
  this.#totalItemCount = Math.max(0, value);
82
82
  }
83
+ /**
84
+ * Creates a new pagination from the specified query.
85
+ * @param query The search parameters providing the query.
86
+ * @param maxItemsPerPage The maximum number of items allowed per page.
87
+ * @returns The pagination corresponding to the specified query.
88
+ */
89
+ static fromQuery(query, maxItemsPerPage = 1000) {
90
+ const currentPage = Number(query.get("Page") ?? "1");
91
+ const itemsPerPage = Number(query.get("PerPage") ?? "25");
92
+ return new this({
93
+ currentPageIndex: (Number.isNaN(currentPage) ? 1 : currentPage) - 1,
94
+ itemsPerPage: Math.min(maxItemsPerPage, Number.isNaN(itemsPerPage) ? 25 : itemsPerPage)
95
+ });
96
+ }
83
97
  }
84
98
  /**
85
99
  * A list with information relevant to the pagination of its items.
@@ -92,6 +92,21 @@ export class Pagination {
92
92
  set totalItemCount(value: number) {
93
93
  this.#totalItemCount = Math.max(0, value);
94
94
  }
95
+
96
+ /**
97
+ * Creates a new pagination from the specified query.
98
+ * @param query The search parameters providing the query.
99
+ * @param maxItemsPerPage The maximum number of items allowed per page.
100
+ * @returns The pagination corresponding to the specified query.
101
+ */
102
+ static fromQuery(query: URLSearchParams, maxItemsPerPage = 1000): Pagination {
103
+ const currentPage = Number(query.get("Page") ?? "1");
104
+ const itemsPerPage = Number(query.get("PerPage") ?? "25");
105
+ return new this({
106
+ currentPageIndex: (Number.isNaN(currentPage) ? 1 : currentPage) - 1,
107
+ itemsPerPage: Math.min(maxItemsPerPage, Number.isNaN(itemsPerPage) ? 25 : itemsPerPage)
108
+ });
109
+ }
95
110
  }
96
111
 
97
112
  /**
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.12.0",
10
+ "version": "0.13.0",
11
11
  "allowScripts": {
12
12
  "esbuild": true,
13
13
  "playwright-firefox": true