@inbeat/ui 0.7.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/CHANGELOG.md +76 -0
- package/package.json +100 -0
- package/src/components/alert-dialog.tsx +246 -0
- package/src/components/alert.tsx +66 -0
- package/src/components/app-nav.tsx +55 -0
- package/src/components/app-shell.tsx +95 -0
- package/src/components/avatar.tsx +73 -0
- package/src/components/badge.tsx +42 -0
- package/src/components/breadcrumb.tsx +109 -0
- package/src/components/button.tsx +75 -0
- package/src/components/calendar.tsx +220 -0
- package/src/components/carousel.tsx +83 -0
- package/src/components/checkbox.tsx +29 -0
- package/src/components/collapsible-section.tsx +88 -0
- package/src/components/combobox.tsx +351 -0
- package/src/components/data-table-shell.tsx +6 -0
- package/src/components/data-table-sortable-header.tsx +29 -0
- package/src/components/data-table.tsx +141 -0
- package/src/components/destructive-action-dialog.tsx +108 -0
- package/src/components/dialog.tsx +187 -0
- package/src/components/dropdown-menu.tsx +228 -0
- package/src/components/empty-state.tsx +55 -0
- package/src/components/field.tsx +248 -0
- package/src/components/icon-button.tsx +51 -0
- package/src/components/input-group.tsx +170 -0
- package/src/components/input.tsx +22 -0
- package/src/components/label.tsx +24 -0
- package/src/components/labeled-field.tsx +18 -0
- package/src/components/load-more-sentinel.tsx +12 -0
- package/src/components/member-avatar-stack.tsx +44 -0
- package/src/components/multi-select-popover.tsx +202 -0
- package/src/components/nav-user.tsx +71 -0
- package/src/components/number-dot.tsx +13 -0
- package/src/components/person-identity.tsx +52 -0
- package/src/components/platform-disclaimer.tsx +70 -0
- package/src/components/popover.tsx +92 -0
- package/src/components/portal-container.tsx +21 -0
- package/src/components/progress.tsx +23 -0
- package/src/components/search-input.tsx +57 -0
- package/src/components/select.tsx +232 -0
- package/src/components/separator.tsx +28 -0
- package/src/components/sheet.tsx +147 -0
- package/src/components/sidebar.tsx +471 -0
- package/src/components/skeleton.tsx +13 -0
- package/src/components/sonner.tsx +46 -0
- package/src/components/spinner.tsx +21 -0
- package/src/components/table.tsx +92 -0
- package/src/components/tabs.tsx +62 -0
- package/src/components/textarea.tsx +18 -0
- package/src/components/toggle-pills.tsx +32 -0
- package/src/components/tooltip.tsx +67 -0
- package/src/hooks/use-mobile.ts +21 -0
- package/src/lib/easing.ts +5 -0
- package/src/lib/initials.ts +12 -0
- package/src/lib/utils.ts +6 -0
- package/theme.css +141 -0
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { Checkbox } from "./checkbox";
|
|
4
|
+
import { Popover, PopoverContent, PopoverTrigger } from "./popover";
|
|
5
|
+
import { SearchInput } from "./search-input";
|
|
6
|
+
import { selectTriggerClassName } from "./select";
|
|
7
|
+
import { Spinner } from "./spinner";
|
|
8
|
+
import { ChevronDownIcon } from "lucide-react";
|
|
9
|
+
import { useMemo, useState } from "react";
|
|
10
|
+
import { cn } from "../lib/utils";
|
|
11
|
+
import { PersonAvatar } from "./person-identity";
|
|
12
|
+
|
|
13
|
+
const ELLIPSIS = "…";
|
|
14
|
+
|
|
15
|
+
export type MultiSelectOption = {
|
|
16
|
+
value: string;
|
|
17
|
+
label: string;
|
|
18
|
+
imageUrl?: string | null;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
function truncateText(value: string, maxLength: number): string {
|
|
22
|
+
if (maxLength < 1) return ELLIPSIS;
|
|
23
|
+
if (value.length <= maxLength) return value;
|
|
24
|
+
return `${value.slice(0, Math.max(0, maxLength - ELLIPSIS.length))}${ELLIPSIS}`;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function toggleMultiSelectValue<T extends string>(selected: T[], value: T): T[] {
|
|
28
|
+
return selected.includes(value)
|
|
29
|
+
? selected.filter((item) => item !== value)
|
|
30
|
+
: [...selected, value];
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function getMultiSelectLabel({
|
|
34
|
+
placeholder,
|
|
35
|
+
selectedValues,
|
|
36
|
+
options,
|
|
37
|
+
}: {
|
|
38
|
+
placeholder: string;
|
|
39
|
+
selectedValues: string[];
|
|
40
|
+
options: MultiSelectOption[];
|
|
41
|
+
}) {
|
|
42
|
+
if (selectedValues.length === 0) return placeholder;
|
|
43
|
+
if (selectedValues.length === 1) {
|
|
44
|
+
return truncateText(
|
|
45
|
+
options.find((option) => option.value === selectedValues[0])?.label ?? placeholder,
|
|
46
|
+
18,
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
return `${placeholder} (${selectedValues.length})`;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function MultiSelectOptionList({
|
|
53
|
+
options,
|
|
54
|
+
selectedValues,
|
|
55
|
+
onToggle,
|
|
56
|
+
disabled,
|
|
57
|
+
emptyMessage = "No options",
|
|
58
|
+
isPending,
|
|
59
|
+
keepOpenOnToggle = true,
|
|
60
|
+
idPrefix = "multi-select-option",
|
|
61
|
+
searchable,
|
|
62
|
+
searchPlaceholder = "Search…",
|
|
63
|
+
}: {
|
|
64
|
+
options: MultiSelectOption[];
|
|
65
|
+
selectedValues: string[];
|
|
66
|
+
onToggle: (value: string) => void;
|
|
67
|
+
disabled?: boolean;
|
|
68
|
+
emptyMessage?: string;
|
|
69
|
+
isPending?: boolean;
|
|
70
|
+
keepOpenOnToggle?: boolean;
|
|
71
|
+
idPrefix?: string;
|
|
72
|
+
searchable?: boolean;
|
|
73
|
+
searchPlaceholder?: string;
|
|
74
|
+
}) {
|
|
75
|
+
const [query, setQuery] = useState("");
|
|
76
|
+
const visibleOptions = useMemo(() => {
|
|
77
|
+
const q = query.trim().toLowerCase();
|
|
78
|
+
if (!searchable || !q) return options;
|
|
79
|
+
return options.filter((option) => option.label.toLowerCase().includes(q));
|
|
80
|
+
}, [options, query, searchable]);
|
|
81
|
+
|
|
82
|
+
if (isPending) {
|
|
83
|
+
return (
|
|
84
|
+
<div className="flex min-h-[140px] w-full items-center justify-center p-4">
|
|
85
|
+
<Spinner className="size-5" />
|
|
86
|
+
</div>
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return (
|
|
91
|
+
<div className="flex max-h-64 flex-col">
|
|
92
|
+
{searchable ? (
|
|
93
|
+
<div className="shrink-0 border-b p-1.5">
|
|
94
|
+
<SearchInput
|
|
95
|
+
value={query}
|
|
96
|
+
onChange={setQuery}
|
|
97
|
+
placeholder={searchPlaceholder}
|
|
98
|
+
className="w-full"
|
|
99
|
+
/>
|
|
100
|
+
</div>
|
|
101
|
+
) : null}
|
|
102
|
+
<div
|
|
103
|
+
className="min-h-0 flex-1 overflow-y-auto overscroll-y-contain p-1"
|
|
104
|
+
onWheel={(event) => event.stopPropagation()}
|
|
105
|
+
>
|
|
106
|
+
{visibleOptions.map((option) => {
|
|
107
|
+
const checked = selectedValues.includes(option.value);
|
|
108
|
+
const rowId = `${idPrefix}-${option.value}`;
|
|
109
|
+
return (
|
|
110
|
+
<label
|
|
111
|
+
key={option.value}
|
|
112
|
+
htmlFor={rowId}
|
|
113
|
+
onPointerDown={keepOpenOnToggle ? (event) => event.preventDefault() : undefined}
|
|
114
|
+
className={cn(
|
|
115
|
+
"flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-sm",
|
|
116
|
+
"hover:bg-muted/80 focus-within:outline-none focus-within:ring-2 focus-within:ring-ring",
|
|
117
|
+
disabled && "pointer-events-none opacity-50",
|
|
118
|
+
)}
|
|
119
|
+
>
|
|
120
|
+
<Checkbox
|
|
121
|
+
id={rowId}
|
|
122
|
+
checked={checked}
|
|
123
|
+
disabled={disabled}
|
|
124
|
+
onCheckedChange={disabled ? undefined : () => onToggle(option.value)}
|
|
125
|
+
/>
|
|
126
|
+
{option.imageUrl !== undefined ? (
|
|
127
|
+
<PersonAvatar imageUrl={option.imageUrl} name={option.label} />
|
|
128
|
+
) : null}
|
|
129
|
+
<span className="min-w-0 flex-1 truncate">{option.label}</span>
|
|
130
|
+
</label>
|
|
131
|
+
);
|
|
132
|
+
})}
|
|
133
|
+
{visibleOptions.length === 0 ? (
|
|
134
|
+
<p className="px-2 py-3 text-sm text-muted-foreground">
|
|
135
|
+
{options.length === 0 ? emptyMessage : "No matches."}
|
|
136
|
+
</p>
|
|
137
|
+
) : null}
|
|
138
|
+
</div>
|
|
139
|
+
</div>
|
|
140
|
+
);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export function MultiSelectPopover({
|
|
144
|
+
placeholder,
|
|
145
|
+
selectedValues,
|
|
146
|
+
options,
|
|
147
|
+
onChange,
|
|
148
|
+
triggerClassName = "min-w-36 w-44 max-w-44",
|
|
149
|
+
contentClassName = "w-72 overflow-hidden",
|
|
150
|
+
emptyMessage,
|
|
151
|
+
disabled,
|
|
152
|
+
idPrefix,
|
|
153
|
+
}: {
|
|
154
|
+
placeholder: string;
|
|
155
|
+
selectedValues: string[];
|
|
156
|
+
options: MultiSelectOption[];
|
|
157
|
+
onChange: (values: string[]) => void;
|
|
158
|
+
triggerClassName?: string;
|
|
159
|
+
contentClassName?: string;
|
|
160
|
+
emptyMessage?: string;
|
|
161
|
+
disabled?: boolean;
|
|
162
|
+
idPrefix?: string;
|
|
163
|
+
}) {
|
|
164
|
+
const isActive = selectedValues.length > 0;
|
|
165
|
+
const triggerLabel = getMultiSelectLabel({ placeholder, selectedValues, options });
|
|
166
|
+
|
|
167
|
+
return (
|
|
168
|
+
<Popover modal={false}>
|
|
169
|
+
<PopoverTrigger asChild>
|
|
170
|
+
<button
|
|
171
|
+
type="button"
|
|
172
|
+
data-size="sm"
|
|
173
|
+
className={selectTriggerClassName({
|
|
174
|
+
className: triggerClassName,
|
|
175
|
+
noneSelected: !isActive,
|
|
176
|
+
})}
|
|
177
|
+
disabled={disabled}
|
|
178
|
+
>
|
|
179
|
+
<span data-slot="select-value" className="truncate">
|
|
180
|
+
{triggerLabel}
|
|
181
|
+
</span>
|
|
182
|
+
<ChevronDownIcon className="size-3.5 opacity-50" aria-hidden />
|
|
183
|
+
</button>
|
|
184
|
+
</PopoverTrigger>
|
|
185
|
+
<PopoverContent
|
|
186
|
+
align="start"
|
|
187
|
+
className={cn("overscroll-y-contain p-0", contentClassName)}
|
|
188
|
+
onOpenAutoFocus={(event) => event.preventDefault()}
|
|
189
|
+
onWheel={(event) => event.stopPropagation()}
|
|
190
|
+
>
|
|
191
|
+
<MultiSelectOptionList
|
|
192
|
+
options={options}
|
|
193
|
+
selectedValues={selectedValues}
|
|
194
|
+
onToggle={(value) => onChange(toggleMultiSelectValue(selectedValues, value))}
|
|
195
|
+
disabled={disabled}
|
|
196
|
+
emptyMessage={emptyMessage}
|
|
197
|
+
idPrefix={idPrefix}
|
|
198
|
+
/>
|
|
199
|
+
</PopoverContent>
|
|
200
|
+
</Popover>
|
|
201
|
+
);
|
|
202
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { ChevronsUpDown } from "lucide-react";
|
|
4
|
+
import type * as React from "react";
|
|
5
|
+
import { getInitials } from "../lib/initials";
|
|
6
|
+
import { Avatar, AvatarFallback, AvatarImage } from "./avatar";
|
|
7
|
+
import {
|
|
8
|
+
DropdownMenu,
|
|
9
|
+
DropdownMenuContent,
|
|
10
|
+
DropdownMenuLabel,
|
|
11
|
+
DropdownMenuSeparator,
|
|
12
|
+
DropdownMenuTrigger,
|
|
13
|
+
} from "./dropdown-menu";
|
|
14
|
+
import { SidebarMenu, SidebarMenuButton, SidebarMenuItem, useSidebar } from "./sidebar";
|
|
15
|
+
|
|
16
|
+
type NavUserProfile = {
|
|
17
|
+
name: string;
|
|
18
|
+
email: string;
|
|
19
|
+
avatarUrl?: string;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
function UserSummary({ name, email, avatarUrl }: NavUserProfile) {
|
|
23
|
+
return (
|
|
24
|
+
<>
|
|
25
|
+
<Avatar className="size-8 rounded-lg">
|
|
26
|
+
{avatarUrl ? <AvatarImage src={avatarUrl} alt={name} /> : null}
|
|
27
|
+
<AvatarFallback className="rounded-lg">{getInitials(name, "?")}</AvatarFallback>
|
|
28
|
+
</Avatar>
|
|
29
|
+
<div className="grid flex-1 text-left text-sm leading-tight">
|
|
30
|
+
<span className="truncate font-medium">{name}</span>
|
|
31
|
+
<span className="truncate text-xs">{email}</span>
|
|
32
|
+
</div>
|
|
33
|
+
</>
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function NavUser({ children, ...profile }: NavUserProfile & { children: React.ReactNode }) {
|
|
38
|
+
const { isMobile } = useSidebar();
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<SidebarMenu>
|
|
42
|
+
<SidebarMenuItem>
|
|
43
|
+
<DropdownMenu>
|
|
44
|
+
<DropdownMenuTrigger asChild>
|
|
45
|
+
<SidebarMenuButton
|
|
46
|
+
data-slot="nav-user"
|
|
47
|
+
className="h-12 data-[state=open]:bg-sidebar-accent data-[state=open]:text-sidebar-accent-foreground"
|
|
48
|
+
>
|
|
49
|
+
<UserSummary {...profile} />
|
|
50
|
+
<ChevronsUpDown className="ml-auto" />
|
|
51
|
+
</SidebarMenuButton>
|
|
52
|
+
</DropdownMenuTrigger>
|
|
53
|
+
<DropdownMenuContent
|
|
54
|
+
className="w-(--radix-dropdown-menu-trigger-width) min-w-56 rounded-lg"
|
|
55
|
+
side={isMobile ? "bottom" : "right"}
|
|
56
|
+
align="end"
|
|
57
|
+
sideOffset={4}
|
|
58
|
+
>
|
|
59
|
+
<DropdownMenuLabel className="flex items-center gap-2 px-1 py-1.5 font-normal">
|
|
60
|
+
<UserSummary {...profile} />
|
|
61
|
+
</DropdownMenuLabel>
|
|
62
|
+
<DropdownMenuSeparator />
|
|
63
|
+
{children}
|
|
64
|
+
</DropdownMenuContent>
|
|
65
|
+
</DropdownMenu>
|
|
66
|
+
</SidebarMenuItem>
|
|
67
|
+
</SidebarMenu>
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export { NavUser };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
interface NumberDotProps {
|
|
2
|
+
count: number;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export function NumberDot({ count }: NumberDotProps) {
|
|
6
|
+
if (count <= 0) return null;
|
|
7
|
+
|
|
8
|
+
return (
|
|
9
|
+
<span className="ml-0.5 text-xs bg-muted-foreground/10 px-1 font-bold rounded-full flex items-center justify-center text-muted-foreground">
|
|
10
|
+
{count}
|
|
11
|
+
</span>
|
|
12
|
+
);
|
|
13
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { Avatar, AvatarFallback, AvatarImage } from "./avatar";
|
|
2
|
+
import { getInitials } from "../lib/initials";
|
|
3
|
+
import { cn } from "../lib/utils";
|
|
4
|
+
|
|
5
|
+
export type PersonIdentityProfile = {
|
|
6
|
+
name: string;
|
|
7
|
+
imageUrl?: string | null;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export interface PersonAvatarProps {
|
|
11
|
+
imageUrl?: string | null;
|
|
12
|
+
name: string;
|
|
13
|
+
className?: string;
|
|
14
|
+
fallbackClassName?: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function PersonAvatar({ imageUrl, name, className, fallbackClassName }: PersonAvatarProps) {
|
|
18
|
+
return (
|
|
19
|
+
<Avatar className={cn("size-5 shrink-0 text-[8px] leading-none", className)}>
|
|
20
|
+
{imageUrl ? <AvatarImage src={imageUrl} alt={name} /> : null}
|
|
21
|
+
<AvatarFallback className={cn("text-[8px] leading-none", fallbackClassName)}>
|
|
22
|
+
{getInitials(name)}
|
|
23
|
+
</AvatarFallback>
|
|
24
|
+
</Avatar>
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface PersonNameProps {
|
|
29
|
+
name: string;
|
|
30
|
+
className?: string;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function PersonName({ name, className }: PersonNameProps) {
|
|
34
|
+
return (
|
|
35
|
+
<p className={cn("w-full whitespace-nowrap text-[13px] text-muted-foreground", className)}>
|
|
36
|
+
{name}
|
|
37
|
+
</p>
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface PersonIdentityProps extends PersonIdentityProfile {
|
|
42
|
+
className?: string;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function PersonIdentity({ name, imageUrl, className }: PersonIdentityProps) {
|
|
46
|
+
return (
|
|
47
|
+
<div className={cn("flex items-center gap-1.5 cursor-pointer", className)}>
|
|
48
|
+
<PersonAvatar imageUrl={imageUrl} name={name} />
|
|
49
|
+
<PersonName name={name} />
|
|
50
|
+
</div>
|
|
51
|
+
);
|
|
52
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { X } from "lucide-react";
|
|
4
|
+
import { motion } from "motion/react";
|
|
5
|
+
import { useLayoutEffect, useState } from "react";
|
|
6
|
+
import { Alert, AlertDescription, AlertTitle } from "./alert";
|
|
7
|
+
import { Button } from "./button";
|
|
8
|
+
import { Tooltip } from "./tooltip";
|
|
9
|
+
|
|
10
|
+
const DISMISS_MAX_AGE_SECONDS = 60 * 60 * 24 * 7;
|
|
11
|
+
|
|
12
|
+
function isDismissed(cookieName: string): boolean {
|
|
13
|
+
return document.cookie.split("; ").includes(`${cookieName}=1`);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function persistDismissed(cookieName: string) {
|
|
17
|
+
// biome-ignore lint/suspicious/noDocumentCookie: CookieStore API lacks Safari support
|
|
18
|
+
document.cookie = `${cookieName}=1; path=/; max-age=${DISMISS_MAX_AGE_SECONDS}; SameSite=Lax`;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
type PlatformDisclaimerProps = {
|
|
22
|
+
title: string;
|
|
23
|
+
description: string;
|
|
24
|
+
cookieName: string;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
function PlatformDisclaimer({ title, description, cookieName }: PlatformDisclaimerProps) {
|
|
28
|
+
const [dismissed, setDismissed] = useState<boolean | null>(null);
|
|
29
|
+
|
|
30
|
+
useLayoutEffect(() => {
|
|
31
|
+
setDismissed(isDismissed(cookieName));
|
|
32
|
+
}, [cookieName]);
|
|
33
|
+
|
|
34
|
+
if (dismissed !== false) return null;
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<div className="pointer-events-none fixed right-6 bottom-6 z-40">
|
|
38
|
+
<motion.div
|
|
39
|
+
className="pointer-events-auto max-w-sm"
|
|
40
|
+
initial={{ opacity: 0, y: 10 }}
|
|
41
|
+
animate={{ opacity: 1, y: 0 }}
|
|
42
|
+
transition={{ duration: 0.3, delay: 2 }}
|
|
43
|
+
>
|
|
44
|
+
<Alert className="shadow-elevated flex items-start gap-3 rounded-xl p-4">
|
|
45
|
+
<div className="min-w-0 flex-1">
|
|
46
|
+
<AlertTitle>{title}</AlertTitle>
|
|
47
|
+
<AlertDescription className="text-foreground/80">{description}</AlertDescription>
|
|
48
|
+
</div>
|
|
49
|
+
<Tooltip content="Dismiss">
|
|
50
|
+
<Button
|
|
51
|
+
type="button"
|
|
52
|
+
variant="ghost"
|
|
53
|
+
size="icon-sm"
|
|
54
|
+
aria-label="Dismiss"
|
|
55
|
+
className="shrink-0 text-muted-foreground hover:text-foreground"
|
|
56
|
+
onClick={() => {
|
|
57
|
+
persistDismissed(cookieName);
|
|
58
|
+
setDismissed(true);
|
|
59
|
+
}}
|
|
60
|
+
>
|
|
61
|
+
<X />
|
|
62
|
+
</Button>
|
|
63
|
+
</Tooltip>
|
|
64
|
+
</Alert>
|
|
65
|
+
</motion.div>
|
|
66
|
+
</div>
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export { PlatformDisclaimer };
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from "react"
|
|
4
|
+
import { Popover as PopoverPrimitive } from "radix-ui"
|
|
5
|
+
|
|
6
|
+
import { usePortalContainer } from "./portal-container"
|
|
7
|
+
import { cn } from "../lib/utils"
|
|
8
|
+
|
|
9
|
+
function Popover({
|
|
10
|
+
...props
|
|
11
|
+
}: React.ComponentProps<typeof PopoverPrimitive.Root>) {
|
|
12
|
+
return <PopoverPrimitive.Root data-slot="popover" {...props} />
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function PopoverTrigger({
|
|
16
|
+
...props
|
|
17
|
+
}: React.ComponentProps<typeof PopoverPrimitive.Trigger>) {
|
|
18
|
+
return <PopoverPrimitive.Trigger data-slot="popover-trigger" {...props} />
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function PopoverContent({
|
|
22
|
+
className,
|
|
23
|
+
align = "center",
|
|
24
|
+
sideOffset = 4,
|
|
25
|
+
...props
|
|
26
|
+
}: React.ComponentProps<typeof PopoverPrimitive.Content>) {
|
|
27
|
+
const portalContainer = usePortalContainer()
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<PopoverPrimitive.Portal container={portalContainer ?? undefined}>
|
|
31
|
+
<PopoverPrimitive.Content
|
|
32
|
+
data-slot="popover-content"
|
|
33
|
+
align={align}
|
|
34
|
+
sideOffset={sideOffset}
|
|
35
|
+
className={cn(
|
|
36
|
+
"z-50 w-72 origin-(--radix-popover-content-transform-origin) rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-hidden data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95",
|
|
37
|
+
className
|
|
38
|
+
)}
|
|
39
|
+
{...props}
|
|
40
|
+
/>
|
|
41
|
+
</PopoverPrimitive.Portal>
|
|
42
|
+
)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function PopoverAnchor({
|
|
46
|
+
...props
|
|
47
|
+
}: React.ComponentProps<typeof PopoverPrimitive.Anchor>) {
|
|
48
|
+
return <PopoverPrimitive.Anchor data-slot="popover-anchor" {...props} />
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function PopoverHeader({ className, ...props }: React.ComponentProps<"div">) {
|
|
52
|
+
return (
|
|
53
|
+
<div
|
|
54
|
+
data-slot="popover-header"
|
|
55
|
+
className={cn("flex flex-col gap-1 text-sm", className)}
|
|
56
|
+
{...props}
|
|
57
|
+
/>
|
|
58
|
+
)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function PopoverTitle({ className, ...props }: React.ComponentProps<"h2">) {
|
|
62
|
+
return (
|
|
63
|
+
<div
|
|
64
|
+
data-slot="popover-title"
|
|
65
|
+
className={cn("font-medium", className)}
|
|
66
|
+
{...props}
|
|
67
|
+
/>
|
|
68
|
+
)
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function PopoverDescription({
|
|
72
|
+
className,
|
|
73
|
+
...props
|
|
74
|
+
}: React.ComponentProps<"p">) {
|
|
75
|
+
return (
|
|
76
|
+
<p
|
|
77
|
+
data-slot="popover-description"
|
|
78
|
+
className={cn("text-muted-foreground", className)}
|
|
79
|
+
{...props}
|
|
80
|
+
/>
|
|
81
|
+
)
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export {
|
|
85
|
+
Popover,
|
|
86
|
+
PopoverTrigger,
|
|
87
|
+
PopoverContent,
|
|
88
|
+
PopoverAnchor,
|
|
89
|
+
PopoverHeader,
|
|
90
|
+
PopoverTitle,
|
|
91
|
+
PopoverDescription,
|
|
92
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { createContext, type ReactNode, useContext } from "react";
|
|
4
|
+
|
|
5
|
+
const PortalContainerContext = createContext<HTMLElement | null>(null);
|
|
6
|
+
|
|
7
|
+
export function usePortalContainer() {
|
|
8
|
+
return useContext(PortalContainerContext);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function PortalContainerProvider({
|
|
12
|
+
container,
|
|
13
|
+
children,
|
|
14
|
+
}: {
|
|
15
|
+
container: HTMLElement | null;
|
|
16
|
+
children: ReactNode;
|
|
17
|
+
}) {
|
|
18
|
+
return (
|
|
19
|
+
<PortalContainerContext.Provider value={container}>{children}</PortalContainerContext.Provider>
|
|
20
|
+
);
|
|
21
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { Progress as ProgressPrimitive } from "radix-ui";
|
|
3
|
+
|
|
4
|
+
import { cn } from "../lib/utils";
|
|
5
|
+
|
|
6
|
+
const Progress = React.forwardRef<
|
|
7
|
+
React.ComponentRef<typeof ProgressPrimitive.Root>,
|
|
8
|
+
React.ComponentPropsWithoutRef<typeof ProgressPrimitive.Root>
|
|
9
|
+
>(({ className, value, ...props }, ref) => (
|
|
10
|
+
<ProgressPrimitive.Root
|
|
11
|
+
ref={ref}
|
|
12
|
+
className={cn("relative h-2 w-full overflow-hidden rounded-full bg-primary/20", className)}
|
|
13
|
+
{...props}
|
|
14
|
+
>
|
|
15
|
+
<ProgressPrimitive.Indicator
|
|
16
|
+
className="h-full w-full flex-1 bg-primary transition-all"
|
|
17
|
+
style={{ transform: `translateX(-${100 - (value || 0)}%)` }}
|
|
18
|
+
/>
|
|
19
|
+
</ProgressPrimitive.Root>
|
|
20
|
+
));
|
|
21
|
+
Progress.displayName = ProgressPrimitive.Root.displayName;
|
|
22
|
+
|
|
23
|
+
export { Progress };
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { Search, X } from "lucide-react";
|
|
4
|
+
import type * as React from "react";
|
|
5
|
+
import { Button } from "./button";
|
|
6
|
+
import { Input } from "./input";
|
|
7
|
+
import { Spinner } from "./spinner";
|
|
8
|
+
import { cn } from "../lib/utils";
|
|
9
|
+
|
|
10
|
+
interface SearchInputProps extends Omit<React.ComponentProps<"input">, "onChange" | "value"> {
|
|
11
|
+
value: string;
|
|
12
|
+
onChange: (value: string) => void;
|
|
13
|
+
isLoading?: boolean;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function SearchInput({
|
|
17
|
+
value,
|
|
18
|
+
onChange,
|
|
19
|
+
isLoading,
|
|
20
|
+
placeholder = "Search…",
|
|
21
|
+
className,
|
|
22
|
+
...props
|
|
23
|
+
}: SearchInputProps) {
|
|
24
|
+
const showClear = value.length > 0;
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<div className={cn("relative min-w-56 w-80 max-w-full", className)}>
|
|
28
|
+
{isLoading ? (
|
|
29
|
+
<Spinner className="pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2" />
|
|
30
|
+
) : (
|
|
31
|
+
<Search
|
|
32
|
+
className="pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"
|
|
33
|
+
aria-hidden
|
|
34
|
+
/>
|
|
35
|
+
)}
|
|
36
|
+
<Input
|
|
37
|
+
{...props}
|
|
38
|
+
value={value}
|
|
39
|
+
onChange={(e) => onChange(e.target.value)}
|
|
40
|
+
placeholder={placeholder}
|
|
41
|
+
className={cn("h-8 rounded-lg pl-9 text-sm", showClear && "pr-8")}
|
|
42
|
+
/>
|
|
43
|
+
{showClear && (
|
|
44
|
+
<Button
|
|
45
|
+
type="button"
|
|
46
|
+
variant="ghost"
|
|
47
|
+
size="icon-xs"
|
|
48
|
+
aria-label="Clear search"
|
|
49
|
+
onClick={() => onChange("")}
|
|
50
|
+
className="absolute right-1.5 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground"
|
|
51
|
+
>
|
|
52
|
+
<X aria-hidden strokeWidth={3} />
|
|
53
|
+
</Button>
|
|
54
|
+
)}
|
|
55
|
+
</div>
|
|
56
|
+
);
|
|
57
|
+
}
|