From 69071616f3d460ac63221e95ef64ea2b322d229f Mon Sep 17 00:00:00 2001
From: 2betop <2betop.cn@gmail.com>
Date: Sat, 9 May 2020 15:14:10 +0800
Subject: [PATCH] =?UTF-8?q?tooltip=20=E4=BD=8D=E7=BD=AE=E6=94=B9=E6=88=90?=
=?UTF-8?q?=E5=B7=A6=E8=BE=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/components/Tree.tsx | 274 ++++++++++++++++++++--------------------
1 file changed, 140 insertions(+), 134 deletions(-)
diff --git a/src/components/Tree.tsx b/src/components/Tree.tsx
index d6d77643..25cbb7a7 100644
--- a/src/components/Tree.tsx
+++ b/src/components/Tree.tsx
@@ -97,7 +97,7 @@ interface TreeSelectorState {
export class TreeSelector extends React.Component<
TreeSelectorProps,
TreeSelectorState
- > {
+> {
static defaultProps = {
showIcon: true,
initiallyOpen: true,
@@ -322,8 +322,8 @@ export class TreeSelector extends React.Component<
joinValues
? value.map(item => item[valueField as string]).join(delimiter)
: extractValue
- ? value.map(item => item[valueField as string])
- : value
+ ? value.map(item => item[valueField as string])
+ : value
);
}
);
@@ -507,8 +507,8 @@ export class TreeSelector extends React.Component<
cascade
? false
: uncheckable ||
- (selfDisabledAffectChildren ? selfDisabled : false) ||
- (multiple && checked)
+ (selfDisabledAffectChildren ? selfDisabled : false) ||
+ (multiple && checked)
);
tmpChildrenChecked = !!childrenItems.childrenChecked;
if (
@@ -564,109 +564,112 @@ export class TreeSelector extends React.Component<
{isEditing && editingItem === item ? (
this.renderInput(checkbox)
) : (
-
+ {!isLeaf ? (
+
this.toggleUnfolded(item)}
+ className={cx('Tree-itemArrow', {
+ 'is-folded': !unfolded[item[valueField]]
+ })}
+ />
+ ) : (
+
+ )}
+
+ {checkbox}
+
+
+ !nodeDisabled &&
+ (multiple
+ ? this.handleCheck(item, !selfChecked)
+ : this.handleSelect(item))
+ }
>
- {!isLeaf ? (
+ {showIcon ? (
this.toggleUnfolded(item)}
- className={cx('Tree-itemArrow', {
- 'is-folded': !unfolded[item[valueField]]
- })}
- />
- ) : (
-
- )}
-
- {checkbox}
-
-
- !nodeDisabled &&
- (multiple
- ? this.handleCheck(item, !selfChecked)
- : this.handleSelect(item))
- }
- >
- {showIcon ? (
-
+ )}
+ />
+ ) : null}
+
+ {highlightTxt
+ ? highlight(item[labelField], highlightTxt)
+ : item[labelField]}
+
+
+ {!nodeDisabled && !isAdding && !isEditing ? (
+
+ {creatable && hasAbility(item, 'creatable') ? (
+
+
+
) : null}
- {highlightTxt
- ? highlight(item[labelField], highlightTxt)
- : item[labelField]}
-
+ {removable && hasAbility(item, 'removable') ? (
+
+
+
+ ) : null}
- {!nodeDisabled && !isAdding && !isEditing ? (
-
- {creatable && hasAbility(item, 'creatable') ? (
-
-
-
- ) : null}
-
- {removable && hasAbility(item, 'removable') ? (
-
-
-
- ) : null}
-
- {editable && hasAbility(item, 'editable') ? (
-
-
-
- ) : null}
-
- ) : null}
-
- )}
+ {editable && hasAbility(item, 'editable') ? (
+
+
+
+ ) : null}
+
+ ) : null}
+
+ )}
{/* 有children而且为展开状态 或者 添加child时 */}
{(childrenItems && unfolded[item[valueField]]) ||
- (isAdding && addingParent === item) ? (
-
- {isAdding && addingParent === item ? (
- -
- {this.renderInput(
- checkbox
- ? React.cloneElement(checkbox, {
+ (isAdding && addingParent === item) ? (
+
+ {isAdding && addingParent === item ? (
+ -
+ {this.renderInput(
+ checkbox
+ ? React.cloneElement(checkbox, {
checked: false,
disabled: true
})
- : null
- )}
-
- ) : null}
- {childrenItems}
-
- ) : !childrenItems &&
- item.placeholder &&
- unfolded[item[valueField]] ? (
-
- -
-
{item.placeholder}
-
-
+ : null
+ )}
+
) : null}
+ {childrenItems}
+
+ ) : !childrenItems &&
+ item.placeholder &&
+ unfolded[item[valueField]] ? (
+
+ -
+
{item.placeholder}
+
+
+ ) : null}
);
});
@@ -722,47 +725,50 @@ export class TreeSelector extends React.Component<
{this.renderList(options, value, false).dom}
>
) : (
-
-
-
- {showIcon ? (
-
- ) : null}
- {rootLabel}
-
- {!disabled &&
- creatable &&
- rootCreatable !== false &&
- !isAdding &&
- !isEditing ? (
-
- {creatable ? (
-
-
-
- ) : null}
-
- ) : null}
-
-
- {isAdding && !addingParent ? (
- - {this.renderInput()}
+ -
+
+
+ {showIcon ? (
+
) : null}
- {this.renderList(options, value, false).dom}
-
-
- )}
+ {rootLabel}
+
+ {!disabled &&
+ creatable &&
+ rootCreatable !== false &&
+ !isAdding &&
+ !isEditing ? (
+
+ {creatable ? (
+
+
+
+ ) : null}
+
+ ) : null}
+
+
+ {isAdding && !addingParent ? (
+ - {this.renderInput()}
+ ) : null}
+ {this.renderList(options, value, false).dom}
+
+
+ )}
) : (
- {placeholder}
- )}
+ {placeholder}
+ )}
);
}