-
Notifications
You must be signed in to change notification settings - Fork 577
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow the use of a custom input component (#739)
- Loading branch information
Showing
8 changed files
with
93 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"react-mentions": minor | ||
--- | ||
|
||
Allow the use of a custom input component |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,4 +8,6 @@ | |
|
||
npm-debug.log* | ||
|
||
*.log | ||
*.log | ||
|
||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import React from 'react' | ||
|
||
import { Mention, MentionsInput } from '../../../src' | ||
|
||
import { provideExampleValue } from './higher-order' | ||
import defaultStyle from './defaultStyle' | ||
import defaultMentionStyle from './defaultMentionStyle' | ||
|
||
// eslint-disable-next-line no-unused-vars | ||
import classNames from './example.module.css' // uses global css selector | ||
|
||
const CustomInput = React.forwardRef((props, ref) => { | ||
return <textarea ref={ref} {...props} className="custom-textarea" /> | ||
}) | ||
|
||
function CustomInputComponent({ value, data, onChange, onAdd }) { | ||
return ( | ||
<div className="custom-input"> | ||
<h3>Custom input component</h3> | ||
|
||
<MentionsInput | ||
value={value} | ||
onChange={onChange} | ||
style={defaultStyle} | ||
placeholder={"Mention people using '@'"} | ||
a11ySuggestionsListLabel={"Suggested mentions"} | ||
inputComponent={CustomInput} | ||
> | ||
<Mention data={data} onAdd={onAdd} style={defaultMentionStyle} /> | ||
</MentionsInput> | ||
</div> | ||
) | ||
} | ||
|
||
const asExample = provideExampleValue('') | ||
|
||
export default asExample(CustomInputComponent) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters