Merge pull request #852 from 306392691/master

为NestedSelect添加checkAll和checkAllLabel选项
This commit is contained in:
RickCole 2020-08-14 15:03:05 +08:00 committed by GitHub
commit be264b0f23
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -38,7 +38,9 @@ export default class NestedSelectControl extends React.Component<
static defaultProps: Partial<NestedSelectProps> = {
cascade: false,
withChildren: false,
searchPromptText: '输入内容进行检索'
searchPromptText: '输入内容进行检索',
checkAll: true,
checkAllLabel: '全选',
};
target: any;
input: HTMLInputElement;
@ -395,6 +397,8 @@ export default class NestedSelectControl extends React.Component<
options,
disabled,
searchable,
checkAll,
checkAllLabel,
searchPromptText,
translate: __,
labelField
@ -430,7 +434,7 @@ export default class NestedSelectControl extends React.Component<
{stack.map((options, index) => (
<div key={index} className={cx('NestedSelect-menu')}>
{index === 0 ? searchInput : null}
{multiple && index === 0 ? (
{multiple && checkAll && index === 0 ? (
<div
className={cx('NestedSelect-option', 'checkall')}
onMouseEnter={this.onMouseEnterAll}
@ -440,7 +444,7 @@ export default class NestedSelectControl extends React.Component<
checked={partialChecked}
partial={partialChecked && !allChecked}
>
{__(checkAllLabel)}
</Checkbox>
</div>
) : null}