@basis-ng/primitives 0.0.1-alpha.67 → 0.0.1-alpha.68

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.
@@ -27,10 +27,13 @@ export declare class SelectComponent implements OnInit, ControlValueAccessor {
27
27
  */
28
28
  readonly optionsList: import("@angular/core").Signal<SelectOptionsComponent | undefined>;
29
29
  /**
30
- * Computed signal representing the selected values from the dropdown.
31
- * This is linked to the value of the `OptionsListComponent`.
30
+ * Value of the select component.
32
31
  */
33
- readonly value: import("@angular/core").WritableSignal<string[] | undefined>;
32
+ value: string[];
33
+ /**
34
+ * Content to be displayed in the button.
35
+ */
36
+ content: string | undefined;
34
37
  /**
35
38
  * Linked signal for the width of the button element.
36
39
  * This is used to set the width of the dropdown overlay.
@@ -46,11 +49,6 @@ export declare class SelectComponent implements OnInit, ControlValueAccessor {
46
49
  * This retrieves the options from the `OptionsListComponent`.
47
50
  */
48
51
  readonly options: import("@angular/core").Signal<readonly import("@basis-ng/primitives").OptionComponent[] | undefined>;
49
- /**
50
- * Computed signal representing the content of the selected option(s).
51
- * If no option is selected, it returns the placeholder text.
52
- */
53
- readonly content: import("@angular/core").Signal<string | undefined>;
54
52
  /**
55
53
  * Signal representing the delay before closing the dropdown.
56
54
  * This is used to provide a smooth transition when closing the dropdown.
@@ -71,6 +69,14 @@ export declare class SelectComponent implements OnInit, ControlValueAccessor {
71
69
  * Focuses the options list when the overlay is attached.
72
70
  */
73
71
  onOverlayAttached(): void;
72
+ /**
73
+ * Returns the content to be displayed in the button.
74
+ * If no value is selected, it returns the placeholder text.
75
+ * Otherwise, it returns the selected option(s) as a comma-separated string.
76
+ *
77
+ * @param value - The array of selected values.
78
+ */
79
+ getContent(value: string[]): string | undefined;
74
80
  /**
75
81
  * Sets the width of the dropdown overlay based on the button's width.
76
82
  * This ensures that the dropdown aligns properly with the button.
@@ -749,10 +749,13 @@ class SelectComponent {
749
749
  */
750
750
  optionsList = contentChild(SelectOptionsComponent);
751
751
  /**
752
- * Computed signal representing the selected values from the dropdown.
753
- * This is linked to the value of the `OptionsListComponent`.
752
+ * Value of the select component.
753
+ */
754
+ value = [];
755
+ /**
756
+ * Content to be displayed in the button.
754
757
  */
755
- value = linkedSignal(() => this.optionsList()?.value());
758
+ content;
756
759
  /**
757
760
  * Linked signal for the width of the button element.
758
761
  * This is used to set the width of the dropdown overlay.
@@ -768,28 +771,6 @@ class SelectComponent {
768
771
  * This retrieves the options from the `OptionsListComponent`.
769
772
  */
770
773
  options = computed(() => this.optionsList()?.options());
771
- /**
772
- * Computed signal representing the content of the selected option(s).
773
- * If no option is selected, it returns the placeholder text.
774
- */
775
- content = computed(() => {
776
- const selected = this.value();
777
- if (selected &&
778
- selected.length > 0 &&
779
- !(selected.length === 1 && selected[0] === '')) {
780
- return this.options()?.reduce((acc, option) => {
781
- if (selected.includes(option.cdkOption.value)) {
782
- return acc
783
- ? acc + ', ' + option.el.nativeElement.innerText
784
- : option.el.nativeElement.innerText;
785
- }
786
- return acc;
787
- }, '');
788
- }
789
- else {
790
- return this.placeholder();
791
- }
792
- });
793
774
  /**
794
775
  * Signal representing the delay before closing the dropdown.
795
776
  * This is used to provide a smooth transition when closing the dropdown.
@@ -809,7 +790,7 @@ class SelectComponent {
809
790
  */
810
791
  handleSelectedValueChange() {
811
792
  this.optionsList()?.closeEmitter.subscribe(() => {
812
- this.onChange(this.value());
793
+ this.onChange(this.value);
813
794
  this.onTouched();
814
795
  this.isOpen.set(false);
815
796
  });
@@ -821,6 +802,28 @@ class SelectComponent {
821
802
  this.buttonWidth.set(this.button()?.el.nativeElement.offsetWidth);
822
803
  this.optionsList()?.el.nativeElement.focus();
823
804
  }
805
+ /**
806
+ * Returns the content to be displayed in the button.
807
+ * If no value is selected, it returns the placeholder text.
808
+ * Otherwise, it returns the selected option(s) as a comma-separated string.
809
+ *
810
+ * @param value - The array of selected values.
811
+ */
812
+ getContent(value) {
813
+ if (value && value.length > 0) {
814
+ return this.options()?.reduce((acc, option) => {
815
+ if (value.includes(option.cdkOption.value)) {
816
+ return acc
817
+ ? acc + ', ' + option.el.nativeElement.innerText
818
+ : option.el.nativeElement.innerText;
819
+ }
820
+ return acc;
821
+ }, '');
822
+ }
823
+ else {
824
+ return this.placeholder();
825
+ }
826
+ }
824
827
  /**
825
828
  * Sets the width of the dropdown overlay based on the button's width.
826
829
  * This ensures that the dropdown aligns properly with the button.
@@ -849,7 +852,7 @@ class SelectComponent {
849
852
  value.forEach(value => {
850
853
  this.optionsList()?.listBox?.selectValue(value);
851
854
  });
852
- this.value.set(value);
855
+ this.content = this.getContent(value);
853
856
  }
854
857
  }
855
858
  /**
@@ -890,7 +893,7 @@ class SelectComponent {
890
893
  [activeEnabled]="false"
891
894
  bOverlayTrigger
892
895
  #trigger="bOverlayTrigger">
893
- <span>{{ content() }}</span>
896
+ <span>{{ content }}</span>
894
897
  <i b-icon icon="ChevronDown" [size]="16"></i>
895
898
  </button>
896
899
  <ng-template
@@ -925,7 +928,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.10", ngImpo
925
928
  [activeEnabled]="false"
926
929
  bOverlayTrigger
927
930
  #trigger="bOverlayTrigger">
928
- <span>{{ content() }}</span>
931
+ <span>{{ content }}</span>
929
932
  <i b-icon icon="ChevronDown" [size]="16"></i>
930
933
  </button>
931
934
  <ng-template