@ploykit/ui 0.0.0-stage → 0.1.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/README.md +41 -3
- package/dist/components/ConfirmDialog.d.ts +13 -0
- package/dist/components/ConfirmDialog.js +29 -0
- package/dist/components/CronInput.d.ts +15 -0
- package/dist/components/CronInput.js +112 -0
- package/dist/components/DataTable.d.ts +22 -0
- package/dist/components/DataTable.js +13 -0
- package/dist/components/ErrorBoundary.d.ts +16 -0
- package/dist/components/ErrorBoundary.js +24 -0
- package/dist/components/FormField.d.ts +10 -0
- package/dist/components/FormField.js +22 -0
- package/dist/components/ImpersonationBanner.d.ts +3 -0
- package/dist/components/ImpersonationBanner.js +10 -0
- package/dist/components/NotificationBell.d.ts +3 -0
- package/dist/components/NotificationBell.js +47 -0
- package/dist/components/OnboardingChecklist.d.ts +12 -0
- package/dist/components/OnboardingChecklist.js +43 -0
- package/dist/components/Page.d.ts +17 -0
- package/dist/components/Page.js +16 -0
- package/dist/components/SecretModal.d.ts +16 -0
- package/dist/components/SecretModal.js +45 -0
- package/dist/components/SettingsCard.d.ts +10 -0
- package/dist/components/SettingsCard.js +6 -0
- package/dist/components/SiteBanner.d.ts +6 -0
- package/dist/components/SiteBanner.js +11 -0
- package/dist/components/SiteBannerLayer.d.ts +4 -0
- package/dist/components/SiteBannerLayer.js +9 -0
- package/dist/components/UserMenu.d.ts +13 -0
- package/dist/components/UserMenu.js +30 -0
- package/dist/components/WorkspaceSwitcher.d.ts +1 -0
- package/dist/components/WorkspaceSwitcher.js +53 -0
- package/dist/components/toast.d.ts +7 -0
- package/dist/components/toast.js +11 -0
- package/dist/components/ui/Badge.d.ts +13 -0
- package/dist/components/ui/Badge.js +21 -0
- package/dist/components/ui/Button.d.ts +10 -0
- package/dist/components/ui/Button.js +33 -0
- package/dist/components/ui/Input.d.ts +3 -0
- package/dist/components/ui/Input.js +10 -0
- package/dist/components/ui/alert-dialog.d.ts +18 -0
- package/dist/components/ui/alert-dialog.js +41 -0
- package/dist/components/ui/avatar.d.ts +11 -0
- package/dist/components/ui/avatar.js +22 -0
- package/dist/components/ui/breadcrumb.d.ts +10 -0
- package/dist/components/ui/breadcrumb.js +36 -0
- package/dist/components/ui/card.d.ts +13 -0
- package/dist/components/ui/card.js +24 -0
- package/dist/components/ui/checkbox.d.ts +3 -0
- package/dist/components/ui/checkbox.js +8 -0
- package/dist/components/ui/dialog.d.ts +15 -0
- package/dist/components/ui/dialog.js +26 -0
- package/dist/components/ui/empty.d.ts +13 -0
- package/dist/components/ui/empty.js +36 -0
- package/dist/components/ui/field.d.ts +24 -0
- package/dist/components/ui/field.js +67 -0
- package/dist/components/ui/label.d.ts +3 -0
- package/dist/components/ui/label.js +6 -0
- package/dist/components/ui/menu.d.ts +29 -0
- package/dist/components/ui/menu.js +50 -0
- package/dist/components/ui/popover.d.ts +9 -0
- package/dist/components/ui/popover.js +22 -0
- package/dist/components/ui/progress.d.ts +7 -0
- package/dist/components/ui/progress.js +19 -0
- package/dist/components/ui/select.d.ts +15 -0
- package/dist/components/ui/select.js +33 -0
- package/dist/components/ui/separator.d.ts +3 -0
- package/dist/components/ui/separator.js +7 -0
- package/dist/components/ui/sheet.d.ts +14 -0
- package/dist/components/ui/sheet.js +36 -0
- package/dist/components/ui/sidebar.d.ts +63 -0
- package/dist/components/ui/sidebar.js +265 -0
- package/dist/components/ui/skeleton.d.ts +3 -0
- package/dist/components/ui/skeleton.js +6 -0
- package/dist/components/ui/switch.d.ts +5 -0
- package/dist/components/ui/switch.js +7 -0
- package/dist/components/ui/tabs.d.ts +10 -0
- package/dist/components/ui/tabs.js +28 -0
- package/dist/components/ui/tooltip.d.ts +6 -0
- package/dist/components/ui/tooltip.js +16 -0
- package/dist/hooks/use-mobile.d.ts +1 -0
- package/dist/hooks/use-mobile.js +15 -0
- package/dist/hooks/useApi.d.ts +10 -0
- package/dist/hooks/useApi.js +11 -0
- package/dist/hooks/useAudit.d.ts +39 -0
- package/dist/hooks/useAudit.js +55 -0
- package/dist/hooks/useAuth.d.ts +1 -0
- package/dist/hooks/useAuth.js +4 -0
- package/dist/hooks/useBilling.d.ts +44 -0
- package/dist/hooks/useBilling.js +64 -0
- package/dist/hooks/useLogin.d.ts +10 -0
- package/dist/hooks/useLogin.js +39 -0
- package/dist/hooks/useMembers.d.ts +125 -0
- package/dist/hooks/useMembers.js +127 -0
- package/dist/hooks/useNotificationPrefs.d.ts +20 -0
- package/dist/hooks/useNotificationPrefs.js +42 -0
- package/dist/hooks/usePasswordReset.d.ts +5 -0
- package/dist/hooks/usePasswordReset.js +12 -0
- package/dist/hooks/useSEO.d.ts +6 -0
- package/dist/hooks/useSEO.js +14 -0
- package/dist/hooks/useSessions.d.ts +20 -0
- package/dist/hooks/useSessions.js +38 -0
- package/dist/hooks/useSiteConfig.d.ts +12 -0
- package/dist/hooks/useSiteConfig.js +11 -0
- package/dist/hooks/useTokens.d.ts +36 -0
- package/dist/hooks/useTokens.js +35 -0
- package/dist/hooks/useUsage.d.ts +20 -0
- package/dist/hooks/useUsage.js +21 -0
- package/dist/hooks/useWorkspace.d.ts +26 -0
- package/dist/hooks/useWorkspace.js +32 -0
- package/dist/hooks/useZodForm.d.ts +6 -0
- package/dist/hooks/useZodForm.js +6 -0
- package/dist/hooks/ws.d.ts +4 -0
- package/dist/hooks/ws.js +21 -0
- package/dist/index.d.ts +124 -0
- package/dist/index.js +94 -0
- package/dist/layouts/AppShell.d.ts +20 -0
- package/dist/layouts/AppShell.js +21 -0
- package/dist/layouts/AuthShell.d.ts +7 -0
- package/dist/layouts/AuthShell.js +4 -0
- package/dist/layouts/SettingsShell.d.ts +19 -0
- package/dist/layouts/SettingsShell.js +21 -0
- package/dist/lib/api-error.d.ts +1 -0
- package/dist/lib/api-error.js +74 -0
- package/dist/lib/perm.d.ts +2 -0
- package/dist/lib/perm.js +7 -0
- package/dist/lib/utils.d.ts +12 -0
- package/dist/lib/utils.js +84 -0
- package/dist/lib/ws-query-bridge.d.ts +7 -0
- package/dist/lib/ws-query-bridge.js +35 -0
- package/dist/pages/LandingPage.d.ts +22 -0
- package/dist/pages/LandingPage.js +5 -0
- package/dist/pages/LoginPage.d.ts +15 -0
- package/dist/pages/LoginPage.js +87 -0
- package/dist/pages/account/NotificationPreferencesPage.d.ts +13 -0
- package/dist/pages/account/NotificationPreferencesPage.js +41 -0
- package/dist/pages/account/ProfileSettingsPage.d.ts +4 -0
- package/dist/pages/account/ProfileSettingsPage.js +96 -0
- package/dist/pages/account/SecuritySettingsPage.d.ts +1 -0
- package/dist/pages/account/SecuritySettingsPage.js +134 -0
- package/dist/pages/account/TokensPage.d.ts +1 -0
- package/dist/pages/account/TokensPage.js +117 -0
- package/dist/pages/admin/AdminSettingsPage.d.ts +1 -0
- package/dist/pages/admin/AdminSettingsPage.js +210 -0
- package/dist/pages/admin/AdminShell.d.ts +7 -0
- package/dist/pages/admin/AdminShell.js +79 -0
- package/dist/pages/admin/AuditPage.d.ts +1 -0
- package/dist/pages/admin/AuditPage.js +164 -0
- package/dist/pages/admin/OrdersPage.d.ts +1 -0
- package/dist/pages/admin/OrdersPage.js +236 -0
- package/dist/pages/admin/OverviewPage.d.ts +1 -0
- package/dist/pages/admin/OverviewPage.js +200 -0
- package/dist/pages/admin/SSOPage.d.ts +1 -0
- package/dist/pages/admin/SSOPage.js +53 -0
- package/dist/pages/admin/UserDetailPage.d.ts +1 -0
- package/dist/pages/admin/UserDetailPage.js +266 -0
- package/dist/pages/admin/UsersPage.d.ts +4 -0
- package/dist/pages/admin/UsersPage.js +201 -0
- package/dist/pages/admin/WebhookDeliveriesPage.d.ts +1 -0
- package/dist/pages/admin/WebhookDeliveriesPage.js +128 -0
- package/dist/pages/admin/WorkspaceDetailPage.d.ts +1 -0
- package/dist/pages/admin/WorkspaceDetailPage.js +202 -0
- package/dist/pages/admin/WorkspacesPage.d.ts +1 -0
- package/dist/pages/admin/WorkspacesPage.js +133 -0
- package/dist/pages/admin/shared.d.ts +8 -0
- package/dist/pages/admin/shared.js +23 -0
- package/dist/pages/auth/ForgotPasswordPage.d.ts +6 -0
- package/dist/pages/auth/ForgotPasswordPage.js +32 -0
- package/dist/pages/auth/InviteAcceptPage.d.ts +5 -0
- package/dist/pages/auth/InviteAcceptPage.js +40 -0
- package/dist/pages/auth/RegisterPage.d.ts +15 -0
- package/dist/pages/auth/RegisterPage.js +80 -0
- package/dist/pages/auth/ResetPasswordPage.d.ts +4 -0
- package/dist/pages/auth/ResetPasswordPage.js +71 -0
- package/dist/pages/auth/VerifyEmailPage.d.ts +1 -0
- package/dist/pages/auth/VerifyEmailPage.js +45 -0
- package/dist/pages/workspace/BillingPage.d.ts +4 -0
- package/dist/pages/workspace/BillingPage.js +183 -0
- package/dist/pages/workspace/BillingSuccessPage.d.ts +4 -0
- package/dist/pages/workspace/BillingSuccessPage.js +72 -0
- package/dist/pages/workspace/MembersPage.d.ts +3 -0
- package/dist/pages/workspace/MembersPage.js +262 -0
- package/dist/pages/workspace/SchedulesPage.d.ts +4 -0
- package/dist/pages/workspace/SchedulesPage.js +177 -0
- package/dist/pages/workspace/UsagePage.d.ts +15 -0
- package/dist/pages/workspace/UsagePage.js +74 -0
- package/dist/pages/workspace/WebhooksPage.d.ts +3 -0
- package/dist/pages/workspace/WebhooksPage.js +242 -0
- package/dist/pages/workspace/WorkspaceAuditPage.d.ts +3 -0
- package/dist/pages/workspace/WorkspaceAuditPage.js +109 -0
- package/dist/pages/workspace/WorkspaceGeneralPage.d.ts +4 -0
- package/dist/pages/workspace/WorkspaceGeneralPage.js +101 -0
- package/dist/provider/PloykitProvider.d.ts +50 -0
- package/dist/provider/PloykitProvider.js +240 -0
- package/dist/realtime.d.ts +3 -0
- package/dist/realtime.js +11 -0
- package/package.json +63 -6
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { mergeProps } from "@base-ui/react/merge-props";
|
|
4
|
+
import { useRender } from "@base-ui/react/use-render";
|
|
5
|
+
import { cva } from "class-variance-authority";
|
|
6
|
+
import { cn } from "../../lib/utils";
|
|
7
|
+
import { useIsMobile } from "../../hooks/use-mobile";
|
|
8
|
+
import { Button } from "./Button";
|
|
9
|
+
import { Input } from "./Input";
|
|
10
|
+
import { Separator } from "./separator";
|
|
11
|
+
import { Sheet, SheetContent, SheetDescription, SheetHeader, SheetTitle, } from "./sheet";
|
|
12
|
+
import { Skeleton } from "./skeleton";
|
|
13
|
+
import { Tooltip, TooltipContent, TooltipTrigger, } from "./tooltip";
|
|
14
|
+
import { PanelLeftIcon } from "lucide-react";
|
|
15
|
+
const SIDEBAR_COOKIE_NAME = "sidebar_state";
|
|
16
|
+
const SIDEBAR_COOKIE_MAX_AGE = 60 * 60 * 24 * 7;
|
|
17
|
+
const SIDEBAR_WIDTH = "16rem";
|
|
18
|
+
const SIDEBAR_WIDTH_MOBILE = "18rem";
|
|
19
|
+
const SIDEBAR_WIDTH_ICON = "3rem";
|
|
20
|
+
const SIDEBAR_KEYBOARD_SHORTCUT = "b";
|
|
21
|
+
function readSidebarCookie() {
|
|
22
|
+
if (typeof document === "undefined")
|
|
23
|
+
return undefined;
|
|
24
|
+
const match = document.cookie
|
|
25
|
+
.split("; ")
|
|
26
|
+
.find((row) => row.startsWith(`${SIDEBAR_COOKIE_NAME}=`));
|
|
27
|
+
if (!match)
|
|
28
|
+
return undefined;
|
|
29
|
+
return match.split("=")[1] === "false" ? false : true;
|
|
30
|
+
}
|
|
31
|
+
const SidebarContext = React.createContext(null);
|
|
32
|
+
function useSidebar() {
|
|
33
|
+
const context = React.useContext(SidebarContext);
|
|
34
|
+
if (!context) {
|
|
35
|
+
throw new Error("useSidebar must be used within a SidebarProvider.");
|
|
36
|
+
}
|
|
37
|
+
return context;
|
|
38
|
+
}
|
|
39
|
+
function SidebarProvider({ defaultOpen, open: openProp, onOpenChange: setOpenProp, className, style, children, ...props }) {
|
|
40
|
+
const isMobile = useIsMobile();
|
|
41
|
+
const [openMobile, setOpenMobile] = React.useState(false);
|
|
42
|
+
const [_open, _setOpen] = React.useState(() => {
|
|
43
|
+
if (defaultOpen !== undefined)
|
|
44
|
+
return defaultOpen;
|
|
45
|
+
return readSidebarCookie() ?? true;
|
|
46
|
+
});
|
|
47
|
+
const open = openProp ?? _open;
|
|
48
|
+
const setOpen = React.useCallback((value) => {
|
|
49
|
+
const openState = typeof value === "function" ? value(open) : value;
|
|
50
|
+
if (setOpenProp) {
|
|
51
|
+
setOpenProp(openState);
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
_setOpen(openState);
|
|
55
|
+
}
|
|
56
|
+
document.cookie = `${SIDEBAR_COOKIE_NAME}=${openState}; path=/; max-age=${SIDEBAR_COOKIE_MAX_AGE}`;
|
|
57
|
+
}, [setOpenProp, open]);
|
|
58
|
+
const toggleSidebar = React.useCallback(() => {
|
|
59
|
+
return isMobile ? setOpenMobile((open) => !open) : setOpen((open) => !open);
|
|
60
|
+
}, [isMobile, setOpen, setOpenMobile]);
|
|
61
|
+
React.useEffect(() => {
|
|
62
|
+
const handleKeyDown = (event) => {
|
|
63
|
+
if (event.key === SIDEBAR_KEYBOARD_SHORTCUT &&
|
|
64
|
+
(event.metaKey || event.ctrlKey)) {
|
|
65
|
+
const target = event.target;
|
|
66
|
+
if (target?.isContentEditable ||
|
|
67
|
+
(target && typeof target.matches === "function" &&
|
|
68
|
+
target.matches("input, textarea, select"))) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
event.preventDefault();
|
|
72
|
+
toggleSidebar();
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
window.addEventListener("keydown", handleKeyDown);
|
|
76
|
+
return () => window.removeEventListener("keydown", handleKeyDown);
|
|
77
|
+
}, [toggleSidebar]);
|
|
78
|
+
const state = open ? "expanded" : "collapsed";
|
|
79
|
+
const contextValue = React.useMemo(() => ({
|
|
80
|
+
state,
|
|
81
|
+
open,
|
|
82
|
+
setOpen,
|
|
83
|
+
isMobile,
|
|
84
|
+
openMobile,
|
|
85
|
+
setOpenMobile,
|
|
86
|
+
toggleSidebar,
|
|
87
|
+
}), [state, open, setOpen, isMobile, openMobile, setOpenMobile, toggleSidebar]);
|
|
88
|
+
return (_jsx(SidebarContext.Provider, { value: contextValue, children: _jsx("div", { "data-slot": "sidebar-wrapper", style: {
|
|
89
|
+
"--sidebar-width": SIDEBAR_WIDTH,
|
|
90
|
+
"--sidebar-width-icon": SIDEBAR_WIDTH_ICON,
|
|
91
|
+
...style,
|
|
92
|
+
}, className: cn("group/sidebar-wrapper flex min-h-svh w-full has-data-[variant=inset]:bg-sidebar", className), ...props, children: children }) }));
|
|
93
|
+
}
|
|
94
|
+
function Sidebar({ side = "left", variant = "sidebar", collapsible = "offcanvas", className, children, dir, ...props }) {
|
|
95
|
+
const { isMobile, state, openMobile, setOpenMobile } = useSidebar();
|
|
96
|
+
if (collapsible === "none") {
|
|
97
|
+
return (_jsx("div", { "data-slot": "sidebar", className: cn("flex h-full w-(--sidebar-width) flex-col bg-sidebar text-sidebar-foreground", className), ...props, children: children }));
|
|
98
|
+
}
|
|
99
|
+
if (isMobile) {
|
|
100
|
+
return (_jsx(Sheet, { open: openMobile, onOpenChange: setOpenMobile, ...props, children: _jsxs(SheetContent, { dir: dir, "data-sidebar": "sidebar", "data-slot": "sidebar", "data-mobile": "true", className: "w-(--sidebar-width) bg-sidebar p-0 text-sidebar-foreground [&>button]:hidden", style: {
|
|
101
|
+
"--sidebar-width": SIDEBAR_WIDTH_MOBILE,
|
|
102
|
+
}, side: side, children: [_jsxs(SheetHeader, { className: "sr-only", children: [_jsx(SheetTitle, { children: "Sidebar" }), _jsx(SheetDescription, { children: "Displays the mobile sidebar." })] }), _jsx("div", { className: "flex h-full w-full flex-col", children: children })] }) }));
|
|
103
|
+
}
|
|
104
|
+
return (_jsxs("div", { className: "group peer hidden text-sidebar-foreground md:block", "data-collapsible": state === "collapsed" ? collapsible : "", "data-variant": variant, "data-side": side, "data-slot": "sidebar", children: [_jsx("div", { "data-slot": "sidebar-gap", className: cn("relative w-(--sidebar-width) bg-transparent transition-[width] duration-200 ease-linear", "group-data-[collapsible=offcanvas]:w-0", "group-data-[side=right]:rotate-180", variant === "floating" || variant === "inset"
|
|
105
|
+
? "group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]"
|
|
106
|
+
: "group-data-[collapsible=icon]:w-(--sidebar-width-icon)") }), _jsx("div", { "data-slot": "sidebar-container", "data-side": side, className: cn("fixed inset-y-0 z-10 hidden h-svh w-(--sidebar-width) transition-[left,right,width] duration-200 ease-linear data-[side=left]:left-0 data-[side=left]:group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)] data-[side=right]:right-0 data-[side=right]:group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)] md:flex", variant === "floating" || variant === "inset"
|
|
107
|
+
? "p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]"
|
|
108
|
+
: "group-data-[collapsible=icon]:w-(--sidebar-width-icon) group-data-[side=left]:border-r group-data-[side=right]:border-l", className), ...props, children: _jsx("div", { "data-sidebar": "sidebar", "data-slot": "sidebar-inner", className: "flex size-full flex-col bg-sidebar group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:shadow-sm group-data-[variant=floating]:ring-1 group-data-[variant=floating]:ring-sidebar-border", children: children }) })] }));
|
|
109
|
+
}
|
|
110
|
+
function SidebarTrigger({ className, onClick, ...props }) {
|
|
111
|
+
const { toggleSidebar } = useSidebar();
|
|
112
|
+
return (_jsxs(Button, { "data-sidebar": "trigger", "data-slot": "sidebar-trigger", variant: "ghost", size: "iconSm", className: cn(className), onClick: (event) => {
|
|
113
|
+
onClick?.(event);
|
|
114
|
+
toggleSidebar();
|
|
115
|
+
}, ...props, children: [_jsx(PanelLeftIcon, {}), _jsx("span", { className: "sr-only", children: "Toggle Sidebar" })] }));
|
|
116
|
+
}
|
|
117
|
+
function SidebarRail({ className, ...props }) {
|
|
118
|
+
const { toggleSidebar } = useSidebar();
|
|
119
|
+
return (_jsx("button", { "data-sidebar": "rail", "data-slot": "sidebar-rail", "aria-label": "Toggle Sidebar", tabIndex: -1, onClick: toggleSidebar, title: "Toggle Sidebar", className: cn("absolute inset-y-0 z-20 hidden w-4 transition-all ease-linear group-data-[side=left]:-right-4 group-data-[side=right]:left-0 after:absolute after:inset-y-0 after:start-1/2 after:w-[2px] hover:after:bg-sidebar-border sm:flex ltr:-translate-x-1/2 rtl:-translate-x-1/2", "in-data-[side=left]:cursor-w-resize in-data-[side=right]:cursor-e-resize", "[[data-side=left][data-collapsible=icon]_&]:cursor-e-resize [[data-side=left][data-collapsible=offcanvas]_&]:cursor-e-resize [[data-side=right][data-collapsible=icon]_&]:cursor-w-resize [[data-side=right][data-collapsible=offcanvas]_&]:cursor-w-resize", "group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full hover:group-data-[collapsible=offcanvas]:bg-sidebar", "[[data-side=left][data-collapsible=offcanvas]_&]:-right-2", "[[data-side=right][data-collapsible=offcanvas]_&]:-left-2", className), ...props }));
|
|
120
|
+
}
|
|
121
|
+
function SidebarInset({ className, ...props }) {
|
|
122
|
+
return (_jsx("main", { "data-slot": "sidebar-inset", className: cn("relative flex w-full flex-1 flex-col bg-background md:peer-data-[variant=inset]:m-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow-sm md:peer-data-[variant=inset]:peer-data-[collapsible=icon]:ml-2 md:peer-data-[variant=inset]:peer-data-[collapsible=offcanvas]:ml-2", className), ...props }));
|
|
123
|
+
}
|
|
124
|
+
function SidebarInput({ className, ...props }) {
|
|
125
|
+
return (_jsx(Input, { "data-slot": "sidebar-input", "data-sidebar": "input", className: cn("h-8 w-full bg-background shadow-none", className), ...props }));
|
|
126
|
+
}
|
|
127
|
+
function SidebarHeader({ className, ...props }) {
|
|
128
|
+
return (_jsx("div", { "data-slot": "sidebar-header", "data-sidebar": "header", className: cn("flex flex-col gap-2 p-2", className), ...props }));
|
|
129
|
+
}
|
|
130
|
+
function SidebarFooter({ className, ...props }) {
|
|
131
|
+
return (_jsx("div", { "data-slot": "sidebar-footer", "data-sidebar": "footer", className: cn("flex flex-col gap-2 p-2", className), ...props }));
|
|
132
|
+
}
|
|
133
|
+
function SidebarSeparator({ className, ...props }) {
|
|
134
|
+
return (_jsx(Separator, { "data-slot": "sidebar-separator", "data-sidebar": "separator", className: cn("mx-2 w-auto bg-sidebar-border", className), ...props }));
|
|
135
|
+
}
|
|
136
|
+
function SidebarContent({ className, ...props }) {
|
|
137
|
+
return (_jsx("div", { "data-slot": "sidebar-content", "data-sidebar": "content", className: cn("no-scrollbar flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden", className), ...props }));
|
|
138
|
+
}
|
|
139
|
+
function SidebarGroup({ className, ...props }) {
|
|
140
|
+
return (_jsx("div", { "data-slot": "sidebar-group", "data-sidebar": "group", className: cn("relative flex w-full min-w-0 flex-col p-2", className), ...props }));
|
|
141
|
+
}
|
|
142
|
+
function SidebarGroupLabel({ className, render, ...props }) {
|
|
143
|
+
return useRender({
|
|
144
|
+
defaultTagName: "div",
|
|
145
|
+
props: mergeProps({
|
|
146
|
+
className: cn("flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium text-sidebar-foreground/70 ring-sidebar-ring outline-hidden transition-[margin,opacity] duration-200 ease-linear group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0 focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0", className),
|
|
147
|
+
}, props),
|
|
148
|
+
render,
|
|
149
|
+
state: {
|
|
150
|
+
slot: "sidebar-group-label",
|
|
151
|
+
sidebar: "group-label",
|
|
152
|
+
},
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
function SidebarGroupAction({ className, render, ...props }) {
|
|
156
|
+
return useRender({
|
|
157
|
+
defaultTagName: "button",
|
|
158
|
+
props: mergeProps({
|
|
159
|
+
className: cn("absolute top-3.5 right-3 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground ring-sidebar-ring outline-hidden transition-transform group-data-[collapsible=icon]:hidden after:absolute after:-inset-2 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 md:after:hidden [&>svg]:size-4 [&>svg]:shrink-0", className),
|
|
160
|
+
}, props),
|
|
161
|
+
render,
|
|
162
|
+
state: {
|
|
163
|
+
slot: "sidebar-group-action",
|
|
164
|
+
sidebar: "group-action",
|
|
165
|
+
},
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
function SidebarGroupContent({ className, ...props }) {
|
|
169
|
+
return (_jsx("div", { "data-slot": "sidebar-group-content", "data-sidebar": "group-content", className: cn("w-full text-sm", className), ...props }));
|
|
170
|
+
}
|
|
171
|
+
function SidebarMenu({ className, ...props }) {
|
|
172
|
+
return (_jsx("ul", { "data-slot": "sidebar-menu", "data-sidebar": "menu", className: cn("flex w-full min-w-0 flex-col gap-1", className), ...props }));
|
|
173
|
+
}
|
|
174
|
+
function SidebarMenuItem({ className, ...props }) {
|
|
175
|
+
return (_jsx("li", { "data-slot": "sidebar-menu-item", "data-sidebar": "menu-item", className: cn("group/menu-item relative", className), ...props }));
|
|
176
|
+
}
|
|
177
|
+
const sidebarMenuButtonVariants = cva("peer/menu-button group/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm ring-sidebar-ring outline-hidden transition-[width,height,padding] group-has-data-[sidebar=menu-action]/menu-item:pr-8 group-data-[collapsible=icon]:size-8! group-data-[collapsible=icon]:p-2! hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-open:hover:bg-sidebar-accent data-open:hover:text-sidebar-accent-foreground data-active:bg-sidebar-accent data-active:font-medium data-active:text-sidebar-accent-foreground [&_svg]:size-4 [&_svg]:shrink-0 [&>span:last-child]:truncate", {
|
|
178
|
+
variants: {
|
|
179
|
+
variant: {
|
|
180
|
+
default: "hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",
|
|
181
|
+
outline: "bg-background shadow-[0_0_0_1px_var(--sidebar-border)] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_var(--sidebar-accent)]",
|
|
182
|
+
},
|
|
183
|
+
size: {
|
|
184
|
+
default: "h-8 text-sm",
|
|
185
|
+
sm: "h-7 text-xs",
|
|
186
|
+
lg: "h-12 text-sm group-data-[collapsible=icon]:p-0!",
|
|
187
|
+
},
|
|
188
|
+
},
|
|
189
|
+
defaultVariants: {
|
|
190
|
+
variant: "default",
|
|
191
|
+
size: "default",
|
|
192
|
+
},
|
|
193
|
+
});
|
|
194
|
+
function SidebarMenuButton({ render, isActive = false, variant = "default", size = "default", tooltip, className, ...props }) {
|
|
195
|
+
const { isMobile, state } = useSidebar();
|
|
196
|
+
const comp = useRender({
|
|
197
|
+
defaultTagName: "button",
|
|
198
|
+
props: mergeProps({
|
|
199
|
+
className: cn(sidebarMenuButtonVariants({ variant, size }), className),
|
|
200
|
+
}, props),
|
|
201
|
+
render: !tooltip ? render : _jsx(TooltipTrigger, { render: render }),
|
|
202
|
+
state: {
|
|
203
|
+
slot: "sidebar-menu-button",
|
|
204
|
+
sidebar: "menu-button",
|
|
205
|
+
size,
|
|
206
|
+
active: isActive,
|
|
207
|
+
},
|
|
208
|
+
});
|
|
209
|
+
if (!tooltip) {
|
|
210
|
+
return comp;
|
|
211
|
+
}
|
|
212
|
+
if (typeof tooltip === "string") {
|
|
213
|
+
tooltip = {
|
|
214
|
+
children: tooltip,
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
return (_jsxs(Tooltip, { children: [comp, _jsx(TooltipContent, { side: "right", align: "center", hidden: state !== "collapsed" || isMobile, ...tooltip })] }));
|
|
218
|
+
}
|
|
219
|
+
function SidebarMenuAction({ className, render, showOnHover = false, ...props }) {
|
|
220
|
+
return useRender({
|
|
221
|
+
defaultTagName: "button",
|
|
222
|
+
props: mergeProps({
|
|
223
|
+
className: cn("absolute top-1.5 right-1 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground ring-sidebar-ring outline-hidden transition-transform group-data-[collapsible=icon]:hidden peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[size=default]/menu-button:top-1.5 peer-data-[size=lg]/menu-button:top-2.5 peer-data-[size=sm]/menu-button:top-1 after:absolute after:-inset-2 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 md:after:hidden [&>svg]:size-4 [&>svg]:shrink-0", showOnHover &&
|
|
224
|
+
"group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 peer-data-active/menu-button:text-sidebar-accent-foreground aria-expanded:opacity-100 md:opacity-0", className),
|
|
225
|
+
}, props),
|
|
226
|
+
render,
|
|
227
|
+
state: {
|
|
228
|
+
slot: "sidebar-menu-action",
|
|
229
|
+
sidebar: "menu-action",
|
|
230
|
+
},
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
function SidebarMenuBadge({ className, ...props }) {
|
|
234
|
+
return (_jsx("div", { "data-slot": "sidebar-menu-badge", "data-sidebar": "menu-badge", className: cn("pointer-events-none absolute right-1 flex h-5 min-w-5 items-center justify-center rounded-md px-1 text-xs font-medium text-sidebar-foreground tabular-nums select-none group-data-[collapsible=icon]:hidden peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[size=default]/menu-button:top-1.5 peer-data-[size=lg]/menu-button:top-2.5 peer-data-[size=sm]/menu-button:top-1 peer-data-active/menu-button:text-sidebar-accent-foreground", className), ...props }));
|
|
235
|
+
}
|
|
236
|
+
function SidebarMenuSkeleton({ className, showIcon = false, ...props }) {
|
|
237
|
+
const id = React.useId();
|
|
238
|
+
const SKELETON_WIDTHS = ["50%", "58%", "66%", "74%", "82%", "90%"];
|
|
239
|
+
const width = SKELETON_WIDTHS[Math.abs(Array.from(id).reduce((acc, ch) => (acc * 31 + ch.charCodeAt(0)) | 0, 7)) % SKELETON_WIDTHS.length];
|
|
240
|
+
return (_jsxs("div", { "data-slot": "sidebar-menu-skeleton", "data-sidebar": "menu-skeleton", className: cn("flex h-8 items-center gap-2 rounded-md px-2", className), ...props, children: [showIcon && (_jsx(Skeleton, { className: "size-4 rounded-md", "data-sidebar": "menu-skeleton-icon" })), _jsx(Skeleton, { className: "h-4 max-w-(--skeleton-width) flex-1", "data-sidebar": "menu-skeleton-text", style: {
|
|
241
|
+
"--skeleton-width": width,
|
|
242
|
+
} })] }));
|
|
243
|
+
}
|
|
244
|
+
function SidebarMenuSub({ className, ...props }) {
|
|
245
|
+
return (_jsx("ul", { "data-slot": "sidebar-menu-sub", "data-sidebar": "menu-sub", className: cn("mx-3.5 flex min-w-0 translate-x-px flex-col gap-1 border-l border-sidebar-border px-2.5 py-0.5 group-data-[collapsible=icon]:hidden", className), ...props }));
|
|
246
|
+
}
|
|
247
|
+
function SidebarMenuSubItem({ className, ...props }) {
|
|
248
|
+
return (_jsx("li", { "data-slot": "sidebar-menu-sub-item", "data-sidebar": "menu-sub-item", className: cn("group/menu-sub-item relative", className), ...props }));
|
|
249
|
+
}
|
|
250
|
+
function SidebarMenuSubButton({ render, size = "md", isActive = false, className, ...props }) {
|
|
251
|
+
return useRender({
|
|
252
|
+
defaultTagName: "a",
|
|
253
|
+
props: mergeProps({
|
|
254
|
+
className: cn("flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 text-sidebar-foreground ring-sidebar-ring outline-hidden group-data-[collapsible=icon]:hidden hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[size=md]:text-sm data-[size=sm]:text-xs data-active:bg-sidebar-accent data-active:text-sidebar-accent-foreground [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:text-sidebar-accent-foreground", className),
|
|
255
|
+
}, props),
|
|
256
|
+
render,
|
|
257
|
+
state: {
|
|
258
|
+
slot: "sidebar-menu-sub-button",
|
|
259
|
+
sidebar: "menu-sub-button",
|
|
260
|
+
size,
|
|
261
|
+
active: isActive,
|
|
262
|
+
},
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
export { Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInput, SidebarInset, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider, SidebarRail, SidebarSeparator, SidebarTrigger, useSidebar, };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from "../../lib/utils";
|
|
3
|
+
function Skeleton({ className, ...props }) {
|
|
4
|
+
return (_jsx("div", { "data-slot": "skeleton", className: cn("animate-pulse rounded-md bg-muted", className), ...props }));
|
|
5
|
+
}
|
|
6
|
+
export { Skeleton };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Switch as SwitchPrimitive } from "@base-ui/react/switch";
|
|
3
|
+
import { cn } from "../../lib/utils";
|
|
4
|
+
function Switch({ className, size = "default", ...props }) {
|
|
5
|
+
return (_jsx(SwitchPrimitive.Root, { "data-slot": "switch", "data-size": size, className: cn("peer group/switch relative inline-flex shrink-0 items-center rounded-full border border-transparent bg-input shadow-xs transition-all outline-none after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-checked:border-primary data-checked:bg-primary data-unchecked:bg-input group-has-[:focus-visible]/field-label:ring-0 group-has-[:focus-visible]/field-label:border-transparent data-disabled:cursor-not-allowed data-disabled:opacity-50 data-[size=default]:h-[18.4px] data-[size=default]:w-[32px] data-[size=sm]:h-[14px] data-[size=sm]:w-[24px] dark:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 dark:data-unchecked:bg-input/80 dark:data-checked:bg-primary", className), ...props, children: _jsx(SwitchPrimitive.Thumb, { "data-slot": "switch-thumb", className: "pointer-events-none block size-4 rounded-full bg-background ring-0 transition-transform group-data-[size=default]/switch:data-checked:translate-x-[calc(100%-2px)] group-data-[size=sm]/switch:data-checked:translate-x-[calc(100%-2px)] group-data-[size=default]/switch:data-unchecked:translate-x-0 group-data-[size=sm]/switch:data-unchecked:translate-x-0 group-data-[size=sm]/switch:size-3 dark:data-unchecked:bg-foreground dark:data-checked:bg-primary-foreground" }) }));
|
|
6
|
+
}
|
|
7
|
+
export { Switch };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Tabs as TabsPrimitive } from "@base-ui/react/tabs";
|
|
2
|
+
import { type VariantProps } from "class-variance-authority";
|
|
3
|
+
declare function Tabs({ className, orientation, ...props }: TabsPrimitive.Root.Props): import("react").JSX.Element;
|
|
4
|
+
declare const tabsListVariants: (props?: ({
|
|
5
|
+
variant?: "default" | "line" | null | undefined;
|
|
6
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
7
|
+
declare function TabsList({ className, variant, ...props }: TabsPrimitive.List.Props & VariantProps<typeof tabsListVariants>): import("react").JSX.Element;
|
|
8
|
+
declare function TabsTrigger({ className, ...props }: TabsPrimitive.Tab.Props): import("react").JSX.Element;
|
|
9
|
+
declare function TabsContent({ className, ...props }: TabsPrimitive.Panel.Props): import("react").JSX.Element;
|
|
10
|
+
export { Tabs, TabsList, TabsTrigger, TabsContent, tabsListVariants };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Tabs as TabsPrimitive } from "@base-ui/react/tabs";
|
|
3
|
+
import { cva } from "class-variance-authority";
|
|
4
|
+
import { cn } from "../../lib/utils";
|
|
5
|
+
function Tabs({ className, orientation = "horizontal", ...props }) {
|
|
6
|
+
return (_jsx(TabsPrimitive.Root, { "data-slot": "tabs", "data-orientation": orientation, className: cn("group/tabs flex gap-2 data-[orientation=horizontal]:flex-col", className), ...props }));
|
|
7
|
+
}
|
|
8
|
+
const tabsListVariants = cva("group/tabs-list inline-flex w-fit items-center justify-center rounded-lg p-[3px] text-muted-foreground h-9 group-data-[orientation=vertical]/tabs:h-fit group-data-[orientation=vertical]/tabs:flex-col data-[variant=line]:rounded-none", {
|
|
9
|
+
variants: {
|
|
10
|
+
variant: {
|
|
11
|
+
default: "bg-muted",
|
|
12
|
+
line: "gap-1 bg-transparent",
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
defaultVariants: {
|
|
16
|
+
variant: "default",
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
function TabsList({ className, variant = "default", ...props }) {
|
|
20
|
+
return (_jsx(TabsPrimitive.List, { "data-slot": "tabs-list", "data-variant": variant, className: cn(tabsListVariants({ variant }), className), ...props }));
|
|
21
|
+
}
|
|
22
|
+
function TabsTrigger({ className, ...props }) {
|
|
23
|
+
return (_jsx(TabsPrimitive.Tab, { "data-slot": "tabs-trigger", className: cn("relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 whitespace-nowrap rounded-md border border-transparent px-2 py-1 text-sm font-medium text-foreground/60 transition-all group-data-[orientation=vertical]/tabs:w-full group-data-[orientation=vertical]/tabs:justify-start hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 dark:text-muted-foreground dark:hover:text-foreground [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 [&_svg]:shrink-0", "group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-active:bg-transparent dark:group-data-[variant=line]/tabs-list:data-active:border-transparent dark:group-data-[variant=line]/tabs-list:data-active:bg-transparent", "data-active:bg-background data-active:text-foreground dark:data-active:border-input dark:data-active:bg-input/30 dark:data-active:text-foreground", "group-data-[variant=default]/tabs-list:data-active:shadow-sm group-data-[variant=line]/tabs-list:data-active:shadow-none", "after:absolute after:bg-foreground after:opacity-0 after:transition-opacity group-data-[orientation=horizontal]/tabs:after:inset-x-0 group-data-[orientation=horizontal]/tabs:after:bottom-[-5px] group-data-[orientation=horizontal]/tabs:after:h-0.5 group-data-[orientation=vertical]/tabs:after:inset-y-0 group-data-[orientation=vertical]/tabs:after:-right-1 group-data-[orientation=vertical]/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-active:after:opacity-100", className), ...props }));
|
|
24
|
+
}
|
|
25
|
+
function TabsContent({ className, ...props }) {
|
|
26
|
+
return (_jsx(TabsPrimitive.Panel, { "data-slot": "tabs-content", className: cn("flex-1 text-sm outline-none", className), ...props }));
|
|
27
|
+
}
|
|
28
|
+
export { Tabs, TabsList, TabsTrigger, TabsContent, tabsListVariants };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Tooltip as TooltipPrimitive } from "@base-ui/react/tooltip";
|
|
2
|
+
declare function TooltipProvider({ delay, ...props }: TooltipPrimitive.Provider.Props): import("react").JSX.Element;
|
|
3
|
+
declare function Tooltip({ ...props }: TooltipPrimitive.Root.Props): import("react").JSX.Element;
|
|
4
|
+
declare function TooltipTrigger({ ...props }: TooltipPrimitive.Trigger.Props): import("react").JSX.Element;
|
|
5
|
+
declare function TooltipContent({ className, side, sideOffset, align, alignOffset, children, ...props }: TooltipPrimitive.Popup.Props & Pick<TooltipPrimitive.Positioner.Props, "align" | "alignOffset" | "side" | "sideOffset">): import("react").JSX.Element;
|
|
6
|
+
export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Tooltip as TooltipPrimitive } from "@base-ui/react/tooltip";
|
|
3
|
+
import { cn } from "../../lib/utils";
|
|
4
|
+
function TooltipProvider({ delay = 0, ...props }) {
|
|
5
|
+
return (_jsx(TooltipPrimitive.Provider, { "data-slot": "tooltip-provider", delay: delay, ...props }));
|
|
6
|
+
}
|
|
7
|
+
function Tooltip({ ...props }) {
|
|
8
|
+
return _jsx(TooltipPrimitive.Root, { "data-slot": "tooltip", ...props });
|
|
9
|
+
}
|
|
10
|
+
function TooltipTrigger({ ...props }) {
|
|
11
|
+
return _jsx(TooltipPrimitive.Trigger, { "data-slot": "tooltip-trigger", ...props });
|
|
12
|
+
}
|
|
13
|
+
function TooltipContent({ className, side = "top", sideOffset = 4, align = "center", alignOffset = 0, children, ...props }) {
|
|
14
|
+
return (_jsx(TooltipPrimitive.Portal, { children: _jsx(TooltipPrimitive.Positioner, { align: align, alignOffset: alignOffset, side: side, sideOffset: sideOffset, className: "isolate z-50", children: _jsxs(TooltipPrimitive.Popup, { "data-slot": "tooltip-content", className: cn("z-50 inline-flex w-fit max-w-xs origin-(--transform-origin) items-center gap-1.5 rounded-md bg-foreground px-3 py-1.5 text-xs text-background has-data-[slot=kbd]:pr-1.5 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-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-[slot=kbd]:relative **:data-[slot=kbd]:isolate **:data-[slot=kbd]:z-50 **:data-[slot=kbd]:rounded-sm data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95", className), ...props, children: [children, _jsx(TooltipPrimitive.Arrow, { className: "z-50 size-2.5 translate-y-[calc(-50%-2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground data-[side=bottom]:top-1 data-[side=inline-end]:top-1/2! data-[side=inline-end]:-left-1 data-[side=inline-end]:-translate-y-1/2 data-[side=inline-start]:top-1/2! data-[side=inline-start]:-right-1 data-[side=inline-start]:-translate-y-1/2 data-[side=left]:top-1/2! data-[side=left]:-right-1 data-[side=left]:-translate-y-1/2 data-[side=right]:top-1/2! data-[side=right]:-left-1 data-[side=right]:-translate-y-1/2 data-[side=top]:-bottom-2.5" })] }) }) }));
|
|
15
|
+
}
|
|
16
|
+
export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useIsMobile(): boolean;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
const MOBILE_BREAKPOINT = 768;
|
|
3
|
+
export function useIsMobile() {
|
|
4
|
+
const [isMobile, setIsMobile] = React.useState(undefined);
|
|
5
|
+
React.useEffect(() => {
|
|
6
|
+
const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`);
|
|
7
|
+
const onChange = () => {
|
|
8
|
+
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
|
|
9
|
+
};
|
|
10
|
+
mql.addEventListener("change", onChange);
|
|
11
|
+
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
|
|
12
|
+
return () => mql.removeEventListener("change", onChange);
|
|
13
|
+
}, []);
|
|
14
|
+
return !!isMobile;
|
|
15
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ApiError } from '@ploykit/client';
|
|
2
|
+
export { ApiError };
|
|
3
|
+
export type { ApiFetchOptions } from '@ploykit/client';
|
|
4
|
+
export declare function useApi(): {
|
|
5
|
+
get: <T>(path: string) => Promise<T>;
|
|
6
|
+
post: <T>(path: string, body?: unknown) => Promise<T>;
|
|
7
|
+
put: <T>(path: string, body?: unknown) => Promise<T>;
|
|
8
|
+
patch: <T>(path: string, body?: unknown) => Promise<T>;
|
|
9
|
+
delete: <T>(path: string, body?: unknown) => Promise<T>;
|
|
10
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { useCallback, useMemo } from 'react';
|
|
2
|
+
import { api, ApiError } from '@ploykit/client';
|
|
3
|
+
export { ApiError };
|
|
4
|
+
export function useApi() {
|
|
5
|
+
const get = useCallback((path) => api.get(path), []);
|
|
6
|
+
const post = useCallback((path, body) => api.post(path, body), []);
|
|
7
|
+
const put = useCallback((path, body) => api.put(path, body), []);
|
|
8
|
+
const patch = useCallback((path, body) => api.patch(path, body), []);
|
|
9
|
+
const del = useCallback((path, body) => api.delete(path, body), []);
|
|
10
|
+
return useMemo(() => ({ get, post, put, patch, delete: del }), [get, post, put, patch, del]);
|
|
11
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { components } from '@ploykit/client';
|
|
2
|
+
export type PKAuditEvent = components['schemas']['AuditEvent'];
|
|
3
|
+
export interface AuditListResp {
|
|
4
|
+
items: PKAuditEvent[];
|
|
5
|
+
total: number;
|
|
6
|
+
}
|
|
7
|
+
export interface AuditFilters {
|
|
8
|
+
action: string;
|
|
9
|
+
actorId: string;
|
|
10
|
+
resourceType: string;
|
|
11
|
+
from: string;
|
|
12
|
+
to: string;
|
|
13
|
+
}
|
|
14
|
+
export declare const EMPTY_AUDIT_FILTERS: AuditFilters;
|
|
15
|
+
export declare function auditQueryString(f: AuditFilters, limit: number, offset: number): string;
|
|
16
|
+
export declare function useAudit(filters: AuditFilters, limit?: number, offset?: number): {
|
|
17
|
+
wsId: string;
|
|
18
|
+
items: {
|
|
19
|
+
id: string;
|
|
20
|
+
workspace_id: string;
|
|
21
|
+
actor_type: "user" | "pat" | "system";
|
|
22
|
+
actor_id: string | null;
|
|
23
|
+
actor_snapshot: {
|
|
24
|
+
[key: string]: unknown;
|
|
25
|
+
};
|
|
26
|
+
action: string;
|
|
27
|
+
resource_type: string;
|
|
28
|
+
resource_id: string | null;
|
|
29
|
+
metadata: {
|
|
30
|
+
[key: string]: unknown;
|
|
31
|
+
};
|
|
32
|
+
created_at: string;
|
|
33
|
+
}[];
|
|
34
|
+
total: number;
|
|
35
|
+
loading: boolean;
|
|
36
|
+
error: Error | null;
|
|
37
|
+
refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<AuditListResp, Error>>;
|
|
38
|
+
};
|
|
39
|
+
export declare function exportAuditCsv(filters: AuditFilters): Promise<void>;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { useQuery } from '@tanstack/react-query';
|
|
2
|
+
import { apiFetch } from '@ploykit/client';
|
|
3
|
+
import { useApi } from './useApi';
|
|
4
|
+
import { useWorkspace } from './useWorkspace';
|
|
5
|
+
import { queryKeys } from '../provider/PloykitProvider';
|
|
6
|
+
export const EMPTY_AUDIT_FILTERS = {
|
|
7
|
+
action: '', actorId: '', resourceType: '', from: '', to: '',
|
|
8
|
+
};
|
|
9
|
+
export function auditQueryString(f, limit, offset) {
|
|
10
|
+
const q = new URLSearchParams();
|
|
11
|
+
if (f.action)
|
|
12
|
+
q.set('action', f.action);
|
|
13
|
+
if (f.actorId)
|
|
14
|
+
q.set('actor_id', f.actorId);
|
|
15
|
+
if (f.resourceType)
|
|
16
|
+
q.set('resource_type', f.resourceType);
|
|
17
|
+
if (f.from)
|
|
18
|
+
q.set('from', f.from);
|
|
19
|
+
if (f.to)
|
|
20
|
+
q.set('to', f.to);
|
|
21
|
+
q.set('limit', String(limit));
|
|
22
|
+
q.set('offset', String(offset));
|
|
23
|
+
return q.toString();
|
|
24
|
+
}
|
|
25
|
+
export function useAudit(filters, limit = 20, offset = 0) {
|
|
26
|
+
const { current } = useWorkspace();
|
|
27
|
+
const api = useApi();
|
|
28
|
+
const wsId = current?.id ?? '';
|
|
29
|
+
const qs = auditQueryString(filters, limit, offset);
|
|
30
|
+
const q = useQuery({
|
|
31
|
+
queryKey: queryKeys.audit(wsId, { ...filters, limit, offset }),
|
|
32
|
+
queryFn: () => api.get(`/api/audit?${qs}`),
|
|
33
|
+
enabled: !!wsId,
|
|
34
|
+
});
|
|
35
|
+
return {
|
|
36
|
+
wsId,
|
|
37
|
+
items: wsId ? (q.data?.items ?? []) : [],
|
|
38
|
+
total: wsId ? (q.data?.total ?? 0) : 0,
|
|
39
|
+
loading: !!wsId && q.isPending,
|
|
40
|
+
error: q.error,
|
|
41
|
+
refetch: q.refetch,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
export async function exportAuditCsv(filters) {
|
|
45
|
+
const qs = auditQueryString(filters, 5000, 0);
|
|
46
|
+
const blob = await apiFetch(`/api/audit/export.csv?${qs}`, { responseType: 'blob' });
|
|
47
|
+
const url = URL.createObjectURL(blob);
|
|
48
|
+
const a = document.createElement('a');
|
|
49
|
+
a.href = url;
|
|
50
|
+
a.download = `audit-${new Date().toISOString().slice(0, 10)}.csv`;
|
|
51
|
+
document.body.appendChild(a);
|
|
52
|
+
a.click();
|
|
53
|
+
a.remove();
|
|
54
|
+
URL.revokeObjectURL(url);
|
|
55
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useAuth(): import("../provider/PloykitProvider").AuthContextValue;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import { type components } from '@ploykit/client';
|
|
3
|
+
export declare function useBilling(): {
|
|
4
|
+
subscription: {
|
|
5
|
+
plan_code: string;
|
|
6
|
+
orders: components["schemas"]["Order"][];
|
|
7
|
+
} | null;
|
|
8
|
+
plans: {
|
|
9
|
+
code: string;
|
|
10
|
+
name: string;
|
|
11
|
+
currency?: string;
|
|
12
|
+
trial_days?: number;
|
|
13
|
+
limits: {
|
|
14
|
+
[key: string]: number;
|
|
15
|
+
};
|
|
16
|
+
sort_no: number;
|
|
17
|
+
}[];
|
|
18
|
+
checkout: (planCode: string, interval: string, channel: string) => Promise<{
|
|
19
|
+
order_id: string;
|
|
20
|
+
channel: "stripe" | "alipay" | "wechat";
|
|
21
|
+
action_url: string;
|
|
22
|
+
session_ref: string;
|
|
23
|
+
expires_at: string;
|
|
24
|
+
} | null>;
|
|
25
|
+
checkoutError: Error | null;
|
|
26
|
+
loading: boolean;
|
|
27
|
+
refresh: () => Promise<void>;
|
|
28
|
+
};
|
|
29
|
+
export declare function PlanGate({ plan, denied, children, busy }: {
|
|
30
|
+
plan: string;
|
|
31
|
+
denied?: ReactNode;
|
|
32
|
+
children: ReactNode;
|
|
33
|
+
busy?: ReactNode;
|
|
34
|
+
}): import("react").JSX.Element;
|
|
35
|
+
export type UsagePreviewItem = components['schemas']['UsagePreviewItem'];
|
|
36
|
+
export type UsagePreviewResp = components['schemas']['UsagePreview'];
|
|
37
|
+
export declare function useUsagePreview(): {
|
|
38
|
+
preview: {
|
|
39
|
+
period: string;
|
|
40
|
+
items: components["schemas"]["UsagePreviewItem"][];
|
|
41
|
+
projected_total_cents: number;
|
|
42
|
+
} | null;
|
|
43
|
+
loading: boolean;
|
|
44
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback } from 'react';
|
|
3
|
+
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
|
|
4
|
+
import { api } from '@ploykit/client';
|
|
5
|
+
import { useWorkspaceCtx, queryKeys, } from '../provider/PloykitProvider';
|
|
6
|
+
export function useBilling() {
|
|
7
|
+
const { current } = useWorkspaceCtx();
|
|
8
|
+
const qc = useQueryClient();
|
|
9
|
+
const wsId = current?.id ?? '';
|
|
10
|
+
const subQ = useQuery({
|
|
11
|
+
queryKey: queryKeys.billingSubscription(wsId),
|
|
12
|
+
queryFn: () => api.get('/api/billing/subscription'),
|
|
13
|
+
enabled: !!current,
|
|
14
|
+
});
|
|
15
|
+
const planQ = useQuery({
|
|
16
|
+
queryKey: queryKeys.billingPlans,
|
|
17
|
+
queryFn: () => api.get('/api/billing/plans'),
|
|
18
|
+
});
|
|
19
|
+
const checkoutM = useMutation({
|
|
20
|
+
mutationFn: (v) => api.post('/api/billing/checkout', {
|
|
21
|
+
plan_code: v.planCode, interval: v.interval, channel: v.channel,
|
|
22
|
+
}),
|
|
23
|
+
onSuccess: () => qc.invalidateQueries({ queryKey: queryKeys.billing }),
|
|
24
|
+
});
|
|
25
|
+
const checkout = useCallback(async (planCode, interval, channel) => {
|
|
26
|
+
if (!wsId)
|
|
27
|
+
return null;
|
|
28
|
+
return checkoutM.mutateAsync({ planCode, interval, channel }).catch(() => null);
|
|
29
|
+
}, [wsId, checkoutM.mutateAsync]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
30
|
+
const refresh = useCallback(async () => {
|
|
31
|
+
await qc.invalidateQueries({ queryKey: queryKeys.billing });
|
|
32
|
+
}, [qc]);
|
|
33
|
+
return {
|
|
34
|
+
subscription: current ? (subQ.data ?? null) : null,
|
|
35
|
+
plans: Array.isArray(planQ.data) ? planQ.data : [],
|
|
36
|
+
checkout,
|
|
37
|
+
checkoutError: checkoutM.error ?? null,
|
|
38
|
+
loading: planQ.isPending || (!!current && subQ.isPending),
|
|
39
|
+
refresh,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
export function PlanGate({ plan, denied, children, busy }) {
|
|
43
|
+
const { subscription, plans, loading } = useBilling();
|
|
44
|
+
if (loading)
|
|
45
|
+
return _jsx(_Fragment, { children: busy ?? null });
|
|
46
|
+
if (!subscription)
|
|
47
|
+
return _jsx(_Fragment, { children: denied ?? null });
|
|
48
|
+
const currentPlan = plans.find((p) => p.code === subscription.plan_code);
|
|
49
|
+
const requiredPlan = plans.find((p) => p.code === plan);
|
|
50
|
+
const entitled = currentPlan && requiredPlan && currentPlan.sort_no >= requiredPlan.sort_no;
|
|
51
|
+
return _jsx(_Fragment, { children: entitled ? children : denied });
|
|
52
|
+
}
|
|
53
|
+
export function useUsagePreview() {
|
|
54
|
+
const { current } = useWorkspaceCtx();
|
|
55
|
+
const previewQ = useQuery({
|
|
56
|
+
queryKey: ['billing', 'usage-preview', current?.id ?? ''],
|
|
57
|
+
queryFn: () => api.get('/api/billing/usage-preview'),
|
|
58
|
+
enabled: !!current,
|
|
59
|
+
});
|
|
60
|
+
return {
|
|
61
|
+
preview: current ? (previewQ.data ?? null) : null,
|
|
62
|
+
loading: !!current && previewQ.isPending,
|
|
63
|
+
};
|
|
64
|
+
}
|