From 6138c0362d3505fd84018a50c5fca2776bda8f4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=B8=85?= Date: Tue, 7 Aug 2018 18:16:08 +0800 Subject: [PATCH] add hideCheckAll in TagSelect --- src/components/TagSelect/index.d.ts | 1 + src/components/TagSelect/index.js | 13 +++++++++---- src/components/TagSelect/index.md | 2 +- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/components/TagSelect/index.d.ts b/src/components/TagSelect/index.d.ts index b17d34d8..736ca52f 100644 --- a/src/components/TagSelect/index.d.ts +++ b/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 { diff --git a/src/components/TagSelect/index.js b/src/components/TagSelect/index.js index 7b2ef95b..b7aea130 100644 --- a/src/components/TagSelect/index.js +++ b/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 (
- - 全部 - + {hideCheckAll ? null : ( + + 全部 + + )} {value && React.Children.map(children, child => { if (this.isTagSelectOption(child)) { diff --git a/src/components/TagSelect/index.md b/src/components/TagSelect/index.md index 608219cd..25a42b57 100644 --- a/src/components/TagSelect/index.md +++ b/src/components/TagSelect/index.md @@ -19,7 +19,7 @@ order: 13 | defaultValue |默认选中的项 |string[] \| number[] | | | onChange | 标签选择的回调函数 | Function(checkedTags) | | | expandable | 是否展示 `展开/收起` 按钮 | Boolean | false | - +| hideCheckAll | 隐藏 `全部` 按钮 | Boolean | false | ### TagSelectOption -- GitLab