@shival99/z-ui 2.6.6 → 2.6.8

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 (82) hide show
  1. package/assets/css/base.css +16 -16
  2. package/fesm2022/shival99-z-ui-components-z-button-group.mjs +1 -1
  3. package/fesm2022/shival99-z-ui-components-z-button-group.mjs.map +1 -1
  4. package/fesm2022/shival99-z-ui-components-z-calendar.mjs +13 -13
  5. package/fesm2022/shival99-z-ui-components-z-calendar.mjs.map +1 -1
  6. package/fesm2022/shival99-z-ui-components-z-editor.mjs +1 -1
  7. package/fesm2022/shival99-z-ui-components-z-editor.mjs.map +1 -1
  8. package/fesm2022/shival99-z-ui-components-z-menu.mjs +5 -3
  9. package/fesm2022/shival99-z-ui-components-z-menu.mjs.map +1 -1
  10. package/fesm2022/shival99-z-ui-components-z-modal.mjs +6 -7
  11. package/fesm2022/shival99-z-ui-components-z-modal.mjs.map +1 -1
  12. package/fesm2022/shival99-z-ui-components-z-popover.mjs +2 -2
  13. package/fesm2022/shival99-z-ui-components-z-popover.mjs.map +1 -1
  14. package/fesm2022/shival99-z-ui-components-z-select.mjs +3 -2
  15. package/fesm2022/shival99-z-ui-components-z-select.mjs.map +1 -1
  16. package/fesm2022/shival99-z-ui-components-z-toast.mjs +4 -4
  17. package/fesm2022/shival99-z-ui-components-z-toast.mjs.map +1 -1
  18. package/fesm2022/shival99-z-ui-components-z-tooltip.mjs +1 -1
  19. package/fesm2022/shival99-z-ui-components-z-tooltip.mjs.map +1 -1
  20. package/fesm2022/shival99-z-ui-components-z-upload.mjs +3 -2
  21. package/fesm2022/shival99-z-ui-components-z-upload.mjs.map +1 -1
  22. package/fesm2022/shival99-z-ui-utils.mjs +27 -1
  23. package/fesm2022/shival99-z-ui-utils.mjs.map +1 -1
  24. package/package.json +1 -1
  25. package/types/shival99-z-ui-components-z-button-group.d.ts +1 -1
  26. package/types/shival99-z-ui-components-z-menu.d.ts +2 -0
  27. package/types/shival99-z-ui-components-z-modal.d.ts +1 -1
  28. package/types/shival99-z-ui-components-z-select.d.ts +1 -0
  29. package/types/shival99-z-ui-components-z-upload.d.ts +1 -0
  30. package/types/shival99-z-ui-utils.d.ts +8 -2
  31. package/.npmignore +0 -58
  32. package/fesm2022/shival99-z-ui-components-z-autocomplete.mjs +0 -1215
  33. package/fesm2022/shival99-z-ui-components-z-autocomplete.mjs.map +0 -1
  34. package/fesm2022/shival99-z-ui-components-z-drawer.mjs +0 -994
  35. package/fesm2022/shival99-z-ui-components-z-drawer.mjs.map +0 -1
  36. package/fesm2022/shival99-z-ui-components-z-dropdown-menu.mjs +0 -99
  37. package/fesm2022/shival99-z-ui-components-z-dropdown-menu.mjs.map +0 -1
  38. package/fesm2022/shival99-z-ui-components-z-filter.mjs +0 -962
  39. package/fesm2022/shival99-z-ui-components-z-filter.mjs.map +0 -1
  40. package/fesm2022/shival99-z-ui-components-z-number-ticker.mjs +0 -352
  41. package/fesm2022/shival99-z-ui-components-z-number-ticker.mjs.map +0 -1
  42. package/fesm2022/shival99-z-ui-components-z-pagination.mjs +0 -179
  43. package/fesm2022/shival99-z-ui-components-z-pagination.mjs.map +0 -1
  44. package/fesm2022/shival99-z-ui-components-z-qrcode.mjs +0 -429
  45. package/fesm2022/shival99-z-ui-components-z-qrcode.mjs.map +0 -1
  46. package/fesm2022/shival99-z-ui-components-z-radio.mjs +0 -183
  47. package/fesm2022/shival99-z-ui-components-z-radio.mjs.map +0 -1
  48. package/fesm2022/shival99-z-ui-components-z-scrollarea.mjs +0 -143
  49. package/fesm2022/shival99-z-ui-components-z-scrollarea.mjs.map +0 -1
  50. package/fesm2022/shival99-z-ui-components-z-show-more.mjs +0 -138
  51. package/fesm2022/shival99-z-ui-components-z-show-more.mjs.map +0 -1
  52. package/fesm2022/shival99-z-ui-components-z-skeleton-auto.mjs +0 -80
  53. package/fesm2022/shival99-z-ui-components-z-skeleton-auto.mjs.map +0 -1
  54. package/fesm2022/shival99-z-ui-components-z-steps.mjs +0 -420
  55. package/fesm2022/shival99-z-ui-components-z-steps.mjs.map +0 -1
  56. package/fesm2022/shival99-z-ui-components-z-table.mjs +0 -11471
  57. package/fesm2022/shival99-z-ui-components-z-table.mjs.map +0 -1
  58. package/fesm2022/shival99-z-ui-components-z-tabs.mjs +0 -1102
  59. package/fesm2022/shival99-z-ui-components-z-tabs.mjs.map +0 -1
  60. package/fesm2022/shival99-z-ui-components-z-tags.mjs +0 -364
  61. package/fesm2022/shival99-z-ui-components-z-tags.mjs.map +0 -1
  62. package/fesm2022/shival99-z-ui-components-z-timeline.mjs +0 -254
  63. package/fesm2022/shival99-z-ui-components-z-timeline.mjs.map +0 -1
  64. package/fesm2022/shival99-z-ui-services-excel.mjs +0 -672
  65. package/fesm2022/shival99-z-ui-services-excel.mjs.map +0 -1
  66. package/types/shival99-z-ui-components-z-autocomplete.d.ts +0 -299
  67. package/types/shival99-z-ui-components-z-drawer.d.ts +0 -301
  68. package/types/shival99-z-ui-components-z-dropdown-menu.d.ts +0 -52
  69. package/types/shival99-z-ui-components-z-filter.d.ts +0 -285
  70. package/types/shival99-z-ui-components-z-number-ticker.d.ts +0 -110
  71. package/types/shival99-z-ui-components-z-pagination.d.ts +0 -55
  72. package/types/shival99-z-ui-components-z-qrcode.d.ts +0 -79
  73. package/types/shival99-z-ui-components-z-radio.d.ts +0 -69
  74. package/types/shival99-z-ui-components-z-scrollarea.d.ts +0 -46
  75. package/types/shival99-z-ui-components-z-show-more.d.ts +0 -36
  76. package/types/shival99-z-ui-components-z-skeleton-auto.d.ts +0 -35
  77. package/types/shival99-z-ui-components-z-steps.d.ts +0 -106
  78. package/types/shival99-z-ui-components-z-table.d.ts +0 -2413
  79. package/types/shival99-z-ui-components-z-tabs.d.ts +0 -196
  80. package/types/shival99-z-ui-components-z-tags.d.ts +0 -127
  81. package/types/shival99-z-ui-components-z-timeline.d.ts +0 -71
  82. package/types/shival99-z-ui-services-excel.d.ts +0 -36
