1.2.3 • Published 1 year ago

react-masked-mentions v1.2.3

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

rc-mentions

NPM version Test coverage Dependencies DevDependencies npm download

Screenshots

Feature

  • support ie9,ie9+,chrome,firefox,safari

Keyboard

  • Open mentions (focus input || focus and click)
  • KeyDown/KeyUp/Enter to navigate menu

install

rc-mentions

Usage

basic use

/**
 * inline: true
 */
import Mentions from 'rc-mentions';

const { Option } = Mentions;

var Demo = (
  <Mentions>
    <Option value="light">Light</Option>
    <Option value="bamboo">Bamboo</Option>
    <Option value="cat">Cat</Option>
  </Mentions>
);
React.render(<Demo />, container);

API

Mentions props

namedescriptiontypedefault
autoFocusAuto get focus when component mountedbooleanfalse
defaultValueDefault valuestring-
filterOptionCustomize filter option logicfalse \| (input: string, option: OptionProps) => boolean-
notFoundContentSet mentions content when not matchReactNode'Not Found'
placementSet popup placement'top' \| 'bottom''bottom'
directionSet popup direction'ltr' \| 'rtl''ltr'
prefixSet trigger prefix keywordstring \| string[]'@'
rowsSet row countnumber1
splitSet split string before and after selected mentionstring' '
validateSearchCustomize trigger search logic(text: string, props: MentionsProps) => void-
valueSet value of mentionsstring-
onChangeTrigger when value changed(text: string) => void-
onKeyDownTrigger when user hits a keyReact.KeyboardEventHandler<HTMLTextAreaElement>-
onKeyUpTrigger when user releases a keyReact.KeyboardEventHandler<HTMLTextAreaElement>-
onSelectTrigger when user select the option(option: OptionProps, prefix: string) => void-
onSearchTrigger when prefix hit(text: string, prefix: string) => void-
onFocusTrigger when mentions get focusReact.FocusEventHandler<HTMLTextAreaElement>-
onBlurTrigger when mentions lose focusReact.FocusEventHandler<HTMLTextAreaElement>-
getPopupContainerDOM Container for suggestions() => HTMLElement-
autoSizeTextarea height autosize feature, can be set to true\|false or an object { minRows: 2, maxRows: 6 }boolean \| object-
onPressEnterThe callback function that is triggered when Enter key is pressedfunction(e)-
onResizeThe callback function that is triggered when textarea resizefunction({ width, height })-

Methods

namedescription
focus()Component get focus
blur()Component lose focus

Development

npm install
npm start

Example

http://localhost:9001/

online example: http://react-component.github.io/mentions/

Test Case

npm test

Coverage

npm run coverage

License

rc-mentions is released under the MIT license.

1.2.3

1 year ago

1.2.2

1 year ago

1.2.1

1 year ago

1.2.0

1 year ago

1.1.4

1 year ago

1.1.3

1 year ago

1.1.2

1 year ago

1.1.1

1 year ago

1.1.0

1 year ago