@bootkit/ng0 0.0.0-alpha.21 → 0.0.0-alpha.23
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/common/index.d.ts +125 -7
- package/components/dropdown/index.d.ts +87 -25
- package/components/list/index.d.ts +138 -45
- package/components/select/index.d.ts +32 -25
- package/data/index.d.ts +25 -122
- package/fesm2022/bootkit-ng0-common.mjs +145 -11
- package/fesm2022/bootkit-ng0-common.mjs.map +1 -1
- package/fesm2022/bootkit-ng0-components-dropdown.mjs +208 -95
- package/fesm2022/bootkit-ng0-components-dropdown.mjs.map +1 -1
- package/fesm2022/bootkit-ng0-components-list.mjs +287 -144
- package/fesm2022/bootkit-ng0-components-list.mjs.map +1 -1
- package/fesm2022/bootkit-ng0-components-select.mjs +168 -236
- package/fesm2022/bootkit-ng0-components-select.mjs.map +1 -1
- package/fesm2022/bootkit-ng0-data.mjs +49 -114
- package/fesm2022/bootkit-ng0-data.mjs.map +1 -1
- package/fesm2022/bootkit-ng0-localization-locales.mjs +2 -16
- package/fesm2022/bootkit-ng0-localization-locales.mjs.map +1 -1
- package/fesm2022/bootkit-ng0-localization.mjs +42 -44
- package/fesm2022/bootkit-ng0-localization.mjs.map +1 -1
- package/fesm2022/bootkit-ng0-routing.mjs +80 -0
- package/fesm2022/bootkit-ng0-routing.mjs.map +1 -0
- package/localization/index.d.ts +29 -23
- package/package.json +9 -5
- package/routing/index.d.ts +124 -0
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import * as _bootkit_ng0_common from '@bootkit/ng0/common';
|
|
2
|
-
import { SelectOption } from '@bootkit/ng0/common';
|
|
3
1
|
import * as _bootkit_ng0_localization from '@bootkit/ng0/localization';
|
|
4
|
-
import * as
|
|
5
|
-
import {
|
|
2
|
+
import * as _bootkit_ng0_common from '@bootkit/ng0/common';
|
|
3
|
+
import { SelectOption, FilterPredicate, IdGenerator } from '@bootkit/ng0/common';
|
|
6
4
|
import * as _angular_core from '@angular/core';
|
|
7
5
|
import { OnInit, TemplateRef, ElementRef } from '@angular/core';
|
|
6
|
+
import { DataSource, DataSourceLike } from '@bootkit/ng0/data';
|
|
8
7
|
import { ControlValueAccessor } from '@angular/forms';
|
|
9
8
|
import { FlexibleConnectedPositionStrategy, ScrollStrategy } from '@angular/cdk/overlay';
|
|
9
|
+
import { ListSelectionChangeEvent } from '@bootkit/ng0/components/list';
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Select component that allows users to choose an option from a dropdown list.
|
|
@@ -15,13 +15,12 @@ declare class SelectComponent implements OnInit, ControlValueAccessor {
|
|
|
15
15
|
private _resizeObserver?;
|
|
16
16
|
private _resizeObserverInitialized;
|
|
17
17
|
private _viewpoerRulerSubscription?;
|
|
18
|
-
protected _cdkListboxValue: _angular_core.WritableSignal<any>;
|
|
19
18
|
private _filterElementRef?;
|
|
20
|
-
private
|
|
21
|
-
private
|
|
19
|
+
private _listComponent?;
|
|
20
|
+
private _changeCallback;
|
|
21
|
+
private _touchCallback;
|
|
22
22
|
protected readonly _options: _angular_core.WritableSignal<SelectOption[]>;
|
|
23
23
|
protected readonly _isDisabled: _angular_core.WritableSignal<boolean>;
|
|
24
|
-
protected readonly _selectedOptionIndex: _angular_core.WritableSignal<number>;
|
|
25
24
|
protected readonly _activeOptionIndex: _angular_core.WritableSignal<number>;
|
|
26
25
|
protected _optionTemplate?: TemplateRef<any>;
|
|
27
26
|
protected _positionStrategy: FlexibleConnectedPositionStrategy;
|
|
@@ -34,12 +33,17 @@ declare class SelectComponent implements OnInit, ControlValueAccessor {
|
|
|
34
33
|
private _renderer;
|
|
35
34
|
private _viewportRuler;
|
|
36
35
|
private _changeDetector;
|
|
36
|
+
private _activateSlectedItemEffectRef;
|
|
37
37
|
/**
|
|
38
38
|
* The data source for the select component.
|
|
39
39
|
* This can be an array of data, a function that returns an observable of data,
|
|
40
40
|
* or an instance of DataSource.
|
|
41
41
|
*/
|
|
42
42
|
readonly source: _angular_core.InputSignalWithTransform<DataSource<any>, DataSourceLike<any>>;
|
|
43
|
+
/**
|
|
44
|
+
* Value of the select component.
|
|
45
|
+
*/
|
|
46
|
+
value: _angular_core.ModelSignal<any>;
|
|
43
47
|
/**
|
|
44
48
|
* Indicates whether multi selection is enabled or not.
|
|
45
49
|
*/
|
|
@@ -51,18 +55,18 @@ declare class SelectComponent implements OnInit, ControlValueAccessor {
|
|
|
51
55
|
/**
|
|
52
56
|
* A custom comparer function or the name of a field for comparing two objects.
|
|
53
57
|
*/
|
|
54
|
-
readonly compareBy: _angular_core.InputSignalWithTransform<
|
|
58
|
+
readonly compareBy: _angular_core.InputSignalWithTransform<_bootkit_ng0_common.EqualityComparer, _bootkit_ng0_common.EqualityComparerLike>;
|
|
55
59
|
/**
|
|
56
60
|
* Custom format function to convert an item to a string for display.
|
|
57
61
|
* Default converts the item to a string using its toString method.
|
|
58
62
|
*/
|
|
59
|
-
readonly formatBy: _angular_core.InputSignalWithTransform<_bootkit_ng0_localization.
|
|
63
|
+
readonly formatBy: _angular_core.InputSignalWithTransform<_bootkit_ng0_localization.ObjectFormatter, _bootkit_ng0_localization.ObjectFormatterLike>;
|
|
60
64
|
/**
|
|
61
|
-
* Custom value
|
|
65
|
+
* Custom value writer function to extract the value of any object while writing values.
|
|
62
66
|
*/
|
|
63
|
-
readonly writeBy: _angular_core.InputSignalWithTransform<
|
|
67
|
+
readonly writeBy: _angular_core.InputSignalWithTransform<_bootkit_ng0_common.ValueWriter, _bootkit_ng0_common.ValueWriterLike>;
|
|
64
68
|
/**
|
|
65
|
-
* Indicates whether the
|
|
69
|
+
* Indicates whether the select component is filterable.
|
|
66
70
|
*/
|
|
67
71
|
readonly filterable: _angular_core.InputSignalWithTransform<boolean, unknown>;
|
|
68
72
|
/**
|
|
@@ -75,33 +79,36 @@ declare class SelectComponent implements OnInit, ControlValueAccessor {
|
|
|
75
79
|
*/
|
|
76
80
|
readonly filterBy: _angular_core.InputSignal<FilterPredicate>;
|
|
77
81
|
/**
|
|
78
|
-
* CSS class or classes to apply to the
|
|
82
|
+
* CSS class or classes to apply to the items.
|
|
79
83
|
*/
|
|
80
84
|
readonly itemClass: _angular_core.InputSignalWithTransform<_bootkit_ng0_common.CssClassGetter, _bootkit_ng0_common.CssClassLike>;
|
|
81
|
-
constructor();
|
|
82
|
-
ngOnInit(): void;
|
|
83
|
-
private _loadItems;
|
|
84
|
-
private _handleDataSourceChange;
|
|
85
85
|
/**
|
|
86
|
-
*
|
|
86
|
+
* Custom id generator function to generate unique ids for each item.
|
|
87
|
+
* Default generates sequential ids with the prefix 'ng0-select-item-'.
|
|
88
|
+
* If set to undefined, no ids will be generated.
|
|
87
89
|
*/
|
|
88
|
-
|
|
89
|
-
|
|
90
|
+
readonly idGenerator: _angular_core.InputSignal<IdGenerator>;
|
|
91
|
+
constructor();
|
|
92
|
+
ngOnInit(): void;
|
|
90
93
|
writeValue(obj: any): void;
|
|
91
94
|
registerOnChange(fn: any): void;
|
|
92
95
|
registerOnTouched(fn: any): void;
|
|
93
96
|
setDisabledState?(isDisabled: boolean): void;
|
|
94
|
-
protected _onKeydown(e: KeyboardEvent, firedByFilter?: boolean): void;
|
|
95
97
|
protected _onFilterBlur(): void;
|
|
96
|
-
protected _filterItems(filter: string): void;
|
|
97
98
|
protected _onOverlayAttach(): void;
|
|
98
99
|
protected _onOverlayDetach(): void;
|
|
99
|
-
|
|
100
|
+
protected _onListSelectionChange(e: ListSelectionChangeEvent): void;
|
|
101
|
+
protected _mappedValue: _angular_core.Signal<any>;
|
|
100
102
|
private _listenToResizeEvents;
|
|
101
103
|
private _unlistenFromResizeEvents;
|
|
104
|
+
private _selectFirst;
|
|
105
|
+
private _selectLast;
|
|
106
|
+
private _selectNext;
|
|
107
|
+
private _selectPrevious;
|
|
108
|
+
private _onHostKeydown;
|
|
102
109
|
private _onHostClick;
|
|
103
110
|
static ɵfac: _angular_core.ɵɵFactoryDeclaration<SelectComponent, never>;
|
|
104
|
-
static ɵcmp: _angular_core.ɵɵComponentDeclaration<SelectComponent, "ng0-select", ["ng0Select"], { "source": { "alias": "source"; "required": true; "isSignal": true; }; "multiple": { "alias": "multiple"; "required": false; "isSignal": true; }; "open": { "alias": "open"; "required": false; "isSignal": true; }; "compareBy": { "alias": "compareBy"; "required": false; "isSignal": true; }; "formatBy": { "alias": "formatBy"; "required": false; "isSignal": true; }; "writeBy": { "alias": "writeBy"; "required": false; "isSignal": true; }; "filterable": { "alias": "filterable"; "required": false; "isSignal": true; }; "filterPlaceholder": { "alias": "filterPlaceholder"; "required": false; "isSignal": true; }; "filterBy": { "alias": "filterBy"; "required": false; "isSignal": true; }; "itemClass": { "alias": "itemClass"; "required": false; "isSignal": true; }; }, { "open": "openChange"; }, ["_optionTemplate"], never, true, never>;
|
|
111
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<SelectComponent, "ng0-select", ["ng0Select"], { "source": { "alias": "source"; "required": true; "isSignal": true; }; "value": { "alias": "value"; "required": false; "isSignal": true; }; "multiple": { "alias": "multiple"; "required": false; "isSignal": true; }; "open": { "alias": "open"; "required": false; "isSignal": true; }; "compareBy": { "alias": "compareBy"; "required": false; "isSignal": true; }; "formatBy": { "alias": "formatBy"; "required": false; "isSignal": true; }; "writeBy": { "alias": "writeBy"; "required": false; "isSignal": true; }; "filterable": { "alias": "filterable"; "required": false; "isSignal": true; }; "filterPlaceholder": { "alias": "filterPlaceholder"; "required": false; "isSignal": true; }; "filterBy": { "alias": "filterBy"; "required": false; "isSignal": true; }; "itemClass": { "alias": "itemClass"; "required": false; "isSignal": true; }; "idGenerator": { "alias": "idGenerator"; "required": false; "isSignal": true; }; }, { "value": "valueChange"; "open": "openChange"; }, ["_optionTemplate"], never, true, never>;
|
|
105
112
|
}
|
|
106
113
|
|
|
107
114
|
/**
|
package/data/index.d.ts
CHANGED
|
@@ -3,26 +3,6 @@ import * as rxjs from 'rxjs';
|
|
|
3
3
|
import { Observable, Subject } from 'rxjs';
|
|
4
4
|
import * as _bootkit_ng0_data from '@bootkit/ng0/data';
|
|
5
5
|
|
|
6
|
-
/**
|
|
7
|
-
* Boolean value comparer function type.
|
|
8
|
-
* @param a First value to compare.
|
|
9
|
-
* @param b Second value to compare.
|
|
10
|
-
* @returns true if a is considered equal to b else returns false
|
|
11
|
-
*/
|
|
12
|
-
type BooleanValueComparer = (a: any, b: any) => boolean;
|
|
13
|
-
/**
|
|
14
|
-
* Boolean value comparer can be a function or a string representing the property name to compare.
|
|
15
|
-
*/
|
|
16
|
-
type BooleanValueComparerLike = BooleanValueComparer | string;
|
|
17
|
-
/**
|
|
18
|
-
* Default value comparer function.
|
|
19
|
-
* @param a
|
|
20
|
-
* @param b
|
|
21
|
-
* @returns true if a === b else returns false
|
|
22
|
-
*/
|
|
23
|
-
declare function defaultBooleanValueComparer(a: any, b: any): boolean;
|
|
24
|
-
declare function BooleanValueComparerAttribute(v: BooleanValueComparerLike): BooleanValueComparer;
|
|
25
|
-
|
|
26
6
|
/**
|
|
27
7
|
* DataRequest class represents a request for data with pagination, filtering, sorting, and field selection.
|
|
28
8
|
* It is used to encapsulate the parameters needed to fetch data from a data source.
|
|
@@ -102,33 +82,25 @@ declare class DataResult<T = any> {
|
|
|
102
82
|
constructor(data: T[], total?: number | undefined);
|
|
103
83
|
}
|
|
104
84
|
|
|
105
|
-
/**
|
|
106
|
-
* DataLoader is a function that takes a DataRequest and returns an Observable of DataResult.
|
|
107
|
-
* It is used by RemoteDataSource to load data asynchronously.
|
|
108
|
-
*/
|
|
109
|
-
type DataLoader<T = any> = (request: DataRequest) => Observable<DataResult<T>>;
|
|
110
85
|
interface DataSourceChange {
|
|
111
|
-
type: '
|
|
86
|
+
type: 'push';
|
|
112
87
|
}
|
|
113
|
-
interface
|
|
114
|
-
type: '
|
|
115
|
-
/**
|
|
116
|
-
|
|
88
|
+
interface DataSourcePushChange extends DataSourceChange {
|
|
89
|
+
type: 'push';
|
|
90
|
+
/**
|
|
91
|
+
* The items to insert.
|
|
92
|
+
*/
|
|
117
93
|
items: any[];
|
|
118
94
|
}
|
|
119
|
-
interface DataSourceItemReplace extends DataSourceChange {
|
|
120
|
-
type: 'replace';
|
|
121
|
-
index: number;
|
|
122
|
-
value: any;
|
|
123
|
-
}
|
|
124
|
-
interface DataSourceItemRemove extends DataSourceChange {
|
|
125
|
-
type: 'remove';
|
|
126
|
-
index: number;
|
|
127
|
-
count?: number;
|
|
128
|
-
}
|
|
129
95
|
interface DataSourceChangeEvent {
|
|
130
|
-
changes: Array<
|
|
96
|
+
changes: Array<DataSourcePushChange>;
|
|
131
97
|
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* DataLoader is a function that takes a DataRequest and returns an Observable of DataResult.
|
|
101
|
+
* It is used by RemoteDataSource to load data asynchronously.
|
|
102
|
+
*/
|
|
103
|
+
type DataLoader<T = any> = (request: DataRequest) => Observable<DataResult<T>>;
|
|
132
104
|
/**
|
|
133
105
|
* Abstract base class for data sources.
|
|
134
106
|
* This class provides a common interface for loading data from various sources.
|
|
@@ -178,27 +150,6 @@ declare class RemoteDataSource extends DataSource {
|
|
|
178
150
|
load(request: DataRequest): Observable<_bootkit_ng0_data.DataResult<any>>;
|
|
179
151
|
}
|
|
180
152
|
|
|
181
|
-
/**
|
|
182
|
-
* Value extractor function type.
|
|
183
|
-
*/
|
|
184
|
-
type ValueExtractor = (a: any) => any;
|
|
185
|
-
/**
|
|
186
|
-
* Value extractor can be a function or a string representing the property name to extract.
|
|
187
|
-
*/
|
|
188
|
-
type ValueExtractorLike = ValueExtractor | string;
|
|
189
|
-
/**
|
|
190
|
-
* Default value extractor function.
|
|
191
|
-
* @param a The input value
|
|
192
|
-
* @returns the input value
|
|
193
|
-
*/
|
|
194
|
-
declare function defaultValueExtractor(a: any): any;
|
|
195
|
-
/**
|
|
196
|
-
* Converts a ValueExtractorLike to a ValueExtractorFunction.
|
|
197
|
-
* @param v The value extractor to convert.
|
|
198
|
-
* @returns A function that extracts the desired value.
|
|
199
|
-
*/
|
|
200
|
-
declare function ValueExtractorAttribute(v: ValueExtractorLike): ValueExtractor;
|
|
201
|
-
|
|
202
153
|
/**
|
|
203
154
|
* An implementation of DataSource that uses an array as the data source.
|
|
204
155
|
* This is useful for static data or when you want to manage the data manually.
|
|
@@ -206,7 +157,6 @@ declare function ValueExtractorAttribute(v: ValueExtractorLike): ValueExtractor;
|
|
|
206
157
|
declare class LocalDataSource extends DataSource {
|
|
207
158
|
private items;
|
|
208
159
|
readonly type = "local";
|
|
209
|
-
valueExtractor: (initialValue: ValueExtractor, options?: _angular_core.CreateSignalOptions<ValueExtractor> | undefined) => _angular_core.WritableSignal<ValueExtractor>;
|
|
210
160
|
constructor(items: any[]);
|
|
211
161
|
/**
|
|
212
162
|
* Creates a LocalDataSource from enum values.
|
|
@@ -214,73 +164,26 @@ declare class LocalDataSource extends DataSource {
|
|
|
214
164
|
* @returns A LocalDataSource containing the enum values.
|
|
215
165
|
*/
|
|
216
166
|
static fromEnum(enumClass: Record<string, string | number>): LocalDataSource;
|
|
167
|
+
/**
|
|
168
|
+
* Loads data from the local array based on the provided DataRequest.
|
|
169
|
+
* @param request The DataRequest containing filtering, sorting, and pagination information.
|
|
170
|
+
* @returns An observable of DataResult containing the requested data.
|
|
171
|
+
*/
|
|
217
172
|
load(request: DataRequest): rxjs.Observable<DataResult<any>>;
|
|
218
|
-
|
|
219
|
-
|
|
173
|
+
/**
|
|
174
|
+
* Adds items to the end of the local array.
|
|
175
|
+
* @param items The items to add.
|
|
176
|
+
*/
|
|
220
177
|
push(...items: any[]): void;
|
|
221
|
-
|
|
178
|
+
private _validateIndex;
|
|
222
179
|
}
|
|
223
180
|
|
|
224
181
|
declare function toDataResult<T = any>(dr: DataRequest): (source: Observable<any>) => Observable<DataResult<T>>;
|
|
225
182
|
|
|
226
|
-
/**
|
|
227
|
-
* A comparison function type that defines an ordering relation between two values.
|
|
228
|
-
* @param a The first value to compare.
|
|
229
|
-
* @param b The second value to compare.
|
|
230
|
-
* @returns
|
|
231
|
-
* - A negative number if `a` should come before `b`
|
|
232
|
-
* - A positive number if `a` should come after `b`
|
|
233
|
-
* - Zero if `a` and `b` are considered equal
|
|
234
|
-
*/
|
|
235
|
-
type ValueComparer = (a: any, b: any) => number;
|
|
236
|
-
/**
|
|
237
|
-
* Value comparer can be a function or a string representing the property name to compare.
|
|
238
|
-
*/
|
|
239
|
-
type ValueComparerLike = ValueComparer | string;
|
|
240
|
-
/**
|
|
241
|
-
* Default value comparer function.
|
|
242
|
-
* @param a
|
|
243
|
-
* @param b
|
|
244
|
-
* @returns -1 if a < b, 1 if a > b, 0 if a === b
|
|
245
|
-
*/
|
|
246
|
-
declare function defaultValueComparer(a: any, b: any): number;
|
|
247
|
-
/**
|
|
248
|
-
* Converts a ValueComparerLike to a ValueComparerFunction.
|
|
249
|
-
* @param v The value comparer to convert.
|
|
250
|
-
* @returns A function that compares two values.
|
|
251
|
-
*/
|
|
252
|
-
declare function ValueComparerAttribute(v: ValueComparerLike): ValueComparer;
|
|
253
|
-
|
|
254
|
-
/**
|
|
255
|
-
* Filter predicate function type.
|
|
256
|
-
* @param item The item to test against the filter.
|
|
257
|
-
* @param params Additional parameters to pass to the filter function.
|
|
258
|
-
* @returns True if the item matches the filter, false otherwise.
|
|
259
|
-
*/
|
|
260
|
-
type FilterPredicate = (item: any, ...params: any[]) => boolean;
|
|
261
|
-
/**
|
|
262
|
-
* Filter predicate can be a function or a string representing the property name to filter.
|
|
263
|
-
*/
|
|
264
|
-
type FilterPredicateLike = FilterPredicate | string;
|
|
265
|
-
/**
|
|
266
|
-
* A filter predicate that checks if a string contains the filter criteria (case insensitive).
|
|
267
|
-
* @param item The item to test against the filter.
|
|
268
|
-
* @param criteria The filter criteria.
|
|
269
|
-
* @returns True if the item matches the filter, false otherwise.
|
|
270
|
-
*/
|
|
271
|
-
declare const stringFilter: FilterPredicate;
|
|
272
|
-
/**
|
|
273
|
-
* Converts a FilterPredicateLike to a FilterPredicate function.
|
|
274
|
-
* If the input is a string, it creates a predicate that checks the property with that name.
|
|
275
|
-
* @param v The FilterPredicateLike to convert.
|
|
276
|
-
* @returns The corresponding FilterPredicate function.
|
|
277
|
-
*/
|
|
278
|
-
declare function FilterPredicateAttribute(v: FilterPredicateLike): FilterPredicate;
|
|
279
|
-
|
|
280
183
|
/**
|
|
281
184
|
* LogicalOperator is a list of predefined logical operators that can be used in data requests to filter data.
|
|
282
185
|
*/
|
|
283
186
|
type LogicalOperator = 'contains' | 'endsWith' | 'startsWith' | 'like' | 'eq' | 'ne' | 'gt' | 'gte' | 'lt' | 'lte';
|
|
284
187
|
|
|
285
|
-
export {
|
|
286
|
-
export type {
|
|
188
|
+
export { DataRequest, DataResult, DataSource, LocalDataSource, RemoteDataSource, dataSourceAttribute, toDataResult };
|
|
189
|
+
export type { DataLoader, DataRequestFilter, DataRequestPage, DataRequestSort, DataSourceChange, DataSourceChangeEvent, DataSourceLike, DataSourcePushChange, LogicalOperator };
|
|
@@ -62,6 +62,25 @@ function toObservable(value) {
|
|
|
62
62
|
function numberArray(start, end) {
|
|
63
63
|
return Array.from({ length: end - start + 1 }, (_, i) => i + start);
|
|
64
64
|
}
|
|
65
|
+
/**
|
|
66
|
+
* Deletes multiple entries from an array based on the provided indices.
|
|
67
|
+
* @param array
|
|
68
|
+
* @param indices
|
|
69
|
+
* @private
|
|
70
|
+
*/
|
|
71
|
+
function deleteEntries(array, indices) {
|
|
72
|
+
// Sort indices in descending order
|
|
73
|
+
// This prevents index shifting issues when removing multiple items
|
|
74
|
+
indices.sort((a, b) => b - a);
|
|
75
|
+
indices.forEach(index => {
|
|
76
|
+
if (index >= 0 && index < array.length) {
|
|
77
|
+
array.splice(index, 1);
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
throw new Error(`Index out of bounds: ${index}`);
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
}
|
|
65
84
|
|
|
66
85
|
function getEnumValues(enumClass) {
|
|
67
86
|
return Object.keys(enumClass)
|
|
@@ -71,12 +90,6 @@ function getEnumValues(enumClass) {
|
|
|
71
90
|
;
|
|
72
91
|
|
|
73
92
|
let _idCounter = 0;
|
|
74
|
-
class _IdGenerator {
|
|
75
|
-
static _idCounter = 0;
|
|
76
|
-
static next() {
|
|
77
|
-
return _IdGenerator._idCounter++;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
93
|
/**
|
|
81
94
|
* Creates a sequential ID generator function with an optional prefix.
|
|
82
95
|
* @param prefix Optional prefix for the generated IDs.
|
|
@@ -92,20 +105,141 @@ function sequentialIdGenerator(prefix) {
|
|
|
92
105
|
* @returns A function that returns the desired CSS class.
|
|
93
106
|
*/
|
|
94
107
|
function CssClassAttribute(v) {
|
|
108
|
+
if (v === undefined || v === null) {
|
|
109
|
+
return (item) => undefined;
|
|
110
|
+
}
|
|
111
|
+
else if (typeof v === 'function')
|
|
112
|
+
return v;
|
|
113
|
+
else if (typeof v === 'string' || Array.isArray(v) || typeof v === 'object') {
|
|
114
|
+
return (item) => v;
|
|
115
|
+
}
|
|
116
|
+
throw Error('invalid css class getter');
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Default equality comparer function.
|
|
121
|
+
* @param a First value to compare.
|
|
122
|
+
* @param b Second value to compare.
|
|
123
|
+
* @returns true if a === b else returns false
|
|
124
|
+
*/
|
|
125
|
+
function defaultEqualityComparer(a, b) {
|
|
126
|
+
return a === b;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Converts an EqualityComparerLike to an EqualityComparer function.
|
|
130
|
+
* @param e The EqualityComparerLike to convert.
|
|
131
|
+
* @returns The converted EqualityComparer.
|
|
132
|
+
*/
|
|
133
|
+
function equalityComparerAttribute(e) {
|
|
134
|
+
if (typeof e === 'function')
|
|
135
|
+
return e;
|
|
136
|
+
if (typeof e === 'string') {
|
|
137
|
+
return (a, b) => {
|
|
138
|
+
let a2 = a != null && Object.hasOwn(a, e) ? a[e] : a;
|
|
139
|
+
let b2 = b != null && Object.hasOwn(b, e) ? b[e] : b;
|
|
140
|
+
return a2 === b2;
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
throw Error('invalid equality comparer');
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* @private
|
|
147
|
+
* @param items
|
|
148
|
+
* @param value
|
|
149
|
+
* @param comparer
|
|
150
|
+
*/
|
|
151
|
+
function findValueByComparer(items, value, comparer) {
|
|
152
|
+
if (!items || items.length === 0 || value === undefined || value === null) {
|
|
153
|
+
return undefined;
|
|
154
|
+
}
|
|
155
|
+
return items.find(i => comparer(i, value));
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* @private
|
|
159
|
+
* @param items
|
|
160
|
+
* @param values
|
|
161
|
+
* @param comparer
|
|
162
|
+
*/
|
|
163
|
+
function findValuesByComparer(items, values, comparer) {
|
|
164
|
+
if (!items || items.length === 0 || !values || values.length === 0) {
|
|
165
|
+
return [];
|
|
166
|
+
}
|
|
167
|
+
const result = [];
|
|
168
|
+
for (let v of values) {
|
|
169
|
+
const item = items.find(i => comparer(i, v));
|
|
170
|
+
if (item) {
|
|
171
|
+
result.push(item);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
return result;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Default value writer function.
|
|
179
|
+
* @param a The input value
|
|
180
|
+
* @returns the input value (it does not transform it)
|
|
181
|
+
*/
|
|
182
|
+
function defaultValueWriter(a) {
|
|
183
|
+
return a;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Converts a ValueWriterLike to a ValueWriterFunction.
|
|
187
|
+
* @param v The value writer to convert.
|
|
188
|
+
* @returns A ValueWriter function.
|
|
189
|
+
*/
|
|
190
|
+
function valueWriterAttribute(v) {
|
|
95
191
|
if (typeof v === 'function')
|
|
96
192
|
return v;
|
|
97
193
|
if (typeof v === 'string') {
|
|
98
|
-
return (item) => v;
|
|
194
|
+
return (item) => item ? item[v] : undefined;
|
|
99
195
|
}
|
|
100
|
-
|
|
101
|
-
|
|
196
|
+
throw Error('invalid value writer');
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* A simple comparer function.
|
|
201
|
+
* @param a The first value to compare.
|
|
202
|
+
* @param b The second value to compare.
|
|
203
|
+
* @returns -1 if a < b, 1 if a > b, 0 if a === b
|
|
204
|
+
*/
|
|
205
|
+
function defaultComparer(a, b) {
|
|
206
|
+
return a === b ? 0 : a < b ? -1 : 1;
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Converts a ComparerLike to a Comparer.
|
|
210
|
+
* @param v The comparer to convert.
|
|
211
|
+
* @returns A function that compares two values.
|
|
212
|
+
*/
|
|
213
|
+
function comparerAttribute(v) {
|
|
214
|
+
if (typeof v === 'function')
|
|
215
|
+
return v;
|
|
216
|
+
if (typeof v === 'string') {
|
|
217
|
+
return (a, b) => a?.[v] === b?.[v] ? 0 : a?.[v] < b?.[v] ? -1 : 1;
|
|
102
218
|
}
|
|
103
|
-
throw Error('invalid
|
|
219
|
+
throw Error('invalid value comparer');
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
*
|
|
224
|
+
* @param item
|
|
225
|
+
* @returns
|
|
226
|
+
*/
|
|
227
|
+
const noopFilter = (item) => true;
|
|
228
|
+
/**
|
|
229
|
+
* Converts a FilterPredicateLike to a FilterPredicate function.
|
|
230
|
+
* If the input is a string, it creates a predicate that checks the property with that name.
|
|
231
|
+
* @param v The FilterPredicateLike to convert.
|
|
232
|
+
* @returns The corresponding FilterPredicate function.
|
|
233
|
+
*/
|
|
234
|
+
function filterPredicateAttribute(v) {
|
|
235
|
+
if (typeof v === 'function')
|
|
236
|
+
return v;
|
|
237
|
+
throw Error('invalid filter predicate');
|
|
104
238
|
}
|
|
105
239
|
|
|
106
240
|
/**
|
|
107
241
|
* Generated bundle index. Do not edit.
|
|
108
242
|
*/
|
|
109
243
|
|
|
110
|
-
export { CssClassAttribute, RTL,
|
|
244
|
+
export { CssClassAttribute, RTL, comparerAttribute, defaultComparer, defaultEqualityComparer, defaultValueWriter, deleteEntries, equalityComparerAttribute, filterPredicateAttribute, findValueByComparer, findValuesByComparer, flipPlacement, formatString, getEnumValues, noopFilter, numberArray, sequentialIdGenerator, toObservable, valueWriterAttribute };
|
|
111
245
|
//# sourceMappingURL=bootkit-ng0-common.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bootkit-ng0-common.mjs","sources":["../../../projects/ng0/common/types.ts","../../../projects/ng0/common/layout.ts","../../../projects/ng0/common/string-utils.ts","../../../projects/ng0/common/rxjs-utils.ts","../../../projects/ng0/common/array-utils.ts","../../../projects/ng0/common/enum.ts","../../../projects/ng0/common/id-generator.ts","../../../projects/ng0/common/css-class.ts","../../../projects/ng0/common/bootkit-ng0-common.ts"],"sourcesContent":["import { InjectionToken } from \"@angular/core\";\r\n\r\nexport const RTL = new InjectionToken<boolean>('RTL Direction');\r\n\r\n/**\r\n * List item interface.\r\n */\r\nexport interface SelectOption {\r\n id: string,\r\n value: any,\r\n show?: boolean,\r\n}\r\n\r\n\r\n","export type Placement = 'start' | 'end' | 'top' | 'bottom';\r\nexport type Alignment = 'start' | 'center' | 'end';\r\n\r\n/**\r\n * Flips the placement direction.\r\n * @param placement The placement direction to flip.\r\n * @returns The flipped placement direction.\r\n */\r\nexport function flipPlacement(placement: Placement) {\r\n switch (placement) {\r\n case 'bottom':\r\n return 'top'\r\n case 'top':\r\n return 'bottom'\r\n case 'start':\r\n return 'end'\r\n case 'end':\r\n return 'start'\r\n }\r\n}\r\n\r\n\r\n","/**\r\n * Formats a string by replacing placeholders with the provided arguments.\r\n * @param str The string to format, containing placeholders in the form of {0}, {1}, etc.\r\n * @param args The values to replace the placeholders with.\r\n * @returns The formatted string.\r\n */\r\nexport function formatString(str: string, ...args: any[]) {\r\n return str.replace(/\\{(\\d+)\\}/g, function (match, index) {\r\n return args[index];\r\n });\r\n}\r\n","import { from, Observable, of } from 'rxjs';\r\n\r\n/**\r\n * Converts a value to an Observable.\r\n * If the value is already an Observable, it returns it directly.\r\n * If the value is a Promise, it converts it to an Observable.\r\n * If the value is neither, it wraps it in an Observable using `of`.\r\n * @param value The value to convert.\r\n * @returns An Observable that emits the value.\r\n */\r\nexport function toObservable<T>(value: T | Observable<T> | Promise<T>): Observable<T> {\r\n if (value instanceof Observable) {\r\n return value;\r\n } else if (value instanceof Promise) {\r\n return from(value);\r\n } else {\r\n return of(value);\r\n }\r\n}\r\n","/**\r\n * Creates an array of numbers within a specified range.\r\n * @param start The starting number of the range (inclusive).\r\n * @param end The ending number of the range (inclusive).\r\n * @returns An array of numbers within the specified range.\r\n */\r\nexport function numberArray(start: number, end: number) {\r\n return Array.from({ length: end - start + 1 }, (_, i) => i + start)\r\n}","\r\nexport function getEnumValues(enumClass: Record<string, string | number>): Array<string | number> {\r\n return Object.keys(enumClass)\r\n .filter(k => isNaN(Number(k))) // remove reverse-mapping keys\r\n .map(k => enumClass[k]);\r\n};\r\n","let _idCounter = 0;\r\n\r\nexport abstract class _IdGenerator {\r\n private static _idCounter = 0;\r\n\r\n public static next(): number {\r\n return _IdGenerator._idCounter++;\r\n }\r\n}\r\n\r\n/**\r\n * Type definition for an ID generator function.\r\n */\r\nexport type IdGenerator = (param?: any) => string;\r\n\r\n/**\r\n * Creates a sequential ID generator function with an optional prefix.\r\n * @param prefix Optional prefix for the generated IDs.\r\n * @returns A function that generates sequential IDs with the given prefix.\r\n */\r\nexport function sequentialIdGenerator(prefix?: string): IdGenerator {\r\n return (item?: any) => `${prefix || ''}${_idCounter++}`;\r\n}\r\n","/**\r\n * CSS class type which can be a string, array of strings, set of strings, or an object with class names as keys.\r\n */\r\nexport type CssClass = string | string[] | Set<string> | { [klass: string]: any } | null | undefined;\r\n\r\n\r\n/**\r\n * A function that takes an item and returns a CssClass.\r\n * @param item The item to get the CSS class for.\r\n * @returns The CSS class for the item.\r\n */\r\nexport type CssClassGetter = (item: any) => CssClass;\r\n\r\n/**\r\n * A type that represents a CSS class or a function that returns a CSS class.\r\n */\r\nexport type CssClassLike = CssClass | CssClassGetter | null | undefined;\r\n\r\n\r\n/**\r\n * Converts a CssClassLike to a CssClassGetter function.\r\n * @param v The CssClassLike to convert.\r\n * @returns A function that returns the desired CSS class.\r\n */\r\nexport function CssClassAttribute(v: CssClassLike): CssClassGetter {\r\n if (typeof v === 'function')\r\n return v as CssClassGetter;\r\n if (typeof v === 'string') {\r\n return (item: any) => v;\r\n } else if (v === undefined || v === null) {\r\n return (item: any) => undefined;\r\n }\r\n\r\n throw Error('invalid css class getter');\r\n}\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;MAEa,GAAG,GAAG,IAAI,cAAc,CAAU,eAAe;;ACC9D;;;;AAIG;AACG,SAAU,aAAa,CAAC,SAAoB,EAAA;IAC9C,QAAQ,SAAS;AACb,QAAA,KAAK,QAAQ;AACT,YAAA,OAAO,KAAK;AAChB,QAAA,KAAK,KAAK;AACN,YAAA,OAAO,QAAQ;AACnB,QAAA,KAAK,OAAO;AACR,YAAA,OAAO,KAAK;AAChB,QAAA,KAAK,KAAK;AACN,YAAA,OAAO,OAAO;;AAE1B;;ACnBA;;;;;AAKG;SACa,YAAY,CAAC,GAAW,EAAE,GAAG,IAAW,EAAA;IACpD,OAAO,GAAG,CAAC,OAAO,CAAC,YAAY,EAAE,UAAU,KAAK,EAAE,KAAK,EAAA;AACnD,QAAA,OAAO,IAAI,CAAC,KAAK,CAAC;AACtB,IAAA,CAAC,CAAC;AACN;;ACRA;;;;;;;AAOG;AACG,SAAU,YAAY,CAAI,KAAqC,EAAA;AACjE,IAAA,IAAI,KAAK,YAAY,UAAU,EAAE;AAC7B,QAAA,OAAO,KAAK;IAChB;AAAO,SAAA,IAAI,KAAK,YAAY,OAAO,EAAE;AACjC,QAAA,OAAO,IAAI,CAAC,KAAK,CAAC;IACtB;SAAO;AACH,QAAA,OAAO,EAAE,CAAC,KAA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"bootkit-ng0-common.mjs","sources":["../../../projects/ng0/common/types.ts","../../../projects/ng0/common/layout.ts","../../../projects/ng0/common/string-utils.ts","../../../projects/ng0/common/rxjs-utils.ts","../../../projects/ng0/common/array-utils.ts","../../../projects/ng0/common/enum.ts","../../../projects/ng0/common/id-generator.ts","../../../projects/ng0/common/css-class.ts","../../../projects/ng0/common/equality-comparer.ts","../../../projects/ng0/common/value-writer.ts","../../../projects/ng0/common/comparer.ts","../../../projects/ng0/common/filter.ts","../../../projects/ng0/common/bootkit-ng0-common.ts"],"sourcesContent":["import { InjectionToken } from \"@angular/core\";\r\n\r\nexport const RTL = new InjectionToken<boolean>('RTL Direction');\r\n\r\n/**\r\n * List item interface.\r\n */\r\nexport interface SelectOption {\r\n id: string,\r\n value: any,\r\n show?: boolean,\r\n}\r\n\r\n\r\n","export type Placement = 'start' | 'end' | 'top' | 'bottom';\r\nexport type Alignment = 'start' | 'center' | 'end';\r\n\r\n/**\r\n * Flips the placement direction.\r\n * @param placement The placement direction to flip.\r\n * @returns The flipped placement direction.\r\n */\r\nexport function flipPlacement(placement: Placement) {\r\n switch (placement) {\r\n case 'bottom':\r\n return 'top'\r\n case 'top':\r\n return 'bottom'\r\n case 'start':\r\n return 'end'\r\n case 'end':\r\n return 'start'\r\n }\r\n}\r\n\r\n\r\n","/**\r\n * Formats a string by replacing placeholders with the provided arguments.\r\n * @param str The string to format, containing placeholders in the form of {0}, {1}, etc.\r\n * @param args The values to replace the placeholders with.\r\n * @returns The formatted string.\r\n */\r\nexport function formatString(str: string, ...args: any[]) {\r\n return str.replace(/\\{(\\d+)\\}/g, function (match, index) {\r\n return args[index];\r\n });\r\n}\r\n","import { from, Observable, of } from 'rxjs';\r\n\r\n/**\r\n * Converts a value to an Observable.\r\n * If the value is already an Observable, it returns it directly.\r\n * If the value is a Promise, it converts it to an Observable.\r\n * If the value is neither, it wraps it in an Observable using `of`.\r\n * @param value The value to convert.\r\n * @returns An Observable that emits the value.\r\n */\r\nexport function toObservable<T>(value: T | Observable<T> | Promise<T>): Observable<T> {\r\n if (value instanceof Observable) {\r\n return value;\r\n } else if (value instanceof Promise) {\r\n return from(value);\r\n } else {\r\n return of(value);\r\n }\r\n}\r\n","/**\r\n * Creates an array of numbers within a specified range.\r\n * @param start The starting number of the range (inclusive).\r\n * @param end The ending number of the range (inclusive).\r\n * @returns An array of numbers within the specified range.\r\n */\r\nexport function numberArray(start: number, end: number) {\r\n return Array.from({ length: end - start + 1 }, (_, i) => i + start)\r\n}\r\n\r\n/**\r\n * Deletes multiple entries from an array based on the provided indices.\r\n * @param array \r\n * @param indices \r\n * @private\r\n */\r\nexport function deleteEntries(array: any[], indices: number[]) {\r\n // Sort indices in descending order\r\n // This prevents index shifting issues when removing multiple items\r\n indices.sort((a, b) => b - a); \r\n indices.forEach(index => {\r\n if (index >= 0 && index < array.length) {\r\n array.splice(index, 1);\r\n } else {\r\n throw new Error(`Index out of bounds: ${index}`);\r\n }\r\n });\r\n}\r\n","\r\nexport function getEnumValues(enumClass: Record<string, string | number>): Array<string | number> {\r\n return Object.keys(enumClass)\r\n .filter(k => isNaN(Number(k))) // remove reverse-mapping keys\r\n .map(k => enumClass[k]);\r\n};\r\n","let _idCounter = 0;\r\n\r\n/**\r\n * Type definition for an ID generator function.\r\n */\r\nexport type IdGenerator = (param?: any) => string;\r\n\r\n/**\r\n * Creates a sequential ID generator function with an optional prefix.\r\n * @param prefix Optional prefix for the generated IDs.\r\n * @returns A function that generates sequential IDs with the given prefix.\r\n */\r\nexport function sequentialIdGenerator(prefix?: string): IdGenerator {\r\n return (item?: any) => `${prefix || ''}${_idCounter++}`;\r\n}\r\n","/**\r\n * CSS class type which can be a string, array of strings, set of strings, or an object with class names as keys.\r\n */\r\nexport type CssClass = string | string[] | Set<string> | { [klass: string]: any } | null | undefined;\r\n\r\n\r\n/**\r\n * A function that takes an item and returns a CssClass.\r\n * @param item The item to get the CSS class for.\r\n * @returns The CSS class for the item.\r\n */\r\nexport type CssClassGetter = (obj: any) => CssClass;\r\n\r\n/**\r\n * A type that represents a CSS class or a function that returns a CSS class.\r\n */\r\nexport type CssClassLike = CssClass | CssClassGetter | null | undefined;\r\n\r\n\r\n/**\r\n * Converts a CssClassLike to a CssClassGetter function.\r\n * @param v The CssClassLike to convert.\r\n * @returns A function that returns the desired CSS class.\r\n */\r\nexport function CssClassAttribute(v: CssClassLike): CssClassGetter {\r\n if (v === undefined || v === null) {\r\n return (item: any) => undefined;\r\n } else if (typeof v === 'function')\r\n return v as CssClassGetter;\r\n else if (typeof v === 'string' || Array.isArray(v) || typeof v === 'object') {\r\n return (item: any) => v;\r\n }\r\n\r\n throw Error('invalid css class getter');\r\n}\r\n","/**\r\n * Equality comparer function type.\r\n * @param a First value to compare.\r\n * @param b Second value to compare.\r\n * @returns true if a is considered equal to b else returns false\r\n */\r\nexport type EqualityComparer = (a: any, b: any) => boolean;\r\n\r\n/**\r\n * Equality comparer like type.\r\n * can be a function or a string representing the property name to compare.\r\n */\r\nexport type EqualityComparerLike = EqualityComparer | string;\r\n\r\n/**\r\n * Default equality comparer function.\r\n * @param a First value to compare.\r\n * @param b Second value to compare.\r\n * @returns true if a === b else returns false\r\n */\r\nexport function defaultEqualityComparer(a: any, b: any): boolean {\r\n return a === b;\r\n}\r\n\r\n/**\r\n * Converts an EqualityComparerLike to an EqualityComparer function.\r\n * @param e The EqualityComparerLike to convert.\r\n * @returns The converted EqualityComparer.\r\n */\r\nexport function equalityComparerAttribute(e: EqualityComparerLike): EqualityComparer {\r\n if (typeof e === 'function')\r\n return e;\r\n if (typeof e === 'string') {\r\n return (a: any, b: any) => {\r\n let a2 = a != null && Object.hasOwn(a, e) ? a[e] : a;\r\n let b2 = b != null && Object.hasOwn(b, e) ? b[e] : b;\r\n return a2 === b2;\r\n }\r\n }\r\n\r\n throw Error('invalid equality comparer');\r\n}\r\n\r\n/**\r\n * @private \r\n * @param items \r\n * @param value \r\n * @param comparer \r\n */\r\nexport function findValueByComparer(items: any[], value: any, comparer: EqualityComparer): any {\r\n if (!items || items.length === 0 || value === undefined || value === null) {\r\n return undefined;\r\n }\r\n \r\n return items.find(i => comparer(i, value));\r\n}\r\n\r\n/**\r\n * @private \r\n * @param items \r\n * @param values\r\n * @param comparer \r\n */\r\nexport function findValuesByComparer(items: any[], values: any[], comparer: EqualityComparer): any[] {\r\n if (!items || items.length === 0 || !values || values.length === 0) {\r\n return [];\r\n }\r\n\r\n const result: any[] = [];\r\n for (let v of values) {\r\n const item = items.find(i => comparer(i, v));\r\n if (item) {\r\n result.push(item);\r\n }\r\n }\r\n\r\n return result;\r\n}\r\n","/**\r\n * Value writer function type.\r\n * @param a The input value\r\n * @returns The written value\r\n */\r\nexport type ValueWriter = (a: any) => any;\r\n\r\n/**\r\n * Value writer can be a function or a string representing the property name to extract the value from.\r\n */\r\nexport type ValueWriterLike = ValueWriter | string;\r\n\r\n\r\n/**\r\n * Default value writer function.\r\n * @param a The input value\r\n * @returns the input value (it does not transform it)\r\n */\r\nexport function defaultValueWriter(a: any): any {\r\n return a;\r\n}\r\n\r\n/**\r\n * Converts a ValueWriterLike to a ValueWriterFunction.\r\n * @param v The value writer to convert.\r\n * @returns A ValueWriter function.\r\n */\r\nexport function valueWriterAttribute(v: ValueWriterLike): ValueWriter {\r\n if (typeof v === 'function')\r\n return v;\r\n if (typeof v === 'string') {\r\n return (item: any) => item ? item[v] : undefined;\r\n }\r\n\r\n throw Error('invalid value writer');\r\n}\r\n","/**\r\n * A comparison function type that defines an ordering relation between two values.\r\n * @param a The first value to compare.\r\n * @param b The second value to compare.\r\n * @returns\r\n * - A negative number if `a` should come before `b`\r\n * - A positive number if `a` should come after `b`\r\n * - Zero if `a` and `b` are considered equal\r\n */\r\nexport type Comparer = (a: any, b: any) => number;\r\n\r\n/**\r\n * Value comparer can be a function or a string representing the property name to compare.\r\n */\r\nexport type ComparerLike = Comparer | string;\r\n\r\n/**\r\n * A simple comparer function.\r\n * @param a The first value to compare.\r\n * @param b The second value to compare.\r\n * @returns -1 if a < b, 1 if a > b, 0 if a === b\r\n */\r\nexport function defaultComparer(a: any, b: any): number {\r\n return a === b ? 0 : a < b ? -1 : 1;\r\n}\r\n\r\n/**\r\n * Converts a ComparerLike to a Comparer.\r\n * @param v The comparer to convert.\r\n * @returns A function that compares two values.\r\n */\r\nexport function comparerAttribute(v: ComparerLike): Comparer {\r\n if (typeof v === 'function')\r\n return v;\r\n if (typeof v === 'string') {\r\n return (a: any, b: any) => a?.[v] === b?.[v] ? 0 : a?.[v] < b?.[v] ? -1 : 1;\r\n }\r\n\r\n throw Error('invalid value comparer');\r\n}\r\n\r\n","/**\r\n * Filter predicate function type.\r\n * @param item The item to test against the filter.\r\n * @returns True if the item matches the filter, false otherwise.\r\n */\r\nexport type FilterPredicate = (item: any) => boolean;\r\n\r\n/**\r\n * Filter predicate can be a function or a string representing the property name to filter.\r\n */\r\nexport type FilterPredicateLike = FilterPredicate | string;\r\n\r\n/**\r\n * \r\n * @param item \r\n * @returns \r\n */\r\nexport const noopFilter: FilterPredicate = (item: string) => true;\r\n\r\n\r\n/**\r\n * Converts a FilterPredicateLike to a FilterPredicate function.\r\n * If the input is a string, it creates a predicate that checks the property with that name.\r\n * @param v The FilterPredicateLike to convert.\r\n * @returns The corresponding FilterPredicate function.\r\n */\r\nexport function filterPredicateAttribute(v: FilterPredicateLike): FilterPredicate {\r\n if (typeof v === 'function')\r\n return v;\r\n\r\n throw Error('invalid filter predicate');\r\n}\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;MAEa,GAAG,GAAG,IAAI,cAAc,CAAU,eAAe;;ACC9D;;;;AAIG;AACG,SAAU,aAAa,CAAC,SAAoB,EAAA;IAC9C,QAAQ,SAAS;AACb,QAAA,KAAK,QAAQ;AACT,YAAA,OAAO,KAAK;AAChB,QAAA,KAAK,KAAK;AACN,YAAA,OAAO,QAAQ;AACnB,QAAA,KAAK,OAAO;AACR,YAAA,OAAO,KAAK;AAChB,QAAA,KAAK,K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