@basis-ng/primitives 0.0.1-alpha.69 → 0.0.1-alpha.70

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.
@@ -17,7 +17,7 @@ export declare class SelectOptionsComponent {
17
17
  * Event emitter triggered when the dropdown should close.
18
18
  * This is used to notify the parent component to close the dropdown.
19
19
  */
20
- closeEmitter: import("@angular/core").OutputEmitterRef<string[]>;
20
+ closeEmitter: import("@angular/core").OutputEmitterRef<void>;
21
21
  /**
22
22
  * Reference to the host element of the component.
23
23
  * This provides access to the DOM element of the options list.
@@ -46,11 +46,6 @@ export declare class SelectOptionsComponent {
46
46
  * @param value - The new array of selected values.
47
47
  */
48
48
  handleValueChange(value: string[]): void;
49
- /**
50
- * Emits the current value when the Enter key is pressed.
51
- * This ensures the dropdown closes and the parent component is notified.
52
- */
53
- emitCurrentValueOnEnter(): void;
54
49
  static ɵfac: i0.ɵɵFactoryDeclaration<SelectOptionsComponent, never>;
55
50
  static ɵcmp: i0.ɵɵComponentDeclaration<SelectOptionsComponent, "ul[b-select-options]", never, { "maxHeight": { "alias": "maxHeight"; "required": false; "isSignal": true; }; }, { "closeEmitter": "closeEmitter"; }, ["options"], ["*"], true, [{ directive: typeof i1.CdkListbox; inputs: { "cdkListboxValue": "cdkListboxValue"; }; outputs: { "cdkListboxValueChange": "cdkListboxValueChange"; }; }]>;
56
51
  }
@@ -27,13 +27,10 @@ export declare class SelectComponent implements OnInit, ControlValueAccessor {
27
27
  */
28
28
  readonly optionsList: import("@angular/core").Signal<SelectOptionsComponent | undefined>;
29
29
  /**
30
- * Value of the select component.
30
+ * Computed signal representing the selected values from the dropdown.
31
+ * This is linked to the value of the `OptionsListComponent`.
31
32
  */
32
- value: string[];
33
- /**
34
- * Content to be displayed in the button.
35
- */
36
- content: string | undefined;
33
+ readonly value: import("@angular/core").WritableSignal<string[] | undefined>;
37
34
  /**
38
35
  * Linked signal for the width of the button element.
39
36
  * This is used to set the width of the dropdown overlay.
@@ -49,6 +46,11 @@ export declare class SelectComponent implements OnInit, ControlValueAccessor {
49
46
  * This retrieves the options from the `OptionsListComponent`.
50
47
  */
51
48
  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>;
52
54
  /**
53
55
  * Signal representing the delay before closing the dropdown.
54
56
  * This is used to provide a smooth transition when closing the dropdown.
@@ -69,14 +71,6 @@ export declare class SelectComponent implements OnInit, ControlValueAccessor {
69
71
  * Focuses the options list when the overlay is attached.
70
72
  */
71
73
  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;
80
74
  /**
81
75
  * Sets the width of the dropdown overlay based on the button's width.
82
76
  * This ensures that the dropdown aligns properly with the button.
@@ -344,17 +344,10 @@ class SelectOptionsComponent {
344
344
  */
345
345
  handleValueChange(value) {
346
346
  this.value.set(value);
347
- this.closeEmitter.emit(value); // Emitimos el valor seleccionado
348
- }
349
- /**
350
- * Emits the current value when the Enter key is pressed.
351
- * This ensures the dropdown closes and the parent component is notified.
352
- */
353
- emitCurrentValueOnEnter() {
354
- this.closeEmitter.emit(this.value());
347
+ this.closeEmitter.emit();
355
348
  }
356
349
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.10", ngImport: i0, type: SelectOptionsComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
357
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "19.2.10", type: SelectOptionsComponent, isStandalone: true, selector: "ul[b-select-options]", inputs: { maxHeight: { classPropertyName: "maxHeight", publicName: "maxHeight", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { closeEmitter: "closeEmitter" }, host: { listeners: { "cdkListboxValueChange": "handleValueChange($event.value)", "keydown.enter": "emitCurrentValueOnEnter()" }, properties: { "cdkListboxValue": "value()", "style.max-height": "maxHeight()" } }, queries: [{ propertyName: "options", predicate: OptionComponent, isSignal: true }], hostDirectives: [{ directive: i1.CdkListbox, inputs: ["cdkListboxValue", "cdkListboxValue"], outputs: ["cdkListboxValueChange", "cdkListboxValueChange"] }], ngImport: i0, template: `<ng-content />`, isInline: true });
350
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "19.2.10", type: SelectOptionsComponent, isStandalone: true, selector: "ul[b-select-options]", inputs: { maxHeight: { classPropertyName: "maxHeight", publicName: "maxHeight", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { closeEmitter: "closeEmitter" }, host: { listeners: { "cdkListboxValueChange": "handleValueChange($event.value)", "keydown.enter": "closeEmitter.emit()" }, properties: { "cdkListboxValue": "value()", "style.max-height": "maxHeight()" } }, queries: [{ propertyName: "options", predicate: OptionComponent, isSignal: true }], hostDirectives: [{ directive: i1.CdkListbox, inputs: ["cdkListboxValue", "cdkListboxValue"], outputs: ["cdkListboxValueChange", "cdkListboxValueChange"] }], ngImport: i0, template: `<ng-content />`, isInline: true });
358
351
  }
