Skip to content

feat(react-rating): add useRatingBase_unstable hook#35823

Draft
dmytrokirpa wants to merge 3 commits intomasterfrom
feat/react-rating-base-hooks
Draft

feat(react-rating): add useRatingBase_unstable hook#35823
dmytrokirpa wants to merge 3 commits intomasterfrom
feat/react-rating-base-hooks

Conversation

@dmytrokirpa
Copy link
Contributor

Summary

  • Adds useRatingBase_unstable for the Rating component: manages role=radiogroup, controlled/uncontrolled value state, hover state, and onChange/onMouseOver/onMouseLeave event handlers; omits color and size design props
  • Adds useRatingDisplayBase_unstable for RatingDisplay: manages role=img, aria-labelledby composition from valueText/countText IDs, compact vs. full display mode slot structure; omits color and size design props
  • Adds useRatingItemBase_unstable for RatingItem: manages icon fill width calculation, radio input ARIA labels, aria-label from itemLabel callback, half/full value radio input slots; omits color and size (from context) design props
  • Adds RatingBaseProps/RatingBaseState, RatingDisplayBaseProps/RatingDisplayBaseState, RatingItemBaseProps/RatingItemBaseState types using DistributiveOmit
  • Refactors useRating_unstable, useRatingDisplay_unstable, and useRatingItem_unstable to delegate to base hooks, then add design props
  • Exports all new types and hooks from component index.ts files, barrel files, and package index.ts

Design props excluded from base hooks

Component Omitted props
Rating color, size
RatingDisplay color, size
RatingItem color (from context), size (from context)

Structural/behavioral props retained in base hooks

  • max, name, step, value, defaultValue, onChange, itemLabel, iconFilled, iconOutline (Rating)
  • compact, icon, max, count, value (RatingDisplay)
  • value, icon fill width logic, radio inputs (RatingItem)

Test plan

  • TypeScript compiles without errors (npx tsc -p packages/react-components/react-rating/library/tsconfig.json --noEmit)
  • All new base hooks and types are exported from the package index
  • Existing Rating, RatingDisplay, and RatingItem behavior is unchanged

🤖 Generated with Claude Code

dmytrokirpa and others added 2 commits March 5, 2026 12:07
…unstable, and useRatingItemBase_unstable hooks

Implements base state hooks for Rating, RatingDisplay, and RatingItem components that
extract pure component logic without design props (color, size):

- useRatingBase_unstable: manages radiogroup ARIA role, controlled/uncontrolled value,
  hover state tracking, and radio input structure; omits color and size
- useRatingDisplayBase_unstable: manages img ARIA role, aria-labelledby from
  valueText/countText IDs, compact/full display modes; omits color and size
- useRatingItemBase_unstable: manages fill width calculation, radio input slots for
  ARIA rating interaction, icon slots; omits color and size from context

Adds corresponding Base props/state types using DistributiveOmit.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@dmytrokirpa dmytrokirpa force-pushed the feat/react-rating-base-hooks branch from ae10056 to 86b1df7 Compare March 5, 2026 11:07
@dmytrokirpa dmytrokirpa changed the base branch from experimental/component-base-hooks to master March 5, 2026 11:07
@github-actions github-actions bot removed the CI label Mar 5, 2026
@github-actions
Copy link

github-actions bot commented Mar 5, 2026

📊 Bundle size report

Package & Exports Baseline (minified/GZIP) PR Change
react-components
react-components: entire library
1.292 MB
323.107 kB
1.292 MB
323.144 kB
135 B
37 B
Unchanged fixtures
Package & Exports Size (minified/GZIP)
react-components
react-components: Button, FluentProvider & webLightTheme
70.397 kB
19.96 kB
react-components
react-components: Accordion, Button, FluentProvider, Image, Menu, Popover
236.537 kB
68.697 kB
react-components
react-components: FluentProvider & webLightTheme
43.612 kB
14.022 kB
react-portal-compat
PortalCompatProvider
8.386 kB
2.624 kB
react-timepicker-compat
TimePicker
108.174 kB
35.695 kB
🤖 This report was generated against ace36179073ac4600a3635304a0941bd7dcda21d

@github-actions
Copy link

github-actions bot commented Mar 5, 2026

Pull request demo site: URL

@@ -0,0 +1,7 @@
{
Copy link

@github-actions github-actions bot Mar 5, 2026

Choose a reason for hiding this comment

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

🕵🏾‍♀️ visual changes to review in the Visual Change Report

vr-tests-react-components/CalendarCompat 4 screenshots
Image Name Diff(in Pixels) Image Type
vr-tests-react-components/CalendarCompat.multiDayView - High Contrast.default.chromium.png 1236 Changed
vr-tests-react-components/CalendarCompat.multiDayView - Dark Mode.default.chromium.png 1107 Changed
vr-tests-react-components/CalendarCompat.multiDayView - RTL.default.chromium.png 495 Changed
vr-tests-react-components/CalendarCompat.multiDayView.default.chromium_1.png 403 Changed
vr-tests-react-components/Charts-DonutChart 2 screenshots
Image Name Diff(in Pixels) Image Type
vr-tests-react-components/Charts-DonutChart.Dynamic - RTL.default.chromium.png 5570 Changed
vr-tests-react-components/Charts-DonutChart.Dynamic.default.chromium.png 5581 Changed
vr-tests-react-components/Positioning 2 screenshots
Image Name Diff(in Pixels) Image Type
vr-tests-react-components/Positioning.Positioning end.updated 2 times.chromium.png 509 Changed
vr-tests-react-components/Positioning.Positioning end.chromium.png 726 Changed
vr-tests-react-components/TagPicker 2 screenshots
Image Name Diff(in Pixels) Image Type
vr-tests-react-components/TagPicker.disabled - Dark Mode.disabled input hover.chromium.png 658 Changed
vr-tests-react-components/TagPicker.disabled.disabled input hover.chromium.png 677 Changed

There were 3 duplicate changes discarded. Check the build logs for more information.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant