UNPKG

@worktif/purei

Version:

Work TIF Material UI Theme Provider and Customization Suite for React applications with dark mode support and dynamic color schemes

102 lines 5.1 kB
"use strict"; /* * Business Source License 1.1 * * Copyright (C) 2025 Raman Marozau, raman@worktif.com * Use of this software is governed by the Business Source License included in the LICENSE file and at www.mariadb.com/bsl11. * * Change Date: Never * On the date above, in accordance with the Business Source License, use of this software will be governed by the open source license specified in the LICENSE file. * Additional Use Grant: Free for personal and non-commercial research use only. * * * SPDX-License-Identifier: BUSL-1.1 */ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || (function () { var ownKeys = function(o) { ownKeys = Object.getOwnPropertyNames || function (o) { var ar = []; for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; return ar; }; return ownKeys(o); }; return function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); __setModuleDefault(result, mod); return result; }; })(); Object.defineProperty(exports, "__esModule", { value: true }); exports.BaseLayout = void 0; const React = __importStar(require("react")); const react_1 = require("react"); const material_1 = require("@mui/material"); const context_1 = require("../../../context"); const ui_1 = require("../../ui"); const layout_worktif_1 = require("./layout-worktif/layout-worktif"); /** * BaseLayout is a functional React component that provides a consistent base-layout structure for the application. * * It acts as a wrapper component to house nested children components within a predefined base-layout format. The base-layout includes * elements such as notifications, a container, and a grid system to ensure responsive design and visual consistency. * * The component also uses a notification system, which dynamically renders based on the dialog state retrieved from the * DialogContext. * * Dependencies: * - Material-UI styles for theming and styling. * - DialogContext to manage and render dialog-based information dynamically. * - Notification component for rendering alerts or notices at the top level. * - WorkTifLayout to encapsulate the provided children components within a specific base-layout structure. * * Props: * @prop {React.ReactNode} children - The child components or elements to render inside the base-layout. * * Hooks utilized: * - `useContext(DialogContext)` to access dialog state (open, dialogComponent, and title). * - `useMemo` to memoize the notification component and prevent unnecessary re-renders. */ const BaseLayout = ({ children, sx = (theme) => ({}) }) => { const { open: dialogOpen, dialogComponent, title } = (0, react_1.useContext)(context_1.DialogContext); const memoizedNotification = (0, react_1.useMemo)(() => (React.createElement(ui_1.Notification, { whyDidYouRender: true, title: title, dialogComponent: dialogComponent !== null && dialogComponent !== void 0 ? dialogComponent : void 0 })), [dialogComponent, title]); return (React.createElement(material_1.Box, { sx: (theme) => (Object.assign({ display: 'flex', minHeight: '100vh', background: 'linear-gradient(to bottom right, #F8FBFF, #EFF3F9)' }, sx(theme))) }, memoizedNotification, React.createElement(material_1.Container, { sx: (theme) => ({ pl: '0px !important', pr: '0px !important', maxWidth: '100vw !important', }) }, React.createElement(material_1.Grid, { container: true, sx: { // background: 'linear-gradient(to bottom right, #F8FBFF, #EFF3F9)', maxWidth: '100vw', } }, React.createElement(material_1.Grid, { size: { xs: 12 }, sx: (theme) => ({ position: 'relative', minHeight: '100vh', width: '100%', // background: 'linear-gradient(to bottom right, #F8FBFF, #EFF3F9)', background: '#000', }) }, React.createElement(layout_worktif_1.WorkTifLayout, null, children)))))); }; exports.BaseLayout = BaseLayout; //# sourceMappingURL=index.js.map