@myrmidon/paged-data-browsers 4.0.1 → 5.0.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.
@@ -1,23 +0,0 @@
1
- import * as i0 from "@angular/core";
2
- export declare class RangeViewComponent {
3
- /**
4
- * The domain of the range view (start, limit).
5
- */
6
- domain: import("@angular/core").InputSignal<number[]>;
7
- /**
8
- * The range of the range view (start, limit).
9
- */
10
- range: import("@angular/core").InputSignal<number[]>;
11
- /**
12
- * The width of the component.
13
- */
14
- width: import("@angular/core").InputSignal<number>;
15
- /**
16
- * The height of the component.
17
- */
18
- height: import("@angular/core").InputSignal<number>;
19
- scaledRange: import("@angular/core").Signal<number[]>;
20
- constructor();
21
- static ɵfac: i0.ɵɵFactoryDeclaration<RangeViewComponent, never>;
22
- static ɵcmp: i0.ɵɵComponentDeclaration<RangeViewComponent, "pdb-range-view", never, { "domain": { "alias": "domain"; "required": false; "isSignal": true; }; "range": { "alias": "range"; "required": false; "isSignal": true; }; "width": { "alias": "width"; "required": false; "isSignal": true; }; "height": { "alias": "height"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
23
- }
@@ -1,59 +0,0 @@
1
- /**
2
- * A Least Recently Used cache that can be used to store any type of object.
3
- * The cache works in two modes: considering the size of the objects or not.
4
- * If the size is considered, the cache will have a maximum size and will
5
- * remove the oldest objects when the maximum size is reached. Note that
6
- * the size is only roughly estimated. This avoids removing too many
7
- * entries from the cache when the maximum is reached.
8
- * If the size is not considered, the cache will have a maximum number of
9
- * objects and will remove the oldest objects when the maximum number is
10
- * reached.
11
- */
12
- export declare class LRUCache<T> {
13
- private _maxSize;
14
- private _totalSize;
15
- private _considerSize;
16
- private _cache;
17
- private _sizes;
18
- /**
19
- * Creates a new cache.
20
- * @param maxSize The maximum size of the cache. This is either
21
- * the maximum number of items in the cache (when considerSize
22
- * is false) or the maximum total size of all items in the
23
- * cache in bytes (when considerSize is true).
24
- * @param considerSize True if the size of the objects should be
25
- * considered.
26
- */
27
- constructor(maxSize: number, considerSize?: boolean);
28
- /**
29
- * Get an item from the cache.
30
- * @param key The key of the item to get.
31
- * @returns The item or undefined if the item is not in the cache.
32
- */
33
- get(key: string): T | undefined;
34
- /**
35
- * Check if an item is in the cache.
36
- * @param key The key of the item to check.
37
- * @returns True if the item is in cache.
38
- */
39
- has(key: string): boolean;
40
- /**
41
- * Put an item in the cache.
42
- * @param key The key of the item to put.
43
- * @param item The item to put.
44
- * @param size The estimated size of the item in bytes.
45
- * This must be calculated by the caller but only when
46
- * considerSize is true.
47
- */
48
- put(key: string, item: T, size: number): void;
49
- /**
50
- * Clear the cache.
51
- */
52
- clear(): void;
53
- /**
54
- * Estimate the size of an object in bytes.
55
- * @param obj The object to calculate the size of.
56
- * @returns The estimated size of the object in bytes.
57
- */
58
- static calculateObjectSize(obj: any): number;
59
- }
@@ -1,133 +0,0 @@
1
- import { Observable } from 'rxjs';
2
- import { DataPage } from '@myrmidon/ngx-tools';
3
- /**
4
- * Options for the paged list store.
5
- */
6
- export interface PagedListStoreOptions {
7
- /**
8
- * The size of pages in the store.
9
- */
10
- pageSize: number;
11
- /**
12
- * The size of the cache for pages in the store.
13
- */
14
- cacheSize: number;
15
- /**
16
- * A custom function for building the cache key for the given page number
17
- * and filter.
18
- * @param pageNumber The page number.
19
- * @param filter The filter.
20
- * @returns A string to be used as cache key.
21
- */
22
- buildCacheKey?: (pageNumber: number, filter: any) => string;
23
- }
24
- /**
25
- * Default options for the paged list store.
26
- */
27
- export declare const DEFAULT_PAGED_LIST_STORE_OPTIONS: PagedListStoreOptions;
28
- /**
29
- * The interface to be implemented by the service used by PagedListStore.
30
- */
31
- export interface PagedListStoreService<F, E> {
32
- /**
33
- * Load the page with the given number.
34
- * @param pageNumber The page number to load.
35
- * @param pageSize The size of the page to load.
36
- * @param filter The filter to apply.
37
- */
38
- loadPage(pageNumber: number, pageSize: number, filter: F): Observable<DataPage<E>>;
39
- }
40
- /**
41
- * A generic paged list store using a filter object of type F
42
- * and a list of elements of type E.
43
- */
44
- export declare class PagedListStore<F, E> {
45
- private _service;
46
- private _pageSize;
47
- private readonly _customCacheKeyBuilder?;
48
- private _page$;
49
- private _filter$;
50
- private readonly _cache;
51
- /**
52
- * The page. It is updated when the page is changed or the filter is changed.
53
- */
54
- page$: Observable<Readonly<DataPage<E>>>;
55
- /**
56
- * The filter. It is updated when the filter is changed.
57
- */
58
- filter$: Observable<Readonly<F>>;
59
- /**
60
- * The size of nodes pages in this store. If you change it, the store
61
- * is reset. The default value is 20.
62
- */
63
- get pageSize(): number;
64
- set pageSize(value: number);
65
- /**
66
- * Create a new paged list store.
67
- * @param options Options for the paged list store.
68
- */
69
- constructor(_service: PagedListStoreService<F, E>, options?: PagedListStoreOptions);
70
- /**
71
- * Returns true if the store is empty, false otherwise.
72
- * @returns true if the store is empty, false otherwise.
73
- */
74
- isEmpty(): boolean;
75
- /**
76
- * Build the cache key for the given page number and filter.
77
- * The default implementation just returns a stringified object
78
- * containing the page number and the filter. You may override
79
- * this method to provide a custom cache key.
80
- * @param pageNumber The page number.
81
- * @param filter The filter.
82
- * @returns A string to be used as cache key.
83
- */
84
- buildCacheKey(pageNumber: number, filter: F): string;
85
- /**
86
- * Load the page with the given number.
87
- * @param pageNumber the page number to load.
88
- */
89
- private loadPage;
90
- /**
91
- * Set the page with the given number.
92
- * @param pageNumber The page number to load.
93
- * @param pageSize The page size.
94
- * @returns Promise which resolves when the page is loaded.
95
- */
96
- setPage(pageNumber: number, pageSize?: number): Promise<void>;
97
- /**
98
- * Get the current page.
99
- * @returns The current page.
100
- */
101
- getPage(): DataPage<E>;
102
- /**
103
- * Apply the given filter and load the first page.
104
- * @param filter The filter to apply.
105
- * @returns Promise which resolves when the page is loaded.
106
- */
107
- setFilter(filter: F): Promise<void>;
108
- /**
109
- * Get the current filter.
110
- * @returns The current filter.
111
- */
112
- getFilter(): F;
113
- /**
114
- * Reset the filter and load the first page. The cache is cleared.
115
- * @returns Promise which resolves when the page is loaded.
116
- */
117
- reset(): Promise<void>;
118
- /**
119
- * Clear the store. The cache is cleared and the page is emptied.
120
- */
121
- clear(): void;
122
- /**
123
- * Clear the cache.
124
- */
125
- clearCache(): void;
126
- /**
127
- * Check if the page with the given number and filter is in cache.
128
- * @param pageNumber The page number.
129
- * @param filter The filter.
130
- * @returns True if the page is in cache, false otherwise.
131
- */
132
- hasCachedPage(pageNumber: number, filter: F): boolean;
133
- }
@@ -1,242 +0,0 @@
1
- import { Observable } from 'rxjs';
2
- import { DataPage } from '@myrmidon/ngx-tools';
3
- /**
4
- * A tree node. Your data service should return a list of these nodes
5
- * or of any type extending this interface.
6
- */
7
- export interface TreeNode {
8
- id: number;
9
- parentId?: number;
10
- y: number;
11
- x: number;
12
- label: string;
13
- tag?: string;
14
- hasChildren?: boolean;
15
- }
16
- /**
17
- * A filter for tree nodes.
18
- */
19
- export interface TreeNodeFilter {
20
- tags?: string[];
21
- parentId?: number;
22
- }
23
- /**
24
- * Paging information for a paged tree node.
25
- */
26
- export interface PagingInfo {
27
- pageNumber: number;
28
- pageCount: number;
29
- total: number;
30
- }
31
- /**
32
- * A tree node with paging information, used in NodeBrowserStore.
33
- */
34
- export interface PagedTreeNode<F extends TreeNodeFilter> extends TreeNode {
35
- paging: PagingInfo;
36
- expanded?: boolean;
37
- filter?: F;
38
- }
39
- /**
40
- * The interface to be implemented by the service used by NodeBrowserStore
41
- * to load nodes.
42
- */
43
- export interface PagedTreeStoreService<F extends TreeNodeFilter> {
44
- /**
45
- * Get the specified page of nodes.
46
- * @param filter The filter.
47
- * @param pageNumber The page number.
48
- * @param pageSize The page size.
49
- * @param hasMockRoot If true, the root node is a mock node provided by your
50
- * service, which implies that its Y value is 0 rather than 1. Default is
51
- * false, meaning that your service will return a single root node with Y
52
- * value 1.
53
- */
54
- getNodes(filter: F, pageNumber: number, pageSize: number, hasMockRoot?: boolean): Observable<DataPage<TreeNode>>;
55
- }
56
- /**
57
- * Options for the NodeBrowserStore.
58
- */
59
- export interface PagedTreeStoreOptions {
60
- /**
61
- * The size of pages in the store.
62
- */
63
- pageSize: number;
64
- /**
65
- * The size of the cache for pages in the store.
66
- */
67
- cacheSize: number;
68
- /**
69
- * A custom function for building the cache key for the given page number
70
- * and filter.
71
- * @param pageNumber The page number.
72
- * @param filter The filter.
73
- * @returns A string to be used as cache key.
74
- */
75
- buildCacheKey?: (pageNumber: number, filter: any) => string;
76
- /**
77
- * If true, the root node is a mock node provided by your service, which
78
- * implies that its Y value is 0 rather than 1. Default is false, meaning
79
- * that there are many root-level nodes, all with parent ID = undefined.
80
- */
81
- hasMockRoot?: boolean;
82
- }
83
- /**
84
- * A store for the node browser component. This store is used to keep a
85
- * list of nodes, and to load them from the API. It also keeps the root
86
- * node. Every tree node in the list is extended with page number,
87
- * page count and total items, plus expansion-related metadata.
88
- * The store keeps a flat list of these tree nodes, allowing users to
89
- * expand and collapse them.
90
- * F is the type of the filter object, E is the type of the paged tree nodes.
91
- */
92
- export declare class PagedTreeStore<E extends PagedTreeNode<F>, F extends TreeNodeFilter> {
93
- private _service;
94
- private _nodes$;
95
- private _filter$;
96
- private readonly _customCacheKeyBuilder?;
97
- private readonly _cache;
98
- private readonly _hasMockRoot;
99
- private _pageSize;
100
- private _dirty?;
101
- /**
102
- * The flat list of paged nodes in this store.
103
- */
104
- nodes$: Observable<Readonly<E[]>>;
105
- /**
106
- * The global filter for all the nodes.
107
- */
108
- filter$: Observable<Readonly<F>>;
109
- /**
110
- * The size of nodes pages in this store. If you change it, the store
111
- * is reset. The default value is 20.
112
- */
113
- get pageSize(): number;
114
- set pageSize(value: number);
115
- /**
116
- * Create an instance of the store.
117
- * @param _service The service used to load nodes.
118
- * @param options The options to configure this store.
119
- */
120
- constructor(_service: PagedTreeStoreService<F>, options?: PagedTreeStoreOptions);
121
- /**
122
- * Gets the global filter, eventually overridden with values
123
- * from the specified node's filter.
124
- * @param node The optional node.
125
- * @returns The filter.
126
- */
127
- private getFilter;
128
- /**
129
- * Checks if this store is empty.
130
- * @returns True if this store is empty.
131
- */
132
- isEmpty(): boolean;
133
- /**
134
- * Gets all the nodes in the store.
135
- * @returns The nodes.
136
- */
137
- getNodes(): Readonly<PagedTreeNode<F>[]>;
138
- /**
139
- * Get the root node of the tree.
140
- * @returns The root node of the tree or undefined if empty.
141
- */
142
- getRootNode(): PagedTreeNode<F> | undefined;
143
- /**
144
- * Build the cache key for the given page number and filter.
145
- * The default implementation just returns a stringified object
146
- * containing the page number and the filter. You may override
147
- * this method to provide a custom cache key.
148
- * @param pageNumber The page number.
149
- * @param filter The filter.
150
- * @returns A string to be used as cache key.
151
- */
152
- buildCacheKey(pageNumber: number, filter: F): string;
153
- /**
154
- * Get the specified page of nodes, either from cache or from the server.
155
- * When the page is retrieved from the server, it is stored in cache.
156
- * @param filter The filter to apply.
157
- * @param pageNumber The page number to get.
158
- * @returns Observable of the page of nodes.
159
- */
160
- private getPageFromCacheOrServer;
161
- /**
162
- * Create paged tree nodes from a page of tree nodes, by providing further
163
- * metadata like page number, page count and total items.
164
- * @param page The page to create nodes from.
165
- * @returns Paged nodes.
166
- */
167
- private createPageNodes;
168
- /**
169
- * Sets the filter for this store. Whenever the filter is set,
170
- * the store is reset.
171
- * @param filter The filter.
172
- * @returns true if tree was changed, false otherwise.
173
- */
174
- setFilter(filter: F): Promise<boolean>;
175
- /**
176
- * Reset the store, loading the root nodes and their children.
177
- * @returns true if tree was changed, false otherwise.
178
- */
179
- reset(): Promise<boolean>;
180
- /**
181
- * Set the node filter for the node with the specified ID.
182
- * @param id The node ID.
183
- * @param filter The filter to set.
184
- * @returns Promise with true if filter was set, false otherwise.
185
- */
186
- setNodeFilter(id: number, filter?: F | null): Promise<boolean>;
187
- /**
188
- * Expand the node with the specified ID. If the node is not expandable,
189
- * or it is already expanded, this method does nothing.
190
- * @param node The ID of the node to expand.
191
- * @returns Promise with true if the node was expanded, false otherwise.
192
- */
193
- expand(id: number): Promise<boolean>;
194
- /**
195
- * Expand all the descendants of the node with the specified ID.
196
- *
197
- * @param id The ID of the node to expand, or undefined to expand the
198
- * descendants of all the root level nodes.
199
- * @returns Promise.
200
- */
201
- expandAll(id?: number): Promise<boolean>;
202
- getChildren(id: number): E[];
203
- private removeDescendants;
204
- /**
205
- * Collapse the node with the specified ID. If the node is not expandable,
206
- * or it is already collapsed, this method does nothing.
207
- * @param node The node to collapse.
208
- * @returns Promise with true if the node was collapsed, false otherwise.
209
- */
210
- collapse(id: number): Promise<boolean>;
211
- /**
212
- * Collapse all the descendants of the node with the specified ID.
213
- *
214
- * @param id The ID of the node to collapse, or undefined to collapse the
215
- * descendants of all the root level nodes.
216
- * @returns Promise.
217
- */
218
- collapseAll(id?: number): Promise<boolean>;
219
- /**
220
- * Change the page including the node with the specified ID.
221
- * @param parentId The ID of the parent node whose children are inside the page
222
- * you want to change.
223
- * @param pageNumber The new page number.
224
- * @returns Promise with true if the page was changed, false otherwise.
225
- */
226
- changePage(parentId: number, pageNumber: number): Promise<boolean>;
227
- /**
228
- * Clear the store. The cache is cleared and the nodes are removed.
229
- */
230
- clear(): void;
231
- /**
232
- * Clear the cache.
233
- */
234
- clearCache(): void;
235
- /**
236
- * Check if the page with the given number and filter is in cache.
237
- * @param pageNumber The page number.
238
- * @param filter The filter.
239
- * @returns True if the page is in cache, false otherwise.
240
- */
241
- hasCachedPage(pageNumber: number, filter: F): boolean;
242
- }
package/public-api.d.ts DELETED
@@ -1,6 +0,0 @@
1
- export * from './lib/components/compact-pager/compact-pager.component';
2
- export * from './lib/components/range-view/range-view.component';
3
- export * from './lib/components/browser-tree-node/browser-tree-node.component';
4
- export * from './lib/services/paged-list.store';
5
- export * from './lib/services/paged-tree.store';
6
- export * from './lib/services/lru-cache';