11import React , { useState , useRef , useImperativeHandle , useEffect } from 'react' ;
2- import classNames from 'classnames' ;
32import {
43 BrowseIcon as TdBrowseIcon ,
54 BrowseOffIcon as TdBrowseOffIcon ,
65 CloseCircleFilledIcon as TdCloseCircleFilledIcon ,
76} from 'tdesign-icons-react' ;
7+ import classNames from 'classnames' ;
88import { isFunction } from 'lodash-es' ;
99import useLayoutEffect from '../hooks/useLayoutEffect' ;
1010import forwardRefWithStatics from '../_util/forwardRefWithStatics' ;
@@ -82,6 +82,8 @@ const Input = forwardRefWithStatics(
8282 allowInput,
8383 allowInputOverMax,
8484 name,
85+ readOnly,
86+ readonly,
8587 format,
8688 onClick,
8789 onClear,
@@ -101,7 +103,7 @@ const Input = forwardRefWithStatics(
101103 onChange : onChangeFromProps ,
102104 ...restProps
103105 } = props ;
104- const readOnly = props . readOnly || props . readonly ;
106+ const readOnlyProp = readOnly || readonly ;
105107
106108 const [ value , onChange ] = useControlled ( props , 'value' , onChangeFromProps ) ;
107109 const { limitNumber, getValueByLimitNumber, tStatus } = useLengthLimit ( {
@@ -126,7 +128,7 @@ const Input = forwardRefWithStatics(
126128 const [ composingValue , setComposingValue ] = useState < string > ( '' ) ;
127129
128130 // 组件内部 input 原生控件是否处于 readonly 状态,当整个组件 readonly 时,或者处于不可输入时
129- const isInnerInputReadonly = readOnly || ! allowInput ;
131+ const isInnerInputReadonly = readOnlyProp || ! allowInput ;
130132 const isValueEnabled = value && ! disabled ;
131133 const alwaysShowClearIcon = inputConfig ?. clearTrigger === 'always' ;
132134 const isShowClearIcon =
@@ -248,7 +250,7 @@ const Input = forwardRefWithStatics(
248250 const renderInputNode = (
249251 < div
250252 className = { classNames ( inputClass , `${ classPrefix } -input` , {
251- [ `${ classPrefix } -is-readonly` ] : readOnly ,
253+ [ `${ classPrefix } -is-readonly` ] : readOnlyProp ,
252254 [ `${ classPrefix } -is-disabled` ] : disabled ,
253255 [ `${ classPrefix } -is-focused` ] : isFocused ,
254256 [ `${ classPrefix } -size-s` ] : size === 'small' ,
0 commit comments