@bootkit/ng0 0.0.0-alpha.23 → 0.0.0-alpha.25

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 CHANGED
@@ -1,4 +1,5 @@
1
- import { InjectionToken } from '@angular/core';
1
+ import * as i0 from '@angular/core';
2
+ import { InjectionToken, TrackByFunction } from '@angular/core';
2
3
  import { Observable } from 'rxjs';
3
4
 
4
5
  declare const RTL: InjectionToken<boolean>;
@@ -91,14 +92,27 @@ declare function getEnumValues(enumClass: Record<string, string | number>): Arra
91
92
 
92
93
  /**
93
94
  * Type definition for an ID generator function.
95
+ * @param item The item for which the ID is to be generated.
96
+ * @returns A string representing the generated ID.
94
97
  */
95
- type IdGenerator = (param?: any) => string;
98
+ type IdGenerator = (item: any) => string;
99
+ /**
100
+ * Type definition for an ID generator which can be a function or a string representing the property name to extract the ID from.
101
+ */
102
+ type IdGeneratorLike = IdGenerator | string;
96
103
  /**
97
104
  * Creates a sequential ID generator function with an optional prefix.
105
+ * This function generates unique IDs by incrementing a counter each time it is called.
98
106
  * @param prefix Optional prefix for the generated IDs.
99
107
  * @returns A function that generates sequential IDs with the given prefix.
100
108
  */
101
109
  declare function sequentialIdGenerator(prefix?: string): IdGenerator;
110
+ /**
111
+ * Converts an IdGeneratorLike to an IdGenerator function.
112
+ * @param v The ID generator to convert.
113
+ * @returns An IdGenerator function.
114
+ */
115
+ declare function IdGeneratorAttribute(v: IdGeneratorLike): IdGenerator;
102
116
 
103
117
  /**
104
118
  * CSS class type which can be a string, array of strings, set of strings, or an object with class names as keys.
@@ -238,5 +252,39 @@ declare const noopFilter: FilterPredicate;
238
252
  */
239
253
  declare function filterPredicateAttribute(v: FilterPredicateLike): FilterPredicate;
240
254
 
241
- export { CssClassAttribute, RTL, comparerAttribute, defaultComparer, defaultEqualityComparer, defaultValueWriter, deleteEntries, equalityComparerAttribute, filterPredicateAttribute, findValueByComparer, findValuesByComparer, flipPlacement, formatString, getEnumValues, noopFilter, numberArray, sequentialIdGenerator, toObservable, valueWriterAttribute };
242
- export type { Alignment, ClaimLike, ClaimObject, Comparer, ComparerLike, CssClass, CssClassGetter, CssClassLike, EqualityComparer, EqualityComparerLike, FilterPredicate, FilterPredicateLike, IdGenerator, MenuItem, Placement, SelectOption, ValueWriter, ValueWriterLike };
255
+ /**
256
+ * An item tracker that can be either a TrackByFunction or a string property name.
257
+ */
258
+ type TrackByLike = TrackByFunction<any> | string;
259
+ /**
260
+ * A trackBy function that tracks items by their index.
261
+ */
262
+ declare const trackByIndex: TrackByFunction<any>;
263
+ /**
264
+ * A trackBy function that tracks items by the item itself.
265
+ */
266
+ declare const trackByItem: TrackByFunction<any>;
267
+ /**
268
+ * Converts a TrackByLike to a TrackByFunction.
269
+ * @param v The item tracker to convert.
270
+ * @returns A TrackByFunction.
271
+ */
272
+ declare function TrackByAttribute(v: TrackByLike): TrackByFunction<any>;
273
+
274
+ /**
275
+ * IfDirective is a structural directive that conditionally includes or excludes a template
276
+ * based on the boolean value of the `show` input property.
277
+ *
278
+ */
279
+ declare class IfDirective {
280
+ private readonly _templateRef;
281
+ private _vcr;
282
+ private _viewRef?;
283
+ readonly show: i0.InputSignal<boolean>;
284
+ constructor();
285
+ static ɵfac: i0.ɵɵFactoryDeclaration<IfDirective, never>;
286
+ static ɵdir: i0.ɵɵDirectiveDeclaration<IfDirective, "[ng0If]", ["ng0If"], { "show": { "alias": "ng0If"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
287
+ }
288
+
289
+ export { CssClassAttribute, IdGeneratorAttribute, IfDirective, RTL, TrackByAttribute, comparerAttribute, defaultComparer, defaultEqualityComparer, defaultValueWriter, deleteEntries, equalityComparerAttribute, filterPredicateAttribute, findValueByComparer, findValuesByComparer, flipPlacement, formatString, getEnumValues, noopFilter, numberArray, sequentialIdGenerator, toObservable, trackByIndex, trackByItem, valueWriterAttribute };
290
+ export type { Alignment, ClaimLike, ClaimObject, Comparer, ComparerLike, CssClass, CssClassGetter, CssClassLike, EqualityComparer, EqualityComparerLike, FilterPredicate, FilterPredicateLike, IdGenerator, IdGeneratorLike, MenuItem, Placement, SelectOption, TrackByLike, ValueWriter, ValueWriterLike };
@@ -1,29 +1,88 @@
1
1
  import * as _bootkit_ng0_localization from '@bootkit/ng0/localization';
2
2
  import * as _bootkit_ng0_common from '@bootkit/ng0/common';
3
- import { FilterPredicate, IdGenerator } from '@bootkit/ng0/common';
4
3
  import * as _angular_core from '@angular/core';
5
- import { TemplateRef, ElementRef, EventEmitter } from '@angular/core';
4
+ import { ElementRef, TemplateRef, EventEmitter } from '@angular/core';
6
5
  import { DataSource, DataSourceLike } from '@bootkit/ng0/data';
7
6
  import { ControlValueAccessor } from '@angular/forms';
8
7
 
9
8
  /**
10
- * Select component that allows users to choose an option from a dropdown list.
9
+ * ListItemComponent represents an individual item within a ListComponent.
10
+ */
11
+ declare class ListItemComponent {
12
+ /**
13
+ * The value associated with the item. This can be of any type.
14
+ */
15
+ readonly value: _angular_core.InputSignal<any>;
16
+ /**
17
+ * The id of the item.
18
+ */
19
+ readonly id: _angular_core.InputSignal<any>;
20
+ /**
21
+ * Reference to the parent list component
22
+ */
23
+ readonly list: ListComponent;
24
+ /**
25
+ * Reference to the host element
26
+ */
27
+ readonly elementRef: ElementRef<HTMLElement>;
28
+ /**
29
+ * Indicates whether the item is active.
30
+ * @returns True if the item is active, false otherwise.
31
+ */
32
+ isActive(): boolean;
33
+ /**
34
+ * Indicates whether the item is selected.
35
+ * @returns True if the item is selected, false otherwise.
36
+ */
37
+ isSelected(): boolean;
38
+ /**
39
+ * Selects the item.
40
+ * @returns
41
+ */
42
+ select(): void;
43
+ /**
44
+ * Deselects the item.
45
+ * @returns
46
+ */
47
+ deselect(): void;
48
+ /**
49
+ * Toggles the selection state of the item.
50
+ * @returns void
51
+ */
52
+ toggle(): void;
53
+ /**
54
+ * Scrolls the item into view within its parent container.
55
+ * @param position The vertical alignment of the item after scrolling.
56
+ * Can be 'start', 'center', 'end', or 'nearest'.
57
+ * Default is 'nearest'.
58
+ * @param behavior The scrolling behavior.
59
+ */
60
+ scrollIntoView(position?: ScrollLogicalPosition, behavior?: ScrollBehavior): void;
61
+ /**
62
+ * Sets focus on the item.
63
+ */
64
+ focus(): void;
65
+ private _getTabIndex;
66
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<ListItemComponent, never>;
67
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<ListItemComponent, "ng0-list-item", ["ng0ListItem"], { "value": { "alias": "value"; "required": false; "isSignal": true; }; "id": { "alias": "id"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
68
+ }
69
+
70
+ /**
71
+ * ListComponent is a versatile component that displays a list of items with support for single or multiple selection,
72
+ * custom item templates, filtering, and keyboard navigation.
11
73
  */
12
74
  declare class ListComponent implements ControlValueAccessor {
13
- private _document;
14
- private _ls;
15
- private _renderer;
16
- private _destroyRef;
75
+ private _localizationService;
17
76
  private _changeDetector;
18
77
  private _value;
19
78
  private _changeCallback?;
20
79
  private _touchCallback?;
21
- private _selectedIndices;
22
- protected readonly _items: _angular_core.WritableSignal<ListItem[]>;
80
+ protected readonly _sourceItems: _angular_core.WritableSignal<any[]>;
81
+ private readonly _selectedValues;
82
+ protected readonly _activeItem: _angular_core.WritableSignal<ListItemComponent | undefined>;
83
+ private readonly _visibleItems;
23
84
  protected readonly _isDisabled: _angular_core.WritableSignal<boolean>;
24
- protected readonly _activeOptionIndex: _angular_core.WritableSignal<number>;
25
- protected _itemTemplate?: TemplateRef<any>;
26
- private _ariaActiveDescendant;
85
+ itemTemplate?: TemplateRef<any>;
27
86
  /**
28
87
  * Reference to the host element
29
88
  */
@@ -61,7 +120,22 @@ declare class ListComponent implements ControlValueAccessor {
61
120
  * Default checks if the item's string representation contains the filter string (case-insensitive).
62
121
  * The filter predicate can be a function or a string representing the property name to filter.
63
122
  */
64
- readonly filterBy: _angular_core.InputSignalWithTransform<FilterPredicate, _bootkit_ng0_common.FilterPredicateLike>;
123
+ readonly filterBy: _angular_core.InputSignalWithTransform<_bootkit_ng0_common.FilterPredicate, _bootkit_ng0_common.FilterPredicateLike>;
124
+ /**
125
+ * A function that uniquely identifies each item in the list.
126
+ * If set to a function, it will be called with the index and item as arguments to generate the unique id.
127
+ * If set to a string, it will be used as the property name to extract the unique id from each item.
128
+ * Two predifined trackBy options are available:
129
+ * - '@index': uses the index of the item as its unique id.
130
+ * - '@item': uses the item itself as its unique id.
131
+ * @example
132
+ * trackBy="@index"
133
+ * trackBy="@item"
134
+ * trackBy="objectFieldName"
135
+ * [trackBy]="customTrackByFunction"
136
+ * @default trackByIndex
137
+ */
138
+ readonly trackBy: _angular_core.InputSignalWithTransform<_angular_core.TrackByFunction<any>, _bootkit_ng0_common.TrackByLike>;
65
139
  /**
66
140
  * CSS class or classes to apply to the list container.
67
141
  * Default is undefined.
@@ -76,131 +150,77 @@ declare class ListComponent implements ControlValueAccessor {
76
150
  */
77
151
  readonly focus: _angular_core.InputSignal<"none" | "roving" | "activeDescendant">;
78
152
  /**
79
- * Custom id generator function to generate unique ids for each item.
80
- * Default generates sequential ids with the prefix 'ng0-list-item-'.
81
- * If set to undefined, no ids will be generated.
82
- * @default sequentialIdGenerator('ng0-list-item-')
153
+ * A function that generates unique ids for each item in the list.
154
+ * If set to a function, it will be called with the item as an argument to generate the id.
155
+ * If set to undefined, no ids will be generated for the items.
156
+ * @default undefined
83
157
  */
84
- readonly idGenerator: _angular_core.InputSignal<IdGenerator>;
158
+ readonly idGenerator: _angular_core.InputSignalWithTransform<_bootkit_ng0_common.IdGenerator | undefined, _bootkit_ng0_common.IdGeneratorLike>;
85
159
  /**
86
160
  * Event emitted when the selection state of an item changes by user interaction.
87
161
  */
88
162
  readonly selectionChange: EventEmitter<ListSelectionChangeEvent>;
163
+ _uuid: number;
89
164
  constructor();
90
165
  /**
91
- * Gets the items of the list component.
92
- * @returns A readonly array of the items in the list.
93
- */
94
- items(): ReadonlyArray<ListItem>;
95
- /**
96
- * Sets an option as active
97
- * @param index The index of the option to set as active.
98
- * @param scrollIntoView Whether to scroll the active option into view. Default is true.
99
- * @returns void
100
- */
101
- active(index: number, scrollIntoView?: boolean): void;
102
- /**
103
- * Selects an option by index
104
- * @param index The index of the option to select.
105
- * @returns void
166
+ * Indicates whether an item is active.
167
+ * @param item
168
+ * @returns
106
169
  */
107
- select(index: number): void;
170
+ isActive(item: ListItemComponent): boolean;
108
171
  /**
109
- * Deselects an option by index
110
- * @param index The index of the option to deselect.
111
- * @returns void
172
+ * Indicates whether the given value is selected.
173
+ * @param item
174
+ * @returns
112
175
  */
113
- deselect(index: number): void;
176
+ isSelected(value: any): boolean;
114
177
  /**
115
- * Toggles the selection state of an option by index
116
- * @param index The index of the option to toggle.
117
- * @returns void
178
+ * Selects the given value.
179
+ * @param item
118
180
  */
119
- toggle(index: number): void;
181
+ select(value: any): void;
120
182
  /**
121
- * Checks if an option is selected.
122
- * @param index The index of the option to check.
123
- * @returns True if the option is selected, false otherwise.
183
+ * Deselects the given value.
184
+ * @param item
124
185
  */
125
- isSelected(index: number): boolean;
186
+ deselect(value: any): void;
126
187
  /**
127
- * Checks if an option is active.
128
- * @param index The index of the option to check.
129
- * @returns True if the option is active, false otherwise.
188
+ * Toggles the selection state of the given value.
189
+ * @param item
130
190
  */
131
- isActive(index: number): boolean;
191
+ toggle(value: any): void;
132
192
  /**
133
- * Sets the value of the list component.
134
- * @param value The value to set. Can be a single value or an array of values in multiple selection mode.
193
+ * Deselects all items in the list.
135
194
  */
136
- set(value: any): void;
195
+ deselectAll(): void;
137
196
  /**
138
- * Gets the currently selected indices.
139
- * @returns An array of the currently selected indices.
140
- * @description
141
- * - In single selection mode, the array will contain at most one item.
142
- * - In multiple selection mode, the array can contain multiple items.
143
- * - Changing the selection should be done using select(), deselect(), or toggle() methods to ensure proper event emission and state management.
144
- * - Direct manipulation of the returned array will not affect the component's state.
197
+ * Selects all items in the list. Only applicable in multiple selection mode.
145
198
  */
146
- selectedIndices(): ReadonlyArray<number>;
147
- /**
148
- * Scrolls the item at the specified index into view within the dropdown list.
149
- * @param index The index of the item to scroll into view.
150
- * @param position The vertical alignment of the item after scrolling.
151
- * Can be 'start', 'center', 'end', or 'nearest'.
152
- * Default is 'nearest'.
153
- * @param behavior The scrolling behavior.
154
- */
155
- scrollIntoView(index: number, position?: ScrollLogicalPosition, behavior?: ScrollBehavior): void;
199
+ selectAll(): void;
156
200
  writeValue(value: any): void;
157
- private _setValue;
158
201
  registerOnChange(fn: any): void;
159
202
  registerOnTouched(fn: any): void;
160
203
  setDisabledState?(isDisabled: boolean): void;
161
- protected _getItemTabIndex(index: number): -1 | 0 | undefined;
162
- protected _handleUserSelection(index: number, item: ListItem): void;
163
- private _loadItems;
164
- private _createItems;
204
+ protected _handleUserSelection(item: ListItemComponent): void;
205
+ protected _showLoadingSppiner: _angular_core.Signal<boolean>;
206
+ private _findAndSelectItems;
207
+ private _updateValue;
208
+ private _hostAriaActiveDescendant;
209
+ private _hostTabIndex;
165
210
  private _onHostClick;
211
+ private _onHostBlur;
166
212
  private _onKeydown;
167
- private _verifyIndexRange;
168
213
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<ListComponent, never>;
169
- static ɵcmp: _angular_core.ɵɵComponentDeclaration<ListComponent, "ng0-list", ["ng0List"], { "source": { "alias": "source"; "required": true; "isSignal": true; }; "multiple": { "alias": "multiple"; "required": false; "isSignal": true; }; "showSelectionIndicator": { "alias": "showSelectionIndicator"; "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; }; "filterBy": { "alias": "filterBy"; "required": false; "isSignal": true; }; "itemClass": { "alias": "itemClass"; "required": false; "isSignal": true; }; "focus": { "alias": "focus"; "required": false; "isSignal": true; }; "idGenerator": { "alias": "idGenerator"; "required": false; "isSignal": true; }; }, { "selectionChange": "selectionChange"; }, ["_itemTemplate"], never, true, never>;
170
- }
171
- /**
172
- * Represents an item in the list.
173
- */
174
- interface ListItem {
175
- /**
176
- * Id of the item (if idGenerator is provided, otherwise undefined).
177
- */
178
- id: string;
179
- /**
180
- * Value of the item.
181
- */
182
- value: any;
214
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<ListComponent, "ng0-list", ["ng0List"], { "source": { "alias": "source"; "required": true; "isSignal": true; }; "multiple": { "alias": "multiple"; "required": false; "isSignal": true; }; "showSelectionIndicator": { "alias": "showSelectionIndicator"; "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; }; "filterBy": { "alias": "filterBy"; "required": false; "isSignal": true; }; "trackBy": { "alias": "trackBy"; "required": false; "isSignal": true; }; "itemClass": { "alias": "itemClass"; "required": false; "isSignal": true; }; "focus": { "alias": "focus"; "required": false; "isSignal": true; }; "idGenerator": { "alias": "idGenerator"; "required": false; "isSignal": true; }; }, { "selectionChange": "selectionChange"; }, ["itemTemplate"], never, true, never>;
183
215
  }
184
216
  /**
185
217
  * Event emitted when the selection state of the list changes by user interaction.
186
218
  */
187
219
  interface ListSelectionChangeEvent {
188
220
  /**
189
- * Index of the item that was selected or deselected.
190
- */
191
- readonly index: number;
192
- /**
193
- * The value of the item that was selected or deselected.
194
- */
195
- readonly value: any;
196
- /**
197
- * Indicates whether the item was selected (true) or deselected (false).
198
- */
199
- readonly selected: boolean;
200
- /**
201
- * The indices of all currently selected items.
221
+ * The item that was selected or deselected.
202
222
  */
203
- readonly selectedIndices: ReadonlyArray<number>;
223
+ readonly item: ListItemComponent;
204
224
  /**
205
225
  * The list component that emitted the event.
206
226
  */
@@ -217,4 +237,4 @@ declare class ListModule {
217
237
  }
218
238
 
219
239
  export { ListComponent, ListModule };
220
- export type { ListItem, ListSelectionChangeEvent };
240
+ export type { ListSelectionChangeEvent };
@@ -13,13 +13,13 @@ declare class SidenavComponent implements OnInit, OnDestroy {
13
13
  private _vcr;
14
14
  private _elmentRef;
15
15
  private _renderer;
16
- open: _angular_core.InputSignal<boolean>;
16
+ open: _angular_core.InputSignalWithTransform<boolean, unknown>;
17
17
  mode: _angular_core.InputSignal<SidenavMode>;
18
18
  hasBackdrop: _angular_core.InputSignal<boolean>;
19
19
  zIndex: _angular_core.InputSignal<number | undefined>;
20
20
  position: _angular_core.InputSignal<SidenavPosition>;
21
21
  sidenavWidth: _angular_core.InputSignal<number>;
22
- fixedInViewport: _angular_core.InputSignal<boolean>;
22
+ fixedInViewport: _angular_core.InputSignalWithTransform<boolean, unknown>;
23
23
  backdropClick: EventEmitter<MouseEvent>;
24
24
  private _backdropRef?;
25
25
  private _backdropClickHandlerUnlisten?;
package/data/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as _angular_core from '@angular/core';
2
2
  import * as rxjs from 'rxjs';
3
- import { Observable, Subject } from 'rxjs';
3
+ import { Observable } from 'rxjs';
4
4
  import * as _bootkit_ng0_data from '@bootkit/ng0/data';
5
5
 
6
6
  /**
@@ -82,20 +82,6 @@ declare class DataResult<T = any> {
82
82
  constructor(data: T[], total?: number | undefined);
83
83
  }
84
84
 
85
- interface DataSourceChange {
86
- type: 'push';
87
- }
88
- interface DataSourcePushChange extends DataSourceChange {
89
- type: 'push';
90
- /**
91
- * The items to insert.
92
- */
93
- items: any[];
94
- }
95
- interface DataSourceChangeEvent {
96
- changes: Array<DataSourcePushChange>;
97
- }
98
-
99
85
  /**
100
86
  * DataLoader is a function that takes a DataRequest and returns an Observable of DataResult.
101
87
  * It is used by RemoteDataSource to load data asynchronously.
@@ -107,16 +93,12 @@ type DataLoader<T = any> = (request: DataRequest) => Observable<DataResult<T>>;
107
93
  */
108
94
  declare abstract class DataSource<T = any> {
109
95
  abstract readonly type: 'local' | 'remote';
110
- protected changeSubject: Subject<DataSourceChangeEvent>;
111
- protected loading: _angular_core.WritableSignal<boolean>;
112
- /**
113
- *
114
- */
115
- readonly change: Observable<DataSourceChangeEvent>;
96
+ protected _isLoading: _angular_core.WritableSignal<boolean>;
116
97
  /**
117
98
  * Indicates whether the data source is currently loading data.
118
99
  */
119
100
  isLoading: _angular_core.Signal<boolean>;
101
+ constructor();
120
102
  /**
121
103
  * Loads data from the data source.
122
104
  * @param request The data request object containing pagination, sorting, and filtering information.
@@ -157,6 +139,10 @@ declare class RemoteDataSource extends DataSource {
157
139
  declare class LocalDataSource extends DataSource {
158
140
  private items;
159
141
  readonly type = "local";
142
+ /**
143
+ * Creates a new LocalDataSource.
144
+ * @param items The array of items to be used as the data source.
145
+ */
160
146
  constructor(items: any[]);
161
147
  /**
162
148
  * Creates a LocalDataSource from enum values.
@@ -170,12 +156,6 @@ declare class LocalDataSource extends DataSource {
170
156
  * @returns An observable of DataResult containing the requested data.
171
157
  */
172
158
  load(request: DataRequest): rxjs.Observable<DataResult<any>>;
173
- /**
174
- * Adds items to the end of the local array.
175
- * @param items The items to add.
176
- */
177
- push(...items: any[]): void;
178
- private _validateIndex;
179
159
  }
180
160
 
181
161
  declare function toDataResult<T = any>(dr: DataRequest): (source: Observable<any>) => Observable<DataResult<T>>;
@@ -186,4 +166,4 @@ declare function toDataResult<T = any>(dr: DataRequest): (source: Observable<any
186
166
  type LogicalOperator = 'contains' | 'endsWith' | 'startsWith' | 'like' | 'eq' | 'ne' | 'gt' | 'gte' | 'lt' | 'lte';
187
167
 
188
168
  export { DataRequest, DataResult, DataSource, LocalDataSource, RemoteDataSource, dataSourceAttribute, toDataResult };
189
- export type { DataLoader, DataRequestFilter, DataRequestPage, DataRequestSort, DataSourceChange, DataSourceChangeEvent, DataSourceLike, DataSourcePushChange, LogicalOperator };
169
+ export type { DataLoader, DataRequestFilter, DataRequestPage, DataRequestSort, DataSourceLike, LogicalOperator };
@@ -1,4 +1,5 @@
1
- import { InjectionToken } from '@angular/core';
1
+ import * as i0 from '@angular/core';
2
+ import { InjectionToken, inject, TemplateRef, ViewContainerRef, input, effect, Directive } from '@angular/core';
2
3
  import { Observable, from, of } from 'rxjs';
3
4
 
4
5
  const RTL = new InjectionToken('RTL Direction');
@@ -92,12 +93,26 @@ function getEnumValues(enumClass) {
92
93
  let _idCounter = 0;
93
94
  /**
94
95
  * Creates a sequential ID generator function with an optional prefix.
96
+ * This function generates unique IDs by incrementing a counter each time it is called.
95
97
  * @param prefix Optional prefix for the generated IDs.
96
98
  * @returns A function that generates sequential IDs with the given prefix.
97
99
  */
98
100
  function sequentialIdGenerator(prefix) {
99
101
  return (item) => `${prefix || ''}${_idCounter++}`;
100
102
  }
103
+ /**
104
+ * Converts an IdGeneratorLike to an IdGenerator function.
105
+ * @param v The ID generator to convert.
106
+ * @returns An IdGenerator function.
107
+ */
108
+ function IdGeneratorAttribute(v) {
109
+ if (typeof v === 'function')
110
+ return v;
111
+ else if (typeof v === 'string') {
112
+ return (item) => item ? item[v] : undefined;
113
+ }
114
+ throw Error('invalid id generator');
115
+ }
101
116
 
102
117
  /**
103
118
  * Converts a CssClassLike to a CssClassGetter function.
@@ -237,9 +252,78 @@ function filterPredicateAttribute(v) {
237
252
  throw Error('invalid filter predicate');
238
253
  }
239
254
 
255
+ /**
256
+ * A trackBy function that tracks items by their index.
257
+ */
258
+ const trackByIndex = (index, item) => index;
259
+ /**
260
+ * A trackBy function that tracks items by the item itself.
261
+ */
262
+ const trackByItem = (index, item) => item;
263
+ /**
264
+ * Converts a TrackByLike to a TrackByFunction.
265
+ * @param v The item tracker to convert.
266
+ * @returns A TrackByFunction.
267
+ */
268
+ function TrackByAttribute(v) {
269
+ if (typeof v === 'function')
270
+ return v;
271
+ else if (typeof v === 'string') {
272
+ if (v.startsWith('@item')) {
273
+ return trackByItem;
274
+ }
275
+ else if (v.startsWith('@index')) {
276
+ return trackByIndex;
277
+ }
278
+ else {
279
+ return (index, item) => item ? item[v] : undefined;
280
+ }
281
+ }
282
+ throw Error('invalid TrackBy value');
283
+ }
284
+
285
+ /**
286
+ * IfDirective is a structural directive that conditionally includes or excludes a template
287
+ * based on the boolean value of the `show` input property.
288
+ *
289
+ */
290
+ class IfDirective {
291
+ _templateRef = inject((TemplateRef));
292
+ _vcr = inject(ViewContainerRef);
293
+ _viewRef;
294
+ show = input(true, ...(ngDevMode ? [{ debugName: "show", alias: 'ng0If' }] : [{ alias: 'ng0If' }]));
295
+ constructor() {
296
+ effect(() => {
297
+ if (this.show()) {
298
+ if (!this._viewRef) {
299
+ this._viewRef = this._vcr.createEmbeddedView(this._templateRef);
300
+ }
301
+ if (this._vcr.length === 0) {
302
+ this._vcr.insert(this._viewRef);
303
+ }
304
+ }
305
+ else {
306
+ if (this._vcr.length > 0) {
307
+ this._vcr.detach(0);
308
+ }
309
+ }
310
+ });
311
+ }
312
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.2.1", ngImport: i0, type: IfDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
313
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "20.2.1", type: IfDirective, isStandalone: true, selector: "[ng0If]", inputs: { show: { classPropertyName: "show", publicName: "ng0If", isSignal: true, isRequired: false, transformFunction: null } }, exportAs: ["ng0If"], ngImport: i0 });
314
+ }
315
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.2.1", ngImport: i0, type: IfDirective, decorators: [{
316
+ type: Directive,
317
+ args: [{
318
+ selector: '[ng0If]',
319
+ exportAs: 'ng0If',
320
+ standalone: true,
321
+ }]
322
+ }], ctorParameters: () => [] });
323
+
240
324
  /**
241
325
  * Generated bundle index. Do not edit.
242
326
  */
243
327
 
244
- export { CssClassAttribute, RTL, comparerAttribute, defaultComparer, defaultEqualityComparer, defaultValueWriter, deleteEntries, equalityComparerAttribute, filterPredicateAttribute, findValueByComparer, findValuesByComparer, flipPlacement, formatString, getEnumValues, noopFilter, numberArray, sequentialIdGenerator, toObservable, valueWriterAttribute };
328
+ export { CssClassAttribute, IdGeneratorAttribute, IfDirective, RTL, TrackByAttribute, comparerAttribute, defaultComparer, defaultEqualityComparer, defaultValueWriter, deleteEntries, equalityComparerAttribute, filterPredicateAttribute, findValueByComparer, findValuesByComparer, flipPlacement, formatString, getEnumValues, noopFilter, numberArray, sequentialIdGenerator, toObservable, trackByIndex, trackByItem, valueWriterAttribute };
245
329
  //# sourceMappingURL=bootkit-ng0-common.mjs.map