@allbluecn/ui 0.2.0

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 (49) hide show
  1. package/package.json +85 -0
  2. package/src/ai-command-button.tsx +36 -0
  3. package/src/ai-stream-text.tsx +37 -0
  4. package/src/alert-dialog.tsx +216 -0
  5. package/src/animated-theme-toggler.tsx +272 -0
  6. package/src/auth-client.ts +108 -0
  7. package/src/auth-layout.tsx +66 -0
  8. package/src/avatar.tsx +129 -0
  9. package/src/badge.tsx +66 -0
  10. package/src/button.tsx +84 -0
  11. package/src/card.tsx +120 -0
  12. package/src/checkbox.tsx +50 -0
  13. package/src/context-menu.tsx +280 -0
  14. package/src/dialog.tsx +183 -0
  15. package/src/dropdown-menu.tsx +286 -0
  16. package/src/empty.tsx +121 -0
  17. package/src/grid-pattern.tsx +87 -0
  18. package/src/icon-packs/index.ts +27 -0
  19. package/src/icon-packs/knowledge.ts +55 -0
  20. package/src/icon-packs/prd.ts +63 -0
  21. package/src/icon-packs/project.ts +59 -0
  22. package/src/icon-picker.tsx +68 -0
  23. package/src/index.ts +23 -0
  24. package/src/input.tsx +36 -0
  25. package/src/item.tsx +213 -0
  26. package/src/kbd.tsx +33 -0
  27. package/src/label.tsx +39 -0
  28. package/src/layout-panel-top.tsx +160 -0
  29. package/src/name-confirm-dialog.tsx +153 -0
  30. package/src/nav-float-button.tsx +301 -0
  31. package/src/notion-avatar.tsx +126 -0
  32. package/src/placeholder-page.tsx +42 -0
  33. package/src/popover.tsx +106 -0
  34. package/src/reference-inline.tsx +53 -0
  35. package/src/reference-search.tsx +52 -0
  36. package/src/resizable.tsx +67 -0
  37. package/src/select.tsx +207 -0
  38. package/src/separator.tsx +45 -0
  39. package/src/sheet.tsx +164 -0
  40. package/src/sidebar.tsx +708 -0
  41. package/src/skeleton.tsx +30 -0
  42. package/src/sonner.tsx +37 -0
  43. package/src/switch.tsx +48 -0
  44. package/src/textarea.tsx +35 -0
  45. package/src/timezone-provider.tsx +55 -0
  46. package/src/tooltip.tsx +72 -0
  47. package/src/use-mobile.ts +36 -0
  48. package/src/user-avatar.tsx +79 -0
  49. package/src/utils.ts +6 -0
