diff --git a/src/BootstrapBlazor.Shared/Demos/Display/DisplayDataType.razor b/src/BootstrapBlazor.Shared/Demos/Display/DisplayDataType.razor new file mode 100644 index 000000000..60fce1c8c --- /dev/null +++ b/src/BootstrapBlazor.Shared/Demos/Display/DisplayDataType.razor @@ -0,0 +1,50 @@ +@inject IStringLocalizer Localizer + +
+
+ Integer + +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +@code { + /// + /// Foo 类为Demo测试用,如有需要请自行下载源码查阅 + /// Foo class is used for Demo test, please download the source code if necessary + /// https://gitee.com/LongbowEnterprise/BootstrapBlazor/blob/main/src/BootstrapBlazor.Shared/Data/Foo.cs + /// + [NotNull] + private Foo? Model { get; set; } + + [Inject] + [NotNull] + private IStringLocalizer? FooLocalizer { get; set; } + + private byte[] ByteArray { get; set; } = { 0x01, 0x12, 0x34, 0x56 }; + + /// + /// OnInitialized 方法 + /// + protected override void OnInitialized() + { + base.OnInitialized(); + + Model = Foo.Generate(FooLocalizer); + Model.Hobby = Foo.GenerateHobbys(FooLocalizer).Take(3).Select(i => i.Text); + } +} diff --git a/src/BootstrapBlazor.Shared/Demos/Display/DisplayEditorForm.razor b/src/BootstrapBlazor.Shared/Demos/Display/DisplayEditorForm.razor new file mode 100644 index 000000000..2f1868ddc --- /dev/null +++ b/src/BootstrapBlazor.Shared/Demos/Display/DisplayEditorForm.razor @@ -0,0 +1,34 @@ + + + + + + +@code { + /// + /// Foo 类为Demo测试用,如有需要请自行下载源码查阅 + /// Foo class is used for Demo test, please download the source code if necessary + /// https://gitee.com/LongbowEnterprise/BootstrapBlazor/blob/main/src/BootstrapBlazor.Shared/Data/Foo.cs + /// + [NotNull] + private Foo? Model { get; set; } + + [Inject] + [NotNull] + private IStringLocalizer? FooLocalizer { get; set; } + + [NotNull] + private IEnumerable? Hobbys { get; set; } + + /// + /// OnInitialized 方法 + /// + protected override void OnInitialized() + { + base.OnInitialized(); + + Model = Foo.Generate(FooLocalizer); + Model.Hobby = Foo.GenerateHobbys(FooLocalizer).Take(3).Select(i => i.Text); + Hobbys = Foo.GenerateHobbys(FooLocalizer); + } +} diff --git a/src/BootstrapBlazor.Shared/Demos/Display/DisplayFormatString.razor b/src/BootstrapBlazor.Shared/Demos/Display/DisplayFormatString.razor new file mode 100644 index 000000000..ef16b1746 --- /dev/null +++ b/src/BootstrapBlazor.Shared/Demos/Display/DisplayFormatString.razor @@ -0,0 +1,31 @@ +@inject IStringLocalizer Localizer + +
+
@Localizer["FormatStringettingText"] FormatString
+
+ +
+
@Localizer["FormatStringettingText"] Formatter
+
+ +
+
+

@((MarkupString)Localizer["FormatStringP"].Value)

+
+
@Localizer["FormatStringettingText"] Formatter
+
+ +
+
+ +@code { + private byte[] ByteArray { get; set; } = { 0x01, 0x12, 0x34, 0x56 }; + + private static Task DateTimeFormatter(DateTime source) => Task.FromResult(source.ToString("yyyy-MM-dd")); + + private static async Task ByteArrayFormatter(byte[] source) + { + await Task.Delay(10); + return Convert.ToBase64String(source); + } +} diff --git a/src/BootstrapBlazor.Shared/Demos/Display/DisplayLabels.razor b/src/BootstrapBlazor.Shared/Demos/Display/DisplayLabels.razor new file mode 100644 index 000000000..75ea08969 --- /dev/null +++ b/src/BootstrapBlazor.Shared/Demos/Display/DisplayLabels.razor @@ -0,0 +1,56 @@ +@inject IStringLocalizer Localizer + +
+
+ +
+
+

@((MarkupString)Localizer["BindWayP2"].Value)

+
+
+ +
+
+ +
+
+

@((MarkupString)Localizer["BindWayP3"].Value)

+
+
+ +
+
+ +
+
+

@((MarkupString)Localizer["BindWayP4"].Value)

+
+
+ +
+
+ +@code { + /// + /// Foo 类为Demo测试用,如有需要请自行下载源码查阅 + /// Foo class is used for Demo test, please download the source code if necessary + /// https://gitee.com/LongbowEnterprise/BootstrapBlazor/blob/main/src/BootstrapBlazor.Shared/Data/Foo.cs + /// + [NotNull] + private Foo? Model { get; set; } + + [Inject] + [NotNull] + private IStringLocalizer? FooLocalizer { get; set; } + + /// + /// OnInitialized 方法 + /// + protected override void OnInitialized() + { + base.OnInitialized(); + + Model = Foo.Generate(FooLocalizer); + Model.Hobby = Foo.GenerateHobbys(FooLocalizer).Take(3).Select(i => i.Text); + } +} diff --git a/src/BootstrapBlazor.Shared/Demos/Display/DisplayLookup.razor b/src/BootstrapBlazor.Shared/Demos/Display/DisplayLookup.razor new file mode 100644 index 000000000..b1d89f6b5 --- /dev/null +++ b/src/BootstrapBlazor.Shared/Demos/Display/DisplayLookup.razor @@ -0,0 +1,12 @@ + + +@code { + private IEnumerable IntValue { get; set; } = new[] { 1, 2, 3 }; + + private IEnumerable IntValueSource { get; set; } = new[] + { + new SelectedItem("1", "Text1"), + new SelectedItem("2", "Text2"), + new SelectedItem("3", "Text3") + }; +} diff --git a/src/BootstrapBlazor.Shared/Demos/Display/DisplayNormal.razor b/src/BootstrapBlazor.Shared/Demos/Display/DisplayNormal.razor new file mode 100644 index 000000000..ae582b93a --- /dev/null +++ b/src/BootstrapBlazor.Shared/Demos/Display/DisplayNormal.razor @@ -0,0 +1,35 @@ +@inject IStringLocalizer Localizer + +
+
+ @Localizer["BasicUsage"] +
+
+ +
+
+ +@code { + /// + /// Foo 类为Demo测试用,如有需要请自行下载源码查阅 + /// Foo class is used for Demo test, please download the source code if necessary + /// https://gitee.com/LongbowEnterprise/BootstrapBlazor/blob/main/src/BootstrapBlazor.Shared/Data/Foo.cs + /// + [NotNull] + private Foo? Model { get; set; } + + [Inject] + [NotNull] + private IStringLocalizer? FooLocalizer { get; set; } + + /// + /// OnInitialized 方法 + /// + protected override void OnInitialized() + { + base.OnInitialized(); + + Model = Foo.Generate(FooLocalizer); + Model.Hobby = Foo.GenerateHobbys(FooLocalizer).Take(3).Select(i => i.Text); + } +} diff --git a/src/BootstrapBlazor.Shared/Locales/en.json b/src/BootstrapBlazor.Shared/Locales/en.json index be8e09c1f..8ac6d723f 100644 --- a/src/BootstrapBlazor.Shared/Locales/en.json +++ b/src/BootstrapBlazor.Shared/Locales/en.json @@ -3984,37 +3984,45 @@ "SubTitle": "Displays static text data", "BasicUsageTitle": "Basic usage", "BasicUsageIntro": "Show only", - "BasicUsage": "Basic usage", "BindWayTitle": "Bind data in both directions", "BindWayIntro": "Two-way binding automatically gets the display labels in the resource file", "BindWayP1": "When the Dispaly components turn on bidirectional binding, the Display/DisplayName label value is automatically obtained based on the Model property value of the binding and appears as a pre-Label, with DisplayText properties you can customize the display of the pre-label, or by turning off the display of the pre-label through the ShowLabel property", - "BindWayCustomLabel": "Custom labels", - "BindWayP2": "Set the DisplayText value to custom label ", - "BindWayOccupants": "Occupants", - "BindWayP3": "The value of DisplayText is displayed when ShowLabel is true, regardless of whether the value is set", - "BindWayNotccupants": "Do not occupy seats", - "BindWayP4": "The value of DisplayText is not displayed when the ShowLabel is false", "DataTypeTitle": "Generic binding", "DataTypeIntro": "The Display component has built-in processing of enumerated collections array, customize formatting or callback delegate methods if they do not meet the criteria", "EditorFormTitle": "Used within the form", "EditorFormIntro": "The Dispaly component is used in form components EditorForm, and is used in detail pages and is not editable", "FormatStringTitle": "Custom format", "FormatStringIntro": "When you set the FormatString property value to yyyy-MM-dd, the component displays a time format of the year and day", - "FormatStringettingText": "Set up", - "FormatStringP": "The Dispaly component binding byte[] array, formatted as an example of base64 encoded string", "LookupTitle": "Automatically translated into Text", "LookupIntro": "Set the Lookup value to IEnumerable<SelectedItem> collection, through which the component will perform translations through the Value display Text", - "LookupP1": "In this example, the component Value='@IntValue' set Lookup='@IntValueSource' component to display the Text corresponding to the value of the Value", + "LookupP1": "In this example, the component Value='@IntValue' set Lookup='@IntValueSource' component to display the Value corresponding to the value of the Text Value", "ShowLabel": "Whether to display the front label", "DisplayText": "The front label displays text", "FormatString": "The numerically formatted string", "Formatter": "TableHeader instance", - "TypeResolver": "It is used internally when the type resolution callback method tvalue is an array instance", + "TypeResolver": "It is used internally when the type resolution callback method tvalue is an array instance" + }, + "BootstrapBlazor.Shared.Demos.Display.DisplayNormal": { + "BasicUsage": "Basic usage" + }, + "BootstrapBlazor.Shared.Demos.Display.DisplayLabels": { + "BindWayCustomLabel": "Custom labels", + "BindWayP2": "Set the DisplayText value to custom label ", + "BindWayOccupants": "Occupants", + "BindWayP3": "The value of DisplayText is displayed when ShowLabel is true, regardless of whether the value is set", + "BindWayNotccupants": "Do not occupy seats", + "BindWayP4": "The value of DisplayText is not displayed when the ShowLabel is false" + }, + "BootstrapBlazor.Shared.Demos.Display.DisplayDataType": { "Integer": "Integer", "Enum": "Enumerate", "Collection": "Collection", "Arr": "Array" }, + "BootstrapBlazor.Shared.Demos.Display.DisplayFormatString": { + "FormatStringettingText": "Set up", + "FormatStringP": "The Dispaly component binding byte[] array, formatted as an example of base64 encoded string" + }, "BootstrapBlazor.Shared.Samples.DropdownWidgets": { "Title": "DropdownWidget", "SubTitle": "More for head information summary presentation", diff --git a/src/BootstrapBlazor.Shared/Locales/zh.json b/src/BootstrapBlazor.Shared/Locales/zh.json index 05bd40684..68a075dbf 100644 --- a/src/BootstrapBlazor.Shared/Locales/zh.json +++ b/src/BootstrapBlazor.Shared/Locales/zh.json @@ -3988,24 +3988,15 @@ "SubTitle": "显示静态文本数据", "BasicUsageTitle": "基础用法", "BasicUsageIntro": "仅显示", - "BasicUsage": "基础用法", "BindWayTitle": "双向绑定数据", "BindWayIntro": "通过双向绑定可以自动获取资源文件中的显示标签", "BindWayP1": "Display 组件开启双向绑定时,会根据绑定的 Model 属性值去自动获取 Display/DisplayName 标签值并且显示为前置 Label,通过 DisplayText 属性可以自定义显示前置标签,或者通过 ShowLabel 属性关闭前置标签是否显示", - "BindWayCustomLabel": "自定义标签", - "BindWayP2": "设置 DisplayText 值为 自定义标签", - "BindWayOccupants": "占位", - "BindWayP3": "无论是否设置 DisplayText 值,当 ShowLabeltrue 时均显示", - "BindWayNotccupants": "不占位", - "BindWayP4": "无论是否设置 DisplayText 值,当 ShowLabelfalse 时均不显示", "DataTypeTitle": "泛型绑定", "DataTypeIntro": "Display 组件内置对 枚举 集合 数组 进行处理,如不符合条件时,请自定义格式化或者回调委托方法", "EditorFormTitle": "表单内使用", "EditorFormIntro": "Display 组件在表单组件 EditorForm 中使用,多用于明细页,不可编辑模式", "FormatStringTitle": "自定义格式", "FormatStringIntro": "设置 FormatString 属性值为 yyyy-MM-dd 时,组件显示的时间格式为年月日", - "FormatStringettingText": "设置", - "FormatStringP": "Display 组件绑定 byte[] 数组,格式化成 base64 编码字符串示例", "LookupTitle": "自动翻译为 Text", "LookupIntro": "设置 Lookup 值为 IEnumerable<SelectedItem> 集合,组件将通过此数据集,进行通过 Value 显示 Text 翻译工作", "LookupP1": "本例中组件 Value='@IntValue' 设置 Lookup='@IntValueSource' 组件将 Value 值对应的 Text 显示出来", @@ -4013,12 +4004,29 @@ "DisplayText": "前置标签显示文本", "FormatString": "数值格式化字符串", "Formatter": "TableHeader 实例", - "TypeResolver": "类型解析回调方法 TValue 为 Array 实例时内部使用", + "TypeResolver": "类型解析回调方法 TValue 为 Array 实例时内部使用" + }, + "BootstrapBlazor.Shared.Demos.Display.DisplayNormal": { + "BasicUsage": "基础用法" + }, + "BootstrapBlazor.Shared.Demos.Display.DisplayLabels": { + "BindWayCustomLabel": "自定义标签", + "BindWayP2": "设置 DisplayText 值为 自定义标签", + "BindWayOccupants": "占位", + "BindWayP3": "无论是否设置 DisplayText 值,当 ShowLabeltrue 时均显示", + "BindWayNotccupants": "不占位", + "BindWayP4": "无论是否设置 DisplayText 值,当 ShowLabelfalse 时均不显示" + }, + "BootstrapBlazor.Shared.Demos.Display.DisplayDataType": { "Integer": "整型", "Enum": "枚举", "Collection": "集合", "Arr": "数组" }, + "BootstrapBlazor.Shared.Demos.Display.DisplayFormatString": { + "FormatStringettingText": "设置", + "FormatStringP": "Display 组件绑定 byte[] 数组,格式化成 base64 编码字符串示例" + }, "BootstrapBlazor.Shared.Samples.DropdownWidgets": { "Title": "DropdownWidget 下拉挂件", "SubTitle": "多用于头部信息汇总展示", diff --git a/src/BootstrapBlazor.Shared/Samples/Displays.razor b/src/BootstrapBlazor.Shared/Samples/Displays.razor index 2fcdd4e51..936df401f 100644 --- a/src/BootstrapBlazor.Shared/Samples/Displays.razor +++ b/src/BootstrapBlazor.Shared/Samples/Displays.razor @@ -5,108 +5,24 @@

@Localizer["SubTitle"]

- -
-
- @Localizer["BasicUsage"] -
-
- -
-
-
+ - +

@((MarkupString)Localizer["BindWayP1"].Value)

-
-
- -
-
-

@((MarkupString)Localizer["BindWayP2"].Value)

-
-
- -
-
- -
-
-

@((MarkupString)Localizer["BindWayP3"].Value)

-
-
- -
-
- -
-
-

@((MarkupString)Localizer["BindWayP4"].Value)

-
-
- -
-
- -
-
Integer - -
-
- -
-
- -
-
- -
-
- -
-
- -
-
-
+ - - - - - - - + - -
-
@Localizer["FormatStringettingText"] FormatString
-
- -
-
@Localizer["FormatStringettingText"] Formatter
-
- -
-
-

@((MarkupString)Localizer["FormatStringP"].Value)

-
-
@Localizer["FormatStringettingText"] Formatter
-
- -
-
-
+ - +

@((MarkupString)Localizer["LookupP1"].Value)
InitValue: 1,2,3
IntValueSource: Text1,Text2,Text3

-
diff --git a/src/BootstrapBlazor.Shared/Samples/Displays.razor.cs b/src/BootstrapBlazor.Shared/Samples/Displays.razor.cs index 57de5fb1c..37b49e567 100644 --- a/src/BootstrapBlazor.Shared/Samples/Displays.razor.cs +++ b/src/BootstrapBlazor.Shared/Samples/Displays.razor.cs @@ -9,47 +9,6 @@ namespace BootstrapBlazor.Shared.Samples; /// public partial class Displays { - [NotNull] - private Foo? Model { get; set; } - - [Inject] - [NotNull] - private IStringLocalizer? FooLocalizer { get; set; } - - [NotNull] - private IEnumerable? Hobbys { get; set; } - - private byte[] ByteArray { get; set; } = new byte[] { 0x01, 0x12, 0x34, 0x56 }; - - private IEnumerable IntValue { get; set; } = new[] { 1, 2, 3 }; - - private IEnumerable IntValueSource { get; set; } = new[] - { - new SelectedItem("1", "Text1"), - new SelectedItem("2", "Text2"), - new SelectedItem("3", "Text3") - }; - - private static async Task ByteArrayFormatter(byte[] source) - { - await Task.Delay(10); - return Convert.ToBase64String(source); - } - - private static Task DateTimeFormatter(DateTime source) => Task.FromResult(source.ToString("yyyy-MM-dd")); - - /// - /// OnInitialized 方法 - /// - protected override void OnInitialized() - { - base.OnInitialized(); - - Model = Foo.Generate(FooLocalizer); - Model.Hobby = Foo.GenerateHobbys(FooLocalizer).Take(3).Select(i => i.Text); - Hobbys = Foo.GenerateHobbys(FooLocalizer); - } - private IEnumerable GetAttributes() => new[] { new AttributeItem() {