@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.
- package/package.json +85 -0
- package/src/ai-command-button.tsx +36 -0
- package/src/ai-stream-text.tsx +37 -0
- package/src/alert-dialog.tsx +216 -0
- package/src/animated-theme-toggler.tsx +272 -0
- package/src/auth-client.ts +108 -0
- package/src/auth-layout.tsx +66 -0
- package/src/avatar.tsx +129 -0
- package/src/badge.tsx +66 -0
- package/src/button.tsx +84 -0
- package/src/card.tsx +120 -0
- package/src/checkbox.tsx +50 -0
- package/src/context-menu.tsx +280 -0
- package/src/dialog.tsx +183 -0
- package/src/dropdown-menu.tsx +286 -0
- package/src/empty.tsx +121 -0
- package/src/grid-pattern.tsx +87 -0
- package/src/icon-packs/index.ts +27 -0
- package/src/icon-packs/knowledge.ts +55 -0
- package/src/icon-packs/prd.ts +63 -0
- package/src/icon-packs/project.ts +59 -0
- package/src/icon-picker.tsx +68 -0
- package/src/index.ts +23 -0
- package/src/input.tsx +36 -0
- package/src/item.tsx +213 -0
- package/src/kbd.tsx +33 -0
- package/src/label.tsx +39 -0
- package/src/layout-panel-top.tsx +160 -0
- package/src/name-confirm-dialog.tsx +153 -0
- package/src/nav-float-button.tsx +301 -0
- package/src/notion-avatar.tsx +126 -0
- package/src/placeholder-page.tsx +42 -0
- package/src/popover.tsx +106 -0
- package/src/reference-inline.tsx +53 -0
- package/src/reference-search.tsx +52 -0
- package/src/resizable.tsx +67 -0
- package/src/select.tsx +207 -0
- package/src/separator.tsx +45 -0
- package/src/sheet.tsx +164 -0
- package/src/sidebar.tsx +708 -0
- package/src/skeleton.tsx +30 -0
- package/src/sonner.tsx +37 -0
- package/src/switch.tsx +48 -0
- package/src/textarea.tsx +35 -0
- package/src/timezone-provider.tsx +55 -0
- package/src/tooltip.tsx +72 -0
- package/src/use-mobile.ts +36 -0
- package/src/user-avatar.tsx +79 -0
- package/src/utils.ts +6 -0
|
@@ -0,0 +1,68 @@
|
|
|
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 { IconItem } from "./icon-packs";
|
|
19
|
+
import { useTranslation } from "react-i18next";
|
|
20
|
+
import { cn } from "./utils";
|
|
21
|
+
|
|
22
|
+
interface IconPickerProps {
|
|
23
|
+
icons: IconItem[];
|
|
24
|
+
value?: string;
|
|
25
|
+
onChange: (value: string) => void;
|
|
26
|
+
className?: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function IconPicker({
|
|
30
|
+
icons,
|
|
31
|
+
value,
|
|
32
|
+
onChange,
|
|
33
|
+
className,
|
|
34
|
+
}: IconPickerProps) {
|
|
35
|
+
const { t } = useTranslation('common')
|
|
36
|
+
const selectedIcon = icons.find((icon) => icon.value === value) ?? icons[0];
|
|
37
|
+
const SelectedComponent = selectedIcon.icon;
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<div className={cn("flex flex-col items-center gap-8", className)}>
|
|
41
|
+
<div className="flex items-center justify-center size-24 rounded-full border border-zinc-300 bg-primary/10">
|
|
42
|
+
<SelectedComponent size={40} className="text-primary" />
|
|
43
|
+
</div>
|
|
44
|
+
<span className="text-sm text-muted-foreground">{t('iconPicker.select')}</span>
|
|
45
|
+
<div className="flex flex-wrap justify-center gap-2 max-w-170">
|
|
46
|
+
{icons.map((item) => {
|
|
47
|
+
const Icon = item.icon;
|
|
48
|
+
const isSelected = item.value === value;
|
|
49
|
+
return (
|
|
50
|
+
<button
|
|
51
|
+
key={item.value}
|
|
52
|
+
type="button"
|
|
53
|
+
onClick={() => onChange(item.value)}
|
|
54
|
+
className={cn(
|
|
55
|
+
"flex items-center justify-center w-10 h-10 rounded-lg border transition-colors",
|
|
56
|
+
isSelected
|
|
57
|
+
? "border-primary bg-primary/10 text-primary"
|
|
58
|
+
: "border-border hover:bg-muted text-muted-foreground"
|
|
59
|
+
)}
|
|
60
|
+
>
|
|
61
|
+
<Icon size={20} />
|
|
62
|
+
</button>
|
|
63
|
+
);
|
|
64
|
+
})}
|
|
65
|
+
</div>
|
|
66
|
+
</div>
|
|
67
|
+
);
|
|
68
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
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
|
+
export { ReferenceInline } from "./reference-inline";
|
|
19
|
+
export { ReferenceSearch } from "./reference-search";
|
|
20
|
+
export { AICommandButton } from "./ai-command-button";
|
|
21
|
+
export { AIStreamText } from "./ai-stream-text";
|
|
22
|
+
export { NotionAvatar } from "./notion-avatar";
|
|
23
|
+
export { UserAvatar } from "./user-avatar";
|
package/src/input.tsx
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
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 Input({ className, type, ...props }: React.ComponentProps<"input">) {
|
|
23
|
+
return (
|
|
24
|
+
<input
|
|
25
|
+
type={type}
|
|
26
|
+
data-slot="input"
|
|
27
|
+
className={cn(
|
|
28
|
+
"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/40 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 ",
|
|
29
|
+
className
|
|
30
|
+
)}
|
|
31
|
+
{...props}
|
|
32
|
+
/>
|
|
33
|
+
)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export { Input }
|
package/src/item.tsx
ADDED
|
@@ -0,0 +1,213 @@
|
|
|
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
|
+
import { Separator } from "./separator"
|
|
24
|
+
|
|
25
|
+
function ItemGroup({ className, ...props }: React.ComponentProps<"div">) {
|
|
26
|
+
return (
|
|
27
|
+
<div
|
|
28
|
+
role="list"
|
|
29
|
+
data-slot="item-group"
|
|
30
|
+
className={cn(
|
|
31
|
+
"group/item-group flex w-full flex-col gap-4 has-data-[size=sm]:gap-2.5 has-data-[size=xs]:gap-2",
|
|
32
|
+
className
|
|
33
|
+
)}
|
|
34
|
+
{...props}
|
|
35
|
+
/>
|
|
36
|
+
)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function ItemSeparator({
|
|
40
|
+
className,
|
|
41
|
+
...props
|
|
42
|
+
}: React.ComponentProps<typeof Separator>) {
|
|
43
|
+
return (
|
|
44
|
+
<Separator
|
|
45
|
+
data-slot="item-separator"
|
|
46
|
+
orientation="horizontal"
|
|
47
|
+
className={cn("my-2", className)}
|
|
48
|
+
{...props}
|
|
49
|
+
/>
|
|
50
|
+
)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const itemVariants = cva(
|
|
54
|
+
"group/item flex w-full flex-wrap items-center rounded-lg border text-sm transition-colors duration-100 outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 [a]:transition-colors [a]:hover:bg-muted",
|
|
55
|
+
{
|
|
56
|
+
variants: {
|
|
57
|
+
variant: {
|
|
58
|
+
default: "border-transparent",
|
|
59
|
+
outline: "border-border",
|
|
60
|
+
muted: "border-transparent bg-muted/50",
|
|
61
|
+
},
|
|
62
|
+
size: {
|
|
63
|
+
default: "gap-2.5 px-3 py-2.5",
|
|
64
|
+
sm: "gap-2.5 px-3 py-2.5",
|
|
65
|
+
xs: "gap-2 px-2.5 py-2 in-data-[slot=dropdown-menu-content]:p-0",
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
defaultVariants: {
|
|
69
|
+
variant: "default",
|
|
70
|
+
size: "default",
|
|
71
|
+
},
|
|
72
|
+
}
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
function Item({
|
|
76
|
+
className,
|
|
77
|
+
variant = "default",
|
|
78
|
+
size = "default",
|
|
79
|
+
asChild = false,
|
|
80
|
+
...props
|
|
81
|
+
}: React.ComponentProps<"div"> &
|
|
82
|
+
VariantProps<typeof itemVariants> & { asChild?: boolean }) {
|
|
83
|
+
const Comp = asChild ? Slot.Root : "div"
|
|
84
|
+
return (
|
|
85
|
+
<Comp
|
|
86
|
+
data-slot="item"
|
|
87
|
+
data-variant={variant}
|
|
88
|
+
data-size={size}
|
|
89
|
+
className={cn(itemVariants({ variant, size, className }))}
|
|
90
|
+
{...props}
|
|
91
|
+
/>
|
|
92
|
+
)
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const itemMediaVariants = cva(
|
|
96
|
+
"flex shrink-0 items-center justify-center gap-2 group-has-data-[slot=item-description]/item:translate-y-0.5 group-has-data-[slot=item-description]/item:self-start [&_svg]:pointer-events-none",
|
|
97
|
+
{
|
|
98
|
+
variants: {
|
|
99
|
+
variant: {
|
|
100
|
+
default: "bg-transparent",
|
|
101
|
+
icon: "[&_svg:not([class*='size-'])]:size-4",
|
|
102
|
+
image:
|
|
103
|
+
"size-10 overflow-hidden rounded-sm group-data-[size=sm]/item:size-8 group-data-[size=xs]/item:size-6 [&_img]:size-full [&_img]:object-cover",
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
defaultVariants: {
|
|
107
|
+
variant: "default",
|
|
108
|
+
},
|
|
109
|
+
}
|
|
110
|
+
)
|
|
111
|
+
|
|
112
|
+
function ItemMedia({
|
|
113
|
+
className,
|
|
114
|
+
variant = "default",
|
|
115
|
+
...props
|
|
116
|
+
}: React.ComponentProps<"div"> & VariantProps<typeof itemMediaVariants>) {
|
|
117
|
+
return (
|
|
118
|
+
<div
|
|
119
|
+
data-slot="item-media"
|
|
120
|
+
data-variant={variant}
|
|
121
|
+
className={cn(itemMediaVariants({ variant, className }))}
|
|
122
|
+
{...props}
|
|
123
|
+
/>
|
|
124
|
+
)
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function ItemContent({ className, ...props }: React.ComponentProps<"div">) {
|
|
128
|
+
return (
|
|
129
|
+
<div
|
|
130
|
+
data-slot="item-content"
|
|
131
|
+
className={cn(
|
|
132
|
+
"flex flex-1 flex-col gap-1 group-data-[size=xs]/item:gap-0 [&+[data-slot=item-content]]:flex-none",
|
|
133
|
+
className
|
|
134
|
+
)}
|
|
135
|
+
{...props}
|
|
136
|
+
/>
|
|
137
|
+
)
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function ItemTitle({ className, ...props }: React.ComponentProps<"div">) {
|
|
141
|
+
return (
|
|
142
|
+
<div
|
|
143
|
+
data-slot="item-title"
|
|
144
|
+
className={cn(
|
|
145
|
+
"line-clamp-1 flex w-fit items-center gap-2 text-sm leading-snug font-medium underline-offset-4",
|
|
146
|
+
className
|
|
147
|
+
)}
|
|
148
|
+
{...props}
|
|
149
|
+
/>
|
|
150
|
+
)
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function ItemDescription({ className, ...props }: React.ComponentProps<"p">) {
|
|
154
|
+
return (
|
|
155
|
+
<p
|
|
156
|
+
data-slot="item-description"
|
|
157
|
+
className={cn(
|
|
158
|
+
"line-clamp-2 text-left text-sm leading-normal font-normal text-muted-foreground group-data-[size=xs]/item:text-xs [&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary",
|
|
159
|
+
className
|
|
160
|
+
)}
|
|
161
|
+
{...props}
|
|
162
|
+
/>
|
|
163
|
+
)
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
function ItemActions({ className, ...props }: React.ComponentProps<"div">) {
|
|
167
|
+
return (
|
|
168
|
+
<div
|
|
169
|
+
data-slot="item-actions"
|
|
170
|
+
className={cn("flex items-center gap-2", className)}
|
|
171
|
+
{...props}
|
|
172
|
+
/>
|
|
173
|
+
)
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
function ItemHeader({ className, ...props }: React.ComponentProps<"div">) {
|
|
177
|
+
return (
|
|
178
|
+
<div
|
|
179
|
+
data-slot="item-header"
|
|
180
|
+
className={cn(
|
|
181
|
+
"flex basis-full items-center justify-between gap-2",
|
|
182
|
+
className
|
|
183
|
+
)}
|
|
184
|
+
{...props}
|
|
185
|
+
/>
|
|
186
|
+
)
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
function ItemFooter({ className, ...props }: React.ComponentProps<"div">) {
|
|
190
|
+
return (
|
|
191
|
+
<div
|
|
192
|
+
data-slot="item-footer"
|
|
193
|
+
className={cn(
|
|
194
|
+
"flex basis-full items-center justify-between gap-2",
|
|
195
|
+
className
|
|
196
|
+
)}
|
|
197
|
+
{...props}
|
|
198
|
+
/>
|
|
199
|
+
)
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
export {
|
|
203
|
+
Item,
|
|
204
|
+
ItemMedia,
|
|
205
|
+
ItemContent,
|
|
206
|
+
ItemActions,
|
|
207
|
+
ItemGroup,
|
|
208
|
+
ItemSeparator,
|
|
209
|
+
ItemTitle,
|
|
210
|
+
ItemDescription,
|
|
211
|
+
ItemHeader,
|
|
212
|
+
ItemFooter,
|
|
213
|
+
}
|
package/src/kbd.tsx
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
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 { cn } from "@/lib/utils"
|
|
19
|
+
|
|
20
|
+
function Kbd({ className, ...props }: React.ComponentProps<"kbd">) {
|
|
21
|
+
return (
|
|
22
|
+
<kbd
|
|
23
|
+
data-slot="kbd"
|
|
24
|
+
className={cn(
|
|
25
|
+
"inline-flex items-center justify-center rounded bg-muted px-1.5 py-1 font-mono text-[10px] font-medium text-muted-foreground",
|
|
26
|
+
className
|
|
27
|
+
)}
|
|
28
|
+
{...props}
|
|
29
|
+
/>
|
|
30
|
+
)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export { Kbd }
|
package/src/label.tsx
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
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 { Label as LabelPrimitive } from "radix-ui"
|
|
20
|
+
|
|
21
|
+
import { cn } from "./utils"
|
|
22
|
+
|
|
23
|
+
function Label({
|
|
24
|
+
className,
|
|
25
|
+
...props
|
|
26
|
+
}: React.ComponentProps<typeof LabelPrimitive.Root>) {
|
|
27
|
+
return (
|
|
28
|
+
<LabelPrimitive.Root
|
|
29
|
+
data-slot="label"
|
|
30
|
+
className={cn(
|
|
31
|
+
"flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",
|
|
32
|
+
className
|
|
33
|
+
)}
|
|
34
|
+
{...props}
|
|
35
|
+
/>
|
|
36
|
+
)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export { Label }
|
|
@@ -0,0 +1,160 @@
|
|
|
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 { m, useAnimation } from "motion/react";
|
|
21
|
+
import type { HTMLAttributes } from "react";
|
|
22
|
+
import { forwardRef, useCallback, useImperativeHandle, useRef } from "react";
|
|
23
|
+
|
|
24
|
+
import { cn } from "./utils";
|
|
25
|
+
|
|
26
|
+
export interface LayoutPanelTopIconHandle {
|
|
27
|
+
startAnimation: () => void;
|
|
28
|
+
stopAnimation: () => void;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
interface LayoutPanelTopIconProps extends HTMLAttributes<HTMLDivElement> {
|
|
32
|
+
size?: number;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const LayoutPanelTopIcon = forwardRef<
|
|
36
|
+
LayoutPanelTopIconHandle,
|
|
37
|
+
LayoutPanelTopIconProps
|
|
38
|
+
>(({ onMouseEnter, onMouseLeave, className, size = 28, ...props }, ref) => {
|
|
39
|
+
const controls = useAnimation();
|
|
40
|
+
const isControlledRef = useRef(false);
|
|
41
|
+
|
|
42
|
+
useImperativeHandle(ref, () => {
|
|
43
|
+
isControlledRef.current = true;
|
|
44
|
+
|
|
45
|
+
return {
|
|
46
|
+
startAnimation: () => controls.start("animate"),
|
|
47
|
+
stopAnimation: () => controls.start("normal"),
|
|
48
|
+
};
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
const handleMouseEnter = useCallback(
|
|
52
|
+
(e: React.MouseEvent<HTMLDivElement>) => {
|
|
53
|
+
if (isControlledRef.current) {
|
|
54
|
+
onMouseEnter?.(e);
|
|
55
|
+
} else {
|
|
56
|
+
controls.start("animate");
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
[controls, onMouseEnter]
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
const handleMouseLeave = useCallback(
|
|
63
|
+
(e: React.MouseEvent<HTMLDivElement>) => {
|
|
64
|
+
if (isControlledRef.current) {
|
|
65
|
+
onMouseLeave?.(e);
|
|
66
|
+
} else {
|
|
67
|
+
controls.start("normal");
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
[controls, onMouseLeave]
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
return (
|
|
74
|
+
<div
|
|
75
|
+
className={cn(className)}
|
|
76
|
+
onMouseEnter={handleMouseEnter}
|
|
77
|
+
onMouseLeave={handleMouseLeave}
|
|
78
|
+
{...props}
|
|
79
|
+
>
|
|
80
|
+
<svg
|
|
81
|
+
fill="none"
|
|
82
|
+
height={size}
|
|
83
|
+
stroke="currentColor"
|
|
84
|
+
strokeLinecap="round"
|
|
85
|
+
strokeLinejoin="round"
|
|
86
|
+
strokeWidth="2"
|
|
87
|
+
viewBox="0 0 24 24"
|
|
88
|
+
width={size}
|
|
89
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
90
|
+
>
|
|
91
|
+
<m.rect
|
|
92
|
+
animate={controls}
|
|
93
|
+
height="7"
|
|
94
|
+
initial="normal"
|
|
95
|
+
rx="1"
|
|
96
|
+
variants={{
|
|
97
|
+
normal: { opacity: 1, translateY: 0 },
|
|
98
|
+
animate: {
|
|
99
|
+
opacity: [0, 1],
|
|
100
|
+
translateY: [-5, 0],
|
|
101
|
+
transition: {
|
|
102
|
+
opacity: { duration: 0.5, times: [0.2, 1] },
|
|
103
|
+
duration: 0.5,
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
}}
|
|
107
|
+
width="18"
|
|
108
|
+
x="3"
|
|
109
|
+
y="3"
|
|
110
|
+
/>
|
|
111
|
+
<m.rect
|
|
112
|
+
animate={controls}
|
|
113
|
+
height="7"
|
|
114
|
+
initial="normal"
|
|
115
|
+
rx="1"
|
|
116
|
+
variants={{
|
|
117
|
+
normal: { opacity: 1, translateX: 0 },
|
|
118
|
+
animate: {
|
|
119
|
+
opacity: [0, 1],
|
|
120
|
+
translateX: [-10, 0],
|
|
121
|
+
transition: {
|
|
122
|
+
opacity: { duration: 0.7, times: [0.5, 1] },
|
|
123
|
+
translateX: { delay: 0.3 },
|
|
124
|
+
duration: 0.5,
|
|
125
|
+
},
|
|
126
|
+
},
|
|
127
|
+
}}
|
|
128
|
+
width="7"
|
|
129
|
+
x="3"
|
|
130
|
+
y="14"
|
|
131
|
+
/>
|
|
132
|
+
<m.rect
|
|
133
|
+
animate={controls}
|
|
134
|
+
height="7"
|
|
135
|
+
initial="normal"
|
|
136
|
+
rx="1"
|
|
137
|
+
variants={{
|
|
138
|
+
normal: { opacity: 1, translateX: 0 },
|
|
139
|
+
animate: {
|
|
140
|
+
opacity: [0, 1],
|
|
141
|
+
translateX: [10, 0],
|
|
142
|
+
transition: {
|
|
143
|
+
opacity: { duration: 0.8, times: [0.5, 1] },
|
|
144
|
+
translateX: { delay: 0.4 },
|
|
145
|
+
duration: 0.5,
|
|
146
|
+
},
|
|
147
|
+
},
|
|
148
|
+
}}
|
|
149
|
+
width="7"
|
|
150
|
+
x="14"
|
|
151
|
+
y="14"
|
|
152
|
+
/>
|
|
153
|
+
</svg>
|
|
154
|
+
</div>
|
|
155
|
+
);
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
LayoutPanelTopIcon.displayName = "LayoutPanelTopIcon";
|
|
159
|
+
|
|
160
|
+
export { LayoutPanelTopIcon };
|