9
9
* governing permissions and limitations under the License.
10
10
*/
11
11
12
+ import { baseColor , focusRing , style } from '../style' with { type : 'macro' } ;
12
13
import { box , iconStyles } from './Checkbox' ;
13
14
import Checkmark from '../ui-icons/Checkmark' ;
14
15
import {
@@ -19,20 +20,24 @@ import {
19
20
ListBoxProps ,
20
21
Provider
21
22
} from 'react-aria-components' ;
22
- import { DOMRef , DOMRefValue , GlobalDOMAttributes , Orientation } from '@react-types/shared' ;
23
- import { focusRing , style } from '../style' with { type : 'macro' } ;
23
+ import { DOMRef , DOMRefValue , GlobalDOMAttributes , Key , Orientation } from '@react-types/shared' ;
24
24
import { getAllowedOverrides , StyleProps } from './style-utils' with { type : 'macro' } ;
25
25
import { IllustrationContext } from '../src/Icon' ;
26
26
import { pressScale } from './pressScale' ;
27
27
import React , { createContext , forwardRef , ReactNode , useContext , useMemo , useRef } from 'react' ;
28
28
import { TextContext } from './Content' ;
29
29
import { useSpectrumContextProps } from './useSpectrumContextProps' ;
30
30
31
- export interface SelectBoxGroupProps < T > extends StyleProps , Omit < ListBoxProps < T > , keyof GlobalDOMAttributes | 'layout' | 'dragAndDropHooks' | 'dependencies' | 'renderEmptyState' | 'children' | 'onAction' | 'shouldFocusOnHover' | 'selectionBehavior' | 'style' | 'className' > {
31
+ export interface SelectBoxGroupProps < T > extends StyleProps , Omit < ListBoxProps < T > , keyof GlobalDOMAttributes | 'layout' | 'dragAndDropHooks' | 'dependencies' | 'renderEmptyState' | 'children' | 'onAction' | 'shouldFocusOnHover' | 'selectionBehavior' | 'shouldSelectOnPressUp' | 'shouldFocusWrap' | ' style' | 'className' > {
32
32
/**
33
33
* The SelectBox elements contained within the SelectBoxGroup.
34
34
*/
35
35
children : ReactNode ,
36
+ /**
37
+ * The layout direction of the content in each SelectBox.
38
+ * @default 'vertical'
39
+ */
40
+ orientation ?: Orientation ,
36
41
/**
37
42
* The selection mode for the SelectBoxGroup.
38
43
* @default 'single'
@@ -45,12 +50,14 @@ export interface SelectBoxGroupProps<T> extends StyleProps, Omit<ListBoxProps<T>
45
50
}
46
51
47
52
export interface SelectBoxProps extends StyleProps {
53
+ /** The unique id of the SelectBox. */
54
+ id ?: Key ,
55
+ /** A string representation of the SelectBox's contents, used for features like typeahead. */
56
+ textValue ?: string ,
57
+ /** An accessibility label for this item. */
58
+ 'aria-label' ?: string ,
48
59
/**
49
- * The value of the SelectBox.
50
- */
51
- value : string ,
52
- /**
53
- * The label for the element.
60
+ * The contents of the SelectBox.
54
61
*/
55
62
children : ReactNode ,
56
63
/**
@@ -76,6 +83,7 @@ const selectBoxStyles = style({
76
83
gridAutoRows : '1fr' ,
77
84
position : 'relative' ,
78
85
font : 'ui' ,
86
+ cursor : 'default' ,
79
87
boxSizing : 'border-box' ,
80
88
overflow : 'hidden' ,
81
89
width : {
@@ -176,7 +184,7 @@ const selectBoxStyles = style({
176
184
} ,
177
185
backgroundColor : {
178
186
default : 'layer-2' ,
179
- isDisabled : 'layer-1 '
187
+ isDisabled : 'disabled '
180
188
} ,
181
189
color : {
182
190
isDisabled : 'disabled'
@@ -196,12 +204,12 @@ const illustrationContainer = style({
196
204
alignSelf : 'center' ,
197
205
justifySelf : 'center' ,
198
206
minSize : 48 ,
199
- color : {
200
- isDisabled : 'disabled ' ,
201
- isHovered : 'gray-900'
202
- } ,
203
- opacity : {
204
- isDisabled : 0.4
207
+ '--iconPrimary' : {
208
+ type : 'color ' ,
209
+ value : {
210
+ default : baseColor ( 'neutral' ) ,
211
+ isDisabled : 'disabled'
212
+ }
205
213
}
206
214
} ) ;
207
215
@@ -222,8 +230,7 @@ const descriptionText = style({
222
230
}
223
231
} ,
224
232
color : {
225
- default : 'neutral' ,
226
- isHovered : 'gray-900' ,
233
+ default : baseColor ( 'neutral' ) ,
227
234
isDisabled : 'disabled'
228
235
}
229
236
} ) ;
@@ -254,20 +261,29 @@ const labelText = style({
254
261
}
255
262
} ,
256
263
color : {
257
- default : 'neutral' ,
258
- isHovered : 'gray-900' ,
264
+ default : baseColor ( 'neutral' ) ,
259
265
isDisabled : 'disabled'
260
266
}
261
267
} ) ;
262
268
263
269
const gridStyles = style < { orientation ?: Orientation } > ( {
264
270
display : 'grid' ,
265
271
gridAutoRows : '1fr' ,
266
- gap : 16 ,
272
+ gap : 24 ,
273
+ justifyContent : 'center' ,
274
+ '--size' : {
275
+ type : 'width' ,
276
+ value : {
277
+ orientation : {
278
+ horizontal : 368 ,
279
+ vertical : 170
280
+ }
281
+ }
282
+ } ,
267
283
gridTemplateColumns : {
268
284
orientation : {
269
- horizontal : 'repeat(auto-fit, minmax(368px, 1fr ))' ,
270
- vertical : 'repeat(auto-fit, minmax(170px, 1fr ))'
285
+ horizontal : 'repeat(auto-fit, var(--size ))' ,
286
+ vertical : 'repeat(auto-fit, var(--size ))'
271
287
}
272
288
}
273
289
} , getAllowedOverrides ( ) ) ;
@@ -276,7 +292,7 @@ const gridStyles = style<{orientation?: Orientation}>({
276
292
* SelectBox is a single selectable item in a SelectBoxGroup.
277
293
*/
278
294
export function SelectBox ( props : SelectBoxProps ) : ReactNode {
279
- let { children, value , isDisabled : individualDisabled = false , UNSAFE_style, UNSAFE_className, styles, ...otherProps } = props ;
295
+ let { children, isDisabled : individualDisabled = false , UNSAFE_style, UNSAFE_className, styles, ...otherProps } = props ;
280
296
281
297
let {
282
298
orientation = 'vertical' ,
@@ -288,8 +304,6 @@ export function SelectBox(props: SelectBoxProps): ReactNode {
288
304
289
305
return (
290
306
< ListBoxItem
291
- id = { value }
292
- textValue = { value }
293
307
isDisabled = { isDisabled }
294
308
ref = { ref }
295
309
className = { renderProps => ( UNSAFE_className || '' ) + selectBoxStyles ( {
@@ -364,6 +378,7 @@ export const SelectBoxGroup = /*#__PURE__*/ forwardRef(function SelectBoxGroup<T
364
378
isDisabled = false ,
365
379
UNSAFE_className,
366
380
UNSAFE_style,
381
+ styles,
367
382
...otherProps
368
383
} = props ;
369
384
@@ -382,7 +397,7 @@ export const SelectBoxGroup = /*#__PURE__*/ forwardRef(function SelectBoxGroup<T
382
397
< ListBox
383
398
selectionMode = { selectionMode }
384
399
layout = "grid"
385
- className = { ( UNSAFE_className || '' ) + gridStyles ( { orientation} ) }
400
+ className = { ( UNSAFE_className || '' ) + gridStyles ( { orientation} , styles ) }
386
401
style = { UNSAFE_style }
387
402
{ ...otherProps } >
388
403
< SelectBoxContext . Provider value = { selectBoxContextValue } >
0 commit comments