2019-05-17 12:05:03 +08:00
|
|
|
---
|
|
|
|
category: Components
|
|
|
|
type: Data Entry
|
|
|
|
title: Mentions
|
2020-05-31 11:48:34 +08:00
|
|
|
cover: https://gw.alipayobjects.com/zos/alicdn/0pF5j477V/Mentions.svg
|
2019-05-17 12:05:03 +08:00
|
|
|
---
|
|
|
|
|
|
|
|
Mention component.
|
|
|
|
|
|
|
|
## When To Use
|
|
|
|
|
|
|
|
When need to mention someone or something.
|
|
|
|
|
|
|
|
## API
|
|
|
|
|
|
|
|
```jsx
|
|
|
|
<Mentions onChange={onChange}>
|
|
|
|
<Mentions.Option value="sample">Sample</Mentions.Option>
|
|
|
|
</Mentions>
|
|
|
|
```
|
|
|
|
|
|
|
|
### Mention
|
|
|
|
|
2019-11-22 14:37:39 +08:00
|
|
|
| Property | Description | Type | Default |
|
|
|
|
| --- | --- | --- | --- |
|
2020-06-17 23:18:14 +08:00
|
|
|
| autoFocus | Auto get focus when component mounted | boolean | false |
|
2020-07-01 15:14:31 +08:00
|
|
|
| defaultValue | Default value | string | - |
|
|
|
|
| filterOption | Customize filter option logic | false \| (input: string, option: OptionProps) => boolean | - |
|
|
|
|
| notFoundContent | Set mentions content when not match | ReactNode | `Not Found` |
|
2020-01-17 17:23:48 +08:00
|
|
|
| placement | Set popup placement | `top` \| `bottom` | `bottom` |
|
2020-06-17 23:18:14 +08:00
|
|
|
| prefix | Set trigger prefix keyword | string \| string[] | `@` |
|
|
|
|
| split | Set split string before and after selected mention | string | `` |
|
2020-07-01 15:14:31 +08:00
|
|
|
| validateSearch | Customize trigger search logic | (text: string, props: MentionsProps) => void | - |
|
|
|
|
| value | Set value of mentions | string | - |
|
|
|
|
| onChange | Trigger when value changed | (text: string) => void | - |
|
|
|
|
| onSelect | Trigger when user select the option | (option: OptionProps, prefix: string) => void | - |
|
|
|
|
| onSearch | Trigger when prefix hit | (text: string, prefix: string) => void | - |
|
|
|
|
| onFocus | Trigger when mentions get focus | () => void | - |
|
|
|
|
| onBlur | Trigger when mentions lose focus | () => void | - |
|
|
|
|
| getPopupContainer | Set the mount HTML node for suggestions | () => HTMLElement | - |
|
|
|
|
| autoSize | Textarea height autosize feature, can be set to true \| false or an object { minRows: 2, maxRows: 6 } | boolean \| object | false |
|
|
|
|
| onResize | The callback function that is triggered when textarea resize | function({ width, height }) | - |
|
2019-05-17 12:05:03 +08:00
|
|
|
|
|
|
|
### Mention methods
|
|
|
|
|
2019-11-22 14:37:39 +08:00
|
|
|
| Name | Description |
|
|
|
|
| ------- | ------------ |
|
2020-07-01 15:14:31 +08:00
|
|
|
| blur() | Remove focus |
|
|
|
|
| focus() | Get focus |
|
2019-05-17 12:05:03 +08:00
|
|
|
|
|
|
|
### Option
|
|
|
|
|
2019-11-22 14:37:39 +08:00
|
|
|
| Property | Description | Type | Default |
|
|
|
|
| --- | --- | --- | --- |
|
2020-07-01 15:14:31 +08:00
|
|
|
| children | Suggestion content | ReactNode | - |
|
|
|
|
| value | The value of suggestion, the value will insert into input filed while selected | string | - |
|