Skip to content

Commit 4ef55ed

Browse files
committed
chore(Input): 重构Inupt 组件 更新 Drawe 文档
1 parent 05339d9 commit 4ef55ed

File tree

5 files changed

+238
-216
lines changed

5 files changed

+238
-216
lines changed

example/examples/src/routes/Input/index.tsx

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, {Component} from 'react';
22
import {StyleSheet} from 'react-native';
3-
import {Input} from '@uiw/react-native';
3+
import {Input, Toast} from '@uiw/react-native';
44
import Layout, {Container} from '../../Layout';
55
import {ComProps} from '../../routes';
66

@@ -11,6 +11,7 @@ export interface InputProps extends ComProps {}
1111
export default class InputView extends Component<InputProps> {
1212
state = {
1313
value: '',
14+
value2: '',
1415
};
1516
render() {
1617
const {route} = this.props;
@@ -24,20 +25,36 @@ export default class InputView extends Component<InputProps> {
2425
<Card title="基础实例" style={styles.card}>
2526
<Input
2627
style={styles.input}
27-
onChange={(value: string) => {
28+
placeholder="请输入"
29+
disabled={true}
30+
onChangeText={(value: string) => {
2831
this.setState({value});
2932
}}
3033
value={this.state.value}
3134
/>
3235
</Card>
36+
<Card title="默认聚焦" style={styles.card}>
37+
<Input style={styles.input} autoFocus />
38+
</Card>
3339
<Card title="额外的内容" style={styles.card}>
34-
<Input style={styles.input} extra="小数" />
40+
<Input
41+
style={styles.input}
42+
extraStart="https://"
43+
extraEnd=".com"
44+
/>
3545
</Card>
3646
<Card title="报错" style={styles.card}>
3747
<Input style={styles.input} error />
3848
</Card>
39-
<Card title="手机号" style={styles.card}>
40-
<Input style={styles.input} type="phone" />
49+
<Card title="数字键盘" style={styles.card}>
50+
<Input style={styles.input} keyboardType="numeric" />
51+
</Card>
52+
<Card title="校验" style={styles.card}>
53+
<Input
54+
style={styles.input}
55+
rule={/\d/}
56+
wrongfulHandle={() => Toast.info('内容不合法', 2, 'info')}
57+
/>
4158
</Card>
4259
</Body>
4360
<Footer />

packages/core/src/Drawer/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Drawer 抽屉
66
## 基础示例
77

88
```jsx
9-
import { Fragment } from 'react';
9+
import { Fragment, useState } from 'react';
1010
import { View, Text } from 'react-native';
1111
import { Drawer, Button } from '@uiw/react-native';
1212

@@ -31,7 +31,7 @@ function Demo() {
3131
## 右边展示
3232

3333
```jsx
34-
import { Fragment } from 'react';
34+
import { Fragment, useState } from 'react';
3535
import { View, Text } from 'react-native';
3636
import { Drawer, Button } from '@uiw/react-native';
3737

packages/core/src/Input/PropsType.tsx

Lines changed: 0 additions & 21 deletions
This file was deleted.

packages/core/src/Input/README.md

Lines changed: 61 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ Input 文本输入
99

1010
import React from 'react';
1111
import { View, Input } from '@uiw/react-native';
12+
import {View} from 'react-native';
1213

1314
export default class BasicInputExample extends React.Component {
1415
render() {
1516
return <View>
1617
<Input onChange={(value) => {this.setState({value})}} value={this.state.value} />
1718
<Input extra="小数" />
1819
<Input error />
19-
<Input type="phone" />
2020
</View>
2121
}
2222
}
@@ -26,13 +26,65 @@ export default class BasicInputExample extends React.Component {
2626

2727
## Props
2828

29-
| 参数 | 说明 | 类型 | 默认值 |
30-
|------|------|-----|------|
31-
| `clear` | 是否显示清除按钮 | boolean | false |
32-
| `extra` | 额外的文字 | ReactNode \| string | - |
33-
| `error` | 是否显示错误 | boolean | false |
34-
| `onExtraClick` | `extra` 点击事件触发的回调函数 | (e: Object): void | - |
35-
| `onErrorClick` | 点击报错 `icon` 触发的回调函数 | (e: Object): void | - |
29+
```tsx
30+
import { StyleProp,TextStyle,TextInputProps, NativeSyntheticEvent, TextInputFocusEventData, TextInputChangeEventData, KeyboardTypeOptions,ViewStyle } from 'react-native'
31+
32+
export interface InputProps extends TextInputProps {
33+
/** 输入框默认值 */
34+
value?: string;
35+
/** 限制输入条件 */
36+
rule?: RegExp | (value: string)=>boolean;
37+
/** 输入不合法时触发方法 */
38+
wrongfulHandle?: Function;
39+
/** 限制文本框中最多的字符数。使用这个属性而不用 JS 逻辑去实现,可以避免闪烁的现象。 */
40+
maxLength?: number;
41+
/** 如果没有任何文字输入,会显示此字符串。 */
42+
placeholder: string;
43+
/** 输入框样式 */
44+
style?: StyleProp<TextStyle>;
45+
/** 容器样式 */
46+
containerStyle?: StyleProp<ViewStyle>;
47+
/** 显示错误 */
48+
error?: boolean;
49+
/** 自定义错误提示 */
50+
renderError?: React.ReactNode;
51+
/** 边框 */
52+
border?: 'bottom'|'top'|'left'|'right'|null|'always';
53+
/** 边框颜色 */
54+
borderColor?: string;
55+
/** 唤起键盘类型 详情 https://lefkowitz.me/visual-guide-to-react-native-textinput-keyboardtype-options/ */
56+
keyboardType?: KeyboardTypeOptions;
57+
/** 如果为 true,文本框是不可编辑的。默认值为 false */
58+
disabled?: boolean;
59+
/** 如果为 true,在componentDidMount后会获得焦点。默认值为 false。 */
60+
autoFocus?: boolean;
61+
/** 设置输入框高亮时的颜色(还包括光标)。 */
62+
selectionColor?: string;
63+
/** 如果为 true,则隐藏光标。默认值为 false。 */
64+
caretHidden?: boolean;
65+
/** 是否显示清除按钮 */
66+
clear?: boolean;
67+
/** 清除按钮样式 */
68+
clearStyle?: StyleProp<TextStyle>;
69+
/** 自定义清除元素 */
70+
renderClear?: React.ReactNode;
71+
/** 如果为 true,每次开始输入的时候都会清除文本框的内容。 */
72+
clearText?: boolean;
73+
/** 输入框前缀的额外的信息 */
74+
extraStart?: string|React.ReactNode
75+
/** 输入框末尾额外的信息 */
76+
extraEnd?: string|React.ReactNode
77+
/** 当文本框内容变化时调用此回调函数。改变后的文字内容会作为参数传递 */
78+
onChangeText?: ((text: string) => void);
79+
/** 当文本框失去焦点的时候调用此回调函数。 */
80+
onBlur?: ((e: NativeSyntheticEvent<TextInputFocusEventData>) => void);
81+
/** 当文本框内容变化时调用此回调函数。回调参数为{ nativeEvent: { eventCount, target, text} }。 */
82+
onChange?: ((e: NativeSyntheticEvent<TextInputChangeEventData>) => void);
83+
/** 输入框 ref */
84+
inputRef?: React.RefObject<TextInput>
85+
}
86+
87+
```
3688

3789

38-
> 更多 react-native InputItem 属性请参考 react-native TextInput (http://facebook.github.io/react-native/docs/textinput.html)
90+
> 更多 react-native Input 属性请参考 react-native TextInput (https://www.react-native.cn/docs/textinput)

0 commit comments

Comments
 (0)