@vsn-ux/ngx-gaia 0.2.2 → 0.2.4

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.
@@ -1,21 +1,19 @@
1
1
  import * as i0 from '@angular/core';
2
- import { inject, ElementRef, input, numberAttribute, Component, ViewEncapsulation, Attribute, NgModule, ChangeDetectionStrategy, Injectable, makeEnvironmentProviders, booleanAttribute, output, computed, contentChild, forwardRef, Injector, signal, linkedSignal, Directive, model, HostListener, InjectionToken, effect, TemplateRef, NgZone, Input, viewChild, contentChildren, isDevMode, afterNextRender } from '@angular/core';
2
+ import { inject, ElementRef, input, numberAttribute, Component, ViewEncapsulation, Attribute, NgModule, ChangeDetectionStrategy, Injectable, makeEnvironmentProviders, booleanAttribute, output, computed, contentChild, forwardRef, Injector, signal, linkedSignal, Directive, model, HostListener, InjectionToken, effect, TemplateRef, NgZone, Input, afterRender, contentChildren, viewChild } from '@angular/core';
3
3
  import * as i1 from 'lucide-angular';
4
4
  import { LucideAngularModule, X, CircleCheck, TriangleAlert, OctagonAlert, Info, Minus, Check, ChevronUp, ChevronDown } from 'lucide-angular';
5
5
  import { NG_VALUE_ACCESSOR, NgControl, NG_VALIDATORS, CheckboxRequiredValidator, RequiredValidator } from '@angular/forms';
6
+ import { DOCUMENT, NgTemplateOutlet } from '@angular/common';
6
7
  import * as i1$1 from '@angular/cdk/menu';
7
8
  import { CdkMenu, CdkMenuItem, CdkMenuTrigger } from '@angular/cdk/menu';
8
- import { toSignal, outputToObservable } from '@angular/core/rxjs-interop';
9
- import { merge, map, Subject, takeUntil, firstValueFrom } from 'rxjs';
9
+ import { toSignal } from '@angular/core/rxjs-interop';
10
+ import { merge, map, Subject, takeUntil } from 'rxjs';
10
11
  import * as i1$3 from '@angular/cdk/overlay';
11
- import { Overlay, OverlayModule } from '@angular/cdk/overlay';
12
+ import { Overlay, CdkOverlayOrigin, OverlayModule } from '@angular/cdk/overlay';
12
13
  import { ComponentPortal } from '@angular/cdk/portal';
13
14
  import { ESCAPE, hasModifierKey } from '@angular/cdk/keycodes';
14
- import { NgTemplateOutlet } from '@angular/common';
15
15
  import * as i1$2 from '@angular/cdk/listbox';
16
16
  import { CdkOption, CdkListbox } from '@angular/cdk/listbox';
17
- import * as i2 from '@angular/cdk/observers';
18
- import { ObserversModule } from '@angular/cdk/observers';
19
17
 
20
18
  class GaIconComponent {
21
19
  elementRef = inject(ElementRef);
@@ -322,11 +320,11 @@ const CHECKBOX_CONTROL_VALUE_ACCESSOR = {
322
320
  };
323
321
  // Increasing integer for generating unique ids for checkbox components.
324
322
  // Inspired by @angular/components
325
- let nextUniqueId$4 = 0;
323
+ let nextUniqueId$5 = 0;
326
324
  class GaCheckboxComponent {
327
325
  tabindex;
328
326
  /** @ignore */
329
- _uniqueId = `ga-checkbox-${++nextUniqueId$4}`;
327
+ _uniqueId = `ga-checkbox-${++nextUniqueId$5}`;
330
328
  /** @ignore */
331
329
  injector = inject(Injector);
332
330
  icons = { Minus, Check };
@@ -572,8 +570,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.5", ngImpor
572
570
 
573
571
  const GA_FORM_CONTROL = new InjectionToken('ga-form-control');
574
572
  class GaFormControlDirective {
573
+ _formControlId = input(undefined, {
574
+ alias: 'gaFormControl',
575
+ });
575
576
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.5", ngImport: i0, type: GaFormControlDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
576
- static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.1.5", type: GaFormControlDirective, isStandalone: true, selector: "[gaFormControl]", providers: [
577
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.1.5", type: GaFormControlDirective, isStandalone: true, selector: "[gaFormControl]", inputs: { _formControlId: { classPropertyName: "_formControlId", publicName: "gaFormControl", isSignal: true, isRequired: false, transformFunction: null } }, providers: [
577
578
  { provide: GA_FORM_CONTROL, useExisting: GaFormControlDirective },
578
579
  ], ngImport: i0 });
579
580
  }
@@ -587,9 +588,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.5", ngImpor
587
588
  }]
588
589
  }] });
589
590
 
590
- let nextUniqueId$3 = 0;
591
+ let nextUniqueId$4 = 0;
591
592
  class GaInputDirective {
592
- uniqueId = `ga-input-${++nextUniqueId$3}`;
593
+ uniqueId = `ga-input-${++nextUniqueId$4}`;
593
594
  implicitNgControl = inject(NgControl, {
594
595
  optional: true,
595
596
  self: true,
@@ -609,6 +610,7 @@ class GaInputDirective {
609
610
  return this.idInput() ?? this.uniqueId;
610
611
  });
611
612
  errors = this.implicitErrors.asReadonly();
613
+ _formControlId = this.id;
612
614
  ngDoCheck() {
613
615
  if (this.hasWrapper)
614
616
  return;
@@ -650,12 +652,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.5", ngImpor
650
652
  }]
651
653
  }] });
652
654
 
653
- let nextUniqueId$2 = 0;
655
+ let nextUniqueId$3 = 0;
654
656
  class GaFormFieldComponent {
655
- uniqueId = `ga-form-field-${++nextUniqueId$2}`;
656
- formControl = contentChild(GA_FORM_CONTROL);
657
+ uniqueId = `ga-form-field-${++nextUniqueId$3}`;
658
+ formControl = contentChild(GA_FORM_CONTROL, { descendants: true });
657
659
  controlId = computed(() => {
658
- return this.formControl()?.id() ?? this.uniqueId;
660
+ return this.formControl()?._formControlId() ?? this.uniqueId;
659
661
  });
660
662
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.5", ngImport: i0, type: GaFormFieldComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
661
663
  static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "19.1.5", type: GaFormFieldComponent, isStandalone: true, selector: "ga-form-field", host: { classAttribute: "ga-form-field" }, queries: [{ propertyName: "formControl", first: true, predicate: GA_FORM_CONTROL, descendants: true, isSignal: true }], exportAs: ["gaFormField"], ngImport: i0, template: "<ng-content />\n", changeDetection: i0.ChangeDetectionStrategy.OnPush });
@@ -668,13 +670,32 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.5", ngImpor
668
670
  }] });
669
671
 
670
672
  class GaFieldLabelComponent {
673
+ document = inject(DOCUMENT);
671
674
  formField = inject(GaFormFieldComponent);
672
675
  for = input();
673
676
  controlId = computed(() => {
674
677
  return this.for() ?? this.formField.controlId();
675
678
  });
679
+ controlElement = computed(() => {
680
+ const control = this.document.querySelector(`#${this.controlId()}`);
681
+ if (control instanceof HTMLElement) {
682
+ return control;
683
+ }
684
+ return null;
685
+ });
686
+ focusControl() {
687
+ const control = this.controlElement();
688
+ // only focus custom elements as native elements already
689
+ // have support for connecting label and reacting to events
690
+ if (control?.tagName.includes('-')) {
691
+ control.focus();
692
+ }
693
+ }
676
694
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.5", ngImport: i0, type: GaFieldLabelComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
677
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "19.1.5", type: GaFieldLabelComponent, isStandalone: true, selector: "ga-label", inputs: { for: { classPropertyName: "for", publicName: "for", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: `<label [attr.for]="controlId()" class="ga-form-field__label"
695
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "19.1.5", type: GaFieldLabelComponent, isStandalone: true, selector: "ga-label", inputs: { for: { classPropertyName: "for", publicName: "for", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: `<label
696
+ [attr.for]="controlId()"
697
+ class="ga-form-field__label"
698
+ (click)="focusControl()"
678
699
  ><ng-content
679
700
  /></label>`, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
680
701
  }
@@ -682,7 +703,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.5", ngImpor
682
703
  type: Component,
683
704
  args: [{
684
705
  selector: 'ga-label',
685
- template: `<label [attr.for]="controlId()" class="ga-form-field__label"
706
+ template: `<label
707
+ [attr.for]="controlId()"
708
+ class="ga-form-field__label"
709
+ (click)="focusControl()"
686
710
  ><ng-content
687
711
  /></label>`,
688
712
  changeDetection: ChangeDetectionStrategy.OnPush,
@@ -1260,10 +1284,10 @@ const RADIO_CONTROL_VALUE_ACCESSOR = {
1260
1284
  multi: true,
1261
1285
  };
1262
1286
  // Increasing integer for generating unique ids for radio components.
1263
- let nextUniqueId$1 = 0;
1287
+ let nextUniqueId$2 = 0;
1264
1288
  class GaRadioGroupComponent {
1265
1289
  /** Name of the radio button group. All radio buttons inside this group will use this name. */
1266
- name = input(`ga-radio-group-${nextUniqueId$1++}`);
1290
+ name = input(`ga-radio-group-${nextUniqueId$2++}`);
1267
1291
  /**
1268
1292
  * Value for the radio-group. Should equal the value of the selected radio button if there is
1269
1293
  * a corresponding radio button with a matching value. If there is not such a corresponding
@@ -1322,13 +1346,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.5", ngImpor
1322
1346
  }] });
1323
1347
 
1324
1348
  // Increasing integer for generating unique ids for radio button components.
1325
- let nextUniqueId = 0;
1349
+ let nextUniqueId$1 = 0;
1326
1350
  class GaRadioButtonComponent {
1327
1351
  tabindex;
1328
1352
  radioGroup = inject(GaRadioGroupComponent, {
1329
1353
  optional: true,
1330
1354
  });
1331
- _uniqueId = `ga-radio-button-${++nextUniqueId}`;
1355
+ _uniqueId = `ga-radio-button-${++nextUniqueId$1}`;
1332
1356
  /** The value attribute of the native input element */
1333
1357
  value = input(null);
1334
1358
  inputId = input(null, { alias: 'id' });
@@ -1424,11 +1448,13 @@ class GaOptionComponent {
1424
1448
  this.cdkOption.value !== null &&
1425
1449
  this.cdkOption.value !== '');
1426
1450
  active = this._isActive.asReadonly();
1427
- ngDoCheck() {
1428
- // NOTE: currently there is no other reliable way to track the selected state,
1429
- // refactor once cdk will be based on signals or more appropriate events introduced
1430
- this._isSelected.set(this.cdkOption.isSelected());
1431
- this._isActive.set(this.cdkOption.isActive());
1451
+ constructor() {
1452
+ afterRender(() => {
1453
+ // NOTE: currently there is no other reliable way to track the selected state,
1454
+ // refactor once cdk will be based on signals or more appropriate events introduced
1455
+ this._isSelected.set(this.cdkOption.isSelected());
1456
+ this._isActive.set(this.cdkOption.isActive());
1457
+ });
1432
1458
  }
1433
1459
  onClick() {
1434
1460
  if (!this.cdkOption.disabled) {
@@ -1456,111 +1482,45 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.5", ngImpor
1456
1482
  '[class.ga-dropdown__item--active]': 'active() && !cdkOption.disabled',
1457
1483
  '(click)': 'onClick()',
1458
1484
  }, template: "@if (withInput()) {\n @if (selectComponent.multiple()) {\n <ga-checkbox\n [checked]=\"selected()\"\n [disabled]=\"disabled()\"\n aria-hidden=\"true\"\n style=\"pointer-events: none\"\n tabindex=\"-1\"\n />\n } @else {\n <ga-radio-button\n [checked]=\"selected()\"\n [disabled]=\"disabled()\"\n aria-hidden=\"true\"\n style=\"pointer-events: none\"\n tabindex=\"-1\"\n />\n }\n}\n<ng-content />\n" }]
1459
- }] });
1485
+ }], ctorParameters: () => [] });
1460
1486
 
1461
1487
  class GaSelectValueComponent {
1462
- selectComponent = inject(GaSelectComponent);
1463
- optionViewValue = computed(() => {
1464
- const options = this.selectComponent.selectedOptions();
1465
- if (!options.length) {
1466
- return null;
1467
- }
1468
- return options
1469
- .map((option) => option.cdkOption.element.textContent?.trim() ?? '')
1470
- .join(', ');
1471
- });
1472
1488
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.5", ngImport: i0, type: GaSelectValueComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
1473
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.1.5", type: GaSelectValueComponent, isStandalone: true, selector: "ga-select-value", ngImport: i0, template: `{{ optionViewValue() }}`, isInline: true });
1489
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.1.5", type: GaSelectValueComponent, isStandalone: true, selector: "ga-select-value", ngImport: i0, template: `<ng-content />`, isInline: true });
1474
1490
  }
1475
1491
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.5", ngImport: i0, type: GaSelectValueComponent, decorators: [{
1476
1492
  type: Component,
1477
1493
  args: [{
1478
1494
  selector: 'ga-select-value',
1479
- template: `{{ optionViewValue() }}`,
1495
+ template: `<ng-content />`,
1480
1496
  }]
1481
1497
  }] });
1482
1498
 
1483
- const GA_SELECT_TRIGGER = new InjectionToken('gaSelectTrigger');
1484
-
1485
- class GaSelectTriggerComponent {
1499
+ class GaSelectDefaultValueComponent {
1486
1500
  selectComponent = inject(GaSelectComponent);
1487
- content = viewChild('ngContent', { read: ElementRef });
1488
- hasCustomLabel = signal(false);
1489
- menuStatusIcon = computed(() => {
1490
- return this.selectComponent.isOpen() ? ChevronUp : ChevronDown;
1501
+ optionViewValue = computed(() => {
1502
+ const options = this.selectComponent.selectedOptions();
1503
+ if (!options.length) {
1504
+ return null;
1505
+ }
1506
+ return options
1507
+ .map((option) => option.cdkOption.element.textContent?.trim() ?? '')
1508
+ .join(', ');
1491
1509
  });
1492
- leftIcon = input();
1493
- ngAfterViewInit() {
1494
- this.checkIfHasCustomLabel();
1495
- }
1496
- checkIfHasCustomLabel() {
1497
- this.hasCustomLabel.set(!!this.content()?.nativeElement.children.length);
1498
- }
1499
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.5", ngImport: i0, type: GaSelectTriggerComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
1500
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.1.5", type: GaSelectTriggerComponent, isStandalone: true, selector: "ga-select-trigger", inputs: { leftIcon: { classPropertyName: "leftIcon", publicName: "leftIcon", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "role": "combobox", "aria-haspopup": "listbox" }, listeners: { "click": "selectComponent.toggle()", "keydown.arrowdown": "selectComponent.open(); $event.preventDefault()", "keydown.space": "selectComponent.open(); $event.preventDefault()", "keydown.enter": "selectComponent.open(); $event.preventDefault()" }, properties: { "class.ga-select--expanded": "selectComponent.isOpen()", "class.ga-select--disabled": "selectComponent.disabled()", "class.ga-select--invalid": "selectComponent.invalid()", "class.ga-select--empty": "!selectComponent.hasValue()", "attr.aria-expanded": "selectComponent.isOpen()", "attr.aria-controls": "selectComponent.listboxId()", "attr.aria-invalid": "selectComponent.invalid()", "attr.aria-disabled": "selectComponent.disabled()", "attr.aria-activedescendant": "selectComponent.activeDescendantId()", "attr.tabindex": "selectComponent.disabled() ? -1 : 0" }, classAttribute: "ga-select" }, providers: [
1501
- {
1502
- provide: GA_SELECT_TRIGGER,
1503
- useExisting: forwardRef(() => GaSelectTriggerComponent),
1504
- },
1505
- ], viewQueries: [{ propertyName: "content", first: true, predicate: ["ngContent"], descendants: true, read: ElementRef, isSignal: true }], ngImport: i0, template: "@if (leftIcon()) {\n <ga-icon [icon]=\"leftIcon()\" />\n}\n@if (selectComponent.hasValue()) {\n <div class=\"ga-select__value\">\n <span #ngContent (cdkObserveContent)=\"checkIfHasCustomLabel()\">\n <ng-content />\n </span>\n @if (!hasCustomLabel()) {\n <ga-select-value />\n }\n </div>\n} @else {\n <div class=\"ga-select__placeholder\">\n {{ selectComponent.placeholder() }}\n </div>\n}\n<ga-icon [icon]=\"menuStatusIcon()\" />\n", dependencies: [{ kind: "ngmodule", type: GaInputModule }, { kind: "ngmodule", type: GaIconModule }, { kind: "component", type: GaIconComponent, selector: "ga-icon", inputs: ["icon", "size", "color", "strokeWidth"] }, { kind: "component", type: GaSelectValueComponent, selector: "ga-select-value" }, { kind: "ngmodule", type: ObserversModule }, { kind: "directive", type: i2.CdkObserveContent, selector: "[cdkObserveContent]", inputs: ["cdkObserveContentDisabled", "debounce"], outputs: ["cdkObserveContent"], exportAs: ["cdkObserveContent"] }] });
1510
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.5", ngImport: i0, type: GaSelectDefaultValueComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
1511
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.1.5", type: GaSelectDefaultValueComponent, isStandalone: true, selector: "ga-select-default-value", ngImport: i0, template: `{{ optionViewValue() }}`, isInline: true });
1506
1512
  }
1507
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.5", ngImport: i0, type: GaSelectTriggerComponent, decorators: [{
1508
- type: Component,
1509
- args: [{ selector: 'ga-select-trigger', imports: [
1510
- GaInputModule,
1511
- GaIconModule,
1512
- GaSelectValueComponent,
1513
- ObserversModule,
1514
- ], providers: [
1515
- {
1516
- provide: GA_SELECT_TRIGGER,
1517
- useExisting: forwardRef(() => GaSelectTriggerComponent),
1518
- },
1519
- ], host: {
1520
- role: 'combobox',
1521
- class: 'ga-select',
1522
- '[class.ga-select--expanded]': 'selectComponent.isOpen()',
1523
- '[class.ga-select--disabled]': 'selectComponent.disabled()',
1524
- '[class.ga-select--invalid]': 'selectComponent.invalid()',
1525
- '[class.ga-select--empty]': '!selectComponent.hasValue()',
1526
- 'aria-haspopup': 'listbox',
1527
- '[attr.aria-expanded]': 'selectComponent.isOpen()',
1528
- '[attr.aria-controls]': 'selectComponent.listboxId()',
1529
- '[attr.aria-invalid]': 'selectComponent.invalid()',
1530
- '[attr.aria-disabled]': 'selectComponent.disabled()',
1531
- '[attr.aria-activedescendant]': 'selectComponent.activeDescendantId()',
1532
- '[attr.tabindex]': 'selectComponent.disabled() ? -1 : 0',
1533
- '(click)': 'selectComponent.toggle()',
1534
- '(keydown.arrowdown)': 'selectComponent.open(); $event.preventDefault()',
1535
- '(keydown.space)': 'selectComponent.open(); $event.preventDefault()',
1536
- '(keydown.enter)': 'selectComponent.open(); $event.preventDefault()',
1537
- }, template: "@if (leftIcon()) {\n <ga-icon [icon]=\"leftIcon()\" />\n}\n@if (selectComponent.hasValue()) {\n <div class=\"ga-select__value\">\n <span #ngContent (cdkObserveContent)=\"checkIfHasCustomLabel()\">\n <ng-content />\n </span>\n @if (!hasCustomLabel()) {\n <ga-select-value />\n }\n </div>\n} @else {\n <div class=\"ga-select__placeholder\">\n {{ selectComponent.placeholder() }}\n </div>\n}\n<ga-icon [icon]=\"menuStatusIcon()\" />\n" }]
1538
- }] });
1539
-
1540
- class GaSelectCustomTriggerComponent {
1541
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.5", ngImport: i0, type: GaSelectCustomTriggerComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
1542
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.1.5", type: GaSelectCustomTriggerComponent, isStandalone: true, selector: "ga-select-custom-trigger", providers: [
1543
- {
1544
- provide: GA_SELECT_TRIGGER,
1545
- useExisting: forwardRef(() => GaSelectCustomTriggerComponent),
1546
- },
1547
- ], ngImport: i0, template: `<ng-content></ng-content>`, isInline: true });
1548
- }
1549
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.5", ngImport: i0, type: GaSelectCustomTriggerComponent, decorators: [{
1513
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.5", ngImport: i0, type: GaSelectDefaultValueComponent, decorators: [{
1550
1514
  type: Component,
1551
1515
  args: [{
1552
- selector: 'ga-select-custom-trigger',
1553
- template: `<ng-content></ng-content>`,
1554
- providers: [
1555
- {
1556
- provide: GA_SELECT_TRIGGER,
1557
- useExisting: forwardRef(() => GaSelectCustomTriggerComponent),
1558
- },
1559
- ],
1516
+ selector: 'ga-select-default-value',
1517
+ template: `{{ optionViewValue() }}`,
1560
1518
  }]
1561
1519
  }] });
1562
1520
 
1521
+ let nextUniqueId = 0;
1563
1522
  class GaSelectComponent {
1523
+ _uniqueId = `ga-select-${++nextUniqueId}`;
1564
1524
  focusedTriggerElement = null;
1565
1525
  _onTouched;
1566
1526
  _onModelChanged;
@@ -1579,8 +1539,23 @@ class GaSelectComponent {
1579
1539
  overlayY: 'bottom',
1580
1540
  offsetY: -8,
1581
1541
  },
1542
+ {
1543
+ originX: 'start',
1544
+ originY: 'bottom',
1545
+ overlayX: 'start',
1546
+ overlayY: 'top',
1547
+ offsetY: 8,
1548
+ },
1549
+ {
1550
+ originX: 'start',
1551
+ originY: 'top',
1552
+ overlayX: 'start',
1553
+ overlayY: 'bottom',
1554
+ offsetY: -8,
1555
+ },
1582
1556
  ];
1583
1557
  injector = inject(Injector);
1558
+ overlayOrigin = inject(CdkOverlayOrigin);
1584
1559
  implicitInvalid = signal(false);
1585
1560
  _isOpen = signal(false);
1586
1561
  value = model(null);
@@ -1595,19 +1570,25 @@ class GaSelectComponent {
1595
1570
  });
1596
1571
  multiple = input(false, { transform: booleanAttribute });
1597
1572
  compareWith = input();
1598
- withoutAutoFocus = signal(false);
1599
- opened = output();
1600
- closed = output();
1573
+ searchable = input(false, { transform: booleanAttribute });
1574
+ textValue = model('');
1575
+ leftIcon = input();
1576
+ idInput = input(null, { alias: 'id' });
1601
1577
  // TODO: if we rename this to options, it breaks, why?
1602
1578
  gaOptions = contentChildren(GaOptionComponent, {
1603
1579
  descendants: true,
1604
1580
  read: GaOptionComponent,
1605
1581
  });
1606
1582
  cdkListbox = contentChild.required(CdkListbox);
1607
- explicitTrigger = contentChild(GA_SELECT_TRIGGER);
1583
+ customSelectValue = contentChild(GaSelectValueComponent);
1584
+ inputSearch = viewChild('inputSearch');
1585
+ content = viewChild('ngContent', { read: ElementRef });
1586
+ id = computed(() => {
1587
+ return this.idInput() ?? this._uniqueId;
1588
+ });
1608
1589
  isOpen = this._isOpen.asReadonly();
1609
1590
  disabled = linkedSignal(() => this.disabledInput());
1610
- icon = computed(() => {
1591
+ menuStatusIcon = computed(() => {
1611
1592
  return this._isOpen() ? ChevronUp : ChevronDown;
1612
1593
  });
1613
1594
  selectedOptions = computed(() => {
@@ -1627,7 +1608,7 @@ class GaSelectComponent {
1627
1608
  invalid = computed(() => {
1628
1609
  return this.invalidInput() ?? this.implicitInvalid();
1629
1610
  });
1630
- listboxId = computed(() => this.cdkListbox().id);
1611
+ _formControlId = computed(() => this.id());
1631
1612
  constructor() {
1632
1613
  effect(() => {
1633
1614
  // if the select became disabled while open, close it
@@ -1639,7 +1620,7 @@ class GaSelectComponent {
1639
1620
  ngAfterContentInit() {
1640
1621
  effect(() => {
1641
1622
  this.cdkListbox().multiple = this.multiple();
1642
- this.cdkListbox().useActiveDescendant = this.withoutAutoFocus();
1623
+ this.cdkListbox().useActiveDescendant = this.searchable();
1643
1624
  this.cdkListbox().compareWith = this.compareWith();
1644
1625
  this.cdkListbox().value = this.multiple()
1645
1626
  ? this.value()
@@ -1655,12 +1636,6 @@ class GaSelectComponent {
1655
1636
  // this is needed because value could be also changed via keyboard
1656
1637
  this.autoClose();
1657
1638
  });
1658
- if (isDevMode() &&
1659
- this.explicitTrigger() instanceof GaSelectCustomTriggerComponent) {
1660
- if (this.multiple()) {
1661
- console.warn('<ga-select>: The `multiple` property requires custom handling when using a custom trigger component. If you have implemented the multiple selection logic in your custom trigger, you can ignore this warning. [This message is visible in dev mode only]');
1662
- }
1663
- }
1664
1639
  }
1665
1640
  ngDoCheck() {
1666
1641
  const implicitNgControl = this.injector.get(NgControl, null);
@@ -1691,17 +1666,15 @@ class GaSelectComponent {
1691
1666
  }
1692
1667
  open() {
1693
1668
  if (this.disabled() || this._isOpen()) {
1694
- return Promise.resolve();
1669
+ return;
1695
1670
  }
1696
1671
  this._isOpen.set(true);
1697
- return firstValueFrom(outputToObservable(this.opened));
1698
1672
  }
1699
1673
  close() {
1700
1674
  if (!this._isOpen()) {
1701
- return Promise.resolve();
1675
+ return;
1702
1676
  }
1703
1677
  this._isOpen.set(false);
1704
- return firstValueFrom(outputToObservable(this.closed));
1705
1678
  }
1706
1679
  autoClose() {
1707
1680
  // close that was initiated by clicking the option
@@ -1734,19 +1707,44 @@ class GaSelectComponent {
1734
1707
  this.value.set(value);
1735
1708
  }
1736
1709
  }
1710
+ onInputKeyDown(event) {
1711
+ switch (event.code) {
1712
+ case 'ArrowDown':
1713
+ this.setNextItemActive();
1714
+ event.preventDefault();
1715
+ event.stopPropagation();
1716
+ break;
1717
+ case 'ArrowUp':
1718
+ this.setPreviousItemActive();
1719
+ event.preventDefault();
1720
+ event.stopPropagation();
1721
+ break;
1722
+ case 'Space':
1723
+ event.stopPropagation();
1724
+ break;
1725
+ case 'Enter':
1726
+ this.setActiveItemAsSelected();
1727
+ this.autoClose();
1728
+ event.preventDefault();
1729
+ event.stopPropagation();
1730
+ break;
1731
+ }
1732
+ }
1737
1733
  onOverlayAttach() {
1738
1734
  this._isOpen.set(true);
1739
1735
  this.focusedTriggerElement = document.activeElement;
1740
- this.opened.emit();
1741
- if (!this.withoutAutoFocus()) {
1736
+ if (this.searchable()) {
1737
+ this.inputSearch().nativeElement.focus();
1738
+ }
1739
+ else {
1742
1740
  this.focusListbox();
1743
1741
  }
1744
1742
  }
1745
1743
  onOverlayDetach() {
1746
1744
  this._isOpen.set(false);
1747
1745
  this.focusedTriggerElement?.focus();
1746
+ this.textValue.set('');
1748
1747
  this._onTouched?.();
1749
- this.closed.emit();
1750
1748
  }
1751
1749
  setItemActive(direction) {
1752
1750
  const options = this.gaOptions();
@@ -1768,13 +1766,17 @@ class GaSelectComponent {
1768
1766
  }
1769
1767
  }
1770
1768
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.5", ngImport: i0, type: GaSelectComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
1771
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.1.5", type: GaSelectComponent, isStandalone: true, selector: "ga-select", inputs: { value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, disabledInput: { classPropertyName: "disabledInput", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, invalidInput: { classPropertyName: "invalidInput", publicName: "invalid", isSignal: true, isRequired: false, transformFunction: null }, multiple: { classPropertyName: "multiple", publicName: "multiple", isSignal: true, isRequired: false, transformFunction: null }, compareWith: { classPropertyName: "compareWith", publicName: "compareWith", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { value: "valueChange", opened: "opened", closed: "closed" }, providers: [
1769
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.1.5", type: GaSelectComponent, isStandalone: true, selector: "ga-select", inputs: { value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, disabledInput: { classPropertyName: "disabledInput", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, invalidInput: { classPropertyName: "invalidInput", publicName: "invalid", isSignal: true, isRequired: false, transformFunction: null }, multiple: { classPropertyName: "multiple", publicName: "multiple", isSignal: true, isRequired: false, transformFunction: null }, compareWith: { classPropertyName: "compareWith", publicName: "compareWith", isSignal: true, isRequired: false, transformFunction: null }, searchable: { classPropertyName: "searchable", publicName: "searchable", isSignal: true, isRequired: false, transformFunction: null }, textValue: { classPropertyName: "textValue", publicName: "textValue", isSignal: true, isRequired: false, transformFunction: null }, leftIcon: { classPropertyName: "leftIcon", publicName: "leftIcon", isSignal: true, isRequired: false, transformFunction: null }, idInput: { classPropertyName: "idInput", publicName: "id", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { value: "valueChange", textValue: "textValueChange" }, host: { attributes: { "role": "combobox", "aria-haspopup": "listbox" }, listeners: { "click": "toggle()", "keydown.arrowdown": "open(); $event.preventDefault()", "keydown.space": "open(); $event.preventDefault()", "keydown.enter": "open(); $event.preventDefault()" }, properties: { "attr.id": "id()", "class.ga-select--expanded": "isOpen()", "class.ga-select--disabled": "disabled()", "class.ga-select--invalid": "invalid()", "class.ga-select--empty": "!hasValue()", "attr.aria-expanded": "isOpen()", "attr.aria-controls": "cdkListbox().id", "attr.aria-invalid": "invalid()", "attr.aria-disabled": "disabled()", "attr.aria-owns": "searchable() ? cdkListbox().id : null", "attr.aria-activedescendant": "!searchable() ? activeDescendantId() : null", "attr.tabindex": "disabled() ? -1 : 0" }, classAttribute: "ga-select" }, providers: [
1772
1770
  {
1773
1771
  provide: NG_VALUE_ACCESSOR,
1774
1772
  useExisting: forwardRef(() => GaSelectComponent),
1775
1773
  multi: true,
1776
1774
  },
1777
- ], queries: [{ propertyName: "gaOptions", predicate: GaOptionComponent, descendants: true, read: GaOptionComponent, isSignal: true }, { propertyName: "cdkListbox", first: true, predicate: CdkListbox, descendants: true, isSignal: true }, { propertyName: "explicitTrigger", first: true, predicate: GA_SELECT_TRIGGER, descendants: true, isSignal: true }], ngImport: i0, template: "<div cdkOverlayOrigin #trigger=\"cdkOverlayOrigin\">\n @if (explicitTrigger()) {\n <ng-content\n select=\"ga-select-custom-trigger, ga-select-trigger, ga-select-searchable-trigger\"\n />\n } @else {\n <ga-select-trigger />\n }\n</div>\n\n<ng-template\n cdkConnectedOverlay\n cdkConnectedOverlayLockPosition\n [cdkConnectedOverlayOrigin]=\"trigger\"\n [cdkConnectedOverlayOpen]=\"isOpen()\"\n [cdkConnectedOverlayPositions]=\"positions\"\n (overlayOutsideClick)=\"close()\"\n (attach)=\"onOverlayAttach()\"\n (detach)=\"onOverlayDetach()\"\n>\n <ng-content select=\"ga-select-content\" />\n</ng-template>\n", styles: ["ga-select{display:inline-block}\n"], dependencies: [{ kind: "ngmodule", type: GaIconModule }, { kind: "ngmodule", type: GaButtonModule }, { kind: "ngmodule", type: OverlayModule }, { kind: "directive", type: i1$3.CdkConnectedOverlay, selector: "[cdk-connected-overlay], [connected-overlay], [cdkConnectedOverlay]", inputs: ["cdkConnectedOverlayOrigin", "cdkConnectedOverlayPositions", "cdkConnectedOverlayPositionStrategy", "cdkConnectedOverlayOffsetX", "cdkConnectedOverlayOffsetY", "cdkConnectedOverlayWidth", "cdkConnectedOverlayHeight", "cdkConnectedOverlayMinWidth", "cdkConnectedOverlayMinHeight", "cdkConnectedOverlayBackdropClass", "cdkConnectedOverlayPanelClass", "cdkConnectedOverlayViewportMargin", "cdkConnectedOverlayScrollStrategy", "cdkConnectedOverlayOpen", "cdkConnectedOverlayDisableClose", "cdkConnectedOverlayTransformOriginOn", "cdkConnectedOverlayHasBackdrop", "cdkConnectedOverlayLockPosition", "cdkConnectedOverlayFlexibleDimensions", "cdkConnectedOverlayGrowAfterOpen", "cdkConnectedOverlayPush", "cdkConnectedOverlayDisposeOnNavigation"], outputs: ["backdropClick", "positionChange", "attach", "detach", "overlayKeydown", "overlayOutsideClick"], exportAs: ["cdkConnectedOverlay"] }, { kind: "directive", type: i1$3.CdkOverlayOrigin, selector: "[cdk-overlay-origin], [overlay-origin], [cdkOverlayOrigin]", exportAs: ["cdkOverlayOrigin"] }, { kind: "component", type: GaSelectTriggerComponent, selector: "ga-select-trigger", inputs: ["leftIcon"] }], encapsulation: i0.ViewEncapsulation.None });
1775
+ {
1776
+ provide: GA_FORM_CONTROL,
1777
+ useExisting: forwardRef(() => GaSelectComponent),
1778
+ },
1779
+ ], queries: [{ propertyName: "gaOptions", predicate: GaOptionComponent, descendants: true, read: GaOptionComponent, isSignal: true }, { propertyName: "cdkListbox", first: true, predicate: CdkListbox, descendants: true, isSignal: true }, { propertyName: "customSelectValue", first: true, predicate: GaSelectValueComponent, descendants: true, isSignal: true }], viewQueries: [{ propertyName: "inputSearch", first: true, predicate: ["inputSearch"], descendants: true, isSignal: true }, { propertyName: "content", first: true, predicate: ["ngContent"], descendants: true, read: ElementRef, isSignal: true }], hostDirectives: [{ directive: i1$3.CdkOverlayOrigin }], ngImport: i0, template: "@if (leftIcon()) {\n <ga-icon [icon]=\"leftIcon()\" />\n}\n@if (searchable() && isOpen()) {\n <input\n #inputSearch\n type=\"text\"\n class=\"ga-select__input\"\n aria-autocomplete=\"list\"\n [value]=\"textValue()\"\n (input)=\"textValue.set(inputSearch.value)\"\n (click)=\"$event.stopPropagation()\"\n [attr.aria-expanded]=\"isOpen()\"\n [attr.aria-controls]=\"cdkListbox().id\"\n [attr.aria-activedescendant]=\"activeDescendantId()\"\n [placeholder]=\"placeholder()\"\n (keydown)=\"onInputKeyDown($event)\"\n tabindex=\"-1\"\n />\n} @else if (hasValue()) {\n <div class=\"ga-select__value\">\n @if (customSelectValue()) {\n <ng-content select=\"ga-select-value\" />\n } @else {\n <ga-select-default-value />\n }\n </div>\n} @else {\n <div class=\"ga-select__placeholder\">\n {{ placeholder() }}\n </div>\n}\n<ga-icon [icon]=\"menuStatusIcon()\" />\n\n<ng-template\n cdkConnectedOverlay\n cdkConnectedOverlayLockPosition\n [cdkConnectedOverlayOrigin]=\"overlayOrigin\"\n [cdkConnectedOverlayOpen]=\"isOpen()\"\n [cdkConnectedOverlayPositions]=\"positions\"\n (overlayOutsideClick)=\"close()\"\n (attach)=\"onOverlayAttach()\"\n (detach)=\"onOverlayDetach()\"\n>\n <ng-content select=\"ga-select-dropdown\" />\n</ng-template>\n", dependencies: [{ kind: "ngmodule", type: GaIconModule }, { kind: "component", type: GaIconComponent, selector: "ga-icon", inputs: ["icon", "size", "color", "strokeWidth"] }, { kind: "ngmodule", type: GaButtonModule }, { kind: "ngmodule", type: OverlayModule }, { kind: "directive", type: i1$3.CdkConnectedOverlay, selector: "[cdk-connected-overlay], [connected-overlay], [cdkConnectedOverlay]", inputs: ["cdkConnectedOverlayOrigin", "cdkConnectedOverlayPositions", "cdkConnectedOverlayPositionStrategy", "cdkConnectedOverlayOffsetX", "cdkConnectedOverlayOffsetY", "cdkConnectedOverlayWidth", "cdkConnectedOverlayHeight", "cdkConnectedOverlayMinWidth", "cdkConnectedOverlayMinHeight", "cdkConnectedOverlayBackdropClass", "cdkConnectedOverlayPanelClass", "cdkConnectedOverlayViewportMargin", "cdkConnectedOverlayScrollStrategy", "cdkConnectedOverlayOpen", "cdkConnectedOverlayDisableClose", "cdkConnectedOverlayTransformOriginOn", "cdkConnectedOverlayHasBackdrop", "cdkConnectedOverlayLockPosition", "cdkConnectedOverlayFlexibleDimensions", "cdkConnectedOverlayGrowAfterOpen", "cdkConnectedOverlayPush", "cdkConnectedOverlayDisposeOnNavigation"], outputs: ["backdropClick", "positionChange", "attach", "detach", "overlayKeydown", "overlayOutsideClick"], exportAs: ["cdkConnectedOverlay"] }, { kind: "component", type: GaSelectDefaultValueComponent, selector: "ga-select-default-value" }] });
1778
1780
  }
1779
1781
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.5", ngImport: i0, type: GaSelectComponent, decorators: [{
1780
1782
  type: Component,
@@ -1782,14 +1784,38 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.5", ngImpor
1782
1784
  GaIconModule,
1783
1785
  GaButtonModule,
1784
1786
  OverlayModule,
1785
- GaSelectTriggerComponent,
1786
- ], providers: [
1787
+ GaSelectDefaultValueComponent,
1788
+ ], hostDirectives: [CdkOverlayOrigin], providers: [
1787
1789
  {
1788
1790
  provide: NG_VALUE_ACCESSOR,
1789
1791
  useExisting: forwardRef(() => GaSelectComponent),
1790
1792
  multi: true,
1791
1793
  },
1792
- ], encapsulation: ViewEncapsulation.None, template: "<div cdkOverlayOrigin #trigger=\"cdkOverlayOrigin\">\n @if (explicitTrigger()) {\n <ng-content\n select=\"ga-select-custom-trigger, ga-select-trigger, ga-select-searchable-trigger\"\n />\n } @else {\n <ga-select-trigger />\n }\n</div>\n\n<ng-template\n cdkConnectedOverlay\n cdkConnectedOverlayLockPosition\n [cdkConnectedOverlayOrigin]=\"trigger\"\n [cdkConnectedOverlayOpen]=\"isOpen()\"\n [cdkConnectedOverlayPositions]=\"positions\"\n (overlayOutsideClick)=\"close()\"\n (attach)=\"onOverlayAttach()\"\n (detach)=\"onOverlayDetach()\"\n>\n <ng-content select=\"ga-select-content\" />\n</ng-template>\n", styles: ["ga-select{display:inline-block}\n"] }]
1794
+ {
1795
+ provide: GA_FORM_CONTROL,
1796
+ useExisting: forwardRef(() => GaSelectComponent),
1797
+ },
1798
+ ], host: {
1799
+ role: 'combobox',
1800
+ '[attr.id]': 'id()',
1801
+ class: 'ga-select',
1802
+ '[class.ga-select--expanded]': 'isOpen()',
1803
+ '[class.ga-select--disabled]': 'disabled()',
1804
+ '[class.ga-select--invalid]': 'invalid()',
1805
+ '[class.ga-select--empty]': '!hasValue()',
1806
+ 'aria-haspopup': 'listbox',
1807
+ '[attr.aria-expanded]': 'isOpen()',
1808
+ '[attr.aria-controls]': 'cdkListbox().id',
1809
+ '[attr.aria-invalid]': 'invalid()',
1810
+ '[attr.aria-disabled]': 'disabled()',
1811
+ '[attr.aria-owns]': 'searchable() ? cdkListbox().id : null',
1812
+ '[attr.aria-activedescendant]': '!searchable() ? activeDescendantId() : null',
1813
+ '[attr.tabindex]': 'disabled() ? -1 : 0',
1814
+ '(click)': 'toggle()',
1815
+ '(keydown.arrowdown)': 'open(); $event.preventDefault()',
1816
+ '(keydown.space)': 'open(); $event.preventDefault()',
1817
+ '(keydown.enter)': 'open(); $event.preventDefault()',
1818
+ }, template: "@if (leftIcon()) {\n <ga-icon [icon]=\"leftIcon()\" />\n}\n@if (searchable() && isOpen()) {\n <input\n #inputSearch\n type=\"text\"\n class=\"ga-select__input\"\n aria-autocomplete=\"list\"\n [value]=\"textValue()\"\n (input)=\"textValue.set(inputSearch.value)\"\n (click)=\"$event.stopPropagation()\"\n [attr.aria-expanded]=\"isOpen()\"\n [attr.aria-controls]=\"cdkListbox().id\"\n [attr.aria-activedescendant]=\"activeDescendantId()\"\n [placeholder]=\"placeholder()\"\n (keydown)=\"onInputKeyDown($event)\"\n tabindex=\"-1\"\n />\n} @else if (hasValue()) {\n <div class=\"ga-select__value\">\n @if (customSelectValue()) {\n <ng-content select=\"ga-select-value\" />\n } @else {\n <ga-select-default-value />\n }\n </div>\n} @else {\n <div class=\"ga-select__placeholder\">\n {{ placeholder() }}\n </div>\n}\n<ga-icon [icon]=\"menuStatusIcon()\" />\n\n<ng-template\n cdkConnectedOverlay\n cdkConnectedOverlayLockPosition\n [cdkConnectedOverlayOrigin]=\"overlayOrigin\"\n [cdkConnectedOverlayOpen]=\"isOpen()\"\n [cdkConnectedOverlayPositions]=\"positions\"\n (overlayOutsideClick)=\"close()\"\n (attach)=\"onOverlayAttach()\"\n (detach)=\"onOverlayDetach()\"\n>\n <ng-content select=\"ga-select-dropdown\" />\n</ng-template>\n" }]
1793
1819
  }], ctorParameters: () => [] });
1794
1820
 
1795
1821
  class GaOptgroupComponent {
@@ -1902,14 +1928,14 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.5", ngImpor
1902
1928
  }]
1903
1929
  }] });
1904
1930
 
1905
- class GaSelectContentLoadingComponent {
1906
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.5", ngImport: i0, type: GaSelectContentLoadingComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
1907
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.1.5", type: GaSelectContentLoadingComponent, isStandalone: true, selector: "ga-select-content-loading", host: { classAttribute: "ga-dropdown__content-spinner" }, ngImport: i0, template: `<ga-spinner size="16" />`, isInline: true, dependencies: [{ kind: "ngmodule", type: GaSpinnerModule }, { kind: "component", type: GaSpinnerComponent, selector: "ga-spinner", inputs: ["size"] }] });
1931
+ class GaSelectDropdownLoadingComponent {
1932
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.5", ngImport: i0, type: GaSelectDropdownLoadingComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
1933
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.1.5", type: GaSelectDropdownLoadingComponent, isStandalone: true, selector: "ga-select-dropdown-loader", host: { classAttribute: "ga-dropdown__content-spinner" }, ngImport: i0, template: `<ga-spinner size="16" />`, isInline: true, dependencies: [{ kind: "ngmodule", type: GaSpinnerModule }, { kind: "component", type: GaSpinnerComponent, selector: "ga-spinner", inputs: ["size"] }] });
1908
1934
  }
1909
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.5", ngImport: i0, type: GaSelectContentLoadingComponent, decorators: [{
1935
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.5", ngImport: i0, type: GaSelectDropdownLoadingComponent, decorators: [{
1910
1936
  type: Component,
1911
1937
  args: [{
1912
- selector: 'ga-select-content-loading',
1938
+ selector: 'ga-select-dropdown-loader',
1913
1939
  template: `<ga-spinner size="16" />`,
1914
1940
  imports: [GaSpinnerModule],
1915
1941
  host: {
@@ -1918,121 +1944,18 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.5", ngImpor
1918
1944
  }]
1919
1945
  }] });
