2019-05-17 12:05:03 +08:00
|
|
|
---
|
|
|
|
category: Components
|
2022-11-09 12:28:04 +08:00
|
|
|
group: Data Entry
|
2019-05-17 12:05:03 +08:00
|
|
|
title: Mentions
|
2020-05-31 11:48:34 +08:00
|
|
|
cover: https://gw.alipayobjects.com/zos/alicdn/0pF5j477V/Mentions.svg
|
2022-11-09 12:28:04 +08:00
|
|
|
demo:
|
|
|
|
cols: 2
|
2019-05-17 12:05:03 +08:00
|
|
|
---
|
|
|
|
|
|
|
|
Mention component.
|
|
|
|
|
|
|
|
## When To Use
|
|
|
|
|
2021-07-19 16:21:09 +08:00
|
|
|
When you need to mention someone or something.
|
2019-05-17 12:05:03 +08:00
|
|
|
|
2022-11-09 12:28:04 +08:00
|
|
|
## Examples
|
|
|
|
|
2022-11-17 17:31:26 +08:00
|
|
|
<!-- prettier-ignore -->
|
2022-11-09 12:28:04 +08:00
|
|
|
<code src="./demo/basic.tsx">Basic</code>
|
|
|
|
<code src="./demo/async.tsx">Asynchronous loading</code>
|
|
|
|
<code src="./demo/form.tsx">With Form</code>
|
|
|
|
<code src="./demo/prefix.tsx">Customize Trigger Token</code>
|
|
|
|
<code src="./demo/readonly.tsx">disabled or readOnly</code>
|
|
|
|
<code src="./demo/placement.tsx">Placement</code>
|
|
|
|
<code src="./demo/autoSize.tsx">autoSize</code>
|
|
|
|
<code src="./demo/status.tsx">Status</code>
|
|
|
|
<code src="./demo/render-panel.tsx" debug>_InternalPanelDoNotUseOrYouWillBeFired</code>
|
|
|
|
|
2019-05-17 12:05:03 +08:00
|
|
|
## API
|
|
|
|
|
|
|
|
### Mention
|
|
|
|
|
2022-02-16 21:14:05 +08:00
|
|
|
| Property | Description | Type | Default | Version |
|
|
|
|
| --- | --- | --- | --- | --- |
|
|
|
|
| autoFocus | Auto get focus when component mounted | boolean | false | |
|
|
|
|
| autoSize | Textarea height autosize feature, can be set to true \| false or an object { minRows: 2, maxRows: 6 } | boolean \| object | false | |
|
|
|
|
| defaultValue | Default value | string | - | |
|
|
|
|
| filterOption | Customize filter option logic | false \| (input: string, option: OptionProps) => boolean | - | |
|
|
|
|
| getPopupContainer | Set the mount HTML node for suggestions | () => HTMLElement | - | |
|
|
|
|
| notFoundContent | Set mentions content when not match | ReactNode | `Not Found` | |
|
|
|
|
| placement | Set popup placement | `top` \| `bottom` | `bottom` | |
|
|
|
|
| prefix | Set trigger prefix keyword | string \| string\[] | `@` | |
|
|
|
|
| split | Set split string before and after selected mention | string | ` ` | |
|
|
|
|
| status | Set validation status | 'error' \| 'warning' \| 'success' \| 'validating' | - | 4.19.0 |
|
|
|
|
| validateSearch | Customize trigger search logic | (text: string, props: MentionsProps) => void | - | |
|
|
|
|
| value | Set value of mentions | string | - | |
|
|
|
|
| onBlur | Trigger when mentions lose focus | () => void | - | |
|
|
|
|
| onChange | Trigger when value changed | (text: string) => void | - | |
|
|
|
|
| onFocus | Trigger when mentions get focus | () => void | - | |
|
|
|
|
| onResize | The callback function that is triggered when textarea resize | function({ width, height }) | - | |
|
|
|
|
| onSearch | Trigger when prefix hit | (text: string, prefix: string) => void | - | |
|
|
|
|
| onSelect | Trigger when user select the option | (option: OptionProps, prefix: string) => void | - | |
|
2022-11-25 11:12:59 +08:00
|
|
|
| options | Option Configuration | [Options](#Option) | \[] | 5.1.0 |
|
2019-05-17 12:05:03 +08:00
|
|
|
|
|
|
|
### Mention methods
|
|
|
|
|
2022-02-16 21:14:05 +08:00
|
|
|
| Name | Description |
|
|
|
|
| ------- | ------------ |
|
|
|
|
| blur() | Remove focus |
|
|
|
|
| focus() | Get focus |
|
2019-05-17 12:05:03 +08:00
|
|
|
|
|
|
|
### Option
|
|
|
|
|
2022-11-25 11:12:59 +08:00
|
|
|
| Property | Description | Type | Default |
|
|
|
|
| --------- | --------------------------- | ------------------- | ------- |
|
|
|
|
| label | Title of the option | React.ReactNode | - |
|
|
|
|
| key | The key value of the option | string | - |
|
|
|
|
| disabled | Optional | boolean | - |
|
|
|
|
| className | className | string | - |
|
|
|
|
| style | The style of the option | React.CSSProperties | - |
|