@zauru-sdk/components 1.0.98 → 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 +16 -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 +9 -6
- 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,102 +1,147 @@
|
|
|
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
|
-
};
|
|
25
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.SelectField =
|
|
3
|
+
exports.SelectField = void 0;
|
|
27
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
28
5
|
const icons_1 = require("@zauru-sdk/icons");
|
|
29
|
-
const redux_1 = require("@zauru-sdk/redux");
|
|
30
6
|
const react_1 = require("react");
|
|
31
|
-
const react_select_1 = __importStar(require("react-select"));
|
|
32
7
|
const index_js_1 = require("../../Skeletons/index.js");
|
|
33
|
-
const
|
|
34
|
-
const
|
|
35
|
-
const { id, name, title, defaultValue, defaultValueMulti = [], helpText, hint, options, onChange, onChangeMulti, isClearable = false,
|
|
8
|
+
const react_hook_form_1 = require("react-hook-form");
|
|
9
|
+
const SelectField = (props) => {
|
|
10
|
+
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;
|
|
36
11
|
const [value, setValue] = (0, react_1.useState)(defaultValue || null);
|
|
37
12
|
const [valueMulti, setValueMulti] = (0, react_1.useState)(defaultValueMulti);
|
|
38
|
-
const [inputValue, setInputValue] = (0, react_1.useState)("");
|
|
13
|
+
const [inputValue, setInputValue] = (0, react_1.useState)(defaultValue?.label || "");
|
|
39
14
|
const [showTooltip, setShowTooltip] = (0, react_1.useState)(false);
|
|
40
|
-
const [
|
|
41
|
-
const
|
|
15
|
+
const [isOpen, setIsOpen] = (0, react_1.useState)(false);
|
|
16
|
+
const [filteredOptions, setFilteredOptions] = (0, react_1.useState)(options);
|
|
17
|
+
const [highlightedIndex, setHighlightedIndex] = (0, react_1.useState)(-1);
|
|
18
|
+
const selectRef = (0, react_1.useRef)(null);
|
|
19
|
+
const optionsRef = (0, react_1.useRef)(null);
|
|
20
|
+
const [isTabPressed, setIsTabPressed] = (0, react_1.useState)(false);
|
|
21
|
+
const [isEnterPressed, setIsEnterPressed] = (0, react_1.useState)(false);
|
|
22
|
+
const [isSearching, setIsSearching] = (0, react_1.useState)(false);
|
|
23
|
+
const { control, formState: { errors }, setValue: setFormValue, } = (0, react_hook_form_1.useFormContext)() || { formState: {} };
|
|
24
|
+
const error = errors ? errors[props.name ?? "-1"] : undefined;
|
|
42
25
|
const color = error ? "red" : "gray";
|
|
43
|
-
let documentRef = null;
|
|
44
26
|
const isReadOnly = disabled || readOnly;
|
|
45
27
|
const bgColor = isReadOnly ? "bg-gray-200" : `bg-${color}-50`;
|
|
46
28
|
const textColor = isReadOnly ? "text-gray-500" : `text-${color}-900`;
|
|
47
29
|
const borderColor = isReadOnly ? "border-gray-300" : `border-${color}-500`;
|
|
48
|
-
if (typeof window !== "undefined") {
|
|
49
|
-
documentRef = document;
|
|
50
|
-
}
|
|
51
30
|
(0, react_1.useEffect)(() => {
|
|
52
|
-
|
|
53
|
-
}, [
|
|
31
|
+
setFilteredOptions(options);
|
|
32
|
+
}, [options]);
|
|
54
33
|
(0, react_1.useEffect)(() => {
|
|
55
|
-
|
|
34
|
+
const handleClickOutside = (event) => {
|
|
35
|
+
if (selectRef.current &&
|
|
36
|
+
!selectRef.current.contains(event.target)) {
|
|
37
|
+
setIsOpen(false);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
if (defaultValue) {
|
|
41
|
+
setValue(defaultValue);
|
|
42
|
+
setInputValue(defaultValue.label);
|
|
43
|
+
setFormValue(name || "", defaultValue);
|
|
44
|
+
}
|
|
45
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
46
|
+
return () => {
|
|
47
|
+
document.removeEventListener("mousedown", handleClickOutside);
|
|
48
|
+
};
|
|
56
49
|
}, []);
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
50
|
+
const handleInputChange = (e) => {
|
|
51
|
+
const newValue = e.target.value;
|
|
52
|
+
setInputValue(newValue);
|
|
53
|
+
onInputChange && onInputChange(newValue);
|
|
54
|
+
setIsSearching(true);
|
|
55
|
+
setFilteredOptions(options.filter((option) => option.label.toLowerCase().includes(newValue.toLowerCase())));
|
|
56
|
+
};
|
|
57
|
+
const handleOptionClick = (option) => {
|
|
58
|
+
if (isMulti) {
|
|
59
|
+
const newValue = valueMulti.some((v) => v.value === option.value)
|
|
60
|
+
? valueMulti.filter((v) => v.value !== option.value)
|
|
61
|
+
: [...valueMulti, option];
|
|
62
|
+
setValueMulti(newValue);
|
|
63
|
+
onChangeMulti && onChangeMulti(newValue);
|
|
64
|
+
setFormValue(name || "", newValue);
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
setValue(option);
|
|
68
|
+
setInputValue(option.label);
|
|
69
|
+
onChange && onChange(option);
|
|
70
|
+
setFormValue(name || "", option);
|
|
71
|
+
}
|
|
72
|
+
setIsOpen(false);
|
|
73
|
+
};
|
|
74
|
+
const handleClear = () => {
|
|
75
|
+
if (isMulti) {
|
|
76
|
+
setValueMulti([]);
|
|
77
|
+
onChangeMulti && onChangeMulti([]);
|
|
78
|
+
setFormValue(name || "", []);
|
|
68
79
|
}
|
|
69
80
|
else {
|
|
70
81
|
setValue(null);
|
|
71
82
|
onChange && onChange(null);
|
|
83
|
+
setFormValue(name || "", null);
|
|
72
84
|
}
|
|
85
|
+
setInputValue("");
|
|
86
|
+
};
|
|
87
|
+
const handleBlur = () => {
|
|
88
|
+
setTimeout(() => {
|
|
89
|
+
if (isTabPressed &&
|
|
90
|
+
filteredOptions.length > 0 &&
|
|
91
|
+
!isEnterPressed &&
|
|
92
|
+
isSearching) {
|
|
93
|
+
handleOptionClick(filteredOptions[0]);
|
|
94
|
+
}
|
|
95
|
+
setIsTabPressed(false);
|
|
96
|
+
setIsEnterPressed(false);
|
|
97
|
+
setIsSearching(false);
|
|
98
|
+
setIsOpen(false);
|
|
99
|
+
}, 200);
|
|
73
100
|
};
|
|
74
|
-
const
|
|
75
|
-
if (
|
|
76
|
-
|
|
77
|
-
onChangeMulti &&
|
|
78
|
-
onChangeMulti(selection);
|
|
101
|
+
const handleKeyDown = (e) => {
|
|
102
|
+
if (e.key === "Tab") {
|
|
103
|
+
setIsTabPressed(true);
|
|
79
104
|
}
|
|
80
|
-
else {
|
|
81
|
-
|
|
82
|
-
|
|
105
|
+
else if (e.key === "ArrowDown") {
|
|
106
|
+
e.preventDefault();
|
|
107
|
+
setHighlightedIndex((prevIndex) => prevIndex < filteredOptions.length - 1 ? prevIndex + 1 : 0);
|
|
108
|
+
scrollToHighlightedOption();
|
|
109
|
+
}
|
|
110
|
+
else if (e.key === "ArrowUp") {
|
|
111
|
+
e.preventDefault();
|
|
112
|
+
setHighlightedIndex((prevIndex) => prevIndex > 0 ? prevIndex - 1 : filteredOptions.length - 1);
|
|
113
|
+
scrollToHighlightedOption();
|
|
114
|
+
}
|
|
115
|
+
else if (e.key === "Enter" && highlightedIndex !== -1) {
|
|
116
|
+
e.preventDefault();
|
|
117
|
+
setIsEnterPressed(true);
|
|
118
|
+
handleOptionClick(filteredOptions[highlightedIndex]);
|
|
83
119
|
}
|
|
84
120
|
};
|
|
85
|
-
const
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
121
|
+
const scrollToHighlightedOption = () => {
|
|
122
|
+
if (optionsRef.current && optionsRef.current.children[highlightedIndex]) {
|
|
123
|
+
const highlightedOption = optionsRef.current.children[highlightedIndex];
|
|
124
|
+
highlightedOption.scrollIntoView({
|
|
125
|
+
block: "center",
|
|
126
|
+
inline: "center",
|
|
127
|
+
behavior: "smooth",
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
if (loading) {
|
|
132
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [title && ((0, jsx_runtime_1.jsx)("label", { htmlFor: error ? `${name}-error` : `${name}-success`, className: `block text-sm font-medium text-${color}-700 dark:text-${color}-500`, children: title })), (0, jsx_runtime_1.jsx)(index_js_1.LoadingInputSkeleton, {}), helpText && ((0, jsx_runtime_1.jsx)("p", { className: `mt-2 italic text-sm text-${color}-500 dark:text-${color}-400`, children: helpText }))] }));
|
|
133
|
+
}
|
|
134
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: `col-span-6 sm:col-span-3 ${className}`, ref: selectRef, children: [title && ((0, jsx_runtime_1.jsxs)("label", { htmlFor: error ? `${name}-error` : `${name}-success`, className: `block text-sm font-medium ${color === "red"
|
|
92
135
|
? "text-red-700 dark:text-red-500"
|
|
93
|
-
: "text-gray-700 dark:text-gray-500"}`, children: title
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
136
|
+
: "text-gray-700 dark:text-gray-500"}`, children: [title, required && (0, jsx_runtime_1.jsx)("span", { className: "text-red-500", children: "*" })] })), (0, jsx_runtime_1.jsxs)("div", { className: "relative", children: [(0, jsx_runtime_1.jsx)(react_hook_form_1.Controller, { name: name || "", control: control, rules: { required }, defaultValue: defaultValue || (isMulti ? [] : null), render: ({ field }) => ((0, jsx_runtime_1.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) => {
|
|
137
|
+
field.onChange(e);
|
|
138
|
+
handleInputChange(e);
|
|
139
|
+
} })) }), isClearable && (value || valueMulti.length > 0) && ((0, jsx_runtime_1.jsx)("button", { type: "button", onClick: handleClear, className: "absolute inset-y-0 right-0 pr-3 flex items-center", children: "\u00D7" })), isOpen && !isReadOnly && ((0, jsx_runtime_1.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) => ((0, jsx_runtime_1.jsx)("li", { className: `cursor-pointer select-none relative py-2 pl-3 pr-9 ${(isMulti
|
|
140
|
+
? valueMulti.some((v) => v.value === option.value)
|
|
141
|
+
: value?.value === option.value)
|
|
142
|
+
? "text-white bg-indigo-600"
|
|
143
|
+
: index === highlightedIndex
|
|
144
|
+
? "text-black bg-sky-200"
|
|
145
|
+
: "text-gray-900"}`, onClick: () => handleOptionClick(option), onMouseEnter: () => setHighlightedIndex(index), onMouseLeave: () => setHighlightedIndex(-1), children: option.label }, `${option.value}-${index}`))) }))] }), isMulti && ((0, jsx_runtime_1.jsx)("div", { className: "mt-2 flex flex-wrap gap-2", children: valueMulti.map((option, index) => ((0, jsx_runtime_1.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, (0, jsx_runtime_1.jsx)("button", { type: "button", onClick: () => handleOptionClick(option), className: "ml-1 text-blue-600 hover:text-blue-800", children: "\u00D7" })] }, `${option.value}-${index}`))) })), helpText && ((0, jsx_runtime_1.jsx)("div", { className: "flex items-center relative mt-1", children: (0, jsx_runtime_1.jsxs)("div", { className: "relative cursor-pointer", onMouseEnter: () => setShowTooltip(true), onMouseLeave: () => setShowTooltip(false), children: [(0, jsx_runtime_1.jsx)(icons_1.IdeaIconSVG, {}), showTooltip && ((0, jsx_runtime_1.jsx)("div", { className: "absolute -left-48 top-0 mt-8 p-2 bg-white border rounded shadow text-black z-50", children: helpText }))] }) })), error && ((0, jsx_runtime_1.jsxs)("p", { className: `mt-2 text-sm text-${color}-600 dark:text-${color}-500`, children: [(0, jsx_runtime_1.jsx)("span", { className: "font-medium", children: "Oops!" }), " ", error?.message?.toString() || "Error desconocido"] })), !error && hint && ((0, jsx_runtime_1.jsx)("p", { className: `mt-2 italic text-sm text-${color}-500 dark:text-${color}-400`, children: hint }))] }));
|
|
101
146
|
};
|
|
102
147
|
exports.SelectField = SelectField;
|
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TextArea =
|
|
3
|
+
exports.TextArea = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const redux_1 = require("@zauru-sdk/redux");
|
|
6
5
|
const react_1 = require("react");
|
|
7
|
-
const
|
|
8
|
-
|
|
6
|
+
const react_hook_form_1 = require("react-hook-form");
|
|
7
|
+
const TextArea = (props) => {
|
|
8
|
+
const { id, name, title, defaultValue = "", hidden, hint, onChange, onKeyDown, disabled = false, readOnly = false, rows, cols, stopChangeEvents, className = "", required, } = props;
|
|
9
9
|
const [value, setValue] = (0, react_1.useState)(defaultValue);
|
|
10
|
+
const { register: tempRegister, formState: { errors }, } = (0, react_hook_form_1.useFormContext)() || { formState: {} }; // Obtener el contexto solo si existe
|
|
11
|
+
const error = errors ? errors[props.name ?? "-1"] : undefined;
|
|
12
|
+
const register = tempRegister
|
|
13
|
+
? tempRegister(props.name ?? "-1", { required })
|
|
14
|
+
: undefined; // Solo usar register si está disponible
|
|
10
15
|
const color = error ? "red" : "gray";
|
|
11
16
|
const isReadOnly = disabled || readOnly;
|
|
12
17
|
const bgColor = isReadOnly ? "bg-gray-200" : `bg-${color}-50`;
|
|
@@ -16,9 +21,12 @@ const TextAreaWithoutValidation = (props) => {
|
|
|
16
21
|
setValue(defaultValue);
|
|
17
22
|
}, [defaultValue]);
|
|
18
23
|
if (hidden) {
|
|
19
|
-
return ((0, jsx_runtime_1.jsx)("textarea", { id: id ?? name,
|
|
24
|
+
return ((0, jsx_runtime_1.jsx)("textarea", { id: id ?? name, value: defaultValue, readOnly: true, hidden: true, ...(register ?? {}), name: name }));
|
|
20
25
|
}
|
|
21
26
|
const handleInputChange = (event) => {
|
|
27
|
+
if (register) {
|
|
28
|
+
register.onChange(event);
|
|
29
|
+
}
|
|
22
30
|
if (stopChangeEvents) {
|
|
23
31
|
event.stopPropagation();
|
|
24
32
|
event.preventDefault();
|
|
@@ -26,16 +34,8 @@ const TextAreaWithoutValidation = (props) => {
|
|
|
26
34
|
setValue(event.target.value);
|
|
27
35
|
onChange && onChange(event.target.value);
|
|
28
36
|
};
|
|
29
|
-
return ((0, jsx_runtime_1.jsxs)("div", { className: `col-span-6 sm:col-span-3 ${className}`, children: [title && ((0, jsx_runtime_1.
|
|
37
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: `col-span-6 sm:col-span-3 ${className}`, children: [title && ((0, jsx_runtime_1.jsxs)("label", { htmlFor: error ? `${name}-error` : `${name}-success`, className: `block text-sm font-medium text-${color}-700 dark:text-${color}-500`, children: [title, required && (0, jsx_runtime_1.jsx)("span", { className: "text-red-500", children: "*" })] })), (0, jsx_runtime_1.jsx)("textarea", { readOnly: readOnly, disabled: disabled, id: id ?? name, autoComplete: "given-name", value: value, rows: rows, cols: cols, onKeyDown: (event) => {
|
|
30
38
|
onKeyDown && onKeyDown(event);
|
|
31
|
-
}, className: `mt-1 block w-full rounded-md ${bgColor} ${borderColor} ${textColor} shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm
|
|
32
|
-
};
|
|
33
|
-
exports.TextAreaWithoutValidation = TextAreaWithoutValidation;
|
|
34
|
-
//<reference> https://tailwindui.com/components/application-ui/forms/form-layouts
|
|
35
|
-
const TextArea = (props) => {
|
|
36
|
-
const { formValidations } = (0, redux_1.useAppSelector)((state) => state.formValidation);
|
|
37
|
-
const error = formValidations[props.formName ?? "-1"]?.[props.name ?? "-1"];
|
|
38
|
-
props = { ...props, error };
|
|
39
|
-
return (0, jsx_runtime_1.jsx)(exports.TextAreaWithoutValidation, { ...props });
|
|
39
|
+
}, 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 && ((0, jsx_runtime_1.jsxs)("p", { className: `mt-2 text-sm text-${color}-600 dark:text-${color}-500`, children: [(0, jsx_runtime_1.jsx)("span", { className: "font-medium", children: "Oops!" }), " ", error.message?.toString()] })), !error && hint && ((0, jsx_runtime_1.jsx)("p", { className: `mt-2 italic text-sm text-${color}-500 dark:text-${color}-400`, children: hint }))] }));
|
|
40
40
|
};
|
|
41
41
|
exports.TextArea = TextArea;
|
|
@@ -1,14 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TextField =
|
|
3
|
+
exports.TextField = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const icons_1 = require("@zauru-sdk/icons");
|
|
6
|
-
const redux_1 = require("@zauru-sdk/redux");
|
|
7
6
|
const react_1 = require("react");
|
|
8
|
-
const
|
|
9
|
-
|
|
7
|
+
const react_hook_form_1 = require("react-hook-form");
|
|
8
|
+
const TextField = (props) => {
|
|
9
|
+
const { id, name, defaultValue = "", hidden, type = "text", onChange, onKeyDown, disabled = false, readOnly = false, min, integer = false, stopChangeEvents, style, title, helpText, className, hint, required, } = props;
|
|
10
10
|
const [showTooltip, setShowTooltip] = (0, react_1.useState)(false);
|
|
11
11
|
const [value, setValue] = (0, react_1.useState)(defaultValue);
|
|
12
|
+
const { register: tempRegister, formState: { errors }, } = (0, react_hook_form_1.useFormContext)() || { formState: {} }; // Obtener el contexto solo si existe
|
|
13
|
+
const error = errors ? errors[props.name ?? "-1"] : undefined;
|
|
14
|
+
const register = tempRegister
|
|
15
|
+
? tempRegister(props.name ?? "-1", {
|
|
16
|
+
valueAsNumber: props.type === "number",
|
|
17
|
+
required,
|
|
18
|
+
})
|
|
19
|
+
: undefined; // Solo usar register si está disponible
|
|
12
20
|
const color = error ? "red" : "gray";
|
|
13
21
|
const isReadOnly = disabled || readOnly;
|
|
14
22
|
const bgColor = isReadOnly ? "bg-gray-200" : `bg-${color}-50`;
|
|
@@ -18,9 +26,12 @@ const TextFieldWithoutValidation = (props) => {
|
|
|
18
26
|
setValue(defaultValue);
|
|
19
27
|
}, [defaultValue]);
|
|
20
28
|
if (hidden) {
|
|
21
|
-
return ((0, jsx_runtime_1.jsx)("input", { type: type, id: id ?? name,
|
|
29
|
+
return ((0, jsx_runtime_1.jsx)("input", { type: type, id: id ?? name, value: defaultValue, readOnly: true, hidden: true, ...(register ?? {}), name: name }));
|
|
22
30
|
}
|
|
23
31
|
const handleInputChange = (event) => {
|
|
32
|
+
if (register) {
|
|
33
|
+
register.onChange(event);
|
|
34
|
+
}
|
|
24
35
|
if (stopChangeEvents) {
|
|
25
36
|
event.stopPropagation();
|
|
26
37
|
event.preventDefault();
|
|
@@ -54,22 +65,15 @@ const TextFieldWithoutValidation = (props) => {
|
|
|
54
65
|
}
|
|
55
66
|
}
|
|
56
67
|
};
|
|
57
|
-
const inputComponent = ((0, jsx_runtime_1.jsx)("input", { type: type,
|
|
68
|
+
const inputComponent = ((0, jsx_runtime_1.jsx)("input", { type: type, readOnly: readOnly, disabled: disabled, id: id ?? name, autoComplete: "given-name", value: value, onWheel: (e) => {
|
|
58
69
|
e.currentTarget.blur();
|
|
59
|
-
}, step: type === "number" ? 0.01 : undefined,
|
|
70
|
+
}, step: type === "number" ? 0.01 : undefined, onKeyDown: (event) => {
|
|
60
71
|
handleKeyDown(event);
|
|
61
72
|
onKeyDown && onKeyDown(event);
|
|
62
|
-
}, 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
|
|
73
|
+
}, 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 }));
|
|
63
74
|
if (!error && !title) {
|
|
64
75
|
return (0, jsx_runtime_1.jsx)("div", { className: `${className}`, children: inputComponent });
|
|
65
76
|
}
|
|
66
|
-
return ((0, jsx_runtime_1.jsxs)("div", { className: `col-span-6 sm:col-span-3 ${className}`, children: [title && ((0, jsx_runtime_1.
|
|
67
|
-
};
|
|
68
|
-
exports.TextFieldWithoutValidation = TextFieldWithoutValidation;
|
|
69
|
-
const TextField = (props) => {
|
|
70
|
-
const { formValidations } = (0, redux_1.useAppSelector)((state) => state.formValidation);
|
|
71
|
-
const error = formValidations[props.formName ?? "-1"]?.[props.name ?? "-1"];
|
|
72
|
-
props = { ...props, error };
|
|
73
|
-
return (0, jsx_runtime_1.jsx)(exports.TextFieldWithoutValidation, { ...props });
|
|
77
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: `col-span-6 sm:col-span-3 ${className}`, children: [title && ((0, jsx_runtime_1.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 && (0, jsx_runtime_1.jsx)("span", { className: "text-red-500", children: "*" })] })), (0, jsx_runtime_1.jsxs)("div", { className: "flex relative items-center", children: [inputComponent, helpText && ((0, jsx_runtime_1.jsx)("div", { className: "flex items-center relative ml-3", children: (0, jsx_runtime_1.jsxs)("div", { className: "relative cursor-pointer", onMouseEnter: () => setShowTooltip(true), onMouseLeave: () => setShowTooltip(false), children: [(0, jsx_runtime_1.jsx)(icons_1.IdeaIconSVG, {}), showTooltip && ((0, jsx_runtime_1.jsx)("div", { className: "absolute -left-48 top-0 mt-8 p-2 bg-white border rounded shadow text-black z-50", children: helpText }))] }) }))] }), error && ((0, jsx_runtime_1.jsxs)("p", { className: `mt-2 text-sm text-${color}-600 dark:text-${color}-500`, children: [(0, jsx_runtime_1.jsx)("span", { className: "font-medium", children: "Oops!" }), " ", error.message?.toString()] })), !error && hint && ((0, jsx_runtime_1.jsx)("p", { className: `mt-2 italic text-sm text-${color}-500 dark:text-${color}-400`, children: hint }))] }));
|
|
74
78
|
};
|
|
75
79
|
exports.TextField = TextField;
|
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FormTimePicker =
|
|
3
|
+
exports.FormTimePicker = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const icons_1 = require("@zauru-sdk/icons");
|
|
6
|
-
const redux_1 = require("@zauru-sdk/redux");
|
|
7
6
|
const react_1 = require("react");
|
|
8
|
-
const
|
|
9
|
-
|
|
7
|
+
const react_hook_form_1 = require("react-hook-form");
|
|
8
|
+
const FormTimePicker = (props) => {
|
|
9
|
+
const { id, name, title, defaultValue = "", hint, helpText, onChange, tabIndex, disabled = false, required = false, } = props;
|
|
10
10
|
const [value, setValue] = (0, react_1.useState)(defaultValue);
|
|
11
11
|
const [showTooltip, setShowTooltip] = (0, react_1.useState)(false);
|
|
12
|
+
const { register: tempRegister, formState: { errors }, } = (0, react_hook_form_1.useFormContext)() || { formState: {} }; // Obtener el contexto solo si existe
|
|
13
|
+
const error = errors ? errors[props.name ?? "-1"] : undefined;
|
|
14
|
+
const register = tempRegister
|
|
15
|
+
? tempRegister(props.name ?? "-1", { required })
|
|
16
|
+
: undefined; // Solo usar register si está disponible
|
|
12
17
|
const color = error ? "red" : "gray";
|
|
13
18
|
const isReadOnly = disabled;
|
|
14
19
|
const bgColor = isReadOnly ? "bg-gray-200" : `bg-${color}-50`;
|
|
@@ -21,16 +26,13 @@ const FormTimePickerWithoutValidation = (props) => {
|
|
|
21
26
|
setValue("");
|
|
22
27
|
onChange && onChange("");
|
|
23
28
|
};
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
const error = formValidations[props.formName ?? "-1"]?.[props.name ?? "-1"];
|
|
33
|
-
props = { ...props, error };
|
|
34
|
-
return (0, jsx_runtime_1.jsx)(exports.FormTimePickerWithoutValidation, { ...props });
|
|
29
|
+
const handleOnChange = (e) => {
|
|
30
|
+
setValue(e.target.value);
|
|
31
|
+
onChange && onChange(e.target.value);
|
|
32
|
+
if (register) {
|
|
33
|
+
register.onChange(e);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [title && ((0, jsx_runtime_1.jsxs)("label", { htmlFor: error ? `${name}-error` : `${name}-success`, className: `block text-sm font-medium ${textColor}`, children: [title, required && (0, jsx_runtime_1.jsx)("span", { className: "text-red-500", children: "*" })] })), (0, jsx_runtime_1.jsxs)("div", { className: "flex relative items-center", children: [(0, jsx_runtime_1.jsx)("div", { className: "absolute left-0 flex items-center pl-3 pointer-events-none", children: (0, jsx_runtime_1.jsx)(icons_1.ClockIconSVG, {}) }), (0, jsx_runtime_1.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 && ((0, jsx_runtime_1.jsx)("button", { type: "button", onClick: clearValue, className: "absolute right-0 mr-10", children: (0, jsx_runtime_1.jsx)(icons_1.CloseSvgIcon, {}) })), helpText && ((0, jsx_runtime_1.jsx)("div", { className: "flex items-center relative ml-3", children: (0, jsx_runtime_1.jsxs)("div", { className: "relative cursor-pointer", onMouseEnter: () => setShowTooltip(true), onMouseLeave: () => setShowTooltip(false), children: [(0, jsx_runtime_1.jsx)(icons_1.IdeaIconSVG, {}), showTooltip && ((0, jsx_runtime_1.jsx)("div", { className: "absolute -left-48 top-0 mt-8 p-2 bg-white border rounded shadow text-black", children: helpText }))] }) }))] }), error && ((0, jsx_runtime_1.jsxs)("p", { className: `mt-2 text-sm text-${color}-600 dark:text-${color}-500`, children: [(0, jsx_runtime_1.jsx)("span", { className: "font-medium", children: "Oops!" }), " ", error.message?.toString()] })), !error && hint && ((0, jsx_runtime_1.jsx)("p", { className: `mt-2 italic text-sm text-${color}-500 dark:text-${color}-400`, children: hint }))] }));
|
|
35
37
|
};
|
|
36
38
|
exports.FormTimePicker = FormTimePicker;
|
|
@@ -2,21 +2,27 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.YesNo = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const redux_1 = require("@zauru-sdk/redux");
|
|
6
5
|
const react_1 = require("react");
|
|
6
|
+
const react_hook_form_1 = require("react-hook-form");
|
|
7
7
|
const YesNo = (props) => {
|
|
8
|
-
const { id, name, title, defaultValue = false, helpText, onChange, disabled, } = props;
|
|
9
|
-
const {
|
|
10
|
-
const error =
|
|
8
|
+
const { id, name, title, defaultValue = false, helpText, onChange, disabled, required, } = props;
|
|
9
|
+
const { register: tempRegister, formState: { errors }, } = (0, react_hook_form_1.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
|
|
11
14
|
const [value, setValue] = (0, react_1.useState)(defaultValue);
|
|
12
15
|
const color = error ? "red" : "gray";
|
|
13
|
-
const handleOnChange = () => {
|
|
16
|
+
const handleOnChange = (e) => {
|
|
14
17
|
if (disabled)
|
|
15
18
|
return; // No hacer nada si está deshabilitado
|
|
19
|
+
if (register) {
|
|
20
|
+
register.onChange(e);
|
|
21
|
+
}
|
|
16
22
|
const newValue = !value;
|
|
17
23
|
setValue(newValue);
|
|
18
24
|
onChange && onChange(newValue);
|
|
19
25
|
};
|
|
20
|
-
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("label", { className: `relative inline-flex items-center cursor-pointer ${disabled ? "opacity-50" : ""}`, children: [(0, jsx_runtime_1.jsx)("input", { type: "checkbox", id: id ?? name,
|
|
26
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("label", { className: `relative inline-flex items-center cursor-pointer ${disabled ? "opacity-50" : ""}`, children: [(0, jsx_runtime_1.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" && ((0, jsx_runtime_1.jsx)("input", { type: "hidden", name: name, value: "false" })), (0, jsx_runtime_1.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" }), (0, jsx_runtime_1.jsx)("span", { className: "ml-3 text-sm font-medium text-gray-900", children: title }), required && (0, jsx_runtime_1.jsx)("span", { className: "text-red-500", children: "*" })] }), error && ((0, jsx_runtime_1.jsxs)("p", { className: `mt-2 text-sm text-${color}-600 dark:text-${color}-500`, children: [(0, jsx_runtime_1.jsx)("span", { className: "font-medium", children: "Oops!" }), " ", error.message?.toString()] })), !error && helpText && ((0, jsx_runtime_1.jsx)("p", { className: `mt-2 italic text-sm text-${color}-500 dark:text-${color}-400`, children: helpText }))] }));
|
|
21
27
|
};
|
|
22
28
|
exports.YesNo = YesNo;
|
package/dist/cjs/Form/index.js
CHANGED
|
@@ -21,10 +21,9 @@ __exportStar(require("./DynamicBaculoForm/index.js"), exports);
|
|
|
21
21
|
__exportStar(require("./FieldContainer/index.js"), exports);
|
|
22
22
|
__exportStar(require("./FileUpload/index.js"), exports);
|
|
23
23
|
__exportStar(require("./FormButtons/index.js"), exports);
|
|
24
|
-
__exportStar(require("./FormLayout/index.js"), exports);
|
|
25
24
|
__exportStar(require("./SelectField/index.js"), exports);
|
|
26
25
|
__exportStar(require("./TextArea/index.js"), exports);
|
|
27
26
|
__exportStar(require("./TextField/index.js"), exports);
|
|
28
27
|
__exportStar(require("./TimePicker/index.js"), exports);
|
|
29
28
|
__exportStar(require("./YesNo/index.js"), exports);
|
|
30
|
-
__exportStar(require("./
|
|
29
|
+
__exportStar(require("./ReactZodForm/index.js"), exports);
|
|
@@ -2,13 +2,50 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.HomeLayout = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
5
|
+
const react_1 = require("@remix-run/react");
|
|
6
|
+
const HomeLayout = ({ title, description, loading, color = "green", }) => {
|
|
7
|
+
const getColorClasses = (shade) => {
|
|
8
|
+
switch (color) {
|
|
9
|
+
case "blue":
|
|
10
|
+
return `bg-blue-${shade}`;
|
|
11
|
+
case "red":
|
|
12
|
+
return `bg-red-${shade}`;
|
|
13
|
+
case "purple":
|
|
14
|
+
return `bg-purple-${shade}`;
|
|
15
|
+
case "yellow":
|
|
16
|
+
return `bg-yellow-${shade}`;
|
|
17
|
+
default:
|
|
18
|
+
return `bg-green-${shade}`;
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
const getGradientClasses = () => {
|
|
22
|
+
switch (color) {
|
|
23
|
+
case "blue":
|
|
24
|
+
return "from-blue-100 to-blue-200";
|
|
25
|
+
case "red":
|
|
26
|
+
return "from-red-100 to-red-200";
|
|
27
|
+
case "purple":
|
|
28
|
+
return "from-purple-100 to-purple-200";
|
|
29
|
+
case "yellow":
|
|
30
|
+
return "from-yellow-100 to-yellow-200";
|
|
31
|
+
default:
|
|
32
|
+
return "from-green-100 to-green-200";
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
const getButtonClasses = () => {
|
|
36
|
+
switch (color) {
|
|
37
|
+
case "blue":
|
|
38
|
+
return "bg-blue-600 hover:bg-blue-700 focus:ring-blue-500";
|
|
39
|
+
case "red":
|
|
40
|
+
return "bg-red-600 hover:bg-red-700 focus:ring-red-500";
|
|
41
|
+
case "purple":
|
|
42
|
+
return "bg-purple-600 hover:bg-purple-700 focus:ring-purple-500";
|
|
43
|
+
case "yellow":
|
|
44
|
+
return "bg-yellow-600 hover:bg-yellow-700 focus:ring-yellow-500";
|
|
45
|
+
default:
|
|
46
|
+
return "bg-green-600 hover:bg-green-700 focus:ring-green-500";
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
return ((0, jsx_runtime_1.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: [(0, jsx_runtime_1.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` }), (0, jsx_runtime_1.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` }), (0, jsx_runtime_1.jsx)("div", { className: `absolute top-1/2 left-1/4 w-48 h-48 ${getColorClasses(400)} rounded-full opacity-30` }), (0, jsx_runtime_1.jsx)("div", { className: `absolute top-1/3 right-1/4 w-32 h-32 ${getColorClasses(500)} rounded-full opacity-25` }), (0, jsx_runtime_1.jsx)("div", { className: `absolute bottom-1/4 left-1/3 w-40 h-40 ${getColorClasses(400)} rounded-full opacity-20` }), (0, jsx_runtime_1.jsx)("div", { className: `absolute top-3/4 right-1/2 w-24 h-24 ${getColorClasses(600)} rounded-full opacity-15` }), (0, jsx_runtime_1.jsxs)("div", { className: "sm:mx-auto sm:w-full sm:max-w-md relative z-10", children: [(0, jsx_runtime_1.jsx)("img", { className: "mx-auto h-12 w-auto", src: "/logo.png", alt: "Zauru Logo" }), (0, jsx_runtime_1.jsx)("h2", { className: "mt-6 text-center text-3xl font-extrabold text-gray-900", children: title ?? "Bienvenido" }), (0, jsx_runtime_1.jsx)("p", { className: "mt-2 text-center text-sm text-gray-600", children: description ?? "Inicie sesión para acceder a su cuenta" })] }), loading ? ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {})) : ((0, jsx_runtime_1.jsx)("div", { className: "mt-8 sm:mx-auto sm:w-full sm:max-w-md relative z-10", children: (0, jsx_runtime_1.jsx)("div", { className: "bg-white bg-opacity-90 py-8 px-4 shadow-lg sm:rounded-lg sm:px-10", children: (0, jsx_runtime_1.jsx)(react_1.Form, { className: "space-y-6", method: "post", action: "/login", children: (0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.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" }) }) }) }) }))] }));
|
|
13
50
|
};
|
|
14
51
|
exports.HomeLayout = HomeLayout;
|
package/dist/cjs/Modal/Modal.js
CHANGED
|
@@ -28,8 +28,7 @@ const createModal = ({ title, description, okButtonText, showOptions = true, })
|
|
|
28
28
|
modalOverlay.classList.add("fixed", "inset-0", "bg-black", "opacity-50", "z-40");
|
|
29
29
|
document.body.appendChild(modalOverlay);
|
|
30
30
|
document.body.appendChild(modalWrapper);
|
|
31
|
-
const
|
|
32
|
-
const ModalContent = () => ((0, jsx_runtime_1.jsx)("div", { className: "relative w-auto my-6 mx-auto max-w-3xl", children: (0, jsx_runtime_1.jsxs)("div", { className: "border-0 rounded-lg shadow-lg relative flex flex-col w-full bg-white outline-none focus:outline-none", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex items-start justify-between p-5 border-b border-solid border-slate-200 rounded-t", children: [(0, jsx_runtime_1.jsx)("h3", { className: "text-3xl font-semibold", children: title }), (0, jsx_runtime_1.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: (0, jsx_runtime_1.jsx)("span", { className: "close-button", onClick: handleClose, children: "\u00D7" }) })] }), (0, jsx_runtime_1.jsx)("div", { className: "relative p-6 flex-auto", children: content }), showOptions && ((0, jsx_runtime_1.jsxs)("div", { className: "flex items-center justify-end p-6 border-t border-solid border-slate-200 rounded-b", children: [(0, jsx_runtime_1.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" }), (0, jsx_runtime_1.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" })] }))] }) }));
|
|
31
|
+
const ModalContent = () => ((0, jsx_runtime_1.jsx)("div", { className: "relative w-auto my-6 mx-auto max-w-3xl", children: (0, jsx_runtime_1.jsxs)("div", { className: "border-0 rounded-lg shadow-lg relative flex flex-col w-full bg-white outline-none focus:outline-none", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex items-start justify-between p-5 border-b border-solid border-slate-200 rounded-t", children: [(0, jsx_runtime_1.jsx)("h3", { className: "text-3xl font-semibold", children: title }), (0, jsx_runtime_1.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: (0, jsx_runtime_1.jsx)("span", { className: "close-button", onClick: handleClose, children: "\u00D7" }) })] }), (0, jsx_runtime_1.jsx)("div", { className: "relative p-6 flex-auto", children: description }), showOptions && ((0, jsx_runtime_1.jsxs)("div", { className: "flex items-center justify-end p-6 border-t border-solid border-slate-200 rounded-b", children: [(0, jsx_runtime_1.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" }), (0, jsx_runtime_1.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" })] }))] }) }));
|
|
33
32
|
const root = (0, client_1.createRoot)(modalWrapper);
|
|
34
33
|
root.render((0, jsx_runtime_1.jsx)(ModalContent, {}));
|
|
35
34
|
});
|