react-dropdown-now
Advanced tools
Comparing version 1.0.3 to 1.0.4
@@ -71,2 +71,3 @@ "use strict"; | ||
_this.fireChangeEvent = _this.fireChangeEvent.bind(_assertThisInitialized(_this)); | ||
_this.handleOpenStateEvents = _this.handleOpenStateEvents.bind(_assertThisInitialized(_this)); | ||
return _this; | ||
@@ -111,2 +112,13 @@ } | ||
}, { | ||
key: "handleOpenStateEvents", | ||
value: function handleOpenStateEvents(isOpen) { | ||
if (isOpen && typeof this.props.onOpen === 'function') { | ||
this.props.onOpen(); | ||
} | ||
if (!isOpen && typeof this.props.onClose === 'function') { | ||
this.props.onClose(); | ||
} | ||
} | ||
}, { | ||
key: "handleMouseDown", | ||
@@ -123,5 +135,7 @@ value: function handleMouseDown(event) { | ||
if (!this.props.disabled) { | ||
var isOpen = !this.state.isOpen; | ||
this.setState({ | ||
isOpen: !this.state.isOpen | ||
isOpen: isOpen | ||
}); | ||
this.handleOpenStateEvents(isOpen); | ||
} | ||
@@ -166,2 +180,3 @@ } | ||
this.setState(newState); | ||
this.handleOpenStateEvents(false); | ||
} | ||
@@ -240,2 +255,3 @@ }, { | ||
}); | ||
this.handleOpenStateEvents(false); | ||
} | ||
@@ -300,5 +316,7 @@ } | ||
Dropdown.defaultProps = { | ||
baseClassName: 'Dropdown' | ||
baseClassName: 'Dropdown', | ||
onOpen: function onOpen() {}, | ||
onClose: function onClose() {} | ||
}; | ||
var _default = Dropdown; | ||
exports["default"] = _default; |
@@ -1,3 +0,3 @@ | ||
declare module "react-dropdown-now" { | ||
import * as React from "react"; | ||
declare module 'react-dropdown-now' { | ||
import * as React from 'react'; | ||
export interface Option { | ||
@@ -9,3 +9,3 @@ label: React.ReactNode; | ||
export interface Group { | ||
type: "group"; | ||
type: 'group'; | ||
name: string; | ||
@@ -23,6 +23,8 @@ items: Option[]; | ||
disabled?: boolean; | ||
arrowClosed?: React.ReactNode, | ||
arrowOpen?: React.ReactNode, | ||
arrowClosed?: React.ReactNode; | ||
arrowOpen?: React.ReactNode; | ||
onChange?: (arg: Option) => void; | ||
onFocus?: (arg: boolean) => void; | ||
onOpen?: () => void; | ||
onClose?: () => void; | ||
value?: Option | string; | ||
@@ -32,6 +34,5 @@ placeholder?: String; | ||
class ReactDropdown extends React.Component<ReactDropdownProps> { | ||
} | ||
class ReactDropdown extends React.Component<ReactDropdownProps> {} | ||
export default ReactDropdown; | ||
} |
{ | ||
"name": "react-dropdown-now", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "React dropdown component", | ||
@@ -86,2 +86,3 @@ "main": "dist/index.js", | ||
"lint": "eslint index.js", | ||
"lint:fix": "eslint index.js --fix", | ||
"test": "npm run lint && NODE_ENV=test ava --verbose" | ||
@@ -88,0 +89,0 @@ }, |
@@ -1,3 +0,2 @@ | ||
react-dropdown-now | ||
================== | ||
# react-dropdown-now | ||
@@ -9,2 +8,3 @@ [![NPM version][npm-image]][npm-url] | ||
The [demo page is here.][1] react-dropdown-now is a [fork of react-dropdown.][0] | ||
```Javascript | ||
@@ -61,3 +61,4 @@ import Dropdown from 'react-dropdown-now'; | ||
----------------------------------- | ||
--- | ||
### Customizing | ||
@@ -115,5 +116,14 @@ | ||
**onClose**, **onOpen** | ||
The `onClose` & `onOpen` props enable actions to be taken when the dropdown either opens/closes | ||
```JavaScript | ||
<Dropdown | ||
onClose={() => { /** do something **/ }} | ||
onOpen={() => { /** do something **/ }} />; | ||
``` | ||
More [examples in the docs folder.][2] | ||
[0]: https://github.com/fraserxu/react-dropdown/issues/183 | ||
@@ -123,3 +133,2 @@ [1]: https://iambumblehead.github.io/react-dropdown-now/ | ||
### License | ||
@@ -135,3 +144,2 @@ | ||
[npm-image]: https://img.shields.io/npm/v/react-dropdown-now.svg?style=flat-square | ||
@@ -138,0 +146,0 @@ [npm-url]: https://npmjs.org/package/react-dropdown-now |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
25628
393
146