Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add autoSize property to Sender component #637

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions components/sender/demo/basic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const Demo: React.FC = () => {
setLoading(false);
message.error('Cancel sending!');
}}
autoSize={{ minRows: 2, maxRows: 6 }}
/>
<Sender value="Force as loading" loading readOnly />
<Sender disabled value="Set to disabled" />
Expand Down
1 change: 1 addition & 0 deletions components/sender/index.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ Common props ref:[Common props](/docs/react/common-props)
| onChange | Callback when input value changes | (value: string, event?: React.FormEvent<`HTMLTextAreaElement`> \| React.ChangeEvent<`HTMLTextAreaElement`> ) => void | - | - |
| onCancel | Callback when click cancel button | () => void | - | - |
| onPasteFile | Callback when paste files | (firstFile: File, files: FileList) => void | - | - |
| autoSize | Height auto size feature, can be set to true \| false or an object { minRows: 2, maxRows: 6 } | boolean \| { minRows?: number; maxRows?: number } | { maxRows: 8 } | - |

```typescript | pure
type SpeechConfig = {
Expand Down
4 changes: 3 additions & 1 deletion components/sender/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export interface SenderProps
allowSpeech?: AllowSpeech;
prefix?: React.ReactNode;
header?: React.ReactNode;
autoSize?: boolean | { minRows?: number; maxRows?: number };
}

export type SenderRef = {
Expand Down Expand Up @@ -114,6 +115,7 @@ const ForwardSender = React.forwardRef<SenderRef, SenderProps>((props, ref) => {
header,
onPaste,
onPasteFile,
autoSize = { maxRows: 8 },
...rest
} = props;

Expand Down Expand Up @@ -308,7 +310,7 @@ const ForwardSender = React.forwardRef<SenderRef, SenderProps>((props, ref) => {
disabled={disabled}
style={{ ...contextConfig.styles.input, ...styles.input }}
className={classnames(inputCls, contextConfig.classNames.input, classNames.input)}
autoSize={{ maxRows: 8 }}
autoSize={autoSize}
value={innerValue}
onChange={(event) => {
triggerValueChange(
Expand Down
1 change: 1 addition & 0 deletions components/sender/index.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ coverDark: https://mdn.alipayobjects.com/huamei_iwk9zp/afts/img/A*cOfrS4fVkOMAAA
| onChange | 输入框值改变的回调 | (value: string, event?: React.FormEvent<`HTMLTextAreaElement`> \| React.ChangeEvent<`HTMLTextAreaElement`> ) => void | - | - |
| onCancel | 点击取消按钮的回调 | () => void | - | - |
| onPasteFile | 黏贴文件的回调 | (firstFile: File, files: FileList) => void | - | - |
| autoSize | 自适应内容高度,可设置为 true \| false 或对象:{ minRows: 2, maxRows: 6 } | boolean \| { minRows?: number; maxRows?: number } | { maxRows: 8 } | - |

```typescript | pure
type SpeechConfig = {
Expand Down