# Input - 输入框

## 说明

单行受控输入框组件，支持普通文本和密码输入、键盘类型、输入字数限制、前缀内容、清除按钮及反馈提示。

## 属性

| 属性 | 说明 | 类型 | 默认值 | 必填 |
|------|------|------|--------|------|
| **value** | 输入值（受控） | `string` | `''` | 否 |
| **onChangeText** | 输入值变化回调 | `(text: string) => void` | - | 否 |
| **placeholder** | 占位文本 | `string` | `''` | 否 |
| **type** | 输入类型 | `'normal' \| 'password'` | `'normal'` | 否 |
| **keyboardType** | RN 键盘类型；密码模式下不生效；**v1.18.20（待发布）新增** | `KeyboardTypeOptions` | 普通输入框为 `'default'`，密码输入框固定为 `'ascii-capable'` | 否 |
| **maxLength** | 最大可输入字符数；**v1.18.20（待发布）新增** | `number` | - | 否 |
| **colorDepth** | 输入框底色深度 | `'base' \| 'low'` | `'base'` | 否 |
| **prefix** | 左侧自定义内容 | `ReactElement` | - | 否 |
| **showClear** | 有值时是否显示清除按钮 | `boolean` | `true` | 否 |
| **colorType** | 聚焦边框、光标和密码切换图标色系 | `ColorType` | `'green'` | 否 |
| **feedbackText** | 反馈提示文本 | `string` | - | 否 |
| **feedbackType** | 反馈提示类型 | `'normal' \| 'notice' \| 'warning'` | `'normal'` | 否 |
| **feedbackIconType** | 反馈提示图标类型 | `'none' \| 'alert' \| 'help' \| 'info'` | `'none'` | 否 |
| **onFocus** | 聚焦回调 | `() => void` | - | 否 |
| **onBlur** | 失焦回调 | `() => void` | - | 否 |
| **onSubmitEditing** | 提交回调 | `() => void` | - | 否 |
| **autoFocus** | 是否自动聚焦 | `boolean` | `false` | 否 |

## 使用示例

```tsx
import { Input } from 'mhui-rn';

// 数字输入，最多 6 个字符
<Input
  value={value}
  onChangeText={setValue}
  placeholder="请输入编号"
  keyboardType="numeric"
  maxLength={6}
/>

// 密码输入；未指定 keyboardType 时默认使用 ascii-capable
<Input
  type="password"
  value={password}
  onChangeText={setPassword}
  placeholder="请输入密码"
  maxLength={20}
/>
```

## 注意事项

- `keyboardType` 和 `maxLength` 会透传给 React Native `TextInput`。
- 密码模式固定使用 `ascii-capable`；普通模式下显式传入的 `keyboardType` 优先于默认值。
- `maxLength` 限制用户通过原生输入框输入的字符数；组件是受控模式，外部传入的 `value` 仍由业务侧负责维护。
- 密码模式会过滤 ASCII 可打印字符范围以外的输入，保持现有密码输入行为。
