@shival99/z-ui 1.9.22 → 1.9.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/fesm2022/shival99-z-ui-components-z-autocomplete.mjs +26 -186
- package/fesm2022/shival99-z-ui-components-z-autocomplete.mjs.map +1 -1
- package/fesm2022/shival99-z-ui-components-z-calendar.mjs +106 -247
- package/fesm2022/shival99-z-ui-components-z-calendar.mjs.map +1 -1
- package/fesm2022/shival99-z-ui-components-z-editor.mjs +5 -0
- package/fesm2022/shival99-z-ui-components-z-editor.mjs.map +1 -1
- package/fesm2022/shival99-z-ui-components-z-gallery.mjs +109 -6
- package/fesm2022/shival99-z-ui-components-z-gallery.mjs.map +1 -1
- package/fesm2022/shival99-z-ui-components-z-input.mjs +5 -0
- package/fesm2022/shival99-z-ui-components-z-input.mjs.map +1 -1
- package/fesm2022/shival99-z-ui-components-z-kanban.mjs +1 -1
- package/fesm2022/shival99-z-ui-components-z-kanban.mjs.map +1 -1
- package/fesm2022/shival99-z-ui-components-z-menu.mjs +318 -2
- package/fesm2022/shival99-z-ui-components-z-menu.mjs.map +1 -1
- package/fesm2022/shival99-z-ui-components-z-pagination.mjs +1 -1
- package/fesm2022/shival99-z-ui-components-z-pagination.mjs.map +1 -1
- package/fesm2022/shival99-z-ui-components-z-select.mjs +45 -205
- package/fesm2022/shival99-z-ui-components-z-select.mjs.map +1 -1
- package/fesm2022/shival99-z-ui-components-z-table.mjs +2 -2
- package/fesm2022/shival99-z-ui-components-z-table.mjs.map +1 -1
- package/fesm2022/shival99-z-ui-components-z-tabs.mjs +15 -10
- package/fesm2022/shival99-z-ui-components-z-tabs.mjs.map +1 -1
- package/fesm2022/shival99-z-ui-components-z-upload.mjs +5 -0
- package/fesm2022/shival99-z-ui-components-z-upload.mjs.map +1 -1
- package/fesm2022/shival99-z-ui-i18n.mjs +8 -0
- package/fesm2022/shival99-z-ui-i18n.mjs.map +1 -1
- package/fesm2022/shival99-z-ui-utils.mjs +2 -69
- package/fesm2022/shival99-z-ui-utils.mjs.map +1 -1
- package/package.json +1 -1
- package/types/shival99-z-ui-components-z-autocomplete.d.ts +6 -37
- package/types/shival99-z-ui-components-z-calendar.d.ts +11 -1
- package/types/shival99-z-ui-components-z-editor.d.ts +8 -1
- package/types/shival99-z-ui-components-z-gallery.d.ts +38 -3
- package/types/shival99-z-ui-components-z-input.d.ts +8 -1
- package/types/shival99-z-ui-components-z-menu.d.ts +67 -2
- package/types/shival99-z-ui-components-z-modal.d.ts +1 -1
- package/types/shival99-z-ui-components-z-select.d.ts +12 -38
- package/types/shival99-z-ui-components-z-tabs.d.ts +3 -2
- package/types/shival99-z-ui-components-z-upload.d.ts +8 -0
- package/types/shival99-z-ui-utils.d.ts +2 -47
|
@@ -10,8 +10,8 @@ import { ZLoadingComponent } from '@shival99/z-ui/components/z-loading';
|
|
|
10
10
|
import { ZPopoverDirective } from '@shival99/z-ui/components/z-popover';
|
|
11
11
|
import { ZTooltipDirective } from '@shival99/z-ui/components/z-tooltip';
|
|
12
12
|
import { ZHighlightPipe, ZSafeHtmlPipe } from '@shival99/z-ui/pipes';
|
|
13
|
-
import { zTransform, zUuid, zRemoveVietnamese, zMergeClasses, zCreateEvent
|
|
14
|
-
import { Subject, debounceTime, distinctUntilChanged
|
|
13
|
+
import { zTransform, zUuid, zRemoveVietnamese, zMergeClasses, zCreateEvent } from '@shival99/z-ui/utils';
|
|
14
|
+
import { Subject, debounceTime, distinctUntilChanged } from 'rxjs';
|
|
15
15
|
import { cva } from 'class-variance-authority';
|
|
16
16
|
|
|
17
17
|
class ZAutocompleteOptionDirective {
|
|
@@ -142,12 +142,6 @@ class ZAutocompleteComponent {
|
|
|
142
142
|
_formControl = signal(null, ...(ngDevMode ? [{ debugName: "_formControl" }] : []));
|
|
143
143
|
_popoverControl = signal(null, ...(ngDevMode ? [{ debugName: "_popoverControl" }] : []));
|
|
144
144
|
_selectedOption = signal(null, ...(ngDevMode ? [{ debugName: "_selectedOption" }] : []));
|
|
145
|
-
_asyncOptions = signal([], ...(ngDevMode ? [{ debugName: "_asyncOptions" }] : []));
|
|
146
|
-
_asyncKeyword = signal('', ...(ngDevMode ? [{ debugName: "_asyncKeyword" }] : []));
|
|
147
|
-
_asyncPage = signal(1, ...(ngDevMode ? [{ debugName: "_asyncPage" }] : []));
|
|
148
|
-
_asyncHasMore = signal(false, ...(ngDevMode ? [{ debugName: "_asyncHasMore" }] : []));
|
|
149
|
-
_asyncLoading = signal(false, ...(ngDevMode ? [{ debugName: "_asyncLoading" }] : []));
|
|
150
|
-
_asyncLoadingMore = signal(false, ...(ngDevMode ? [{ debugName: "_asyncLoadingMore" }] : []));
|
|
151
145
|
uiState = signal({
|
|
152
146
|
isOpen: false,
|
|
153
147
|
isFocused: false,
|
|
@@ -166,8 +160,6 @@ class ZAutocompleteComponent {
|
|
|
166
160
|
_localLoadingTimeout = null;
|
|
167
161
|
_loadMoreObserver = null;
|
|
168
162
|
_virtualScrollListener = null;
|
|
169
|
-
_asyncLoadSubscription = null;
|
|
170
|
-
_asyncRequestId = 0;
|
|
171
163
|
_lastFilteredOptionsLength = 0;
|
|
172
164
|
_shouldScrollActiveOption = false;
|
|
173
165
|
/** Stores input value before keyboard navigation for ESC revert */
|
|
@@ -192,11 +184,6 @@ class ZAutocompleteComponent {
|
|
|
192
184
|
...Z_AUTOCOMPLETE_DEFAULT_CONFIG,
|
|
193
185
|
...this.zConfig(),
|
|
194
186
|
}), ...(ngDevMode ? [{ debugName: "config" }] : []));
|
|
195
|
-
hasAsyncOptions = computed(() => !!this.config().async?.load, ...(ngDevMode ? [{ debugName: "hasAsyncOptions" }] : []));
|
|
196
|
-
sourceOptions = computed(() => (this.hasAsyncOptions() ? this._asyncOptions() : this.zOptions()), ...(ngDevMode ? [{ debugName: "sourceOptions" }] : []));
|
|
197
|
-
isLoading = computed(() => this.zLoading() || this._asyncLoading(), ...(ngDevMode ? [{ debugName: "isLoading" }] : []));
|
|
198
|
-
isLoadingMore = computed(() => this.zLoadingMore() || this._asyncLoadingMore(), ...(ngDevMode ? [{ debugName: "isLoadingMore" }] : []));
|
|
199
|
-
canLoadMore = computed(() => this.hasAsyncOptions() ? this._asyncHasMore() : this.zEnableLoadMore(), ...(ngDevMode ? [{ debugName: "canLoadMore" }] : []));
|
|
200
187
|
isDisabled = computed(() => this._disabled() || this.zDisabled(), ...(ngDevMode ? [{ debugName: "isDisabled" }] : []));
|
|
201
188
|
isReadonly = computed(() => this.zReadonly(), ...(ngDevMode ? [{ debugName: "isReadonly" }] : []));
|
|
202
189
|
isInteractionDisabled = computed(() => this.isDisabled() || this.isReadonly() || this.zLoading(), ...(ngDevMode ? [{ debugName: "isInteractionDisabled" }] : []));
|
|
@@ -204,7 +191,7 @@ class ZAutocompleteComponent {
|
|
|
204
191
|
effectiveHeightExpand = computed(() => this.zHeightExpand() || this.config().dropdownMaxHeight, ...(ngDevMode ? [{ debugName: "effectiveHeightExpand" }] : []));
|
|
205
192
|
effectiveEmptyText = computed(() => this.zEmptyText() || this.config().emptyMessage, ...(ngDevMode ? [{ debugName: "effectiveEmptyText" }] : []));
|
|
206
193
|
effectiveNoDataText = computed(() => this.zNoDataText() || this.config().noDataMessage, ...(ngDevMode ? [{ debugName: "effectiveNoDataText" }] : []));
|
|
207
|
-
effectiveDebounceTime = computed(() => this.
|
|
194
|
+
effectiveDebounceTime = computed(() => this.zDebounceTime(), ...(ngDevMode ? [{ debugName: "effectiveDebounceTime" }] : []));
|
|
208
195
|
effectiveOptionTemplate = computed(() => {
|
|
209
196
|
const directive = this.customOptionDirective();
|
|
210
197
|
if (directive) {
|
|
@@ -219,7 +206,7 @@ class ZAutocompleteComponent {
|
|
|
219
206
|
* Server mode relies only on zLoading from parent.
|
|
220
207
|
*/
|
|
221
208
|
isLoadingState = computed(() => {
|
|
222
|
-
if (this.config().serverSearch
|
|
209
|
+
if (this.config().serverSearch) {
|
|
223
210
|
return false;
|
|
224
211
|
}
|
|
225
212
|
const hasInput = this.inputValue().trim() !== '';
|
|
@@ -236,22 +223,22 @@ class ZAutocompleteComponent {
|
|
|
236
223
|
if (this.hasCustomOptionTemplate()) {
|
|
237
224
|
return false;
|
|
238
225
|
}
|
|
239
|
-
if (this.
|
|
226
|
+
if (this.zEnableLoadMore()) {
|
|
240
227
|
return false;
|
|
241
228
|
}
|
|
242
229
|
const maxVisible = this.zMaxVisible();
|
|
243
|
-
if (maxVisible !== null && this.
|
|
230
|
+
if (maxVisible !== null && this.zOptions().length > maxVisible) {
|
|
244
231
|
return true;
|
|
245
232
|
}
|
|
246
|
-
return this.
|
|
233
|
+
return this.zOptions().length > 50;
|
|
247
234
|
}, ...(ngDevMode ? [{ debugName: "shouldUseVirtualScroll" }] : []));
|
|
248
235
|
filteredOptions = computed(() => {
|
|
249
|
-
const options = this.
|
|
236
|
+
const options = this.zOptions();
|
|
250
237
|
const cfg = this.config();
|
|
251
238
|
const allowCustom = this.zAllowCustomValue();
|
|
252
239
|
const query = this.zType() === 'address_bar' ? this.searchQuery() : this.debouncedQuery();
|
|
253
240
|
// If server search is enabled, skip local filtering - just apply maxDisplayed limit
|
|
254
|
-
if (cfg.serverSearch
|
|
241
|
+
if (cfg.serverSearch) {
|
|
255
242
|
let result = options;
|
|
256
243
|
if (cfg.maxDisplayed && options.length > cfg.maxDisplayed) {
|
|
257
244
|
result = options.slice(0, cfg.maxDisplayed);
|
|
@@ -353,7 +340,7 @@ class ZAutocompleteComponent {
|
|
|
353
340
|
if (!isOpen || idx < 0) {
|
|
354
341
|
return;
|
|
355
342
|
}
|
|
356
|
-
if (!this._shouldScrollActiveOption || this.shouldUseVirtualScroll() || this.
|
|
343
|
+
if (!this._shouldScrollActiveOption || this.shouldUseVirtualScroll() || this.zEnableLoadMore()) {
|
|
357
344
|
return;
|
|
358
345
|
}
|
|
359
346
|
this._shouldScrollActiveOption = false;
|
|
@@ -371,7 +358,7 @@ class ZAutocompleteComponent {
|
|
|
371
358
|
const sentinel = this.loadMoreSentinelRef();
|
|
372
359
|
const { isOpen } = this.uiState();
|
|
373
360
|
const optionsCount = this.filteredOptions().length;
|
|
374
|
-
if (!sentinel || !isOpen || optionsCount === 0
|
|
361
|
+
if (!sentinel || !isOpen || optionsCount === 0) {
|
|
375
362
|
this._cleanupLoadMoreObserver();
|
|
376
363
|
return;
|
|
377
364
|
}
|
|
@@ -602,9 +589,7 @@ class ZAutocompleteComponent {
|
|
|
602
589
|
this._value.set('');
|
|
603
590
|
this._onChange('');
|
|
604
591
|
this.zValueChange.emit('');
|
|
605
|
-
|
|
606
|
-
this._query$.next('');
|
|
607
|
-
}
|
|
592
|
+
this._query$.next('');
|
|
608
593
|
this._closePanel();
|
|
609
594
|
this.activeIndex.set(-1);
|
|
610
595
|
}
|
|
@@ -613,7 +598,6 @@ class ZAutocompleteComponent {
|
|
|
613
598
|
}
|
|
614
599
|
onPopoverShow() {
|
|
615
600
|
this.uiState.update(s => ({ ...s, isOpen: true }));
|
|
616
|
-
this._loadAsyncOptionsOnFocus();
|
|
617
601
|
setTimeout(() => {
|
|
618
602
|
this.inputRef()?.nativeElement.focus();
|
|
619
603
|
}, 50);
|
|
@@ -624,9 +608,7 @@ class ZAutocompleteComponent {
|
|
|
624
608
|
this._clearLocalLoadingTimer();
|
|
625
609
|
this._pendingSearch.set(false);
|
|
626
610
|
this.debouncedQuery.set('');
|
|
627
|
-
|
|
628
|
-
this._query$.next('');
|
|
629
|
-
}
|
|
611
|
+
this._query$.next('');
|
|
630
612
|
}
|
|
631
613
|
onPopoverHideEnd() {
|
|
632
614
|
this.actualPosition.set('bottom');
|
|
@@ -669,11 +651,8 @@ class ZAutocompleteComponent {
|
|
|
669
651
|
if (this.zType() === 'address_bar') {
|
|
670
652
|
this.searchQuery.set('');
|
|
671
653
|
}
|
|
672
|
-
|
|
673
|
-
this._query$.next('');
|
|
674
|
-
}
|
|
654
|
+
this._query$.next('');
|
|
675
655
|
this.zOnCommit.emit({ value: '', source: 'blur' });
|
|
676
|
-
this._resetAsyncOptions();
|
|
677
656
|
setTimeout(() => {
|
|
678
657
|
this.inputRef()?.nativeElement.focus();
|
|
679
658
|
});
|
|
@@ -704,7 +683,6 @@ class ZAutocompleteComponent {
|
|
|
704
683
|
this._closePanel();
|
|
705
684
|
this._clearLocalLoadingTimer();
|
|
706
685
|
this._pendingSearch.set(false);
|
|
707
|
-
this._resetAsyncOptions();
|
|
708
686
|
if (this.zType() === 'address_bar') {
|
|
709
687
|
this.searchQuery.set('');
|
|
710
688
|
}
|
|
@@ -747,10 +725,6 @@ class ZAutocompleteComponent {
|
|
|
747
725
|
}
|
|
748
726
|
this.debouncedQuery.set(query);
|
|
749
727
|
this.zOnSearch.emit(query);
|
|
750
|
-
if (this.hasAsyncOptions()) {
|
|
751
|
-
this._loadAsyncOptions(query, false);
|
|
752
|
-
return;
|
|
753
|
-
}
|
|
754
728
|
if (this.config().serverSearch) {
|
|
755
729
|
return;
|
|
756
730
|
}
|
|
@@ -762,133 +736,6 @@ class ZAutocompleteComponent {
|
|
|
762
736
|
}, 100);
|
|
763
737
|
});
|
|
764
738
|
}
|
|
765
|
-
_loadAsyncOptionsOnFocus() {
|
|
766
|
-
const asyncConfig = this.config().async;
|
|
767
|
-
if (!asyncConfig?.loadOnFocus) {
|
|
768
|
-
return;
|
|
769
|
-
}
|
|
770
|
-
const keyword = this.inputValue().trim();
|
|
771
|
-
if (this._asyncKeyword() === keyword && this._asyncOptions().length > 0) {
|
|
772
|
-
return;
|
|
773
|
-
}
|
|
774
|
-
this._loadAsyncOptions(keyword, false);
|
|
775
|
-
}
|
|
776
|
-
_loadAsyncOptions(keyword, append) {
|
|
777
|
-
const asyncConfig = this.config().async;
|
|
778
|
-
if (!asyncConfig) {
|
|
779
|
-
return;
|
|
780
|
-
}
|
|
781
|
-
const normalizedKeyword = keyword.trim();
|
|
782
|
-
const pageSize = asyncConfig.pageSize ?? Z_ASYNC_OPTIONS_DEFAULT_PAGE_SIZE;
|
|
783
|
-
const { minLength } = this.config();
|
|
784
|
-
const canLoadEmptyOnFocus = asyncConfig.loadOnFocus && normalizedKeyword.length === 0;
|
|
785
|
-
if (!append && normalizedKeyword.length < minLength && !canLoadEmptyOnFocus) {
|
|
786
|
-
this._resetAsyncOptions();
|
|
787
|
-
return;
|
|
788
|
-
}
|
|
789
|
-
if (append && (!this._asyncHasMore() || this._asyncLoading() || this._asyncLoadingMore())) {
|
|
790
|
-
return;
|
|
791
|
-
}
|
|
792
|
-
const page = append ? this._asyncPage() + 1 : 1;
|
|
793
|
-
const requestId = ++this._asyncRequestId;
|
|
794
|
-
const scrollTopBeforeAppend = append ? this._getAsyncOptionsScrollTop() : null;
|
|
795
|
-
if (!append) {
|
|
796
|
-
this._asyncLoadSubscription?.unsubscribe();
|
|
797
|
-
this._asyncKeyword.set(normalizedKeyword);
|
|
798
|
-
this._asyncLoading.set(true);
|
|
799
|
-
this._asyncHasMore.set(false);
|
|
800
|
-
}
|
|
801
|
-
else {
|
|
802
|
-
this._asyncLoadingMore.set(true);
|
|
803
|
-
}
|
|
804
|
-
let result;
|
|
805
|
-
try {
|
|
806
|
-
result = asyncConfig.load({
|
|
807
|
-
keyword: normalizedKeyword,
|
|
808
|
-
page,
|
|
809
|
-
pageSize,
|
|
810
|
-
});
|
|
811
|
-
}
|
|
812
|
-
catch (error) {
|
|
813
|
-
this._handleAsyncOptionsError(error, append);
|
|
814
|
-
return;
|
|
815
|
-
}
|
|
816
|
-
this._asyncLoadSubscription = zToAsyncOptionsObservable(result)
|
|
817
|
-
.pipe(finalize(() => {
|
|
818
|
-
if (requestId !== this._asyncRequestId) {
|
|
819
|
-
return;
|
|
820
|
-
}
|
|
821
|
-
this._asyncLoading.set(false);
|
|
822
|
-
this._asyncLoadingMore.set(false);
|
|
823
|
-
}), takeUntilDestroyed(this._destroyRef))
|
|
824
|
-
.subscribe({
|
|
825
|
-
next: response => {
|
|
826
|
-
if (requestId !== this._asyncRequestId) {
|
|
827
|
-
return;
|
|
828
|
-
}
|
|
829
|
-
const nextItems = response.items ?? [];
|
|
830
|
-
const previousCount = this._asyncOptions().length;
|
|
831
|
-
const mergedOptions = append
|
|
832
|
-
? zMergeAsyncOptions(this._asyncOptions(), nextItems, asyncConfig.dedupeBy)
|
|
833
|
-
: zMergeAsyncOptions([], nextItems, asyncConfig.dedupeBy);
|
|
834
|
-
const hasNewItems = mergedOptions.length > previousCount;
|
|
835
|
-
if (append && !hasNewItems) {
|
|
836
|
-
this._asyncHasMore.set(false);
|
|
837
|
-
this._restoreAsyncOptionsScrollTop(scrollTopBeforeAppend);
|
|
838
|
-
return;
|
|
839
|
-
}
|
|
840
|
-
this._asyncOptions.set(mergedOptions);
|
|
841
|
-
this._asyncPage.set(page);
|
|
842
|
-
this._asyncHasMore.set(append && !hasNewItems ? false : zResolveAsyncOptionsHasMore(response, pageSize, mergedOptions.length));
|
|
843
|
-
this._restoreAsyncOptionsScrollTop(scrollTopBeforeAppend);
|
|
844
|
-
},
|
|
845
|
-
error: error => {
|
|
846
|
-
if (requestId !== this._asyncRequestId) {
|
|
847
|
-
return;
|
|
848
|
-
}
|
|
849
|
-
this._handleAsyncOptionsError(error, append);
|
|
850
|
-
},
|
|
851
|
-
});
|
|
852
|
-
}
|
|
853
|
-
_handleAsyncOptionsError(error, append) {
|
|
854
|
-
console.error('ZAutocomplete async options load failed:', error);
|
|
855
|
-
if (!append) {
|
|
856
|
-
this._asyncOptions.set([]);
|
|
857
|
-
this._asyncPage.set(1);
|
|
858
|
-
}
|
|
859
|
-
this._asyncHasMore.set(false);
|
|
860
|
-
this._asyncLoading.set(false);
|
|
861
|
-
this._asyncLoadingMore.set(false);
|
|
862
|
-
}
|
|
863
|
-
_getAsyncOptionsScrollTop() {
|
|
864
|
-
const scrollElement = this.shouldUseVirtualScroll()
|
|
865
|
-
? this.virtualScrollRef()?.nativeElement
|
|
866
|
-
: this.optionsContainerRef()?.nativeElement;
|
|
867
|
-
return scrollElement?.scrollTop ?? null;
|
|
868
|
-
}
|
|
869
|
-
_restoreAsyncOptionsScrollTop(scrollTop) {
|
|
870
|
-
if (scrollTop === null) {
|
|
871
|
-
return;
|
|
872
|
-
}
|
|
873
|
-
requestAnimationFrame(() => {
|
|
874
|
-
const scrollElement = this.shouldUseVirtualScroll()
|
|
875
|
-
? this.virtualScrollRef()?.nativeElement
|
|
876
|
-
: this.optionsContainerRef()?.nativeElement;
|
|
877
|
-
if (scrollElement) {
|
|
878
|
-
scrollElement.scrollTop = scrollTop;
|
|
879
|
-
}
|
|
880
|
-
});
|
|
881
|
-
}
|
|
882
|
-
_resetAsyncOptions() {
|
|
883
|
-
this._asyncLoadSubscription?.unsubscribe();
|
|
884
|
-
this._asyncRequestId++;
|
|
885
|
-
this._asyncOptions.set([]);
|
|
886
|
-
this._asyncKeyword.set('');
|
|
887
|
-
this._asyncPage.set(1);
|
|
888
|
-
this._asyncHasMore.set(false);
|
|
889
|
-
this._asyncLoading.set(false);
|
|
890
|
-
this._asyncLoadingMore.set(false);
|
|
891
|
-
}
|
|
892
739
|
_clearLocalLoadingTimer() {
|
|
893
740
|
if (!this._localLoadingTimeout) {
|
|
894
741
|
return;
|
|
@@ -905,8 +752,11 @@ class ZAutocompleteComponent {
|
|
|
905
752
|
}
|
|
906
753
|
this._loadMoreObserver = new IntersectionObserver(entries => {
|
|
907
754
|
const entry = entries[0];
|
|
908
|
-
if (entry?.isIntersecting && !this.
|
|
909
|
-
this.
|
|
755
|
+
if (entry?.isIntersecting && !this.zLoadingMore()) {
|
|
756
|
+
this.zOnLoadMore.emit({
|
|
757
|
+
currentCount: this.filteredOptions().length,
|
|
758
|
+
scrollTop: container.scrollTop,
|
|
759
|
+
});
|
|
910
760
|
}
|
|
911
761
|
}, {
|
|
912
762
|
root: container,
|
|
@@ -929,14 +779,17 @@ class ZAutocompleteComponent {
|
|
|
929
779
|
return;
|
|
930
780
|
}
|
|
931
781
|
const handleScroll = () => {
|
|
932
|
-
if (this.
|
|
782
|
+
if (this.zLoadingMore()) {
|
|
933
783
|
return;
|
|
934
784
|
}
|
|
935
785
|
const { scrollTop, scrollHeight, clientHeight } = scrollElement;
|
|
936
786
|
const threshold = clientHeight * this.zScrollDistance();
|
|
937
787
|
const distanceFromBottom = scrollHeight - scrollTop - clientHeight;
|
|
938
788
|
if (distanceFromBottom <= threshold) {
|
|
939
|
-
this.
|
|
789
|
+
this.zOnLoadMore.emit({
|
|
790
|
+
currentCount: this.filteredOptions().length,
|
|
791
|
+
scrollTop,
|
|
792
|
+
});
|
|
940
793
|
}
|
|
941
794
|
};
|
|
942
795
|
scrollElement.addEventListener('scroll', handleScroll);
|
|
@@ -951,19 +804,6 @@ class ZAutocompleteComponent {
|
|
|
951
804
|
this._virtualScrollListener();
|
|
952
805
|
this._virtualScrollListener = null;
|
|
953
806
|
}
|
|
954
|
-
_handleLoadMore(scrollTop) {
|
|
955
|
-
if (this.hasAsyncOptions()) {
|
|
956
|
-
if (!this.canLoadMore()) {
|
|
957
|
-
return;
|
|
958
|
-
}
|
|
959
|
-
this._loadAsyncOptions(this._asyncKeyword(), true);
|
|
960
|
-
return;
|
|
961
|
-
}
|
|
962
|
-
this.zOnLoadMore.emit({
|
|
963
|
-
currentCount: this.filteredOptions().length,
|
|
964
|
-
scrollTop,
|
|
965
|
-
});
|
|
966
|
-
}
|
|
967
807
|
_emitControl() {
|
|
968
808
|
this.zControl.emit({
|
|
969
809
|
focus: () => this.focus(),
|
|
@@ -995,7 +835,7 @@ class ZAutocompleteComponent {
|
|
|
995
835
|
useExisting: forwardRef(() => ZAutocompleteComponent),
|
|
996
836
|
multi: true,
|
|
997
837
|
},
|
|
998
|
-
], 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 zTrigger=\"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 [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 min-w-0 flex-1 bg-transparent outline-none\"\n [class.text-sm]=\"zSize() === 'sm' || zSize() === 'default'\"\n [placeholder]=\"zPlaceholder()\"\n [disabled]=\"isDisabled()\"\n [readOnly]=\"isReadonly()\"\n [value]=\"inputValue()\"\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-lg\"\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 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 class=\"z-autocomplete-option absolute right-0 left-0 min-w-0\"\n [ngClass]=\"getOptionClasses(opt, virtualItem.index)\"\n [class.items-start]=\"hasCustomOptionTemplate()\"\n [attr.data-index]=\"virtualItem.index\"\n [style.height.px]=\"zDynamicSize() ? null : effectiveOptionHeight()\"\n [style.minHeight.px]=\"zDynamicSize() ? effectiveOptionHeight() : null\"\n [style.transform]=\"'translateY(' + virtualItem.start + 'px)'\"\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 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 </div>\n } @else {\n <!-- Normal Scroll Mode -->\n <div\n #optionsContainer\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 class=\"z-autocomplete-option relative min-w-0\"\n [ngClass]=\"getOptionClasses(opt, i)\"\n [class.items-start]=\"hasCustomOptionTemplate()\"\n [style.minHeight.px]=\"effectiveOptionHeight()\"\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 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 </div>\n }\n\n @if (isLoadingMore()) {\n <div class=\"z-autocomplete-loading-more border-border/50 flex items-center justify-center border-t py-1.5\">\n <z-loading zSize=\"xs\" [zLoading]=\"true\" />\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}.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}}\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", "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", "zClass", "zShowDelay", "zHideDelay", "zDisabled", "zOffset", "zPopoverWidth", "zManualClose", "zScrollClose", "zShowArrow"], outputs: ["zShow", "zHide", "zHideStart", "zControl", "zPositionChange"], exportAs: ["zPopover"] }, { kind: "directive", type: ZTooltipDirective, selector: "[z-tooltip], [zTooltip]", inputs: ["zContent", "zPosition", "zTrigger", "zTooltipType", "zTooltipSize", "zClass", "zShowDelay", "zHideDelay", "zArrow", "zDisabled", "zOffset", "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: "pipe", type: ZHighlightPipe, name: "zHighlight" }, { kind: "pipe", type: ZSafeHtmlPipe, name: "zSafeHtml" }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
838
|
+
], 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 zTrigger=\"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 [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 min-w-0 flex-1 bg-transparent outline-none\"\n [class.text-sm]=\"zSize() === 'sm' || zSize() === 'default'\"\n [placeholder]=\"zPlaceholder()\"\n [disabled]=\"isDisabled()\"\n [readOnly]=\"isReadonly()\"\n [value]=\"inputValue()\"\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 (zLoading() || isLoadingState() || zLoadingMore()) {\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-lg\"\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 (zLoading() || 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 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 class=\"z-autocomplete-option absolute right-0 left-0 min-w-0\"\n [ngClass]=\"getOptionClasses(opt, virtualItem.index)\"\n [class.items-start]=\"hasCustomOptionTemplate()\"\n [attr.data-index]=\"virtualItem.index\"\n [style.height.px]=\"zDynamicSize() ? null : effectiveOptionHeight()\"\n [style.minHeight.px]=\"zDynamicSize() ? effectiveOptionHeight() : null\"\n [style.transform]=\"'translateY(' + virtualItem.start + 'px)'\"\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 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 </div>\n } @else {\n <!-- Normal Scroll Mode -->\n <div\n #optionsContainer\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 class=\"z-autocomplete-option relative min-w-0\"\n [ngClass]=\"getOptionClasses(opt, i)\"\n [class.items-start]=\"hasCustomOptionTemplate()\"\n [style.minHeight.px]=\"effectiveOptionHeight()\"\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 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 (zEnableLoadMore()) {\n <div #loadMoreSentinel class=\"h-px w-full shrink-0\"></div>\n }\n </div>\n }\n\n @if (zLoadingMore()) {\n <div class=\"z-autocomplete-loading-more border-border/50 flex items-center justify-center border-t py-1.5\">\n <z-loading zSize=\"xs\" [zLoading]=\"true\" />\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}.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}}\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", "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", "zClass", "zShowDelay", "zHideDelay", "zDisabled", "zOffset", "zPopoverWidth", "zManualClose", "zScrollClose", "zShowArrow"], outputs: ["zShow", "zHide", "zHideStart", "zControl", "zPositionChange"], exportAs: ["zPopover"] }, { kind: "directive", type: ZTooltipDirective, selector: "[z-tooltip], [zTooltip]", inputs: ["zContent", "zPosition", "zTrigger", "zTooltipType", "zTooltipSize", "zClass", "zShowDelay", "zHideDelay", "zArrow", "zDisabled", "zOffset", "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: "pipe", type: ZHighlightPipe, name: "zHighlight" }, { kind: "pipe", type: ZSafeHtmlPipe, name: "zSafeHtml" }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
999
839
|
}
|
|
1000
840
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.9", ngImport: i0, type: ZAutocompleteComponent, decorators: [{
|
|
1001
841
|
type: Component,
|
|
@@ -1016,7 +856,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.9", ngImpor
|
|
|
1016
856
|
useExisting: forwardRef(() => ZAutocompleteComponent),
|
|
1017
857
|
multi: true,
|
|
1018
858
|
},
|
|
1019
|
-
], 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 zTrigger=\"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 [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 min-w-0 flex-1 bg-transparent outline-none\"\n [class.text-sm]=\"zSize() === 'sm' || zSize() === 'default'\"\n [placeholder]=\"zPlaceholder()\"\n [disabled]=\"isDisabled()\"\n [readOnly]=\"isReadonly()\"\n [value]=\"inputValue()\"\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-lg\"\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 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 class=\"z-autocomplete-option absolute right-0 left-0 min-w-0\"\n [ngClass]=\"getOptionClasses(opt, virtualItem.index)\"\n [class.items-start]=\"hasCustomOptionTemplate()\"\n [attr.data-index]=\"virtualItem.index\"\n [style.height.px]=\"zDynamicSize() ? null : effectiveOptionHeight()\"\n [style.minHeight.px]=\"zDynamicSize() ? effectiveOptionHeight() : null\"\n [style.transform]=\"'translateY(' + virtualItem.start + 'px)'\"\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 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 </div>\n } @else {\n <!-- Normal Scroll Mode -->\n <div\n #optionsContainer\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 class=\"z-autocomplete-option relative min-w-0\"\n [ngClass]=\"getOptionClasses(opt, i)\"\n [class.items-start]=\"hasCustomOptionTemplate()\"\n [style.minHeight.px]=\"effectiveOptionHeight()\"\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 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 </div>\n }\n\n @if (isLoadingMore()) {\n <div class=\"z-autocomplete-loading-more border-border/50 flex items-center justify-center border-t py-1.5\">\n <z-loading zSize=\"xs\" [zLoading]=\"true\" />\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}.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}}\n"] }]
|
|
859
|
+
], 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 zTrigger=\"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 [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 min-w-0 flex-1 bg-transparent outline-none\"\n [class.text-sm]=\"zSize() === 'sm' || zSize() === 'default'\"\n [placeholder]=\"zPlaceholder()\"\n [disabled]=\"isDisabled()\"\n [readOnly]=\"isReadonly()\"\n [value]=\"inputValue()\"\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 (zLoading() || isLoadingState() || zLoadingMore()) {\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-lg\"\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 (zLoading() || 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 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 class=\"z-autocomplete-option absolute right-0 left-0 min-w-0\"\n [ngClass]=\"getOptionClasses(opt, virtualItem.index)\"\n [class.items-start]=\"hasCustomOptionTemplate()\"\n [attr.data-index]=\"virtualItem.index\"\n [style.height.px]=\"zDynamicSize() ? null : effectiveOptionHeight()\"\n [style.minHeight.px]=\"zDynamicSize() ? effectiveOptionHeight() : null\"\n [style.transform]=\"'translateY(' + virtualItem.start + 'px)'\"\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 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 </div>\n } @else {\n <!-- Normal Scroll Mode -->\n <div\n #optionsContainer\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 class=\"z-autocomplete-option relative min-w-0\"\n [ngClass]=\"getOptionClasses(opt, i)\"\n [class.items-start]=\"hasCustomOptionTemplate()\"\n [style.minHeight.px]=\"effectiveOptionHeight()\"\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 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 (zEnableLoadMore()) {\n <div #loadMoreSentinel class=\"h-px w-full shrink-0\"></div>\n }\n </div>\n }\n\n @if (zLoadingMore()) {\n <div class=\"z-autocomplete-loading-more border-border/50 flex items-center justify-center border-t py-1.5\">\n <z-loading zSize=\"xs\" [zLoading]=\"true\" />\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}.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}}\n"] }]
|
|
1020
860
|
}], 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 }] }], 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 }] }], 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 }] }], 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"] }] } });
|
|
1021
861
|
|
|
1022
862
|
/**
|