@@ -11,14 +11,10 @@ import {KeyboardEventManager, PointerEventManager, Modifier} from '../behaviors/
11
11
import { computed , signal } from '@angular/core' ;
12
12
import { SignalLike } from '../behaviors/signal-like/signal-like' ;
13
13
import { List , ListInputs } from '../behaviors/list/list' ;
14
- import { ComboboxPattern , ComboboxPopupControls } from '../combobox/combobox' ;
15
14
16
15
/** Represents the required inputs for a listbox. */
17
16
export type ListboxInputs < V > = ListInputs < OptionPattern < V > , V > & {
18
17
readonly : SignalLike < boolean > ;
19
-
20
- /** The combobox controlling the listbox. */
21
- combobox : SignalLike < ComboboxPattern < OptionPattern < V > , V > | undefined > ;
22
18
} ;
23
19
24
20
/** Controls the state of a listbox. */
@@ -35,7 +31,7 @@ export class ListboxPattern<V> {
35
31
readonly : SignalLike < boolean > ;
36
32
37
33
/** The tabindex of the listbox. */
38
- tabindex = computed ( ( ) => ( this . inputs . combobox ( ) ? - 1 : this . listBehavior . tabindex ( ) ) ) ;
34
+ tabindex : SignalLike < - 1 | 0 > = computed ( ( ) => this . listBehavior . tabindex ( ) ) ;
39
35
40
36
/** The id of the current active item. */
41
37
activedescendant = computed ( ( ) => this . listBehavior . activedescendant ( ) ) ;
@@ -192,12 +188,6 @@ export class ListboxPattern<V> {
192
188
this . readonly = inputs . readonly ;
193
189
this . orientation = inputs . orientation ;
194
190
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
-
201
191
this . listBehavior = new List ( inputs ) ;
202
192
}
203
193
@@ -224,13 +214,13 @@ export class ListboxPattern<V> {
224
214
225
215
/** Handles keydown events for the listbox. */
226
216
onKeydown ( event : KeyboardEvent ) {
227
- if ( ! this . disabled ( ) && ! this . inputs . combobox ( ) ) {
217
+ if ( ! this . disabled ( ) ) {
228
218
this . keydown ( ) . handle ( event ) ;
229
219
}
230
220
}
231
221
232
222
onPointerdown ( event : PointerEvent ) {
233
- if ( ! this . disabled ( ) && ! this . inputs . combobox ( ) ) {
223
+ if ( ! this . disabled ( ) ) {
234
224
this . pointerdown ( ) . handle ( event ) ;
235
225
}
236
226
}
@@ -246,10 +236,6 @@ export class ListboxPattern<V> {
246
236
* is called.
247
237
*/
248
238
setDefaultState ( ) {
249
- if ( this . inputs . combobox ( ) ) {
250
- return ;
251
- }
252
-
253
239
let firstItem : OptionPattern < V > | null = null ;
254
240
255
241
for ( const item of this . inputs . items ( ) ) {
@@ -269,39 +255,12 @@ export class ListboxPattern<V> {
269
255
}
270
256
}
271
257
272
- private _getItem ( e : PointerEvent ) {
258
+ protected _getItem ( e : PointerEvent ) {
273
259
if ( ! ( e . target instanceof HTMLElement ) ) {
274
260
return ;
275
261
}
276
262
277
263
const element = e . target . closest ( '[role="option"]' ) ;
278
264
return this . inputs . items ( ) . find ( i => i . element ( ) === element ) ;
279
265
}
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
- } ;
307
266
}
0 commit comments