@cuxt/chama 0.0.1

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/README.md ADDED
@@ -0,0 +1,78 @@
1
+ # @cuxt/chama
2
+
3
+ 基于 [shadcn/ui](https://ui.shadcn.com/) Nova 预设的 React 组件库,使用 [Base UI](https://base-ui.com/) 作为底层 primitives,样式基于 Tailwind CSS v4。
4
+
5
+ ## 安装
6
+
7
+ ```bash
8
+ pnpm add @cuxt/chama
9
+ ```
10
+
11
+ **peer dependencies(必须安装,版本 ≥ ^19 / ^1.8)**
12
+
13
+ - `react` ^19
14
+ - `react-dom` ^19
15
+ - `@base-ui/react` ^1.8
16
+ - `lucide-react`
17
+ - `class-variance-authority`
18
+ - `cn`
19
+
20
+ **强制安装(dependencies,无需手动安装)**
21
+
22
+ - `tailwindcss` ^4
23
+ - `tw-animate-css`
24
+ - `@fontsource-variable/geist`
25
+ - `shadcn` ^4
26
+
27
+ ## 配置样式
28
+
29
+ 在你的项目入口 CSS 中(例如 `src/app.css`):
30
+
31
+ ```css
32
+ @import "tailwindcss";
33
+ @import "@cuxt/chama/style.css";
34
+
35
+ /* 让 Tailwind v4 扫描组件库代码以生成对应的工具类 */
36
+ @source "../node_modules/@cuxt/chama/dist";
37
+ ```
38
+
39
+ ## 使用
40
+
41
+ ```tsx
42
+ import { Button } from "@cuxt/chama";
43
+
44
+ export function App() {
45
+ return <Button variant="outline">点击我</Button>;
46
+ }
47
+ ```
48
+
49
+ ## 组件
50
+
51
+ | 名称 | 描述 |
52
+ | ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
53
+ | `Button` | 基于 Base UI `Button` 的多态按钮,支持 `variant`(`default` / `outline` / `secondary` / `ghost` / `destructive` / `link`)与 `size`(`default` / `xs` / `sm` / `lg` / `icon` / `icon-xs` / `icon-sm` / `icon-lg`) |
54
+ | `buttonVariants` | 由 `class-variance-authority` 导出的样式变体,可直接用于自定义组件 |
55
+
56
+ ## 开发
57
+
58
+ ```bash
59
+ pnpm install
60
+ pnpm run build # vp pack:构建库产物到 dist/
61
+ pnpm run check # vp check:lint + format + type-check
62
+ ```
63
+
64
+ ## 发布
65
+
66
+ ```bash
67
+ # 首次发布前确保已在 npm 创建 organization @cuxt
68
+ npm login
69
+ npm publish
70
+
71
+ # 后续发布
72
+ pnpm exec bumpp # 交互式 bump 版本
73
+ npm publish
74
+ ```
75
+
76
+ ## License
77
+
78
+ MIT © [cuxt](https://github.com/cuxt)
@@ -0,0 +1,10 @@
1
+ import { Button as Button$1 } from "@base-ui/react/button";
2
+ import { VariantProps } from "class-variance-authority";
3
+ //#region src/components/ui/button.d.ts
4
+ declare const buttonVariants: (props?: ({
5
+ variant?: "default" | "destructive" | "ghost" | "link" | "outline" | "secondary" | null | undefined;
6
+ size?: "default" | "icon" | "icon-lg" | "icon-sm" | "icon-xs" | "lg" | "sm" | "xs" | null | undefined;
7
+ } & import("class-variance-authority/types").ClassProp) | undefined) => string;
8
+ declare function Button({ className, variant, size, ...props }: Button$1.Props & VariantProps<typeof buttonVariants>): import("react").JSX.Element;
9
+ //#endregion
10
+ export { Button, buttonVariants };
package/dist/index.mjs ADDED
@@ -0,0 +1,44 @@
1
+ import { Button as Button$1 } from "@base-ui/react/button";
2
+ import { cva } from "class-variance-authority";
3
+ import { cn } from "cn";
4
+ import { jsx } from "react/jsx-runtime";
5
+ //#region src/components/ui/button.tsx
6
+ 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:not-aria-[haspopup]: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", {
7
+ variants: {
8
+ variant: {
9
+ default: "bg-primary text-primary-foreground hover:bg-primary/80",
10
+ 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",
11
+ secondary: "bg-secondary text-secondary-foreground hover:bg-[color-mix(in_oklch,var(--secondary),var(--foreground)_5%)] aria-expanded:bg-secondary aria-expanded:text-secondary-foreground",
12
+ ghost: "hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50",
13
+ 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",
14
+ link: "text-primary underline-offset-4 hover:underline"
15
+ },
16
+ size: {
17
+ default: "h-8 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
18
+ 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",
19
+ 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",
20
+ lg: "h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
21
+ icon: "size-8",
22
+ "icon-xs": "size-6 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-lg [&_svg:not([class*='size-'])]:size-3",
23
+ "icon-sm": "size-7 rounded-[min(var(--radius-md),12px)] in-data-[slot=button-group]:rounded-lg",
24
+ "icon-lg": "size-9"
25
+ }
26
+ },
27
+ defaultVariants: {
28
+ variant: "default",
29
+ size: "default"
30
+ }
31
+ });
32
+ function Button({ className, variant = "default", size = "default", ...props }) {
33
+ return /* @__PURE__ */ jsx(Button$1, {
34
+ "data-slot": "button",
35
+ className: cn(buttonVariants({
36
+ variant,
37
+ size,
38
+ className
39
+ })),
40
+ ...props
41
+ });
42
+ }
43
+ //#endregion
44
+ export { Button, buttonVariants };