-
Notifications
You must be signed in to change notification settings - Fork 329
Add shadcn registry component #445
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| { | ||
| "$schema": "https://ui.shadcn.com/schema/registry.json", | ||
| "name": "react-grab", | ||
| "homepage": "https://react-grab.com", | ||
| "items": [ | ||
| { | ||
| "name": "react-grab", | ||
| "type": "registry:component", | ||
| "title": "React Grab", | ||
| "description": "Installs and loads React Grab from a React component.", | ||
| "dependencies": ["react-grab"], | ||
| "files": [ | ||
| { | ||
| "path": "registry/react-grab.tsx", | ||
| "type": "registry:component", | ||
| "target": "@components/react-grab.tsx" | ||
| } | ||
| ] | ||
| } | ||
| ] | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,60 @@ | ||||||||||||||||||||||
| "use client"; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| import { useEffect } from "react"; | ||||||||||||||||||||||
| import type { Options } from "react-grab"; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| declare global { | ||||||||||||||||||||||
| interface Window { | ||||||||||||||||||||||
| __REACT_GRAB_DISABLED__?: boolean; | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| interface ReactGrabProps { | ||||||||||||||||||||||
| enabled?: boolean; | ||||||||||||||||||||||
| options?: Options; | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| const reactGrabOptions: Options = { | ||||||||||||||||||||||
| // activationMode: "toggle", | ||||||||||||||||||||||
| // activationKey: "Alt+KeyG", | ||||||||||||||||||||||
| // keyHoldDuration: 500, | ||||||||||||||||||||||
| // allowActivationInsideInput: true, | ||||||||||||||||||||||
| }; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| export const ReactGrab = (props: ReactGrabProps) => { | ||||||||||||||||||||||
| useEffect(() => { | ||||||||||||||||||||||
| if (props.enabled === false) return; | ||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Enabled prop never deactivatesMedium Severity Setting Additional Locations (1)Reviewed by Cursor Bugbot for commit 094ba5b. Configure here.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: When Prompt for AI agents |
||||||||||||||||||||||
|
|
||||||||||||||||||||||
| let isActive = true; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| const loadReactGrab = async () => { | ||||||||||||||||||||||
| window.__REACT_GRAB_DISABLED__ = true; | ||||||||||||||||||||||
| try { | ||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: The Prompt for AI agents |
||||||||||||||||||||||
| const reactGrab = await import("react-grab"); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| if (!isActive) return; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| const existingApi = reactGrab.getGlobalApi(); | ||||||||||||||||||||||
| if (existingApi) return; | ||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated options prop ignoredMedium Severity The effect depends on Additional Locations (1)Reviewed by Cursor Bugbot for commit 094ba5b. Configure here.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: Existing global instance short-circuits the effect, so Prompt for AI agentsThere was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Disposed API blocks reinitializationMedium Severity After Reviewed by Cursor Bugbot for commit 3634587. Configure here. |
||||||||||||||||||||||
|
|
||||||||||||||||||||||
| const api = reactGrab.init({ | ||||||||||||||||||||||
| ...reactGrabOptions, | ||||||||||||||||||||||
| ...props.options, | ||||||||||||||||||||||
| }); | ||||||||||||||||||||||
|
Comment on lines
+43
to
+46
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P1: Guard against Prompt for AI agents
Suggested change
|
||||||||||||||||||||||
|
|
||||||||||||||||||||||
| reactGrab.setGlobalApi(api); | ||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Concurrent init overwrites global APIHigh Severity Overlapping Reviewed by Cursor Bugbot for commit 094ba5b. Configure here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pending plugins never flushedMedium Severity After manual Reviewed by Cursor Bugbot for commit 094ba5b. Configure here. |
||||||||||||||||||||||
| window.dispatchEvent(new CustomEvent("react-grab:init", { detail: api })); | ||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Noop init published globallyHigh Severity When Additional Locations (1)Reviewed by Cursor Bugbot for commit 094ba5b. Configure here. |
||||||||||||||||||||||
| } finally { | ||||||||||||||||||||||
| delete window.__REACT_GRAB_DISABLED__; | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
| }; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| void loadReactGrab(); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| return () => { | ||||||||||||||||||||||
| isActive = false; | ||||||||||||||||||||||
| }; | ||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unmount leaves grab runningMedium Severity The effect cleanup only clears a local Reviewed by Cursor Bugbot for commit 3634587. Configure here. |
||||||||||||||||||||||
| }, [props.enabled, props.options]); | ||||||||||||||||||||||
|
vercel[bot] marked this conversation as resolved.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P3: Prompt for AI agents |
||||||||||||||||||||||
|
|
||||||||||||||||||||||
| return null; | ||||||||||||||||||||||
| }; | ||||||||||||||||||||||


There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P3: The new
### shadcn Registryheading accidentally nests the existing manual framework sections under the registry subsection.Prompt for AI agents