@@ -14,11 +14,11 @@ import {
14
14
inject ,
15
15
input ,
16
16
model ,
17
+ OnDestroy ,
17
18
signal ,
18
19
} from '@angular/core' ;
19
- import { Option } from '../ui-patterns/listbox/option' ;
20
- import { ListboxInputs , ListboxPattern } from '../ui-patterns/listbox/listbox' ;
21
20
import { Directionality } from '@angular/cdk/bidi' ;
21
+ import { ListboxInputs , ListboxPattern , OptionPattern } from '@angular/cdk-experimental/ui-patterns' ;
22
22
import { startWith , takeUntil } from 'rxjs/operators' ;
23
23
import { Subject } from 'rxjs' ;
24
24
@@ -40,7 +40,7 @@ import {Subject} from 'rxjs';
40
40
// '(focusin)': '_handleFocusIn()',
41
41
} ,
42
42
} )
43
- export class CdkListbox implements ListboxInputs {
43
+ export class CdkListbox implements ListboxInputs , OnDestroy {
44
44
/** Whether the list is vertically or horizontally oriented. */
45
45
orientation = input < 'vertical' | 'horizontal' > ( 'vertical' ) ;
46
46
@@ -69,31 +69,31 @@ export class CdkListbox implements ListboxInputs {
69
69
activeIndex = model < number > ( 0 ) ;
70
70
71
71
/** The CdkOptions nested inside of the CdkListbox. */
72
- private cdkOptions = contentChildren ( CdkOption , { descendants : true } ) ;
72
+ private _cdkOptions = contentChildren ( CdkOption , { descendants : true } ) ;
73
73
74
74
/** The Option UIPatterns of the child CdkOptions. */
75
- items = computed ( ( ) => this . cdkOptions ( ) . map ( option => option . state ) ) ;
75
+ items = computed ( ( ) => this . _cdkOptions ( ) . map ( option => option . state ) ) ;
76
76
77
77
/** The directionality (LTR / RTL) context for the application (or a subtree of it). */
78
- private dir = inject ( Directionality ) ;
78
+ private _dir = inject ( Directionality ) ;
79
79
80
80
/** A signal wrapper for directionality. */
81
81
directionality = signal < 'rtl' | 'ltr' > ( 'rtl' ) ;
82
82
83
83
/** Emits when the list has been destroyed. */
84
- private readonly destroyed = new Subject < void > ( ) ;
84
+ private readonly _destroyed = new Subject < void > ( ) ;
85
85
86
86
/** The Listbox UIPattern. */
87
87
state : ListboxPattern = new ListboxPattern ( this ) ;
88
88
89
89
constructor ( ) {
90
- this . dir . change
91
- . pipe ( startWith ( this . dir . value ) , takeUntil ( this . destroyed ) )
90
+ this . _dir . change
91
+ . pipe ( startWith ( this . _dir . value ) , takeUntil ( this . _destroyed ) )
92
92
. subscribe ( value => this . directionality . set ( value ) ) ;
93
93
}
94
94
95
95
ngOnDestroy ( ) {
96
- this . destroyed . complete ( ) ;
96
+ this . _destroyed . complete ( ) ;
97
97
}
98
98
}
99
99
@@ -122,16 +122,16 @@ export class CdkOption {
122
122
searchTerm = computed ( ( ) => this . label ( ) ?? this . element ( ) . textContent ) ;
123
123
124
124
/** A reference to the option element. */
125
- private elementRef = inject ( ElementRef ) ;
125
+ private _elementRef = inject ( ElementRef ) ;
126
126
127
- element = computed ( ( ) => this . elementRef . nativeElement ) ;
127
+ element = computed ( ( ) => this . _elementRef . nativeElement ) ;
128
128
129
129
/** The parent CdkListbox. */
130
- private cdkListbox = inject ( CdkListbox ) ;
130
+ private _cdkListbox = inject ( CdkListbox ) ;
131
131
132
132
/** The parent Listbox UIPattern. */
133
- listbox = computed ( ( ) => this . cdkListbox . state ) ;
133
+ listbox = computed ( ( ) => this . _cdkListbox . state ) ;
134
134
135
135
/** The Option UIPattern. */
136
- state : Option = new Option ( this ) ;
136
+ state = new OptionPattern ( this ) ;
137
137
}
0 commit comments