@@ -0,0 +1,108 @@
1
+ // SPDX-License-Identifier: AGPL-3.0-or-later
2
+ // AllBlue - 理想之海
3
+ // Copyright (C) 2026 AllBlue Contributors
4
+ //
5
+ // This program is free software: you can redistribute it and/or modify
6
+ // it under the terms of the GNU Affero General Public License as published by
7
+ // the Free Software Foundation, either version 3 of the License, or
8
+ // (at your option) any later version.
9
+ //
10
+ // This program is distributed in the hope that it will be useful,
11
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ // GNU Affero General Public License for more details.
14
+ //
15
+ // You should have received a copy of the GNU Affero General Public License
16
+ // along with this program. If not, see <https://www.gnu.org/licenses/>.
17
+
18
+ import { useQuery } from '@tanstack/react-query'
19
+
20
+ export interface Session {
21
+ user: {
22
+ id: string
23
+ email: string
24
+ name: string
25
+ role: 'USER' | 'ADMIN' | 'SUPER_ADMIN'
26
+ image?: string | null
27
+ aiProvider?: string | null
28
+ aiModel?: string | null
29
+ hasAiKey?: boolean | null
30
+ timezone?: string | null
31
+ }
32
+ expires: string
33
+ }
34
+
35
+ export function useSession() {
36
+ return useQuery({
37
+ queryKey: ['session'],
38
+ queryFn: async () => {
39
+ const res = await fetch('/api/auth/session', { credentials: 'include' })
40
+ if (!res.ok) return null
41
+ const data = await res.json()
42
+ return data?.user ? (data as Session) : null
43
+ },
44
+ staleTime: 0,
45
+ refetchOnMount: true,
46
+ })
47
+ }
48
+
49
+ export async function signIn(provider: string, options?: { redirectTo?: string; email?: string; password?: string; remember?: boolean }) {
50
+ if (provider !== 'credentials') {
51
+ const csrfRes = await fetch('/api/auth/csrf', { credentials: 'include' })
52
+ const { csrfToken } = await csrfRes.json()
53
+ const redirectPath = options?.redirectTo ?? '/dashboard'
54
+ const callbackUrl = `${window.location.origin}${redirectPath}`
55
+ const form = document.createElement('form')
56
+ form.method = 'POST'
57
+ form.action = `/api/auth/signin/${provider}`
58
+ form.style.display = 'none'
59
+ const csrfInput = document.createElement('input')
60
+ csrfInput.name = 'csrfToken'
61
+ csrfInput.value = csrfToken
62
+ form.appendChild(csrfInput)
63
+ const cbInput = document.createElement('input')
64
+ cbInput.name = 'callbackUrl'
65
+ cbInput.value = callbackUrl
66
+ form.appendChild(cbInput)
67
+ document.body.appendChild(form)
68
+ form.submit()
69
+ return
70
+ }
71
+
72
+ const csrfRes = await fetch('/api/auth/csrf', { credentials: 'include' })
73
+ const { csrfToken } = await csrfRes.json()
74
+ const callbackUrl = options?.redirectTo ?? '/'
75
+ const form = document.createElement('form')
76
+ form.method = 'POST'
77
+ form.action = '/api/auth/callback/credentials'
78
+ form.style.display = 'none'
79
+ const fields = [
80
+ { name: 'email', value: options?.email ?? '' },
81
+ { name: 'password', value: options?.password ?? '' },
82
+ { name: 'remember', value: String(options?.remember ?? false) },
83
+ { name: 'callbackUrl', value: callbackUrl },
84
+ { name: 'csrfToken', value: csrfToken },
85
+ ]
86
+ for (const field of fields) {
87
+ const input = document.createElement('input')
88
+ input.type = 'hidden'
89
+ input.name = field.name
90
+ input.value = field.value
91
+ form.appendChild(input)
92
+ }
93
+ document.body.appendChild(form)
94
+ form.submit()
95
+ return
96
+ }
97
+
98
+ export async function signOut() {
99
+ const csrfRes = await fetch('/api/auth/csrf', { credentials: 'include' })
100
+ const { csrfToken } = await csrfRes.json()
101
+ await fetch('/api/auth/signout', {
102
+ method: 'POST',
103
+ headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
104
+ body: new URLSearchParams({ csrfToken }).toString(),
105
+ credentials: 'include',
106
+ })
107
+ return { success: true }
108
+ }
@@ -0,0 +1,66 @@
1
+ // SPDX-License-Identifier: AGPL-3.0-or-later
2
+ // AllBlue - 理想之海
3
+ // Copyright (C) 2026 AllBlue Contributors
4
+ //
5
+ // This program is free software: you can redistribute it and/or modify
6
+ // it under the terms of the GNU Affero General Public License as published by
7
+ // the Free Software Foundation, either version 3 of the License, or
8
+ // (at your option) any later version.
9
+ //
10
+ // This program is distributed in the hope that it will be useful,
11
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ // GNU Affero General Public License for more details.
14
+ //
15
+ // You should have received a copy of the GNU Affero General Public License
16
+ // along with this program. If not, see <https://www.gnu.org/licenses/>.
17
+
18
+ import type { ReactNode } from 'react'
19
+ import { AnimatedThemeToggler } from './animated-theme-toggler'
20
+
21
+ interface AuthLayoutProps {
22
+ children: ReactNode
23
+ }
24
+
25
+ export function AuthLayout({ children }: AuthLayoutProps) {
26
+ const left = findChild(children, AuthLayoutLeft)
27
+ const right = findChild(children, AuthLayoutRight)
28
+
29
+ return (
30
+ <div className="flex min-h-screen">
31
+ <div className="relative flex flex-1 items-center justify-center p-6">
32
+ <div className="absolute" style={{ top: '1.5rem', right: '1.5rem' }}>
33
+ <AnimatedThemeToggler className="flex size-6 items-center justify-center rounded-full hover:bg-accent" />
34
+ </div>
35
+ <div className="w-full max-w-sm space-y-6">
36
+ {left}
37
+ </div>
38
+ </div>
39
+ {right && (
40
+ <div className="hidden lg:flex flex-1 bg-linear-to-br from-primary/10 via-primary/5 to-background items-center justify-center p-12">
41
+ <div className="w-full max-w-md text-center space-y-8">
42
+ {right}
43
+ </div>
44
+ </div>
45
+ )}
46
+ </div>
47
+ )
48
+ }
49
+
50
+ export function AuthLayoutLeft({ children }: { children: ReactNode }) {
51
+ return <>{children}</>
52
+ }
53
+
54
+ export function AuthLayoutRight({ children }: { children: ReactNode }) {
55
+ return <>{children}</>
56
+ }
57
+
58
+ function findChild(children: ReactNode, type: any) {
59
+ const arr = Array.isArray(children) ? children : [children]
60
+ for (const child of arr) {
61
+ if ((child as any)?.type === type) {
62
+ return (child as any).props.children
63
+ }
64
+ }
65
+ return null
66
+ }
package/src/avatar.tsx ADDED
@@ -0,0 +1,129 @@
1
+ // SPDX-License-Identifier: AGPL-3.0-or-later
2
+ // AllBlue - 理想之海
3
+ // Copyright (C) 2026 AllBlue Contributors
4
+ //
5
+ // This program is free software: you can redistribute it and/or modify
6
+ // it under the terms of the GNU Affero General Public License as published by
7
+ // the Free Software Foundation, either version 3 of the License, or
8
+ // (at your option) any later version.
9
+ //
10
+ // This program is distributed in the hope that it will be useful,
11
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ // GNU Affero General Public License for more details.
14
+ //
15
+ // You should have received a copy of the GNU Affero General Public License
16
+ // along with this program. If not, see <https://www.gnu.org/licenses/>.
17
+
18
+ "use client"
19
+
20
+ import * as React from "react"
21
+ import { Avatar as AvatarPrimitive } from "radix-ui"
22
+
23
+ import { cn } from "./utils"
24
+
25
+ function Avatar({
26
+ className,
27
+ size = "default",
28
+ ...props
29
+ }: React.ComponentProps<typeof AvatarPrimitive.Root> & {
30
+ size?: "default" | "sm" | "lg"
31
+ }) {
32
+ return (
33
+ <AvatarPrimitive.Root
34
+ data-slot="avatar"
35
+ data-size={size}
36
+ className={cn(
37
+ "group/avatar relative flex size-8 shrink-0 rounded-full select-none after:absolute after:inset-0 after:rounded-full after:border after:border-border after:mix-blend-darken data-[size=lg]:size-10 data-[size=sm]:size-6 dark:after:mix-blend-lighten",
38
+ className
39
+ )}
40
+ {...props}
41
+ />
42
+ )
43
+ }
44
+
45
+ function AvatarImage({
46
+ className,
47
+ ...props
48
+ }: React.ComponentProps<typeof AvatarPrimitive.Image>) {
49
+ return (
50
+ <AvatarPrimitive.Image
51
+ data-slot="avatar-image"
52
+ className={cn(
53
+ "aspect-square size-full rounded-full object-cover",
54
+ className
55
+ )}
56
+ {...props}
57
+ />
58
+ )
59
+ }
60
+
61
+ function AvatarFallback({
62
+ className,
63
+ ...props
64
+ }: React.ComponentProps<typeof AvatarPrimitive.Fallback>) {
65
+ return (
66
+ <AvatarPrimitive.Fallback
67
+ data-slot="avatar-fallback"
68
+ className={cn(
69
+ "flex size-full items-center justify-center rounded-full bg-muted text-sm text-muted-foreground group-data-[size=sm]/avatar:text-xs",
70
+ className
71
+ )}
72
+ {...props}
73
+ />
74
+ )
75
+ }
76
+
77
+ function AvatarBadge({ className, ...props }: React.ComponentProps<"span">) {
78
+ return (
79
+ <span
80
+ data-slot="avatar-badge"
81
+ className={cn(
82
+ "absolute right-0 bottom-0 z-10 inline-flex items-center justify-center rounded-full bg-primary text-primary-foreground bg-blend-color ring-2 ring-background select-none",
83
+ "group-data-[size=sm]/avatar:size-2 group-data-[size=sm]/avatar:[&>svg]:hidden",
84
+ "group-data-[size=default]/avatar:size-2.5 group-data-[size=default]/avatar:[&>svg]:size-2",
85
+ "group-data-[size=lg]/avatar:size-3 group-data-[size=lg]/avatar:[&>svg]:size-2",
86
+ className
87
+ )}
88
+ {...props}
89
+ />
90
+ )
91
+ }
92
+
93
+ function AvatarGroup({ className, ...props }: React.ComponentProps<"div">) {
94
+ return (
95
+ <div
96
+ data-slot="avatar-group"
97
+ className={cn(
98
+ "group/avatar-group flex -space-x-2 *:data-[slot=avatar]:ring-2 *:data-[slot=avatar]:ring-background",
99
+ className
100
+ )}
101
+ {...props}
102
+ />
103
+ )
104
+ }
105
+
106
+ function AvatarGroupCount({
107
+ className,
108
+ ...props
109
+ }: React.ComponentProps<"div">) {
110
+ return (
111
+ <div
112
+ data-slot="avatar-group-count"
113
+ className={cn(
114
+ "relative flex size-8 shrink-0 items-center justify-center rounded-full bg-muted text-sm text-muted-foreground ring-2 ring-background group-has-data-[size=lg]/avatar-group:size-10 group-has-data-[size=sm]/avatar-group:size-6 [&>svg]:size-4 group-has-data-[size=lg]/avatar-group:[&>svg]:size-5 group-has-data-[size=sm]/avatar-group:[&>svg]:size-3",
115
+ className
116
+ )}
117
+ {...props}
118
+ />
119
+ )
120
+ }
121
+
122
+ export {
123
+ Avatar,
124
+ AvatarImage,
125
+ AvatarFallback,
126
+ AvatarGroup,
127
+ AvatarGroupCount,
128
+ AvatarBadge,
129
+ }
package/src/badge.tsx ADDED
@@ -0,0 +1,66 @@
1
+ // SPDX-License-Identifier: AGPL-3.0-or-later
2
+ // AllBlue - 理想之海
3
+ // Copyright (C) 2026 AllBlue Contributors
4
+ //
5
+ // This program is free software: you can redistribute it and/or modify
6
+ // it under the terms of the GNU Affero General Public License as published by
7
+ // the Free Software Foundation, either version 3 of the License, or
8
+ // (at your option) any later version.
9
+ //
10
+ // This program is distributed in the hope that it will be useful,
11
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ // GNU Affero General Public License for more details.
14
+ //
15
+ // You should have received a copy of the GNU Affero General Public License
16
+ // along with this program. If not, see <https://www.gnu.org/licenses/>.
17
+
18
+ import * as React from "react"
19
+ import { cva, type VariantProps } from "class-variance-authority"
20
+ import { Slot } from "radix-ui"
21
+
22
+ import { cn } from "./utils"
23
+
24
+ const badgeVariants = cva(
25
+ "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!",
26
+ {
27
+ variants: {
28
+ variant: {
29
+ default: "bg-primary text-primary-foreground [a]:hover:bg-primary/80",
30
+ secondary:
31
+ "bg-secondary text-secondary-foreground [a]:hover:bg-secondary/80",
32
+ destructive:
33
+ "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",
34
+ outline:
35
+ "border-border text-foreground [a]:hover:bg-muted [a]:hover:text-muted-foreground",
36
+ ghost:
37
+ "hover:bg-muted hover:text-muted-foreground dark:hover:bg-muted/50",
38
+ link: "text-primary underline-offset-4 hover:underline",
39
+ },
40
+ },
41
+ defaultVariants: {
42
+ variant: "default",
43
+ },
44
+ }
45
+ )
46
+
47
+ function Badge({
48
+ className,
49
+ variant = "default",
50
+ asChild = false,
51
+ ...props
52
+ }: React.ComponentProps<"span"> &
53
+ VariantProps<typeof badgeVariants> & { asChild?: boolean }) {
54
+ const Comp = asChild ? Slot.Root : "span"
55
+
56
+ return (
57
+ <Comp
58
+ data-slot="badge"
59
+ data-variant={variant}
60
+ className={cn(badgeVariants({ variant }), className)}
61
+ {...props}
62
+ />
63
+ )
64
+ }
65
+
66
+ export { Badge, badgeVariants }
package/src/button.tsx ADDED
@@ -0,0 +1,84 @@
1
+ // SPDX-License-Identifier: AGPL-3.0-or-later
2
+ // AllBlue - 理想之海
3
+ // Copyright (C) 2026 AllBlue Contributors
4
+ //
5
+ // This program is free software: you can redistribute it and/or modify
6
+ // it under the terms of the GNU Affero General Public License as published by
7
+ // the Free Software Foundation, either version 3 of the License, or
8
+ // (at your option) any later version.
9
+ //
10
+ // This program is distributed in the hope that it will be useful,
11
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ // GNU Affero General Public License for more details.
14
+ //
15
+ // You should have received a copy of the GNU Affero General Public License
16
+ // along with this program. If not, see <https://www.gnu.org/licenses/>.
17
+
18
+ import * as React from "react"
19
+ import { cva, type VariantProps } from "class-variance-authority"
20
+ import { Slot } from "radix-ui"
21
+
22
+ import { cn } from "./utils"
23
+
24
+ const buttonVariants = cva(
25
+ "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",
26
+ {
27
+ variants: {
28
+ variant: {
29
+ default: "bg-primary text-primary-foreground hover:bg-primary/80",
30
+ outline:
31
+ "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",
32
+ secondary:
33
+ "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",
34
+ ghost:
35
+ "hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50",
36
+ destructive:
37
+ "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",
38
+ link: "text-primary underline-offset-4 hover:underline",
39
+ },
40
+ size: {
41
+ default:
42
+ "h-8 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
43
+ 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",
44
+ 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",
45
+ lg: "h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
46
+ icon: "size-8",
47
+ "icon-xs":
48
+ "size-6 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-lg [&_svg:not([class*='size-'])]:size-3",
49
+ "icon-sm":
50
+ "size-7 rounded-[min(var(--radius-md),12px)] in-data-[slot=button-group]:rounded-lg",
51
+ "icon-lg": "size-9",
52
+ },
53
+ },
54
+ defaultVariants: {
55
+ variant: "default",
56
+ size: "default",
57
+ },
58
+ }
59
+ )
60
+
61
+ function Button({
62
+ className,
63
+ variant = "default",
64
+ size = "default",
65
+ asChild = false,
66
+ ...props
67
+ }: React.ComponentProps<"button"> &
68
+ VariantProps<typeof buttonVariants> & {
69
+ asChild?: boolean
70
+ }) {
71
+ const Comp = asChild ? Slot.Root : "button"
72
+
73
+ return (
74
+ <Comp
75
+ data-slot="button"
76
+ data-variant={variant}
77
+ data-size={size}
78
+ className={cn(buttonVariants({ variant, size, className }))}
79
+ {...props}
80
+ />
81
+ )
82
+ }
83
+
84
+ export { Button, buttonVariants }
package/src/card.tsx ADDED
@@ -0,0 +1,120 @@
1
+ // SPDX-License-Identifier: AGPL-3.0-or-later
2
+ // AllBlue - 理想之海
3
+ // Copyright (C) 2026 AllBlue Contributors
4
+ //
5
+ // This program is free software: you can redistribute it and/or modify
6
+ // it under the terms of the GNU Affero General Public License as published by
7
+ // the Free Software Foundation, either version 3 of the License, or
8
+ // (at your option) any later version.
9
+ //
10
+ // This program is distributed in the hope that it will be useful,
11
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ // GNU Affero General Public License for more details.
14
+ //
15
+ // You should have received a copy of the GNU Affero General Public License
16
+ // along with this program. If not, see <https://www.gnu.org/licenses/>.
17
+
18
+ import * as React from "react"
19
+
20
+ import { cn } from "./utils"
21
+
22
+ function Card({
23
+ className,
24
+ size = "default",
25
+ ...props
26
+ }: React.ComponentProps<"div"> & { size?: "default" | "sm" }) {
27
+ return (
28
+ <div
29
+ data-slot="card"
30
+ data-size={size}
31
+ className={cn(
32
+ "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",
33
+ className
34
+ )}
35
+ {...props}
36
+ />
37
+ )
38
+ }
39
+
40
+ function CardHeader({ className, ...props }: React.ComponentProps<"div">) {
41
+ return (
42
+ <div
43
+ data-slot="card-header"
44
+ className={cn(
45
+ "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)",
46
+ className
47
+ )}
48
+ {...props}
49
+ />
50
+ )
51
+ }
52
+
53
+ function CardTitle({ className, ...props }: React.ComponentProps<"div">) {
54
+ return (
55
+ <div
56
+ data-slot="card-title"
57
+ className={cn(
58
+ "font-heading text-base leading-snug font-medium group-data-[size=sm]/card:text-sm",
59
+ className
60
+ )}
61
+ {...props}
62
+ />
63
+ )
64
+ }
65
+
66
+ function CardDescription({ className, ...props }: React.ComponentProps<"div">) {
67
+ return (
68
+ <div
69
+ data-slot="card-description"
70
+ className={cn("text-sm text-muted-foreground", className)}
71
+ {...props}
72
+ />
73
+ )
74
+ }
75
+
76
+ function CardAction({ className, ...props }: React.ComponentProps<"div">) {
77
+ return (
78
+ <div
79
+ data-slot="card-action"
80
+ className={cn(
81
+ "col-start-2 row-span-2 row-start-1 self-start justify-self-end",
82
+ className
83
+ )}
84
+ {...props}
85
+ />
86
+ )
87
+ }
88
+
89
+ function CardContent({ className, ...props }: React.ComponentProps<"div">) {
90
+ return (
91
+ <div
92
+ data-slot="card-content"
93
+ className={cn("px-(--card-spacing)", className)}
94
+ {...props}
95
+ />
96
+ )
97
+ }
98
+
99
+ function CardFooter({ className, ...props }: React.ComponentProps<"div">) {
100
+ return (
101
+ <div
102
+ data-slot="card-footer"
103
+ className={cn(
104
+ "flex items-center rounded-b-xl border-t bg-muted/50 p-(--card-spacing)",
105
+ className
106
+ )}
107
+ {...props}
108
+ />
109
+ )
110
+ }
111
+
112
+ export {
113
+ Card,
114
+ CardHeader,
115
+ CardFooter,
116
+ CardTitle,
117
+ CardAction,
118
+ CardDescription,
119
+ CardContent,
120
+ }
@@ -0,0 +1,50 @@
1
+ // SPDX-License-Identifier: AGPL-3.0-or-later
2
+ // AllBlue - 理想之海
3
+ // Copyright (C) 2026 AllBlue Contributors
4
+ //
5
+ // This program is free software: you can redistribute it and/or modify
6
+ // it under the terms of the GNU Affero General Public License as published by
7
+ // the Free Software Foundation, either version 3 of the License, or
8
+ // (at your option) any later version.
9
+ //
10
+ // This program is distributed in the hope that it will be useful,
11
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ // GNU Affero General Public License for more details.
14
+ //
15
+ // You should have received a copy of the GNU Affero General Public License
16
+ // along with this program. If not, see <https://www.gnu.org/licenses/>.
17
+
18
+ import * as React from "react"
19
+ import { Checkbox as CheckboxPrimitive } from "radix-ui"
20
+
21
+ import { cn } from "./utils"
22
+ import { CheckIcon, MinusIcon } from "lucide-react"
23
+
24
+ function Checkbox({
25
+ className,
26
+ checked,
27
+ ...props
28
+ }: React.ComponentProps<typeof CheckboxPrimitive.Root>) {
29
+ const indeterminate = checked === "indeterminate"
30
+ return (
31
+ <CheckboxPrimitive.Root
32
+ data-slot="checkbox"
33
+ className={cn(
34
+ "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 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:border-primary/50 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-[state=checked]:border-primary data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground data-[state=indeterminate]:border-primary data-[state=indeterminate]:bg-primary data-[state=indeterminate]:text-primary-foreground",
35
+ className
36
+ )}
37
+ checked={checked}
38
+ {...props}
39
+ >
40
+ <CheckboxPrimitive.Indicator
41
+ data-slot="checkbox-indicator"
42
+ className="grid place-content-center text-current transition-none [&>svg]:size-3.5"
43
+ >
44
+ {indeterminate ? <MinusIcon /> : <CheckIcon />}
45
+ </CheckboxPrimitive.Indicator>
46
+ </CheckboxPrimitive.Root>
47
+ )
48
+ }
49
+
50
+ export { Checkbox }