Spaces:
Sleeping
Sleeping
Pull Request Number: 4288 | |
Title: fix(dropdown): correct initial animation direction to match fallback placement | |
Base Branch: canary | |
Head Branch: fix/dropdown-animate-direction | |
Author: ryo-manba | |
URL: https://github.com/nextui-org/nextui/pull/4288 | |
State: OPEN | |
Created At: 2024-12-09T08:34:01Z | |
Merged At: None | |
Participants: ryo-manba | |
Description: | |
Closes #4251 | |
π Description | |
When the fallback placement is used, the animation did not follow the final placement. | |
As a result, the popup position and its animation did not match. | |
β³οΈ Current behavior (updates) | |
The popup shows in the correct place, but the initial animation starts from the wrong direction, causing a flicker. | |
dropdown-animation-before.mov | |
π New behavior | |
The animation now correctly aligns with the final placement. | |
Changed the code to use useOverlayPosition similar to the Tooltip implementation. | |
dropdown-animation-after.mov | |
π£ Is this a breaking change (Yes/No): | |
No. | |
π Additional Information | |
Dropdown docs do not mention placement, but that will be addressed separately. | |
Summary by CodeRabbit | |
New Features | |
Added a new dependency for enhanced dropdown functionality. | |
Introduced new props for flexible dropdown positioning, including containerPadding, offset, crossOffset, and shouldFlip. | |
New Storybook story demonstrating various dropdown placements. | |
Bug Fixes | |
Improved management of dropdown placement defaults and configurations. | |
Documentation | |
Enhanced Storybook examples with a new story and updated template for better clarity. | |
Commits: | |
- fix(dropdown): correct initial animation direction\n- chore: add changeset\n- fix: typo\n | |
Labels: | |
Comments: | |
- vercel: [vc]: #ipyzuJWZDCiESkkkdQW9PVAp3b9SjnnMdo8hity5QSg=:eyJpc01vbm9yZXBvIjp0cnVlLCJ0eXBlIjoiZ2l0aHViIiwicHJvamVjdHMiOlt7Im5hbWUiOiJuZXh0dWktZG9jcy12MiIsInJvb3REaXJlY3RvcnkiOiJhcHBzL2RvY3MiLCJpbnNwZWN0b3JVcmwiOiJodHRwczovL3ZlcmNlbC5jb20vbmV4dHVpLW9yZy9uZXh0dWktZG9jcy12Mi9GcmNrdXlnTGs5WjlyMWdvV0dRdEhoY0tVN3RZIiwicHJldmlld1VybCI6Im5leHR1aS1kb2NzLXYyLWdpdC1maXgtZHJvcGRvd24tYW5pbWF0ZS1kaXJlY3Rpb24tbmV4dHVpLW9yZy52ZXJjZWwuYXBwIiwibmV4dENvbW1pdFN0YXR1cyI6IkRFUExPWUVEIiwibGl2ZUZlZWRiYWNrIjp7InJlc29sdmVkIjowLCJ1bnJlc29sdmVkIjowLCJ0b3RhbCI6MCwibGluayI6Im5leHR1aS1kb2NzLXYyLWdpdC1maXgtZHJvcGRvd24tYW5pbWF0ZS1kaXJlY3Rpb24tbmV4dHVpLW9yZy52ZXJjZWwuYXBwIn19LHsibmFtZSI6Im5leHR1aS1zdG9yeWJvb2stdjIiLCJyb290RGlyZWN0b3J5IjoicGFja2FnZXMvc3Rvcnlib29rIiwiaW5zcGVjdG9yVXJsIjoiaHR0cHM6Ly92ZXJjZWwuY29tL25leHR1aS1vcmcvbmV4dHVpLXN0b3J5Ym9vay12Mi82UjVoQjlidUJ6TUVUY3B1Q0NoUm1laERFSkE1IiwicHJldmlld1VybCI6Im5leHR1aS1zdG9yeWJvb2stdjItZ2l0LWZpeC1kcm9wZG93bi1hbmltYXRlLWU0NTMxMC1uZXh0dWktb3JnLnZlcmNlbC5hcHAiLCJuZXh0Q29tbWl0U3RhdHVzIjoiREVQTE9ZRUQiLCJsaXZlRmVlZGJhY2siOnsicmVzb2x2ZWQiOjAsInVucmVzb2x2ZWQiOjAsInRvdGFsIjowLCJsaW5rIjoibmV4dHVpLXN0b3J5Ym9vay12Mi1naXQtZml4LWRyb3Bkb3duLWFuaW1hdGUtZTQ1MzEwLW5leHR1aS1vcmcudmVyY2VsLmFwcCJ9fV19 | |
**The latest updates on your projects**. Learn more about [Vercel for Git βοΈ](https://vercel.link/github-learn-more) | |
| Name | Status | Preview | Comments | Updated (UTC) | | |
| :--- | :----- | :------ | :------- | :------ | | |
| **nextui-docs-v2** | β Ready ([Inspect](https://vercel.com/nextui-org/nextui-docs-v2/FrckuygLk9Z9r1goWGQtHhcKU7tY)) | [Visit Preview](https://nextui-docs-v2-git-fix-dropdown-animate-direction-nextui-org.vercel.app) | π¬ [**Add feedback**](https://vercel.live/open-feedback/nextui-docs-v2-git-fix-dropdown-animate-direction-nextui-org.vercel.app?via=pr-comment-feedback-link) | Dec 9, 2024 8:52am | | |
| **nextui-storybook-v2** | β Ready ([Inspect](https://vercel.com/nextui-org/nextui-storybook-v2/6R5hB9buBzMETcpuCChRmehDEJA5)) | [Visit Preview](https://nextui-storybook-v2-git-fix-dropdown-animate-e45310-nextui-org.vercel.app) | π¬ [**Add feedback**](https://vercel.live/open-feedback/nextui-storybook-v2-git-fix-dropdown-animate-e45310-nextui-org.vercel.app?via=pr-comment-feedback-link) | Dec 9, 2024 8:52am | | |
\n- changeset-bot: ### π¦ Changeset detected | |
Latest commit: bf3790cac78004baf26fefacb2afaf899a333be7 | |
**The changes in this PR will be included in the next version bump.** | |
<details><summary>This PR includes changesets to release 2 packages</summary> | |
| Name | Type | | |
| -------------------- | ----- | | |
| @nextui-org/dropdown | Patch | | |
| @nextui-org/react | Patch | | |
</details> | |
Not sure what this means? [Click here to learn what changesets are](https://github.com/changesets/changesets/blob/main/docs/adding-a-changeset.md). | |
[Click here if you're a maintainer who wants to add another changeset to this PR](https://github.com/nextui-org/nextui/new/fix/dropdown-animate-direction?filename=.changeset/eighty-trees-build.md&value=---%0A%22%40nextui-org%2Fdropdown%22%3A%20patch%0A---%0A%0Afix(dropdown)%3A%20correct%20initial%20animation%20direction%20to%20match%20fallback%20placement%0A) | |
\n- coderabbitai: <!-- This is an auto-generated comment: summarize by coderabbit.ai --> | |
<!-- This is an auto-generated comment: rate limited by coderabbit.ai --> | |
> [!WARNING] | |
> ## Rate limit exceeded | |
> | |
> @ryo-manba has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait **15 minutes and 33 seconds** before requesting another review. | |
> | |
> <details> | |
> <summary>β How to resolve this issue?</summary> | |
> | |
> After the wait time has elapsed, a review can be triggered using the `@coderabbitai review` command as a PR comment. Alternatively, push new commits to this PR. | |
> | |
> We recommend that you space out your commits to avoid hitting the rate limit. | |
> | |
> </details> | |
> | |
> | |
> <details> | |
> <summary>π¦ How do rate limits work?</summary> | |
> | |
> CodeRabbit enforces hourly rate limits for each developer per organization. | |
> | |
> Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. | |
> | |
> Please see our [FAQ](https://docs.coderabbit.ai/faq) for further information. | |
> | |
> </details> | |
> | |
> <details> | |
> <summary>π₯ Commits</summary> | |
> | |
> Reviewing files that changed from the base of the PR and between de11cf8bebc2219f25aadb6d90896ab81811de7f and bf3790cac78004baf26fefacb2afaf899a333be7. | |
> | |
> </details> | |
> | |
> <details> | |
> <summary>π Files selected for processing (1)</summary> | |
> | |
> * `packages/components/dropdown/stories/dropdown.stories.tsx` (2 hunks) | |
> | |
> </details> | |
<!-- end of auto-generated comment: rate limited by coderabbit.ai --> | |
<!-- walkthrough_start --> | |
## Walkthrough | |
The pull request introduces several changes to the dropdown component. A new dependency, `@react-aria/overlays` version `3.24.0`, is added to the `package.json`. The `use-dropdown.ts` file is modified to enhance the `useDropdown` hook, introducing new props for flexible positioning and updating the placement management. Additionally, a new story, `WithFallbackPlacements`, is added to the Storybook configuration to demonstrate various dropdown placements, along with updates to the `Template` function for improved labeling. | |
## Changes | |
| File | Change Summary | | |
|--------------------------------------------------------------|---------------------------------------------------------------------------------------------------| | |
| packages/components/dropdown/package.json | Added dependency: `"@react-aria/overlays": "3.24.0"` | | |
| packages/components/dropdown/src/use-dropdown.ts | - Added `toReactAriaPlacement` function and `DEFAULT_PLACEMENT` constant. <br> - Updated `useDropdown` parameters to include `placementProp`, `containerPadding`, `offset`, `crossOffset`, and `shouldFlip`. <br> - Modified `getPopoverProps` to derive placement from `useOverlayPosition`. | | |
| packages/components/dropdown/stories/dropdown.stories.tsx | - Added new story: `WithFallbackPlacements` for demonstrating various dropdown placements. <br> - Updated `Template` function to include a new `label` prop. | | |
## Assessment against linked issues | |
| Objective | Addressed | Explanation | | |
|---------------------------------------------------------------------------|-----------|--------------------------------------------------| | |
| Dropdown menu should always animate in the correct direction it is appearing in (#[4251]) | β | | | |
## Possibly related PRs | |
- **#2598**: This PR modifies the `useDropdown` function, which is directly related to the changes made in the main PR regarding the `use-dropdown.ts` file, enhancing the dropdown's functionality and handling of the `closeOnSelect` property. | |
- **#3762**: This PR also updates the `use-dropdown.ts` file, introducing new utility functions and modifying the `onAction` handler, which aligns with the changes made in the main PR to improve dropdown functionality. | |
- **#4278**: This PR addresses the unnecessary ref in the `DropdownTrigger`, which is related to the changes in the dropdown component's handling of refs and props, connecting it to the modifications in the main PR. | |
## Suggested labels | |
`π Scope : Docs` | |
## Suggested reviewers | |
- wingkwong | |
- jrgarciadev | |
<!-- walkthrough_end --> | |
<!-- internal state start --> | |
<!-- FAHghAtBAEAqAWBLAztF0CGA7TBXALgPYQDmAplmQE4b5kAm0AxoQLasX4Bc0ADldEIAjAFZkm+RADcyqIQE9mhetQxChifADoMiaFAB8wY+CjGAxOegAFAErQAyrnYYq84wjJ9cAGx/QqMgBHXFl8aEl8HwZoACIAM0QADwAKeipCXnpCAHcsAEoeFipAiTQsTUQMf2xEVlpEQhx6RFLJJtjoHIxUZFwhVk06RgUI+C9cZGoA+WJ6rCEMTCxGdEQVLElEmJ6beyxnIWmAFgAmAA5zwRwAcU0ACX6tOCRUO0x6dNkp1Gw0ZD6Xhy40CYy8tXq7RwhHiYOg6Uy2Ty0A4B3h62gWEI4WqiBIOBymngaHwqESWGqfB8GCYZFR4WBFGgk0QWBI0Hi1R8iyYAGsqTS6Zxng5eOJEIkmFz5AAaOGsyqUiENJrQZD4VzDDkZVhwnIZNnotqNLByqUsw1LeI+RB86ZkeLxcTaF5eJjwbDkVD1FTlMbod4UPqg/Ae8Kh8EVSEmzG5JQlZ0+RS4/GoQmhuHkym8am0+mCWER+EZLK5HCo3BaDzjZi4BObaBHD1SRoCVlSQg+GSMIu8TK4Xjo5A5jDyVns1lw4ptPiEZCVVVCAjLOoNQ3xHXLcr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GosQFZWsh4psF4hgD4rZXmgEmYjQBYqEtYhEqAEogTIMPgJhusMgJhoEC2LeAwJhnBsFOEv9ejUIDCmDLTKcAAJy0wADsXk9AtMxwXkTA9A8QHkxwxwDNtM8QDMDM5w6gDNZAYMDAMKXkHkagSwNi6NKgXk7N8QwtZAQgTApwpwXktN8QYMGAgKQgtM9AtNMK5w9Nag5wXkFtzNZADNsICiaNUAGNmg2NtseNMcAEOQRNKihgQAA --> | |
<!-- internal state end --> | |
<!-- tips_start --> | |
--- | |
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? | |
<details> | |
<summary>β€οΈ Share</summary> | |
- [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) | |
- [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) | |
- [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) | |
- [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code) | |
</details> | |
<details> | |
<summary>πͺ§ Tips</summary> | |
### Chat | |
There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai): | |
- 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 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](https://docs.coderabbit.ai) for detailed information on how to use CodeRabbit. | |
- Join our [Discord Community](http://discord.gg/coderabbit) to get help, request features, and share feedback. | |
- Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements. | |
</details> | |
<!-- tips_end -->\n | |
Files Changed: | |
- .changeset/cyan-dodos-glow.md (added, 5 changes)\n Patch: @@ -0,0 +1,5 @@ | |
+--- | |
+"@nextui-org/dropdown": patch | |
+--- | |
+ | |
+Fix initial animation direction to match fallback placement (#4251)\n- packages/components/dropdown/package.json (modified, 1 changes)\n Patch: @@ -48,6 +48,7 @@ | |
"@nextui-org/shared-utils": "workspace:*", | |
"@react-aria/focus": "3.19.0", | |
"@react-aria/menu": "3.16.0", | |
+ "@react-aria/overlays": "3.24.0", | |
"@react-aria/utils": "3.26.0", | |
"@react-stately/menu": "3.9.0", | |
"@react-types/menu": "3.9.13"\n- packages/components/dropdown/src/use-dropdown.ts (modified, 24 changes)\n Patch: @@ -9,11 +9,12 @@ import {useMenuTrigger} from "@react-aria/menu"; | |
import {dropdown} from "@nextui-org/theme"; | |
import {clsx} from "@nextui-org/shared-utils"; | |
import {ReactRef, mergeRefs} from "@nextui-org/react-utils"; | |
-import {ariaShouldCloseOnInteractOutside} from "@nextui-org/aria-utils"; | |
+import {ariaShouldCloseOnInteractOutside, toReactAriaPlacement} from "@nextui-org/aria-utils"; | |
import {useMemo, useRef} from "react"; | |
import {mergeProps} from "@react-aria/utils"; | |
import {MenuProps} from "@nextui-org/menu"; | |
import {CollectionElement} from "@react-types/shared"; | |
+import {useOverlayPosition} from "@react-aria/overlays"; | |
interface Props extends HTMLNextUIProps<"div"> { | |
/** | |
@@ -77,6 +78,8 @@ const getCloseOnSelect = <T extends object>( | |
return props?.closeOnSelect; | |
}; | |
+const DEFAULT_PLACEMENT = "bottom"; | |
+ | |
export function useDropdown(props: UseDropdownProps): UseDropdownReturn { | |
const globalContext = useProviderContext(); | |
@@ -89,13 +92,17 @@ export function useDropdown(props: UseDropdownProps): UseDropdownReturn { | |
isDisabled, | |
type = "menu", | |
trigger = "press", | |
- placement = "bottom", | |
+ placement: placementProp = DEFAULT_PLACEMENT, | |
closeOnSelect = true, | |
shouldBlockScroll = true, | |
classNames: classNamesProp, | |
disableAnimation = globalContext?.disableAnimation ?? false, | |
onClose, | |
className, | |
+ containerPadding = 12, | |
+ offset = 7, | |
+ crossOffset = 0, | |
+ shouldFlip = true, | |
...otherProps | |
} = props; | |
@@ -132,6 +139,17 @@ export function useDropdown(props: UseDropdownProps): UseDropdownReturn { | |
[className], | |
); | |
+ const {placement} = useOverlayPosition({ | |
+ isOpen: state.isOpen, | |
+ targetRef: triggerRef, | |
+ overlayRef: popoverRef, | |
+ placement: toReactAriaPlacement(placementProp), | |
+ offset, | |
+ crossOffset, | |
+ shouldFlip, | |
+ containerPadding, | |
+ }); | |
+ | |
const onMenuAction = (menuCloseOnSelect?: boolean) => { | |
if (menuCloseOnSelect !== undefined && !menuCloseOnSelect) { | |
return; | |
@@ -146,7 +164,7 @@ export function useDropdown(props: UseDropdownProps): UseDropdownReturn { | |
return { | |
state, | |
- placement, | |
+ placement: placement || DEFAULT_PLACEMENT, | |
ref: popoverRef, | |
disableAnimation, | |
shouldBlockScroll,\n- packages/components/dropdown/stories/dropdown.stories.tsx (modified, 35 changes)\n Patch: @@ -137,10 +137,15 @@ const items = [ | |
}, | |
]; | |
-const Template = ({color, variant, ...args}: DropdownProps & DropdownMenuProps) => ( | |
+const Template = ({ | |
+ color, | |
+ variant, | |
+ label = "Trigger", | |
+ ...args | |
+}: DropdownProps & DropdownMenuProps & {label: string}) => ( | |
<Dropdown {...args}> | |
<DropdownTrigger> | |
- <Button>Trigger</Button> | |
+ <Button>{label}</Button> | |
</DropdownTrigger> | |
<DropdownMenu aria-label="Actions" color={color} variant={variant}> | |
<DropdownItem key="new">New file</DropdownItem> | |
@@ -782,3 +787,29 @@ export const ItemCloseOnSelect = { | |
...defaultProps, | |
}, | |
}; | |
+ | |
+export const WithFallbackPlacements = { | |
+ args: { | |
+ ...defaultProps, | |
+ }, | |
+ render: (args) => ( | |
+ <div className="relative h-screen w-screen"> | |
+ <div className="absolute top-0 left-0 p-8 flex gap-4"> | |
+ <Template {...args} label="placement: top" placement="top" /> | |
+ <Template {...args} label="placement: bottom" placement="bottom" /> | |
+ </div> | |
+ <div className="absolute bottom-0 left-0 p-8 flex gap-4"> | |
+ <Template {...args} label="placement: bottom" placement="bottom" /> | |
+ <Template {...args} label="placement: top" placement="top" /> | |
+ </div> | |
+ <div className="absolute left-0 top-1/2 -translate-y-1/2 p-8 flex flex-col gap-4"> | |
+ <Template {...args} label="placement: left" placement="left" /> | |
+ <Template {...args} label="placement: right" placement="right" /> | |
+ </div> | |
+ <div className="absolute right-0 top-1/2 -translate-y-1/2 p-8 flex flex-col gap-4"> | |
+ <Template {...args} label="placement: right" placement="right" /> | |
+ <Template {...args} label="placement: left" placement="left" /> | |
+ </div> | |
+ </div> | |
+ ), | |
+};\n- pnpm-lock.yaml (modified, 54 changes)\n Patch: @@ -1581,6 +1581,9 @@ importers: | |
'@react-aria/menu': | |
specifier: 3.16.0 | |
version: 3.16.0([email protected]([email protected]))([email protected]) | |
+ '@react-aria/overlays': | |
+ specifier: 3.24.0 | |
+ version: 3.24.0([email protected]([email protected]))([email protected]) | |
'@react-aria/utils': | |
specifier: 3.26.0 | |
version: 3.26.0([email protected]) | |
@@ -3318,7 +3321,7 @@ importers: | |
version: 18.2.0 | |
tailwind-variants: | |
specifier: ^0.1.20 | |
- version: 0.1.20([email protected]([email protected](@swc/[email protected](@swc/[email protected]))(@types/[email protected])([email protected]))) | |
+ version: 0.1.20([email protected]([email protected](@swc/[email protected](@swc/[email protected]))(@types/[email protected])([email protected]))) | |
packages/core/theme: | |
dependencies: | |
@@ -3345,7 +3348,7 @@ importers: | |
version: 2.5.4 | |
tailwind-variants: | |
specifier: ^0.1.20 | |
- version: 0.1.20([email protected]([email protected](@swc/[email protected](@swc/[email protected]))(@types/[email protected])([email protected]))) | |
+ version: 0.1.20([email protected]([email protected](@swc/[email protected](@swc/[email protected]))(@types/[email protected])([email protected]))) | |
devDependencies: | |
'@types/color': | |
specifier: ^3.0.3 | |
@@ -3358,7 +3361,7 @@ importers: | |
version: 2.2.0 | |
tailwindcss: | |
specifier: ^3.4.0 | |
- version: 3.4.15([email protected](@swc/[email protected](@swc/[email protected]))(@types/[email protected])([email protected])) | |
+ version: 3.4.15([email protected](@swc/[email protected](@swc/[email protected]))(@types/[email protected])([email protected])) | |
packages/hooks/use-aria-accordion: | |
dependencies: | |
@@ -26223,14 +26226,6 @@ snapshots: | |
postcss: 8.4.49 | |
ts-node: 10.9.2(@swc/[email protected](@swc/[email protected]))(@types/[email protected])([email protected]) | |
- [email protected]([email protected])([email protected](@swc/[email protected](@swc/[email protected]))(@types/[email protected])([email protected])): | |
- dependencies: | |
- lilconfig: 3.1.2 | |
- yaml: 2.6.1 | |
- optionalDependencies: | |
- postcss: 8.4.49 | |
- ts-node: 10.9.2(@swc/[email protected](@swc/[email protected]))(@types/[email protected])([email protected]) | |
- | |
[email protected]([email protected])([email protected](@swc/[email protected](@swc/[email protected]))(@types/[email protected])([email protected])): | |
dependencies: | |
lilconfig: 3.1.2 | |
@@ -27782,10 +27777,10 @@ snapshots: | |
tailwind-merge: 1.14.0 | |
tailwindcss: 3.4.14([email protected](@swc/[email protected](@swc/[email protected]))(@types/[email protected])([email protected])) | |
- [email protected]([email protected]([email protected](@swc/[email protected](@swc/[email protected]))(@types/[email protected])([email protected]))): | |
+ [email protected]([email protected]([email protected](@swc/[email protected](@swc/[email protected]))(@types/[email protected])([email protected]))): | |
dependencies: | |
tailwind-merge: 1.14.0 | |
- tailwindcss: 3.4.15([email protected](@swc/[email protected](@swc/[email protected]))(@types/[email protected])([email protected])) | |
+ tailwindcss: 3.4.15([email protected](@swc/[email protected](@swc/[email protected]))(@types/[email protected])([email protected])) | |
[email protected]([email protected](@swc/[email protected](@swc/[email protected]))(@types/[email protected])([email protected])): | |
dependencies: | |
@@ -27814,33 +27809,6 @@ snapshots: | |
transitivePeerDependencies: | |
- ts-node | |
- [email protected]([email protected](@swc/[email protected](@swc/[email protected]))(@types/[email protected])([email protected])): | |
- dependencies: | |
- '@alloc/quick-lru': 5.2.0 | |
- arg: 5.0.2 | |
- chokidar: 3.6.0 | |
- didyoumean: 1.2.2 | |
- dlv: 1.1.3 | |
- fast-glob: 3.3.2 | |
- glob-parent: 6.0.2 | |
- is-glob: 4.0.3 | |
- jiti: 1.21.6 | |
- lilconfig: 2.1.0 | |
- micromatch: 4.0.8 | |
- normalize-path: 3.0.0 | |
- object-hash: 3.0.0 | |
- picocolors: 1.1.1 | |
- postcss: 8.4.49 | |
- postcss-import: 15.1.0([email protected]) | |
- postcss-js: 4.0.1([email protected]) | |
- postcss-load-config: 4.0.2([email protected])([email protected](@swc/[email protected](@swc/[email protected]))(@types/[email protected])([email protected])) | |
- postcss-nested: 6.2.0([email protected]) | |
- postcss-selector-parser: 6.1.2 | |
- resolve: 1.22.8 | |
- sucrase: 3.35.0 | |
- transitivePeerDependencies: | |
- - ts-node | |
- | |
[email protected]([email protected](@swc/[email protected](@swc/[email protected]))(@types/[email protected])([email protected])): | |
dependencies: | |
'@alloc/quick-lru': 5.2.0 | |
@@ -27928,14 +27896,14 @@ snapshots: | |
'@swc/core': 1.9.2(@swc/[email protected]) | |
esbuild: 0.15.18 | |
- [email protected](@swc/[email protected](@swc/[email protected]))([email protected])([email protected](@swc/[email protected](@swc/[email protected]))([email protected])([email protected]([email protected]))): | |
+ [email protected](@swc/[email protected](@swc/[email protected]))([email protected])([email protected](@swc/[email protected](@swc/[email protected]))([email protected])([email protected])): | |
dependencies: | |
'@jridgewell/trace-mapping': 0.3.25 | |
jest-worker: 27.5.1 | |
schema-utils: 3.3.0 | |
serialize-javascript: 6.0.2 | |
terser: 5.36.0 | |
- webpack: 5.96.1(@swc/[email protected](@swc/[email protected]))([email protected])([email protected]([email protected])) | |
+ webpack: 5.96.1(@swc/[email protected](@swc/[email protected]))([email protected])([email protected]) | |
optionalDependencies: | |
'@swc/core': 1.9.2(@swc/[email protected]) | |
esbuild: 0.21.5 | |
@@ -28742,7 +28710,7 @@ snapshots: | |
neo-async: 2.6.2 | |
schema-utils: 3.3.0 | |
tapable: 2.2.1 | |
- terser-webpack-plugin: 5.3.10(@swc/[email protected](@swc/[email protected]))([email protected])([email protected](@swc/[email protected](@swc/[email protected]))([email protected])([email protected]([email protected]))) | |
+ terser-webpack-plugin: 5.3.10(@swc/[email protected](@swc/[email protected]))([email protected])([email protected](@swc/[email protected](@swc/[email protected]))([email protected])([email protected])) | |
watchpack: 2.4.2 | |
webpack-sources: 3.2.3 | |
optionalDependencies:\n |