@@ -21,6 +21,16 @@ import { Menu, MenuProps, DropdownMenuItemProps } from './Menu';
21
21
import { Coords , getAdjustedCoords } from './getAdjustedCoords' ;
22
22
import { IconButton } from '../buttons/IconButton/IconButton' ;
23
23
import { focusStyleTransition , getFocusShadowStyle } from '../../utils/utils' ;
24
+ import {
25
+ FrameProps ,
26
+ FramePropsKeys ,
27
+ pickAndPrepareFrameProps ,
28
+ withFrameProps ,
29
+ } from '../../utils/frameProps' ;
30
+ import { TransientProps } from '../../utils/transientProps' ;
31
+
32
+ export const allowedDropdownFrameProps = [ 'width' ] as const satisfies FramePropsKeys [ ] ;
33
+ type AllowedFrameProps = Pick < FrameProps , ( typeof allowedDropdownFrameProps ) [ number ] > ;
24
34
25
35
const MoreIcon = styled ( IconButton ) < { $isToggled : boolean } > `
26
36
background: ${ ( { isDisabled, $isToggled, theme } ) =>
@@ -31,7 +41,9 @@ const MoreIcon = styled(IconButton)<{ $isToggled: boolean }>`
31
41
}
32
42
` ;
33
43
34
- const Container = styled . div < { $disabled ?: boolean ; $hasCustomChildren : boolean } > `
44
+ const Container = styled . div <
45
+ { $disabled ?: boolean ; $hasCustomChildren : boolean } & TransientProps < AllowedFrameProps >
46
+ > `
35
47
all: unset;
36
48
width: fit-content;
37
49
height: fit-content;
@@ -40,6 +52,8 @@ const Container = styled.div<{ $disabled?: boolean; $hasCustomChildren: boolean
40
52
${ getFocusShadowStyle ( ) } ;
41
53
cursor: ${ ( { $disabled } ) => ( $disabled ? 'default' : 'pointer' ) } ;
42
54
55
+ ${ withFrameProps }
56
+
43
57
${ ( { $hasCustomChildren } ) =>
44
58
$hasCustomChildren
45
59
? undefined
@@ -75,14 +89,15 @@ const getPlacementData = (
75
89
return { coordsToUse, toggleDimensions } ;
76
90
} ;
77
91
78
- export type DropdownProps = Omit < MenuProps , 'setToggled' > & {
79
- isDisabled ?: boolean ;
80
- renderOnClickPosition ?: boolean ;
81
- onToggle ?: ( isToggled : boolean ) => void ;
82
- className ?: string ;
83
- 'data-testid' ?: string ;
84
- children ?: ( ( isToggled : boolean ) => ReactElement < any > ) | ReactElement < any > ;
85
- } ;
92
+ export type DropdownProps = Omit < MenuProps , 'setToggled' > &
93
+ AllowedFrameProps & {
94
+ isDisabled ?: boolean ;
95
+ renderOnClickPosition ?: boolean ;
96
+ onToggle ?: ( isToggled : boolean ) => void ;
97
+ className ?: string ;
98
+ 'data-testid' ?: string ;
99
+ children ?: ( ( isToggled : boolean ) => ReactElement < any > ) | ReactElement < any > ;
100
+ } ;
86
101
87
102
export interface DropdownRef {
88
103
close : ( ) => void ;
@@ -106,6 +121,7 @@ export const Dropdown = forwardRef(
106
121
className,
107
122
children,
108
123
'data-testid' : dataTest ,
124
+ ...rest
109
125
} : DropdownProps ,
110
126
ref ,
111
127
) => {
@@ -230,6 +246,8 @@ export const Dropdown = forwardRef(
230
246
document . body ,
231
247
) ;
232
248
249
+ const frameProps = pickAndPrepareFrameProps ( rest , allowedDropdownFrameProps ) ;
250
+
233
251
return (
234
252
< Container
235
253
ref = { toggleRef }
@@ -240,6 +258,7 @@ export const Dropdown = forwardRef(
240
258
onFocus = { ( ) => ! isDisabled && ! renderOnClickPosition && setToggled ( true ) }
241
259
onBlur = { e => ! menuRef . current ?. contains ( e . relatedTarget ) && setToggled ( false ) }
242
260
$hasCustomChildren = { hasCustomChildren }
261
+ { ...frameProps }
243
262
>
244
263
{ ToggleComponent }
245
264
{ isToggled && PortalMenu }
0 commit comments