capacitor-native-input-dialog
Version:
Capacitor plugin for native input dialogs with enhanced text input experience on mobile devices
165 lines (110 loc) • 6.99 kB
Markdown
# native-input
Provides native input dialogs for better text input experience on mobile devices
## Install
```bash
npm install native-input
npx cap sync
```
## API
<docgen-index>
* [`showNativeInput(...)`](#shownativeinput)
* [`createNativeOverlay(...)`](#createnativeoverlay)
* [`updateNativeOverlay(...)`](#updatenativeoverlay)
* [`removeNativeOverlay(...)`](#removenativeoverlay)
* [`isAvailable()`](#isavailable)
* [Interfaces](#interfaces)
</docgen-index>
<docgen-api>
<!--Update the source file JSDoc comments and rerun docgen to update the docs below-->
### showNativeInput(...)
```typescript
showNativeInput(options: NativeInputOptions) => Promise<NativeInputResult>
```
显示原生输入对话框
| Param | Type |
| ------------- | ----------------------------------------------------------------- |
| **`options`** | <code><a href="#nativeinputoptions">NativeInputOptions</a></code> |
**Returns:** <code>Promise<<a href="#nativeinputresult">NativeInputResult</a>></code>
--------------------
### createNativeOverlay(...)
```typescript
createNativeOverlay(options: NativeOverlayOptions) => Promise<{ id: string; }>
```
创建原生输入框覆盖层
| Param | Type |
| ------------- | --------------------------------------------------------------------- |
| **`options`** | <code><a href="#nativeoverlayoptions">NativeOverlayOptions</a></code> |
**Returns:** <code>Promise<{ id: string; }></code>
--------------------
### updateNativeOverlay(...)
```typescript
updateNativeOverlay(options: UpdateOverlayOptions) => Promise<void>
```
更新原生输入框覆盖层
| Param | Type |
| ------------- | --------------------------------------------------------------------- |
| **`options`** | <code><a href="#updateoverlayoptions">UpdateOverlayOptions</a></code> |
--------------------
### removeNativeOverlay(...)
```typescript
removeNativeOverlay(options: { id: string; }) => Promise<void>
```
移除原生输入框覆盖层
| Param | Type |
| ------------- | ---------------------------- |
| **`options`** | <code>{ id: string; }</code> |
--------------------
### isAvailable()
```typescript
isAvailable() => Promise<{ available: boolean; }>
```
检查原生输入功能是否可用
**Returns:** <code>Promise<{ available: boolean; }></code>
--------------------
### Interfaces
#### NativeInputResult
| Prop | Type | Description |
| --------------- | -------------------- | ----------- |
| **`value`** | <code>string</code> | 用户输入的文本 |
| **`cancelled`** | <code>boolean</code> | 是否被取消 |
#### NativeInputOptions
| Prop | Type | Description |
| ----------------------- | ----------------------------------------------------------------------- | ----------- |
| **`title`** | <code>string</code> | 输入框标题 |
| **`placeholder`** | <code>string</code> | 输入框提示文本 |
| **`initialValue`** | <code>string</code> | 初始值 |
| **`inputType`** | <code>'number' \| 'text' \| 'email' \| 'password' \| 'multiline'</code> | 输入类型 |
| **`confirmButtonText`** | <code>string</code> | 确认按钮文本 |
| **`cancelButtonText`** | <code>string</code> | 取消按钮文本 |
| **`maxLength`** | <code>number</code> | 最大字符数限制 |
| **`multiline`** | <code>boolean</code> | 是否允许多行输入 |
| **`maxLines`** | <code>number</code> | 多行输入时的最大行数 |
#### NativeOverlayOptions
| Prop | Type | Description |
| --------------------- | ----------------------------------------------------------------------- | ----------- |
| **`x`** | <code>number</code> | 输入框位置和尺寸 |
| **`y`** | <code>number</code> | |
| **`width`** | <code>number</code> | |
| **`height`** | <code>number</code> | |
| **`placeholder`** | <code>string</code> | 输入框提示文本 |
| **`initialValue`** | <code>string</code> | 初始值 |
| **`inputType`** | <code>'number' \| 'text' \| 'email' \| 'password' \| 'multiline'</code> | 输入类型 |
| **`maxLength`** | <code>number</code> | 最大字符数限制 |
| **`multiline`** | <code>boolean</code> | 是否允许多行输入 |
| **`maxLines`** | <code>number</code> | 多行输入时的最大行数 |
| **`fontSize`** | <code>number</code> | 字体大小 |
| **`backgroundColor`** | <code>string</code> | 背景颜色 |
| **`textColor`** | <code>string</code> | 文字颜色 |
| **`borderColor`** | <code>string</code> | 边框颜色 |
| **`borderRadius`** | <code>number</code> | 边框圆角 |
#### UpdateOverlayOptions
| Prop | Type | Description |
| ----------------- | ------------------- | ----------- |
| **`id`** | <code>string</code> | 覆盖层ID |
| **`value`** | <code>string</code> | 新的文本值 |
| **`x`** | <code>number</code> | 新的位置和尺寸 |
| **`y`** | <code>number</code> | |
| **`width`** | <code>number</code> | |
| **`height`** | <code>number</code> | |
| **`placeholder`** | <code>string</code> | 新的占位符 |
</docgen-api>