fix(web): normalize user transfer picker layout

This commit is contained in:
2026-06-17 23:15:35 +08:00
parent f96d3a2ea4
commit 78d859df92
5 changed files with 160 additions and 67 deletions

View File

@@ -38,13 +38,13 @@ type UserTransferPickerProps = {
data?: Record<string, unknown>;
name?: string;
label?: string | false;
required?: boolean;
className?: string;
style?: CSSProperties;
onChange?: (value: string | string[] | undefined) => void;
multiple?: boolean;
delimiter?: string;
mode?: string;
userSelectMode?: string;
disabled?: boolean;
readOnly?: boolean;
placeholder?: string;
@@ -217,7 +217,7 @@ export class UserTransferPicker extends Component<UserTransferPickerProps, UserT
}
private mode() {
return this.props.mode ?? 'controlled';
return this.props.userSelectMode ?? this.props.mode ?? 'controlled';
}
private effectiveValue(props: UserTransferPickerProps = this.props): PickerValue {
@@ -438,11 +438,9 @@ export class UserTransferPicker extends Component<UserTransferPickerProps, UserT
const {
className,
disabled,
label,
readOnly,
placeholder = '请选择',
clearable = true,
required,
style,
} = this.props;
const {
@@ -465,11 +463,8 @@ export class UserTransferPicker extends Component<UserTransferPickerProps, UserT
const selectedFiltered = filterOptions(draft, selectedSearch);
const displayText = displayTextFor(labels, placeholder);
const fullTitle = labels.map((item) => item.label).join(', ');
const fieldClassName = [
className,
'eip4-user-transfer-field',
].filter(Boolean).join(' ');
const controlClassName = [
className,
'eip4-user-transfer-control',
disabled || readOnly ? 'is-disabled' : '',
labels.length ? '' : 'is-empty',
@@ -477,28 +472,21 @@ export class UserTransferPicker extends Component<UserTransferPickerProps, UserT
return (
<>
<div className={fieldClassName} style={style}>
{label !== false && label ? (
<label className="eip4-user-transfer-label">
{label}
{required ? <span className="eip4-user-transfer-star">*</span> : null}
</label>
<div
className={controlClassName}
onClick={this.openDialog}
role="button"
style={style}
tabIndex={disabled || readOnly ? -1 : 0}
title={fullTitle || undefined}
>
<span className="eip4-user-transfer-text">{displayText}</span>
{clearable && labels.length > 0 && !disabled && !readOnly ? (
<button type="button" onClick={this.clearValue} aria-label="清空">
×
</button>
) : null}
<div
className={controlClassName}
onClick={this.openDialog}
role="button"
tabIndex={disabled || readOnly ? -1 : 0}
title={fullTitle || undefined}
>
<span className="eip4-user-transfer-text">{displayText}</span>
{clearable && labels.length > 0 && !disabled && !readOnly ? (
<button type="button" onClick={this.clearValue} aria-label="清空">
×
</button>
) : null}
<span className="eip4-user-transfer-icon" aria-hidden="true" />
</div>
<span className="eip4-user-transfer-icon" aria-hidden="true" />
</div>
{open ? (