Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

rc-tree-select

Package Overview
Dependencies
Maintainers
2
Versions
264
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rc-tree-select - npm Package Compare versions

Comparing version 1.5.3 to 1.5.4

152

lib/Select.js

@@ -106,6 +106,6 @@ 'use strict';

placeholder: _react.PropTypes.any,
value: _react.PropTypes.oneOfType([_react.PropTypes.array, _react.PropTypes.string]),
defaultValue: _react.PropTypes.oneOfType([_react.PropTypes.array, _react.PropTypes.string]),
label: _react.PropTypes.oneOfType([_react.PropTypes.array, _react.PropTypes.any]),
defaultLabel: _react.PropTypes.oneOfType([_react.PropTypes.array, _react.PropTypes.any]),
value: _react.PropTypes.oneOfType([_react.PropTypes.array, _react.PropTypes.string, _react.PropTypes.object]),
defaultValue: _react.PropTypes.oneOfType([_react.PropTypes.array, _react.PropTypes.string, _react.PropTypes.object]),
label: _react.PropTypes.any,
defaultLabel: _react.PropTypes.any,
labelInValue: _react.PropTypes.bool,

@@ -118,3 +118,2 @@ dropdownStyle: _react.PropTypes.object,

treeCheckStrictly: _react.PropTypes.bool,
treeHalfCheckedValues: _react.PropTypes.array,
treeIcon: _react.PropTypes.bool,

@@ -289,3 +288,3 @@ treeLine: _react.PropTypes.bool,

var popValue = value.pop();
props.onDeselect(props.labelInValue ? popValue : popValue.key);
props.onDeselect(this.isLabelInValue() ? popValue : popValue.key);
this.fireChange(value);

@@ -333,3 +332,3 @@ }

