@vultro/ui 0.0.0-stage → 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.
Files changed (39) hide show
  1. package/README.md +58 -2
  2. package/dist/components/alert.d.ts +16 -0
  3. package/dist/components/alert.js +43 -0
  4. package/dist/components/badge.d.ts +7 -0
  5. package/dist/components/badge.js +28 -0
  6. package/dist/components/button.d.ts +8 -0
  7. package/dist/components/button.js +43 -0
  8. package/dist/components/card.d.ts +11 -0
  9. package/dist/components/card.js +55 -0
  10. package/dist/components/chart.d.ts +44 -0
  11. package/dist/components/chart.js +148 -0
  12. package/dist/components/checkbox.d.ts +3 -0
  13. package/dist/components/checkbox.js +18 -0
  14. package/dist/components/dialog.d.ts +18 -0
  15. package/dist/components/dialog.js +76 -0
  16. package/dist/components/input.d.ts +3 -0
  17. package/dist/components/input.js +14 -0
  18. package/dist/components/label.d.ts +10 -0
  19. package/dist/components/label.js +19 -0
  20. package/dist/components/separator.d.ts +3 -0
  21. package/dist/components/separator.js +14 -0
  22. package/dist/components/sheet.d.ts +14 -0
  23. package/dist/components/sheet.js +88 -0
  24. package/dist/components/sidebar.d.ts +63 -0
  25. package/dist/components/sidebar.js +385 -0
  26. package/dist/components/skeleton.d.ts +9 -0
  27. package/dist/components/skeleton.js +18 -0
  28. package/dist/components/table.d.ts +18 -0
  29. package/dist/components/table.js +73 -0
  30. package/dist/components/textarea.d.ts +10 -0
  31. package/dist/components/textarea.js +19 -0
  32. package/dist/components/tooltip.d.ts +6 -0
  33. package/dist/components/tooltip.js +40 -0
  34. package/dist/hooks/use-mobile.d.ts +1 -0
  35. package/dist/hooks/use-mobile.js +17 -0
  36. package/dist/lib/utils.d.ts +1 -0
  37. package/dist/lib/utils.js +1 -0
  38. package/dist/styles/globals.css +135 -0
  39. package/package.json +35 -4
