@bootkit/ng0 0.0.0-alpha.3 → 0.0.0-alpha.30

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.
Files changed (105) hide show
  1. package/common/index.d.ts +271 -7
  2. package/components/accordion/index.d.ts +1 -1
  3. package/components/backdrop/index.d.ts +12 -0
  4. package/components/button/index.d.ts +48 -0
  5. package/components/card/index.d.ts +27 -0
  6. package/components/code/index.d.ts +35 -0
  7. package/components/confirmation/index.d.ts +66 -0
  8. package/components/dropdown/index.d.ts +140 -0
  9. package/components/form-field/index.d.ts +24 -41
  10. package/components/list/index.d.ts +259 -0
  11. package/components/modal/index.d.ts +22 -4
  12. package/components/nav/index.d.ts +23 -19
  13. package/components/pagination/index.d.ts +35 -9
  14. package/components/popover/index.d.ts +1 -1
  15. package/components/select/index.d.ts +159 -0
  16. package/components/sidenav/index.d.ts +59 -0
  17. package/components/stepper/index.d.ts +26 -0
  18. package/components/table/index.d.ts +273 -0
  19. package/components/toast/index.d.ts +1 -1
  20. package/components/tooltip/index.d.ts +1 -1
  21. package/components/vertical-menu/index.d.ts +61 -0
  22. package/data/index.d.ts +145 -45
  23. package/date/index.d.ts +34 -0
  24. package/fesm2022/bootkit-ng0-common.mjs +295 -12
  25. package/fesm2022/bootkit-ng0-common.mjs.map +1 -1
  26. package/fesm2022/bootkit-ng0-components-accordion.mjs +15 -15
  27. package/fesm2022/bootkit-ng0-components-accordion.mjs.map +1 -1
  28. package/fesm2022/bootkit-ng0-components-backdrop.mjs +46 -0
  29. package/fesm2022/bootkit-ng0-components-backdrop.mjs.map +1 -0
  30. package/fesm2022/bootkit-ng0-components-button.mjs +119 -0
  31. package/fesm2022/bootkit-ng0-components-button.mjs.map +1 -0
  32. package/fesm2022/bootkit-ng0-components-card.mjs +62 -0
  33. package/fesm2022/bootkit-ng0-components-card.mjs.map +1 -0
  34. package/fesm2022/bootkit-ng0-components-code.mjs +70 -0
  35. package/fesm2022/bootkit-ng0-components-code.mjs.map +1 -0
  36. package/fesm2022/bootkit-ng0-components-collapse.mjs +16 -16
  37. package/fesm2022/bootkit-ng0-components-collapse.mjs.map +1 -1
  38. package/fesm2022/bootkit-ng0-components-confirmation.mjs +167 -0
  39. package/fesm2022/bootkit-ng0-components-confirmation.mjs.map +1 -0
  40. package/fesm2022/bootkit-ng0-components-dropdown.mjs +302 -0
  41. package/fesm2022/bootkit-ng0-components-dropdown.mjs.map +1 -0
  42. package/fesm2022/bootkit-ng0-components-form-field.mjs +62 -84
  43. package/fesm2022/bootkit-ng0-components-form-field.mjs.map +1 -1
  44. package/fesm2022/bootkit-ng0-components-list.mjs +563 -0
  45. package/fesm2022/bootkit-ng0-components-list.mjs.map +1 -0
  46. package/fesm2022/bootkit-ng0-components-modal.mjs +41 -24
  47. package/fesm2022/bootkit-ng0-components-modal.mjs.map +1 -1
  48. package/fesm2022/bootkit-ng0-components-nav.mjs +59 -60
  49. package/fesm2022/bootkit-ng0-components-nav.mjs.map +1 -1
  50. package/fesm2022/bootkit-ng0-components-offcanvas.mjs +10 -10
  51. package/fesm2022/bootkit-ng0-components-offcanvas.mjs.map +1 -1
  52. package/fesm2022/bootkit-ng0-components-overlay.mjs.map +1 -1
  53. package/fesm2022/bootkit-ng0-components-pagination.mjs +59 -24
  54. package/fesm2022/bootkit-ng0-components-pagination.mjs.map +1 -1
  55. package/fesm2022/bootkit-ng0-components-popover.mjs +11 -11
  56. package/fesm2022/bootkit-ng0-components-popover.mjs.map +1 -1
  57. package/fesm2022/bootkit-ng0-components-select.mjs +446 -0
  58. package/fesm2022/bootkit-ng0-components-select.mjs.map +1 -0
  59. package/fesm2022/bootkit-ng0-components-sidenav.mjs +153 -0
  60. package/fesm2022/bootkit-ng0-components-sidenav.mjs.map +1 -0
  61. package/fesm2022/bootkit-ng0-components-stepper.mjs +91 -0
  62. package/fesm2022/bootkit-ng0-components-stepper.mjs.map +1 -0
  63. package/fesm2022/bootkit-ng0-components-table.mjs +461 -0
  64. package/fesm2022/bootkit-ng0-components-table.mjs.map +1 -0
  65. package/fesm2022/bootkit-ng0-components-toast.mjs +7 -7
  66. package/fesm2022/bootkit-ng0-components-toast.mjs.map +1 -1
  67. package/fesm2022/bootkit-ng0-components-tooltip.mjs +9 -9
  68. package/fesm2022/bootkit-ng0-components-tooltip.mjs.map +1 -1
  69. package/fesm2022/bootkit-ng0-components-vertical-menu.mjs +161 -0
  70. package/fesm2022/bootkit-ng0-components-vertical-menu.mjs.map +1 -0
  71. package/fesm2022/bootkit-ng0-data.mjs +180 -90
  72. package/fesm2022/bootkit-ng0-data.mjs.map +1 -1
  73. package/fesm2022/bootkit-ng0-date.mjs +50 -0
  74. package/fesm2022/bootkit-ng0-date.mjs.map +1 -0
  75. package/fesm2022/bootkit-ng0-file.mjs +50 -0
  76. package/fesm2022/bootkit-ng0-file.mjs.map +1 -0
  77. package/fesm2022/bootkit-ng0-form.mjs +514 -0
  78. package/fesm2022/bootkit-ng0-form.mjs.map +1 -0
  79. package/fesm2022/bootkit-ng0-http.mjs +224 -176
  80. package/fesm2022/bootkit-ng0-http.mjs.map +1 -1
  81. package/fesm2022/bootkit-ng0-layouts-layout1.mjs +138 -0
  82. package/fesm2022/bootkit-ng0-layouts-layout1.mjs.map +1 -0
  83. package/fesm2022/bootkit-ng0-localization-locales.mjs +101 -0
  84. package/fesm2022/bootkit-ng0-localization-locales.mjs.map +1 -0
  85. package/fesm2022/bootkit-ng0-localization.mjs +347 -105
  86. package/fesm2022/bootkit-ng0-localization.mjs.map +1 -1
  87. package/fesm2022/bootkit-ng0-platform-browser.mjs +51 -0
  88. package/fesm2022/bootkit-ng0-platform-browser.mjs.map +1 -0
  89. package/fesm2022/bootkit-ng0-routing.mjs +80 -0
  90. package/fesm2022/bootkit-ng0-routing.mjs.map +1 -0
  91. package/fesm2022/bootkit-ng0-script.mjs +59 -0
  92. package/fesm2022/bootkit-ng0-script.mjs.map +1 -0
  93. package/fesm2022/bootkit-ng0-security.mjs +18 -16
  94. package/fesm2022/bootkit-ng0-security.mjs.map +1 -1
  95. package/file/index.d.ts +22 -0
  96. package/form/index.d.ts +127 -0
  97. package/http/index.d.ts +138 -37
  98. package/layouts/layout1/index.d.ts +92 -0
  99. package/localization/index.d.ts +180 -41
  100. package/localization/locales/index.d.ts +7 -0
  101. package/package.json +95 -15
  102. package/platform/browser/index.d.ts +22 -0
  103. package/routing/index.d.ts +124 -0
  104. package/script/index.d.ts +27 -0
  105. package/security/index.d.ts +3 -9
