@badnpm/ui 0.0.0 → 0.0.1
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 +11 -11
- package/dist/cjs/components/accordion.cjs +24 -0
- package/dist/cjs/components/alert-dialog.cjs +56 -0
- package/dist/cjs/components/alert.cjs +34 -0
- package/dist/cjs/components/aspect-ratio.cjs +12 -0
- package/dist/cjs/components/attachment.cjs +80 -0
- package/dist/cjs/components/avatar.cjs +31 -0
- package/dist/cjs/components/badge.cjs +38 -0
- package/dist/cjs/components/breadcrumb.cjs +46 -0
- package/dist/cjs/components/bubble.cjs +66 -0
- package/dist/cjs/components/button-group.cjs +43 -0
- package/dist/cjs/components/calendar.cjs +100 -0
- package/dist/cjs/components/card.cjs +34 -0
- package/dist/cjs/components/carousel.cjs +113 -0
- package/dist/cjs/components/chart.cjs +160 -0
- package/dist/cjs/components/checkbox.cjs +13 -0
- package/dist/cjs/components/code-block.cjs +110 -0
- package/dist/cjs/components/collapsible.cjs +18 -0
- package/dist/cjs/components/combobox.cjs +96 -0
- package/dist/cjs/components/command.cjs +46 -0
- package/dist/cjs/components/context-menu.cjs +69 -0
- package/dist/cjs/components/dialog.cjs +50 -0
- package/dist/cjs/components/drawer.cjs +108 -0
- package/dist/cjs/components/dropdown-menu.cjs +68 -0
- package/dist/cjs/components/empty.cjs +42 -0
- package/dist/cjs/components/field.cjs +80 -0
- package/dist/cjs/components/hover-card.cjs +20 -0
- package/dist/cjs/components/input-group.cjs +66 -0
- package/dist/cjs/components/input-otp.cjs +46 -0
- package/dist/cjs/components/item.cjs +91 -0
- package/dist/cjs/components/kbd.cjs +14 -0
- package/dist/cjs/components/label.cjs +11 -0
- package/dist/cjs/components/marker.cjs +41 -0
- package/dist/cjs/components/menubar.cjs +75 -0
- package/dist/cjs/components/message-scroller.cjs +45 -0
- package/dist/cjs/components/message.cjs +30 -0
- package/dist/cjs/components/native-select.cjs +19 -0
- package/dist/cjs/components/navigation-menu.cjs +43 -0
- package/dist/cjs/components/pagination.cjs +36 -0
- package/dist/cjs/components/popover.cjs +31 -0
- package/dist/cjs/components/progress.cjs +28 -0
- package/dist/cjs/components/questionnaire.cjs +70 -0
- package/dist/cjs/components/radio-group.cjs +16 -0
- package/dist/cjs/components/resizable.cjs +39 -0
- package/dist/cjs/components/scroll-area.cjs +15 -0
- package/dist/cjs/components/select.cjs +47 -0
- package/dist/cjs/components/separator.cjs +11 -0
- package/dist/cjs/components/sheet.cjs +47 -0
- package/dist/cjs/components/sidebar.cjs +301 -0
- package/dist/cjs/components/skeleton.cjs +10 -0
- package/dist/cjs/components/slider.cjs +16 -0
- package/dist/cjs/components/spinner.cjs +11 -0
- package/dist/cjs/components/switch.cjs +12 -0
- package/dist/cjs/components/table.cjs +38 -0
- package/dist/cjs/components/tabs.cjs +37 -0
- package/dist/cjs/components/textarea.cjs +10 -0
- package/dist/cjs/components/toast.cjs +82 -0
- package/dist/cjs/components/toggle-group.cjs +47 -0
- package/dist/cjs/components/toggle.cjs +30 -0
- package/dist/cjs/components/tooltip.cjs +24 -0
- package/dist/cjs/components/trace.cjs +40 -0
- package/dist/cjs/hooks/use-highlighted-code.cjs +73 -0
- package/dist/cjs/hooks/use-hydrated.cjs +2 -2
- package/dist/cjs/hooks/use-mobile.cjs +36 -0
- package/dist/cjs/index.cjs +467 -0
- package/dist/cjs/lib/highlighter.cjs +96 -0
- package/dist/cjs/providers/preference-provider.cjs +13 -13
- package/dist/cjs/providers/theme-provider.cjs +10 -10
- package/dist/cjs/types/components/accordion.d.ts +9 -0
- package/dist/cjs/types/components/alert-dialog.d.ts +20 -0
- package/dist/cjs/types/components/alert.d.ts +13 -0
- package/dist/cjs/types/components/aspect-ratio.d.ts +7 -0
- package/dist/cjs/types/components/attachment.d.ts +26 -0
- package/dist/cjs/types/components/avatar.d.ts +13 -0
- package/dist/cjs/types/components/badge.d.ts +11 -0
- package/dist/cjs/types/components/breadcrumb.d.ts +12 -0
- package/dist/cjs/types/components/bubble.d.ts +19 -0
- package/dist/cjs/types/components/button-group.d.ts +14 -0
- package/dist/cjs/types/components/button.d.ts +4 -4
- package/dist/cjs/types/components/calendar.d.ts +12 -0
- package/dist/cjs/types/components/card.d.ts +13 -0
- package/dist/cjs/types/components/carousel.d.ts +31 -0
- package/dist/cjs/types/components/chart.d.ts +47 -0
- package/dist/cjs/types/components/checkbox.d.ts +6 -0
- package/dist/cjs/types/components/code-block.d.ts +29 -0
- package/dist/cjs/types/components/collapsible.d.ts +8 -0
- package/dist/cjs/types/components/combobox.d.ts +26 -0
- package/dist/cjs/types/components/command.d.ts +21 -0
- package/dist/cjs/types/components/context-menu.d.ts +31 -0
- package/dist/cjs/types/components/dialog.d.ts +19 -0
- package/dist/cjs/types/components/direction.d.ts +1 -0
- package/dist/cjs/types/components/drawer.d.ts +18 -0
- package/dist/cjs/types/components/dropdown-menu.d.ts +31 -0
- package/dist/cjs/types/components/empty.d.ts +15 -0
- package/dist/cjs/types/components/field.d.ts +28 -0
- package/dist/cjs/types/components/hover-card.d.ts +8 -0
- package/dist/cjs/types/components/index.d.ts +62 -0
- package/dist/cjs/types/components/input-group.d.ts +21 -0
- package/dist/cjs/types/components/input-otp.d.ts +13 -0
- package/dist/cjs/types/components/input.d.ts +2 -2
- package/dist/cjs/types/components/item.d.ts +25 -0
- package/dist/cjs/types/components/kbd.d.ts +6 -0
- package/dist/cjs/types/components/label.d.ts +5 -0
- package/dist/cjs/types/components/marker.d.ts +13 -0
- package/dist/cjs/types/components/menubar.d.ts +31 -0
- package/dist/cjs/types/components/message-scroller.d.ts +13 -0
- package/dist/cjs/types/components/message.d.ts +12 -0
- package/dist/cjs/types/components/native-select.d.ts +10 -0
- package/dist/cjs/types/components/navigation-menu.d.ts +15 -0
- package/dist/cjs/types/components/pagination.d.ts +19 -0
- package/dist/cjs/types/components/popover.d.ts +11 -0
- package/dist/cjs/types/components/progress.d.ts +10 -0
- package/dist/cjs/types/components/questionnaire.d.ts +21 -0
- package/dist/cjs/types/components/radio-group.d.ts +8 -0
- package/dist/cjs/types/components/resizable.d.ts +10 -0
- package/dist/cjs/types/components/scroll-area.d.ts +7 -0
- package/dist/cjs/types/components/select.d.ts +17 -0
- package/dist/cjs/types/components/separator.d.ts +6 -0
- package/dist/cjs/types/components/sheet.d.ts +16 -0
- package/dist/cjs/types/components/sidebar.d.ts +66 -0
- package/dist/cjs/types/components/skeleton.d.ts +5 -0
- package/dist/cjs/types/components/slider.d.ts +6 -0
- package/dist/cjs/types/components/spinner.d.ts +5 -0
- package/dist/cjs/types/components/switch.d.ts +8 -0
- package/dist/cjs/types/components/table.d.ts +12 -0
- package/dist/cjs/types/components/tabs.d.ts +14 -0
- package/dist/cjs/types/components/textarea.d.ts +5 -0
- package/dist/cjs/types/components/theme-toggle.d.ts +2 -2
- package/dist/cjs/types/components/toast.d.ts +19 -0
- package/dist/cjs/types/components/toggle-group.d.ts +13 -0
- package/dist/cjs/types/components/toggle.d.ts +12 -0
- package/dist/cjs/types/components/tooltip.d.ts +9 -0
- package/dist/cjs/types/components/trace.d.ts +20 -0
- package/dist/cjs/types/hooks/index.d.ts +2 -0
- package/dist/cjs/types/hooks/use-highlighted-code.d.ts +3 -0
- package/dist/cjs/types/hooks/use-mobile.d.ts +3 -0
- package/dist/cjs/types/index.d.ts +65 -0
- package/dist/cjs/types/lib/highlighter.d.ts +11 -0
- package/dist/cjs/types/lib/index.d.ts +1 -0
- package/dist/cjs/types/providers/preference-provider.d.ts +2 -2
- package/dist/cjs/types/providers/theme-provider.d.ts +2 -2
- package/dist/esm/components/accordion.js +19 -0
- package/dist/esm/components/alert-dialog.js +43 -0
- package/dist/esm/components/alert.js +29 -0
- package/dist/esm/components/aspect-ratio.js +10 -0
- package/dist/esm/components/attachment.js +70 -0
- package/dist/esm/components/avatar.js +24 -0
- package/dist/esm/components/badge.js +35 -0
- package/dist/esm/components/breadcrumb.js +38 -0
- package/dist/esm/components/bubble.js +61 -0
- package/dist/esm/components/button-group.js +38 -0
- package/dist/esm/components/calendar.js +78 -0
- package/dist/esm/components/card.js +26 -0
- package/dist/esm/components/carousel.js +87 -0
- package/dist/esm/components/chart.js +133 -0
- package/dist/esm/components/checkbox.js +11 -0
- package/dist/esm/components/code-block.js +82 -0
- package/dist/esm/components/collapsible.js +14 -0
- package/dist/esm/components/combobox.js +60 -0
- package/dist/esm/components/command.js +36 -0
- package/dist/esm/components/context-menu.js +53 -0
- package/dist/esm/components/dialog.js +39 -0
- package/dist/esm/components/drawer.js +77 -0
- package/dist/esm/components/dropdown-menu.js +52 -0
- package/dist/esm/components/empty.js +35 -0
- package/dist/esm/components/field.js +69 -0
- package/dist/esm/components/hover-card.js +16 -0
- package/dist/esm/components/input-group.js +59 -0
- package/dist/esm/components/input-otp.js +22 -0
- package/dist/esm/components/item.js +80 -0
- package/dist/esm/components/kbd.js +11 -0
- package/dist/esm/components/label.js +9 -0
- package/dist/esm/components/marker.js +36 -0
- package/dist/esm/components/menubar.js +58 -0
- package/dist/esm/components/message-scroller.js +27 -0
- package/dist/esm/components/message.js +23 -0
- package/dist/esm/components/native-select.js +15 -0
- package/dist/esm/components/navigation-menu.js +33 -0
- package/dist/esm/components/pagination.js +28 -0
- package/dist/esm/components/popover.js +24 -0
- package/dist/esm/components/progress.js +22 -0
- package/dist/esm/components/questionnaire.js +54 -0
- package/dist/esm/components/radio-group.js +13 -0
- package/dist/esm/components/resizable.js +16 -0
- package/dist/esm/components/scroll-area.js +12 -0
- package/dist/esm/components/select.js +36 -0
- package/dist/esm/components/separator.js +9 -0
- package/dist/esm/components/sheet.js +38 -0
- package/dist/esm/components/sidebar.js +257 -0
- package/dist/esm/components/skeleton.js +8 -0
- package/dist/esm/components/slider.js +14 -0
- package/dist/esm/components/spinner.js +9 -0
- package/dist/esm/components/switch.js +10 -0
- package/dist/esm/components/table.js +29 -0
- package/dist/esm/components/tabs.js +31 -0
- package/dist/esm/components/textarea.js +8 -0
- package/dist/esm/components/toast.js +68 -0
- package/dist/esm/components/toggle-group.js +25 -0
- package/dist/esm/components/toggle.js +27 -0
- package/dist/esm/components/tooltip.js +19 -0
- package/dist/esm/components/trace.js +31 -0
- package/dist/esm/hooks/use-highlighted-code.js +52 -0
- package/dist/esm/hooks/use-mobile.js +15 -0
- package/dist/esm/index.js +65 -0
- package/dist/esm/lib/highlighter.js +93 -0
- package/dist/styles/custom.css +2 -0
- package/dist/styles/index.css +1 -1
- package/dist/types/components/accordion.d.ts +9 -0
- package/dist/types/components/alert-dialog.d.ts +20 -0
- package/dist/types/components/alert.d.ts +13 -0
- package/dist/types/components/aspect-ratio.d.ts +7 -0
- package/dist/types/components/attachment.d.ts +26 -0
- package/dist/types/components/avatar.d.ts +13 -0
- package/dist/types/components/badge.d.ts +11 -0
- package/dist/types/components/breadcrumb.d.ts +12 -0
- package/dist/types/components/bubble.d.ts +19 -0
- package/dist/types/components/button-group.d.ts +14 -0
- package/dist/types/components/button.d.ts +4 -4
- package/dist/types/components/calendar.d.ts +12 -0
- package/dist/types/components/card.d.ts +13 -0
- package/dist/types/components/carousel.d.ts +31 -0
- package/dist/types/components/chart.d.ts +47 -0
- package/dist/types/components/checkbox.d.ts +6 -0
- package/dist/types/components/code-block.d.ts +29 -0
- package/dist/types/components/collapsible.d.ts +8 -0
- package/dist/types/components/combobox.d.ts +26 -0
- package/dist/types/components/command.d.ts +21 -0
- package/dist/types/components/context-menu.d.ts +31 -0
- package/dist/types/components/dialog.d.ts +19 -0
- package/dist/types/components/direction.d.ts +1 -0
- package/dist/types/components/drawer.d.ts +18 -0
- package/dist/types/components/dropdown-menu.d.ts +31 -0
- package/dist/types/components/empty.d.ts +15 -0
- package/dist/types/components/field.d.ts +28 -0
- package/dist/types/components/hover-card.d.ts +8 -0
- package/dist/types/components/index.d.ts +62 -0
- package/dist/types/components/input-group.d.ts +21 -0
- package/dist/types/components/input-otp.d.ts +13 -0
- package/dist/types/components/input.d.ts +2 -2
- package/dist/types/components/item.d.ts +25 -0
- package/dist/types/components/kbd.d.ts +6 -0
- package/dist/types/components/label.d.ts +5 -0
- package/dist/types/components/marker.d.ts +13 -0
- package/dist/types/components/menubar.d.ts +31 -0
- package/dist/types/components/message-scroller.d.ts +13 -0
- package/dist/types/components/message.d.ts +12 -0
- package/dist/types/components/native-select.d.ts +10 -0
- package/dist/types/components/navigation-menu.d.ts +15 -0
- package/dist/types/components/pagination.d.ts +19 -0
- package/dist/types/components/popover.d.ts +11 -0
- package/dist/types/components/progress.d.ts +10 -0
- package/dist/types/components/questionnaire.d.ts +21 -0
- package/dist/types/components/radio-group.d.ts +8 -0
- package/dist/types/components/resizable.d.ts +10 -0
- package/dist/types/components/scroll-area.d.ts +7 -0
- package/dist/types/components/select.d.ts +17 -0
- package/dist/types/components/separator.d.ts +6 -0
- package/dist/types/components/sheet.d.ts +16 -0
- package/dist/types/components/sidebar.d.ts +66 -0
- package/dist/types/components/skeleton.d.ts +5 -0
- package/dist/types/components/slider.d.ts +6 -0
- package/dist/types/components/spinner.d.ts +5 -0
- package/dist/types/components/switch.d.ts +8 -0
- package/dist/types/components/table.d.ts +12 -0
- package/dist/types/components/tabs.d.ts +14 -0
- package/dist/types/components/textarea.d.ts +5 -0
- package/dist/types/components/theme-toggle.d.ts +2 -2
- package/dist/types/components/toast.d.ts +19 -0
- package/dist/types/components/toggle-group.d.ts +13 -0
- package/dist/types/components/toggle.d.ts +12 -0
- package/dist/types/components/tooltip.d.ts +9 -0
- package/dist/types/components/trace.d.ts +20 -0
- package/dist/types/hooks/index.d.ts +2 -0
- package/dist/types/hooks/use-highlighted-code.d.ts +3 -0
- package/dist/types/hooks/use-mobile.d.ts +3 -0
- package/dist/types/index.d.ts +65 -0
- package/dist/types/lib/highlighter.d.ts +11 -0
- package/dist/types/lib/index.d.ts +1 -0
- package/dist/types/providers/preference-provider.d.ts +2 -2
- package/dist/types/providers/theme-provider.d.ts +2 -2
- package/dist/umd/index.js +86764 -3487
- package/package.json +39 -4
- package/dist/styles/body.css +0 -7
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
import { jsx, 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 'cn';
|
|
7
|
+
import { useIsMobile } from '../hooks/use-mobile.js';
|
|
8
|
+
import { Button } from './button.js';
|
|
9
|
+
import { Input } from './input.js';
|
|
10
|
+
import { Separator } from './separator.js';
|
|
11
|
+
import { Sheet, SheetContent, SheetHeader, SheetTitle, SheetDescription } from './sheet.js';
|
|
12
|
+
import { Skeleton } from './skeleton.js';
|
|
13
|
+
import { TooltipTrigger, Tooltip, TooltipContent } from './tooltip.js';
|
|
14
|
+
import { PanelLeftIcon } from 'lucide-react';
|
|
15
|
+
|
|
16
|
+
const SIDEBAR_COOKIE_NAME = "sidebar_state";
|
|
17
|
+
const SIDEBAR_COOKIE_MAX_AGE = 60 * 60 * 24 * 7;
|
|
18
|
+
const SIDEBAR_WIDTH = "16rem";
|
|
19
|
+
const SIDEBAR_WIDTH_MOBILE = "18rem";
|
|
20
|
+
const SIDEBAR_WIDTH_ICON = "3rem";
|
|
21
|
+
const SIDEBAR_KEYBOARD_SHORTCUT = "b";
|
|
22
|
+
const SidebarContext = React.createContext(null);
|
|
23
|
+
function useSidebar() {
|
|
24
|
+
const context = React.useContext(SidebarContext);
|
|
25
|
+
if (!context) {
|
|
26
|
+
throw new Error("useSidebar must be used within a SidebarProvider.");
|
|
27
|
+
}
|
|
28
|
+
return context;
|
|
29
|
+
}
|
|
30
|
+
function SidebarProvider({ defaultOpen = true, open: openProp, onOpenChange: setOpenProp, className, style, children, ...props }) {
|
|
31
|
+
const isMobile = useIsMobile();
|
|
32
|
+
const [openMobile, setOpenMobile] = React.useState(false);
|
|
33
|
+
// This is the internal state of the sidebar.
|
|
34
|
+
// We use openProp and setOpenProp for control from outside the component.
|
|
35
|
+
const [_open, _setOpen] = React.useState(defaultOpen);
|
|
36
|
+
const open = openProp ?? _open;
|
|
37
|
+
const setOpen = React.useCallback((value) => {
|
|
38
|
+
const openState = typeof value === "function" ? value(open) : value;
|
|
39
|
+
if (setOpenProp) {
|
|
40
|
+
setOpenProp(openState);
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
_setOpen(openState);
|
|
44
|
+
}
|
|
45
|
+
// This sets the cookie to keep the sidebar state.
|
|
46
|
+
document.cookie = `${SIDEBAR_COOKIE_NAME}=${openState}; path=/; max-age=${SIDEBAR_COOKIE_MAX_AGE}`;
|
|
47
|
+
}, [setOpenProp, open]);
|
|
48
|
+
// Helper to toggle the sidebar.
|
|
49
|
+
const toggleSidebar = React.useCallback(() => {
|
|
50
|
+
return isMobile ? setOpenMobile((open) => !open) : setOpen((open) => !open);
|
|
51
|
+
}, [isMobile, setOpen, setOpenMobile]);
|
|
52
|
+
// Adds a keyboard shortcut to toggle the sidebar.
|
|
53
|
+
React.useEffect(() => {
|
|
54
|
+
const handleKeyDown = (event) => {
|
|
55
|
+
if (event.key === SIDEBAR_KEYBOARD_SHORTCUT &&
|
|
56
|
+
(event.metaKey || event.ctrlKey)) {
|
|
57
|
+
event.preventDefault();
|
|
58
|
+
toggleSidebar();
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
window.addEventListener("keydown", handleKeyDown);
|
|
62
|
+
return () => window.removeEventListener("keydown", handleKeyDown);
|
|
63
|
+
}, [toggleSidebar]);
|
|
64
|
+
// We add a state so that we can do data-state="expanded" or "collapsed".
|
|
65
|
+
// This makes it easier to style the sidebar with Tailwind classes.
|
|
66
|
+
const state = open ? "expanded" : "collapsed";
|
|
67
|
+
const contextValue = React.useMemo(() => ({
|
|
68
|
+
state,
|
|
69
|
+
open,
|
|
70
|
+
setOpen,
|
|
71
|
+
isMobile,
|
|
72
|
+
openMobile,
|
|
73
|
+
setOpenMobile,
|
|
74
|
+
toggleSidebar,
|
|
75
|
+
}), [state, open, setOpen, isMobile, openMobile, setOpenMobile, toggleSidebar]);
|
|
76
|
+
return (jsx(SidebarContext.Provider, { value: contextValue, children: jsx("div", { "data-slot": "sidebar-wrapper", style: {
|
|
77
|
+
"--sidebar-width": SIDEBAR_WIDTH,
|
|
78
|
+
"--sidebar-width-icon": SIDEBAR_WIDTH_ICON,
|
|
79
|
+
...style,
|
|
80
|
+
}, className: cn("group/sidebar-wrapper flex min-h-svh w-full has-data-[variant=inset]:bg-sidebar", className), ...props, children: children }) }));
|
|
81
|
+
}
|
|
82
|
+
function Sidebar({ side = "left", variant = "sidebar", collapsible = "offcanvas", className, children, dir, ...props }) {
|
|
83
|
+
const { isMobile, state, openMobile, setOpenMobile } = useSidebar();
|
|
84
|
+
if (collapsible === "none") {
|
|
85
|
+
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 }));
|
|
86
|
+
}
|
|
87
|
+
if (isMobile) {
|
|
88
|
+
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: {
|
|
89
|
+
"--sidebar-width": SIDEBAR_WIDTH_MOBILE,
|
|
90
|
+
}, 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 })] }) }));
|
|
91
|
+
}
|
|
92
|
+
return (jsxs("div", { className: "group peer hidden text-sidebar-foreground md:block", "data-state": state, "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"
|
|
93
|
+
? "group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]"
|
|
94
|
+
: "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",
|
|
95
|
+
// Adjust the padding for floating and inset variants.
|
|
96
|
+
variant === "floating" || variant === "inset"
|
|
97
|
+
? "p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]"
|
|
98
|
+
: "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 }) })] }));
|
|
99
|
+
}
|
|
100
|
+
function SidebarTrigger({ className, onClick, ...props }) {
|
|
101
|
+
const { toggleSidebar } = useSidebar();
|
|
102
|
+
return (jsxs(Button, { "data-sidebar": "trigger", "data-slot": "sidebar-trigger", variant: "ghost", size: "icon-sm", className: cn(className), onClick: (event) => {
|
|
103
|
+
onClick?.(event);
|
|
104
|
+
toggleSidebar();
|
|
105
|
+
}, ...props, children: [jsx(PanelLeftIcon, {}), jsx("span", { className: "sr-only", children: "Toggle Sidebar" })] }));
|
|
106
|
+
}
|
|
107
|
+
function SidebarRail({ className, ...props }) {
|
|
108
|
+
const { toggleSidebar } = useSidebar();
|
|
109
|
+
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-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]: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 }));
|
|
110
|
+
}
|
|
111
|
+
function SidebarInset({ className, ...props }) {
|
|
112
|
+
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-[state=collapsed]:ml-2", className), ...props }));
|
|
113
|
+
}
|
|
114
|
+
function SidebarInput({ className, ...props }) {
|
|
115
|
+
return (jsx(Input, { "data-slot": "sidebar-input", "data-sidebar": "input", className: cn("h-8 w-full bg-background shadow-none", className), ...props }));
|
|
116
|
+
}
|
|
117
|
+
function SidebarHeader({ className, ...props }) {
|
|
118
|
+
return (jsx("div", { "data-slot": "sidebar-header", "data-sidebar": "header", className: cn("flex flex-col gap-2 p-2", className), ...props }));
|
|
119
|
+
}
|
|
120
|
+
function SidebarFooter({ className, ...props }) {
|
|
121
|
+
return (jsx("div", { "data-slot": "sidebar-footer", "data-sidebar": "footer", className: cn("flex flex-col gap-2 p-2", className), ...props }));
|
|
122
|
+
}
|
|
123
|
+
function SidebarSeparator({ className, ...props }) {
|
|
124
|
+
return (jsx(Separator, { "data-slot": "sidebar-separator", "data-sidebar": "separator", className: cn("mx-2 w-auto bg-sidebar-border", className), ...props }));
|
|
125
|
+
}
|
|
126
|
+
function SidebarContent({ className, ...props }) {
|
|
127
|
+
return (jsx("div", { "data-slot": "sidebar-content", "data-sidebar": "content", className: cn("no-scrollbar flex min-h-0 flex-1 flex-col gap-0 overflow-auto group-data-[collapsible=icon]:overflow-hidden", className), ...props }));
|
|
128
|
+
}
|
|
129
|
+
function SidebarGroup({ className, ...props }) {
|
|
130
|
+
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 }));
|
|
131
|
+
}
|
|
132
|
+
function SidebarGroupLabel({ className, render, ...props }) {
|
|
133
|
+
return useRender({
|
|
134
|
+
defaultTagName: "div",
|
|
135
|
+
props: mergeProps({
|
|
136
|
+
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),
|
|
137
|
+
}, props),
|
|
138
|
+
render,
|
|
139
|
+
state: {
|
|
140
|
+
slot: "sidebar-group-label",
|
|
141
|
+
sidebar: "group-label",
|
|
142
|
+
},
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
function SidebarGroupAction({ className, render, ...props }) {
|
|
146
|
+
return useRender({
|
|
147
|
+
defaultTagName: "button",
|
|
148
|
+
props: mergeProps({
|
|
149
|
+
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),
|
|
150
|
+
}, props),
|
|
151
|
+
render,
|
|
152
|
+
state: {
|
|
153
|
+
slot: "sidebar-group-action",
|
|
154
|
+
sidebar: "group-action",
|
|
155
|
+
},
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
function SidebarGroupContent({ className, ...props }) {
|
|
159
|
+
return (jsx("div", { "data-slot": "sidebar-group-content", "data-sidebar": "group-content", className: cn("w-full text-sm", className), ...props }));
|
|
160
|
+
}
|
|
161
|
+
function SidebarMenu({ className, ...props }) {
|
|
162
|
+
return (jsx("ul", { "data-slot": "sidebar-menu", "data-sidebar": "menu", className: cn("flex w-full min-w-0 flex-col gap-0", className), ...props }));
|
|
163
|
+
}
|
|
164
|
+
function SidebarMenuItem({ className, ...props }) {
|
|
165
|
+
return (jsx("li", { "data-slot": "sidebar-menu-item", "data-sidebar": "menu-item", className: cn("group/menu-item relative", className), ...props }));
|
|
166
|
+
}
|
|
167
|
+
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", {
|
|
168
|
+
variants: {
|
|
169
|
+
variant: {
|
|
170
|
+
default: "hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",
|
|
171
|
+
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)]",
|
|
172
|
+
},
|
|
173
|
+
size: {
|
|
174
|
+
default: "h-8 text-sm",
|
|
175
|
+
sm: "h-7 text-xs",
|
|
176
|
+
lg: "h-12 text-sm group-data-[collapsible=icon]:p-0!",
|
|
177
|
+
},
|
|
178
|
+
},
|
|
179
|
+
defaultVariants: {
|
|
180
|
+
variant: "default",
|
|
181
|
+
size: "default",
|
|
182
|
+
},
|
|
183
|
+
});
|
|
184
|
+
function SidebarMenuButton({ render, isActive = false, variant = "default", size = "default", tooltip, className, ...props }) {
|
|
185
|
+
const { isMobile, state } = useSidebar();
|
|
186
|
+
const comp = useRender({
|
|
187
|
+
defaultTagName: "button",
|
|
188
|
+
props: mergeProps({
|
|
189
|
+
className: cn(sidebarMenuButtonVariants({ variant, size }), className),
|
|
190
|
+
}, props),
|
|
191
|
+
render: !tooltip ? render : jsx(TooltipTrigger, { render: render }),
|
|
192
|
+
state: {
|
|
193
|
+
slot: "sidebar-menu-button",
|
|
194
|
+
sidebar: "menu-button",
|
|
195
|
+
size,
|
|
196
|
+
active: isActive,
|
|
197
|
+
},
|
|
198
|
+
});
|
|
199
|
+
if (!tooltip) {
|
|
200
|
+
return comp;
|
|
201
|
+
}
|
|
202
|
+
if (typeof tooltip === "string") {
|
|
203
|
+
tooltip = {
|
|
204
|
+
children: tooltip,
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
return (jsxs(Tooltip, { children: [comp, jsx(TooltipContent, { side: "right", align: "center", hidden: state !== "collapsed" || isMobile, ...tooltip })] }));
|
|
208
|
+
}
|
|
209
|
+
function SidebarMenuAction({ className, render, showOnHover = false, ...props }) {
|
|
210
|
+
return useRender({
|
|
211
|
+
defaultTagName: "button",
|
|
212
|
+
props: mergeProps({
|
|
213
|
+
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 &&
|
|
214
|
+
"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),
|
|
215
|
+
}, props),
|
|
216
|
+
render,
|
|
217
|
+
state: {
|
|
218
|
+
slot: "sidebar-menu-action",
|
|
219
|
+
sidebar: "menu-action",
|
|
220
|
+
},
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
function SidebarMenuBadge({ className, ...props }) {
|
|
224
|
+
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 }));
|
|
225
|
+
}
|
|
226
|
+
function SidebarMenuSkeleton({ className, showIcon = false, ...props }) {
|
|
227
|
+
// Random width between 50 to 90%.
|
|
228
|
+
const [width] = React.useState(() => {
|
|
229
|
+
return `${Math.floor(Math.random() * 40) + 50}%`;
|
|
230
|
+
});
|
|
231
|
+
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: {
|
|
232
|
+
"--skeleton-width": width,
|
|
233
|
+
} })] }));
|
|
234
|
+
}
|
|
235
|
+
function SidebarMenuSub({ className, ...props }) {
|
|
236
|
+
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 }));
|
|
237
|
+
}
|
|
238
|
+
function SidebarMenuSubItem({ className, ...props }) {
|
|
239
|
+
return (jsx("li", { "data-slot": "sidebar-menu-sub-item", "data-sidebar": "menu-sub-item", className: cn("group/menu-sub-item relative", className), ...props }));
|
|
240
|
+
}
|
|
241
|
+
function SidebarMenuSubButton({ render, size = "md", isActive = false, className, ...props }) {
|
|
242
|
+
return useRender({
|
|
243
|
+
defaultTagName: "a",
|
|
244
|
+
props: mergeProps({
|
|
245
|
+
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),
|
|
246
|
+
}, props),
|
|
247
|
+
render,
|
|
248
|
+
state: {
|
|
249
|
+
slot: "sidebar-menu-sub-button",
|
|
250
|
+
sidebar: "menu-sub-button",
|
|
251
|
+
size,
|
|
252
|
+
active: isActive,
|
|
253
|
+
},
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
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,8 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { cn } from 'cn';
|
|
3
|
+
|
|
4
|
+
function Skeleton({ className, ...props }) {
|
|
5
|
+
return (jsx("div", { "data-slot": "skeleton", className: cn("animate-pulse rounded-md bg-muted", className), ...props }));
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export { Skeleton };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
|
+
import { Slider as Slider$1 } from '@base-ui/react/slider';
|
|
3
|
+
import { cn } from 'cn';
|
|
4
|
+
|
|
5
|
+
function Slider({ className, defaultValue, value, min = 0, max = 100, ...props }) {
|
|
6
|
+
const _values = Array.isArray(value)
|
|
7
|
+
? value
|
|
8
|
+
: Array.isArray(defaultValue)
|
|
9
|
+
? defaultValue
|
|
10
|
+
: [min, max];
|
|
11
|
+
return (jsx(Slider$1.Root, { className: cn("data-horizontal:w-full data-vertical:h-full", className), "data-slot": "slider", defaultValue: defaultValue, value: value, min: min, max: max, thumbAlignment: "edge", ...props, children: jsxs(Slider$1.Control, { className: "relative flex w-full touch-none items-center select-none data-disabled:opacity-50 data-vertical:h-full data-vertical:min-h-40 data-vertical:w-auto data-vertical:flex-col", children: [jsx(Slider$1.Track, { "data-slot": "slider-track", className: "relative grow overflow-hidden rounded-full bg-muted select-none data-horizontal:h-1 data-horizontal:w-full data-vertical:h-full data-vertical:w-1", children: jsx(Slider$1.Indicator, { "data-slot": "slider-range", className: "bg-primary select-none data-horizontal:h-full data-vertical:w-full" }) }), Array.from({ length: _values.length }, (_, index) => (jsx(Slider$1.Thumb, { "data-slot": "slider-thumb", className: "relative block size-3 shrink-0 rounded-full border border-ring bg-white ring-ring/50 transition-[color,box-shadow] select-none after:absolute after:-inset-2 hover:ring-3 focus-visible:ring-3 focus-visible:outline-hidden active:ring-3 disabled:pointer-events-none disabled:opacity-50" }, index)))] }) }));
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export { Slider };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { cn } from 'cn';
|
|
3
|
+
import { Loader2Icon } from 'lucide-react';
|
|
4
|
+
|
|
5
|
+
function Spinner({ className, ...props }) {
|
|
6
|
+
return (jsx(Loader2Icon, { "data-slot": "spinner", role: "status", "aria-label": "Loading", className: cn("size-4 animate-spin", className), ...props }));
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export { Spinner };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { Switch as Switch$1 } from '@base-ui/react/switch';
|
|
4
|
+
import { cn } from 'cn';
|
|
5
|
+
|
|
6
|
+
function Switch({ className, size = "default", ...props }) {
|
|
7
|
+
return (jsx(Switch$1.Root, { "data-slot": "switch", "data-size": size, className: cn("peer group/switch relative inline-flex shrink-0 items-center rounded-full border border-transparent transition-all outline-none group-has-[:focus-visible]/field-label:border-transparent group-has-[:focus-visible]/field-label:ring-0 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-[size=default]:h-[18.4px] data-[size=default]:w-[32px] data-[size=sm]:h-[14px] data-[size=sm]:w-[24px] dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:bg-primary data-unchecked:bg-input dark:data-unchecked:bg-input/80 data-disabled:cursor-not-allowed data-disabled:opacity-50", className), ...props, children: jsx(Switch$1.Thumb, { "data-slot": "switch-thumb", className: "pointer-events-none block rounded-full bg-background ring-0 transition-transform group-data-[size=default]/switch:size-4 group-data-[size=sm]/switch:size-3 group-data-[size=default]/switch:data-checked:translate-x-[calc(100%-2px)] group-data-[size=sm]/switch:data-checked:translate-x-[calc(100%-2px)] dark:data-checked:bg-primary-foreground group-data-[size=default]/switch:data-unchecked:translate-x-0 group-data-[size=sm]/switch:data-unchecked:translate-x-0 dark:data-unchecked:bg-foreground" }) }));
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export { Switch };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { cn } from 'cn';
|
|
3
|
+
|
|
4
|
+
function Table({ className, ...props }) {
|
|
5
|
+
return (jsx("div", { "data-slot": "table-container", className: "relative w-full overflow-x-auto", children: jsx("table", { "data-slot": "table", className: cn("w-full caption-bottom text-sm", className), ...props }) }));
|
|
6
|
+
}
|
|
7
|
+
function TableHeader({ className, ...props }) {
|
|
8
|
+
return (jsx("thead", { "data-slot": "table-header", className: cn("[&_tr]:border-b", className), ...props }));
|
|
9
|
+
}
|
|
10
|
+
function TableBody({ className, ...props }) {
|
|
11
|
+
return (jsx("tbody", { "data-slot": "table-body", className: cn("[&_tr:last-child]:border-0", className), ...props }));
|
|
12
|
+
}
|
|
13
|
+
function TableFooter({ className, ...props }) {
|
|
14
|
+
return (jsx("tfoot", { "data-slot": "table-footer", className: cn("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0", className), ...props }));
|
|
15
|
+
}
|
|
16
|
+
function TableRow({ className, ...props }) {
|
|
17
|
+
return (jsx("tr", { "data-slot": "table-row", className: cn("border-b transition-colors hover:bg-muted/50 has-aria-expanded:bg-muted/50 data-[state=selected]:bg-muted", className), ...props }));
|
|
18
|
+
}
|
|
19
|
+
function TableHead({ className, ...props }) {
|
|
20
|
+
return (jsx("th", { "data-slot": "table-head", className: cn("h-10 px-2 text-left align-middle font-medium whitespace-nowrap text-foreground [&:has([role=checkbox])]:pr-0", className), ...props }));
|
|
21
|
+
}
|
|
22
|
+
function TableCell({ className, ...props }) {
|
|
23
|
+
return (jsx("td", { "data-slot": "table-cell", className: cn("p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0", className), ...props }));
|
|
24
|
+
}
|
|
25
|
+
function TableCaption({ className, ...props }) {
|
|
26
|
+
return (jsx("caption", { "data-slot": "table-caption", className: cn("mt-4 text-sm text-muted-foreground", className), ...props }));
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export { Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { Tabs as Tabs$1 } from '@base-ui/react/tabs';
|
|
4
|
+
import { cva } from 'class-variance-authority';
|
|
5
|
+
import { cn } from 'cn';
|
|
6
|
+
|
|
7
|
+
function Tabs({ className, orientation = "horizontal", ...props }) {
|
|
8
|
+
return (jsx(Tabs$1.Root, { "data-slot": "tabs", "data-orientation": orientation, className: cn("group/tabs flex gap-2 data-horizontal:flex-col", className), ...props }));
|
|
9
|
+
}
|
|
10
|
+
const tabsListVariants = cva("group/tabs-list inline-flex w-fit items-center justify-center rounded-lg p-[3px] text-muted-foreground group-data-horizontal/tabs:h-8 group-data-vertical/tabs:h-fit group-data-vertical/tabs:flex-col data-[variant=line]:rounded-none", {
|
|
11
|
+
variants: {
|
|
12
|
+
variant: {
|
|
13
|
+
default: "bg-muted",
|
|
14
|
+
line: "gap-1 bg-transparent",
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
defaultVariants: {
|
|
18
|
+
variant: "default",
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
function TabsList({ className, variant = "default", ...props }) {
|
|
22
|
+
return (jsx(Tabs$1.List, { "data-slot": "tabs-list", "data-variant": variant, className: cn(tabsListVariants({ variant }), className), ...props }));
|
|
23
|
+
}
|
|
24
|
+
function TabsTrigger({ className, ...props }) {
|
|
25
|
+
return (jsx(Tabs$1.Tab, { "data-slot": "tabs-trigger", className: cn("relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-1.5 py-0.5 text-sm font-medium whitespace-nowrap text-foreground/60 transition-all group-data-vertical/tabs:w-full group-data-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 has-data-[icon=inline-end]:pr-1 has-data-[icon=inline-start]:pl-1 aria-disabled:pointer-events-none aria-disabled:opacity-50 dark:text-muted-foreground dark:hover:text-foreground group-data-[variant=default]/tabs-list:data-active:shadow-sm group-data-[variant=line]/tabs-list:data-active:shadow-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", "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", "after:absolute after:bg-foreground after:opacity-0 after:transition-opacity group-data-horizontal/tabs:after:inset-x-0 group-data-horizontal/tabs:after:bottom-[-5px] group-data-horizontal/tabs:after:h-0.5 group-data-vertical/tabs:after:inset-y-0 group-data-vertical/tabs:after:-right-1 group-data-vertical/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-active:after:opacity-100", className), ...props }));
|
|
26
|
+
}
|
|
27
|
+
function TabsContent({ className, ...props }) {
|
|
28
|
+
return (jsx(Tabs$1.Panel, { "data-slot": "tabs-content", className: cn("flex-1 text-sm outline-none", className), ...props }));
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export { Tabs, TabsContent, TabsList, TabsTrigger, tabsListVariants };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { cn } from 'cn';
|
|
3
|
+
|
|
4
|
+
function Textarea({ className, ...props }) {
|
|
5
|
+
return (jsx("textarea", { "data-slot": "textarea", className: cn("flex field-sizing-content min-h-16 w-full rounded-lg border border-input bg-transparent px-2.5 py-2 text-base transition-colors outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40", className), ...props }));
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export { Textarea };
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
3
|
+
import { Toast as Toast$1 } from '@base-ui/react/toast';
|
|
4
|
+
import { cn } from 'cn';
|
|
5
|
+
import { Button } from './button.js';
|
|
6
|
+
import { XIcon, CircleCheckIcon, InfoIcon, TriangleAlertIcon, OctagonXIcon, Loader2Icon } from 'lucide-react';
|
|
7
|
+
|
|
8
|
+
const toast = Toast$1.createToastManager();
|
|
9
|
+
function ToastProvider({ ...props }) {
|
|
10
|
+
return jsx(Toast$1.Provider, { ...props });
|
|
11
|
+
}
|
|
12
|
+
function ToastPortal({ ...props }) {
|
|
13
|
+
return jsx(Toast$1.Portal, { "data-slot": "toast-portal", ...props });
|
|
14
|
+
}
|
|
15
|
+
function ToastViewport({ className, ...props }) {
|
|
16
|
+
return (jsx(Toast$1.Viewport, { "data-slot": "toast-viewport", className: cn("pointer-events-none fixed inset-x-4 bottom-4 z-50 mx-auto w-auto max-w-sm outline-none sm:right-4 sm:left-auto sm:mx-0 sm:w-full", className), ...props }));
|
|
17
|
+
}
|
|
18
|
+
function Toast({ className, ...props }) {
|
|
19
|
+
return (jsx(Toast$1.Root, { "data-slot": "toast", className: cn("group/toast pointer-events-auto absolute right-0 bottom-0 z-[calc(1000-var(--toast-index))] w-full origin-bottom rounded-2xl border bg-popover text-popover-foreground shadow-lg will-change-transform outline-none select-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50", "[--gap:0.75rem] [--height:var(--toast-frontmost-height,var(--toast-height))] [--offset-y:calc(var(--toast-offset-y)*-1+calc(var(--toast-index)*var(--gap)*-1)+var(--toast-swipe-movement-y))] [--peek:0.75rem] [--scale:calc(max(0,1-(var(--toast-index)*0.1)))] [--shrink:calc(1-var(--scale))]", "h-(--height) [transform:translateX(var(--toast-swipe-movement-x))_translateY(calc(var(--toast-swipe-movement-y)-(var(--toast-index)*var(--peek))-(var(--shrink)*var(--height))))_scale(var(--scale))] [transition:transform_500ms_cubic-bezier(0.22,1,0.36,1),opacity_500ms,height_150ms]", "after:absolute after:top-full after:left-0 after:h-[calc(var(--gap)+1px)] after:w-full after:content-['']", "data-expanded:h-(--toast-height) data-expanded:[transform:translateX(var(--toast-swipe-movement-x))_translateY(var(--offset-y))]", "data-limited:opacity-0 data-starting-style:[transform:translateY(150%)]", "[&[data-ending-style]:not([data-limited]):not([data-swipe-direction])]:[transform:translateY(150%)]", "data-ending-style:data-[swipe-direction=down]:[transform:translateY(calc(var(--toast-swipe-movement-y)+150%))]", "data-ending-style:data-[swipe-direction=left]:[transform:translateX(calc(var(--toast-swipe-movement-x)-150%))_translateY(var(--offset-y))]", "data-ending-style:data-[swipe-direction=right]:[transform:translateX(calc(var(--toast-swipe-movement-x)+150%))_translateY(var(--offset-y))]", "data-ending-style:data-[swipe-direction=up]:[transform:translateY(calc(var(--toast-swipe-movement-y)-150%))]", "data-expanded:data-ending-style:data-[swipe-direction=down]:[transform:translateY(calc(var(--toast-swipe-movement-y)+150%))]", "data-expanded:data-ending-style:data-[swipe-direction=left]:[transform:translateX(calc(var(--toast-swipe-movement-x)-150%))_translateY(var(--offset-y))]", "data-expanded:data-ending-style:data-[swipe-direction=right]:[transform:translateX(calc(var(--toast-swipe-movement-x)+150%))_translateY(var(--offset-y))]", "data-expanded:data-ending-style:data-[swipe-direction=up]:[transform:translateY(calc(var(--toast-swipe-movement-y)-150%))]", className), ...props }));
|
|
20
|
+
}
|
|
21
|
+
function ToastContent({ className, ...props }) {
|
|
22
|
+
return (jsx(Toast$1.Content, { "data-slot": "toast-content", className: cn("flex h-full items-center gap-3 overflow-hidden p-4 transition-opacity duration-250 ease-[cubic-bezier(0.22,1,0.36,1)] data-behind:opacity-0 data-expanded:opacity-100", className), ...props }));
|
|
23
|
+
}
|
|
24
|
+
function ToastTitle({ className, ...props }) {
|
|
25
|
+
return (jsx(Toast$1.Title, { "data-slot": "toast-title", className: cn("text-sm font-medium", className), ...props }));
|
|
26
|
+
}
|
|
27
|
+
function ToastDescription({ className, ...props }) {
|
|
28
|
+
return (jsx(Toast$1.Description, { "data-slot": "toast-description", className: cn("text-sm text-muted-foreground", className), ...props }));
|
|
29
|
+
}
|
|
30
|
+
function ToastAction({ className, render = jsx(Button, { variant: "outline", size: "sm" }), ...props }) {
|
|
31
|
+
return (jsx(Toast$1.Action, { "data-slot": "toast-action", render: render, className: cn("shrink-0", className), ...props }));
|
|
32
|
+
}
|
|
33
|
+
function ToastClose({ className, children, render = jsx(Button, { variant: "ghost", size: "icon-sm" }), ...props }) {
|
|
34
|
+
return (jsx(Toast$1.Close, { "data-slot": "toast-close", "aria-label": "Close toast", render: render, className: cn("relative shrink-0 text-muted-foreground after:absolute after:-inset-2 after:content-[''] hover:text-foreground", className), ...props, children: children ?? (jsx(XIcon, { "aria-hidden": "true" })) }));
|
|
35
|
+
}
|
|
36
|
+
function ToastIcon({ type }) {
|
|
37
|
+
let icon = null;
|
|
38
|
+
if (type === "success") {
|
|
39
|
+
icon = (jsx(CircleCheckIcon, { "aria-hidden": "true" }));
|
|
40
|
+
}
|
|
41
|
+
if (type === "info") {
|
|
42
|
+
icon = (jsx(InfoIcon, { "aria-hidden": "true" }));
|
|
43
|
+
}
|
|
44
|
+
if (type === "warning") {
|
|
45
|
+
icon = (jsx(TriangleAlertIcon, { "aria-hidden": "true" }));
|
|
46
|
+
}
|
|
47
|
+
if (type === "error") {
|
|
48
|
+
icon = (jsx(OctagonXIcon, { className: "text-destructive", "aria-hidden": "true" }));
|
|
49
|
+
}
|
|
50
|
+
if (type === "loading") {
|
|
51
|
+
icon = (jsx(Loader2Icon, { className: "animate-spin", "aria-hidden": "true" }));
|
|
52
|
+
}
|
|
53
|
+
if (!icon) {
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
return (jsx("span", { "data-slot": "toast-icon", className: "shrink-0 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4", children: icon }));
|
|
57
|
+
}
|
|
58
|
+
function ToastList() {
|
|
59
|
+
const { toasts } = Toast$1.useToastManager();
|
|
60
|
+
return toasts.map((toastItem) => (jsx(Toast, { toast: toastItem, children: jsxs(ToastContent, { children: [jsx(ToastIcon, { type: toastItem.type }), jsxs("div", { className: "flex min-w-0 flex-1 flex-col gap-1", children: [jsx(ToastTitle, {}), jsx(ToastDescription, {})] }), jsx(ToastAction, {}), jsx(ToastClose, {})] }) }, toastItem.id)));
|
|
61
|
+
}
|
|
62
|
+
function Toaster({ children, toastManager = toast, ...props }) {
|
|
63
|
+
return (jsxs(ToastProvider, { toastManager: toastManager, ...props, children: [children, jsx(ToastPortal, { children: jsx(ToastViewport, { children: jsx(ToastList, {}) }) })] }));
|
|
64
|
+
}
|
|
65
|
+
const createToastManager = Toast$1.createToastManager;
|
|
66
|
+
const useToastManager = Toast$1.useToastManager;
|
|
67
|
+
|
|
68
|
+
export { Toast, ToastAction, ToastClose, ToastContent, ToastDescription, ToastPortal, ToastProvider, ToastTitle, ToastViewport, Toaster, createToastManager, toast, useToastManager };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { Toggle } from '@base-ui/react/toggle';
|
|
4
|
+
import { ToggleGroup as ToggleGroup$1 } from '@base-ui/react/toggle-group';
|
|
5
|
+
import { cn } from 'cn';
|
|
6
|
+
import { toggleVariants } from './toggle.js';
|
|
7
|
+
|
|
8
|
+
const ToggleGroupContext = React.createContext({
|
|
9
|
+
size: "default",
|
|
10
|
+
variant: "default",
|
|
11
|
+
spacing: 2,
|
|
12
|
+
orientation: "horizontal",
|
|
13
|
+
});
|
|
14
|
+
function ToggleGroup({ className, variant, size, spacing = 2, orientation = "horizontal", children, ...props }) {
|
|
15
|
+
return (jsx(ToggleGroup$1, { "data-slot": "toggle-group", "data-variant": variant, "data-size": size, "data-spacing": spacing, "data-orientation": orientation, style: { "--gap": spacing }, className: cn("group/toggle-group flex w-fit flex-row items-center gap-[--spacing(var(--gap))] rounded-lg data-[size=sm]:rounded-[min(var(--radius-md),10px)] data-vertical:flex-col data-vertical:items-stretch", className), ...props, children: jsx(ToggleGroupContext.Provider, { value: { variant, size, spacing, orientation }, children: children }) }));
|
|
16
|
+
}
|
|
17
|
+
function ToggleGroupItem({ className, children, variant = "default", size = "default", ...props }) {
|
|
18
|
+
const context = React.useContext(ToggleGroupContext);
|
|
19
|
+
return (jsx(Toggle, { "data-slot": "toggle-group-item", "data-variant": context.variant || variant, "data-size": context.size || size, "data-spacing": context.spacing, className: cn("shrink-0 group-data-[spacing=0]/toggle-group:rounded-none group-data-[spacing=0]/toggle-group:px-2 focus:z-10 focus-visible:z-10 group-data-[spacing=0]/toggle-group:has-data-[icon=inline-end]:pr-1.5 group-data-[spacing=0]/toggle-group:has-data-[icon=inline-start]:pl-1.5 group-data-horizontal/toggle-group:data-[spacing=0]:first:rounded-l-lg group-data-vertical/toggle-group:data-[spacing=0]:first:rounded-t-lg group-data-horizontal/toggle-group:data-[spacing=0]:last:rounded-r-lg group-data-vertical/toggle-group:data-[spacing=0]:last:rounded-b-lg group-data-horizontal/toggle-group:data-[spacing=0]:data-[variant=outline]:border-l-0 group-data-vertical/toggle-group:data-[spacing=0]:data-[variant=outline]:border-t-0 group-data-horizontal/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-l group-data-vertical/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-t", toggleVariants({
|
|
20
|
+
variant: context.variant || variant,
|
|
21
|
+
size: context.size || size,
|
|
22
|
+
}), className), ...props, children: children }));
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export { ToggleGroup, ToggleGroupItem };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { Toggle as Toggle$1 } from '@base-ui/react/toggle';
|
|
3
|
+
import { cva } from 'class-variance-authority';
|
|
4
|
+
import { cn } from 'cn';
|
|
5
|
+
|
|
6
|
+
const toggleVariants = cva("group/toggle inline-flex items-center justify-center gap-1 rounded-lg text-sm font-medium whitespace-nowrap transition-all outline-none hover:bg-muted hover:text-foreground 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 aria-pressed:bg-muted data-[state=on]:bg-muted dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", {
|
|
7
|
+
variants: {
|
|
8
|
+
variant: {
|
|
9
|
+
default: "bg-transparent",
|
|
10
|
+
outline: "border border-input bg-transparent hover:bg-muted",
|
|
11
|
+
},
|
|
12
|
+
size: {
|
|
13
|
+
default: "h-8 min-w-8 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
|
|
14
|
+
sm: "h-7 min-w-7 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5",
|
|
15
|
+
lg: "h-9 min-w-9 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
defaultVariants: {
|
|
19
|
+
variant: "default",
|
|
20
|
+
size: "default",
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
function Toggle({ className, variant = "default", size = "default", ...props }) {
|
|
24
|
+
return (jsx(Toggle$1, { "data-slot": "toggle", className: cn(toggleVariants({ variant, size, className })), ...props }));
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export { Toggle, toggleVariants };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
3
|
+
import { Tooltip as Tooltip$1 } from '@base-ui/react/tooltip';
|
|
4
|
+
import { cn } from 'cn';
|
|
5
|
+
|
|
6
|
+
function TooltipProvider({ delay = 0, ...props }) {
|
|
7
|
+
return (jsx(Tooltip$1.Provider, { "data-slot": "tooltip-provider", delay: delay, ...props }));
|
|
8
|
+
}
|
|
9
|
+
function Tooltip({ ...props }) {
|
|
10
|
+
return jsx(Tooltip$1.Root, { "data-slot": "tooltip", ...props });
|
|
11
|
+
}
|
|
12
|
+
function TooltipTrigger({ ...props }) {
|
|
13
|
+
return jsx(Tooltip$1.Trigger, { "data-slot": "tooltip-trigger", ...props });
|
|
14
|
+
}
|
|
15
|
+
function TooltipContent({ className, side = "top", sideOffset = 4, align = "center", alignOffset = 0, children, ...props }) {
|
|
16
|
+
return (jsx(Tooltip$1.Portal, { children: jsx(Tooltip$1.Positioner, { align: align, alignOffset: alignOffset, side: side, sideOffset: sideOffset, className: "isolate z-50", children: jsxs(Tooltip$1.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-[state=delayed-open]:animate-in data-[state=delayed-open]:fade-in-0 data-[state=delayed-open]:zoom-in-95 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(Tooltip$1.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" })] }) }) }));
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
|
+
import { cn } from 'cn';
|
|
3
|
+
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from './collapsible.js';
|
|
4
|
+
import { ChevronRightIcon } from 'lucide-react';
|
|
5
|
+
|
|
6
|
+
function Trace({ className, ...props }) {
|
|
7
|
+
return (jsx("div", { "data-slot": "trace", className: cn("flex w-full min-w-0 flex-col gap-2 *:has-[>[data-slot=trace-line]]:flex *:has-[>[data-slot=trace-line]]:w-fit *:has-[>[data-slot=trace-line]]:max-w-full *:has-[>[data-slot=trace-line]]:min-w-0 *:has-[>[data-slot=trace-line]]:rounded-md *:has-[>[data-slot=trace-line]]:text-left *:has-[>[data-slot=trace-line]]:outline-none *:has-[>[data-slot=trace-line]]:focus-visible:ring-3 *:has-[>[data-slot=trace-line]]:focus-visible:ring-ring/50", className), ...props }));
|
|
8
|
+
}
|
|
9
|
+
function TraceLine({ className, status, ...props }) {
|
|
10
|
+
return (jsx("span", { "data-slot": "trace-line", "data-status": status, className: cn("flex w-fit max-w-full min-w-0 items-center gap-2 text-sm text-muted-foreground transition-colors in-[a,button]:cursor-pointer in-[a:hover,button:hover]:text-foreground data-[status=error]:text-destructive data-[status=error]:in-[a:hover,button:hover]:text-destructive data-[status=running]:*:data-[slot=trace-title]:shimmer", className), ...props }));
|
|
11
|
+
}
|
|
12
|
+
function TraceIcon({ className, ...props }) {
|
|
13
|
+
return (jsx("span", { "data-slot": "trace-icon", "aria-hidden": "true", className: cn("flex size-4 shrink-0 items-center justify-center [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 [[data-slot=trace-title]~&]:-ml-1", className), ...props }));
|
|
14
|
+
}
|
|
15
|
+
function TraceTitle({ className, ...props }) {
|
|
16
|
+
return (jsx("span", { "data-slot": "trace-title", className: cn("min-w-0 truncate motion-reduce:shimmer-none", className), ...props }));
|
|
17
|
+
}
|
|
18
|
+
function TraceDescription({ className, ...props }) {
|
|
19
|
+
return (jsx("span", { "data-slot": "trace-description", className: cn("shrink-0 text-muted-foreground tabular-nums", className), ...props }));
|
|
20
|
+
}
|
|
21
|
+
function TraceCollapsible({ className, ...props }) {
|
|
22
|
+
return (jsx(Collapsible, { "data-slot": "trace-collapsible", className: cn("flex w-full min-w-0 flex-col", className), ...props }));
|
|
23
|
+
}
|
|
24
|
+
function TraceCollapsibleTrigger({ className, children, ...props }) {
|
|
25
|
+
return (jsxs(CollapsibleTrigger, { "data-slot": "trace-collapsible-trigger", className: cn("group/trace-collapsible-trigger flex w-fit max-w-full min-w-0 cursor-pointer items-center gap-1 rounded-md text-left text-muted-foreground transition-colors outline-none hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50 has-[[data-status=error]]:text-destructive", className), ...props, children: [children, jsx(TraceIcon, { className: "transition-transform group-aria-expanded/trace-collapsible-trigger:rotate-90", children: jsx(ChevronRightIcon, {}) })] }));
|
|
26
|
+
}
|
|
27
|
+
function TraceCollapsibleContent({ className, children, ...props }) {
|
|
28
|
+
return (jsx(CollapsibleContent, { "data-slot": "trace-collapsible-content", className: "h-(--collapsible-panel-height) min-w-0 overflow-hidden transition-[height] duration-200 data-ending-style:h-0 data-starting-style:h-0", ...props, children: jsx("div", { "data-slot": "trace-collapsible-content-inner", className: cn("mt-2 mb-1 ml-[calc(--spacing(2)-1px)] min-w-0 border-l pr-1 pl-4 leading-relaxed wrap-break-word text-muted-foreground", className), children: children }) }));
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export { Trace, TraceCollapsible, TraceCollapsibleContent, TraceCollapsibleTrigger, TraceDescription, TraceIcon, TraceLine, TraceTitle };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { loadHighlighter } from '../lib/highlighter.js';
|
|
3
|
+
|
|
4
|
+
function useHighlightedCode(value, language) {
|
|
5
|
+
// A trailing newline would render as an extra empty line.
|
|
6
|
+
const code = value.endsWith("\n") ? value.slice(0, -1) : value;
|
|
7
|
+
const [loaded, setLoaded] = React.useState(null);
|
|
8
|
+
const highlighter = loaded?.language === language ? loaded.highlighter : null;
|
|
9
|
+
React.useEffect(() => {
|
|
10
|
+
let cancelled = false;
|
|
11
|
+
loadHighlighter(language)
|
|
12
|
+
.then((next) => {
|
|
13
|
+
if (!cancelled) {
|
|
14
|
+
setLoaded({ language, highlighter: next });
|
|
15
|
+
}
|
|
16
|
+
})
|
|
17
|
+
.catch(() => { });
|
|
18
|
+
return () => {
|
|
19
|
+
cancelled = true;
|
|
20
|
+
};
|
|
21
|
+
}, [language]);
|
|
22
|
+
// The complete lines, highlighted. While the code streams, only the new
|
|
23
|
+
// lines are tokenized, starting from the grammar state of the last one.
|
|
24
|
+
const [done, setDone] = React.useState({ highlighter: null, text: "", lines: [] });
|
|
25
|
+
let next = done;
|
|
26
|
+
if (next.highlighter !== highlighter || !code.startsWith(next.text)) {
|
|
27
|
+
next = { highlighter, text: "", lines: [] };
|
|
28
|
+
}
|
|
29
|
+
const end = code.lastIndexOf("\n") + 1;
|
|
30
|
+
if (highlighter && end > next.text.length) {
|
|
31
|
+
const result = highlighter.highlight(code.slice(next.text.length, end - 1), next.state);
|
|
32
|
+
next = {
|
|
33
|
+
highlighter,
|
|
34
|
+
text: code.slice(0, end),
|
|
35
|
+
lines: [...next.lines, ...result.lines],
|
|
36
|
+
state: result.state,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
if (next !== done) {
|
|
40
|
+
setDone(next);
|
|
41
|
+
}
|
|
42
|
+
// The last line is still being written, so it is tokenized on every render.
|
|
43
|
+
const tail = code.slice(end);
|
|
44
|
+
return React.useMemo(() => {
|
|
45
|
+
if (!highlighter) {
|
|
46
|
+
return code.split("\n");
|
|
47
|
+
}
|
|
48
|
+
return [...next.lines, highlighter.highlight(tail, next.state).lines[0]];
|
|
49
|
+
}, [code, highlighter, next, tail]);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export { useHighlightedCode };
|