@@ -6,32 +6,39 @@ import {
6
6
} from '@builder.io/qwik' ;
7
7
import {
8
8
ReferenceElement ,
9
+ arrow ,
9
10
autoUpdate ,
10
11
computePosition ,
11
12
flip ,
12
13
offset ,
14
+ shift ,
13
15
} from '@floating-ui/dom' ;
14
16
import ComboboxContextId from './combobox-context-id' ;
15
17
import type { ComboboxContext , Option } from './combobox-context.type' ;
16
18
19
+ // type ArrowData = { element: HTMLElement; padding?: number | undefined };
20
+
17
21
export type ComboboxListboxProps = {
18
- shift ?: {
22
+ // come back to shift later
23
+ arrowData ?: { element : HTMLElement ; padding ?: number | undefined } ;
24
+ setArrow ?: boolean ;
25
+ setShift ?: {
19
26
mainAxis ?: boolean ;
20
27
crossAxis ?: boolean ;
21
28
limiter ?: {
22
29
fn : ( state : unknown ) => unknown ;
23
30
options ?: unknown ;
24
31
} ;
25
32
} ;
26
- gap ?:
33
+ setOffset ?:
27
34
| number
28
35
| {
29
36
mainAxis ?: number ;
30
37
crossAxis ?: number ;
31
38
alignmentAxis ?: number | null ;
32
39
} ;
33
- toggleFlip ?: boolean ;
34
- position ?:
40
+ setFlip ?: boolean ;
41
+ placement ?:
35
42
| 'top'
36
43
| 'top-start'
37
44
| 'top-end'
@@ -53,9 +60,12 @@ export type ComboboxListboxProps = {
53
60
54
61
export const ComboboxListbox = component$ (
55
62
< O extends Option = Option > ( {
56
- gap,
57
- toggleFlip = true ,
58
- position = 'bottom' ,
63
+ setOffset,
64
+ setFlip = true ,
65
+ placement = 'bottom' ,
66
+ setShift,
67
+ setArrow,
68
+ arrowData,
59
69
ancestorScroll = true ,
60
70
ancestorResize = true ,
61
71
elementResize = true ,
@@ -68,12 +78,18 @@ export const ComboboxListbox = component$(
68
78
useVisibleTask$ ( function setListboxPosition ( { cleanup } ) {
69
79
// Our settings from Floating UI
70
80
function updatePosition ( ) {
81
+ const middleware = [ offset ( setOffset ) , setFlip && flip ( ) , setShift && shift ( ) ] ;
82
+
83
+ if ( setArrow && arrowData ) {
84
+ middleware . push ( arrow ( arrowData ) ) ;
85
+ }
86
+
71
87
computePosition (
72
88
context . inputRef . value as ReferenceElement ,
73
89
context . listboxRef . value as HTMLElement ,
74
90
{
75
- placement : position ,
76
- middleware : [ offset ( gap ) , toggleFlip && flip ( ) ] ,
91
+ placement : placement ,
92
+ middleware : middleware ,
77
93
} ,
78
94
) . then ( ( { x, y } ) => {
79
95
if ( context . listboxRef . value ) {
0 commit comments