Coder Social home page Coder Social logo

cooperhash / rc-mentions Goto Github PK

View Code? Open in Web Editor NEW

This project forked from react-component/mentions

0.0 0.0 0.0 4.67 MB

React Mentions

Home Page: https://rc-mentions.react-component.now.sh

License: MIT License

Shell 0.15% JavaScript 1.17% TypeScript 95.09% Less 3.59%

rc-mentions's Introduction

rc-mentions

NPM version npm download build status Codecov bundle size dumi

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

name description type default
autoFocus Auto get focus when component mounted boolean false
defaultValue Default value string -
filterOption Customize filter option logic false | (input: string, option: OptionProps) => boolean -
notFoundContent Set mentions content when not match ReactNode 'Not Found'
placement Set popup placement 'top' | 'bottom' 'bottom'
direction Set popup direction 'ltr' | 'rtl' 'ltr'
prefix Set trigger prefix keyword string | string[] '@'
rows Set row count number 1
split Set split string before and after selected mention string ' '
validateSearch Customize trigger search logic (text: string, props: MentionsProps) => void -
value Set value of mentions string -
onChange Trigger when value changed (text: string) => void -
onKeyDown Trigger when user hits a key React.KeyboardEventHandler<HTMLTextAreaElement> -
onKeyUp Trigger when user releases a key React.KeyboardEventHandler<HTMLTextAreaElement> -
onSelect Trigger when user select the option (option: OptionProps, prefix: string) => void -
onSearch Trigger when prefix hit (text: string, prefix: string) => void -
onFocus Trigger when mentions get focus React.FocusEventHandler<HTMLTextAreaElement> -
onBlur Trigger when mentions lose focus React.FocusEventHandler<HTMLTextAreaElement> -
getPopupContainer DOM Container for suggestions () => HTMLElement -
autoSize Textarea height autosize feature, can be set to true|false or an object { minRows: 2, maxRows: 6 } boolean | object -
onPressEnter The callback function that is triggered when Enter key is pressed function(e) -
onResize The callback function that is triggered when textarea resize function({ width, height }) -

Methods

name description
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.

rc-mentions's People

Contributors

zombiej avatar madccc avatar afc163 avatar dependabot[bot] avatar dependabot-preview[bot] avatar triptate avatar muxinfeng avatar heiyu4585 avatar zhangyu1818 avatar kerm1it avatar jarvisart avatar gylllll avatar yoyo837 avatar brandonbloom avatar dunqing avatar yociduo avatar vijayst avatar kiner-tang avatar xrkffgg avatar shaodahong avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.