diff options
author | TheArcaneBrony <myrainbowdash949@gmail.com> | 2023-06-13 20:25:05 +0200 |
---|---|---|
committer | TheArcaneBrony <myrainbowdash949@gmail.com> | 2023-06-13 20:25:05 +0200 |
commit | 712ad189c99570f686ab779782b2a873e172428e (patch) | |
tree | 6102e4719416e71522e9143fa4e06951258bd77c /MatrixRoomUtils.Web/Shared/SimpleComponents | |
parent | Fix passwords being visible during editing (diff) | |
download | MatrixUtils-712ad189c99570f686ab779782b2a873e172428e.tar.xz |
Change syntax style
Diffstat (limited to 'MatrixRoomUtils.Web/Shared/SimpleComponents')
4 files changed, 26 insertions, 35 deletions
diff --git a/MatrixRoomUtils.Web/Shared/SimpleComponents/DictionaryEditor.razor b/MatrixRoomUtils.Web/Shared/SimpleComponents/DictionaryEditor.razor index 4d90c57..42a5f64 100644 --- a/MatrixRoomUtils.Web/Shared/SimpleComponents/DictionaryEditor.razor +++ b/MatrixRoomUtils.Web/Shared/SimpleComponents/DictionaryEditor.razor @@ -1,9 +1,8 @@ @using MatrixRoomUtils.Core.Extensions <table> - @foreach(var i in Items.Keys) - { + @foreach (var i in Items.Keys) { var key = i; - <input value="@Items[key]" @oninput="(obj) => inputChanged(obj, key)"> + <input value="@Items[key]" @oninput="obj => inputChanged(obj, key)"> <button @onclick="() => { Items.Remove(key); ItemsChanged.InvokeAsync(); }">Remove</button> <br/> } @@ -11,28 +10,26 @@ <button @onclick="() => { Items.Add(string.Empty, default); ItemsChanged.InvokeAsync(); }">Add</button> @code { - + [Parameter] public Dictionary<string, object> Items { get; set; } = new(); - [Parameter, EditorRequired] + [Parameter] + [EditorRequired] public EventCallback ItemsChanged { get; set; } [Parameter] - public Func<string,string>? KeyFormatter { get; set; } - + public Func<string, string>? KeyFormatter { get; set; } + [Parameter] public Action? OnFocusLost { get; set; } - - protected override Task OnInitializedAsync() - { + protected override Task OnInitializedAsync() { Console.WriteLine($"DictionaryEditor initialized with {Items.Count} items: {Items.ToJson()}"); return base.OnInitializedAsync(); } - private void inputChanged(ChangeEventArgs obj, string key) - { + private void inputChanged(ChangeEventArgs obj, string key) { Console.WriteLine($"StringListEditor inputChanged {key} {obj.Value}"); Items[key] = obj.Value.ToString(); ItemsChanged.InvokeAsync(); diff --git a/MatrixRoomUtils.Web/Shared/SimpleComponents/FancyTextBox.razor b/MatrixRoomUtils.Web/Shared/SimpleComponents/FancyTextBox.razor index 702d41e..d17d0de 100644 --- a/MatrixRoomUtils.Web/Shared/SimpleComponents/FancyTextBox.razor +++ b/MatrixRoomUtils.Web/Shared/SimpleComponents/FancyTextBox.razor @@ -1,35 +1,29 @@ @inject IJSRuntime JsRuntime -@if (isVisible) -{ +@if (isVisible) { <input autofocus type="@(IsPassword ? "password" : "text")" @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> +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); - } + protected override async Task OnAfterRenderAsync(bool firstRender) => await JsRuntime.InvokeVoidAsync("BlazorFocusElement", elementToFocus); } \ No newline at end of file diff --git a/MatrixRoomUtils.Web/Shared/SimpleComponents/StringListEditor.razor b/MatrixRoomUtils.Web/Shared/SimpleComponents/StringListEditor.razor index fe3a938..2bd6ed5 100644 --- a/MatrixRoomUtils.Web/Shared/SimpleComponents/StringListEditor.razor +++ b/MatrixRoomUtils.Web/Shared/SimpleComponents/StringListEditor.razor @@ -1,5 +1,4 @@ -@for (int i = 0; i < Items.Count; i++) -{ +@for (var i = 0; i < Items.Count; i++) { var self = i; <button @onclick="() => { Items.RemoveAt(self); ItemsChanged.InvokeAsync(); }">Remove</button> <FancyTextBox Value="@Items[self]" ValueChanged="@(obj => inputChanged(obj, self))"/> @@ -10,19 +9,18 @@ @code { [Parameter] - public List<string> Items { get; set; } = new List<string>(); + public List<string> Items { get; set; } = new(); - [Parameter, EditorRequired] + [Parameter] + [EditorRequired] public EventCallback ItemsChanged { get; set; } - protected override Task OnInitializedAsync() - { + protected override Task OnInitializedAsync() { Console.WriteLine($"StringListEditor initialized with {Items.Count} items: {string.Join(",", Items)}"); return base.OnInitializedAsync(); } - private void inputChanged(string obj, int i) - { + private void inputChanged(string obj, int i) { Console.WriteLine($"StringListEditor inputChanged {i} {obj}"); Items[i] = obj; ItemsChanged.InvokeAsync(); diff --git a/MatrixRoomUtils.Web/Shared/SimpleComponents/ToggleSlider.razor b/MatrixRoomUtils.Web/Shared/SimpleComponents/ToggleSlider.razor index 49a363d..1a38e26 100644 --- a/MatrixRoomUtils.Web/Shared/SimpleComponents/ToggleSlider.razor +++ b/MatrixRoomUtils.Web/Shared/SimpleComponents/ToggleSlider.razor @@ -59,12 +59,14 @@ </style> @code { + [Parameter] public RenderFragment? ChildContent { get; set; } - + [Parameter] public bool Value { get; set; } + [Parameter] public EventCallback<bool> ValueChanged { get; set; } - + } \ No newline at end of file |