0.2.1 • Published 5 years ago

hy-mentions v0.2.1

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

rc-mentions


React Mentions

NPM version build status Test coverage Dependencies DevDependencies npm download Storybook

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

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
autoSizeauto extend rowsboolean or AutoSizeTypefalse
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'
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-
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-
onBlurTrigger when mentions lose focusReact.FocusEventHandler-
getPopupContainerDOM Container for suggestions() => HTMLElement-

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.