@wener/console
Version:
Base console UI toolkit
30 lines (29 loc) • 984 B
JavaScript
import React from "react";
import { Outlet } from "react-router-dom";
import { z } from "zod";
import { ExpandableSideMenuLayout } from "../../web/index.js";
import { useUserPreferenceState } from "../hooks/index.js";
const ModuleLayoutState = z.object({
expanded: z.boolean().optional().default(true)
});
function useModuleLayoutState({ path }) {
return useUserPreferenceState({
key: `ModuleLayoutState.${path}`,
schema: ModuleLayoutState
});
}
export const ModuleMainLayout = ({ children = /*#__PURE__*/ React.createElement(Outlet, null), path = "default", ...props }) => {
const [{ expanded }, update] = useModuleLayoutState({
path
});
return /*#__PURE__*/ React.createElement(ExpandableSideMenuLayout, {
expanded: expanded,
onExpandedChange: (next) => {
update({
expanded: next
});
},
...props
}, children);
};
//# sourceMappingURL=ModuleMainLayout.js.map