feat(BootstrapInputCurrency):add Currency support component - #8443
feat(BootstrapInputCurrency):add Currency support component#8443Tony-ST0754 wants to merge 6 commits into
Conversation
refactor:支持数字格式化显示,例如:$123,252.12 feat:增加文化信息参数 feat:增加Parser,以便与Formatter成配套使用;即Formatter可以输出任意格式,Parser负责反向
Reviewer's Guide该 PR 通过以 inputmode="decimal" 替代 type="number",解除浏览器原生数字输入对格式化文本的限制;同时引入 CultureInfo 和 Parser,使 InputNumber 支持区域化默认转换及 Formatter 输出的自定义逆向解析,并补充转换、组件交互和筛选器测试。 Sequence diagram for formatted InputNumber parsingsequenceDiagram
participant User
participant InputNumber
participant Parser
participant Converter
User->>InputNumber: Enter formatted value
alt Parser is configured
InputNumber->>Parser: Parser(value, CultureInfo)
Parser-->>InputNumber: Success, parsed TValue
else Default conversion
InputNumber->>Converter: TryConvertTo(value, CultureInfo)
Converter-->>InputNumber: Success, parsed TValue
end
InputNumber-->>User: Update numeric Value or show validation error
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 2 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="src/BootstrapBlazor.Server/appsettings.json" line_range="53-55" />
<code_context>
- "Float": "0.1",
- "Double": "0.01",
- "Decimal": "0.01"
+ "Float": "any",
+ "Double": "any",
+ "Decimal": "any"
},
"ConnectionHubOptions": {
</code_context>
<issue_to_address>
**issue (bug_risk):** The sample application's default Float, Double, and Decimal step values are changed to `any`, but `BootstrapInputNumber.GetStepString()` converts `any` to `1` for its increment/decrement logic. Decimal inputs using the configured defaults therefore increment by whole integers instead of their previous fractional steps.
**Triggers:** When a floating-point or decimal InputNumber uses the sample application's default StepSettings and ShowButton is enabled.
**Suggested fix:** Keep the fractional defaults, or handle `any` separately in the button calculation instead of converting it to `1`.
</issue_to_address>
### Comment 2
<location path="src/BootstrapBlazor.Server/Components/Samples/InputNumbers.razor" line_range="8-11" />
<code_context>
<h4>@Localizer["InputNumbersDescription"]</h4>
-<DemoBlock Title="@Localizer["InputNumbersNormalTitle"]"
+@* <DemoBlock Title="@Localizer["InputNumbersNormalTitle"]"
Introduction="@Localizer["InputNumbersNormalIntro"]"
Name="Normal">
</code_context>
<issue_to_address>
**nitpick:** The PR comments out the normal, ShowButton, Step, and Disabled InputNumber demo blocks, so the public sample page no longer demonstrates those existing component behaviors and their associated localized descriptions.
**Triggers:** When users visit the InputNumber documentation/sample page.
**Suggested fix:** Keep the existing examples enabled and add separate formatting examples for the new Formatter, Parser, and CultureInfo behavior.
</issue_to_address>Sourcery assessment
Needs a human reviewer. 1 finding to address first, and this changes shared numeric parsing and formatting behavior, including culture-specific conversion and custom parsers, so an incorrect parse could submit a wrong numeric value to a consuming application. Reverting restores the old behavior, but values already accepted and stored downstream would need to be identified and repaired.
Blocking findings: src/BootstrapBlazor.Server/appsettings.json:55
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #8443 +/- ##
==========================================
Coverage 100.00% 100.00%
==========================================
Files 772 776 +4
Lines 34798 35167 +369
==========================================
+ Hits 34798 35167 +369
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
refactor:重构数据清洗标准化逻辑 test:调整单元测试
Link issues
fixes #8442 #8444
根本原因
目前
InputNumber组件,虽提供了Formatter回调,但由于组件最终还是会在Web里面了生成相应的Html元素,因此,采用了Input元素,且使用了type="number"这个类型,因此,不管怎么格式化,最终由于Html标准的限制导致格式化的内容无法按期望(用户)设定的显示解决方案
新增
InputCurrency组件,专门用于输入数值后进行格式化显示的组件Regression?
Risk
Verification
Packaging changes reviewed?
☑️ Self Check before Merge
Summary by Sourcery
Introduce culture-aware currency and formatted numeric input support through a new BootstrapInputCurrency component.
New Features:
Enhancements:
Documentation:
Tests: