about summary refs log tree commit diff
path: root/MatrixRoomUtils.Web/Shared/SimpleComponents/FancyTextBox.razor
diff options
context:
space:
mode:
authorTheArcaneBrony <myrainbowdash949@gmail.com>2023-05-28 11:30:53 +0200
committerTheArcaneBrony <myrainbowdash949@gmail.com>2023-05-28 11:30:53 +0200
commita357bec1831611758a19bf23ff0fa5a5fe99ca52 (patch)
tree2aa839591e39fdfd9e94a4f1c75fe93b94b246d5 /MatrixRoomUtils.Web/Shared/SimpleComponents/FancyTextBox.razor
parentRemove a bunch of caching, make room listings more reliable (diff)
downloadMatrixUtils-a357bec1831611758a19bf23ff0fa5a5fe99ca52.tar.xz
Add changes
Diffstat (limited to 'MatrixRoomUtils.Web/Shared/SimpleComponents/FancyTextBox.razor')
-rw-r--r--MatrixRoomUtils.Web/Shared/SimpleComponents/FancyTextBox.razor35
1 files changed, 35 insertions, 0 deletions
diff --git a/MatrixRoomUtils.Web/Shared/SimpleComponents/FancyTextBox.razor b/MatrixRoomUtils.Web/Shared/SimpleComponents/FancyTextBox.razor
new file mode 100644

index 0000000..9c325a7 --- /dev/null +++ b/MatrixRoomUtils.Web/Shared/SimpleComponents/FancyTextBox.razor
@@ -0,0 +1,35 @@ +@inject IJSRuntime JsRuntime +@if (isVisible) +{ + <input autofocus @bind="Value" @onfocusout="() => { isVisible = false; ValueChanged.InvokeAsync(Value); }" @ref="elementToFocus"/> +} +else +{ + <span tabindex="0" style="border-bottom: #ccc solid 1px; height: 1.4em; display: inline-block; @(string.IsNullOrEmpty(Value) ? "min-width: 50px;" : "")" @onfocusin="() => isVisible = true">@(Formatter?.Invoke(Value) ?? (IsPassword ? string.Join("", Value.Select(x=>'*')) : Value))</span> +} + +@code { + + [Parameter] + public string Value { get; set; } + + [Parameter] + public bool IsPassword { get; set; } = false; + + [Parameter] + public EventCallback<string> ValueChanged { get; set; } + + [Parameter] + public Func<string?, string>? Formatter { get; set; } + + + private bool isVisible { get; set; } = false; + + private ElementReference elementToFocus; + + protected override async Task OnAfterRenderAsync(bool firstRender) + { + await JsRuntime.InvokeVoidAsync("BlazorFocusElement", elementToFocus); + } + +} \ No newline at end of file