package/README.md CHANGED
@@ -1,3 +1,59 @@
1
- # Temporary Holding Version
1
+ # @vultro/ui
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ `plays/play-*` 与 `apps/dashboard-self-hosted` 共用的 shadcn + Tailwind v4 组件包。
4
+
5
+ - 组件源码:`src/components`
6
+ - hooks:`src/hooks`(例如 Sidebar 使用的 `use-mobile`)
7
+ - 工具函数:`src/lib`
8
+ - Tailwind / shadcn 主题:`src/styles/globals.css`
9
+
10
+ `sidebar` / `chart` / `sheet` / `tooltip` 直接来自 shadcn 的 `base-nova`
11
+ 注册表;`chart` 依赖 `recharts@3.8.0`,随本包一起安装。
12
+
13
+ - 通过 `@vultro/ui/*` 子路径导出,例如:
14
+
15
+ ```tsx
16
+ import { Button } from "@vultro/ui/components/button"
17
+ import { Card, CardContent } from "@vultro/ui/components/card"
18
+ import {
19
+ Sidebar,
20
+ SidebarProvider,
21
+ SidebarInset,
22
+ } from "@vultro/ui/components/sidebar"
23
+ import {
24
+ ChartContainer,
25
+ ChartTooltip,
26
+ ChartTooltipContent,
27
+ } from "@vultro/ui/components/chart"
28
+ import { cn } from "@vultro/ui/lib/utils"
29
+ ```
30
+
31
+ ## 添加组件
32
+
33
+ 在仓库根目录运行:
34
+
35
+ ```bash
36
+ bunx --bun shadcn@latest add card input checkbox badge separator -c packages/ui
37
+ ```
38
+
39
+ `packages/ui/components.json` 已配置 `@vultro/ui` 别名,组件会写入
40
+ `packages/ui/src/components`。
41
+
42
+ ## 使用
43
+
44
+ `plays/play-*` 通过 workspace 依赖引入本包:
45
+
46
+ ```json
47
+ {
48
+ "dependencies": {
49
+ "@vultro/ui": "workspace:*"
50
+ }
51
+ }
52
+ ```
53
+
54
+ 并在 `src/client.tsx` 先加载主题 CSS:
55
+
56
+ ```ts
57
+ import "@vultro/ui/globals.css"
58
+ import "./styles.css"
59
+ ```
@@ -0,0 +1,16 @@
1
+ import * as React from "react";
2
+ import { type VariantProps } from "class-variance-authority";
3
+ /**
4
+ * 页面内的提示块。
5
+ *
6
+ * `destructive` 用于事务失败 / 权限错误,`warning` 用于只读或降级提示,
7
+ * `default` 用于普通说明。和 Callout 相比这个组件不依赖图标库,方便在
8
+ * 错误边界里使用(错误边界本身就可能在图标加载失败时渲染)。
9
+ */
10
+ declare const alertVariants: (props?: ({
11
+ variant?: "default" | "destructive" | "warning" | null | undefined;
12
+ } & import("class-variance-authority/types").ClassProp) | undefined) => string;
13
+ declare function Alert({ className, variant, ...props }: React.ComponentProps<"div"> & VariantProps<typeof alertVariants>): React.JSX.Element;
14
+ declare function AlertTitle({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
15
+ declare function AlertDescription({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
16
+ export { Alert, AlertTitle, AlertDescription, alertVariants };
@@ -0,0 +1,43 @@
1
+ import "react";
2
+ import { cva } from "class-variance-authority";
3
+ import { cn } from "cn";
4
+ import { jsx } from "react/jsx-runtime";
5
+ // src/components/alert.tsx
6
+ /**
7
+ * 页面内的提示块。
8
+ *
9
+ * `destructive` 用于事务失败 / 权限错误,`warning` 用于只读或降级提示,
10
+ * `default` 用于普通说明。和 Callout 相比这个组件不依赖图标库,方便在
11
+ * 错误边界里使用(错误边界本身就可能在图标加载失败时渲染)。
12
+ */
13
+ var alertVariants = cva("relative grid w-full grid-cols-[0_1fr] items-start gap-y-0.5 rounded-lg border px-3 py-2 text-sm has-[>svg]:grid-cols-[--spacing(4)_1fr] has-[>svg]:gap-x-2 [&>svg]:size-4 [&>svg]:translate-y-0.5", {
14
+ variants: { variant: {
15
+ default: "border-border bg-card text-card-foreground",
16
+ destructive: "border-destructive/30 bg-destructive/10 text-destructive [&>svg]:text-destructive",
17
+ warning: "border-amber-500/30 bg-amber-500/10 text-amber-900 dark:text-amber-200"
18
+ } },
19
+ defaultVariants: { variant: "default" }
20
+ });
21
+ function Alert({ className, variant, ...props }) {
22
+ return /* @__PURE__ */ jsx("div", {
23
+ "data-slot": "alert",
24
+ role: "alert",
25
+ className: cn(alertVariants({ variant }), className),
26
+ ...props
27
+ });
28
+ }
29
+ function AlertTitle({ className, ...props }) {
30
+ return /* @__PURE__ */ jsx("div", {
31
+ "data-slot": "alert-title",
32
+ className: cn("col-start-2 line-clamp-1 font-medium", className),
33
+ ...props
34
+ });
35
+ }
36
+ function AlertDescription({ className, ...props }) {
37
+ return /* @__PURE__ */ jsx("div", {
38
+ "data-slot": "alert-description",
39
+ className: cn("col-start-2 text-sm text-muted-foreground", className),
40
+ ...props
41
+ });
42
+ }
43
+ export { Alert, AlertDescription, AlertTitle, alertVariants };
@@ -0,0 +1,7 @@
1
+ import { useRender } from "@base-ui/react/use-render";
2
+ import { type VariantProps } from "class-variance-authority";
3
+ declare const badgeVariants: (props?: ({
4
+ variant?: "default" | "destructive" | "link" | "secondary" | "outline" | "ghost" | null | undefined;
5
+ } & import("class-variance-authority/types").ClassProp) | undefined) => string;
6
+ declare function Badge({ className, variant, render, ...props }: useRender.ComponentProps<"span"> & VariantProps<typeof badgeVariants>): import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
7
+ export { Badge, badgeVariants };
@@ -0,0 +1,28 @@
1
+ import { mergeProps } from "@base-ui/react/merge-props";
2
+ import { useRender } from "@base-ui/react/use-render";
3
+ import { cva } from "class-variance-authority";
4
+ import { cn } from "cn";
5
+ // src/components/badge.tsx
6
+ var badgeVariants = cva("group/badge inline-flex h-5 w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-4xl border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-all focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3!", {
7
+ variants: { variant: {
8
+ default: "bg-primary text-primary-foreground [a]:hover:bg-primary/80",
9
+ secondary: "bg-secondary text-secondary-foreground [a]:hover:bg-secondary/80",
10
+ destructive: "bg-destructive/10 text-destructive focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:focus-visible:ring-destructive/40 [a]:hover:bg-destructive/20",
11
+ outline: "border-border text-foreground [a]:hover:bg-muted [a]:hover:text-muted-foreground",
12
+ ghost: "hover:bg-muted hover:text-muted-foreground dark:hover:bg-muted/50",
13
+ link: "text-primary underline-offset-4 hover:underline"
14
+ } },
15
+ defaultVariants: { variant: "default" }
16
+ });
17
+ function Badge({ className, variant = "default", render, ...props }) {
18
+ return useRender({
19
+ defaultTagName: "span",
20
+ props: mergeProps({ className: cn(badgeVariants({ variant }), className) }, props),
21
+ render,
22
+ state: {
23
+ slot: "badge",
24
+ variant
25
+ }
26
+ });
27
+ }
28
+ export { Badge, badgeVariants };
@@ -0,0 +1,8 @@
1
+ import { Button as ButtonPrimitive } from "@base-ui/react/button";
2
+ import { type VariantProps } from "class-variance-authority";
3
+ declare const buttonVariants: (props?: ({
4
+ variant?: "default" | "destructive" | "link" | "secondary" | "outline" | "ghost" | null | undefined;
5
+ size?: "default" | "xs" | "sm" | "lg" | "icon" | "icon-xs" | "icon-sm" | "icon-lg" | null | undefined;
6
+ } & import("class-variance-authority/types").ClassProp) | undefined) => string;
7
+ declare function Button({ className, variant, size, ...props }: ButtonPrimitive.Props & VariantProps<typeof buttonVariants>): import("react").JSX.Element;
8
+ export { Button, buttonVariants };
@@ -0,0 +1,43 @@
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
+ // src/components/button.tsx
6
+ var 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
+ export { Button, buttonVariants };
@@ -0,0 +1,11 @@
1
+ import * as React from "react";
2
+ declare function Card({ className, size, ...props }: React.ComponentProps<"div"> & {
3
+ size?: "default" | "sm";
4
+ }): React.JSX.Element;
5
+ declare function CardHeader({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
6
+ declare function CardTitle({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
7
+ declare function CardDescription({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
8
+ declare function CardAction({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
9
+ declare function CardContent({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
10
+ declare function CardFooter({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
11
+ export { Card, CardHeader, CardFooter, CardTitle, CardAction, CardDescription, CardContent, };
@@ -0,0 +1,55 @@
1
+ import "react";
2
+ import { cn } from "cn";
3
+ import { jsx } from "react/jsx-runtime";
4
+ // src/components/card.tsx
5
+ function Card({ className, size = "default", ...props }) {
6
+ return /* @__PURE__ */ jsx("div", {
7
+ "data-slot": "card",
8
+ "data-size": size,
9
+ className: cn("group/card flex flex-col gap-(--card-spacing) overflow-hidden rounded-xl bg-card py-(--card-spacing) text-sm text-card-foreground ring-1 ring-foreground/10 [--card-spacing:--spacing(4)] has-data-[slot=card-footer]:pb-0 has-[>img:first-child]:pt-0 data-[size=sm]:[--card-spacing:--spacing(3)] data-[size=sm]:has-data-[slot=card-footer]:pb-0 *:[img:first-child]:rounded-t-xl *:[img:last-child]:rounded-b-xl", className),
10
+ ...props
11
+ });
12
+ }
13
+ function CardHeader({ className, ...props }) {
14
+ return /* @__PURE__ */ jsx("div", {
15
+ "data-slot": "card-header",
16
+ className: cn("group/card-header @container/card-header grid auto-rows-min items-start gap-1 rounded-t-xl px-(--card-spacing) has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto] [.border-b]:pb-(--card-spacing)", className),
17
+ ...props
18
+ });
19
+ }
20
+ function CardTitle({ className, ...props }) {
21
+ return /* @__PURE__ */ jsx("div", {
22
+ "data-slot": "card-title",
23
+ className: cn("font-heading text-base leading-snug font-medium group-data-[size=sm]/card:text-sm", className),
24
+ ...props
25
+ });
26
+ }
27
+ function CardDescription({ className, ...props }) {
28
+ return /* @__PURE__ */ jsx("div", {
29
+ "data-slot": "card-description",
30
+ className: cn("text-sm text-muted-foreground", className),
31
+ ...props
32
+ });
33
+ }
34
+ function CardAction({ className, ...props }) {
35
+ return /* @__PURE__ */ jsx("div", {
36
+ "data-slot": "card-action",
37
+ className: cn("col-start-2 row-span-2 row-start-1 self-start justify-self-end", className),
38
+ ...props
39
+ });
40
+ }
41
+ function CardContent({ className, ...props }) {
42
+ return /* @__PURE__ */ jsx("div", {
43
+ "data-slot": "card-content",
44
+ className: cn("px-(--card-spacing)", className),
45
+ ...props
46
+ });
47
+ }
48
+ function CardFooter({ className, ...props }) {
49
+ return /* @__PURE__ */ jsx("div", {
50
+ "data-slot": "card-footer",
51
+ className: cn("flex items-center rounded-b-xl border-t bg-muted/50 p-(--card-spacing)", className),
52
+ ...props
53
+ });
54
+ }
55
+ export { Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle };
@@ -0,0 +1,44 @@
1
+ import * as React from "react";
2
+ import * as RechartsPrimitive from "recharts";
3
+ import type { TooltipValueType } from "recharts";
4
+ declare const THEMES: {
5
+ readonly light: "";
6
+ readonly dark: ".dark";
7
+ };
8
+ type TooltipNameType = number | string;
9
+ export type ChartConfig = Record<string, {
10
+ label?: React.ReactNode;
11
+ icon?: React.ComponentType;
12
+ } & ({
13
+ color?: string;
14
+ theme?: never;
15
+ } | {
16
+ color?: never;
17
+ theme: Record<keyof typeof THEMES, string>;
18
+ })>;
19
+ declare function ChartContainer({ id, className, children, config, initialDimension, ...props }: React.ComponentProps<"div"> & {
20
+ config: ChartConfig;
21
+ children: React.ComponentProps<typeof RechartsPrimitive.ResponsiveContainer>["children"];
22
+ initialDimension?: {
23
+ width: number;
24
+ height: number;
25
+ };
26
+ }): React.JSX.Element;
27
+ declare const ChartStyle: ({ id, config }: {
28
+ id: string;
29
+ config: ChartConfig;
30
+ }) => React.JSX.Element | null;
31
+ declare const ChartTooltip: typeof RechartsPrimitive.Tooltip;
32
+ declare function ChartTooltipContent({ active, payload, className, indicator, hideLabel, hideIndicator, label, labelFormatter, labelClassName, formatter, color, nameKey, labelKey, }: React.ComponentProps<typeof RechartsPrimitive.Tooltip> & React.ComponentProps<"div"> & {
33
+ hideLabel?: boolean;
34
+ hideIndicator?: boolean;
35
+ indicator?: "line" | "dot" | "dashed";
36
+ nameKey?: string;
37
+ labelKey?: string;
38
+ } & Omit<RechartsPrimitive.DefaultTooltipContentProps<TooltipValueType, TooltipNameType>, "accessibilityLayer">): React.JSX.Element | null;
39
+ declare const ChartLegend: React.MemoExoticComponent<(outsideProps: RechartsPrimitive.LegendProps) => React.ReactPortal | null>;
40
+ declare function ChartLegendContent({ className, hideIcon, payload, verticalAlign, nameKey, }: React.ComponentProps<"div"> & {
41
+ hideIcon?: boolean;
42
+ nameKey?: string;
43
+ } & RechartsPrimitive.DefaultLegendContentProps): React.JSX.Element | null;
44
+ export { ChartContainer, ChartTooltip, ChartTooltipContent, ChartLegend, ChartLegendContent, ChartStyle, };
@@ -0,0 +1,148 @@
1
+ "use client";
2
+ import * as React from "react";
3
+ import { cn } from "cn";
4
+ import * as RechartsPrimitive from "recharts";
5
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
6
+ // src/components/chart.tsx
7
+ var THEMES = {
8
+ light: "",
9
+ dark: ".dark"
10
+ };
11
+ var INITIAL_DIMENSION = {
12
+ width: 320,
13
+ height: 200
14
+ };
15
+ var ChartContext = React.createContext(null);
16
+ function useChart() {
17
+ const context = React.useContext(ChartContext);
18
+ if (!context) throw new Error("useChart must be used within a <ChartContainer />");
19
+ return context;
20
+ }
21
+ function ChartContainer({ id, className, children, config, initialDimension = INITIAL_DIMENSION, ...props }) {
22
+ const uniqueId = React.useId();
23
+ const chartId = `chart-${id ?? uniqueId.replace(/:/g, "")}`;
24
+ return /* @__PURE__ */ jsx(ChartContext.Provider, {
25
+ value: { config },
26
+ children: /* @__PURE__ */ jsxs("div", {
27
+ "data-slot": "chart",
28
+ "data-chart": chartId,
29
+ className: cn("flex aspect-video justify-center text-xs [&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground [&_.recharts-cartesian-grid_line[stroke='#ccc']]:stroke-border/50 [&_.recharts-curve.recharts-tooltip-cursor]:stroke-border [&_.recharts-dot[stroke='#fff']]:stroke-transparent [&_.recharts-layer]:outline-hidden [&_.recharts-polar-grid_[stroke='#ccc']]:stroke-border [&_.recharts-radial-bar-background-sector]:fill-muted [&_.recharts-rectangle.recharts-tooltip-cursor]:fill-muted [&_.recharts-reference-line_[stroke='#ccc']]:stroke-border [&_.recharts-sector]:outline-hidden [&_.recharts-sector[stroke='#fff']]:stroke-transparent [&_.recharts-surface]:outline-hidden", className),
30
+ ...props,
31
+ children: [/* @__PURE__ */ jsx(ChartStyle, {
32
+ id: chartId,
33
+ config
34
+ }), /* @__PURE__ */ jsx(RechartsPrimitive.ResponsiveContainer, {
35
+ initialDimension,
36
+ children
37
+ })]
38
+ })
39
+ });
40
+ }
41
+ var ChartStyle = ({ id, config }) => {
42
+ const colorConfig = Object.entries(config).filter(([, config]) => config.theme ?? config.color);
43
+ if (!colorConfig.length) return null;
44
+ return /* @__PURE__ */ jsx("style", { dangerouslySetInnerHTML: { __html: Object.entries(THEMES).map(([theme, prefix]) => `
45
+ ${prefix} [data-chart=${id}] {
46
+ ${colorConfig.map(([key, itemConfig]) => {
47
+ const color = itemConfig.theme?.[theme] ?? itemConfig.color;
48
+ return color ? ` --color-${key}: ${color};` : null;
49
+ }).join("\n")}
50
+ }
51
+ `).join("\n") } });
52
+ };
53
+ var ChartTooltip = RechartsPrimitive.Tooltip;
54
+ function ChartTooltipContent({ active, payload, className, indicator = "dot", hideLabel = false, hideIndicator = false, label, labelFormatter, labelClassName, formatter, color, nameKey, labelKey }) {
55
+ const { config } = useChart();
56
+ const tooltipLabel = React.useMemo(() => {
57
+ if (hideLabel || !payload?.length) return null;
58
+ const [item] = payload;
59
+ const key = `${labelKey ?? item?.dataKey ?? item?.name ?? "value"}`;
60
+ const itemConfig = getPayloadConfigFromPayload(config, item, key);
61
+ const value = !labelKey && typeof label === "string" ? config[label]?.label ?? label : itemConfig?.label;
62
+ if (labelFormatter) return /* @__PURE__ */ jsx("div", {
63
+ className: cn("font-medium", labelClassName),
64
+ children: labelFormatter(value, payload)
65
+ });
66
+ if (!value) return null;
67
+ return /* @__PURE__ */ jsx("div", {
68
+ className: cn("font-medium", labelClassName),
69
+ children: value
70
+ });
71
+ }, [
72
+ label,
73
+ labelFormatter,
74
+ payload,
75
+ hideLabel,
76
+ labelClassName,
77
+ config,
78
+ labelKey
79
+ ]);
80
+ if (!active || !payload?.length) return null;
81
+ const nestLabel = payload.length === 1 && indicator !== "dot";
82
+ return /* @__PURE__ */ jsxs("div", {
83
+ className: cn("grid min-w-32 items-start gap-1.5 rounded-lg border border-border/50 bg-background px-2.5 py-1.5 text-xs shadow-xl", className),
84
+ children: [!nestLabel ? tooltipLabel : null, /* @__PURE__ */ jsx("div", {
85
+ className: "grid gap-1.5",
86
+ children: payload.filter((item) => item.type !== "none").map((item, index) => {
87
+ const key = `${nameKey ?? item.name ?? item.dataKey ?? "value"}`;
88
+ const itemConfig = getPayloadConfigFromPayload(config, item, key);
89
+ const indicatorColor = color ?? item.payload?.fill ?? item.color;
90
+ return /* @__PURE__ */ jsx("div", {
91
+ className: cn("flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5 [&>svg]:text-muted-foreground", indicator === "dot" && "items-center"),
92
+ children: formatter && item?.value !== void 0 && item.name ? formatter(item.value, item.name, item, index, item.payload) : /* @__PURE__ */ jsxs(Fragment, { children: [itemConfig?.icon ? /* @__PURE__ */ jsx(itemConfig.icon, {}) : !hideIndicator && /* @__PURE__ */ jsx("div", {
93
+ className: cn("shrink-0 rounded-[2px] border-(--color-border) bg-(--color-bg)", {
94
+ "h-2.5 w-2.5": indicator === "dot",
95
+ "w-1": indicator === "line",
96
+ "w-0 border-[1.5px] border-dashed bg-transparent": indicator === "dashed",
97
+ "my-0.5": nestLabel && indicator === "dashed"
98
+ }),
99
+ style: {
100
+ "--color-bg": indicatorColor,
101
+ "--color-border": indicatorColor
102
+ }
103
+ }), /* @__PURE__ */ jsxs("div", {
104
+ className: cn("flex flex-1 justify-between leading-none", nestLabel ? "items-end" : "items-center"),
105
+ children: [/* @__PURE__ */ jsxs("div", {
106
+ className: "grid gap-1.5",
107
+ children: [nestLabel ? tooltipLabel : null, /* @__PURE__ */ jsx("span", {
108
+ className: "text-muted-foreground",
109
+ children: itemConfig?.label ?? item.name
110
+ })]
111
+ }), item.value != null && /* @__PURE__ */ jsx("span", {
112
+ className: "font-mono font-medium text-foreground tabular-nums",
113
+ children: typeof item.value === "number" ? item.value.toLocaleString() : String(item.value)
114
+ })]
115
+ })] })
116
+ }, index);
117
+ })
118
+ })]
119
+ });
120
+ }
121
+ var ChartLegend = RechartsPrimitive.Legend;
122
+ function ChartLegendContent({ className, hideIcon = false, payload, verticalAlign = "bottom", nameKey }) {
123
+ const { config } = useChart();
124
+ if (!payload?.length) return null;
125
+ return /* @__PURE__ */ jsx("div", {
126
+ className: cn("flex items-center justify-center gap-4", verticalAlign === "top" ? "pb-3" : "pt-3", className),
127
+ children: payload.filter((item) => item.type !== "none").map((item, index) => {
128
+ const key = `${nameKey ?? item.dataKey ?? "value"}`;
129
+ const itemConfig = getPayloadConfigFromPayload(config, item, key);
130
+ return /* @__PURE__ */ jsxs("div", {
131
+ className: cn("flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3 [&>svg]:text-muted-foreground"),
132
+ children: [itemConfig?.icon && !hideIcon ? /* @__PURE__ */ jsx(itemConfig.icon, {}) : /* @__PURE__ */ jsx("div", {
133
+ className: "h-2 w-2 shrink-0 rounded-[2px]",
134
+ style: { backgroundColor: item.color }
135
+ }), itemConfig?.label]
136
+ }, index);
137
+ })
138
+ });
139
+ }
140
+ function getPayloadConfigFromPayload(config, payload, key) {
141
+ if (typeof payload !== "object" || payload === null) return;
142
+ const payloadPayload = "payload" in payload && typeof payload.payload === "object" && payload.payload !== null ? payload.payload : void 0;
143
+ let configLabelKey = key;
144
+ if (key in payload && typeof payload[key] === "string") configLabelKey = payload[key];
145
+ else if (payloadPayload && key in payloadPayload && typeof payloadPayload[key] === "string") configLabelKey = payloadPayload[key];
146
+ return configLabelKey in config ? config[configLabelKey] : config[key];
147
+ }
148
+ export { ChartContainer, ChartLegend, ChartLegendContent, ChartStyle, ChartTooltip, ChartTooltipContent };
@@ -0,0 +1,3 @@
1
+ import { Checkbox as CheckboxPrimitive } from "@base-ui/react/checkbox";
2
+ declare function Checkbox({ className, ...props }: CheckboxPrimitive.Root.Props): import("react").JSX.Element;
3
+ export { Checkbox };
@@ -0,0 +1,18 @@
1
+ import { Checkbox as Checkbox$1 } from "@base-ui/react/checkbox";
2
+ import { cn } from "cn";
3
+ import { CheckIcon } from "lucide-react";
4
+ import { jsx } from "react/jsx-runtime";
5
+ // src/components/checkbox.tsx
6
+ function Checkbox({ className, ...props }) {
7
+ return /* @__PURE__ */ jsx(Checkbox$1.Root, {
8
+ "data-slot": "checkbox",
9
+ className: cn("peer relative flex size-4 shrink-0 items-center justify-center rounded-[4px] border border-input transition-colors outline-none group-has-disabled/field:opacity-50 group-has-[:focus-visible]/field-label:ring-0 group-has-[:focus-visible]/field-label:not-data-checked:border-input after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 aria-invalid:aria-checked:border-primary dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:border-primary data-checked:bg-primary data-checked:text-primary-foreground group-has-[:focus-visible]/field-label:data-checked:border-primary dark:data-checked:bg-primary", className),
10
+ ...props,
11
+ children: /* @__PURE__ */ jsx(Checkbox$1.Indicator, {
12
+ "data-slot": "checkbox-indicator",
13
+ className: "grid place-content-center text-current transition-none [&>svg]:size-3.5",
14
+ children: /* @__PURE__ */ jsx(CheckIcon, {})
15
+ })
16
+ });
17
+ }
18
+ export { Checkbox };
@@ -0,0 +1,18 @@
1
+ import * as React from "react";
2
+ import { Dialog as DialogPrimitive } from "@base-ui/react/dialog";
3
+ /**
4
+ * 模态对话框。
5
+ *
6
+ * 基于 Base UI 的 Dialog:焦点捕获、Esc 关闭、滚动锁定都由 primitive
7
+ * 处理。dashboard 用它编辑文档和显示函数运行结果,内容可能很长,所以
8
+ * `DialogContent` 只限制最大高度并让内部区域自己滚动。
9
+ */
10
+ declare function Dialog(props: DialogPrimitive.Root.Props): React.JSX.Element;
11
+ declare function DialogTrigger(props: DialogPrimitive.Trigger.Props): React.JSX.Element;
12
+ declare function DialogClose(props: DialogPrimitive.Close.Props): React.JSX.Element;
13
+ declare function DialogContent({ className, children, ...props }: DialogPrimitive.Popup.Props): React.JSX.Element;
14
+ declare function DialogHeader({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
15
+ declare function DialogFooter({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
16
+ declare function DialogTitle({ className, ...props }: DialogPrimitive.Title.Props): React.JSX.Element;
17
+ declare function DialogDescription({ className, ...props }: DialogPrimitive.Description.Props): React.JSX.Element;
18
+ export { Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger, };
@@ -0,0 +1,76 @@
1
+ import "react";
2
+ import { Dialog as Dialog$1 } from "@base-ui/react/dialog";
3
+ import { cn } from "cn";
4
+ import { X } from "lucide-react";
5
+ import { jsx, jsxs } from "react/jsx-runtime";
6
+ // src/components/dialog.tsx
7
+ /**
8
+ * 模态对话框。
9
+ *
10
+ * 基于 Base UI 的 Dialog:焦点捕获、Esc 关闭、滚动锁定都由 primitive
11
+ * 处理。dashboard 用它编辑文档和显示函数运行结果,内容可能很长,所以
12
+ * `DialogContent` 只限制最大高度并让内部区域自己滚动。
13
+ */
14
+ function Dialog(props) {
15
+ return /* @__PURE__ */ jsx(Dialog$1.Root, {
16
+ "data-slot": "dialog",
17
+ ...props
18
+ });
19
+ }
20
+ function DialogTrigger(props) {
21
+ return /* @__PURE__ */ jsx(Dialog$1.Trigger, {
22
+ "data-slot": "dialog-trigger",
23
+ ...props
24
+ });
25
+ }
26
+ function DialogClose(props) {
27
+ return /* @__PURE__ */ jsx(Dialog$1.Close, {
28
+ "data-slot": "dialog-close",
29
+ ...props
30
+ });
31
+ }
32
+ function DialogContent({ className, children, ...props }) {
33
+ return /* @__PURE__ */ jsxs(Dialog$1.Portal, { children: [/* @__PURE__ */ jsx(Dialog$1.Backdrop, {
34
+ "data-slot": "dialog-backdrop",
35
+ className: "fixed inset-0 z-50 bg-black/40 backdrop-blur-[2px] data-[starting-style]:opacity-0 data-[ending-style]:opacity-0"
36
+ }), /* @__PURE__ */ jsxs(Dialog$1.Popup, {
37
+ "data-slot": "dialog-content",
38
+ className: cn("fixed top-1/2 left-1/2 z-50 flex max-h-[85vh] w-[min(56rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col gap-4 overflow-hidden rounded-xl border border-border bg-background p-4 shadow-xl outline-none data-[starting-style]:scale-95 data-[starting-style]:opacity-0 data-[ending-style]:scale-95 data-[ending-style]:opacity-0", className),
39
+ ...props,
40
+ children: [children, /* @__PURE__ */ jsx(Dialog$1.Close, {
41
+ "data-slot": "dialog-close-x",
42
+ "aria-label": "Close",
43
+ className: "absolute top-3 right-3 rounded-md p-1 text-muted-foreground hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring",
44
+ children: /* @__PURE__ */ jsx(X, { className: "size-4" })
45
+ })]
46
+ })] });
47
+ }
48
+ function DialogHeader({ className, ...props }) {
49
+ return /* @__PURE__ */ jsx("div", {
50
+ "data-slot": "dialog-header",
51
+ className: cn("flex flex-col gap-1 pr-8", className),
52
+ ...props
53
+ });
54
+ }
55
+ function DialogFooter({ className, ...props }) {
56
+ return /* @__PURE__ */ jsx("div", {
57
+ "data-slot": "dialog-footer",
58
+ className: cn("flex items-center justify-end gap-2", className),
59
+ ...props
60
+ });
61
+ }
62
+ function DialogTitle({ className, ...props }) {
63
+ return /* @__PURE__ */ jsx(Dialog$1.Title, {
64
+ "data-slot": "dialog-title",
65
+ className: cn("text-base font-semibold", className),
66
+ ...props
67
+ });
68
+ }
69
+ function DialogDescription({ className, ...props }) {
70
+ return /* @__PURE__ */ jsx(Dialog$1.Description, {
71
+ "data-slot": "dialog-description",
72
+ className: cn("text-sm text-muted-foreground", className),
73
+ ...props
74
+ });
75
+ }
76
+ export { Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger };
@@ -0,0 +1,3 @@
1
+ import * as React from "react";
2
+ declare function Input({ className, type, ...props }: React.ComponentProps<"input">): React.JSX.Element;
3
+ export { Input };
@@ -0,0 +1,14 @@
1
+ import "react";
2
+ import { Input as Input$1 } from "@base-ui/react/input";
3
+ import { cn } from "cn";
4
+ import { jsx } from "react/jsx-runtime";
5
+ // src/components/input.tsx
6
+ function Input({ className, type, ...props }) {
7
+ return /* @__PURE__ */ jsx(Input$1, {
8
+ type,
9
+ "data-slot": "input",
10
+ className: cn("h-8 w-full min-w-0 rounded-lg border border-input bg-transparent px-2.5 py-1 text-base transition-colors outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40", className),
11
+ ...props
12
+ });
13
+ }
14
+ export { Input };
@@ -0,0 +1,10 @@
1
+ import * as React from "react";
2
+ /**
3
+ * 表单标签。
4
+ *
5
+ * 使用原生 `<label>` 而不是 Base UI 的 Field.Label:dashboard 里的表单
6
+ * 没有复杂的校验状态联动,原生元素配合 `htmlFor` 就能获得完整的点击与
7
+ * 屏幕阅读器行为,也更方便在 Markdown / 表格里复用。
8
+ */
9
+ declare function Label({ className, ...props }: React.ComponentProps<"label">): React.JSX.Element;
10
+ export { Label };