Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion src/BootstrapBlazor.Server/Components/Samples/Transfers.razor
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,29 @@
<DemoBlock Title="@Localizer["TransferNormalTitle"]"
Introduction="@Localizer["TransferNormalIntro"]"
Name="Normal">
<Transfer TValue="string" Items="@Items" OnSelectedItemsChanged="@OnSelectedItemsChanged" />
<section ignore class="row form-inline g-3">
<div class="col-12 col-sm-6">
<BootstrapInputGroup>
<BootstrapInputGroupLabel DisplayText="IsWrapItem"></BootstrapInputGroupLabel>
<Switch @bind-Value="_isWrapItem"></Switch>
</BootstrapInputGroup>
</div>
<div class="col-12 col-sm-6">
<BootstrapInputGroup>
<BootstrapInputGroupLabel DisplayText="IsWrapItemText"></BootstrapInputGroupLabel>
<Switch @bind-Value="_isWrapItemText"></Switch>
</BootstrapInputGroup>
</div>
<div class="col-12 col-sm-6">
<BootstrapInputGroup>
<BootstrapInputGroupLabel DisplayText="ItemWidth"></BootstrapInputGroupLabel>
<BootstrapInput @bind-Value="@_itemWidth"></BootstrapInput>
</BootstrapInputGroup>
</div>
</section>
<Transfer TValue="string" Items="@Items"
IsWrapItem="_isWrapItem" IsWrapItemText="_isWrapItemText" ItemWidth="@_itemWidth"
OnSelectedItemsChanged="@OnSelectedItemsChanged" />
<ConsoleLogger @ref="Logger" />
</DemoBlock>

Expand Down
12 changes: 9 additions & 3 deletions src/BootstrapBlazor.Server/Components/Samples/Transfers.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ public sealed partial class Transfers : ComponentBase

private IEnumerable<SelectedItem> SelectedValue { get; set; } = Enumerable.Empty<SelectedItem>();

private bool _isWrapItem = true;
private bool _isWrapItemText = true;
private string? _itemWidth = "160px";

private Task OnSelectedItemsChanged(IEnumerable<SelectedItem> items)
{
Logger.Log(string.Join(" ", items.Select(i => i.Text)));
Expand All @@ -59,15 +63,17 @@ protected override async Task OnInitializedAsync()
// 模拟异步加载数据源
await Task.Delay(100);

Items = GeneratorItems();
var items = GeneratorItems().ToList();
items[1].Text = "我是一个超级长的专门为了测试溢出折行功能的候选项";
Items = items;
Items1 = GeneratorItems();
Items2 = GeneratorItems();

Items3 = Enumerable.Range(1, 15).Select(i => new SelectedItem()
Items3 = [.. Enumerable.Range(1, 15).Select(i => new SelectedItem()
{
Text = $"{Localizer["Backup"]} {i:d2}",
Value = i.ToString()
}).ToList();
})];

Items4 = GeneratorItems();
Items5 = GeneratorItems();
Expand Down
2 changes: 1 addition & 1 deletion src/BootstrapBlazor.Server/Locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -3219,7 +3219,7 @@
"PlaceHolder": "Please enter",
"TransfersTitle": "Transfer",
"TransferNormalTitle": "Basic usage",
"TransferNormalIntro": "Searchable",
"TransferNormalIntro": "Select the candidate items on the left and click the move button to move them to the right",
"TransferCustomerTitle": "Customizable",
"TransferCustomerIntro": "You can customize the list title copy, button copy, rendering function of data items, check status copy at the bottom of the list, content area at the bottom of the list, and so on.",
"TransferSearchTitle": "Searchable",
Expand Down
2 changes: 1 addition & 1 deletion src/BootstrapBlazor.Server/Locales/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -3219,7 +3219,7 @@
"PlaceHolder": "请输入",
"TransfersTitle": "Transfer 穿梭框",
"TransferNormalTitle": "基础用法",
"TransferNormalIntro": "可搜索",
"TransferNormalIntro": "左边勾选候选项点击移动按钮将候选项移动到右侧",
"TransferCustomerTitle": "可自定义",
"TransferCustomerIntro": "可以对列表标题文案、按钮文案、数据项的渲染函数、列表底部的勾选状态文案、列表底部的内容区等进行自定义。",
"TransferSearchTitle": "可搜索",
Expand Down
6 changes: 4 additions & 2 deletions src/BootstrapBlazor/Components/Transfer/Transfer.razor
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@
HeaderTemplate="LeftHeaderTemplate!" ItemTemplate="LeftItemTemplate!">
</TransferPanel>
<div class="transfer-buttons">
<Button Color="@Color.Primary" IsDisabled="@GetButtonState(RightItems)" OnClick="() => TransferItems(RightItems, LeftItems, false)">
<Button Color="@Color.Primary" IsDisabled="@GetButtonState(RightItems)"
OnClick="() => TransferItems(RightItems, LeftItems, false)">
<i class="@LeftIcon"></i>
<span class="@LeftButtonClassName">@LeftButtonText</span>
</Button>
<Button Color="@Color.Primary" IsDisabled="@GetButtonState(LeftItems)" OnClick="() => TransferItems(LeftItems, RightItems, true)">
<Button Color="@Color.Primary" IsDisabled="@GetButtonState(LeftItems)"
OnClick="() => TransferItems(LeftItems, RightItems, true)">
<span class="@RightButtonClassName">@RightButtonText</span>
<i class="@RightIcon"></i>
</Button>
Expand Down
11 changes: 9 additions & 2 deletions src/BootstrapBlazor/Components/Transfer/Transfer.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -192,24 +192,31 @@ public partial class Transfer<TValue>
public string? Height { get; set; }

