From 991ae78218cf4e4d6d44e5ed78bbee2bdde33bf0 Mon Sep 17 00:00:00 2001 From: Peace Date: Tue, 9 Jul 2024 14:19:54 +0900 Subject: [PATCH] select --- .../Components/Layout/NavMenu.razor | 3 +- ...InputList.razor => FormInputListbox.razor} | 2 +- .../Pages/FormInputs/FormInputSelect.razor | 116 ++++++++++++++++++ 3 files changed, 119 insertions(+), 2 deletions(-) rename BlazorFluentUI/Components/Pages/FormInputs/{FormInputList.razor => FormInputListbox.razor} (99%) create mode 100644 BlazorFluentUI/Components/Pages/FormInputs/FormInputSelect.razor diff --git a/BlazorFluentUI/Components/Layout/NavMenu.razor b/BlazorFluentUI/Components/Layout/NavMenu.razor index e04c768..cccc8d1 100644 --- a/BlazorFluentUI/Components/Layout/NavMenu.razor +++ b/BlazorFluentUI/Components/Layout/NavMenu.razor @@ -27,7 +27,8 @@ InputFile Combobox - List + Listbox + Select diff --git a/BlazorFluentUI/Components/Pages/FormInputs/FormInputList.razor b/BlazorFluentUI/Components/Pages/FormInputs/FormInputListbox.razor similarity index 99% rename from BlazorFluentUI/Components/Pages/FormInputs/FormInputList.razor rename to BlazorFluentUI/Components/Pages/FormInputs/FormInputListbox.razor index 392e4d8..db62473 100644 --- a/BlazorFluentUI/Components/Pages/FormInputs/FormInputList.razor +++ b/BlazorFluentUI/Components/Pages/FormInputs/FormInputListbox.razor @@ -1,4 +1,4 @@ -@page "/forminputlist" +@page "/forminputlistbox" @inject EmployeeService employeeService; diff --git a/BlazorFluentUI/Components/Pages/FormInputs/FormInputSelect.razor b/BlazorFluentUI/Components/Pages/FormInputs/FormInputSelect.razor new file mode 100644 index 0000000..7592cfc --- /dev/null +++ b/BlazorFluentUI/Components/Pages/FormInputs/FormInputSelect.razor @@ -0,0 +1,116 @@ +@page "/forminputselect" + +@inject EmployeeService employeeService; + +@rendermode RenderMode.InteractiveServer + +Select + + + The FluentSelect wrap a web component of a select. + + +Default Example + + +

+ Selected value: @defaultSelectedValue
+ Selected Employee: @defaultSelectedEmployee?.ToString(); +

+
+ +From a list of Option<T> + +

From Option<string> items

+ +

+ Selected Value: @stringValue
+ Selected Item
+ Value: @selectedStringOption?.Value (Type: @(selectedStringOption?.GetType()))
+ Text: @selectedStringOption?.Text
+

+ +

From Option<int> items

+ +

+ Selected Value: @intValue
+ Selected Item
+ Value: @selectedIntOption?.Value (Type: @(selectedIntOption?.GetType()))
+ Text: @selectedIntOption?.Text
+

+ +

From Option<string> items where multiple can be selected

+ +

+ Selected string + @(selectedStringMultipleOptions == null ? "" : string.Join(',', selectedStringMultipleOptions.Select(v => v.Value)))
+

+
+ +@code { + string? defaultSelectedValue; + Employee? defaultSelectedEmployee; + + Option selectedStringOption = default; + string? stringValue; + Option selectedIntOption = default; + string? intValue; + + List> stringOptions = new() + { + { new Option { Value = "1", Text = "One" } }, + { new Option { Value = "2", Text = "Two", Selected = true } }, + { new Option { Value = "3", Text = "Three" } }, + { new Option { Value = "4", Text = "Four" } }, + { new Option { Value = "5", Text = "Five", Icon = (new Icons.Regular.Size24.AppFolder(), Color.Accent, "start") } }, + }; + + List> intOptions = new() + { + { new Option { Value = 1, Text = "1", Disabled = true, Icon = (new Icons.Regular.Size24.NumberCircle1(), Color.Accent, "start") } }, + { new Option { Value = 2, Text = "2", Icon = (new Icons.Regular.Size24.NumberCircle2(), Color.Accent, "end") } }, + { new Option { Value = 3, Text = "3", Icon = (new Icons.Regular.Size24.NumberCircle3(), Color.Accent, "start") } }, + }; + + static IEnumerable>? selectedStringMultipleOptions = default; + List> stringMultipleOptions = new() + { + { new Option { Value = "1", Text = "One" } }, + { new Option { Value = "2", Text = "Two", Selected = true } }, + { new Option { Value = "3", Text = "Three" } }, + { new Option { Value = "4", Text = "Four" } }, + { new Option { Value = "5", Text = "Five", Icon = (new Icons.Regular.Size24.AppFolder(), Color.Accent, "start") } }, + { new Option { Value = "6", Text = "Six" } }, + { new Option { Value = "7", Text = "Seven", Icon = (new Icons.Regular.Size24.Accessibility(), Color.Accent, "end"), Selected = true } }, + { new Option { Value = "8", Text = "Eight" } }, + { new Option { Value = "9", Text = "Nine", Icon = (new Icons.Regular.Size24.Fireplace(), Color.Accent, "start"), Selected = true } }, + + }; +}