@zauru-sdk/components 1.0.109 → 1.0.111

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.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,22 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [1.0.111](https://github.com/intuitiva/zauru-typescript-sdk/compare/v1.0.110...v1.0.111) (2024-09-19)
7
+
8
+ **Note:** Version bump only for package @zauru-sdk/components
9
+
10
+
11
+
12
+
13
+
14
+ ## [1.0.110](https://github.com/intuitiva/zauru-typescript-sdk/compare/v1.0.109...v1.0.110) (2024-09-18)
15
+
16
+ **Note:** Version bump only for package @zauru-sdk/components
17
+
18
+
19
+
20
+
21
+
6
22
  ## [1.0.109](https://github.com/intuitiva/zauru-typescript-sdk/compare/v1.0.108...v1.0.109) (2024-09-18)
7
23
 
8
24
  **Note:** Version bump only for package @zauru-sdk/components
@@ -11,6 +11,7 @@ type Props = {
11
11
  className?: string;
12
12
  disabled?: boolean;
13
13
  enableFormErrorsValidation?: boolean;
14
+ enableFormErrorsDescriptions?: boolean;
14
15
  };
15
16
  export declare const Button: (props: Props) => import("react/jsx-runtime").JSX.Element;
16
17
  export {};
@@ -1,2 +1,2 @@
1
1
  import type { NavBarProps } from "./NavBar.types.js";
2
- export declare const NavBar: ({ title, loggedIn, items, selectedColor, }: NavBarProps) => import("react/jsx-runtime").JSX.Element;
2
+ export declare const NavBar: ({ title, loggedIn, items, selectedColor, version, }: NavBarProps) => import("react/jsx-runtime").JSX.Element;
@@ -12,6 +12,7 @@ export type NavBarProps = {
12
12
  items: Array<NavBarItemsSchema>;
13
13
  selectedColor: "pink" | "purple" | "slate" | "green" | "yellow" | "red" | "sky";
14
14
  LinkComponent?: any;
15
+ version?: string;
15
16
  };
16
17
  export type NavBarStateProps = {
17
18
  NavBarOpen: boolean;
@@ -41,10 +42,3 @@ export type EntityProps = {
41
42
  color: ColorInterface;
42
43
  options: any[];
43
44
  };
44
- export type DropDownLinkButtonType = {
45
- text: string;
46
- path: string;
47
- icon?: any;
48
- buttonHover?: string;
49
- LinkComponent?: any;
50
- };
@@ -1,5 +1,4 @@
1
1
  import type { TableProps } from "react-data-table-component";
2
- import { ExpandableRowsComponent } from "react-data-table-component/dist/DataTable/types.js";
3
2
  type Props = TableProps<any> & {
4
3
  columns: any;
5
4
  conditionalRowStyles?: any;
@@ -14,10 +13,6 @@ type Props = TableProps<any> & {
14
13
  search?: {
15
14
  placeholderSearch?: string;
16
15
  };
17
- expandable?: {
18
- expandableRowExpanded?: (row: any) => boolean;
19
- expandableRowsComponent?: ExpandableRowsComponent<any>;
20
- };
21
16
  theme?: "solarized" | "subTable";
22
17
  className?: string;
23
18
  };
@@ -2,10 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Button = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
- const WithTooltip_js_1 = require("../WithTooltip/WithTooltip.js");
6
5
  const react_hook_form_1 = require("react-hook-form");
7
6
  const Button = (props) => {
8
- const { type = "submit", loading = false, loadingText = "Guardando...", title = "Guardar", name = "save", onClickSave, selectedColor = "indigo", children, className = "", disabled = false, enableFormErrorsValidation = true, } = props;
7
+ const { type = "submit", loading = false, loadingText = "Guardando...", title = "Guardar", name = "save", onClickSave, selectedColor = "indigo", children, className = "", disabled = false, enableFormErrorsValidation = false, enableFormErrorsDescriptions = false, } = props;
9
8
  const formContext = (0, react_hook_form_1.useFormContext)();
10
9
  const formHasErrors = formContext ? !formContext.formState.isValid : false;
11
10
  const formErrors = formContext ? formContext.formState.errors : {};
@@ -45,7 +44,7 @@ const Button = (props) => {
45
44
  };
46
45
  const color = COLORS[selectedColor];
47
46
  const inside = children ?? title;
48
- const errorMessage = enableFormErrorsValidation && formHasErrors
47
+ const errorMessage = formHasErrors
49
48
  ? Object.values(formErrors)
50
49
  .map((error) => error?.message?.toString())
51
50
  .join(", ")
@@ -57,6 +56,7 @@ const Button = (props) => {
57
56
  : `${disabled || (enableFormErrorsValidation && formHasErrors)
58
57
  ? ""
59
58
  : `hover:${color.bg700}`}`} inline-flex justify-center rounded-md border border-transparent ${color.bg600} py-2 px-4 text-sm font-medium text-white shadow-sm focus:outline-none focus:ring-2 focus:${color.ring500} focus:ring-offset-2 ${className}`, children: loading ? loadingText : inside }));
60
- return enableFormErrorsValidation && formHasErrors ? ((0, jsx_runtime_1.jsx)(WithTooltip_js_1.WithTooltip, { text: errorMessage, children: buttonContent })) : (buttonContent);
59
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(enableFormErrorsValidation && formHasErrors && errorMessage) ||
60
+ (enableFormErrorsDescriptions && errorMessage) ? ((0, jsx_runtime_1.jsx)("div", { className: "flex flex-col items-end mb-2", children: (0, jsx_runtime_1.jsx)("div", { className: "p-2 bg-red-100 border border-red-400 text-red-700 rounded-md shadow-sm", children: (0, jsx_runtime_1.jsx)("p", { className: "text-sm", children: errorMessage }) }) })) : null, buttonContent] }));
61
61
  };
62
62
  exports.Button = Button;
@@ -1,20 +1,64 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
2
25
  Object.defineProperty(exports, "__esModule", { value: true });
3
26
  exports.NavBar = void 0;
4
27
  const jsx_runtime_1 = require("react/jsx-runtime");
5
- const react_1 = require("react");
28
+ const react_1 = __importStar(require("react"));
6
29
  const icons_1 = require("@zauru-sdk/icons");
7
30
  const NavBar_utils_js_1 = require("./NavBar.utils.js");
8
31
  const react_2 = require("@remix-run/react");
9
- const DropDownLinkButton = ({ text, path, icon, buttonHover, }) => ((0, jsx_runtime_1.jsx)(react_2.Link, { className: `block px-4 py-3 text-sm text-gray-600 capitalize transition-colors duration-200 transform dark:text-gray-300 ${buttonHover ?? ""} dark:hover:bg-gray-700 dark:hover:text-white`, to: path, prefetch: "none", children: (0, jsx_runtime_1.jsxs)("div", { className: "mx-auto pt-2", children: [icon, (0, jsx_runtime_1.jsx)("span", { children: text })] }) }));
10
32
  const OptionsDropDownButton = ({ color, options, name }) => {
11
33
  const [showOptionsMenu, setShowOptionsMenu] = (0, react_1.useState)(true);
12
- return ((0, jsx_runtime_1.jsx)("div", { className: "nav-item ml-auto", children: (0, jsx_runtime_1.jsx)("div", { className: "flex justify-center", children: (0, jsx_runtime_1.jsxs)("div", { className: "relative inline-block", children: [(0, jsx_runtime_1.jsxs)("button", { onClick: () => setShowOptionsMenu(!showOptionsMenu), className: `relative flex items-center p-2 text-xs text-white ${color.bg700} active:${color.bg900} border border-transparent rounded-full uppercase focus:ring-opacity-40 focus:outline-none`, children: [name ?? (0, jsx_runtime_1.jsx)(icons_1.OpcionButtonSvgIcon, {}), (0, jsx_runtime_1.jsx)(icons_1.DropDownArrowSvgIcon, {})] }), (0, jsx_runtime_1.jsx)("div", { className: "absolute right-0 z-20 w-56 py-2 mt-2 overflow-hidden bg-white rounded-md shadow-xl dark:bg-gray-800", hidden: showOptionsMenu, onMouseLeave: () => setShowOptionsMenu(true), children: options.map((option) => option) })] }) }) }));
34
+ return ((0, jsx_runtime_1.jsx)("div", { className: "nav-item ml-auto", children: (0, jsx_runtime_1.jsx)("div", { className: "flex justify-center", children: (0, jsx_runtime_1.jsxs)("div", { className: "relative inline-block", children: [(0, jsx_runtime_1.jsxs)("button", { onClick: () => setShowOptionsMenu(!showOptionsMenu), className: `relative flex items-center p-2 text-xs text-white ${color.bg700} active:${color.bg900} border border-transparent rounded-full uppercase focus:ring-opacity-40 focus:outline-none`, children: [name ?? (0, jsx_runtime_1.jsx)(icons_1.OpcionButtonSvgIcon, {}), (0, jsx_runtime_1.jsx)(icons_1.DropDownArrowSvgIcon, {})] }), (0, jsx_runtime_1.jsx)("div", { className: "absolute right-0 z-20 w-56 py-2 mt-2 overflow-hidden bg-white rounded-md shadow-xl dark:bg-gray-800", hidden: showOptionsMenu, onMouseLeave: () => setShowOptionsMenu(true), children: options.map((option, index) => ((0, jsx_runtime_1.jsx)(react_1.default.Fragment, { children: option }, index))) })] }) }) }));
13
35
  };
14
- const NavItem = ({ name, link, icon, color, specialColor, childrens = [], }) => ((0, jsx_runtime_1.jsx)("li", { className: "nav-item", children: childrens.length > 0 ? ((0, jsx_runtime_1.jsx)(OptionsDropDownButton, { name: name, color: color, options: childrens.map((x, index) => ((0, jsx_runtime_1.jsx)(DropDownLinkButton, { text: x.name, path: x.link, buttonHover: "hover:bg-red-100" }, index))) })) : ((0, jsx_runtime_1.jsx)("div", { className: `${specialColor ? specialColor.bg700 : color.bg700} container text-white w-full sm:w-auto h-10 text-sm py-1 uppercase shadow hover:shadow-lg outline-none rounded-full focus:outline-none my-auto sm:my-0 sm:mr-1 mb-1 ease-linear transition-all duration-150 `, children: (0, jsx_runtime_1.jsx)(react_2.Link, { className: "px-3 flex items-center text-xs leading-snug text-white uppercase hover:opacity-75", to: link, prefetch: "none", children: (0, jsx_runtime_1.jsxs)("div", { className: "mx-auto pt-2", children: [icon, (0, jsx_runtime_1.jsx)("span", { children: name })] }) }) })) }));
15
- const NavBar = ({ title, loggedIn, items, selectedColor, }) => {
36
+ const NavItem = ({ name, link, icon, color, specialColor, childrens = [], }) => ((0, jsx_runtime_1.jsx)("li", { className: "nav-item", children: childrens.length > 0 ? ((0, jsx_runtime_1.jsx)(OptionsDropDownButton, { name: name, color: color, options: childrens.map((x, index) => ((0, jsx_runtime_1.jsx)(react_2.Link, { to: x.link, className: "hover:bg-red-100", children: x.name }, index))) })) : ((0, jsx_runtime_1.jsx)("div", { className: `${specialColor ? specialColor.bg700 : color.bg700} container text-white w-full sm:w-auto h-10 text-sm py-1 uppercase shadow hover:shadow-lg outline-none rounded-full focus:outline-none my-auto sm:my-0 sm:mr-1 mb-1 ease-linear transition-all duration-150 `, children: (0, jsx_runtime_1.jsx)(react_2.Link, { className: "px-3 flex items-center text-xs leading-snug text-white uppercase hover:opacity-75", to: link, prefetch: "none", children: (0, jsx_runtime_1.jsxs)("div", { className: "mx-auto pt-2", children: [icon, (0, jsx_runtime_1.jsx)("span", { children: name })] }) }) })) }));
37
+ const NavBar = ({ title, loggedIn, items, selectedColor, version, }) => {
16
38
  const color = NavBar_utils_js_1.COLORS[selectedColor];
17
39
  const [NavBarOpen, setNavBarOpen] = (0, react_1.useState)(false);
40
+ const [isDarkMode, setIsDarkMode] = (0, react_1.useState)(false);
41
+ const [currentVersion, setCurrentVersion] = (0, react_1.useState)(version);
42
+ const navigate = (0, react_2.useNavigate)();
43
+ (0, react_1.useEffect)(() => {
44
+ if (isDarkMode) {
45
+ document.documentElement.classList.add("dark");
46
+ }
47
+ else {
48
+ document.documentElement.classList.remove("dark");
49
+ }
50
+ }, [isDarkMode]);
51
+ (0, react_1.useEffect)(() => {
52
+ if (version !== currentVersion) {
53
+ setCurrentVersion(version);
54
+ }
55
+ }, [version, currentVersion]);
56
+ const toggleDarkMode = () => {
57
+ setIsDarkMode(!isDarkMode);
58
+ };
59
+ const refreshPage = () => {
60
+ navigate(0);
61
+ };
18
62
  const renderNavItems = (items) => ((0, jsx_runtime_1.jsx)("div", { className: "flex flex-col lg:flex-row w-full", children: items.map((item, index) => {
19
63
  const specialColor = item.color
20
64
  ? NavBar_utils_js_1.COLORS[item.color]
@@ -24,8 +68,9 @@ const NavBar = ({ title, loggedIn, items, selectedColor, }) => {
24
68
  }) }, index));
25
69
  }) }));
26
70
  const options = ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("ul", { className: "w-full lg:flex lg:items-center", children: renderNavItems(items.filter((item) => item.loggedIn === loggedIn)) }), (0, jsx_runtime_1.jsx)("ul", { className: "sm:flex sm:flex-col lg:flex-row ml-auto", children: loggedIn && ((0, jsx_runtime_1.jsx)(OptionsDropDownButton, { color: color, options: [
27
- (0, jsx_runtime_1.jsx)(DropDownLinkButton, { text: "Cerrar Sesi\u00F3n", path: "/logout", icon: (0, jsx_runtime_1.jsx)(icons_1.LogoutDropDownSvgIcon, {}), buttonHover: "hover:bg-red-100" }, 0),
71
+ (0, jsx_runtime_1.jsx)(react_2.Link, { className: `block px-4 py-3 text-sm text-gray-600 capitalize transition-colors duration-200 transform dark:text-gray-300 hover:bg-red-100 dark:hover:bg-gray-700 dark:hover:text-white`, to: "/logout", prefetch: "none", children: (0, jsx_runtime_1.jsxs)("div", { className: "mx-auto pt-2", children: [(0, jsx_runtime_1.jsx)(icons_1.LogoutDropDownSvgIcon, {}), (0, jsx_runtime_1.jsx)("span", { children: "Cerrar sesi\u00F3n" })] }) }),
72
+ (0, jsx_runtime_1.jsx)("button", { className: `block w-full text-left px-4 py-3 text-sm text-gray-600 capitalize transition-colors duration-200 transform dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 dark:hover:text-white`, onClick: toggleDarkMode, children: (0, jsx_runtime_1.jsxs)("div", { className: "mx-auto pt-2", children: [isDarkMode ? "🌞" : "🌙", (0, jsx_runtime_1.jsx)("span", { children: isDarkMode ? "Modo Claro" : "Modo Oscuro" })] }) }),
28
73
  ] })) })] }));
29
- return ((0, jsx_runtime_1.jsx)("nav", { className: `py-3 ${color.bg600}`, children: (0, jsx_runtime_1.jsxs)("div", { className: "flex items-center justify-between ml-5 mr-5", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex justify-between w-full lg:w-auto", children: [(0, jsx_runtime_1.jsx)(react_2.Link, { className: "text-sm font-bold leading-relaxed inline-block mr-4 py-2 whitespace-nowrap uppercase text-white", to: "/home", prefetch: "none", children: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { className: "inline-block mr-2 mb-2 align-middle", children: (0, jsx_runtime_1.jsx)("img", { className: "w-auto h-7", src: "/logo.png", alt: "logo-zauru" }) }), title] }) }), (0, jsx_runtime_1.jsx)("button", { className: `rounded lg:hidden focus:outline-none focus:ring focus:${color.ring600} focus:ring-opacity-50`, "aria-label": "Toggle mobile menu", type: "button", onClick: () => setNavBarOpen(!NavBarOpen), children: (0, jsx_runtime_1.jsx)(icons_1.MenuAlt4Svg, { open: NavBarOpen }) })] }), (0, jsx_runtime_1.jsx)("div", { className: `lg:hidden fixed top-0 left-0 z-50 w-64 h-full ${color.bg700} shadow-lg transform ${NavBarOpen ? "translate-x-0" : "-translate-x-full"} transition-transform duration-300 ease-in-out overflow-y-auto`, children: (0, jsx_runtime_1.jsx)("div", { className: "p-4", children: options }) }), (0, jsx_runtime_1.jsx)("div", { className: "hidden lg:flex lg:items-center w-full lg:w-auto", children: options })] }) }));
74
+ return ((0, jsx_runtime_1.jsx)("nav", { className: `py-3 ${color.bg600} dark:bg-gray-800`, children: (0, jsx_runtime_1.jsxs)("div", { className: "flex items-center justify-between ml-5 mr-5", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex justify-between items-center w-full lg:w-auto", children: [(0, jsx_runtime_1.jsx)(react_2.Link, { className: "text-sm font-bold leading-relaxed inline-block mr-4 py-2 whitespace-nowrap uppercase text-white", to: "/home", prefetch: "none", children: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { className: "inline-block mr-2 mb-2 align-middle", children: (0, jsx_runtime_1.jsx)("img", { className: "w-auto h-7", src: "/logo.png", alt: "logo-zauru" }) }), title] }) }), version !== currentVersion && ((0, jsx_runtime_1.jsx)("button", { className: `ml-2 px-2 py-1 text-xs text-white ${color.bg700} rounded-full hover:${color.bg900} transition-colors duration-200`, onClick: refreshPage, children: "\uD83D\uDD04 Actualizar versi\u00F3n" })), (0, jsx_runtime_1.jsx)("button", { className: `rounded lg:hidden focus:outline-none focus:ring focus:${color.ring600} focus:ring-opacity-50`, "aria-label": "Toggle mobile menu", type: "button", onClick: () => setNavBarOpen(!NavBarOpen), children: (0, jsx_runtime_1.jsx)(icons_1.MenuAlt4Svg, { open: NavBarOpen }) })] }), (0, jsx_runtime_1.jsx)("div", { className: `lg:hidden fixed top-0 left-0 z-50 w-64 h-full ${color.bg700} dark:bg-gray-900 shadow-lg transform ${NavBarOpen ? "translate-x-0" : "-translate-x-full"} transition-transform duration-300 ease-in-out overflow-y-auto`, children: (0, jsx_runtime_1.jsx)("div", { className: "p-4", children: options }) }), (0, jsx_runtime_1.jsx)("div", { className: "hidden lg:flex lg:items-center w-full lg:w-auto", children: options })] }) }));
30
75
  };
31
76
  exports.NavBar = NavBar;
@@ -113,7 +113,7 @@ const customStyles = {
113
113
  });
114
114
  //Documentación de la tabla https://react-data-table-component.netlify.app/?path=/docs/getting-started-intro--docs
115
115
  const ZauruTable = (props) => {
116
- const { columns, conditionalRowStyles, data, loading = false, pagination, search, expandable, theme, className, offlineSearch = [], whitOutPagination = false, ...others } = props;
116
+ const { columns, conditionalRowStyles, data, loading = false, pagination, search, theme, className, offlineSearch = [], whitOutPagination = false, ...others } = props;
117
117
  const [, setSearchParams] = (0, react_1.useSearchParams)({
118
118
  page: "1",
119
119
  perPage: "10",
@@ -179,7 +179,7 @@ const ZauruTable = (props) => {
179
179
  };
180
180
  const loadSubHeader = !!(search || offlineSearch.length > 0);
181
181
  const subHeaderComponent = loadSubHeader ? subHeaderComponentMemo : undefined;
182
- return ((0, jsx_runtime_1.jsx)(DataTable, { className: className, subHeaderWrap: true, theme: theme ?? "solarized", columns: columns, conditionalRowStyles: conditionalRowStyles, data: filteredData, customStyles: customStyles, progressPending: loading, highlightOnHover: true, pointerOnHover: true, dense: true, striped: true, pagination: !whitOutPagination, persistTableHead: true, responsive: true, noHeader: true, expandableRows: !!expandable, expandableRowExpanded: expandable ? expandable.expandableRowExpanded : undefined, expandableRowsComponent: expandable ? expandable.expandableRowsComponent : undefined, subHeader: loadSubHeader, subHeaderComponent: subHeaderComponent, paginationServer: !!pagination, paginationTotalRows: pagination?.totalRows ?? undefined, onChangeRowsPerPage: pagination ? handlePerRowsChange : undefined, onChangePage: pagination ? handlePageChange : undefined, paginationComponentOptions: paginationComponentOptions, paginationRowsPerPageOptions: pagination?.rowsPerPageOptions
182
+ return ((0, jsx_runtime_1.jsx)(DataTable, { className: className, subHeaderWrap: true, theme: theme ?? "solarized", columns: columns, conditionalRowStyles: conditionalRowStyles, data: filteredData, customStyles: customStyles, progressPending: loading, highlightOnHover: true, pointerOnHover: true, dense: true, striped: true, pagination: !whitOutPagination, persistTableHead: true, responsive: true, noHeader: true, subHeader: loadSubHeader, subHeaderComponent: subHeaderComponent, paginationServer: !!pagination, paginationTotalRows: pagination?.totalRows ?? undefined, onChangeRowsPerPage: pagination ? handlePerRowsChange : undefined, onChangePage: pagination ? handlePageChange : undefined, paginationComponentOptions: paginationComponentOptions, paginationRowsPerPageOptions: pagination?.rowsPerPageOptions
183
183
  ? pagination.rowsPerPageOptions
184
184
  : [10, 50, 100], ...others }));
185
185
  };
@@ -1,8 +1,7 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { WithTooltip } from "../WithTooltip/WithTooltip.js";
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
3
2
  import { useFormContext } from "react-hook-form";
4
3
  export const Button = (props) => {
5
- const { type = "submit", loading = false, loadingText = "Guardando...", title = "Guardar", name = "save", onClickSave, selectedColor = "indigo", children, className = "", disabled = false, enableFormErrorsValidation = true, } = props;
4
+ const { type = "submit", loading = false, loadingText = "Guardando...", title = "Guardar", name = "save", onClickSave, selectedColor = "indigo", children, className = "", disabled = false, enableFormErrorsValidation = false, enableFormErrorsDescriptions = false, } = props;
6
5
  const formContext = useFormContext();
7
6
  const formHasErrors = formContext ? !formContext.formState.isValid : false;
8
7
  const formErrors = formContext ? formContext.formState.errors : {};
@@ -42,7 +41,7 @@ export const Button = (props) => {
42
41
  };
43
42
  const color = COLORS[selectedColor];
44
43
  const inside = children ?? title;
45
- const errorMessage = enableFormErrorsValidation && formHasErrors
44
+ const errorMessage = formHasErrors
46
45
  ? Object.values(formErrors)
47
46
  .map((error) => error?.message?.toString())
48
47
  .join(", ")
@@ -54,5 +53,6 @@ export const Button = (props) => {
54
53
  : `${disabled || (enableFormErrorsValidation && formHasErrors)
55
54
  ? ""
56
55
  : `hover:${color.bg700}`}`} inline-flex justify-center rounded-md border border-transparent ${color.bg600} py-2 px-4 text-sm font-medium text-white shadow-sm focus:outline-none focus:ring-2 focus:${color.ring500} focus:ring-offset-2 ${className}`, children: loading ? loadingText : inside }));
57
- return enableFormErrorsValidation && formHasErrors ? (_jsx(WithTooltip, { text: errorMessage, children: buttonContent })) : (buttonContent);
56
+ return (_jsxs(_Fragment, { children: [(enableFormErrorsValidation && formHasErrors && errorMessage) ||
57
+ (enableFormErrorsDescriptions && errorMessage) ? (_jsx("div", { className: "flex flex-col items-end mb-2", children: _jsx("div", { className: "p-2 bg-red-100 border border-red-400 text-red-700 rounded-md shadow-sm", children: _jsx("p", { className: "text-sm", children: errorMessage }) }) })) : null, buttonContent] }));
58
58
  };
@@ -1,17 +1,38 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
- import { useState } from "react";
2
+ import React, { useState, useEffect } from "react";
3
3
  import { DropDownArrowSvgIcon, LogoutDropDownSvgIcon, MenuAlt4Svg, OpcionButtonSvgIcon, } from "@zauru-sdk/icons";
4
4
  import { COLORS } from "./NavBar.utils.js";
5
- import { Link } from "@remix-run/react";
6
- const DropDownLinkButton = ({ text, path, icon, buttonHover, }) => (_jsx(Link, { className: `block px-4 py-3 text-sm text-gray-600 capitalize transition-colors duration-200 transform dark:text-gray-300 ${buttonHover ?? ""} dark:hover:bg-gray-700 dark:hover:text-white`, to: path, prefetch: "none", children: _jsxs("div", { className: "mx-auto pt-2", children: [icon, _jsx("span", { children: text })] }) }));
5
+ import { Link, useNavigate } from "@remix-run/react";
7
6
  const OptionsDropDownButton = ({ color, options, name }) => {
8
7
  const [showOptionsMenu, setShowOptionsMenu] = useState(true);
9
- return (_jsx("div", { className: "nav-item ml-auto", children: _jsx("div", { className: "flex justify-center", children: _jsxs("div", { className: "relative inline-block", children: [_jsxs("button", { onClick: () => setShowOptionsMenu(!showOptionsMenu), className: `relative flex items-center p-2 text-xs text-white ${color.bg700} active:${color.bg900} border border-transparent rounded-full uppercase focus:ring-opacity-40 focus:outline-none`, children: [name ?? _jsx(OpcionButtonSvgIcon, {}), _jsx(DropDownArrowSvgIcon, {})] }), _jsx("div", { className: "absolute right-0 z-20 w-56 py-2 mt-2 overflow-hidden bg-white rounded-md shadow-xl dark:bg-gray-800", hidden: showOptionsMenu, onMouseLeave: () => setShowOptionsMenu(true), children: options.map((option) => option) })] }) }) }));
8
+ return (_jsx("div", { className: "nav-item ml-auto", children: _jsx("div", { className: "flex justify-center", children: _jsxs("div", { className: "relative inline-block", children: [_jsxs("button", { onClick: () => setShowOptionsMenu(!showOptionsMenu), className: `relative flex items-center p-2 text-xs text-white ${color.bg700} active:${color.bg900} border border-transparent rounded-full uppercase focus:ring-opacity-40 focus:outline-none`, children: [name ?? _jsx(OpcionButtonSvgIcon, {}), _jsx(DropDownArrowSvgIcon, {})] }), _jsx("div", { className: "absolute right-0 z-20 w-56 py-2 mt-2 overflow-hidden bg-white rounded-md shadow-xl dark:bg-gray-800", hidden: showOptionsMenu, onMouseLeave: () => setShowOptionsMenu(true), children: options.map((option, index) => (_jsx(React.Fragment, { children: option }, index))) })] }) }) }));
10
9
  };
