rc-trigger
base abstract trigger component for react
Last updated 2 years ago by zombiej .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ gnpm install rc-trigger 
SYNC missed versions from official npm registry.

rc-trigger


React Trigger Component

NPM version build status Test coverage Dependencies DevDependencies npm download bundle size dumi

Install

rc-trigger

Usage

Include the default styling and then:

import React from 'react';
import ReactDOM from 'react-dom';
import Trigger from 'rc-trigger';

ReactDOM.render((
  <Trigger
    action={['click']}
    popup={<span>popup</span>}
    popupAlign={{
      points: ['tl', 'bl'],
      offset: [0, 3]
    }}
  >
    <a href='#'>hover</a>
  </Trigger>
), container);

Compatibility

IE / Edge
IE / Edge
Firefox
Firefox
Chrome
Chrome
Safari
Safari
Electron
Electron
IE11, Edge last 2 versions last 2 versions last 2 versions last 2 versions

Example

http://localhost:9001

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

Development

npm install
npm start

API

props

name type default description
alignPoint bool false Popup will align with mouse position (support action of 'click', 'hover' and 'contextMenu')
popupClassName string additional className added to popup
forceRender boolean false whether render popup before first show
destroyPopupOnHide boolean false whether destroy popup when hide
getPopupClassNameFromAlign getPopupClassNameFromAlign(align: Object):String additional className added to popup according to align
action string[] ['hover'] which actions cause popup shown. enum of 'hover','click','focus','contextMenu'
mouseEnterDelay number 0 delay time to show when mouse enter. unit: s.
mouseLeaveDelay number 0.1 delay time to hide when mouse leave. unit: s.
popupStyle Object additional style of popup
prefixCls String rc-trigger-popup prefix class name
popupTransitionName String|Object https://github.com/react-component/animate
maskTransitionName String|Object https://github.com/react-component/animate
onPopupVisibleChange Function call when popup visible is changed
mask boolean false whether to support mask
maskClosable boolean true whether to support click mask to hide
popupVisible boolean whether popup is visible
zIndex number popup's zIndex
defaultPopupVisible boolean whether popup is visible initially
popupAlign Object: alignConfig of [dom-align](https://github.com/yiminghe/dom-align) popup 's align config
onPopupAlign function(popupDomNode, align) callback when popup node is aligned
popup React.Element | function() => React.Element popup content
getPopupContainer getPopupContainer(): HTMLElement function returning html node which will act as popup container
getDocument getDocument(): HTMLElement function returning document node which will be attached click event to close trigger
popupPlacement string use preset popup align config from builtinPlacements, can be merged by popupAlign prop
builtinPlacements object builtin placement align map. used by placement prop
stretch string Let popup div stretch with trigger element. enums of 'width', 'minWidth', 'height', 'minHeight'. (You can also mixed with 'height minWidth')

Test Case

npm test
npm run chrome-test

Coverage

npm run coverage

open coverage/ dir

React 16 Note

After React 16, you won't access popup element's ref in parent component's componentDidMount, which means following code won't work.

class App extends React.Component {
  componentDidMount() {
    this.input.focus(); // error, this.input is undefined.
  }

  render() {
    return (
      <Trigger
        action={['click']}
        popup={<div><input ref={node => this.input = node} type="text" /></div>}
      >
        <button>click</button>
      </Trigger>
    )
  }
}

Consider wrap your popup element to a separate component:

class InputPopup extends React.Component {
  componentDidMount() {
    this.props.onMount();
  }

  render() {
    return (
      <div>
        <input ref={this.props.inputRef} type="text" />
      </div>
    );
  }
}

class App extends React.Component {
  handlePopupMount() {
    this.input.focus(); // error, this.input is undefined.
  }

  render() {
    return (
      <Trigger
        action={['click']}
        popup={<InputPopup inputRef={node => this.input = node} onMount={this.handlePopupMount} />}
      >
        <button>click</button>
      </Trigger>
    )
  }
}

License

rc-trigger is released under the MIT license.

Current Tags

  • 2.7.0-alpha.0                                ...           beta (6 years ago)
  • 5.3.4                                ...           latest (2 years ago)

154 Versions

  • 5.3.4                                ...           2 years ago
  • 5.3.3                                ...           2 years ago
  • 5.3.2                                ...           2 years ago
  • 5.3.1                                ...           3 years ago
  • 5.2.19                                ...           3 years ago
  • 5.2.18                                ...           3 years ago
  • 5.2.17                                ...           3 years ago
  • 5.2.16                                ...           3 years ago
  • 5.2.15                                ...           3 years ago
  • 5.2.14                                ...           3 years ago
  • 5.2.13                                ...           3 years ago
  • 5.2.12                                ...           3 years ago
  • 5.2.11                                ...           3 years ago
  • 5.2.10                                ...           3 years ago
  • 5.2.9                                ...           3 years ago
  • 5.2.8                                ...           4 years ago
  • 5.2.7                                ...           4 years ago
  • 5.2.6                                ...           4 years ago
  • 5.2.5                                ...           4 years ago
  • 5.2.4                                ...           4 years ago
  • 5.2.3                                ...           4 years ago
  • 5.2.2                                ...           4 years ago
  • 5.2.1                                ...           4 years ago
  • 5.2.0                                ...           4 years ago
  • 5.1.2                                ...           4 years ago
  • 5.1.1                                ...           4 years ago
  • 5.1.0                                ...           4 years ago
  • 5.0.9                                ...           4 years ago
  • 5.0.8                                ...           4 years ago
  • 5.0.7                                ...           4 years ago
  • 5.0.6                                ...           4 years ago
  • 5.0.5                                ...           4 years ago
  • 4.4.3                                ...           4 years ago
  • 5.0.4                                ...           4 years ago
  • 5.0.3                                ...           4 years ago
  • 5.0.2                                ...           4 years ago
  • 5.0.1                                ...           4 years ago
  • 5.0.0                                ...           4 years ago
  • 4.5.0-alpha.0 [deprecated]           ...           4 years ago
  • 4.4.2                                ...           4 years ago
  • 4.4.1                                ...           4 years ago
  • 4.4.0                                ...           4 years ago
  • 4.3.5                                ...           4 years ago
  • 4.3.4                                ...           4 years ago
  • 4.3.3                                ...           4 years ago
  • 4.3.2                                ...           4 years ago
  • 4.3.1                                ...           4 years ago
  • 4.3.0                                ...           5 years ago
  • 4.2.2                                ...           5 years ago
  • 4.2.1                                ...           5 years ago
  • 4.2.0                                ...           5 years ago
  • 4.1.0                                ...           5 years ago
  • 4.0.2                                ...           5 years ago
  • 4.0.1                                ...           5 years ago
  • 4.0.0                                ...           5 years ago
  • 4.0.0-rc.5                                ...           5 years ago
  • 4.0.0-rc.4                                ...           5 years ago
  • 4.0.0-rc.3                                ...           5 years ago
  • 4.0.0-rc.2                                ...           5 years ago
  • 4.0.0-rc.1                                ...           5 years ago
  • 4.0.0-rc.0                                ...           5 years ago
  • 4.0.0-alpha.8                                ...           5 years ago
  • 3.0.0                                ...           5 years ago
  • 4.0.0-alpha.7                                ...           5 years ago
  • 4.0.0-alpha.6                                ...           5 years ago
  • 4.0.0-alpha.5                                ...           5 years ago
  • 4.0.0-alpha.4                                ...           5 years ago
  • 4.0.0-alpha.3                                ...           5 years ago
  • 4.0.0-alpha.2                                ...           5 years ago
  • 4.0.0-alpha.1                                ...           5 years ago
  • 4.0.0-alpha.0                                ...           5 years ago
  • 2.6.5                                ...           5 years ago
  • 2.6.4                                ...           5 years ago
  • 2.6.3                                ...           5 years ago
  • 2.7.0-alpha.0                                ...           6 years ago
  • 2.6.2                                ...           6 years ago
  • 2.6.1                                ...           6 years ago
  • 2.6.0                                ...           6 years ago
  • 3.0.0-rc.3                                ...           6 years ago
  • 3.0.0-rc.2                                ...           6 years ago
  • 2.5.4                                ...           6 years ago
  • 3.0.0-rc.1                                ...           6 years ago
  • 3.0.0-rc.0                                ...           6 years ago
  • 2.5.3                                ...           6 years ago
  • 2.5.2                                ...           6 years ago
  • 2.5.1                                ...           6 years ago
  • 2.5.0                                ...           6 years ago
  • 2.4.2                                ...           7 years ago
  • 2.4.1                                ...           7 years ago
  • 2.4.0                                ...           7 years ago
  • 2.3.4                                ...           7 years ago
  • 2.3.3                                ...           7 years ago
  • 2.3.2                                ...           7 years ago
  • 2.3.1                                ...           7 years ago
  • 2.3.0                                ...           7 years ago
  • 2.2.2                                ...           7 years ago
  • 2.2.1                                ...           7 years ago
  • 2.2.0                                ...           7 years ago
  • 2.1.0                                ...           7 years ago
  • 1.11.5                                ...           7 years ago
  • 2.0.2                                ...           7 years ago
  • 2.0.1                                ...           7 years ago
  • 2.0.0                                ...           7 years ago
  • 1.11.4                                ...           7 years ago
  • 1.11.3                                ...           7 years ago
  • 1.11.2                                ...           7 years ago
  • 1.11.1                                ...           7 years ago
  • 1.11.0                                ...           7 years ago
  • 1.10.4                                ...           8 years ago
  • 1.10.3                                ...           8 years ago
  • 1.10.2                                ...           8 years ago
  • 1.10.1                                ...           8 years ago
  • 1.10.0                                ...           8 years ago
  • 1.9.1                                ...           8 years ago
  • 1.8.4                                ...           8 years ago
  • 1.9.0                                ...           8 years ago
  • 1.8.3                                ...           8 years ago
  • 1.8.2                                ...           8 years ago
  • 1.8.1                                ...           8 years ago
  • 1.8.0                                ...           8 years ago
  • 1.7.3                                ...           8 years ago
  • 1.7.2                                ...           8 years ago
  • 1.7.1                                ...           8 years ago
  • 1.7.0                                ...           8 years ago
  • 1.6.3                                ...           8 years ago
  • 1.6.2                                ...           8 years ago
  • 1.6.1                                ...           8 years ago
  • 1.6.0                                ...           8 years ago
  • 1.5.1                                ...           8 years ago
  • 1.5.0                                ...           9 years ago
  • 1.4.4                                ...           9 years ago
  • 1.4.3                                ...           9 years ago
  • 1.4.2                                ...           9 years ago
  • 1.4.1                                ...           9 years ago
  • 1.4.0                                ...           9 years ago
  • 1.3.1                                ...           9 years ago
  • 1.3.0                                ...           9 years ago
  • 1.2.5                                ...           9 years ago
  • 1.2.4                                ...           9 years ago
  • 1.2.3                                ...           9 years ago
  • 1.2.2                                ...           9 years ago
  • 1.2.1                                ...           9 years ago
  • 1.2.0                                ...           9 years ago
  • 1.1.1                                ...           9 years ago
  • 1.1.0                                ...           9 years ago
  • 1.0.6                                ...           9 years ago
  • 1.0.5                                ...           9 years ago
  • 1.0.4                                ...           9 years ago
  • 1.0.3                                ...           9 years ago
  • 1.0.2                                ...           9 years ago
  • 1.0.1                                ...           9 years ago
  • 1.0.0                                ...           9 years ago
  • 0.1.0                                ...           9 years ago
  • 0.0.0                                ...           9 years ago
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (5)
Dev Dependencies (18)
Dependents (2)

Copyright 2013 - present © cnpmjs.org | Home |