@zauru-sdk/components 1.0.54 → 1.0.60
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 +48 -0
- package/LICENCE.md +11 -11
- package/package.json +7 -7
- package/src/Alerts/ErrorBoundaryAlert/ErrorBoundaryAlert.tsx +66 -66
- package/src/Alerts/StaticAlert.tsx +121 -121
- package/src/Alerts/index.ts +2 -2
- package/src/BlockUI/BlockUI.tsx +50 -50
- package/src/BlockUI/index.tsx +1 -1
- package/src/Buttons/Button.tsx +90 -90
- package/src/Buttons/index.ts +1 -1
- package/src/Card/Card.tsx +24 -24
- package/src/Card/index.ts +1 -1
- package/src/Chat/ChatLayout.tsx +131 -131
- package/src/Chat/ChatMessageHistory.tsx +142 -142
- package/src/Chat/index.ts +2 -2
- package/src/ConnectionState/ConnectionState.tsx +27 -27
- package/src/ConnectionState/index.tsx +1 -1
- package/src/Containers/BodyContainer.tsx +14 -14
- package/src/Containers/ButtonSectionContainer.tsx +21 -21
- package/src/Containers/Container.tsx +39 -39
- package/src/Containers/DoubleContainer.tsx +48 -48
- package/src/Containers/MainContainer.tsx +17 -17
- package/src/Containers/OutletContainer.tsx +14 -14
- package/src/Containers/SubContainer.tsx +37 -37
- package/src/Containers/index.ts +7 -7
- package/src/DynamicTable/BasicPrintDynamicTable.tsx +73 -73
- package/src/DynamicTable/DynamicPrintTable.tsx +288 -288
- package/src/DynamicTable/DynamicTable.tsx +405 -405
- package/src/DynamicTable/GenericDynamicTable.tsx +456 -456
- package/src/DynamicTable/index.tsx +4 -4
- package/src/Footer/Footer.tsx +50 -50
- package/src/Footer/index.tsx +1 -1
- package/src/Form/Checkbox/index.tsx +96 -96
- package/src/Form/Checklist/index.tsx +35 -35
- package/src/Form/DatePicker/index.tsx +132 -132
- package/src/Form/DynamicBaculoForm/index.tsx +361 -361
- package/src/Form/FieldContainer/DoubleFieldContainer.tsx +35 -35
- package/src/Form/FieldContainer/QuadrupleFieldContainer.tsx +36 -36
- package/src/Form/FieldContainer/TripleFieldContainer.tsx +35 -35
- package/src/Form/FieldContainer/index.ts +3 -3
- package/src/Form/FileUpload/index.tsx +184 -184
- package/src/Form/FormButtons/index.tsx +78 -78
- package/src/Form/FormLayout/index.tsx +37 -37
- package/src/Form/SelectField/index.tsx +237 -237
- package/src/Form/TextArea/index.tsx +125 -125
- package/src/Form/TextField/index.tsx +194 -194
- package/src/Form/TimePicker/index.tsx +127 -127
- package/src/Form/YesNo/index.tsx +77 -77
- package/src/Form/index.ts +13 -13
- package/src/Labels/InfoLabel/index.tsx +21 -21
- package/src/Labels/index.tsx +1 -1
- package/src/Layouts/homeLayout/index.tsx +34 -34
- package/src/Layouts/index.ts +1 -1
- package/src/LineSeparator/LineSeparator.tsx +3 -3
- package/src/LineSeparator/index.tsx +1 -1
- package/src/Modal/Modal.tsx +104 -104
- package/src/Modal/index.tsx +1 -1
- package/src/NavBar/NavBar.tsx +223 -223
- package/src/NavBar/NavBar.types.ts +64 -64
- package/src/NavBar/NavBar.utils.ts +58 -58
- package/src/NavBar/index.tsx +5 -5
- package/src/ProgressBar/ProgressBar.tsx +25 -25
- package/src/ProgressBar/ProgressCircle.tsx +75 -75
- package/src/ProgressBar/index.tsx +2 -2
- package/src/Skeletons/LoadingInputSkeleton.tsx +12 -12
- package/src/Skeletons/index.ts +1 -1
- package/src/Tab/Tab.tsx +63 -63
- package/src/Tab/index.ts +1 -1
- package/src/Table/ZauruTable.tsx +265 -265
- package/src/Table/index.tsx +1 -1
- package/src/TaskList/TaskList.tsx +88 -88
- package/src/TaskList/index.ts +1 -1
- package/src/Titles/LabelArray.tsx +17 -17
- package/src/Titles/TableColumnTitle.tsx +9 -9
- package/src/Titles/TitleH1.tsx +10 -10
- package/src/Titles/TitleH2.tsx +10 -10
- package/src/Titles/TitleH3.tsx +10 -10
- package/src/Titles/index.ts +5 -5
- package/src/Tooltip/Tooltip.tsx +42 -42
- package/src/Tooltip/index.ts +1 -1
- package/src/WithTooltip/WithTooltip.tsx +21 -21
- package/src/WithTooltip/index.tsx +1 -1
- package/src/Wizards/StepWizard.tsx +88 -88
- package/src/Wizards/index.ts +1 -1
- package/src/Zendesk/Chat.tsx +83 -83
- package/src/Zendesk/index.ts +2 -2
- package/src/Zendesk/zendesk.config.ts +40 -40
- package/src/index.ts +24 -24
- package/src/postcss.config.mjs +5 -5
- package/src/tailwind.config.ts +10 -10
- package/src/tailwind.css +3 -3
- package/tsconfig.cjs.json +8 -8
- package/tsconfig.esm.json +11 -11
- package/tsconfig.json +17 -17
package/src/Modal/Modal.tsx
CHANGED
|
@@ -1,104 +1,104 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { createRoot } from "react-dom/client";
|
|
3
|
-
|
|
4
|
-
export type ModalOption = "OK" | "CANCEL" | null;
|
|
5
|
-
|
|
6
|
-
type ModalParams = {
|
|
7
|
-
title: string;
|
|
8
|
-
description: React.ReactNode;
|
|
9
|
-
okButtonText?: string;
|
|
10
|
-
showOptions?: boolean;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export const createModal = ({
|
|
14
|
-
title,
|
|
15
|
-
description,
|
|
16
|
-
okButtonText,
|
|
17
|
-
showOptions = true,
|
|
18
|
-
}: ModalParams): Promise<ModalOption> => {
|
|
19
|
-
return new Promise((resolve) => {
|
|
20
|
-
const handleClose = () => {
|
|
21
|
-
resolve(null);
|
|
22
|
-
removeModal();
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
const handleOk = () => {
|
|
26
|
-
resolve("OK");
|
|
27
|
-
removeModal();
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
const handleCancel = () => {
|
|
31
|
-
resolve("CANCEL");
|
|
32
|
-
removeModal();
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
const removeModal = () => {
|
|
36
|
-
document.body.removeChild(modalWrapper);
|
|
37
|
-
document.body.removeChild(modalOverlay);
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
const modalWrapper = document.createElement("div");
|
|
41
|
-
modalWrapper.classList.add(
|
|
42
|
-
"justify-center",
|
|
43
|
-
"items-center",
|
|
44
|
-
"flex",
|
|
45
|
-
"overflow-x-hidden",
|
|
46
|
-
"overflow-y-auto",
|
|
47
|
-
"fixed",
|
|
48
|
-
"inset-0",
|
|
49
|
-
"z-50",
|
|
50
|
-
"outline-none",
|
|
51
|
-
"focus:outline-none"
|
|
52
|
-
);
|
|
53
|
-
|
|
54
|
-
// Crear capa de fondo detrás del modal
|
|
55
|
-
const modalOverlay = document.createElement("div");
|
|
56
|
-
modalOverlay.classList.add(
|
|
57
|
-
"fixed",
|
|
58
|
-
"inset-0",
|
|
59
|
-
"bg-black",
|
|
60
|
-
"opacity-50",
|
|
61
|
-
"z-40"
|
|
62
|
-
);
|
|
63
|
-
|
|
64
|
-
document.body.appendChild(modalOverlay);
|
|
65
|
-
document.body.appendChild(modalWrapper);
|
|
66
|
-
|
|
67
|
-
const ModalContent = () => (
|
|
68
|
-
<div className="relative w-auto my-6 mx-auto max-w-3xl">
|
|
69
|
-
<div className="border-0 rounded-lg shadow-lg relative flex flex-col w-full bg-white outline-none focus:outline-none">
|
|
70
|
-
<div className="flex items-start justify-between p-5 border-b border-solid border-slate-200 rounded-t">
|
|
71
|
-
<h3 className="text-3xl font-semibold">{title}</h3>
|
|
72
|
-
<button className="p-1 ml-auto bg-transparent border-0 text-black float-right text-3xl leading-none font-semibold outline-none focus:outline-none">
|
|
73
|
-
<span className="close-button" onClick={handleClose}>
|
|
74
|
-
×
|
|
75
|
-
</span>
|
|
76
|
-
</button>
|
|
77
|
-
</div>
|
|
78
|
-
<div className="relative p-6 flex-auto">{description}</div>
|
|
79
|
-
{showOptions && (
|
|
80
|
-
<div className="flex items-center justify-end p-6 border-t border-solid border-slate-200 rounded-b">
|
|
81
|
-
<button
|
|
82
|
-
className="cancel-button text-red-700 background-transparent font-bold uppercase px-6 py-2 text-sm outline-none focus:outline-none mr-1 mb-1 ease-linear transition-all duration-150"
|
|
83
|
-
type="button"
|
|
84
|
-
onClick={handleCancel}
|
|
85
|
-
>
|
|
86
|
-
Cancelar
|
|
87
|
-
</button>
|
|
88
|
-
<button
|
|
89
|
-
className="ok-button bg-emerald-700 text-white active:bg-emerald-600 font-bold uppercase text-sm px-6 py-3 rounded shadow hover:shadow-lg outline-none focus:outline-none mr-1 mb-1 ease-linear transition-all duration-150"
|
|
90
|
-
type="button"
|
|
91
|
-
onClick={handleOk}
|
|
92
|
-
>
|
|
93
|
-
{okButtonText ?? "Aceptar"}
|
|
94
|
-
</button>
|
|
95
|
-
</div>
|
|
96
|
-
)}
|
|
97
|
-
</div>
|
|
98
|
-
</div>
|
|
99
|
-
);
|
|
100
|
-
|
|
101
|
-
const root = createRoot(modalWrapper);
|
|
102
|
-
root.render(<ModalContent />);
|
|
103
|
-
});
|
|
104
|
-
};
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { createRoot } from "react-dom/client";
|
|
3
|
+
|
|
4
|
+
export type ModalOption = "OK" | "CANCEL" | null;
|
|
5
|
+
|
|
6
|
+
type ModalParams = {
|
|
7
|
+
title: string;
|
|
8
|
+
description: React.ReactNode;
|
|
9
|
+
okButtonText?: string;
|
|
10
|
+
showOptions?: boolean;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export const createModal = ({
|
|
14
|
+
title,
|
|
15
|
+
description,
|
|
16
|
+
okButtonText,
|
|
17
|
+
showOptions = true,
|
|
18
|
+
}: ModalParams): Promise<ModalOption> => {
|
|
19
|
+
return new Promise((resolve) => {
|
|
20
|
+
const handleClose = () => {
|
|
21
|
+
resolve(null);
|
|
22
|
+
removeModal();
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const handleOk = () => {
|
|
26
|
+
resolve("OK");
|
|
27
|
+
removeModal();
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const handleCancel = () => {
|
|
31
|
+
resolve("CANCEL");
|
|
32
|
+
removeModal();
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const removeModal = () => {
|
|
36
|
+
document.body.removeChild(modalWrapper);
|
|
37
|
+
document.body.removeChild(modalOverlay);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const modalWrapper = document.createElement("div");
|
|
41
|
+
modalWrapper.classList.add(
|
|
42
|
+
"justify-center",
|
|
43
|
+
"items-center",
|
|
44
|
+
"flex",
|
|
45
|
+
"overflow-x-hidden",
|
|
46
|
+
"overflow-y-auto",
|
|
47
|
+
"fixed",
|
|
48
|
+
"inset-0",
|
|
49
|
+
"z-50",
|
|
50
|
+
"outline-none",
|
|
51
|
+
"focus:outline-none"
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
// Crear capa de fondo detrás del modal
|
|
55
|
+
const modalOverlay = document.createElement("div");
|
|
56
|
+
modalOverlay.classList.add(
|
|
57
|
+
"fixed",
|
|
58
|
+
"inset-0",
|
|
59
|
+
"bg-black",
|
|
60
|
+
"opacity-50",
|
|
61
|
+
"z-40"
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
document.body.appendChild(modalOverlay);
|
|
65
|
+
document.body.appendChild(modalWrapper);
|
|
66
|
+
|
|
67
|
+
const ModalContent = () => (
|
|
68
|
+
<div className="relative w-auto my-6 mx-auto max-w-3xl">
|
|
69
|
+
<div className="border-0 rounded-lg shadow-lg relative flex flex-col w-full bg-white outline-none focus:outline-none">
|
|
70
|
+
<div className="flex items-start justify-between p-5 border-b border-solid border-slate-200 rounded-t">
|
|
71
|
+
<h3 className="text-3xl font-semibold">{title}</h3>
|
|
72
|
+
<button className="p-1 ml-auto bg-transparent border-0 text-black float-right text-3xl leading-none font-semibold outline-none focus:outline-none">
|
|
73
|
+
<span className="close-button" onClick={handleClose}>
|
|
74
|
+
×
|
|
75
|
+
</span>
|
|
76
|
+
</button>
|
|
77
|
+
</div>
|
|
78
|
+
<div className="relative p-6 flex-auto">{description}</div>
|
|
79
|
+
{showOptions && (
|
|
80
|
+
<div className="flex items-center justify-end p-6 border-t border-solid border-slate-200 rounded-b">
|
|
81
|
+
<button
|
|
82
|
+
className="cancel-button text-red-700 background-transparent font-bold uppercase px-6 py-2 text-sm outline-none focus:outline-none mr-1 mb-1 ease-linear transition-all duration-150"
|
|
83
|
+
type="button"
|
|
84
|
+
onClick={handleCancel}
|
|
85
|
+
>
|
|
86
|
+
Cancelar
|
|
87
|
+
</button>
|
|
88
|
+
<button
|
|
89
|
+
className="ok-button bg-emerald-700 text-white active:bg-emerald-600 font-bold uppercase text-sm px-6 py-3 rounded shadow hover:shadow-lg outline-none focus:outline-none mr-1 mb-1 ease-linear transition-all duration-150"
|
|
90
|
+
type="button"
|
|
91
|
+
onClick={handleOk}
|
|
92
|
+
>
|
|
93
|
+
{okButtonText ?? "Aceptar"}
|
|
94
|
+
</button>
|
|
95
|
+
</div>
|
|
96
|
+
)}
|
|
97
|
+
</div>
|
|
98
|
+
</div>
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
const root = createRoot(modalWrapper);
|
|
102
|
+
root.render(<ModalContent />);
|
|
103
|
+
});
|
|
104
|
+
};
|
package/src/Modal/index.tsx
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from "./Modal.js";
|
|
1
|
+
export * from "./Modal.js";
|
package/src/NavBar/NavBar.tsx
CHANGED
|
@@ -1,223 +1,223 @@
|
|
|
1
|
-
import React, { useState } from "react";
|
|
2
|
-
import {
|
|
3
|
-
DropDownArrowSvgIcon,
|
|
4
|
-
LogoutDropDownSvgIcon,
|
|
5
|
-
MenuAlt4Svg,
|
|
6
|
-
OpcionButtonSvgIcon,
|
|
7
|
-
} from "@zauru-sdk/icons";
|
|
8
|
-
import { COLORS } from "./NavBar.utils.js";
|
|
9
|
-
import type {
|
|
10
|
-
ColorInterface,
|
|
11
|
-
DropDownLinkButtonType,
|
|
12
|
-
EntityProps,
|
|
13
|
-
NavBarProps,
|
|
14
|
-
NavItemProps,
|
|
15
|
-
} from "./NavBar.types.js";
|
|
16
|
-
import { Link } from "@remix-run/react";
|
|
17
|
-
|
|
18
|
-
const DropDownLinkButton = ({
|
|
19
|
-
text,
|
|
20
|
-
path,
|
|
21
|
-
icon,
|
|
22
|
-
buttonHover,
|
|
23
|
-
}: DropDownLinkButtonType) => (
|
|
24
|
-
<Link
|
|
25
|
-
className={`block px-4 py-3 text-sm text-gray-600 capitalize transition-colors duration-200 transform dark:text-gray-300 ${
|
|
26
|
-
buttonHover ?? ""
|
|
27
|
-
} dark:hover:bg-gray-700 dark:hover:text-white`}
|
|
28
|
-
to={path}
|
|
29
|
-
prefetch="none"
|
|
30
|
-
>
|
|
31
|
-
<div className="mx-auto pt-2">
|
|
32
|
-
{icon}
|
|
33
|
-
<span>{text}</span>
|
|
34
|
-
</div>
|
|
35
|
-
</Link>
|
|
36
|
-
);
|
|
37
|
-
|
|
38
|
-
const OptionsDropDownButton = ({ color, options, name }: EntityProps) => {
|
|
39
|
-
const [showOptionsMenu, setShowOptionsMenu] = useState(true);
|
|
40
|
-
|
|
41
|
-
return (
|
|
42
|
-
<div className="nav-item ml-auto">
|
|
43
|
-
<div className="flex justify-center">
|
|
44
|
-
<div className="relative inline-block">
|
|
45
|
-
<button
|
|
46
|
-
onClick={() => setShowOptionsMenu(!showOptionsMenu)}
|
|
47
|
-
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`}
|
|
48
|
-
>
|
|
49
|
-
{name ?? <OpcionButtonSvgIcon />}
|
|
50
|
-
<DropDownArrowSvgIcon />
|
|
51
|
-
</button>
|
|
52
|
-
<div
|
|
53
|
-
className="absolute right-0 z-20 w-56 py-2 mt-2 overflow-hidden bg-white rounded-md shadow-xl dark:bg-gray-800"
|
|
54
|
-
hidden={showOptionsMenu}
|
|
55
|
-
onMouseLeave={() => setShowOptionsMenu(true)}
|
|
56
|
-
>
|
|
57
|
-
{options.map((option) => option)}
|
|
58
|
-
</div>
|
|
59
|
-
</div>
|
|
60
|
-
</div>
|
|
61
|
-
</div>
|
|
62
|
-
);
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
const NavItem = ({
|
|
66
|
-
name,
|
|
67
|
-
link,
|
|
68
|
-
icon,
|
|
69
|
-
color,
|
|
70
|
-
specialColor,
|
|
71
|
-
childrens = [],
|
|
72
|
-
}: NavItemProps) => (
|
|
73
|
-
<li className="nav-item">
|
|
74
|
-
{childrens.length > 0 ? (
|
|
75
|
-
<OptionsDropDownButton
|
|
76
|
-
name={name}
|
|
77
|
-
color={color}
|
|
78
|
-
options={childrens.map((x, index) => (
|
|
79
|
-
<DropDownLinkButton
|
|
80
|
-
key={index}
|
|
81
|
-
text={x.name}
|
|
82
|
-
path={x.link}
|
|
83
|
-
buttonHover="hover:bg-red-100"
|
|
84
|
-
/>
|
|
85
|
-
))}
|
|
86
|
-
/>
|
|
87
|
-
) : (
|
|
88
|
-
<div
|
|
89
|
-
className={`${
|
|
90
|
-
specialColor ? specialColor.bg700 : color.bg700
|
|
91
|
-
} container text-white w-56 sm:w-auto h-10 text-sm py-1 uppercase rounded 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 `}
|
|
92
|
-
>
|
|
93
|
-
<Link
|
|
94
|
-
className="px-3 flex items-center text-xs leading-snug text-white uppercase hover:opacity-75"
|
|
95
|
-
to={link}
|
|
96
|
-
prefetch="none"
|
|
97
|
-
>
|
|
98
|
-
<div className="mx-auto pt-2">
|
|
99
|
-
{icon}
|
|
100
|
-
<span>{name}</span>
|
|
101
|
-
</div>
|
|
102
|
-
</Link>
|
|
103
|
-
</div>
|
|
104
|
-
)}
|
|
105
|
-
</li>
|
|
106
|
-
);
|
|
107
|
-
|
|
108
|
-
export const NavBar = ({
|
|
109
|
-
title,
|
|
110
|
-
loggedIn,
|
|
111
|
-
items,
|
|
112
|
-
selectedColor,
|
|
113
|
-
}: NavBarProps) => {
|
|
114
|
-
const color: ColorInterface = COLORS[selectedColor];
|
|
115
|
-
const [NavBarOpen, setNavBarOpen] = useState(false);
|
|
116
|
-
|
|
117
|
-
const options = (
|
|
118
|
-
<>
|
|
119
|
-
<ul>
|
|
120
|
-
{loggedIn && (
|
|
121
|
-
<div className="flex flex-col sm:flex-row ">
|
|
122
|
-
{items
|
|
123
|
-
.filter((item) => item.loggedIn)
|
|
124
|
-
.map((item, index) => {
|
|
125
|
-
const specialColor: ColorInterface | undefined = item.color
|
|
126
|
-
? COLORS[item.color]
|
|
127
|
-
: undefined;
|
|
128
|
-
return (
|
|
129
|
-
<NavItem
|
|
130
|
-
key={index}
|
|
131
|
-
name={item.name}
|
|
132
|
-
link={item.link}
|
|
133
|
-
icon={item.icon}
|
|
134
|
-
specialColor={specialColor}
|
|
135
|
-
color={color}
|
|
136
|
-
childrens={item.childrens?.map((x) => {
|
|
137
|
-
return { ...x } as any;
|
|
138
|
-
})}
|
|
139
|
-
/>
|
|
140
|
-
);
|
|
141
|
-
})}
|
|
142
|
-
</div>
|
|
143
|
-
)}
|
|
144
|
-
</ul>
|
|
145
|
-
<ul className="sm:flex sm:flex-col ml-auto lg:flex-row">
|
|
146
|
-
{loggedIn ? (
|
|
147
|
-
<OptionsDropDownButton
|
|
148
|
-
color={color}
|
|
149
|
-
options={[
|
|
150
|
-
<DropDownLinkButton
|
|
151
|
-
key={0}
|
|
152
|
-
text="Cerrar Sesión"
|
|
153
|
-
path="/logout"
|
|
154
|
-
icon={<LogoutDropDownSvgIcon />}
|
|
155
|
-
buttonHover="hover:bg-red-100"
|
|
156
|
-
/>,
|
|
157
|
-
]}
|
|
158
|
-
/>
|
|
159
|
-
) : (
|
|
160
|
-
items
|
|
161
|
-
.filter((item) => !item.loggedIn)
|
|
162
|
-
.map((item, index) => {
|
|
163
|
-
return (
|
|
164
|
-
<NavItem
|
|
165
|
-
key={index}
|
|
166
|
-
name={item.name}
|
|
167
|
-
link={item.link}
|
|
168
|
-
icon={item.icon}
|
|
169
|
-
color={color}
|
|
170
|
-
/>
|
|
171
|
-
);
|
|
172
|
-
})
|
|
173
|
-
)}
|
|
174
|
-
</ul>
|
|
175
|
-
</>
|
|
176
|
-
);
|
|
177
|
-
|
|
178
|
-
return (
|
|
179
|
-
<nav className={`py-3 ${color.bg600}`}>
|
|
180
|
-
<div className="flex items-center justify-between ml-5 mr-5">
|
|
181
|
-
<div className="flex justify-between w-full lg:w-auto">
|
|
182
|
-
<Link
|
|
183
|
-
className="text-sm font-bold leading-relaxed inline-block mr-4 py-2 whitespace-nowrap uppercase text-white"
|
|
184
|
-
to={"/home"}
|
|
185
|
-
prefetch="none"
|
|
186
|
-
children={
|
|
187
|
-
<>
|
|
188
|
-
<div className="inline-block mr-2 mb-2 align-middle">
|
|
189
|
-
<img
|
|
190
|
-
className="w-auto h-7"
|
|
191
|
-
src="/logo.png"
|
|
192
|
-
alt="logo-zauru"
|
|
193
|
-
/>
|
|
194
|
-
</div>
|
|
195
|
-
{title}
|
|
196
|
-
</>
|
|
197
|
-
}
|
|
198
|
-
/>
|
|
199
|
-
<button
|
|
200
|
-
className={`rounded lg:hidden focus:outline-none focus:ring focus:${color.ring600} focus:ring-opacity-50`}
|
|
201
|
-
aria-label="Toggle mobile menu"
|
|
202
|
-
type="button"
|
|
203
|
-
onClick={() => setNavBarOpen(!NavBarOpen)}
|
|
204
|
-
>
|
|
205
|
-
<MenuAlt4Svg open={NavBarOpen} />
|
|
206
|
-
</button>
|
|
207
|
-
</div>
|
|
208
|
-
{/* Menú para dispositivos móviles */}
|
|
209
|
-
<div
|
|
210
|
-
className={`lg:hidden absolute top-0 left-0 z-50 w-64 h-full ${
|
|
211
|
-
color.bg700
|
|
212
|
-
} shadow-lg transform ${
|
|
213
|
-
NavBarOpen ? "translate-x-0" : "-translate-x-full"
|
|
214
|
-
} transition-transform duration-300 ease-in-out`}
|
|
215
|
-
>
|
|
216
|
-
{options}
|
|
217
|
-
</div>
|
|
218
|
-
{/* Menú para escritorio */}
|
|
219
|
-
<div className="hidden lg:flex w-full lg:w-auto">{options}</div>
|
|
220
|
-
</div>
|
|
221
|
-
</nav>
|
|
222
|
-
);
|
|
223
|
-
};
|
|
1
|
+
import React, { useState } from "react";
|
|
2
|
+
import {
|
|
3
|
+
DropDownArrowSvgIcon,
|
|
4
|
+
LogoutDropDownSvgIcon,
|
|
5
|
+
MenuAlt4Svg,
|
|
6
|
+
OpcionButtonSvgIcon,
|
|
7
|
+
} from "@zauru-sdk/icons";
|
|
8
|
+
import { COLORS } from "./NavBar.utils.js";
|
|
9
|
+
import type {
|
|
10
|
+
ColorInterface,
|
|
11
|
+
DropDownLinkButtonType,
|
|
12
|
+
EntityProps,
|
|
13
|
+
NavBarProps,
|
|
14
|
+
NavItemProps,
|
|
15
|
+
} from "./NavBar.types.js";
|
|
16
|
+
import { Link } from "@remix-run/react";
|
|
17
|
+
|
|
18
|
+
const DropDownLinkButton = ({
|
|
19
|
+
text,
|
|
20
|
+
path,
|
|
21
|
+
icon,
|
|
22
|
+
buttonHover,
|
|
23
|
+
}: DropDownLinkButtonType) => (
|
|
24
|
+
<Link
|
|
25
|
+
className={`block px-4 py-3 text-sm text-gray-600 capitalize transition-colors duration-200 transform dark:text-gray-300 ${
|
|
26
|
+
buttonHover ?? ""
|
|
27
|
+
} dark:hover:bg-gray-700 dark:hover:text-white`}
|
|
28
|
+
to={path}
|
|
29
|
+
prefetch="none"
|
|
30
|
+
>
|
|
31
|
+
<div className="mx-auto pt-2">
|
|
32
|
+
{icon}
|
|
33
|
+
<span>{text}</span>
|
|
34
|
+
</div>
|
|
35
|
+
</Link>
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
const OptionsDropDownButton = ({ color, options, name }: EntityProps) => {
|
|
39
|
+
const [showOptionsMenu, setShowOptionsMenu] = useState(true);
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<div className="nav-item ml-auto">
|
|
43
|
+
<div className="flex justify-center">
|
|
44
|
+
<div className="relative inline-block">
|
|
45
|
+
<button
|
|
46
|
+
onClick={() => setShowOptionsMenu(!showOptionsMenu)}
|
|
47
|
+
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`}
|
|
48
|
+
>
|
|
49
|
+
{name ?? <OpcionButtonSvgIcon />}
|
|
50
|
+
<DropDownArrowSvgIcon />
|
|
51
|
+
</button>
|
|
52
|
+
<div
|
|
53
|
+
className="absolute right-0 z-20 w-56 py-2 mt-2 overflow-hidden bg-white rounded-md shadow-xl dark:bg-gray-800"
|
|
54
|
+
hidden={showOptionsMenu}
|
|
55
|
+
onMouseLeave={() => setShowOptionsMenu(true)}
|
|
56
|
+
>
|
|
57
|
+
{options.map((option) => option)}
|
|
58
|
+
</div>
|
|
59
|
+
</div>
|
|
60
|
+
</div>
|
|
61
|
+
</div>
|
|
62
|
+
);
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const NavItem = ({
|
|
66
|
+
name,
|
|
67
|
+
link,
|
|
68
|
+
icon,
|
|
69
|
+
color,
|
|
70
|
+
specialColor,
|
|
71
|
+
childrens = [],
|
|
72
|
+
}: NavItemProps) => (
|
|
73
|
+
<li className="nav-item">
|
|
74
|
+
{childrens.length > 0 ? (
|
|
75
|
+
<OptionsDropDownButton
|
|
76
|
+
name={name}
|
|
77
|
+
color={color}
|
|
78
|
+
options={childrens.map((x, index) => (
|
|
79
|
+
<DropDownLinkButton
|
|
80
|
+
key={index}
|
|
81
|
+
text={x.name}
|
|
82
|
+
path={x.link}
|
|
83
|
+
buttonHover="hover:bg-red-100"
|
|
84
|
+
/>
|
|
85
|
+
))}
|
|
86
|
+
/>
|
|
87
|
+
) : (
|
|
88
|
+
<div
|
|
89
|
+
className={`${
|
|
90
|
+
specialColor ? specialColor.bg700 : color.bg700
|
|
91
|
+
} container text-white w-56 sm:w-auto h-10 text-sm py-1 uppercase rounded 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 `}
|
|
92
|
+
>
|
|
93
|
+
<Link
|
|
94
|
+
className="px-3 flex items-center text-xs leading-snug text-white uppercase hover:opacity-75"
|
|
95
|
+
to={link}
|
|
96
|
+
prefetch="none"
|
|
97
|
+
>
|
|
98
|
+
<div className="mx-auto pt-2">
|
|
99
|
+
{icon}
|
|
100
|
+
<span>{name}</span>
|
|
101
|
+
</div>
|
|
102
|
+
</Link>
|
|
103
|
+
</div>
|
|
104
|
+
)}
|
|
105
|
+
</li>
|
|
106
|
+
);
|
|
107
|
+
|
|
108
|
+
export const NavBar = ({
|
|
109
|
+
title,
|
|
110
|
+
loggedIn,
|
|
111
|
+
items,
|
|
112
|
+
selectedColor,
|
|
113
|
+
}: NavBarProps) => {
|
|
114
|
+
const color: ColorInterface = COLORS[selectedColor];
|
|
115
|
+
const [NavBarOpen, setNavBarOpen] = useState(false);
|
|
116
|
+
|
|
117
|
+
const options = (
|
|
118
|
+
<>
|
|
119
|
+
<ul>
|
|
120
|
+
{loggedIn && (
|
|
121
|
+
<div className="flex flex-col sm:flex-row ">
|
|
122
|
+
{items
|
|
123
|
+
.filter((item) => item.loggedIn)
|
|
124
|
+
.map((item, index) => {
|
|
125
|
+
const specialColor: ColorInterface | undefined = item.color
|
|
126
|
+
? COLORS[item.color]
|
|
127
|
+
: undefined;
|
|
128
|
+
return (
|
|
129
|
+
<NavItem
|
|
130
|
+
key={index}
|
|
131
|
+
name={item.name}
|
|
132
|
+
link={item.link}
|
|
133
|
+
icon={item.icon}
|
|
134
|
+
specialColor={specialColor}
|
|
135
|
+
color={color}
|
|
136
|
+
childrens={item.childrens?.map((x) => {
|
|
137
|
+
return { ...x } as any;
|
|
138
|
+
})}
|
|
139
|
+
/>
|
|
140
|
+
);
|
|
141
|
+
})}
|
|
142
|
+
</div>
|
|
143
|
+
)}
|
|
144
|
+
</ul>
|
|
145
|
+
<ul className="sm:flex sm:flex-col ml-auto lg:flex-row">
|
|
146
|
+
{loggedIn ? (
|
|
147
|
+
<OptionsDropDownButton
|
|
148
|
+
color={color}
|
|
149
|
+
options={[
|
|
150
|
+
<DropDownLinkButton
|
|
151
|
+
key={0}
|
|
152
|
+
text="Cerrar Sesión"
|
|
153
|
+
path="/logout"
|
|
154
|
+
icon={<LogoutDropDownSvgIcon />}
|
|
155
|
+
buttonHover="hover:bg-red-100"
|
|
156
|
+
/>,
|
|
157
|
+
]}
|
|
158
|
+
/>
|
|
159
|
+
) : (
|
|
160
|
+
items
|
|
161
|
+
.filter((item) => !item.loggedIn)
|
|
162
|
+
.map((item, index) => {
|
|
163
|
+
return (
|
|
164
|
+
<NavItem
|
|
165
|
+
key={index}
|
|
166
|
+
name={item.name}
|
|
167
|
+
link={item.link}
|
|
168
|
+
icon={item.icon}
|
|
169
|
+
color={color}
|
|
170
|
+
/>
|
|
171
|
+
);
|
|
172
|
+
})
|
|
173
|
+
)}
|
|
174
|
+
</ul>
|
|
175
|
+
</>
|
|
176
|
+
);
|
|
177
|
+
|
|
178
|
+
return (
|
|
179
|
+
<nav className={`py-3 ${color.bg600}`}>
|
|
180
|
+
<div className="flex items-center justify-between ml-5 mr-5">
|
|
181
|
+
<div className="flex justify-between w-full lg:w-auto">
|
|
182
|
+
<Link
|
|
183
|
+
className="text-sm font-bold leading-relaxed inline-block mr-4 py-2 whitespace-nowrap uppercase text-white"
|
|
184
|
+
to={"/home"}
|
|
185
|
+
prefetch="none"
|
|
186
|
+
children={
|
|
187
|
+
<>
|
|
188
|
+
<div className="inline-block mr-2 mb-2 align-middle">
|
|
189
|
+
<img
|
|
190
|
+
className="w-auto h-7"
|
|
191
|
+
src="/logo.png"
|
|
192
|
+
alt="logo-zauru"
|
|
193
|
+
/>
|
|
194
|
+
</div>
|
|
195
|
+
{title}
|
|
196
|
+
</>
|
|
197
|
+
}
|
|
198
|
+
/>
|
|
199
|
+
<button
|
|
200
|
+
className={`rounded lg:hidden focus:outline-none focus:ring focus:${color.ring600} focus:ring-opacity-50`}
|
|
201
|
+
aria-label="Toggle mobile menu"
|
|
202
|
+
type="button"
|
|
203
|
+
onClick={() => setNavBarOpen(!NavBarOpen)}
|
|
204
|
+
>
|
|
205
|
+
<MenuAlt4Svg open={NavBarOpen} />
|
|
206
|
+
</button>
|
|
207
|
+
</div>
|
|
208
|
+
{/* Menú para dispositivos móviles */}
|
|
209
|
+
<div
|
|
210
|
+
className={`lg:hidden absolute top-0 left-0 z-50 w-64 h-full ${
|
|
211
|
+
color.bg700
|
|
212
|
+
} shadow-lg transform ${
|
|
213
|
+
NavBarOpen ? "translate-x-0" : "-translate-x-full"
|
|
214
|
+
} transition-transform duration-300 ease-in-out`}
|
|
215
|
+
>
|
|
216
|
+
{options}
|
|
217
|
+
</div>
|
|
218
|
+
{/* Menú para escritorio */}
|
|
219
|
+
<div className="hidden lg:flex w-full lg:w-auto">{options}</div>
|
|
220
|
+
</div>
|
|
221
|
+
</nav>
|
|
222
|
+
);
|
|
223
|
+
};
|