nexheal-lib 0.0.68 → 0.0.69

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.
@@ -3074,8 +3074,12 @@ class PaginatedAutocompleteControl {
3074
3074
  paginationType = 'scroll';
3075
3075
  pageSize = 10;
3076
3076
  searchDebounce = 300;
3077
- /** Min trimmed characters before page-1 search / pageChange (0 = no minimum). Empty search always allowed. */
3078
- minSearchLength = 0;
3077
+ /**
3078
+ * Omit: search runs only from the search icon (and Enter). Set a number: type-to-search
3079
+ * with that minimum trimmed length (empty search still loads the full list). Pass 0 for
3080
+ * type-to-search with no minimum.
3081
+ */
3082
+ minSearchLength;
3079
3083
  /** Re-fetch page 1 every time the dropdown opens, instead of reusing cached results */
3080
3084
  refreshOnOpen = false;
3081
3085
  /** Total record count for the current search, from the API response */
@@ -3184,6 +3188,10 @@ class PaginatedAutocompleteControl {
3184
3188
  get controlDisabled() {
3185
3189
  return this._disabled || this.inputControl.disabled;
3186
3190
  }
3191
+ /** `minSearchLength` omitted — API only via search icon / Enter, not while typing. */
3192
+ get searchOnButtonOnly() {
3193
+ return this.minSearchLength === undefined;
3194
+ }
3187
3195
  constructor() { }
3188
3196
  ngOnInit() {
3189
3197
  this.inputControl.markAsPristine();
@@ -3195,8 +3203,12 @@ class PaginatedAutocompleteControl {
3195
3203
  // A selection happened after this keystroke — drop the search
3196
3204
  if (this.cancelPendingSearch)
3197
3205
  return;
3198
- if (this.readonly || this.controlDisabled || !this.hasFocus)
3206
+ if (this.searchOnButtonOnly ||
3207
+ this.readonly ||
3208
+ this.controlDisabled ||
3209
+ !this.hasFocus) {
3199
3210
  return;
3211
+ }
3200
3212
  this.loadPage(1, value);
3201
3213
  }));
3202
3214
  }
@@ -3260,7 +3272,7 @@ class PaginatedAutocompleteControl {
3260
3272
  }
3261
3273
  // paging
3262
3274
  isSearchAllowed(search) {
3263
- if (this.minSearchLength <= 0) {
3275
+ if (this.minSearchLength == null || this.minSearchLength <= 0) {
3264
3276
  return true;
3265
3277
  }
3266
3278
  const trimmed = search.trim();
@@ -3426,12 +3438,15 @@ class PaginatedAutocompleteControl {
3426
3438
  onSearchIconClick(event) {
3427
3439
  event.preventDefault();
3428
3440
  event.stopPropagation();
3441
+ this.inputElement?.nativeElement.focus();
3442
+ this.runSearchAction();
3443
+ }
3444
+ runSearchAction() {
3429
3445
  if (this.readonly || this.controlDisabled) {
3430
3446
  return;
3431
3447
  }
3432
3448
  this.cancelPendingSearch = false;
3433
3449
  this.hasFocus = true;
3434
- this.inputElement?.nativeElement.focus();
3435
3450
  this.loadPage(1, this.openSearchTerm());
3436
3451
  }
3437
3452
  /** Text to search with when the dropdown opens: if the input just holds the
@@ -3444,25 +3459,35 @@ class PaginatedAutocompleteControl {
3444
3459
  }
3445
3460
  return value;
3446
3461
  }
3462
+ /** Reopen the dropdown from cached results for `term` without calling the API. */
3463
+ tryReopenCachedSearch(term) {
3464
+ if (this.refreshOnOpen ||
3465
+ this.lastLoadedSearch !== term ||
3466
+ this._displayedOptions.length === 0) {
3467
+ return false;
3468
+ }
3469
+ this.isPageLoading = false;
3470
+ this.openDropdown();
3471
+ if (this.paginationType === 'arrow') {
3472
+ this.showCachedPage(1);
3473
+ }
3474
+ const idx = this.selectedItems
3475
+ ? this._displayedOptions.findIndex((o) => o.id === this.selectedItems.id)
3476
+ : -1;
3477
+ this.highlightedIndex =
3478
+ idx >= 0 ? idx : this._displayedOptions.length > 0 ? 0 : null;
3479
+ return true;
3480
+ }
3447
3481
  openWithSearch() {
3448
3482
  if (this.readonly || this.controlDisabled) {
3449
3483
  return;
3450
3484
  }
3451
3485
  const term = this.openSearchTerm();
3452
- // Reuse cached results when reopening with the same search term
3453
- if (!this.refreshOnOpen &&
3454
- this.lastLoadedSearch === term &&
3455
- this._displayedOptions.length > 0) {
3456
- this.isPageLoading = false;
3457
- this.openDropdown();
3458
- if (this.paginationType === 'arrow') {
3459
- this.showCachedPage(1);
3460
- }
3461
- const idx = this.selectedItems
3462
- ? this._displayedOptions.findIndex((o) => o.id === this.selectedItems.id)
3463
- : -1;
3464
- this.highlightedIndex =
3465
- idx >= 0 ? idx : this._displayedOptions.length > 0 ? 0 : null;
3486
+ if (this.searchOnButtonOnly) {
3487
+ this.tryReopenCachedSearch(term);
3488
+ return;
3489
+ }
3490
+ if (this.tryReopenCachedSearch(term)) {
3466
3491
  return;
3467
3492
  }
3468
3493
  this.loadPage(1, term);
@@ -3513,6 +3538,10 @@ class PaginatedAutocompleteControl {
3513
3538
  }
3514
3539
  onKeyDown(event) {
3515
3540
  if (!this.isDropdownOpen) {
3541
+ if (this.searchOnButtonOnly && event.key === "Enter") {
3542
+ event.preventDefault();
3543
+ this.runSearchAction();
3544
+ }
3516
3545
  return;
3517
3546
  }
3518
3547
  switch (event.key) {
@@ -3629,6 +3658,14 @@ class PaginatedAutocompleteControl {
3629
3658
  this.valueBuffer = null;
3630
3659
  this.onChange(null);
3631
3660
  this.selectionCleared.emit();
3661
+ if (this.searchOnButtonOnly) {
3662
+ this.isDropdownOpen = false;
3663
+ this.isPageLoading = false;
3664
+ this._displayedOptions = [];
3665
+ this.pageCache.clear();
3666
+ this.lastLoadedSearch = null;
3667
+ return;
3668
+ }
3632
3669
  if (this.hasFocus) {
3633
3670
  this.loadPage(1, "");
3634
3671
  }