@curvenote/theme-ui 1.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/dist/components/index.d.ts +4 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +3 -0
- package/dist/components/layout/app-layout.d.ts +8 -0
- package/dist/components/layout/app-layout.d.ts.map +1 -0
- package/dist/components/layout/app-layout.js +24 -0
- package/dist/components/layout/app-sidebar.d.ts +2 -0
- package/dist/components/layout/app-sidebar.d.ts.map +1 -0
- package/dist/components/layout/app-sidebar.js +125 -0
- package/dist/components/layout/article-layout.d.ts +8 -0
- package/dist/components/layout/article-layout.d.ts.map +1 -0
- package/dist/components/layout/article-layout.js +20 -0
- package/dist/components/layout/grid.d.ts +2 -0
- package/dist/components/layout/grid.d.ts.map +1 -0
- package/dist/components/layout/grid.js +4 -0
- package/dist/components/layout/header.d.ts +5 -0
- package/dist/components/layout/header.d.ts.map +1 -0
- package/dist/components/layout/header.js +5 -0
- package/dist/components/layout/index.d.ts +7 -0
- package/dist/components/layout/index.d.ts.map +1 -0
- package/dist/components/layout/index.js +7 -0
- package/dist/components/layout/loading-bar.d.ts +12 -0
- package/dist/components/layout/loading-bar.d.ts.map +1 -0
- package/dist/components/layout/loading-bar.js +53 -0
- package/dist/components/layout/site-header.d.ts +8 -0
- package/dist/components/layout/site-header.d.ts.map +1 -0
- package/dist/components/layout/site-header.js +55 -0
- package/dist/components/layout/types.d.ts +6 -0
- package/dist/components/layout/types.d.ts.map +1 -0
- package/dist/components/layout/types.js +1 -0
- package/dist/components/providers/compute.d.ts +5 -0
- package/dist/components/providers/compute.d.ts.map +1 -0
- package/dist/components/providers/compute.js +6 -0
- package/dist/components/providers/connect.d.ts +24 -0
- package/dist/components/providers/connect.d.ts.map +1 -0
- package/dist/components/providers/connect.js +208 -0
- package/dist/components/providers/curvenote-providers.d.ts +52 -0
- package/dist/components/providers/curvenote-providers.d.ts.map +1 -0
- package/dist/components/providers/curvenote-providers.js +199 -0
- package/dist/components/providers/design.d.ts +39 -0
- package/dist/components/providers/design.d.ts.map +1 -0
- package/dist/components/providers/design.js +50 -0
- package/dist/components/providers/index.d.ts +10 -0
- package/dist/components/providers/index.d.ts.map +1 -0
- package/dist/components/providers/index.js +12 -0
- package/dist/components/providers/lightbox-provider.d.ts +31 -0
- package/dist/components/providers/lightbox-provider.d.ts.map +1 -0
- package/dist/components/providers/lightbox-provider.js +109 -0
- package/dist/components/providers/myst-providers.d.ts +6 -0
- package/dist/components/providers/myst-providers.d.ts.map +1 -0
- package/dist/components/providers/myst-providers.js +29 -0
- package/dist/components/providers/page-providers.d.ts +15 -0
- package/dist/components/providers/page-providers.d.ts.map +1 -0
- package/dist/components/providers/page-providers.js +28 -0
- package/dist/components/providers/ping-boundary.d.ts +40 -0
- package/dist/components/providers/ping-boundary.d.ts.map +1 -0
- package/dist/components/providers/ping-boundary.js +115 -0
- package/dist/components/providers/platform-providers.d.ts +18 -0
- package/dist/components/providers/platform-providers.d.ts.map +1 -0
- package/dist/components/providers/platform-providers.js +29 -0
- package/dist/components/providers/types.d.ts +30 -0
- package/dist/components/providers/types.d.ts.map +1 -0
- package/dist/components/providers/types.js +1 -0
- package/dist/components/ui/Callout.d.ts +10 -0
- package/dist/components/ui/Callout.d.ts.map +1 -0
- package/dist/components/ui/Callout.js +7 -0
- package/dist/components/ui/PageCards.d.ts +2 -0
- package/dist/components/ui/PageCards.d.ts.map +1 -0
- package/dist/components/ui/PageCards.js +11 -0
- package/dist/components/ui/abbreviations.d.ts +5 -0
- package/dist/components/ui/abbreviations.d.ts.map +1 -0
- package/dist/components/ui/abbreviations.js +31 -0
- package/dist/components/ui/abstract.d.ts +8 -0
- package/dist/components/ui/abstract.d.ts.map +1 -0
- package/dist/components/ui/abstract.js +9 -0
- package/dist/components/ui/accessibility-skip-to.d.ts +15 -0
- package/dist/components/ui/accessibility-skip-to.d.ts.map +1 -0
- package/dist/components/ui/accessibility-skip-to.js +31 -0
- package/dist/components/ui/acknowledgements.d.ts +4 -0
- package/dist/components/ui/acknowledgements.d.ts.map +1 -0
- package/dist/components/ui/acknowledgements.js +20 -0
- package/dist/components/ui/article-actions-downloads.d.ts +26 -0
- package/dist/components/ui/article-actions-downloads.d.ts.map +1 -0
- package/dist/components/ui/article-actions-downloads.js +143 -0
- package/dist/components/ui/article-actions-dropdown.d.ts +5 -0
- package/dist/components/ui/article-actions-dropdown.d.ts.map +1 -0
- package/dist/components/ui/article-actions-dropdown.js +68 -0
- package/dist/components/ui/article-actions-share.d.ts +5 -0
- package/dist/components/ui/article-actions-share.d.ts.map +1 -0
- package/dist/components/ui/article-actions-share.js +52 -0
- package/dist/components/ui/article-actions.d.ts +2 -0
- package/dist/components/ui/article-actions.d.ts.map +1 -0
- package/dist/components/ui/article-actions.js +20 -0
- package/dist/components/ui/article-bar.d.ts +8 -0
- package/dist/components/ui/article-bar.d.ts.map +1 -0
- package/dist/components/ui/article-bar.js +32 -0
- package/dist/components/ui/article-card.d.ts +12 -0
- package/dist/components/ui/article-card.d.ts.map +1 -0
- package/dist/components/ui/article-card.js +22 -0
- package/dist/components/ui/article-footer.d.ts +2 -0
- package/dist/components/ui/article-footer.d.ts.map +1 -0
- package/dist/components/ui/article-footer.js +7 -0
- package/dist/components/ui/author-popover.d.ts +7 -0
- package/dist/components/ui/author-popover.d.ts.map +1 -0
- package/dist/components/ui/author-popover.js +36 -0
- package/dist/components/ui/backmatter.d.ts +9 -0
- package/dist/components/ui/backmatter.d.ts.map +1 -0
- package/dist/components/ui/backmatter.js +49 -0
- package/dist/components/ui/badge.d.ts +10 -0
- package/dist/components/ui/badge.d.ts.map +1 -0
- package/dist/components/ui/badge.js +23 -0
- package/dist/components/ui/banner.d.ts +7 -0
- package/dist/components/ui/banner.d.ts.map +1 -0
- package/dist/components/ui/banner.js +44 -0
- package/dist/components/ui/bibliography.d.ts +6 -0
- package/dist/components/ui/bibliography.d.ts.map +1 -0
- package/dist/components/ui/bibliography.js +20 -0
- package/dist/components/ui/breadcrumb.d.ts +12 -0
- package/dist/components/ui/breadcrumb.d.ts.map +1 -0
- package/dist/components/ui/breadcrumb.js +28 -0
- package/dist/components/ui/button.d.ts +11 -0
- package/dist/components/ui/button.d.ts.map +1 -0
- package/dist/components/ui/button.js +33 -0
- package/dist/components/ui/citation.d.ts +7 -0
- package/dist/components/ui/citation.d.ts.map +1 -0
- package/dist/components/ui/citation.js +99 -0
- package/dist/components/ui/collapsible.d.ts +6 -0
- package/dist/components/ui/collapsible.d.ts.map +1 -0
- package/dist/components/ui/collapsible.js +12 -0
- package/dist/components/ui/cookie-banner.d.ts +8 -0
- package/dist/components/ui/cookie-banner.d.ts.map +1 -0
- package/dist/components/ui/cookie-banner.js +31 -0
- package/dist/components/ui/data-availability.d.ts +4 -0
- package/dist/components/ui/data-availability.d.ts.map +1 -0
- package/dist/components/ui/data-availability.js +20 -0
- package/dist/components/ui/dialog.d.ts +16 -0
- package/dist/components/ui/dialog.d.ts.map +1 -0
- package/dist/components/ui/dialog.js +36 -0
- package/dist/components/ui/document-outline.d.ts +8 -0
- package/dist/components/ui/document-outline.d.ts.map +1 -0
- package/dist/components/ui/document-outline.js +168 -0
- package/dist/components/ui/dropdown-menu.d.ts +26 -0
- package/dist/components/ui/dropdown-menu.d.ts.map +1 -0
- package/dist/components/ui/dropdown-menu.js +51 -0
- package/dist/components/ui/error-page.d.ts +9 -0
- package/dist/components/ui/error-page.d.ts.map +1 -0
- package/dist/components/ui/error-page.js +21 -0
- package/dist/components/ui/footer-links.d.ts +14 -0
- package/dist/components/ui/footer-links.d.ts.map +1 -0
- package/dist/components/ui/footer-links.js +18 -0
- package/dist/components/ui/footnotes.d.ts +4 -0
- package/dist/components/ui/footnotes.d.ts.map +1 -0
- package/dist/components/ui/footnotes.js +30 -0
- package/dist/components/ui/frontmatter-badges.d.ts +27 -0
- package/dist/components/ui/frontmatter-badges.d.ts.map +1 -0
- package/dist/components/ui/frontmatter-badges.js +60 -0
- package/dist/components/ui/frontmatter.d.ts +7 -0
- package/dist/components/ui/frontmatter.d.ts.map +1 -0
- package/dist/components/ui/frontmatter.js +6 -0
- package/dist/components/ui/image.d.ts +34 -0
- package/dist/components/ui/image.d.ts.map +1 -0
- package/dist/components/ui/image.js +83 -0
- package/dist/components/ui/index.d.ts +50 -0
- package/dist/components/ui/index.d.ts.map +1 -0
- package/dist/components/ui/index.js +56 -0
- package/dist/components/ui/input.d.ts +4 -0
- package/dist/components/ui/input.d.ts.map +1 -0
- package/dist/components/ui/input.js +7 -0
- package/dist/components/ui/license-description.d.ts +4 -0
- package/dist/components/ui/license-description.d.ts.map +1 -0
- package/dist/components/ui/license-description.js +63 -0
- package/dist/components/ui/license-frontmatter.d.ts +22 -0
- package/dist/components/ui/license-frontmatter.d.ts.map +1 -0
- package/dist/components/ui/license-frontmatter.js +37 -0
- package/dist/components/ui/lightbox-container.d.ts +11 -0
- package/dist/components/ui/lightbox-container.d.ts.map +1 -0
- package/dist/components/ui/lightbox-container.js +13 -0
- package/dist/components/ui/lightbox.d.ts +17 -0
- package/dist/components/ui/lightbox.d.ts.map +1 -0
- package/dist/components/ui/lightbox.js +129 -0
- package/dist/components/ui/link-card.d.ts +15 -0
- package/dist/components/ui/link-card.d.ts.map +1 -0
- package/dist/components/ui/link-card.js +28 -0
- package/dist/components/ui/popover.d.ts +8 -0
- package/dist/components/ui/popover.d.ts.map +1 -0
- package/dist/components/ui/popover.js +17 -0
- package/dist/components/ui/search.d.ts +9 -0
- package/dist/components/ui/search.d.ts.map +1 -0
- package/dist/components/ui/search.js +290 -0
- package/dist/components/ui/separator.d.ts +5 -0
- package/dist/components/ui/separator.d.ts.map +1 -0
- package/dist/components/ui/separator.js +8 -0
- package/dist/components/ui/sheet.d.ts +14 -0
- package/dist/components/ui/sheet.d.ts.map +1 -0
- package/dist/components/ui/sheet.js +40 -0
- package/dist/components/ui/sidebar.d.ts +67 -0
- package/dist/components/ui/sidebar.d.ts.map +1 -0
- package/dist/components/ui/sidebar.js +202 -0
- package/dist/components/ui/skeleton.d.ts +3 -0
- package/dist/components/ui/skeleton.d.ts.map +1 -0
- package/dist/components/ui/skeleton.js +6 -0
- package/dist/components/ui/sonner.d.ts +5 -0
- package/dist/components/ui/sonner.d.ts.map +1 -0
- package/dist/components/ui/sonner.js +13 -0
- package/dist/components/ui/theme-button.d.ts +2 -0
- package/dist/components/ui/theme-button.d.ts.map +1 -0
- package/dist/components/ui/theme-button.js +9 -0
- package/dist/components/ui/tooltip.d.ts +13 -0
- package/dist/components/ui/tooltip.d.ts.map +1 -0
- package/dist/components/ui/tooltip.js +20 -0
- package/dist/components/ui/types.d.ts +11 -0
- package/dist/components/ui/types.d.ts.map +1 -0
- package/dist/components/ui/types.js +10 -0
- package/dist/hooks/index.d.ts +5 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +4 -0
- package/dist/hooks/use-hydrated.d.ts +2 -0
- package/dist/hooks/use-hydrated.d.ts.map +1 -0
- package/dist/hooks/use-hydrated.js +6 -0
- package/dist/hooks/use-image-load.d.ts +14 -0
- package/dist/hooks/use-image-load.d.ts.map +1 -0
- package/dist/hooks/use-image-load.js +41 -0
- package/dist/hooks/use-mobile.d.ts +2 -0
- package/dist/hooks/use-mobile.d.ts.map +1 -0
- package/dist/hooks/use-mobile.js +15 -0
- package/dist/hooks/use-theme.d.ts +6 -0
- package/dist/hooks/use-theme.d.ts.map +1 -0
- package/dist/hooks/use-theme.js +23 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/dist/lib/checkMecaExport.d.ts +5 -0
- package/dist/lib/checkMecaExport.d.ts.map +1 -0
- package/dist/lib/checkMecaExport.js +4 -0
- package/dist/lib/index.d.ts +6 -0
- package/dist/lib/index.d.ts.map +1 -0
- package/dist/lib/index.js +6 -0
- package/dist/lib/knownParts.d.ts +12 -0
- package/dist/lib/knownParts.d.ts.map +1 -0
- package/dist/lib/knownParts.js +14 -0
- package/dist/lib/links.d.ts +3 -0
- package/dist/lib/links.d.ts.map +1 -0
- package/dist/lib/links.js +7 -0
- package/dist/lib/parse-date.d.ts +2 -0
- package/dist/lib/parse-date.d.ts.map +1 -0
- package/dist/lib/parse-date.js +7 -0
- package/dist/lib/utils.d.ts +3 -0
- package/dist/lib/utils.d.ts.map +1 -0
- package/dist/lib/utils.js +5 -0
- package/package.json +67 -0
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { Slot } from '@radix-ui/react-slot';
|
|
4
|
+
import { cva } from 'class-variance-authority';
|
|
5
|
+
import { PanelLeftIcon } from 'lucide-react';
|
|
6
|
+
import { useIsMobile } from '../../hooks/use-mobile';
|
|
7
|
+
import { cn } from '../../lib/utils';
|
|
8
|
+
import { Button, Input, Separator, Sheet, SheetContent, SheetDescription, SheetHeader, SheetTitle, Skeleton, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, } from '.';
|
|
9
|
+
const SIDEBAR_COOKIE_NAME = 'sidebar_state';
|
|
10
|
+
const SIDEBAR_COOKIE_MAX_AGE = 60 * 60 * 24 * 7;
|
|
11
|
+
const SIDEBAR_WIDTH = '16rem';
|
|
12
|
+
const SIDEBAR_WIDTH_MOBILE = '18rem';
|
|
13
|
+
const SIDEBAR_WIDTH_ICON = '3rem';
|
|
14
|
+
const SIDEBAR_KEYBOARD_SHORTCUT = 'b';
|
|
15
|
+
const SidebarContext = React.createContext(null);
|
|
16
|
+
function useSidebar() {
|
|
17
|
+
const context = React.useContext(SidebarContext);
|
|
18
|
+
return context;
|
|
19
|
+
}
|
|
20
|
+
function SidebarProvider({ defaultOpen = true, open: openProp, onOpenChange: setOpenProp, className, style, children, ...props }) {
|
|
21
|
+
const isMobile = useIsMobile();
|
|
22
|
+
const [openMobile, setOpenMobile] = React.useState(false);
|
|
23
|
+
// This is the internal state of the sidebar.
|
|
24
|
+
// We use openProp and setOpenProp for control from outside the component.
|
|
25
|
+
const [_open, _setOpen] = React.useState(defaultOpen);
|
|
26
|
+
const open = openProp ?? _open;
|
|
27
|
+
const setOpen = React.useCallback((value) => {
|
|
28
|
+
const openState = typeof value === 'function' ? value(open) : value;
|
|
29
|
+
if (setOpenProp) {
|
|
30
|
+
setOpenProp(openState);
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
_setOpen(openState);
|
|
34
|
+
}
|
|
35
|
+
// This sets the cookie to keep the sidebar state.
|
|
36
|
+
document.cookie = `${SIDEBAR_COOKIE_NAME}=${openState}; path=/; max-age=${SIDEBAR_COOKIE_MAX_AGE}`;
|
|
37
|
+
}, [setOpenProp, open]);
|
|
38
|
+
// Helper to toggle the sidebar.
|
|
39
|
+
const toggleSidebar = React.useCallback(() => {
|
|
40
|
+
return isMobile ? setOpenMobile((o) => !o) : setOpen((o) => !o);
|
|
41
|
+
}, [isMobile, setOpen, setOpenMobile]);
|
|
42
|
+
// Adds a keyboard shortcut to toggle the sidebar.
|
|
43
|
+
React.useEffect(() => {
|
|
44
|
+
const handleKeyDown = (event) => {
|
|
45
|
+
if (event.key === SIDEBAR_KEYBOARD_SHORTCUT && (event.metaKey || event.ctrlKey)) {
|
|
46
|
+
event.preventDefault();
|
|
47
|
+
toggleSidebar();
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
window.addEventListener('keydown', handleKeyDown);
|
|
51
|
+
return () => window.removeEventListener('keydown', handleKeyDown);
|
|
52
|
+
}, [toggleSidebar]);
|
|
53
|
+
// We add a state so that we can do data-state="expanded" or "collapsed".
|
|
54
|
+
// This makes it easier to style the sidebar with Tailwind classes.
|
|
55
|
+
const state = open ? 'expanded' : 'collapsed';
|
|
56
|
+
const contextValue = React.useMemo(() => ({
|
|
57
|
+
state,
|
|
58
|
+
open,
|
|
59
|
+
setOpen,
|
|
60
|
+
isMobile,
|
|
61
|
+
openMobile,
|
|
62
|
+
setOpenMobile,
|
|
63
|
+
toggleSidebar,
|
|
64
|
+
}), [state, open, setOpen, isMobile, openMobile, setOpenMobile, toggleSidebar]);
|
|
65
|
+
return (_jsx(SidebarContext.Provider, { value: contextValue, children: _jsx(TooltipProvider, { delayDuration: 0, children: _jsx("div", { "data-slot": "sidebar-wrapper", style: {
|
|
66
|
+
'--sidebar-width': SIDEBAR_WIDTH,
|
|
67
|
+
'--sidebar-width-icon': SIDEBAR_WIDTH_ICON,
|
|
68
|
+
...style,
|
|
69
|
+
}, className: cn('group/sidebar-wrapper has-data-[variant=inset]:bg-sidebar flex min-h-svh w-full', className), ...props, children: children }) }) }));
|
|
70
|
+
}
|
|
71
|
+
function Sidebar({ side = 'left', variant = 'sidebar', collapsible = 'offcanvas', className, children, ...props }) {
|
|
72
|
+
const { isMobile, state, openMobile, setOpenMobile } = useSidebar() ?? {};
|
|
73
|
+
if (collapsible === 'none') {
|
|
74
|
+
return (_jsx("div", { "data-slot": "sidebar", className: cn('flex flex-col h-full bg-sidebar text-sidebar-foreground w-(--sidebar-width)', className), ...props, children: children }));
|
|
75
|
+
}
|
|
76
|
+
if (isMobile) {
|
|
77
|
+
return (_jsx(Sheet, { open: openMobile, onOpenChange: setOpenMobile, ...props, children: _jsxs(SheetContent, { "data-sidebar": "sidebar", "data-slot": "sidebar", "data-mobile": "true", className: "bg-sidebar text-sidebar-foreground w-(--sidebar-width) p-0 [&>button]:hidden", style: {
|
|
78
|
+
'--sidebar-width': SIDEBAR_WIDTH_MOBILE,
|
|
79
|
+
}, side: side, children: [_jsxs(SheetHeader, { className: "sr-only", children: [_jsx(SheetTitle, { children: "Sidebar" }), _jsx(SheetDescription, { children: "Displays the mobile sidebar." })] }), _jsx("div", { className: "flex flex-col w-full h-full", children: children })] }) }));
|
|
80
|
+
}
|
|
81
|
+
return (_jsxs("div", { className: "hidden group peer 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'
|
|
82
|
+
? 'group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]'
|
|
83
|
+
: 'group-data-[collapsible=icon]:w-(--sidebar-width-icon)') }), _jsx("div", { "data-slot": "sidebar-container", className: cn('fixed inset-y-0 z-10 hidden h-svh w-(--sidebar-width) transition-[left,right,width] duration-200 ease-linear md:flex', side === 'left'
|
|
84
|
+
? 'left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]'
|
|
85
|
+
: 'right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]',
|
|
86
|
+
// Adjust the padding for floating and inset variants.
|
|
87
|
+
variant === 'floating' || variant === 'inset'
|
|
88
|
+
? 'p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]'
|
|
89
|
+
: '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: "bg-sidebar group-data-[variant=floating]:border-sidebar-border flex h-full w-full flex-col group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:border group-data-[variant=floating]:shadow-sm", children: children }) })] }));
|
|
90
|
+
}
|
|
91
|
+
function SidebarTrigger({ className, onClick, ...props }) {
|
|
92
|
+
const { toggleSidebar } = useSidebar() ?? {};
|
|
93
|
+
return (_jsxs(Button, { "data-sidebar": "trigger", "data-slot": "sidebar-trigger", variant: "ghost", size: "icon", className: cn('size-7', className), onClick: (event) => {
|
|
94
|
+
onClick?.(event);
|
|
95
|
+
toggleSidebar?.();
|
|
96
|
+
}, ...props, children: [_jsx(PanelLeftIcon, {}), _jsx("span", { className: "sr-only", children: "Toggle Sidebar" })] }));
|
|
97
|
+
}
|
|
98
|
+
function SidebarRail({ className, ...props }) {
|
|
99
|
+
const { toggleSidebar } = useSidebar() ?? {};
|
|
100
|
+
return (_jsx("button", { "data-sidebar": "rail", "data-slot": "sidebar-rail", "aria-label": "Toggle Sidebar", tabIndex: -1, onClick: toggleSidebar, title: "Toggle Sidebar", className: cn('hover:after:bg-sidebar-border absolute inset-y-0 z-20 hidden w-4 -translate-x-1/2 transition-all ease-linear group-data-[side=left]:-right-4 group-data-[side=right]:left-0 after:absolute after:inset-y-0 after:left-1/2 after:w-[2px] sm:flex', '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', 'hover:group-data-[collapsible=offcanvas]:bg-sidebar group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full', '[[data-side=left][data-collapsible=offcanvas]_&]:-right-2', '[[data-side=right][data-collapsible=offcanvas]_&]:-left-2', className), ...props }));
|
|
101
|
+
}
|
|
102
|
+
function SidebarInset({ className, ...props }) {
|
|
103
|
+
return (_jsx("main", { "data-slot": "sidebar-inset", className: cn('bg-background relative flex w-full flex-1 flex-col', '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 }));
|
|
104
|
+
}
|
|
105
|
+
function SidebarInput({ className, ...props }) {
|
|
106
|
+
return (_jsx(Input, { "data-slot": "sidebar-input", "data-sidebar": "input", className: cn('w-full h-8 shadow-none bg-background', className), ...props }));
|
|
107
|
+
}
|
|
108
|
+
function SidebarHeader({ className, ...props }) {
|
|
109
|
+
return (_jsx("div", { "data-slot": "sidebar-header", "data-sidebar": "header", className: cn('flex flex-col gap-2 p-2', className), ...props }));
|
|
110
|
+
}
|
|
111
|
+
function SidebarFooter({ className, ...props }) {
|
|
112
|
+
return (_jsx("div", { "data-slot": "sidebar-footer", "data-sidebar": "footer", className: cn('flex flex-col gap-2 p-2', className), ...props }));
|
|
113
|
+
}
|
|
114
|
+
function SidebarSeparator({ className, ...props }) {
|
|
115
|
+
return (_jsx(Separator, { "data-slot": "sidebar-separator", "data-sidebar": "separator", className: cn('mx-2 w-auto bg-sidebar-border', className), ...props }));
|
|
116
|
+
}
|
|
117
|
+
function SidebarContent({ className, ...props }) {
|
|
118
|
+
return (_jsx("div", { "data-slot": "sidebar-content", "data-sidebar": "content", className: cn('flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden', className), ...props }));
|
|
119
|
+
}
|
|
120
|
+
function SidebarGroup({ className, ...props }) {
|
|
121
|
+
return (_jsx("div", { "data-slot": "sidebar-group", "data-sidebar": "group", className: cn('flex relative flex-col p-2 w-full min-w-0', className), ...props }));
|
|
122
|
+
}
|
|
123
|
+
function SidebarGroupLabel({ className, asChild = false, ...props }) {
|
|
124
|
+
const Comp = asChild ? Slot : 'div';
|
|
125
|
+
return (_jsx(Comp, { "data-slot": "sidebar-group-label", "data-sidebar": "group-label", className: cn('text-sidebar-foreground/70 ring-sidebar-ring flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium outline-hidden transition-[margin,opacity] duration-200 ease-linear focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0', 'group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0', className), ...props }));
|
|
126
|
+
}
|
|
127
|
+
function SidebarGroupAction({ className, asChild = false, ...props }) {
|
|
128
|
+
const Comp = asChild ? Slot : 'button';
|
|
129
|
+
return (_jsx(Comp, { "data-slot": "sidebar-group-action", "data-sidebar": "group-action", className: cn('text-sidebar-foreground ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground absolute top-3.5 right-3 flex aspect-square w-5 items-center justify-center rounded-md p-0 outline-hidden transition-transform focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0',
|
|
130
|
+
// Increases the hit area of the button on mobile.
|
|
131
|
+
'after:absolute after:-inset-2 md:after:hidden', 'group-data-[collapsible=icon]:hidden', className), ...props }));
|
|
132
|
+
}
|
|
133
|
+
function SidebarGroupContent({ className, ...props }) {
|
|
134
|
+
return (_jsx("div", { "data-slot": "sidebar-group-content", "data-sidebar": "group-content", className: cn('w-full text-sm', className), ...props }));
|
|
135
|
+
}
|
|
136
|
+
function SidebarMenu({ className, ...props }) {
|
|
137
|
+
return (_jsx("ul", { "data-slot": "sidebar-menu", "data-sidebar": "menu", className: cn('flex flex-col gap-1 w-full min-w-0', className), ...props }));
|
|
138
|
+
}
|
|
139
|
+
function SidebarMenuItem({ className, ...props }) {
|
|
140
|
+
return (_jsx("li", { "data-slot": "sidebar-menu-item", "data-sidebar": "menu-item", className: cn('relative group/menu-item', className), ...props }));
|
|
141
|
+
}
|
|
142
|
+
const sidebarMenuButtonVariants = cva('peer/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm outline-hidden ring-sidebar-ring transition-[width,height,padding] 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 group-has-data-[sidebar=menu-action]/menu-item:pr-8 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[active=true]:bg-sidebar-accent data-[active=true]:font-medium data-[active=true]:text-sidebar-accent-foreground data-[state=open]:hover:bg-sidebar-accent data-[state=open]:hover:text-sidebar-accent-foreground group-data-[collapsible=icon]:size-8! group-data-[collapsible=icon]:p-2! [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0', {
|
|
143
|
+
variants: {
|
|
144
|
+
variant: {
|
|
145
|
+
default: 'hover:bg-sidebar-accent hover:text-sidebar-accent-foreground',
|
|
146
|
+
outline: 'bg-background shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]',
|
|
147
|
+
},
|
|
148
|
+
size: {
|
|
149
|
+
default: 'h-8 text-sm',
|
|
150
|
+
sm: 'h-7 text-xs',
|
|
151
|
+
lg: 'h-12 text-sm group-data-[collapsible=icon]:p-0!',
|
|
152
|
+
},
|
|
153
|
+
},
|
|
154
|
+
defaultVariants: {
|
|
155
|
+
variant: 'default',
|
|
156
|
+
size: 'default',
|
|
157
|
+
},
|
|
158
|
+
});
|
|
159
|
+
function SidebarMenuButton({ asChild = false, isActive = false, variant = 'default', size = 'default', tooltip, className, ...props }) {
|
|
160
|
+
const Comp = asChild ? Slot : 'button';
|
|
161
|
+
const { isMobile, state } = useSidebar() ?? {};
|
|
162
|
+
const button = (_jsx(Comp, { "data-slot": "sidebar-menu-button", "data-sidebar": "menu-button", "data-size": size, "data-active": isActive, className: cn(sidebarMenuButtonVariants({ variant, size }), className), ...props }));
|
|
163
|
+
if (!tooltip) {
|
|
164
|
+
return button;
|
|
165
|
+
}
|
|
166
|
+
if (typeof tooltip === 'string') {
|
|
167
|
+
tooltip = {
|
|
168
|
+
children: tooltip,
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
return (_jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { asChild: true, children: button }), _jsx(TooltipContent, { side: "right", align: "center", hidden: state !== 'collapsed' || isMobile, ...tooltip })] }));
|
|
172
|
+
}
|
|
173
|
+
function SidebarMenuAction({ className, asChild = false, showOnHover = false, ...props }) {
|
|
174
|
+
const Comp = asChild ? Slot : 'button';
|
|
175
|
+
return (_jsx(Comp, { "data-slot": "sidebar-menu-action", "data-sidebar": "menu-action", className: cn('text-sidebar-foreground ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground peer-hover/menu-button:text-sidebar-accent-foreground absolute top-1.5 right-1 flex aspect-square w-5 items-center justify-center rounded-md p-0 outline-hidden transition-transform focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0',
|
|
176
|
+
// Increases the hit area of the button on mobile.
|
|
177
|
+
'after:absolute after:-inset-2 md:after:hidden', 'peer-data-[size=sm]/menu-button:top-1', 'peer-data-[size=default]/menu-button:top-1.5', 'peer-data-[size=lg]/menu-button:top-2.5', 'group-data-[collapsible=icon]:hidden', showOnHover &&
|
|
178
|
+
'peer-data-[active=true]/menu-button:text-sidebar-accent-foreground group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 data-[state=open]:opacity-100 md:opacity-0', className), ...props }));
|
|
179
|
+
}
|
|
180
|
+
function SidebarMenuBadge({ className, ...props }) {
|
|
181
|
+
return (_jsx("div", { "data-slot": "sidebar-menu-badge", "data-sidebar": "menu-badge", className: cn('text-sidebar-foreground pointer-events-none absolute right-1 flex h-5 min-w-5 items-center justify-center rounded-md px-1 text-xs font-medium tabular-nums select-none', 'peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[active=true]/menu-button:text-sidebar-accent-foreground', 'peer-data-[size=sm]/menu-button:top-1', 'peer-data-[size=default]/menu-button:top-1.5', 'peer-data-[size=lg]/menu-button:top-2.5', 'group-data-[collapsible=icon]:hidden', className), ...props }));
|
|
182
|
+
}
|
|
183
|
+
function SidebarMenuSkeleton({ className, showIcon = false, ...props }) {
|
|
184
|
+
// Random width between 50 to 90%.
|
|
185
|
+
const width = React.useMemo(() => {
|
|
186
|
+
return `${Math.floor(Math.random() * 40) + 50}%`;
|
|
187
|
+
}, []);
|
|
188
|
+
return (_jsxs("div", { "data-slot": "sidebar-menu-skeleton", "data-sidebar": "menu-skeleton", className: cn('flex gap-2 items-center px-2 h-8 rounded-md', className), ...props, children: [showIcon && _jsx(Skeleton, { className: "rounded-md size-4", "data-sidebar": "menu-skeleton-icon" }), _jsx(Skeleton, { className: "h-4 max-w-(--skeleton-width) flex-1", "data-sidebar": "menu-skeleton-text", style: {
|
|
189
|
+
'--skeleton-width': width,
|
|
190
|
+
} })] }));
|
|
191
|
+
}
|
|
192
|
+
function SidebarMenuSub({ className, ...props }) {
|
|
193
|
+
return (_jsx("ul", { "data-slot": "sidebar-menu-sub", "data-sidebar": "menu-sub", className: cn('border-sidebar-border mx-3.5 flex min-w-0 translate-x-px flex-col gap-1 border-l px-2.5 py-0.5', 'group-data-[collapsible=icon]:hidden', className), ...props }));
|
|
194
|
+
}
|
|
195
|
+
function SidebarMenuSubItem({ className, ...props }) {
|
|
196
|
+
return (_jsx("li", { "data-slot": "sidebar-menu-sub-item", "data-sidebar": "menu-sub-item", className: cn('relative group/menu-sub-item', className), ...props }));
|
|
197
|
+
}
|
|
198
|
+
function SidebarMenuSubButton({ asChild = false, size = 'md', isActive = false, className, ...props }) {
|
|
199
|
+
const Comp = asChild ? Slot : 'a';
|
|
200
|
+
return (_jsx(Comp, { "data-slot": "sidebar-menu-sub-button", "data-sidebar": "menu-sub-button", "data-size": size, "data-active": isActive, className: cn('text-sidebar-foreground ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground active:bg-sidebar-accent active:text-sidebar-accent-foreground [&>svg]:text-sidebar-accent-foreground flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 outline-hidden focus-visible:ring-2 disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0', 'data-[active=true]:bg-sidebar-accent data-[active=true]:text-sidebar-accent-foreground', size === 'sm' && 'text-xs', size === 'md' && 'text-sm', 'group-data-[collapsible=icon]:hidden', className), ...props }));
|
|
201
|
+
}
|
|
202
|
+
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 @@
|
|
|
1
|
+
{"version":3,"file":"skeleton.d.ts","sourceRoot":"","sources":["../../../src/components/ui/skeleton.tsx"],"names":[],"mappings":"AAEA,iBAAS,QAAQ,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,2CAQrE;AAED,OAAO,EAAE,QAAQ,EAAE,CAAC"}
|
|
@@ -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('bg-accent animate-pulse rounded-md', className), ...props }));
|
|
5
|
+
}
|
|
6
|
+
export { Skeleton };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sonner.d.ts","sourceRoot":"","sources":["../../../src/components/ui/sonner.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC3C,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,QAAA,MAAM,OAAO,GAAI,cAAc,KAAK,CAAC,cAAc,CAAC,OAAO,MAAM,CAAC,4CAiBjE,CAAC;AAEF,OAAO,EAAE,OAAO,EAAE,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useTheme } from 'next-themes';
|
|
3
|
+
import { Toaster as Sonner } from 'sonner';
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
const Toaster = ({ ...props }) => {
|
|
6
|
+
const { theme = 'system' } = useTheme();
|
|
7
|
+
return (_jsx(Sonner, { theme: theme, className: "toaster group", style: {
|
|
8
|
+
'--normal-bg': 'var(--popover)',
|
|
9
|
+
'--normal-text': 'var(--popover-foreground)',
|
|
10
|
+
'--normal-border': 'var(--border)',
|
|
11
|
+
}, ...props }));
|
|
12
|
+
};
|
|
13
|
+
export { Toaster };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"theme-button.d.ts","sourceRoot":"","sources":["../../../src/components/ui/theme-button.tsx"],"names":[],"mappings":"AAKA,wBAAgB,WAAW,4CAmB1B"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Moon, Sun } from 'lucide-react';
|
|
3
|
+
import { useThemeSwitcher } from '../../hooks/use-theme';
|
|
4
|
+
import { Button } from './button';
|
|
5
|
+
import { SimpleTooltip } from './tooltip';
|
|
6
|
+
export function ThemeButton() {
|
|
7
|
+
const { theme, nextTheme } = useThemeSwitcher();
|
|
8
|
+
return (_jsx(SimpleTooltip, { title: "Toggle Theme", children: _jsx(Button, { variant: "ghost", size: "icon", onClick: nextTheme, "aria-label": `Switch to ${theme === 'dark' ? 'light' : 'dark'} theme`, children: theme === 'dark' ? (_jsx(Sun, { className: "m-auto w-4 h-4" })) : (_jsx(Moon, { className: "m-auto w-4 h-4" })) }) }));
|
|
9
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import * as TooltipPrimitive from '@radix-ui/react-tooltip';
|
|
3
|
+
declare function TooltipProvider({ delayDuration, ...props }: React.ComponentProps<typeof TooltipPrimitive.Provider>): import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
declare function Tooltip({ ...props }: React.ComponentProps<typeof TooltipPrimitive.Root>): import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
declare function TooltipTrigger({ ...props }: React.ComponentProps<typeof TooltipPrimitive.Trigger>): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
declare function TooltipContent({ className, sideOffset, children, ...props }: React.ComponentProps<typeof TooltipPrimitive.Content>): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export declare function SimpleTooltip({ children, title, delayDuration, }: {
|
|
8
|
+
children: React.ReactNode;
|
|
9
|
+
title: string;
|
|
10
|
+
delayDuration?: number;
|
|
11
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider };
|
|
13
|
+
//# sourceMappingURL=tooltip.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tooltip.d.ts","sourceRoot":"","sources":["../../../src/components/ui/tooltip.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,gBAAgB,MAAM,yBAAyB,CAAC;AAI5D,iBAAS,eAAe,CAAC,EACvB,aAAiB,EACjB,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,gBAAgB,CAAC,QAAQ,CAAC,2CAQxD;AAED,iBAAS,OAAO,CAAC,EAAE,GAAG,KAAK,EAAE,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,gBAAgB,CAAC,IAAI,CAAC,2CAMhF;AAED,iBAAS,cAAc,CAAC,EAAE,GAAG,KAAK,EAAE,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,gBAAgB,CAAC,OAAO,CAAC,2CAE1F;AAED,iBAAS,cAAc,CAAC,EACtB,SAAS,EACT,UAAc,EACd,QAAQ,EACR,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,gBAAgB,CAAC,OAAO,CAAC,2CAiBvD;AAED,wBAAgB,aAAa,CAAC,EAC5B,QAAQ,EACR,KAAK,EACL,aAAmB,GACpB,EAAE;IACD,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,2CAOA;AAED,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,eAAe,EAAE,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import * as TooltipPrimitive from '@radix-ui/react-tooltip';
|
|
4
|
+
import { cn } from '../../lib/utils';
|
|
5
|
+
function TooltipProvider({ delayDuration = 0, ...props }) {
|
|
6
|
+
return (_jsx(TooltipPrimitive.Provider, { "data-slot": "tooltip-provider", delayDuration: delayDuration, ...props }));
|
|
7
|
+
}
|
|
8
|
+
function Tooltip({ ...props }) {
|
|
9
|
+
return (_jsx(TooltipProvider, { children: _jsx(TooltipPrimitive.Root, { "data-slot": "tooltip", ...props }) }));
|
|
10
|
+
}
|
|
11
|
+
function TooltipTrigger({ ...props }) {
|
|
12
|
+
return _jsx(TooltipPrimitive.Trigger, { "data-slot": "tooltip-trigger", ...props });
|
|
13
|
+
}
|
|
14
|
+
function TooltipContent({ className, sideOffset = 0, children, ...props }) {
|
|
15
|
+
return (_jsx(TooltipPrimitive.Portal, { children: _jsxs(TooltipPrimitive.Content, { "data-slot": "tooltip-content", sideOffset: sideOffset, className: cn('bg-primary text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance', className), ...props, children: [children, _jsx(TooltipPrimitive.Arrow, { className: "bg-primary fill-primary z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]" })] }) }));
|
|
16
|
+
}
|
|
17
|
+
export function SimpleTooltip({ children, title, delayDuration = 500, }) {
|
|
18
|
+
return (_jsxs(Tooltip, { delayDuration: delayDuration, children: [_jsx(TooltipTrigger, { asChild: true, children: children }), _jsx(TooltipContent, { children: title })] }));
|
|
19
|
+
}
|
|
20
|
+
export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare const PART_IDS: {
|
|
2
|
+
skip_to_frontmatter: string;
|
|
3
|
+
skip_to_content: string;
|
|
4
|
+
skip_to_backmatter: string;
|
|
5
|
+
data_availability: string;
|
|
6
|
+
license: string;
|
|
7
|
+
abbreviations: string;
|
|
8
|
+
bibliography: string;
|
|
9
|
+
acknowledgements: string;
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/ui/types.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,QAAQ;;;;;;;;;CASpB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export const PART_IDS = {
|
|
2
|
+
skip_to_frontmatter: 'skip-to-frontmatter',
|
|
3
|
+
skip_to_content: 'skip-to-content',
|
|
4
|
+
skip_to_backmatter: 'skip-to-backmatter',
|
|
5
|
+
data_availability: 'article-data-availability',
|
|
6
|
+
license: 'article-license',
|
|
7
|
+
abbreviations: 'article-abbreviations',
|
|
8
|
+
bibliography: 'article-bibliography',
|
|
9
|
+
acknowledgements: 'article-acknowledgements',
|
|
10
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-hydrated.d.ts","sourceRoot":"","sources":["../../src/hooks/use-hydrated.ts"],"names":[],"mappings":"AAEA,wBAAgB,WAAW,YAI1B"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
interface UseImageLoadOptions {
|
|
2
|
+
src: string;
|
|
3
|
+
showPlaceholder?: boolean;
|
|
4
|
+
minDelay?: number;
|
|
5
|
+
}
|
|
6
|
+
interface UseImageLoadReturn {
|
|
7
|
+
imageLoaded: boolean;
|
|
8
|
+
showPlaceholder: boolean;
|
|
9
|
+
imgRef: React.RefObject<HTMLImageElement | null>;
|
|
10
|
+
handleImageLoad: () => void;
|
|
11
|
+
}
|
|
12
|
+
export declare function useImageLoad({ src, showPlaceholder, minDelay, }: UseImageLoadOptions): UseImageLoadReturn;
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=use-image-load.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-image-load.d.ts","sourceRoot":"","sources":["../../src/hooks/use-image-load.ts"],"names":[],"mappings":"AAEA,UAAU,mBAAmB;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,UAAU,kBAAkB;IAC1B,WAAW,EAAE,OAAO,CAAC;IACrB,eAAe,EAAE,OAAO,CAAC;IACzB,MAAM,EAAE,KAAK,CAAC,SAAS,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAAC;IACjD,eAAe,EAAE,MAAM,IAAI,CAAC;CAC7B;AAED,wBAAgB,YAAY,CAAC,EAC3B,GAAG,EACH,eAAsB,EACtB,QAAY,GACb,EAAE,mBAAmB,GAAG,kBAAkB,CA2C1C"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { useState, useEffect, useRef } from 'react';
|
|
2
|
+
export function useImageLoad({ src, showPlaceholder = true, minDelay = 0, }) {
|
|
3
|
+
const [imageLoaded, setImageLoaded] = useState(false);
|
|
4
|
+
const [showPlaceholderState, setShowPlaceholderState] = useState(showPlaceholder);
|
|
5
|
+
const imgRef = useRef(null);
|
|
6
|
+
const startTimeRef = useRef(Date.now());
|
|
7
|
+
const handleImageLoad = () => {
|
|
8
|
+
const elapsed = Date.now() - startTimeRef.current;
|
|
9
|
+
const remainingDelay = Math.max(0, minDelay - elapsed);
|
|
10
|
+
if (remainingDelay > 0) {
|
|
11
|
+
setTimeout(() => {
|
|
12
|
+
setImageLoaded(true);
|
|
13
|
+
setShowPlaceholderState(false);
|
|
14
|
+
}, remainingDelay);
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
setImageLoaded(true);
|
|
18
|
+
setShowPlaceholderState(false);
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
// Reset states when src changes
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
setImageLoaded(false);
|
|
24
|
+
setShowPlaceholderState(showPlaceholder);
|
|
25
|
+
startTimeRef.current = Date.now();
|
|
26
|
+
// Check if image is already cached and loaded using naturalWidth
|
|
27
|
+
if (imgRef.current && imgRef.current.naturalWidth !== 0) {
|
|
28
|
+
// Image is already loaded from cache, show it after minimum delay
|
|
29
|
+
setTimeout(() => {
|
|
30
|
+
setImageLoaded(true);
|
|
31
|
+
setShowPlaceholderState(false);
|
|
32
|
+
}, minDelay);
|
|
33
|
+
}
|
|
34
|
+
}, [src, showPlaceholder, minDelay]);
|
|
35
|
+
return {
|
|
36
|
+
imageLoaded,
|
|
37
|
+
showPlaceholder: showPlaceholderState,
|
|
38
|
+
imgRef,
|
|
39
|
+
handleImageLoad,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-mobile.d.ts","sourceRoot":"","sources":["../../src/hooks/use-mobile.ts"],"names":[],"mappings":"AAIA,wBAAgB,WAAW,YAc1B"}
|
|
@@ -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 @@
|
|
|
1
|
+
{"version":3,"file":"use-theme.d.ts","sourceRoot":"","sources":["../../src/hooks/use-theme.ts"],"names":[],"mappings":"AAGA,wBAAgB,gBAAgB;;;;EAsB/B"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { useTheme } from 'next-themes';
|
|
2
|
+
import { useEffect, useState } from 'react';
|
|
3
|
+
export function useThemeSwitcher() {
|
|
4
|
+
const { theme, setTheme, resolvedTheme } = useTheme();
|
|
5
|
+
const [mounted, setMounted] = useState(false);
|
|
6
|
+
// useEffect only runs on the client, so now we can safely show the UI
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
setMounted(true);
|
|
9
|
+
}, []);
|
|
10
|
+
const nextTheme = () => {
|
|
11
|
+
if (resolvedTheme === 'dark') {
|
|
12
|
+
setTheme('light');
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
setTheme('dark');
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
return {
|
|
19
|
+
theme: mounted ? resolvedTheme : 'light',
|
|
20
|
+
nextTheme,
|
|
21
|
+
setTheme,
|
|
22
|
+
};
|
|
23
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,OAAO,CAAC;AACtB,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkMecaExport.d.ts","sourceRoot":"","sources":["../../src/lib/checkMecaExport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,KAAK,eAAe,GAAG,QAAQ,CAAC,YAAY,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;AAQ7D,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAEpE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lib/index.ts"],"names":[],"mappings":"AACA,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { GenericParent } from 'myst-common';
|
|
2
|
+
export type KnownParts = {
|
|
3
|
+
abstract?: GenericParent;
|
|
4
|
+
summary?: GenericParent;
|
|
5
|
+
keypoints?: GenericParent;
|
|
6
|
+
data_availability?: GenericParent;
|
|
7
|
+
acknowledgments?: GenericParent;
|
|
8
|
+
};
|
|
9
|
+
export declare function extractKnownParts(tree: GenericParent, parts?: Record<string, {
|
|
10
|
+
mdast?: GenericParent;
|
|
11
|
+
}>): KnownParts;
|
|
12
|
+
//# sourceMappingURL=knownParts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"knownParts.d.ts","sourceRoot":"","sources":["../../src/lib/knownParts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAGjD,MAAM,MAAM,UAAU,GAAG;IACvB,QAAQ,CAAC,EAAE,aAAa,CAAC;IACzB,OAAO,CAAC,EAAE,aAAa,CAAC;IACxB,SAAS,CAAC,EAAE,aAAa,CAAC;IAC1B,iBAAiB,CAAC,EAAE,aAAa,CAAC;IAClC,eAAe,CAAC,EAAE,aAAa,CAAC;CACjC,CAAC;AAEF,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,aAAa,EACnB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE;IAAE,KAAK,CAAC,EAAE,aAAa,CAAA;CAAE,CAAC,GAChD,UAAU,CAaZ"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { extractPart } from 'myst-common';
|
|
2
|
+
export function extractKnownParts(tree, parts) {
|
|
3
|
+
if (!tree)
|
|
4
|
+
return extractKnownParts({ type: 'root', children: [] }, parts);
|
|
5
|
+
const abstract = extractPart(tree, 'abstract');
|
|
6
|
+
const summary = extractPart(tree, 'summary', { requireExplicitPart: true });
|
|
7
|
+
const keypoints = extractPart(tree, ['keypoints'], { requireExplicitPart: true });
|
|
8
|
+
const data_availability = extractPart(tree, ['data_availability', 'data availability']);
|
|
9
|
+
const acknowledgments = extractPart(tree, ['acknowledgments', 'acknowledgements']);
|
|
10
|
+
const otherParts = Object.fromEntries(Object.entries(parts ?? {}).map(([k, v]) => {
|
|
11
|
+
return [k, v.mdast];
|
|
12
|
+
}));
|
|
13
|
+
return { abstract, summary, keypoints, data_availability, acknowledgments, ...otherParts };
|
|
14
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"links.d.ts","sourceRoot":"","sources":["../../src/lib/links.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAEvD,eAAO,MAAM,QAAQ,EAAE,kBAKtB,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import {} from 'react-router';
|
|
2
|
+
export const KatexCSS = {
|
|
3
|
+
rel: 'stylesheet',
|
|
4
|
+
href: 'https://cdn.jsdelivr.net/npm/katex@0.15.2/dist/katex.min.css',
|
|
5
|
+
integrity: 'sha384-MlJdn/WNKDGXveldHDdyRP1R4CTHr3FeuDNfhsLPYrq2t0UBkUdK2jyTnXPEK1NQ',
|
|
6
|
+
crossOrigin: 'anonymous',
|
|
7
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-date.d.ts","sourceRoot":"","sources":["../../src/lib/parse-date.ts"],"names":[],"mappings":"AAAA,wBAAgB,OAAO,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAK1D"}
|