11
- const NavItem = ({ name, link, icon, color, specialColor, childrens = [], }) => (_jsx("li", { className: "nav-item", children: childrens.length > 0 ? (_jsx(OptionsDropDownButton, { name: name, color: color, options: childrens.map((x, index) => (_jsx(DropDownLinkButton, { text: x.name, path: x.link, buttonHover: "hover:bg-red-100" }, index))) })) : (_jsx("div", { className: `${specialColor ? specialColor.bg700 : color.bg700} container text-white w-full sm:w-auto h-10 text-sm py-1 uppercase shadow hover:shadow-lg outline-none rounded-full focus:outline-none my-auto sm:my-0 sm:mr-1 mb-1 ease-linear transition-all duration-150 `, children: _jsx(Link, { className: "px-3 flex items-center text-xs leading-snug text-white uppercase hover:opacity-75", to: link, prefetch: "none", children: _jsxs("div", { className: "mx-auto pt-2", children: [icon, _jsx("span", { children: name })] }) }) })) }));
12
- export const NavBar = ({ title, loggedIn, items, selectedColor, }) => {
10
+ const NavItem = ({ name, link, icon, color, specialColor, childrens = [], }) => (_jsx("li", { className: "nav-item", children: childrens.length > 0 ? (_jsx(OptionsDropDownButton, { name: name, color: color, options: childrens.map((x, index) => (_jsx(Link, { to: x.link, className: "hover:bg-red-100", children: x.name }, index))) })) : (_jsx("div", { className: `${specialColor ? specialColor.bg700 : color.bg700} container text-white w-full sm:w-auto h-10 text-sm py-1 uppercase shadow hover:shadow-lg outline-none rounded-full focus:outline-none my-auto sm:my-0 sm:mr-1 mb-1 ease-linear transition-all duration-150 `, children: _jsx(Link, { className: "px-3 flex items-center text-xs leading-snug text-white uppercase hover:opacity-75", to: link, prefetch: "none", children: _jsxs("div", { className: "mx-auto pt-2", children: [icon, _jsx("span", { children: name })] }) }) })) }));
11
+ export const NavBar = ({ title, loggedIn, items, selectedColor, version, }) => {
13
12
  const color = COLORS[selectedColor];
14
13
  const [NavBarOpen, setNavBarOpen] = useState(false);
14
+ const [isDarkMode, setIsDarkMode] = useState(false);
15
+ const [currentVersion, setCurrentVersion] = useState(version);
16
+ const navigate = useNavigate();
17
+ useEffect(() => {
18
+ if (isDarkMode) {
19
+ document.documentElement.classList.add("dark");
20
+ }
21
+ else {
22
+ document.documentElement.classList.remove("dark");
23
+ }
24
+ }, [isDarkMode]);
25
+ useEffect(() => {
26
+ if (version !== currentVersion) {
27
+ setCurrentVersion(version);
28
+ }
29
+ }, [version, currentVersion]);
30
+ const toggleDarkMode = () => {
31
+ setIsDarkMode(!isDarkMode);
32
+ };
33
+ const refreshPage = () => {
34
+ navigate(0);
35
+ };
15
36
  const renderNavItems = (items) => (_jsx("div", { className: "flex flex-col lg:flex-row w-full", children: items.map((item, index) => {
16
37
  const specialColor = item.color
17
38
  ? COLORS[item.color]
@@ -21,7 +42,8 @@ export const NavBar = ({ title, loggedIn, items, selectedColor, }) => {
21
42
  }) }, index));
22
43
  }) }));
