nexheal-lib 0.0.62 → 0.0.63

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.
@@ -2658,8 +2658,7 @@ class MultiselectControl {
2658
2658
  });
2659
2659
  // Initialize filteredOptions to match all options
2660
2660
  this.filteredOptions = [...this.options];
2661
- // Sync the input display in case selectedItems was set before init
2662
- this._syncSelectedItemList();
2661
+ this._updateSelectedItemList();
2663
2662
  }
2664
2663
  ngAfterViewChecked() {
2665
2664
  if (this.isDropdownOpen && !this.dropdownInitialized) {
@@ -2678,8 +2677,11 @@ class MultiselectControl {
2678
2677
  // When the parent replaces “options,” we reapply any filtering and “select all” logic
2679
2678
  this.filteredOptions = [...this.options];
2680
2679
  this._recomputeSelectAllState();
2681
- // Sync input display (selectedItems may already be set from writeValue)
2682
- this._syncSelectedItemList();
2680
+ }
2681
+ if (changes["selectedItems"] ||
2682
+ changes["optionDisplayProperty"] ||
2683
+ changes["options"]) {
2684
+ this._updateSelectedItemList();
2683
2685
  }
2684
2686
  }
2685
2687
  writeValue(value) {
@@ -2688,7 +2690,7 @@ class MultiselectControl {
2688
2690
  this._isPrimitivePatch = false;
2689
2691
  this._pendingPrimitiveValues = [];
2690
2692
  this.selectedItems = [];
2691
- this._syncSelectedItemList();
2693
+ this._updateSelectedItemList();
2692
2694
  this.selectAllChecked = false;
2693
2695
  return;
2694
2696
  }
@@ -2699,17 +2701,13 @@ class MultiselectControl {
2699
2701
  this._pendingPrimitiveValues = [...value];
2700
2702
  this._mapPrimitivesToObjects();
2701
2703
  this._recomputeSelectAllState();
2702
- this._syncSelectedItemList();
2703
2704
  return;
2704
2705
  }
2705
2706
  // CASE B: array of full objects (with `id` or whatever `optionValueProperty` is)
2706
2707
  if (value.length > 0 &&
2707
2708
  typeof value[0] === "object" &&
2708
2709
  value[0][this.optionValueProperty] != null) {
2709
- // Immediately use the value objects for display
2710
- this.selectedItems = [...value];
2711
- this._syncSelectedItemList();
2712
- // Also set up pending mapping to sync with option references when available
2710
+ // Convert to an array of IDs, then treat exactly like CASE A
2713
2711
  const idArray = value.map((obj) => obj[this.optionValueProperty]);
2714
2712
  this._isPrimitivePatch = true;
2715
2713
  this._pendingPrimitiveValues = idArray;
@@ -2722,7 +2720,7 @@ class MultiselectControl {
2722
2720
  this._isPrimitivePatch = false;
2723
2721
  this._pendingPrimitiveValues = [];
2724
2722
  this.selectedItems = [...value];
2725
- this._syncSelectedItemList();
2723
+ this._updateSelectedItemList();
2726
2724
  this.onChange(this.selectedItems);
2727
2725
  this._recomputeSelectAllState();
2728
2726
  }
@@ -2735,7 +2733,7 @@ class MultiselectControl {
2735
2733
  // Find matching option‐objects whose ID property is in the pending list
2736
2734
  const matched = this._options.filter((opt) => this._pendingPrimitiveValues.includes(opt[this.optionValueProperty]));
2737
2735
  this.selectedItems = matched;
2738
- this._syncSelectedItemList();
2736
+ this._updateSelectedItemList();
2739
2737
  // Notify “onChange” with the full‐object selection
2740
2738
  this.onChange(this.selectedItems);
2741
2739
  this._isPrimitivePatch = false;
@@ -2823,13 +2821,13 @@ class MultiselectControl {
2823
2821
  // Remove all filtered options from selection
2824
2822
  this.selectedItems = this.selectedItems.filter((item) => !this.filteredOptions.includes(item));
2825
2823
  }
2826
- this._syncSelectedItemList();
2824
+ this._updateSelectedItemList();
2827
2825
  this.onChange(this.selectedItems);
2828
2826
  this.optionsSelected.emit(this.selectedItems);
2829
2827
  }
2830
2828
  removeSelectedOption(option) {
2831
2829
  this.selectedItems = this.selectedItems.filter((item) => item !== option);
2832
- this._syncSelectedItemList();
2830
+ this._updateSelectedItemList();
2833
2831
  this.onChange(this.selectedItems);
2834
2832
  this.onTouched();
2835
2833
  this.optionsSelected.emit(this.selectedItems);
@@ -2841,7 +2839,7 @@ class MultiselectControl {
2841
2839
  else {
2842
2840
  this.selectedItems = [...this.selectedItems, option];
2843
2841
  }
2844
- this._syncSelectedItemList();
2842
+ this._updateSelectedItemList();
2845
2843
  // Update “select all” checkbox
2846
2844
  this._recomputeSelectAllState();
2847
2845
  // Notify form that selection changed
@@ -2955,7 +2953,7 @@ class MultiselectControl {
2955
2953
  }
2956
2954
  resetSelection() {
2957
2955
  this.selectedItems = [];
2958
- this._syncSelectedItemList();
2956
+ this._updateSelectedItemList();
2959
2957
  this.onChange([]);
2960
2958
  this.onTouched();
2961
2959
  this.isDropdownOpen = false;
@@ -2966,17 +2964,20 @@ class MultiselectControl {
2966
2964
  this.isDropdownOpen = false;
2967
2965
  this._recomputeSelectAllState();
2968
2966
  }
2969
- _syncSelectedItemList() {
2970
- if (this._options && this._options.length > 0 && this.selectedItems.length === this._options.length) {
2967
+ _updateSelectedItemList() {
2968
+ const items = this.selectedItems ?? [];
2969
+ if (this._options && this._options.length > 0 && items.length === this._options.length) {
2971
2970
  this.selectedItemList = "All Items Selected";
2972
2971
  }
2973
2972
  else {
2974
- this.selectedItemList = (this.selectedItems ?? [])
2973
+ this.selectedItemList = items
2975
2974
  .map((item) => item?.[this.optionDisplayProperty])
2976
- .filter((label) => !!label)
2975
+ .filter((label) => label != null && String(label).trim() !== "")
2977
2976
  .join(", ");
2978
2977
  }
2979
- this.inputControl.setValue(this.selectedItemList, { emitEvent: false });
2978
+ if (this.inputControl.value !== this.selectedItemList) {
2979
+ this.inputControl.setValue(this.selectedItemList, { emitEvent: false });
2980
+ }
2980
2981
  }
2981
2982
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.25", ngImport: i0, type: MultiselectControl, deps: [{ token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
2982
2983
  static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.25", type: MultiselectControl, isStandalone: true, selector: "multiselect-control", inputs: { title: "title", selectedItems: "selectedItems", required: "required", placeholder: "placeholder", customClass: "customClass", clearVal: "clearVal", deFocus: "deFocus", optionValueProperty: "optionValueProperty", inputLoader: "inputLoader", error: "error", errorMessage: "errorMessage", autocomplete: "autocomplete", showSearch: "showSearch", optionDisplayProperty: "optionDisplayProperty", options: "options", readonly: "readonly", disabled: "disabled" }, outputs: { optionsSelected: "optionsSelected", selectionCleared: "selectionCleared", blurEvent: "blurEvent" }, host: { listeners: { "window:keydown": "handleWindowKeydown($event)" } }, providers: [