Socket
Socket
Sign inDemoInstall

rc-select

Package Overview
Dependencies
Maintainers
2
Versions
465
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rc-select - npm Package Compare versions

Comparing version 3.1.0 to 3.2.0

examples/suggest.html

45

lib/Select.js

@@ -93,11 +93,13 @@ /** @jsx React.DOM */

var childrenKeys = [];
var filterOption = props.filterOption;
var tags = props.tags;
React.Children.forEach(props.children, (child)=> {
if (!inputValue || !child.props.disabled && getValueFromOptionChild(child).indexOf(inputValue) > -1) {
if (!filterOption || !inputValue || !child.props.disabled && getValueFromOptionChild(child).indexOf(inputValue) > -1) {
sel.push(child);
}
if (!child.props.disabled) {
if (tags && !child.props.disabled) {
childrenKeys.push(getValueFromOptionChild(child));
}
});
if (props.tags) {
if (tags) {
var value = this.state.value || [];

@@ -192,13 +194,16 @@ value = value.filter((v)=> {

var value;
if (isMultipleOrTags(this.props)) {
var props = this.props;
var selectedValue = item.props.value;
if (isMultipleOrTags(props)) {
value = this.state.value.concat();
value.push(item.props.value);
value.push(selectedValue);
} else {
if (this.state.value[0] === item.props.value) {
if (this.state.value[0] === selectedValue) {
this.setOpenState(false);
return;
}
value = [item.props.value];
value = [selectedValue];
}
this.props.onChange(isMultipleOrTags(this.props) ? value : value[0]);
props.onSelect(selectedValue);
props.onChange(isMultipleOrTags(props) ? value : value[0]);
this.setState({

@@ -209,3 +214,3 @@ value: value,

this.setOpenState(false);
if (this.props.combobox) {
if (props.combobox) {
this.setState({

@@ -244,7 +249,12 @@ inputValue: value[0]

removeSelected(value) {
value = this.state.value.filter((v)=> {
return v !== value;
removeSelected(selectedValue) {
var props = this.props;
var value = this.state.value.filter((v)=> {
return v !== selectedValue;
});
this.props.onChange(isMultipleOrTags(this.props) ? value : value[0]);
var canMultiple = isMultipleOrTags(props);
if (canMultiple) {
props.onDeselect(selectedValue);
}
props.onChange(isMultipleOrTags(props) ? value : value[0]);
this.setState({

@@ -257,3 +267,3 @@ value: value

e.stopPropagation();
if (this.state.value.length) {
if (this.state.inputValue || this.state.value.length) {
this.props.onChange(isMultipleOrTags(this.props) ? [] : undefined);

@@ -418,3 +428,5 @@ this.setState({

tags: React.PropTypes.bool,
onChange: React.PropTypes.func
onChange: React.PropTypes.func,
onSelect: React.PropTypes.func,
onDeselect: React.PropTypes.func
};

@@ -424,4 +436,7 @@

prefixCls: 'rc-select',
filterOption: true,
allowClear: true,
onChange: noop,
onSelect: noop,
onDeselect: noop,
notFoundContent: 'Not Found'

@@ -428,0 +443,0 @@ };

{
"name": "rc-select",
"version": "3.1.0",
"version": "3.2.0",
"description": "select ui component for react",

@@ -49,3 +49,5 @@ "keywords": [

"expect.js": "~0.3.1",
"jsonp": "^0.2.0",
"precommit-hook": "^1.0.7",
"querystring": "^0.2.0",
"rc-server": "^2.0.0",

@@ -52,0 +54,0 @@ "rc-tools": "2.x",

@@ -99,2 +99,8 @@ # rc-select

<tr>
<td>filterOption</td>
<td></td>
<td>true</td>
<td>whether filter options by input value</td>
</tr>
<tr>
<td>tags</td>

@@ -118,2 +124,14 @@ <td></td>

<tr>
<td>onSelect</td>
<td>Function</td>
<td></td>
<td>called when a option is selected. param is option's value</td>
</tr>
<tr>
<td>onDeselect</td>
<td>Function</td>
<td></td>
<td>called when a option is deselected. param is option's value. only called for multiple or tags</td>
</tr>
<tr>
<td>onChange</td>

@@ -120,0 +138,0 @@ <td>function(value)</td>

@@ -153,10 +153,13 @@ /** @jsx React.DOM */

var node = React.findDOMNode(instance.refs.input);
React.addons.TestUtils.Simulate.keyDown( node, {key:"A"} )
node.focus();
node.value = 'A';
Simulate.change(node);
setTimeout(function () {
React.addons.TestUtils.Simulate.keyDown( node, {key:"Enter"} )
Simulate.keyDown(node, {
keyCode: KeyCode.ENTER
});
setTimeout(function () {
expect(instance.state.value).to.contain("A");
done();
}, 100);
done();
}, 100);

@@ -163,0 +166,0 @@ });

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc