forked from heroui-inc/heroui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: inert value in next15 (heroui-inc#4491)
* feat: add post install * feat: add postinstall * feat: add postinstall * fix: type * fix: type * fix: next version * chore(changeset): update package name --------- Co-authored-by: աӄա <[email protected]>
- Loading branch information
Showing
21 changed files
with
124 additions
and
47 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 }) | ||
} | ||
|
||
function modifyDts(path) { | ||
const dts = fs.readFileSync(path, 'utf8') | ||
const modifiedDts = dts.replace(/\.\.\/\.\.\/common/g, './common') | ||
|
||
fs.writeFileSync(path, modifiedDts, 'utf8') | ||
} | ||
|
||
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 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 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 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 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 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 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 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"; |