@@ -11,14 +11,10 @@ import {KeyboardEventManager, PointerEventManager, Modifier} from '../behaviors/
1111import { computed , signal } from '@angular/core' ;
1212import { SignalLike } from '../behaviors/signal-like/signal-like' ;
1313import { List , ListInputs } from '../behaviors/list/list' ;
14- import { ComboboxPattern , ComboboxPopupControls } from '../combobox/combobox' ;
1514
1615/** Represents the required inputs for a listbox. */
1716export type ListboxInputs < V > = ListInputs < OptionPattern < V > , V > & {
1817 readonly : SignalLike < boolean > ;
19-
20- /** The combobox controlling the listbox. */
21- combobox : SignalLike < ComboboxPattern < OptionPattern < V > , V > | undefined > ;
2218} ;
2319
2420/** Controls the state of a listbox. */
@@ -35,7 +31,7 @@ export class ListboxPattern<V> {
3531 readonly : SignalLike < boolean > ;
3632
3733 /** The tabindex of the listbox. */
38- tabindex = computed ( ( ) => ( this . inputs . combobox ( ) ? - 1 : this . listBehavior . tabindex ( ) ) ) ;
34+ tabindex : SignalLike < - 1 | 0 > = computed ( ( ) => this . listBehavior . tabindex ( ) ) ;
3935
4036 /** The id of the current active item. */
4137 activedescendant = computed ( ( ) => this . listBehavior . activedescendant ( ) ) ;
@@ -192,12 +188,6 @@ export class ListboxPattern<V> {
192188 this . readonly = inputs . readonly ;
193189 this . orientation = inputs . orientation ;
194190 this . multi = inputs . multi ;
195-
196- if ( this . inputs . combobox ( ) ) {
197- this . inputs . focusMode = ( ) => 'activedescendant' ;
198- this . inputs . element = this . inputs . combobox ( ) ! . inputs . inputEl ;
199- }
200-
201191 this . listBehavior = new List ( inputs ) ;
202192 }
203193
@@ -224,13 +214,13 @@ export class ListboxPattern<V> {
224214
225215 /** Handles keydown events for the listbox. */
226216 onKeydown ( event : KeyboardEvent ) {
227- if ( ! this . disabled ( ) && ! this . inputs . combobox ( ) ) {
217+ if ( ! this . disabled ( ) ) {
228218 this . keydown ( ) . handle ( event ) ;
229219 }
230220 }
231221
232222 onPointerdown ( event : PointerEvent ) {
233- if ( ! this . disabled ( ) && ! this . inputs . combobox ( ) ) {
223+ if ( ! this . disabled ( ) ) {
234224 this . pointerdown ( ) . handle ( event ) ;
235225 }
236226 }
@@ -246,10 +236,6 @@ export class ListboxPattern<V> {
246236 * is called.
247237 */
248238 setDefaultState ( ) {
249- if ( this . inputs . combobox ( ) ) {
250- return ;
251- }
252-
253239 let firstItem : OptionPattern < V > | null = null ;
254240
255241 for ( const item of this . inputs . items ( ) ) {
@@ -269,39 +255,12 @@ export class ListboxPattern<V> {
269255 }
270256 }
271257
272- private _getItem ( e : PointerEvent ) {
258+ protected _getItem ( e : PointerEvent ) {
273259 if ( ! ( e . target instanceof HTMLElement ) ) {
274260 return ;
275261 }
276262
277263 const element = e . target . closest ( '[role="option"]' ) ;
278264 return this . inputs . items ( ) . find ( i => i . element ( ) === element ) ;
279265 }
280-
281- /** The actions that can be performed on a combobox popup listbox. */
282- comboboxActions : ComboboxPopupControls < OptionPattern < V > , V > = {
283- activeId : computed ( ( ) => this . listBehavior . activedescendant ( ) ) ,
284-
285- next : ( ) => this . listBehavior . next ( ) ,
286- prev : ( ) => this . listBehavior . prev ( ) ,
287- last : ( ) => this . listBehavior . last ( ) ,
288- first : ( ) => this . listBehavior . first ( ) ,
289- unfocus : ( ) => this . listBehavior . unfocus ( ) ,
290- select : item => this . listBehavior . select ( item ) ,
291- clearSelection : ( ) => this . listBehavior . deselectAll ( ) ,
292-
293- getItem : e => this . _getItem ( e ) ,
294- getSelectedItem : ( ) => this . inputs . items ( ) . find ( i => i . selected ( ) ) ,
295-
296- setValue : ( value : V | undefined ) => this . inputs . value . set ( value ? [ value ] : [ ] ) ,
297-
298- filter : ( text : string ) => {
299- const filterFn = this . inputs . combobox ( ) ! . inputs . filter ( ) ;
300-
301- this . inputs . items ( ) . forEach ( i => {
302- const isMatch = filterFn ( text , i . searchTerm ( ) ) ;
303- i . inert . set ( isMatch ? null : true ) ;
304- } ) ;
305- } ,
306- } ;
307266}
0 commit comments