rc-tree-select
Advanced tools
Comparing version 1.4.3 to 1.5.0
@@ -102,2 +102,3 @@ 'use strict'; | ||
onSelect: _react.PropTypes.func, | ||
onDeselect: _react.PropTypes.func, | ||
onSearch: _react.PropTypes.func, | ||
@@ -110,2 +111,3 @@ searchPlaceholder: _react.PropTypes.string, | ||
defaultLabel: _react.PropTypes.oneOfType([_react.PropTypes.array, _react.PropTypes.any]), | ||
labelInValue: _react.PropTypes.bool, | ||
dropdownStyle: _react.PropTypes.object, | ||
@@ -134,2 +136,3 @@ drodownPopupAlign: _react.PropTypes.object, | ||
searchPlaceholder: '', | ||
labelInValue: false, | ||
defaultValue: [], | ||
@@ -139,2 +142,3 @@ onClick: noop, | ||
onSelect: noop, | ||
onDeselect: noop, | ||
onSearch: noop, | ||
@@ -164,12 +168,11 @@ showArrow: true, | ||
} | ||
if (props.treeCheckable && !props.skipHandleInitValue) { | ||
value = this.getValue((0, _util.getTreeNodesStates)(this.renderTreeData() || props.children, value).checkedTreeNodes); | ||
} | ||
var label = this.getLabelFromProps(props, value, 1); | ||
value = this.addLabelToValue(props, value); | ||
value = this.getValue(props, value); | ||
// const label = this.getLabelFromProps(props, value, 1); | ||
var inputValue = ''; | ||
if (props.combobox) { | ||
inputValue = value[0] || ''; | ||
inputValue = value.length ? String(value[0].value) : ''; | ||
} | ||
this.saveInputRef = saveRef.bind(this, 'inputInstance'); | ||
return { value: value, inputValue: inputValue, label: label }; | ||
return { value: value, inputValue: inputValue }; | ||
}, | ||
@@ -180,13 +183,10 @@ | ||
var value = (0, _util.toArray)(nextProps.value); | ||
if (nextProps.treeCheckable && !nextProps.skipHandleInitValue) { | ||
value = this.getValue((0, _util.getTreeNodesStates)(this.renderTreeData(nextProps) || nextProps.children, value).checkedTreeNodes); | ||
} | ||
var label = this.getLabelFromProps(nextProps, value); | ||
value = this.addLabelToValue(nextProps, value); | ||
value = this.getValue(nextProps, value); | ||
this.setState({ | ||
value: value, | ||
label: label | ||
value: value | ||
}); | ||
if (nextProps.combobox) { | ||
this.setState({ | ||
inputValue: value[0] || '' | ||
inputValue: value.length ? String(value[0].key) : '' | ||
}); | ||
@@ -212,2 +212,3 @@ } | ||
componentWillUnmount: function componentWillUnmount() { | ||
this.clearDelayTimer(); | ||
if (this.dropdownContainer) { | ||
@@ -223,2 +224,3 @@ _reactDom2['default'].unmountComponentAtNode(this.dropdownContainer); | ||
var props = this.props; | ||
this.setState({ | ||
@@ -229,3 +231,5 @@ inputValue: val, | ||
if ((0, _util.isCombobox)(props)) { | ||
this.fireChange([val], [val]); | ||
this.fireChange([{ | ||
value: val | ||
}]); | ||
} | ||
@@ -236,2 +240,6 @@ props.onSearch(val); | ||
onDropdownVisibleChange: function onDropdownVisibleChange(open) { | ||
// selection inside combobox cause click | ||
if (!open && document.activeElement === this.getInputDOMNode()) { | ||
return; | ||
} | ||
this.setOpenState(open); | ||
@@ -255,4 +263,19 @@ }, | ||
onInputBlur: function onInputBlur() { | ||
var _this = this; | ||
if ((0, _util.isMultipleOrTagsOrCombobox)(this.props)) { | ||
return; | ||
} | ||
this.clearDelayTimer(); | ||
this.delayTimer = setTimeout(function () { | ||
_this.setOpenState(false); | ||
}, 150); | ||
}, | ||
onInputKeyDown: function onInputKeyDown(event) { | ||
var props = this.props; | ||
if (props.disabled) { | ||
return; | ||
} | ||
var state = this.state; | ||
@@ -263,10 +286,8 @@ var keyCode = event.keyCode; | ||
if (value.length) { | ||
var label = state.label.concat(); | ||
value.pop(); | ||
label.pop(); | ||
this.fireChange(value, label); | ||
var popValue = value.pop(); | ||
props.onDeselect(props.labelInValue ? popValue : popValue.key); | ||
this.fireChange(value); | ||
} | ||
return; | ||
} | ||
if (keyCode === _rcUtil.KeyCode.DOWN) { | ||
@@ -298,5 +319,4 @@ if (!state.open) { | ||
onSelect: function onSelect(selectedKeys, info) { | ||
var _this = this; | ||
var _this2 = this; | ||
var checkEvt = info.event === 'check'; | ||
if (info.selected === false) { | ||
@@ -308,56 +328,45 @@ this.onDeselect(info); | ||
var value = this.state.value; | ||
var label = this.state.label; | ||
var props = this.props; | ||
var selectedValue = (0, _util.getValuePropValue)(item); | ||
var selectedLabel = this.getLabelFromNode(item); | ||
props.onSelect(selectedValue, item); | ||
var event = selectedValue; | ||
if (props.labelInValue) { | ||
event = { | ||
value: event, | ||
label: selectedLabel | ||
}; | ||
} | ||
props.onSelect(event, item); | ||
var checkEvt = info.event === 'check'; | ||
if ((0, _util.isMultipleOrTags)(props)) { | ||
if (checkEvt) { | ||
// TODO treeCheckable does not support tags/dynamic | ||
var checkedNodes = info.checkedNodes; | ||
var checkedNodesPositions = info.checkedNodesPositions; | ||
if (props.showCheckedStrategy === SHOW_ALL) { | ||
checkedNodes = checkedNodes; | ||
} else if (props.showCheckedStrategy === SHOW_PARENT) { | ||
(function () { | ||
var posArr = (0, _util.filterParentPosition)(checkedNodesPositions.map(function (itemObj) { | ||
return itemObj.pos; | ||
})); | ||
checkedNodes = checkedNodesPositions.filter(function (itemObj) { | ||
return posArr.indexOf(itemObj.pos) !== -1; | ||
}).map(function (itemObj) { | ||
return itemObj.node; | ||
}); | ||
})(); | ||
} else { | ||
checkedNodes = checkedNodes.filter(function (n) { | ||
return !n.props.children; | ||
}); | ||
} | ||
value = checkedNodes.map(function (n) { | ||
return (0, _util.getValuePropValue)(n); | ||
value = this.getCheckedNodes(info, props).map(function (n) { | ||
return { | ||
value: (0, _util.getValuePropValue)(n), | ||
label: _this2.getLabelFromNode(n) | ||
}; | ||
}); | ||
label = checkedNodes.map(function (n) { | ||
return _this.getLabelFromNode(n); | ||
}); | ||
} else { | ||
if (value.indexOf(selectedValue) !== -1) { | ||
if ((0, _util.findIndexInValueByKey)(value, selectedValue) !== -1) { | ||
return; | ||
} | ||
value = value.concat([selectedValue]); | ||
label = label.concat([selectedLabel]); | ||
value = value.concat([{ | ||
value: selectedValue, | ||
label: selectedLabel | ||
}]); | ||
} | ||
if (!checkEvt && value.indexOf(selectedValue) !== -1) { | ||
// 设置 multiple 时会有bug。(isValueChange 已有检查,此处注释掉) | ||
// return; | ||
} | ||
// if (!checkEvt && value.indexOf(selectedValue) !== -1) { | ||
// 设置 multiple 时会有bug。(isValueChange 已有检查,此处注释掉) | ||
// return; | ||
// } | ||
} else { | ||
if (value[0] === selectedValue) { | ||
this.setOpenState(false); | ||
if (value.length && value[0].value === selectedValue) { | ||
this.setOpenState(false, true); | ||
return; | ||
} | ||
value = [selectedValue]; | ||
label = [selectedLabel]; | ||
this.setOpenState(false); | ||
value = [{ | ||
value: selectedValue, | ||
label: selectedLabel | ||
}]; | ||
this.setOpenState(false, true); | ||
} | ||
@@ -371,3 +380,2 @@ | ||
extraInfo.checked = info.checked; | ||
// extraInfo.allCheckedNodes = info.checkedNodes; | ||
extraInfo.allCheckedNodes = (0, _util.flatToHierarchy)(info.checkedNodesPositions); | ||
@@ -378,3 +386,3 @@ } else { | ||
this.fireChange(value, label, extraInfo); | ||
this.fireChange(value, extraInfo); | ||
this.setState({ | ||
@@ -412,3 +420,3 @@ inputValue: '' | ||
if (state.inputValue || state.value.length) { | ||
this.fireChange([], []); | ||
this.fireChange([]); | ||
this.setOpenState(false); | ||
@@ -422,3 +430,3 @@ this.setState({ | ||
getLabelBySingleValue: function getLabelBySingleValue(children, value) { | ||
var _this2 = this; | ||
var _this3 = this; | ||
@@ -435,3 +443,3 @@ if (value === undefined) { | ||
if ((0, _util.getValuePropValue)(item) === value) { | ||
label = _this2.getLabelFromNode(item); | ||
label = _this3.getLabelFromNode(item); | ||
} | ||
@@ -455,3 +463,3 @@ }); | ||
} else { | ||
label = this.getLabelByValue(this.renderTreeData(props) || props.children, value); | ||
label = this.getLabelByValue(this.renderTreeData(props) || props.children, (0, _util.toArray)(value))[0]; | ||
} | ||
@@ -461,4 +469,10 @@ return label; | ||
getVLForOnChange: function getVLForOnChange(vls) { | ||
getVLForOnChange: function getVLForOnChange(vls_) { | ||
var vls = vls_; | ||
if (vls !== undefined) { | ||
if (!this.props.labelInValue) { | ||
vls = vls.map(function (v) { | ||
return v.value; | ||
}); | ||
} | ||
return (0, _util.isMultipleOrTags)(this.props) ? vls : vls[0]; | ||
@@ -470,6 +484,6 @@ } | ||
getLabelByValue: function getLabelByValue(children, values) { | ||
var _this3 = this; | ||
var _this4 = this; | ||
return values.map(function (value) { | ||
var label = _this3.getLabelBySingleValue(children, value); | ||
var label = _this4.getLabelBySingleValue(children, value); | ||
if (label === null) { | ||
@@ -492,3 +506,9 @@ return value; | ||
var props = this.props; | ||
if (props.searchPlaceholder) { | ||
var placeholder = undefined; | ||
if ((0, _util.isMultipleOrTagsOrCombobox)(props)) { | ||
placeholder = props.placeholder || props.searchPlaceholder; | ||
} else { | ||
placeholder = props.searchPlaceholder; | ||
} | ||
if (placeholder) { | ||
return _react2['default'].createElement( | ||
@@ -499,4 +519,5 @@ 'span', | ||
onClick: this.onPlaceholderClick, | ||
className: props.prefixCls + '-search__field__placeholder' }, | ||
props.searchPlaceholder | ||
className: props.prefixCls + '-search__field__placeholder' | ||
}, | ||
placeholder | ||
); | ||
@@ -512,3 +533,5 @@ } | ||
{ className: props.prefixCls + '-search__field__wrap' }, | ||
_react2['default'].createElement('input', { ref: this.saveInputRef, | ||
_react2['default'].createElement('input', { | ||
ref: this.saveInputRef, | ||
onBlur: this.onInputBlur, | ||
onChange: this.onInputChange, | ||
@@ -536,7 +559,16 @@ onKeyDown: this.onInputKeyDown, | ||
getValue: function getValue(checkedTreeNodes) { | ||
getValue: function getValue(_props, value) { | ||
if (!(_props.treeCheckable && !_props.skipHandleInitValue)) { | ||
return value; | ||
} | ||
var checkedTreeNodes = (0, _util.getTreeNodesStates)(this.renderTreeData(_props) || _props.children, value.map(function (item) { | ||
return item.value; | ||
})).checkedTreeNodes; | ||
this.checkedTreeNodes = checkedTreeNodes; | ||
var mapVal = function mapVal(arr) { | ||
var mapLabVal = function mapLabVal(arr) { | ||
return arr.map(function (itemObj) { | ||
return (0, _util.getValuePropValue)(itemObj.node); | ||
return { | ||
value: (0, _util.getValuePropValue)(itemObj.node), | ||
label: (0, _util.getPropValue)(itemObj.node, _props.treeNodeLabelProp) | ||
}; | ||
}); | ||
@@ -547,3 +579,3 @@ }; | ||
if (props.showCheckedStrategy === SHOW_ALL) { | ||
checkedValues = mapVal(checkedTreeNodes); | ||
checkedValues = mapLabVal(checkedTreeNodes); | ||
} else if (props.showCheckedStrategy === SHOW_PARENT) { | ||
@@ -554,3 +586,3 @@ (function () { | ||
})); | ||
checkedValues = mapVal(checkedTreeNodes.filter(function (itemObj) { | ||
checkedValues = mapLabVal(checkedTreeNodes.filter(function (itemObj) { | ||
return posArr.indexOf(itemObj.pos) !== -1; | ||
@@ -560,3 +592,3 @@ })); | ||
} else { | ||
checkedValues = mapVal(checkedTreeNodes.filter(function (itemObj) { | ||
checkedValues = mapLabVal(checkedTreeNodes.filter(function (itemObj) { | ||
return !itemObj.node.props.children; | ||
@@ -568,2 +600,28 @@ })); | ||
getCheckedNodes: function getCheckedNodes(info, props) { | ||
// TODO treeCheckable does not support tags/dynamic | ||
var checkedNodes = info.checkedNodes; | ||
var checkedNodesPositions = info.checkedNodesPositions; | ||
if (props.showCheckedStrategy === SHOW_ALL) { | ||
checkedNodes = checkedNodes; | ||
} else if (props.showCheckedStrategy === SHOW_PARENT) { | ||
(function () { | ||
var posArr = (0, _util.filterParentPosition)(checkedNodesPositions.map(function (itemObj) { | ||
return itemObj.pos; | ||
})); | ||
checkedNodes = checkedNodesPositions.filter(function (itemObj) { | ||
return posArr.indexOf(itemObj.pos) !== -1; | ||
}).map(function (itemObj) { | ||
return itemObj.node; | ||
}); | ||
})(); | ||
} else { | ||
checkedNodes = checkedNodes.filter(function (n) { | ||
return !n.props.children; | ||
}); | ||
} | ||
return checkedNodes; | ||
}, | ||
getDeselectedValue: function getDeselectedValue(selectedValue) { | ||
@@ -588,24 +646,30 @@ var checkedTreeNodes = this.checkedTreeNodes; | ||
}); | ||
var label = this.state.label.concat(); | ||
this.state.value.forEach(function (val, index) { | ||
if (newVals.indexOf(val) === -1) { | ||
label.splice(index, 1); | ||
} | ||
}); | ||
this.fireChange(newVals, label, { triggerValue: selectedValue, clear: true }); | ||
this.fireChange(this.state.value.filter(function (val) { | ||
return newVals.indexOf(val.value) !== -1; | ||
}), { triggerValue: selectedValue, clear: true }); | ||
}, | ||
setOpenState: function setOpenState(open) { | ||
var _this4 = this; | ||
setOpenState: function setOpenState(open, needFocus) { | ||
var _this5 = this; | ||
this.clearDelayTimer(); | ||
var props = this.props; | ||
var refs = this.refs; | ||
// can not optimize, if children is empty | ||
// if (this.state.open === open) { | ||
// return; | ||
// } | ||
this.setState({ | ||
open: open | ||
}, function () { | ||
if (open || (0, _util.isMultipleOrTagsOrCombobox)(_this4.props)) { | ||
if (_this4.getInputDOMNode()) { | ||
_this4.getInputDOMNode().focus(); | ||
if (needFocus || open) { | ||
if (open || (0, _util.isMultipleOrTagsOrCombobox)(props)) { | ||
var input = _this5.getInputDOMNode(); | ||
if (input && document.activeElement !== input) { | ||
input.focus(); | ||
} | ||
} else if (refs.selection) { | ||
refs.selection.focus(); | ||
} | ||
} else if (refs.selection) { | ||
refs.selection.focus(); | ||
} | ||
@@ -615,3 +679,29 @@ }); | ||
removeSelected: function removeSelected(selectedValue, e) { | ||
addLabelToValue: function addLabelToValue(props, value_) { | ||
var _this6 = this; | ||
var value = value_; | ||
if (props.labelInValue) { | ||
value.forEach(function (v) { | ||
v.label = v.label || _this6.getLabelFromProps(props, v.value); | ||
}); | ||
} else { | ||
value = value.map(function (v) { | ||
return { | ||
value: v, | ||
label: _this6.getLabelFromProps(props, v) | ||
}; | ||
}); | ||
} | ||
return value; | ||
}, | ||
clearDelayTimer: function clearDelayTimer() { | ||
if (this.delayTimer) { | ||
clearTimeout(this.delayTimer); | ||
this.delayTimer = null; | ||
} | ||
}, | ||
removeSelected: function removeSelected(selectedKey) { | ||
var props = this.props; | ||
@@ -621,18 +711,26 @@ if (props.disabled) { | ||
} | ||
if (e) { | ||
e.stopPropagation(); | ||
} | ||
if ((props.showCheckedStrategy === SHOW_ALL || props.showCheckedStrategy === SHOW_PARENT) && !props.skipHandleInitValue) { | ||
this.getDeselectedValue(selectedValue); | ||
this.getDeselectedValue(selectedKey); | ||
return; | ||
} | ||
var label = this.state.label.concat(); | ||
var index = this.state.value.indexOf(selectedValue); | ||
var label = undefined; | ||
var value = this.state.value.filter(function (singleValue) { | ||
return singleValue !== selectedValue; | ||
if (singleValue.value === selectedKey) { | ||
label = singleValue.label; | ||
} | ||
return singleValue.value !== selectedKey; | ||
}); | ||
if (index !== -1) { | ||
label.splice(index, 1); | ||
var canMultiple = (0, _util.isMultipleOrTags)(props); | ||
if (canMultiple) { | ||
var _event = selectedKey; | ||
if (props.labelInValue) { | ||
_event = { | ||
value: selectedKey, | ||
label: label | ||
}; | ||
} | ||
props.onDeselect(_event); | ||
} | ||
this.fireChange(value, label, { triggerValue: selectedValue, clear: true }); | ||
this.fireChange(value, { triggerValue: selectedKey, clear: true }); | ||
}, | ||
@@ -647,22 +745,18 @@ | ||
isValueChange: function isValueChange(value) { | ||
var sv = this.state.value; | ||
if (typeof sv === 'string') { | ||
sv = [sv]; | ||
} | ||
if (value.length !== sv.length || !value.every(function (val, index) { | ||
return sv[index] === val; | ||
})) { | ||
return true; | ||
} | ||
}, | ||
fireChange: function fireChange(value, label, extraInfo) { | ||
fireChange: function fireChange(value, extraInfo) { | ||
var props = this.props; | ||
if (!('value' in props)) { | ||
this.setState({ | ||
value: value, label: label | ||
value: value | ||
}); | ||
} | ||
if (this.isValueChange(value)) { | ||
var vals = value.map(function (i) { | ||
return i.value; | ||
}); | ||
var sv = this.state.value.map(function (i) { | ||
return i.value; | ||
}); | ||
if (vals.length !== sv.length || !vals.every(function (val, index) { | ||
return sv[index] === val; | ||
})) { | ||
var ex = { preValue: [].concat(_toConsumableArray(this.state.value)) }; | ||
@@ -672,10 +766,11 @@ if (extraInfo) { | ||
} | ||
props.onChange(this.getVLForOnChange(value), this.getVLForOnChange(label), ex); | ||
props.onChange(this.getVLForOnChange(value), ex); | ||
} | ||
}, | ||
renderTopControlNode: function renderTopControlNode() { | ||
var _this5 = this; | ||
var _this7 = this; | ||
var value = this.state.value; | ||
var label = this.state.label; | ||
var props = this.props; | ||
@@ -688,14 +783,15 @@ var choiceTransitionName = props.choiceTransitionName; | ||
if ((0, _util.isSingleMode)(props)) { | ||
var placeholder = _react2['default'].createElement( | ||
var innerNode = _react2['default'].createElement( | ||
'span', | ||
{ key: 'placeholder', | ||
className: prefixCls + '-selection__placeholder' }, | ||
{ | ||
key: 'placeholder', | ||
className: prefixCls + '-selection__placeholder' | ||
}, | ||
props.placeholder | ||
); | ||
var innerNode = placeholder; | ||
if (this.state.label[0]) { | ||
if (value.length) { | ||
innerNode = _react2['default'].createElement( | ||
'span', | ||
{ key: 'value' }, | ||
this.state.label[0] | ||
value[0].label | ||
); | ||
@@ -712,4 +808,4 @@ } | ||
if ((0, _util.isMultipleOrTags)(props)) { | ||
selectedValueNodes = value.map(function (singleValue, index) { | ||
var content = label[index]; | ||
selectedValueNodes = value.map(function (singleValue) { | ||
var content = singleValue.label; | ||
var title = content; | ||
@@ -721,5 +817,10 @@ if (maxTagTextLength && typeof content === 'string' && content.length > maxTagTextLength) { | ||
'li', | ||
{ className: prefixCls + '-selection__choice', | ||
key: singleValue, | ||
title: title }, | ||
_extends({ | ||
style: _util.UNSELECTABLE_STYLE | ||
}, _util.UNSELECTABLE_ATTRIBUTE, { | ||
onMouseDown: _util.preventDefaultEvent, | ||
className: prefixCls + '-selection__choice', | ||
key: singleValue.value, | ||
title: title | ||
}), | ||
_react2['default'].createElement( | ||
@@ -730,4 +831,6 @@ 'span', | ||
), | ||
_react2['default'].createElement('span', { className: prefixCls + '-selection__choice__remove', | ||
onClick: _this5.removeSelected.bind(_this5, singleValue) }) | ||
_react2['default'].createElement('span', { | ||
className: prefixCls + '-selection__choice__remove', | ||
onClick: _this7.removeSelected.bind(_this7, singleValue.value) | ||
}) | ||
); | ||
@@ -738,3 +841,6 @@ }); | ||
'li', | ||
{ className: prefixCls + '-search ' + prefixCls + '-search--inline', key: '__input' }, | ||
{ | ||
className: prefixCls + '-search ' + prefixCls + '-search--inline', | ||
key: '__input' | ||
}, | ||
this.getInputElement() | ||
@@ -746,5 +852,7 @@ )); | ||
_rcAnimate2['default'], | ||
{ className: className, | ||
{ | ||
className: className, | ||
component: 'ul', | ||
transitionName: choiceTransitionName }, | ||
transitionName: choiceTransitionName | ||
}, | ||
selectedValueNodes | ||
@@ -759,2 +867,3 @@ ); | ||
}, | ||
renderTreeData: function renderTreeData(props) { | ||
@@ -766,2 +875,3 @@ var validProps = props || this.props; | ||
}, | ||
render: function render() { | ||
@@ -780,3 +890,3 @@ var _rootCls; | ||
var extraSelectionProps = {}; | ||
if (!(0, _util.isCombobox)(props)) { | ||
if (!(0, _util.isMultipleOrTagsOrCombobox)(props)) { | ||
extraSelectionProps = { | ||
@@ -787,7 +897,9 @@ onKeyDown: this.onKeyDown, | ||
} | ||
var rootCls = (_rootCls = {}, _defineProperty(_rootCls, className, !!className), _defineProperty(_rootCls, prefixCls, 1), _defineProperty(_rootCls, prefixCls + '-open', state.open), _defineProperty(_rootCls, prefixCls + '-combobox', (0, _util.isCombobox)(props)), _defineProperty(_rootCls, prefixCls + '-disabled', disabled), _defineProperty(_rootCls, prefixCls + '-enabled', !disabled), _rootCls); | ||
var rootCls = (_rootCls = {}, _defineProperty(_rootCls, className, !!className), _defineProperty(_rootCls, prefixCls, 1), _defineProperty(_rootCls, prefixCls + '-open', open), _defineProperty(_rootCls, prefixCls + '-combobox', (0, _util.isCombobox)(props)), _defineProperty(_rootCls, prefixCls + '-disabled', disabled), _defineProperty(_rootCls, prefixCls + '-enabled', !disabled), _rootCls); | ||
var clear = _react2['default'].createElement('span', { key: 'clear', | ||
var clear = _react2['default'].createElement('span', { | ||
key: 'clear', | ||
className: prefixCls + '-selection__clear', | ||
onClick: this.onClearSelection }); | ||
onClick: this.onClearSelection | ||
}); | ||
return _react2['default'].createElement( | ||
@@ -806,3 +918,4 @@ _SelectTrigger2['default'], | ||
onSelect: this.onSelect, | ||
ref: 'trigger' }), | ||
ref: 'trigger' | ||
}), | ||
_react2['default'].createElement( | ||
@@ -813,8 +926,10 @@ 'span', | ||
onClick: props.onClick, | ||
className: (0, _classnames2['default'])(rootCls) }, | ||
className: (0, _classnames2['default'])(rootCls) | ||
}, | ||
_react2['default'].createElement( | ||
'span', | ||
_extends({ ref: 'selection', | ||
_extends({ | ||
ref: 'selection', | ||
key: 'selection', | ||
className: prefixCls + '-selection ' + prefixCls + '-selection--' + (multiple ? 'multiple' : 'single'), | ||
className: prefixCls + '-selection\n ' + prefixCls + '-selection--' + (multiple ? 'multiple' : 'single'), | ||
role: 'combobox', | ||
@@ -826,6 +941,10 @@ 'aria-autocomplete': 'list', | ||
ctrlNode, | ||
allowClear && !(0, _util.isMultipleOrTags)(props) ? clear : null, | ||
allowClear && !multiple ? clear : null, | ||
multiple || !props.showArrow ? null : _react2['default'].createElement( | ||
'span', | ||
{ key: 'arrow', className: prefixCls + '-arrow', tabIndex: '-1', style: { outline: 'none' } }, | ||
{ | ||
key: 'arrow', | ||
className: prefixCls + '-arrow', | ||
style: { outline: 'none' } | ||
}, | ||
_react2['default'].createElement('b', null) | ||
@@ -832,0 +951,0 @@ ), |
@@ -171,6 +171,7 @@ 'use strict'; | ||
}; | ||
var vals = props.value || props.defaultValue; | ||
var keys = []; | ||
(0, _util.loopAllChildren)(treeNodes, function (child) { | ||
if (vals.indexOf((0, _util.getValuePropValue)(child)) > -1) { | ||
if (props.value.some(function (item) { | ||
return item.value === (0, _util.getValuePropValue)(child); | ||
})) { | ||
keys.push(child.key); | ||
@@ -177,0 +178,0 @@ } |
@@ -16,2 +16,4 @@ 'use strict'; | ||
exports.toArray = toArray; | ||
exports.preventDefaultEvent = preventDefaultEvent; | ||
exports.findIndexInValueByKey = findIndexInValueByKey; | ||
exports.labelCompatible = labelCompatible; | ||
@@ -77,2 +79,29 @@ exports.isInclude = isInclude; | ||
function preventDefaultEvent(e) { | ||
e.preventDefault(); | ||
} | ||
function findIndexInValueByKey(value, key) { | ||
var index = -1; | ||
for (var i = 0; i < value.length; i++) { | ||
if (value[i].value === key) { | ||
index = i; | ||
break; | ||
} | ||
} | ||
return index; | ||
} | ||
var UNSELECTABLE_STYLE = { | ||
userSelect: 'none', | ||
WebkitUserSelect: 'none' | ||
}; | ||
exports.UNSELECTABLE_STYLE = UNSELECTABLE_STYLE; | ||
var UNSELECTABLE_ATTRIBUTE = { | ||
unselectable: 'unselectable' | ||
}; | ||
exports.UNSELECTABLE_ATTRIBUTE = UNSELECTABLE_ATTRIBUTE; | ||
function labelCompatible(prop) { | ||
@@ -79,0 +108,0 @@ var newProp = prop; |
{ | ||
"name": "rc-tree-select", | ||
"version": "1.4.3", | ||
"version": "1.5.0", | ||
"description": "tree-select ui component for react", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -74,2 +74,3 @@ # rc-tree-select | ||
|value | current selected option(s) | String/Array<String> | - | | ||
|labelInValue| whether to embed label in value, see above value type | Bool | false | | ||
|onChange | called when select treeNode or input value change(combobox) | function(value, label) | - | | ||
@@ -76,0 +77,0 @@ |onSelect | called when select treeNode | function(value, node) | - | |
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
95245
2796
112