9 changed files with 3645 additions and 179 deletions
@ -0,0 +1,25 @@ |
|||||||
|
{ |
||||||
|
"$schema": "https://ui.shadcn.com/schema.json", |
||||||
|
"style": "base-nova", |
||||||
|
"rsc": true, |
||||||
|
"tsx": true, |
||||||
|
"tailwind": { |
||||||
|
"config": "", |
||||||
|
"css": "src/app/globals.css", |
||||||
|
"baseColor": "neutral", |
||||||
|
"cssVariables": true, |
||||||
|
"prefix": "" |
||||||
|
}, |
||||||
|
"iconLibrary": "lucide", |
||||||
|
"rtl": false, |
||||||
|
"aliases": { |
||||||
|
"components": "@/components", |
||||||
|
"utils": "@/lib/utils", |
||||||
|
"ui": "@/components/ui", |
||||||
|
"lib": "@/lib", |
||||||
|
"hooks": "@/hooks" |
||||||
|
}, |
||||||
|
"menuColor": "default", |
||||||
|
"menuAccent": "subtle", |
||||||
|
"registries": {} |
||||||
|
} |
||||||
@ -0,0 +1,14 @@ |
|||||||
|
import { CopilotRuntime, OpenAIAdapter } from "@copilotkit/backend"; |
||||||
|
import OpenAI from "openai"; |
||||||
|
|
||||||
|
// 将您的 API Key 放在同级目录或应用根目录的 .env 文件中
|
||||||
|
export const runtime = 'edge'; |
||||||
|
|
||||||
|
export async function POST(req: Request) { |
||||||
|
// 如果环境变量未就绪,使用默认的容错模式(要求客户稍后补齐)
|
||||||
|
const openai = new OpenAI({ apiKey: process.env.OPENAI_API_KEY || "dummy-key-for-local-test" }); |
||||||
|
|
||||||
|
const copilotKit = new CopilotRuntime(); |
||||||
|
|
||||||
|
return copilotKit.response(req, new OpenAIAdapter({ openai })); |
||||||
|
} |
||||||
@ -1,26 +1,130 @@ |
|||||||
@import "tailwindcss"; |
@import "tailwindcss"; |
||||||
|
@import "tw-animate-css"; |
||||||
|
@import "shadcn/tailwind.css"; |
||||||
|
|
||||||
:root { |
@custom-variant dark (&:is(.dark *)); |
||||||
--background: #ffffff; |
|
||||||
--foreground: #171717; |
|
||||||
} |
|
||||||
|
|
||||||
@theme inline { |
@theme inline { |
||||||
--color-background: var(--background); |
--color-background: var(--background); |
||||||
--color-foreground: var(--foreground); |
--color-foreground: var(--foreground); |
||||||
--font-sans: var(--font-geist-sans); |
--font-sans: var(--font-sans); |
||||||
--font-mono: var(--font-geist-mono); |
--font-mono: var(--font-geist-mono); |
||||||
|
--font-heading: var(--font-sans); |
||||||
|
--color-sidebar-ring: var(--sidebar-ring); |
||||||
|
--color-sidebar-border: var(--sidebar-border); |
||||||
|
--color-sidebar-accent-foreground: var(--sidebar-accent-foreground); |
||||||
|
--color-sidebar-accent: var(--sidebar-accent); |
||||||
|
--color-sidebar-primary-foreground: var(--sidebar-primary-foreground); |
||||||
|
--color-sidebar-primary: var(--sidebar-primary); |
||||||
|
--color-sidebar-foreground: var(--sidebar-foreground); |
||||||
|
--color-sidebar: var(--sidebar); |
||||||
|
--color-chart-5: var(--chart-5); |
||||||
|
--color-chart-4: var(--chart-4); |
||||||
|
--color-chart-3: var(--chart-3); |
||||||
|
--color-chart-2: var(--chart-2); |
||||||
|
--color-chart-1: var(--chart-1); |
||||||
|
--color-ring: var(--ring); |
||||||
|
--color-input: var(--input); |
||||||
|
--color-border: var(--border); |
||||||
|
--color-destructive: var(--destructive); |
||||||
|
--color-accent-foreground: var(--accent-foreground); |
||||||
|
--color-accent: var(--accent); |
||||||
|
--color-muted-foreground: var(--muted-foreground); |
||||||
|
--color-muted: var(--muted); |
||||||
|
--color-secondary-foreground: var(--secondary-foreground); |
||||||
|
--color-secondary: var(--secondary); |
||||||
|
--color-primary-foreground: var(--primary-foreground); |
||||||
|
--color-primary: var(--primary); |
||||||
|
--color-popover-foreground: var(--popover-foreground); |
||||||
|
--color-popover: var(--popover); |
||||||
|
--color-card-foreground: var(--card-foreground); |
||||||
|
--color-card: var(--card); |
||||||
|
--radius-sm: calc(var(--radius) * 0.6); |
||||||
|
--radius-md: calc(var(--radius) * 0.8); |
||||||
|
--radius-lg: var(--radius); |
||||||
|
--radius-xl: calc(var(--radius) * 1.4); |
||||||
|
--radius-2xl: calc(var(--radius) * 1.8); |
||||||
|
--radius-3xl: calc(var(--radius) * 2.2); |
||||||
|
--radius-4xl: calc(var(--radius) * 2.6); |
||||||
} |
} |
||||||
|
|
||||||
@media (prefers-color-scheme: dark) { |
:root { |
||||||
:root { |
--background: oklch(1 0 0); |
||||||
--background: #0a0a0a; |
--foreground: oklch(0.145 0 0); |
||||||
--foreground: #ededed; |
--card: oklch(1 0 0); |
||||||
} |
--card-foreground: oklch(0.145 0 0); |
||||||
|
--popover: oklch(1 0 0); |
||||||
|
--popover-foreground: oklch(0.145 0 0); |
||||||
|
--primary: oklch(0.205 0 0); |
||||||
|
--primary-foreground: oklch(0.985 0 0); |
||||||
|
--secondary: oklch(0.97 0 0); |
||||||
|
--secondary-foreground: oklch(0.205 0 0); |
||||||
|
--muted: oklch(0.97 0 0); |
||||||
|
--muted-foreground: oklch(0.556 0 0); |
||||||
|
--accent: oklch(0.97 0 0); |
||||||
|
--accent-foreground: oklch(0.205 0 0); |
||||||
|
--destructive: oklch(0.577 0.245 27.325); |
||||||
|
--border: oklch(0.922 0 0); |
||||||
|
--input: oklch(0.922 0 0); |
||||||
|
--ring: oklch(0.708 0 0); |
||||||
|
--chart-1: oklch(0.87 0 0); |
||||||
|
--chart-2: oklch(0.556 0 0); |
||||||
|
--chart-3: oklch(0.439 0 0); |
||||||
|
--chart-4: oklch(0.371 0 0); |
||||||
|
--chart-5: oklch(0.269 0 0); |
||||||
|
--radius: 0.625rem; |
||||||
|
--sidebar: oklch(0.985 0 0); |
||||||
|
--sidebar-foreground: oklch(0.145 0 0); |
||||||
|
--sidebar-primary: oklch(0.205 0 0); |
||||||
|
--sidebar-primary-foreground: oklch(0.985 0 0); |
||||||
|
--sidebar-accent: oklch(0.97 0 0); |
||||||
|
--sidebar-accent-foreground: oklch(0.205 0 0); |
||||||
|
--sidebar-border: oklch(0.922 0 0); |
||||||
|
--sidebar-ring: oklch(0.708 0 0); |
||||||
} |
} |
||||||
|
|
||||||
body { |
.dark { |
||||||
background: var(--background); |
--background: oklch(0.145 0 0); |
||||||
color: var(--foreground); |
--foreground: oklch(0.985 0 0); |
||||||
font-family: Arial, Helvetica, sans-serif; |
--card: oklch(0.205 0 0); |
||||||
|
--card-foreground: oklch(0.985 0 0); |
||||||
|
--popover: oklch(0.205 0 0); |
||||||
|
--popover-foreground: oklch(0.985 0 0); |
||||||
|
--primary: oklch(0.922 0 0); |
||||||
|
--primary-foreground: oklch(0.205 0 0); |
||||||
|
--secondary: oklch(0.269 0 0); |
||||||
|
--secondary-foreground: oklch(0.985 0 0); |
||||||
|
--muted: oklch(0.269 0 0); |
||||||
|
--muted-foreground: oklch(0.708 0 0); |
||||||
|
--accent: oklch(0.269 0 0); |
||||||
|
--accent-foreground: oklch(0.985 0 0); |
||||||
|
--destructive: oklch(0.704 0.191 22.216); |
||||||
|
--border: oklch(1 0 0 / 10%); |
||||||
|
--input: oklch(1 0 0 / 15%); |
||||||
|
--ring: oklch(0.556 0 0); |
||||||
|
--chart-1: oklch(0.87 0 0); |
||||||
|
--chart-2: oklch(0.556 0 0); |
||||||
|
--chart-3: oklch(0.439 0 0); |
||||||
|
--chart-4: oklch(0.371 0 0); |
||||||
|
--chart-5: oklch(0.269 0 0); |
||||||
|
--sidebar: oklch(0.205 0 0); |
||||||
|
--sidebar-foreground: oklch(0.985 0 0); |
||||||
|
--sidebar-primary: oklch(0.488 0.243 264.376); |
||||||
|
--sidebar-primary-foreground: oklch(0.985 0 0); |
||||||
|
--sidebar-accent: oklch(0.269 0 0); |
||||||
|
--sidebar-accent-foreground: oklch(0.985 0 0); |
||||||
|
--sidebar-border: oklch(1 0 0 / 10%); |
||||||
|
--sidebar-ring: oklch(0.556 0 0); |
||||||
|
} |
||||||
|
|
||||||
|
@layer base { |
||||||
|
* { |
||||||
|
@apply border-border outline-ring/50; |
||||||
|
} |
||||||
|
body { |
||||||
|
@apply bg-background text-foreground; |
||||||
|
} |
||||||
|
html { |
||||||
|
@apply font-sans; |
||||||
|
} |
||||||
} |
} |
||||||
@ -1,65 +1,49 @@ |
|||||||
import Image from "next/image"; |
"use client"; |
||||||
|
|
||||||
|
import { CopilotKit } from "@copilotkit/react-core"; |
||||||
|
import { CopilotPopup } from "@copilotkit/react-ui"; |
||||||
|
import "@copilotkit/react-ui/styles.css"; |
||||||
|
import UniversalModuleRenderer from "@/components/UniversalModuleRenderer"; |
||||||
|
|
||||||
export default function Home() { |
export default function Home() { |
||||||
return ( |
return ( |
||||||
<div className="flex flex-col flex-1 items-center justify-center bg-zinc-50 font-sans dark:bg-black"> |
<CopilotKit runtimeUrl="/api/copilotkit"> |
||||||
<main className="flex flex-1 w-full max-w-3xl flex-col items-center justify-between py-32 px-16 bg-white dark:bg-black sm:items-start"> |
<div className="min-h-screen bg-slate-50 font-[family-name:var(--font-geist-sans)]"> |
||||||
<Image |
{/* 顶部导航 */} |
||||||
className="dark:invert" |
<header className="bg-white shadow-sm border-b px-8 py-4 flex items-center justify-between"> |
||||||
src="/next.svg" |
<h1 className="text-2xl font-black text-gray-800 tracking-tight">AI-Native <span className="text-blue-600">Copilot CRM</span></h1> |
||||||
alt="Next.js logo" |
<div className="flex items-center space-x-4"> |
||||||
width={100} |
<span className="text-sm font-medium text-gray-500">登录身份: <span className="text-gray-900 bg-gray-100 px-2 py-1 rounded">ADMIN_TENANT_1</span></span> |
||||||
height={20} |
</div> |
||||||
priority |
</header> |
||||||
/> |
|
||||||
<div className="flex flex-col items-center gap-6 text-center sm:items-start sm:text-left"> |
<main className="p-8 max-w-5xl mx-auto mt-8 flex flex-col gap-6"> |
||||||
<h1 className="max-w-xs text-3xl font-semibold leading-10 tracking-tight text-black dark:text-zinc-50"> |
<div className="bg-white p-6 rounded-xl shadow-sm border border-gray-100 relative overflow-hidden"> |
||||||
To get started, edit the page.tsx file. |
<div className="absolute top-0 right-0 w-32 h-32 bg-blue-50 rounded-bl-full -z-10 opacity-50"></div> |
||||||
</h1> |
<h2 className="text-xl font-bold mb-2">欢迎使用声明式工作台</h2> |
||||||
<p className="max-w-md text-lg leading-8 text-zinc-600 dark:text-zinc-400"> |
<p className="text-gray-600 text-sm leading-relaxed max-w-2xl"> |
||||||
Looking for a starting point or more instructions? Head over to{" "} |
在这个颠覆性的系统中,您不再需要联系研发排期写代码。只需点击右下角的智能体按钮,例如告诉它:<b>“我需要一个内部采购报销单,要求包含物品名称、总造价和期待到货日期”</b>,系统就会立刻为您画出表单架构。 |
||||||
<a |
|
||||||
href="https://vercel.com/templates?framework=next.js&utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app" |
|
||||||
className="font-medium text-zinc-950 dark:text-zinc-50" |
|
||||||
> |
|
||||||
Templates |
|
||||||
</a>{" "} |
|
||||||
or the{" "} |
|
||||||
<a |
|
||||||
href="https://nextjs.org/learn?utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app" |
|
||||||
className="font-medium text-zinc-950 dark:text-zinc-50" |
|
||||||
> |
|
||||||
Learning |
|
||||||
</a>{" "} |
|
||||||
center. |
|
||||||
</p> |
</p> |
||||||
</div> |
</div> |
||||||
<div className="flex flex-col gap-4 text-base font-medium sm:flex-row"> |
|
||||||
<a |
<div className="w-full bg-white border border-gray-200 border-dashed p-10 rounded-xl min-h-[400px] flex flex-col items-center justify-center relative shadow-inner"> |
||||||
className="flex h-12 w-full items-center justify-center gap-2 rounded-full bg-foreground px-5 text-background transition-colors hover:bg-[#383838] dark:hover:bg-[#ccc] md:w-[158px]" |
<svg className="w-12 h-12 text-gray-300 mb-4" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d="M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 002-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"></path></svg> |
||||||
href="https://vercel.com/new?utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app" |
<p className="text-gray-400 font-medium">业务模块画布空空如也,等待 AI 为您注入灵魂 (Generative UI Render Area)...</p> |
||||||
target="_blank" |
|
||||||
rel="noopener noreferrer" |
|
||||||
> |
|
||||||
<Image |
|
||||||
className="dark:invert" |
|
||||||
src="/vercel.svg" |
|
||||||
alt="Vercel logomark" |
|
||||||
width={16} |
|
||||||
height={16} |
|
||||||
/> |
|
||||||
Deploy Now |
|
||||||
</a> |
|
||||||
<a |
|
||||||
className="flex h-12 w-full items-center justify-center rounded-full border border-solid border-black/[.08] px-5 transition-colors hover:border-transparent hover:bg-black/[.04] dark:border-white/[.145] dark:hover:bg-[#1a1a1a] md:w-[158px]" |
|
||||||
href="https://nextjs.org/docs?utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app" |
|
||||||
target="_blank" |
|
||||||
rel="noopener noreferrer" |
|
||||||
> |
|
||||||
Documentation |
|
||||||
</a> |
|
||||||
</div> |
</div> |
||||||
|
|
||||||
|
{/* 这里挂载在页面后台,负责监听并执行 AI 下发的 UI 画指令 */} |
||||||
|
<UniversalModuleRenderer /> |
||||||
</main> |
</main> |
||||||
</div> |
</div> |
||||||
|
|
||||||
|
<CopilotPopup |
||||||
|
instructions="你是一个嵌入在高级企业 CRM 系统中的智能架构师。当用户需要新建任何功能时,请调用 renderDynamicForm 工具响应用户并渲染出一个 JSON Schema 定义的表单。" |
||||||
|
labels={{ |
||||||
|
title: "🤖 CRM 架构探求者", |
||||||
|
initial: "您好,刘总。您今天想为公司内部门添加什么新功能模块?", |
||||||
|
}} |
||||||
|
defaultOpen={true} |
||||||
|
/> |
||||||
|
</CopilotKit> |
||||||
); |
); |
||||||
} |
} |
||||||
|
|||||||
@ -0,0 +1,81 @@ |
|||||||
|
"use client"; |
||||||
|
|
||||||
|
import { useCopilotAction } from "@copilotkit/react-core"; |
||||||
|
import { useState } from "react"; |
||||||
|
|
||||||
|
export default function UniversalModuleRenderer() { |
||||||
|
const [currentSchema, setCurrentSchema] = useState<any>(null); |
||||||
|
|
||||||
|
// 核心:这个 Action 让 AI 能够在聊天流中不仅回复文字,更能直接把这段 React 树“扔”到前端界面里!
|
||||||
|
useCopilotAction({ |
||||||
|
name: "renderDynamicForm", |
||||||
|
description: "在页面上为一个新的业务模块渲染基于 JSON Schema 的动态表单,使用在对话中。", |
||||||
|
parameters: [ |
||||||
|
{ name: "entityName", type: "string", description: "表单或业务实体的中文名称,如'客户拜访记录'" }, |
||||||
|
{ name: "entityCode", type: "string", description: "该业务的唯一英文编码,如'customer_visit'" }, |
||||||
|
{ name: "jsonSchema", type: "string", description: "完全按照刚才设计的 JSON Schema 标准化字符串" } |
||||||
|
], |
||||||
|
handler: async ({ entityName, entityCode, jsonSchema }) => { |
||||||
|
// 这个动作代表 AI 的渲染指令已经送达前端
|
||||||
|
return "UI 渲染通道已打开并呈现给用户。"; |
||||||
|
}, |
||||||
|
render: ({ status, args }) => { |
||||||
|
// 状态机:大模型还在努力生成字的时候显示打草稿状态
|
||||||
|
if (status === "inProgress") { |
||||||
|
return ( |
||||||
|
<div className="p-4 border-2 border-dashed border-blue-200 rounded-lg bg-blue-50/50 animate-pulse text-sm text-blue-600"> |
||||||
|
正在构思 <strong>{args.entityName || '未知模块'}</strong> 的界面结构 (Generative UI IN PROGRESS)... |
||||||
|
</div> |
||||||
|
); |
||||||
|
} |
||||||
|
// 状态机:大模型生成完毕
|
||||||
|
if (!args.jsonSchema) return null; |
||||||
|
|
||||||
|
try { |
||||||
|
// 安全地解析大模型幻觉可能导致的脏 JSON
|
||||||
|
const schemaObj = JSON.parse(args.jsonSchema); |
||||||
|
|
||||||
|
// 动态构建出完整的可填报表单
|
||||||
|
return ( |
||||||
|
<div className="p-6 border rounded-xl shadow-lg bg-white mt-4 transition-all duration-300 transform scale-100"> |
||||||
|
<div className="flex items-center justify-between mb-6 border-b pb-4"> |
||||||
|
<h3 className="text-xl font-bold text-gray-800">{args.entityName}</h3> |
||||||
|
<span className="text-xs bg-zinc-100 px-2 py-1 rounded text-zinc-500">{args.entityCode}</span> |
||||||
|
</div> |
||||||
|
|
||||||
|
<div className="space-y-5"> |
||||||
|
{Object.entries(schemaObj.properties || {}).map(([key, field]: [string, any]) => ( |
||||||
|
<div key={key} className="flex flex-col space-y-1.5"> |
||||||
|
<label className="text-sm font-semibold text-gray-700">{field.title || key}</label> |
||||||
|
<input
|
||||||
|
type={field.type === 'number' ? 'number' : 'text'} |
||||||
|
className="w-full border border-gray-300 p-2.5 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 outline-none transition-all shadow-sm text-sm" |
||||||
|
placeholder={`请输入 ${field.title || key}`} |
||||||
|
/> |
||||||
|
</div> |
||||||
|
))} |
||||||
|
</div> |
||||||
|
<div className="mt-8 pt-4 border-t flex justify-end"> |
||||||
|
<button
|
||||||
|
className="px-6 py-2.5 bg-blue-600 text-white rounded-lg hover:bg-blue-700 font-medium shadow-md transition-colors" |
||||||
|
onClick={() => alert('这里将调用 Spring Boot 的 /api/dynamic 接口入库!')} |
||||||
|
> |
||||||
|
保存数据到后端 JSONB |
||||||
|
</button> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
); |
||||||
|
} catch (e) { |
||||||
|
// 回退 / 降级 UI (Fallback UI)
|
||||||
|
return ( |
||||||
|
<div className="p-4 text-red-500 bg-red-50 border border-red-200 rounded-lg mt-4 text-sm"> |
||||||
|
<p className="font-bold mb-2">大模型格式幻觉,表单渲染失败</p> |
||||||
|
<p className="text-xs break-all">{args.jsonSchema}</p> |
||||||
|
</div> |
||||||
|
); |
||||||
|
} |
||||||
|
} |
||||||
|
}); |
||||||
|
|
||||||
|
return <div className="hidden" aria-hidden="true" />; |
||||||
|
} |
||||||
@ -0,0 +1,60 @@ |
|||||||
|
"use client" |
||||||
|
|
||||||
|
import { Button as ButtonPrimitive } from "@base-ui/react/button" |
||||||
|
import { cva, type VariantProps } from "class-variance-authority" |
||||||
|
|
||||||
|
import { cn } from "@/lib/utils" |
||||||
|
|
||||||
|
const buttonVariants = cva( |
||||||
|
"group/button inline-flex shrink-0 items-center justify-center rounded-lg border border-transparent bg-clip-padding text-sm font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 active:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", |
||||||
|
{ |
||||||
|
variants: { |
||||||
|
variant: { |
||||||
|
default: "bg-primary text-primary-foreground [a]:hover:bg-primary/80", |
||||||
|
outline: |
||||||
|
"border-border bg-background hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50", |
||||||
|
secondary: |
||||||
|
"bg-secondary text-secondary-foreground hover:bg-secondary/80 aria-expanded:bg-secondary aria-expanded:text-secondary-foreground", |
||||||
|
ghost: |
||||||
|
"hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50", |
||||||
|
destructive: |
||||||
|
"bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40", |
||||||
|
link: "text-primary underline-offset-4 hover:underline", |
||||||
|
}, |
||||||
|
size: { |
||||||
|
default: |
||||||
|
"h-8 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2", |
||||||
|
xs: "h-6 gap-1 rounded-[min(var(--radius-md),10px)] px-2 text-xs in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3", |
||||||
|
sm: "h-7 gap-1 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5", |
||||||
|
lg: "h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-3 has-data-[icon=inline-start]:pl-3", |
||||||
|
icon: "size-8", |
||||||
|
"icon-xs": |
||||||
|
"size-6 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-lg [&_svg:not([class*='size-'])]:size-3", |
||||||
|
"icon-sm": |
||||||
|
"size-7 rounded-[min(var(--radius-md),12px)] in-data-[slot=button-group]:rounded-lg", |
||||||
|
"icon-lg": "size-9", |
||||||
|
}, |
||||||
|
}, |
||||||
|
defaultVariants: { |
||||||
|
variant: "default", |
||||||
|
size: "default", |
||||||
|
}, |
||||||
|
} |
||||||
|
) |
||||||
|
|
||||||
|
function Button({ |
||||||
|
className, |
||||||
|
variant = "default", |
||||||
|
size = "default", |
||||||
|
...props |
||||||
|
}: ButtonPrimitive.Props & VariantProps<typeof buttonVariants>) { |
||||||
|
return ( |
||||||
|
<ButtonPrimitive |
||||||
|
data-slot="button" |
||||||
|
className={cn(buttonVariants({ variant, size, className }))} |
||||||
|
{...props} |
||||||
|
/> |
||||||
|
) |
||||||
|
} |
||||||
|
|
||||||
|
export { Button, buttonVariants } |
||||||
Loading…
Reference in new issue