/// <summary>
/// 获得/设置 是否为换行模式 默认 false 不换行
/// 获得/设置 候选项是否为换行模式 默认 false 不换行
/// </summary>
[Parameter]
public bool IsWrapItem { get; set; }
public bool IsWrapItem { get; set; } = true;

/// <summary>
/// 获得/设置 候选项宽度 默认 null 未设置
/// </summary>
[Parameter]
public string? ItemWidth { get; set; }

/// <summary>
/// 获得/设置 候选项文本是否为换行 默认 false 不换行
/// </summary>
[Parameter]
public bool IsWrapItemText { get; set; }

[Inject]
[NotNull]
private IIconTheme? IconTheme { get; set; }

private string? ClassString => CssBuilder.Default("bb-transfer")
.AddClass("has-height", !string.IsNullOrEmpty(Height))
.AddClass("wrap-item", IsWrapItem)
.AddClass("wrap-item-text", IsWrapItemText)
.AddClassFromAttributes(AdditionalAttributes)
.Build();

Expand Down
24 changes: 22 additions & 2 deletions src/BootstrapBlazor/Components/Transfer/Transfer.razor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,29 @@
}

&.wrap-item {
.transfer-panel-list {
flex-direction: row;
flex-wrap: wrap;

.transfer-panel-item {
width: var(--bb-transfer-panel-item-width);
}
}
}

&.wrap-item-text {
.transfer-panel-item .form-check-input + .form-check-label {
white-space: normal;
text-overflow: clip;
overflow: visible;
}
}

.transfer-panel-item .form-check-input + .form-check-label {
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
}
}

.transfer-panel {
Expand Down Expand Up @@ -70,13 +87,16 @@
max-height: var(--bb-transfer-panel-list-max-height);
min-height: var(--bb-transfer-panel-list-min-height);
display: flex;
flex-wrap: wrap;
flex-direction: column;

.form-check {
min-height: unset;
}
}

.transfer-panel-item {
border-radius: var(--bs-border-radius);
padding: var(--bb-transfer-panel-item-padding);
width: var(--bb-transfer-panel-item-width);
}

.transfer-panel-item .form-check-input + .form-check-label {
Expand Down
7 changes: 4 additions & 3 deletions src/BootstrapBlazor/Components/Transfer/TransferPanel.razor
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
@if (ShowSearch)
{
<div class="transfer-panel-filter">
<input type="text" autocomplete="off" placeholder="@SearchPlaceHolderString" disabled="@Disabled" class="input-inner" value="@SearchText" @oninput="@OnSearch" @onkeyup="@OnKeyUp">
<input type="text" autocomplete="off" placeholder="@SearchPlaceHolderString" disabled="@Disabled"
class="input-inner" value="@SearchText" @oninput="@OnSearch" @onkeyup="@OnKeyUp">
<span class="@SearchClass" @onclick="@ClearSearch">
<i class="@SearchIcon"></i>
</span>
Expand All @@ -30,8 +31,8 @@
{
var state = item.Active ? CheckboxState.Checked : CheckboxState.UnChecked;
<Checkbox TValue="SelectedItem" IsDisabled="@IsDisabled" class="@GetItemClass(item)"
DisplayText="@item.Text" Value="item" ShowAfterLabel="true" ShowLabel="false"
State="@state" OnStateChanged="@OnStateChanged"></Checkbox>
DisplayText="@item.Text" Value="item" ShowAfterLabel="true" ShowLabel="false"
State="@state" OnStateChanged="@OnStateChanged"></Checkbox>
}
else
{
Expand Down
Loading