@@ -67,7 +67,12 @@ export interface PickerStyleProps {
67
67
*
68
68
* @default 'M'
69
69
*/
70
- size ?: 'S' | 'M' | 'L' | 'XL'
70
+ size ?: 'S' | 'M' | 'L' | 'XL' ,
71
+ /**
72
+ * Whether the picker should be displayed with a quiet style.
73
+ * @private
74
+ */
75
+ isQuiet ?: boolean
71
76
}
72
77
73
78
export interface PickerProps < T extends object > extends
@@ -101,6 +106,9 @@ interface PickerButtonProps extends PickerStyleProps, ButtonRenderProps {}
101
106
const inputButton = style < PickerButtonProps | AriaSelectRenderProps > ( {
102
107
...focusRing ( ) ,
103
108
...fieldInput ( ) ,
109
+ outlineStyle : {
110
+ isQuiet : 'none'
111
+ } ,
104
112
position : 'relative' ,
105
113
font : 'control' ,
106
114
display : 'flex' ,
@@ -110,19 +118,42 @@ const inputButton = style<PickerButtonProps | AriaSelectRenderProps>({
110
118
alignItems : 'center' ,
111
119
height : 'control' ,
112
120
transition : 'default' ,
113
- columnGap : 'text-to-control' ,
114
- paddingX : 'edge-to-text' ,
121
+ columnGap : {
122
+ default : 'text-to-control' ,
123
+ isQuiet : 'text-to-visual'
124
+ } ,
125
+ paddingX : {
126
+ default : 'edge-to-text' ,
127
+ isQuiet : 0
128
+ } ,
115
129
backgroundColor : {
116
130
default : baseColor ( 'gray-100' ) ,
117
131
isOpen : 'gray-200' ,
118
- isDisabled : 'disabled'
132
+ isDisabled : 'disabled' ,
133
+ isQuiet : 'transparent'
119
134
} ,
120
135
color : {
121
136
default : 'neutral' ,
122
137
isDisabled : 'disabled'
138
+ } ,
139
+ maxWidth : {
140
+ isQuiet : 'max'
123
141
}
124
142
} ) ;
125
143
144
+ const quietFocusLine = style ( {
145
+ width : 'full' ,
146
+ // Use pixels since we are emulating a border.
147
+ height : `[2px]` ,
148
+ position : 'absolute' ,
149
+ bottom : 0 ,
150
+ borderRadius : 'full' ,
151
+ backgroundColor : {
152
+ default : 'blue-800' ,
153
+ forcedColors : 'Highlight'
154
+ }
155
+ } )
156
+
126
157
export let menu = style ( {
127
158
outlineStyle : 'none' ,
128
159
display : 'grid' ,
@@ -157,7 +188,10 @@ const invalidBorder = style({
157
188
} ) ;
158
189
159
190
const valueStyles = style ( {
160
- flexGrow : 1 ,
191
+ flexGrow : {
192
+ default : 1 ,
193
+ isQuiet : 0
194
+ } ,
161
195
truncate : true ,
162
196
display : 'flex' ,
163
197
alignItems : 'center'
@@ -195,7 +229,8 @@ function Picker<T extends object>(props: PickerProps<T>, ref: FocusableRef<HTMLB
195
229
necessityIndicator,
196
230
UNSAFE_className = '' ,
197
231
UNSAFE_style,
198
- placeholder = 'Select an option...' ,
232
+ placeholder = 'Select...' ,
233
+ isQuiet,
199
234
...pickerProps
200
235
} = props ;
201
236
@@ -221,7 +256,7 @@ function Picker<T extends object>(props: PickerProps<T>, ref: FocusableRef<HTMLB
221
256
labelPosition,
222
257
size
223
258
} , props . styles ) } >
224
- { ( { isDisabled, isOpen, isInvalid, isRequired} ) => (
259
+ { ( { isDisabled, isOpen, isFocusVisible , isInvalid, isRequired} ) => (
225
260
< >
226
261
< InternalPickerContext . Provider value = { { size} } >
227
262
< FieldLabel
@@ -230,6 +265,7 @@ function Picker<T extends object>(props: PickerProps<T>, ref: FocusableRef<HTMLB
230
265
size = { size }
231
266
labelPosition = { labelPosition }
232
267
labelAlign = { labelAlign }
268
+ isQuiet = { isQuiet }
233
269
necessityIndicator = { necessityIndicator }
234
270
contextualHelp = { props . contextualHelp } >
235
271
{ label }
@@ -240,11 +276,12 @@ function Picker<T extends object>(props: PickerProps<T>, ref: FocusableRef<HTMLB
240
276
className = { renderProps => inputButton ( {
241
277
...renderProps ,
242
278
size : size ,
243
- isOpen
279
+ isOpen,
280
+ isQuiet
244
281
} ) } >
245
282
{ ( renderProps ) => (
246
283
< >
247
- < SelectValue className = { valueStyles + ' ' + raw ( '&> * {display: none;}' ) } >
284
+ < SelectValue className = { valueStyles ( { isQuiet } ) + ' ' + raw ( '&> * {display: none;}' ) } >
248
285
{ ( { defaultChildren} ) => {
249
286
return (
250
287
< Provider
@@ -280,7 +317,8 @@ function Picker<T extends object>(props: PickerProps<T>, ref: FocusableRef<HTMLB
280
317
< ChevronIcon
281
318
size = { size }
282
319
className = { iconStyles } />
283
- { isInvalid && ! isDisabled &&
320
+ { isFocusVisible && isQuiet && < span className = { quietFocusLine } /> }
321
+ { isInvalid && ! isDisabled && ! isQuiet &&
284
322
// @ts -ignore known limitation detecting functions from the theme
285
323
< div className = { invalidBorder ( { ...renderProps , size} ) } />
286
324
}
@@ -300,14 +338,21 @@ function Picker<T extends object>(props: PickerProps<T>, ref: FocusableRef<HTMLB
300
338
placement = { `${ direction } ${ align } ` as Placement }
301
339
shouldFlip = { shouldFlip }
302
340
UNSAFE_style = { {
303
- width : menuWidth ? `${ menuWidth } px` : undefined
341
+ width : menuWidth && ! isQuiet ? `${ menuWidth } px` : undefined
304
342
} }
305
343
styles = { style ( {
344
+ marginStart : {
345
+ isQuiet : - 12
346
+ } ,
306
347
minWidth : {
307
- default : '[var(--trigger-width)]'
348
+ default : '[var(--trigger-width)]' ,
349
+ isQuiet : 192
308
350
} ,
309
- width : '[var(--trigger-width)]'
310
- } ) } >
351
+ width : {
352
+ default : '[var(--trigger-width)]' ,
353
+ isQuiet : '[calc(var(--trigger-width) + (-2 * self(marginStart)))]'
354
+ }
355
+ } ) ( props ) } >
311
356
< Provider
312
357
values = { [
313
358
[ HeaderContext , { className : sectionHeader ( { size} ) } ] ,
0 commit comments