@basis-ng/primitives 0.0.1-alpha.13 → 0.0.1-alpha.15

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.
@@ -79,6 +79,11 @@ export declare class ComboboxComponent implements OnInit, ControlValueAccessor {
79
79
  * value is propagated to Angular Forms.
80
80
  */
81
81
  handleSelectedValueChange(): void;
82
+ /**
83
+ * Opens the dropdown and focuses the listbox.
84
+ * This method sets the `isOpen` signal to `true` and ensures the listbox gains focus.
85
+ */
86
+ open(): void;
82
87
  /**
83
88
  * Closes the dropdown with a transition effect and refocuses the button.
84
89
  * This method sets the `isOpen` signal to `false` after a delay and removes
@@ -40,7 +40,7 @@ export declare class CommandOptionsComponent implements OnInit {
40
40
  /**
41
41
  * Selects the currently active option and updates the listbox value.
42
42
  */
43
- selectOption(): void;
43
+ selectOption(value?: string[]): void;
44
44
  /**
45
45
  * Moves the active item to the next option and updates the highlighted option.
46
46
  */
@@ -54,5 +54,5 @@ export declare class CommandOptionsComponent implements OnInit {
54
54
  */
55
55
  updateHighlightedOption(): void;
56
56
  static ɵfac: i0.ɵɵFactoryDeclaration<CommandOptionsComponent, never>;
57
- static ɵcmp: i0.ɵɵComponentDeclaration<CommandOptionsComponent, "ul[b-command-options]", never, {}, { "closeEmitter": "closeEmitter"; }, ["options"], ["*"], true, [{ directive: typeof i1.CdkListbox; inputs: {}; outputs: {}; }]>;
57
+ static ɵcmp: i0.ɵɵComponentDeclaration<CommandOptionsComponent, "ul[b-command-options]", never, {}, { "closeEmitter": "closeEmitter"; }, ["options"], ["*"], true, [{ directive: typeof i1.CdkListbox; inputs: {}; outputs: { "cdkListboxValueChange": "cdkListboxValueChange"; }; }]>;
58
58
  }
@@ -1,3 +1,4 @@
1
+ import { ElementRef } from '@angular/core';
1
2
  import { CommandOptionsComponent } from './command-options.component';
2
3
  import * as i0 from "@angular/core";
3
4
  /**
@@ -30,6 +31,11 @@ export declare class CommandComponent {
30
31
  * This is linked to the options of the `CommandOptionsComponent`.
31
32
  */
32
33
  readonly options: import("@angular/core").Signal<readonly import("@angular/cdk/listbox").CdkOption<any>[] | undefined>;
34
+ /**
35
+ * Reference to the host element of the component.
36
+ * This provides access to the DOM element of the command component.
37
+ */
38
+ el: ElementRef<any>;
33
39
  static ɵfac: i0.ɵɵFactoryDeclaration<CommandComponent, never>;
34
40
  static ɵcmp: i0.ɵɵComponentDeclaration<CommandComponent, "b-command", never, { "maxWidth": { "alias": "maxWidth"; "required": false; "isSignal": true; }; "maxHeight": { "alias": "maxHeight"; "required": false; "isSignal": true; }; }, {}, ["commandOptions"], ["*"], true, never>;
35
41
  }
@@ -3,7 +3,6 @@ import { ElementRef } from '@angular/core';
3
3
  import { OptionComponent } from '../../../shared/components/option.component';
4
4
  import * as i0 from "@angular/core";
5
5
  import * as i1 from "@angular/cdk/listbox";
6
- import * as i2 from "@angular/cdk/a11y";
7
6
  /**
8
7
  * Component representing the list of options in a select.
9
8
  * This component integrates with Angular CDK Listbox to manage options and their selection.
@@ -48,5 +47,5 @@ export declare class SelectOptionsComponent {
48
47
  */
49
48
  handleValueChange(value: string[]): void;
50
49
  static ɵfac: i0.ɵɵFactoryDeclaration<SelectOptionsComponent, never>;
51
- 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"; }; }, { directive: typeof i2.CdkTrapFocus; inputs: { "cdkTrapFocusAutoCapture": "cdkTrapFocusAutoCapture"; }; outputs: {}; }]>;
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"; }; }]>;
52
51
  }
@@ -79,6 +79,11 @@ export declare class SelectComponent implements OnInit, ControlValueAccessor {
79
79
  * value is propagated to Angular Forms.
80
80
  */
81
81
  handleSelectedValueChange(): void;
82
+ /**
83
+ * Opens the dropdown and focuses the listbox.
84
+ * This method sets the `isOpen` signal to `true` and ensures the listbox gains focus.
85
+ */
86
+ open(): void;
82
87
  /**
83
88
  * Closes the dropdown with a transition effect and refocuses the button.
84
89
  * This method sets the `isOpen` signal to `false` after a delay and removes
@@ -5,14 +5,13 @@ import { NgModel, NG_VALUE_ACCESSOR, ControlContainer } from '@angular/forms';
5
5
  import { CdkConnectedOverlay, CdkOverlayOrigin } from '@angular/cdk/overlay';
6
6
  import * as i1 from '@angular/cdk/listbox';
7
7
  import { CdkOption, CdkListbox } from '@angular/cdk/listbox';
8
- import * as i2 from '@angular/cdk/a11y';
9
- import { CdkTrapFocus, ActiveDescendantKeyManager } from '@angular/cdk/a11y';
10
8
  import { DomSanitizer } from '@angular/platform-browser';
11
9
  import { icons, createElement } from 'lucide';
12
10
  import * as i1$1 from '@angular/cdk/drag-drop';
13
11
  import { CdkDrag, CdkDragHandle, CdkDropList, CdkDropListGroup } from '@angular/cdk/drag-drop';
14
12
  import * as i1$2 from '@angular/cdk/menu';
15
13
  import { CdkMenu, CdkMenuItem, CdkMenuItemCheckbox, CdkMenuItemRadio, CdkMenuTrigger } from '@angular/cdk/menu';
14
+ import { ActiveDescendantKeyManager, CdkTrapFocus } from '@angular/cdk/a11y';
16
15
 
17
16
  class ThemeService {
18
17
  /**
@@ -357,7 +356,7 @@ class SelectOptionsComponent {
357
356
  this.closeEmitter.emit();
358
357
  }
359
358
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.7", ngImport: i0, type: SelectOptionsComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
360
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "19.2.7", 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)" }, properties: { "cdkListboxValue": "value()", "style.max-height": "maxHeight()", "cdkTrapFocusAutoCapture": "true" } }, queries: [{ propertyName: "options", predicate: OptionComponent, isSignal: true }], hostDirectives: [{ directive: i1.CdkListbox, inputs: ["cdkListboxValue", "cdkListboxValue"], outputs: ["cdkListboxValueChange", "cdkListboxValueChange"] }, { directive: i2.CdkTrapFocus, inputs: ["cdkTrapFocusAutoCapture", "cdkTrapFocusAutoCapture"] }], ngImport: i0, template: `<ng-content />`, isInline: true });
359
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "19.2.7", 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)" }, 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 });
361
360
  }
362
361
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.7", ngImport: i0, type: SelectOptionsComponent, decorators: [{
363
362
  type: Component,
@@ -371,16 +370,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.7", ngImpor
371
370
  inputs: ['cdkListboxValue'],
372
371
  outputs: ['cdkListboxValueChange'],
373
372
  },
374
- {
375
- directive: CdkTrapFocus,
376
- inputs: ['cdkTrapFocusAutoCapture'],
377
- },
378
373
  ],
379
374
  host: {
380
375
  '[cdkListboxValue]': 'value()',
381
376
  '(cdkListboxValueChange)': 'handleValueChange($event.value)',
382
377
  '[style.max-height]': 'maxHeight()',
383
- '[cdkTrapFocusAutoCapture]': 'true',
384
378
  },
385
379
  }]
386
380
  }] });
@@ -535,6 +529,14 @@ class SelectComponent {
535
529
  this.close(); // Close the dropdown
536
530
  });
537
531
  }
532
+ /**
533
+ * Opens the dropdown and focuses the listbox.
534
+ * This method sets the `isOpen` signal to `true` and ensures the listbox gains focus.
535
+ */
536
+ open() {
537
+ this.isOpen.set(true);
538
+ setTimeout(() => this.optionsList()?.el.nativeElement.focus(), 0);
539
+ }
538
540
  /**
539
541
  * Closes the dropdown with a transition effect and refocuses the button.
540
542
  * This method sets the `isOpen` signal to `false` after a delay and removes
@@ -604,9 +606,9 @@ class SelectComponent {
604
606
  ], queries: [{ propertyName: "optionsList", first: true, predicate: SelectOptionsComponent, descendants: true, isSignal: true }], viewQueries: [{ propertyName: "button", first: true, predicate: Button, descendants: true, isSignal: true }, { propertyName: "cdkConnectedOverlay", first: true, predicate: CdkConnectedOverlay, descendants: true, isSignal: true }], ngImport: i0, template: ` <button
605
607
  b-button
606
608
  variant="outlined"
607
- (click)="isOpen() ? close() : this.isOpen.set(true)"
608
- (keydown.arrowUp)="!isOpen() && this.isOpen.set(true)"
609
- (keydown.arrowDown)="!isOpen() && this.isOpen.set(true)"
609
+ (click)="isOpen() ? close() : open()"
610
+ (keydown.arrowUp)="!isOpen() && open()"
611
+ (keydown.arrowDown)="!isOpen() && open()"
610
612
  cdkOverlayOrigin
611
613
  [activeEnabled]="false"
612
614
  #trigger="cdkOverlayOrigin">
@@ -649,9 +651,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.7", ngImpor
649
651
  template: ` <button
650
652
  b-button
651
653
  variant="outlined"
652
- (click)="isOpen() ? close() : this.isOpen.set(true)"
653
- (keydown.arrowUp)="!isOpen() && this.isOpen.set(true)"
654
- (keydown.arrowDown)="!isOpen() && this.isOpen.set(true)"
654
+ (click)="isOpen() ? close() : open()"
655
+ (keydown.arrowUp)="!isOpen() && open()"
656
+ (keydown.arrowDown)="!isOpen() && open()"
655
657
  cdkOverlayOrigin
656
658
  [activeEnabled]="false"
657
659
  #trigger="cdkOverlayOrigin">
@@ -2518,8 +2520,11 @@ class CommandOptionsComponent {
2518
2520
  /**
2519
2521
  * Selects the currently active option and updates the listbox value.
2520
2522
  */
2521
- selectOption() {
2522
- this.value.set(this.listKeyManager().activeItem?.value ?? []);
2523
+ selectOption(value) {
2524
+ const selectValue = value
2525
+ ? value
2526
+ : (this.listKeyManager().activeItem?.value ?? []);
2527
+ this.value.set(selectValue);
2523
2528
  this.cdkListbox.value = this.value();
2524
2529
  this.closeEmitter.emit();
2525
2530
  }
@@ -2553,7 +2558,7 @@ class CommandOptionsComponent {
2553
2558
  });
2554
2559
  }
2555
2560
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.7", ngImport: i0, type: CommandOptionsComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
2556
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "19.2.7", type: CommandOptionsComponent, isStandalone: true, selector: "ul[b-command-options]", outputs: { closeEmitter: "closeEmitter" }, queries: [{ propertyName: "options", predicate: CdkOption, isSignal: true }], hostDirectives: [{ directive: i1.CdkListbox }], ngImport: i0, template: `<ng-content />`, isInline: true });
2561
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "19.2.7", type: CommandOptionsComponent, isStandalone: true, selector: "ul[b-command-options]", outputs: { closeEmitter: "closeEmitter" }, host: { listeners: { "cdkListboxValueChange": "selectOption($event.value)" } }, queries: [{ propertyName: "options", predicate: CdkOption, isSignal: true }], hostDirectives: [{ directive: i1.CdkListbox, outputs: ["cdkListboxValueChange", "cdkListboxValueChange"] }], ngImport: i0, template: `<ng-content />`, isInline: true });
2557
2562
  }
2558
2563
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.7", ngImport: i0, type: CommandOptionsComponent, decorators: [{
2559
2564
  type: Component,
@@ -2561,7 +2566,15 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.7", ngImpor
2561
2566
  selector: 'ul[b-command-options]',
2562
2567
  imports: [],
2563
2568
  template: `<ng-content />`,
2564
- hostDirectives: [CdkListbox],
2569
+ hostDirectives: [
2570
+ {
2571
+ directive: CdkListbox,
2572
+ outputs: ['cdkListboxValueChange'],
2573
+ },
2574
+ ],
2575
+ host: {
2576
+ '(cdkListboxValueChange)': 'selectOption($event.value)',
2577
+ },
2565
2578
  }]
2566
2579
  }] });
2567
2580
 
@@ -2595,6 +2608,11 @@ class CommandComponent {
2595
2608
  * This is linked to the options of the `CommandOptionsComponent`.
2596
2609
  */
2597
2610
  options = computed(() => this.commandOptions()?.options());
2611
+ /**
2612
+ * Reference to the host element of the component.
2613
+ * This provides access to the DOM element of the command component.
2614
+ */
2615
+ el = inject(ElementRef);
2598
2616
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.7", ngImport: i0, type: CommandComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
2599
2617
  static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "19.2.7", type: CommandComponent, isStandalone: true, selector: "b-command", inputs: { maxWidth: { classPropertyName: "maxWidth", publicName: "maxWidth", isSignal: true, isRequired: false, transformFunction: null }, maxHeight: { classPropertyName: "maxHeight", publicName: "maxHeight", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "style.maxWidth": "maxWidth()", "style.maxHeight": "maxHeight()" } }, queries: [{ propertyName: "commandOptions", first: true, predicate: CommandOptionsComponent, descendants: true, isSignal: true }], ngImport: i0, template: `<input
2600
2618
  type="text"
@@ -2729,6 +2747,13 @@ class ComboboxComponent {
2729
2747
  this.close(); // Close the dropdown
2730
2748
  });
2731
2749
  }
2750
+ /**
2751
+ * Opens the dropdown and focuses the listbox.
2752
+ * This method sets the `isOpen` signal to `true` and ensures the listbox gains focus.
2753
+ */
2754
+ open() {
2755
+ this.isOpen.set(true);
2756
+ }
2732
2757
  /**
2733
2758
  * Closes the dropdown with a transition effect and refocuses the button.
2734
2759
  * This method sets the `isOpen` signal to `false` after a delay and removes
@@ -2798,9 +2823,7 @@ class ComboboxComponent {
2798
2823
  ], queries: [{ propertyName: "command", first: true, predicate: CommandComponent, descendants: true, isSignal: true }], viewQueries: [{ propertyName: "button", first: true, predicate: Button, descendants: true, isSignal: true }, { propertyName: "cdkConnectedOverlay", first: true, predicate: CdkConnectedOverlay, descendants: true, isSignal: true }], ngImport: i0, template: ` <button
2799
2824
  b-button
2800
2825
  variant="outlined"
2801
- (click)="isOpen() ? close() : this.isOpen.set(true)"
2802
- (keydown.arrowUp)="!isOpen() && this.isOpen.set(true)"
2803
- (keydown.arrowDown)="!isOpen() && this.isOpen.set(true)"
2826
+ (click)="isOpen() ? close() : open()"
2804
2827
  cdkOverlayOrigin
2805
2828
  [activeEnabled]="false"
2806
2829
  #trigger="cdkOverlayOrigin">
@@ -2843,9 +2866,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.7", ngImpor
2843
2866
  template: ` <button
2844
2867
  b-button
2845
2868
  variant="outlined"
2846
- (click)="isOpen() ? close() : this.isOpen.set(true)"
2847
- (keydown.arrowUp)="!isOpen() && this.isOpen.set(true)"
2848
- (keydown.arrowDown)="!isOpen() && this.isOpen.set(true)"
2869
+ (click)="isOpen() ? close() : open()"
2849
2870
  cdkOverlayOrigin
2850
2871
  [activeEnabled]="false"
2851
2872
  #trigger="cdkOverlayOrigin">