var event = selectedValue;
if (props.labelInValue) {
if (this.isLabelInValue()) {
event = {

@@ -430,3 +429,7 @@ value: event,

getLabelBySingleValue: function getLabelBySingleValue(children, value) {
getLabelFromNode: function getLabelFromNode(child) {
return (0, _util.getPropValue)(child, this.props.treeNodeLabelProp);
},
getLabelFromProps: function getLabelFromProps(props, value) {
var _this2 = this;

@@ -438,39 +441,7 @@

var label = null;
var loop = function loop(childs) {
_react2['default'].Children.forEach(childs, function (item) {
if (item.props.children) {
loop(item.props.children);
}
if ((0, _util.getValuePropValue)(item) === value) {
label = _this2.getLabelFromNode(item);
}
});
};
loop(children, 0);
return label;
},
getLabelFromNode: function getLabelFromNode(child) {
return (0, _util.getPropValue)(child, this.props.treeNodeLabelProp);
},
getLabelFromProps: function getLabelFromProps(props, value) {
return this.getLabelByValue(this.renderedTreeData || props.children, value);
},
getVLForOnChange: function getVLForOnChange(vls_) {
var vls = vls_;
if (vls !== undefined) {
if (!this.props.labelInValue) {
vls = vls.map(function (v) {
return v.value;
});
(0, _util.loopAllChildren)(this.renderedTreeData || props.children, function (item) {
if ((0, _util.getValuePropValue)(item) === value) {
label = _this2.getLabelFromNode(item);
}
return (0, _util.isMultipleOrTags)(this.props) ? vls : vls[0];
}
return vls;
},
getLabelByValue: function getLabelByValue(children, value) {
var label = this.getLabelBySingleValue(children, value);
});
if (label === null) {

@@ -542,3 +513,17 @@ return value;

getValue: function getValue(_props, value) {
getValue: function getValue(_props, val) {
var _this3 = this;
var value = val;
if (_props.treeCheckable && _props.treeCheckStrictly) {
this.halfCheckedValues = [];
value = [];
val.forEach(function (i) {
if (!i.halfChecked) {
value.push(i);
} else {
_this3.halfCheckedValues.push(i);
}
});
}
if (!(_props.treeCheckable && !_props.treeCheckStrictly)) {

@@ -641,3 +626,3 @@ return value;

setOpenState: function setOpenState(open, needFocus) {
var _this3 = this;
var _this4 = this;

@@ -657,3 +642,3 @@ this.clearDelayTimer();

if (open || (0, _util.isMultipleOrTagsOrCombobox)(props)) {
var input = _this3.getInputDOMNode();
var input = _this4.getInputDOMNode();
if (input && document.activeElement !== input) {

@@ -670,8 +655,15 @@ input.focus();

addLabelToValue: function addLabelToValue(props, value_) {
var _this4 = this;
var _this5 = this;
var value = value_;
if (props.labelInValue) {
value.forEach(function (v) {
v.label = v.label || _this4.getLabelFromProps(props, v.value);
if (this.isLabelInValue()) {
value.forEach(function (v, i) {
if (Object.prototype.toString.call(value[i]) !== '[object Object]') {
value[i] = {
value: '',
label: ''
};
return;
}
v.label = v.label || _this5.getLabelFromProps(props, v.value);
});

@@ -682,3 +674,3 @@ } else {

value: v,
label: _this4.getLabelFromProps(props, v)
label: _this5.getLabelFromProps(props, v)
};

@@ -718,3 +710,3 @@ });

var _event = selectedKey;
if (props.labelInValue) {
if (this.isLabelInValue()) {
_event = {

@@ -738,2 +730,4 @@ value: selectedKey,

fireChange: function fireChange(value, extraInfo) {
var _this6 = this;
var props = this.props;

@@ -754,16 +748,45 @@ if (!('value' in props)) {

})) {
var ex = { preValue: [].concat(_toConsumableArray(this.state.value)) };
if (extraInfo) {
(0, _objectAssign2['default'])(ex, extraInfo);
}
var labs = props.labelInValue ? null : value.map(function (i) {
return i.label;
});
this._savedValue = this.getVLForOnChange(value);
props.onChange(this._savedValue, labs, ex);
(function () {
var ex = { preValue: [].concat(_toConsumableArray(_this6.state.value)) };
if (extraInfo) {
(0, _objectAssign2['default'])(ex, extraInfo);
}
var labs = null;
var vls = value;
if (!_this6.isLabelInValue()) {
labs = value.map(function (i) {
return i.label;
});
vls = vls.map(function (v) {
return v.value;
});
} else if (_this6.halfCheckedValues.length) {
_this6.halfCheckedValues.forEach(function (i) {
if (!vls.some(function (v) {
return v.value === i.value;
})) {
vls.push(i);
}
});
}
_this6._savedValue = (0, _util.isMultipleOrTags)(props) ? vls : vls[0];
props.onChange(_this6._savedValue, labs, ex);
})();
}
},
isLabelInValue: function isLabelInValue() {
var _props2 = this.props;
var treeCheckable = _props2.treeCheckable;
var treeCheckStrictly = _props2.treeCheckStrictly;
var labelInValue = _props2.labelInValue;
if (treeCheckable && treeCheckStrictly) {
return true;
}
return labelInValue || false;
},
renderTopControlNode: function renderTopControlNode() {
var _this5 = this;
var _this7 = this;

@@ -826,3 +849,3 @@ var value = this.state.value;

className: prefixCls + '-selection__choice__remove',
onClick: _this5.removeSelected.bind(_this5, singleValue.value)
onClick: _this7.removeSelected.bind(_this7, singleValue.value)
})

@@ -905,2 +928,3 @@ );

_treeNodesStates: this._treeNodesStates,
halfCheckedValues: this.halfCheckedValues,
multiple: multiple,

@@ -907,0 +931,0 @@ disabled: disabled,

@@ -134,16 +134,16 @@ 'use strict';

defaultExpandAll: props.treeDefaultExpandAll,
checkable: props.treeCheckable,
checkStrictly: props.treeCheckStrictly,
filterTreeNode: this.filterTree,
_treeNodesStates: props._treeNodesStates
};
if (props.treeCheckStrictly && halfCheckedKeys.length) {
trProps.halfCheckedKeys = halfCheckedKeys;
}
// 为避免混乱,checkable 模式下,select 失效
if (trProps.checkable) {
if (props.treeCheckable) {
trProps.selectable = false;
trProps.checkedKeys = keys;
trProps.checkable = props.treeCheckable;
trProps.checkStrictly = props.treeCheckStrictly;
trProps.onCheck = props.onSelect;
if (props.treeCheckStrictly && halfCheckedKeys.length) {
trProps.checkedKeys = { checked: keys, halfChecked: halfCheckedKeys };
} else {
trProps.checkedKeys = keys;
}
} else {

@@ -250,4 +250,4 @@ trProps.selectedKeys = keys;

}
if (props.treeHalfCheckedValues && props.treeHalfCheckedValues.some(function (item) {
return item === (0, _util.getValuePropValue)(child);
if (props.halfCheckedValues && props.halfCheckedValues.some(function (item) {
return item.value === (0, _util.getValuePropValue)(child);
})) {

@@ -254,0 +254,0 @@ halfCheckedKeys.push(child.key);

@@ -313,3 +313,3 @@ /* eslint no-loop-func: 0*/

if (iArr.length > _posArr.length && isInclude(_posArr, iArr)) {
obj[i].checkPart = false;
obj[i].halfChecked = false;
obj[i].checked = checkIt;

@@ -355,3 +355,3 @@ objKeys[index] = null;

}
} else if (obj[i].checkPart) {
} else if (obj[i].halfChecked) {
siblingChecked += 0.5;

@@ -368,8 +368,8 @@ }

parent.checked = false;
parent.checkPart = false;
parent.halfChecked = false;
} else if (siblingChecked === sibling) {
parent.checked = true;
parent.checkPart = false;
parent.halfChecked = false;
} else {
parent.checkPart = true;
parent.halfChecked = true;
parent.checked = false;

@@ -390,3 +390,3 @@ }

function getCheck(treeNodesStates, checkedPositions) {
var checkPartKeys = [];
var halfCheckedKeys = [];
var checkedKeys = [];

@@ -400,8 +400,8 @@ var checkedNodes = [];

checkedNodes.push(_extends({}, itemObj, { pos: item }));
} else if (itemObj.checkPart) {
checkPartKeys.push(itemObj.key);
} else if (itemObj.halfChecked) {
halfCheckedKeys.push(itemObj.key);
}
});
return {
checkPartKeys: checkPartKeys, checkedKeys: checkedKeys, checkedNodes: checkedNodes, treeNodesStates: treeNodesStates, checkedPositions: checkedPositions
halfCheckedKeys: halfCheckedKeys, checkedKeys: checkedKeys, checkedNodes: checkedNodes, treeNodesStates: treeNodesStates, checkedPositions: checkedPositions
};

@@ -418,3 +418,3 @@ }

checked: false,
checkPart: false,
halfChecked: false,
siblingPosition: siblingPosition

@@ -421,0 +421,0 @@ };

{
"name": "rc-tree-select",
"version": "1.5.3",
"version": "1.5.4",
"description": "tree-select ui component for react",

@@ -5,0 +5,0 @@ "keywords": [

@@ -73,3 +73,3 @@ # rc-tree-select

|defaultValue | initial selected treeNode(s) | String/Array<String> | - |
|value | current selected treeNode(s) | String/Array<String> | - |
|value | current selected treeNode(s). | normal: String/Array<String>. labelInValue: {value:String,label:React.Node}/Array<{value,label}>. treeCheckStrictly(halfChecked default false): {value:String,label:React.Node, halfChecked}/Array<{value,label,halfChecked}>. | - |
|labelInValue| whether to embed label in value, see above value type | Bool | false |

@@ -85,3 +85,2 @@ |onChange | called when select treeNode or input value change(combobox) | function(value, label(null), extra) | - |

|treeCheckStrictly | check node precisely, parent and children nodes are not associated| bool | false |
|treeHalfCheckedValues | half checked treeNode values, when set checkStrictly, it works. | array | - |
|filterTreeNode | filter some treeNodes as you need. it should return true | function(treeNode) | - |

@@ -101,3 +100,3 @@ |treeNodeFilterProp | which prop value of treeNode will be used for filter if filterTreeNode return true | String | 'value' |

|value | default as treeNodeFilterProp | String | '' |
|title | tree/subTree's title | String | '---' |
|title | tree/subTree's title | String/element | '---' |
|isLeaf | whether it's leaf node | bool | false |

@@ -104,0 +103,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