Skip to content

Simplify and export some of the new animation props#7481

Merged
PavelVanecek merged 1 commit into
mainfrom
animations-refactor-again
Jun 21, 2026
Merged

Simplify and export some of the new animation props#7481
PavelVanecek merged 1 commit into
mainfrom
animations-refactor-again

Conversation

@PavelVanecek

@PavelVanecek PavelVanecek commented Jun 21, 2026

Copy link
Copy Markdown
Collaborator

I tried to use the new components on our website and turns out the generics were awkward and some names were not so intuitive so I changed things one more time and exported some components that turn out to be quite useful.

Again, not a breaking change, these are not yet released.

Summary by CodeRabbit

  • New Features

    • Newly exported animation control APIs including AnimationHandle, JavascriptAnimation, CSSTransitionAnimation, AnimationController, OnAnimationStateUpdate, TimeoutController, CancelableTimeout, and AnimationControllerProvider
  • Refactor

    • Simplified AnimationController to a non-generic type system
    • Updated animation handle method names for consistency: getDuration()getAnimationDuration(), getBeginDelay()getAnimationBegin()
    • Added new timing getters: getAnimationStartedTime() and getBeginStartedTime()
  • Tests

    • Added TypeScript type inference tests for AnimationController

@coderabbitai

coderabbitai Bot commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

Renames the AnimationStateMachine abstraction to AnimationHandle by introducing an internal RechartsAnimation abstract base class, removing generics from the controller contract, renaming public API methods, and defining AnimationHandle as a JavascriptAnimation | CSSTransitionAnimation union. New animation types are exported from the package root, and all tests, mocks, and build snapshots are updated accordingly.

Changes

AnimationHandle Refactor and Public API Surface Expansion

Layer / File(s) Summary
AnimationHandle base class and exported type union
src/animation/AnimationHandle.ts
Removes AnimationStateMachine interface; introduces internal RechartsAnimation abstract class with a duration() helper, renames public API methods (getDurationgetAnimationDuration, getBeginDelaygetAnimationBegin), adds timing getters, rewrites tick() and complete() state logic, and defines AnimationHandle = JavascriptAnimation | CSSTransitionAnimation.
AnimationController and OnAnimationStateUpdate contract
src/animation/AnimationController.ts, src/animation/AnimationControllerImpl.ts, src/animation/timeoutController.ts
Introduces OnAnimationStateUpdate = (newState: number | string) => void, removes generic type parameters from AnimationController and animationControllerImpl, and adds JSDoc to timeout controller types while removing the requestAnimationFrame existence guard.
CSSTransitionAnimate and JavascriptAnimate consumer updates
src/animation/CSSTransitionAnimate.tsx, src/animation/JavascriptAnimate.tsx
Updates imports from ./AnimationHandle, widens style state to string | number, and ensures Number(style) is passed to the children callback.
Package entry point and docs registration
src/index.ts, www/src/docs/apiCates.ts
Adds AnimationHandle, JavascriptAnimation, CSSTransitionAnimation, AnimationController, OnAnimationStateUpdate, TimeoutController, CancelableTimeout, and AnimationControllerProvider to the top-level exports and registers AnimationControllerProvider in the animation docs category.
Test utilities, typed spec, and mock updates
test/animation/MockProgressAnimationManager.ts, test/animation/CompositeAnimationManager.ts, test/animation/mockAnimationController.ts, test/animation/AnimationController.typed.spec.ts, test/animation/AnimationControllerImpl.spec.ts, test/animation/RechartsAnimation.spec.ts, omnidoc/verifyExamples.spec.ts
Updates all test mocks and utilities to AnimationHandle/OnAnimationStateUpdate; adds a new TypeScript inference test suite for AnimationController; repoints imports to ../../src; extends the exportsThatNeedExamples exclusion list.
Build artifact snapshots
scripts/snapshots/es6Files.txt, scripts/snapshots/libFiles.txt, scripts/snapshots/typesFiles.txt
Replaces AnimationStateMachine entries with AnimationHandle in all three snapshot manifests.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • recharts/recharts#7457: Part of the same animation refactor series, updating AnimationController/AnimationControllerImpl and test utilities to the new animation-state-machine/handle model.
  • recharts/recharts#7477: Directly precedes this PR's work by replacing AnimationStateMachine-based controller props with the newer AnimationHandle contract and updating provider/test usage.
  • recharts/recharts#7476: Modifies omnidoc/verifyExamples.spec.ts in the same way by changing the exportsThatNeedExamples exclusion list and related example-coverage assertions.

Suggested reviewers

  • ckifer
🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive The PR description is vague and generic. It mentions changes to generics and component names but lacks specific details about what was changed, tested, or which components were exported. Provide specific details about which components were exported, what generic issues were simplified, which names were changed, and document testing performed to validate these changes.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Simplify and export some of the new animation props' clearly and specifically describes the main changes in the PR: simplifying animation-related code and exporting previously internal components.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch animations-refactor-again

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 and usage tips.

@codecov

codecov Bot commented Jun 21, 2026

Copy link
Copy Markdown

Bundle Report

Changes will increase total bundle size by 17.13kB (0.31%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
recharts/bundle-cjs 1.43MB 3.36kB (0.24%) ⬆️
recharts/bundle-es6 1.26MB 2.92kB (0.23%) ⬆️
recharts/bundle-umd 586.18kB 184 bytes (0.03%) ⬆️
recharts/bundle-treeshaking-cartesian 717.68kB 2.75kB (0.39%) ⬆️
recharts/bundle-treeshaking-polar 474.27kB 2.58kB (0.55%) ⬆️
recharts/bundle-treeshaking-treemap 388.54kB 2.75kB (0.71%) ⬆️
recharts/bundle-treeshaking-sankey 375.27kB 2.58kB (0.69%) ⬆️

Affected Assets, Files, and Routes:

view changes for bundle: recharts/bundle-treeshaking-sankey

Assets Changed:

Asset Name Size Change Total Size Change (%)
bundle.js 2.58kB 375.27kB 0.69%
view changes for bundle: recharts/bundle-treeshaking-polar

Assets Changed:

Asset Name Size Change Total Size Change (%)
bundle.js 2.58kB 474.27kB 0.55%
view changes for bundle: recharts/bundle-umd

Assets Changed:

Asset Name Size Change Total Size Change (%)
Recharts.js 184 bytes 586.18kB 0.03%
view changes for bundle: recharts/bundle-treeshaking-cartesian

Assets Changed:

Asset Name Size Change Total Size Change (%)
bundle.js 2.75kB 717.68kB 0.39%
view changes for bundle: recharts/bundle-es6

Assets Changed:

Asset Name Size Change Total Size Change (%)
animation/AnimationHandle.js (New) 9.65kB 9.65kB 100.0% 🚀
animation/CSSTransitionAnimate.js -6 bytes 4.53kB -0.13%
index.js 173 bytes 4.35kB 4.14%
animation/JavascriptAnimate.js 2 bytes 3.81kB 0.05%
animation/timeoutController.js 238 bytes 1.23kB 24.04% ⚠️
animation/AnimationStateMachine.js (Deleted) -7.14kB 0 bytes -100.0% 🗑️
view changes for bundle: recharts/bundle-cjs

Assets Changed:

Asset Name Size Change Total Size Change (%)
index.js 640 bytes 17.0kB 3.91%
animation/AnimationHandle.js (New) 9.91kB 9.91kB 100.0% 🚀
animation/CSSTransitionAnimate.js -18 bytes 4.82kB -0.37%
animation/JavascriptAnimate.js -10 bytes 4.07kB -0.25%
animation/timeoutController.js 238 bytes 1.45kB 19.69% ⚠️
animation/AnimationStateMachine.js (Deleted) -7.4kB 0 bytes -100.0% 🗑️
view changes for bundle: recharts/bundle-treeshaking-treemap

Assets Changed:

Asset Name Size Change Total Size Change (%)
bundle.js 2.75kB 388.54kB 0.71%

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/animation/AnimationHandle.ts (1)

116-134: 💤 Low value

Consider adding descriptive error messages to thrown errors.

The bare throw new Error() at line 125 provides no context when debugging. Since this represents an invariant violation (being in PENDING state without beginStartedTime set), a descriptive message would help diagnose issues.

💡 Suggested improvement
     if (this.getState() === PENDING) {
       if (this.beginStartedTime == null) {
-        throw new Error();
+        throw new Error('beginStartedTime must be set when in PENDING state');
       }

Similarly for the error at line 139.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/animation/AnimationHandle.ts` around lines 116 - 134, The tick method in
the AnimationHandle class contains bare Error throws without descriptive
messages, making debugging difficult. Add descriptive error messages to both
Error throws in this method: first, replace the Error thrown when
beginStartedTime is null in the PENDING state with a message explaining this
invariant violation, and second, add a descriptive message to the other Error
throw mentioned at line 139. Each error message should clearly explain what
state invariant was violated to aid in troubleshooting.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@www/src/docs/apiCates.ts`:
- Around line 108-116: The animation category items array is missing two
exported animation classes that are defined as value exports. Add
JavascriptAnimation and CSSTransitionAnimation to the items array in the
animation category section of the apiCates mapping to ensure these
runtime-exported symbols have corresponding navigation links. Include them in
the items array alongside the existing entries like matchByIndex,
matchByDataKey, and the other animation-related exports.

---

Nitpick comments:
In `@src/animation/AnimationHandle.ts`:
- Around line 116-134: The tick method in the AnimationHandle class contains
bare Error throws without descriptive messages, making debugging difficult. Add
descriptive error messages to both Error throws in this method: first, replace
the Error thrown when beginStartedTime is null in the PENDING state with a
message explaining this invariant violation, and second, add a descriptive
message to the other Error throw mentioned at line 139. Each error message
should clearly explain what state invariant was violated to aid in
troubleshooting.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 2c8761d1-cb69-497b-8d18-d010f8a642d6

📥 Commits

Reviewing files that changed from the base of the PR and between 410cf5c and 814f0ac.

📒 Files selected for processing (18)
  • omnidoc/verifyExamples.spec.ts
  • scripts/snapshots/es6Files.txt
  • scripts/snapshots/libFiles.txt
  • scripts/snapshots/typesFiles.txt
  • src/animation/AnimationController.ts
  • src/animation/AnimationControllerImpl.ts
  • src/animation/AnimationHandle.ts
  • src/animation/CSSTransitionAnimate.tsx
  • src/animation/JavascriptAnimate.tsx
  • src/animation/timeoutController.ts
  • src/index.ts
  • test/animation/AnimationController.typed.spec.ts
  • test/animation/AnimationControllerImpl.spec.ts
  • test/animation/CompositeAnimationManager.ts
  • test/animation/MockProgressAnimationManager.ts
  • test/animation/RechartsAnimation.spec.ts
  • test/animation/mockAnimationController.ts
  • www/src/docs/apiCates.ts

Comment thread www/src/docs/apiCates.ts
Comment on lines +108 to +116
items: [
'matchByIndex',
'matchByDataKey',
'matchAppend',
'interpolate',
'AreaRevealShape',
'LineDrawShape',
'AnimationControllerProvider',
],

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

Add missing runtime exports to the animation category.

The JavascriptAnimation and CSSTransitionAnimation are exported as value exports in src/index.ts (line 171) but are missing from this apiCates mapping. According to the omnidoc test in omnidoc/omnidoc.spec.ts, every runtime-exported symbol must appear in apiCates for navigation links to render correctly.

🔧 Add missing exports to apiCates
    items: [
      'matchByIndex',
      'matchByDataKey',
      'matchAppend',
      'interpolate',
      'AreaRevealShape',
      'LineDrawShape',
+     'JavascriptAnimation',
+     'CSSTransitionAnimation',
      'AnimationControllerProvider',
    ],
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
items: [
'matchByIndex',
'matchByDataKey',
'matchAppend',
'interpolate',
'AreaRevealShape',
'LineDrawShape',
'AnimationControllerProvider',
],
items: [
'matchByIndex',
'matchByDataKey',
'matchAppend',
'interpolate',
'AreaRevealShape',
'LineDrawShape',
'JavascriptAnimation',
'CSSTransitionAnimation',
'AnimationControllerProvider',
],
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@www/src/docs/apiCates.ts` around lines 108 - 116, The animation category
items array is missing two exported animation classes that are defined as value
exports. Add JavascriptAnimation and CSSTransitionAnimation to the items array
in the animation category section of the apiCates mapping to ensure these
runtime-exported symbols have corresponding navigation links. Include them in
the items array alongside the existing entries like matchByIndex,
matchByDataKey, and the other animation-related exports.

@chromatic-com

chromatic-com Bot commented Jun 21, 2026

Copy link
Copy Markdown

Tip

All tests passed and all changes approved!

🟢 UI Tests: 198 tests unchanged
🟢 UI Review: 198 stories published -- no changes
Storybook icon Storybook Publish: 198 stories published

@codecov

codecov Bot commented Jun 21, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 86.11111% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.39%. Comparing base (410cf5c) to head (814f0ac).

Files with missing lines Patch % Lines
src/animation/AnimationHandle.ts 78.26% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7481      +/-   ##
==========================================
- Coverage   88.41%   88.39%   -0.03%     
==========================================
  Files         602      602              
  Lines       13907    13911       +4     
  Branches     3514     3514              
==========================================
  Hits        12296    12296              
- Misses       1428     1432       +4     
  Partials      183      183              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions

Copy link
Copy Markdown
Contributor

@PavelVanecek
PavelVanecek merged commit c88f5f3 into main Jun 21, 2026
63 of 65 checks passed
@PavelVanecek
PavelVanecek deleted the animations-refactor-again branch June 21, 2026 12:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant