@ekkolyth/ui 0.0.2 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +3 -22
- package/dist/index.js +48 -95
- package/dist/next.d.ts +3 -0
- package/dist/next.js +45 -0
- package/dist/providers/next-theme-provider.d.ts +7 -0
- package/dist/providers/next-theme-provider.js +45 -0
- package/dist/providers/tanstack-theme-provider.d.ts +18 -0
- package/dist/providers/tanstack-theme-provider.js +79 -0
- package/dist/tanstack.d.ts +2 -0
- package/dist/tanstack.js +80 -0
- package/package.json +9 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { ThemeProviderProps } from 'next-themes';
|
|
3
|
-
export { ThemeProviderProps as NextThemeProviderProps, useTheme as useNextTheme } from 'next-themes';
|
|
4
2
|
import * as React$1 from 'react';
|
|
5
3
|
import { Accordion as Accordion$1, AlertDialog as AlertDialog$1, AspectRatio as AspectRatio$1, Avatar as Avatar$1, Separator as Separator$1, Checkbox as Checkbox$1, Collapsible as Collapsible$1, Dialog as Dialog$1, ContextMenu as ContextMenu$1, DropdownMenu as DropdownMenu$1, Label as Label$1, HoverCard as HoverCard$1, Menubar as Menubar$1, NavigationMenu as NavigationMenu$1, Popover as Popover$1, Progress as Progress$1, RadioGroup as RadioGroup$1, ScrollArea as ScrollArea$1, Select as Select$1, Tooltip as Tooltip$1, Slider as Slider$1, Switch as Switch$1, Tabs as Tabs$1, Toggle as Toggle$1, ToggleGroup as ToggleGroup$1 } from 'radix-ui';
|
|
6
4
|
import * as class_variance_authority_types from 'class-variance-authority/types';
|
|
@@ -16,23 +14,6 @@ import * as ResizablePrimitive from 'react-resizable-panels';
|
|
|
16
14
|
import { ToasterProps } from 'sonner';
|
|
17
15
|
import { ClassValue } from 'clsx';
|
|
18
16
|
|
|
19
|
-
declare function NextThemeProvider({ children, ...props }: React.PropsWithChildren<ThemeProviderProps>): react_jsx_runtime.JSX.Element;
|
|
20
|
-
|
|
21
|
-
type ResolvedTheme = "dark" | "light";
|
|
22
|
-
type Theme = ResolvedTheme | "system";
|
|
23
|
-
interface TanstackThemeProviderProps {
|
|
24
|
-
children: React.ReactNode;
|
|
25
|
-
defaultTheme?: Theme;
|
|
26
|
-
storageKey?: string;
|
|
27
|
-
}
|
|
28
|
-
interface TanstackThemeProviderState {
|
|
29
|
-
theme: Theme;
|
|
30
|
-
resolvedTheme: ResolvedTheme;
|
|
31
|
-
setTheme: (theme: Theme) => void;
|
|
32
|
-
}
|
|
33
|
-
declare function TanstackThemeProvider({ children, defaultTheme, storageKey, }: TanstackThemeProviderProps): react_jsx_runtime.JSX.Element;
|
|
34
|
-
declare function useTanstackTheme(): TanstackThemeProviderState;
|
|
35
|
-
|
|
36
17
|
declare function Accordion({ className, ...props }: React$1.ComponentProps<typeof Accordion$1.Root>): react_jsx_runtime.JSX.Element;
|
|
37
18
|
declare function AccordionItem({ className, ...props }: React$1.ComponentProps<typeof Accordion$1.Item>): react_jsx_runtime.JSX.Element;
|
|
38
19
|
declare function AccordionTrigger({ className, children, ...props }: React$1.ComponentProps<typeof Accordion$1.Trigger>): react_jsx_runtime.JSX.Element;
|
|
@@ -375,7 +356,7 @@ declare function Item({ className, variant, size, asChild, ...props }: React$1.C
|
|
|
375
356
|
asChild?: boolean;
|
|
376
357
|
}): react_jsx_runtime.JSX.Element;
|
|
377
358
|
declare const itemMediaVariants: (props?: ({
|
|
378
|
-
variant?: "
|
|
359
|
+
variant?: "image" | "default" | "icon" | null | undefined;
|
|
379
360
|
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
380
361
|
declare function ItemMedia({ className, variant, ...props }: React$1.ComponentProps<"div"> & VariantProps<typeof itemMediaVariants>): react_jsx_runtime.JSX.Element;
|
|
381
362
|
declare function ItemContent({ className, ...props }: React$1.ComponentProps<"div">): react_jsx_runtime.JSX.Element;
|
|
@@ -575,7 +556,7 @@ declare function TableCaption({ className, ...props }: React$1.ComponentProps<"c
|
|
|
575
556
|
|
|
576
557
|
declare function Tabs({ className, orientation, ...props }: React$1.ComponentProps<typeof Tabs$1.Root>): react_jsx_runtime.JSX.Element;
|
|
577
558
|
declare const tabsListVariants: (props?: ({
|
|
578
|
-
variant?: "
|
|
559
|
+
variant?: "line" | "default" | null | undefined;
|
|
579
560
|
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
580
561
|
declare function TabsList({ className, variant, ...props }: React$1.ComponentProps<typeof Tabs$1.List> & VariantProps<typeof tabsListVariants>): react_jsx_runtime.JSX.Element;
|
|
581
562
|
declare function TabsTrigger({ className, ...props }: React$1.ComponentProps<typeof Tabs$1.Trigger>): react_jsx_runtime.JSX.Element;
|
|
@@ -599,4 +580,4 @@ declare function useIsMobile(): boolean;
|
|
|
599
580
|
|
|
600
581
|
declare function cn(...inputs: ClassValue[]): string;
|
|
601
582
|
|
|
602
|
-
export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, Alert, AlertAction, AlertDescription, AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogMedia, AlertDialogOverlay, AlertDialogPortal, AlertDialogTitle, AlertDialogTrigger, AlertTitle, AspectRatio, Avatar, AvatarBadge, AvatarFallback, AvatarGroup, AvatarGroupCount, AvatarImage, Badge, Breadcrumb, BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator, Button, ButtonGroup, ButtonGroupSeparator, ButtonGroupText, Calendar, CalendarDayButton, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Carousel, type CarouselApi, CarouselContent, CarouselItem, CarouselNext, CarouselPrevious, type ChartConfig, ChartContainer, ChartLegend, ChartLegendContent, ChartStyle, ChartTooltip, ChartTooltipContent, Checkbox, Collapsible, CollapsibleContent, CollapsibleTrigger, Combobox, ComboboxChip, ComboboxChips, ComboboxChipsInput, ComboboxCollection, ComboboxContent, ComboboxEmpty, ComboboxGroup, ComboboxInput, ComboboxItem, ComboboxLabel, ComboboxList, ComboboxSeparator, ComboboxTrigger, ComboboxValue, Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, ContextMenu, ContextMenuCheckboxItem, ContextMenuContent, ContextMenuGroup, ContextMenuItem, ContextMenuLabel, ContextMenuPortal, ContextMenuRadioGroup, ContextMenuRadioItem, ContextMenuSeparator, ContextMenuShortcut, ContextMenuSub, ContextMenuSubContent, ContextMenuSubTrigger, ContextMenuTrigger, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, Drawer, DrawerClose, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerOverlay, DrawerPortal, DrawerTitle, DrawerTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyMedia, EmptyTitle, Field, FieldContent, FieldDescription, FieldError, FieldGroup, FieldLabel, FieldLegend, FieldSeparator, FieldSet, FieldTitle, HoverCard, HoverCardContent, HoverCardTrigger, Input, InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput, InputGroupText, InputGroupTextarea, InputOTP, InputOTPGroup, InputOTPSeparator, InputOTPSlot, Item, ItemActions, ItemContent, ItemDescription, ItemFooter, ItemGroup, ItemHeader, ItemMedia, ItemSeparator, ItemTitle, Kbd, KbdGroup, Label, Menubar, MenubarCheckboxItem, MenubarContent, MenubarGroup, MenubarItem, MenubarLabel, MenubarMenu, MenubarPortal, MenubarRadioGroup, MenubarRadioItem, MenubarSeparator, MenubarShortcut, MenubarSub, MenubarSubContent, MenubarSubTrigger, MenubarTrigger, NavigationMenu, NavigationMenuContent, NavigationMenuIndicator, NavigationMenuItem, NavigationMenuLink, NavigationMenuList, NavigationMenuTrigger, NavigationMenuViewport,
|
|
583
|
+
export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, Alert, AlertAction, AlertDescription, AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogMedia, AlertDialogOverlay, AlertDialogPortal, AlertDialogTitle, AlertDialogTrigger, AlertTitle, AspectRatio, Avatar, AvatarBadge, AvatarFallback, AvatarGroup, AvatarGroupCount, AvatarImage, Badge, Breadcrumb, BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator, Button, ButtonGroup, ButtonGroupSeparator, ButtonGroupText, Calendar, CalendarDayButton, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Carousel, type CarouselApi, CarouselContent, CarouselItem, CarouselNext, CarouselPrevious, type ChartConfig, ChartContainer, ChartLegend, ChartLegendContent, ChartStyle, ChartTooltip, ChartTooltipContent, Checkbox, Collapsible, CollapsibleContent, CollapsibleTrigger, Combobox, ComboboxChip, ComboboxChips, ComboboxChipsInput, ComboboxCollection, ComboboxContent, ComboboxEmpty, ComboboxGroup, ComboboxInput, ComboboxItem, ComboboxLabel, ComboboxList, ComboboxSeparator, ComboboxTrigger, ComboboxValue, Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, ContextMenu, ContextMenuCheckboxItem, ContextMenuContent, ContextMenuGroup, ContextMenuItem, ContextMenuLabel, ContextMenuPortal, ContextMenuRadioGroup, ContextMenuRadioItem, ContextMenuSeparator, ContextMenuShortcut, ContextMenuSub, ContextMenuSubContent, ContextMenuSubTrigger, ContextMenuTrigger, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, Drawer, DrawerClose, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerOverlay, DrawerPortal, DrawerTitle, DrawerTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyMedia, EmptyTitle, Field, FieldContent, FieldDescription, FieldError, FieldGroup, FieldLabel, FieldLegend, FieldSeparator, FieldSet, FieldTitle, HoverCard, HoverCardContent, HoverCardTrigger, Input, InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput, InputGroupText, InputGroupTextarea, InputOTP, InputOTPGroup, InputOTPSeparator, InputOTPSlot, Item, ItemActions, ItemContent, ItemDescription, ItemFooter, ItemGroup, ItemHeader, ItemMedia, ItemSeparator, ItemTitle, Kbd, KbdGroup, Label, Menubar, MenubarCheckboxItem, MenubarContent, MenubarGroup, MenubarItem, MenubarLabel, MenubarMenu, MenubarPortal, MenubarRadioGroup, MenubarRadioItem, MenubarSeparator, MenubarShortcut, MenubarSub, MenubarSubContent, MenubarSubTrigger, MenubarTrigger, NavigationMenu, NavigationMenuContent, NavigationMenuIndicator, NavigationMenuItem, NavigationMenuLink, NavigationMenuList, NavigationMenuTrigger, NavigationMenuViewport, Pagination, PaginationContent, PaginationEllipsis, PaginationItem, PaginationLink, PaginationNext, PaginationPrevious, Popover, PopoverAnchor, PopoverContent, PopoverDescription, PopoverHeader, PopoverTitle, PopoverTrigger, Progress, RadioGroup, RadioGroupItem, ResizableHandle, ResizablePanel, ResizablePanelGroup, ScrollArea, ScrollBar, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle, SheetTrigger, Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInput, SidebarInset, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider, SidebarRail, SidebarSeparator, SidebarTrigger, Skeleton, Slider, Spinner, Switch, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, Tabs, TabsContent, TabsList, TabsTrigger, Textarea, Toaster, Toggle, ToggleGroup, ToggleGroupItem, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, badgeVariants, buttonGroupVariants, buttonVariants, cn, navigationMenuTriggerStyle, tabsListVariants, toggleVariants, useCarousel, useComboboxAnchor, useIsMobile, useSidebar };
|
package/dist/index.js
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
import { ThemeProvider, useTheme } from 'next-themes';
|
|
2
|
-
export { useTheme as useNextTheme } from 'next-themes';
|
|
3
|
-
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
4
|
-
import * as React2 from 'react';
|
|
5
|
-
import { createContext, useState, useEffect, useMemo, use } from 'react';
|
|
6
|
-
import { ScriptOnce } from '@tanstack/react-router';
|
|
7
1
|
import { Accordion as Accordion$1, Slot, AlertDialog as AlertDialog$1, AspectRatio as AspectRatio$1, Avatar as Avatar$1, Separator as Separator$1, Checkbox as Checkbox$1, Collapsible as Collapsible$1, Dialog as Dialog$1, ContextMenu as ContextMenu$1, DropdownMenu as DropdownMenu$1, Label as Label$1, HoverCard as HoverCard$1, Menubar as Menubar$1, NavigationMenu as NavigationMenu$1, Popover as Popover$1, Progress as Progress$1, RadioGroup as RadioGroup$1, ScrollArea as ScrollArea$1, Select as Select$1, Tooltip, Slider as Slider$1, Switch as Switch$1, Tabs as Tabs$1, Toggle as Toggle$1, ToggleGroup as ToggleGroup$1 } from 'radix-ui';
|
|
8
2
|
import { clsx } from 'clsx';
|
|
9
3
|
import { twMerge } from 'tailwind-merge';
|
|
10
4
|
import { ChevronLeftIcon, ChevronRightIcon, ChevronDownIcon, CheckIcon, XIcon, SearchIcon, CircleIcon, Loader2Icon, ChevronUpIcon, MoreHorizontalIcon, MinusIcon, PanelLeftIcon, OctagonXIcon, TriangleAlertIcon, InfoIcon, CircleCheckIcon } from 'lucide-react';
|
|
5
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
11
6
|
import { cva } from 'class-variance-authority';
|
|
7
|
+
import * as React2 from 'react';
|
|
8
|
+
import { useMemo, useState, useEffect } from 'react';
|
|
12
9
|
import { getDefaultClassNames, DayPicker } from 'react-day-picker';
|
|
13
10
|
import useEmblaCarousel from 'embla-carousel-react';
|
|
14
11
|
import * as RechartsPrimitive from 'recharts';
|
|
@@ -50,87 +47,6 @@ var __objRest = (source, exclude) => {
|
|
|
50
47
|
}
|
|
51
48
|
return target;
|
|
52
49
|
};
|
|
53
|
-
function NextThemeProvider(_a) {
|
|
54
|
-
var _b = _a, {
|
|
55
|
-
children
|
|
56
|
-
} = _b, props = __objRest(_b, [
|
|
57
|
-
"children"
|
|
58
|
-
]);
|
|
59
|
-
return /* @__PURE__ */ jsx(ThemeProvider, __spreadProps(__spreadValues({}, props), { children }));
|
|
60
|
-
}
|
|
61
|
-
var initialState = {
|
|
62
|
-
theme: "system",
|
|
63
|
-
resolvedTheme: "light",
|
|
64
|
-
setTheme: () => null
|
|
65
|
-
};
|
|
66
|
-
var TanstackThemeProviderContext = createContext(initialState);
|
|
67
|
-
function FunctionOnce({
|
|
68
|
-
children,
|
|
69
|
-
param
|
|
70
|
-
}) {
|
|
71
|
-
return /* @__PURE__ */ jsx(ScriptOnce, { children: `(${children.toString()})(${JSON.stringify(param)})` });
|
|
72
|
-
}
|
|
73
|
-
function TanstackThemeProvider({
|
|
74
|
-
children,
|
|
75
|
-
defaultTheme = "system",
|
|
76
|
-
storageKey = "ekko-ui.theme"
|
|
77
|
-
}) {
|
|
78
|
-
const [theme, setThemeState] = useState(defaultTheme);
|
|
79
|
-
const [resolvedTheme, setResolvedTheme] = useState("light");
|
|
80
|
-
const [mounted, setMounted] = useState(false);
|
|
81
|
-
useEffect(() => {
|
|
82
|
-
setMounted(true);
|
|
83
|
-
const stored = localStorage.getItem(storageKey);
|
|
84
|
-
if (stored && (stored === "light" || stored === "dark" || stored === "system")) {
|
|
85
|
-
setThemeState(stored);
|
|
86
|
-
}
|
|
87
|
-
}, [storageKey]);
|
|
88
|
-
useEffect(() => {
|
|
89
|
-
const root = window.document.documentElement;
|
|
90
|
-
const mediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
|
|
91
|
-
function updateTheme() {
|
|
92
|
-
root.classList.remove("light", "dark");
|
|
93
|
-
if (theme === "system") {
|
|
94
|
-
const systemTheme = mediaQuery.matches ? "dark" : "light";
|
|
95
|
-
setResolvedTheme(systemTheme);
|
|
96
|
-
root.classList.add(systemTheme);
|
|
97
|
-
return;
|
|
98
|
-
}
|
|
99
|
-
setResolvedTheme(theme);
|
|
100
|
-
root.classList.add(theme);
|
|
101
|
-
}
|
|
102
|
-
mediaQuery.addEventListener("change", updateTheme);
|
|
103
|
-
updateTheme();
|
|
104
|
-
return () => mediaQuery.removeEventListener("change", updateTheme);
|
|
105
|
-
}, [theme]);
|
|
106
|
-
const value = useMemo(
|
|
107
|
-
() => ({
|
|
108
|
-
theme,
|
|
109
|
-
resolvedTheme,
|
|
110
|
-
setTheme: (newTheme) => {
|
|
111
|
-
localStorage.setItem(storageKey, newTheme);
|
|
112
|
-
setThemeState(newTheme);
|
|
113
|
-
}
|
|
114
|
-
}),
|
|
115
|
-
[theme, resolvedTheme, storageKey]
|
|
116
|
-
);
|
|
117
|
-
return /* @__PURE__ */ jsxs(TanstackThemeProviderContext.Provider, { value, children: [
|
|
118
|
-
/* @__PURE__ */ jsx(FunctionOnce, { param: storageKey, children: (storageKey2) => {
|
|
119
|
-
const theme2 = localStorage.getItem(storageKey2);
|
|
120
|
-
if (theme2 === "dark" || (theme2 === null || theme2 === "system") && window.matchMedia("(prefers-color-scheme: dark)").matches) {
|
|
121
|
-
document.documentElement.classList.add("dark");
|
|
122
|
-
}
|
|
123
|
-
} }),
|
|
124
|
-
children
|
|
125
|
-
] });
|
|
126
|
-
}
|
|
127
|
-
function useTanstackTheme() {
|
|
128
|
-
const context = use(TanstackThemeProviderContext);
|
|
129
|
-
if (context === void 0) {
|
|
130
|
-
throw new Error("useTanstackTheme must be used within a TanstackThemeProvider");
|
|
131
|
-
}
|
|
132
|
-
return context;
|
|
133
|
-
}
|
|
134
50
|
function cn(...inputs) {
|
|
135
51
|
return twMerge(clsx(inputs));
|
|
136
52
|
}
|
|
@@ -5516,13 +5432,55 @@ function Slider(_a) {
|
|
|
5516
5432
|
})
|
|
5517
5433
|
);
|
|
5518
5434
|
}
|
|
5435
|
+
var DARK_THEMES = /* @__PURE__ */ new Set([
|
|
5436
|
+
"dark",
|
|
5437
|
+
"frappe",
|
|
5438
|
+
"macchiato",
|
|
5439
|
+
"mocha",
|
|
5440
|
+
"tokyo-night"
|
|
5441
|
+
]);
|
|
5442
|
+
var LIGHT_THEMES = /* @__PURE__ */ new Set(["light", "latte"]);
|
|
5443
|
+
var getSonnerTheme = (dataTheme) => {
|
|
5444
|
+
if (!dataTheme) {
|
|
5445
|
+
if (typeof window !== "undefined") {
|
|
5446
|
+
const hasDarkClass = document.documentElement.classList.contains("dark") || document.body.classList.contains("dark");
|
|
5447
|
+
if (hasDarkClass) return "dark";
|
|
5448
|
+
const prefersDark = window.matchMedia(
|
|
5449
|
+
"(prefers-color-scheme: dark)"
|
|
5450
|
+
).matches;
|
|
5451
|
+
return prefersDark ? "dark" : "light";
|
|
5452
|
+
}
|
|
5453
|
+
return "dark";
|
|
5454
|
+
}
|
|
5455
|
+
if (DARK_THEMES.has(dataTheme)) return "dark";
|
|
5456
|
+
if (LIGHT_THEMES.has(dataTheme)) return "light";
|
|
5457
|
+
return "dark";
|
|
5458
|
+
};
|
|
5519
5459
|
var Toaster = (_a) => {
|
|
5520
5460
|
var props = __objRest(_a, []);
|
|
5521
|
-
const
|
|
5461
|
+
const [sonnerTheme, setSonnerTheme] = useState(
|
|
5462
|
+
"dark"
|
|
5463
|
+
);
|
|
5464
|
+
useEffect(() => {
|
|
5465
|
+
if (typeof window === "undefined") return;
|
|
5466
|
+
const detectTheme = () => {
|
|
5467
|
+
const dataTheme = document.documentElement.getAttribute("data-theme");
|
|
5468
|
+
return getSonnerTheme(dataTheme);
|
|
5469
|
+
};
|
|
5470
|
+
setSonnerTheme(detectTheme());
|
|
5471
|
+
const observer = new MutationObserver(() => {
|
|
5472
|
+
setSonnerTheme(detectTheme());
|
|
5473
|
+
});
|
|
5474
|
+
observer.observe(document.documentElement, {
|
|
5475
|
+
attributes: true,
|
|
5476
|
+
attributeFilter: ["data-theme", "class"]
|
|
5477
|
+
});
|
|
5478
|
+
return () => observer.disconnect();
|
|
5479
|
+
}, []);
|
|
5522
5480
|
return /* @__PURE__ */ jsx(
|
|
5523
5481
|
Toaster$1,
|
|
5524
5482
|
__spreadValues({
|
|
5525
|
-
theme,
|
|
5483
|
+
theme: sonnerTheme,
|
|
5526
5484
|
className: "toaster group",
|
|
5527
5485
|
icons: {
|
|
5528
5486
|
success: /* @__PURE__ */ jsx(CircleCheckIcon, { className: "size-4" }),
|
|
@@ -5536,11 +5494,6 @@ var Toaster = (_a) => {
|
|
|
5536
5494
|
"--normal-text": "var(--popover-foreground)",
|
|
5537
5495
|
"--normal-border": "var(--border)",
|
|
5538
5496
|
"--border-radius": "var(--radius)"
|
|
5539
|
-
},
|
|
5540
|
-
toastOptions: {
|
|
5541
|
-
classNames: {
|
|
5542
|
-
toast: "cn-toast"
|
|
5543
|
-
}
|
|
5544
5497
|
}
|
|
5545
5498
|
}, props)
|
|
5546
5499
|
);
|
|
@@ -5890,4 +5843,4 @@ function ToggleGroupItem(_a) {
|
|
|
5890
5843
|
);
|
|
5891
5844
|
}
|
|
5892
5845
|
|
|
5893
|
-
export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, Alert, AlertAction, AlertDescription, AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogMedia, AlertDialogOverlay, AlertDialogPortal, AlertDialogTitle, AlertDialogTrigger, AlertTitle, AspectRatio, Avatar, AvatarBadge, AvatarFallback, AvatarGroup, AvatarGroupCount, AvatarImage, Badge, Breadcrumb, BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator, Button, ButtonGroup, ButtonGroupSeparator, ButtonGroupText, Calendar, CalendarDayButton, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Carousel, CarouselContent, CarouselItem, CarouselNext, CarouselPrevious, ChartContainer, ChartLegend, ChartLegendContent, ChartStyle, ChartTooltip, ChartTooltipContent, Checkbox, Collapsible, CollapsibleContent, CollapsibleTrigger, Combobox, ComboboxChip, ComboboxChips, ComboboxChipsInput, ComboboxCollection, ComboboxContent, ComboboxEmpty, ComboboxGroup, ComboboxInput, ComboboxItem, ComboboxLabel, ComboboxList, ComboboxSeparator, ComboboxTrigger, ComboboxValue, Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, ContextMenu, ContextMenuCheckboxItem, ContextMenuContent, ContextMenuGroup, ContextMenuItem, ContextMenuLabel, ContextMenuPortal, ContextMenuRadioGroup, ContextMenuRadioItem, ContextMenuSeparator, ContextMenuShortcut, ContextMenuSub, ContextMenuSubContent, ContextMenuSubTrigger, ContextMenuTrigger, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, Drawer, DrawerClose, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerOverlay, DrawerPortal, DrawerTitle, DrawerTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyMedia, EmptyTitle, Field, FieldContent, FieldDescription, FieldError, FieldGroup, FieldLabel, FieldLegend, FieldSeparator, FieldSet, FieldTitle, HoverCard, HoverCardContent, HoverCardTrigger, Input, InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput, InputGroupText, InputGroupTextarea, InputOTP, InputOTPGroup, InputOTPSeparator, InputOTPSlot, Item, ItemActions, ItemContent, ItemDescription, ItemFooter, ItemGroup, ItemHeader, ItemMedia, ItemSeparator, ItemTitle, Kbd, KbdGroup, Label, Menubar, MenubarCheckboxItem, MenubarContent, MenubarGroup, MenubarItem, MenubarLabel, MenubarMenu, MenubarPortal, MenubarRadioGroup, MenubarRadioItem, MenubarSeparator, MenubarShortcut, MenubarSub, MenubarSubContent, MenubarSubTrigger, MenubarTrigger, NavigationMenu, NavigationMenuContent, NavigationMenuIndicator, NavigationMenuItem, NavigationMenuLink, NavigationMenuList, NavigationMenuTrigger, NavigationMenuViewport,
|
|
5846
|
+
export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, Alert, AlertAction, AlertDescription, AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogMedia, AlertDialogOverlay, AlertDialogPortal, AlertDialogTitle, AlertDialogTrigger, AlertTitle, AspectRatio, Avatar, AvatarBadge, AvatarFallback, AvatarGroup, AvatarGroupCount, AvatarImage, Badge, Breadcrumb, BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator, Button, ButtonGroup, ButtonGroupSeparator, ButtonGroupText, Calendar, CalendarDayButton, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Carousel, CarouselContent, CarouselItem, CarouselNext, CarouselPrevious, ChartContainer, ChartLegend, ChartLegendContent, ChartStyle, ChartTooltip, ChartTooltipContent, Checkbox, Collapsible, CollapsibleContent, CollapsibleTrigger, Combobox, ComboboxChip, ComboboxChips, ComboboxChipsInput, ComboboxCollection, ComboboxContent, ComboboxEmpty, ComboboxGroup, ComboboxInput, ComboboxItem, ComboboxLabel, ComboboxList, ComboboxSeparator, ComboboxTrigger, ComboboxValue, Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, ContextMenu, ContextMenuCheckboxItem, ContextMenuContent, ContextMenuGroup, ContextMenuItem, ContextMenuLabel, ContextMenuPortal, ContextMenuRadioGroup, ContextMenuRadioItem, ContextMenuSeparator, ContextMenuShortcut, ContextMenuSub, ContextMenuSubContent, ContextMenuSubTrigger, ContextMenuTrigger, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, Drawer, DrawerClose, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerOverlay, DrawerPortal, DrawerTitle, DrawerTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyMedia, EmptyTitle, Field, FieldContent, FieldDescription, FieldError, FieldGroup, FieldLabel, FieldLegend, FieldSeparator, FieldSet, FieldTitle, HoverCard, HoverCardContent, HoverCardTrigger, Input, InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput, InputGroupText, InputGroupTextarea, InputOTP, InputOTPGroup, InputOTPSeparator, InputOTPSlot, Item, ItemActions, ItemContent, ItemDescription, ItemFooter, ItemGroup, ItemHeader, ItemMedia, ItemSeparator, ItemTitle, Kbd, KbdGroup, Label, Menubar, MenubarCheckboxItem, MenubarContent, MenubarGroup, MenubarItem, MenubarLabel, MenubarMenu, MenubarPortal, MenubarRadioGroup, MenubarRadioItem, MenubarSeparator, MenubarShortcut, MenubarSub, MenubarSubContent, MenubarSubTrigger, MenubarTrigger, NavigationMenu, NavigationMenuContent, NavigationMenuIndicator, NavigationMenuItem, NavigationMenuLink, NavigationMenuList, NavigationMenuTrigger, NavigationMenuViewport, Pagination, PaginationContent, PaginationEllipsis, PaginationItem, PaginationLink, PaginationNext, PaginationPrevious, Popover, PopoverAnchor, PopoverContent, PopoverDescription, PopoverHeader, PopoverTitle, PopoverTrigger, Progress, RadioGroup, RadioGroupItem, ResizableHandle, ResizablePanel, ResizablePanelGroup, ScrollArea, ScrollBar, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle, SheetTrigger, Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInput, SidebarInset, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider, SidebarRail, SidebarSeparator, SidebarTrigger, Skeleton, Slider, Spinner, Switch, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, Tabs, TabsContent, TabsList, TabsTrigger, Textarea, Toaster, Toggle, ToggleGroup, ToggleGroupItem, Tooltip2 as Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, badgeVariants, buttonGroupVariants, buttonVariants, cn, navigationMenuTriggerStyle, tabsListVariants, toggleVariants, useCarousel, useComboboxAnchor, useIsMobile, useSidebar };
|
package/dist/next.d.ts
ADDED
package/dist/next.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { ThemeProvider } from 'next-themes';
|
|
2
|
+
export { useTheme } from 'next-themes';
|
|
3
|
+
import { jsx } from 'react/jsx-runtime';
|
|
4
|
+
|
|
5
|
+
var __defProp = Object.defineProperty;
|
|
6
|
+
var __defProps = Object.defineProperties;
|
|
7
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
8
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
9
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
11
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
12
|
+
var __spreadValues = (a, b) => {
|
|
13
|
+
for (var prop in b || (b = {}))
|
|
14
|
+
if (__hasOwnProp.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
if (__getOwnPropSymbols)
|
|
17
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
18
|
+
if (__propIsEnum.call(b, prop))
|
|
19
|
+
__defNormalProp(a, prop, b[prop]);
|
|
20
|
+
}
|
|
21
|
+
return a;
|
|
22
|
+
};
|
|
23
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
24
|
+
var __objRest = (source, exclude) => {
|
|
25
|
+
var target = {};
|
|
26
|
+
for (var prop in source)
|
|
27
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
28
|
+
target[prop] = source[prop];
|
|
29
|
+
if (source != null && __getOwnPropSymbols)
|
|
30
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
31
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
32
|
+
target[prop] = source[prop];
|
|
33
|
+
}
|
|
34
|
+
return target;
|
|
35
|
+
};
|
|
36
|
+
function NextThemeProvider(_a) {
|
|
37
|
+
var _b = _a, {
|
|
38
|
+
children
|
|
39
|
+
} = _b, props = __objRest(_b, [
|
|
40
|
+
"children"
|
|
41
|
+
]);
|
|
42
|
+
return /* @__PURE__ */ jsx(ThemeProvider, __spreadProps(__spreadValues({}, props), { children }));
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export { NextThemeProvider as ThemeProvider };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ThemeProviderProps } from 'next-themes';
|
|
3
|
+
export { ThemeProviderProps as NextThemeProviderProps, useTheme as useNextTheme } from 'next-themes';
|
|
4
|
+
|
|
5
|
+
declare function NextThemeProvider({ children, ...props }: React.PropsWithChildren<ThemeProviderProps>): react_jsx_runtime.JSX.Element;
|
|
6
|
+
|
|
7
|
+
export { NextThemeProvider };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { ThemeProvider } from 'next-themes';
|
|
2
|
+
export { useTheme as useNextTheme } from 'next-themes';
|
|
3
|
+
import { jsx } from 'react/jsx-runtime';
|
|
4
|
+
|
|
5
|
+
var __defProp = Object.defineProperty;
|
|
6
|
+
var __defProps = Object.defineProperties;
|
|
7
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
8
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
9
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
11
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
12
|
+
var __spreadValues = (a, b) => {
|
|
13
|
+
for (var prop in b || (b = {}))
|
|
14
|
+
if (__hasOwnProp.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
if (__getOwnPropSymbols)
|
|
17
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
18
|
+
if (__propIsEnum.call(b, prop))
|
|
19
|
+
__defNormalProp(a, prop, b[prop]);
|
|
20
|
+
}
|
|
21
|
+
return a;
|
|
22
|
+
};
|
|
23
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
24
|
+
var __objRest = (source, exclude) => {
|
|
25
|
+
var target = {};
|
|
26
|
+
for (var prop in source)
|
|
27
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
28
|
+
target[prop] = source[prop];
|
|
29
|
+
if (source != null && __getOwnPropSymbols)
|
|
30
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
31
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
32
|
+
target[prop] = source[prop];
|
|
33
|
+
}
|
|
34
|
+
return target;
|
|
35
|
+
};
|
|
36
|
+
function NextThemeProvider(_a) {
|
|
37
|
+
var _b = _a, {
|
|
38
|
+
children
|
|
39
|
+
} = _b, props = __objRest(_b, [
|
|
40
|
+
"children"
|
|
41
|
+
]);
|
|
42
|
+
return /* @__PURE__ */ jsx(ThemeProvider, __spreadProps(__spreadValues({}, props), { children }));
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export { NextThemeProvider };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
|
|
3
|
+
type ResolvedTheme = "dark" | "light";
|
|
4
|
+
type Theme = ResolvedTheme | "system";
|
|
5
|
+
interface TanstackThemeProviderProps {
|
|
6
|
+
children: React.ReactNode;
|
|
7
|
+
defaultTheme?: Theme;
|
|
8
|
+
storageKey?: string;
|
|
9
|
+
}
|
|
10
|
+
interface TanstackThemeProviderState {
|
|
11
|
+
theme: Theme;
|
|
12
|
+
resolvedTheme: ResolvedTheme;
|
|
13
|
+
setTheme: (theme: Theme) => void;
|
|
14
|
+
}
|
|
15
|
+
declare function TanstackThemeProvider({ children, defaultTheme, storageKey, }: TanstackThemeProviderProps): react_jsx_runtime.JSX.Element;
|
|
16
|
+
declare function useTanstackTheme(): TanstackThemeProviderState;
|
|
17
|
+
|
|
18
|
+
export { type ResolvedTheme, TanstackThemeProvider, type Theme, useTanstackTheme };
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { createContext, useState, useEffect, useMemo, use } from 'react';
|
|
2
|
+
import { ScriptOnce } from '@tanstack/react-router';
|
|
3
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
4
|
+
|
|
5
|
+
var initialState = {
|
|
6
|
+
theme: "system",
|
|
7
|
+
resolvedTheme: "light",
|
|
8
|
+
setTheme: () => null
|
|
9
|
+
};
|
|
10
|
+
var TanstackThemeProviderContext = createContext(initialState);
|
|
11
|
+
function FunctionOnce({
|
|
12
|
+
children,
|
|
13
|
+
param
|
|
14
|
+
}) {
|
|
15
|
+
return /* @__PURE__ */ jsx(ScriptOnce, { children: `(${children.toString()})(${JSON.stringify(param)})` });
|
|
16
|
+
}
|
|
17
|
+
function TanstackThemeProvider({
|
|
18
|
+
children,
|
|
19
|
+
defaultTheme = "system",
|
|
20
|
+
storageKey = "ekko-ui.theme"
|
|
21
|
+
}) {
|
|
22
|
+
const [theme, setThemeState] = useState(defaultTheme);
|
|
23
|
+
const [resolvedTheme, setResolvedTheme] = useState("light");
|
|
24
|
+
const [mounted, setMounted] = useState(false);
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
setMounted(true);
|
|
27
|
+
const stored = localStorage.getItem(storageKey);
|
|
28
|
+
if (stored && (stored === "light" || stored === "dark" || stored === "system")) {
|
|
29
|
+
setThemeState(stored);
|
|
30
|
+
}
|
|
31
|
+
}, [storageKey]);
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
const root = window.document.documentElement;
|
|
34
|
+
const mediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
|
|
35
|
+
function updateTheme() {
|
|
36
|
+
root.classList.remove("light", "dark");
|
|
37
|
+
if (theme === "system") {
|
|
38
|
+
const systemTheme = mediaQuery.matches ? "dark" : "light";
|
|
39
|
+
setResolvedTheme(systemTheme);
|
|
40
|
+
root.classList.add(systemTheme);
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
setResolvedTheme(theme);
|
|
44
|
+
root.classList.add(theme);
|
|
45
|
+
}
|
|
46
|
+
mediaQuery.addEventListener("change", updateTheme);
|
|
47
|
+
updateTheme();
|
|
48
|
+
return () => mediaQuery.removeEventListener("change", updateTheme);
|
|
49
|
+
}, [theme]);
|
|
50
|
+
const value = useMemo(
|
|
51
|
+
() => ({
|
|
52
|
+
theme,
|
|
53
|
+
resolvedTheme,
|
|
54
|
+
setTheme: (newTheme) => {
|
|
55
|
+
localStorage.setItem(storageKey, newTheme);
|
|
56
|
+
setThemeState(newTheme);
|
|
57
|
+
}
|
|
58
|
+
}),
|
|
59
|
+
[theme, resolvedTheme, storageKey]
|
|
60
|
+
);
|
|
61
|
+
return /* @__PURE__ */ jsxs(TanstackThemeProviderContext.Provider, { value, children: [
|
|
62
|
+
/* @__PURE__ */ jsx(FunctionOnce, { param: storageKey, children: (storageKey2) => {
|
|
63
|
+
const theme2 = localStorage.getItem(storageKey2);
|
|
64
|
+
if (theme2 === "dark" || (theme2 === null || theme2 === "system") && window.matchMedia("(prefers-color-scheme: dark)").matches) {
|
|
65
|
+
document.documentElement.classList.add("dark");
|
|
66
|
+
}
|
|
67
|
+
} }),
|
|
68
|
+
children
|
|
69
|
+
] });
|
|
70
|
+
}
|
|
71
|
+
function useTanstackTheme() {
|
|
72
|
+
const context = use(TanstackThemeProviderContext);
|
|
73
|
+
if (context === void 0) {
|
|
74
|
+
throw new Error("useTanstackTheme must be used within a TanstackThemeProvider");
|
|
75
|
+
}
|
|
76
|
+
return context;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export { TanstackThemeProvider, useTanstackTheme };
|
package/dist/tanstack.js
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { createContext, useState, useEffect, useMemo, use } from 'react';
|
|
2
|
+
import { ScriptOnce } from '@tanstack/react-router';
|
|
3
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
4
|
+
|
|
5
|
+
// src/components/theme/providers/tanstack-theme-provider.tsx
|
|
6
|
+
var initialState = {
|
|
7
|
+
theme: "system",
|
|
8
|
+
resolvedTheme: "light",
|
|
9
|
+
setTheme: () => null
|
|
10
|
+
};
|
|
11
|
+
var TanstackThemeProviderContext = createContext(initialState);
|
|
12
|
+
function FunctionOnce({
|
|
13
|
+
children,
|
|
14
|
+
param
|
|
15
|
+
}) {
|
|
16
|
+
return /* @__PURE__ */ jsx(ScriptOnce, { children: `(${children.toString()})(${JSON.stringify(param)})` });
|
|
17
|
+
}
|
|
18
|
+
function TanstackThemeProvider({
|
|
19
|
+
children,
|
|
20
|
+
defaultTheme = "system",
|
|
21
|
+
storageKey = "ekko-ui.theme"
|
|
22
|
+
}) {
|
|
23
|
+
const [theme, setThemeState] = useState(defaultTheme);
|
|
24
|
+
const [resolvedTheme, setResolvedTheme] = useState("light");
|
|
25
|
+
const [mounted, setMounted] = useState(false);
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
setMounted(true);
|
|
28
|
+
const stored = localStorage.getItem(storageKey);
|
|
29
|
+
if (stored && (stored === "light" || stored === "dark" || stored === "system")) {
|
|
30
|
+
setThemeState(stored);
|
|
31
|
+
}
|
|
32
|
+
}, [storageKey]);
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
const root = window.document.documentElement;
|
|
35
|
+
const mediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
|
|
36
|
+
function updateTheme() {
|
|
37
|
+
root.classList.remove("light", "dark");
|
|
38
|
+
if (theme === "system") {
|
|
39
|
+
const systemTheme = mediaQuery.matches ? "dark" : "light";
|
|
40
|
+
setResolvedTheme(systemTheme);
|
|
41
|
+
root.classList.add(systemTheme);
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
setResolvedTheme(theme);
|
|
45
|
+
root.classList.add(theme);
|
|
46
|
+
}
|
|
47
|
+
mediaQuery.addEventListener("change", updateTheme);
|
|
48
|
+
updateTheme();
|
|
49
|
+
return () => mediaQuery.removeEventListener("change", updateTheme);
|
|
50
|
+
}, [theme]);
|
|
51
|
+
const value = useMemo(
|
|
52
|
+
() => ({
|
|
53
|
+
theme,
|
|
54
|
+
resolvedTheme,
|
|
55
|
+
setTheme: (newTheme) => {
|
|
56
|
+
localStorage.setItem(storageKey, newTheme);
|
|
57
|
+
setThemeState(newTheme);
|
|
58
|
+
}
|
|
59
|
+
}),
|
|
60
|
+
[theme, resolvedTheme, storageKey]
|
|
61
|
+
);
|
|
62
|
+
return /* @__PURE__ */ jsxs(TanstackThemeProviderContext.Provider, { value, children: [
|
|
63
|
+
/* @__PURE__ */ jsx(FunctionOnce, { param: storageKey, children: (storageKey2) => {
|
|
64
|
+
const theme2 = localStorage.getItem(storageKey2);
|
|
65
|
+
if (theme2 === "dark" || (theme2 === null || theme2 === "system") && window.matchMedia("(prefers-color-scheme: dark)").matches) {
|
|
66
|
+
document.documentElement.classList.add("dark");
|
|
67
|
+
}
|
|
68
|
+
} }),
|
|
69
|
+
children
|
|
70
|
+
] });
|
|
71
|
+
}
|
|
72
|
+
function useTanstackTheme() {
|
|
73
|
+
const context = use(TanstackThemeProviderContext);
|
|
74
|
+
if (context === void 0) {
|
|
75
|
+
throw new Error("useTanstackTheme must be used within a TanstackThemeProvider");
|
|
76
|
+
}
|
|
77
|
+
return context;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export { TanstackThemeProvider as ThemeProvider, useTanstackTheme as useTheme };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ekkolyth/ui",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "Shared UI Library for my personal projects",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"theme",
|
|
@@ -21,6 +21,14 @@
|
|
|
21
21
|
"types": "./dist/index.d.ts",
|
|
22
22
|
"import": "./dist/index.js"
|
|
23
23
|
},
|
|
24
|
+
"./next": {
|
|
25
|
+
"types": "./dist/next.d.ts",
|
|
26
|
+
"import": "./dist/next.js"
|
|
27
|
+
},
|
|
28
|
+
"./tanstack": {
|
|
29
|
+
"types": "./dist/tanstack.d.ts",
|
|
30
|
+
"import": "./dist/tanstack.js"
|
|
31
|
+
},
|
|
24
32
|
"./providers/next-theme": {
|
|
25
33
|
"types": "./dist/providers/next-theme-provider.d.ts",
|
|
26
34
|
"import": "./dist/providers/next-theme-provider.js"
|