359
352
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.10", ngImport: i0, type: SelectOptionsComponent, decorators: [{
360
353
  type: Component,
@@ -373,7 +366,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.10", ngImpo
373
366
  '[cdkListboxValue]': 'value()',
374
367
  '(cdkListboxValueChange)': 'handleValueChange($event.value)',
375
368
  '[style.max-height]': 'maxHeight()',
376
- '(keydown.enter)': 'emitCurrentValueOnEnter()',
369
+ '(keydown.enter)': 'closeEmitter.emit()',
377
370
  },
378
371
  }]
379
372
  }] });
@@ -756,13 +749,10 @@ class SelectComponent {
756
749
  */
757
750
  optionsList = contentChild(SelectOptionsComponent);
758
751
  /**
759
- * Value of the select component.
760
- */
761
- value = [];
762
- /**
763
- * Content to be displayed in the button.
752
+ * Computed signal representing the selected values from the dropdown.
753
+ * This is linked to the value of the `OptionsListComponent`.
764
754
  */
765
- content;
755
+ value = linkedSignal(() => this.optionsList()?.value());
766
756
  /**
767
757
  * Linked signal for the width of the button element.
768
758
  * This is used to set the width of the dropdown overlay.
@@ -778,6 +768,28 @@ class SelectComponent {
778
768
  * This retrieves the options from the `OptionsListComponent`.
779
769
  */
780
770
  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
+ });
781
793
  /**
782
794
  * Signal representing the delay before closing the dropdown.
783
795
  * This is used to provide a smooth transition when closing the dropdown.
@@ -796,10 +808,8 @@ class SelectComponent {
796
808
  * value is propagated to Angular Forms.
797
809
  */
798
810
  handleSelectedValueChange() {
799
- this.optionsList()?.closeEmitter.subscribe((value) => {
800
- this.value = value;
801
- this.onChange(this.value);
802
- this.content = this.getContent(this.value);
811
+ this.optionsList()?.closeEmitter.subscribe(() => {
812
+ this.onChange(this.value());
803
813
  this.onTouched();
804
814
  this.isOpen.set(false);
805
815
  });
@@ -811,28 +821,6 @@ class SelectComponent {
811
821
  this.buttonWidth.set(this.button()?.el.nativeElement.offsetWidth);
812
822
  this.optionsList()?.el.nativeElement.focus();
813
823
  }
814
- /**
815
- * Returns the content to be displayed in the button.
816
- * If no value is selected, it returns the placeholder text.
817
- * Otherwise, it returns the selected option(s) as a comma-separated string.
818
- *
819
- * @param value - The array of selected values.
820
- */
821
- getContent(value) {
822
- if (value && value.length > 0) {
823
- return this.options()?.reduce((acc, option) => {
824
- if (value.includes(option.cdkOption.value)) {
825
- return acc
826
- ? acc + ', ' + option.el.nativeElement.innerText
827
- : option.el.nativeElement.innerText;
828
- }
829
- return acc;
830
- }, '');
831
- }
832
- else {
833
- return this.placeholder();
834
- }
835
- }
836
824
  /**
837
825
  * Sets the width of the dropdown overlay based on the button's width.
838
826
  * This ensures that the dropdown aligns properly with the button.
@@ -861,7 +849,7 @@ class SelectComponent {
861
849
  value.forEach(value => {
862
850
  this.optionsList()?.listBox?.selectValue(value);
863
851
  });
864
- this.content = this.getContent(value);
852
+ this.value.set(value);
865
853
  }
866
854
  }
867
855
  /**
@@ -902,7 +890,7 @@ class SelectComponent {
902
890
  [activeEnabled]="false"
903
891
  bOverlayTrigger
904
892
  #trigger="bOverlayTrigger">
905
- <span>{{ content }}</span>
893
+ <span>{{ content() }}</span>
906
894
  <i b-icon icon="ChevronDown" [size]="16"></i>
907
895
  </button>
908
896
  <ng-template
@@ -937,7 +925,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.10", ngImpo
937
925
  [activeEnabled]="false"
938
926
  bOverlayTrigger
939
927
  #trigger="bOverlayTrigger">
940
- <span>{{ content }}</span>
928
+ <span>{{ content() }}</span>
941
929
  <i b-icon icon="ChevronDown" [size]="16"></i>
942
930
  </button>
943
931
  <ng-template