23
44
  const options = (_jsxs(_Fragment, { children: [_jsx("ul", { className: "w-full lg:flex lg:items-center", children: renderNavItems(items.filter((item) => item.loggedIn === loggedIn)) }), _jsx("ul", { className: "sm:flex sm:flex-col lg:flex-row ml-auto", children: loggedIn && (_jsx(OptionsDropDownButton, { color: color, options: [
24
- _jsx(DropDownLinkButton, { text: "Cerrar Sesi\u00F3n", path: "/logout", icon: _jsx(LogoutDropDownSvgIcon, {}), buttonHover: "hover:bg-red-100" }, 0),
45
+ _jsx(Link, { className: `block px-4 py-3 text-sm text-gray-600 capitalize transition-colors duration-200 transform dark:text-gray-300 hover:bg-red-100 dark:hover:bg-gray-700 dark:hover:text-white`, to: "/logout", prefetch: "none", children: _jsxs("div", { className: "mx-auto pt-2", children: [_jsx(LogoutDropDownSvgIcon, {}), _jsx("span", { children: "Cerrar sesi\u00F3n" })] }) }),
46
+ _jsx("button", { className: `block w-full text-left px-4 py-3 text-sm text-gray-600 capitalize transition-colors duration-200 transform dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 dark:hover:text-white`, onClick: toggleDarkMode, children: _jsxs("div", { className: "mx-auto pt-2", children: [isDarkMode ? "🌞" : "🌙", _jsx("span", { children: isDarkMode ? "Modo Claro" : "Modo Oscuro" })] }) }),
25
47
  ] })) })] }));
