@grafosoft/excel-validator 1.0.6 → 1.0.7

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.
@@ -28,7 +28,7 @@ const ExcelFile = ({ initData, fileContent, matrix, error, onFileSelected, onRes
28
28
  }
29
29
  return (bytes / KB).toFixed(2) + " KB";
30
30
  };
31
- return ((0, jsx_runtime_1.jsxs)("section", { className: "h-full bg-content1 p-4 border-r border-default-200", children: [(0, jsx_runtime_1.jsxs)("h2", { className: "text-xl font-semibold text-default-700", children: ["Importa ", initData.title] }), error ? ((0, jsx_runtime_1.jsx)(react_1.Alert, { color: "danger", title: error, className: "mt-3", radius: "sm", hideIconWrapper: true })) : isVisible ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(react_1.Alert, { radius: "sm", hideIconWrapper: true, hideIcon: true, isVisible: isVisible, className: "mt-4", variant: "bordered", onClose: handleReset, children: (0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-2 text-default-700", children: [(0, jsx_runtime_1.jsx)(tb_1.TbFile, { size: 28 }), " ", (0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col", children: [(0, jsx_runtime_1.jsx)("p", { className: "text-sm", children: fileContent === null || fileContent === void 0 ? void 0 : fileContent.name }), (0, jsx_runtime_1.jsx)("small", { className: "text-default-500", children: bytesFormat((_a = fileContent === null || fileContent === void 0 ? void 0 : fileContent.size) !== null && _a !== void 0 ? _a : 0) })] })] }) }), initData.type === "accounts" && ((0, jsx_runtime_1.jsxs)("div", { className: "mt-4 space-y-2", children: [(0, jsx_runtime_1.jsx)(react_1.Button, { className: "w-full border-1", color: "warning", variant: "bordered", radius: "sm", startContent: (0, jsx_runtime_1.jsx)(tb_1.TbFilter, { size: 18 }), onPress: onApplyStringEmptyFilter, isDisabled: !hasStringEmptyDuplicateErrors || isStringEmptyFilterApplied, children: isStringEmptyFilterApplied
31
+ return ((0, jsx_runtime_1.jsxs)("section", { className: "h-full bg-content1 p-4 border-r border-default-200", children: [(0, jsx_runtime_1.jsxs)("h2", { className: "text-xl font-semibold text-default-700", children: ["Importa ", initData.title] }), error ? ((0, jsx_runtime_1.jsx)(react_1.Alert, { color: "danger", title: error, className: "mt-3", radius: "sm", hideIconWrapper: true })) : isVisible ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(react_1.Alert, { radius: "sm", hideIconWrapper: true, hideIcon: true, isVisible: isVisible, className: "mt-4", variant: "bordered", onClose: handleReset, children: (0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-2 text-default-700", children: [(0, jsx_runtime_1.jsx)(tb_1.TbFile, { size: 28 }), " ", (0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col", children: [(0, jsx_runtime_1.jsx)("p", { className: "text-sm", children: fileContent === null || fileContent === void 0 ? void 0 : fileContent.name }), (0, jsx_runtime_1.jsx)("small", { className: "text-default-500", children: bytesFormat((_a = fileContent === null || fileContent === void 0 ? void 0 : fileContent.size) !== null && _a !== void 0 ? _a : 0) })] })] }) }), initData.type === "accounts" && ((0, jsx_runtime_1.jsxs)("div", { className: "mt-4 space-y-2 flex md:flex-col gap-5 md:gap-0", children: [(0, jsx_runtime_1.jsx)(react_1.Button, { className: "w-full border-1", color: "warning", variant: "bordered", radius: "sm", startContent: (0, jsx_runtime_1.jsx)(tb_1.TbFilter, { size: 18 }), onPress: onApplyStringEmptyFilter, isDisabled: !hasStringEmptyDuplicateErrors || isStringEmptyFilterApplied, children: isStringEmptyFilterApplied
32
32
  ? "Filtro aplicado"
33
33
  : "Filtrar cuentas ya registradas" }), (0, jsx_runtime_1.jsx)(react_1.Button, { className: "w-full border-1", color: "success", variant: "bordered", radius: "sm", startContent: (0, jsx_runtime_1.jsx)(tb_1.TbDownload, { size: 18 }), onPress: onDownloadFilteredExcel, isDisabled: !isStringEmptyFilterApplied || !hasStringEmptyDuplicateErrors, children: "Descargar Nuevo Excel" })] })), (0, jsx_runtime_1.jsx)(ExcelValidator_1.ExcelValidator, { initData: initData, fileContent: fileContent, matrix: matrix, validationErrors: validationErrors, onSelectError: onSelectError, hasBalanceDifference: hasBalanceDifference })] })) : ((0, jsx_runtime_1.jsx)("label", { className: "mt-4 flex cursor-pointer items-center justify-center rounded-lg border border-dashed border-default-300 px-4 py-8 text-sm font-medium text-default-600 transition hover:border-primary hover:text-primary", htmlFor: "excel-upload", children: (0, jsx_runtime_1.jsxs)("div", { className: "text-center flex flex-col items-center gap-2", children: [(0, jsx_runtime_1.jsx)(tb_1.TbUpload, { size: 28 }), (0, jsx_runtime_1.jsx)("p", { className: "font-semibold text-lg", children: "Seleccionar plantilla" }), (0, jsx_runtime_1.jsx)("small", { className: "text-default-500", children: "Adjunta un archivo .xlsx o .xls para validar y previsualizar." })] }) })), (0, jsx_runtime_1.jsx)("input", { id: "excel-upload", ref: inputRef, className: "hidden", type: "file", accept: ".xlsx,.xls", onChange: (event) => {
34
34
  void onFileSelected(event);
@@ -548,6 +548,27 @@ function ExcelLayout({ initData, jsonValidator, isBalances = false, }) {
548
548
  token: Date.now(),
549
549
  });
550
550
  };
551
+ const mainRef = (0, react_1.useRef)(null);
552
+ const [mainHeight, setMainHeight] = (0, react_1.useState)(null);
553
+ (0, react_1.useEffect)(() => {
554
+ const updateHeight = () => {
555
+ if (!mainRef.current) {
556
+ return;
557
+ }
558
+ const { top } = mainRef.current.getBoundingClientRect();
559
+ setMainHeight(Math.max(280, Math.floor(window.innerHeight - top - 8)));
560
+ };
561
+ updateHeight();
562
+ window.addEventListener("resize", updateHeight);
563
+ const observer = typeof ResizeObserver !== "undefined"
564
+ ? new ResizeObserver(updateHeight)
565
+ : null;
566
+ observer === null || observer === void 0 ? void 0 : observer.observe(document.body);
567
+ return () => {
568
+ window.removeEventListener("resize", updateHeight);
569
+ observer === null || observer === void 0 ? void 0 : observer.disconnect();
570
+ };
571
+ }, []);
551
572
  const handleReset = () => {
552
573
  setFileContent(undefined);
553
574
  setMatrix([]);
@@ -556,5 +577,5 @@ function ExcelLayout({ initData, jsonValidator, isBalances = false, }) {
556
577
  setFocusTarget(null);
557
578
  setIsStringEmptyFilterApplied(false);
558
579
  };
559
- return ((0, jsx_runtime_1.jsxs)("main", { className: "grid min-h-screen grid-cols-1 md:grid-cols-4", children: [(0, jsx_runtime_1.jsx)("div", { className: "space-y-4 md:col-span-1", children: (0, jsx_runtime_1.jsx)(ExcelFile_1.ExcelFile, { initData: initData, fileContent: fileContent, matrix: matrix, error: error, onFileSelected: handleFileSelected, onReset: handleReset, validationErrors: validationErrorsForPanel, onSelectError: handleSelectError, hasBalanceDifference: hasBalanceDifference, onApplyStringEmptyFilter: handleApplyStringEmptyFilter, onDownloadFilteredExcel: handleDownloadFilteredExcel, isStringEmptyFilterApplied: isStringEmptyFilterApplied, hasStringEmptyDuplicateErrors: hasStringEmptyDuplicateErrors }) }), (0, jsx_runtime_1.jsx)("div", { className: "md:col-span-3", children: (0, jsx_runtime_1.jsx)(ExcelPreview_1.ExcelPreview, { initData: initData, fileContent: fileContent, matrix: matrix, error: error, validationErrors: validationErrors, focusTarget: focusTarget, currentPage: currentPage, onPageChange: setCurrentPage, isBalances: isBalances, hiddenFilteredRowIndexes: isStringEmptyFilterApplied ? stringEmptyDuplicateRowIndexes : [] }) })] }));
580
+ return ((0, jsx_runtime_1.jsxs)("main", { ref: mainRef, style: mainHeight ? { height: `${mainHeight}px` } : undefined, className: "grid grid-cols-1 grid-rows-2 md:grid-rows-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 overflow-hidden", children: [(0, jsx_runtime_1.jsx)("div", { className: "space-y-4 col-span-1 order-2 ", children: (0, jsx_runtime_1.jsx)(ExcelFile_1.ExcelFile, { initData: initData, fileContent: fileContent, matrix: matrix, error: error, onFileSelected: handleFileSelected, onReset: handleReset, validationErrors: validationErrorsForPanel, onSelectError: handleSelectError, hasBalanceDifference: hasBalanceDifference, onApplyStringEmptyFilter: handleApplyStringEmptyFilter, onDownloadFilteredExcel: handleDownloadFilteredExcel, isStringEmptyFilterApplied: isStringEmptyFilterApplied, hasStringEmptyDuplicateErrors: hasStringEmptyDuplicateErrors }) }), (0, jsx_runtime_1.jsx)("div", { className: "col-span-1 lg:col-span-2 xl:col-span-3", children: (0, jsx_runtime_1.jsx)(ExcelPreview_1.ExcelPreview, { initData: initData, fileContent: fileContent, matrix: matrix, error: error, validationErrors: validationErrors, focusTarget: focusTarget, currentPage: currentPage, onPageChange: setCurrentPage, isBalances: isBalances, hiddenFilteredRowIndexes: isStringEmptyFilterApplied ? stringEmptyDuplicateRowIndexes : [] }) })] }));
560
581
  }
@@ -57,7 +57,7 @@ const ExcelPreview = ({ initData, fileContent, matrix, error, validationErrors,
57
57
  targetCell.focus();
58
58
  });
59
59
  }, [focusTarget, effectivePage]);
60
- return ((0, jsx_runtime_1.jsxs)("section", { className: "h-full bg-gray-50 dark:bg-content1 border-l border-default-200 px-4 py-2", children: [!fileContent ? ((0, jsx_runtime_1.jsx)(react_1.Alert, { color: "primary", title: `Al importar ${initData.title} verás una previsualización de su contenido.`, className: "my-3", radius: "sm", hideIconWrapper: true, variant: "faded" })) : null, fileContent && matrix.length === 0 && !error ? ((0, jsx_runtime_1.jsx)(react_1.Alert, { color: "danger", title: `No se encontraron datos en el archivo seleccionado.`, className: "my-3", radius: "sm", hideIconWrapper: true, variant: "faded" })) : null, fileContent && matrix.length > 0 ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { className: "mt-4 max-h-[85vh] max-w-full overflow-x-auto overflow-y-auto ", children: (0, jsx_runtime_1.jsxs)("table", { className: "min-w-max w-full text-sm", children: [(0, jsx_runtime_1.jsx)("thead", { className: "sticky top-0 bg-default-100", children: (0, jsx_runtime_1.jsx)("tr", { children: Array.from({ length: maxColumns }).map((_, columnIndex) => ((0, jsx_runtime_1.jsx)("th", { className: "border-x border-t border-default-200 p-3 font-semibold text-default-700", children: tableHeaders[columnIndex] ||
60
+ return ((0, jsx_runtime_1.jsxs)("section", { className: "h-full bg-gray-50 dark:bg-content1 border-l border-default-200 px-4 py-2 flex flex-col overflow-hidden", children: [!fileContent ? ((0, jsx_runtime_1.jsx)(react_1.Alert, { color: "primary", title: `Al importar ${initData.title} verás una previsualización de su contenido.`, className: "my-3 max-h-[70px]", radius: "sm", hideIconWrapper: true, variant: "faded" })) : null, fileContent && matrix.length === 0 && !error ? ((0, jsx_runtime_1.jsx)(react_1.Alert, { color: "danger", title: `No se encontraron datos en el archivo seleccionado.`, className: "my-3", radius: "sm", hideIconWrapper: true, variant: "faded" })) : null, fileContent && matrix.length > 0 ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { className: "mt-4 min-h-0 flex-1 max-w-full overflow-x-auto overflow-y-auto", children: (0, jsx_runtime_1.jsxs)("table", { className: "min-w-max w-full text-sm", children: [(0, jsx_runtime_1.jsx)("thead", { className: "sticky top-0 bg-default-100", children: (0, jsx_runtime_1.jsx)("tr", { children: Array.from({ length: maxColumns }).map((_, columnIndex) => ((0, jsx_runtime_1.jsx)("th", { className: "border-x border-t border-default-200 p-3 font-semibold text-default-700", children: tableHeaders[columnIndex] ||
61
61
  `Columna ${columnIndex + 1}` }, `header-${columnIndex}`))) }) }), (0, jsx_runtime_1.jsx)("tbody", { className: "bg-content1", children: dataRows.map((row, rowIndex) => ((0, jsx_runtime_1.jsx)("tr", { children: Array.from({ length: maxColumns }).map((_, columnIndex) => (() => {
62
62
  var _a, _b;
63
63
  const originalFilteredRowIndex = row.originalFilteredRowIndex;
@@ -59,7 +59,7 @@ const ExcelValidator = ({ initData, fileContent, matrix, validationErrors, onSel
59
59
  }, 3000);
60
60
  }
61
61
  };
62
- return ((0, jsx_runtime_1.jsxs)("section", { className: "mt-10 bg-content1 max-h-[calc(100vh-11.5rem)] overflow-y-auto pr-1", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex xl:flex-row lg:flex-col mb-3 justify-between items-center", children: [(0, jsx_runtime_1.jsx)("h2", { className: "text-xl font-semibold text-default-700", children: "Validaciones" }), (0, jsx_runtime_1.jsx)(react_1.Chip, { color: validationErrors.length > 0 ? "danger" : "success", variant: "solid", className: "text-white", startContent: validationErrors.length > 0 ? ((0, jsx_runtime_1.jsx)(tb_1.TbAlertCircle, { size: 20 })) : ((0, jsx_runtime_1.jsx)(tb_1.TbCheck, { size: 20 })), children: (0, jsx_runtime_1.jsxs)("p", { className: "pl-1", children: [validationErrors.length, " ", validationErrors.length === 1
62
+ return ((0, jsx_runtime_1.jsxs)("section", { className: "mt-5 bg-content1 max-h-[calc(100vh-11.5rem)] overflow-y-auto pr-1", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex xl:flex-row lg:flex-col mb-3 justify-between items-center", children: [(0, jsx_runtime_1.jsx)("h2", { className: "text-xl font-semibold text-default-700", children: "Validaciones" }), (0, jsx_runtime_1.jsx)(react_1.Chip, { color: validationErrors.length > 0 ? "danger" : "success", variant: "solid", className: "text-white", startContent: validationErrors.length > 0 ? ((0, jsx_runtime_1.jsx)(tb_1.TbAlertCircle, { size: 20 })) : ((0, jsx_runtime_1.jsx)(tb_1.TbCheck, { size: 20 })), children: (0, jsx_runtime_1.jsxs)("p", { className: "pl-1", children: [validationErrors.length, " ", validationErrors.length === 1
63
63
  ? "error encontrado"
64
64
  : "errores encontrados"] }) })] }), hasBalanceDifference ? ((0, jsx_runtime_1.jsx)(react_1.Alert, { color: "danger", title: "Hay diferencias en los saldos iniciales", variant: "faded", hideIcon: true, startContent: (0, jsx_runtime_1.jsx)(tb_1.TbAlertCircle, { size: 30 }), className: "mb-3" })) : null, validationErrors.length === 0 && !hasBalanceDifference ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(react_1.Alert, { color: "success", title: "Sin errores de validaci\u00F3n.", variant: "faded", hideIcon: true, startContent: (0, jsx_runtime_1.jsx)(tb_1.TbCircleCheck, { size: 30 }) }), (0, jsx_runtime_1.jsx)(react_1.Button, { color: "success", className: "mt-4 w-full", variant: "flat", endContent: (0, jsx_runtime_1.jsx)(tb_1.TbUpload, { size: 20 }), radius: "sm", isLoading: isUploadingTemplate, onPress: handleTXTFormat, children: "Enviar Plantilla" }), uploadMessage ? ((0, jsx_runtime_1.jsx)("p", { className: `mt-2 text-sm ${uploadMessage.type === "success"
65
65
  ? "text-success-600"
@@ -0,0 +1,6 @@
1
+ import { type FC } from "react";
2
+ interface Props {
3
+ showMobileMenu?: () => void;
4
+ }
5
+ export declare const NavbarUser: FC<Props>;
6
+ export {};
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NavbarUser = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const ri_1 = require("react-icons/ri");
6
+ const tb_1 = require("react-icons/tb");
7
+ const react_1 = require("@heroui/react");
8
+ const fa_1 = require("react-icons/fa");
9
+ const io_1 = require("react-icons/io");
10
+ const navigation_1 = require("next/navigation");
11
+ const ThemeSwitcher_1 = require("../ThemeSwitcher");
12
+ const NavbarUser = ({ showMobileMenu }) => {
13
+ const pathname = (0, navigation_1.usePathname)();
14
+ return ((0, jsx_runtime_1.jsxs)("div", { className: `flex w-full bg-[#04383f] px-4 py-3 justify-between lg:justify-end`, children: [pathname !== "/empresas" && pathname !== "/proveedores" && ((0, jsx_runtime_1.jsx)("button", { className: "lg:hidden", onClick: showMobileMenu, children: (0, jsx_runtime_1.jsxs)("div", { className: "flex", children: [(0, jsx_runtime_1.jsx)(tb_1.TbGridDots, { size: 25, className: "text-white" }), (0, jsx_runtime_1.jsx)("p", { className: "text-white font-semibold pl-2", children: "Menu" })] }) })), (0, jsx_runtime_1.jsxs)("div", { className: "flex items-center", children: [(0, jsx_runtime_1.jsx)(ThemeSwitcher_1.ThemeSwitcher, {}), (0, jsx_runtime_1.jsx)(tb_1.TbBellFilled, { size: 20, className: "cursor-pointer mx-3", style: { color: "white" } }), (0, jsx_runtime_1.jsxs)(react_1.Popover, { placement: "bottom", showArrow: true, children: [(0, jsx_runtime_1.jsx)(react_1.PopoverTrigger, { children: (0, jsx_runtime_1.jsx)("button", { className: "outline-none", children: (0, jsx_runtime_1.jsx)(tb_1.TbHelpSquareRoundedFilled, { size: 20, className: "cursor-pointer mx-3", style: { color: "white" } }) }) }), (0, jsx_runtime_1.jsx)(react_1.PopoverContent, { children: (0, jsx_runtime_1.jsxs)("div", { className: "px-2 py-3", children: [(0, jsx_runtime_1.jsx)(react_1.Link, { isExternal: true, href: "https://api.whatsapp.com/send?phone=573142441243", children: (0, jsx_runtime_1.jsxs)("div", { className: "text-small font-medium flex items-center pb-3 gap-2", children: [(0, jsx_runtime_1.jsx)(io_1.IoLogoWhatsapp, { size: 20, className: "text-[#25d366]" }), " ", "Com\u00FAnicate al WhatsApp"] }) }), (0, jsx_runtime_1.jsx)(react_1.Divider, {}), (0, jsx_runtime_1.jsx)(react_1.Link, { isExternal: true, href: "mailto:contacto@grafosoft.com", children: (0, jsx_runtime_1.jsxs)("div", { className: "text-small font-medium flex items-center py-3 gap-2", children: [(0, jsx_runtime_1.jsx)(tb_1.TbMailFilled, { size: 20, className: "text-[#f31260]" }), " ", "contacto@grafosoft.com"] }) }), (0, jsx_runtime_1.jsx)(react_1.Divider, {}), (0, jsx_runtime_1.jsx)(react_1.Link, { isExternal: true, href: "https://bilidox.com/contacto/", children: (0, jsx_runtime_1.jsxs)("div", { className: "text-small font-medium flex items-center py-3 gap-2", children: [(0, jsx_runtime_1.jsx)(fa_1.FaGlobe, { size: 20, className: "text-[#006FEE]" }), " P\u00E1gina de contacto"] }) }), (0, jsx_runtime_1.jsx)(react_1.Divider, {}), (0, jsx_runtime_1.jsx)(react_1.Link, { isExternal: true, href: "https://grafosoft.atlassian.net/wiki/spaces/GUB", children: (0, jsx_runtime_1.jsxs)("div", { className: "text-small font-medium flex items-center pt-3 gap-2", children: [(0, jsx_runtime_1.jsx)(ri_1.RiBookMarkFill, { size: 20, className: "text-purple-600" }), " Guia BILIDOX"] }) })] }) })] }), (0, jsx_runtime_1.jsx)(tb_1.TbSettingsFilled, { size: 20, className: "cursor-pointer mx-3", style: { color: "white" } }), (0, jsx_runtime_1.jsx)(tb_1.TbLogout, { size: 20, className: "cursor-pointer mx-5", color: "#60941a" })] })] }));
15
+ };
16
+ exports.NavbarUser = NavbarUser;
@@ -0,0 +1,2 @@
1
+ import { FC } from "react";
2
+ export declare const NavigationPage: FC;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NavigationPage = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = require("@heroui/react");
6
+ const navigation_1 = require("next/navigation");
7
+ const NavigationPage = () => {
8
+ const pathName = (0, navigation_1.usePathname)();
9
+ const router = (0, navigation_1.useRouter)();
10
+ const newArrayPath = pathName.split("/").filter((element) => element !== "");
11
+ const goToBreadcrumb = (index) => {
12
+ const target = `/${newArrayPath.slice(0, index + 1).join("/")}`;
13
+ router.push(target);
14
+ };
15
+ return ((0, jsx_runtime_1.jsx)(react_1.Breadcrumbs, { size: "lg", className: "pt-5 pl-5", children: newArrayPath.map((element, index) => ((0, jsx_runtime_1.jsx)(react_1.BreadcrumbItem, { onPress: () => {
16
+ goToBreadcrumb(index);
17
+ }, className: "capitalize", children: element }, index))) }));
18
+ };
19
+ exports.NavigationPage = NavigationPage;
@@ -0,0 +1,7 @@
1
+ import { type FC, type ReactNode } from "react";
2
+ interface Props {
3
+ children: ReactNode;
4
+ isError?: boolean;
5
+ }
6
+ export declare const DashboardLayout: FC<Props>;
7
+ export {};
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DashboardLayout = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = require("react");
6
+ const Sidebar_1 = require("./Sidebar");
7
+ const tb_1 = require("react-icons/tb");
8
+ const navigation_1 = require("next/navigation");
9
+ const Sidebar_2 = require("./Sidebar");
10
+ const NavbarUser_1 = require("../navbar/NavbarUser");
11
+ const DashboardLayout = ({ children, isError = false }) => {
12
+ const pathname = (0, navigation_1.usePathname)();
13
+ const [sideBarMobile, setSideBarMobile] = (0, react_1.useState)(false);
14
+ const companyId = "";
15
+ const [expanded, setExpanded] = (0, react_1.useState)(true);
16
+ return ((0, jsx_runtime_1.jsx)(Sidebar_2.SidebarContext.Provider, { value: expanded, children: (0, jsx_runtime_1.jsxs)("div", { className: "flex", children: [(0, jsx_runtime_1.jsxs)(Sidebar_1.Sidebar, { openMenu: sideBarMobile, setOpenMenu: setSideBarMobile, companyId: companyId, expanded: expanded, setExpanded: setExpanded, children: [(0, jsx_runtime_1.jsx)(Sidebar_1.SidebarItem, { icon: (0, jsx_runtime_1.jsx)(tb_1.TbBuilding, { size: 25 }), text: "Ver Empresa", urlPath: `/empresa/${companyId}`, active: pathname.includes("/empresa") }), (0, jsx_runtime_1.jsx)(Sidebar_1.SidebarItem, { icon: (0, jsx_runtime_1.jsx)(tb_1.TbFileInvoice, { size: 25 }), text: "Documentos", urlPath: `/documentos`, active: pathname.includes("/documento") }), (0, jsx_runtime_1.jsx)(Sidebar_1.SidebarItem, { icon: (0, jsx_runtime_1.jsx)(tb_1.TbLayoutCollage, { size: 25 }), text: "Certificados", urlPath: `/certificados`, active: pathname.includes("/certificado") }), (0, jsx_runtime_1.jsx)(Sidebar_1.SidebarItem, { icon: (0, jsx_runtime_1.jsx)(tb_1.TbInbox, { size: 25 }), text: "Softwares", urlPath: `/softwares`, active: pathname.includes("/software") }), (0, jsx_runtime_1.jsx)(Sidebar_1.SidebarItem, { icon: (0, jsx_runtime_1.jsx)(tb_1.TbFileDigit, { size: 25 }), text: "Numeraciones", urlPath: `/numeraciones`, active: pathname.includes("/numeracion") }), (0, jsx_runtime_1.jsx)(Sidebar_1.SidebarItem, { icon: (0, jsx_runtime_1.jsx)(tb_1.TbSourceCode, { size: 25 }), text: "M\u00F3dulos", urlPath: `/modulos`, active: pathname.includes("/modulos") ||
17
+ pathname.includes("/facturas-excel") }), (0, jsx_runtime_1.jsx)(Sidebar_1.SidebarItem, { icon: (0, jsx_runtime_1.jsx)(tb_1.TbCalendarDollar, { size: 25 }), text: "Ordenes de Compra", urlPath: `/ordenes`, active: pathname.includes("/orden") }), (0, jsx_runtime_1.jsx)(Sidebar_1.SidebarItem, { icon: (0, jsx_runtime_1.jsx)(tb_1.TbUsers, { size: 25 }), text: "Usuarios", urlPath: `/usuarios`, active: pathname.includes("/usuario") })] }), (0, jsx_runtime_1.jsxs)("div", { className: "w-full", children: [(0, jsx_runtime_1.jsx)(NavbarUser_1.NavbarUser, { showMobileMenu: () => {
18
+ setSideBarMobile((prev) => !prev);
19
+ } }), isError ? ((0, jsx_runtime_1.jsx)("div", { children: children })) : ((0, jsx_runtime_1.jsx)("div", { className: `transition-all duration-300 ease-in-out ${expanded ? "lg:ml-[250px]" : "lg:pl-[68px]"}`, children: children }))] })] }) }));
20
+ };
21
+ exports.DashboardLayout = DashboardLayout;
@@ -0,0 +1,21 @@
1
+ import { type FC, type ReactNode } from "react";
2
+ export declare const SidebarContext: import("react").Context<boolean>;
3
+ interface Props {
4
+ children: ReactNode;
5
+ openMenu: boolean;
6
+ setOpenMenu: (openMenu: boolean) => void;
7
+ companyId: string;
8
+ expanded: boolean;
9
+ setExpanded: React.Dispatch<React.SetStateAction<boolean>>;
10
+ }
11
+ export declare const Sidebar: FC<Props>;
12
+ interface SidebarItemProps {
13
+ icon: ReactNode;
14
+ text: string;
15
+ active?: boolean;
16
+ dropdown?: boolean;
17
+ sidebarList?: React.JSX.Element[];
18
+ urlPath?: string;
19
+ }
20
+ export declare const SidebarItem: FC<SidebarItemProps>;
21
+ export {};
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SidebarItem = exports.Sidebar = exports.SidebarContext = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = require("@heroui/react");
6
+ const react_2 = require("react");
7
+ const tb_1 = require("react-icons/tb");
8
+ const cg_1 = require("react-icons/cg");
9
+ const fa_1 = require("react-icons/fa");
10
+ const navigation_1 = require("next/navigation");
11
+ exports.SidebarContext = (0, react_2.createContext)(false);
12
+ const Sidebar = ({ children, openMenu, setOpenMenu, expanded, setExpanded, }) => {
13
+ var _a, _b;
14
+ const [companyInfo] = (0, react_2.useState)({
15
+ imageUrl: "",
16
+ name: "",
17
+ email: "",
18
+ });
19
+ const ref = (0, react_2.useRef)(null);
20
+ (0, react_2.useEffect)(() => {
21
+ function handleClickOutside(e) {
22
+ if (ref.current && !ref.current.contains(e.target)) {
23
+ setOpenMenu(false);
24
+ }
25
+ }
26
+ document.addEventListener("mousedown", handleClickOutside);
27
+ return () => {
28
+ document.removeEventListener("mousedown", handleClickOutside);
29
+ };
30
+ }, [ref, setOpenMenu]);
31
+ return ((0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)("aside", { className: `flex flex-col justify-between
32
+ bg-white shadow-2xl lg:shadow-sm lg:h-screen dark:bg-black
33
+ lg:dark:bg-black top-0 fixed h-full transition-transform
34
+ .3s ease-in-out lg:-translate-x-0 ${!openMenu ? "-translate-x-full" : ""}`, style: { maxWidth: "250px", zIndex: "50" }, ref: ref, children: (0, jsx_runtime_1.jsxs)("nav", { className: "h-full flex flex-col dark:border-none", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex p-4 pb-2 justify-between items-center", children: [expanded ? (0, jsx_runtime_1.jsx)(fa_1.FaDownload, { size: 50 }) : (0, jsx_runtime_1.jsx)("div", {}), (0, jsx_runtime_1.jsx)("button", { onClick: () => {
35
+ setExpanded((curr) => !curr);
36
+ }, className: "p-1.5 rounded-lg bg-gray-50 dark:bg-transparent bg-green-50 text-green-800", children: expanded ? ((0, jsx_runtime_1.jsx)(cg_1.CgPushChevronLeft, { size: 20 })) : ((0, jsx_runtime_1.jsx)(cg_1.CgPushChevronRight, { size: 20 })) })] }), (0, jsx_runtime_1.jsx)("ul", { className: "flex-1 px-3", children: children }), (0, jsx_runtime_1.jsxs)("div", { className: "cursos-pointer border-t dark:border-none flex p-3", children: [(0, jsx_runtime_1.jsx)(react_1.Avatar, { showFallback: true, fallback: (0, jsx_runtime_1.jsx)(tb_1.TbBuilding, { size: 25 }), size: "md", radius: "sm", src: companyInfo.imageUrl, classNames: {
37
+ base: companyInfo.imageUrl ? "bg-transparent" : "",
38
+ } }), (0, jsx_runtime_1.jsx)("div", { className: `
39
+ flex justify-between items-center
40
+ overflow-hidden transition-all ${expanded ? "w-52 ml-3" : "w-0"}
41
+ `, children: (0, jsx_runtime_1.jsxs)("div", { className: "leading-4", children: [(0, jsx_runtime_1.jsx)("h4", { className: "font-medium", children: (_a = companyInfo.name) !== null && _a !== void 0 ? _a : "Empresa" }), (0, jsx_runtime_1.jsx)("span", { className: "text-xs text-gray-400", children: (_b = companyInfo.email) !== null && _b !== void 0 ? _b : "correo@empresa.com" })] }) })] })] }) }) }));
42
+ };
43
+ exports.Sidebar = Sidebar;
44
+ const SidebarItem = ({ icon, text, active, dropdown, sidebarList, urlPath = "/", }) => {
45
+ const expanded = (0, react_2.useContext)(exports.SidebarContext);
46
+ const router = (0, navigation_1.useRouter)();
47
+ const children = ((0, jsx_runtime_1.jsxs)("li", { className: `
48
+ relative flex items-center py-2 px-3 my-1
49
+ font-medium rounded-md cursor-pointer
50
+ transition-colors group
51
+ ${active
52
+ ? "bg-gradient-to-tr from-green-200 to-green-100 text-green-800"
53
+ : "hover:bg-green-50 hover:text-green-800"}
54
+ `, onClick: async () => {
55
+ var _a;
56
+ const urlApikey = urlPath.replace("$apikey", (_a = localStorage.getItem("apikey")) !== null && _a !== void 0 ? _a : "");
57
+ if (!dropdown) {
58
+ router.push(urlApikey);
59
+ }
60
+ }, children: [(0, jsx_runtime_1.jsx)("div", { className: "", children: icon }), (0, jsx_runtime_1.jsx)("span", { className: `font-normal text-md overflow-hidden transition-all ${expanded ? "w-52 ml-3" : "w-0"}`, children: text }), !expanded && ((0, jsx_runtime_1.jsx)("div", { className: `
61
+ absolute left-full rounded-md px-2 py-1 ml-6
62
+ bg-green-100 text-green-800 text-sm
63
+ invisible opacity-20 -translate-x-3 transition-all
64
+ group-hover:visible group-hover:opacity-100 group-hover:translate-x-0
65
+ `, children: text }))] }));
66
+ return dropdown && expanded ? ((0, jsx_runtime_1.jsx)(react_1.Accordion, { className: "px-0", isCompact: true, children: (0, jsx_runtime_1.jsx)(react_1.AccordionItem, { "aria-label": text, isCompact: true, title: text, startContent: icon, className: "py-2 px-3", children: sidebarList }) })) : dropdown && !expanded ? ((0, jsx_runtime_1.jsxs)(react_1.Popover, { placement: "right", showArrow: true, offset: 25, children: [(0, jsx_runtime_1.jsx)(react_1.PopoverTrigger, { children: children }), (0, jsx_runtime_1.jsx)(react_1.PopoverContent, { children: (0, jsx_runtime_1.jsx)("div", { className: "px-1 py-2", children: sidebarList }) })] })) : (children);
67
+ };
68
+ exports.SidebarItem = SidebarItem;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grafosoft/excel-validator",
3
- "version": "1.0.6",
3
+ "version": "1.0.7",
4
4
  "description": "React component to validate Excel files against configurable JSON rules.",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",