mtxuilib 0.1.296 → 0.1.297

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.
Files changed (35) hide show
  1. package/dist/hooks/use-media-query.js +3 -3
  2. package/dist/i18n/I18nProvider.d.ts +2 -0
  3. package/dist/i18n/I18nProvider.js +7 -0
  4. package/dist/i18n/i18n.d.ts +1 -1
  5. package/dist/i18n/i18n.js +5 -1
  6. package/dist/icons/icons.d.ts +2 -0
  7. package/dist/icons/icons.js +3 -1
  8. package/dist/layouts/DashLayoutProvider.d.ts +45 -0
  9. package/dist/layouts/DashLayoutProvider.js +55 -0
  10. package/dist/layouts/DashLayoutRender.d.ts +2 -0
  11. package/dist/layouts/DashLayoutRender.js +7 -0
  12. package/dist/layouts/dash5/DashSider.d.ts +2 -0
  13. package/dist/layouts/dash5/DashSider.js +13 -0
  14. package/dist/layouts/dash5/MainHeader.d.ts +1 -0
  15. package/dist/layouts/dash5/{header.js → MainHeader.js} +1 -1
  16. package/dist/layouts/dash5/SiderDebug.d.ts +1 -0
  17. package/dist/layouts/dash5/SiderDebug.js +5 -0
  18. package/dist/layouts/dash5/SiderNavItem.d.ts +2 -13
  19. package/dist/layouts/dash5/SiderNavItem.js +13 -4
  20. package/dist/layouts/dash5/SiderToggleButton.d.ts +5 -0
  21. package/dist/layouts/dash5/SiderToggleButton.js +5 -0
  22. package/dist/layouts/dash5/dash5.store.d.ts +3 -2
  23. package/dist/layouts/dash5/dash5.store.js +0 -1
  24. package/dist/layouts/dash5/index.js +6 -21
  25. package/dist/layouts/types.d.ts +18 -0
  26. package/dist/layouts/types.js +1 -0
  27. package/dist/lib/clientlib.d.ts +1 -1
  28. package/dist/lib/clientlib.js +6 -2
  29. package/dist/ui/mt/dialog/MtDialog.js +2 -2
  30. package/dist/ui/select.d.ts +3 -1
  31. package/dist/ui/select.js +14 -9
  32. package/package.json +3 -3
  33. package/dist/layouts/dash5/header.d.ts +0 -1
  34. package/dist/layouts/dash5/nav.d.ts +0 -12
  35. package/dist/layouts/dash5/nav.js +0 -25
@@ -1,8 +1,8 @@
1
1
  'use client';
2
- import * as React from "react";
2
+ import { useEffect, useState } from "react";
3
3
  export function useMediaQuery(query) {
4
- const [value, setValue] = React.useState(false);
5
- React.useEffect(() => {
4
+ const [value, setValue] = useState(false);
5
+ useEffect(() => {
6
6
  function onChange(event) {
7
7
  setValue(event.matches);
8
8
  }
@@ -0,0 +1,2 @@
1
+ import { PropsWithChildren } from "react";
2
+ export declare function I18nProvider({ children }: PropsWithChildren): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,7 @@
1
+ 'use client';
2
+ import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
3
+ import { i18nSetupLocalization } from "./i18n";
4
+ i18nSetupLocalization();
5
+ export function I18nProvider({ children }) {
6
+ return _jsx(_Fragment, { children: children });
7
+ }
@@ -11,4 +11,4 @@ export declare const useTranslation: () => {
11
11
  ready: boolean;
12
12
  i18n: import("i18next").i18n;
13
13
  };
14
- export default Translator;
14
+ export {};
package/dist/i18n/i18n.js CHANGED
@@ -6,7 +6,12 @@ const i18nConfig = {
6
6
  fallbackLng: "en-US",
7
7
  defaultNS: "translation",
8
8
  };
9
+ let isSetuped = false;
9
10
  export function i18nSetupLocalization() {
11
+ if (isSetuped) {
12
+ return;
13
+ }
14
+ isSetuped = true;
10
15
  i18n
11
16
  .use(initReactI18next)
12
17
  .init(i18nConfig)
@@ -32,4 +37,3 @@ export const useTranslation = () => {
32
37
  i18n,
33
38
  };
34
39
  };
35
- export default Translator;
@@ -110,6 +110,8 @@ export declare const Icons: {
110
110
  embed: import("react").ForwardRefExoticComponent<Omit<LucideProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
111
111
  highlight: import("react").ForwardRefExoticComponent<Omit<LucideProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
112
112
  suggesting: import("react").ForwardRefExoticComponent<Omit<LucideProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
113
+ terminal: import("react").ForwardRefExoticComponent<Omit<LucideProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
114
+ dashboard: import("react").ForwardRefExoticComponent<Omit<LucideProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
113
115
  google: (props: IconProps) => import("react/jsx-runtime").JSX.Element;
114
116
  logo: (props: IconProps) => import("react/jsx-runtime").JSX.Element;
115
117
  twitter: (props: IconProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { cva } from "class-variance-authority";
3
- import { AlertTriangle, AlignCenter, AlignJustify, AlignLeft, AlignRight, ArrowLeft, ArrowRight, Baseline, Bell, Bold, Bug, Check, ChevronDown, ChevronLeft, ChevronRight, ChevronsUpDown, ClipboardCheck, Code2, Combine, Copy, CreditCard, DownloadCloud, Edit2, ExternalLink, Eye, File, FileCode, FileText, Film, GripVertical, Heading1, Heading2, Heading3, Heading4, Heading5, Heading6, HelpCircle, Highlighter, Image, Indent, Italic, Keyboard, Laptop, Link2, Link2Off, List, ListOrdered, Loader2, MailX, Menu, MessageSquare, MessageSquarePlus, Minus, Moon, MoreHorizontal, MoreVertical, Outdent, PaintBucket, Paperclip, PenLine, PenTool, Pilcrow, Pizza, Plus, Quote, RectangleHorizontal, RectangleVertical, RotateCcw, Search, SeparatorHorizontal, Settings, Smile, SquareIcon, Star, Strikethrough, Subscript, SunMedium, Superscript, Table, Text, Trash, Underline, Ungroup, User, Verified, WrapText, X, } from "lucide-react";
3
+ import { AlertTriangle, AlignCenter, AlignJustify, AlignLeft, AlignRight, ArrowLeft, ArrowRight, Baseline, Bell, Bold, Bug, Check, ChevronDown, ChevronLeft, ChevronRight, ChevronsUpDown, ClipboardCheck, Code2, Combine, Copy, CreditCard, DownloadCloud, Edit2, ExternalLink, Eye, File, FileCode, FileText, Film, GripVertical, Heading1, Heading2, Heading3, Heading4, Heading5, Heading6, HelpCircle, Highlighter, Image, Indent, Italic, Keyboard, Laptop, LayoutDashboard, Link2, Link2Off, List, ListOrdered, Loader2, MailX, Menu, MessageSquare, MessageSquarePlus, Minus, Moon, MoreHorizontal, MoreVertical, Outdent, PaintBucket, Paperclip, PenLine, PenTool, Pilcrow, Pizza, Plus, Quote, RectangleHorizontal, RectangleVertical, RotateCcw, Search, SeparatorHorizontal, Settings, Smile, SquareIcon, Star, Strikethrough, Subscript, SunMedium, Superscript, Table, Terminal, Text, Trash, Underline, Ungroup, User, Verified, WrapText, X, } from "lucide-react";
4
4
  export const iconVariants = cva("", {
5
5
  variants: {
6
6
  variant: {
@@ -124,6 +124,8 @@ export const Icons = {
124
124
  embed: Film,
125
125
  highlight: Highlighter,
126
126
  suggesting: PenLine,
127
+ terminal: Terminal,
128
+ dashboard: LayoutDashboard,
127
129
  google: (props) => (_jsx("svg", { role: "img", viewBox: "0 0 24 24", ...props, children: _jsx("path", { fill: "currentColor", d: "M12.48 10.92v3.28h7.84c-.24 1.84-.853 3.187-1.787 4.133-1.147 1.147-2.933 2.4-6.053 2.4-4.827 0-8.6-3.893-8.6-8.72s3.773-8.72 8.6-8.72c2.6 0 4.507 1.027 5.907 2.347l2.307-2.307C18.747 1.44 16.133 0 12.48 0 5.867 0 .307 5.387.307 12s5.56 12 12.173 12c3.573 0 6.267-1.173 8.373-3.36 2.16-2.16 2.84-5.213 2.84-7.667 0-.76-.053-1.467-.173-2.053H12.48z" }) })),
128
130
  logo: (props) => (_jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 256 256", ...props, children: [_jsx("rect", { width: "256", height: "256", fill: "none" }), _jsx("line", { x1: "208", y1: "128", x2: "128", y2: "208", fill: "none", stroke: "currentColor", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "16" }), _jsx("line", { x1: "192", y1: "40", x2: "40", y2: "192", fill: "none", stroke: "currentColor", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "16" })] })),
129
131
  twitter: (props) => (_jsx("svg", { ...props, height: "23", viewBox: "0 0 1200 1227", width: "23", xmlns: "http://www.w3.org/2000/svg", children: _jsx("path", { d: "M714.163 519.284L1160.89 0H1055.03L667.137 450.887L357.328 0H0L468.492 681.821L0 1226.37H105.866L515.491 750.218L842.672 1226.37H1200L714.137 519.284H714.163ZM569.165 687.828L521.697 619.934L144.011 79.6944H306.615L611.412 515.685L658.88 583.579L1055.08 1150.3H892.476L569.165 687.854V687.828Z" }) })),
@@ -0,0 +1,45 @@
1
+ import { type StateCreator } from "zustand";
2
+ import type { SiderNavItemProps } from "./types";
3
+ export interface DashConfig {
4
+ pathPrefix: string;
5
+ logo?: string;
6
+ siderNavMenus: SiderNavItemProps[];
7
+ }
8
+ export interface MtmaiBotProps {
9
+ isDev?: boolean;
10
+ config?: DashConfig;
11
+ }
12
+ export interface DashState extends MtmaiBotProps {
13
+ hasHydrated?: boolean;
14
+ setHasHydrated: (hasHydrated: boolean) => void;
15
+ setConfig: (config: DashConfig) => void;
16
+ }
17
+ export declare const createAppSlice: StateCreator<DashState, [], [], DashState>;
18
+ export declare const dashContext: import("react").Context<(Omit<Omit<Omit<import("zustand").StoreApi<DashState>, "persist"> & {
19
+ persist: {
20
+ setOptions: (options: Partial<import("zustand/middleware").PersistOptions<DashState, {
21
+ [k: string]: unknown;
22
+ }>>) => void;
23
+ clearStorage: () => void;
24
+ rehydrate: () => Promise<void> | void;
25
+ hasHydrated: () => boolean;
26
+ onHydrate: (fn: (state: DashState) => void) => () => void;
27
+ onFinishHydration: (fn: (state: DashState) => void) => () => void;
28
+ getOptions: () => Partial<import("zustand/middleware").PersistOptions<DashState, {
29
+ [k: string]: unknown;
30
+ }>>;
31
+ };
32
+ }, "setState"> & {
33
+ setState<A extends string | {
34
+ type: string;
35
+ }>(partial: DashState | Partial<DashState> | ((state: DashState) => DashState | Partial<DashState>), replace?: boolean | undefined, action?: A | undefined): void;
36
+ }, "setState"> & {
37
+ setState(nextStateOrUpdater: DashState | Partial<DashState> | ((state: import("immer").WritableDraft<DashState>) => void), shouldReplace?: boolean | undefined, action?: string | {
38
+ type: string;
39
+ } | undefined): void;
40
+ }) | null>;
41
+ type AppProviderProps = React.PropsWithChildren<MtmaiBotProps>;
42
+ export declare const DashLayoutProvider: (props: AppProviderProps) => import("react/jsx-runtime").JSX.Element;
43
+ export declare function useDash(): DashState;
44
+ export declare function useDash<T>(selector: (state: DashState) => T): T;
45
+ export {};
@@ -0,0 +1,55 @@
1
+ "use client";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { createContext, useContext, useMemo } from "react";
4
+ import { createStore, useStore } from "zustand";
5
+ import { devtools, persist } from "zustand/middleware";
6
+ import { immer } from "zustand/middleware/immer";
7
+ import { useShallow } from "zustand/react/shallow";
8
+ export const createAppSlice = (set, get, init) => {
9
+ return {
10
+ isDev: false,
11
+ ...init,
12
+ setHasHydrated: (hasHydrated) => set({ hasHydrated }),
13
+ setConfig: (config) => set({ config }),
14
+ };
15
+ };
16
+ const createMtAppStore = (initProps) => {
17
+ const initialState = { ...initProps };
18
+ return createStore()(persist(devtools(immer((...a) => ({
19
+ ...createAppSlice(...a),
20
+ ...initialState,
21
+ })), {
22
+ name: "DashProvider",
23
+ }), {
24
+ name: "DashProvider",
25
+ skipHydration: false,
26
+ version: 2,
27
+ onRehydrateStorage: () => (state, error) => {
28
+ state?.setHasHydrated(true);
29
+ if (error) {
30
+ console.error("onRehydrateStorage error", error);
31
+ }
32
+ },
33
+ partialize: (state) => {
34
+ return Object.fromEntries(Object.entries(state).filter(([key]) => {
35
+ return !["cookieStr", "socket", "session"].includes(key);
36
+ }));
37
+ },
38
+ }));
39
+ };
40
+ export const dashContext = createContext(null);
41
+ export const DashLayoutProvider = (props) => {
42
+ const { children, ...etc } = props;
43
+ const mystore = useMemo(() => createMtAppStore(etc), [etc]);
44
+ return (_jsx(dashContext.Provider, { value: mystore, children: children }));
45
+ };
46
+ const DEFAULT_USE_SHALLOW = false;
47
+ export function useDash(selector) {
48
+ const store = useContext(dashContext);
49
+ if (!store)
50
+ throw new Error("useDash must in DashLayoutProvider");
51
+ if (selector) {
52
+ return useStore(store, DEFAULT_USE_SHALLOW ? useShallow(selector) : selector);
53
+ }
54
+ return useStore(store);
55
+ }
@@ -0,0 +1,2 @@
1
+ import { PropsWithChildren } from "react";
2
+ export declare const DashLayoutRender: (props: PropsWithChildren) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,7 @@
1
+ 'use client';
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { Dash5Layout } from "./dash5";
4
+ export const DashLayoutRender = (props) => {
5
+ const { children, ...etc } = props;
6
+ return _jsx(Dash5Layout, { ...etc, children: children });
7
+ };
@@ -0,0 +1,2 @@
1
+ import { DashSiderProps } from "../types";
2
+ export declare const DashSider: (props: DashSiderProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,13 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useDash5Store } from "mtxuilib/layouts/dash5/dash5.store";
4
+ import { SiderToggleButton } from "mtxuilib/layouts/dash5/SiderToggleButton";
5
+ import { cn } from "mtxuilib/lib/utils";
6
+ import { useDash } from "../DashLayoutProvider";
7
+ import { SiderNavItem } from "./SiderNavItem";
8
+ export const DashSider = (props) => {
9
+ const isSideCollapsed = useDash5Store((x) => x.isSideCollapsed);
10
+ const setIsSideCollapsed = useDash5Store((x) => x.setIsSideCollapsed);
11
+ const siderNavMenus = useDash(x => x.config?.siderNavMenus);
12
+ return (_jsxs("div", { className: "flex flex-col gap-2 p-1 h-full", children: [_jsx("div", { className: "mb-2 flex items-center justify-between", children: _jsx("img", { src: "/media/logo.svg", alt: "mtmai-logo", width: 200, height: 26, loading: "lazy", className: cn("m-1 max-w-none duration-75 group-hover:[clip-path:none] 2xl:[clip-path:none] block dark:hidden", isSideCollapsed && "[clip-path:inset(0%_75%_0%_0%)]") }) }), _jsx("div", { className: "flex-1", children: _jsx(SiderNavItem, { isCollapsed: props.isCollapsed, items: siderNavMenus || [] }) }), _jsx("div", { children: _jsx(SiderToggleButton, { isCollapsed: !!isSideCollapsed, setIsCollapsed: setIsSideCollapsed }) })] }));
13
+ };
@@ -0,0 +1 @@
1
+ export declare const MainHeader: () => import("react/jsx-runtime").JSX.Element;
@@ -6,6 +6,6 @@ import { Button } from "mtxuilib/ui/button";
6
6
  import { Sheet, SheetContent, SheetTrigger } from "mtxuilib/ui/sheet";
7
7
  import Link from "next/link";
8
8
  import { Suspense } from "react";
9
- export const Header = () => {
9
+ export const MainHeader = () => {
10
10
  return (_jsxs("header", { className: cn("bg-background sticky top-0 z-30 flex h-14 items-center gap-4 border-b px-4 pt-1 sm:static sm:h-auto sm:border-0 sm:bg-transparent sm:px-6"), children: [_jsxs(Sheet, { children: [_jsx(SheetTrigger, { asChild: true, children: _jsxs(Button, { size: "icon", variant: "outline", className: "sm:hidden", children: [_jsx(PanelLeft, { className: "h-5 w-5" }), _jsx("span", { className: "sr-only", children: "Toggle Menu" })] }) }), _jsx(SheetContent, { side: "left", className: "sm:max-w-xs", children: _jsxs("nav", { className: "grid gap-6 text-lg font-medium", children: [_jsxs(Link, { href: "#", className: "bg-primary text-primary-foreground group flex h-10 w-10 shrink-0 items-center justify-center gap-2 rounded-full text-lg font-semibold md:text-base", children: [_jsx(Package2, { className: "h-5 w-5 transition-all group-hover:scale-110" }), _jsx("span", { className: "sr-only", children: "Acme Inc" })] }), _jsxs(Link, { href: "#", className: "text-muted-foreground hover:text-foreground flex items-center gap-4 px-2.5", children: [_jsx(Home, { className: "h-5 w-5" }), "Dashboard"] }), _jsxs(Link, { href: "#", className: "text-foreground flex items-center gap-4 px-2.5", children: [_jsx(ShoppingCart, { className: "h-5 w-5" }), "Orders"] }), _jsxs(Link, { href: "#", className: "text-muted-foreground hover:text-foreground flex items-center gap-4 px-2.5", children: [_jsx(Package, { className: "h-5 w-5" }), "Products"] }), _jsxs(Link, { href: "#", className: "text-muted-foreground hover:text-foreground flex items-center gap-4 px-2.5", children: [_jsx(Users2, { className: "h-5 w-5" }), "Customers"] }), _jsxs(Link, { href: "#", className: "text-muted-foreground hover:text-foreground flex items-center gap-4 px-2.5", children: [_jsx(LineChart, { className: "h-5 w-5" }), "Settings"] })] }) })] }), _jsx("div", { className: "flex-1" }), _jsx(Suspense, {})] }));
11
11
  };
@@ -0,0 +1 @@
1
+ export declare const SiderDebug: () => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,5 @@
1
+ 'use client';
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ export const SiderDebug = () => {
4
+ return _jsx("div", { children: _jsx("div", { children: "sider_debug" }) });
5
+ };
@@ -1,13 +1,2 @@
1
- import type { LucideIcon } from "lucide-react";
2
- interface SiderNavItemProps {
3
- isCollapsed: boolean;
4
- links?: {
5
- title: string;
6
- label?: string;
7
- icon: LucideIcon;
8
- variant: "default" | "ghost";
9
- href: string;
10
- }[];
11
- }
12
- export declare function SiderNavItem({ links, isCollapsed }: SiderNavItemProps): import("react/jsx-runtime").JSX.Element;
13
- export {};
1
+ import { NavProps } from "../types";
2
+ export declare function SiderNavItem({ items, isCollapsed }: NavProps): import("react/jsx-runtime").JSX.Element;
@@ -1,10 +1,19 @@
1
1
  "use client";
2
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
+ import { IconX } from "mtxuilib/icons/icons";
3
4
  import { cn } from "mtxuilib/lib/utils";
4
5
  import { buttonVariants } from "mtxuilib/ui/button";
5
6
  import { Tooltip, TooltipContent, TooltipTrigger } from "mtxuilib/ui/tooltip";
6
7
  import Link from "next/link";
7
- export function SiderNavItem({ links, isCollapsed }) {
8
- return (_jsx("div", { "data-collapsed": isCollapsed, className: "group flex flex-col gap-4 py-2 data-[collapsed=true]:py-2", children: _jsx("nav", { className: "grid gap-1 px-2 group-[[data-collapsed=true]]:justify-center group-[[data-collapsed=true]]:px-2", children: links?.map((link, index) => isCollapsed ? (_jsxs(Tooltip, { delayDuration: 0, children: [_jsx(TooltipTrigger, { asChild: true, children: _jsxs(Link, { href: link.href, className: cn(buttonVariants({ variant: link.variant, size: "icon" }), "h-9 w-9", link.variant === "default" &&
9
- "dark:bg-muted dark:text-muted-foreground dark:hover:bg-muted dark:hover:text-white"), children: [_jsx(link.icon, { className: "h-4 w-4" }), _jsx("span", { className: "sr-only", children: link.title })] }) }), _jsxs(TooltipContent, { side: "right", className: "flex items-center gap-4", children: [link.title, link.label && _jsx("span", { className: "text-muted-foreground ml-auto", children: link.label })] })] }, link.href)) : (_jsxs(Link, { href: link.href, className: cn(buttonVariants({ variant: link.variant, size: "sm" }), link.variant === "default" && "dark:bg-muted dark:hover:bg-muted dark:text-white dark:hover:text-white", "justify-start"), children: [_jsx(link.icon, { className: "mr-2 h-4 w-4" }), link.title, link.label && (_jsx("span", { className: cn("ml-auto", link.variant === "default" && "text-background dark:text-white"), children: link.label }))] }, link.href))) }) }));
8
+ import { useSelectedLayoutSegment } from "next/navigation";
9
+ import { Fragment } from "react/jsx-runtime";
10
+ export function SiderNavItem({ items, isCollapsed }) {
11
+ const activatePath = useSelectedLayoutSegment();
12
+ return (_jsx("div", { "data-collapsed": isCollapsed, className: "group flex flex-col gap-4 py-2 data-[collapsed=true]:py-2", children: _jsx("nav", { className: "grid gap-1 px-2 group-[[data-collapsed=true]]:justify-center group-[[data-collapsed=true]]:px-2", children: items.map((link, index) => {
13
+ const isActive = link.url === activatePath || link.url === "/" + activatePath || link.url === "/" + activatePath + "/";
14
+ return _jsx(Fragment, { children: isCollapsed ? _jsx(_Fragment, { children: _jsxs(Tooltip, { delayDuration: 0, children: [_jsx(TooltipTrigger, { asChild: true, children: _jsxs(Link, { href: "#", className: cn(buttonVariants({ variant: link.variant, size: "icon" }), "h-9 w-9", link.variant === "default" &&
15
+ "dark:bg-muted dark:text-muted-foreground dark:hover:bg-muted dark:hover:text-white", isActive && "bg-blue-500"), children: [_jsx(IconX, { name: link.icon, className: "h-5 w-5" }), _jsx("span", { className: "sr-only", children: link.title })] }) }), _jsxs(TooltipContent, { side: "right", className: "flex items-center gap-4", children: [link.title, link.label && (_jsx("span", { className: "ml-auto text-muted-foreground", children: link.label }))] })] }, index) }) : _jsx(_Fragment, { children: _jsxs(Link, { href: link.url || "#", className: cn(buttonVariants({ variant: link.variant, size: "default" }), link.variant === "default" &&
16
+ "dark:bg-muted dark:text-white dark:hover:bg-muted dark:hover:text-white", "justify-start", isActive && "bg-muted dark:bg-primary hover:shadow-sm"), children: [_jsx(IconX, { name: link.icon, className: "mr-2 h-5 w-5" }), link.title, link.label && (_jsx("span", { className: cn("ml-auto", link.variant === "default" &&
17
+ "text-background dark:text-white"), children: link.label }))] }, index) }) }, index);
18
+ }) }) }));
10
19
  }
@@ -0,0 +1,5 @@
1
+ export interface SiderToggleButtonProps {
2
+ isCollapsed: boolean;
3
+ setIsCollapsed: (isCollapsed: boolean) => void;
4
+ }
5
+ export declare const SiderToggleButton: ({ isCollapsed, setIsCollapsed }: SiderToggleButtonProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,5 @@
1
+ 'use client';
2
+ import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
3
+ export const SiderToggleButton = ({ isCollapsed, setIsCollapsed }) => {
4
+ return (_jsx(_Fragment, { children: _jsx("button", { onClick: () => setIsCollapsed(!isCollapsed), className: "flex w-full items-center justify-center p-2 text-gray-600 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-800 transition-colors", "aria-label": isCollapsed ? "Expand sidebar" : "Collapse sidebar", children: isCollapsed ? (_jsx("svg", { xmlns: "http://www.w3.org/2000/svg", className: "h-6 w-6", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: _jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M13 5l7 7-7 7M5 5l7 7-7 7" }) })) : (_jsx("svg", { xmlns: "http://www.w3.org/2000/svg", className: "h-6 w-6", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: _jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M11 19l-7-7 7-7m8 14l-7-7 7-7" }) })) }) }));
5
+ };
@@ -1,12 +1,13 @@
1
1
  import { type ReactNode } from "react";
2
2
  import { type StateCreator } from "zustand";
3
3
  import type { Renderable } from "../../lib/render";
4
+ import { DashSiderProps } from "../types";
4
5
  export type Dash5LayoutProps = {
5
6
  defaultAsideCollapsed?: boolean;
6
7
  navCollapsedSize?: number;
7
8
  isSideCollapsed?: boolean;
8
- siderComponent?: Renderable;
9
- postion?: "fullScreen" | "inline";
9
+ siderComponent?: Renderable<DashSiderProps>;
10
+ headerComponent?: Renderable<DashSiderProps>;
10
11
  };
11
12
  export interface Dash5LayoutState extends Dash5LayoutProps {
12
13
  _hasHydrated?: boolean;
@@ -10,7 +10,6 @@ export const createAppSlice = (set, get, init) => {
10
10
  isDev: false,
11
11
  isCollapsed: false,
12
12
  defaultLayout: [30, 70],
13
- postion: "fullScreen",
14
13
  ...init,
15
14
  setHasHydrated: (_hasHydrated) => set({ _hasHydrated }),
16
15
  setIsSideCollapsed: (isSideCollapsed) => {
@@ -2,22 +2,12 @@
2
2
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { cn } from "mtxuilib/lib/utils";
4
4
  import { useRef } from "react";
5
- import { Users2 } from "lucide-react";
6
- import { flexRender } from "../../lib/render";
7
- import { ScreenPanel } from "../../ui/mt/ScreenPanel";
8
5
  import { ResizableHandle, ResizablePanel, ResizablePanelGroup, } from "../../ui/resizable";
6
+ import { useDash } from "../DashLayoutProvider";
9
7
  import { Dash5LayoutProvider, useDash5Store, } from "./dash5.store";
10
- import { Header } from "./header";
11
- import { Nav } from "./nav";
12
- const childrenDashRouters = [
13
- {
14
- label: "dashboard",
15
- },
16
- { label: "home" },
17
- ];
8
+ import { DashSider } from "./DashSider";
18
9
  export function Dash5Layout(props) {
19
- const position = props.postion || "fullScreen";
20
- return (_jsx(Dash5LayoutProvider, { ...props, children: position === "fullScreen" ? (_jsx(ScreenPanel, { children: _jsx(DashLayoutInner, { children: props.children }) })) : (_jsx(DashLayoutInner, { children: props.children })) }));
10
+ return (_jsx(Dash5LayoutProvider, { ...props, children: _jsx(DashLayoutInner, { children: props.children }) }));
21
11
  }
22
12
  const DashLayoutInner = (props) => {
23
13
  const isSideCollapsed = useDash5Store((x) => x.isSideCollapsed);
@@ -26,6 +16,8 @@ const DashLayoutInner = (props) => {
26
16
  const setIsSideCollapsed = useDash5Store((x) => x.setIsSideCollapsed);
27
17
  const siderComponent = useDash5Store((x) => x.siderComponent);
28
18
  const navPanelRef = useRef(null);
19
+ const logo = useDash(x => x.config?.logo);
20
+ const siderNavMenus = useDash(x => x.config?.siderNavMenus);
29
21
  return (_jsxs(ResizablePanelGroup, { direction: "horizontal", onLayout: (sizes) => {
30
22
  document.cookie = `react-resizable-panels:layout=${JSON.stringify(sizes)}`;
31
23
  }, className: "h-full items-stretch", children: [_jsx(ResizablePanel, { ref: navPanelRef, defaultSize: defaultLayout[0], collapsedSize: navCollapsedSize, collapsible: true, minSize: 12, maxSize: 30, onCollapse: () => {
@@ -33,12 +25,5 @@ const DashLayoutInner = (props) => {
33
25
  }, onExpand: () => {
34
26
  setIsSideCollapsed(false);
35
27
  }, className: cn(isSideCollapsed &&
36
- "min-w-[50px] transition-all duration-300 ease-in-out", "hidden sm:flex sm:flex-col"), children: _jsxs(_Fragment, { children: [_jsx(Nav, { isCollapsed: isSideCollapsed || false, links: childrenDashRouters?.map((x) => {
37
- return {
38
- title: x.label || "no-title",
39
- label: x.label || "no-label",
40
- icon: Users2,
41
- variant: "ghost",
42
- };
43
- }) }), siderComponent && flexRender(siderComponent, {})] }) }), _jsx(ResizableHandle, { withHandle: true, className: "hidden md:flex" }), _jsx(ResizablePanel, { defaultSize: defaultLayout[1], minSize: 30, children: _jsx("div", { className: "bg-muted/40 flex min-h-screen w-full flex-col", children: _jsxs("div", { className: cn("flex min-h-dvh flex-col"), children: [_jsx(Header, {}), _jsx("main", { className: cn("flex h-full min-h-full flex-1 p-1 flex-col px-1"), children: _jsx("div", { className: "min-h-full w-full flex-1 flex flex-col", children: props.children }) }), _jsx("div", { className: "bg-slate-50" })] }) }) })] }));
28
+ "min-w-[60px] transition-all duration-300 ease-in-out", "hidden sm:flex sm:flex-col"), children: _jsx(_Fragment, { children: _jsx(DashSider, { isCollapsed: !!isSideCollapsed }) }) }), _jsx(ResizableHandle, { withHandle: true, className: "hidden md:flex" }), _jsx(ResizablePanel, { defaultSize: defaultLayout[1], minSize: 30, children: _jsx("div", { className: "bg-muted/40 flex min-h-screen w-full flex-col", children: _jsxs("div", { className: cn("flex min-h-dvh flex-col"), children: [_jsx("main", { className: cn("flex h-full min-h-full flex-1 p-1 flex-col px-1"), children: _jsx("div", { className: "min-h-full w-full flex-1 flex flex-col", children: props.children }) }), _jsx("div", { className: "bg-slate-50" })] }) }) })] }));
44
29
  };
@@ -0,0 +1,18 @@
1
+ export interface DashSiderProps {
2
+ isCollapsed?: boolean;
3
+ }
4
+ export interface DashHeaderProps {
5
+ hidden?: boolean;
6
+ }
7
+ export interface SiderNavItemProps {
8
+ title: string;
9
+ label?: string;
10
+ icon?: string;
11
+ variant?: "default" | "ghost";
12
+ url?: string;
13
+ }
14
+ export interface NavProps {
15
+ isCollapsed?: boolean;
16
+ isActive?: boolean;
17
+ items: SiderNavItemProps[];
18
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -1,5 +1,5 @@
1
1
  export declare function mergeRefs<T>(refs: Array<React.MutableRefObject<T> | React.LegacyRef<T>>): React.RefCallback<T>;
2
2
  export declare function getCookie(name: string): string | undefined;
3
3
  export declare function deleteAllCookies(): void;
4
- export declare function setCookie(name: string, value: any): void;
4
+ export declare function setCookie(name: string, value: any, path?: string, domain?: string): void;
5
5
  export declare function deleteCookie(name: string, path?: string, domain?: string): void;
@@ -29,8 +29,12 @@ export function deleteAllCookies() {
29
29
  document.cookie = `${name}=;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/`;
30
30
  }
31
31
  }
32
- export function setCookie(name, value) {
33
- document.cookie = `${name}=${value}`;
32
+ export function setCookie(name, value, path = "/", domain) {
33
+ let cookieString = `${name}=${value};path=${path}`;
34
+ if (domain) {
35
+ cookieString += `;domain=${domain}`;
36
+ }
37
+ document.cookie = cookieString;
34
38
  }
35
39
  export function deleteCookie(name, path = "/", domain) {
36
40
  let cookieString = `${name}=;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=${path}`;
@@ -1,11 +1,11 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useState } from "react";
3
- import { useMediaQuery } from "../../../hooks/use-media-query";
3
+ import { useIsDesktop } from "../../../hooks/use-media-query";
4
4
  import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, } from "../../dialog";
5
5
  import { Drawer, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerTitle, } from "../../drawer";
6
6
  export function MtDialog(props) {
7
7
  const [open, setOpen] = useState(props.open || false);
8
- const isDesktop = useMediaQuery("(min-width: 768px)");
8
+ const isDesktop = useIsDesktop();
9
9
  const handleOpenChange = (open) => {
10
10
  setOpen(open);
11
11
  props.onOpenChange?.(open);
@@ -4,8 +4,10 @@ declare const Select: React.FC<SelectPrimitive.SelectProps>;
4
4
  declare const SelectGroup: React.ForwardRefExoticComponent<SelectPrimitive.SelectGroupProps & React.RefAttributes<HTMLDivElement>>;
5
5
  declare const SelectValue: React.ForwardRefExoticComponent<SelectPrimitive.SelectValueProps & React.RefAttributes<HTMLSpanElement>>;
6
6
  declare const SelectTrigger: React.ForwardRefExoticComponent<Omit<SelectPrimitive.SelectTriggerProps & React.RefAttributes<HTMLButtonElement>, "ref"> & React.RefAttributes<HTMLButtonElement>>;
7
+ declare const SelectScrollUpButton: React.ForwardRefExoticComponent<Omit<SelectPrimitive.SelectScrollUpButtonProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
8
+ declare const SelectScrollDownButton: React.ForwardRefExoticComponent<Omit<SelectPrimitive.SelectScrollDownButtonProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
7
9
  declare const SelectContent: React.ForwardRefExoticComponent<Omit<SelectPrimitive.SelectContentProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
8
10
  declare const SelectLabel: React.ForwardRefExoticComponent<Omit<SelectPrimitive.SelectLabelProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
9
11
  declare const SelectItem: React.ForwardRefExoticComponent<Omit<SelectPrimitive.SelectItemProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
10
12
  declare const SelectSeparator: React.ForwardRefExoticComponent<Omit<SelectPrimitive.SelectSeparatorProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
11
- export { Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectSeparator, SelectTrigger, SelectValue };
13
+ export { Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue };
package/dist/ui/select.js CHANGED
@@ -1,22 +1,27 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { CaretSortIcon, CheckIcon } from "@radix-ui/react-icons";
4
3
  import * as SelectPrimitive from "@radix-ui/react-select";
4
+ import { Check, ChevronDown, ChevronUp } from "lucide-react";
5
5
  import * as React from "react";
6
6
  import { cn } from "../lib/utils";
7
7
  const Select = SelectPrimitive.Root;
8
8
  const SelectGroup = SelectPrimitive.Group;
9
9
  const SelectValue = SelectPrimitive.Value;
10
- const SelectTrigger = React.forwardRef(({ className, children, ...props }, ref) => (_jsxs(SelectPrimitive.Trigger, { ref: ref, className: cn("border-input ring-offset-background placeholder:text-muted-foreground focus:ring-ring flex h-9 w-full items-center justify-between rounded-md border bg-transparent px-3 py-2 text-sm shadow-sm focus:outline-none focus:ring-1 disabled:cursor-not-allowed disabled:opacity-50", className), ...props, children: [children, _jsx(SelectPrimitive.Icon, { asChild: true, children: _jsx(CaretSortIcon, { className: "h-4 w-4 opacity-50" }) })] })));
10
+ const SelectTrigger = React.forwardRef(({ className, children, ...props }, ref) => (_jsxs(SelectPrimitive.Trigger, { ref: ref, className: cn("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1", className), ...props, children: [children, _jsx(SelectPrimitive.Icon, { asChild: true, children: _jsx(ChevronDown, { className: "h-4 w-4 opacity-50" }) })] })));
11
11
  SelectTrigger.displayName = SelectPrimitive.Trigger.displayName;
12
- const SelectContent = React.forwardRef(({ className, children, position = "popper", ...props }, ref) => (_jsx(SelectPrimitive.Portal, { children: _jsx(SelectPrimitive.Content, { ref: ref, className: cn("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-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 relative z-50 min-w-32 overflow-hidden rounded-md border shadow-md", position === "popper" &&
13
- "data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1", className), position: position, ...props, children: _jsx(SelectPrimitive.Viewport, { className: cn("p-1", position === "popper" &&
14
- "h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"), children: children }) }) })));
12
+ const SelectScrollUpButton = React.forwardRef(({ className, ...props }, ref) => (_jsx(SelectPrimitive.ScrollUpButton, { ref: ref, className: cn("flex cursor-default items-center justify-center py-1", className), ...props, children: _jsx(ChevronUp, { className: "h-4 w-4" }) })));
13
+ SelectScrollUpButton.displayName = SelectPrimitive.ScrollUpButton.displayName;
14
+ const SelectScrollDownButton = React.forwardRef(({ className, ...props }, ref) => (_jsx(SelectPrimitive.ScrollDownButton, { ref: ref, className: cn("flex cursor-default items-center justify-center py-1", className), ...props, children: _jsx(ChevronDown, { className: "h-4 w-4" }) })));
15
+ SelectScrollDownButton.displayName =
16
+ SelectPrimitive.ScrollDownButton.displayName;
17
+ const SelectContent = React.forwardRef(({ className, children, position = "popper", ...props }, ref) => (_jsx(SelectPrimitive.Portal, { children: _jsxs(SelectPrimitive.Content, { ref: ref, className: cn("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-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", position === "popper" &&
18
+ "data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1", className), position: position, ...props, children: [_jsx(SelectScrollUpButton, {}), _jsx(SelectPrimitive.Viewport, { className: cn("p-1", position === "popper" &&
19
+ "h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"), children: children }), _jsx(SelectScrollDownButton, {})] }) })));
15
20
  SelectContent.displayName = SelectPrimitive.Content.displayName;
16
- const SelectLabel = React.forwardRef(({ className, ...props }, ref) => (_jsx(SelectPrimitive.Label, { ref: ref, className: cn("px-2 py-1.5 text-sm font-semibold", className), ...props })));
21
+ const SelectLabel = React.forwardRef(({ className, ...props }, ref) => (_jsx(SelectPrimitive.Label, { ref: ref, className: cn("py-1.5 pl-8 pr-2 text-sm font-semibold", className), ...props })));
17
22
  SelectLabel.displayName = SelectPrimitive.Label.displayName;
18
- const SelectItem = React.forwardRef(({ className, children, ...props }, ref) => (_jsxs(SelectPrimitive.Item, { ref: ref, className: cn("focus:bg-accent focus:text-accent-foreground relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50", className), ...props, children: [_jsx("span", { className: "absolute right-2 flex h-3.5 w-3.5 items-center justify-center", children: _jsx(SelectPrimitive.ItemIndicator, { children: _jsx(CheckIcon, { className: "h-4 w-4" }) }) }), _jsx(SelectPrimitive.ItemText, { children: children })] })));
23
+ const SelectItem = React.forwardRef(({ className, children, ...props }, ref) => (_jsxs(SelectPrimitive.Item, { ref: ref, className: cn("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50", className), ...props, children: [_jsx("span", { className: "absolute left-2 flex h-3.5 w-3.5 items-center justify-center", children: _jsx(SelectPrimitive.ItemIndicator, { children: _jsx(Check, { className: "h-4 w-4" }) }) }), _jsx(SelectPrimitive.ItemText, { children: children })] })));
19
24
  SelectItem.displayName = SelectPrimitive.Item.displayName;
20
- const SelectSeparator = React.forwardRef(({ className, ...props }, ref) => (_jsx(SelectPrimitive.Separator, { ref: ref, className: cn("bg-muted -mx-1 my-1 h-px", className), ...props })));
25
+ const SelectSeparator = React.forwardRef(({ className, ...props }, ref) => (_jsx(SelectPrimitive.Separator, { ref: ref, className: cn("-mx-1 my-1 h-px bg-muted", className), ...props })));
21
26
  SelectSeparator.displayName = SelectPrimitive.Separator.displayName;
22
- export { Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectSeparator, SelectTrigger, SelectValue };
27
+ export { Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mtxuilib",
3
3
  "private": false,
4
- "version": "0.1.296",
4
+ "version": "0.1.297",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -106,7 +106,7 @@
106
106
  "@radix-ui/react-progress": "^1.1.0",
107
107
  "@radix-ui/react-radio-group": "^1.2.0",
108
108
  "@radix-ui/react-scroll-area": "^1.1.0",
109
- "@radix-ui/react-select": "^1.2.2",
109
+ "@radix-ui/react-select": "^2.1.1",
110
110
  "@radix-ui/react-separator": "^1.1.0",
111
111
  "@radix-ui/react-slider": "^1.2.0",
112
112
  "@radix-ui/react-slot": "^1.1.0",
@@ -157,8 +157,8 @@
157
157
  "openai": "^4.55.5",
158
158
  "path-to-regexp": "^6.2.2",
159
159
  "react": "^19.0.0-beta-26f2496093-20240514",
160
- "react-dom": "^19.0.0-beta-26f2496093-20240514",
161
160
  "react-day-picker": "^8.10.1",
161
+ "react-dom": "^19.0.0-beta-26f2496093-20240514",
162
162
  "react-easy-infinite-scroll-hook": "^2.1.4",
163
163
  "react-error-boundary": "^4.0.13",
164
164
  "react-hook-form": "^7.53.0",
@@ -1 +0,0 @@
1
- export declare const Header: () => import("react/jsx-runtime").JSX.Element;
@@ -1,12 +0,0 @@
1
- import type { LucideIcon } from "lucide-react";
2
- interface NavProps {
3
- isCollapsed: boolean;
4
- links: {
5
- title: string;
6
- label?: string;
7
- icon: LucideIcon;
8
- variant: "default" | "ghost";
9
- }[];
10
- }
11
- export declare function Nav({ links, isCollapsed }: NavProps): import("react/jsx-runtime").JSX.Element;
12
- export {};
@@ -1,25 +0,0 @@
1
- "use client";
2
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
- import Link from "next/link";
4
- import { cn } from "../../lib/utils";
5
- import { buttonVariants } from "../../ui/button";
6
- import { MtButton } from "../../ui/mt/Button";
7
- import { Tooltip, TooltipContent, TooltipTrigger } from "../../ui/tooltip";
8
- import { useDash5Store } from "./dash5.store";
9
- export function Nav({ links, isCollapsed }) {
10
- return (_jsxs("div", { "data-collapsed": isCollapsed, className: "group flex flex-col gap-4 py-2 data-[collapsed=true]:py-2", children: [_jsx("nav", { className: "grid gap-1 px-2 group-[[data-collapsed=true]]:justify-center group-[[data-collapsed=true]]:px-2", children: links.map((link, index) => isCollapsed ? (_jsxs(Tooltip, { delayDuration: 0, children: [_jsx(TooltipTrigger, { asChild: true, children: _jsxs(Link, { href: "#", className: cn(buttonVariants({ variant: link.variant, size: "icon" }), "h-9 w-9", link.variant === "default" &&
11
- "dark:bg-muted dark:text-muted-foreground dark:hover:bg-muted dark:hover:text-white"), children: [_jsx(link.icon, { className: "h-4 w-4" }), _jsx("span", { className: "sr-only", children: link.title })] }) }), _jsxs(TooltipContent, { side: "right", className: "flex items-center gap-4", children: [link.title, link.label && (_jsx("span", { className: "ml-auto text-muted-foreground", children: link.label }))] })] }, index)) : (_jsxs(Link, { href: "#", className: cn(buttonVariants({ variant: link.variant, size: "sm" }), link.variant === "default" &&
12
- "dark:bg-muted dark:text-white dark:hover:bg-muted dark:hover:text-white", "justify-start"), children: [_jsx(link.icon, { className: "mr-2 h-4 w-4" }), link.title, link.label && (_jsx("span", { className: cn("ml-auto", link.variant === "default" &&
13
- "text-background dark:text-white"), children: link.label }))] }, index))) }), _jsxs("div", { className: "mt-auto pb-4", children: [_jsx(CollapseButton, {}), _jsx(Test1Button, {})] })] }));
14
- }
15
- const CollapseButton = () => {
16
- const isSideCollapsed = useDash5Store((x) => x.isSideCollapsed);
17
- const setIsSideCollapsed = useDash5Store((x) => x.setIsSideCollapsed);
18
- return (_jsx(_Fragment, { children: _jsx("button", { onClick: () => setIsSideCollapsed(!isSideCollapsed), className: "flex w-full items-center justify-center p-2 text-gray-600 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-800 transition-colors", "aria-label": isSideCollapsed ? "Expand sidebar" : "Collapse sidebar", children: isSideCollapsed ? (_jsx("svg", { xmlns: "http://www.w3.org/2000/svg", className: "h-6 w-6", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: _jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M13 5l7 7-7 7M5 5l7 7-7 7" }) })) : (_jsx("svg", { xmlns: "http://www.w3.org/2000/svg", className: "h-6 w-6", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: _jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M11 19l-7-7 7-7m8 14l-7-7 7-7" }) })) }) }));
19
- };
20
- const Test1Button = () => {
21
- const state = useDash5Store();
22
- return (_jsx(MtButton, { onClick: () => {
23
- console.log(state);
24
- }, children: "\u6D4B\u8BD51" }));
25
- };