26
- return (_jsx("nav", { className: `py-3 ${color.bg600}`, children: _jsxs("div", { className: "flex items-center justify-between ml-5 mr-5", children: [_jsxs("div", { className: "flex justify-between w-full lg:w-auto", children: [_jsx(Link, { className: "text-sm font-bold leading-relaxed inline-block mr-4 py-2 whitespace-nowrap uppercase text-white", to: "/home", prefetch: "none", children: _jsxs(_Fragment, { children: [_jsx("div", { className: "inline-block mr-2 mb-2 align-middle", children: _jsx("img", { className: "w-auto h-7", src: "/logo.png", alt: "logo-zauru" }) }), title] }) }), _jsx("button", { className: `rounded lg:hidden focus:outline-none focus:ring focus:${color.ring600} focus:ring-opacity-50`, "aria-label": "Toggle mobile menu", type: "button", onClick: () => setNavBarOpen(!NavBarOpen), children: _jsx(MenuAlt4Svg, { open: NavBarOpen }) })] }), _jsx("div", { className: `lg:hidden fixed top-0 left-0 z-50 w-64 h-full ${color.bg700} shadow-lg transform ${NavBarOpen ? "translate-x-0" : "-translate-x-full"} transition-transform duration-300 ease-in-out overflow-y-auto`, children: _jsx("div", { className: "p-4", children: options }) }), _jsx("div", { className: "hidden lg:flex lg:items-center w-full lg:w-auto", children: options })] }) }));
48
+ return (_jsx("nav", { className: `py-3 ${color.bg600} dark:bg-gray-800`, children: _jsxs("div", { className: "flex items-center justify-between ml-5 mr-5", children: [_jsxs("div", { className: "flex justify-between items-center w-full lg:w-auto", children: [_jsx(Link, { className: "text-sm font-bold leading-relaxed inline-block mr-4 py-2 whitespace-nowrap uppercase text-white", to: "/home", prefetch: "none", children: _jsxs(_Fragment, { children: [_jsx("div", { className: "inline-block mr-2 mb-2 align-middle", children: _jsx("img", { className: "w-auto h-7", src: "/logo.png", alt: "logo-zauru" }) }), title] }) }), version !== currentVersion && (_jsx("button", { className: `ml-2 px-2 py-1 text-xs text-white ${color.bg700} rounded-full hover:${color.bg900} transition-colors duration-200`, onClick: refreshPage, children: "\uD83D\uDD04 Actualizar versi\u00F3n" })), _jsx("button", { className: `rounded lg:hidden focus:outline-none focus:ring focus:${color.ring600} focus:ring-opacity-50`, "aria-label": "Toggle mobile menu", type: "button", onClick: () => setNavBarOpen(!NavBarOpen), children: _jsx(MenuAlt4Svg, { open: NavBarOpen }) })] }), _jsx("div", { className: `lg:hidden fixed top-0 left-0 z-50 w-64 h-full ${color.bg700} dark:bg-gray-900 shadow-lg transform ${NavBarOpen ? "translate-x-0" : "-translate-x-full"} transition-transform duration-300 ease-in-out overflow-y-auto`, children: _jsx("div", { className: "p-4", children: options }) }), _jsx("div", { className: "hidden lg:flex lg:items-center w-full lg:w-auto", children: options })] }) }));
27
49
  };
@@ -87,7 +87,7 @@ createTheme("subTable", {
87
87
  });
88
88
  //Documentación de la tabla https://react-data-table-component.netlify.app/?path=/docs/getting-started-intro--docs
89
89
  export const ZauruTable = (props) => {
90
- const { columns, conditionalRowStyles, data, loading = false, pagination, search, expandable, theme, className, offlineSearch = [], whitOutPagination = false, ...others } = props;
90
+ const { columns, conditionalRowStyles, data, loading = false, pagination, search, theme, className, offlineSearch = [], whitOutPagination = false, ...others } = props;
91
91
  const [, setSearchParams] = useSearchParams({
92
92
  page: "1",
93
93
  perPage: "10",
@@ -153,7 +153,7 @@ export const ZauruTable = (props) => {
153
153
  };
154
154
  const loadSubHeader = !!(search || offlineSearch.length > 0);
155
155
  const subHeaderComponent = loadSubHeader ? subHeaderComponentMemo : undefined;
156
- return (_jsx(DataTable, { className: className, subHeaderWrap: true, theme: theme ?? "solarized", columns: columns, conditionalRowStyles: conditionalRowStyles, data: filteredData, customStyles: customStyles, progressPending: loading, highlightOnHover: true, pointerOnHover: true, dense: true, striped: true, pagination: !whitOutPagination, persistTableHead: true, responsive: true, noHeader: true, expandableRows: !!expandable, expandableRowExpanded: expandable ? expandable.expandableRowExpanded : undefined, expandableRowsComponent: expandable ? expandable.expandableRowsComponent : undefined, subHeader: loadSubHeader, subHeaderComponent: subHeaderComponent, paginationServer: !!pagination, paginationTotalRows: pagination?.totalRows ?? undefined, onChangeRowsPerPage: pagination ? handlePerRowsChange : undefined, onChangePage: pagination ? handlePageChange : undefined, paginationComponentOptions: paginationComponentOptions, paginationRowsPerPageOptions: pagination?.rowsPerPageOptions
156
+ return (_jsx(DataTable, { className: className, subHeaderWrap: true, theme: theme ?? "solarized", columns: columns, conditionalRowStyles: conditionalRowStyles, data: filteredData, customStyles: customStyles, progressPending: loading, highlightOnHover: true, pointerOnHover: true, dense: true, striped: true, pagination: !whitOutPagination, persistTableHead: true, responsive: true, noHeader: true, subHeader: loadSubHeader, subHeaderComponent: subHeaderComponent, paginationServer: !!pagination, paginationTotalRows: pagination?.totalRows ?? undefined, onChangeRowsPerPage: pagination ? handlePerRowsChange : undefined, onChangePage: pagination ? handlePageChange : undefined, paginationComponentOptions: paginationComponentOptions, paginationRowsPerPageOptions: pagination?.rowsPerPageOptions
157
157
  ? pagination.rowsPerPageOptions
158
158
  : [10, 50, 100], ...others }));
159
159
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zauru-sdk/components",
3
- "version": "1.0.109",
3
+ "version": "1.0.111",
4
4
  "description": "Componentes reutilizables en las WebApps de Zauru.",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "module": "./dist/esm/index.js",
@@ -34,11 +34,11 @@
34
34
  "@hookform/resolvers": "^3.9.0",
35
35
  "@reduxjs/toolkit": "^2.2.1",
36
36
  "@remix-run/react": "^2.8.1",
37
- "@zauru-sdk/common": "^1.0.109",
38
- "@zauru-sdk/hooks": "^1.0.109",
37
+ "@zauru-sdk/common": "^1.0.110",
38
+ "@zauru-sdk/hooks": "^1.0.110",
39
39
  "@zauru-sdk/icons": "^1.0.60",
40
40
  "@zauru-sdk/types": "^1.0.109",
41
- "@zauru-sdk/utils": "^1.0.109",
41
+ "@zauru-sdk/utils": "^1.0.111",
42
42
  "framer-motion": "^11.0.8",
43
43
  "jsonwebtoken": "^9.0.2",
44
44
  "react": "^18.2.0",
@@ -50,5 +50,5 @@
50
50
  "styled-components": "^5.3.5",
51
51
  "zod": "^3.23.8"
52
52
  },
53
- "gitHead": "4ab7975fd17cda15da080998aed10f26ec119c9e"
53
+ "gitHead": "0ba44e89c12e146c8f0c3bd7a4604e0ccda29b1e"
54
54
  }
@@ -1,4 +1,3 @@
1
- import { WithTooltip } from "../WithTooltip/WithTooltip.js";
2
1
  import type { ColorInterface } from "../NavBar/NavBar.types.js";
3
2
  import { useFormContext } from "react-hook-form";
4
3
 
@@ -15,6 +14,7 @@ type Props = {
15
14
  className?: string;
16
15
  disabled?: boolean;
17
16
  enableFormErrorsValidation?: boolean;
17
+ enableFormErrorsDescriptions?: boolean;
18
18
  };
19
19
 
20
20
  export const Button = (props: Props) => {
@@ -29,7 +29,8 @@ export const Button = (props: Props) => {
29
29
  children,
30
30
  className = "",
31
31
  disabled = false,
32
- enableFormErrorsValidation = true,
32
+ enableFormErrorsValidation = false,
33
+ enableFormErrorsDescriptions = false,
33
34
  } = props;
34
35
 
35
36
  const formContext = useFormContext();
@@ -75,12 +76,11 @@ export const Button = (props: Props) => {
75
76
 
76
77
  const inside = children ?? title;
77
78
 
78
- const errorMessage =
79
- enableFormErrorsValidation && formHasErrors
80
- ? Object.values(formErrors)
81
- .map((error) => error?.message?.toString())
82
- .join(", ")
83
- : "";
79
+ const errorMessage = formHasErrors
80
+ ? Object.values(formErrors)
81
+ .map((error) => error?.message?.toString())
82
+ .join(", ")
83
+ : "";
84
84
 
85
85
  const buttonContent = (
86
86
  <button
@@ -113,9 +113,17 @@ export const Button = (props: Props) => {
113
113
  </button>
114
114
  );
115
115
 
116
- return enableFormErrorsValidation && formHasErrors ? (
117
- <WithTooltip text={errorMessage}>{buttonContent}</WithTooltip>
118
- ) : (
119
- buttonContent
116
+ return (
117
+ <>
118
+ {(enableFormErrorsValidation && formHasErrors && errorMessage) ||
119
+ (enableFormErrorsDescriptions && errorMessage) ? (
120
+ <div className="flex flex-col items-end mb-2">
121
+ <div className="p-2 bg-red-100 border border-red-400 text-red-700 rounded-md shadow-sm">
122
+ <p className="text-sm">{errorMessage}</p>
123
+ </div>
124
+ </div>
125
+ ) : null}
126
+ {buttonContent}
127
+ </>
120
128
  );
121
129
  };
@@ -1,4 +1,4 @@
1
- import React, { useState } from "react";
1
+ import React, { useState, useEffect } from "react";
2
2
  import {
3
3
  DropDownArrowSvgIcon,
4
4
  LogoutDropDownSvgIcon,
@@ -8,33 +8,12 @@ import {
8
8
  import { COLORS } from "./NavBar.utils.js";
9
9
  import type {
10
10
  ColorInterface,
11
- DropDownLinkButtonType,
12
11
  EntityProps,
13
12
  NavBarItemsSchema,
14
13
  NavBarProps,
15
14
  NavItemProps,
16
15
  } from "./NavBar.types.js";
17
- import { Link } from "@remix-run/react";
18
-
19
- const DropDownLinkButton = ({
20
- text,
21
- path,
22
- icon,
23
- buttonHover,
24
- }: DropDownLinkButtonType) => (
25
- <Link
26
- className={`block px-4 py-3 text-sm text-gray-600 capitalize transition-colors duration-200 transform dark:text-gray-300 ${
27
- buttonHover ?? ""
28
- } dark:hover:bg-gray-700 dark:hover:text-white`}
29
- to={path}
30
- prefetch="none"
31
- >
32
- <div className="mx-auto pt-2">
33
- {icon}
34
- <span>{text}</span>
35
- </div>
36
- </Link>
37
- );
16
+ import { Link, useNavigate } from "@remix-run/react";
38
17
 
39
18
  const OptionsDropDownButton = ({ color, options, name }: EntityProps) => {
40
19
  const [showOptionsMenu, setShowOptionsMenu] = useState(true);
@@ -55,7 +34,9 @@ const OptionsDropDownButton = ({ color, options, name }: EntityProps) => {
55
34
  hidden={showOptionsMenu}
56
35
  onMouseLeave={() => setShowOptionsMenu(true)}
57
36
  >
58
- {options.map((option) => option)}
37
+ {options.map((option, index) => (
38
+ <React.Fragment key={index}>{option}</React.Fragment>
39
+ ))}
59
40
  </div>
60
41
  </div>
61
42
  </div>
@@ -77,12 +58,9 @@ const NavItem = ({
77
58
  name={name}
78
59
  color={color}
79
60
  options={childrens.map((x, index) => (
80
- <DropDownLinkButton
81
- key={index}
82
- text={x.name}
83
- path={x.link}
84
- buttonHover="hover:bg-red-100"
85
- />
61
+ <Link key={index} to={x.link} className="hover:bg-red-100">
62
+ {x.name}
63
+ </Link>
86
64
  ))}
87
65
  />
88
66
  ) : (
@@ -111,9 +89,35 @@ export const NavBar = ({
111
89
  loggedIn,
112
90
  items,
113
91
  selectedColor,
92
+ version,
114
93
  }: NavBarProps) => {
115
94
  const color: ColorInterface = COLORS[selectedColor];
116
95
  const [NavBarOpen, setNavBarOpen] = useState(false);
96
+ const [isDarkMode, setIsDarkMode] = useState(false);
97
+ const [currentVersion, setCurrentVersion] = useState(version);
98
+ const navigate = useNavigate();
99
+
100
+ useEffect(() => {
101
+ if (isDarkMode) {
102
+ document.documentElement.classList.add("dark");
103
+ } else {
104
+ document.documentElement.classList.remove("dark");
105
+ }
106
+ }, [isDarkMode]);
107
+
108
+ useEffect(() => {
109
+ if (version !== currentVersion) {
110
+ setCurrentVersion(version);
111
+ }
112
+ }, [version, currentVersion]);
113
+
114
+ const toggleDarkMode = () => {
115
+ setIsDarkMode(!isDarkMode);
116
+ };
117
+
118
+ const refreshPage = () => {
119
+ navigate(0);
120
+ };
117
121
 
118
122
  const renderNavItems = (items: NavBarItemsSchema[]) => (
119
123
  <div className="flex flex-col lg:flex-row w-full">
@@ -148,13 +152,25 @@ export const NavBar = ({
148
152
  <OptionsDropDownButton
149
153
  color={color}
150
154
  options={[
151
- <DropDownLinkButton
152
- key={0}
153
- text="Cerrar Sesión"
154
- path="/logout"
155
- icon={<LogoutDropDownSvgIcon />}
156
- buttonHover="hover:bg-red-100"
157
- />,
155
+ <Link
156
+ className={`block px-4 py-3 text-sm text-gray-600 capitalize transition-colors duration-200 transform dark:text-gray-300 hover:bg-red-100 dark:hover:bg-gray-700 dark:hover:text-white`}
157
+ to="/logout"
158
+ prefetch="none"
159
+ >
160
+ <div className="mx-auto pt-2">
161
+ {<LogoutDropDownSvgIcon />}
162
+ <span>Cerrar sesión</span>
163
+ </div>
164
+ </Link>,
165
+ <button
166
+ className={`block w-full text-left px-4 py-3 text-sm text-gray-600 capitalize transition-colors duration-200 transform dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 dark:hover:text-white`}
167
+ onClick={toggleDarkMode}
168
+ >
169
+ <div className="mx-auto pt-2">
170
+ {isDarkMode ? "🌞" : "🌙"}
171
+ <span>{isDarkMode ? "Modo Claro" : "Modo Oscuro"}</span>
172
+ </div>
173
+ </button>,
158
174
  ]}
159
175
  />
160
176
  )}
@@ -163,9 +179,9 @@ export const NavBar = ({
163
179
  );
164
180
 
165
181
  return (
166
- <nav className={`py-3 ${color.bg600}`}>
182
+ <nav className={`py-3 ${color.bg600} dark:bg-gray-800`}>
167
183
  <div className="flex items-center justify-between ml-5 mr-5">
168
- <div className="flex justify-between w-full lg:w-auto">
184
+ <div className="flex justify-between items-center w-full lg:w-auto">
169
185
  <Link
170
186
  className="text-sm font-bold leading-relaxed inline-block mr-4 py-2 whitespace-nowrap uppercase text-white"
171
187
  to={"/home"}
@@ -183,6 +199,14 @@ export const NavBar = ({
183
199
  </>
184
200
  }
185
201
  />
202
+ {version !== currentVersion && (
203
+ <button
204
+ className={`ml-2 px-2 py-1 text-xs text-white ${color.bg700} rounded-full hover:${color.bg900} transition-colors duration-200`}
205
+ onClick={refreshPage}
206
+ >
207
+ 🔄 Actualizar versión
208
+ </button>
209
+ )}
186
210
  <button
187
211
  className={`rounded lg:hidden focus:outline-none focus:ring focus:${color.ring600} focus:ring-opacity-50`}
188
212
  aria-label="Toggle mobile menu"
@@ -196,7 +220,7 @@ export const NavBar = ({
196
220
  <div
197
221
  className={`lg:hidden fixed top-0 left-0 z-50 w-64 h-full ${
198
222
  color.bg700
199
- } shadow-lg transform ${
223
+ } dark:bg-gray-900 shadow-lg transform ${
200
224
  NavBarOpen ? "translate-x-0" : "-translate-x-full"
201
225
  } transition-transform duration-300 ease-in-out overflow-y-auto`}
202
226
  >
@@ -20,6 +20,7 @@ export type NavBarProps = {
20
20
  | "red"
21
21
  | "sky";
22
22
  LinkComponent?: any;
23
+ version?: string;
23
24
  };
24
25
 
25
26
  export type NavBarStateProps = {
@@ -54,11 +55,3 @@ export type EntityProps = {
54
55
  color: ColorInterface;
55
56
  options: any[];
56
57
  };
57
-
58
- export type DropDownLinkButtonType = {
59
- text: string;
60
- path: string;
61
- icon?: any;
62
- buttonHover?: string;
63
- LinkComponent?: any;
64
- };
@@ -9,7 +9,6 @@ import { createTheme } from "react-data-table-component";
9
9
  import { SearchSVG } from "@zauru-sdk/icons";
10
10
  import * as ReactDataTableComponent from "react-data-table-component";
11
11
  const DataTable = ReactDataTableComponent.default as any;
12
- import { ExpandableRowsComponent } from "react-data-table-component/dist/DataTable/types.js";
13
12
 
14
13
  const customStyles: TableStyles = {
15
14
  headCells: {
@@ -108,10 +107,6 @@ type Props = TableProps<any> & {
108
107
  search?: {
109
108
  placeholderSearch?: string;
110
109
  };
111
- expandable?: {
112
- expandableRowExpanded?: (row: any) => boolean;
113
- expandableRowsComponent?: ExpandableRowsComponent<any>;
114
- };
115
110
  theme?: "solarized" | "subTable";
116
111
  className?: string;
117
112
  };
@@ -125,7 +120,6 @@ export const ZauruTable = (props: Props) => {
125
120
  loading = false,
126
121
  pagination,
127
122
  search,
128
- expandable,
129
123
  theme,
130
124
  className,
131
125
  offlineSearch = [],
@@ -249,13 +243,6 @@ export const ZauruTable = (props: Props) => {
249
243
  persistTableHead
250
244
  responsive
251
245
  noHeader
252
- expandableRows={!!expandable}
253
- expandableRowExpanded={
254
- expandable ? expandable.expandableRowExpanded : undefined
255
- }
256
- expandableRowsComponent={
257
- expandable ? expandable.expandableRowsComponent : undefined
258
- }
259
246
  subHeader={loadSubHeader}
260
247
  subHeaderComponent={subHeaderComponent}
261
248
  paginationServer={!!pagination}