Commit 6138c036 authored by 陈帅's avatar 陈帅

add hideCheckAll in TagSelect

parent d2de675e
...@@ -6,6 +6,7 @@ export interface ITagSelectProps { ...@@ -6,6 +6,7 @@ export interface ITagSelectProps {
expandable?: boolean; expandable?: boolean;
value?: string[] | number[]; value?: string[] | number[];
style?: React.CSSProperties; style?: React.CSSProperties;
hideCheckAll?: boolean;
} }
export default class TagSelect extends React.Component<ITagSelectProps, any> { export default class TagSelect extends React.Component<ITagSelectProps, any> {
......
...@@ -15,6 +15,9 @@ const TagSelectOption = ({ children, checked, onChange, value }) => ( ...@@ -15,6 +15,9 @@ const TagSelectOption = ({ children, checked, onChange, value }) => (
TagSelectOption.isTagSelectOption = true; TagSelectOption.isTagSelectOption = true;
class TagSelect extends Component { class TagSelect extends Component {
static defaultProps = {
hideCheckAll: false,
};
constructor(props) { constructor(props) {
super(props); super(props);
this.state = { this.state = {
...@@ -87,7 +90,7 @@ class TagSelect extends Component { ...@@ -87,7 +90,7 @@ class TagSelect extends Component {
render() { render() {
const { value, expand } = this.state; 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; const checkedAll = this.getAllTags().length === value.length;
...@@ -97,9 +100,11 @@ class TagSelect extends Component { ...@@ -97,9 +100,11 @@ class TagSelect extends Component {
}); });
return ( return (
<div className={cls} style={style}> <div className={cls} style={style}>
{hideCheckAll ? null : (
<CheckableTag checked={checkedAll} key="tag-select-__all__" onChange={this.onSelectAll}> <CheckableTag checked={checkedAll} key="tag-select-__all__" onChange={this.onSelectAll}>
全部 全部
</CheckableTag> </CheckableTag>
)}
{value && {value &&
React.Children.map(children, child => { React.Children.map(children, child => {
if (this.isTagSelectOption(child)) { if (this.isTagSelectOption(child)) {
......
...@@ -19,7 +19,7 @@ order: 13 ...@@ -19,7 +19,7 @@ order: 13
| defaultValue |默认选中的项 |string[] \| number[] | | | defaultValue |默认选中的项 |string[] \| number[] | |
| onChange | 标签选择的回调函数 | Function(checkedTags) | | | onChange | 标签选择的回调函数 | Function(checkedTags) | |
| expandable | 是否展示 `展开/收起` 按钮 | Boolean | false | | expandable | 是否展示 `展开/收起` 按钮 | Boolean | false |
| hideCheckAll | 隐藏 `全部` 按钮 | Boolean | false |
### TagSelectOption ### TagSelectOption
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment