create-expo-updates-server 0.1.5 → 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/dist/template/.dockerignore +16 -0
- package/dist/template/README.md +51 -660
- package/dist/template/app/api/admin/device-targets/route.test.ts +43 -0
- package/dist/template/app/api/admin/device-targets/route.ts +91 -0
- package/dist/template/app/api/admin/devices/route.test.ts +41 -0
- package/dist/template/app/api/admin/devices/route.ts +15 -0
- package/dist/template/app/api/admin/updates/[encodedKey]/audience/route.ts +75 -0
- package/dist/template/app/api/device-heartbeat/route.ts +2 -0
- package/dist/template/app/globals.css +114 -15
- package/dist/template/app/layout.tsx +12 -4
- package/dist/template/app/login/page.tsx +22 -18
- package/dist/template/app/updates/[encodedKey]/page.tsx +112 -88
- package/dist/template/app/updates/devices/page.tsx +264 -0
- package/dist/template/app/updates/embedded/page.tsx +102 -68
- package/dist/template/app/updates/emergency-redirects/page.tsx +144 -111
- package/dist/template/app/updates/layout.tsx +6 -1
- package/dist/template/app/updates/page.tsx +262 -212
- package/dist/template/components/admin/admin-shell.tsx +196 -0
- package/dist/template/components/admin/language-switcher.tsx +25 -0
- package/dist/template/components/admin/theme-provider.tsx +15 -0
- package/dist/template/components/ui/alert.tsx +65 -0
- package/dist/template/components/ui/badge.tsx +47 -0
- package/dist/template/components/ui/button.tsx +63 -0
- package/dist/template/components/ui/card.tsx +91 -0
- package/dist/template/components/ui/chart.tsx +373 -0
- package/dist/template/components/ui/checkbox.tsx +31 -0
- package/dist/template/components/ui/dialog.tsx +158 -0
- package/dist/template/components/ui/dropdown-menu.tsx +256 -0
- package/dist/template/components/ui/input.tsx +20 -0
- package/dist/template/components/ui/label.tsx +23 -0
- package/dist/template/components/ui/native-select.tsx +61 -0
- package/dist/template/components/ui/popover.tsx +88 -0
- package/dist/template/components/ui/scroll-area.tsx +57 -0
- package/dist/template/components/ui/select.tsx +189 -0
- package/dist/template/components/ui/separator.tsx +27 -0
- package/dist/template/components/ui/sheet.tsx +142 -0
- package/dist/template/components/ui/sidebar.tsx +736 -0
- package/dist/template/components/ui/skeleton.tsx +13 -0
- package/dist/template/components/ui/switch.tsx +34 -0
- package/dist/template/components/ui/table.tsx +115 -0
- package/dist/template/components/ui/tabs.tsx +90 -0
- package/dist/template/components/ui/textarea.tsx +17 -0
- package/dist/template/components/ui/tooltip.tsx +56 -0
- package/dist/template/components.json +22 -0
- package/dist/template/docs/admin-ui.md +35 -0
- package/dist/template/docs/device-targeting.md +129 -0
- package/dist/template/docs/doctor.md +137 -0
- package/dist/template/docs/expo-app-setup.md +174 -47
- package/dist/template/docs/getting-started.md +105 -146
- package/dist/template/docs/getting-started.ru.md +106 -191
- package/dist/template/docs/index.md +14 -33
- package/dist/template/docs/installation-telemetry.md +233 -0
- package/dist/template/docs/migrations/2026-10-16-manifest-identity.sql +89 -0
- package/dist/template/docs/migrations/2026-10-19-device-heartbeat.sql +131 -0
- package/dist/template/docs/migrations/2026-10-22-device-analytics.sql +264 -0
- package/dist/template/docs/migrations/2026-10-22-device-targeting-activation.sql +108 -0
- package/dist/template/docs/migrations/2026-10-22-device-targeting.sql +130 -0
- package/dist/template/docs/migrations/2026-10-22-device-version-metadata.sql +154 -0
- package/dist/template/docs/migrations/schema.sql +868 -6
- package/dist/template/docs/npm-installer.md +15 -30
- package/dist/template/docs/operations-guide.md +87 -0
- package/dist/template/docs/ota-client-lifecycle.md +263 -0
- package/dist/template/docs/ota-update-policy.md +36 -2
- package/dist/template/docs/supabase-setup.md +4 -0
- package/dist/template/hooks/use-mobile.ts +21 -0
- package/dist/template/lib/utils.ts +6 -0
- package/dist/template/package-lock.json +2325 -101
- package/dist/template/package.json +13 -3
- package/dist/template/scripts/configure-expo-app.mjs +11 -15
- package/dist/template/scripts/doctor.mjs +51 -0
- package/dist/template/scripts/ensure-test-bucket.mjs +21 -0
- package/dist/template/scripts/lib/device-identity.test.ts +29 -0
- package/dist/template/scripts/lib/doctor-probes.mjs +139 -0
- package/dist/template/scripts/lib/doctor.mjs +208 -0
- package/dist/template/scripts/lib/doctor.test.mjs +262 -0
- package/dist/template/scripts/lib/expo-app-configurator.mjs +14 -9
- package/dist/template/scripts/lib/expo-app-configurator.test.ts +3 -2
- package/dist/template/scripts/lib/ota-client-configurator.mjs +69 -0
- package/dist/template/scripts/lib/ota-client-configurator.test.ts +88 -0
- package/dist/template/scripts/lib/ota-client.test.ts +55 -0
- package/dist/template/scripts/lib/ota-root-hook-patcher.mjs +173 -0
- package/dist/template/scripts/lib/ota-root-hook-patcher.test.ts +123 -0
- package/dist/template/scripts/lib/ota-update-controller.test.ts +231 -0
- package/dist/template/scripts/tests/device-analytics-migrations.mjs +80 -0
- package/dist/template/scripts/tests/device-analytics.mjs +126 -0
- package/dist/template/scripts/tests/device-heartbeat.mjs +86 -0
- package/dist/template/scripts/tests/device-targeting-activation.mjs +111 -0
- package/dist/template/scripts/tests/device-targeting.mjs +39 -0
- package/dist/template/scripts/tests/device-version-metadata.mjs +31 -0
- package/dist/template/scripts/tests/manifest-identity-concurrency.mjs +106 -0
- package/dist/template/scripts/tests/manifest-identity.sql +204 -0
- package/dist/template/src/client/admin-types.ts +1 -0
- package/dist/template/src/client/devices/analytics.tsx +429 -0
- package/dist/template/src/client/devices/device-name.tsx +82 -0
- package/dist/template/src/client/devices/registry.tsx +399 -0
- package/dist/template/src/client/devices/use-devices-report.ts +108 -0
- package/dist/template/src/client/devices/version-adoption-chart.tsx +269 -0
- package/dist/template/src/client/devices/version-groups.test.ts +57 -0
- package/dist/template/src/client/devices/version-groups.ts +101 -0
- package/dist/template/src/client/distribution-control.tsx +135 -81
- package/dist/template/src/client/guard-action-combobox.tsx +13 -24
- package/dist/template/src/client/i18n/en.json +286 -0
- package/dist/template/src/client/i18n/messages.test.ts +42 -0
- package/dist/template/src/client/i18n/messages.ts +31 -0
- package/dist/template/src/client/i18n/provider.tsx +55 -0
- package/dist/template/src/client/i18n/use-formatters.ts +38 -0
- package/dist/template/src/client/logout-button.tsx +3 -1
- package/dist/template/src/client/update-audience-editor.tsx +285 -0
- package/dist/template/src/client/update-policy-editor.tsx +53 -41
- package/dist/template/src/server/controllers/manifest.test.ts +250 -7
- package/dist/template/src/server/controllers/manifest.ts +39 -31
- package/dist/template/src/server/devices/audience.test.ts +48 -0
- package/dist/template/src/server/devices/audience.ts +86 -0
- package/dist/template/src/server/devices/heartbeat.test.ts +39 -0
- package/dist/template/src/server/devices/heartbeat.ts +75 -0
- package/dist/template/src/server/devices/report-types.ts +114 -0
- package/dist/template/src/server/devices/report.test.ts +29 -0
- package/dist/template/src/server/devices/report.ts +27 -0
- package/dist/template/src/server/lib/admin-audience-activation.test.ts +94 -0
- package/dist/template/src/server/lib/admin-updates.ts +32 -168
- package/dist/template/src/server/lib/distribution-control.test.ts +23 -2
- package/dist/template/src/server/lib/distribution-control.ts +13 -4
- package/dist/template/src/server/lib/supabase.js +10 -10
- package/dist/template/src/server/lib/supabase.test.ts +11 -0
- package/dist/template/src/server/manifest/manifest-identity.test.ts +30 -0
- package/dist/template/src/server/manifest/manifest-identity.ts +24 -0
- package/dist/template/src/server/manifest/manifest-repository.ts +31 -102
- package/dist/template/src/server/manifest/manifest-response.ts +1 -1
- package/dist/template/templates/expo-app/ota-client/README.md +59 -0
- package/dist/template/templates/expo-app/ota-client/controller.js +60 -0
- package/dist/template/templates/expo-app/ota-client/device-identity.js +26 -0
- package/dist/template/templates/expo-app/ota-client/docs/update-lifecycle.md +52 -0
- package/dist/template/templates/expo-app/ota-client/index.d.ts +47 -0
- package/dist/template/templates/expo-app/ota-client/index.js +3 -0
- package/dist/template/templates/expo-app/ota-client/model/hooks/useOtaUpdates.js +48 -0
- package/dist/template/templates/expo-app/ota-client/model/update-controller.js +182 -0
- package/dist/template/templates/expo-app/ota-client/runtime.js +112 -0
- package/dist/template/templates/expo-app/ota-client/ui/ota-update-gate.js +56 -0
- package/dist/template-manifest.json +582 -77
- package/lib/cli.mjs +4 -6
- package/package.json +1 -1
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { LanguageSwitcher } from "@/components/admin/language-switcher";
|
|
3
|
+
import { useI18n } from "@/src/client/i18n/provider";
|
|
4
|
+
|
|
5
|
+
import Link from "next/link";
|
|
6
|
+
import { usePathname, useRouter } from "next/navigation";
|
|
7
|
+
import { useTheme } from "next-themes";
|
|
8
|
+
import { useState, type CSSProperties } from "react";
|
|
9
|
+
import {
|
|
10
|
+
Activity,
|
|
11
|
+
ArrowUpToLine,
|
|
12
|
+
Boxes,
|
|
13
|
+
ShieldAlert,
|
|
14
|
+
Smartphone,
|
|
15
|
+
LogOut,
|
|
16
|
+
Moon,
|
|
17
|
+
Sun,
|
|
18
|
+
} from "lucide-react";
|
|
19
|
+
import { adminLogout } from "@/src/client/admin-api";
|
|
20
|
+
import { Button } from "@/components/ui/button";
|
|
21
|
+
import { Badge } from "@/components/ui/badge";
|
|
22
|
+
import {
|
|
23
|
+
Sidebar,
|
|
24
|
+
SidebarContent,
|
|
25
|
+
SidebarFooter,
|
|
26
|
+
SidebarHeader,
|
|
27
|
+
SidebarGroup,
|
|
28
|
+
SidebarGroupLabel,
|
|
29
|
+
SidebarGroupContent,
|
|
30
|
+
SidebarMenu,
|
|
31
|
+
SidebarMenuItem,
|
|
32
|
+
SidebarMenuButton,
|
|
33
|
+
SidebarProvider,
|
|
34
|
+
SidebarInset,
|
|
35
|
+
SidebarTrigger,
|
|
36
|
+
useSidebar,
|
|
37
|
+
} from "@/components/ui/sidebar";
|
|
38
|
+
function Navigation() {
|
|
39
|
+
const { t } = useI18n();
|
|
40
|
+
const navigation = [
|
|
41
|
+
{ href: "/updates/devices", label: t("Установки"), icon: Smartphone },
|
|
42
|
+
{ href: "/updates", label: t("OTA-обновления"), icon: ArrowUpToLine },
|
|
43
|
+
{ href: "/updates/embedded", label: t("Embedded-сборки"), icon: Boxes },
|
|
44
|
+
{
|
|
45
|
+
href: "/updates/emergency-redirects",
|
|
46
|
+
label: t("Аварийные маршруты"),
|
|
47
|
+
icon: ShieldAlert,
|
|
48
|
+
},
|
|
49
|
+
];
|
|
50
|
+
|
|
51
|
+
const path = usePathname();
|
|
52
|
+
const { setOpenMobile } = useSidebar();
|
|
53
|
+
return (
|
|
54
|
+
<SidebarMenu>
|
|
55
|
+
{navigation.map(({ href, label, icon: Icon }) => (
|
|
56
|
+
<SidebarMenuItem key={href}>
|
|
57
|
+
<SidebarMenuButton
|
|
58
|
+
asChild
|
|
59
|
+
isActive={
|
|
60
|
+
href === "/updates"
|
|
61
|
+
? path === href ||
|
|
62
|
+
!navigation
|
|
63
|
+
.slice(0, 1)
|
|
64
|
+
.concat(navigation.slice(2))
|
|
65
|
+
.some((n) => path.startsWith(n.href))
|
|
66
|
+
: path.startsWith(href)
|
|
67
|
+
}
|
|
68
|
+
tooltip={label}
|
|
69
|
+
>
|
|
70
|
+
<Link href={href} onClick={() => setOpenMobile(false)}>
|
|
71
|
+
<Icon aria-hidden="true" />
|
|
72
|
+
<span>{label}</span>
|
|
73
|
+
</Link>
|
|
74
|
+
</SidebarMenuButton>
|
|
75
|
+
</SidebarMenuItem>
|
|
76
|
+
))}
|
|
77
|
+
</SidebarMenu>
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
export function AdminShell({
|
|
81
|
+
children,
|
|
82
|
+
session,
|
|
83
|
+
}: {
|
|
84
|
+
children: React.ReactNode;
|
|
85
|
+
session: { username: string; role: string };
|
|
86
|
+
}) {
|
|
87
|
+
const { t } = useI18n();
|
|
88
|
+
const { resolvedTheme, setTheme } = useTheme();
|
|
89
|
+
const router = useRouter();
|
|
90
|
+
const [busy, setBusy] = useState(false);
|
|
91
|
+
const [error, setError] = useState("");
|
|
92
|
+
async function logout() {
|
|
93
|
+
setBusy(true);
|
|
94
|
+
try {
|
|
95
|
+
await adminLogout();
|
|
96
|
+
router.replace("/login");
|
|
97
|
+
} catch {
|
|
98
|
+
setError("Не удалось выйти. Попробуйте ещё раз.");
|
|
99
|
+
} finally {
|
|
100
|
+
setBusy(false);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return (
|
|
104
|
+
<SidebarProvider style={{ "--sidebar-width": "14rem" } as CSSProperties}>
|
|
105
|
+
<a
|
|
106
|
+
href="#main-content"
|
|
107
|
+
className="sr-only focus:not-sr-only focus:fixed focus:left-4 focus:top-4 focus:z-50 focus:rounded focus:bg-card focus:p-3"
|
|
108
|
+
>
|
|
109
|
+
{t("К содержимому")}
|
|
110
|
+
</a>
|
|
111
|
+
<Sidebar collapsible="offcanvas">
|
|
112
|
+
<SidebarHeader className="h-20 justify-center border-b px-5">
|
|
113
|
+
<Link
|
|
114
|
+
href="/updates/devices"
|
|
115
|
+
className="flex items-center gap-3 font-semibold text-foreground"
|
|
116
|
+
>
|
|
117
|
+
<span className="flex size-9 items-center justify-center rounded-xl bg-primary text-primary-foreground">
|
|
118
|
+
<Activity className="size-5" />
|
|
119
|
+
</span>
|
|
120
|
+
<span>
|
|
121
|
+
OTA Console
|
|
122
|
+
<span className="block text-[10px] font-medium uppercase tracking-[.18em] text-muted-foreground">
|
|
123
|
+
Release workspace
|
|
124
|
+
</span>
|
|
125
|
+
</span>
|
|
126
|
+
</Link>
|
|
127
|
+
</SidebarHeader>
|
|
128
|
+
<SidebarContent className="p-2">
|
|
129
|
+
<SidebarGroup>
|
|
130
|
+
<SidebarGroupLabel>{t("Управление")}</SidebarGroupLabel>
|
|
131
|
+
<SidebarGroupContent>
|
|
132
|
+
<Navigation />
|
|
133
|
+
</SidebarGroupContent>
|
|
134
|
+
</SidebarGroup>
|
|
135
|
+
</SidebarContent>
|
|
136
|
+
<SidebarFooter className="gap-3 border-t p-4">
|
|
137
|
+
<div className="flex items-center gap-3">
|
|
138
|
+
<span className="flex size-9 shrink-0 items-center justify-center rounded-full bg-muted text-sm font-semibold uppercase">
|
|
139
|
+
{session.username.slice(0, 2)}
|
|
140
|
+
</span>
|
|
141
|
+
<div className="min-w-0">
|
|
142
|
+
<p className="truncate text-sm font-medium text-foreground">
|
|
143
|
+
{session.username}
|
|
144
|
+
</p>
|
|
145
|
+
<p className="text-xs text-muted-foreground">{session.role}</p>
|
|
146
|
+
</div>
|
|
147
|
+
</div>
|
|
148
|
+
{error && (
|
|
149
|
+
<p role="alert" className="text-xs text-destructive">
|
|
150
|
+
{t(error)}
|
|
151
|
+
</p>
|
|
152
|
+
)}
|
|
153
|
+
<Button
|
|
154
|
+
variant="ghost"
|
|
155
|
+
className="justify-start"
|
|
156
|
+
disabled={busy}
|
|
157
|
+
onClick={logout}
|
|
158
|
+
>
|
|
159
|
+
<LogOut />
|
|
160
|
+
{busy ? t("Выход…") : t("Выйти")}
|
|
161
|
+
</Button>
|
|
162
|
+
</SidebarFooter>
|
|
163
|
+
</Sidebar>
|
|
164
|
+
<SidebarInset className="min-w-0 bg-background">
|
|
165
|
+
<header className="flex h-16 shrink-0 items-center justify-between gap-4 border-b bg-card/80 px-4 md:px-8">
|
|
166
|
+
<div className="flex items-center gap-3">
|
|
167
|
+
<SidebarTrigger aria-label={t("Открыть или скрыть навигацию")} />
|
|
168
|
+
<span className="text-sm text-muted-foreground">
|
|
169
|
+
{t("Управление обновлениями")}
|
|
170
|
+
</span>
|
|
171
|
+
</div>
|
|
172
|
+
<div className="flex items-center gap-2">
|
|
173
|
+
<LanguageSwitcher />
|
|
174
|
+
<Badge variant="outline" className="hidden sm:inline-flex">
|
|
175
|
+
Expo OTA
|
|
176
|
+
</Badge>
|
|
177
|
+
<Button
|
|
178
|
+
variant="ghost"
|
|
179
|
+
size="icon"
|
|
180
|
+
aria-label={t("Переключить светлую и тёмную тему")}
|
|
181
|
+
onClick={() =>
|
|
182
|
+
setTheme(resolvedTheme === "dark" ? "light" : "dark")
|
|
183
|
+
}
|
|
184
|
+
>
|
|
185
|
+
<Moon className="dark:hidden" />
|
|
186
|
+
<Sun className="hidden dark:block" />
|
|
187
|
+
</Button>
|
|
188
|
+
</div>
|
|
189
|
+
</header>
|
|
190
|
+
<div id="main-content" className="min-w-0 flex-1">
|
|
191
|
+
{children}
|
|
192
|
+
</div>
|
|
193
|
+
</SidebarInset>
|
|
194
|
+
</SidebarProvider>
|
|
195
|
+
);
|
|
196
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useI18n } from "@/src/client/i18n/provider";
|
|
4
|
+
import { resolveLocale } from "@/src/client/i18n/messages";
|
|
5
|
+
|
|
6
|
+
export function LanguageSwitcher() {
|
|
7
|
+
const { locale, setLocale } = useI18n();
|
|
8
|
+
const label = locale === "en" ? "Interface language" : "Язык интерфейса";
|
|
9
|
+
return (
|
|
10
|
+
<select
|
|
11
|
+
aria-label={label}
|
|
12
|
+
title={label}
|
|
13
|
+
value={locale}
|
|
14
|
+
onChange={(event) => setLocale(resolveLocale(event.target.value))}
|
|
15
|
+
className="h-9 rounded-md border border-input bg-background px-2 text-sm text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
|
|
16
|
+
>
|
|
17
|
+
<option value="en" lang="en">
|
|
18
|
+
English
|
|
19
|
+
</option>
|
|
20
|
+
<option value="ru" lang="ru">
|
|
21
|
+
Русский
|
|
22
|
+
</option>
|
|
23
|
+
</select>
|
|
24
|
+
);
|
|
25
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { ThemeProvider as Provider } from "next-themes";
|
|
3
|
+
export function ThemeProvider({ children }: { children: React.ReactNode }) {
|
|
4
|
+
return (
|
|
5
|
+
<Provider
|
|
6
|
+
attribute="class"
|
|
7
|
+
defaultTheme="dark"
|
|
8
|
+
storageKey="ota-console-theme"
|
|
9
|
+
enableSystem
|
|
10
|
+
disableTransitionOnChange
|
|
11
|
+
>
|
|
12
|
+
{children}
|
|
13
|
+
</Provider>
|
|
14
|
+
);
|
|
15
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { cva, type VariantProps } from "class-variance-authority";
|
|
3
|
+
import { cn } from "@/lib/utils";
|
|
4
|
+
|
|
5
|
+
const alertVariants = cva(
|
|
6
|
+
"relative grid w-full grid-cols-[0_1fr] items-start gap-y-0.5 rounded-lg border px-4 py-3 text-sm has-[>svg]:grid-cols-[calc(var(--spacing)*4)_1fr] has-[>svg]:gap-x-3 [&>svg]:size-4 [&>svg]:translate-y-0.5 [&>svg]:text-current",
|
|
7
|
+
{
|
|
8
|
+
variants: {
|
|
9
|
+
variant: {
|
|
10
|
+
default: "bg-card text-card-foreground",
|
|
11
|
+
destructive:
|
|
12
|
+
"bg-card text-destructive *:data-[slot=alert-description]:text-destructive/90 [&>svg]:text-current",
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
defaultVariants: {
|
|
16
|
+
variant: "default",
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
function Alert({
|
|
22
|
+
className,
|
|
23
|
+
variant,
|
|
24
|
+
...props
|
|
25
|
+
}: React.ComponentProps<"div"> & VariantProps<typeof alertVariants>) {
|
|
26
|
+
return (
|
|
27
|
+
<div
|
|
28
|
+
data-slot="alert"
|
|
29
|
+
role="alert"
|
|
30
|
+
className={cn(alertVariants({ variant }), className)}
|
|
31
|
+
{...props}
|
|
32
|
+
/>
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function AlertTitle({ className, ...props }: React.ComponentProps<"div">) {
|
|
37
|
+
return (
|
|
38
|
+
<div
|
|
39
|
+
data-slot="alert-title"
|
|
40
|
+
className={cn(
|
|
41
|
+
"col-start-2 line-clamp-1 min-h-4 font-medium tracking-tight",
|
|
42
|
+
className,
|
|
43
|
+
)}
|
|
44
|
+
{...props}
|
|
45
|
+
/>
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function AlertDescription({
|
|
50
|
+
className,
|
|
51
|
+
...props
|
|
52
|
+
}: React.ComponentProps<"div">) {
|
|
53
|
+
return (
|
|
54
|
+
<div
|
|
55
|
+
data-slot="alert-description"
|
|
56
|
+
className={cn(
|
|
57
|
+
"col-start-2 grid justify-items-start gap-1 text-sm text-muted-foreground [&_p]:leading-relaxed",
|
|
58
|
+
className,
|
|
59
|
+
)}
|
|
60
|
+
{...props}
|
|
61
|
+
/>
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export { Alert, AlertTitle, AlertDescription };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { cva, type VariantProps } from "class-variance-authority";
|
|
3
|
+
import { cn } from "@/lib/utils";
|
|
4
|
+
import { Slot } from "radix-ui";
|
|
5
|
+
|
|
6
|
+
const badgeVariants = cva(
|
|
7
|
+
"inline-flex w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-full border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-[color,box-shadow] focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3",
|
|
8
|
+
{
|
|
9
|
+
variants: {
|
|
10
|
+
variant: {
|
|
11
|
+
default: "bg-primary text-primary-foreground [a&]:hover:bg-primary/90",
|
|
12
|
+
secondary:
|
|
13
|
+
"bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",
|
|
14
|
+
destructive:
|
|
15
|
+
"bg-destructive text-white focus-visible:ring-destructive/20 dark:bg-destructive/60 dark:focus-visible:ring-destructive/40 [a&]:hover:bg-destructive/90",
|
|
16
|
+
outline:
|
|
17
|
+
"border-border text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground",
|
|
18
|
+
ghost: "[a&]:hover:bg-accent [a&]:hover:text-accent-foreground",
|
|
19
|
+
link: "text-primary underline-offset-4 [a&]:hover:underline",
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
defaultVariants: {
|
|
23
|
+
variant: "default",
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
function Badge({
|
|
29
|
+
className,
|
|
30
|
+
variant = "default",
|
|
31
|
+
asChild = false,
|
|
32
|
+
...props
|
|
33
|
+
}: React.ComponentProps<"span"> &
|
|
34
|
+
VariantProps<typeof badgeVariants> & { asChild?: boolean }) {
|
|
35
|
+
const Comp = asChild ? Slot.Root : "span";
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<Comp
|
|
39
|
+
data-slot="badge"
|
|
40
|
+
data-variant={variant}
|
|
41
|
+
className={cn(badgeVariants({ variant }), className)}
|
|
42
|
+
{...props}
|
|
43
|
+
/>
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export { Badge, badgeVariants };
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { cva, type VariantProps } from "class-variance-authority";
|
|
3
|
+
import { cn } from "@/lib/utils";
|
|
4
|
+
import { Slot } from "radix-ui";
|
|
5
|
+
|
|
6
|
+
const buttonVariants = cva(
|
|
7
|
+
"inline-flex shrink-0 items-center justify-center gap-2 rounded-md text-sm font-medium whitespace-nowrap transition-all outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
8
|
+
{
|
|
9
|
+
variants: {
|
|
10
|
+
variant: {
|
|
11
|
+
default: "bg-primary text-primary-foreground hover:bg-primary/90",
|
|
12
|
+
destructive:
|
|
13
|
+
"bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:bg-destructive/60 dark:focus-visible:ring-destructive/40",
|
|
14
|
+
outline:
|
|
15
|
+
"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",
|
|
16
|
+
secondary:
|
|
17
|
+
"bg-secondary text-secondary-foreground hover:bg-secondary/80",
|
|
18
|
+
ghost:
|
|
19
|
+
"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",
|
|
20
|
+
link: "text-primary underline-offset-4 hover:underline",
|
|
21
|
+
},
|
|
22
|
+
size: {
|
|
23
|
+
default: "h-9 px-4 py-2 has-[>svg]:px-3",
|
|
24
|
+
xs: "h-6 gap-1 rounded-md px-2 text-xs has-[>svg]:px-1.5 [&_svg:not([class*='size-'])]:size-3",
|
|
25
|
+
sm: "h-8 gap-1.5 rounded-md px-3 has-[>svg]:px-2.5",
|
|
26
|
+
lg: "h-10 rounded-md px-6 has-[>svg]:px-4",
|
|
27
|
+
icon: "size-9",
|
|
28
|
+
"icon-xs": "size-6 rounded-md [&_svg:not([class*='size-'])]:size-3",
|
|
29
|
+
"icon-sm": "size-8",
|
|
30
|
+
"icon-lg": "size-10",
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
defaultVariants: {
|
|
34
|
+
variant: "default",
|
|
35
|
+
size: "default",
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
function Button({
|
|
41
|
+
className,
|
|
42
|
+
variant = "default",
|
|
43
|
+
size = "default",
|
|
44
|
+
asChild = false,
|
|
45
|
+
...props
|
|
46
|
+
}: React.ComponentProps<"button"> &
|
|
47
|
+
VariantProps<typeof buttonVariants> & {
|
|
48
|
+
asChild?: boolean;
|
|
49
|
+
}) {
|
|
50
|
+
const Comp = asChild ? Slot.Root : "button";
|
|
51
|
+
|
|
52
|
+
return (
|
|
53
|
+
<Comp
|
|
54
|
+
data-slot="button"
|
|
55
|
+
data-variant={variant}
|
|
56
|
+
data-size={size}
|
|
57
|
+
className={cn(buttonVariants({ variant, size, className }))}
|
|
58
|
+
{...props}
|
|
59
|
+
/>
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export { Button, buttonVariants };
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { cn } from "@/lib/utils";
|
|
3
|
+
|
|
4
|
+
function Card({ className, ...props }: React.ComponentProps<"div">) {
|
|
5
|
+
return (
|
|
6
|
+
<div
|
|
7
|
+
data-slot="card"
|
|
8
|
+
className={cn(
|
|
9
|
+
"flex flex-col gap-6 rounded-xl border bg-card py-6 text-card-foreground shadow-sm",
|
|
10
|
+
className,
|
|
11
|
+
)}
|
|
12
|
+
{...props}
|
|
13
|
+
/>
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function CardHeader({ className, ...props }: React.ComponentProps<"div">) {
|
|
18
|
+
return (
|
|
19
|
+
<div
|
|
20
|
+
data-slot="card-header"
|
|
21
|
+
className={cn(
|
|
22
|
+
"@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-2 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6",
|
|
23
|
+
className,
|
|
24
|
+
)}
|
|
25
|
+
{...props}
|
|
26
|
+
/>
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function CardTitle({ className, ...props }: React.ComponentProps<"div">) {
|
|
31
|
+
return (
|
|
32
|
+
<div
|
|
33
|
+
data-slot="card-title"
|
|
34
|
+
className={cn("leading-none font-semibold", className)}
|
|
35
|
+
{...props}
|
|
36
|
+
/>
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function CardDescription({ className, ...props }: React.ComponentProps<"div">) {
|
|
41
|
+
return (
|
|
42
|
+
<div
|
|
43
|
+
data-slot="card-description"
|
|
44
|
+
className={cn("text-sm text-muted-foreground", className)}
|
|
45
|
+
{...props}
|
|
46
|
+
/>
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function CardAction({ className, ...props }: React.ComponentProps<"div">) {
|
|
51
|
+
return (
|
|
52
|
+
<div
|
|
53
|
+
data-slot="card-action"
|
|
54
|
+
className={cn(
|
|
55
|
+
"col-start-2 row-span-2 row-start-1 self-start justify-self-end",
|
|
56
|
+
className,
|
|
57
|
+
)}
|
|
58
|
+
{...props}
|
|
59
|
+
/>
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function CardContent({ className, ...props }: React.ComponentProps<"div">) {
|
|
64
|
+
return (
|
|
65
|
+
<div
|
|
66
|
+
data-slot="card-content"
|
|
67
|
+
className={cn("px-6", className)}
|
|
68
|
+
{...props}
|
|
69
|
+
/>
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function CardFooter({ className, ...props }: React.ComponentProps<"div">) {
|
|
74
|
+
return (
|
|
75
|
+
<div
|
|
76
|
+
data-slot="card-footer"
|
|
77
|
+
className={cn("flex items-center px-6 [.border-t]:pt-6", className)}
|
|
78
|
+
{...props}
|
|
79
|
+
/>
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export {
|
|
84
|
+
Card,
|
|
85
|
+
CardHeader,
|
|
86
|
+
CardFooter,
|
|
87
|
+
CardTitle,
|
|
88
|
+
CardAction,
|
|
89
|
+
CardDescription,
|
|
90
|
+
CardContent,
|
|
91
|
+
};
|