@@ -6,16 +6,21 @@ import Injector from '@s-ui/react-primitive-injector'
66import { CLASS_ARROW , CLASS_ARROW_DOWN , CLASS_ARROW_UP , CLASS_CONTAINER } from './config.js'
77
88const MoleculeInputSelect = props => {
9- const { onClick, iconArrowDown : iconArrow , isOpen, disabled, children, ...rest } = props
9+ const { onClick, iconArrowDown : iconArrow , isOpen, disabled, readOnly , children, ...rest } = props
1010
1111 const classNames = cx ( CLASS_ARROW , {
1212 [ CLASS_ARROW_DOWN ] : ! isOpen ,
1313 [ CLASS_ARROW_UP ] : isOpen
1414 } )
1515
16+ const onClickInputHandler = ev => {
17+ if ( readOnly ) return
18+ onClick ( ev )
19+ }
20+
1621 return (
17- < div className = { CLASS_CONTAINER } onClick = { ! disabled ? onClick : null } >
18- < Injector onClick = { onClick } disabled = { disabled } { ...rest } >
22+ < div className = { CLASS_CONTAINER } onClick = { ! disabled && ! readOnly ? onClick : null } >
23+ < Injector onClick = { onClickInputHandler } disabled = { disabled } readOnly = { readOnly } { ...rest } >
1924 { children }
2025 </ Injector >
2126 < span className = { classNames } > { iconArrow } </ span >
@@ -38,7 +43,10 @@ MoleculeInputSelect.propTypes = {
3843 isOpen : PropTypes . bool ,
3944
4045 /** This Boolean attribute prevents the user from interacting with the input */
41- disabled : PropTypes . bool
46+ disabled : PropTypes . bool ,
47+
48+ /** This Boolean attribute prevents the user from interacting with the input */
49+ readOnly : PropTypes . bool
4250}
4351
4452export default MoleculeInputSelect
0 commit comments