@@ -1,1215 +0,0 @@
1
- import { NgClass, NgTemplateOutlet } from '@angular/common';
2
- import * as i0 from '@angular/core';
3
- import { inject, TemplateRef, Directive, Injector, DestroyRef, viewChild, viewChildren, contentChild, input, output, signal, effect, computed, untracked, forwardRef, ViewEncapsulation, ChangeDetectionStrategy, Component } from '@angular/core';
4
- import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
5
- import { NgControl, FormsModule, NG_VALUE_ACCESSOR } from '@angular/forms';
6
- import { ZEmptyComponent } from '@shival99/z-ui/components/z-empty';
7
- import { ZHoverGlideDirective } from '@shival99/z-ui/components/z-hover-glide';
8
- import { ZIconComponent } from '@shival99/z-ui/components/z-icon';
9
- import { ZLoadingComponent } from '@shival99/z-ui/components/z-loading';
10
- import { ZPopoverDirective } from '@shival99/z-ui/components/z-popover';
11
- import { ZTooltipDirective } from '@shival99/z-ui/components/z-tooltip';
12
- import { ZHighlightPipe, ZSafeHtmlPipe } from '@shival99/z-ui/pipes';
13
- import { zTransform, zUuid, zResolveAsyncSelectedOptions, zMergeAsyncOptions, zRemoveVietnamese, zMergeClasses, zCreateEvent, Z_ASYNC_OPTIONS_DEFAULT_PAGE_SIZE, zToAsyncOptionsObservable, zResolveAsyncOptionsHasMore } from '@shival99/z-ui/utils';
14
- import { injectVirtualizer } from '@tanstack/angular-virtual';
15
- import { Subject, debounceTime, distinctUntilChanged, finalize } from 'rxjs';
16
- import { cva } from 'class-variance-authority';
17
-
18
- class ZAutocompleteOptionDirective {
19
- templateRef = inject((TemplateRef));
20
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: ZAutocompleteOptionDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
21
- static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.1.6", type: ZAutocompleteOptionDirective, isStandalone: true, selector: "[z-autocomplete-option], [zAutocompleteOption]", ngImport: i0 });
22
- }
23
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: ZAutocompleteOptionDirective, decorators: [{
24
- type: Directive,
25
- args: [{
26
- selector: '[z-autocomplete-option], [zAutocompleteOption]',
27
- standalone: true,
28
- }]
29
- }] });
30
-
31
- const Z_AUTOCOMPLETE_DEFAULT_CONFIG = {
32
- minLength: 1,
33
- debounceTime: 0,
34
- maxDisplayed: 0,
35
- highlightMatch: true,
36
- emptyMessage: 'i18n_z_ui_autocomplete_no_results',
37
- noDataMessage: 'i18n_z_ui_autocomplete_no_data',
38
- closeOnSelect: true,
39
- optionHeight: 36,
40
- dropdownMaxHeight: 280,
41
- serverSearch: false,
42
- };
43
-
44
- const zAutocompleteInputVariants = cva([
45
- 'flex w-full items-center rounded-sm border border-input bg-white shadow-xs',
46
- 'transition-[border-color,box-shadow,background-color,color,opacity,border-radius] duration-200',
47
- 'dark:bg-input/30 dark:border-input dark:hover:bg-input/50',
48
- 'outline-none',
49
- 'text-sm',
50
- ], {
51
- variants: {
52
- zSize: {
53
- sm: 'h-8 px-2 gap-2 text-sm',
54
- default: 'h-9 px-2.5 gap-2 text-sm',
55
- lg: 'h-10 px-3 gap-2.5 text-sm',
56
- },
57
- zStatus: {
58
- default: 'focus-within:border-ring focus-within:ring-ring/50 focus-within:ring-[3px]',
59
- open: 'border-ring',
60
- error: 'border-destructive! ring-destructive/20 ring-[3px] focus-within:border-destructive! focus-within:ring-destructive/30',
61
- disabled: 'opacity-50 cursor-not-allowed bg-muted! text-muted-foreground',
62
- readonly: 'cursor-default bg-muted/50 text-muted-foreground',
63
- },
64
- },
65
- defaultVariants: {
66
- zSize: 'default',
67
- zStatus: 'default',
68
- },
69
- });
70
- const zAutocompleteOptionVariants = cva('px-2 py-1.5 cursor-pointer transition-colors text-sm rounded-sm outline-none', {
71
- variants: {
72
- customTemplate: {
73
- true: 'block h-auto whitespace-normal',
74
- false: 'flex items-center gap-2 whitespace-nowrap',
75
- },
76
- active: {
77
- true: 'bg-primary/15 text-primary',
78
- false: 'hover:bg-primary/10 hover:text-foreground',
79
- },
80
- disabled: {
81
- true: 'opacity-50 cursor-not-allowed pointer-events-none',
82
- false: '',
83
- },
84
- },
85
- defaultVariants: {
86
- customTemplate: false,
87
- active: false,
88
- disabled: false,
89
- },
90
- });
91
-
92
- class ZAutocompleteComponent {
93
- _injector = inject(Injector);
94
- _destroyRef = inject(DestroyRef);
95
- _query$ = new Subject();
96
- triggerRef = viewChild('triggerEl', /* @ts-ignore */
97
- ...(ngDevMode ? [{ debugName: "triggerRef" }] : /* istanbul ignore next */ []));
98
- inputRef = viewChild('inputEl', /* @ts-ignore */
99
- ...(ngDevMode ? [{ debugName: "inputRef" }] : /* istanbul ignore next */ []));
100
- dropdownTpl = viewChild('dropdownTpl', /* @ts-ignore */
101
- ...(ngDevMode ? [{ debugName: "dropdownTpl" }] : /* istanbul ignore next */ []));
102
- virtualScrollRef = viewChild('virtualScrollElement', /* @ts-ignore */
103
- ...(ngDevMode ? [{ debugName: "virtualScrollRef" }] : /* istanbul ignore next */ []));
104
- optionsContainerRef = viewChild('optionsContainer', /* @ts-ignore */
105
- ...(ngDevMode ? [{ debugName: "optionsContainerRef" }] : /* istanbul ignore next */ []));
106
- loadMoreSentinelRef = viewChild('loadMoreSentinel', /* @ts-ignore */
107
- ...(ngDevMode ? [{ debugName: "loadMoreSentinelRef" }] : /* istanbul ignore next */ []));
108
- virtualOptionElements = viewChildren('virtualOptionEl', /* @ts-ignore */
109
- ...(ngDevMode ? [{ debugName: "virtualOptionElements" }] : /* istanbul ignore next */ []));
110
- customOptionDirective = contentChild((ZAutocompleteOptionDirective), /* @ts-ignore */
111
- ...(ngDevMode ? [{ debugName: "customOptionDirective" }] : /* istanbul ignore next */ []));
112
- class = input('', /* @ts-ignore */
113
- ...(ngDevMode ? [{ debugName: "class" }] : /* istanbul ignore next */ []));
114
- zOptions = input([], /* @ts-ignore */
115
- ...(ngDevMode ? [{ debugName: "zOptions" }] : /* istanbul ignore next */ []));
116
- zConfig = input({}, /* @ts-ignore */
117
- ...(ngDevMode ? [{ debugName: "zConfig" }] : /* istanbul ignore next */ []));
118
- zSize = input('default', /* @ts-ignore */
119
- ...(ngDevMode ? [{ debugName: "zSize" }] : /* istanbul ignore next */ []));
120
- zType = input('default', /* @ts-ignore */
121
- ...(ngDevMode ? [{ debugName: "zType" }] : /* istanbul ignore next */ []));
122
- zLabel = input('', /* @ts-ignore */
123
- ...(ngDevMode ? [{ debugName: "zLabel" }] : /* istanbul ignore next */ []));
124
- zLabelClass = input('', /* @ts-ignore */
125
- ...(ngDevMode ? [{ debugName: "zLabelClass" }] : /* istanbul ignore next */ []));
126
- zPlaceholder = input('', /* @ts-ignore */
127
- ...(ngDevMode ? [{ debugName: "zPlaceholder" }] : /* istanbul ignore next */ []));
128
- zDisabled = input(false, { ...(ngDevMode ? { debugName: "zDisabled" } : /* istanbul ignore next */ {}), transform: zTransform });
129
- zReadonly = input(false, { ...(ngDevMode ? { debugName: "zReadonly" } : /* istanbul ignore next */ {}), transform: zTransform });
130
- zLoading = input(false, { ...(ngDevMode ? { debugName: "zLoading" } : /* istanbul ignore next */ {}), transform: zTransform });
131
- zLoadingOutline = input(false, { ...(ngDevMode ? { debugName: "zLoadingOutline" } : /* istanbul ignore next */ {}), transform: zTransform });
132
- zRequired = input(false, { ...(ngDevMode ? { debugName: "zRequired" } : /* istanbul ignore next */ {}), transform: zTransform });
133
- zPrefix = input('', /* @ts-ignore */
134
- ...(ngDevMode ? [{ debugName: "zPrefix" }] : /* istanbul ignore next */ []));
135
- zSuffix = input('', /* @ts-ignore */
136
- ...(ngDevMode ? [{ debugName: "zSuffix" }] : /* istanbul ignore next */ []));
137
- zAllowClear = input(true, { ...(ngDevMode ? { debugName: "zAllowClear" } : /* istanbul ignore next */ {}), transform: zTransform });
138
- zVirtualScroll = input(false, { ...(ngDevMode ? { debugName: "zVirtualScroll" } : /* istanbul ignore next */ {}), transform: zTransform });
139
- zDynamicSize = input(true, { ...(ngDevMode ? { debugName: "zDynamicSize" } : /* istanbul ignore next */ {}), transform: zTransform });
140
- zOptionHeight = input(36, /* @ts-ignore */
141
- ...(ngDevMode ? [{ debugName: "zOptionHeight" }] : /* istanbul ignore next */ []));
142
- zDropdownMaxHeight = input(null, /* @ts-ignore */
143
- ...(ngDevMode ? [{ debugName: "zDropdownMaxHeight" }] : /* istanbul ignore next */ []));
144
- /** @deprecated Dùng zDropdownMaxHeight để đồng nhất với z-select. */
145
- zHeightExpand = input(null, /* @ts-ignore */
146
- ...(ngDevMode ? [{ debugName: "zHeightExpand" }] : /* istanbul ignore next */ []));
147
- zMaxVisible = input(null, /* @ts-ignore */
148
- ...(ngDevMode ? [{ debugName: "zMaxVisible" }] : /* istanbul ignore next */ []));
149
- zResetOnSelect = input(true, { ...(ngDevMode ? { debugName: "zResetOnSelect" } : /* istanbul ignore next */ {}), transform: zTransform });
150
- zEmptyText = input('', /* @ts-ignore */
151
- ...(ngDevMode ? [{ debugName: "zEmptyText" }] : /* istanbul ignore next */ []));
152
- zEmptyIcon = input('lucideSearchX', /* @ts-ignore */
153
- ...(ngDevMode ? [{ debugName: "zEmptyIcon" }] : /* istanbul ignore next */ []));
154
- zNoDataText = input('', /* @ts-ignore */
155
- ...(ngDevMode ? [{ debugName: "zNoDataText" }] : /* istanbul ignore next */ []));
156
- zNoDataIcon = input('lucidePackageOpen', /* @ts-ignore */
157
- ...(ngDevMode ? [{ debugName: "zNoDataIcon" }] : /* istanbul ignore next */ []));
158
- zAllowCustomValue = input(false, { ...(ngDevMode ? { debugName: "zAllowCustomValue" } : /* istanbul ignore next */ {}), transform: zTransform });
159
- zOpenOnFocus = input(true, { ...(ngDevMode ? { debugName: "zOpenOnFocus" } : /* istanbul ignore next */ {}), transform: zTransform });
160
- zDebounceTime = input(200, /* @ts-ignore */
161
- ...(ngDevMode ? [{ debugName: "zDebounceTime" }] : /* istanbul ignore next */ []));
162
- zLoadingMore = input(false, { ...(ngDevMode ? { debugName: "zLoadingMore" } : /* istanbul ignore next */ {}), transform: zTransform });
163
- zEnableLoadMore = input(false, { ...(ngDevMode ? { debugName: "zEnableLoadMore" } : /* istanbul ignore next */ {}), transform: zTransform });
164
- zScrollDistance = input(2, /* @ts-ignore */
165
- ...(ngDevMode ? [{ debugName: "zScrollDistance" }] : /* istanbul ignore next */ []));
166
- zKey = input('', /* @ts-ignore */
167
- ...(ngDevMode ? [{ debugName: "zKey" }] : /* istanbul ignore next */ []));
168
- zOptionTemplate = input(null, /* @ts-ignore */
169
- ...(ngDevMode ? [{ debugName: "zOptionTemplate" }] : /* istanbul ignore next */ []));
170
- zOnSearch = output();
171
- zOnLoadMore = output();
172
- zOnSelect = output();
173
- zOnEnter = output();
174
- zOnCommit = output();
175
- zValueChange = output();
176
- zOnBlur = output();
177
- zOnFocus = output();
178
- zControl = output();
179
- zEvent = output();
180
- _value = signal('', /* @ts-ignore */
181
- ...(ngDevMode ? [{ debugName: "_value" }] : /* istanbul ignore next */ []));
182
- _disabled = signal(false, /* @ts-ignore */
183
- ...(ngDevMode ? [{ debugName: "_disabled" }] : /* istanbul ignore next */ []));
184
- _formControl = signal(null, /* @ts-ignore */
185
- ...(ngDevMode ? [{ debugName: "_formControl" }] : /* istanbul ignore next */ []));
186
- _popoverControl = signal(null, /* @ts-ignore */
187
- ...(ngDevMode ? [{ debugName: "_popoverControl" }] : /* istanbul ignore next */ []));
188
- _selectedOption = signal(null, /* @ts-ignore */
189
- ...(ngDevMode ? [{ debugName: "_selectedOption" }] : /* istanbul ignore next */ []));
190
- _asyncOptions = signal([], /* @ts-ignore */
191
- ...(ngDevMode ? [{ debugName: "_asyncOptions" }] : /* istanbul ignore next */ []));
192
- _asyncKeyword = signal('', /* @ts-ignore */
193
- ...(ngDevMode ? [{ debugName: "_asyncKeyword" }] : /* istanbul ignore next */ []));
194
- _asyncPage = signal(1, /* @ts-ignore */
195
- ...(ngDevMode ? [{ debugName: "_asyncPage" }] : /* istanbul ignore next */ []));
196
- _asyncHasMore = signal(false, /* @ts-ignore */
197
- ...(ngDevMode ? [{ debugName: "_asyncHasMore" }] : /* istanbul ignore next */ []));
198
- _asyncLoading = signal(false, /* @ts-ignore */
199
- ...(ngDevMode ? [{ debugName: "_asyncLoading" }] : /* istanbul ignore next */ []));
200
- _asyncLoadingMore = signal(false, /* @ts-ignore */
201
- ...(ngDevMode ? [{ debugName: "_asyncLoadingMore" }] : /* istanbul ignore next */ []));
202
- uiState = signal({
203
- isOpen: false,
204
- isFocused: false,
205
- touched: false,
206
- dirty: false,
207
- }, /* @ts-ignore */
208
- ...(ngDevMode ? [{ debugName: "uiState" }] : /* istanbul ignore next */ []));
209
- actualPosition = signal('bottom', /* @ts-ignore */
210
- ...(ngDevMode ? [{ debugName: "actualPosition" }] : /* istanbul ignore next */ []));
211
- autocompleteId = zUuid('z-autocomplete');
212
- dropdownId = `${this.autocompleteId}-dropdown`;
213
- inputValue = signal('', /* @ts-ignore */
214
- ...(ngDevMode ? [{ debugName: "inputValue" }] : /* istanbul ignore next */ []));
215
- debouncedQuery = signal('', /* @ts-ignore */
216
- ...(ngDevMode ? [{ debugName: "debouncedQuery" }] : /* istanbul ignore next */ []));
217
- searchQuery = signal('', /* @ts-ignore */
218
- ...(ngDevMode ? [{ debugName: "searchQuery" }] : /* istanbul ignore next */ []));
219
- activeIndex = signal(-1, /* @ts-ignore */
220
- ...(ngDevMode ? [{ debugName: "activeIndex" }] : /* istanbul ignore next */ []));
221
- dropdownWidth = signal(0, /* @ts-ignore */
222
- ...(ngDevMode ? [{ debugName: "dropdownWidth" }] : /* istanbul ignore next */ []));
223
- _pendingSearch = signal(false, /* @ts-ignore */
224
- ...(ngDevMode ? [{ debugName: "_pendingSearch" }] : /* istanbul ignore next */ []));
225
- _localLoadingTimeout = null;
226
- _loadMoreObserver = null;
227
- _virtualScrollListener = null;
228
- _asyncLoadSubscription = null;
229
- _asyncRequestId = 0;
230
- _lastFilteredOptionsLength = 0;
231
- _shouldScrollActiveOption = false;
232
- _pendingServerSearchScrollReset = false;
233
- /** Guards against focus+click both requesting an open on the same gesture, which doubled CD cycles. */
234
- _openRequested = false;
235
- /** Stores input value before keyboard navigation for ESC revert */
236
- _valueBeforeNavigation = null;
237
- virtualizer = injectVirtualizer(() => ({
238
- scrollElement: this.virtualScrollRef(),
239
- count: this.filteredOptions().length,
240
- estimateSize: () => this.effectiveOptionHeight(),
241
- measureElement: (element) => element.getBoundingClientRect().height,
242
- gap: 3,
243
- overscan: 5,
244
- useApplicationRefTick: false,
245
- }));
246
- _measureVirtualItems = effect(() => {
247
- if (!this.zDynamicSize()) {
248
- return;
249
- }
250
- const elements = this.virtualOptionElements();
251
- for (const el of elements) {
252
- this.virtualizer.measureElement(el.nativeElement);
253
- }
254
- }, /* @ts-ignore */
255
- ...(ngDevMode ? [{ debugName: "_measureVirtualItems" }] : /* istanbul ignore next */ []));
256
- config = computed(() => ({
257
- ...Z_AUTOCOMPLETE_DEFAULT_CONFIG,
258
- ...this.zConfig(),
259
- }), /* @ts-ignore */
260
- ...(ngDevMode ? [{ debugName: "config" }] : /* istanbul ignore next */ []));
261
- hasAsyncOptions = computed(() => !!this.config().async?.load, /* @ts-ignore */
262
- ...(ngDevMode ? [{ debugName: "hasAsyncOptions" }] : /* istanbul ignore next */ []));
263
- asyncSelectedOptions = computed(() => zResolveAsyncSelectedOptions(this.config().async), /* @ts-ignore */
264
- ...(ngDevMode ? [{ debugName: "asyncSelectedOptions" }] : /* istanbul ignore next */ []));
265
- sourceOptions = computed(() => {
266
- if (!this.hasAsyncOptions()) {
267
- return this.zOptions();
268
- }
269
- return zMergeAsyncOptions(this._asyncOptions(), this.asyncSelectedOptions(), this.config().async?.dedupeBy);
270
- }, /* @ts-ignore */
271
- ...(ngDevMode ? [{ debugName: "sourceOptions" }] : /* istanbul ignore next */ []));
272
- isLoading = computed(() => this.zLoading() || this._asyncLoading(), /* @ts-ignore */
273
- ...(ngDevMode ? [{ debugName: "isLoading" }] : /* istanbul ignore next */ []));
274
- isLoadingMore = computed(() => this.zLoadingMore() || this._asyncLoadingMore(), /* @ts-ignore */
275
- ...(ngDevMode ? [{ debugName: "isLoadingMore" }] : /* istanbul ignore next */ []));
276
- canLoadMore = computed(() => this.hasAsyncOptions() ? this._asyncHasMore() : this.zEnableLoadMore(), /* @ts-ignore */
277
- ...(ngDevMode ? [{ debugName: "canLoadMore" }] : /* istanbul ignore next */ []));
278
- isDisabled = computed(() => this._disabled() || this.zDisabled(), /* @ts-ignore */
279
- ...(ngDevMode ? [{ debugName: "isDisabled" }] : /* istanbul ignore next */ []));
280
- isReadonly = computed(() => this.zReadonly(), /* @ts-ignore */
281
- ...(ngDevMode ? [{ debugName: "isReadonly" }] : /* istanbul ignore next */ []));
282
- isInteractionDisabled = computed(() => this.isDisabled() || this.isReadonly() || this.zLoading(), /* @ts-ignore */
283
- ...(ngDevMode ? [{ debugName: "isInteractionDisabled" }] : /* istanbul ignore next */ []));
284
- effectiveOptionHeight = computed(() => this.zOptionHeight() || this.config().optionHeight, /* @ts-ignore */
285
- ...(ngDevMode ? [{ debugName: "effectiveOptionHeight" }] : /* istanbul ignore next */ []));
286
- effectiveHeightExpand = computed(() => this.zDropdownMaxHeight() ?? this.zHeightExpand() ?? this.config().dropdownMaxHeight, /* @ts-ignore */
287
- ...(ngDevMode ? [{ debugName: "effectiveHeightExpand" }] : /* istanbul ignore next */ []));
288
- effectiveEmptyText = computed(() => this.zEmptyText() || this.config().emptyMessage, /* @ts-ignore */
289
- ...(ngDevMode ? [{ debugName: "effectiveEmptyText" }] : /* istanbul ignore next */ []));
290
- effectiveNoDataText = computed(() => this.zNoDataText() || this.config().noDataMessage, /* @ts-ignore */
291
- ...(ngDevMode ? [{ debugName: "effectiveNoDataText" }] : /* istanbul ignore next */ []));
292
- effectiveDebounceTime = computed(() => this.zConfig().debounceTime ?? this.zDebounceTime(), /* @ts-ignore */
293
- ...(ngDevMode ? [{ debugName: "effectiveDebounceTime" }] : /* istanbul ignore next */ []));
294
- effectiveOptionTemplate = computed(() => {
295
- const directive = this.customOptionDirective();
296
- if (directive) {
297
- return directive.templateRef;
298
- }
299
- return this.zOptionTemplate();
300
- }, /* @ts-ignore */
301
- ...(ngDevMode ? [{ debugName: "effectiveOptionTemplate" }] : /* istanbul ignore next */ []));
302
- hasCustomOptionTemplate = computed(() => this.effectiveOptionTemplate() !== null, /* @ts-ignore */
303
- ...(ngDevMode ? [{ debugName: "hasCustomOptionTemplate" }] : /* istanbul ignore next */ []));
304
- selected = computed(() => {
305
- const option = this._selectedOption();
306
- if (!option) {
307
- return [];
308
- }
309
- return [option];
310
- }, /* @ts-ignore */
311
- ...(ngDevMode ? [{ debugName: "selected" }] : /* istanbul ignore next */ []));
312
- highlightQuery = computed(() => this.zType() === 'address_bar' ? this.searchQuery() : this.debouncedQuery(), /* @ts-ignore */
313
- ...(ngDevMode ? [{ debugName: "highlightQuery" }] : /* istanbul ignore next */ []));
314
- /**
315
- * Local-mode loading state after debounce to avoid quick flicker.
316
- * Server mode relies only on zLoading from parent.
317
- */
318
- isLoadingState = computed(() => {
319
- if (this.config().serverSearch || this.hasAsyncOptions()) {
320
- return false;
321
- }
322
- const hasInput = this.inputValue().trim() !== '';
323
- return hasInput && this._pendingSearch();
324
- }, /* @ts-ignore */
325
- ...(ngDevMode ? [{ debugName: "isLoadingState" }] : /* istanbul ignore next */ []));
326
- isPositionTop = computed(() => {
327
- const pos = this.actualPosition();
328
- return pos.startsWith('top');
329
- }, /* @ts-ignore */
330
- ...(ngDevMode ? [{ debugName: "isPositionTop" }] : /* istanbul ignore next */ []));
331
- shouldUseVirtualScroll = computed(() => {
332
- if (this.zVirtualScroll()) {
333
- return true;
334
- }
335
- if (this.hasCustomOptionTemplate()) {
336
- return false;
337
- }
338
- if (this.canLoadMore()) {
339
- return false;
340
- }
341
- if (this.hasAsyncOptions() && this._asyncPage() > 1) {
342
- return false;
343
- }
344
- const maxVisible = this.zMaxVisible();
345
- if (maxVisible !== null && this.sourceOptions().length > maxVisible) {
346
- return true;
347
- }
348
- return this.sourceOptions().length > 50;
349
- }, /* @ts-ignore */
350
- ...(ngDevMode ? [{ debugName: "shouldUseVirtualScroll" }] : /* istanbul ignore next */ []));
351
- filteredOptions = computed(() => {
352
- const options = this.sourceOptions();
353
- const cfg = this.config();
354
- const allowCustom = this.zAllowCustomValue();
355
- const query = this.zType() === 'address_bar' ? this.searchQuery() : this.debouncedQuery();
356
- // If server search is enabled, skip local filtering - just apply maxDisplayed limit
357
- if (cfg.serverSearch || this.hasAsyncOptions()) {
358
- let result = options;
359
- if (cfg.maxDisplayed && options.length > cfg.maxDisplayed) {
360
- result = options.slice(0, cfg.maxDisplayed);
361
- }
362
- // Allow custom value: if no results from server, show typed text as option
363
- if (allowCustom && result.length === 0 && query.trim() !== '') {
364
- return [{ label: query.trim(), value: query.trim() }];
365
- }
366
- return result;
367
- }
368
- if (!query || query.trim() === '') {
369
- if (cfg.maxDisplayed && options.length > cfg.maxDisplayed) {
370
- return options.slice(0, cfg.maxDisplayed);
371
- }
372
- return options;
373
- }
374
- const normalizedQuery = zRemoveVietnamese(query.toLowerCase());
375
- let filtered = options.filter(opt => {
376
- const normalizedLabel = zRemoveVietnamese(opt.label.toLowerCase());
377
- return normalizedLabel.includes(normalizedQuery);
378
- });
379
- if (cfg.maxDisplayed && filtered.length > cfg.maxDisplayed) {
380
- filtered = filtered.slice(0, cfg.maxDisplayed);
381
- }
382
- if (allowCustom && filtered.length === 0 && query.trim() !== '') {
383
- return [{ label: query.trim(), value: query.trim() }];
384
- }
385
- return filtered;
386
- }, /* @ts-ignore */
387
- ...(ngDevMode ? [{ debugName: "filteredOptions" }] : /* istanbul ignore next */ []));
388
- optionViews = computed(() => this.filteredOptions().map((option, index) => ({
389
- option,
390
- index,
391
- trackKey: `${String(this._getOptionKey(option))}::${index}`,
392
- })), /* @ts-ignore */
393
- ...(ngDevMode ? [{ debugName: "optionViews" }] : /* istanbul ignore next */ []));
394
- hasValue = computed(() => {
395
- const value = this.inputValue();
396
- return value !== null && value !== undefined && value.trim() !== '';
397
- }, /* @ts-ignore */
398
- ...(ngDevMode ? [{ debugName: "hasValue" }] : /* istanbul ignore next */ []));
399
- currentStatus = computed(() => {
400
- if (this.isDisabled()) {
401
- return 'disabled';
402
- }
403
- if (this.isReadonly()) {
404
- return 'readonly';
405
- }
406
- if (this.uiState().isOpen) {
407
- return 'open';
408
- }
409
- return 'default';
410
- }, /* @ts-ignore */
411
- ...(ngDevMode ? [{ debugName: "currentStatus" }] : /* istanbul ignore next */ []));
412
- inputClasses = computed(() => zMergeClasses(zAutocompleteInputVariants({
413
- zSize: this.zSize(),
414
- zStatus: this.currentStatus(),
415
- }), this.zLoading() && this.zLoadingOutline() ? 'z-loading-outline-active !ring-ring/50 !ring-[3px]' : '', this.class()), /* @ts-ignore */
416
- ...(ngDevMode ? [{ debugName: "inputClasses" }] : /* istanbul ignore next */ []));
417
- state = computed(() => ({
418
- focused: this.uiState().isFocused,
419
- touched: this.uiState().touched,
420
- dirty: this.uiState().dirty,
421
- disabled: this.isDisabled(),
422
- readonly: this.isReadonly(),
423
- open: this.uiState().isOpen,
424
- }), /* @ts-ignore */
425
- ...(ngDevMode ? [{ debugName: "state" }] : /* istanbul ignore next */ []));
426
- _onChange = () => void 0;
427
- _onTouched = () => void 0;
428
- _ngControl = null;
429
- _isNavigationFilling = false;
430
- _hasPendingInput = false;
431
- constructor() {
432
- effect(onCleanup => {
433
- const triggerEl = this.triggerRef()?.nativeElement;
434
- if (!triggerEl) {
435
- return;
436
- }
437
- const observer = new ResizeObserver(() => {
438
- this.dropdownWidth.set(triggerEl.getBoundingClientRect().width);
439
- });
440
- observer.observe(triggerEl);
441
- this.dropdownWidth.set(triggerEl.getBoundingClientRect().width);
442
- onCleanup(() => {
443
- observer.disconnect();
444
- });
445
- });
446
- effect(() => {
447
- this.zOptions();
448
- const isServerSearch = this.config().serverSearch;
449
- if (!isServerSearch || !this._pendingServerSearchScrollReset) {
450
- return;
451
- }
452
- this._pendingServerSearchScrollReset = false;
453
- this._resetOptionsScrollTop();
454
- });
455
- effect(() => {
456
- const options = this.filteredOptions();
457
- const { isOpen } = this.uiState();
458
- if (!isOpen || options.length === 0) {
459
- this._lastFilteredOptionsLength = options.length;
460
- return;
461
- }
462
- const previousLength = this._lastFilteredOptionsLength;
463
- const currentIndex = untracked(() => this.activeIndex());
464
- this._lastFilteredOptionsLength = options.length;
465
- if (currentIndex < 0 || currentIndex >= options.length || options.length <= previousLength) {
466
- this.activeIndex.set(0);
467
- }
468
- });
469
- effect(() => {
470
- const idx = this.activeIndex();
471
- const { isOpen } = this.uiState();
472
- if (!isOpen || idx < 0) {
473
- return;
474
- }
475
- if (!this._shouldScrollActiveOption || this.shouldUseVirtualScroll() || this.canLoadMore()) {
476
- return;
477
- }
478
- this._shouldScrollActiveOption = false;
479
- const container = this.optionsContainerRef()?.nativeElement;
480
- if (!container) {
481
- return;
482
- }
483
- const options = container.querySelectorAll('.z-autocomplete-option');
484
- const activeOption = options[idx];
485
- if (activeOption) {
486
- activeOption.scrollIntoView({ block: 'nearest' });
487
- }
488
- });
489
- effect(onCleanup => {
490
- const sentinel = this.loadMoreSentinelRef();
491
- const { isOpen } = this.uiState();
492
- const optionsCount = this.filteredOptions().length;
493
- if (!sentinel || !isOpen || optionsCount === 0 || !this.canLoadMore()) {
494
- this._cleanupLoadMoreObserver();
495
- return;
496
- }
497
- this._setupLoadMoreObserver();
498
- onCleanup(() => {
499
- this._cleanupLoadMoreObserver();
500
- });
501
- });
502
- effect(onCleanup => {
503
- const { isOpen } = this.uiState();
504
- const useVirtual = this.shouldUseVirtualScroll();
505
- const optionsCount = this.filteredOptions().length;
506
- if (!isOpen || !useVirtual || optionsCount === 0) {
507
- this._cleanupVirtualScrollListener();
508
- return;
509
- }
510
- requestAnimationFrame(() => {
511
- requestAnimationFrame(() => {
512
- this._setupVirtualScrollLoadMore();
513
- });
514
- });
515
- onCleanup(() => {
516
- this._cleanupVirtualScrollListener();
517
- });
518
- });
519
- }
520
- ngOnInit() {
521
- this._setupDebounce();
522
- this._emitControl();
523
- queueMicrotask(() => {
524
- try {
525
- this._ngControl = this._injector.get(NgControl, null);
526
- if (this._ngControl?.control) {
527
- this._formControl.set(this._ngControl.control);
528
- }
529
- }
530
- catch {
531
- this._ngControl = null;
532
- }
533
- });
534
- }
535
- writeValue(value) {
536
- this._value.set(value ?? '');
537
- this.inputValue.set(value ?? '');
538
- this.debouncedQuery.set(value ?? '');
539
- this._hasPendingInput = false;
540
- if (this.zType() === 'address_bar') {
541
- this.searchQuery.set(value ?? '');
542
- }
543
- }
544
- registerOnChange(fn) {
545
- this._onChange = fn;
546
- }
547
- registerOnTouched(fn) {
548
- this._onTouched = fn;
549
- }
550
- setDisabledState(isDisabled) {
551
- this._disabled.set(isDisabled);
552
- }
553
- onInput(event) {
554
- const { value } = event.target;
555
- this._clearLocalLoadingTimer();
556
- this._pendingSearch.set(false);
557
- this.inputValue.set(value);
558
- this._value.set(value);
559
- this._hasPendingInput = true;
560
- this.uiState.update(s => ({ ...s, dirty: true }));
561
- this._onChange(value);
562
- if (!this._isNavigationFilling) {
563
- this._query$.next(value);
564
- }
565
- this.zValueChange.emit(value);
566
- if (!this.uiState().isOpen) {
567
- this._openPanel();
568
- }
569
- this._selectedOption.set(null);
570
- }
571
- onFocus(event) {
572
- if (this.isReadonly()) {
573
- event.target.blur();
574
- return;
575
- }
576
- this.uiState.update(s => ({ ...s, isFocused: true }));
577
- this.zOnFocus.emit(event);
578
- this.zEvent.emit(zCreateEvent('focus', event));
579
- if (this.zOpenOnFocus()) {
580
- this._openPanel();
581
- }
582
- }
583
- onInputMousedown(event) {
584
- if (this.isReadonly()) {
585
- event.preventDefault();
586
- }
587
- }
588
- onInputClick() {
589
- if (this.uiState().isOpen || !this.zOpenOnFocus()) {
590
- return;
591
- }
592
- this._openPanel();
593
- }
594
- onBlur(event) {
595
- this.uiState.update(s => ({ ...s, isFocused: false }));
596
- this.zOnBlur.emit(event);
597
- this.zEvent.emit(zCreateEvent('blur', event));
598
- if (this.uiState().dirty) {
599
- this.uiState.update(s => ({ ...s, touched: true }));
600
- }
601
- this._onTouched();
602
- const currentValue = this.inputValue();
603
- this.zOnCommit.emit({ value: currentValue, source: 'blur' });
604
- }
605
- onKeydown(event) {
606
- if (this.isInteractionDisabled()) {
607
- return;
608
- }
609
- const { isOpen } = this.uiState();
610
- const options = this.filteredOptions();
611
- const currentValue = this.inputValue();
612
- const isAddressBarMode = this.zType() === 'address_bar';
613
- if (event.key === 'Enter') {
614
- event.preventDefault();
615
- if (!isOpen) {
616
- this._openPanel();
617
- return;
618
- }
619
- this._handleEnterKey(options, currentValue);
620
- return;
621
- }
622
- if (!isOpen) {
623
- if (event.key === 'ArrowDown') {
624
- event.preventDefault();
625
- this._openPanel();
626
- }
627
- return;
628
- }
629
- switch (event.key) {
630
- case 'ArrowDown':
631
- event.preventDefault();
632
- if (this._valueBeforeNavigation === null) {
633
- this._valueBeforeNavigation = currentValue;
634
- }
635
- this._shouldScrollActiveOption = true;
636
- this.activeIndex.update(i => (i < options.length - 1 ? i + 1 : 0));
637
- if (isAddressBarMode) {
638
- this._fillInputFromActiveOption();
639
- }
640
- break;
641
- case 'ArrowUp':
642
- event.preventDefault();
643
- if (this._valueBeforeNavigation === null) {
644
- this._valueBeforeNavigation = currentValue;
645
- }
646
- this._shouldScrollActiveOption = true;
647
- this.activeIndex.update(i => (i > 0 ? i - 1 : options.length - 1));
648
- if (isAddressBarMode) {
649
- this._fillInputFromActiveOption();
650
- }
651
- break;
652
- case 'Escape':
653
- event.preventDefault();
654
- if (isAddressBarMode && this._valueBeforeNavigation !== null) {
655
- this._revertToValueBeforeNavigation();
656
- this._hasPendingInput = false;
657
- }
658
- else {
659
- this._cancelPendingInput();
660
- }
661
- this._valueBeforeNavigation = null;
662
- this._closePanel();
663
- break;
664
- case 'Tab':
665
- this._valueBeforeNavigation = null;
666
- this._closePanel();
667
- break;
668
- }
669
- }
670
- _handleEnterKey(options, currentValue) {
671
- const trimmedValue = currentValue.trim();
672
- this._valueBeforeNavigation = null;
673
- this.zOnCommit.emit({ value: trimmedValue, source: 'enter' });
674
- if (this.zType() === 'address_bar') {
675
- this._closePanel();
676
- return;
677
- }
678
- const idx = this.activeIndex();
679
- if (options.length > 0) {
680
- const selectedIdx = idx >= 0 && idx < options.length ? idx : 0;
681
- this.selectOption(options[selectedIdx]);
682
- return;
683
- }
684
- if (this.zAllowCustomValue() && trimmedValue) {
685
- this.zOnEnter.emit(trimmedValue);
686
- this._resetInput();
687
- }
688
- }
689
- _fillInputFromActiveOption() {
690
- const idx = this.activeIndex();
691
- const options = this.filteredOptions();
692
- if (idx < 0 || idx >= options.length) {
693
- return;
694
- }
695
- const option = options[idx];
696
- this._isNavigationFilling = true;
697
- this.inputValue.set(option.label);
698
- this._value.set(option.label);
699
- this._onChange(option.label);
700
- this.zValueChange.emit(option.label);
701
- const inputEl = this.inputRef()?.nativeElement;
702
- if (inputEl) {
703
- inputEl.value = option.label;
704
- }
705
- setTimeout(() => {
706
- this._isNavigationFilling = false;
707
- }, 0);
708
- }
709
- _revertToValueBeforeNavigation() {
710
- if (this._valueBeforeNavigation === null) {
711
- return;
712
- }
713
- const value = this._valueBeforeNavigation;
714
- this._isNavigationFilling = true;
715
- this.inputValue.set(value);
716
- this._value.set(value);
717
- this._onChange(value);
718
- this.zValueChange.emit(value);
719
- if (this.zType() === 'address_bar') {
720
- this.searchQuery.set(value);
721
- }
722
- const inputEl = this.inputRef()?.nativeElement;
723
- if (inputEl) {
724
- inputEl.value = value;
725
- }
726
- this._valueBeforeNavigation = null;
727
- setTimeout(() => {
728
- this._isNavigationFilling = false;
729
- }, 0);
730
- }
731
- _resetInput() {
732
- this._hasPendingInput = false;
733
- if (!this.zResetOnSelect()) {
734
- this._closePanel();
735
- this.activeIndex.set(-1);
736
- return;
737
- }
738
- this.inputValue.set('');
739
- this._value.set('');
740
- this._onChange('');
741
- this.zValueChange.emit('');
742
- if (!this.hasAsyncOptions()) {
743
- this._query$.next('');
744
- }
745
- this._closePanel();
746
- this.activeIndex.set(-1);
747
- }
748
- onPopoverControl(control) {
749
- this._popoverControl.set(control);
750
- }
751
- onPopoverShow() {
752
- this._openRequested = false;
753
- this.uiState.update(s => ({ ...s, isOpen: true }));
754
- this._resetOptionsScrollTop();
755
- this._loadAsyncOptionsOnFocus();
756
- // Panel chỉ mở khi user focus/click thật, tức ancestor (vd. modal) đã hết animation transform —
757
- // đo lại ở đây để tránh dùng width "đóng băng" từ lúc effect khởi tạo đo hụt giữa lúc scale().
758
- const triggerEl = this.triggerRef()?.nativeElement;
759
- if (triggerEl) {
760
- this.dropdownWidth.set(triggerEl.getBoundingClientRect().width);
761
- }
762
- setTimeout(() => {
763
- this.inputRef()?.nativeElement.focus();
764
- }, 50);
765
- }
766
- onPopoverHideStart() {
767
- this._cancelPendingInput();
768
- this._openRequested = false;
769
- this.uiState.update(s => ({ ...s, isOpen: false }));
770
- this.activeIndex.set(-1);
771
- this._clearLocalLoadingTimer();
772
- this._pendingSearch.set(false);
773
- this.debouncedQuery.set('');
774
- if (!this.hasAsyncOptions()) {
775
- this._query$.next('');
776
- }
777
- }
778
- onPopoverHideEnd() {
779
- this.actualPosition.set('bottom');
780
- }
781
- onPositionChange(position) {
782
- this.actualPosition.set(position);
783
- }
784
- selectOption(option) {
785
- if (option.disabled) {
786
- return;
787
- }
788
- this.uiState.update(s => ({ ...s, dirty: true }));
789
- this.zOnSelect.emit(option);
790
- this._selectedOption.set(option);
791
- const newValue = this.zResetOnSelect() ? '' : option.label;
792
- this._hasPendingInput = false;
793
- this.inputValue.set(newValue);
794
- this._value.set(newValue);
795
- this.debouncedQuery.set(newValue);
796
- this._onChange(newValue);
797
- this.zValueChange.emit(newValue);
798
- this._valueBeforeNavigation = null;
799
- if (this.config().closeOnSelect) {
800
- this._closePanel();
801
- }
802
- this.activeIndex.set(-1);
803
- }
804
- clearInput(event) {
805
- event.stopPropagation();
806
- event.preventDefault();
807
- this._hasPendingInput = false;
808
- this.inputValue.set('');
809
- this._value.set('');
810
- this.uiState.update(s => ({ ...s, dirty: true }));
811
- this._onChange('');
812
- this.zValueChange.emit('');
813
- this._selectedOption.set(null);
814
- this._closePanel();
815
- this._clearLocalLoadingTimer();
816
- this._pendingSearch.set(false);
817
- this.debouncedQuery.set('');
818
- if (this.zType() === 'address_bar') {
819
- this.searchQuery.set('');
820
- }
821
- if (!this.hasAsyncOptions()) {
822
- this._query$.next('');
823
- }
824
- this.zOnCommit.emit({ value: '', source: 'blur' });
825
- this._resetAsyncOptions();
826
- setTimeout(() => {
827
- this.inputRef()?.nativeElement.focus();
828
- });
829
- }
830
- getOptionClasses(option, index) {
831
- return zAutocompleteOptionVariants({
832
- customTemplate: this.hasCustomOptionTemplate(),
833
- active: this.activeIndex() === index,
834
- disabled: option.disabled ?? false,
835
- });
836
- }
837
- trackByValue = (index, option) => {
838
- const key = this._getOptionKey(option);
839
- return `${String(key)}::${index}`;
840
- };
841
- focus() {
842
- this.inputRef()?.nativeElement.focus();
843
- }
844
- blur() {
845
- this.inputRef()?.nativeElement.blur();
846
- }
847
- clear() {
848
- this._hasPendingInput = false;
849
- this.inputValue.set('');
850
- this._value.set('');
851
- this.debouncedQuery.set('');
852
- const inputEl = this.inputRef()?.nativeElement;
853
- if (inputEl) {
854
- inputEl.value = '';
855
- }
856
- this._onChange('');
857
- this.zValueChange.emit('');
858
- this._selectedOption.set(null);
859
- this._closePanel();
860
- this._clearLocalLoadingTimer();
861
- this._pendingSearch.set(false);
862
- this._resetAsyncOptions();
863
- if (this.zType() === 'address_bar') {
864
- this.searchQuery.set('');
865
- }
866
- }
867
- reset() {
868
- this.clear();
869
- this.uiState.update(s => ({ ...s, touched: false, dirty: false }));
870
- }
871
- open() {
872
- this._openPanel();
873
- }
874
- close() {
875
- this._closePanel();
876
- }
877
- setValue(value) {
878
- this._hasPendingInput = false;
879
- this._value.set(value);
880
- this.inputValue.set(value);
881
- this.debouncedQuery.set(value);
882
- this._selectedOption.set(null);
883
- this._onChange(value);
884
- if (this.zType() === 'address_bar') {
885
- this.searchQuery.set(value);
886
- }
887
- }
888
- _openPanel() {
889
- if (this.isInteractionDisabled() || this._openRequested || this.uiState().isOpen) {
890
- return;
891
- }
892
- this._openRequested = true;
893
- this._popoverControl()?.show();
894
- }
895
- _closePanel() {
896
- this._popoverControl()?.close();
897
- }
898
- _cancelPendingInput() {
899
- if (!this._hasPendingInput) {
900
- return;
901
- }
902
- this._hasPendingInput = false;
903
- this.clear();
904
- }
905
- _setupDebounce() {
906
- this._query$
907
- .pipe(debounceTime(this.effectiveDebounceTime()), distinctUntilChanged(), takeUntilDestroyed(this._destroyRef))
908
- .subscribe(query => {
909
- if (this.zType() === 'address_bar') {
910
- this.searchQuery.set(query);
911
- }
912
- this.debouncedQuery.set(query);
913
- this.zOnSearch.emit(query);
914
- if (this.hasAsyncOptions()) {
915
- this._loadAsyncOptions(query, false);
916
- return;
917
- }
918
- if (this.config().serverSearch) {
919
- this._pendingServerSearchScrollReset = true;
920
- return;
921
- }
922
- this._resetOptionsScrollTop();
923
- this._clearLocalLoadingTimer();
924
- this._pendingSearch.set(true);
925
- this._localLoadingTimeout = setTimeout(() => {
926
- this._pendingSearch.set(false);
927
- this._localLoadingTimeout = null;
928
- }, 100);
929
- });
930
- }
931
- _loadAsyncOptionsOnFocus() {
932
- const asyncConfig = this.config().async;
933
- if (!asyncConfig?.loadOnFocus) {
934
- return;
935
- }
936
- const keyword = this.inputValue().trim();
937
- if (this._asyncKeyword() === keyword && this._asyncOptions().length > 0) {
938
- return;
939
- }
940
- this._loadAsyncOptions(keyword, false);
941
- }
942
- _loadAsyncOptions(keyword, append) {
943
- const asyncConfig = this.config().async;
944
- if (!asyncConfig) {
945
- return;
946
- }
947
- const normalizedKeyword = keyword.trim();
948
- const pageSize = asyncConfig.pageSize ?? Z_ASYNC_OPTIONS_DEFAULT_PAGE_SIZE;
949
- const { minLength } = this.config();
950
- const canLoadEmptyOnFocus = asyncConfig.loadOnFocus && normalizedKeyword.length === 0;
951
- if (!append && normalizedKeyword.length < minLength && !canLoadEmptyOnFocus) {
952
- this._resetAsyncOptions();
953
- return;
954
- }
955
- if (append && (!this._asyncHasMore() || this._asyncLoading() || this._asyncLoadingMore())) {
956
- return;
957
- }
958
- const page = append ? this._asyncPage() + 1 : 1;
959
- const requestId = ++this._asyncRequestId;
960
- const scrollTopBeforeAppend = append ? this._getAsyncOptionsScrollTop() : null;
961
- if (!append) {
962
- this._asyncLoadSubscription?.unsubscribe();
963
- this._asyncKeyword.set(normalizedKeyword);
964
- this._asyncLoading.set(true);
965
- this._asyncHasMore.set(false);
966
- }
967
- else {
968
- this._asyncLoadingMore.set(true);
969
- }
970
- let result;
971
- try {
972
- result = asyncConfig.load({
973
- keyword: normalizedKeyword,
974
- page,
975
- pageSize,
976
- });
977
- }
978
- catch (error) {
979
- this._handleAsyncOptionsError(error, append);
980
- return;
981
- }
982
- this._asyncLoadSubscription = zToAsyncOptionsObservable(result)
983
- .pipe(finalize(() => {
984
- if (requestId !== this._asyncRequestId) {
985
- return;
986
- }
987
- this._asyncLoading.set(false);
988
- this._asyncLoadingMore.set(false);
989
- }), takeUntilDestroyed(this._destroyRef))
990
- .subscribe({
991
- next: response => {
992
- if (requestId !== this._asyncRequestId) {
993
- return;
994
- }
995
- const nextItems = response.items ?? [];
996
- const previousCount = this._asyncOptions().length;
997
- const mergedOptions = append
998
- ? zMergeAsyncOptions(this._asyncOptions(), nextItems, asyncConfig.dedupeBy)
999
- : zMergeAsyncOptions([], nextItems, asyncConfig.dedupeBy);
1000
- const hasNewItems = mergedOptions.length > previousCount;
1001
- if (append && !hasNewItems) {
1002
- this._asyncHasMore.set(false);
1003
- this._restoreAsyncOptionsScrollTop(scrollTopBeforeAppend);
1004
- return;
1005
- }
1006
- this._asyncOptions.set(mergedOptions);
1007
- this._asyncPage.set(page);
1008
- this._asyncHasMore.set(append && !hasNewItems ? false : zResolveAsyncOptionsHasMore(response, pageSize, mergedOptions.length));
1009
- if (append) {
1010
- this._restoreAsyncOptionsScrollTop(scrollTopBeforeAppend);
1011
- return;
1012
- }
1013
- this._resetOptionsScrollTop();
1014
- },
1015
- error: error => {
1016
- if (requestId !== this._asyncRequestId) {
1017
- return;
1018
- }
1019
- this._handleAsyncOptionsError(error, append);
1020
- },
1021
- });
1022
- }
1023
- _handleAsyncOptionsError(error, append) {
1024
- console.error('ZAutocomplete async options load failed:', error);
1025
- if (!append) {
1026
- this._asyncOptions.set([]);
1027
- this._asyncPage.set(1);
1028
- }
1029
- this._asyncHasMore.set(false);
1030
- this._asyncLoading.set(false);
1031
- this._asyncLoadingMore.set(false);
1032
- }
1033
- _getAsyncOptionsScrollTop() {
1034
- return this._getOptionsScrollElement()?.scrollTop ?? null;
1035
- }
1036
- _restoreAsyncOptionsScrollTop(scrollTop) {
1037
- if (scrollTop === null) {
1038
- return;
1039
- }
1040
- requestAnimationFrame(() => {
1041
- const scrollElement = this._getOptionsScrollElement();
1042
- if (scrollElement) {
1043
- scrollElement.scrollTop = scrollTop;
1044
- }
1045
- });
1046
- }
1047
- _resetOptionsScrollTop(attempt = 0) {
1048
- requestAnimationFrame(() => {
1049
- const scrollElement = this._getOptionsScrollElement();
1050
- if (!scrollElement && attempt < 3) {
1051
- this._resetOptionsScrollTop(attempt + 1);
1052
- return;
1053
- }
1054
- if (!scrollElement) {
1055
- return;
1056
- }
1057
- if (this.shouldUseVirtualScroll()) {
1058
- this.virtualizer.scrollToOffset(0);
1059
- }
1060
- scrollElement.scrollTop = 0;
1061
- });
1062
- }
1063
- _getOptionsScrollElement() {
1064
- if (this.shouldUseVirtualScroll()) {
1065
- return this.virtualScrollRef()?.nativeElement ?? null;
1066
- }
1067
- return this.optionsContainerRef()?.nativeElement ?? null;
1068
- }
1069
- _resetAsyncOptions() {
1070
- this._asyncLoadSubscription?.unsubscribe();
1071
- this._asyncRequestId++;
1072
- this._asyncOptions.set([]);
1073
- this._asyncKeyword.set('');
1074
- this._asyncPage.set(1);
1075
- this._asyncHasMore.set(false);
1076
- this._asyncLoading.set(false);
1077
- this._asyncLoadingMore.set(false);
1078
- }
1079
- _clearLocalLoadingTimer() {
1080
- if (!this._localLoadingTimeout) {
1081
- return;
1082
- }
1083
- clearTimeout(this._localLoadingTimeout);
1084
- this._localLoadingTimeout = null;
1085
- }
1086
- _setupLoadMoreObserver() {
1087
- this._cleanupLoadMoreObserver();
1088
- const sentinel = this.loadMoreSentinelRef()?.nativeElement;
1089
- const container = this.optionsContainerRef()?.nativeElement;
1090
- if (!sentinel || !container) {
1091
- return;
1092
- }
1093
- this._loadMoreObserver = new IntersectionObserver(entries => {
1094
- const entry = entries[0];
1095
- if (entry?.isIntersecting && !this.isLoadingMore()) {
1096
- this._handleLoadMore(container.scrollTop);
1097
- }
1098
- }, {
1099
- root: container,
1100
- rootMargin: '100px',
1101
- threshold: 0,
1102
- });
1103
- this._loadMoreObserver.observe(sentinel);
1104
- }
1105
- _cleanupLoadMoreObserver() {
1106
- if (!this._loadMoreObserver) {
1107
- return;
1108
- }
1109
- this._loadMoreObserver.disconnect();
1110
- this._loadMoreObserver = null;
1111
- }
1112
- _setupVirtualScrollLoadMore() {
1113
- this._cleanupVirtualScrollListener();
1114
- const scrollElement = this.virtualScrollRef()?.nativeElement;
1115
- if (!scrollElement) {
1116
- return;
1117
- }
1118
- const handleScroll = () => {
1119
- if (this.isLoadingMore()) {
1120
- return;
1121
- }
1122
- const { scrollTop, scrollHeight, clientHeight } = scrollElement;
1123
- const threshold = clientHeight * this.zScrollDistance();
1124
- const distanceFromBottom = scrollHeight - scrollTop - clientHeight;
1125
- if (distanceFromBottom <= threshold) {
1126
- this._handleLoadMore(scrollTop);
1127
- }
1128
- };
1129
- scrollElement.addEventListener('scroll', handleScroll);
1130
- this._virtualScrollListener = () => {
1131
- scrollElement.removeEventListener('scroll', handleScroll);
1132
- };
1133
- }
1134
- _cleanupVirtualScrollListener() {
1135
- if (!this._virtualScrollListener) {
1136
- return;
1137
- }
1138
- this._virtualScrollListener();
1139
- this._virtualScrollListener = null;
1140
- }
1141
- _handleLoadMore(scrollTop) {
1142
- if (this.hasAsyncOptions()) {
1143
- if (!this.canLoadMore()) {
1144
- return;
1145
- }
1146
- this._loadAsyncOptions(this._asyncKeyword(), true);
1147
- return;
1148
- }
1149
- this.zOnLoadMore.emit({
1150
- currentCount: this.filteredOptions().length,
1151
- scrollTop,
1152
- });
1153
- }
1154
- _emitControl() {
1155
- this.zControl.emit({
1156
- focus: () => this.focus(),
1157
- blur: () => this.blur(),
1158
- clear: () => this.clear(),
1159
- reset: () => this.reset(),
1160
- open: () => this.open(),
1161
- close: () => this.close(),
1162
- setValue: (val) => this.setValue(val),
1163
- value: this._value.asReadonly(),
1164
- selected: this.selected,
1165
- state: this.state,
1166
- });
1167
- }
1168
- _getOptionKey(option) {
1169
- const key = this.zKey();
1170
- if (key && key in option) {
1171
- return option[key];
1172
- }
1173
- if (key && typeof option.value === 'object' && option.value !== null && key in option.value) {
1174
- return option.value[key];
1175
- }
1176
- return option.value;
1177
- }
1178
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: ZAutocompleteComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
1179
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.6", type: ZAutocompleteComponent, isStandalone: true, selector: "z-autocomplete", inputs: { class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null }, zOptions: { classPropertyName: "zOptions", publicName: "zOptions", isSignal: true, isRequired: false, transformFunction: null }, zConfig: { classPropertyName: "zConfig", publicName: "zConfig", isSignal: true, isRequired: false, transformFunction: null }, zSize: { classPropertyName: "zSize", publicName: "zSize", isSignal: true, isRequired: false, transformFunction: null }, zType: { classPropertyName: "zType", publicName: "zType", isSignal: true, isRequired: false, transformFunction: null }, zLabel: { classPropertyName: "zLabel", publicName: "zLabel", isSignal: true, isRequired: false, transformFunction: null }, zLabelClass: { classPropertyName: "zLabelClass", publicName: "zLabelClass", isSignal: true, isRequired: false, transformFunction: null }, zPlaceholder: { classPropertyName: "zPlaceholder", publicName: "zPlaceholder", isSignal: true, isRequired: false, transformFunction: null }, zDisabled: { classPropertyName: "zDisabled", publicName: "zDisabled", isSignal: true, isRequired: false, transformFunction: null }, zReadonly: { classPropertyName: "zReadonly", publicName: "zReadonly", isSignal: true, isRequired: false, transformFunction: null }, zLoading: { classPropertyName: "zLoading", publicName: "zLoading", isSignal: true, isRequired: false, transformFunction: null }, zLoadingOutline: { classPropertyName: "zLoadingOutline", publicName: "zLoadingOutline", isSignal: true, isRequired: false, transformFunction: null }, zRequired: { classPropertyName: "zRequired", publicName: "zRequired", isSignal: true, isRequired: false, transformFunction: null }, zPrefix: { classPropertyName: "zPrefix", publicName: "zPrefix", isSignal: true, isRequired: false, transformFunction: null }, zSuffix: { classPropertyName: "zSuffix", publicName: "zSuffix", isSignal: true, isRequired: false, transformFunction: null }, zAllowClear: { classPropertyName: "zAllowClear", publicName: "zAllowClear", isSignal: true, isRequired: false, transformFunction: null }, zVirtualScroll: { classPropertyName: "zVirtualScroll", publicName: "zVirtualScroll", isSignal: true, isRequired: false, transformFunction: null }, zDynamicSize: { classPropertyName: "zDynamicSize", publicName: "zDynamicSize", isSignal: true, isRequired: false, transformFunction: null }, zOptionHeight: { classPropertyName: "zOptionHeight", publicName: "zOptionHeight", isSignal: true, isRequired: false, transformFunction: null }, zDropdownMaxHeight: { classPropertyName: "zDropdownMaxHeight", publicName: "zDropdownMaxHeight", isSignal: true, isRequired: false, transformFunction: null }, zHeightExpand: { classPropertyName: "zHeightExpand", publicName: "zHeightExpand", isSignal: true, isRequired: false, transformFunction: null }, zMaxVisible: { classPropertyName: "zMaxVisible", publicName: "zMaxVisible", isSignal: true, isRequired: false, transformFunction: null }, zResetOnSelect: { classPropertyName: "zResetOnSelect", publicName: "zResetOnSelect", isSignal: true, isRequired: false, transformFunction: null }, zEmptyText: { classPropertyName: "zEmptyText", publicName: "zEmptyText", isSignal: true, isRequired: false, transformFunction: null }, zEmptyIcon: { classPropertyName: "zEmptyIcon", publicName: "zEmptyIcon", isSignal: true, isRequired: false, transformFunction: null }, zNoDataText: { classPropertyName: "zNoDataText", publicName: "zNoDataText", isSignal: true, isRequired: false, transformFunction: null }, zNoDataIcon: { classPropertyName: "zNoDataIcon", publicName: "zNoDataIcon", isSignal: true, isRequired: false, transformFunction: null }, zAllowCustomValue: { classPropertyName: "zAllowCustomValue", publicName: "zAllowCustomValue", isSignal: true, isRequired: false, transformFunction: null }, zOpenOnFocus: { classPropertyName: "zOpenOnFocus", publicName: "zOpenOnFocus", isSignal: true, isRequired: false, transformFunction: null }, zDebounceTime: { classPropertyName: "zDebounceTime", publicName: "zDebounceTime", isSignal: true, isRequired: false, transformFunction: null }, zLoadingMore: { classPropertyName: "zLoadingMore", publicName: "zLoadingMore", isSignal: true, isRequired: false, transformFunction: null }, zEnableLoadMore: { classPropertyName: "zEnableLoadMore", publicName: "zEnableLoadMore", isSignal: true, isRequired: false, transformFunction: null }, zScrollDistance: { classPropertyName: "zScrollDistance", publicName: "zScrollDistance", isSignal: true, isRequired: false, transformFunction: null }, zKey: { classPropertyName: "zKey", publicName: "zKey", isSignal: true, isRequired: false, transformFunction: null }, zOptionTemplate: { classPropertyName: "zOptionTemplate", publicName: "zOptionTemplate", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { zOnSearch: "zOnSearch", zOnLoadMore: "zOnLoadMore", zOnSelect: "zOnSelect", zOnEnter: "zOnEnter", zOnCommit: "zOnCommit", zValueChange: "zValueChange", zOnBlur: "zOnBlur", zOnFocus: "zOnFocus", zControl: "zControl", zEvent: "zEvent" }, providers: [
1180
- {
1181
- provide: NG_VALUE_ACCESSOR,
1182
- useExisting: forwardRef(() => ZAutocompleteComponent),
1183
- multi: true,
1184
- },
1185
- ], queries: [{ propertyName: "customOptionDirective", first: true, predicate: (ZAutocompleteOptionDirective), descendants: true, isSignal: true }], viewQueries: [{ propertyName: "triggerRef", first: true, predicate: ["triggerEl"], descendants: true, isSignal: true }, { propertyName: "inputRef", first: true, predicate: ["inputEl"], descendants: true, isSignal: true }, { propertyName: "dropdownTpl", first: true, predicate: ["dropdownTpl"], descendants: true, isSignal: true }, { propertyName: "virtualScrollRef", first: true, predicate: ["virtualScrollElement"], descendants: true, isSignal: true }, { propertyName: "optionsContainerRef", first: true, predicate: ["optionsContainer"], descendants: true, isSignal: true }, { propertyName: "loadMoreSentinelRef", first: true, predicate: ["loadMoreSentinel"], descendants: true, isSignal: true }, { propertyName: "virtualOptionElements", predicate: ["virtualOptionEl"], descendants: true, isSignal: true }], exportAs: ["zAutocomplete"], ngImport: i0, template: "<div class=\"z-autocomplete-wrapper relative flex w-full flex-col gap-2\">\n @if (zLabel()) {\n <label [for]=\"autocompleteId\" class=\"text-xs leading-none font-medium\" [class]=\"zLabelClass()\">\n {{ zLabel() }}\n @if (zRequired()) {\n <span class=\"text-destructive! ml-0.5\">*</span>\n }\n </label>\n }\n\n <div\n #triggerEl\n z-popover\n [zPopoverContent]=\"dropdownTpl\"\n [zOffset]=\"0\"\n [zDisabled]=\"isInteractionDisabled()\"\n zPopoverWidth=\"trigger\"\n zPopoverTrigger=\"manual\"\n zPosition=\"bottom\"\n zClass=\"border-0 shadow-none bg-transparent p-0\"\n (zControl)=\"onPopoverControl($event)\"\n (zShow)=\"onPopoverShow()\"\n (zHideStart)=\"onPopoverHideStart()\"\n (zHide)=\"onPopoverHideEnd()\"\n (zPositionChange)=\"onPositionChange($event)\"\n class=\"z-autocomplete-trigger\"\n [class]=\"inputClasses()\"\n z-tooltip\n [zContent]=\"inputValue()\"\n [zTooltipShowDelay]=\"300\"\n zTooltipTrigger=\"hover\"\n zTooltipPosition=\"top\"\n [zTooltipDisabled]=\"uiState().isFocused || uiState().isOpen || !hasValue()\"\n [zTriggerElement]=\"inputEl\"\n [class.z-autocomplete-open]=\"uiState().isOpen\"\n [class.z-autocomplete-open-top]=\"uiState().isOpen && isPositionTop()\"\n [class.z-autocomplete-open-bottom]=\"uiState().isOpen && !isPositionTop()\"\n role=\"combobox\"\n [attr.aria-expanded]=\"uiState().isOpen\"\n [attr.aria-haspopup]=\"'listbox'\"\n [attr.aria-controls]=\"dropdownId\">\n @if (zPrefix()) {\n <z-icon [zType]=\"zPrefix() || 'lucideSearch'\" zSize=\"16\" class=\"text-muted-foreground shrink-0\" />\n }\n\n <input\n #inputEl\n [id]=\"autocompleteId\"\n type=\"text\"\n class=\"z-autocomplete-input placeholder:text-muted-foreground min-w-0 flex-1 overflow-hidden bg-transparent text-ellipsis whitespace-nowrap outline-none\"\n [class.text-sm]=\"zSize() === 'sm' || zSize() === 'default'\"\n [placeholder]=\"zPlaceholder()\"\n [disabled]=\"isDisabled()\"\n [readOnly]=\"isReadonly()\"\n [value]=\"inputValue()\"\n (mousedown)=\"onInputMousedown($event)\"\n (input)=\"onInput($event)\"\n (focus)=\"onFocus($event)\"\n (blur)=\"onBlur($event)\"\n (click)=\"onInputClick()\"\n (keydown)=\"onKeydown($event)\"\n autocomplete=\"off\"\n autocorrect=\"off\"\n spellcheck=\"false\" />\n\n @if (isLoading() || isLoadingState() || isLoadingMore()) {\n <z-icon zType=\"lucideLoaderCircle\" zSize=\"16\" class=\"text-muted-foreground shrink-0 animate-spin\" />\n } @else {\n @if (zAllowClear() && hasValue() && !isDisabled() && !isReadonly()) {\n <button\n type=\"button\"\n class=\"text-muted-foreground hover:text-foreground flex shrink-0 cursor-pointer items-center justify-center transition-colors\"\n (mousedown)=\"clearInput($event)\"\n tabindex=\"-1\">\n <z-icon zType=\"lucideX\" zSize=\"18\" class=\"cursor-pointer!\" />\n </button>\n }\n\n @if (zSuffix()) {\n <z-icon [zType]=\"zSuffix() || 'lucideSearch'\" zSize=\"16\" class=\"text-muted-foreground shrink-0\" />\n }\n }\n </div>\n</div>\n\n<ng-template #dropdownTpl let-close=\"close\">\n <div\n [id]=\"dropdownId\"\n class=\"z-autocomplete-dropdown bg-popover border-ring overflow-hidden border shadow-[var(--z-popover-shadow)]\"\n [class.z-autocomplete-dropdown-bottom]=\"!isPositionTop()\"\n [class.rounded-b-sm]=\"!isPositionTop()\"\n [class.rounded-t-sm]=\"isPositionTop()\"\n [class.border-t-0]=\"!isPositionTop()\"\n [class.border-b-0]=\"isPositionTop()\"\n [style.width.px]=\"dropdownWidth()\"\n role=\"listbox\"\n (mousedown)=\"$event.preventDefault()\">\n @if (isLoading() || isLoadingState()) {\n <div\n class=\"z-autocomplete-content-state flex flex-col items-center justify-center\"\n [style.minHeight.px]=\"effectiveHeightExpand()\">\n <z-loading [zLoading]=\"true\" zSize=\"default\" />\n </div>\n } @else {\n @if (filteredOptions().length === 0) {\n <!-- Empty State -->\n <div\n class=\"z-autocomplete-content-state flex flex-col items-center justify-center p-1\"\n [style.minHeight.px]=\"effectiveHeightExpand()\">\n @if (inputValue().trim() !== '') {\n <!-- Searched but no results -->\n <z-empty [zIcon]=\"zEmptyIcon()\" zSize=\"sm\" [zMessage]=\"effectiveEmptyText()\" />\n } @else {\n <!-- No data initially -->\n <z-empty [zIcon]=\"zNoDataIcon()\" zSize=\"sm\" [zMessage]=\"effectiveNoDataText()\" />\n }\n </div>\n } @else if (shouldUseVirtualScroll()) {\n <!-- Virtual Scroll Mode -->\n <div\n #virtualScrollElement\n zHoverGlide\n zHoverGlideClass=\"bg-primary/15 rounded-(--radius-sm)\"\n class=\"z-autocomplete-content-state z-autocomplete-options z-autocomplete-virtual-scroll relative overflow-x-hidden overflow-y-auto overscroll-y-contain p-1\"\n [style.height.px]=\"effectiveHeightExpand()\">\n <div class=\"z-autocomplete-virtual-inner relative\" [style.height.px]=\"virtualizer.getTotalSize()\">\n @for (virtualItem of virtualizer.getVirtualItems(); track virtualItem.index) {\n @let opt = filteredOptions()[virtualItem.index];\n @let isActive = activeIndex() === virtualItem.index;\n <div\n #virtualOptionEl\n data-glide-item\n class=\"z-autocomplete-option absolute right-0 left-0 min-w-0\"\n [ngClass]=\"getOptionClasses(opt, virtualItem.index)\"\n [attr.data-index]=\"virtualItem.index\"\n [style.display]=\"hasCustomOptionTemplate() ? 'block' : null\"\n [style.height.px]=\"zDynamicSize() ? null : effectiveOptionHeight()\"\n [style.minHeight.px]=\"zDynamicSize() ? effectiveOptionHeight() : null\"\n [style.overflow]=\"hasCustomOptionTemplate() ? 'visible' : null\"\n [style.transform]=\"'translateY(' + virtualItem.start + 'px) translateZ(0)'\"\n [attr.aria-selected]=\"isActive\"\n role=\"option\"\n (mouseenter)=\"activeIndex.set(virtualItem.index)\"\n (click)=\"selectOption(opt)\">\n @if (effectiveOptionTemplate()) {\n <ng-container\n *ngTemplateOutlet=\"effectiveOptionTemplate()!; context: { $implicit: opt, active: isActive }\" />\n } @else {\n @if (opt.icon) {\n <z-icon [zType]=\"opt.icon\" zSize=\"16\" class=\"shrink-0\" />\n }\n <div class=\"min-w-0 flex-1\">\n <span\n class=\"block min-w-0 truncate\"\n z-tooltip\n [zContent]=\"opt.label\"\n [zShowDelay]=\"300\"\n zPosition=\"top\"\n [zHideDelay]=\"0\"\n [zOffset]=\"5\"\n [zArrow]=\"false\"\n [zTriggerElement]=\"virtualOptionEl\"\n [innerHTML]=\"\n config().highlightMatch ? (opt.label | zHighlight: highlightQuery() | zSafeHtml) : opt.label\n \"></span>\n @if (opt.description) {\n <span class=\"text-muted-foreground block min-w-0 truncate text-xs\">{{ opt.description }}</span>\n }\n </div>\n }\n </div>\n }\n </div>\n @if (isLoadingMore()) {\n <div\n class=\"z-autocomplete-loading-more from-popover via-popover/95 sticky bottom-0 -mx-1 -mb-1 flex items-center justify-center bg-gradient-to-t to-transparent pt-6 pb-2\"\n animate.enter=\"z-autocomplete-loading-enter\"\n animate.leave=\"z-autocomplete-loading-leave\">\n <z-loading zSize=\"xs\" [zLoading]=\"true\" />\n </div>\n }\n </div>\n } @else {\n <!-- Normal Scroll Mode -->\n <div\n #optionsContainer\n zHoverGlide\n zHoverGlideClass=\"bg-primary/15 rounded-(--radius-sm)\"\n class=\"z-autocomplete-content-state z-autocomplete-options flex flex-col gap-0.75 overflow-x-hidden overflow-y-auto overscroll-y-contain p-1\"\n [style.minHeight.px]=\"effectiveHeightExpand()\"\n [style.maxHeight.px]=\"effectiveHeightExpand()\">\n @for (item of optionViews(); track item.trackKey) {\n @let opt = item.option;\n @let i = item.index;\n @let isActive = activeIndex() === i;\n <div\n #optionEl2\n data-glide-item\n class=\"z-autocomplete-option relative min-w-0\"\n [ngClass]=\"getOptionClasses(opt, i)\"\n [style.display]=\"hasCustomOptionTemplate() ? 'block' : null\"\n [style.minHeight.px]=\"hasCustomOptionTemplate() ? null : effectiveOptionHeight()\"\n [style.overflow]=\"hasCustomOptionTemplate() ? 'visible' : null\"\n [attr.aria-selected]=\"isActive\"\n role=\"option\"\n (mouseenter)=\"activeIndex.set(i)\"\n (click)=\"selectOption(opt)\">\n @if (effectiveOptionTemplate()) {\n <ng-container\n *ngTemplateOutlet=\"effectiveOptionTemplate()!; context: { $implicit: opt, active: isActive }\" />\n } @else {\n @if (opt.icon) {\n <z-icon [zType]=\"opt.icon\" zSize=\"16\" class=\"shrink-0\" />\n }\n <div class=\"min-w-0 flex-1\">\n <span\n class=\"block min-w-0 truncate\"\n z-tooltip\n [zContent]=\"opt.label\"\n [zShowDelay]=\"300\"\n zPosition=\"top\"\n [zHideDelay]=\"0\"\n [zOffset]=\"5\"\n [zArrow]=\"false\"\n [zTriggerElement]=\"optionEl2\"\n [innerHTML]=\"\n config().highlightMatch ? (opt.label | zHighlight: highlightQuery() | zSafeHtml) : opt.label\n \"></span>\n @if (opt.description) {\n <span class=\"text-muted-foreground block min-w-0 truncate text-xs\">{{ opt.description }}</span>\n }\n </div>\n }\n </div>\n }\n @if (canLoadMore()) {\n <div #loadMoreSentinel class=\"h-px w-full shrink-0\"></div>\n }\n @if (isLoadingMore()) {\n <div\n class=\"z-autocomplete-loading-more from-popover via-popover/95 sticky bottom-0 -mx-1 -mb-1 flex items-center justify-center bg-gradient-to-t to-transparent pt-6 pb-2\"\n animate.enter=\"z-autocomplete-loading-enter\"\n animate.leave=\"z-autocomplete-loading-leave\">\n <z-loading zSize=\"xs\" [zLoading]=\"true\" />\n </div>\n }\n </div>\n }\n }\n </div>\n</ng-template>\n", styles: [".z-autocomplete-wrapper{width:100%}.z-autocomplete-trigger{-webkit-user-select:none;user-select:none}.z-autocomplete-trigger:focus-within{outline:none}.z-autocomplete-trigger *{cursor:inherit}.z-autocomplete-input{text-overflow:ellipsis;overflow:hidden}.z-autocomplete-input::placeholder{color:hsl(var(--muted-foreground))}.z-autocomplete-input:disabled{cursor:not-allowed}.z-autocomplete-open-bottom{border-bottom-left-radius:0!important;border-bottom-right-radius:0!important}.z-autocomplete-open-top{border-top-left-radius:0!important;border-top-right-radius:0!important}.z-autocomplete-dropdown{animation:z-autocomplete-dropdown-from-top .15s ease-out}.z-autocomplete-dropdown-bottom{animation:z-autocomplete-dropdown-from-bottom .15s ease-out}@keyframes z-autocomplete-dropdown-from-top{0%{opacity:0;transform:translateY(-.5rem)}to{opacity:1;transform:translateY(0)}}@keyframes z-autocomplete-dropdown-from-bottom{0%{opacity:0;transform:translateY(.5rem)}to{opacity:1;transform:translateY(0)}}.z-autocomplete-separator{display:none}.z-autocomplete-options{overflow-x:hidden!important;overflow-anchor:none}.z-autocomplete-scrollbar{--scrollbar-padding: 0;--scrollbar-track-color: transparent;--scrollbar-thumb-color: hsl(var(--muted-foreground) / .3);--scrollbar-thumb-hover-color: hsl(var(--muted-foreground) / .5);--scrollbar-size: 6px}.z-autocomplete-virtual-scroll .z-autocomplete-virtual-inner{width:100%}.z-autocomplete-content-state{animation:z-autocomplete-content-fade-in .15s ease-out}@keyframes z-autocomplete-content-fade-in{0%{opacity:0}to{opacity:1}}.z-autocomplete-option mark{background:transparent;color:hsl(var(--primary));font-weight:600}.z-autocomplete-option{transition:background-color .1s ease,color .1s ease}.z-autocomplete-options:not(.z-autocomplete-virtual-scroll) .z-autocomplete-option{animation:z-autocomplete-option-enter .12s ease-out;animation-fill-mode:both}@keyframes z-autocomplete-option-enter{0%{opacity:0}to{opacity:1}}.z-autocomplete-loading-enter{animation:z-autocomplete-loading-fade-in .2s ease-out}.z-autocomplete-loading-leave{animation:z-autocomplete-loading-fade-out .15s ease-in}@keyframes z-autocomplete-loading-fade-in{0%{opacity:0;transform:translateY(.5rem)}to{opacity:1;transform:translateY(0)}}@keyframes z-autocomplete-loading-fade-out{0%{opacity:1;transform:translateY(0)}to{opacity:0;transform:translateY(.5rem)}}@media(prefers-reduced-motion:reduce){.z-autocomplete-loading-enter,.z-autocomplete-loading-leave{animation-duration:1ms}}\n"], dependencies: [{ kind: "ngmodule", type: FormsModule }, { kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "component", type: ZIconComponent, selector: "z-icon, [z-icon]", inputs: ["class", "zType", "zAnimatedType", "zAnimate", "zAnimationTrigger", "zSize", "zStrokeWidth", "zSvg"] }, { kind: "component", type: ZLoadingComponent, selector: "z-loading", inputs: ["class", "zSpinner", "zSize", "zColor", "zText", "zOverlay", "zOverlayType", "zFullscreen", "zLoading"] }, { kind: "directive", type: ZPopoverDirective, selector: "[z-popover]", inputs: ["zPopoverContent", "zPosition", "zTrigger", "zPopoverTrigger", "zClass", "zShowDelay", "zHideDelay", "zDisabled", "zOffset", "zPopoverWidth", "zTriggerRef", "zManualClose", "zOutsideClickClose", "zScrollClose", "zSticky", "zShowArrow", "zKeyboardSafe"], outputs: ["zShow", "zHide", "zHideStart", "zControl", "zPositionChange", "zOutsideClick"], exportAs: ["zPopover"] }, { kind: "directive", type: ZTooltipDirective, selector: "[z-tooltip], [zTooltip]", inputs: ["zContent", "zContext", "zPosition", "zTooltipPosition", "zTrigger", "zTooltipTrigger", "zTooltipType", "zTooltipSize", "zClass", "zTooltipClass", "zShowDelay", "zTooltipShowDelay", "zHideDelay", "zTooltipHideDelay", "zArrow", "zTooltipArrow", "zDisabled", "zTooltipDisabled", "zOffset", "zTooltipOffset", "zAutoDetect", "zTriggerElement", "zAlwaysShow", "zMaxWidth"], outputs: ["zShow", "zHide"], exportAs: ["zTooltip"] }, { kind: "component", type: ZEmptyComponent, selector: "z-empty", inputs: ["class", "zType", "zIcon", "zIconSize", "zSize", "zMessage", "zDescription"] }, { kind: "directive", type: ZHoverGlideDirective, selector: "[zHoverGlide]", inputs: ["zHoverGlideSelector", "zHoverGlideClass", "zHoverGlideDisabled"] }, { kind: "pipe", type: ZHighlightPipe, name: "zHighlight" }, { kind: "pipe", type: ZSafeHtmlPipe, name: "zSafeHtml" }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
1186
- }
1187
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: ZAutocompleteComponent, decorators: [{
1188
- type: Component,
1189
- args: [{ selector: 'z-autocomplete', imports: [
1190
- FormsModule,
1191
- NgClass,
1192
- NgTemplateOutlet,
1193
- ZIconComponent,
1194
- ZLoadingComponent,
1195
- ZPopoverDirective,
1196
- ZTooltipDirective,
1197
- ZEmptyComponent,
1198
- ZHighlightPipe,
1199
- ZSafeHtmlPipe,
1200
- ZHoverGlideDirective,
1201
- ], standalone: true, providers: [
1202
- {
1203
- provide: NG_VALUE_ACCESSOR,
1204
- useExisting: forwardRef(() => ZAutocompleteComponent),
1205
- multi: true,
1206
- },
1207
- ], changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, exportAs: 'zAutocomplete', template: "<div class=\"z-autocomplete-wrapper relative flex w-full flex-col gap-2\">\n @if (zLabel()) {\n <label [for]=\"autocompleteId\" class=\"text-xs leading-none font-medium\" [class]=\"zLabelClass()\">\n {{ zLabel() }}\n @if (zRequired()) {\n <span class=\"text-destructive! ml-0.5\">*</span>\n }\n </label>\n }\n\n <div\n #triggerEl\n z-popover\n [zPopoverContent]=\"dropdownTpl\"\n [zOffset]=\"0\"\n [zDisabled]=\"isInteractionDisabled()\"\n zPopoverWidth=\"trigger\"\n zPopoverTrigger=\"manual\"\n zPosition=\"bottom\"\n zClass=\"border-0 shadow-none bg-transparent p-0\"\n (zControl)=\"onPopoverControl($event)\"\n (zShow)=\"onPopoverShow()\"\n (zHideStart)=\"onPopoverHideStart()\"\n (zHide)=\"onPopoverHideEnd()\"\n (zPositionChange)=\"onPositionChange($event)\"\n class=\"z-autocomplete-trigger\"\n [class]=\"inputClasses()\"\n z-tooltip\n [zContent]=\"inputValue()\"\n [zTooltipShowDelay]=\"300\"\n zTooltipTrigger=\"hover\"\n zTooltipPosition=\"top\"\n [zTooltipDisabled]=\"uiState().isFocused || uiState().isOpen || !hasValue()\"\n [zTriggerElement]=\"inputEl\"\n [class.z-autocomplete-open]=\"uiState().isOpen\"\n [class.z-autocomplete-open-top]=\"uiState().isOpen && isPositionTop()\"\n [class.z-autocomplete-open-bottom]=\"uiState().isOpen && !isPositionTop()\"\n role=\"combobox\"\n [attr.aria-expanded]=\"uiState().isOpen\"\n [attr.aria-haspopup]=\"'listbox'\"\n [attr.aria-controls]=\"dropdownId\">\n @if (zPrefix()) {\n <z-icon [zType]=\"zPrefix() || 'lucideSearch'\" zSize=\"16\" class=\"text-muted-foreground shrink-0\" />\n }\n\n <input\n #inputEl\n [id]=\"autocompleteId\"\n type=\"text\"\n class=\"z-autocomplete-input placeholder:text-muted-foreground min-w-0 flex-1 overflow-hidden bg-transparent text-ellipsis whitespace-nowrap outline-none\"\n [class.text-sm]=\"zSize() === 'sm' || zSize() === 'default'\"\n [placeholder]=\"zPlaceholder()\"\n [disabled]=\"isDisabled()\"\n [readOnly]=\"isReadonly()\"\n [value]=\"inputValue()\"\n (mousedown)=\"onInputMousedown($event)\"\n (input)=\"onInput($event)\"\n (focus)=\"onFocus($event)\"\n (blur)=\"onBlur($event)\"\n (click)=\"onInputClick()\"\n (keydown)=\"onKeydown($event)\"\n autocomplete=\"off\"\n autocorrect=\"off\"\n spellcheck=\"false\" />\n\n @if (isLoading() || isLoadingState() || isLoadingMore()) {\n <z-icon zType=\"lucideLoaderCircle\" zSize=\"16\" class=\"text-muted-foreground shrink-0 animate-spin\" />\n } @else {\n @if (zAllowClear() && hasValue() && !isDisabled() && !isReadonly()) {\n <button\n type=\"button\"\n class=\"text-muted-foreground hover:text-foreground flex shrink-0 cursor-pointer items-center justify-center transition-colors\"\n (mousedown)=\"clearInput($event)\"\n tabindex=\"-1\">\n <z-icon zType=\"lucideX\" zSize=\"18\" class=\"cursor-pointer!\" />\n </button>\n }\n\n @if (zSuffix()) {\n <z-icon [zType]=\"zSuffix() || 'lucideSearch'\" zSize=\"16\" class=\"text-muted-foreground shrink-0\" />\n }\n }\n </div>\n</div>\n\n<ng-template #dropdownTpl let-close=\"close\">\n <div\n [id]=\"dropdownId\"\n class=\"z-autocomplete-dropdown bg-popover border-ring overflow-hidden border shadow-[var(--z-popover-shadow)]\"\n [class.z-autocomplete-dropdown-bottom]=\"!isPositionTop()\"\n [class.rounded-b-sm]=\"!isPositionTop()\"\n [class.rounded-t-sm]=\"isPositionTop()\"\n [class.border-t-0]=\"!isPositionTop()\"\n [class.border-b-0]=\"isPositionTop()\"\n [style.width.px]=\"dropdownWidth()\"\n role=\"listbox\"\n (mousedown)=\"$event.preventDefault()\">\n @if (isLoading() || isLoadingState()) {\n <div\n class=\"z-autocomplete-content-state flex flex-col items-center justify-center\"\n [style.minHeight.px]=\"effectiveHeightExpand()\">\n <z-loading [zLoading]=\"true\" zSize=\"default\" />\n </div>\n } @else {\n @if (filteredOptions().length === 0) {\n <!-- Empty State -->\n <div\n class=\"z-autocomplete-content-state flex flex-col items-center justify-center p-1\"\n [style.minHeight.px]=\"effectiveHeightExpand()\">\n @if (inputValue().trim() !== '') {\n <!-- Searched but no results -->\n <z-empty [zIcon]=\"zEmptyIcon()\" zSize=\"sm\" [zMessage]=\"effectiveEmptyText()\" />\n } @else {\n <!-- No data initially -->\n <z-empty [zIcon]=\"zNoDataIcon()\" zSize=\"sm\" [zMessage]=\"effectiveNoDataText()\" />\n }\n </div>\n } @else if (shouldUseVirtualScroll()) {\n <!-- Virtual Scroll Mode -->\n <div\n #virtualScrollElement\n zHoverGlide\n zHoverGlideClass=\"bg-primary/15 rounded-(--radius-sm)\"\n class=\"z-autocomplete-content-state z-autocomplete-options z-autocomplete-virtual-scroll relative overflow-x-hidden overflow-y-auto overscroll-y-contain p-1\"\n [style.height.px]=\"effectiveHeightExpand()\">\n <div class=\"z-autocomplete-virtual-inner relative\" [style.height.px]=\"virtualizer.getTotalSize()\">\n @for (virtualItem of virtualizer.getVirtualItems(); track virtualItem.index) {\n @let opt = filteredOptions()[virtualItem.index];\n @let isActive = activeIndex() === virtualItem.index;\n <div\n #virtualOptionEl\n data-glide-item\n class=\"z-autocomplete-option absolute right-0 left-0 min-w-0\"\n [ngClass]=\"getOptionClasses(opt, virtualItem.index)\"\n [attr.data-index]=\"virtualItem.index\"\n [style.display]=\"hasCustomOptionTemplate() ? 'block' : null\"\n [style.height.px]=\"zDynamicSize() ? null : effectiveOptionHeight()\"\n [style.minHeight.px]=\"zDynamicSize() ? effectiveOptionHeight() : null\"\n [style.overflow]=\"hasCustomOptionTemplate() ? 'visible' : null\"\n [style.transform]=\"'translateY(' + virtualItem.start + 'px) translateZ(0)'\"\n [attr.aria-selected]=\"isActive\"\n role=\"option\"\n (mouseenter)=\"activeIndex.set(virtualItem.index)\"\n (click)=\"selectOption(opt)\">\n @if (effectiveOptionTemplate()) {\n <ng-container\n *ngTemplateOutlet=\"effectiveOptionTemplate()!; context: { $implicit: opt, active: isActive }\" />\n } @else {\n @if (opt.icon) {\n <z-icon [zType]=\"opt.icon\" zSize=\"16\" class=\"shrink-0\" />\n }\n <div class=\"min-w-0 flex-1\">\n <span\n class=\"block min-w-0 truncate\"\n z-tooltip\n [zContent]=\"opt.label\"\n [zShowDelay]=\"300\"\n zPosition=\"top\"\n [zHideDelay]=\"0\"\n [zOffset]=\"5\"\n [zArrow]=\"false\"\n [zTriggerElement]=\"virtualOptionEl\"\n [innerHTML]=\"\n config().highlightMatch ? (opt.label | zHighlight: highlightQuery() | zSafeHtml) : opt.label\n \"></span>\n @if (opt.description) {\n <span class=\"text-muted-foreground block min-w-0 truncate text-xs\">{{ opt.description }}</span>\n }\n </div>\n }\n </div>\n }\n </div>\n @if (isLoadingMore()) {\n <div\n class=\"z-autocomplete-loading-more from-popover via-popover/95 sticky bottom-0 -mx-1 -mb-1 flex items-center justify-center bg-gradient-to-t to-transparent pt-6 pb-2\"\n animate.enter=\"z-autocomplete-loading-enter\"\n animate.leave=\"z-autocomplete-loading-leave\">\n <z-loading zSize=\"xs\" [zLoading]=\"true\" />\n </div>\n }\n </div>\n } @else {\n <!-- Normal Scroll Mode -->\n <div\n #optionsContainer\n zHoverGlide\n zHoverGlideClass=\"bg-primary/15 rounded-(--radius-sm)\"\n class=\"z-autocomplete-content-state z-autocomplete-options flex flex-col gap-0.75 overflow-x-hidden overflow-y-auto overscroll-y-contain p-1\"\n [style.minHeight.px]=\"effectiveHeightExpand()\"\n [style.maxHeight.px]=\"effectiveHeightExpand()\">\n @for (item of optionViews(); track item.trackKey) {\n @let opt = item.option;\n @let i = item.index;\n @let isActive = activeIndex() === i;\n <div\n #optionEl2\n data-glide-item\n class=\"z-autocomplete-option relative min-w-0\"\n [ngClass]=\"getOptionClasses(opt, i)\"\n [style.display]=\"hasCustomOptionTemplate() ? 'block' : null\"\n [style.minHeight.px]=\"hasCustomOptionTemplate() ? null : effectiveOptionHeight()\"\n [style.overflow]=\"hasCustomOptionTemplate() ? 'visible' : null\"\n [attr.aria-selected]=\"isActive\"\n role=\"option\"\n (mouseenter)=\"activeIndex.set(i)\"\n (click)=\"selectOption(opt)\">\n @if (effectiveOptionTemplate()) {\n <ng-container\n *ngTemplateOutlet=\"effectiveOptionTemplate()!; context: { $implicit: opt, active: isActive }\" />\n } @else {\n @if (opt.icon) {\n <z-icon [zType]=\"opt.icon\" zSize=\"16\" class=\"shrink-0\" />\n }\n <div class=\"min-w-0 flex-1\">\n <span\n class=\"block min-w-0 truncate\"\n z-tooltip\n [zContent]=\"opt.label\"\n [zShowDelay]=\"300\"\n zPosition=\"top\"\n [zHideDelay]=\"0\"\n [zOffset]=\"5\"\n [zArrow]=\"false\"\n [zTriggerElement]=\"optionEl2\"\n [innerHTML]=\"\n config().highlightMatch ? (opt.label | zHighlight: highlightQuery() | zSafeHtml) : opt.label\n \"></span>\n @if (opt.description) {\n <span class=\"text-muted-foreground block min-w-0 truncate text-xs\">{{ opt.description }}</span>\n }\n </div>\n }\n </div>\n }\n @if (canLoadMore()) {\n <div #loadMoreSentinel class=\"h-px w-full shrink-0\"></div>\n }\n @if (isLoadingMore()) {\n <div\n class=\"z-autocomplete-loading-more from-popover via-popover/95 sticky bottom-0 -mx-1 -mb-1 flex items-center justify-center bg-gradient-to-t to-transparent pt-6 pb-2\"\n animate.enter=\"z-autocomplete-loading-enter\"\n animate.leave=\"z-autocomplete-loading-leave\">\n <z-loading zSize=\"xs\" [zLoading]=\"true\" />\n </div>\n }\n </div>\n }\n }\n </div>\n</ng-template>\n", styles: [".z-autocomplete-wrapper{width:100%}.z-autocomplete-trigger{-webkit-user-select:none;user-select:none}.z-autocomplete-trigger:focus-within{outline:none}.z-autocomplete-trigger *{cursor:inherit}.z-autocomplete-input{text-overflow:ellipsis;overflow:hidden}.z-autocomplete-input::placeholder{color:hsl(var(--muted-foreground))}.z-autocomplete-input:disabled{cursor:not-allowed}.z-autocomplete-open-bottom{border-bottom-left-radius:0!important;border-bottom-right-radius:0!important}.z-autocomplete-open-top{border-top-left-radius:0!important;border-top-right-radius:0!important}.z-autocomplete-dropdown{animation:z-autocomplete-dropdown-from-top .15s ease-out}.z-autocomplete-dropdown-bottom{animation:z-autocomplete-dropdown-from-bottom .15s ease-out}@keyframes z-autocomplete-dropdown-from-top{0%{opacity:0;transform:translateY(-.5rem)}to{opacity:1;transform:translateY(0)}}@keyframes z-autocomplete-dropdown-from-bottom{0%{opacity:0;transform:translateY(.5rem)}to{opacity:1;transform:translateY(0)}}.z-autocomplete-separator{display:none}.z-autocomplete-options{overflow-x:hidden!important;overflow-anchor:none}.z-autocomplete-scrollbar{--scrollbar-padding: 0;--scrollbar-track-color: transparent;--scrollbar-thumb-color: hsl(var(--muted-foreground) / .3);--scrollbar-thumb-hover-color: hsl(var(--muted-foreground) / .5);--scrollbar-size: 6px}.z-autocomplete-virtual-scroll .z-autocomplete-virtual-inner{width:100%}.z-autocomplete-content-state{animation:z-autocomplete-content-fade-in .15s ease-out}@keyframes z-autocomplete-content-fade-in{0%{opacity:0}to{opacity:1}}.z-autocomplete-option mark{background:transparent;color:hsl(var(--primary));font-weight:600}.z-autocomplete-option{transition:background-color .1s ease,color .1s ease}.z-autocomplete-options:not(.z-autocomplete-virtual-scroll) .z-autocomplete-option{animation:z-autocomplete-option-enter .12s ease-out;animation-fill-mode:both}@keyframes z-autocomplete-option-enter{0%{opacity:0}to{opacity:1}}.z-autocomplete-loading-enter{animation:z-autocomplete-loading-fade-in .2s ease-out}.z-autocomplete-loading-leave{animation:z-autocomplete-loading-fade-out .15s ease-in}@keyframes z-autocomplete-loading-fade-in{0%{opacity:0;transform:translateY(.5rem)}to{opacity:1;transform:translateY(0)}}@keyframes z-autocomplete-loading-fade-out{0%{opacity:1;transform:translateY(0)}to{opacity:0;transform:translateY(.5rem)}}@media(prefers-reduced-motion:reduce){.z-autocomplete-loading-enter,.z-autocomplete-loading-leave{animation-duration:1ms}}\n"] }]
1208
- }], ctorParameters: () => [], propDecorators: { triggerRef: [{ type: i0.ViewChild, args: ['triggerEl', { isSignal: true }] }], inputRef: [{ type: i0.ViewChild, args: ['inputEl', { isSignal: true }] }], dropdownTpl: [{ type: i0.ViewChild, args: ['dropdownTpl', { isSignal: true }] }], virtualScrollRef: [{ type: i0.ViewChild, args: ['virtualScrollElement', { isSignal: true }] }], optionsContainerRef: [{ type: i0.ViewChild, args: ['optionsContainer', { isSignal: true }] }], loadMoreSentinelRef: [{ type: i0.ViewChild, args: ['loadMoreSentinel', { isSignal: true }] }], virtualOptionElements: [{ type: i0.ViewChildren, args: ['virtualOptionEl', { isSignal: true }] }], customOptionDirective: [{ type: i0.ContentChild, args: [i0.forwardRef(() => ZAutocompleteOptionDirective), { isSignal: true }] }], class: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }], zOptions: [{ type: i0.Input, args: [{ isSignal: true, alias: "zOptions", required: false }] }], zConfig: [{ type: i0.Input, args: [{ isSignal: true, alias: "zConfig", required: false }] }], zSize: [{ type: i0.Input, args: [{ isSignal: true, alias: "zSize", required: false }] }], zType: [{ type: i0.Input, args: [{ isSignal: true, alias: "zType", required: false }] }], zLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "zLabel", required: false }] }], zLabelClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "zLabelClass", required: false }] }], zPlaceholder: [{ type: i0.Input, args: [{ isSignal: true, alias: "zPlaceholder", required: false }] }], zDisabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "zDisabled", required: false }] }], zReadonly: [{ type: i0.Input, args: [{ isSignal: true, alias: "zReadonly", required: false }] }], zLoading: [{ type: i0.Input, args: [{ isSignal: true, alias: "zLoading", required: false }] }], zLoadingOutline: [{ type: i0.Input, args: [{ isSignal: true, alias: "zLoadingOutline", required: false }] }], zRequired: [{ type: i0.Input, args: [{ isSignal: true, alias: "zRequired", required: false }] }], zPrefix: [{ type: i0.Input, args: [{ isSignal: true, alias: "zPrefix", required: false }] }], zSuffix: [{ type: i0.Input, args: [{ isSignal: true, alias: "zSuffix", required: false }] }], zAllowClear: [{ type: i0.Input, args: [{ isSignal: true, alias: "zAllowClear", required: false }] }], zVirtualScroll: [{ type: i0.Input, args: [{ isSignal: true, alias: "zVirtualScroll", required: false }] }], zDynamicSize: [{ type: i0.Input, args: [{ isSignal: true, alias: "zDynamicSize", required: false }] }], zOptionHeight: [{ type: i0.Input, args: [{ isSignal: true, alias: "zOptionHeight", required: false }] }], zDropdownMaxHeight: [{ type: i0.Input, args: [{ isSignal: true, alias: "zDropdownMaxHeight", required: false }] }], zHeightExpand: [{ type: i0.Input, args: [{ isSignal: true, alias: "zHeightExpand", required: false }] }], zMaxVisible: [{ type: i0.Input, args: [{ isSignal: true, alias: "zMaxVisible", required: false }] }], zResetOnSelect: [{ type: i0.Input, args: [{ isSignal: true, alias: "zResetOnSelect", required: false }] }], zEmptyText: [{ type: i0.Input, args: [{ isSignal: true, alias: "zEmptyText", required: false }] }], zEmptyIcon: [{ type: i0.Input, args: [{ isSignal: true, alias: "zEmptyIcon", required: false }] }], zNoDataText: [{ type: i0.Input, args: [{ isSignal: true, alias: "zNoDataText", required: false }] }], zNoDataIcon: [{ type: i0.Input, args: [{ isSignal: true, alias: "zNoDataIcon", required: false }] }], zAllowCustomValue: [{ type: i0.Input, args: [{ isSignal: true, alias: "zAllowCustomValue", required: false }] }], zOpenOnFocus: [{ type: i0.Input, args: [{ isSignal: true, alias: "zOpenOnFocus", required: false }] }], zDebounceTime: [{ type: i0.Input, args: [{ isSignal: true, alias: "zDebounceTime", required: false }] }], zLoadingMore: [{ type: i0.Input, args: [{ isSignal: true, alias: "zLoadingMore", required: false }] }], zEnableLoadMore: [{ type: i0.Input, args: [{ isSignal: true, alias: "zEnableLoadMore", required: false }] }], zScrollDistance: [{ type: i0.Input, args: [{ isSignal: true, alias: "zScrollDistance", required: false }] }], zKey: [{ type: i0.Input, args: [{ isSignal: true, alias: "zKey", required: false }] }], zOptionTemplate: [{ type: i0.Input, args: [{ isSignal: true, alias: "zOptionTemplate", required: false }] }], zOnSearch: [{ type: i0.Output, args: ["zOnSearch"] }], zOnLoadMore: [{ type: i0.Output, args: ["zOnLoadMore"] }], zOnSelect: [{ type: i0.Output, args: ["zOnSelect"] }], zOnEnter: [{ type: i0.Output, args: ["zOnEnter"] }], zOnCommit: [{ type: i0.Output, args: ["zOnCommit"] }], zValueChange: [{ type: i0.Output, args: ["zValueChange"] }], zOnBlur: [{ type: i0.Output, args: ["zOnBlur"] }], zOnFocus: [{ type: i0.Output, args: ["zOnFocus"] }], zControl: [{ type: i0.Output, args: ["zControl"] }], zEvent: [{ type: i0.Output, args: ["zEvent"] }] } });
1209
-
1210
- /**
1211
- * Generated bundle index. Do not edit.
1212
- */
1213
-
1214
- export { ZAutocompleteComponent, ZAutocompleteOptionDirective, Z_AUTOCOMPLETE_DEFAULT_CONFIG, zAutocompleteInputVariants, zAutocompleteOptionVariants };
1215
- //# sourceMappingURL=shival99-z-ui-components-z-autocomplete.mjs.map