@zauru-sdk/components 1.0.99 → 1.0.100
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 +8 -0
- package/dist/Form/Checkbox/index.d.ts +1 -3
- package/dist/Form/DatePicker/index.d.ts +1 -3
- package/dist/Form/FileUpload/index.d.ts +1 -2
- package/dist/Form/ReactZodForm/index.d.ts +12 -0
- package/dist/Form/SelectField/index.d.ts +6 -9
- package/dist/Form/TextArea/index.d.ts +1 -3
- package/dist/Form/TextField/index.d.ts +1 -3
- package/dist/Form/TimePicker/index.d.ts +1 -2
- package/dist/Form/YesNo/index.d.ts +1 -0
- package/dist/Form/index.d.ts +1 -2
- package/dist/Layouts/homeLayout/index.d.ts +3 -1
- package/dist/Modal/Modal.d.ts +1 -1
- package/dist/Zendesk/zendesk.config.d.ts +1 -1
- package/dist/cjs/Alerts/StaticAlert.js +0 -6
- package/dist/cjs/Buttons/Button.js +13 -2
- package/dist/cjs/DynamicTable/DynamicPrintTable.js +2 -2
- package/dist/cjs/DynamicTable/DynamicTable.js +3 -3
- package/dist/cjs/DynamicTable/GenericDynamicTable.js +4 -5
- package/dist/cjs/Footer/Footer.js +1 -1
- package/dist/cjs/Form/Checkbox/index.js +14 -14
- package/dist/cjs/Form/Checklist/index.js +1 -1
- package/dist/cjs/Form/DatePicker/index.js +14 -13
- package/dist/cjs/Form/DynamicBaculoForm/index.js +1 -1
- package/dist/cjs/Form/FileUpload/index.js +25 -13
- package/dist/cjs/Form/ReactZodForm/index.js +31 -0
- package/dist/cjs/Form/SelectField/index.js +118 -73
- package/dist/cjs/Form/TextArea/index.js +15 -15
- package/dist/cjs/Form/TextField/index.js +20 -16
- package/dist/cjs/Form/TimePicker/index.js +17 -15
- package/dist/cjs/Form/YesNo/index.js +12 -6
- package/dist/cjs/Form/index.js +1 -2
- package/dist/cjs/Layouts/homeLayout/index.js +45 -8
- package/dist/cjs/Modal/Modal.js +1 -2
- package/dist/cjs/NavBar/NavBar.js +12 -17
- package/dist/cjs/Table/ZauruTable.js +11 -4
- package/dist/cjs/WithTooltip/WithTooltip.js +1 -1
- package/dist/cjs/Zendesk/zendesk.config.js +7 -9
- package/dist/esm/Alerts/StaticAlert.js +0 -6
- package/dist/esm/Buttons/Button.js +13 -2
- package/dist/esm/DynamicTable/DynamicPrintTable.js +4 -4
- package/dist/esm/DynamicTable/DynamicTable.js +6 -6
- package/dist/esm/DynamicTable/GenericDynamicTable.js +7 -8
- package/dist/esm/Footer/Footer.js +1 -1
- package/dist/esm/Form/Checkbox/index.js +13 -12
- package/dist/esm/Form/Checklist/index.js +2 -2
- package/dist/esm/Form/DatePicker/index.js +13 -11
- package/dist/esm/Form/DynamicBaculoForm/index.js +2 -2
- package/dist/esm/Form/FileUpload/index.js +24 -11
- package/dist/esm/Form/ReactZodForm/index.js +27 -0
- package/dist/esm/Form/SelectField/index.js +118 -49
- package/dist/esm/Form/TextArea/index.js +14 -13
- package/dist/esm/Form/TextField/index.js +19 -14
- package/dist/esm/Form/TimePicker/index.js +16 -13
- package/dist/esm/Form/YesNo/index.js +12 -6
- package/dist/esm/Form/index.js +1 -2
- package/dist/esm/Layouts/homeLayout/index.js +46 -9
- package/dist/esm/Modal/Modal.js +1 -2
- package/dist/esm/NavBar/NavBar.js +12 -17
- package/dist/esm/Table/ZauruTable.js +11 -4
- package/dist/esm/WithTooltip/WithTooltip.js +2 -2
- package/dist/esm/Zendesk/zendesk.config.js +7 -6
- package/package.json +6 -3
- package/src/Alerts/StaticAlert.tsx +0 -10
- package/src/Buttons/Button.tsx +24 -4
- package/src/DynamicTable/DynamicPrintTable.tsx +5 -6
- package/src/DynamicTable/DynamicTable.tsx +7 -7
- package/src/DynamicTable/GenericDynamicTable.tsx +7 -8
- package/src/Footer/Footer.tsx +1 -1
- package/src/Form/Checkbox/index.tsx +21 -18
- package/src/Form/Checklist/index.tsx +2 -2
- package/src/Form/DatePicker/index.tsx +22 -19
- package/src/Form/DynamicBaculoForm/index.tsx +2 -2
- package/src/Form/FileUpload/index.tsx +29 -14
- package/src/Form/ReactZodForm/index.tsx +60 -0
- package/src/Form/SelectField/index.tsx +246 -130
- package/src/Form/TextArea/index.tsx +22 -19
- package/src/Form/TextField/index.tsx +25 -18
- package/src/Form/TimePicker/index.tsx +25 -18
- package/src/Form/YesNo/index.tsx +20 -7
- package/src/Form/index.ts +1 -2
- package/src/Layouts/homeLayout/index.tsx +114 -21
- package/src/Modal/Modal.tsx +2 -5
- package/src/NavBar/NavBar.tsx +35 -46
- package/src/Table/ZauruTable.tsx +11 -4
- package/src/WithTooltip/WithTooltip.tsx +8 -7
- package/src/Zendesk/zendesk.config.ts +8 -6
- package/dist/Form/FormLayout/index.d.ts +0 -11
- package/dist/Form/RadioButtonGroup/index.d.ts +0 -20
- package/dist/cjs/Form/FormLayout/index.js +0 -11
- package/dist/cjs/Form/RadioButtonGroup/index.js +0 -26
- package/dist/esm/Form/FormLayout/index.js +0 -7
- package/dist/esm/Form/RadioButtonGroup/index.js +0 -21
- package/src/Form/FormLayout/index.tsx +0 -37
- package/src/Form/RadioButtonGroup/index.tsx +0 -108
|
@@ -1,74 +1,143 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { IdeaIconSVG } from "@zauru-sdk/icons";
|
|
3
|
-
import {
|
|
4
|
-
import { useEffect, useState } from "react";
|
|
5
|
-
import Select, { components } from "react-select";
|
|
3
|
+
import { useEffect, useState, useRef } from "react";
|
|
6
4
|
import { LoadingInputSkeleton } from "../../Skeletons/index.js";
|
|
7
|
-
|
|
8
|
-
export const
|
|
9
|
-
const { id, name, title, defaultValue, defaultValueMulti = [], helpText, hint, options, onChange, onChangeMulti, isClearable = false,
|
|
5
|
+
import { useFormContext, Controller } from "react-hook-form";
|
|
6
|
+
export const SelectField = (props) => {
|
|
7
|
+
const { id, name, title, defaultValue, defaultValueMulti = [], helpText, hint, options, onChange, onChangeMulti, isClearable = false, disabled = false, readOnly = false, isMulti = false, loading = false, className = "", onInputChange, required, } = props;
|
|
10
8
|
const [value, setValue] = useState(defaultValue || null);
|
|
11
9
|
const [valueMulti, setValueMulti] = useState(defaultValueMulti);
|
|
12
|
-
const [inputValue, setInputValue] = useState("");
|
|
10
|
+
const [inputValue, setInputValue] = useState(defaultValue?.label || "");
|
|
13
11
|
const [showTooltip, setShowTooltip] = useState(false);
|
|
14
|
-
const [
|
|
15
|
-
const
|
|
12
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
13
|
+
const [filteredOptions, setFilteredOptions] = useState(options);
|
|
14
|
+
const [highlightedIndex, setHighlightedIndex] = useState(-1);
|
|
15
|
+
const selectRef = useRef(null);
|
|
16
|
+
const optionsRef = useRef(null);
|
|
17
|
+
const [isTabPressed, setIsTabPressed] = useState(false);
|
|
18
|
+
const [isEnterPressed, setIsEnterPressed] = useState(false);
|
|
19
|
+
const [isSearching, setIsSearching] = useState(false);
|
|
20
|
+
const { control, formState: { errors }, setValue: setFormValue, } = useFormContext() || { formState: {} };
|
|
21
|
+
const error = errors ? errors[props.name ?? "-1"] : undefined;
|
|
16
22
|
const color = error ? "red" : "gray";
|
|
17
|
-
let documentRef = null;
|
|
18
23
|
const isReadOnly = disabled || readOnly;
|
|
19
24
|
const bgColor = isReadOnly ? "bg-gray-200" : `bg-${color}-50`;
|
|
20
25
|
const textColor = isReadOnly ? "text-gray-500" : `text-${color}-900`;
|
|
21
26
|
const borderColor = isReadOnly ? "border-gray-300" : `border-${color}-500`;
|
|
22
|
-
if (typeof window !== "undefined") {
|
|
23
|
-
documentRef = document;
|
|
24
|
-
}
|
|
25
27
|
useEffect(() => {
|
|
26
|
-
|
|
27
|
-
}, [
|
|
28
|
+
setFilteredOptions(options);
|
|
29
|
+
}, [options]);
|
|
28
30
|
useEffect(() => {
|
|
29
|
-
|
|
31
|
+
const handleClickOutside = (event) => {
|
|
32
|
+
if (selectRef.current &&
|
|
33
|
+
!selectRef.current.contains(event.target)) {
|
|
34
|
+
setIsOpen(false);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
if (defaultValue) {
|
|
38
|
+
setValue(defaultValue);
|
|
39
|
+
setInputValue(defaultValue.label);
|
|
40
|
+
setFormValue(name || "", defaultValue);
|
|
41
|
+
}
|
|
42
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
43
|
+
return () => {
|
|
44
|
+
document.removeEventListener("mousedown", handleClickOutside);
|
|
45
|
+
};
|
|
30
46
|
}, []);
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
47
|
+
const handleInputChange = (e) => {
|
|
48
|
+
const newValue = e.target.value;
|
|
49
|
+
setInputValue(newValue);
|
|
50
|
+
onInputChange && onInputChange(newValue);
|
|
51
|
+
setIsSearching(true);
|
|
52
|
+
setFilteredOptions(options.filter((option) => option.label.toLowerCase().includes(newValue.toLowerCase())));
|
|
53
|
+
};
|
|
54
|
+
const handleOptionClick = (option) => {
|
|
55
|
+
if (isMulti) {
|
|
56
|
+
const newValue = valueMulti.some((v) => v.value === option.value)
|
|
57
|
+
? valueMulti.filter((v) => v.value !== option.value)
|
|
58
|
+
: [...valueMulti, option];
|
|
59
|
+
setValueMulti(newValue);
|
|
60
|
+
onChangeMulti && onChangeMulti(newValue);
|
|
61
|
+
setFormValue(name || "", newValue);
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
setValue(option);
|
|
65
|
+
setInputValue(option.label);
|
|
66
|
+
onChange && onChange(option);
|
|
67
|
+
setFormValue(name || "", option);
|
|
68
|
+
}
|
|
69
|
+
setIsOpen(false);
|
|
70
|
+
};
|
|
71
|
+
const handleClear = () => {
|
|
72
|
+
if (isMulti) {
|
|
73
|
+
setValueMulti([]);
|
|
74
|
+
onChangeMulti && onChangeMulti([]);
|
|
75
|
+
setFormValue(name || "", []);
|
|
42
76
|
}
|
|
43
77
|
else {
|
|
44
78
|
setValue(null);
|
|
45
79
|
onChange && onChange(null);
|
|
80
|
+
setFormValue(name || "", null);
|
|
46
81
|
}
|
|
82
|
+
setInputValue("");
|
|
47
83
|
};
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
84
|
+
const handleBlur = () => {
|
|
85
|
+
setTimeout(() => {
|
|
86
|
+
if (isTabPressed &&
|
|
87
|
+
filteredOptions.length > 0 &&
|
|
88
|
+
!isEnterPressed &&
|
|
89
|
+
isSearching) {
|
|
90
|
+
handleOptionClick(filteredOptions[0]);
|
|
91
|
+
}
|
|
92
|
+
setIsTabPressed(false);
|
|
93
|
+
setIsEnterPressed(false);
|
|
94
|
+
setIsSearching(false);
|
|
95
|
+
setIsOpen(false);
|
|
96
|
+
}, 200);
|
|
97
|
+
};
|
|
98
|
+
const handleKeyDown = (e) => {
|
|
99
|
+
if (e.key === "Tab") {
|
|
100
|
+
setIsTabPressed(true);
|
|
53
101
|
}
|
|
54
|
-
else {
|
|
55
|
-
|
|
56
|
-
|
|
102
|
+
else if (e.key === "ArrowDown") {
|
|
103
|
+
e.preventDefault();
|
|
104
|
+
setHighlightedIndex((prevIndex) => prevIndex < filteredOptions.length - 1 ? prevIndex + 1 : 0);
|
|
105
|
+
scrollToHighlightedOption();
|
|
106
|
+
}
|
|
107
|
+
else if (e.key === "ArrowUp") {
|
|
108
|
+
e.preventDefault();
|
|
109
|
+
setHighlightedIndex((prevIndex) => prevIndex > 0 ? prevIndex - 1 : filteredOptions.length - 1);
|
|
110
|
+
scrollToHighlightedOption();
|
|
111
|
+
}
|
|
112
|
+
else if (e.key === "Enter" && highlightedIndex !== -1) {
|
|
113
|
+
e.preventDefault();
|
|
114
|
+
setIsEnterPressed(true);
|
|
115
|
+
handleOptionClick(filteredOptions[highlightedIndex]);
|
|
57
116
|
}
|
|
58
117
|
};
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
118
|
+
const scrollToHighlightedOption = () => {
|
|
119
|
+
if (optionsRef.current && optionsRef.current.children[highlightedIndex]) {
|
|
120
|
+
const highlightedOption = optionsRef.current.children[highlightedIndex];
|
|
121
|
+
highlightedOption.scrollIntoView({
|
|
122
|
+
block: "center",
|
|
123
|
+
inline: "center",
|
|
124
|
+
behavior: "smooth",
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
if (loading) {
|
|
129
|
+
return (_jsxs(_Fragment, { children: [title && (_jsx("label", { htmlFor: error ? `${name}-error` : `${name}-success`, className: `block text-sm font-medium text-${color}-700 dark:text-${color}-500`, children: title })), _jsx(LoadingInputSkeleton, {}), helpText && (_jsx("p", { className: `mt-2 italic text-sm text-${color}-500 dark:text-${color}-400`, children: helpText }))] }));
|
|
130
|
+
}
|
|
131
|
+
return (_jsxs("div", { className: `col-span-6 sm:col-span-3 ${className}`, ref: selectRef, children: [title && (_jsxs("label", { htmlFor: error ? `${name}-error` : `${name}-success`, className: `block text-sm font-medium ${color === "red"
|
|
66
132
|
? "text-red-700 dark:text-red-500"
|
|
67
|
-
: "text-gray-700 dark:text-gray-500"}`, children: title
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
133
|
+
: "text-gray-700 dark:text-gray-500"}`, children: [title, required && _jsx("span", { className: "text-red-500", children: "*" })] })), _jsxs("div", { className: "relative", children: [_jsx(Controller, { name: name || "", control: control, rules: { required }, defaultValue: defaultValue || (isMulti ? [] : null), render: ({ field }) => (_jsx("input", { ...field, type: "text", id: id, value: inputValue, onFocus: () => setIsOpen(true), onBlur: handleBlur, onKeyDown: handleKeyDown, readOnly: isReadOnly, disabled: disabled, className: `block w-full rounded-md ${bgColor} ${borderColor} ${textColor} shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm`, placeholder: isMulti ? "Select options..." : "Select an option...", onChange: (e) => {
|
|
134
|
+
field.onChange(e);
|
|
135
|
+
handleInputChange(e);
|
|
136
|
+
} })) }), isClearable && (value || valueMulti.length > 0) && (_jsx("button", { type: "button", onClick: handleClear, className: "absolute inset-y-0 right-0 pr-3 flex items-center", children: "\u00D7" })), isOpen && !isReadOnly && (_jsx("ul", { ref: optionsRef, className: "absolute z-10 mt-1 w-full bg-white shadow-lg max-h-60 rounded-md py-1 text-base ring-1 ring-black ring-opacity-5 overflow-auto focus:outline-none sm:text-sm", children: filteredOptions.map((option, index) => (_jsx("li", { className: `cursor-pointer select-none relative py-2 pl-3 pr-9 ${(isMulti
|
|
137
|
+
? valueMulti.some((v) => v.value === option.value)
|
|
138
|
+
: value?.value === option.value)
|
|
139
|
+
? "text-white bg-indigo-600"
|
|
140
|
+
: index === highlightedIndex
|
|
141
|
+
? "text-black bg-sky-200"
|
|
142
|
+
: "text-gray-900"}`, onClick: () => handleOptionClick(option), onMouseEnter: () => setHighlightedIndex(index), onMouseLeave: () => setHighlightedIndex(-1), children: option.label }, `${option.value}-${index}`))) }))] }), isMulti && (_jsx("div", { className: "mt-2 flex flex-wrap gap-2", children: valueMulti.map((option, index) => (_jsxs("span", { className: "bg-blue-100 text-blue-800 text-xs font-semibold mr-2 px-2.5 py-0.5 rounded", children: [option.label, _jsx("button", { type: "button", onClick: () => handleOptionClick(option), className: "ml-1 text-blue-600 hover:text-blue-800", children: "\u00D7" })] }, `${option.value}-${index}`))) })), helpText && (_jsx("div", { className: "flex items-center relative mt-1", children: _jsxs("div", { className: "relative cursor-pointer", onMouseEnter: () => setShowTooltip(true), onMouseLeave: () => setShowTooltip(false), children: [_jsx(IdeaIconSVG, {}), showTooltip && (_jsx("div", { className: "absolute -left-48 top-0 mt-8 p-2 bg-white border rounded shadow text-black z-50", children: helpText }))] }) })), error && (_jsxs("p", { className: `mt-2 text-sm text-${color}-600 dark:text-${color}-500`, children: [_jsx("span", { className: "font-medium", children: "Oops!" }), " ", error?.message?.toString() || "Error desconocido"] })), !error && hint && (_jsx("p", { className: `mt-2 italic text-sm text-${color}-500 dark:text-${color}-400`, children: hint }))] }));
|
|
74
143
|
};
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useAppSelector } from "@zauru-sdk/redux";
|
|
3
2
|
import { useEffect, useState } from "react";
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
import { useFormContext } from "react-hook-form";
|
|
4
|
+
export const TextArea = (props) => {
|
|
5
|
+
const { id, name, title, defaultValue = "", hidden, hint, onChange, onKeyDown, disabled = false, readOnly = false, rows, cols, stopChangeEvents, className = "", required, } = props;
|
|
6
6
|
const [value, setValue] = useState(defaultValue);
|
|
7
|
+
const { register: tempRegister, formState: { errors }, } = useFormContext() || { formState: {} }; // Obtener el contexto solo si existe
|
|
8
|
+
const error = errors ? errors[props.name ?? "-1"] : undefined;
|
|
9
|
+
const register = tempRegister
|
|
10
|
+
? tempRegister(props.name ?? "-1", { required })
|
|
11
|
+
: undefined; // Solo usar register si está disponible
|
|
7
12
|
const color = error ? "red" : "gray";
|
|
8
13
|
const isReadOnly = disabled || readOnly;
|
|
9
14
|
const bgColor = isReadOnly ? "bg-gray-200" : `bg-${color}-50`;
|
|
@@ -13,9 +18,12 @@ export const TextAreaWithoutValidation = (props) => {
|
|
|
13
18
|
setValue(defaultValue);
|
|
14
19
|
}, [defaultValue]);
|
|
15
20
|
if (hidden) {
|
|
16
|
-
return (_jsx("textarea", { id: id ?? name,
|
|
21
|
+
return (_jsx("textarea", { id: id ?? name, value: defaultValue, readOnly: true, hidden: true, ...(register ?? {}), name: name }));
|
|
17
22
|
}
|
|
18
23
|
const handleInputChange = (event) => {
|
|
24
|
+
if (register) {
|
|
25
|
+
register.onChange(event);
|
|
26
|
+
}
|
|
19
27
|
if (stopChangeEvents) {
|
|
20
28
|
event.stopPropagation();
|
|
21
29
|
event.preventDefault();
|
|
@@ -23,14 +31,7 @@ export const TextAreaWithoutValidation = (props) => {
|
|
|
23
31
|
setValue(event.target.value);
|
|
24
32
|
onChange && onChange(event.target.value);
|
|
25
33
|
};
|
|
26
|
-
return (_jsxs("div", { className: `col-span-6 sm:col-span-3 ${className}`, children: [title && (
|
|
34
|
+
return (_jsxs("div", { className: `col-span-6 sm:col-span-3 ${className}`, children: [title && (_jsxs("label", { htmlFor: error ? `${name}-error` : `${name}-success`, className: `block text-sm font-medium text-${color}-700 dark:text-${color}-500`, children: [title, required && _jsx("span", { className: "text-red-500", children: "*" })] })), _jsx("textarea", { readOnly: readOnly, disabled: disabled, id: id ?? name, autoComplete: "given-name", value: value, rows: rows, cols: cols, onKeyDown: (event) => {
|
|
27
35
|
onKeyDown && onKeyDown(event);
|
|
28
|
-
}, className: `mt-1 block w-full rounded-md ${bgColor} ${borderColor} ${textColor} shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm
|
|
29
|
-
};
|
|
30
|
-
//<reference> https://tailwindui.com/components/application-ui/forms/form-layouts
|
|
31
|
-
export const TextArea = (props) => {
|
|
32
|
-
const { formValidations } = useAppSelector((state) => state.formValidation);
|
|
33
|
-
const error = formValidations[props.formName ?? "-1"]?.[props.name ?? "-1"];
|
|
34
|
-
props = { ...props, error };
|
|
35
|
-
return _jsx(TextAreaWithoutValidation, { ...props });
|
|
36
|
+
}, className: `mt-1 block w-full rounded-md ${bgColor} ${borderColor} ${textColor} shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm`, ...(register ?? {}), name: name, onChange: handleInputChange }), error && (_jsxs("p", { className: `mt-2 text-sm text-${color}-600 dark:text-${color}-500`, children: [_jsx("span", { className: "font-medium", children: "Oops!" }), " ", error.message?.toString()] })), !error && hint && (_jsx("p", { className: `mt-2 italic text-sm text-${color}-500 dark:text-${color}-400`, children: hint }))] }));
|
|
36
37
|
};
|
|
@@ -1,11 +1,19 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { IdeaIconSVG } from "@zauru-sdk/icons";
|
|
3
|
-
import { useAppSelector } from "@zauru-sdk/redux";
|
|
4
3
|
import { useEffect, useState } from "react";
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
import { useFormContext } from "react-hook-form";
|
|
5
|
+
export const TextField = (props) => {
|
|
6
|
+
const { id, name, defaultValue = "", hidden, type = "text", onChange, onKeyDown, disabled = false, readOnly = false, min, integer = false, stopChangeEvents, style, title, helpText, className, hint, required, } = props;
|
|
7
7
|
const [showTooltip, setShowTooltip] = useState(false);
|
|
8
8
|
const [value, setValue] = useState(defaultValue);
|
|
9
|
+
const { register: tempRegister, formState: { errors }, } = useFormContext() || { formState: {} }; // Obtener el contexto solo si existe
|
|
10
|
+
const error = errors ? errors[props.name ?? "-1"] : undefined;
|
|
11
|
+
const register = tempRegister
|
|
12
|
+
? tempRegister(props.name ?? "-1", {
|
|
13
|
+
valueAsNumber: props.type === "number",
|
|
14
|
+
required,
|
|
15
|
+
})
|
|
16
|
+
: undefined; // Solo usar register si está disponible
|
|
9
17
|
const color = error ? "red" : "gray";
|
|
10
18
|
const isReadOnly = disabled || readOnly;
|
|
11
19
|
const bgColor = isReadOnly ? "bg-gray-200" : `bg-${color}-50`;
|
|
@@ -15,9 +23,12 @@ export const TextFieldWithoutValidation = (props) => {
|
|
|
15
23
|
setValue(defaultValue);
|
|
16
24
|
}, [defaultValue]);
|
|
17
25
|
if (hidden) {
|
|
18
|
-
return (_jsx("input", { type: type, id: id ?? name,
|
|
26
|
+
return (_jsx("input", { type: type, id: id ?? name, value: defaultValue, readOnly: true, hidden: true, ...(register ?? {}), name: name }));
|
|
19
27
|
}
|
|
20
28
|
const handleInputChange = (event) => {
|
|
29
|
+
if (register) {
|
|
30
|
+
register.onChange(event);
|
|
31
|
+
}
|
|
21
32
|
if (stopChangeEvents) {
|
|
22
33
|
event.stopPropagation();
|
|
23
34
|
event.preventDefault();
|
|
@@ -51,20 +62,14 @@ export const TextFieldWithoutValidation = (props) => {
|
|
|
51
62
|
}
|
|
52
63
|
}
|
|
53
64
|
};
|
|
54
|
-
const inputComponent = (_jsx("input", { type: type,
|
|
65
|
+
const inputComponent = (_jsx("input", { type: type, readOnly: readOnly, disabled: disabled, id: id ?? name, autoComplete: "given-name", value: value, onWheel: (e) => {
|
|
55
66
|
e.currentTarget.blur();
|
|
56
|
-
}, step: type === "number" ? 0.01 : undefined,
|
|
67
|
+
}, step: type === "number" ? 0.01 : undefined, onKeyDown: (event) => {
|
|
57
68
|
handleKeyDown(event);
|
|
58
69
|
onKeyDown && onKeyDown(event);
|
|
59
|
-
}, min: min, style: style, className: `block w-full rounded-md ${bgColor} ${borderColor} ${textColor} shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm
|
|
70
|
+
}, min: min, style: style, className: `block w-full rounded-md ${bgColor} ${borderColor} ${textColor} shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm`, ...(register ?? {}), name: name, onChange: handleInputChange }));
|
|
60
71
|
if (!error && !title) {
|
|
61
72
|
return _jsx("div", { className: `${className}`, children: inputComponent });
|
|
62
73
|
}
|
|
63
|
-
return (_jsxs("div", { className: `col-span-6 sm:col-span-3 ${className}`, children: [title && (
|
|
64
|
-
};
|
|
65
|
-
export const TextField = (props) => {
|
|
66
|
-
const { formValidations } = useAppSelector((state) => state.formValidation);
|
|
67
|
-
const error = formValidations[props.formName ?? "-1"]?.[props.name ?? "-1"];
|
|
68
|
-
props = { ...props, error };
|
|
69
|
-
return _jsx(TextFieldWithoutValidation, { ...props });
|
|
74
|
+
return (_jsxs("div", { className: `col-span-6 sm:col-span-3 ${className}`, children: [title && (_jsxs("label", { htmlFor: error ? `${name}-error` : `${name}-success`, className: `block mb-1 text-sm font-medium text-${color}-700 dark:text-${color}-500`, children: [title, required && _jsx("span", { className: "text-red-500", children: "*" })] })), _jsxs("div", { className: "flex relative items-center", children: [inputComponent, helpText && (_jsx("div", { className: "flex items-center relative ml-3", children: _jsxs("div", { className: "relative cursor-pointer", onMouseEnter: () => setShowTooltip(true), onMouseLeave: () => setShowTooltip(false), children: [_jsx(IdeaIconSVG, {}), showTooltip && (_jsx("div", { className: "absolute -left-48 top-0 mt-8 p-2 bg-white border rounded shadow text-black z-50", children: helpText }))] }) }))] }), error && (_jsxs("p", { className: `mt-2 text-sm text-${color}-600 dark:text-${color}-500`, children: [_jsx("span", { className: "font-medium", children: "Oops!" }), " ", error.message?.toString()] })), !error && hint && (_jsx("p", { className: `mt-2 italic text-sm text-${color}-500 dark:text-${color}-400`, children: hint }))] }));
|
|
70
75
|
};
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { ClockIconSVG, CloseSvgIcon, IdeaIconSVG } from "@zauru-sdk/icons";
|
|
3
|
-
import { useAppSelector } from "@zauru-sdk/redux";
|
|
4
3
|
import { useEffect, useState } from "react";
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
import { useFormContext } from "react-hook-form";
|
|
5
|
+
export const FormTimePicker = (props) => {
|
|
6
|
+
const { id, name, title, defaultValue = "", hint, helpText, onChange, tabIndex, disabled = false, required = false, } = props;
|
|
7
7
|
const [value, setValue] = useState(defaultValue);
|
|
8
8
|
const [showTooltip, setShowTooltip] = useState(false);
|
|
9
|
+
const { register: tempRegister, formState: { errors }, } = useFormContext() || { formState: {} }; // Obtener el contexto solo si existe
|
|
10
|
+
const error = errors ? errors[props.name ?? "-1"] : undefined;
|
|
11
|
+
const register = tempRegister
|
|
12
|
+
? tempRegister(props.name ?? "-1", { required })
|
|
13
|
+
: undefined; // Solo usar register si está disponible
|
|
9
14
|
const color = error ? "red" : "gray";
|
|
10
15
|
const isReadOnly = disabled;
|
|
11
16
|
const bgColor = isReadOnly ? "bg-gray-200" : `bg-${color}-50`;
|
|
@@ -18,14 +23,12 @@ export const FormTimePickerWithoutValidation = (props) => {
|
|
|
18
23
|
setValue("");
|
|
19
24
|
onChange && onChange("");
|
|
20
25
|
};
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
props = { ...props, error };
|
|
30
|
-
return _jsx(FormTimePickerWithoutValidation, { ...props });
|
|
26
|
+
const handleOnChange = (e) => {
|
|
27
|
+
setValue(e.target.value);
|
|
28
|
+
onChange && onChange(e.target.value);
|
|
29
|
+
if (register) {
|
|
30
|
+
register.onChange(e);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
return (_jsxs(_Fragment, { children: [title && (_jsxs("label", { htmlFor: error ? `${name}-error` : `${name}-success`, className: `block text-sm font-medium ${textColor}`, children: [title, required && _jsx("span", { className: "text-red-500", children: "*" })] })), _jsxs("div", { className: "flex relative items-center", children: [_jsx("div", { className: "absolute left-0 flex items-center pl-3 pointer-events-none", children: _jsx(ClockIconSVG, {}) }), _jsx("input", { id: id, tabIndex: tabIndex, type: "time", value: value, pattern: "\\d{2}:\\d{2}", className: `${bgColor} ${borderColor} ${textColor} text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full pl-10 p-2.5`, ...(register ?? {}), name: name, onChange: handleOnChange }), value && (_jsx("button", { type: "button", onClick: clearValue, className: "absolute right-0 mr-10", children: _jsx(CloseSvgIcon, {}) })), helpText && (_jsx("div", { className: "flex items-center relative ml-3", children: _jsxs("div", { className: "relative cursor-pointer", onMouseEnter: () => setShowTooltip(true), onMouseLeave: () => setShowTooltip(false), children: [_jsx(IdeaIconSVG, {}), showTooltip && (_jsx("div", { className: "absolute -left-48 top-0 mt-8 p-2 bg-white border rounded shadow text-black", children: helpText }))] }) }))] }), error && (_jsxs("p", { className: `mt-2 text-sm text-${color}-600 dark:text-${color}-500`, children: [_jsx("span", { className: "font-medium", children: "Oops!" }), " ", error.message?.toString()] })), !error && hint && (_jsx("p", { className: `mt-2 italic text-sm text-${color}-500 dark:text-${color}-400`, children: hint }))] }));
|
|
31
34
|
};
|
|
@@ -1,18 +1,24 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { useAppSelector } from "@zauru-sdk/redux";
|
|
3
2
|
import { useState } from "react";
|
|
3
|
+
import { useFormContext } from "react-hook-form";
|
|
4
4
|
export const YesNo = (props) => {
|
|
5
|
-
const { id, name, title, defaultValue = false, helpText, onChange, disabled, } = props;
|
|
6
|
-
const {
|
|
7
|
-
const error =
|
|
5
|
+
const { id, name, title, defaultValue = false, helpText, onChange, disabled, required, } = props;
|
|
6
|
+
const { register: tempRegister, formState: { errors }, } = useFormContext() || { formState: {} }; // Obtener el contexto solo si existe
|
|
7
|
+
const error = errors ? errors[props.name ?? "-1"] : undefined;
|
|
8
|
+
const register = tempRegister
|
|
9
|
+
? tempRegister(props.name ?? "-1", { required })
|
|
10
|
+
: undefined; // Solo usar register si está disponible
|
|
8
11
|
const [value, setValue] = useState(defaultValue);
|
|
9
12
|
const color = error ? "red" : "gray";
|
|
10
|
-
const handleOnChange = () => {
|
|
13
|
+
const handleOnChange = (e) => {
|
|
11
14
|
if (disabled)
|
|
12
15
|
return; // No hacer nada si está deshabilitado
|
|
16
|
+
if (register) {
|
|
17
|
+
register.onChange(e);
|
|
18
|
+
}
|
|
13
19
|
const newValue = !value;
|
|
14
20
|
setValue(newValue);
|
|
15
21
|
onChange && onChange(newValue);
|
|
16
22
|
};
|
|
17
|
-
return (_jsxs(_Fragment, { children: [_jsxs("label", { className: `relative inline-flex items-center cursor-pointer ${disabled ? "opacity-50" : ""}`, children: [_jsx("input", { type: "checkbox", id: id ?? name,
|
|
23
|
+
return (_jsxs(_Fragment, { children: [_jsxs("label", { className: `relative inline-flex items-center cursor-pointer ${disabled ? "opacity-50" : ""}`, children: [_jsx("input", { type: "checkbox", id: id ?? name, checked: value, value: value.toString(), className: "sr-only peer", disabled: disabled, ...(register ?? {}), name: name, onChange: handleOnChange }), value.toString() === "false" && (_jsx("input", { type: "hidden", name: name, value: "false" })), _jsx("div", { className: "w-11 h-6 bg-gray-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-blue-300 rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-blue-600" }), _jsx("span", { className: "ml-3 text-sm font-medium text-gray-900", children: title }), required && _jsx("span", { className: "text-red-500", children: "*" })] }), error && (_jsxs("p", { className: `mt-2 text-sm text-${color}-600 dark:text-${color}-500`, children: [_jsx("span", { className: "font-medium", children: "Oops!" }), " ", error.message?.toString()] })), !error && helpText && (_jsx("p", { className: `mt-2 italic text-sm text-${color}-500 dark:text-${color}-400`, children: helpText }))] }));
|
|
18
24
|
};
|
package/dist/esm/Form/index.js
CHANGED
|
@@ -5,10 +5,9 @@ export * from "./DynamicBaculoForm/index.js";
|
|
|
5
5
|
export * from "./FieldContainer/index.js";
|
|
6
6
|
export * from "./FileUpload/index.js";
|
|
7
7
|
export * from "./FormButtons/index.js";
|
|
8
|
-
export * from "./FormLayout/index.js";
|
|
9
8
|
export * from "./SelectField/index.js";
|
|
10
9
|
export * from "./TextArea/index.js";
|
|
11
10
|
export * from "./TextField/index.js";
|
|
12
11
|
export * from "./TimePicker/index.js";
|
|
13
12
|
export * from "./YesNo/index.js";
|
|
14
|
-
export * from "./
|
|
13
|
+
export * from "./ReactZodForm/index.js";
|
|
@@ -1,10 +1,47 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { Form } from "@remix-run/react";
|
|
3
|
+
export const HomeLayout = ({ title, description, loading, color = "green", }) => {
|
|
4
|
+
const getColorClasses = (shade) => {
|
|
5
|
+
switch (color) {
|
|
6
|
+
case "blue":
|
|
7
|
+
return `bg-blue-${shade}`;
|
|
8
|
+
case "red":
|
|
9
|
+
return `bg-red-${shade}`;
|
|
10
|
+
case "purple":
|
|
11
|
+
return `bg-purple-${shade}`;
|
|
12
|
+
case "yellow":
|
|
13
|
+
return `bg-yellow-${shade}`;
|
|
14
|
+
default:
|
|
15
|
+
return `bg-green-${shade}`;
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
const getGradientClasses = () => {
|
|
19
|
+
switch (color) {
|
|
20
|
+
case "blue":
|
|
21
|
+
return "from-blue-100 to-blue-200";
|
|
22
|
+
case "red":
|
|
23
|
+
return "from-red-100 to-red-200";
|
|
24
|
+
case "purple":
|
|
25
|
+
return "from-purple-100 to-purple-200";
|
|
26
|
+
case "yellow":
|
|
27
|
+
return "from-yellow-100 to-yellow-200";
|
|
28
|
+
default:
|
|
29
|
+
return "from-green-100 to-green-200";
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
const getButtonClasses = () => {
|
|
33
|
+
switch (color) {
|
|
34
|
+
case "blue":
|
|
35
|
+
return "bg-blue-600 hover:bg-blue-700 focus:ring-blue-500";
|
|
36
|
+
case "red":
|
|
37
|
+
return "bg-red-600 hover:bg-red-700 focus:ring-red-500";
|
|
38
|
+
case "purple":
|
|
39
|
+
return "bg-purple-600 hover:bg-purple-700 focus:ring-purple-500";
|
|
40
|
+
case "yellow":
|
|
41
|
+
return "bg-yellow-600 hover:bg-yellow-700 focus:ring-yellow-500";
|
|
42
|
+
default:
|
|
43
|
+
return "bg-green-600 hover:bg-green-700 focus:ring-green-500";
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
return (_jsxs("div", { className: `min-h-screen bg-gradient-to-br ${getGradientClasses()} flex flex-col justify-center py-12 sm:px-6 lg:px-8 relative overflow-hidden`, children: [_jsx("div", { className: `absolute top-0 left-0 w-64 h-64 ${getColorClasses(500)} rounded-full -translate-x-1/2 -translate-y-1/2 opacity-50` }), _jsx("div", { className: `absolute bottom-0 right-0 w-96 h-96 ${getColorClasses(600)} rounded-full translate-x-1/3 translate-y-1/3 opacity-40` }), _jsx("div", { className: `absolute top-1/2 left-1/4 w-48 h-48 ${getColorClasses(400)} rounded-full opacity-30` }), _jsx("div", { className: `absolute top-1/3 right-1/4 w-32 h-32 ${getColorClasses(500)} rounded-full opacity-25` }), _jsx("div", { className: `absolute bottom-1/4 left-1/3 w-40 h-40 ${getColorClasses(400)} rounded-full opacity-20` }), _jsx("div", { className: `absolute top-3/4 right-1/2 w-24 h-24 ${getColorClasses(600)} rounded-full opacity-15` }), _jsxs("div", { className: "sm:mx-auto sm:w-full sm:max-w-md relative z-10", children: [_jsx("img", { className: "mx-auto h-12 w-auto", src: "/logo.png", alt: "Zauru Logo" }), _jsx("h2", { className: "mt-6 text-center text-3xl font-extrabold text-gray-900", children: title ?? "Bienvenido" }), _jsx("p", { className: "mt-2 text-center text-sm text-gray-600", children: description ?? "Inicie sesión para acceder a su cuenta" })] }), loading ? (_jsx(_Fragment, {})) : (_jsx("div", { className: "mt-8 sm:mx-auto sm:w-full sm:max-w-md relative z-10", children: _jsx("div", { className: "bg-white bg-opacity-90 py-8 px-4 shadow-lg sm:rounded-lg sm:px-10", children: _jsx(Form, { className: "space-y-6", method: "post", action: "/login", children: _jsx("div", { children: _jsx("button", { type: "submit", className: `w-full flex justify-center py-2 px-4 border border-transparent rounded-md shadow-sm text-sm font-medium text-white ${getButtonClasses()} transition duration-150 ease-in-out`, children: "Inicie sesi\u00F3n con Zauru" }) }) }) }) }))] }));
|
|
10
47
|
};
|
package/dist/esm/Modal/Modal.js
CHANGED
|
@@ -25,8 +25,7 @@ export const createModal = ({ title, description, okButtonText, showOptions = tr
|
|
|
25
25
|
modalOverlay.classList.add("fixed", "inset-0", "bg-black", "opacity-50", "z-40");
|
|
26
26
|
document.body.appendChild(modalOverlay);
|
|
27
27
|
document.body.appendChild(modalWrapper);
|
|
28
|
-
const
|
|
29
|
-
const ModalContent = () => (_jsx("div", { className: "relative w-auto my-6 mx-auto max-w-3xl", children: _jsxs("div", { className: "border-0 rounded-lg shadow-lg relative flex flex-col w-full bg-white outline-none focus:outline-none", children: [_jsxs("div", { className: "flex items-start justify-between p-5 border-b border-solid border-slate-200 rounded-t", children: [_jsx("h3", { className: "text-3xl font-semibold", children: title }), _jsx("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", children: _jsx("span", { className: "close-button", onClick: handleClose, children: "\u00D7" }) })] }), _jsx("div", { className: "relative p-6 flex-auto", children: content }), showOptions && (_jsxs("div", { className: "flex items-center justify-end p-6 border-t border-solid border-slate-200 rounded-b", children: [_jsx("button", { 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", type: "button", onClick: handleCancel, children: "Cancelar" }), _jsx("button", { 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", type: "button", onClick: handleOk, children: okButtonText ?? "Aceptar" })] }))] }) }));
|
|
28
|
+
const ModalContent = () => (_jsx("div", { className: "relative w-auto my-6 mx-auto max-w-3xl", children: _jsxs("div", { className: "border-0 rounded-lg shadow-lg relative flex flex-col w-full bg-white outline-none focus:outline-none", children: [_jsxs("div", { className: "flex items-start justify-between p-5 border-b border-solid border-slate-200 rounded-t", children: [_jsx("h3", { className: "text-3xl font-semibold", children: title }), _jsx("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", children: _jsx("span", { className: "close-button", onClick: handleClose, children: "\u00D7" }) })] }), _jsx("div", { className: "relative p-6 flex-auto", children: description }), showOptions && (_jsxs("div", { className: "flex items-center justify-end p-6 border-t border-solid border-slate-200 rounded-b", children: [_jsx("button", { 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", type: "button", onClick: handleCancel, children: "Cancelar" }), _jsx("button", { 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", type: "button", onClick: handleOk, children: okButtonText ?? "Aceptar" })] }))] }) }));
|
|
30
29
|
const root = createRoot(modalWrapper);
|
|
31
30
|
root.render(_jsx(ModalContent, {}));
|
|
32
31
|
});
|
|
@@ -8,25 +8,20 @@ const OptionsDropDownButton = ({ color, options, name }) => {
|
|
|
8
8
|
const [showOptionsMenu, setShowOptionsMenu] = useState(true);
|
|
9
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) })] }) }) }));
|
|
10
10
|
};
|
|
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-
|
|
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
12
|
export const NavBar = ({ title, loggedIn, items, selectedColor, }) => {
|
|
13
13
|
const color = COLORS[selectedColor];
|
|
14
14
|
const [NavBarOpen, setNavBarOpen] = useState(false);
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}) })) }), _jsx("ul", { className: "sm:flex sm:flex-col ml-auto lg:flex-row", children: loggedIn ? (_jsx(OptionsDropDownButton, { color: color, options: [
|
|
15
|
+
const renderNavItems = (items) => (_jsx("div", { className: "flex flex-col lg:flex-row w-full", children: items.map((item, index) => {
|
|
16
|
+
const specialColor = item.color
|
|
17
|
+
? COLORS[item.color]
|
|
18
|
+
: undefined;
|
|
19
|
+
return (_jsx(NavItem, { name: item.name, link: item.link, icon: item.icon, specialColor: specialColor, color: color, childrens: item.childrens?.map((x) => {
|
|
20
|
+
return { ...x };
|
|
21
|
+
}) }, index));
|
|
22
|
+
}) }));
|
|
23
|
+
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: [
|
|
25
24
|
_jsx(DropDownLinkButton, { text: "Cerrar Sesi\u00F3n", path: "/logout", icon: _jsx(LogoutDropDownSvgIcon, {}), buttonHover: "hover:bg-red-100" }, 0),
|
|
26
|
-
] }))
|
|
27
|
-
|
|
28
|
-
.map((item, index) => {
|
|
29
|
-
return (_jsx(NavItem, { name: item.name, link: item.link, icon: item.icon, color: color }, index));
|
|
30
|
-
})) })] }));
|
|
31
|
-
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 absolute 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`, children: options }), _jsx("div", { className: "hidden lg:flex w-full lg:w-auto", children: options })] }) }));
|
|
25
|
+
] })) })] }));
|
|
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 })] }) }));
|
|
32
27
|
};
|
|
@@ -10,10 +10,17 @@ const customStyles = {
|
|
|
10
10
|
style: {
|
|
11
11
|
color: "#202124",
|
|
12
12
|
fontSize: "14px",
|
|
13
|
-
justifyContent: "left",
|
|
14
|
-
whiteSpace: "normal",
|
|
15
|
-
wordBreak: "break-word",
|
|
16
|
-
maxWidth: "
|
|
13
|
+
justifyContent: "left",
|
|
14
|
+
whiteSpace: "normal",
|
|
15
|
+
wordBreak: "break-word",
|
|
16
|
+
maxWidth: "250px",
|
|
17
|
+
padding: "4px", // Add some padding
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
cells: {
|
|
21
|
+
style: {
|
|
22
|
+
whiteSpace: "normal", // Allow wrapping for cell content
|
|
23
|
+
wordBreak: "break-word",
|
|
17
24
|
},
|
|
18
25
|
},
|
|
19
26
|
rows: {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
export const WithTooltip = (props) => {
|
|
3
3
|
const { children, text } = props;
|
|
4
|
-
return (
|
|
4
|
+
return (_jsxs("div", { className: "group relative inline-block", children: [children, _jsx("div", { className: "pointer-events-none absolute left-1/2 -translate-x-1/2 bottom-full mb-2 opacity-0 transition-opacity duration-300 group-hover:opacity-100", children: _jsxs("div", { className: "relative bg-black text-white text-sm rounded py-1 px-2 text-wrap w-40", children: [text, _jsx("div", { className: "absolute top-full left-1/2 -translate-x-1/2 border-4 border-transparent border-t-black" })] }) })] }));
|
|
5
5
|
};
|