diff --git a/src/BootstrapBlazor.Shared/Demos/Dropdown/DropdownAlignment.razor b/src/BootstrapBlazor.Shared/Demos/Dropdown/DropdownAlignment.razor new file mode 100644 index 000000000..399f872c6 --- /dev/null +++ b/src/BootstrapBlazor.Shared/Demos/Dropdown/DropdownAlignment.razor @@ -0,0 +1,56 @@ +@inject IStringLocalizer Localizer + +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +@code { + private List Items { get; set; } = new List { }; + + /// + /// OnInitialized + /// + protected override void OnInitialized() + { + base.OnInitialized(); + + Items = new List + { + new SelectedItem{ Text=Localizer["Item1"], Value="0"}, + new SelectedItem{ Text=Localizer["Item2"], Value="1"}, + new SelectedItem{ Text=Localizer["Item3"], Value="2"}, + }; + } +} diff --git a/src/BootstrapBlazor.Shared/Demos/Dropdown/DropdownCascade.razor b/src/BootstrapBlazor.Shared/Demos/Dropdown/DropdownCascade.razor new file mode 100644 index 000000000..4f6b5fc93 --- /dev/null +++ b/src/BootstrapBlazor.Shared/Demos/Dropdown/DropdownCascade.razor @@ -0,0 +1,63 @@ +@inject IStringLocalizer Localizer + +
+
+ +
+
+ +
+
+ +@code { + private IEnumerable? Items2 { get; set; } + + private IEnumerable? Items3 = new SelectedItem[] { }; + + /// + /// OnInitialized + /// + protected override void OnInitialized() + { + base.OnInitialized(); + + Items3 = new SelectedItem[] + { + new SelectedItem ("", Localizer["Item1"]), + new SelectedItem ("Beijing", Localizer["Item2"]) { Active = true }, + new SelectedItem ("Shanghai", Localizer["Item3"]), + new SelectedItem ("Hangzhou", Localizer["Item4"]) + }; + } + + /// + /// 级联绑定菜单 + /// + /// + private async Task OnCascadeBindSelectClick(SelectedItem item) + { + // 模拟异步通讯切换线程 + await Task.Delay(10); + if (item.Value == "Beijing") + { + Items2 = new SelectedItem[] + { + new SelectedItem("1",Localizer["Item5"]) { Active = true }, + new SelectedItem("2",Localizer["Item6"]), + }; + } + else if (item.Value == "Shanghai") + { + Items2 = new SelectedItem[] + { + new SelectedItem("1",Localizer["Item7"]), + new SelectedItem("2",Localizer["Item8"]) { Active = true } , + }; + } + else + { + Items2 = Enumerable.Empty(); + } + StateHasChanged(); + } +} diff --git a/src/BootstrapBlazor.Shared/Demos/Dropdown/DropdownColor.razor b/src/BootstrapBlazor.Shared/Demos/Dropdown/DropdownColor.razor new file mode 100644 index 000000000..83f830be6 --- /dev/null +++ b/src/BootstrapBlazor.Shared/Demos/Dropdown/DropdownColor.razor @@ -0,0 +1,35 @@ +@inject IStringLocalizer Localizer + +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +@code { + private List Items { get; set; } = new List { }; + + /// + /// OnInitialized + /// + protected override void OnInitialized() + { + base.OnInitialized(); + + Items = new List + { + new SelectedItem{ Text=Localizer["Item1"], Value="0"}, + new SelectedItem{ Text=Localizer["Item2"], Value="1"}, + new SelectedItem{ Text=Localizer["Item3"], Value="2"}, + }; + } +} diff --git a/src/BootstrapBlazor.Shared/Demos/Dropdown/DropdownDirection.razor b/src/BootstrapBlazor.Shared/Demos/Dropdown/DropdownDirection.razor new file mode 100644 index 000000000..6838d681a --- /dev/null +++ b/src/BootstrapBlazor.Shared/Demos/Dropdown/DropdownDirection.razor @@ -0,0 +1,35 @@ +@inject IStringLocalizer Localizer + +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +@code { + private List Items { get; set; } = new List { }; + + /// + /// OnInitialized + /// + protected override void OnInitialized() + { + base.OnInitialized(); + + Items = new List + { + new SelectedItem{ Text=Localizer["Item1"], Value="0"}, + new SelectedItem{ Text=Localizer["Item2"], Value="1"}, + new SelectedItem{ Text=Localizer["Item3"], Value="2"}, + }; + } +} diff --git a/src/BootstrapBlazor.Shared/Demos/Dropdown/DropdownFixedButtonText.razor b/src/BootstrapBlazor.Shared/Demos/Dropdown/DropdownFixedButtonText.razor new file mode 100644 index 000000000..bb1f155aa --- /dev/null +++ b/src/BootstrapBlazor.Shared/Demos/Dropdown/DropdownFixedButtonText.razor @@ -0,0 +1,21 @@ +@inject IStringLocalizer Localizer + + + +@code { + private List RadioItems { get; set; } = new List(); + + /// + /// OnInitialized + /// + protected override void OnInitialized() + { + base.OnInitialized(); + + RadioItems = new List + { + new SelectedItem("1", Localizer["Item1"]) { Active = true }, + new SelectedItem("2", Localizer["Item2"]) + }; + } +} diff --git a/src/BootstrapBlazor.Shared/Demos/Dropdown/DropdownIsFixedButtonText.razor b/src/BootstrapBlazor.Shared/Demos/Dropdown/DropdownIsFixedButtonText.razor new file mode 100644 index 000000000..ee05f9857 --- /dev/null +++ b/src/BootstrapBlazor.Shared/Demos/Dropdown/DropdownIsFixedButtonText.razor @@ -0,0 +1,21 @@ +@inject IStringLocalizer Localizer + + + +@code { + private List RadioItems { get; set; } = new List(); + + /// + /// OnInitialized + /// + protected override void OnInitialized() + { + base.OnInitialized(); + + RadioItems = new List + { + new SelectedItem("1", Localizer["Item1"]) { Active = true }, + new SelectedItem("2", Localizer["Item2"]) + }; + } +} diff --git a/src/BootstrapBlazor.Shared/Demos/Dropdown/DropdownItems.razor b/src/BootstrapBlazor.Shared/Demos/Dropdown/DropdownItems.razor new file mode 100644 index 000000000..7f7926553 --- /dev/null +++ b/src/BootstrapBlazor.Shared/Demos/Dropdown/DropdownItems.razor @@ -0,0 +1,50 @@ +@inject IStringLocalizer Localizer + +
+
+ + +
+
+ + +
+
+ +@code { + private List Foos { get; set; } = new List(); + + /// + /// AddItem + /// + private void AddItem() + { + Foos.Add(new SelectedItem($"{Foos.Count}", $"{Localizer["City"]} {Foos.Count}")); + } + + /// + /// RemoveItem + /// + private void RemoveItem() + { + if (Foos.Any()) + { + Foos.RemoveAt(0); + } + } + + /// + /// OnInitialized + /// + protected override void OnInitialized() + { + base.OnInitialized(); + + Foos = new List + { + new SelectedItem{ Text=Localizer["Item1"], Value="0"}, + new SelectedItem{ Text=Localizer["Item2"], Value="1"}, + new SelectedItem{ Text=Localizer["Item3"], Value="2"}, + }; + } +} diff --git a/src/BootstrapBlazor.Shared/Demos/Dropdown/DropdownNormal.razor b/src/BootstrapBlazor.Shared/Demos/Dropdown/DropdownNormal.razor new file mode 100644 index 000000000..22ca73334 --- /dev/null +++ b/src/BootstrapBlazor.Shared/Demos/Dropdown/DropdownNormal.razor @@ -0,0 +1,37 @@ +@inject IStringLocalizer Localizer + + + + +@code { + [NotNull] + private BlockLogger? Trace { get; set; } + + private List Items { get; set; } = new List { }; + + /// + /// ShowMessage + /// + /// + /// + private Task ShowMessage(SelectedItem e) + { + Trace.Log($"Dropdown Item Clicked: Value={e.Value} Text={e.Text}"); + return Task.CompletedTask; + } + + /// + /// OnInitialized + /// + protected override void OnInitialized() + { + base.OnInitialized(); + + Items = new List + { + new SelectedItem{ Text=Localizer["Item1"], Value="0"}, + new SelectedItem{ Text=Localizer["Item2"], Value="1"}, + new SelectedItem{ Text=Localizer["Item3"], Value="2"}, + }; + } +} diff --git a/src/BootstrapBlazor.Shared/Demos/Dropdown/DropdownNull.razor b/src/BootstrapBlazor.Shared/Demos/Dropdown/DropdownNull.razor new file mode 100644 index 000000000..cccd16ab5 --- /dev/null +++ b/src/BootstrapBlazor.Shared/Demos/Dropdown/DropdownNull.razor @@ -0,0 +1,5 @@ + + +@code { + private static List EmptyList => new(); +} diff --git a/src/BootstrapBlazor.Shared/Demos/Dropdown/DropdownRadio.razor b/src/BootstrapBlazor.Shared/Demos/Dropdown/DropdownRadio.razor new file mode 100644 index 000000000..00ba2de2a --- /dev/null +++ b/src/BootstrapBlazor.Shared/Demos/Dropdown/DropdownRadio.razor @@ -0,0 +1,51 @@ +@inject IStringLocalizer Localizer + +
+
+ + +
+
+ + +
+
+@code { + private List RadioItems { get; set; } = new List(); + + private List RadioDropDownItems { get; set; } = new List(); + + /// + /// OnInitialized + /// + protected override void OnInitialized() + { + base.OnInitialized(); + + RadioDropDownItems = new List + { + new SelectedItem("1", Localizer["Item1"]) { Active = true }, + new SelectedItem("2", Localizer["Item2"]), + new SelectedItem("3", Localizer["Item3"]) + }; + + RadioItems = new List + { + new SelectedItem("1", Localizer["Item1"]) { Active = true }, + new SelectedItem("2", Localizer["Item2"]) + }; + } + + /// + /// OnRadioItemChanged + /// + /// + /// + /// + private Task OnRadioItemChanged(IEnumerable values, SelectedItem item) + { + RadioDropDownItems.Add(new SelectedItem($"{RadioDropDownItems.Count + 1}", $"{Localizer["City"]} {RadioDropDownItems.Count}")); + StateHasChanged(); + return Task.CompletedTask; + } +} diff --git a/src/BootstrapBlazor.Shared/Demos/Dropdown/DropdownSize.razor b/src/BootstrapBlazor.Shared/Demos/Dropdown/DropdownSize.razor new file mode 100644 index 000000000..15583964f --- /dev/null +++ b/src/BootstrapBlazor.Shared/Demos/Dropdown/DropdownSize.razor @@ -0,0 +1,41 @@ +@inject IStringLocalizer Localizer + +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +@code { + private List Items { get; set; } = new List { }; + + /// + /// OnInitialized + /// + protected override void OnInitialized() + { + base.OnInitialized(); + + Items = new List + { + new SelectedItem{ Text=Localizer["Item1"], Value="0"}, + new SelectedItem{ Text=Localizer["Item2"], Value="1"}, + new SelectedItem{ Text=Localizer["Item3"], Value="2"}, + }; + } +} diff --git a/src/BootstrapBlazor.Shared/Demos/Dropdown/DropdownSplit.razor b/src/BootstrapBlazor.Shared/Demos/Dropdown/DropdownSplit.razor new file mode 100644 index 000000000..3992c463f --- /dev/null +++ b/src/BootstrapBlazor.Shared/Demos/Dropdown/DropdownSplit.razor @@ -0,0 +1,35 @@ +@inject IStringLocalizer Localizer + +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +@code { + private List Items { get; set; } = new List { }; + + /// + /// OnInitialized + /// + protected override void OnInitialized() + { + base.OnInitialized(); + + Items = new List + { + new SelectedItem{ Text=Localizer["Item1"], Value="0"}, + new SelectedItem{ Text=Localizer["Item2"], Value="1"}, + new SelectedItem{ Text=Localizer["Item3"], Value="2"}, + }; + } +} diff --git a/src/BootstrapBlazor.Shared/Locales/en.json b/src/BootstrapBlazor.Shared/Locales/en.json index 8d0fff4db..a8711c869 100644 --- a/src/BootstrapBlazor.Shared/Locales/en.json +++ b/src/BootstrapBlazor.Shared/Locales/en.json @@ -1705,34 +1705,31 @@ }, "BootstrapBlazor.Shared.Samples.Dropdowns": { "Title": "Dropdown", - "H1": "Collapse actions or menus into drop-down menus", - "Block1Title": "Basic usage", - "Block1Intro": "Use TagName='a' to open a drop-down list with a button tag", - "Block2Title": "Dropdown empty drop-down menu", - "Block2Intro": "Allow empty Items drop-down menus", - "Block3Title": "Drop-down box with color", - "Block3Intro": "Provide warning message boxes in various colors. Quote Color='Color.Primary' and other color and style classes to define the appearance of the drop-down menu", - "Block4Title": "Split button drop-down menu", - "Block4Intro": "You can create a split drop-down menu with tags similar to a single button drop-down menu, and add ShowSplit='true' (you need to add DropdownType='DropdownType.ButtonGroup') when you use a split component. Insert this symbol as a drop-down The options are handled at appropriate intervals (distance).", - "Block5Title": "Size definition", - "Block5Intro": "The drop-down menu has a variety of size specifications to choose from Size attributes, including preset and split button drop-down menus.", - "Block6Title": "Expanding direction", - "Block6Intro": "Add the style of Direction='Direction.Dropup' to make the drop-down menu expand upward.", - "Block7Title": "Menu alignment", - "Block7Intro": "By default, the right side of the drop-down menu is aligned by setting MenuAlignment=Alignment.Right", - "Block8Title": "Bind data source", - "Block8Intro": "When you click the button on the right, the menu items in the drop-down box will increase", - "Button1Text": "Add", - "Button2Text": "Delete", - "Block9Title": "Bind data source", - "Block9Intro": "When you change the options, the menu items in the drop-down box will increase", - "Block10Title": "Cascade binding", - "Block10Intro": "By selecting different options in the first drop-down box, the second drop-down box is filled with content dynamically.", + "Description": "Collapse actions or menus into drop-down menus", + "NormalTitle": "Basic usage", + "NormalIntro": "Use TagName='a' to open a drop-down list with a button tag", + "NullTitle": "Dropdown empty drop-down menu", + "NullIntro": "Allow empty Items drop-down menus", + "ColorTitle": "Drop-down box with color", + "ColorIntro": "Provide warning message boxes in various colors. Quote Color='Color.Primary' and other color and style classes to define the appearance of the drop-down menu", + "SplitTitle": "Split button drop-down menu", + "SplitIntro": "You can create a split drop-down menu with tags similar to a single button drop-down menu, and add ShowSplit='true' (you need to add DropdownType='DropdownType.ButtonGroup') when you use a split component. Insert this symbol as a drop-down The options are handled at appropriate intervals (distance).", + "SizeTitle": "Size definition", + "SizeIntro": "The drop-down menu has a variety of size specifications to choose from Size attributes, including preset and split button drop-down menus.", + "DirectionTitle": "Expanding direction", + "DirectionIntro": "Add the style of Direction='Direction.Dropup' to make the drop-down menu expand upward.", + "AlignmentTitle": "Menu alignment", + "AlignmentIntro": "By default, the right side of the drop-down menu is aligned by setting MenuAlignment=Alignment.Right", + "ItemsTitle": "Bind data source", + "ItemsIntro": "When you click the button on the right, the menu items in the drop-down box will increase", + "RadioTitle": "Bind data source", + "RadioIntro": "When you change the options, the menu items in the drop-down box will increase", + "CascadeTitle": "Cascade binding", + "CascadeIntro": "By selecting different options in the first drop-down box, the second drop-down box is filled with content dynamically.", "IsFixedButtonTextTitle": "Fixed button text", - "IsFixedButtonTextIntro": "Set IsFixedButtonText to true make the ButtonText to const", + "IsFixedButtonTextIntro": "Set IsFixedButtonText to true make the ButtonText to const", "FixedButtonTextTitle": "Set the fixed button text", "FixedButtonTextIntro": "Set the FixedButtonText value for fixed button text", - "FixedButtonTextCity": "City", "ADesc1": "Currently selected value", "ADesc2": "Style", "ADesc3": "Color", @@ -1745,20 +1742,69 @@ "ADesc10": "Size", "ADesc11": "Label", "EDesc1": "Triggered when the value of the drop-down box changes", - "FixedButtonText": "The text of fixed button", - "V1": "Melbourne", - "V2": "Sydney", - "V3": "Queensland", - "F1": "Melbourne", - "F2": "Sydney", - "F3": "Queensland", - "I1": "Select ...", - "I2": "Melbourne", - "I3": "Sydney", - "I4": "Hangzhou", - "RI1": "Melbourne", - "RI2": "Sydney", - "RI3": "Queensland" + "FixedButtonText": "The text of fixed button" + }, + "BootstrapBlazor.Shared.Demos.Dropdown.DropdownNormal": { + "Item1": "Melbourne", + "Item2": "Sydney", + "Item3": "Queensland" + }, + "BootstrapBlazor.Shared.Demos.Dropdown.DropdownColor": { + "Item1": "Melbourne", + "Item2": "Sydney", + "Item3": "Queensland" + }, + "BootstrapBlazor.Shared.Demos.Dropdown.DropdownSplit": { + "Item1": "Melbourne", + "Item2": "Sydney", + "Item3": "Queensland" + }, + "BootstrapBlazor.Shared.Demos.Dropdown.DropdownSize": { + "Item1": "Melbourne", + "Item2": "Sydney", + "Item3": "Queensland" + }, + "BootstrapBlazor.Shared.Demos.Dropdown.DropdownDirection": { + "Item1": "Melbourne", + "Item2": "Sydney", + "Item3": "Queensland" + }, + "BootstrapBlazor.Shared.Demos.Dropdown.DropdownAlignment": { + "Item1": "Melbourne", + "Item2": "Sydney", + "Item3": "Queensland" + }, + "BootstrapBlazor.Shared.Demos.Dropdown.DropdownItems": { + "Item1": "Melbourne", + "Item2": "Sydney", + "Item3": "Queensland", + "AddItem": "Add", + "RemoveItem": "Remove", + "City": "City" + }, + "BootstrapBlazor.Shared.Demos.Dropdown.DropdownRadio": { + "Item1": "Melbourne", + "Item2": "Sydney", + "Item3": "Queensland" + }, + "BootstrapBlazor.Shared.Demos.Dropdown.DropdownCascade": { + "Item1": "Select ...", + "Item2": "Melbourne", + "Item3": "Sydney", + "Item4": "Hangzhou", + "Item5": "chaoyang", + "Item6": "haidian", + "Item7": "jingan", + "Item8": "huangpu" + }, + "BootstrapBlazor.Shared.Demos.Dropdown.DropdownIsFixedButtonText": { + "Item1": "Melbourne", + "Item2": "Sydney" + }, + "BootstrapBlazor.Shared.Demos.Dropdown.DropdownFixedButtonText": { + "Item1": "Melbourne", + "Item2": "Sydney", + "City": "City" }, "BootstrapBlazor.Shared.Samples.GoTops": { "Title": "GoTop", diff --git a/src/BootstrapBlazor.Shared/Locales/zh.json b/src/BootstrapBlazor.Shared/Locales/zh.json index 865de6082..b49549ead 100644 --- a/src/BootstrapBlazor.Shared/Locales/zh.json +++ b/src/BootstrapBlazor.Shared/Locales/zh.json @@ -1708,34 +1708,31 @@ }, "BootstrapBlazor.Shared.Samples.Dropdowns": { "Title": "Dropdown 下拉菜单", - "H1": "将动作或菜单折叠到下拉菜单中", - "Block1Title": "基础用法", - "Block1Intro": "使用 TagName='a' 开启带有 button 标签的下拉表", - "Block2Title": "Dropdown 空下拉菜单", - "Block2Intro": "允许空 Items 存在的下拉菜单", - "Block3Title": "带有颜色的下拉框", - "Block3Intro": "提供各种颜色的警告信息框 引用 Color='Color.Primary' 等颜色及样式类来定义下拉菜单的外在表现", - "Block4Title": "分裂式按钮下拉菜单", - "Block4Intro": "可用与单个按钮下拉菜单近似的标记创建分裂式下拉菜单,添加 ShowSplit='true' (使用分裂式组件时需要加上 DropdownType='DropdownType.ButtonGroup') 插入此符号为下拉选项作适当的间隔(距)处理。", - "Block5Title": "尺寸大小定义", - "Block5Intro": "下拉菜单有各种大小规格可以选用 Size 属性,包括预设及分裂式按钮下拉菜单。", - "Block6Title": "展开方向", - "Block6Intro": "增加 Direction='Direction.Dropup' 样式,使下拉菜单向上展开。", - "Block7Title": "菜单对齐", - "Block7Intro": "默认情况下,通过设置 MenuAlignment=Alignment.Right 使下拉菜单右侧对齐", - "Block8Title": "绑定数据源", - "Block8Intro": "点击右侧按钮时,下拉框内菜单项会增加", - "Button1Text": "添加", - "Button2Text": "删除", - "Block9Title": "绑定数据源", - "Block9Intro": "改变选项时,下拉框内菜单项会增加", - "Block10Title": "级联绑定", - "Block10Intro": "通过选择第一个下拉框不同选项,第二个下拉框动态填充内容。", + "Description": "将动作或菜单折叠到下拉菜单中", + "NormalTitle": "基础用法", + "NormalIntro": "使用 TagName='a' 开启带有 button 标签的下拉表", + "NullTitle": "Dropdown 空下拉菜单", + "NullIntro": "允许空 Items 存在的下拉菜单", + "ColorTitle": "带有颜色的下拉框", + "ColorIntro": "提供各种颜色的警告信息框 引用 Color='Color.Primary' 等颜色及样式类来定义下拉菜单的外在表现", + "SplitTitle": "分裂式按钮下拉菜单", + "SplitIntro": "可用与单个按钮下拉菜单近似的标记创建分裂式下拉菜单,添加 ShowSplit='true' (使用分裂式组件时需要加上 DropdownType='DropdownType.ButtonGroup') 插入此符号为下拉选项作适当的间隔(距)处理。", + "SizeTitle": "尺寸大小定义", + "SizeIntro": "下拉菜单有各种大小规格可以选用 Size 属性,包括预设及分裂式按钮下拉菜单。", + "DirectionTitle": "展开方向", + "DirectionIntro": "增加 Direction='Direction.Dropup' 样式,使下拉菜单向上展开。", + "AlignmentTitle": "菜单对齐", + "AlignmentIntro": "默认情况下,通过设置 MenuAlignment=Alignment.Right 使下拉菜单右侧对齐", + "ItemsTitle": "绑定数据源", + "ItemsIntro": "点击右侧按钮时,下拉框内菜单项会增加", + "RadioTitle": "绑定数据源", + "RadioIntro": "改变选项时,下拉框内菜单项会增加", + "CascadeTitle": "级联绑定", + "CascadeIntro": "通过选择第一个下拉框不同选项,第二个下拉框动态填充内容。", "IsFixedButtonTextTitle": "固定按钮文本", "IsFixedButtonTextIntro": "通过设置 IsFixedButtonText 使更改下拉选项时按钮文本不变", "FixedButtonTextTitle": "设置固定按钮文字", "FixedButtonTextIntro": "通过设置 FixedButtonText 来设置固定按钮的初始文字", - "FixedButtonTextCity": "城市", "ADesc1": "当前选中的值", "ADesc2": "样式", "ADesc3": "颜色", @@ -1748,20 +1745,70 @@ "ADesc10": "尺寸", "ADesc11": "标签", "EDesc1": "下拉框值发生改变时触发", - "FixedButtonText": "固定按钮显示文字", - "V1": "北京", - "V2": "上海", - "V3": "广州", - "F1": "北京", - "F2": "上海", - "F3": "广州", - "I1": "请选择 ...", - "I2": "北京", - "I3": "上海", - "I4": "杭州", - "RI1": "北京", - "RI2": "上海", - "RI3": "广州" + "FixedButtonText": "固定按钮显示文字" + }, + "BootstrapBlazor.Shared.Demos.Dropdown.DropdownNormal": { + "Item1": "北京", + "Item2": "上海", + "Item3": "广州" + }, + "BootstrapBlazor.Shared.Demos.Dropdown.DropdownColor": { + "Item1": "北京", + "Item2": "上海", + "Item3": "广州" + }, + "BootstrapBlazor.Shared.Demos.Dropdown.DropdownSplit": { + "Item1": "北京", + "Item2": "上海", + "Item3": "广州" + }, + "BootstrapBlazor.Shared.Demos.Dropdown.DropdownSize": { + "Item1": "北京", + "Item2": "上海", + "Item3": "广州" + }, + "BootstrapBlazor.Shared.Demos.Dropdown.DropdownDirection": { + "Item1": "北京", + "Item2": "上海", + "Item3": "广州" + }, + "BootstrapBlazor.Shared.Demos.Dropdown.DropdownAlignment": { + "Item1": "北京", + "Item2": "上海", + "Item3": "广州" + }, + "BootstrapBlazor.Shared.Demos.Dropdown.DropdownItems": { + "Item1": "北京", + "Item2": "上海", + "Item3": "广州", + "AddItem": "添加", + "RemoveItem": "删除", + "City": "城市" + }, + "BootstrapBlazor.Shared.Demos.Dropdown.DropdownRadio": { + "Item1": "北京", + "Item2": "上海", + "Item3": "广州", + "City": "城市" + }, + "BootstrapBlazor.Shared.Demos.Dropdown.DropdownCascade": { + "Item1": "请选择 ...", + "Item2": "北京", + "Item3": "上海", + "Item4": "杭州", + "Item5": "朝阳区", + "Item6": "海淀区", + "Item7": "静安区", + "Item8": "黄浦区" + }, + "BootstrapBlazor.Shared.Demos.Dropdown.DropdownIsFixedButtonText": { + "Item1": "北京", + "Item2": "上海" + }, + "BootstrapBlazor.Shared.Demos.Dropdown.DropdownFixedButtonText": { + "Item1": "北京", + "Item2": "上海", + "City": "城市" }, "BootstrapBlazor.Shared.Samples.GoTops": { "Title": "GoTop 返回顶端组件", diff --git a/src/BootstrapBlazor.Shared/Samples/Dropdowns.razor b/src/BootstrapBlazor.Shared/Samples/Dropdowns.razor index 9480acdf8..9ebdf6173 100644 --- a/src/BootstrapBlazor.Shared/Samples/Dropdowns.razor +++ b/src/BootstrapBlazor.Shared/Samples/Dropdowns.razor @@ -3,108 +3,31 @@

@Localizer["Title"]

-

@Localizer["H1"]

+

@Localizer["Description"]

- - - - + - - - + - -
-
-
-
-
-
-
+ - -
-
-
-
-
-
-
+ - -
-
-
-
-
-
-
-
-
+ - -
-
-
-
-
-
-
+ - -
-
-
-
-
-
-
+ - -
-
- - -
-
- - -
-
-
+ - -
-
- - -
-
- - -
-
-
+ - -
-
- -
-
- -
-
-
+ - - - + - - - + diff --git a/src/BootstrapBlazor.Shared/Samples/Dropdowns.razor.cs b/src/BootstrapBlazor.Shared/Samples/Dropdowns.razor.cs index 2c028e315..178eb7aa5 100644 --- a/src/BootstrapBlazor.Shared/Samples/Dropdowns.razor.cs +++ b/src/BootstrapBlazor.Shared/Samples/Dropdowns.razor.cs @@ -5,122 +5,14 @@ namespace BootstrapBlazor.Shared.Samples; /// -/// +/// Dropdowns /// public sealed partial class Dropdowns { - private List Items { get; set; } = new List { }; - private static List EmptyList => new(); - private List Foos { get; set; } = new List(); - private List RadioItems { get; set; } = new List(); - private List RadioDropDownItems { get; set; } = new List(); - - private IEnumerable? Items2 { get; set; } - private IEnumerable Items3 = new SelectedItem[] { }; - /// - /// + /// GetAttributes /// - protected override void OnInitialized() - { - base.OnInitialized(); - - Items = new List - { - new SelectedItem{ Text=Localizer["V1"], Value="0"}, - new SelectedItem{ Text=Localizer["V2"], Value="1"}, - new SelectedItem{ Text=Localizer["V3"], Value="2"}, - }; - - Foos = new List - { - new SelectedItem{ Text=Localizer["F1"], Value="0"}, - new SelectedItem{ Text=Localizer["F2"], Value="1"}, - new SelectedItem{ Text=Localizer["F3"], Value="2"}, - }; - - Items3 = new SelectedItem[] - { - new SelectedItem ("", Localizer["I1"]), - new SelectedItem ("Beijing", Localizer["I2"]) { Active = true }, - new SelectedItem ("Shanghai", Localizer["I3"]), - new SelectedItem ("Hangzhou", Localizer["I4"]) - }; - - RadioDropDownItems = new List - { - new SelectedItem("1", Localizer["RI1"]) { Active = true }, - new SelectedItem("2", Localizer["RI2"]), - new SelectedItem("3", Localizer["RI3"]) - }; - - RadioItems = new List - { - new SelectedItem("1", Localizer["RI1"]) { Active = true }, - new SelectedItem("2", Localizer["RI2"]) - }; - } - -/// -/// 级联绑定菜单 -/// -/// -private async Task OnCascadeBindSelectClick(SelectedItem item) - { - // 模拟异步通讯切换线程 - await Task.Delay(10); - if (item.Value == "Beijing") - { - Items2 = new SelectedItem[] - { - new SelectedItem("1","朝阳区") { Active = true}, - new SelectedItem("2","海淀区"), - }; - } - else if (item.Value == "Shanghai") - { - Items2 = new SelectedItem[] - { - new SelectedItem("1","静安区"), - new SelectedItem("2","黄浦区") { Active = true } , - }; - } - else - { - Items2 = Enumerable.Empty(); - } - StateHasChanged(); - } - - [NotNull] - private BlockLogger? Trace { get; set; } - - private Task ShowMessage(SelectedItem e) - { - Trace.Log($"Dropdown Item Clicked: Value={e.Value} Text={e.Text}"); - return Task.CompletedTask; - } - - private void AddItem() - { - Foos.Add(new SelectedItem($"{Foos.Count}", $"城市 {Foos.Count}")); - } - - private void RemoveItem() - { - if (Foos.Any()) - { - Foos.RemoveAt(0); - } - } - - private Task OnRadioItemChanged(IEnumerable values, SelectedItem item) - { - RadioDropDownItems.Add(new SelectedItem($"{RadioDropDownItems.Count + 1}", $"城市 {RadioDropDownItems.Count}")); - StateHasChanged(); - return Task.CompletedTask; - } - + /// private IEnumerable GetAttributes() => new AttributeItem[] { // TODO: 移动到数据库中 @@ -210,6 +102,10 @@ private async Task OnCascadeBindSelectClick(SelectedItem item) } }; + /// + /// GetEvents + /// + /// private IEnumerable GetEvents() => new EventItem[] { new EventItem()