mtxuilib 0.1.260 → 0.1.261
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.
|
@@ -6,13 +6,13 @@ export type Dash5LayoutProps = {
|
|
|
6
6
|
isSideCollapsed?: boolean;
|
|
7
7
|
siderComponent?: Renderable;
|
|
8
8
|
postion?: "fullScreen" | "inline";
|
|
9
|
-
setSiderComponent: (siderComponent: Renderable) => void;
|
|
10
9
|
};
|
|
11
10
|
export interface Dash5LayoutState extends Dash5LayoutProps {
|
|
12
11
|
_hasHydrated?: boolean;
|
|
13
12
|
setHasHydrated: (_hasHydrated: boolean) => void;
|
|
14
13
|
defaultLayout: number[];
|
|
15
14
|
setIsSideCollapsed: (isSideCollapsed: boolean) => void;
|
|
15
|
+
setSiderComponent: (siderComponent: Renderable) => void;
|
|
16
16
|
}
|
|
17
17
|
export declare const createAppSlice: StateCreator<Dash5LayoutState, [
|
|
18
18
|
], [
|
|
@@ -13,7 +13,10 @@ export const createAppSlice = (set, get, init) => {
|
|
|
13
13
|
postion: "fullScreen",
|
|
14
14
|
...init,
|
|
15
15
|
setHasHydrated: (_hasHydrated) => set({ _hasHydrated }),
|
|
16
|
-
setIsSideCollapsed: (isSideCollapsed) =>
|
|
16
|
+
setIsSideCollapsed: (isSideCollapsed) => {
|
|
17
|
+
console.log("isSideCollapsed", isSideCollapsed);
|
|
18
|
+
set({ isSideCollapsed });
|
|
19
|
+
},
|
|
17
20
|
setSiderComponent: (siderComponent) => set({ siderComponent }),
|
|
18
21
|
};
|
|
19
22
|
};
|
|
@@ -36,11 +39,10 @@ const createMtAppStore = (initProps) => {
|
|
|
36
39
|
return ![
|
|
37
40
|
"cookieStr",
|
|
38
41
|
"children",
|
|
39
|
-
"openFab",
|
|
40
|
-
"userInfo",
|
|
41
42
|
"_hasHydrated",
|
|
42
43
|
"socket",
|
|
43
44
|
"session",
|
|
45
|
+
"siderComponent",
|
|
44
46
|
].includes(key);
|
|
45
47
|
}));
|
|
46
48
|
},
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
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
5
|
import { Users2 } from "lucide-react";
|
|
6
|
+
import { flexRender } from "../../lib/render";
|
|
6
7
|
import { ScreenPanel } from "../../ui/mt/ScreenPanel";
|
|
7
8
|
import { ResizableHandle, ResizablePanel, ResizablePanelGroup, } from "../../ui/resizable";
|
|
8
9
|
import { Dash5LayoutProvider, useDash5Store, } from "./dash5.store";
|
|
@@ -23,20 +24,21 @@ const DashLayoutInner = (props) => {
|
|
|
23
24
|
const defaultLayout = useDash5Store((x) => x.defaultLayout);
|
|
24
25
|
const navCollapsedSize = useDash5Store((x) => x.navCollapsedSize);
|
|
25
26
|
const setIsSideCollapsed = useDash5Store((x) => x.setIsSideCollapsed);
|
|
27
|
+
const siderComponent = useDash5Store((x) => x.siderComponent);
|
|
26
28
|
const navPanelRef = useRef(null);
|
|
27
29
|
return (_jsxs(ResizablePanelGroup, { direction: "horizontal", onLayout: (sizes) => {
|
|
28
30
|
document.cookie = `react-resizable-panels:layout=${JSON.stringify(sizes)}`;
|
|
29
|
-
}, className: "h-full
|
|
31
|
+
}, className: "h-full items-stretch", children: [_jsx(ResizablePanel, { ref: navPanelRef, defaultSize: defaultLayout[0], collapsedSize: navCollapsedSize, collapsible: true, minSize: 12, maxSize: 30, onCollapse: () => {
|
|
30
32
|
setIsSideCollapsed(true);
|
|
31
33
|
}, onExpand: () => {
|
|
32
34
|
setIsSideCollapsed(false);
|
|
33
35
|
}, className: cn(isSideCollapsed &&
|
|
34
|
-
"min-w-[50px] transition-all duration-300 ease-in-out", "hidden sm:flex sm:flex-col"), children: _jsx(Nav, { isCollapsed: isSideCollapsed || false, links: childrenDashRouters?.map((x) => {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
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" })] }) }) })] }));
|
|
42
44
|
};
|
|
@@ -7,8 +7,6 @@ import { MtButton } from "../../ui/mt/Button";
|
|
|
7
7
|
import { Tooltip, TooltipContent, TooltipTrigger } from "../../ui/tooltip";
|
|
8
8
|
import { useDash5Store } from "./dash5.store";
|
|
9
9
|
export function Nav({ links, isCollapsed }) {
|
|
10
|
-
const isSideCollapsed = useDash5Store((x) => x.isSideCollapsed);
|
|
11
|
-
const setIsSideCollapsed = useDash5Store((x) => x.setIsSideCollapsed);
|
|
12
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" &&
|
|
13
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" &&
|
|
14
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" &&
|