|
6 | 6 | * found in the LICENSE file at https://angular.dev/license |
7 | 7 | */ |
8 | 8 |
|
9 | | -import {Directive, input} from '@angular/core'; |
| 9 | +import {contentChild, Directive, inject} from '@angular/core'; |
| 10 | +import {DeferredContent, DeferredContentAware} from '@angular/cdk-experimental/deferred-content'; |
| 11 | + |
| 12 | +@Directive({ |
| 13 | + selector: '[cdkCombobox]', |
| 14 | + exportAs: 'cdkCombobox', |
| 15 | + hostDirectives: [ |
| 16 | + { |
| 17 | + directive: DeferredContentAware, |
| 18 | + inputs: ['preserveContent'], |
| 19 | + }, |
| 20 | + ], |
| 21 | +}) |
| 22 | +export class CdkCombobox { |
| 23 | + /** The DeferredContentAware host directive. */ |
| 24 | + private readonly _deferredContentAware = inject(DeferredContentAware, {optional: true}); |
| 25 | + |
| 26 | + /** The combobox popup. */ |
| 27 | + readonly popup = contentChild(CdkComboboxPopup); |
| 28 | + |
| 29 | + constructor() { |
| 30 | + this._deferredContentAware?.contentVisible.set(true); |
| 31 | + } |
| 32 | +} |
10 | 33 |
|
11 | 34 | @Directive({ |
12 | 35 | selector: 'input[cdkComboboxInput]', |
13 | 36 | exportAs: 'cdkComboboxInput', |
14 | 37 | host: {'role': 'combobox'}, |
15 | 38 | }) |
16 | | -export class CdkComboboxInput { |
17 | | - readonly popup = input.required<CdkComboboxPopup>(); |
18 | | -} |
| 39 | +export class CdkComboboxInput {} |
| 40 | + |
| 41 | +@Directive({ |
| 42 | + selector: 'ng-template[cdkComboboxPopupContent]', |
| 43 | + exportAs: 'cdkComboboxPopupContent', |
| 44 | + hostDirectives: [DeferredContent], |
| 45 | +}) |
| 46 | +export class CdkComboboxPopupContent {} |
19 | 47 |
|
20 | 48 | @Directive({ |
21 | 49 | selector: '[cdkComboboxPopup]', |
22 | 50 | exportAs: 'cdkComboboxPopup', |
23 | 51 | }) |
24 | | -export class CdkComboboxPopup {} |
| 52 | +export class CdkComboboxPopup { |
| 53 | + /** The combobox that the popup belongs to. */ |
| 54 | + readonly combobox = inject(CdkCombobox, {optional: true}); |
| 55 | +} |
0 commit comments