feat(InputNumber): Support better customization with semantic classNames/styles as function #54996
Conversation
…mes/styles as function
|
|
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. ✨ Finishing touches🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
👁 Visual Regression Report for PR #54996 Failed ❌
Important There are 7 diffs found in this PR: 🔄
|
| <div | ||
| class="ant-input-number-input-wrap" | ||
| > | ||
| <input |
There was a problem hiding this comment.
Looks like this element is missing an accessible name or label. That makes it hard for people using screen readers or voice control to use the control.
| <div | ||
| class="ant-input-number-input-wrap" | ||
| > | ||
| <input |
There was a problem hiding this comment.
Looks like this element is missing an accessible name or label. That makes it hard for people using screen readers or voice control to use the control.
| <div | ||
| class="ant-input-number-input-wrap" | ||
| > | ||
| <input |
There was a problem hiding this comment.
Looks like this element is missing an accessible name or label. That makes it hard for people using screen readers or voice control to use the control.
| <div | ||
| class="ant-input-number-input-wrap" | ||
| > | ||
| <input |
There was a problem hiding this comment.
Looks like this element is missing an accessible name or label. That makes it hard for people using screen readers or voice control to use the control.
| <div | ||
| class="ant-input-number-input-wrap" | ||
| > | ||
| <input |
There was a problem hiding this comment.
Looks like this element is missing an accessible name or label. That makes it hard for people using screen readers or voice control to use the control.
There was a problem hiding this comment.
Summary of Changes
Hello @zjr222, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request significantly improves the customizability of the InputNumber component by introducing classNames and styles props. These new props allow developers to apply custom CSS classes and inline styles to specific internal elements of the component. The flexibility is further extended by enabling these props to accept functions, which can dynamically determine the classes or styles based on the component's current properties, offering a powerful way to integrate the InputNumber into diverse design systems with precise styling control.
Highlights
- Enhanced Customization: The
InputNumbercomponent now supportsclassNamesandstylesprops, allowing for more granular customization of its internal semantic DOM structure. - Flexible Prop Types: Both
classNamesandstylesprops can accept either an object (mapping semantic names to class strings or style objects) or a function that receives component props to dynamically determine classes or styles. - New Type Definitions: Introduced
InputNumberClassNamesTypeandInputNumberStylesTypeto provide strong typing for these new customization props. - Updated
useMergeSemanticHook: The internaluseMergeSemantichook has been enhanced to pass component properties, enabling the functional usage ofclassNamesandstyles. - Comprehensive Testing and Documentation: New snapshot tests, a dedicated demo, and updated API documentation (both English and Chinese) have been added to cover and explain the new functionality.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
There was a problem hiding this comment.
Summary of Changes
Hello @zjr222, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request significantly improves the customization capabilities of the InputNumber component by introducing classNames and styles props. These new props enable developers to apply custom CSS classes and inline styles to specific internal elements of the InputNumber component, either statically via objects or dynamically via functions that respond to the component's properties. This change provides greater flexibility for styling and integrating the component into diverse design systems.
Highlights
- Enhanced Customization for InputNumber: The InputNumber component now supports
classNamesandstylesprops, allowing for more granular customization of its internal semantic DOM structure. - Flexible Prop Types: Both
classNamesandstylesprops can accept either an object for static customization or a function that receives componentpropsfor dynamic styling based on the component's state. - New Demo and Documentation: A new demo (
style-class.tsx) and corresponding documentation (style-class.md,index.en-US.md,index.zh-CN.md) have been added to illustrate and explain the usage of these new customization options. - Updated
useMergeSemanticHook: The internaluseMergeSemantichook has been enhanced to correctly process function-basedclassNamesandstylesby passing the component's currentprops.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
There was a problem hiding this comment.
Code Review
This pull request introduces a valuable enhancement to the InputNumber component by allowing classNames and styles to be provided as functions. This enables more dynamic and conditional styling based on the component's props. The implementation in InputNumber/index.tsx is well-structured, correctly creating mergedProps to pass to useMergeSemantic. The new demos and documentation updates are clear and helpful. My main feedback is regarding testing: while the object-based classNames and styles are tested, there are no specific tests for the new function-based capability. Adding tests for this would make the feature more robust.
…ub.com/zjr222/ant-design into feat/input_number/semantic_class_style
More templates
commit: |
Bundle ReportChanges will increase total bundle size by 72 bytes (0.0%) ⬆️. This is within the configured threshold ✅ Detailed changes
Affected Assets, Files, and Routes:view changes for bundle: antd.min-array-pushAssets Changed:
|
|
ci 挂了 更新下 snap |
|
运行 |
There was a problem hiding this comment.
Pull Request Overview
This PR adds support for better customization of the InputNumber component by allowing classNames and styles props to be functions that receive component props as arguments, enabling dynamic styling based on component state.
Key changes:
- Enhanced type definitions to support function-based
classNamesandstyles - Integrated
useMergeSemantichook with proper prop context for dynamic evaluation - Added comprehensive tests and demo showcasing both object and function usage
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
components/input-number/index.tsx |
Updated type definitions and component logic to support function-based semantic styling with proper prop context |
components/input-number/index.zh-CN.md |
Added Chinese documentation for new classNames and styles function support |
components/input-number/index.en-US.md |
Added English documentation for new classNames and styles function support |
components/input-number/demo/style-class.tsx |
Created demo showcasing both object and function usage of semantic styling |
components/input-number/demo/style-class.md |
Added demo documentation in both languages |
components/input-number/__tests__/style-class.test.tsx |
Added comprehensive test coverage for the new semantic styling functionality |
components/input-number/__tests__/__snapshots__/style-class.test.tsx.snap |
Generated snapshots for test validation |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## next #54996 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 793 793
Lines 14661 14661
Branches 3893 3893
=========================================
Hits 14661 14661 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Signed-off-by: 遇见同学 <[email protected]>
Signed-off-by: 遇见同学 <[email protected]>
Signed-off-by: 遇见同学 <[email protected]>
移除冗余的样式和类名配置,使用 createStyles 简化样式管理 更新测试用例以匹配新的实现,移除不必要的快照测试
…ub.com/zjr222/ant-design into feat/input_number/semantic_class_style

















中文版模板 / Chinese template
🤔 This is a ...
🔗 Related Issues
💡 Background and Solution
📝 Change Log