|
|
@@ -26,7 +26,7 @@ const inputVariants = cva(
|
|
|
}
|
|
|
)
|
|
|
|
|
|
-export interface InputProps extends Omit<TaroInputProps, 'className'>, VariantProps<typeof inputVariants> {
|
|
|
+export interface InputProps extends Omit<TaroInputProps, 'className' | 'onChange'>, VariantProps<typeof inputVariants> {
|
|
|
className?: string
|
|
|
leftIcon?: string
|
|
|
rightIcon?: string
|
|
|
@@ -34,10 +34,21 @@ export interface InputProps extends Omit<TaroInputProps, 'className'>, VariantPr
|
|
|
errorMessage?: string
|
|
|
onLeftIconClick?: () => void
|
|
|
onRightIconClick?: () => void
|
|
|
+ onChange?: (value: string, event: any) => void
|
|
|
}
|
|
|
|
|
|
const Input = forwardRef<any, InputProps>(
|
|
|
- ({ className, variant, size, leftIcon, rightIcon, error, errorMessage, onLeftIconClick, onRightIconClick, ...props }, ref) => {
|
|
|
+ ({ className, variant, size, leftIcon, rightIcon, error, errorMessage, onLeftIconClick, onRightIconClick, onChange, ...props }, ref) => {
|
|
|
+ const handleInput = (event: any) => {
|
|
|
+ const value = event.detail.value
|
|
|
+ onChange?.(value, event)
|
|
|
+
|
|
|
+ // 同时调用原始的onInput(如果提供了)
|
|
|
+ if (props.onInput) {
|
|
|
+ props.onInput(event)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
return (
|
|
|
<View className="w-full">
|
|
|
<View className="relative">
|
|
|
@@ -61,6 +72,7 @@ const Input = forwardRef<any, InputProps>(
|
|
|
leftIcon && 'pl-10',
|
|
|
rightIcon && 'pr-10',
|
|
|
)}
|
|
|
+ onInput={handleInput}
|
|
|
{...props}
|
|
|
/>
|
|
|
|