@pallasoft/ps-table-components 1.26.0 → 1.27.1
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/dist/components/ps-data-table.d.ts +9 -1
- package/dist/components/ps-data-table.js +81 -12
- package/dist/components/ps-select-all-matching-banner.d.ts +10 -0
- package/dist/components/ps-select-all-matching-banner.js +10 -0
- package/dist/components/ps-table-pagination.d.ts +3 -1
- package/dist/components/ps-table-pagination.js +12 -4
- package/dist/constants/ps-server-rows-config.d.ts +8 -0
- package/dist/constants/ps-server-rows-config.js +11 -0
- package/dist/constants/ps-table-pagination-config.d.ts +3 -0
- package/dist/constants/ps-table-pagination-config.js +6 -0
- package/dist/esm/components/ps-data-table.js +82 -13
- package/dist/esm/components/ps-select-all-matching-banner.js +6 -0
- package/dist/esm/components/ps-table-pagination.js +12 -4
- package/dist/esm/constants/ps-server-rows-config.js +8 -0
- package/dist/esm/constants/ps-table-pagination-config.js +3 -0
- package/dist/esm/hooks/use-ps-server-rows.js +209 -0
- package/dist/esm/index.js +11 -0
- package/dist/esm/interfaces/ps-server-entry.js +1 -0
- package/dist/esm/interfaces/ps-server-page.js +1 -0
- package/dist/esm/interfaces/ps-server-rows-input.js +1 -0
- package/dist/esm/interfaces/ps-server-rows-result.js +1 -0
- package/dist/esm/interfaces/ps-table-cursor-paging.js +1 -0
- package/dist/esm/interfaces/ps-table-select-all-matching.js +1 -0
- package/dist/esm/services/ps-server-rows-service.js +36 -0
- package/dist/hooks/use-ps-server-rows.d.ts +3 -0
- package/dist/hooks/use-ps-server-rows.js +213 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +11 -0
- package/dist/interfaces/ps-server-entry.d.ts +6 -0
- package/dist/interfaces/ps-server-entry.js +2 -0
- package/dist/interfaces/ps-server-page.d.ts +7 -0
- package/dist/interfaces/ps-server-page.js +2 -0
- package/dist/interfaces/ps-server-rows-input.d.ts +13 -0
- package/dist/interfaces/ps-server-rows-input.js +2 -0
- package/dist/interfaces/ps-server-rows-result.d.ts +18 -0
- package/dist/interfaces/ps-server-rows-result.js +2 -0
- package/dist/interfaces/ps-table-cursor-paging.d.ts +12 -0
- package/dist/interfaces/ps-table-cursor-paging.js +2 -0
- package/dist/interfaces/ps-table-select-all-matching.d.ts +7 -0
- package/dist/interfaces/ps-table-select-all-matching.js +2 -0
- package/dist/services/ps-server-rows-service.d.ts +11 -0
- package/dist/services/ps-server-rows-service.js +40 -0
- package/package.json +1 -1
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PsServerRowsService = void 0;
|
|
4
|
+
const ps_server_rows_config_1 = require("../constants/ps-server-rows-config");
|
|
5
|
+
const ps_table_query_service_1 = require("./ps-table-query-service");
|
|
6
|
+
class PsServerRowsService {
|
|
7
|
+
static queryKey(query, search, pageSize) {
|
|
8
|
+
const filters = Object.entries(query.filters)
|
|
9
|
+
.filter(([, value]) => ps_table_query_service_1.PsTableQueryService.isActive(value))
|
|
10
|
+
.sort(([left], [right]) => left.localeCompare(right));
|
|
11
|
+
return JSON.stringify([filters, search.trim(), query.sort, pageSize]);
|
|
12
|
+
}
|
|
13
|
+
static cacheKey(queryKey, cursor) {
|
|
14
|
+
return `${queryKey}|${cursor === null ? '' : cursor}`;
|
|
15
|
+
}
|
|
16
|
+
static remember(cache, key, page) {
|
|
17
|
+
cache.delete(key);
|
|
18
|
+
cache.set(key, page);
|
|
19
|
+
for (const oldest of cache.keys()) {
|
|
20
|
+
if (cache.size <= ps_server_rows_config_1.PsServerRowsConfig.cacheSize)
|
|
21
|
+
return;
|
|
22
|
+
cache.delete(oldest);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
static recall(cache, key) {
|
|
26
|
+
const page = cache.get(key);
|
|
27
|
+
if (page === undefined)
|
|
28
|
+
return undefined;
|
|
29
|
+
cache.delete(key);
|
|
30
|
+
cache.set(key, page);
|
|
31
|
+
return page;
|
|
32
|
+
}
|
|
33
|
+
static preview(rows, columns, query, getSearchText) {
|
|
34
|
+
return ps_table_query_service_1.PsTableQueryService.apply(rows, columns, query.filters, query.search, getSearchText, query.sort);
|
|
35
|
+
}
|
|
36
|
+
static pageCount(total, pageSize) {
|
|
37
|
+
return Math.max(Math.ceil(total / pageSize), 1);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.PsServerRowsService = PsServerRowsService;
|