@@ -0,0 +1,563 @@
1
+ import * as i0 from '@angular/core';
2
+ import { input, inject, ElementRef, Directive, ChangeDetectorRef, signal, Renderer2, booleanAttribute, EventEmitter, effect, untracked, computed, TemplateRef, forwardRef, HostListener, Output, ViewChildren, ContentChild, ViewEncapsulation, ChangeDetectionStrategy, Component, NgModule } from '@angular/core';
3
+ import * as i1 from '@angular/common';
4
+ import { CommonModule } from '@angular/common';
5
+ import { dataSourceAttribute, DataRequest } from '@bootkit/ng0/data';
6
+ import { NG_VALUE_ACCESSOR } from '@angular/forms';
7
+ import { LocalizationService, defaultFormatter, objectFormatterAttribute } from '@bootkit/ng0/localization';
8
+ import { defaultEqualityComparer, equalityComparerAttribute, defaultValueWriter, valueWriterAttribute, noopFilter, filterPredicateAttribute, trackByIndex, TrackByAttribute, CssClassAttribute, IdGeneratorAttribute, IfDirective } from '@bootkit/ng0/common';
9
+
10
+ /**
11
+ * ListItem represents an individual item within a ListComponent.
12
+ */
13
+ class ListItem {
14
+ /**
15
+ * The value associated with the item. This can be of any type.
16
+ */
17
+ value = input(...(ngDevMode ? [undefined, { debugName: "value" }] : []));
18
+ /**
19
+ * The id of the item.
20
+ */
21
+ id = input(...(ngDevMode ? [undefined, { debugName: "id" }] : []));
22
+ /**
23
+ * Reference to the parent list component
24
+ */
25
+ list = inject(ListComponent);
26
+ /**
27
+ * Reference to the host element
28
+ */
29
+ elementRef = inject(ElementRef);
30
+ /**
31
+ * Indicates whether the item is active.
32
+ * @returns True if the item is active, false otherwise.
33
+ */
34
+ isActive() {
35
+ return this.list.isActive(this);
36
+ }
37
+ /**
38
+ * Indicates whether the item is selected.
39
+ * @returns True if the item is selected, false otherwise.
40
+ */
41
+ isSelected() {
42
+ return this.list.isSelected(this.value());
43
+ }
44
+ /**
45
+ * Selects the item.
46
+ * @returns
47
+ */
48
+ select() {
49
+ return this.list.select(this.value());
50
+ }
51
+ /**
52
+ * Deselects the item.
53
+ * @returns
54
+ */
55
+ deselect() {
56
+ this.list.deselect(this);
57
+ }
58
+ /**
59
+ * Toggles the selection state of the item.
60
+ * @returns void
61
+ */
62
+ toggle() {
63
+ this.list.toggle(this.value());
64
+ }
65
+ // /**
66
+ // * Indicates whether the item is disabled. Default is false.
67
+ // */
68
+ // public readonly disabled = input(false, { transform: booleanAttribute });
69
+ /**
70
+ * Scrolls the item into view within its parent container.
71
+ * @param position The vertical alignment of the item after scrolling.
72
+ * Can be 'start', 'center', 'end', or 'nearest'.
73
+ * Default is 'nearest'.
74
+ * @param behavior The scrolling behavior.
75
+ */
76
+ scrollIntoView(position, behavior) {
77
+ this.elementRef.nativeElement.scrollIntoView({ block: position, behavior: behavior });
78
+ }
79
+ /**
80
+ * Sets focus on the item.
81
+ */
82
+ focus() {
83
+ this.elementRef.nativeElement.focus();
84
+ }
85
+ _getTabIndex() {
86
+ let focus = this.list.focusMode();
87
+ // if (this.list.isDisabled()) {
88
+ // return undefined;
89
+ // }
90
+ if (focus == 'none' || focus == 'activeDescendant') {
91
+ return undefined;
92
+ }
93
+ else {
94
+ // focus: roving
95
+ return this.isActive() ? 0 : -1;
96
+ }
97
+ }
98
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: ListItem, deps: [], target: i0.ɵɵFactoryTarget.Directive });
99
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "20.3.9", type: ListItem, isStandalone: true, selector: "ng0-list-item", inputs: { value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null }, id: { classPropertyName: "id", publicName: "id", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "attr.id": "id()", "attr.tabIndex": "_getTabIndex()" } }, exportAs: ["ng0ListItem"], ngImport: i0 });
100
+ }
101
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: ListItem, decorators: [{
102
+ type: Directive,
103
+ args: [{
104
+ selector: 'ng0-list-item',
105
+ exportAs: 'ng0ListItem',
106
+ standalone: true,
107
+ host: {
108
+ '[attr.id]': 'id()',
109
+ '[attr.tabIndex]': '_getTabIndex()'
110
+ }
111
+ }]
112
+ }], propDecorators: { value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: false }] }], id: [{ type: i0.Input, args: [{ isSignal: true, alias: "id", required: false }] }] } });
113
+
114
+ /**
115
+ * ListComponent is a versatile component that displays a list of items with support for single or multiple selection,
116
+ * custom item templates, filtering, and keyboard navigation.
117
+ */
118
+ class ListComponent {
119
+ _localizationService = inject(LocalizationService);
120
+ _changeDetector = inject(ChangeDetectorRef);
121
+ _changeCallback;
122
+ _touchCallback;
123
+ _selectedItems = new Set();
124
+ _sourceItems = signal([], ...(ngDevMode ? [{ debugName: "_sourceItems" }] : []));
125
+ _itemTemplate;
126
+ _activeItem = signal(undefined, ...(ngDevMode ? [{ debugName: "_activeItem" }] : []));
127
+ _isDisabled = signal(false, ...(ngDevMode ? [{ debugName: "_isDisabled" }] : []));
128
+ _value = signal(undefined, ...(ngDevMode ? [{ debugName: "_value" }] : []));
129
+ _renderer = inject(Renderer2);
130
+ /**
131
+ * A list of all visible list items.
132
+ */
133
+ listItems;
134
+ /**
135
+ * Reference to the host element
136
+ */
137
+ elementRef = inject((ElementRef));
138
+ /**
139
+ * The data source for the select component.
140
+ * This can be an array of data, a function that returns an observable of data,
141
+ * or an instance of DataSource.
142
+ */
143
+ source = input.required(...(ngDevMode ? [{ debugName: "source", transform: v => dataSourceAttribute(v) }] : [{
144
+ transform: v => dataSourceAttribute(v)
145
+ }]));
146
+ /**
147
+ * Indicates whether multi selection is enabled or not.
148
+ */
149
+ multiple = input(false, ...(ngDevMode ? [{ debugName: "multiple", transform: booleanAttribute }] : [{
150
+ transform: booleanAttribute
151
+ }]));
152
+ /**
153
+ * Indicates whether to show selection indicator (checkbox/radio) next to each item.
154
+ * Default is false.
155
+ */
156
+ showSelectionIndicator = input(false, ...(ngDevMode ? [{ debugName: "showSelectionIndicator", transform: booleanAttribute }] : [{
157
+ transform: booleanAttribute
158
+ }]));
159
+ /**
160
+ * A comparer to compare items for selection.
161
+ * Default uses strict equality (===).
162
+ */
163
+ compareBy = input(defaultEqualityComparer, ...(ngDevMode ? [{ debugName: "compareBy", transform: equalityComparerAttribute }] : [{
164
+ transform: equalityComparerAttribute
165
+ }]));
166
+ /**
167
+ * A fromatter to convert each item to a string for display.
168
+ * Default converts the item to a string using its toString method.
169
+ */
170
+ formatBy = input(defaultFormatter, ...(ngDevMode ? [{ debugName: "formatBy", transform: objectFormatterAttribute(this._localizationService.get()) }] : [{
171
+ transform: objectFormatterAttribute(this._localizationService.get())
172
+ }]));
173
+ /**
174
+ * Custom value writer to extract the value of any object while writing values.
175
+ */
176
+ writeBy = input(defaultValueWriter, ...(ngDevMode ? [{ debugName: "writeBy", transform: valueWriterAttribute }] : [{
177
+ transform: valueWriterAttribute
178
+ }]));
179
+ /**
180
+ * Custom filter function to filter items.
181
+ * Default is a noop filter that does not filter any items.
182
+ */
183
+ filterBy = input(noopFilter, ...(ngDevMode ? [{ debugName: "filterBy", transform: filterPredicateAttribute }] : [{
184
+ transform: filterPredicateAttribute
185
+ }]));
186
+ /**
187
+ * A function that uniquely identifies each item in the list.
188
+ * If set to a function, it will be called with the index and item as arguments to generate the unique id.
189
+ * If set to a string, it will be used as the property name to extract the unique id from each item.
190
+ * Two predifined trackBy options are available:
191
+ * - '@index': uses the index of the item as its unique id.
192
+ * - '@item': uses the item itself as its unique id.
193
+ * @example
194
+ * trackBy="@index"
195
+ * trackBy="@item"
196
+ * trackBy="objectFieldName"
197
+ * [trackBy]="customTrackByFunction"
198
+ * @default trackByIndex
199
+ */
200
+ trackBy = input(trackByIndex, ...(ngDevMode ? [{ debugName: "trackBy", transform: TrackByAttribute }] : [{
201
+ transform: TrackByAttribute
202
+ }]));
203
+ /**
204
+ * CSS class or classes to apply to the list container.
205
+ * Default is undefined.
206
+ */
207
+ itemClass = input(undefined, ...(ngDevMode ? [{ debugName: "itemClass", transform: CssClassAttribute }] : [{
208
+ transform: CssClassAttribute
209
+ }]));
210
+ /**
211
+ * Defines the focus behavior of the list component.
212
+ * - 'none': No keyboard interaction is possible. The list cannot be focused.
213
+ * - 'roving': Roving tabindex is enabled. The list can be focused and the active item is tabbable.
214
+ * - 'activeDescendant': The list can be focused, but no item is tabbable. The active item is indicated using aria-activedescendant.
215
+ * @default 'activeDescendant'.
216
+ */
217
+ focusMode = input('activeDescendant', ...(ngDevMode ? [{ debugName: "focusMode" }] : []));
218
+ /**
219
+ * A function that generates unique ids for each item in the list.
220
+ * If set to a function, it will be called with the item as an argument to generate the id.
221
+ * If set to undefined, no ids will be generated for the items.
222
+ * @default undefined
223
+ */
224
+ idGenerator = input(undefined, ...(ngDevMode ? [{ debugName: "idGenerator", transform: IdGeneratorAttribute }] : [{
225
+ transform: IdGeneratorAttribute
226
+ }]));
227
+ /**
228
+ * Event emitted when the selection state of an item changes by user interaction.
229
+ */
230
+ itemSelect = new EventEmitter();
231
+ /**
232
+ * The template to use for each item in the list.
233
+ */
234
+ itemTemplate = input(undefined, ...(ngDevMode ? [{ debugName: "itemTemplate" }] : []));
235
+ constructor() {
236
+ effect(() => {
237
+ this.source().load(new DataRequest()).subscribe(res => {
238
+ untracked(() => {
239
+ this._activeItem.set(undefined);
240
+ this._sourceItems.set(res.data);
241
+ this._updateSelectedItems();
242
+ this._activateFirstSelectedItem();
243
+ });
244
+ });
245
+ });
246
+ }
247
+ /**
248
+ * Indicates whether an item is active.
249
+ * @param item
250
+ * @returns
251
+ */
252
+ isActive(item) {
253
+ return item === this._activeItem();
254
+ }
255
+ /**
256
+ * Indicates whether the given value is selected.
257
+ * @param item
258
+ * @returns
259
+ */
260
+ isSelected(value) {
261
+ return this._selectedItems.has(value);
262
+ }
263
+ /**
264
+ * Selects the given value.
265
+ * @param item
266
+ */
267
+ select(value) {
268
+ if (this.multiple()) {
269
+ if (!this._selectedItems.has(value)) {
270
+ this._selectedItems.add(value);
271
+ this._updateValue();
272
+ this._changeCallback?.(this._value());
273
+ }
274
+ }
275
+ else {
276
+ this._selectedItems.clear();
277
+ this._selectedItems.add(value);
278
+ this._updateValue();
279
+ this._changeCallback?.(this._value());
280
+ }
281
+ }
282
+ /**
283
+ * Deselects the given value.
284
+ * @param item
285
+ */
286
+ deselect(value) {
287
+ this._selectedItems.delete(value);
288
+ this._updateValue();
289
+ this._changeCallback?.(this._value());
290
+ }
291
+ /**
292
+ * Toggles the selection state of the given value.
293
+ * @param item
294
+ */
295
+ toggle(value) {
296
+ if (this.isSelected(value)) {
297
+ this.deselect(value);
298
+ }
299
+ else {
300
+ this.select(value);
301
+ }
302
+ }
303
+ /**
304
+ * Deselects all items in the list.
305
+ */
306
+ deselectAll() {
307
+ this._selectedItems.clear();
308
+ this._updateValue();
309
+ this._changeCallback?.(this._value());
310
+ }
311
+ /**
312
+ * Selects all items in the list. Only applicable in multiple selection mode.
313
+ */
314
+ selectAll() {
315
+ if (this.multiple()) {
316
+ this._selectedItems.clear();
317
+ this._sourceItems().forEach(i => this._selectedItems.add(i));
318
+ this._updateValue();
319
+ this._changeCallback?.(this._value());
320
+ }
321
+ else {
322
+ throw new Error('selectAll is only available in multiple selection mode.');
323
+ }
324
+ }
325
+ /**
326
+ * Gets the current value(s) of the list.
327
+ */
328
+ get value() {
329
+ return this._value();
330
+ }
331
+ /**
332
+ * Gets the current items in the list.
333
+ */
334
+ get items() {
335
+ return this._sourceItems();
336
+ }
337
+ writeValue(value) {
338
+ if (this.multiple()) {
339
+ if (value === null || value === undefined) {
340
+ value = [];
341
+ }
342
+ else if (!Array.isArray(value)) {
343
+ throw Error('invalid value. Expected an array in multiple selection mode.');
344
+ }
345
+ }
346
+ this._value.set(value);
347
+ this._updateSelectedItems();
348
+ this._activateFirstSelectedItem();
349
+ this._changeDetector.markForCheck();
350
+ }
351
+ registerOnChange(fn) {
352
+ this._changeCallback = fn;
353
+ }
354
+ registerOnTouched(fn) {
355
+ this._touchCallback = fn;
356
+ }
357
+ setDisabledState(isDisabled) {
358
+ this._isDisabled.set(isDisabled);
359
+ }
360
+ _handleUserSelection(item, index) {
361
+ let value = item.value();
362
+ if (this.multiple()) {
363
+ this.toggle(value);
364
+ }
365
+ else {
366
+ this.select(value);
367
+ }
368
+ this._activeItem.set(item);
369
+ this.itemSelect.emit({ value: item.value(), item: item, list: this });
370
+ this._changeDetector.detectChanges();
371
+ }
372
+ _showLoadingSppiner = computed(() => {
373
+ let source = this.source();
374
+ return source.isLoading() && source.type == 'remote';
375
+ }, ...(ngDevMode ? [{ debugName: "_showLoadingSppiner" }] : []));
376
+ _updateSelectedItems() {
377
+ let value = this._value();
378
+ let compareBy = this.compareBy();
379
+ let findAndSelect = (v) => {
380
+ let index = this._sourceItems().findIndex(i => compareBy(i, v));
381
+ if (index > -1) {
382
+ let item = this._sourceItems().at(index);
383
+ this._selectedItems.add(item);
384
+ }
385
+ return index;
386
+ };
387
+ this._selectedItems.clear();
388
+ if (this.multiple()) {
389
+ if (Array.isArray(value)) {
390
+ value.forEach(v => findAndSelect(v));
391
+ }
392
+ }
393
+ else {
394
+ findAndSelect(value);
395
+ }
396
+ }
397
+ _activateFirstSelectedItem() {
398
+ if (this._selectedItems.size > 0) {
399
+ let value = this._selectedItems.values().next().value;
400
+ let item = this.listItems?.find(i => i.value() === value);
401
+ if (item) {
402
+ this._activeItem.set(item);
403
+ }
404
+ }
405
+ }
406
+ _updateValue() {
407
+ let value;
408
+ if (this.multiple()) {
409
+ let values = [];
410
+ this._selectedItems.forEach(v => {
411
+ values.push(this.writeBy()(v));
412
+ });
413
+ value = values;
414
+ }
415
+ else {
416
+ if (this._selectedItems.size > 0) {
417
+ let first = this._selectedItems.values().next().value;
418
+ value = this.writeBy()(first);
419
+ }
420
+ else {
421
+ value = undefined;
422
+ }
423
+ }
424
+ this._value.set(value);
425
+ }
426
+ _hostAriaActiveDescendant = computed(() => {
427
+ if (this._activeItem() && !this._isDisabled() && this.focusMode() == 'activeDescendant') {
428
+ return this._activeItem().id();
429
+ }
430
+ return undefined;
431
+ }, ...(ngDevMode ? [{ debugName: "_hostAriaActiveDescendant" }] : []));
432
+ _hostTabIndex = computed(() => {
433
+ let isDisabled = this._isDisabled(); // track the value
434
+ let activeItem = this._activeItem(); // track the value
435
+ if (isDisabled) {
436
+ return undefined;
437
+ }
438
+ switch (this.focusMode()) {
439
+ case 'none':
440
+ return undefined;
441
+ case 'activeDescendant':
442
+ return 0;
443
+ case 'roving':
444
+ return activeItem ? undefined : 0;
445
+ }
446
+ }, ...(ngDevMode ? [{ debugName: "_hostTabIndex" }] : []));
447
+ _onHostBlur() {
448
+ this._touchCallback?.();
449
+ }
450
+ _onKeydown(e) {
451
+ if (this._isDisabled())
452
+ return;
453
+ let listLength = this.listItems.length;
454
+ if (listLength == 0) {
455
+ return;
456
+ }
457
+ let activeItem = this._activeItem();
458
+ let activeItemindex = activeItem ? this.listItems.toArray().findIndex(i => i === activeItem) : -1;
459
+ switch (e.key) {
460
+ case 'ArrowDown':
461
+ if (activeItemindex < listLength - 1) {
462
+ const next = this.listItems.get(activeItemindex + 1);
463
+ this._activeItem.set(next);
464
+ }
465
+ e.preventDefault();
466
+ break;
467
+ case 'ArrowUp':
468
+ if (activeItemindex == -1) {
469
+ const last = this.listItems.get(listLength - 1);
470
+ this._activeItem.set(last);
471
+ }
472
+ else if (activeItemindex > 0) {
473
+ const previous = this.listItems.get(activeItemindex - 1);
474
+ this._activeItem.set(previous);
475
+ }
476
+ e.preventDefault();
477
+ break;
478
+ case 'Enter':
479
+ if (activeItem) {
480
+ this._handleUserSelection(activeItem, activeItemindex);
481
+ }
482
+ break;
483
+ case 'Home':
484
+ const first = this.listItems.get(0);
485
+ this._activeItem.set(first);
486
+ e.preventDefault();
487
+ break;
488
+ case 'End':
489
+ const last = this.listItems.get(listLength - 1);
490
+ this._activeItem.set(last);
491
+ e.preventDefault();
492
+ break;
493
+ }
494
+ this._activeItem()?.scrollIntoView('nearest', listLength > 100 ? 'instant' : 'smooth');
495
+ if (this.focusMode() === 'roving') {
496
+ this._activeItem()?.focus();
497
+ }
498
+ }
499
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: ListComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
500
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.9", type: ListComponent, isStandalone: true, selector: "ng0-list, ng0-select-list", inputs: { source: { classPropertyName: "source", publicName: "source", isSignal: true, isRequired: true, transformFunction: null }, multiple: { classPropertyName: "multiple", publicName: "multiple", isSignal: true, isRequired: false, transformFunction: null }, showSelectionIndicator: { classPropertyName: "showSelectionIndicator", publicName: "showSelectionIndicator", isSignal: true, isRequired: false, transformFunction: null }, compareBy: { classPropertyName: "compareBy", publicName: "compareBy", isSignal: true, isRequired: false, transformFunction: null }, formatBy: { classPropertyName: "formatBy", publicName: "formatBy", isSignal: true, isRequired: false, transformFunction: null }, writeBy: { classPropertyName: "writeBy", publicName: "writeBy", isSignal: true, isRequired: false, transformFunction: null }, filterBy: { classPropertyName: "filterBy", publicName: "filterBy", isSignal: true, isRequired: false, transformFunction: null }, trackBy: { classPropertyName: "trackBy", publicName: "trackBy", isSignal: true, isRequired: false, transformFunction: null }, itemClass: { classPropertyName: "itemClass", publicName: "itemClass", isSignal: true, isRequired: false, transformFunction: null }, focusMode: { classPropertyName: "focusMode", publicName: "focusMode", isSignal: true, isRequired: false, transformFunction: null }, idGenerator: { classPropertyName: "idGenerator", publicName: "idGenerator", isSignal: true, isRequired: false, transformFunction: null }, itemTemplate: { classPropertyName: "itemTemplate", publicName: "itemTemplate", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { itemSelect: "itemSelect" }, host: { listeners: { "blur": "_onHostBlur()", "keydown": "_onKeydown($event)" }, properties: { "class.ng0-list-loading": "source().isLoading()", "attr.aria-activedescendant": "_hostAriaActiveDescendant()", "attr.disabled": "_isDisabled() ? \"\" : undefined", "attr.aria-disabled": "_isDisabled() ? \"\" : undefined", "attr.tabindex": "_hostTabIndex()" } }, providers: [{
501
+ provide: NG_VALUE_ACCESSOR,
502
+ useExisting: forwardRef(() => ListComponent),
503
+ multi: true
504
+ }], queries: [{ propertyName: "_itemTemplate", first: true, predicate: TemplateRef, descendants: true }], viewQueries: [{ propertyName: "listItems", predicate: ListItem, descendants: true }], exportAs: ["ng0List"], ngImport: i0, template: "@let filter = filterBy();\r\n@let formatter = formatBy();\r\n\r\n@for (item of _sourceItems(); track trackBy()($index, item)) {\r\n\r\n<ng0-list-item #listItem=\"ng0ListItem\"\r\n *ng0If=\"!filter || filter(item)\"\r\n [value]=\"item\"\r\n [id]=\"idGenerator()?.(item)\"\r\n [class.active]=\"isActive(listItem)\"\r\n [class.selected]=\"isSelected(item)\"\r\n [ngClass]=\"itemClass()?.(item)\"\r\n (click)=\"_handleUserSelection(listItem, $index);\">\r\n\r\n @if(itemTemplate() || _itemTemplate) {\r\n @let template = itemTemplate() || _itemTemplate;\r\n <ng-container *ngTemplateOutlet=\"template; context: { $implicit: {item: listItem, value: item}}\" />\r\n } @else {\r\n @if(showSelectionIndicator()) {\r\n <input class=\"form-check-input ng0-selection-indicator\"\r\n tabindex=\"-1\"\r\n [checked]=\"isSelected(item)\"\r\n [attr.type]=\"multiple() ? 'checkbox' : 'radio'\">\r\n }\r\n\r\n {{formatter(item)}}\r\n }\r\n</ng0-list-item>\r\n}\r\n\r\n@if(_showLoadingSppiner()) {\r\n@if(_sourceItems().length == 0) {\r\n<div style=\"text-align: center; padding: 0.5rem 0;\">\r\n <ng-container *ngTemplateOutlet=\"spinner\"></ng-container>\r\n</div>\r\n}@else {\r\n<div class=\"ng0-list-loading-cover\">\r\n <ng-container *ngTemplateOutlet=\"spinner\"></ng-container>\r\n</div>\r\n}\r\n}\r\n\r\n<ng-template #spinner>\r\n <div class=\"spinner-border spinner-sm text-primary ng0-list-loading-indicator\" role=\"status\">\r\n <span class=\"visually-hidden\">Loading...</span>\r\n </div>\r\n</ng-template>", styles: ["ng0-list:not(.ng0-list-unstyled){display:block;position:relative;-webkit-user-select:none;user-select:none;border:1px solid var(--bs-border-color);border-radius:var(--bs-border-radius)}ng0-list:not(.ng0-list-unstyled):focus,ng0-list:not(.ng0-list-unstyled):focus-visible{outline:0;box-shadow:var(--bs-focus-ring-x, 0) var(--bs-focus-ring-y, 0) var(--bs-focus-ring-blur, 0) var(--bs-focus-ring-width) var(--bs-focus-ring-color)}ng0-list:not(.ng0-list-unstyled)[disabled],ng0-list:not(.ng0-list-unstyled).disabled{opacity:.5;pointer-events:none}ng0-list:not(.ng0-list-unstyled) .ng0-list-loading-cover{position:absolute;top:0;left:0;width:100%;height:100%;background-color:#ffffffb3;display:flex;align-items:center;justify-content:center}ng0-list:not(.ng0-list-unstyled) ng0-list-item{display:flex}ng0-list:not(.ng0-list-unstyled) ng0-list-item .ng0-selection-indicator{margin-inline-end:.5rem}ng0-list:not(.ng0-list-unstyled) ng0-list-item:focus,ng0-list:not(.ng0-list-unstyled) ng0-list-item:focus-visible{outline:0;box-shadow:var(--bs-focus-ring-x, 0) var(--bs-focus-ring-y, 0) var(--bs-focus-ring-blur, 0) var(--bs-focus-ring-width) var(--bs-focus-ring-color)}ng0-list:not(.ng0-list-unstyled) ng0-list-item{padding:.5rem}ng0-list:not(.ng0-list-unstyled) ng0-list-item.selected{background-color:var(--bs-primary);color:var(--bs-light)}ng0-list:not(.ng0-list-unstyled) ng0-list-item.active:not(.selected){background-color:color-mix(in srgb,var(--bs-primary),white 85%)}ng0-list:not(.ng0-list-unstyled) ng0-list-item:hover:not(.selected):not(.disabled):not(.active){background-color:color-mix(in srgb,var(--bs-primary),white 95%)}ng0-list:not(.ng0-list-unstyled) ng0-list-item:first-child{border-top-left-radius:inherit;border-top-right-radius:inherit}ng0-list:not(.ng0-list-unstyled) ng0-list-item:last-child{border-bottom-left-radius:inherit;border-bottom-right-radius:inherit}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: IfDirective, selector: "[ng0If]", inputs: ["ng0If"], exportAs: ["ng0If"] }, { kind: "directive", type: ListItem, selector: "ng0-list-item", inputs: ["value", "id"], exportAs: ["ng0ListItem"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
505
+ }
506
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: ListComponent, decorators: [{
507
+ type: Component,
508
+ args: [{ selector: 'ng0-list, ng0-select-list', exportAs: 'ng0List', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, imports: [
509
+ CommonModule,
510
+ IfDirective,
511
+ ListItem
512
+ ], providers: [{
513
+ provide: NG_VALUE_ACCESSOR,
514
+ useExisting: forwardRef(() => ListComponent),
515
+ multi: true
516
+ }], host: {
517
+ '[class.ng0-list-loading]': 'source().isLoading()',
518
+ '[attr.aria-activedescendant]': '_hostAriaActiveDescendant()',
519
+ '[attr.disabled]': '_isDisabled() ? "" : undefined',
520
+ '[attr.aria-disabled]': '_isDisabled() ? "" : undefined',
521
+ '[attr.tabindex]': '_hostTabIndex()',
522
+ }, template: "@let filter = filterBy();\r\n@let formatter = formatBy();\r\n\r\n@for (item of _sourceItems(); track trackBy()($index, item)) {\r\n\r\n<ng0-list-item #listItem=\"ng0ListItem\"\r\n *ng0If=\"!filter || filter(item)\"\r\n [value]=\"item\"\r\n [id]=\"idGenerator()?.(item)\"\r\n [class.active]=\"isActive(listItem)\"\r\n [class.selected]=\"isSelected(item)\"\r\n [ngClass]=\"itemClass()?.(item)\"\r\n (click)=\"_handleUserSelection(listItem, $index);\">\r\n\r\n @if(itemTemplate() || _itemTemplate) {\r\n @let template = itemTemplate() || _itemTemplate;\r\n <ng-container *ngTemplateOutlet=\"template; context: { $implicit: {item: listItem, value: item}}\" />\r\n } @else {\r\n @if(showSelectionIndicator()) {\r\n <input class=\"form-check-input ng0-selection-indicator\"\r\n tabindex=\"-1\"\r\n [checked]=\"isSelected(item)\"\r\n [attr.type]=\"multiple() ? 'checkbox' : 'radio'\">\r\n }\r\n\r\n {{formatter(item)}}\r\n }\r\n</ng0-list-item>\r\n}\r\n\r\n@if(_showLoadingSppiner()) {\r\n@if(_sourceItems().length == 0) {\r\n<div style=\"text-align: center; padding: 0.5rem 0;\">\r\n <ng-container *ngTemplateOutlet=\"spinner\"></ng-container>\r\n</div>\r\n}@else {\r\n<div class=\"ng0-list-loading-cover\">\r\n <ng-container *ngTemplateOutlet=\"spinner\"></ng-container>\r\n</div>\r\n}\r\n}\r\n\r\n<ng-template #spinner>\r\n <div class=\"spinner-border spinner-sm text-primary ng0-list-loading-indicator\" role=\"status\">\r\n <span class=\"visually-hidden\">Loading...</span>\r\n </div>\r\n</ng-template>", styles: ["ng0-list:not(.ng0-list-unstyled){display:block;position:relative;-webkit-user-select:none;user-select:none;border:1px solid var(--bs-border-color);border-radius:var(--bs-border-radius)}ng0-list:not(.ng0-list-unstyled):focus,ng0-list:not(.ng0-list-unstyled):focus-visible{outline:0;box-shadow:var(--bs-focus-ring-x, 0) var(--bs-focus-ring-y, 0) var(--bs-focus-ring-blur, 0) var(--bs-focus-ring-width) var(--bs-focus-ring-color)}ng0-list:not(.ng0-list-unstyled)[disabled],ng0-list:not(.ng0-list-unstyled).disabled{opacity:.5;pointer-events:none}ng0-list:not(.ng0-list-unstyled) .ng0-list-loading-cover{position:absolute;top:0;left:0;width:100%;height:100%;background-color:#ffffffb3;display:flex;align-items:center;justify-content:center}ng0-list:not(.ng0-list-unstyled) ng0-list-item{display:flex}ng0-list:not(.ng0-list-unstyled) ng0-list-item .ng0-selection-indicator{margin-inline-end:.5rem}ng0-list:not(.ng0-list-unstyled) ng0-list-item:focus,ng0-list:not(.ng0-list-unstyled) ng0-list-item:focus-visible{outline:0;box-shadow:var(--bs-focus-ring-x, 0) var(--bs-focus-ring-y, 0) var(--bs-focus-ring-blur, 0) var(--bs-focus-ring-width) var(--bs-focus-ring-color)}ng0-list:not(.ng0-list-unstyled) ng0-list-item{padding:.5rem}ng0-list:not(.ng0-list-unstyled) ng0-list-item.selected{background-color:var(--bs-primary);color:var(--bs-light)}ng0-list:not(.ng0-list-unstyled) ng0-list-item.active:not(.selected){background-color:color-mix(in srgb,var(--bs-primary),white 85%)}ng0-list:not(.ng0-list-unstyled) ng0-list-item:hover:not(.selected):not(.disabled):not(.active){background-color:color-mix(in srgb,var(--bs-primary),white 95%)}ng0-list:not(.ng0-list-unstyled) ng0-list-item:first-child{border-top-left-radius:inherit;border-top-right-radius:inherit}ng0-list:not(.ng0-list-unstyled) ng0-list-item:last-child{border-bottom-left-radius:inherit;border-bottom-right-radius:inherit}\n"] }]
523
+ }], ctorParameters: () => [], propDecorators: { _itemTemplate: [{
524
+ type: ContentChild,
525
+ args: [TemplateRef]
526
+ }], listItems: [{
527
+ type: ViewChildren,
528
+ args: [ListItem]
529
+ }], source: [{ type: i0.Input, args: [{ isSignal: true, alias: "source", required: true }] }], multiple: [{ type: i0.Input, args: [{ isSignal: true, alias: "multiple", required: false }] }], showSelectionIndicator: [{ type: i0.Input, args: [{ isSignal: true, alias: "showSelectionIndicator", required: false }] }], compareBy: [{ type: i0.Input, args: [{ isSignal: true, alias: "compareBy", required: false }] }], formatBy: [{ type: i0.Input, args: [{ isSignal: true, alias: "formatBy", required: false }] }], writeBy: [{ type: i0.Input, args: [{ isSignal: true, alias: "writeBy", required: false }] }], filterBy: [{ type: i0.Input, args: [{ isSignal: true, alias: "filterBy", required: false }] }], trackBy: [{ type: i0.Input, args: [{ isSignal: true, alias: "trackBy", required: false }] }], itemClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "itemClass", required: false }] }], focusMode: [{ type: i0.Input, args: [{ isSignal: true, alias: "focusMode", required: false }] }], idGenerator: [{ type: i0.Input, args: [{ isSignal: true, alias: "idGenerator", required: false }] }], itemSelect: [{
530
+ type: Output
531
+ }], itemTemplate: [{ type: i0.Input, args: [{ isSignal: true, alias: "itemTemplate", required: false }] }], _onHostBlur: [{
532
+ type: HostListener,
533
+ args: ['blur']
534
+ }], _onKeydown: [{
535
+ type: HostListener,
536
+ args: ['keydown', ['$event']]
537
+ }] } });
538
+
539
+ const Items = [ListComponent];
540
+ /**
541
+ * List module.
542
+ */
543
+ class ListModule {
544
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: ListModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
545
+ static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.9", ngImport: i0, type: ListModule, imports: [ListComponent], exports: [ListComponent] });
546
+ static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: ListModule, imports: [Items] });
547
+ }
548
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: ListModule, decorators: [{
549
+ type: NgModule,
550
+ args: [{
551
+ imports: Items,
552
+ exports: Items
553
+ }]
554
+ }] });
555
+
556
+ // export * from './types';
557
+
558
+ /**
559
+ * Generated bundle index. Do not edit.
560
+ */
561
+
562
+ export { ListComponent, ListModule };
563
+ //# sourceMappingURL=bootkit-ng0-components-list.mjs.map