This commit is contained in:
wanghaoo 2019-03-06 10:51:52 +08:00
parent 8cf98d7103
commit ab8cf91380
9 changed files with 1672 additions and 1702 deletions

View File

@ -45,7 +45,7 @@ var Tree = function (_React$Component) {
var _this = _possibleConstructorReturn(this, _React$Component.call(this, props));
['onKeyDown', 'onCheck', "onUlFocus", "_focusDom"].forEach(function (m) {
['onKeyDown', 'onCheck', "onUlFocus", "_focusDom", "onUlMouseDown", "onUlMouseEnter", "onUlMouseLeave"].forEach(function (m) {
_this[m] = _this[m].bind(_this);
});
_this.contextmenuKeys = [];
@ -385,7 +385,7 @@ var Tree = function (_React$Component) {
props.onDoubleClick(eventKey, newSt);
};
Tree.prototype.on1Enter = function on1Enter(e, treeNode) {
Tree.prototype.onMouseEnter = function onMouseEnter(e, treeNode) {
this.props.onMouseEnter({
event: e,
node: treeNode
@ -574,7 +574,7 @@ var Tree = function (_React$Component) {
var _this4 = this;
var targetDom = e.target;
if (this.refs.tree == e.target) {
if (this.refs.tree == targetDom && !this.isIn) {
var onFocus = this.props.onFocus;
var _state$selectedKeys = this.state.selectedKeys,
selectedKeys = _state$selectedKeys === undefined ? [] : _state$selectedKeys;
@ -602,7 +602,19 @@ var Tree = function (_React$Component) {
};
Tree.prototype.onUlMouseDown = function onUlMouseDown(e) {
e.preventDefault();
// const targetDom = e.target;
// console.log('mouseDown************',e.target);
// if(this.refs.tree !== targetDom){
// e.preventDefault();
// }
};
Tree.prototype.onUlMouseEnter = function onUlMouseEnter(e) {
this.isIn = true;
};
Tree.prototype.onUlMouseLeave = function onUlMouseLeave(e) {
this.isIn = false;
};
Tree.prototype.getFilterExpandedKeys = function getFilterExpandedKeys(props, expandKeyProp, expandAll) {
@ -818,6 +830,9 @@ var Tree = function (_React$Component) {
role: 'tree-node'
};
domProps.onFocus = this.onUlFocus;
domProps.onMouseEnter = this.onUlMouseEnter;
domProps.onMouseLeave = this.onUlMouseLeave;
// if (props.focusable) {
// // domProps.tabIndex = '0';//需求改成了默认选择第一个节点或者选中的节点
// // domProps.onKeyDown = this.onKeyDown;//添加到具体的treeNode上了
@ -873,7 +888,7 @@ var Tree = function (_React$Component) {
this.selectKeyDomExist = false;
return _react2["default"].createElement(
'ul',
_extends({}, domProps, { unselectable: 'true', ref: 'tree', onFocus: this.onUlFocus, tabIndex: props.focusable && props.tabIndexValue, onMouseDown: this.onUlMouseDown }),
_extends({}, domProps, { unselectable: 'true', ref: 'tree', tabIndex: props.focusable && props.tabIndexValue }),
_react2["default"].Children.map(props.children, this.renderTreeNode, this)
);
};

View File

@ -366,10 +366,6 @@ var TreeNode = function (_React$Component) {
return isLeaf || !loadData && !hasChildren;
};
TreeNode.prototype.onFocus = function onFocus(e) {
e.stopPropagation();
};
TreeNode.prototype.render = function render() {
var _iconEleCls,
_this4 = this;
@ -504,7 +500,6 @@ var TreeNode = function (_React$Component) {
liProps.onDrop = this.onDrop;
liProps.onDragEnd = this.onDragEnd;
}
liProps.onFocus = this.onFocus;
var disabledCls = '';
var dragOverCls = '';
if (props.disabled) {

155
dist/demo.css vendored
View File

@ -2152,13 +2152,13 @@
color: rgb(255,255,255) !important; }
.bg-primary {
background-color: rgb(245, 60, 50) !important; }
background-color: rgb(30,136,229) !important; }
.bg-primary-contrast {
background-color: rgb(255,255,255) !important; }
.bg-primary-dark {
background-color: rgb(230, 0, 18) !important; }
background-color: rgb(21,101,192) !important; }
.bg-accent {
background-color: rgb(67,160,71) !important; }
@ -2167,13 +2167,13 @@
background-color: rgb(255,255,255) !important; }
.text-primary {
color: rgb(245, 60, 50) !important; }
color: rgb(30,136,229) !important; }
.text-primary-contrast {
color: rgb(255,255,255) !important; }
.text-primary-dark {
color: rgb(230, 0, 18) !important; }
color: rgb(21,101,192) !important; }
.text-accent {
color: rgb(67,160,71) !important; }
@ -2181,12 +2181,12 @@
.text-accent-contrast {
color: rgb(255,255,255) !important; }
/*
* 保护有用的浏览器默认样式而不是完全去掉它们
* 一般化的样式为大部分HTML元素提供
* 修复浏览器自身的bug并保证各浏览器的一致性
* 优化CSS可用性用一些小技巧
* 解释代码用注释和详细的文档来
/*
* 保护有用的浏览器默认样式而不是完全去掉它们
* 一般化的样式为大部分HTML元素提供
* 修复浏览器自身的bug并保证各浏览器的一致性
* 优化CSS可用性用一些小技巧
* 解释代码用注释和详细的文档来
*/
html {
width: 100%;
@ -2196,25 +2196,25 @@ html {
-ms-text-size-adjust: 100%;
-webkit-text-size-adjust: 100%; }
/*
* 使body占据整个屏幕删除body边距因此布局容器不会导致额外的溢出
* 去掉默认的margin
/*
* 使body占据整个屏幕删除body边距因此布局容器不会导致额外的溢出
* 去掉默认的margin
*/
body {
margin: 0;
width: 100%;
height: 100%; }
/*
* 主显示屏复位为IE支持
* Source: http://weblog.west-wind.com/posts/2015/Jan/12/main-HTML5-Tag-not-working-in-Internet-Explorer-91011
/*
* 主显示屏复位为IE支持
* Source: http://weblog.west-wind.com/posts/2015/Jan/12/main-HTML5-Tag-not-working-in-Internet-Explorer-91011
*/
main {
display: block; }
/*
* 对具有hidden属性的元素不应用显示
* IE 9 and 10 support.
/*
* 对具有hidden属性的元素不应用显示
* IE 9 and 10 support.
*/
*[hidden] {
display: none !important; }
@ -2415,15 +2415,18 @@ body {
i.uf {
padding: 0 5px; }
/*
* 选择时删除文本阴影及设置默认选中颜色
/*
* 选择时删除文本阴影及设置默认选中颜色
*/
::-moz-selection {
background: rgb(187,222,251);
text-shadow: none; }
::selection {
background: rgb(187,222,251);
text-shadow: none; }
/*
* 默认水平规则
/*
* 默认水平规则
*/
hr {
display: block;
@ -2433,8 +2436,8 @@ hr {
margin: 1em 0;
padding: 0; }
/*
* 删除音频画布iframes图像视频和其容器底部之间的差距
/*
* 删除音频画布iframes图像视频和其容器底部之间的差距
*/
audio,
canvas,
@ -2444,14 +2447,14 @@ svg,
video {
vertical-align: middle; }
/*
* 仅允许垂直调整textareas的大小
/*
* 仅允许垂直调整textareas的大小
*/
textarea {
resize: vertical; }
/* ==========================================================================
浏览器升级提示
/* ==========================================================================
浏览器升级提示
========================================================================== */
.browserupgrade {
margin: 0.2em 0;
@ -2459,8 +2462,8 @@ textarea {
color: #000;
padding: 0.2em 0; }
/*
* 适用于屏幕阅读器的隐藏
/*
* 适用于屏幕阅读器的隐藏
*/
.visuallyhidden {
border: 0;
@ -2472,9 +2475,9 @@ textarea {
position: absolute;
width: 1px; }
/*
* 扩展.visuallyhidden类以允许元素在通过键盘导航时是可对焦的
* https://www.drupal.org/node/897638
/*
* 扩展.visuallyhidden类以允许元素在通过键盘导航时是可对焦的
* https://www.drupal.org/node/897638
*/
.visuallyhidden.focusable:active,
.visuallyhidden.focusable:focus {
@ -2485,9 +2488,9 @@ textarea {
position: static;
width: auto; }
/* ==========================================================================
打印样式内联以避免额外的HTTP请求
/* ==========================================================================
打印样式内联以避免额外的HTTP请求
========================================================================== */
@media print {
*,
@ -2507,9 +2510,9 @@ textarea {
content: " (" attr(href) ")"; }
abbr[title]:after {
content: " (" attr(title) ")"; }
/*
* 不显示片段标识符的链接
* 或使用`javascript`伪协议
/*
* 不显示片段标识符的链接
* 或使用`javascript`伪协议
*/
a[href^="#"]:after,
a[href^="javascript:"]:after {
@ -2518,9 +2521,9 @@ textarea {
blockquote {
border: 1px solid #999;
page-break-inside: avoid; }
/*
* 打印表格:
* http://css-discuss.incutio.com/wiki/Printing_Tables
/*
* 打印表格:
* http://css-discuss.incutio.com/wiki/Printing_Tables
*/
thead {
display: table-header-group; }
@ -2538,8 +2541,8 @@ textarea {
h3 {
page-break-after: avoid; } }
/*
*删除FAB按钮周围的不需要的框 ,主要兼容ios的safari和部分android
/*
*删除FAB按钮周围的不需要的框 ,主要兼容ios的safari和部分android
**/
a, .mdl-accordion, .mdl-button, .mdl-card, .mdl-checkbox, .mdl-dropdown-menu,
.mdl-icon-toggle, .mdl-item, .mdl-radio, .mdl-slider, .mdl-switch, .mdl-tabs__tab {
@ -5288,10 +5291,10 @@ a, .mdl-accordion, .mdl-button, .mdl-card, .mdl-checkbox, .mdl-dropdown-menu,
.u-checkbox input[disabled] {
cursor: not-allowed; }
.u-checkbox input[type='checkbox']:focus + .u-checkbox-label:before {
border-color: rgb(245, 60, 50); }
border-color: rgb(30,136,229); }
.u-checkbox.is-checked .u-checkbox-label:before {
box-shadow: inset 0 0 0 10px rgb(245, 60, 50);
border-color: rgb(245, 60, 50); }
box-shadow: inset 0 0 0 10px rgb(30,136,229);
border-color: rgb(30,136,229); }
.u-checkbox.is-checked .u-checkbox-label:after {
color: #fff;
content: "\e658";
@ -5333,8 +5336,8 @@ a, .mdl-accordion, .mdl-button, .mdl-card, .mdl-checkbox, .mdl-dropdown-menu,
font-size: 14px; }
.u-checkbox.u-checkbox-indeterminate .u-checkbox-label:before {
box-shadow: inset 0 0 0 10px rgb(245, 60, 50);
border-color: rgb(245, 60, 50); }
box-shadow: inset 0 0 0 10px rgb(30,136,229);
border-color: rgb(30,136,229); }
.u-checkbox.u-checkbox-success.is-checked .u-checkbox-label:before {
box-shadow: inset 0 0 0 10px rgb(76,175,80);
@ -5384,8 +5387,8 @@ a, .mdl-accordion, .mdl-button, .mdl-card, .mdl-checkbox, .mdl-dropdown-menu,
position: relative;
vertical-align: middle; }
.u-tree .u-tree-checkbox-checked .u-tree-checkbox-inner, .u-tree .u-tree-checkbox-indeterminate .u-tree-checkbox-inner {
background-color: rgb(245, 60, 50);
border-color: rgb(245, 60, 50); }
background-color: rgb(30,136,229);
border-color: rgb(30,136,229); }
.u-tree .u-tree-checkbox-inner {
position: relative;
top: 0;
@ -5398,8 +5401,8 @@ a, .mdl-accordion, .mdl-button, .mdl-card, .mdl-checkbox, .mdl-dropdown-menu,
background-color: #fff;
transition: all .3s; }
.u-tree .u-tree-checkbox-checked .u-tree-checkbox-inner, .u-tree .u-tree-checkbox-indeterminate .u-tree-checkbox-inner {
background-color: rgb(245, 60, 50);
border-color: rgb(245, 60, 50); }
background-color: rgb(30,136,229);
border-color: rgb(30,136,229); }
.u-tree .u-tree-checkbox-disabled .u-tree-checkbox-inner {
border-color: #d9d9d9;
background-color: #f3f3f3; }
@ -5491,11 +5494,11 @@ a, .mdl-accordion, .mdl-button, .mdl-card, .mdl-checkbox, .mdl-dropdown-menu,
.u-tree li a.u-tree-node-content-wrapper {
width: calc(100% - 18px); }
.u-tree li a:hover {
background-color: rgb(235, 236, 240); }
background-color: rgb(243,243,243); }
.u-tree li a.u-tree-node-selected {
background-color: rgb(235, 236, 240); }
background-color: rgb(243,243,243); }
.u-tree li a.u-tree-node-selected .u-tree-title {
color: rgb(245, 60, 50); }
color: rgb(30,136,229); }
.u-tree li span.u-checkbox {
margin: 2px 4px 0 0; }
.u-tree li span.u-tree-switcher,
@ -6408,7 +6411,7 @@ a, .mdl-accordion, .mdl-button, .mdl-card, .mdl-checkbox, .mdl-dropdown-menu,
background-color: rgb(189,189,189);
border-color: rgb(189,189,189); }
.u-button.colored {
color: rgb(245, 60, 50); }
color: rgb(30,136,229); }
.u-button.colored:focus:not(:active) {
background-color: rgb(238,238,238);
border-color: rgb(189,189,189); }
@ -6431,7 +6434,7 @@ input.u-button[type="submit"] {
width: 38px;
padding: 0;
line-height: normal;
border: 1px solid rgb(165, 173, 186); }
border: 1px solid rgb(189,189,189); }
.u-button-floating.colored {
background: rgb(67,160,71);
color: rgb(255,255,255);
@ -6459,31 +6462,31 @@ input.u-button[type="submit"] {
.u-button-border {
color: rgb(0,0,0);
border: 1px solid rgb(165, 173, 186);
border: 1px solid rgb(189,189,189);
background: rgb(255,255,255); }
.u-button-border:hover {
color: rgb(0,0,0);
background-color: rgb(238,238,238);
border-color: rgb(165, 173, 186); }
border-color: rgb(189,189,189); }
.u-button-border:active {
color: rgb(0,0,0);
background-color: rgb(189,189,189);
border-color: rgb(165, 173, 186); }
border-color: rgb(189,189,189); }
.u-button-border:focus:not(:active) {
color: rgb(0,0,0);
background-color: rgb(238,238,238);
border-color: rgb(165, 173, 186); }
border-color: rgb(189,189,189); }
.u-button.u-button-primary {
color: rgb(255,255,255);
background-color: rgb(245, 60, 50);
border: 1px rgb(245, 60, 50) solid; }
background-color: rgb(30,136,229);
border: 1px rgb(30,136,229) solid; }
.u-button.u-button-primary.focus, .u-button.u-button-primary:focus, .u-button.u-button-primary:hover {
background-color: rgb(230, 0, 18);
border-color: rgb(230, 0, 18); }
background-color: rgb(66,165,245);
border-color: rgb(66,165,245); }
.u-button.u-button-primary.active, .u-button.u-button-primary:active {
background-color: rgb(230, 0, 18);
border-color: rgb(230, 0, 18); }
background-color: rgb(21,101,192);
border-color: rgb(21,101,192); }
.u-button.u-button-secondary {
color: rgb(0,0,0);
@ -6615,17 +6618,17 @@ input.u-button[type="submit"] {
border-color: rgb(0,151,167); }
.u-button-border.u-button-primary {
color: rgb(245, 60, 50);
color: rgb(30,136,229);
background-color: #fff;
border: 1px rgb(245, 60, 50) solid; }
border: 1px rgb(30,136,229) solid; }
.u-button-border.u-button-primary.focus, .u-button-border.u-button-primary:focus, .u-button-border.u-button-primary:hover {
background-color: rgb(230, 0, 18);
border-color: rgb(230, 0, 18);
background-color: rgb(66,165,245);
border-color: rgb(66,165,245);
color: #fff; }
.u-button-border.u-button-primary.active, .u-button-border.u-button-primary:active {
color: #fff;
background-color: rgb(230, 0, 18);
border-color: rgb(230, 0, 18); }
background-color: rgb(21,101,192);
border-color: rgb(21,101,192); }
.u-button-border.u-button-secondary {
color: rgb(224,224,224);
@ -6675,7 +6678,7 @@ input.u-button[type="submit"] {
width: 32px;
padding: 0;
line-height: normal;
border: 1px solid rgb(165, 173, 186); }
border: 1px solid rgb(189,189,189); }
.u-button-lg {
padding: 8px 15px;

2
dist/demo.css.map vendored

File diff suppressed because one or more lines are too long

3150
dist/demo.js vendored

File diff suppressed because one or more lines are too long

6
dist/demo.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,6 @@
{
"name": "bee-tree",
"version": "2.0.2",
"version": "2.0.3",
"description": "Tree ui component for react",
"keywords": [
"react",

View File

@ -21,7 +21,7 @@ function noop() {}
class Tree extends React.Component {
constructor(props) {
super(props);
['onKeyDown', 'onCheck',"onUlFocus","_focusDom"].forEach((m) => {
['onKeyDown', 'onCheck',"onUlFocus","_focusDom","onUlMouseDown","onUlMouseEnter","onUlMouseLeave"].forEach((m) => {
this[m] = this[m].bind(this);
});
this.contextmenuKeys = [];
@ -355,7 +355,7 @@ onExpand(treeNode,keyType) {
props.onDoubleClick(eventKey,newSt);
}
on1Enter(e, treeNode) {
onMouseEnter(e, treeNode) {
this.props.onMouseEnter({
event: e,
node: treeNode
@ -546,7 +546,7 @@ onExpand(treeNode,keyType) {
onUlFocus(e){
const targetDom = e.target;
if(this.refs.tree == e.target){
if(this.refs.tree == targetDom && !this.isIn){
const {onFocus} = this.props;
const {selectedKeys=[]} = this.state;
let tabIndexKey = selectedKeys[0]
@ -575,7 +575,18 @@ onExpand(treeNode,keyType) {
}
onUlMouseDown(e){
e.preventDefault();
// const targetDom = e.target;
// console.log('mouseDown************',e.target);
// if(this.refs.tree !== targetDom){
// e.preventDefault();
// }
}
onUlMouseEnter(e){
this.isIn = true;
}
onUlMouseLeave(e){
this.isIn = false;
}
getFilterExpandedKeys(props, expandKeyProp, expandAll) {
@ -789,6 +800,9 @@ onExpand(treeNode,keyType) {
role: 'tree-node',
};
domProps.onFocus = this.onUlFocus;
domProps.onMouseEnter = this.onUlMouseEnter;
domProps.onMouseLeave = this.onUlMouseLeave;
// if (props.focusable) {
// // domProps.tabIndex = '0';//需求改成了默认选择第一个节点或者选中的节点
// // domProps.onKeyDown = this.onKeyDown;//添加到具体的treeNode上了
@ -844,7 +858,7 @@ onExpand(treeNode,keyType) {
}
this.selectKeyDomExist = false;
return (
<ul {...domProps} unselectable="true" ref="tree" onFocus = {this.onUlFocus} tabIndex={props.focusable && props.tabIndexValue} onMouseDown={this.onUlMouseDown}>
<ul {...domProps} unselectable="true" ref="tree" tabIndex={props.focusable && props.tabIndexValue}>
{React.Children.map(props.children, this.renderTreeNode, this)}
</ul>
);

View File

@ -323,9 +323,7 @@ class TreeNode extends React.Component {
isLeaf || (!loadData && !hasChildren)
);
}
onFocus(e){
e.stopPropagation();
}
render() {
const props = this.props;
const prefixCls = props.prefixCls;
@ -463,7 +461,6 @@ class TreeNode extends React.Component {
liProps.onDrop = this.onDrop;
liProps.onDragEnd = this.onDragEnd;
}
liProps.onFocus = this.onFocus;
let disabledCls = '';
let dragOverCls = '';
if (props.disabled) {