Преглед на файлове

add hideCheckAll in TagSelect

陈帅 преди 7 години
родител
ревизия
6138c0362d
променени са 3 файла, в които са добавени 11 реда и са изтрити 5 реда
  1. 1 0
      src/components/TagSelect/index.d.ts
  2. 9 4
      src/components/TagSelect/index.js
  3. 1 1
      src/components/TagSelect/index.md

+ 1 - 0
src/components/TagSelect/index.d.ts

@@ -6,6 +6,7 @@ export interface ITagSelectProps {
   expandable?: boolean;
   value?: string[] | number[];
   style?: React.CSSProperties;
+  hideCheckAll?: boolean;
 }
 
 export default class TagSelect extends React.Component<ITagSelectProps, any> {

+ 9 - 4
src/components/TagSelect/index.js

@@ -15,6 +15,9 @@ const TagSelectOption = ({ children, checked, onChange, value }) => (
 TagSelectOption.isTagSelectOption = true;
 
 class TagSelect extends Component {
+  static defaultProps = {
+    hideCheckAll: false,
+  };
   constructor(props) {
     super(props);
     this.state = {
@@ -87,7 +90,7 @@ class TagSelect extends Component {
 
   render() {
     const { value, expand } = this.state;
-    const { children, className, style, expandable } = this.props;
+    const { children, hideCheckAll, className, style, expandable } = this.props;
 
     const checkedAll = this.getAllTags().length === value.length;
 
@@ -97,9 +100,11 @@ class TagSelect extends Component {
     });
     return (
       <div className={cls} style={style}>
-        <CheckableTag checked={checkedAll} key="tag-select-__all__" onChange={this.onSelectAll}>
-          全部
-        </CheckableTag>
+        {hideCheckAll ? null : (
+          <CheckableTag checked={checkedAll} key="tag-select-__all__" onChange={this.onSelectAll}>
+            全部
+          </CheckableTag>
+        )}
         {value &&
           React.Children.map(children, child => {
             if (this.isTagSelectOption(child)) {

+ 1 - 1
src/components/TagSelect/index.md

@@ -19,7 +19,7 @@ order: 13
 | defaultValue    |默认选中的项   |string[] \| number[] | |
 | onChange | 标签选择的回调函数 | Function(checkedTags) |  |
 | expandable | 是否展示 `展开/收起` 按钮 | Boolean | false |
-
+| hideCheckAll | 隐藏 `全部` 按钮 | Boolean | false |
 
 ### TagSelectOption