1920
1946
 
1921
- class GaSelectContentComponent {
1947
+ class GaSelectDropdownComponent {
1922
1948
  loading = input(false, { transform: booleanAttribute });
1923
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.5", ngImport: i0, type: GaSelectContentComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
1924
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.1.5", type: GaSelectContentComponent, isStandalone: true, selector: "ga-select-content", inputs: { loading: { classPropertyName: "loading", publicName: "loading", isSignal: true, isRequired: false, transformFunction: null } }, host: { classAttribute: "ga-dropdown ga-dropdown__content" }, hostDirectives: [{ directive: i1$2.CdkListbox }], ngImport: i0, template: "@if (loading()) {\n <ga-select-content-loading />\n} @else {\n <ng-content />\n}\n", dependencies: [{ kind: "component", type: GaSelectContentLoadingComponent, selector: "ga-select-content-loading" }] });
1949
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.5", ngImport: i0, type: GaSelectDropdownComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
1950
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.1.5", type: GaSelectDropdownComponent, isStandalone: true, selector: "ga-select-dropdown", inputs: { loading: { classPropertyName: "loading", publicName: "loading", isSignal: true, isRequired: false, transformFunction: null } }, host: { classAttribute: "ga-dropdown ga-dropdown__content" }, hostDirectives: [{ directive: i1$2.CdkListbox }], ngImport: i0, template: "@if (loading()) {\n <ga-select-dropdown-loader />\n} @else {\n <ng-content />\n}\n", dependencies: [{ kind: "component", type: GaSelectDropdownLoadingComponent, selector: "ga-select-dropdown-loader" }] });
1925
1951
  }
1926
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.5", ngImport: i0, type: GaSelectContentComponent, decorators: [{
1952
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.5", ngImport: i0, type: GaSelectDropdownComponent, decorators: [{
1927
1953
  type: Component,
1928
- args: [{ selector: 'ga-select-content', imports: [GaSelectContentLoadingComponent], hostDirectives: [CdkListbox], host: {
1954
+ args: [{ selector: 'ga-select-dropdown', imports: [GaSelectDropdownLoadingComponent], hostDirectives: [CdkListbox], host: {
1929
1955
  class: 'ga-dropdown ga-dropdown__content',
1930
- }, template: "@if (loading()) {\n <ga-select-content-loading />\n} @else {\n <ng-content />\n}\n" }]
1956
+ }, template: "@if (loading()) {\n <ga-select-dropdown-loader />\n} @else {\n <ng-content />\n}\n" }]
1931
1957
  }] });
1932
1958
 
1933
- class GaSelectComboboxTriggerComponent {
1934
- injector = inject(Injector);
1935
- selectComponent = inject(GaSelectComponent);
1936
- content = viewChild('ngContent', { read: ElementRef });
1937
- inputSearch = viewChild('inputSearch');
1938
- hasCustomLabel = signal(false);
1939
- menuStatusIcon = computed(() => {
1940
- return this.selectComponent.isOpen() ? ChevronUp : ChevronDown;
1941
- });
1942
- textValue = model('');
1943
- leftIcon = input();
1944
- constructor() {
1945
- this.selectComponent.withoutAutoFocus.set(true);
1946
- this.selectComponent.opened.subscribe(() => {
1947
- afterNextRender(() => {
1948
- this.inputSearch().nativeElement.focus();
1949
- }, { injector: this.injector });
1950
- });
1951
- this.selectComponent.closed.subscribe(() => this.textValue.set(''));
1952
- }
1953
- ngAfterViewInit() {
1954
- this.checkIfHasCustomLabel();
1955
- }
1956
- checkIfHasCustomLabel() {
1957
- this.hasCustomLabel.set(!!this.content()?.nativeElement.children.length);
1958
- }
1959
- toggle() {
1960
- if (this.selectComponent.disabled()) {
1961
- return;
1962
- }
1963
- if (!this.selectComponent.isOpen()) {
1964
- this.open();
1965
- }
1966
- else {
1967
- this.selectComponent.close();
1968
- }
1969
- }
1970
- open() {
1971
- this.selectComponent.open();
1972
- }
1973
- onInputKeyDown(event) {
1974
- switch (event.code) {
1975
- case 'ArrowDown':
1976
- this.selectComponent.setNextItemActive();
1977
- event.preventDefault();
1978
- event.stopPropagation();
1979
- break;
1980
- case 'ArrowUp':
1981
- this.selectComponent.setPreviousItemActive();
1982
- event.preventDefault();
1983
- event.stopPropagation();
1984
- break;
1985
- case 'Space':
1986
- event.stopPropagation();
1987
- break;
1988
- case 'Enter':
1989
- this.selectComponent.setActiveItemAsSelected();
1990
- this.selectComponent.autoClose();
1991
- event.preventDefault();
1992
- event.stopPropagation();
1993
- break;
1994
- }
1995
- }
1996
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.5", ngImport: i0, type: GaSelectComboboxTriggerComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
1997
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.1.5", type: GaSelectComboboxTriggerComponent, isStandalone: true, selector: "ga-select-searchable-trigger", inputs: { textValue: { classPropertyName: "textValue", publicName: "textValue", isSignal: true, isRequired: false, transformFunction: null }, leftIcon: { classPropertyName: "leftIcon", publicName: "leftIcon", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { textValue: "textValueChange" }, host: { attributes: { "role": "combobox", "aria-haspopup": "listbox" }, listeners: { "click": "toggle()", "keydown.arrowdown": "open(); $event.preventDefault()", "keydown.space": "open(); $event.preventDefault()", "keydown.enter": "open(); $event.preventDefault()" }, properties: { "class.ga-select--expanded": "selectComponent.isOpen()", "class.ga-select--disabled": "selectComponent.disabled()", "class.ga-select--invalid": "selectComponent.invalid()", "class.ga-select--empty": "!selectComponent.hasValue()", "attr.aria-expanded": "selectComponent.isOpen()", "attr.aria-owns": "selectComponent.listboxId()", "attr.aria-invalid": "selectComponent.invalid()", "attr.aria-disabled": "selectComponent.disabled()", "attr.tabindex": "selectComponent.disabled() ? -1 : 0" }, classAttribute: "ga-select" }, providers: [
1998
- {
1999
- provide: GA_SELECT_TRIGGER,
2000
- useExisting: forwardRef(() => GaSelectComboboxTriggerComponent),
2001
- },
2002
- ], viewQueries: [{ propertyName: "content", first: true, predicate: ["ngContent"], descendants: true, read: ElementRef, isSignal: true }, { propertyName: "inputSearch", first: true, predicate: ["inputSearch"], descendants: true, isSignal: true }], ngImport: i0, template: "@if (leftIcon()) {\n <ga-icon [icon]=\"leftIcon()\" />\n}\n@if (selectComponent.isOpen()) {\n <input\n #inputSearch\n type=\"text\"\n class=\"ga-select__input\"\n aria-autocomplete=\"list\"\n [value]=\"textValue()\"\n (input)=\"textValue.set(inputSearch.value)\"\n (click)=\"$event.stopPropagation()\"\n [attr.aria-expanded]=\"selectComponent.isOpen()\"\n [attr.aria-controls]=\"selectComponent.listboxId()\"\n [attr.aria-activedescendant]=\"selectComponent.activeDescendantId()\"\n [placeholder]=\"selectComponent.placeholder()\"\n (keydown)=\"onInputKeyDown($event)\"\n tabindex=\"-1\"\n />\n} @else if (selectComponent.hasValue()) {\n <div class=\"ga-select__value\">\n <span #ngContent (cdkObserveContent)=\"checkIfHasCustomLabel()\">\n <ng-content />\n </span>\n @if (!hasCustomLabel()) {\n <ga-select-value />\n }\n </div>\n} @else {\n <div class=\"ga-select__placeholder\">\n {{ selectComponent.placeholder() }}\n </div>\n}\n<ga-icon [icon]=\"menuStatusIcon()\" />\n", dependencies: [{ kind: "ngmodule", type: GaInputModule }, { kind: "ngmodule", type: GaIconModule }, { kind: "component", type: GaIconComponent, selector: "ga-icon", inputs: ["icon", "size", "color", "strokeWidth"] }, { kind: "component", type: GaSelectValueComponent, selector: "ga-select-value" }, { kind: "ngmodule", type: ObserversModule }, { kind: "directive", type: i2.CdkObserveContent, selector: "[cdkObserveContent]", inputs: ["cdkObserveContentDisabled", "debounce"], outputs: ["cdkObserveContent"], exportAs: ["cdkObserveContent"] }] });
2003
- }
2004
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.5", ngImport: i0, type: GaSelectComboboxTriggerComponent, decorators: [{
2005
- type: Component,
2006
- args: [{ selector: 'ga-select-searchable-trigger', imports: [
2007
- GaInputModule,
2008
- GaIconModule,
2009
- GaSelectValueComponent,
2010
- ObserversModule,
2011
- ], providers: [
2012
- {
2013
- provide: GA_SELECT_TRIGGER,
2014
- useExisting: forwardRef(() => GaSelectComboboxTriggerComponent),
2015
- },
2016
- ], host: {
2017
- role: 'combobox',
2018
- class: 'ga-select',
2019
- '[class.ga-select--expanded]': 'selectComponent.isOpen()',
2020
- '[class.ga-select--disabled]': 'selectComponent.disabled()',
2021
- '[class.ga-select--invalid]': 'selectComponent.invalid()',
2022
- '[class.ga-select--empty]': '!selectComponent.hasValue()',
2023
- 'aria-haspopup': 'listbox',
2024
- '[attr.aria-expanded]': 'selectComponent.isOpen()',
2025
- '[attr.aria-owns]': 'selectComponent.listboxId()',
2026
- '[attr.aria-invalid]': 'selectComponent.invalid()',
2027
- '[attr.aria-disabled]': 'selectComponent.disabled()',
2028
- '[attr.tabindex]': 'selectComponent.disabled() ? -1 : 0',
2029
- '(click)': 'toggle()',
2030
- '(keydown.arrowdown)': 'open(); $event.preventDefault()',
2031
- '(keydown.space)': 'open(); $event.preventDefault()',
2032
- '(keydown.enter)': 'open(); $event.preventDefault()',
2033
- }, template: "@if (leftIcon()) {\n <ga-icon [icon]=\"leftIcon()\" />\n}\n@if (selectComponent.isOpen()) {\n <input\n #inputSearch\n type=\"text\"\n class=\"ga-select__input\"\n aria-autocomplete=\"list\"\n [value]=\"textValue()\"\n (input)=\"textValue.set(inputSearch.value)\"\n (click)=\"$event.stopPropagation()\"\n [attr.aria-expanded]=\"selectComponent.isOpen()\"\n [attr.aria-controls]=\"selectComponent.listboxId()\"\n [attr.aria-activedescendant]=\"selectComponent.activeDescendantId()\"\n [placeholder]=\"selectComponent.placeholder()\"\n (keydown)=\"onInputKeyDown($event)\"\n tabindex=\"-1\"\n />\n} @else if (selectComponent.hasValue()) {\n <div class=\"ga-select__value\">\n <span #ngContent (cdkObserveContent)=\"checkIfHasCustomLabel()\">\n <ng-content />\n </span>\n @if (!hasCustomLabel()) {\n <ga-select-value />\n }\n </div>\n} @else {\n <div class=\"ga-select__placeholder\">\n {{ selectComponent.placeholder() }}\n </div>\n}\n<ga-icon [icon]=\"menuStatusIcon()\" />\n" }]
2034
- }], ctorParameters: () => [] });
2035
-
2036
1959
  const GA_SELECT_REQUIRED_VALIDATOR = {
2037
1960
  provide: NG_VALIDATORS,
2038
1961
  useExisting: forwardRef(() => GaSelectRequiredValidator),
@@ -2055,24 +1978,18 @@ class GaSelectModule {
2055
1978
  static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.1.5", ngImport: i0, type: GaSelectModule, imports: [GaSelectComponent,
2056
1979
  GaOptionComponent,
2057
1980
  GaOptgroupComponent,
2058
- GaSelectContentComponent,
2059
- GaSelectCustomTriggerComponent,
2060
- GaSelectTriggerComponent,
2061
- GaSelectComboboxTriggerComponent,
2062
- GaSelectContentLoadingComponent,
1981
+ GaSelectDropdownComponent,
1982
+ GaSelectDropdownLoadingComponent,
1983
+ GaSelectValueComponent,
2063
1984
  GaSelectRequiredValidator], exports: [GaSelectComponent,
2064
1985
  GaOptionComponent,
2065
1986
  GaOptgroupComponent,
2066
- GaSelectContentComponent,
2067
- GaSelectCustomTriggerComponent,
2068
- GaSelectComboboxTriggerComponent,
2069
- GaSelectTriggerComponent,
2070
- GaSelectContentLoadingComponent,
1987
+ GaSelectDropdownComponent,
1988
+ GaSelectDropdownLoadingComponent,
1989
+ GaSelectValueComponent,
2071
1990
  GaSelectRequiredValidator] });
2072
1991
  static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.1.5", ngImport: i0, type: GaSelectModule, imports: [GaSelectComponent,
2073
- GaOptionComponent,
2074
- GaSelectTriggerComponent,
2075
- GaSelectComboboxTriggerComponent] });
1992
+ GaOptionComponent] });
2076
1993
  }
2077
1994
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.5", ngImport: i0, type: GaSelectModule, decorators: [{
2078
1995
  type: NgModule,
@@ -2081,22 +1998,18 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.5", ngImpor
2081
1998
  GaSelectComponent,
2082
1999
  GaOptionComponent,
2083
2000
  GaOptgroupComponent,
2084
- GaSelectContentComponent,
2085
- GaSelectCustomTriggerComponent,
2086
- GaSelectTriggerComponent,
2087
- GaSelectComboboxTriggerComponent,
2088
- GaSelectContentLoadingComponent,
2001
+ GaSelectDropdownComponent,
2002
+ GaSelectDropdownLoadingComponent,
2003
+ GaSelectValueComponent,
2089
2004
  GaSelectRequiredValidator,
2090
2005
  ],
2091
2006
  exports: [
2092
2007
  GaSelectComponent,
2093
2008
  GaOptionComponent,
2094
2009
  GaOptgroupComponent,
2095
- GaSelectContentComponent,
2096
- GaSelectCustomTriggerComponent,
2097
- GaSelectComboboxTriggerComponent,
2098
- GaSelectTriggerComponent,
2099
- GaSelectContentLoadingComponent,
2010
+ GaSelectDropdownComponent,
2011
+ GaSelectDropdownLoadingComponent,
2012
+ GaSelectValueComponent,
2100
2013
  GaSelectRequiredValidator,
2101
2014
  ],
2102
2015
  }]
@@ -2110,5 +2023,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.1.5", ngImpor
2110
2023
  * Generated bundle index. Do not edit.
2111
2024
  */
2112
2025
 
2113
- export { CHECKBOX_CONTROL_VALUE_ACCESSOR, GA_ALERT_I18N_FACTORY, GA_CHECKBOX_REQUIRED_VALIDATOR, GA_FORM_CONTROL, GA_SELECT_REQUIRED_VALIDATOR, GA_TOOLTIP_DEFAULT_OFFSET, GaAlertComponent, GaAlertI18n, GaAlertI18nDefault, GaAlertModule, GaAlertTitleActionsComponent, GaAlertTitleComponent, GaBadgeComponent, GaBadgeModule, GaButtonDirective, GaButtonModule, GaCardComponent, GaCardModule, GaCheckboxComponent, GaCheckboxModule, GaCheckboxRequiredValidator, GaFieldInfoComponent, GaFieldLabelComponent, GaFormControlDirective, GaFormFieldComponent, GaFormFieldModule, GaIconButtonDirective, GaIconComponent, GaIconModule, GaInputComponent, GaInputDirective, GaInputModule, GaMenuComponent, GaMenuItemComponent, GaMenuModule, GaMenuSeparatorComponent, GaMenuTitleComponent, GaMenuTriggerDirective, GaMenuTriggerIconComponent, GaOptgroupComponent, GaOptionComponent, GaRadioButtonComponent, GaRadioGroupComponent, GaRadioModule, GaSegmentedControlButtonDirective, GaSegmentedControlComponent, GaSegmentedControlModule, GaSelectComboboxTriggerComponent, GaSelectComponent, GaSelectContentComponent, GaSelectContentLoadingComponent, GaSelectCustomTriggerComponent, GaSelectModule, GaSelectRequiredValidator, GaSelectTriggerComponent, GaSpinnerComponent, GaSpinnerModule, GaTooltipComponent, GaTooltipDirective, GaTooltipModule, RADIO_CONTROL_VALUE_ACCESSOR, provideGaAlertI18n };
2026
+ export { CHECKBOX_CONTROL_VALUE_ACCESSOR, GA_ALERT_I18N_FACTORY, GA_CHECKBOX_REQUIRED_VALIDATOR, GA_FORM_CONTROL, GA_SELECT_REQUIRED_VALIDATOR, GA_TOOLTIP_DEFAULT_OFFSET, GaAlertComponent, GaAlertI18n, GaAlertI18nDefault, GaAlertModule, GaAlertTitleActionsComponent, GaAlertTitleComponent, GaBadgeComponent, GaBadgeModule, GaButtonDirective, GaButtonModule, GaCardComponent, GaCardModule, GaCheckboxComponent, GaCheckboxModule, GaCheckboxRequiredValidator, GaFieldInfoComponent, GaFieldLabelComponent, GaFormControlDirective, GaFormFieldComponent, GaFormFieldModule, GaIconButtonDirective, GaIconComponent, GaIconModule, GaInputComponent, GaInputDirective, GaInputModule, GaMenuComponent, GaMenuItemComponent, GaMenuModule, GaMenuSeparatorComponent, GaMenuTitleComponent, GaMenuTriggerDirective, GaMenuTriggerIconComponent, GaOptgroupComponent, GaOptionComponent, GaRadioButtonComponent, GaRadioGroupComponent, GaRadioModule, GaSegmentedControlButtonDirective, GaSegmentedControlComponent, GaSegmentedControlModule, GaSelectComponent, GaSelectDropdownComponent, GaSelectDropdownLoadingComponent, GaSelectModule, GaSelectRequiredValidator, GaSelectValueComponent, GaSpinnerComponent, GaSpinnerModule, GaTooltipComponent, GaTooltipDirective, GaTooltipModule, RADIO_CONTROL_VALUE_ACCESSOR, provideGaAlertI18n };
2114
2027
  //# sourceMappingURL=vsn-ux-ngx-gaia.mjs.map