99 * governing permissions and limitations under the License.
1010 */
1111
12+ import { baseColor , focusRing , style } from '../style' with { type : 'macro' } ;
1213import { box , iconStyles } from './Checkbox' ;
1314import Checkmark from '../ui-icons/Checkmark' ;
1415import {
@@ -19,20 +20,24 @@ import {
1920 ListBoxProps ,
2021 Provider
2122} 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' ;
2424import { getAllowedOverrides , StyleProps } from './style-utils' with { type : 'macro' } ;
2525import { IllustrationContext } from '../src/Icon' ;
2626import { pressScale } from './pressScale' ;
2727import React , { createContext , forwardRef , ReactNode , useContext , useMemo , useRef } from 'react' ;
2828import { TextContext } from './Content' ;
2929import { useSpectrumContextProps } from './useSpectrumContextProps' ;
3030
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' > {
3232 /**
3333 * The SelectBox elements contained within the SelectBoxGroup.
3434 */
3535 children : ReactNode ,
36+ /**
37+ * The layout direction of the content in each SelectBox.
38+ * @default 'vertical'
39+ */
40+ orientation ?: Orientation ,
3641 /**
3742 * The selection mode for the SelectBoxGroup.
3843 * @default 'single'
@@ -45,12 +50,14 @@ export interface SelectBoxGroupProps<T> extends StyleProps, Omit<ListBoxProps<T>
4550}
4651
4752export 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 ,
4859 /**
49- * The value of the SelectBox.
50- */
51- value : string ,
52- /**
53- * The label for the element.
60+ * The contents of the SelectBox.
5461 */
5562 children : ReactNode ,
5663 /**
@@ -76,6 +83,7 @@ const selectBoxStyles = style({
7683 gridAutoRows : '1fr' ,
7784 position : 'relative' ,
7885 font : 'ui' ,
86+ cursor : 'default' ,
7987 boxSizing : 'border-box' ,
8088 overflow : 'hidden' ,
8189 width : {
@@ -176,7 +184,7 @@ const selectBoxStyles = style({
176184 } ,
177185 backgroundColor : {
178186 default : 'layer-2' ,
179- isDisabled : 'layer-1 '
187+ isDisabled : 'disabled '
180188 } ,
181189 color : {
182190 isDisabled : 'disabled'
@@ -196,12 +204,12 @@ const illustrationContainer = style({
196204 alignSelf : 'center' ,
197205 justifySelf : 'center' ,
198206 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+ }
205213 }
206214} ) ;
207215
@@ -222,8 +230,7 @@ const descriptionText = style({
222230 }
223231 } ,
224232 color : {
225- default : 'neutral' ,
226- isHovered : 'gray-900' ,
233+ default : baseColor ( 'neutral' ) ,
227234 isDisabled : 'disabled'
228235 }
229236} ) ;
@@ -254,20 +261,29 @@ const labelText = style({
254261 }
255262 } ,
256263 color : {
257- default : 'neutral' ,
258- isHovered : 'gray-900' ,
264+ default : baseColor ( 'neutral' ) ,
259265 isDisabled : 'disabled'
260266 }
261267} ) ;
262268
263269const gridStyles = style < { orientation ?: Orientation } > ( {
264270 display : 'grid' ,
265271 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+ } ,
267283 gridTemplateColumns : {
268284 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 ))'
271287 }
272288 }
273289} , getAllowedOverrides ( ) ) ;
@@ -276,7 +292,7 @@ const gridStyles = style<{orientation?: Orientation}>({
276292 * SelectBox is a single selectable item in a SelectBoxGroup.
277293 */
278294export 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 ;
280296
281297 let {
282298 orientation = 'vertical' ,
@@ -288,8 +304,6 @@ export function SelectBox(props: SelectBoxProps): ReactNode {
288304
289305 return (
290306 < ListBoxItem
291- id = { value }
292- textValue = { value }
293307 isDisabled = { isDisabled }
294308 ref = { ref }
295309 className = { renderProps => ( UNSAFE_className || '' ) + selectBoxStyles ( {
@@ -364,6 +378,7 @@ export const SelectBoxGroup = /*#__PURE__*/ forwardRef(function SelectBoxGroup<T
364378 isDisabled = false ,
365379 UNSAFE_className,
366380 UNSAFE_style,
381+ styles,
367382 ...otherProps
368383 } = props ;
369384
@@ -382,7 +397,7 @@ export const SelectBoxGroup = /*#__PURE__*/ forwardRef(function SelectBoxGroup<T
382397 < ListBox
383398 selectionMode = { selectionMode }
384399 layout = "grid"
385- className = { ( UNSAFE_className || '' ) + gridStyles ( { orientation} ) }
400+ className = { ( UNSAFE_className || '' ) + gridStyles ( { orientation} , styles ) }
386401 style = { UNSAFE_style }
387402 { ...otherProps } >
388403 < SelectBoxContext . Provider value = { selectBoxContextValue } >
0 commit comments