@@ -68,7 +68,12 @@ export interface ComboBoxRenderProps {
6868 * Whether the combobox is required.
6969 * @selector [data-required]
7070 */
71- isRequired : boolean
71+ isRequired : boolean ,
72+ /**
73+ * Whether the combobox is read only.
74+ * @selector [data-readonly]
75+ */
76+ isReadOnly : boolean
7277}
7378
7479export interface ComboBoxProps < T extends object , M extends SelectionMode = 'single' > extends Omit < AriaComboBoxProps < T , M > , 'children' | 'placeholder' | 'label' | 'description' | 'errorMessage' | 'validationState' | 'validationBehavior' > , RACValidation , RenderProps < ComboBoxRenderProps > , SlotProps , GlobalDOMAttributes < HTMLDivElement > {
@@ -97,7 +102,7 @@ export const ComboBoxStateContext = createContext<ComboBoxState<any, SelectionMo
97102 */
98103export const ComboBox = /*#__PURE__*/ ( forwardRef as forwardRefType ) ( function ComboBox < T extends object , M extends SelectionMode = 'single' > ( props : ComboBoxProps < T , M > , ref : ForwardedRef < HTMLDivElement > ) {
99104 [ props , ref ] = useContextProps ( props , ref , ComboBoxContext ) ;
100- let { children, isDisabled = false , isInvalid = false , isRequired = false } = props ;
105+ let { children, isDisabled = false , isInvalid = false , isRequired = false , isReadOnly = false } = props ;
101106 let content = useMemo ( ( ) => (
102107 < ListBoxContext . Provider value = { { items : props . items ?? props . defaultItems } } >
103108 { typeof children === 'function'
@@ -106,11 +111,12 @@ export const ComboBox = /*#__PURE__*/ (forwardRef as forwardRefType)(function Co
106111 isDisabled,
107112 isInvalid,
108113 isRequired,
109- defaultChildren : null
114+ defaultChildren : null ,
115+ isReadOnly
110116 } )
111117 : children }
112118 </ ListBoxContext . Provider >
113- ) , [ children , isDisabled , isInvalid , isRequired , props . items , props . defaultItems ] ) ;
119+ ) , [ children , isDisabled , isInvalid , isRequired , isReadOnly , props . items , props . defaultItems ] ) ;
114120
115121 return (
116122 < CollectionBuilder content = { content } >
@@ -200,8 +206,9 @@ function ComboBoxInner<T extends object>({props, collection, comboBoxRef: ref}:
200206 isOpen : state . isOpen ,
201207 isDisabled : props . isDisabled || false ,
202208 isInvalid : validation . isInvalid || false ,
203- isRequired : props . isRequired || false
204- } ) , [ state . isOpen , props . isDisabled , validation . isInvalid , props . isRequired ] ) ;
209+ isRequired : props . isRequired || false ,
210+ isReadOnly : props . isReadOnly || false
211+ } ) , [ state . isOpen , props . isDisabled , validation . isInvalid , props . isRequired , props . isReadOnly ] ) ;
205212
206213 let renderProps = useRenderProps ( {
207214 ...props ,
@@ -262,6 +269,7 @@ function ComboBoxInner<T extends object>({props, collection, comboBoxRef: ref}:
262269 data-focused = { state . isFocused || undefined }
263270 data-open = { state . isOpen || undefined }
264271 data-disabled = { props . isDisabled || undefined }
272+ data-readonly = { props . isReadOnly || undefined }
265273 data-invalid = { validation . isInvalid || undefined }
266274 data-required = { props . isRequired || undefined } >
267275 { renderProps . children }
0 commit comments