From 9d434e35afd550176e3f9c7f61578999323f7216 Mon Sep 17 00:00:00 2001 From: colin Date: Fri, 11 Sep 2026 10:05:36 +0800 Subject: [PATCH] feat: Add component: MudTextFieldEx --- .../Components/MudTextFieldEx.razor | 111 ++++++++++++++++++ .../Components/MudTextFieldExIcon.cs | 20 ++++ 2 files changed, 131 insertions(+) create mode 100644 aspnet-core/modules/elsa/LINGYUN.Abp.ElsaNext.Studio.Blazor/Components/MudTextFieldEx.razor create mode 100644 aspnet-core/modules/elsa/LINGYUN.Abp.ElsaNext.Studio.Blazor/Components/MudTextFieldExIcon.cs diff --git a/aspnet-core/modules/elsa/LINGYUN.Abp.ElsaNext.Studio.Blazor/Components/MudTextFieldEx.razor b/aspnet-core/modules/elsa/LINGYUN.Abp.ElsaNext.Studio.Blazor/Components/MudTextFieldEx.razor new file mode 100644 index 000000000..3eccd3812 --- /dev/null +++ b/aspnet-core/modules/elsa/LINGYUN.Abp.ElsaNext.Studio.Blazor/Components/MudTextFieldEx.razor @@ -0,0 +1,111 @@ +@namespace LINGYUN.Abp.ElsaNext.Studio.Blazor.Components +@using System.Globalization + +
+ + + @if (_visibleIcons.Length > 0) + { +
+ @foreach (var icon in _visibleIcons) + { + var definition = icon; + + + + + } +
+ } +
+ + + +@code { + private const string WrapperClassname = "abp-elsa-adornment-text-field"; + + private MudTextFieldExIcon[] _visibleIcons = []; + + [Parameter] public string? Value { get; set; } + + [Parameter] public EventCallback ValueChanged { get; set; } + + [Parameter] public string? Label { get; set; } + + [Parameter] public string? HelperText { get; set; } + + [Parameter] public string? Placeholder { get; set; } + + [Parameter] public Variant Variant { get; set; } = Variant.Outlined; + + [Parameter] public Margin Margin { get; set; } = Margin.Dense; + + [Parameter] public bool ReadOnly { get; set; } + + [Parameter] public bool Disabled { get; set; } + + [Parameter] public bool Immediate { get; set; } = true; + + [Parameter] public InputType InputType { get; set; } = InputType.Text; + + [Parameter] public IReadOnlyList? AdornmentIcons { get; set; } + + [Parameter] public EventCallback OnFieldClick { get; set; } + + [Parameter] public double AdornmentHeight { get; set; } = 40; + + [Parameter] public string? Class { get; set; } + + [Parameter] public string? Style { get; set; } + + private string Classname => string.IsNullOrWhiteSpace(Class) ? WrapperClassname : $"{WrapperClassname} {Class}"; + + private string WrapperStyle => + $"position: relative; --abp-elsa-adornment-space: {((_visibleIcons.Length * 32) + 8).ToString(CultureInfo.InvariantCulture)}px; " + + $"cursor: {(OnFieldClick.HasDelegate && !Disabled ? "pointer" : "default")}; {Style}"; + + private string IconContainerStyle => + $"position: absolute; top: 0; right: 8px; height: {AdornmentHeight.ToString(CultureInfo.InvariantCulture)}px; " + + "display: flex; align-items: center; gap: 2px; z-index: 1;"; + + protected override void OnParametersSet() + { + _visibleIcons = AdornmentIcons?.Where(x => x.Visible).ToArray() ?? []; + } + + private async Task InvokeIconAsync(MudTextFieldExIcon icon) + { + if (icon.OnClick != null) + { + await icon.OnClick(); + } + } + + private async Task HandleFieldClickAsync() + { + if (!Disabled && OnFieldClick.HasDelegate) + { + await OnFieldClick.InvokeAsync(); + } + } +} diff --git a/aspnet-core/modules/elsa/LINGYUN.Abp.ElsaNext.Studio.Blazor/Components/MudTextFieldExIcon.cs b/aspnet-core/modules/elsa/LINGYUN.Abp.ElsaNext.Studio.Blazor/Components/MudTextFieldExIcon.cs new file mode 100644 index 000000000..44ad425c4 --- /dev/null +++ b/aspnet-core/modules/elsa/LINGYUN.Abp.ElsaNext.Studio.Blazor/Components/MudTextFieldExIcon.cs @@ -0,0 +1,20 @@ +using MudBlazor; + +namespace LINGYUN.Abp.ElsaNext.Studio.Blazor.Components; + +public sealed class MudTextFieldExIcon +{ + public string Icon { get; init; } = string.Empty; + + public Func? OnClick { get; init; } + + public string? Tooltip { get; init; } + + public string? AriaLabel { get; init; } + + public bool Visible { get; init; } = true; + + public bool Disabled { get; init; } + + public Color Color { get; init; } = Color.Default; +}