shadcn 0.0.0-beta.01b72a3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 shadcn
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,61 @@
1
+ # shadcn
2
+
3
+ A CLI for adding components to your project.
4
+
5
+ ## create
6
+
7
+ Use the `create` command to create a new project. You will be taken to a website to build your custom design system and choose your framework.
8
+
9
+ ```bash
10
+ npx shadcn create
11
+ ```
12
+
13
+ ## init
14
+
15
+ Use the `init` command to initialize dependencies for a new project.
16
+
17
+ The `init` command installs dependencies, adds the `cn` util, configures Tailwind CSS, and CSS variables for the project.
18
+
19
+ ```bash
20
+ npx shadcn init
21
+ ```
22
+
23
+ ## apply
24
+
25
+ Use the `apply` command to apply a preset to an existing project.
26
+
27
+ The `apply` command overwrites the current preset configuration, reinstalls detected UI components, and updates fonts and CSS variables to match the new preset.
28
+
29
+ ```bash
30
+ npx shadcn apply --preset a2r6bw
31
+ ```
32
+
33
+ ## add
34
+
35
+ Use the `add` command to add components to your project.
36
+
37
+ The `add` command adds a component to your project and installs all required dependencies.
38
+
39
+ ```bash
40
+ npx shadcn add [component]
41
+ ```
42
+
43
+ ### Example
44
+
45
+ ```bash
46
+ npx shadcn add alert-dialog
47
+ ```
48
+
49
+ You can also run the command without any arguments to view a list of all available components:
50
+
51
+ ```bash
52
+ npx shadcn add
53
+ ```
54
+
55
+ ## Documentation
56
+
57
+ Visit https://ui.shadcn.com/docs/cli to view the documentation.
58
+
59
+ ## License
60
+
61
+ Licensed under the [MIT license](https://github.com/shadcn-ui/ui/blob/main/LICENSE.md).
@@ -0,0 +1,2 @@
1
+ import {a}from'./chunk-CHWMSXYA.js';import {SyntaxKind,Project,ScriptKind}from'ts-morph';import {promises}from'fs';import {twMerge}from'tailwind-merge';var ot=async({sourceFile:r,config:n})=>{let e=n.iconLibrary;if(!e||!(e in a))return r;let t=e,i=a[t],o=[];for(let a$1 of r.getDescendantsOfKind(SyntaxKind.JsxSelfClosingElement)){if(a$1.getTagNameNode()?.getText()!=="IconPlaceholder")continue;let f=a$1.getAttributes().find(g=>g.getKind()!==SyntaxKind.JsxAttribute?false:g.asKindOrThrow(SyntaxKind.JsxAttribute).getNameNode().getText()===t);if(!f)continue;let s=f.asKindOrThrow(SyntaxKind.JsxAttribute),l=s.getInitializer()?.getText().replace(/^["']|["']$/g,"");if(!l)continue;o.includes(l)||o.push(l);let u=i.usage.match(/<(\w+)([^>]*)\s*\/>/);s.remove();for(let g of a$1.getAttributes()){if(g.getKind()!==SyntaxKind.JsxAttribute)continue;let x=g.asKindOrThrow(SyntaxKind.JsxAttribute);x.getNameNode().getText()in a&&x.remove();}if(!u){a$1.getTagNameNode()?.replaceWithText(l);continue}let[,b,K]=u;if(b==="ICON"){let g=a$1.getAttributes().filter(x=>x.getKind()!==SyntaxKind.JsxAttribute?true:!(x.asKindOrThrow(SyntaxKind.JsxAttribute).getNameNode().getText()in a)).map(x=>x.getText()).join(" ");g.trim()?a$1.replaceWithText(`<${l} ${g} />`):a$1.getTagNameNode()?.replaceWithText(l);}else {let g=new Set(a$1.getAttributes().filter(m=>m.getKind()===SyntaxKind.JsxAttribute).map(m=>m.asKindOrThrow(SyntaxKind.JsxAttribute).getNameNode().getText())),A=K.replace(/\{ICON\}/g,`{${l}}`).trim().split(/\s+(?=\w+=)/).filter(m=>m).map(m=>{let E=m.split("=")[0];return E&&!g.has(E)?m:null}).filter(Boolean),y=a$1.getAttributes().filter(m=>m.getKind()!==SyntaxKind.JsxAttribute?true:!(m.asKindOrThrow(SyntaxKind.JsxAttribute).getNameNode().getText()in a)).map(m=>m.getText()).join(" "),M=[...A,y].filter(Boolean).join(" ");a$1.replaceWithText(`<${b} ${M} />`);}}for(let a of r.getImportDeclarations()??[])if(a.getModuleSpecifier()?.getText()?.includes("icon-placeholder")){let l=(a.getNamedImports()??[]).find(d=>d.getName()==="IconPlaceholder");l&&l.remove(),a.getNamedImports()?.length===0&&a.remove();}if(o.length>0){let a=i.import.split(`
2
+ `),f=[];for(let s of a){let l=s.match(/import\s+{([^}]+)}\s+from\s+['"]([^'"]+)['"]/);if(!l)continue;let[,d,u]=l,b=d.split(",").map(g=>g.trim()).map(g=>g==="ICON"?o.map(x=>({name:x})):{name:g}).flat(),K=r.addImportDeclaration({moduleSpecifier:u,namedImports:b});f.push(K);}if(!z(r))for(let s of f)s.replaceWithText(s.getText().replace(";",""));}return r};function z(r){return r.getImportDeclarations()?.[0]?.getText().endsWith(";")??false}var ft=async({sourceFile:r,config:n,baseColor:e})=>(n.tailwind?.cssVariables||!e?.inlineColors||r.getDescendantsOfKind(SyntaxKind.StringLiteral).forEach(t=>{let i=t.getLiteralText(),o=J(i,e.inlineColors).trim();o!==i&&t.setLiteralValue(o);}),r);function L(r){if(!r.includes("/")&&!r.includes(":"))return [null,r,null];let n=-1,e=0;for(let s=r.length-1;s>=0;s--){let l=r[s];if(l==="]")e++;else if(l==="[")e--;else if(l===":"&&e===0){n=s;break}}let t=null,i;n===-1?i=r:(t=r.slice(0,n),i=r.slice(n+1));let o=i.lastIndexOf("/");if(o===-1)return [t,i,null];let a=i.slice(0,o),f=i.slice(o+1);return [t,a,f]}var k=["bg-","text-","border-","ring-offset-","ring-"];function J(r,n){r.includes(" border ")&&(r=r.replace(" border "," border border-border "));let e=r.split(" "),t=new Set,i=new Set;for(let o of e){let[a,f,s]=L(o),l=k.find(u=>f?.startsWith(u));if(!l){t.has(o)||t.add(o);continue}let d=f?.replace(l,"");if(d&&d in n.light){t.add([a,`${l}${n.light[d]}`].filter(Boolean).join(":")+(s?`/${s}`:"")),i.add(["dark",a,`${l}${n.dark[d]}`].filter(Boolean).join(":")+(s?`/${s}`:""));continue}t.has(o)||t.add(o);}return [...Array.from(t),...Array.from(i)].join(" ").trim()}var W=[["-ml-","-ms-"],["-mr-","-me-"],["ml-","ms-"],["mr-","me-"],["pl-","ps-"],["pr-","pe-"],["-left-","-start-"],["-right-","-end-"],["left-","start-"],["right-","end-"],["inset-l-","inset-inline-start-"],["inset-r-","inset-inline-end-"],["rounded-tl-","rounded-ss-"],["rounded-tr-","rounded-se-"],["rounded-bl-","rounded-es-"],["rounded-br-","rounded-ee-"],["rounded-l-","rounded-s-"],["rounded-r-","rounded-e-"],["border-l-","border-s-"],["border-r-","border-e-"],["border-l","border-s"],["border-r","border-e"],["text-left","text-start"],["text-right","text-end"],["scroll-ml-","scroll-ms-"],["scroll-mr-","scroll-me-"],["scroll-pl-","scroll-ps-"],["scroll-pr-","scroll-pe-"],["float-left","float-start"],["float-right","float-end"],["clear-left","clear-start"],["clear-right","clear-end"],["origin-top-left","origin-top-start"],["origin-top-right","origin-top-end"],["origin-bottom-left","origin-bottom-start"],["origin-bottom-right","origin-bottom-end"],["origin-left","origin-start"],["origin-right","origin-end"]],B=[["-translate-x-","translate-x-"],["translate-x-","-translate-x-"]],G=[["space-x-","space-x-reverse"],["divide-x-","divide-x-reverse"]],X=[["cursor-w-resize","cursor-e-resize"],["cursor-e-resize","cursor-w-resize"]],F=[["data-[side=inline-start]","slide-in-from-right","slide-in-from-end"],["data-[side=inline-start]","slide-out-to-right","slide-out-to-end"],["data-[side=inline-end]","slide-in-from-left","slide-in-from-start"],["data-[side=inline-end]","slide-out-to-left","slide-out-to-start"]],Q="cn-rtl-flip",$=["ContextMenuContent","ContextMenuSubContent","DropdownMenuSubContent"],P={right:"inline-end",left:"inline-start"},U=["-left-","-right-","left-","right-"],pt=async({sourceFile:r,config:n})=>(n.rtl&&O(r),r);async function xt(r,n){if(!n)return r;let t=new Project({useInMemoryFileSystem:true}).createSourceFile("component.tsx",r,{scriptKind:ScriptKind.TSX,overwrite:true});return O(t),t.getText()}function C(r){return r.replace(/^["']|["']$/g,"")}function h(r){let n=r.getLiteralText();r.setLiteralValue(q(n));}function q(r){return r.split(" ").flatMap(n=>{if(n.startsWith("rtl:")||n.startsWith("ltr:"))return [n];if(n===Q)return ["rtl:rotate-180"];let[e,t,i]=L(n);if(!t)return [n];for(let[s,l]of B)if(t.startsWith(s)){let d=t.replace(s,l),u=e?`rtl:${e}:${d}${i?`/${i}`:""}`:`rtl:${d}${i?`/${i}`:""}`;return [n,u]}for(let[s,l]of G)if(t.startsWith(s)){let d=e?`rtl:${e}:${l}`:`rtl:${l}`;return [n,d]}for(let[s,l]of X)if(t===s){let d=e?`rtl:${e}:${l}`:`rtl:${l}`;return [n,d]}for(let[s,l,d]of F)if(e?.includes(s)&&t.startsWith(l)){let u=t.replace(l,d);return [i?`${e}:${u}/${i}`:`${e}:${u}`]}let o=e?.includes("data-[side=left]")||e?.includes("data-[side=right]"),a=t;for(let[s,l]of W)if(!(o&&U.some(d=>s.startsWith(d)))&&t.startsWith(s)){if(!s.endsWith("-")&&t!==s)continue;a=t.replace(s,l);break}let f;return e?f=i?`${e}:${a}/${i}`:`${e}:${a}`:f=i?`${a}/${i}`:a,[f]}).join(" ")}function O(r){r.getDescendantsOfKind(SyntaxKind.CallExpression).filter(n=>n.getExpression().getText()==="cva").forEach(n=>{let e=n.getArguments()[0];e?.isKind(SyntaxKind.StringLiteral)&&h(e),n.getArguments()[1]?.isKind(SyntaxKind.ObjectLiteralExpression)&&n.getArguments()[1]?.getDescendantsOfKind(SyntaxKind.PropertyAssignment).find(t=>t.getName()==="variants")?.getDescendantsOfKind(SyntaxKind.PropertyAssignment).forEach(t=>{t.getDescendantsOfKind(SyntaxKind.PropertyAssignment).forEach(i=>{let o=i.getInitializerIfKind(SyntaxKind.StringLiteral);o&&h(o);});});}),r.getDescendantsOfKind(SyntaxKind.JsxAttribute).forEach(n=>{if(n.getNameNode().getText()==="className"){let e=n.getInitializer();if(e?.isKind(SyntaxKind.StringLiteral)&&h(e),n.getInitializer()?.isKind(SyntaxKind.JsxExpression)){let t=n.getInitializer()?.getDescendantsOfKind(SyntaxKind.CallExpression).find(i=>i.getExpression().getText()==="cn");t&&t.getArguments().forEach(i=>{(i.isKind(SyntaxKind.ConditionalExpression)||i.isKind(SyntaxKind.BinaryExpression))&&i.getChildrenOfKind(SyntaxKind.StringLiteral).forEach(h),i.isKind(SyntaxKind.StringLiteral)&&h(i);});}}n.getNameNode().getText()==="classNames"&&n.getInitializer()?.isKind(SyntaxKind.JsxExpression)&&n.getDescendantsOfKind(SyntaxKind.PropertyAssignment).forEach(e=>{if(e.getInitializer()?.isKind(SyntaxKind.CallExpression)){let i=e.getInitializerIfKind(SyntaxKind.CallExpression);i&&i.getArguments().forEach(o=>{o.isKind(SyntaxKind.ConditionalExpression)&&o.getChildrenOfKind(SyntaxKind.StringLiteral).forEach(h),o.isKind(SyntaxKind.StringLiteral)&&h(o);});}let t=e.getInitializer();t?.isKind(SyntaxKind.StringLiteral)&&e.getNameNode().getText()!=="variant"&&h(t);});}),r.getDescendantsOfKind(SyntaxKind.CallExpression).filter(n=>n.getExpression().getText()==="mergeProps").forEach(n=>{let e=n.getArguments()[0];if(e?.isKind(SyntaxKind.ObjectLiteralExpression)){let t=e.getProperties().find(i=>i.isKind(SyntaxKind.PropertyAssignment)&&i.getName()==="className");if(t?.isKind(SyntaxKind.PropertyAssignment)){let i=t.getInitializer();i?.isKind(SyntaxKind.CallExpression)&&i.getExpression().getText()==="cn"&&i.getArguments().forEach(o=>{o.isKind(SyntaxKind.StringLiteral)&&h(o),(o.isKind(SyntaxKind.ConditionalExpression)||o.isKind(SyntaxKind.BinaryExpression))&&o.getChildrenOfKind(SyntaxKind.StringLiteral).forEach(h);}),i?.isKind(SyntaxKind.StringLiteral)&&h(i);}}}),[...r.getDescendantsOfKind(SyntaxKind.JsxSelfClosingElement),...r.getDescendantsOfKind(SyntaxKind.JsxOpeningElement)].forEach(n=>{let e=n.getTagNameNode().getText();if(!$.includes(e))return;let t=n.getAttributes().find(f=>f.isKind(SyntaxKind.JsxAttribute)&&f.getNameNode().getText()==="side");if(!t?.isKind(SyntaxKind.JsxAttribute))return;let i=t.getInitializer();if(!i?.isKind(SyntaxKind.StringLiteral))return;let o=C(i.getText()??""),a=P[o];a&&i.replaceWithText(`"${a}"`);}),r.getDescendantsOfKind(SyntaxKind.BindingElement).forEach(n=>{if(n.getNameNode().getText()!=="side")return;let i=n.getFirstAncestorByKind(SyntaxKind.FunctionDeclaration)?.getName();if(!i||!$.includes(i))return;let o=n.getInitializer();if(!o?.isKind(SyntaxKind.StringLiteral))return;let a=C(o.getText()??""),f=P[a];f&&o.replaceWithText(`"${f}"`);});}var D=[{marker:"cn-font-heading",utility:"font-heading",supportToken:"--font-heading:"}],w=/\bcn-font-heading\b/,v=new Map;async function Y(r,n=[]){let e=new Set(n);if(!r)return e;let t=v.get(r);return t||(t=promises.readFile(r,"utf8").then(i=>{let o=new Set;for(let a of D)i.includes(a.supportToken)&&o.add(a.marker);return o}).catch(()=>new Set),v.set(r,t)),(await t).forEach(i=>{e.add(i);}),e}function R(r,n){let e=r;for(let t of D)e.includes(t.marker)&&(e=e.replace(new RegExp(`\\b${t.marker}\\b`,"g"),n.has(t.marker)?t.utility:""));return e.replace(/\s+/g," ").trim()}function N(r,n){let e=r.getLiteralValue();if(!w.test(e))return;let t=R(e,n);t!==e&&r.setLiteralValue(t);}function I(r,n){for(let e of r.getDescendantsOfKind(SyntaxKind.StringLiteral))N(e,n);for(let e of r.getDescendantsOfKind(SyntaxKind.NoSubstitutionTemplateLiteral))N(e,n);}var At=async({sourceFile:r,config:n,supportedFontMarkers:e})=>{let t=await Y(n.resolvedPaths.tailwindCss,e),i=[];for(let o of r.getDescendantsOfKind(SyntaxKind.JsxAttribute)){let a=o.getNameNode().getText();if(a!=="className"&&a!=="classNames")continue;let f=o.getInitializer();if(f?.isKind(SyntaxKind.StringLiteral)){let s=f.getLiteralValue();if(w.test(s)){let l=R(s,t);l===""?i.push(o):l!==s&&f.setLiteralValue(l);}}f?.isKind(SyntaxKind.JsxExpression)&&I(f,t);}for(let o of i)o.remove();for(let o of r.getDescendantsOfKind(SyntaxKind.CallExpression)){if(o.getExpression().getText()==="cva"){for(let a of o.getArguments()){if(a.isKind(SyntaxKind.StringLiteral)){N(a,t);continue}if(a.isKind(SyntaxKind.NoSubstitutionTemplateLiteral)){N(a,t);continue}I(a,t);}continue}o.getExpression().getText()==="mergeProps"&&I(o,t);}return r};var et="animate-none! relative bg-popover/70 before:pointer-events-none before:absolute before:inset-0 before:-z-1 before:rounded-[inherit] before:backdrop-blur-2xl before:backdrop-saturate-150 **:data-[slot$=-item]:focus:bg-foreground/10 **:data-[slot$=-item]:data-highlighted:bg-foreground/10 **:data-[slot$=-separator]:bg-foreground/5 **:data-[slot$=-trigger]:focus:bg-foreground/10 **:data-[slot$=-trigger]:aria-expanded:bg-foreground/10! **:data-[variant=destructive]:focus:bg-foreground/10! **:data-[variant=destructive]:text-accent-foreground! **:data-[variant=destructive]:**:text-accent-foreground!",yt=async({sourceFile:r,config:n})=>{let e=n.menuColor,t=e==="default-translucent"||e==="inverted-translucent";for(let i of r.getDescendantsOfKind(SyntaxKind.JsxAttribute)){if(i.getNameNode().getText()!=="className")continue;let a=i.getInitializer();if(!a)continue;let f=a.getText();if(!f.includes("cn-menu-target")&&!f.includes("cn-menu-translucent"))continue;let s=f,l=false;e==="inverted"||e==="inverted-translucent"?s=s.replace(/cn-menu-target/g,"dark"):(s=s.replace(/cn-menu-target/g,""),l=true),t?s=s.replace(/"([^"]*cn-menu-translucent[^"]*)"/g,(d,u)=>`"${twMerge(u,et).replace(/\s*\bcn-menu-translucent\b\s*/g," ").trim()}"`):s.includes("cn-menu-translucent")&&(s=s.replace(/cn-menu-translucent/g,""),l=true),l&&(s=s.replace(/\s{2,}/g," "),s=s.replace(/"\s+/g,'"'),s=s.replace(/\s+"/g,'"'),s=s.replace(/,\s*""\s*,/g,","),s=s.replace(/\(\s*""\s*,/g,"("),s=s.replace(/,\s*""\s*\)/g,")")),i.setInitializer(s);}return r};export{ft as a,L as b,ot as c,pt as d,xt as e,At as f,yt as g};
@@ -0,0 +1,2 @@
1
+ var e={lucide:{name:"lucide",title:"Lucide",packages:["lucide-react"],import:"import { ICON } from 'lucide-react'",usage:"<ICON />",export:"lucide-react"},tabler:{name:"tabler",title:"Tabler Icons",packages:["@tabler/icons-react"],import:"import { ICON } from '@tabler/icons-react'",usage:"<ICON />",export:"@tabler/icons-react"},hugeicons:{name:"hugeicons",title:"HugeIcons",packages:["@hugeicons/react","@hugeicons/core-free-icons"],import:`import { HugeiconsIcon } from '@hugeicons/react'
2
+ import { ICON } from '@hugeicons/core-free-icons';`,usage:"<HugeiconsIcon icon={ICON} strokeWidth={2} />",export:"@hugeicons/core-free-icons"},phosphor:{name:"phosphor",title:"Phosphor Icons",packages:["@phosphor-icons/react"],import:"import { ICON } from '@phosphor-icons/react'",usage:"<ICON strokeWidth={2} />",export:"@phosphor-icons/react"},remixicon:{name:"remixicon",title:"Remix Icon",packages:["@remixicon/react"],import:"import { ICON } from '@remixicon/react'",usage:"<ICON />",export:"@remixicon/react"}};export{e as a};
@@ -0,0 +1,75 @@
1
+ import {Qa,Oa,Pa,qa,k,ma,sa,Ra}from'./chunk-NPBIPAZH.js';import {Server}from'@modelcontextprotocol/sdk/server/index.js';import {ListToolsRequestSchema,CallToolRequestSchema}from'@modelcontextprotocol/sdk/types.js';import m from'dedent';import {z}from'zod';import {zodToJsonSchema}from'zod-to-json-schema';var R="shadcn@latest";async function u(r){return `${await ma(process.cwd())} ${R} ${r}`}async function d(r=process.cwd()){return {registries:(await sa(r,{useCache:false})).registries}}function _(r,t){let{query:n,registries:i}=t||{},o=r.items.map(c=>{let g=[`- ${c.name}`];return c.type&&g.push(`(${c.type})`),c.description&&g.push(`- ${c.description}`),c.registry&&g.push(`[${c.registry}]`),g.push(`
2
+ Add command: \`${u(`add ${c.addCommandArgument}`)}\``),g.join(" ")}),a=`Found ${r.pagination.total} items`;n&&(a+=` matching "${n}"`),i&&i.length>0&&(a+=` in registries ${i.join(", ")}`),a+=":";let s=`Showing items ${r.pagination.offset+1}-${Math.min(r.pagination.offset+r.pagination.limit,r.pagination.total)} of ${r.pagination.total}:`,p=`${a}
3
+
4
+ ${s}
5
+
6
+ ${o.join(`
7
+
8
+ `)}`;return r.pagination.hasMore&&(p+=`
9
+
10
+ More items available. Use offset: ${r.pagination.offset+r.pagination.limit} to see the next page.`),p}function w(r){if(!r?.length)return null;let t=Ra(r);return t.length===0?null:`Unknown type${t.length===1?"":"s"}: ${t.join(", ")}. Valid types: ${Qa.join(", ")}.`}function $(r){if(!r.errors?.length)return "";let t=r.errors.map(n=>`- ${n.registry}: ${n.message}`);return `
11
+
12
+ Skipped ${r.errors.length} registr${r.errors.length===1?"y":"ies"} that failed to load:
13
+ ${t.join(`
14
+ `)}`}function E(r){return r.map(t=>[`## ${t.name}`,t.description?`
15
+ ${t.description}
16
+ `:"",t.type?`**Type:** ${t.type}`:"",t.files&&t.files.length>0?`**Files:** ${t.files.length} file(s)`:"",t.dependencies&&t.dependencies.length>0?`**Dependencies:** ${t.dependencies.join(", ")}`:"",t.devDependencies&&t.devDependencies.length>0?`**Dev Dependencies:** ${t.devDependencies.join(", ")}`:""].filter(Boolean).join(`
17
+ `))}function v(r,t){let n=r.map(o=>{let a=[`## Example: ${o.name}`,o.description?`
18
+ ${o.description}
19
+ `:""];return o.files?.length&&o.files.forEach(s=>{s.content&&(a.push(`### Code (${s.path}):
20
+ `),a.push("```tsx"),a.push(s.content),a.push("```"));}),a.filter(Boolean).join(`
21
+ `)});return `# Usage Examples
22
+
23
+ Found ${r.length} example${r.length>1?"s":""} matching "${t}":
24
+ `+n.join(`
25
+
26
+ ---
27
+
28
+ `)}var C=new Server({name:"shadcn",version:"1.0.0"},{capabilities:{resources:{},tools:{}}});C.setRequestHandler(ListToolsRequestSchema,async()=>({tools:[{name:"get_project_registries",description:"Get configured registry names from components.json - Returns error if no components.json exists (use init_project to create one)",inputSchema:zodToJsonSchema(z.object({}))},{name:"list_items_in_registries",description:"List items from registries (requires components.json - use init_project if missing)",inputSchema:zodToJsonSchema(z.object({registries:z.array(z.string()).optional().describe("Array of registry names to list (e.g., ['@shadcn', '@acme']). Omit to list from every registry configured in components.json."),types:z.array(z.string()).optional().describe(`Filter by item type. One of: ${Qa.join(", ")}.`),limit:z.number().optional().describe("Maximum number of items to return (defaults to 100; use 0 for no limit)"),offset:z.number().optional().describe("Number of items to skip for pagination")}))},{name:"search_items_in_registries",description:"Search for components in registries using fuzzy matching (requires components.json). After finding an item, use get_item_examples_from_registries to see usage examples.",inputSchema:zodToJsonSchema(z.object({registries:z.array(z.string()).optional().describe("Array of registry names to search (e.g., ['@shadcn', '@acme']). Omit to search every registry configured in components.json."),query:z.string().describe("Search query string for fuzzy matching against item names and descriptions"),types:z.array(z.string()).optional().describe(`Filter by item type. One of: ${Qa.join(", ")}.`),limit:z.number().optional().describe("Maximum number of items to return (defaults to 100; use 0 for no limit)"),offset:z.number().optional().describe("Number of items to skip for pagination")}))},{name:"view_items_in_registries",description:"View detailed information about specific registry items including the name, description, type and files content. For usage examples, use get_item_examples_from_registries instead.",inputSchema:zodToJsonSchema(z.object({items:z.array(z.string()).describe("Array of item names with registry prefix (e.g., ['@shadcn/button', '@shadcn/card'])")}))},{name:"get_item_examples_from_registries",description:"Find usage examples and demos with their complete code. Search for patterns like 'accordion-demo', 'button example', 'card-demo', etc. Returns full implementation code with dependencies.",inputSchema:zodToJsonSchema(z.object({registries:z.array(z.string()).optional().describe("Array of registry names to search (e.g., ['@shadcn', '@acme']). Omit to search every registry configured in components.json."),query:z.string().describe("Search query for examples (e.g., 'accordion-demo', 'button demo', 'card example', 'tooltip-demo', 'example-booking-form', 'example-hero'). Common patterns: '{item-name}-demo', '{item-name} example', 'example {item-name}'")}))},{name:"get_add_command_for_items",description:"Get the shadcn CLI add command for specific items in a registry. This is useful for adding one or more components to your project.",inputSchema:zodToJsonSchema(z.object({items:z.array(z.string()).describe("Array of items to get the add command for prefixed with the registry name (e.g., ['@shadcn/button', '@shadcn/card'])")}))},{name:"get_audit_checklist",description:"After creating new components or generating new code files, use this tool for a quick checklist to verify that everything is working as expected. Make sure to run the tool after all required steps have been completed.",inputSchema:zodToJsonSchema(z.object({}))}]}));C.setRequestHandler(CallToolRequestSchema,async r=>{try{if(!r.params.arguments)throw new Error("No tool arguments provided.");switch(r.params.name){case "get_project_registries":{let t=await d(process.cwd());return t?.registries?{content:[{type:"text",text:m`The following registries are configured in the current project:
29
+
30
+ ${Object.keys(t.registries).map(n=>`- ${n}`).join(`
31
+ `)}
32
+
33
+ You can view the items in a registry by running:
34
+ \`${await u("view @name-of-registry")}\`
35
+
36
+ For example: \`${await u("view @shadcn")}\` or \`${await u("view @shadcn @acme")}\` to view multiple registries.
37
+ `}]}:{content:[{type:"text",text:m`No components.json found or no registries configured.
38
+
39
+ To fix this:
40
+ 1. Use the \`init\` command to create a components.json file
41
+ 2. Or manually create components.json with a registries section`}]}}case "search_items_in_registries":{let n=z.object({registries:z.array(z.string()).optional(),query:z.string(),types:z.array(z.string()).optional(),limit:z.number().optional(),offset:z.number().optional()}).parse(r.params.arguments),i=w(n.types);if(i)return {content:[{type:"text",text:i}],isError:!0};let o=await d(process.cwd()),a=!n.registries?.length,s=Oa(n.registries??[],o);if(s.length===0)return {content:[{type:"text",text:m`No registries are configured. Add registries to components.json (use get_project_registries to inspect) or pass them explicitly.`}]};let p=await Pa(s,{query:n.query,types:n.types,limit:n.limit??100,offset:n.offset,config:o,useCache:!1,continueOnError:a}),c=$(p);return p.items.length===0?{content:[{type:"text",text:m`No items found matching "${n.query}" in registries ${s.join(", ")}, Try searching with a different query or registry.${c}`}]}:{content:[{type:"text",text:_(p,{query:n.query,registries:s})+c}]}}case "list_items_in_registries":{let n=z.object({registries:z.array(z.string()).optional(),types:z.array(z.string()).optional(),limit:z.number().optional(),offset:z.number().optional(),cwd:z.string().optional()}).parse(r.params.arguments),i=w(n.types);if(i)return {content:[{type:"text",text:i}],isError:!0};let o=await d(process.cwd()),a=!n.registries?.length,s=Oa(n.registries??[],o);if(s.length===0)return {content:[{type:"text",text:m`No registries are configured. Add registries to components.json (use get_project_registries to inspect) or pass them explicitly.`}]};let p=await Pa(s,{types:n.types,limit:n.limit??100,offset:n.offset,config:o,useCache:!1,continueOnError:a}),c=$(p);return p.items.length===0?{content:[{type:"text",text:m`No items found in registries ${s.join(", ")}.${c}`}]}:{content:[{type:"text",text:_(p,{registries:s})+c}]}}case "view_items_in_registries":{let n=z.object({items:z.array(z.string())}).parse(r.params.arguments),i=await qa(n.items,{config:await d(process.cwd()),useCache:!1});if(i?.length===0)return {content:[{type:"text",text:m`No items found for: ${n.items.join(", ")}
42
+
43
+ Make sure the item names are correct and include the registry prefix (e.g., @shadcn/button).`}]};let o=E(i);return {content:[{type:"text",text:m`Item Details:
44
+
45
+ ${o.join(`
46
+
47
+ ---
48
+
49
+ `)}`}]}}case "get_item_examples_from_registries":{let n=z.object({query:z.string(),registries:z.array(z.string()).optional()}).parse(r.params.arguments),i=await d(),o=!n.registries?.length,a=Oa(n.registries??[],i);if(a.length===0)return {content:[{type:"text",text:m`No registries are configured. Add registries to components.json (use get_project_registries to inspect) or pass them explicitly.`}]};let s=await Pa(a,{query:n.query,config:i,useCache:!1,continueOnError:o});if(s.items.length===0)return {content:[{type:"text",text:m`No examples found for query "${n.query}".
50
+
51
+ Try searching with patterns like:
52
+ - "accordion-demo" for accordion examples
53
+ - "button demo" or "button example"
54
+ - Component name followed by "-demo" or "example"
55
+
56
+ You can also:
57
+ 1. Use search_items_in_registries to find all items matching your query
58
+ 2. View the main component with view_items_in_registries for inline usage documentation`}]};let p=s.items.map(g=>g.addCommandArgument),c=await qa(p,{config:i,useCache:!1});return {content:[{type:"text",text:v(c,n.query)}]}}case "get_add_command_for_items":{let t=z.object({items:z.array(z.string())}).parse(r.params.arguments);return {content:[{type:"text",text:await u(`add ${t.items.join(" ")}`)}]}}case "get_audit_checklist":return {content:[{type:"text",text:m`## Component Audit Checklist
59
+
60
+ After adding or generating components, check the following common issues:
61
+
62
+ - [ ] Ensure imports are correct i.e named vs default imports
63
+ - [ ] If using next/image, ensure images.remotePatterns next.config.js is configured correctly.
64
+ - [ ] Ensure all dependencies are installed.
65
+ - [ ] Check for linting errors or warnings
66
+ - [ ] Check for TypeScript errors
67
+ - [ ] Use the Playwright MCP if available.
68
+ `}]};default:throw new Error(`Tool ${r.params.name} not found`)}}catch(t){if(t instanceof z.ZodError)return {content:[{type:"text",text:m`Invalid input parameters:
69
+ ${t.errors.map(i=>`- ${i.path.join(".")}: ${i.message}`).join(`
70
+ `)}
71
+ `}],isError:true};if(t instanceof k){let i=t.message;return t.suggestion&&(i+=`
72
+
73
+ \u{1F4A1} ${t.suggestion}`),t.context&&(i+=`
74
+
75
+ Context: ${JSON.stringify(t.context,null,2)}`),{content:[{type:"text",text:m`Error (${t.code}): ${i}`}],isError:true}}let n=t instanceof Error?t.message:String(t);return {content:[{type:"text",text:m`Error: ${n}`}],isError:true}}});export{C as a};
@@ -0,0 +1 @@
1
+ import {z as z$1}from'zod';var c=z$1.union([z$1.string().refine(e=>e.includes("{name}"),{message:"Registry URL must include {name} placeholder"}),z$1.object({url:z$1.string().refine(e=>e.includes("{name}"),{message:"Registry URL must include {name} placeholder"}),params:z$1.record(z$1.string(),z$1.string()).optional(),headers:z$1.record(z$1.string(),z$1.string()).optional()})]),l=z$1.record(z$1.string().refine(e=>e.startsWith("@"),{message:"Registry names must start with @ (e.g., @v0, @acme)"}),c),s=z$1.object({$schema:z$1.string().optional(),style:z$1.string(),rsc:z$1.coerce.boolean().default(false),tsx:z$1.coerce.boolean().default(true),tailwind:z$1.object({config:z$1.string().optional(),css:z$1.string(),baseColor:z$1.string(),cssVariables:z$1.boolean().default(true),prefix:z$1.string().default("").optional()}),iconLibrary:z$1.string().optional(),rtl:z$1.coerce.boolean().default(false).optional(),menuColor:z$1.enum(["default","inverted","default-translucent","inverted-translucent"]).default("default").optional(),menuAccent:z$1.enum(["subtle","bold"]).default("subtle").optional(),aliases:z$1.object({components:z$1.string(),utils:z$1.string(),ui:z$1.string().optional(),lib:z$1.string().optional(),hooks:z$1.string().optional()}),registries:l.optional()}).strict(),p=s.extend({resolvedPaths:z$1.object({cwd:z$1.string(),tailwindConfig:z$1.string(),tailwindCss:z$1.string(),utils:z$1.string(),components:z$1.string(),lib:z$1.string(),hooks:z$1.string(),ui:z$1.string()})}),I=z$1.record(p),o=z$1.enum(["registry:lib","registry:block","registry:component","registry:ui","registry:hook","registry:page","registry:file","registry:theme","registry:style","registry:item","registry:base","registry:font","registry:example","registry:internal"]),m=z$1.discriminatedUnion("type",[z$1.object({path:z$1.string(),content:z$1.string().optional(),type:z$1.enum(["registry:file","registry:page"]),target:z$1.string()}),z$1.object({path:z$1.string(),content:z$1.string().optional(),type:o.exclude(["registry:file","registry:page"]),target:z$1.string().optional()})]),y=z$1.object({config:z$1.object({content:z$1.array(z$1.string()).optional(),theme:z$1.record(z$1.string(),z$1.any()).optional(),plugins:z$1.array(z$1.string()).optional()}).optional()}),n=z$1.object({theme:z$1.record(z$1.string(),z$1.string()).optional(),light:z$1.record(z$1.string(),z$1.string()).optional(),dark:z$1.record(z$1.string(),z$1.string()).optional()}),a=z$1.lazy(()=>z$1.union([z$1.string(),z$1.array(z$1.union([z$1.string(),z$1.record(z$1.string(),z$1.string())])),z$1.record(z$1.string(),a)])),d=z$1.record(z$1.string(),a),u=z$1.record(z$1.string(),z$1.string()),g=z$1.object({family:z$1.string(),provider:z$1.literal("google"),import:z$1.string(),variable:z$1.string(),weight:z$1.array(z$1.string()).optional(),subsets:z$1.array(z$1.string()).optional(),selector:z$1.string().optional(),dependency:z$1.string().optional()}),r=z$1.object({$schema:z$1.string().optional(),extends:z$1.string().optional(),name:z$1.string(),title:z$1.string().optional(),author:z$1.string().min(2).optional(),description:z$1.string().optional(),dependencies:z$1.array(z$1.string()).optional(),devDependencies:z$1.array(z$1.string()).optional(),registryDependencies:z$1.array(z$1.string()).optional(),files:z$1.array(m).optional(),tailwind:y.optional(),cssVars:n.optional(),css:d.optional(),envVars:u.optional(),meta:z$1.record(z$1.string(),z$1.any()).optional(),docs:z$1.string().optional(),categories:z$1.array(z$1.string()).optional()}),i=z$1.discriminatedUnion("type",[r.extend({type:z$1.literal("registry:base"),config:s.deepPartial().optional()}),r.extend({type:z$1.literal("registry:font"),font:g}),r.extend({type:o.exclude(["registry:base","registry:font"])})]),h=z$1.object({$schema:z$1.string().optional(),name:z$1.string().optional(),homepage:z$1.string().optional(),include:z$1.array(z$1.string()).optional(),items:z$1.array(i).optional()}).refine(e=>e.items!==void 0||e.include!==void 0,{message:"Registry must define at least one of `items` or `include`.",path:["items"]}),f=h.transform(e=>({...e,items:e.items??[]})),C=f.pipe(z$1.object({$schema:z$1.string().optional(),name:z$1.string(),homepage:z$1.string(),include:z$1.array(z$1.string()).optional(),items:z$1.array(i)})),R=z$1.array(i),v=z$1.array(z$1.object({name:z$1.string(),label:z$1.string()})),V=z$1.record(z$1.string(),z$1.record(z$1.string(),z$1.string())),w=z$1.object({inlineColors:z$1.object({light:z$1.record(z$1.string(),z$1.string()),dark:z$1.record(z$1.string(),z$1.string())}),cssVars:n,cssVarsV4:n.optional(),inlineColorsTemplate:z$1.string(),cssVarsTemplate:z$1.string()}),k=r.pick({dependencies:true,devDependencies:true,files:true,tailwind:true,cssVars:true,css:true,envVars:true,docs:true}).extend({fonts:z$1.array(r.extend({type:z$1.literal("registry:font"),font:g})).optional()}),b=z$1.object({name:z$1.string(),type:z$1.string().optional(),description:z$1.string().optional(),registry:z$1.string(),addCommandArgument:z$1.string()}),x=z$1.object({registry:z$1.string(),message:z$1.string()}),z=z$1.object({pagination:z$1.object({total:z$1.number(),offset:z$1.number(),limit:z$1.number(),hasMore:z$1.boolean()}),items:z$1.array(b),errors:z$1.array(x).optional()}),T=z$1.record(z$1.string().regex(/^@[a-zA-Z0-9][a-zA-Z0-9-_]*$/),z$1.string()),A=z$1.array(z$1.object({name:z$1.string(),homepage:z$1.string().optional(),url:z$1.string(),description:z$1.string().optional()})),S=z$1.object({name:z$1.string(),title:z$1.string(),description:z$1.string(),base:z$1.string(),style:z$1.string(),baseColor:z$1.string(),theme:z$1.string(),iconLibrary:z$1.string(),font:z$1.string(),rtl:z$1.coerce.boolean().default(false),menuAccent:z$1.enum(["subtle","bold"]),menuColor:z$1.enum(["default","inverted","default-translucent","inverted-translucent"]),radius:z$1.string()}),$=z$1.object({presets:z$1.array(S)});export{S as A,$ as B,c as a,l as b,s as c,p as d,I as e,o as f,m as g,y as h,n as i,d as j,u as k,g as l,r as m,i as n,f as o,C as p,R as q,v as r,V as s,w as t,k as u,b as v,x as w,z as x,T as y,A as z};