@basis-ng/primitives 0.0.1-alpha.16 → 0.0.1-alpha.18

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.
@@ -39,10 +39,10 @@ export declare class ComboboxComponent implements OnInit, ControlValueAccessor {
39
39
  */
40
40
  readonly maxWidth: import("@angular/core").InputSignal<string>;
41
41
  /**
42
- * Computed signal for the width of the button element.
42
+ * Linked signal for the width of the button element.
43
43
  * This is used to set the width of the dropdown overlay.
44
44
  */
45
- readonly buttonWidth: import("@angular/core").Signal<any>;
45
+ readonly buttonWidth: import("@angular/core").WritableSignal<any>;
46
46
  /**
47
47
  * Model indicating whether the combobox component is disabled.
48
48
  * When disabled, the dropdown cannot be opened or interacted with.
@@ -90,6 +90,15 @@ export declare class ComboboxComponent implements OnInit, ControlValueAccessor {
90
90
  * the transition class from the overlay panel.
91
91
  */
92
92
  close(): void;
93
+ /**
94
+ * Focuses the input element within the command component when the overlay is attached.
95
+ */
96
+ onOverlayAttached(): void;
97
+ /**
98
+ * Sets the width of the button element when the window is resized.
99
+ * This ensures that the dropdown overlay matches the width of the button.
100
+ */
101
+ setButtonWidth(): void;
93
102
  /**
94
103
  * Callback function to propagate changes to the model.
95
104
  * This is called whenever the value changes.
@@ -122,10 +131,6 @@ export declare class ComboboxComponent implements OnInit, ControlValueAccessor {
122
131
  * @param isDisabled - A boolean indicating whether the component should be disabled.
123
132
  */
124
133
  setDisabledState(isDisabled: boolean): void;
125
- /**
126
- * Focuses the input element within the command component when the overlay is attached.
127
- */
128
- onOverlayAttached(): void;
129
134
  static ɵfac: i0.ɵɵFactoryDeclaration<ComboboxComponent, never>;
130
135
  static ɵcmp: i0.ɵɵComponentDeclaration<ComboboxComponent, "b-combobox", never, { "placeholder": { "alias": "placeholder"; "required": false; "isSignal": true; }; "maxWidth": { "alias": "maxWidth"; "required": false; "isSignal": true; }; "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; }, { "disabled": "disabledChange"; }, ["command"], ["*"], true, never>;
131
136
  }
@@ -1,5 +1,6 @@
1
1
  import { ElementRef } from '@angular/core';
2
2
  import { CommandOptionsComponent } from './command-options.component';
3
+ import { BreakpointObserver } from '@angular/cdk/layout';
3
4
  import * as i0 from "@angular/core";
4
5
  /**
5
6
  * Component representing a command input with associated options.
@@ -31,6 +32,15 @@ export declare class CommandComponent {
31
32
  * This is linked to the options of the `CommandOptionsComponent`.
32
33
  */
33
34
  readonly options: import("@angular/core").Signal<readonly import("@angular/cdk/listbox").CdkOption<any>[] | undefined>;
35
+ /**
36
+ * Reference to the BreakpointObserver service for responsive design.
37
+ */
38
+ breakpointObserver: BreakpointObserver;
39
+ /**
40
+ * Signal representing whether the current viewport is desktop or not.
41
+ * This is determined by checking if the Handset breakpoint is matched.
42
+ */
43
+ readonly isDesktop: import("@angular/core").WritableSignal<boolean>;
34
44
  /**
35
45
  * Reference to the host element of the component.
36
46
  * This provides access to the DOM element of the command component.
@@ -39,10 +39,10 @@ export declare class SelectComponent implements OnInit, ControlValueAccessor {
39
39
  */
40
40
  readonly maxWidth: import("@angular/core").InputSignal<string>;
41
41
  /**
42
- * Computed signal for the width of the button element.
42
+ * Linked signal for the width of the button element.
43
43
  * This is used to set the width of the dropdown overlay.
44
44
  */
45
- readonly buttonWidth: import("@angular/core").Signal<any>;
45
+ readonly buttonWidth: import("@angular/core").WritableSignal<any>;
46
46
  /**
47
47
  * Model indicating whether the select component is disabled.
48
48
  * When disabled, the dropdown cannot be opened or interacted with.
@@ -90,6 +90,15 @@ export declare class SelectComponent implements OnInit, ControlValueAccessor {
90
90
  * the transition class from the overlay panel.
91
91
  */
92
92
  close(): void;
93
+ /**
94
+ * Focuses the options list when the overlay is attached.
95
+ */
96
+ onOverlayAttached(): void;
97
+ /**
98
+ * Sets the width of the dropdown overlay based on the button's width.
99
+ * This ensures that the dropdown aligns properly with the button.
100
+ */
101
+ setButtonWidth(): void;
93
102
  /**
94
103
  * Callback function to propagate changes to the model.
95
104
  * This is called whenever the value changes.
@@ -122,10 +131,6 @@ export declare class SelectComponent implements OnInit, ControlValueAccessor {
122
131
  * @param isDisabled - A boolean indicating whether the component should be disabled.
123
132
  */
124
133
  setDisabledState(isDisabled: boolean): void;
125
- /**
126
- * Focuses the options list when the overlay is attached.
127
- */
128
- onOverlayAttached(): void;
129
134
  static ɵfac: i0.ɵɵFactoryDeclaration<SelectComponent, never>;
130
135
  static ɵcmp: i0.ɵɵComponentDeclaration<SelectComponent, "b-select", never, { "placeholder": { "alias": "placeholder"; "required": false; "isSignal": true; }; "maxWidth": { "alias": "maxWidth"; "required": false; "isSignal": true; }; "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; }, { "disabled": "disabledChange"; }, ["optionsList"], ["*"], true, never>;
131
136
  }
@@ -1,5 +1,5 @@
1
1
  import * as i0 from '@angular/core';
2
- import { signal, inject, RendererFactory2, Injectable, input, Component, ElementRef, TemplateRef, Directive, model, computed, output, contentChildren, viewChild, contentChild, linkedSignal, forwardRef, effect, HostListener, afterNextRender, afterRenderEffect } from '@angular/core';
2
+ import { signal, inject, RendererFactory2, Injectable, input, Component, ElementRef, TemplateRef, Directive, model, computed, output, contentChildren, viewChild, contentChild, linkedSignal, forwardRef, HostListener, effect, afterNextRender, afterRenderEffect } from '@angular/core';
3
3
  import { NgStyle, NgClass, CommonModule } from '@angular/common';
4
4
  import { NgModel, NG_VALUE_ACCESSOR, ControlContainer } from '@angular/forms';
5
5
  import { CdkConnectedOverlay, CdkOverlayOrigin } from '@angular/cdk/overlay';
@@ -12,6 +12,7 @@ import { CdkDrag, CdkDragHandle, CdkDropList, CdkDropListGroup } from '@angular/
12
12
  import * as i1$2 from '@angular/cdk/menu';
13
13
  import { CdkMenu, CdkMenuItem, CdkMenuItemCheckbox, CdkMenuItemRadio, CdkMenuTrigger } from '@angular/cdk/menu';
14
14
  import { ActiveDescendantKeyManager, CdkTrapFocus } from '@angular/cdk/a11y';
15
+ import { BreakpointObserver, Breakpoints } from '@angular/cdk/layout';
15
16
 
16
17
  class ThemeService {
17
18
  /**
@@ -466,10 +467,10 @@ class SelectComponent {
466
467
  */
467
468
  maxWidth = input('100%');
468
469
  /**
469
- * Computed signal for the width of the button element.
470
+ * Linked signal for the width of the button element.
470
471
  * This is used to set the width of the dropdown overlay.
471
472
  */
472
- buttonWidth = computed(() => this.button()?.el.nativeElement.offsetWidth);
473
+ buttonWidth = linkedSignal(() => this.button()?.el.nativeElement.offsetWidth);
473
474
  /**
474
475
  * Model indicating whether the select component is disabled.
475
476
  * When disabled, the dropdown cannot be opened or interacted with.
@@ -549,6 +550,19 @@ class SelectComponent {
549
550
  this.button()?.el.nativeElement.focus();
550
551
  }, this.closeDelay());
551
552
  }
553
+ /**
554
+ * Focuses the options list when the overlay is attached.
555
+ */
556
+ onOverlayAttached() {
557
+ this.optionsList()?.el.nativeElement.focus();
558
+ }
559
+ /**
560
+ * Sets the width of the dropdown overlay based on the button's width.
561
+ * This ensures that the dropdown aligns properly with the button.
562
+ */
563
+ setButtonWidth() {
564
+ this.buttonWidth.set(this.button()?.el.nativeElement.offsetWidth);
565
+ }
552
566
  // Control Value Accessor methods
553
567
  /**
554
568
  * Callback function to propagate changes to the model.
@@ -595,14 +609,8 @@ class SelectComponent {
595
609
  setDisabledState(isDisabled) {
596
610
  this.disabled.set(isDisabled);
597
611
  }
598
- /**
599
- * Focuses the options list when the overlay is attached.
600
- */
601
- onOverlayAttached() {
602
- this.optionsList()?.el.nativeElement.focus();
603
- }
604
612
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.7", ngImport: i0, type: SelectComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
605
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "19.2.7", type: SelectComponent, isStandalone: true, selector: "b-select", inputs: { placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, maxWidth: { classPropertyName: "maxWidth", publicName: "maxWidth", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { disabled: "disabledChange" }, host: { properties: { "style.max-width": "maxWidth()", "class.disabled": "disabled()" } }, providers: [
613
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "19.2.7", type: SelectComponent, isStandalone: true, selector: "b-select", inputs: { placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, maxWidth: { classPropertyName: "maxWidth", publicName: "maxWidth", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { disabled: "disabledChange" }, host: { listeners: { "window:resize": "setButtonWidth()" }, properties: { "style.max-width": "maxWidth()", "class.disabled": "disabled()" } }, providers: [
606
614
  {
607
615
  provide: NG_VALUE_ACCESSOR,
608
616
  useExisting: forwardRef(() => SelectComponent),
@@ -706,7 +714,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.7", ngImpor
706
714
  },
707
715
  ],
708
716
  }]
709
- }] });
717
+ }], propDecorators: { setButtonWidth: [{
718
+ type: HostListener,
719
+ args: ['window:resize']
720
+ }] } });
710
721
 
711
722
  class Switch {
712
723
  /**
@@ -2615,6 +2626,15 @@ class CommandComponent {
2615
2626
  * This is linked to the options of the `CommandOptionsComponent`.
2616
2627
  */
2617
2628
  options = computed(() => this.commandOptions()?.options());
2629
+ /**
2630
+ * Reference to the BreakpointObserver service for responsive design.
2631
+ */
2632
+ breakpointObserver = inject(BreakpointObserver);
2633
+ /**
2634
+ * Signal representing whether the current viewport is desktop or not.
2635
+ * This is determined by checking if the Handset breakpoint is matched.
2636
+ */
2637
+ isDesktop = signal(!this.breakpointObserver.isMatched(Breakpoints.Handset));
2618
2638
  /**
2619
2639
  * Reference to the host element of the component.
2620
2640
  * This provides access to the DOM element of the command component.
@@ -2625,12 +2645,12 @@ class CommandComponent {
2625
2645
  type="text"
2626
2646
  b-input
2627
2647
  cdkTrapFocus
2628
- [cdkTrapFocusAutoCapture]="true"
2648
+ [cdkTrapFocusAutoCapture]="isDesktop()"
2629
2649
  #trappedInput
2630
2650
  (keydown.arrowDown)="commandOptions()?.nextOption()"
2631
2651
  (keydown.arrowUp)="commandOptions()?.previousOption()"
2632
2652
  (keydown.enter)="commandOptions()?.selectOption()"
2633
- (blur)="trappedInput.el.nativeElement.focus()" />
2653
+ (blur)="isDesktop() && trappedInput.el.nativeElement.focus()" />
2634
2654
  <ng-content />`, isInline: true, dependencies: [{ kind: "component", type: Input, selector: "input[b-input]", inputs: ["type", "placeholder", "invalid", "disabled", "maxWidth", "decimals", "numberType"], outputs: ["invalidChange", "disabledChange", "valueChange"] }, { kind: "directive", type: CdkTrapFocus, selector: "[cdkTrapFocus]", inputs: ["cdkTrapFocus", "cdkTrapFocusAutoCapture"], exportAs: ["cdkTrapFocus"] }] });
2635
2655
  }
2636
2656
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.7", ngImport: i0, type: CommandComponent, decorators: [{
@@ -2642,12 +2662,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.7", ngImpor
2642
2662
  type="text"
2643
2663
  b-input
2644
2664
  cdkTrapFocus
2645
- [cdkTrapFocusAutoCapture]="true"
2665
+ [cdkTrapFocusAutoCapture]="isDesktop()"
2646
2666
  #trappedInput
2647
2667
  (keydown.arrowDown)="commandOptions()?.nextOption()"
2648
2668
  (keydown.arrowUp)="commandOptions()?.previousOption()"
2649
2669
  (keydown.enter)="commandOptions()?.selectOption()"
2650
- (blur)="trappedInput.el.nativeElement.focus()" />
2670
+ (blur)="isDesktop() && trappedInput.el.nativeElement.focus()" />
2651
2671
  <ng-content />`,
2652
2672
  host: {
2653
2673
  '[style.maxWidth]': 'maxWidth()',
@@ -2691,10 +2711,10 @@ class ComboboxComponent {
2691
2711
  */
2692
2712
  maxWidth = input('100%');
2693
2713
  /**
2694
- * Computed signal for the width of the button element.
2714
+ * Linked signal for the width of the button element.
2695
2715
  * This is used to set the width of the dropdown overlay.
2696
2716
  */
2697
- buttonWidth = computed(() => this.button()?.el.nativeElement.offsetWidth);
2717
+ buttonWidth = linkedSignal(() => this.button()?.el.nativeElement.offsetWidth);
2698
2718
  /**
2699
2719
  * Model indicating whether the combobox component is disabled.
2700
2720
  * When disabled, the dropdown cannot be opened or interacted with.
@@ -2774,6 +2794,19 @@ class ComboboxComponent {
2774
2794
  this.button()?.el.nativeElement.focus();
2775
2795
  }, this.closeDelay());
2776
2796
  }
2797
+ /**
2798
+ * Focuses the input element within the command component when the overlay is attached.
2799
+ */
2800
+ onOverlayAttached() {
2801
+ this.command()?.el.nativeElement.querySelector('input')?.focus();
2802
+ }
2803
+ /**
2804
+ * Sets the width of the button element when the window is resized.
2805
+ * This ensures that the dropdown overlay matches the width of the button.
2806
+ */
2807
+ setButtonWidth() {
2808
+ this.buttonWidth.set(this.button()?.el.nativeElement.offsetWidth);
2809
+ }
2777
2810
  // Control Value Accessor methods
2778
2811
  /**
2779
2812
  * Callback function to propagate changes to the model.
@@ -2820,14 +2853,8 @@ class ComboboxComponent {
2820
2853
  setDisabledState(isDisabled) {
2821
2854
  this.disabled.set(isDisabled);
2822
2855
  }
2823
- /**
2824
- * Focuses the input element within the command component when the overlay is attached.
2825
- */
2826
- onOverlayAttached() {
2827
- this.command()?.el.nativeElement.querySelector('input')?.focus();
2828
- }
2829
2856
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.7", ngImport: i0, type: ComboboxComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
2830
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "19.2.7", type: ComboboxComponent, isStandalone: true, selector: "b-combobox", inputs: { placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, maxWidth: { classPropertyName: "maxWidth", publicName: "maxWidth", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { disabled: "disabledChange" }, host: { properties: { "style.max-width": "maxWidth()", "class.disabled": "disabled()" } }, providers: [
2857
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "19.2.7", type: ComboboxComponent, isStandalone: true, selector: "b-combobox", inputs: { placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, maxWidth: { classPropertyName: "maxWidth", publicName: "maxWidth", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { disabled: "disabledChange" }, host: { listeners: { "window:resize": "setButtonWidth()" }, properties: { "style.max-width": "maxWidth()", "class.disabled": "disabled()" } }, providers: [
2831
2858
  {
2832
2859
  provide: NG_VALUE_ACCESSOR,
2833
2860
  useExisting: forwardRef(() => ComboboxComponent),
@@ -2931,7 +2958,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.7", ngImpor
2931
2958
  },
2932
2959
  ],
2933
2960
  }]
2934
- }] });
2961
+ }], propDecorators: { setButtonWidth: [{
2962
+ type: HostListener,
2963
+ args: ['window:resize']
2964
+ }] } });
2935
2965
 
2936
2966
  /*
2937
2967
  * Public API Surface of basis-ng