feat: select对齐云舍4.0规范 (#3025)

* feat-select 去除group分组

* feat-select 修改clear清空按钮尺寸

* feat-select 调整checkbox位置对齐select/对齐4.0标准

* Select对齐4.0 多选框移到label之前

* Select对齐4.0 itemRender修改参数

* Select对齐4.0 多选框移到label之前&修改分组样式

* city&transfer&tabstransfer更新snapshot

Co-authored-by: xujiahao01 <xujiahao01@baidu.com>
This commit is contained in:
徐佳豪 2022-02-17 10:19:19 +08:00 committed by GitHub
parent 6844e70061
commit 42b128532c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 356 additions and 281 deletions

View File

@ -73,8 +73,8 @@ exports[`Renderer:city 1`] = `
class="cxd-Select-clear"
>
<icon-mock
classname="icon icon-close"
icon="close"
classname="icon icon-close-small"
icon="close-small"
/>
</a>
<span
@ -107,8 +107,8 @@ exports[`Renderer:city 1`] = `
class="cxd-Select-clear"
>
<icon-mock
classname="icon icon-close"
icon="close"
classname="icon icon-close-small"
icon="close-small"
/>
</a>
<span
@ -141,8 +141,8 @@ exports[`Renderer:city 1`] = `
class="cxd-Select-clear"
>
<icon-mock
classname="icon icon-close"
icon="close"
classname="icon icon-close-small"
icon="close-small"
/>
</a>
<span

View File

@ -135,6 +135,17 @@ exports[`Renderer:tabs-transfer 1`] = `
icon="right-arrow-bold"
/>
</a>
<label
class="cxd-Checkbox cxd-Checkbox--checkbox cxd-Checkbox--full cxd-Checkbox--sm"
>
<input
type="checkbox"
/>
<i />
<span
class=""
/>
</label>
<div
class="cxd-TreeSelection-itemLabel"
>
@ -142,17 +153,6 @@ exports[`Renderer:tabs-transfer 1`] = `
法师
</span>
</div>
<label
class="cxd-Checkbox cxd-Checkbox--checkbox cxd-Checkbox--full cxd-Checkbox--sm"
>
<input
type="checkbox"
/>
<i />
<span
class=""
/>
</label>
</div>
<div
class="cxd-TreeSelection-sublist"
@ -163,6 +163,17 @@ exports[`Renderer:tabs-transfer 1`] = `
<div
class="cxd-TreeSelection-itemInner"
>
<label
class="cxd-Checkbox cxd-Checkbox--checkbox cxd-Checkbox--full cxd-Checkbox--sm"
>
<input
type="checkbox"
/>
<i />
<span
class=""
/>
</label>
<div
class="cxd-TreeSelection-itemLabel"
>
@ -170,17 +181,6 @@ exports[`Renderer:tabs-transfer 1`] = `
诸葛亮
</span>
</div>
<label
class="cxd-Checkbox cxd-Checkbox--checkbox cxd-Checkbox--full cxd-Checkbox--sm"
>
<input
type="checkbox"
/>
<i />
<span
class=""
/>
</label>
</div>
</div>
</div>
@ -199,6 +199,17 @@ exports[`Renderer:tabs-transfer 1`] = `
icon="right-arrow-bold"
/>
</a>
<label
class="cxd-Checkbox cxd-Checkbox--checkbox cxd-Checkbox--full cxd-Checkbox--sm"
>
<input
type="checkbox"
/>
<i />
<span
class=""
/>
</label>
<div
class="cxd-TreeSelection-itemLabel"
>
@ -206,17 +217,6 @@ exports[`Renderer:tabs-transfer 1`] = `
战士
</span>
</div>
<label
class="cxd-Checkbox cxd-Checkbox--checkbox cxd-Checkbox--full cxd-Checkbox--sm"
>
<input
type="checkbox"
/>
<i />
<span
class=""
/>
</label>
</div>
<div
class="cxd-TreeSelection-sublist"
@ -227,13 +227,6 @@ exports[`Renderer:tabs-transfer 1`] = `
<div
class="cxd-TreeSelection-itemInner"
>
<div
class="cxd-TreeSelection-itemLabel"
>
<span>
曹操
</span>
</div>
<label
class="cxd-Checkbox cxd-Checkbox--checkbox cxd-Checkbox--full cxd-Checkbox--sm"
>
@ -245,6 +238,13 @@ exports[`Renderer:tabs-transfer 1`] = `
class=""
/>
</label>
<div
class="cxd-TreeSelection-itemLabel"
>
<span>
曹操
</span>
</div>
</div>
</div>
<div
@ -253,13 +253,6 @@ exports[`Renderer:tabs-transfer 1`] = `
<div
class="cxd-TreeSelection-itemInner"
>
<div
class="cxd-TreeSelection-itemLabel"
>
<span>
钟无艳
</span>
</div>
<label
class="cxd-Checkbox cxd-Checkbox--checkbox cxd-Checkbox--full cxd-Checkbox--sm"
>
@ -271,6 +264,13 @@ exports[`Renderer:tabs-transfer 1`] = `
class=""
/>
</label>
<div
class="cxd-TreeSelection-itemLabel"
>
<span>
钟无艳
</span>
</div>
</div>
</div>
</div>
@ -289,13 +289,6 @@ exports[`Renderer:tabs-transfer 1`] = `
icon="right-arrow-bold"
/>
</a>
<div
class="cxd-TreeSelection-itemLabel"
>
<span>
打野
</span>
</div>
<label
class="cxd-Checkbox cxd-Checkbox--checkbox cxd-Checkbox--full cxd-Checkbox--sm"
>
@ -307,6 +300,13 @@ exports[`Renderer:tabs-transfer 1`] = `
class=""
/>
</label>
<div
class="cxd-TreeSelection-itemLabel"
>
<span>
打野
</span>
</div>
</div>
<div
class="cxd-TreeSelection-sublist"
@ -317,6 +317,17 @@ exports[`Renderer:tabs-transfer 1`] = `
<div
class="cxd-TreeSelection-itemInner"
>
<label
class="cxd-Checkbox cxd-Checkbox--checkbox cxd-Checkbox--full cxd-Checkbox--sm"
>
<input
type="checkbox"
/>
<i />
<span
class=""
/>
</label>
<div
class="cxd-TreeSelection-itemLabel"
>
@ -324,6 +335,14 @@ exports[`Renderer:tabs-transfer 1`] = `
李白
</span>
</div>
</div>
</div>
<div
class="cxd-TreeSelection-item"
>
<div
class="cxd-TreeSelection-itemInner"
>
<label
class="cxd-Checkbox cxd-Checkbox--checkbox cxd-Checkbox--full cxd-Checkbox--sm"
>
@ -335,14 +354,6 @@ exports[`Renderer:tabs-transfer 1`] = `
class=""
/>
</label>
</div>
</div>
<div
class="cxd-TreeSelection-item"
>
<div
class="cxd-TreeSelection-itemInner"
>
<div
class="cxd-TreeSelection-itemLabel"
>
@ -350,17 +361,6 @@ exports[`Renderer:tabs-transfer 1`] = `
韩信
</span>
</div>
<label
class="cxd-Checkbox cxd-Checkbox--checkbox cxd-Checkbox--full cxd-Checkbox--sm"
>
<input
type="checkbox"
/>
<i />
<span
class=""
/>
</label>
</div>
</div>
<div
@ -369,13 +369,6 @@ exports[`Renderer:tabs-transfer 1`] = `
<div
class="cxd-TreeSelection-itemInner"
>
<div
class="cxd-TreeSelection-itemLabel"
>
<span>
云中君
</span>
</div>
<label
class="cxd-Checkbox cxd-Checkbox--checkbox cxd-Checkbox--full cxd-Checkbox--sm"
>
@ -387,6 +380,13 @@ exports[`Renderer:tabs-transfer 1`] = `
class=""
/>
</label>
<div
class="cxd-TreeSelection-itemLabel"
>
<span>
云中君
</span>
</div>
</div>
</div>
</div>

View File

@ -95,6 +95,17 @@ exports[`Renderer:transfer 1`] = `
<div
class="cxd-GroupedSelection-item"
>
<label
class="cxd-Checkbox cxd-Checkbox--checkbox cxd-Checkbox--full cxd-Checkbox--sm"
>
<input
type="checkbox"
/>
<i />
<span
class=""
/>
</label>
<div
class="cxd-GroupedSelection-itemLabel"
>
@ -102,6 +113,10 @@ exports[`Renderer:transfer 1`] = `
诸葛亮
</span>
</div>
</div>
<div
class="cxd-GroupedSelection-item"
>
<label
class="cxd-Checkbox cxd-Checkbox--checkbox cxd-Checkbox--full cxd-Checkbox--sm"
>
@ -113,10 +128,6 @@ exports[`Renderer:transfer 1`] = `
class=""
/>
</label>
</div>
<div
class="cxd-GroupedSelection-item"
>
<div
class="cxd-GroupedSelection-itemLabel"
>
@ -124,6 +135,10 @@ exports[`Renderer:transfer 1`] = `
曹操
</span>
</div>
</div>
<div
class="cxd-GroupedSelection-item"
>
<label
class="cxd-Checkbox cxd-Checkbox--checkbox cxd-Checkbox--full cxd-Checkbox--sm"
>
@ -135,10 +150,6 @@ exports[`Renderer:transfer 1`] = `
class=""
/>
</label>
</div>
<div
class="cxd-GroupedSelection-item"
>
<div
class="cxd-GroupedSelection-itemLabel"
>
@ -146,6 +157,10 @@ exports[`Renderer:transfer 1`] = `
钟无艳
</span>
</div>
</div>
<div
class="cxd-GroupedSelection-item"
>
<label
class="cxd-Checkbox cxd-Checkbox--checkbox cxd-Checkbox--full cxd-Checkbox--sm"
>
@ -157,10 +172,6 @@ exports[`Renderer:transfer 1`] = `
class=""
/>
</label>
</div>
<div
class="cxd-GroupedSelection-item"
>
<div
class="cxd-GroupedSelection-itemLabel"
>
@ -168,6 +179,10 @@ exports[`Renderer:transfer 1`] = `
李白
</span>
</div>
</div>
<div
class="cxd-GroupedSelection-item"
>
<label
class="cxd-Checkbox cxd-Checkbox--checkbox cxd-Checkbox--full cxd-Checkbox--sm"
>
@ -179,10 +194,6 @@ exports[`Renderer:transfer 1`] = `
class=""
/>
</label>
</div>
<div
class="cxd-GroupedSelection-item"
>
<div
class="cxd-GroupedSelection-itemLabel"
>
@ -190,6 +201,10 @@ exports[`Renderer:transfer 1`] = `
韩信
</span>
</div>
</div>
<div
class="cxd-GroupedSelection-item"
>
<label
class="cxd-Checkbox cxd-Checkbox--checkbox cxd-Checkbox--full cxd-Checkbox--sm"
>
@ -201,10 +216,6 @@ exports[`Renderer:transfer 1`] = `
class=""
/>
</label>
</div>
<div
class="cxd-GroupedSelection-item"
>
<div
class="cxd-GroupedSelection-itemLabel"
>
@ -212,17 +223,6 @@ exports[`Renderer:transfer 1`] = `
云中君
</span>
</div>
<label
class="cxd-Checkbox cxd-Checkbox--checkbox cxd-Checkbox--full cxd-Checkbox--sm"
>
<input
type="checkbox"
/>
<i />
<span
class=""
/>
</label>
</div>
</div>
</div>
@ -435,6 +435,17 @@ exports[`Renderer:transfer tree 1`] = `
icon="right-arrow-bold"
/>
</a>
<label
class="cxd-Checkbox cxd-Checkbox--checkbox cxd-Checkbox--full cxd-Checkbox--sm"
>
<input
type="checkbox"
/>
<i />
<span
class=""
/>
</label>
<div
class="cxd-TreeSelection-itemLabel"
>
@ -442,17 +453,6 @@ exports[`Renderer:transfer tree 1`] = `
法师
</span>
</div>
<label
class="cxd-Checkbox cxd-Checkbox--checkbox cxd-Checkbox--full cxd-Checkbox--sm"
>
<input
type="checkbox"
/>
<i />
<span
class=""
/>
</label>
</div>
<div
class="cxd-TreeSelection-sublist"
@ -463,6 +463,17 @@ exports[`Renderer:transfer tree 1`] = `
<div
class="cxd-TreeSelection-itemInner"
>
<label
class="cxd-Checkbox cxd-Checkbox--checkbox cxd-Checkbox--full cxd-Checkbox--sm"
>
<input
type="checkbox"
/>
<i />
<span
class=""
/>
</label>
<div
class="cxd-TreeSelection-itemLabel"
>
@ -470,17 +481,6 @@ exports[`Renderer:transfer tree 1`] = `
诸葛亮
</span>
</div>
<label
class="cxd-Checkbox cxd-Checkbox--checkbox cxd-Checkbox--full cxd-Checkbox--sm"
>
<input
type="checkbox"
/>
<i />
<span
class=""
/>
</label>
</div>
</div>
</div>
@ -499,6 +499,17 @@ exports[`Renderer:transfer tree 1`] = `
icon="right-arrow-bold"
/>
</a>
<label
class="cxd-Checkbox cxd-Checkbox--checkbox cxd-Checkbox--full cxd-Checkbox--sm"
>
<input
type="checkbox"
/>
<i />
<span
class=""
/>
</label>
<div
class="cxd-TreeSelection-itemLabel"
>
@ -506,17 +517,6 @@ exports[`Renderer:transfer tree 1`] = `
战士
</span>
</div>
<label
class="cxd-Checkbox cxd-Checkbox--checkbox cxd-Checkbox--full cxd-Checkbox--sm"
>
<input
type="checkbox"
/>
<i />
<span
class=""
/>
</label>
</div>
<div
class="cxd-TreeSelection-sublist"
@ -527,13 +527,6 @@ exports[`Renderer:transfer tree 1`] = `
<div
class="cxd-TreeSelection-itemInner"
>
<div
class="cxd-TreeSelection-itemLabel"
>
<span>
曹操
</span>
</div>
<label
class="cxd-Checkbox cxd-Checkbox--checkbox cxd-Checkbox--full cxd-Checkbox--sm"
>
@ -545,6 +538,13 @@ exports[`Renderer:transfer tree 1`] = `
class=""
/>
</label>
<div
class="cxd-TreeSelection-itemLabel"
>
<span>
曹操
</span>
</div>
</div>
</div>
<div
@ -553,13 +553,6 @@ exports[`Renderer:transfer tree 1`] = `
<div
class="cxd-TreeSelection-itemInner"
>
<div
class="cxd-TreeSelection-itemLabel"
>
<span>
钟无艳
</span>
</div>
<label
class="cxd-Checkbox cxd-Checkbox--checkbox cxd-Checkbox--full cxd-Checkbox--sm"
>
@ -571,6 +564,13 @@ exports[`Renderer:transfer tree 1`] = `
class=""
/>
</label>
<div
class="cxd-TreeSelection-itemLabel"
>
<span>
钟无艳
</span>
</div>
</div>
</div>
</div>
@ -589,13 +589,6 @@ exports[`Renderer:transfer tree 1`] = `
icon="right-arrow-bold"
/>
</a>
<div
class="cxd-TreeSelection-itemLabel"
>
<span>
打野
</span>
</div>
<label
class="cxd-Checkbox cxd-Checkbox--checkbox cxd-Checkbox--full cxd-Checkbox--sm"
>
@ -607,6 +600,13 @@ exports[`Renderer:transfer tree 1`] = `
class=""
/>
</label>
<div
class="cxd-TreeSelection-itemLabel"
>
<span>
打野
</span>
</div>
</div>
<div
class="cxd-TreeSelection-sublist"
@ -617,6 +617,17 @@ exports[`Renderer:transfer tree 1`] = `
<div
class="cxd-TreeSelection-itemInner"
>
<label
class="cxd-Checkbox cxd-Checkbox--checkbox cxd-Checkbox--full cxd-Checkbox--sm"
>
<input
type="checkbox"
/>
<i />
<span
class=""
/>
</label>
<div
class="cxd-TreeSelection-itemLabel"
>
@ -624,6 +635,14 @@ exports[`Renderer:transfer tree 1`] = `
李白
</span>
</div>
</div>
</div>
<div
class="cxd-TreeSelection-item"
>
<div
class="cxd-TreeSelection-itemInner"
>
<label
class="cxd-Checkbox cxd-Checkbox--checkbox cxd-Checkbox--full cxd-Checkbox--sm"
>
@ -635,14 +654,6 @@ exports[`Renderer:transfer tree 1`] = `
class=""
/>
</label>
</div>
</div>
<div
class="cxd-TreeSelection-item"
>
<div
class="cxd-TreeSelection-itemInner"
>
<div
class="cxd-TreeSelection-itemLabel"
>
@ -650,17 +661,6 @@ exports[`Renderer:transfer tree 1`] = `
韩信
</span>
</div>
<label
class="cxd-Checkbox cxd-Checkbox--checkbox cxd-Checkbox--full cxd-Checkbox--sm"
>
<input
type="checkbox"
/>
<i />
<span
class=""
/>
</label>
</div>
</div>
<div
@ -669,13 +669,6 @@ exports[`Renderer:transfer tree 1`] = `
<div
class="cxd-TreeSelection-itemInner"
>
<div
class="cxd-TreeSelection-itemLabel"
>
<span>
云中君
</span>
</div>
<label
class="cxd-Checkbox cxd-Checkbox--checkbox cxd-Checkbox--full cxd-Checkbox--sm"
>
@ -687,6 +680,13 @@ exports[`Renderer:transfer tree 1`] = `
class=""
/>
</label>
<div
class="cxd-TreeSelection-itemLabel"
>
<span>
云中君
</span>
</div>
</div>
</div>
</div>

View File

@ -737,6 +737,7 @@
--Form-select-menu-onDisabled-color: var(--text--muted-color);
--Form-select-menu-onHover-bg: rgba(0, 126, 255, 0.08);
--Form-select-menu-onHover-color: var(--info);
--Form-select-group-color: var(--Form-select-caret-iconColor);
--Form-select-onError-borderColor: var(--Form-input-onError-borderColor);
--Form-select-onFocused-borderColor: var(--Form-input-onFocused-borderColor);
--Form-select-onFocused-color: var(--Form-select-color);
@ -748,8 +749,13 @@
--Form-select-placeholderColor: var(--Form-input-placeholderColor);
--Form-select-popoverGap: 0;
--Form-select-search-height: var(--Form-select-menu-height);
--Form-select-value-bgColor: var(--Form-input-onDisabled-bg);
--Form-select-value-borderColor: var(--Form-select-value-borderColor);
--Form-select-valueIcon-color: var(--Form-select-valueIcon-color);
--Form-select-valueIcon-onHover-color: var(--Form-select-color);
--Form-selectOption-height: var(--Form-input-height);
--Form-selectValue-bg: #{saturate(lighten($info, 40%), 2.5%)};
--Form-selectValue-onHover-bgColor: var(--Form-select-borderColor);
--Form-selectValue-borderColor: #{saturate(lighten($info, 30%), 2.5%)};
--Form-selectValue-color: var(--info);
--Form-selectValue-fontSize: var(--fontSizeSm);
@ -761,6 +767,8 @@
saturate(lighten($info, 40%), 2.5%),
5%
)};
--Form-selectValue-onDisabled-color: var(--Form-select-caret-iconColor);
--Form-valueLabel-maxWidth: #{px2rem(120px)};
--Form-select-onFocus-boxShadow: none;
--IconPicker-content-maxHeight: #{px2rem(350px)};

View File

@ -114,6 +114,18 @@
min-height: 24px;
}
&.#{$ns}TransferDropDown {
padding: 0;
> .#{$ns}ResultBox-value {
background: var(--Form-select-value-bgColor);
&:hover {
background: var(--Form-selectValue-onHover-bgColor);
}
}
}
&.is-mobile {
min-height: calc(var(--Form-input-lineHeight) * var(--fontSizeLg));
border: none;

View File

@ -70,6 +70,10 @@
max-width: 100%;
overflow: hidden;
text-overflow: ellipsis;
&.is-disabled {
color: var(--Form-selectValue-onDisabled-color);
}
}
&--multi {
height: auto;
@ -100,25 +104,34 @@
display: inline-block;
vertical-align: middle;
font-size: var(--Form-selectValue-fontSize);
color: var(--Form-selectValue-color);
background: var(--Form-selectValue-bg);
border: px2rem(1px) solid var(--Form-selectValue-borderColor);
background: var(--Form-select-value-bgColor);
border: px2rem(1px) solid var(--Form-select-value-borderColor);
border-radius: px2rem(2px);
margin-right: var(--gap-xs);
margin-bottom: var(--gap-xs);
&:hover {
background-color: var(--Form-selectValue-onHover-bgColor);
}
}
.#{$ns}Select-valueLabel {
display: inline-block;
max-width: var(--Form-valueLabel-maxWidth);
padding: 0 var(--gap-xs);
overflow: hidden;
vertical-align: top;
text-overflow:ellipsis;
white-space: nowrap;
}
}
&-valueIcon {
cursor: pointer;
border-right: px2rem(1px) solid var(--Form-selectValue-borderColor);
padding: 1px 5px;
color: var(--Form-select-valueIcon-color);
&:hover {
background: var(--Form-selectValue-onHover-bg);
color: var(--Form-select-valueIcon-onHover-color);
}
&.is-disabled {
@ -130,7 +143,8 @@
}
&-arrow {
margin-right: var(--gap-xs);
margin-right: px2rem(12px);
// margin-right: var(--gap-xs);
// margin-left: var(--gap-xs);
width: var(--gap-md);
text-align: center;
@ -172,10 +186,13 @@
&-menu {
max-height: px2rem(300px);
padding-top: px2rem(4px);
padding-bottom: px2rem(4px);
overflow: auto;
user-select: none;
.#{$ns}Checkbox--sm > i {
margin-top: px2rem(-3px);
margin-right: px2rem(4px);
}
&.is-mobile {
width: 100%;
@ -282,7 +299,7 @@
}
&-option-hl {
color: var(--danger);
color: var(--info);
}
&-addBtn {
@ -330,13 +347,15 @@
svg {
fill: var(--Form-input-iconColor);
width: px2rem(10px);
height: px2rem(10px);
width: px2rem(14px);
height: px2rem(14px);
top: 0;
}
&:hover svg {
fill: var(--Form-input-onHover-iconColor);
&:hover > path {
&:first-of-type {
fill: var(--Form-select-valueIcon-color);
}
}
}
}

View File

@ -50,8 +50,7 @@
}
&-group > &-itemLabel {
font-size: var(--fontSizeSm);
padding: var(--gap-xs) var(--gap-xs);
padding: var(--gap-xs) var(--gap-base);
color: var(--text--muted-color);
}
@ -70,7 +69,7 @@
flex-direction: row;
> .#{$ns}Checkbox {
margin-right: 0;
margin-right: px2rem(8px);
}
cursor: pointer;
user-select: none;
@ -91,13 +90,14 @@
}
&-group > &-items > &-item {
padding-left: var(--gap-base);
padding-left: calc(var(--gap-base) * 2);
}
&-itemLabel {
flex-grow: 1;
span {
vertical-align: middle;
white-space: nowrap; // 避免在条件组合中折行
}
}
@ -241,6 +241,11 @@
&-itemLabel {
flex-grow: 1;
span {
margin-left: var(--gap-xs);
vertical-align: middle;
}
}
&-placeholder {
@ -305,6 +310,11 @@
&-itemLabel {
flex-grow: 1;
span {
margin-left: var(--gap-xs);
vertical-align: middle;
}
}
&-placeholder {

View File

@ -174,6 +174,8 @@ $L1: 0px 4px 6px 0px rgba(8, 14, 26, 0.06),
--Form-select-popoverGap: #{$R3};
--Form-select-search-height: #{px2rem(30px)};
--Form-selectValue-color: var(--primary);
--Form-select-value-borderColor: #{$G9};
--Form-select-valueIcon-color: #{$G4};
--InputGroup-select-borderWidth: #{px2rem(1px)};
--InputGroup-select-onFocused-bg: #eaf6fe;

View File

@ -77,16 +77,6 @@ export class ChainedSelection extends BaseSelection<
)}
onClick={() => this.toggleOption(option)}
>
<div className={cx('ChainedSelection-itemLabel')}>
{itemRender(option, {
index: index,
multiple: multiple,
checked: !!~valueArray.indexOf(option),
onChange: () => this.toggleOption(option),
disabled: disabled || option.disabled
})}
</div>
{multiple ? (
<Checkbox
size="sm"
@ -96,6 +86,16 @@ export class ChainedSelection extends BaseSelection<
description={option.description}
/>
) : null}
<div className={cx('ChainedSelection-itemLabel')}>
{itemRender(option, {
index: index,
multiple: multiple,
checked: !!~valueArray.indexOf(option),
onChange: () => this.toggleOption(option),
disabled: disabled || option.disabled
})}
</div>
</div>
);
}

View File

@ -57,16 +57,6 @@ export class GroupedSelection extends BaseSelection {
)}
onClick={() => this.toggleOption(option)}
>
<div className={cx('GroupedSelection-itemLabel')}>
{itemRender(option, {
index: index,
multiple: multiple,
checked: !!~valueArray.indexOf(option),
onChange: () => this.toggleOption(option),
disabled: disabled || option.disabled
})}
</div>
{multiple ? (
<Checkbox
size="sm"
@ -76,6 +66,15 @@ export class GroupedSelection extends BaseSelection {
description={option.description}
/>
) : null}
<div className={cx('GroupedSelection-itemLabel')}>
{itemRender(option, {
index: index,
multiple: multiple,
checked: !!~valueArray.indexOf(option),
onChange: () => this.toggleOption(option),
disabled: disabled || option.disabled
})}
</div>
</div>
);
}

View File

@ -10,6 +10,7 @@ import React from 'react';
import VirtualList from './virtual-list';
import Overlay from './Overlay';
import PopOver from './PopOver';
import TooltipWrapper from './TooltipWrapper';
import Downshift, {ControllerStateAndHelpers} from 'downshift';
import {closeIcon, Icon} from './icons';
// @ts-ignore
@ -377,27 +378,6 @@ export class Select extends React.Component<SelectProps, SelectState> {
constructor(props: SelectProps) {
super(props);
this.open = this.open.bind(this);
this.close = this.close.bind(this);
this.confirm = this.confirm.bind(this);
this.handlePickerChange = this.handlePickerChange.bind(this);
this.toggle = this.toggle.bind(this);
this.onBlur = this.onBlur.bind(this);
this.onFocus = this.onFocus.bind(this);
this.focus = this.focus.bind(this);
this.inputRef = this.inputRef.bind(this);
this.handleChange = this.handleChange.bind(this);
this.handleInputChange = this.handleInputChange.bind(this);
this.clearValue = this.clearValue.bind(this);
this.clearSearchValue = this.clearSearchValue.bind(this);
this.handleStateChange = this.handleStateChange.bind(this);
this.handleKeyPress = this.handleKeyPress.bind(this);
this.getTarget = this.getTarget.bind(this);
this.toggleCheckAll = this.toggleCheckAll.bind(this);
this.handleAddClick = this.handleAddClick.bind(this);
this.handleEditClick = this.handleEditClick.bind(this);
this.handleDeleteClick = this.handleDeleteClick.bind(this);
this.state = {
isOpen: props.defaultOpen || false,
isFocused: false,
@ -432,6 +412,7 @@ export class Select extends React.Component<SelectProps, SelectState> {
}
}
@autobind
open() {
this.props.disabled ||
this.setState(
@ -443,12 +424,14 @@ export class Select extends React.Component<SelectProps, SelectState> {
);
}
@autobind
close() {
this.setState({
isOpen: false
});
}
@autobind
confirm() {
// @ts-ignore
this.handleChange(this.state.pickerSelectItem);
@ -457,6 +440,7 @@ export class Select extends React.Component<SelectProps, SelectState> {
});
}
@autobind
toggle(e?: React.MouseEvent<HTMLDivElement>) {
if (
e &&
@ -476,6 +460,7 @@ export class Select extends React.Component<SelectProps, SelectState> {
);
}
@autobind
onFocus(e: any) {
this.props.disabled ||
this.state.isOpen ||
@ -489,6 +474,7 @@ export class Select extends React.Component<SelectProps, SelectState> {
this.props.onFocus && this.props.onFocus(e);
}
@autobind
onBlur(e: any) {
this.setState({
isFocused: false
@ -497,6 +483,7 @@ export class Select extends React.Component<SelectProps, SelectState> {
this.props.onBlur && this.props.onBlur(e);
}
@autobind
focus() {
this.input
? this.input.focus()
@ -509,6 +496,7 @@ export class Select extends React.Component<SelectProps, SelectState> {
: this.getTarget() && this.getTarget().blur();
}
@autobind
getTarget() {
if (!this.target) {
this.target = findDOMNode(this) as HTMLElement;
@ -516,10 +504,12 @@ export class Select extends React.Component<SelectProps, SelectState> {
return this.target as HTMLElement;
}
@autobind
inputRef(ref: HTMLInputElement) {
this.input = ref;
}
@autobind
toggleCheckAll() {
const {
options,
@ -561,6 +551,7 @@ export class Select extends React.Component<SelectProps, SelectState> {
onChange(simpleValue ? value.map(item => item.value) : value);
}
@autobind
handleInputChange(evt: React.ChangeEvent<HTMLInputElement>) {
const {loadOptions} = this.props;
this.setState(
@ -571,6 +562,7 @@ export class Select extends React.Component<SelectProps, SelectState> {
);
}
@autobind
handlePickerChange(selectItem: any, index: number, confirm?: boolean) {
if (!this.props.multiple) {
selectItem = selectItem[0];
@ -584,6 +576,7 @@ export class Select extends React.Component<SelectProps, SelectState> {
}
}
@autobind
handleChange(selectItem: any) {
const {onChange, multiple, simpleValue, valueField} = this.props;
let {selection} = this.state;
@ -605,6 +598,7 @@ export class Select extends React.Component<SelectProps, SelectState> {
}
}
@autobind
handleStateChange(changes: any) {
const {multiple, checkAll} = this.props;
let update: any = {};
@ -638,6 +632,7 @@ export class Select extends React.Component<SelectProps, SelectState> {
}
}
@autobind
handleKeyPress(e: React.KeyboardEvent) {
if (this.props.multiple && e.key === ' ') {
this.toggle();
@ -645,6 +640,7 @@ export class Select extends React.Component<SelectProps, SelectState> {
}
}
@autobind
clearValue(e: React.MouseEvent<any>) {
const onChange = this.props.onChange;
e.preventDefault();
@ -652,6 +648,7 @@ export class Select extends React.Component<SelectProps, SelectState> {
onChange(this.props.resetValue);
}
@autobind
clearSearchValue() {
const {loadOptions} = this.props;
this.setState(
@ -662,11 +659,13 @@ export class Select extends React.Component<SelectProps, SelectState> {
);
}
@autobind
handleAddClick() {
const {onAdd} = this.props;
onAdd && onAdd();
}
@autobind
handleEditClick(e: Event, item: any) {
const {onEdit} = this.props;
e.preventDefault();
@ -674,6 +673,7 @@ export class Select extends React.Component<SelectProps, SelectState> {
onEdit && onEdit(item);
}
@autobind
handleDeleteClick(e: Event, item: any) {
const {onDelete} = this.props;
e.preventDefault();
@ -688,6 +688,7 @@ export class Select extends React.Component<SelectProps, SelectState> {
renderValue({inputValue, isOpen}: ControllerStateAndHelpers<any>) {
const {
classnames: cx,
multiple,
valuesNoWrap,
placeholder,
@ -711,8 +712,12 @@ export class Select extends React.Component<SelectProps, SelectState> {
return selection.map((item, index) => {
if (!multiple) {
return (
<div className={`${ns}Select-value`} key={index}>
{`${item[labelField || 'label']}`}
<div className={cx('Select-value', {
'is-disabled': disabled
})}
key={index}
>
{item[labelField || 'label']}
</div>
);
}
@ -722,19 +727,26 @@ export class Select extends React.Component<SelectProps, SelectState> {
index === selection.length - 1 ? '' : ' + '
}`
) : (
<div className={`${ns}Select-value`} key={index}>
<span
className={`${ns}Select-valueIcon ${
disabled || item.disabled ? 'is-disabled' : ''
}`}
onClick={this.removeItem.bind(this, index)}
>
×
</span>
<span className={`${ns}Select-valueLabel`}>
{`${item[labelField || 'label']}`}
</span>
</div>
<TooltipWrapper
placement={'top'}
tooltip={item[labelField || 'label']}
trigger={'hover'}
key={index}
>
<div className={`${ns}Select-value`}>
<span className={`${ns}Select-valueLabel`}>
{item[labelField || 'label']}
</span>
<span
className={cx('Select-valueIcon', {
'is-disabled': disabled || item.disabled
})}
onClick={this.removeItem.bind(this, index)}
>
×
</span>
</div>
</TooltipWrapper>
);
});
}
@ -1115,7 +1127,7 @@ export class Select extends React.Component<SelectProps, SelectState> {
!disabled &&
(Array.isArray(value) ? value.length : value !== resetValue) ? (
<a onClick={this.clearValue} className={cx('Select-clear')}>
<Icon icon="close" className="icon" />
<Icon icon="close-small" className="icon" />
</a>
) : null}
{loading ? (

View File

@ -24,6 +24,7 @@ export class TransferDropDown extends Transfer<TransferDropDownProps> {
value,
translate: __,
disabled,
clearable,
className,
onChange,
onSearch,
@ -105,6 +106,7 @@ export class TransferDropDown extends Transfer<TransferDropDownProps> {
onResultClick={onClick}
placeholder={__('Select.placeholder')}
disabled={disabled}
clearable={clearable}
ref={ref}
useMobileUI={useMobileUI}
>

View File

@ -238,16 +238,6 @@ export class TreeSelection extends BaseSelection<
</a>
) : null}
<div className={cx('TreeSelection-itemLabel')}>
{itemRender(option, {
index: index,
multiple: multiple,
checked: checked,
onChange: () => this.toggleOption(option),
disabled: disabled || option.disabled
})}
</div>
{option.defer && option.loading ? <Spinner show size="sm" /> : null}
{multiple && (!option.defer || option.loaded) ? (
@ -260,6 +250,18 @@ export class TreeSelection extends BaseSelection<
description={option.description}
/>
) : null}
<div className={cx('TreeSelection-itemLabel')}>
{itemRender(option, {
index: index,
multiple: multiple,
checked: checked,
onChange: () => this.toggleOption(option),
disabled: disabled || option.disabled
})}
</div>
{option.defer && option.loading ? <Spinner show size="sm" /> : null}
</div>
{hasChildren ? (
<div className={cx('TreeSelection-sublist')}>

View File

@ -6,6 +6,7 @@
import React from 'react';
import CloseIcon from '../icons/close.svg';
import CloseSmallIcon from '../icons/close-small.svg';
import StatusCloseIcon from '../icons/status-close.svg';
import UnDoIcon from '../icons/undo.svg';
import ReDoIcon from '../icons/redo.svg';
@ -108,6 +109,7 @@ export function registerIcon(key: string, component: React.ReactType<{}>) {
}
registerIcon('close', CloseIcon);
registerIcon('close-small', CloseSmallIcon);
registerIcon('status-close', StatusCloseIcon);
registerIcon('undo', UnDoIcon);
registerIcon('redo', ReDoIcon);

View File

@ -0,0 +1,5 @@
<svg
name="multiTone-clear-small" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<path d="M512 832A320 320 0 1 1 512 192a320 320 0 0 1 0 640z" fill="#cdced1" ></path>
<path d="M670.144 398.848L556.992 512l113.152 113.152-45.248 45.248-113.152-113.152-113.152 113.152-45.248-45.248L466.56 512 353.344 398.848l45.248-45.248 113.152 113.152 113.152-113.152 45.248 45.248z" fill="#fff" ></path>
</svg>

After

Width:  |  Height:  |  Size: 473 B

View File

@ -444,6 +444,7 @@ class TransferDropdownRenderer extends BaseTransferRenderer<TransferDropDownProp
showArrow,
deferLoad,
disabled,
clearable,
selectTitle,
selectMode,
multiple,
@ -477,6 +478,7 @@ class TransferDropdownRenderer extends BaseTransferRenderer<TransferDropDownProp
className={className}
value={selectedOptions}
disabled={disabled}
clearable={clearable}
options={options}
onChange={this.handleChange}
option2value={this.option2value}

View File

@ -989,7 +989,7 @@ export function someTree<T extends TreeItem>(
* { id: 3 },
* ]
* }
* ], item => item.id); // 输出 [1, 2, 3]
* ], item => item.id); // 输出 [1, 2, 3]
*
* @param tree
* @param mapper