From 067730bebd8a9eb7aed76d72c1237b9e1dc5eec2 Mon Sep 17 00:00:00 2001 From: Sukhrob Ilyosbekov Date: Tue, 30 Jul 2024 21:37:56 -0400 Subject: [PATCH] added numeric field property editor component --- .../NumericFieldPropertyEditor.razor | 19 ++++++++ .../NumericFieldPropertyEditor.razor.cs | 43 +++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 src/FormBuilder/Components/NumericFieldPropertyEditor.razor create mode 100644 src/FormBuilder/Components/NumericFieldPropertyEditor.razor.cs diff --git a/src/FormBuilder/Components/NumericFieldPropertyEditor.razor b/src/FormBuilder/Components/NumericFieldPropertyEditor.razor new file mode 100644 index 0000000..cc43492 --- /dev/null +++ b/src/FormBuilder/Components/NumericFieldPropertyEditor.razor @@ -0,0 +1,19 @@ +@typeparam TValue where TValue : struct + + + + + + + + + + +
+ + +
+ + + + diff --git a/src/FormBuilder/Components/NumericFieldPropertyEditor.razor.cs b/src/FormBuilder/Components/NumericFieldPropertyEditor.razor.cs new file mode 100644 index 0000000..4a2afb8 --- /dev/null +++ b/src/FormBuilder/Components/NumericFieldPropertyEditor.razor.cs @@ -0,0 +1,43 @@ +using FormBuilder.Models; +using Microsoft.AspNetCore.Components; + +namespace FormBuilder.Components; + +public partial class NumericFieldPropertyEditor : ComponentBase where TValue : struct +{ + [Parameter, EditorRequired] + public NumericField Field { get; set; } = default!; + + [Parameter] + public EventCallback> FieldChanged { get; set; } + + private void OnMinChanged(decimal? value) + { + Field.Min = value; + FieldChanged.InvokeAsync(Field); + } + + private void OnMaxChanged(decimal? value) + { + Field.Max = value; + FieldChanged.InvokeAsync(Field); + } + + private void OnStepChanged(string value) + { + Field.Step = value; + FieldChanged.InvokeAsync(Field); + } + + private void OnShowUpDownChanged(bool value) + { + Field.ShowUpDown = value; + FieldChanged.InvokeAsync(Field); + } + + private void OnFormatChanged(string? value) + { + Field.Format = value; + FieldChanged.InvokeAsync(Field); + } +}