|
|
@@ -11,6 +11,7 @@ interface Props {
|
|
|
disabled?: boolean;
|
|
|
confirmType?: keyof InputProps.ConfirmType;
|
|
|
extra?: () => JSX.Element | JSX.Element[] | undefined;
|
|
|
+ suffix?: () => JSX.Element | JSX.Element[] | undefined;
|
|
|
prefix?: () => JSX.Element | JSX.Element[] | undefined;
|
|
|
style?: React.CSSProperties;
|
|
|
onInput?: (value: string) => void;
|
|
|
@@ -18,6 +19,7 @@ interface Props {
|
|
|
bgColor?: string;
|
|
|
autoFocus?: boolean;
|
|
|
extraClass?: string;
|
|
|
+ adjustPosition?: boolean
|
|
|
onConfirm?: (value: string) => void;
|
|
|
placeholderStyle?: string;
|
|
|
}
|
|
|
@@ -30,6 +32,7 @@ const index = ({
|
|
|
disabled,
|
|
|
confirmType,
|
|
|
prefix,
|
|
|
+ suffix,
|
|
|
autoHeight,
|
|
|
autoFocus = false,
|
|
|
placeholder = "请输入...",
|
|
|
@@ -40,6 +43,7 @@ const index = ({
|
|
|
extra,
|
|
|
onConfirm,
|
|
|
placeholderStyle,
|
|
|
+ adjustPosition,
|
|
|
}: Props) => {
|
|
|
const [focus, setFocus] = useState(false);
|
|
|
const inputRef = useRef<HTMLInputElement>(null); // 创建一个 ref
|
|
|
@@ -76,29 +80,32 @@ const index = ({
|
|
|
>
|
|
|
{prefix && prefix()}
|
|
|
<View className={styleIndex.textareaContainer}>
|
|
|
- <Textarea
|
|
|
- ref={inputRef}
|
|
|
- value={value}
|
|
|
- disabled={disabled}
|
|
|
- confirmType={confirmType}
|
|
|
- style={style}
|
|
|
- onInput={(e: any) => handleInput(e.target.value)}
|
|
|
- placeholder={placeholder}
|
|
|
- placeholderStyle={placeholderStyle ?? 'color: rgba(17,17,17,.25)'}
|
|
|
- className={`${styleIndex.textInput} ${extraClass}`}
|
|
|
- onFocus={handleFocus}
|
|
|
- onBlur={handleBlur}
|
|
|
- autoHeight={autoHeight}
|
|
|
- autoFocus={autoFocus}
|
|
|
- cursorSpacing={cursorSpacing}
|
|
|
- maxlength={10000}
|
|
|
- onConfirm={(e: any) => {
|
|
|
- onConfirm && onConfirm(e.detail.value);
|
|
|
- }}
|
|
|
- />
|
|
|
+ <View className="flex items-end">
|
|
|
+ <Textarea
|
|
|
+ ref={inputRef}
|
|
|
+ value={value}
|
|
|
+ disabled={disabled}
|
|
|
+ adjustPosition={adjustPosition}
|
|
|
+ confirmType={confirmType}
|
|
|
+ style={style}
|
|
|
+ onInput={(e: any) => handleInput(e.target.value)}
|
|
|
+ placeholder={placeholder}
|
|
|
+ placeholderStyle={placeholderStyle ?? 'color: rgba(17,17,17,.25)'}
|
|
|
+ className={`${styleIndex.textInput} ${extraClass}`}
|
|
|
+ onFocus={handleFocus}
|
|
|
+ onBlur={handleBlur}
|
|
|
+ autoHeight={autoHeight}
|
|
|
+ autoFocus={autoFocus}
|
|
|
+ cursorSpacing={cursorSpacing}
|
|
|
+ maxlength={10000}
|
|
|
+ onConfirm={(e: any) => {
|
|
|
+ onConfirm && onConfirm(e.detail.value);
|
|
|
+ }}
|
|
|
+ />
|
|
|
+ {suffix && suffix()}
|
|
|
+ </View>
|
|
|
<View className={`${styleIndex.textareaButtons} justify-end gap-8`}>
|
|
|
{extra && extra()}
|
|
|
- {/* <View className={`button-rounded-mini ${!value.length ? 'disabled' :''}`} onClick={handleClear}>清除</View> */}
|
|
|
{maxlength && (
|
|
|
<View className="text-gray-4">
|
|
|
{maxlength}/{countCharacters(value)}
|