mtxuilib 0.1.260 → 0.1.262

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.
@@ -1,3 +1,4 @@
1
+ import { type ReactNode } from "react";
1
2
  import { type StateCreator } from "zustand";
2
3
  import type { Renderable } from "../../lib/render";
3
4
  export type Dash5LayoutProps = {
@@ -6,13 +7,13 @@ export type Dash5LayoutProps = {
6
7
  isSideCollapsed?: boolean;
7
8
  siderComponent?: Renderable;
8
9
  postion?: "fullScreen" | "inline";
9
- setSiderComponent: (siderComponent: Renderable) => void;
10
10
  };
11
11
  export interface Dash5LayoutState extends Dash5LayoutProps {
12
12
  _hasHydrated?: boolean;
13
13
  setHasHydrated: (_hasHydrated: boolean) => void;
14
14
  defaultLayout: number[];
15
15
  setIsSideCollapsed: (isSideCollapsed: boolean) => void;
16
+ setSiderComponent: (siderComponent: ReactNode) => void;
16
17
  }
17
18
  export declare const createAppSlice: StateCreator<Dash5LayoutState, [
18
19
  ], [
@@ -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) => set({ 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 max-h-[940px] items-stretch", children: [_jsx(ResizablePanel, { ref: navPanelRef, defaultSize: defaultLayout[0], collapsedSize: navCollapsedSize, collapsible: true, minSize: 12, maxSize: 20, onCollapse: () => {
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
- return {
36
- title: x.label || "no-title",
37
- label: x.label || "no-label",
38
- icon: Users2,
39
- variant: "ghost",
40
- };
41
- }) }) }), _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("div", { className: "flex p-1", children: _jsx("main", { className: cn("flex h-full min-h-full flex-1", "flex-col px-1"), children: props.children }) }), _jsx("div", { className: "bg-slate-50" })] }) }) })] }));
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" &&
@@ -0,0 +1,9 @@
1
+ import { type ComponentProps } from "react";
2
+ import { Dialog } from "../../dialog";
3
+ interface MtDialogProps extends ComponentProps<typeof Dialog> {
4
+ title?: React.ReactNode;
5
+ description?: React.ReactNode;
6
+ actions?: React.ReactNode;
7
+ }
8
+ export declare function MtDialog(props: React.PropsWithChildren<MtDialogProps>): import("react/jsx-runtime").JSX.Element;
9
+ export {};
@@ -0,0 +1,17 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useState } from "react";
3
+ import { useMediaQuery } from "../../../hooks/use-media-query";
4
+ import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, } from "../../dialog";
5
+ import { Drawer, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerTitle, } from "../../drawer";
6
+ export function MtDialog(props) {
7
+ const [open, setOpen] = useState(props.open || false);
8
+ const isDesktop = useMediaQuery("(min-width: 768px)");
9
+ const handleOpenChange = (open) => {
10
+ setOpen(open);
11
+ props.onOpenChange?.(open);
12
+ };
13
+ if (isDesktop) {
14
+ return (_jsx(Dialog, { open: open, onOpenChange: handleOpenChange, children: _jsxs(DialogContent, { className: "sm:max-w-[425px]", children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { children: props.title }), props.description && (_jsx(DialogDescription, { children: props.description }))] }), props.children, props.actions && _jsx(DialogFooter, { children: props.actions })] }) }));
15
+ }
16
+ return (_jsx(Drawer, { open: open, onOpenChange: handleOpenChange, children: _jsxs(DrawerContent, { children: [_jsxs(DrawerHeader, { className: "text-left", children: [_jsx(DrawerTitle, { children: props.title }), props.description && (_jsx(DrawerDescription, { children: props.description }))] }), props.children, props.actions && (_jsx(DrawerFooter, { className: "pt-2", children: props.actions }))] }) }));
17
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mtxuilib",
3
3
  "private": false,
4
- "version": "0.1.260",
4
+ "version": "0.1.262",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },