From 94ebc58668ed4b0fc28d77821270e296c4d89c9f Mon Sep 17 00:00:00 2001 From: Tony-ST0754 <6914529@qq.com> Date: Sat, 5 Sep 2026 15:45:19 +0800 Subject: [PATCH 1/6] =?UTF-8?q?feat(InputNumber):=E5=A2=9E=E5=BC=BA?= =?UTF-8?q?=E6=95=B0=E5=AD=97=E6=A0=BC=E5=BC=8F=E5=8C=96=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit refactor:支持数字格式化显示,例如:$123,252.12 feat:增加文化信息参数 feat:增加Parser,以便与Formatter成配套使用;即Formatter可以输出任意格式,Parser负责反向 --- .../Components/Samples/InputNumbers.razor | 51 ++++++------ .../Components/Samples/InputNumbers.razor.cs | 27 ++++++- src/BootstrapBlazor.Server/appsettings.json | 6 +- .../InputNumber/BootstrapInputNumber.razor | 4 +- .../InputNumber/BootstrapInputNumber.razor.cs | 31 ++++++- .../Extensions/ObjectExtensions.cs | 57 +++++++++++++ test/UnitTest/Components/InputNumberTest.cs | 80 +++++++++++++++++++ .../Extensions/ObjectExtensionsTest.cs | 29 +++++++ 8 files changed, 251 insertions(+), 34 deletions(-) diff --git a/src/BootstrapBlazor.Server/Components/Samples/InputNumbers.razor b/src/BootstrapBlazor.Server/Components/Samples/InputNumbers.razor index d7e0a5be2e1..d19b8a6dd82 100644 --- a/src/BootstrapBlazor.Server/Components/Samples/InputNumbers.razor +++ b/src/BootstrapBlazor.Server/Components/Samples/InputNumbers.razor @@ -5,7 +5,7 @@
@Localizer["InputNumbersShowButtonDescription"]
@@ -67,9 +69,9 @@@Localizer["InputNumbersStep0.1"]
@Localizer["InputNumbersColorDescription1"]
+@Localizer["InputNumbersColorDescription1"]
@Localizer["InputNumbersColorDescription2"]
@Localizer["InputNumbersShowButtonDescription"]
@@ -69,9 +67,9 @@@Localizer["InputNumbersStep0.1"]
@Localizer["InputNumbersColorDescription1"]
+@Localizer["InputNumbersColorDescription1"]
@Localizer["InputNumbersColorDescription2"]
IsIntersectionObserver=\"true\" to enable lazy loading, the image will not be loaded when it is in the invisible area, and will be loaded only when it is about to be visible.",
"IntersectionObserverTitle": "Intersection Observer"
},
+ "BootstrapBlazor.Server.Components.Samples.InputCurrency": {
+ "InputCurrencyCultureIntro": "Specify culture information, for example: en-US, zh-CN",
+ "InputCurrencyCultureIntro2": "Specify Brazilian Portuguese, for example: pt-BR",
+ "InputCurrencyCultureTitle": "Culture-specific usage",
+ "InputCurrencyCustomizeIntro": "Use the Formatter callback to achieve custom format usage",
+ "InputCurrencyCustomizeTitle": "Custom format usage",
+ "InputCurrencyDescription": "Only allows standard numeric values and provides formatting capabilities, for example: entering 12345.78 displays as 12,345.78 with thousand separators; as ¥12,345.78 for currency; and as 12,345.78% for percentage.",
+ "InputCurrencyMemo": "This component is actually an extension of the InputNumbers component, designed to meet the need to display formatted numeric values such as currency and percentages in the UI.",
+ "InputCurrencyNormalIntro": "Number numeric type displays a text box, automatically bringing up the numeric keyboard on mobile devices",
+ "InputCurrencyNormalTitle": "Basic usage",
+ "InputCurrencyPercentIntro": "You can use Formatter or FormatString to achieve percentage display",
+ "InputCurrencyPercentTitle": "Percentage usage",
+ "InputCurrencyRangeIntro": "Set Max and Min to control the numeric range 1-10",
+ "InputCurrencyRangeTitle": "Range limitation usage",
+ "InputCurrencyTitle": "InputCurrency"
+ },
"BootstrapBlazor.Server.Components.Samples.InputGroups": {
"InputGroupsCheckboxIntro": "Add Checkbox or CheckboxList to the InputGroup",
"InputGroupsCheckboxTitle": "Checkbox",
@@ -6067,7 +6083,6 @@
"Picture.Required": "{0} is required"
},
"BootstrapBlazor.Server.Components.Samples.ValidateForms": {
- "AsyncValidationError": "The user name already exists.",
"AsyncValidationUserName": "User name",
"ChangeButtonText": "Change",
"CustomValidationFormComment1": "Add mailbox validation rules",
diff --git a/src/BootstrapBlazor.Server/Locales/zh-CN.json b/src/BootstrapBlazor.Server/Locales/zh-CN.json
index 40735fdcb2c..3981912a05d 100644
--- a/src/BootstrapBlazor.Server/Locales/zh-CN.json
+++ b/src/BootstrapBlazor.Server/Locales/zh-CN.json
@@ -2771,6 +2771,22 @@
"IntersectionObserverIntro": "通过设置 IsIntersectionObserver=\"true\" 开启懒加载特性,当图片在不可见区域时不加载图片,当图片即将可见时才开始加载图片",
"IntersectionObserverTitle": "懒加载"
},
+ "BootstrapBlazor.Server.Components.Samples.InputCurrency": {
+ "InputCurrencyCultureIntro": "自行指定文化信息,例如:en-US、zh-CN",
+ "InputCurrencyCultureIntro2": "指定巴西葡萄牙语,例如:pt-BR",
+ "InputCurrencyCultureTitle": "指文化用法",
+ "InputCurrencyCustomizeIntro": "使用 Formatter 回调来实现自定义格式用法",
+ "InputCurrencyCustomizeTitle": "自定义格式用法",
+ "InputCurrencyDescription": "仅允许输入标准的数字值,并提供格式化功能,例如:输入12345.78,千分位显示:12,345.78;货币显示:¥12,345.78;百分比显示:12,345.78%",
+ "InputCurrencyMemo": "本组件,实际上是 InputNumbers 组件的扩展,以满足有需要在 UI 中显示货币、百分比等格式化数值的需求",
+ "InputCurrencyNormalIntro": "Number 数值类型显示文本框,移动端自动弹出数字键盘",
+ "InputCurrencyNormalTitle": "基础用法",
+ "InputCurrencyPercentIntro": "可使用 Formatter 或 FormatString 来实现百分比显示",
+ "InputCurrencyPercentTitle": "百分比用法",
+ "InputCurrencyRangeIntro": "设置 Max Min 来控制数值区间范围 1-10",
+ "InputCurrencyRangeTitle": "区间限制用法",
+ "InputCurrencyTitle": "InputCurrency 组件"
+ },
"BootstrapBlazor.Server.Components.Samples.InputGroups": {
"InputGroupsCheckboxIntro": "往 InputGroup 里面增加 Checkbox 或者 CheckboxList",
"InputGroupsCheckboxTitle": "复选框组合",
@@ -6067,7 +6083,6 @@
"Picture.Required": "上传文件不能为空"
},
"BootstrapBlazor.Server.Components.Samples.ValidateForms": {
- "AsyncValidationError": "用户名已存在",
"AsyncValidationUserName": "用户名",
"ChangeButtonText": "更改组件",
"CustomValidationFormComment1": "增加邮箱验证规则",
diff --git a/src/BootstrapBlazor.Server/docs.json b/src/BootstrapBlazor.Server/docs.json
index 4dd9a807ec2..3d4a710849f 100644
--- a/src/BootstrapBlazor.Server/docs.json
+++ b/src/BootstrapBlazor.Server/docs.json
@@ -104,6 +104,7 @@
"iframe": "IFrames",
"image-viewer": "ImageViewers",
"input-number": "InputNumbers",
+ "input-currency": "InputCurrency",
"input": "Inputs",
"input-group": "InputGroups",
"ip": "Ips",
diff --git a/src/BootstrapBlazor/Components/InputCurrency/BootstrapInputCurrency.razor b/src/BootstrapBlazor/Components/InputCurrency/BootstrapInputCurrency.razor
new file mode 100644
index 00000000000..225677568fc
--- /dev/null
+++ b/src/BootstrapBlazor/Components/InputCurrency/BootstrapInputCurrency.razor
@@ -0,0 +1,17 @@
+@namespace BootstrapBlazor.Components
+@typeparam TValue
+@inherits BootstrapInputNumberBase