Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: inert value in next15 #4491

Open
wants to merge 6 commits into
base: canary
Choose a base branch
from
Open

Conversation

winchesHe
Copy link
Member

@winchesHe winchesHe commented Jan 4, 2025

Closes #

📝 Description

⛳️ Current behavior (updates)

🚀 New behavior

💣 Is this a breaking change (Yes/No):

📝 Additional Information

Summary by CodeRabbit

Release Notes for @nextui-org/shared-utils

  • Package Updates

    • Renamed package from @nextui-org/system to @nextui-org/shared-utils
    • Updated package configuration and installation instructions
  • New Features

    • Added post-installation script for handling React version-specific utilities
    • Introduced version-specific getInertValue function for inert attribute handling
  • Improvements

    • Enhanced support for React 18 and React 19 compatibility
    • Streamlined module exports for easier access to utility functions
  • Bug Fixes

    • Resolved issue with Tabs component in Next.js 15 environment
  • Refactor

    • Removed outdated React version-checking functions to simplify codebase

@winchesHe winchesHe requested a review from jrgarciadev as a code owner January 4, 2025 09:03
Copy link

changeset-bot bot commented Jan 4, 2025

🦋 Changeset detected

Latest commit: 2d1d692

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 58 packages
Name Type
@nextui-org/shared-utils Patch
@nextui-org/accordion Patch
@nextui-org/alert Patch
@nextui-org/autocomplete Patch
@nextui-org/avatar Patch
@nextui-org/badge Patch
@nextui-org/breadcrumbs Patch
@nextui-org/button Patch
@nextui-org/calendar Patch
@nextui-org/card Patch
@nextui-org/checkbox Patch
@nextui-org/chip Patch
@nextui-org/code Patch
@nextui-org/date-input Patch
@nextui-org/date-picker Patch
@nextui-org/divider Patch
@nextui-org/drawer Patch
@nextui-org/dropdown Patch
@nextui-org/form Patch
@nextui-org/image Patch
@nextui-org/input-otp Patch
@nextui-org/input Patch
@nextui-org/kbd Patch
@nextui-org/link Patch
@nextui-org/listbox Patch
@nextui-org/menu Patch
@nextui-org/modal Patch
@nextui-org/navbar Patch
@nextui-org/pagination Patch
@nextui-org/popover Patch
@nextui-org/progress Patch
@nextui-org/radio Patch
@nextui-org/ripple Patch
@nextui-org/scroll-shadow Patch
@nextui-org/select Patch
@nextui-org/skeleton Patch
@nextui-org/slider Patch
@nextui-org/snippet Patch
@nextui-org/spacer Patch
@nextui-org/spinner Patch
@nextui-org/switch Patch
@nextui-org/table Patch
@nextui-org/tabs Patch
@nextui-org/tooltip Patch
@nextui-org/user Patch
@nextui-org/theme Patch
@nextui-org/use-aria-button Patch
@nextui-org/use-aria-link Patch
@nextui-org/use-data-scroll-overflow Patch
@nextui-org/use-infinite-scroll Patch
@nextui-org/use-pagination Patch
@nextui-org/aria-utils Patch
@nextui-org/framer-utils Patch
@nextui-org/react-utils Patch
@nextui-org/react Patch
@nextui-org/system Patch
@nextui-org/use-image Patch
@nextui-org/use-real-shape Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

vercel bot commented Jan 4, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
nextui-docs-v2 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 12, 2025 7:43am
nextui-storybook-v2 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 12, 2025 7:43am

Copy link
Contributor

coderabbitai bot commented Jan 4, 2025

Walkthrough

This pull request introduces changes to the @nextui-org/shared-utils package, focusing on resolving issues with the Tabs component and enhancing compatibility with different React versions. Key updates include renaming the package, modifying the package configuration, and restructuring exports. A new post-installation script has been added to manage React version-specific tasks, such as copying directories and updating TypeScript definitions. The changes also involve the removal of certain version-checking functions and the introduction of new utility functions tailored for React 18 and React 19.

Changes

File Change Summary
.changeset/smart-eagles-hope.md Patch for @nextui-org/shared-utils addressing Tabs component issue
packages/utilities/shared-utils/README.md Package name updated from @nextui-org/system to @nextui-org/shared-utils, new "File structure" section added
packages/utilities/shared-utils/package.json Added scripts to files, new postinstall and postbuild scripts, updated tsup configuration
packages/utilities/shared-utils/scripts/postinstall.js New post-installation script for handling React version-specific directory copying
packages/utilities/shared-utils/src/common/functions.ts Removed isReact19 and getInertValue functions
packages/utilities/shared-utils/src/common/index.ts Added comprehensive exports from multiple modules
packages/utilities/shared-utils/src/demi/react18/getInertValue.ts New getInertValue function for React 18
packages/utilities/shared-utils/src/demi/react19/getInertValue.ts New getInertValue function for React 19
packages/utilities/shared-utils/src/index.ts Removed multiple export statements, added exports for common and demi/react18 modules

Possibly related PRs

Suggested labels

📋 Scope : Docs

Suggested reviewers

  • jrgarciadev

📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ede6b12 and 2d1d692.

📒 Files selected for processing (1)
  • packages/utilities/shared-utils/scripts/postinstall.js (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/utilities/shared-utils/scripts/postinstall.js
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: TypeScript
  • GitHub Check: Build

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

linear bot commented Jan 4, 2025

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

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 (3)
packages/utilities/shared-utils/src/functions.ts (2)

404-413: Consider using semver for robust version checks.
Dynamically importing next/package.json might introduce overhead and partial reliability issues if the version format changes. Relying on startsWith("15") in other parts of the code is also somewhat fragile. Using a semver library would provide a more resilient approach.


415-419: Handle minor & patch releases when identifying Next.js 15.
Using version.startsWith("15") might work for now, but it may fail to capture or properly handle any future minor/patch releases (e.g., 15.10.x). A semantic version check would be more maintainable long-term.

.changeset/smart-eagles-hope.md (1)

1-5: Enhance the patch description for clarity.
Consider adding more details about this fix, including how it impacts Tabs or addresses the Next.js 15 error, to help future maintainers and users understand the scope of the patch more readily.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a43b156 and 44d466e.

📒 Files selected for processing (3)
  • .changeset/smart-eagles-hope.md (1 hunks)
  • packages/components/tabs/src/tab-panel.tsx (0 hunks)
  • packages/utilities/shared-utils/src/functions.ts (2 hunks)
💤 Files with no reviewable changes (1)
  • packages/components/tabs/src/tab-panel.tsx

packages/utilities/shared-utils/src/functions.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🧹 Nitpick comments (3)
packages/utilities/shared-utils/README.md (2)

21-29: Add language specification to code block

The file structure code block should specify a language for better syntax highlighting.

-```
+```text
 src/
 ├── common/ # Common utilities for all React versions
 └── demi/ # Demi utilities for different React versions
    ├── react18/
    └── react19/
🧰 Tools
🪛 Markdownlint (0.37.0)

23-23: null
Fenced code blocks should have a language specified

(MD040, fenced-code-language)


Line range hint 1-34: Enhance documentation with version compatibility details

Consider adding a section about React version compatibility and how the package handles different versions.

Add the following section:

+## Version Compatibility
+
+This package automatically adapts to your React version:
+- React 18 / Next.js 14: Uses react18 utilities
+- React 19 / Next.js 15+: Uses react19 utilities
+
 ## License
🧰 Tools
🪛 Markdownlint (0.37.0)

23-23: null
Fenced code blocks should have a language specified

(MD040, fenced-code-language)

packages/utilities/shared-utils/src/demi/react18/getInertValue.ts (1)

1-17: Consider adding type guards for better type safety

While the implementation is correct, you might want to consider adding type guards to ensure type safety when consuming the function.

-export const getInertValue = (v: boolean): boolean | string | undefined => {
+export const getInertValue = (v: boolean): "" | undefined => {
   return v ? "" : undefined;
 };
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 44d466e and ede6b12.

📒 Files selected for processing (11)
  • .changeset/smart-eagles-hope.md (1 hunks)
  • packages/utilities/shared-utils/README.md (3 hunks)
  • packages/utilities/shared-utils/package.json (3 hunks)
  • packages/utilities/shared-utils/scripts/postinstall.js (1 hunks)
  • packages/utilities/shared-utils/src/common/functions.ts (0 hunks)
  • packages/utilities/shared-utils/src/common/index.ts (1 hunks)
  • packages/utilities/shared-utils/src/demi/react18/getInertValue.ts (1 hunks)
  • packages/utilities/shared-utils/src/demi/react18/index.ts (1 hunks)
  • packages/utilities/shared-utils/src/demi/react19/getInertValue.ts (1 hunks)
  • packages/utilities/shared-utils/src/demi/react19/index.ts (1 hunks)
  • packages/utilities/shared-utils/src/index.ts (1 hunks)
💤 Files with no reviewable changes (1)
  • packages/utilities/shared-utils/src/common/functions.ts
✅ Files skipped from review due to trivial changes (3)
  • packages/utilities/shared-utils/src/demi/react18/index.ts
  • packages/utilities/shared-utils/src/demi/react19/index.ts
  • packages/utilities/shared-utils/src/common/index.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • .changeset/smart-eagles-hope.md
🧰 Additional context used
🪛 Markdownlint (0.37.0)
packages/utilities/shared-utils/README.md

23-23: null
Fenced code blocks should have a language specified

(MD040, fenced-code-language)

⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: TypeScript
  • GitHub Check: Build
🔇 Additional comments (7)
packages/utilities/shared-utils/scripts/postinstall.js (1)

4-10: Well-implemented error handling!

The function safely handles package requirements with proper error fallback.

packages/utilities/shared-utils/package.json (1)

49-51: LGTM: Build configuration changes

The tsup configuration changes appropriately handle the new directory structure with React version-specific entries.

packages/utilities/shared-utils/src/index.ts (2)

1-3: Clarify the "For Development" comment

The comment "For Development" is ambiguous. Please clarify if this is a temporary state or if there are specific development-related implications.


4-5: Verify the impact of removed exports

The removal of multiple utility exports (assertion, clsx, object, text, etc.) could be a breaking change for consumers. Please ensure this is intentional and documented.

✅ Verification successful

No breaking changes detected - utilities are still available

The utilities (assertion, clsx, object, text, etc.) have not been removed but rather reorganized into individual files under the common/ directory. They remain accessible through the same import path @nextui-org/shared-utils as evidenced by their continued successful usage throughout the codebase.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for usage of removed utilities in the codebase
rg -l "import.*from.*@nextui-org/shared-utils.*" | xargs rg "(assertion|clsx|object|text|dimensions|functions|numbers|console|types|dates|regex)"

Length of output: 66732


Script:

#!/bin/bash
# Check the contents of the remaining export files
echo "Contents of ./common:"
cat packages/utilities/shared-utils/src/common.ts || echo "File not found"

echo -e "\nContents of ./demi/react18:"
cat packages/utilities/shared-utils/src/demi/react18.ts || echo "File not found"

# Also check if there are other potential utility files
echo -e "\nListing all .ts files in shared-utils src:"
find packages/utilities/shared-utils/src -name "*.ts" -type f

Length of output: 1571

packages/utilities/shared-utils/src/demi/react19/getInertValue.ts (2)

1-14: Excellent documentation!

The JSDoc comment is thorough and well-written, including a clear explanation of the behavior differences between React versions and a reference link.


15-17: Implementation matches React 19 requirements

The function correctly returns the boolean value directly for React 19, as specified in the documentation.

packages/utilities/shared-utils/src/demi/react18/getInertValue.ts (1)

15-17: Implementation matches legacy React requirements

The function correctly implements the legacy behavior for React 18 and earlier versions, returning an empty string for true and undefined for false.

Consider adding unit tests to verify the behavior:

describe('getInertValue', () => {
  test('should return empty string when true', () => {
    expect(getInertValue(true)).toBe('');
  });
  test('should return undefined when false', () => {
    expect(getInertValue(false)).toBe(undefined);
  });
});
✅ Verification successful

Implementation verified, test coverage recommended

The implementation is correctly handling the legacy React 18 behavior, and its usage across calendar and tabs components is consistent. The original test suggestion remains valid and would help ensure the behavior is maintained.

  • Used in calendar-month.tsx, calendar-picker.tsx, and tab-panel.tsx for managing inert states
  • Implementation aligns with React version-specific requirements as documented
🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for test files related to getInertValue
fd -e test.ts -e spec.ts | grep -i inert

# Find React 19 implementation
fd getInertValue.ts | grep react19

# Search for usages of getInertValue
rg "getInertValue" -l

Length of output: 563


Script:

#!/bin/bash
# Check React 19 implementation
cat packages/utilities/shared-utils/src/demi/react19/getInertValue.ts

# Check usage in components
rg "getInertValue" -A 2 -B 2 packages/components/tabs/src/tab-panel.tsx packages/components/calendar/src/calendar-picker.tsx packages/components/calendar/src/calendar-month.tsx

Length of output: 3903

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.

2 participants