Skip to content

feat: support show exact value - #218

Open
dogledogle wants to merge 1 commit into
react-component:masterfrom
dogledogle:feat-support-show-exact-value
Open

feat: support show exact value#218
dogledogle wants to merge 1 commit into
react-component:masterfrom
dogledogle:feat-support-show-exact-value

Conversation

@dogledogle

@dogledogle dogledogle commented Aug 24, 2026

Copy link
Copy Markdown

为 Ant Design Rate 精细显示需求提供 rc-rate 底层支持。

本改动用于实现 Ant Design #52986 提出的 Rate 只读模式展示体验优化,使组件能够准确展示 3.8、4.7、4.9 等非整星、非半星评分。

  • 新增 showExactValue 布尔值 prop,仅在 disabled 状态下生效
  • 补充示例及中英文 API 文档

Summary by CodeRabbit

  • 新功能

    • 评分组件在禁用状态下支持按原始小数值精确显示评分,而不再仅显示整星或半星。
    • 新增 showExactValue 配置,默认关闭,并支持 RTL(从右到左)布局。
  • 文档

    • 更新中英文 API 文档,并补充精确评分显示示例。
  • 测试

    • 新增精确评分、RTL 布局及与半星配置兼容性的测试覆盖。
@vercel

vercel Bot commented Aug 24, 2026

Copy link
Copy Markdown

@dogledogle is attempting to deploy a commit to the afc163's projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Aug 24, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: a3adf1fa-5a1e-4800-a0a5-d50a057a0c5a

📥 Commits

Reviewing files that changed from the base of the PR and between 82114f5 and ba5e167.

📒 Files selected for processing (6)
  • README.md
  • README.zh-CN.md
  • docs/examples/simple.tsx
  • src/Rate.tsx
  • src/Star.tsx
  • tests/simple.spec.js

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


Walkthrough

Rate 新增 showExactValue 属性。禁用状态下,Star 按评分小数部分设置字符宽度。文档、示例和测试覆盖精确展示、RTL、交互模式及 allowHalf 组合。

Changes

Rate 精确评分展示

Layer / File(s) Summary
API 属性与组件传递
src/Rate.tsx, src/Star.tsx
RatePropsStarProps 新增 showExactValue。Rate 默认关闭该属性,并仅在禁用状态下传递给 Star。
小数比例渲染
src/Star.tsx
Star 根据评分与索引计算小数比例,并为首层字符设置动态宽度。
示例、文档与行为验证
README.md, README.zh-CN.md, docs/examples/simple.tsx, tests/simple.spec.js
文档和 Disabled 示例增加精确评分说明。测试覆盖禁用、RTL、交互模式及 allowHalf 组合。

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to ba5e1

This localized change adds exact-value display support for disabled ratings; no actionable merge-blocking risk remains beyond normal checks and review.

Suggested reviewers: afc163

Sequence Diagram(s)

sequenceDiagram
  participant Rate
  participant Star
  participant RatingMarkup
  Rate->>Star: disabled && showExactValue
  Star->>RatingMarkup: 根据小数比例设置宽度
  RatingMarkup-->>Star: 渲染精确评分
Loading

Poem

我是小兔,带来精确星光,
三点八分,不再匆忙取整。
Star 量出八成宽,
RTL 方向也清晰明亮。
文档与测试排好队,
耳朵一抖,改动完成。

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题准确概括了本次新增 showExactValue 属性的主要变更,内容简洁且与代码、文档和测试改动一致。
Docstring Coverage ✅ Passed Docstring check was indeterminate for this PR — some files could not be analyzed in time. Not blocking.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with 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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@nrps9909 nrps9909 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved exact head ba5e1673413471194634594f13e706980f267716.

I verified that showExactValue remains disabled by default and is gated to read-only Rate instances, while allowHalf retains its existing interactive behavior. The submitted repository scope passes 2/2 suites, 46/46 tests, and 7/7 snapshots. TypeScript and source lint also pass with zero errors (one unchanged useEffect dependency warning), and ESM, CJS, declaration, and Less compilation complete successfully.

A temporary independent matrix covered 0.1, 1.999999999, and 2.25 across RTL rendering, confirming the exact 10%, 99.9999999%, and 25% clip widths. A controlled rerender also verified that disabling showExactValue removes the dynamic width and half-state class instead of leaving stale exact-value presentation. All 4 added probes passed and were removed after validation.

The only remote failure is the fork Vercel authorization gate, not a source check.

Codex-assisted review: Codex traced the Rate/Star display precedence, ran the full repository and build validation, and executed the isolated boundary matrix in a detached exact-head worktree. No repository files were changed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants