@allbluecn/ui 0.3.13 → 0.4.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 (146) hide show
  1. package/dist/ai-command-button.d.ts +10 -0
  2. package/dist/ai-command-button.js +12 -0
  3. package/dist/ai-stream-text.d.ts +9 -0
  4. package/dist/ai-stream-text.js +12 -0
  5. package/dist/alert-dialog.d.ts +20 -0
  6. package/dist/alert-dialog.js +101 -0
  7. package/dist/animated-theme-toggler.d.ts +11 -0
  8. package/dist/animated-theme-toggler.js +169 -0
  9. package/dist/auth-client.d.ts +27 -0
  10. package/dist/auth-client.js +86 -0
  11. package/dist/auth-layout.d.ts +14 -0
  12. package/dist/auth-layout.js +43 -0
  13. package/dist/avatar.d.ts +13 -0
  14. package/dist/avatar.js +51 -0
  15. package/dist/badge.d.ts +11 -0
  16. package/dist/badge.js +28 -0
  17. package/dist/button.d.ts +12 -0
  18. package/dist/button.js +48 -0
  19. package/dist/card.d.ts +13 -0
  20. package/dist/card.js +56 -0
  21. package/dist/checkbox.d.ts +6 -0
  22. package/dist/checkbox.js +22 -0
  23. package/dist/context-menu.d.ts +33 -0
  24. package/dist/context-menu.js +125 -0
  25. package/dist/dialog.d.ts +19 -0
  26. package/dist/dialog.js +95 -0
  27. package/dist/dropdown-menu.d.ts +31 -0
  28. package/dist/dropdown-menu.js +128 -0
  29. package/dist/empty.d.ts +13 -0
  30. package/dist/empty.js +59 -0
  31. package/dist/grid-pattern.d.ts +14 -0
  32. package/dist/grid-pattern.js +47 -0
  33. package/dist/icon-packs/index.d.ts +2 -0
  34. package/dist/icon-packs/index.js +4 -0
  35. package/dist/icon-packs/knowledge.d.ts +2 -0
  36. package/dist/icon-packs/knowledge.js +70 -0
  37. package/dist/icon-packs/prd.d.ts +2 -0
  38. package/dist/icon-packs/prd.js +86 -0
  39. package/dist/icon-packs/project.d.ts +2 -0
  40. package/dist/icon-packs/project.js +74 -0
  41. package/dist/icon-picker.d.ts +11 -0
  42. package/dist/icon-picker.js +39 -0
  43. package/dist/index-CQsbeClc.d.ts +17 -0
  44. package/dist/index.d.ts +7 -0
  45. package/dist/index.js +7 -0
  46. package/dist/input.d.ts +5 -0
  47. package/dist/input.js +14 -0
  48. package/dist/item.d.ts +25 -0
  49. package/dist/item.js +118 -0
  50. package/dist/kbd.d.ts +4 -0
  51. package/dist/kbd.js +12 -0
  52. package/dist/label.d.ts +6 -0
  53. package/dist/label.js +14 -0
  54. package/dist/layout-panel-top.d.ts +12 -0
  55. package/dist/layout-panel-top.js +127 -0
  56. package/dist/name-confirm-dialog.d.ts +15 -0
  57. package/dist/name-confirm-dialog.js +105 -0
  58. package/dist/nav-float-button.d.ts +12 -0
  59. package/dist/nav-float-button.js +249 -0
  60. package/dist/notion-avatar.d.ts +13 -0
  61. package/dist/notion-avatar.js +83 -0
  62. package/dist/placeholder-page.d.ts +10 -0
  63. package/dist/placeholder-page.js +28 -0
  64. package/dist/popover.d.ts +12 -0
  65. package/dist/popover.js +56 -0
  66. package/dist/reference-inline.d.ts +10 -0
  67. package/dist/reference-inline.js +35 -0
  68. package/dist/reference-search.d.ts +12 -0
  69. package/dist/reference-search.js +26 -0
  70. package/dist/resizable.d.ts +9 -0
  71. package/dist/resizable.js +28 -0
  72. package/dist/select.d.ts +17 -0
  73. package/dist/select.js +99 -0
  74. package/dist/separator.d.ts +6 -0
  75. package/dist/separator.js +17 -0
  76. package/dist/sheet.d.ts +16 -0
  77. package/dist/sheet.js +90 -0
  78. package/dist/sidebar.d.ts +71 -0
  79. package/dist/sidebar.js +369 -0
  80. package/dist/skeleton.d.ts +4 -0
  81. package/dist/skeleton.js +12 -0
  82. package/dist/sonner.d.ts +5 -0
  83. package/dist/sonner.js +19 -0
  84. package/dist/switch.d.ts +8 -0
  85. package/dist/switch.js +19 -0
  86. package/dist/textarea.d.ts +5 -0
  87. package/dist/textarea.js +13 -0
  88. package/dist/timezone-provider.d.ts +18 -0
  89. package/dist/timezone-provider.js +29 -0
  90. package/dist/tooltip.d.ts +9 -0
  91. package/dist/tooltip.js +35 -0
  92. package/dist/use-mobile.d.ts +4 -0
  93. package/dist/use-mobile.js +18 -0
  94. package/dist/user-avatar.d.ts +14 -0
  95. package/dist/user-avatar.js +34 -0
  96. package/dist/utils.d.ts +5 -0
  97. package/dist/utils.js +8 -0
  98. package/package.json +178 -49
  99. package/src/ai-command-button.tsx +0 -36
  100. package/src/ai-stream-text.tsx +0 -37
  101. package/src/alert-dialog.tsx +0 -216
  102. package/src/animated-theme-toggler.tsx +0 -272
  103. package/src/auth-client.ts +0 -108
  104. package/src/auth-layout.tsx +0 -66
  105. package/src/avatar.tsx +0 -129
  106. package/src/badge.tsx +0 -66
  107. package/src/button.tsx +0 -84
  108. package/src/card.tsx +0 -120
  109. package/src/checkbox.tsx +0 -50
  110. package/src/context-menu.tsx +0 -280
  111. package/src/dialog.tsx +0 -183
  112. package/src/dropdown-menu.tsx +0 -286
  113. package/src/empty.tsx +0 -121
  114. package/src/grid-pattern.tsx +0 -87
  115. package/src/icon-packs/index.ts +0 -27
  116. package/src/icon-packs/knowledge.ts +0 -55
  117. package/src/icon-packs/prd.ts +0 -63
  118. package/src/icon-packs/project.ts +0 -59
  119. package/src/icon-picker.tsx +0 -68
  120. package/src/index.ts +0 -23
  121. package/src/input.tsx +0 -36
  122. package/src/item.tsx +0 -213
  123. package/src/kbd.tsx +0 -33
  124. package/src/label.tsx +0 -39
  125. package/src/layout-panel-top.tsx +0 -160
  126. package/src/name-confirm-dialog.tsx +0 -153
  127. package/src/nav-float-button.tsx +0 -301
  128. package/src/notion-avatar.tsx +0 -126
  129. package/src/placeholder-page.tsx +0 -42
  130. package/src/popover.tsx +0 -106
  131. package/src/reference-inline.tsx +0 -53
  132. package/src/reference-search.tsx +0 -52
  133. package/src/resizable.tsx +0 -67
  134. package/src/select.tsx +0 -207
  135. package/src/separator.tsx +0 -45
  136. package/src/sheet.tsx +0 -164
  137. package/src/sidebar.tsx +0 -708
  138. package/src/skeleton.tsx +0 -30
  139. package/src/sonner.tsx +0 -37
  140. package/src/switch.tsx +0 -48
  141. package/src/textarea.tsx +0 -35
  142. package/src/timezone-provider.tsx +0 -55
  143. package/src/tooltip.tsx +0 -72
  144. package/src/use-mobile.ts +0 -36
  145. package/src/user-avatar.tsx +0 -79
  146. package/src/utils.ts +0 -6
@@ -1,272 +0,0 @@
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
-
19
- import { useCallback, useEffect, useRef, useState } from "react"
20
- import { Moon, Sun } from "lucide-react"
21
- import { flushSync } from "react-dom"
22
- import { useTheme } from "next-themes"
23
-
24
- import { cn } from "./utils"
25
-
26
- export type TransitionVariant =
27
- | "circle"
28
- | "square"
29
- | "triangle"
30
- | "diamond"
31
- | "hexagon"
32
- | "rectangle"
33
- | "star"
34
-
35
- interface AnimatedThemeTogglerProps extends React.ComponentPropsWithoutRef<"button"> {
36
- duration?: number
37
- variant?: TransitionVariant
38
- /** When true, the transition expands from the viewport center instead of the button center. */
39
- fromCenter?: boolean
40
- }
41
-
42
- function polygonCollapsed(cx: number, cy: number, vertexCount: number): string {
43
- const pairs = Array.from(
44
- { length: vertexCount },
45
- () => `${cx}px ${cy}px`
46
- ).join(", ")
47
- return `polygon(${pairs})`
48
- }
49
-
50
- function getThemeTransitionClipPaths(
51
- variant: TransitionVariant,
52
- cx: number,
53
- cy: number,
54
- maxRadius: number,
55
- viewportWidth: number,
56
- viewportHeight: number
57
- ): [string, string] {
58
- switch (variant) {
59
- case "circle":
60
- return [
61
- `circle(0px at ${cx}px ${cy}px)`,
62
- `circle(${maxRadius}px at ${cx}px ${cy}px)`,
63
- ]
64
- case "square": {
65
- const halfW = Math.max(cx, viewportWidth - cx)
66
- const halfH = Math.max(cy, viewportHeight - cy)
67
- const halfSide = Math.max(halfW, halfH) * 1.05
68
- const end = [
69
- `${cx - halfSide}px ${cy - halfSide}px`,
70
- `${cx + halfSide}px ${cy - halfSide}px`,
71
- `${cx + halfSide}px ${cy + halfSide}px`,
72
- `${cx - halfSide}px ${cy + halfSide}px`,
73
- ].join(", ")
74
- return [polygonCollapsed(cx, cy, 4), `polygon(${end})`]
75
- }
76
- case "triangle": {
77
- const scale = maxRadius * 2.2
78
- const dx = (Math.sqrt(3) / 2) * scale
79
- const verts = [
80
- `${cx}px ${cy - scale}px`,
81
- `${cx + dx}px ${cy + 0.5 * scale}px`,
82
- `${cx - dx}px ${cy + 0.5 * scale}px`,
83
- ].join(", ")
84
- return [polygonCollapsed(cx, cy, 3), `polygon(${verts})`]
85
- }
86
- case "diamond": {
87
- // Slightly larger than the view-transition circle radius so axis-aligned coverage matches the circle reveal.
88
- const R = maxRadius * Math.SQRT2
89
- const end = [
90
- `${cx}px ${cy - R}px`,
91
- `${cx + R}px ${cy}px`,
92
- `${cx}px ${cy + R}px`,
93
- `${cx - R}px ${cy}px`,
94
- ].join(", ")
95
- return [polygonCollapsed(cx, cy, 4), `polygon(${end})`]
96
- }
97
- case "hexagon": {
98
- const R = maxRadius * Math.SQRT2
99
- const verts: string[] = []
100
- for (let i = 0; i < 6; i++) {
101
- const a = -Math.PI / 2 + (i * Math.PI) / 3
102
- verts.push(`${cx + R * Math.cos(a)}px ${cy + R * Math.sin(a)}px`)
103
- }
104
- return [polygonCollapsed(cx, cy, 6), `polygon(${verts.join(", ")})`]
105
- }
106
- case "rectangle": {
107
- const halfW = Math.max(cx, viewportWidth - cx)
108
- const halfH = Math.max(cy, viewportHeight - cy)
109
- const end = [
110
- `${cx - halfW}px ${cy - halfH}px`,
111
- `${cx + halfW}px ${cy - halfH}px`,
112
- `${cx + halfW}px ${cy + halfH}px`,
113
- `${cx - halfW}px ${cy + halfH}px`,
114
- ].join(", ")
115
- return [polygonCollapsed(cx, cy, 4), `polygon(${end})`]
116
- }
117
- case "star": {
118
- // Small overscan so the last frames never leave a 1px seam before the transition group ends.
119
- const R = maxRadius * Math.SQRT2 * 1.03
120
- const innerRatio = 0.42
121
- const starPolygon = (radius: number) => {
122
- const verts: string[] = []
123
- for (let i = 0; i < 5; i++) {
124
- const outerA = -Math.PI / 2 + (i * 2 * Math.PI) / 5
125
- verts.push(
126
- `${cx + radius * Math.cos(outerA)}px ${cy + radius * Math.sin(outerA)}px`
127
- )
128
- const innerA = outerA + Math.PI / 5
129
- verts.push(
130
- `${cx + radius * innerRatio * Math.cos(innerA)}px ${cy + radius * innerRatio * Math.sin(innerA)}px`
131
- )
132
- }
133
- return `polygon(${verts.join(", ")})`
134
- }
135
- const startR = Math.max(2, R * 0.025)
136
- return [starPolygon(startR), starPolygon(R)]
137
- }
138
- default:
139
- return [
140
- `circle(0px at ${cx}px ${cy}px)`,
141
- `circle(${maxRadius}px at ${cx}px ${cy}px)`,
142
- ]
143
- }
144
- }
145
-
146
- export const AnimatedThemeToggler = ({
147
- className,
148
- duration = 400,
149
- variant,
150
- fromCenter = false,
151
- ...props
152
- }: AnimatedThemeTogglerProps) => {
153
- const shape = variant ?? "circle"
154
- const { theme, setTheme } = useTheme()
155
- const [isDark, setIsDark] = useState(false)
156
- const buttonRef = useRef<HTMLButtonElement>(null)
157
-
158
- useEffect(() => {
159
- setIsDark(theme === "dark")
160
- }, [theme])
161
-
162
- const toggleTheme = useCallback(() => {
163
- const button = buttonRef.current
164
- if (!button) return
165
-
166
- const viewportWidth = window.visualViewport?.width ?? window.innerWidth
167
- const viewportHeight = window.visualViewport?.height ?? window.innerHeight
168
-
169
- let x: number
170
- let y: number
171
- if (fromCenter) {
172
- x = viewportWidth / 2
173
- y = viewportHeight / 2
174
- } else {
175
- const { top, left, width, height } = button.getBoundingClientRect()
176
- x = left + width / 2
177
- y = top + height / 2
178
- }
179
-
180
- const maxRadius = Math.hypot(
181
- Math.max(x, viewportWidth - x),
182
- Math.max(y, viewportHeight - y)
183
- )
184
-
185
- const newTheme = !isDark
186
-
187
- const applyTheme = () => {
188
- setIsDark(newTheme)
189
- document.documentElement.classList.toggle("dark", newTheme)
190
- }
191
-
192
- const syncNextThemes = () => {
193
- setTheme(newTheme ? "dark" : "light")
194
- }
195
-
196
- if (typeof document.startViewTransition !== "function") {
197
- applyTheme()
198
- syncNextThemes()
199
- return
200
- }
201
-
202
- const clipPath = getThemeTransitionClipPaths(
203
- shape,
204
- x,
205
- y,
206
- maxRadius,
207
- viewportWidth,
208
- viewportHeight
209
- )
210
-
211
- const root = document.documentElement
212
- root.dataset.magicuiThemeVt = "active"
213
- root.style.setProperty(
214
- "--magicui-theme-toggle-vt-duration",
215
- `${duration}ms`
216
- )
217
- // Pin the collapsed clip-path via CSS so Firefox does not paint the new
218
- // theme unclipped between snapshot and the ready.then() JS animation.
219
- root.style.setProperty("--magicui-theme-vt-clip-from", clipPath[0])
220
- const cleanup = () => {
221
- delete root.dataset.magicuiThemeVt
222
- root.style.removeProperty("--magicui-theme-toggle-vt-duration")
223
- root.style.removeProperty("--magicui-theme-vt-clip-from")
224
- }
225
-
226
- const transition = document.startViewTransition(() => {
227
- flushSync(applyTheme)
228
- })
229
-
230
- const onFinish = () => {
231
- cleanup()
232
- syncNextThemes()
233
- }
234
-
235
- if (typeof transition?.finished?.then === "function") {
236
- transition.finished.then(onFinish)
237
- } else {
238
- onFinish()
239
- }
240
-
241
- const ready = transition?.ready
242
- if (ready && typeof ready.then === "function") {
243
- ready.then(() => {
244
- document.documentElement.animate(
245
- {
246
- clipPath,
247
- },
248
- {
249
- duration,
250
- // Star: linear avoids easing overshoot that fights polygon interpolation at t→1; VT group duration is synced above.
251
- easing: shape === "star" ? "linear" : "ease-in-out",
252
- fill: "forwards",
253
- pseudoElement: "::view-transition-new(root)",
254
- }
255
- )
256
- })
257
- }
258
- }, [shape, fromCenter, duration, isDark, setTheme])
259
-
260
- return (
261
- <button
262
- type="button"
263
- ref={buttonRef}
264
- onClick={toggleTheme}
265
- className={cn(className)}
266
- {...props}
267
- >
268
- {isDark ? <Sun className={cn("size-5", className)} /> : <Moon className={cn("size-5", className)} />}
269
- <span className="sr-only">Toggle theme</span>
270
- </button>
271
- )
272
- }
@@ -1,108 +0,0 @@
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
- }
@@ -1,66 +0,0 @@
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 DELETED
@@ -1,129 +0,0 @@
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 DELETED
@@ -1,66 +0,0 @@
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 }