1.2.0 • Published 2 years ago

react-native-mentionable-textinput v1.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

react-native-mentionable-textinput

ReactNative TextInput with enhanced capabilities for mentions

CircleCI

Installation

npm install react-native-mentionable-textinput
npm install react-native-device-info # Needed to fix a well-known textinput bug on Xiaomi family devices
cd ios; pod install ## Needed to link react-native-device-info

Usage

import { TextInputMention } from "react-native-mentionable-textinput";

// ...

<TextInputMention
    mentionsTypes={[
      {
        type: 'users',
        mentionChar: '@',
      },
      {
        type: 'channels',
        mentionChar: '#',
      },
    ]}
    onSend={onSubmit}
    searchMentionableItems={searchItems}
    mentionableItems={itemsFound}
    submitIcon={<Image style={iconStyle} source={{ uri: send }} />}
    mentionIcon={<Image style={iconStyle} source={{ uri: email }} />}
    closeIcon={<Image style={iconStyle} source={{ uri: close }} />}
    maxHeightMentionWindow={200}
  />

Component props

NameTypeMandatoryAdditional info
mentionsTypesArray✔️Type of objects that can be mentioned
initialTextstringInitial text of the text input
placeholderstringText input placeholder
initialMentionedArrayEvery mention is contained in this array. Fill it with inital mention elements
isMentionsDisabledbooleanFalse if text input should not have mentions
isSendButtonDisabledbooleanTrue if text input submit button is disable.
isSmartSearchEnabledbooleanTrue if smart search should be enabled
childrenArray<JSX.Element>Optional view that will be attached above text input
mentionableItemsArray✔️List of visible items that can be mentioned
searchMentionableItems(mentionType: string, searchText: string) => void✔️Search callback to filter mentionable items
onChangeText(text: string, mentioned: Array) => voidCallback passed to text input
onMentionClose() => voidCallback when the list of mentionable items is closed
onSend(text: string, mentioned: Array)✔️Called on submit
onEndTyping() => voidCallback passed to text input
textStyleStylePropStyle of text, excluded mentions
mentionStyleStylePropStyle of mentions, included mention character
mentionContainerStyleStylePropStyle of mentions container view
textInputContainerStyleStylePropStyle of text input container
separatorColorstringColor of the separator between text input and mention window
submitIconJSX.Element✔️Icon for on submit action
mentionIconJSX.Element✔️Icon for mention
closeIconJSX.Element✔️Icon for close
textInputPropsTextInputPropsProps for native TextInput
keyboardAvoidingViewPropsKeyboardAvoidingViewPropsProps for native KeyboardAvoidingView
maxHeightMentionWindownumber✔️Max height of mentions container view
renderMentionType(mentionType: string) => JSX.ElementCustom render of mentionable items

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT