-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
fix: inert value in next15 #4491
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
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
7b779e4
feat: add post install
winchesHe 00ed91e
feat: add postinstall
winchesHe 9d9224b
feat: add postinstall
winchesHe 60d1d82
fix: type
winchesHe ede6b12
fix: type
winchesHe 2d1d692
fix: next version
winchesHe 2716f06
chore(changeset): update package name
wingkwong 13a5d41
Merge branch 'canary' into fix/eng-1718-inert-value
wingkwong File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "@heroui/shared-utils": patch | ||
| --- | ||
|
|
||
| Tabs with prop destroyInactiveTabPanel error in nextjs15(#4344) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| const path = require('path') | ||
| const fs = require('fs') | ||
|
|
||
| function tryRequirePkg(pkg) { | ||
| try { | ||
| return require(pkg); | ||
| } catch (e) { | ||
| return null; | ||
| } | ||
| } | ||
|
|
||
| function copyDemiDir(dir) { | ||
| const src = path.join(__dirname, '..', 'dist', 'demi', dir) | ||
| const dest = path.join(__dirname, '..', 'dist') | ||
|
|
||
| fs.cpSync(src, dest, { recursive: true }) | ||
| } | ||
|
winchesHe marked this conversation as resolved.
|
||
|
|
||
| function modifyDts(path) { | ||
| const dts = fs.readFileSync(path, 'utf8') | ||
| const modifiedDts = dts.replace(/\.\.\/\.\.\/common/g, './common') | ||
|
|
||
| fs.writeFileSync(path, modifiedDts, 'utf8') | ||
| } | ||
|
winchesHe marked this conversation as resolved.
|
||
|
|
||
| function postinstall() { | ||
| const nextjs = tryRequirePkg('next/package.json') | ||
| const react = tryRequirePkg('react/package.json') | ||
| const nextjsVersion = Number((nextjs?.version || '').split('.')[0]) | ||
| const reactVersion = Number((react?.version || '').split('.')[0]) | ||
|
|
||
| if (reactVersion === 18 && nextjsVersion < 15) { | ||
| copyDemiDir('react18') | ||
| } else { | ||
| copyDemiDir('react19') | ||
| } | ||
|
|
||
| modifyDts(path.join(__dirname, '..', 'dist', 'index.d.ts')) | ||
| } | ||
|
|
||
| postinstall(); | ||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| export * from "./assertion"; | ||
| export * from "./clsx"; | ||
| export * from "./object"; | ||
| export * from "./text"; | ||
| export * from "./dimensions"; | ||
| export * from "./functions"; | ||
| export * from "./numbers"; | ||
| export * from "./console"; | ||
| export * from "./types"; | ||
| export * from "./dates"; | ||
| export * from "./regex"; |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
17 changes: 17 additions & 0 deletions
17
packages/utilities/shared-utils/src/demi/react18/getInertValue.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| /** | ||
| * Returns an appropriate value for the `inert` attribute based on the React version. | ||
| * | ||
| * In React 19, the attribute `inert` is a boolean. In versions prior to 19, the attribute | ||
| * behaves differently: setting `inert=""` will make it `true`, and `inert=undefined` will make it `false`. | ||
| * | ||
| * @param {boolean} v - The desired boolean state for the `inert` attribute. | ||
| * @returns {boolean | string | undefined} - Depending on the React version: | ||
| * - Returns `boolean` if React version is 19 (the input value `v` directly). | ||
| * - Returns `string` (empty string) if `v` is `true` in older React versions. | ||
| * - Returns `undefined` if `v` is `false` in older React versions. | ||
| * | ||
| * @see {@link https://github.com/facebook/react/issues/17157} for more details on the behavior in older React versions. | ||
| */ | ||
| export const getInertValue = (v: boolean): boolean | string | undefined => { | ||
| return v ? "" : undefined; | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| export * from "./getInertValue"; | ||
|
|
||
| export * from "../../common"; |
17 changes: 17 additions & 0 deletions
17
packages/utilities/shared-utils/src/demi/react19/getInertValue.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| /** | ||
| * Returns an appropriate value for the `inert` attribute based on the React version. | ||
| * | ||
| * In React 19, the attribute `inert` is a boolean. In versions prior to 19, the attribute | ||
| * behaves differently: setting `inert=""` will make it `true`, and `inert=undefined` will make it `false`. | ||
| * | ||
| * @param {boolean} v - The desired boolean state for the `inert` attribute. | ||
| * @returns {boolean | string | undefined} - Depending on the React version: | ||
| * - Returns `boolean` if React version is 19 (the input value `v` directly). | ||
| * - Returns `string` (empty string) if `v` is `true` in older React versions. | ||
| * - Returns `undefined` if `v` is `false` in older React versions. | ||
| * | ||
| * @see {@link https://github.com/facebook/react/issues/17157} for more details on the behavior in older React versions. | ||
| */ | ||
| export const getInertValue = (v: boolean): boolean | string | undefined => { | ||
| return v; | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| export * from "./getInertValue"; | ||
|
|
||
| export * from "../../common"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,5 @@ | ||
| export * from "./assertion"; | ||
| export * from "./clsx"; | ||
| export * from "./object"; | ||
| export * from "./text"; | ||
| export * from "./dimensions"; | ||
| export * from "./functions"; | ||
| export * from "./numbers"; | ||
| export * from "./console"; | ||
| export * from "./types"; | ||
| export * from "./dates"; | ||
| export * from "./regex"; | ||
| /** | ||
| * For Development | ||
| */ | ||
| export * from "./common"; | ||
| export * from "./demi/react18"; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.