@zauru-sdk/components 1.0.116 → 1.0.119
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 +24 -0
- package/dist/Buttons/Button.d.ts +0 -1
- package/dist/HOC/ValidateEmployeeAccess/index.d.ts +1 -1
- package/dist/Layouts/errorLayout/index.d.ts +3 -1
- package/dist/ProgressBar/ProgressCircle.d.ts +1 -1
- package/dist/Zendesk/Chat.d.ts +0 -1
- package/dist/esm/Form/SelectField/index.js +2 -2
- package/dist/esm/Layouts/errorLayout/index.js +6 -6
- package/dist/esm/SidePanel/index.js +1 -1
- package/package.json +8 -9
- package/src/Form/SelectField/index.tsx +19 -1
- package/src/Form/TextField/index.tsx +1 -1
- package/src/Layouts/errorLayout/index.tsx +6 -1
- package/src/SidePanel/index.tsx +26 -26
- package/dist/cjs/Alerts/ErrorBoundaryAlert/ErrorBoundaryAlert.js +0 -9
- package/dist/cjs/Alerts/StaticAlert.js +0 -32
- package/dist/cjs/Alerts/index.js +0 -18
- package/dist/cjs/BlockUI/BlockUI.js +0 -12
- package/dist/cjs/BlockUI/index.js +0 -17
- package/dist/cjs/Buttons/Button.js +0 -62
- package/dist/cjs/Buttons/index.js +0 -17
- package/dist/cjs/Card/Card.js +0 -9
- package/dist/cjs/Card/index.js +0 -17
- package/dist/cjs/Chat/ChatLayout.js +0 -31
- package/dist/cjs/Chat/ChatMessageHistory.js +0 -57
- package/dist/cjs/Chat/index.js +0 -18
- package/dist/cjs/ConnectionState/ConnectionState.js +0 -25
- package/dist/cjs/ConnectionState/index.js +0 -17
- package/dist/cjs/Containers/BodyContainer.js +0 -9
- package/dist/cjs/Containers/ButtonSectionContainer.js +0 -9
- package/dist/cjs/Containers/Container.js +0 -10
- package/dist/cjs/Containers/DoubleContainer.js +0 -18
- package/dist/cjs/Containers/MainContainer.js +0 -9
- package/dist/cjs/Containers/OutletContainer.js +0 -9
- package/dist/cjs/Containers/SubContainer.js +0 -10
- package/dist/cjs/Containers/index.js +0 -23
- package/dist/cjs/DynamicTable/BasicPrintDynamicTable.js +0 -31
- package/dist/cjs/DynamicTable/DynamicPrintTable.js +0 -158
- package/dist/cjs/DynamicTable/DynamicTable.js +0 -219
- package/dist/cjs/DynamicTable/GenericDynamicTable.js +0 -200
- package/dist/cjs/DynamicTable/index.js +0 -20
- package/dist/cjs/Footer/Footer.js +0 -20
- package/dist/cjs/Footer/index.js +0 -17
- package/dist/cjs/Form/Checkbox/index.js +0 -39
- package/dist/cjs/Form/Checklist/index.js +0 -14
- package/dist/cjs/Form/DatePicker/index.js +0 -37
- package/dist/cjs/Form/DynamicBaculoForm/index.js +0 -144
- package/dist/cjs/Form/FieldContainer/DoubleFieldContainer.js +0 -18
- package/dist/cjs/Form/FieldContainer/QuadrupleFieldContainer.js +0 -18
- package/dist/cjs/Form/FieldContainer/TripleFieldContainer.js +0 -18
- package/dist/cjs/Form/FieldContainer/index.js +0 -19
- package/dist/cjs/Form/FileUpload/index.js +0 -71
- package/dist/cjs/Form/FormButtons/index.js +0 -9
- package/dist/cjs/Form/ReactZodForm/index.js +0 -29
- package/dist/cjs/Form/SelectField/index.js +0 -176
- package/dist/cjs/Form/TextArea/index.js +0 -41
- package/dist/cjs/Form/TextField/index.js +0 -73
- package/dist/cjs/Form/TimePicker/index.js +0 -38
- package/dist/cjs/Form/YesNo/index.js +0 -28
- package/dist/cjs/Form/index.js +0 -29
- package/dist/cjs/HOC/ValidateEmployeeAccess/index.js +0 -17
- package/dist/cjs/Labels/InfoLabel/index.js +0 -9
- package/dist/cjs/Labels/index.js +0 -17
- package/dist/cjs/Layouts/errorLayout/index.js +0 -14
- package/dist/cjs/Layouts/homeLayout/index.js +0 -51
- package/dist/cjs/Layouts/index.js +0 -18
- package/dist/cjs/LineSeparator/LineSeparator.js +0 -8
- package/dist/cjs/LineSeparator/index.js +0 -17
- package/dist/cjs/Modal/Modal.js +0 -36
- package/dist/cjs/Modal/index.js +0 -17
- package/dist/cjs/NavBar/NavBar.js +0 -76
- package/dist/cjs/NavBar/NavBar.types.js +0 -2
- package/dist/cjs/NavBar/NavBar.utils.js +0 -61
- package/dist/cjs/NavBar/index.js +0 -19
- package/dist/cjs/ProgressBar/ProgressBar.js +0 -9
- package/dist/cjs/ProgressBar/ProgressCircle.js +0 -26
- package/dist/cjs/ProgressBar/index.js +0 -18
- package/dist/cjs/SidePanel/index.js +0 -48
- package/dist/cjs/Skeletons/LoadingInputSkeleton.js +0 -12
- package/dist/cjs/Skeletons/index.js +0 -17
- package/dist/cjs/Tab/Tab.js +0 -26
- package/dist/cjs/Tab/index.js +0 -17
- package/dist/cjs/Table/ZauruTable.js +0 -186
- package/dist/cjs/Table/index.js +0 -17
- package/dist/cjs/TaskList/TaskList.js +0 -40
- package/dist/cjs/TaskList/index.js +0 -17
- package/dist/cjs/Titles/LabelArray.js +0 -11
- package/dist/cjs/Titles/TableColumnTitle.js +0 -9
- package/dist/cjs/Titles/TitleH1.js +0 -9
- package/dist/cjs/Titles/TitleH2.js +0 -9
- package/dist/cjs/Titles/TitleH3.js +0 -9
- package/dist/cjs/Titles/index.js +0 -21
- package/dist/cjs/Tooltip/Tooltip.js +0 -18
- package/dist/cjs/Tooltip/index.js +0 -17
- package/dist/cjs/WithTooltip/WithTooltip.js +0 -9
- package/dist/cjs/WithTooltip/index.js +0 -17
- package/dist/cjs/Wizards/StepWizard.js +0 -18
- package/dist/cjs/Wizards/index.js +0 -17
- package/dist/cjs/Zendesk/Chat.js +0 -69
- package/dist/cjs/Zendesk/index.js +0 -18
- package/dist/cjs/Zendesk/zendesk.config.js +0 -29
- package/dist/cjs/index.js +0 -43
- package/dist/cjs/tailwind.config.js +0 -9
- package/tsconfig.cjs.json +0 -8
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FileUploadField = void 0;
|
|
4
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const icons_1 = require("@zauru-sdk/icons");
|
|
6
|
-
const react_1 = require("react");
|
|
7
|
-
const react_hook_form_1 = require("react-hook-form");
|
|
8
|
-
const FileUploadField = (props) => {
|
|
9
|
-
const { id, name, title, helpText, hint, onChange, disabled = false, readOnly = false, fileTypes = [], showAvailableTypes = false, className, defaultValue = undefined, download = false, required = false, } = props;
|
|
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
|
|
15
|
-
const [showTooltip, setShowTooltip] = (0, react_1.useState)(false);
|
|
16
|
-
if (typeof defaultValue == "string") {
|
|
17
|
-
if (download) {
|
|
18
|
-
return ((0, jsx_runtime_1.jsxs)("div", { role: "button", tabIndex: 0, onClick: () => {
|
|
19
|
-
window.open(defaultValue, "_blank");
|
|
20
|
-
}, onKeyDown: (event) => {
|
|
21
|
-
// Permite que el evento se active con la tecla Enter
|
|
22
|
-
if (event.key === "Enter") {
|
|
23
|
-
window.open(defaultValue, "_blank");
|
|
24
|
-
}
|
|
25
|
-
}, children: [title && ((0, jsx_runtime_1.jsx)("label", { htmlFor: name, className: "block mb-1 text-sm font-medium text-gray-700", children: title })), " ", (0, jsx_runtime_1.jsx)(icons_1.DownloadIconSVG, {})] }));
|
|
26
|
-
}
|
|
27
|
-
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: name, className: `block mb-1 text-sm font-medium text-gray-700`, children: [title, required && (0, jsx_runtime_1.jsx)("span", { className: "text-red-500", children: "*" })] })), " ", (0, jsx_runtime_1.jsx)("div", { role: "button", tabIndex: 0, onClick: () => {
|
|
28
|
-
if (register) {
|
|
29
|
-
register.onChange({
|
|
30
|
-
target: {
|
|
31
|
-
value: defaultValue,
|
|
32
|
-
},
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
window.open(defaultValue, "_blank");
|
|
36
|
-
}, onKeyDown: (event) => {
|
|
37
|
-
// Permite que el evento se active con la tecla Enter
|
|
38
|
-
if (event.key === "Enter") {
|
|
39
|
-
if (register) {
|
|
40
|
-
register.onChange({
|
|
41
|
-
target: {
|
|
42
|
-
value: defaultValue,
|
|
43
|
-
},
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
window.open(defaultValue, "_blank");
|
|
47
|
-
}
|
|
48
|
-
}, children: (0, jsx_runtime_1.jsx)("img", { src: defaultValue, alt: name, className: `h-48 w-48 inline mr-1 pb-1`, style: {
|
|
49
|
-
stroke: "currentColor",
|
|
50
|
-
strokeWidth: 2,
|
|
51
|
-
strokeLinecap: "round",
|
|
52
|
-
strokeLinejoin: "round",
|
|
53
|
-
fill: "none",
|
|
54
|
-
backgroundColor: "transparent",
|
|
55
|
-
} }) })] }));
|
|
56
|
-
}
|
|
57
|
-
const handleInputChange = (event) => {
|
|
58
|
-
onChange && onChange(event);
|
|
59
|
-
};
|
|
60
|
-
let hintMessage = hint;
|
|
61
|
-
if (showAvailableTypes && fileTypes.length > 0) {
|
|
62
|
-
hintMessage = `${hint} Archivos permitidos: ${fileTypes.join(", ")}`;
|
|
63
|
-
}
|
|
64
|
-
const color = error ? "red" : "gray";
|
|
65
|
-
const isReadOnly = disabled || readOnly;
|
|
66
|
-
const bgColor = isReadOnly ? "bg-gray-200" : `bg-${color}-50`;
|
|
67
|
-
const textColor = isReadOnly ? "text-gray-500" : `text-${color}-900`;
|
|
68
|
-
const borderColor = isReadOnly ? "border-gray-300" : `border-${color}-500`;
|
|
69
|
-
return ((0, jsx_runtime_1.jsxs)("div", { className: `col-span-6 sm:col-span-3 ${className}`, children: [title && ((0, jsx_runtime_1.jsx)("label", { htmlFor: name, className: `block mb-1 text-sm font-medium text-${color}-700`, children: title })), (0, jsx_runtime_1.jsxs)("div", { className: "flex relative items-center", children: [(0, jsx_runtime_1.jsx)("input", { type: "file", name: name, id: id ?? name, disabled: disabled, readOnly: readOnly, accept: fileTypes.map((ft) => `.${ft}`).join(", "), onChange: handleInputChange, className: `block w-full rounded-md ${bgColor} ${borderColor} ${textColor} shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm` }), 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`, children: [(0, jsx_runtime_1.jsx)("span", { className: "font-medium", children: "Oops!" }), " ", error.message?.toString()] })), !error && hintMessage && ((0, jsx_runtime_1.jsx)("p", { className: `mt-2 italic text-sm text-${color}-500`, children: hintMessage }))] }));
|
|
70
|
-
};
|
|
71
|
-
exports.FileUploadField = FileUploadField;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FormButtons = void 0;
|
|
4
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const FormButtons = (props) => {
|
|
6
|
-
const { saveTitle = "Guardar", saveName = "save", cancelTitle = "Cancelar", cancelName = "cancel", showCancel = true, showClear = false, clearName = "clear", clearTitle = "Limpiar", loading = false, onClickSave, loadingSaveText = "Guardando...", } = props;
|
|
7
|
-
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [showClear && ((0, jsx_runtime_1.jsx)("button", { type: "reset", name: "action", disabled: loading, value: clearName, className: `ml-5 ${loading ? " bg-opacity-25 cursor-progress" : ""} rounded-md border border-gray-300 bg-white py-2 px-3 text-sm font-medium leading-4 text-gray-700 shadow-sm hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2`, children: clearTitle })), showCancel && ((0, jsx_runtime_1.jsx)("button", { type: "button", name: "action", disabled: loading, value: cancelName, className: `${showClear ? "ml-2" : "ml-5"} ${loading ? " bg-opacity-25 cursor-progress" : ""} rounded-md border border-gray-300 bg-white py-2 px-3 text-sm font-medium leading-4 text-gray-700 shadow-sm hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2`, children: cancelTitle })), (0, jsx_runtime_1.jsx)("button", { type: "submit", name: "action", disabled: loading, value: saveName, onClick: onClickSave, className: `ml-2 ${loading ? " bg-opacity-25 cursor-progress" : "hover:bg-indigo-700"} inline-flex justify-center rounded-md border border-transparent bg-indigo-600 py-2 px-4 text-sm font-medium text-white shadow-sm focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2`, children: loading ? loadingSaveText : saveTitle })] }));
|
|
8
|
-
};
|
|
9
|
-
exports.FormButtons = FormButtons;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ReactZodForm = void 0;
|
|
4
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const zod_1 = require("@hookform/resolvers/zod");
|
|
6
|
-
const react_1 = require("@remix-run/react");
|
|
7
|
-
const react_hook_form_1 = require("react-hook-form");
|
|
8
|
-
const zod_2 = require("zod");
|
|
9
|
-
const emptySchema = zod_2.z.any();
|
|
10
|
-
const ReactZodForm = (props) => {
|
|
11
|
-
const { children, method = "post", schema = emptySchema, onSubmit, id, className, } = props;
|
|
12
|
-
const submit = (0, react_1.useSubmit)();
|
|
13
|
-
const methods = (0, react_hook_form_1.useForm)({
|
|
14
|
-
resolver: (0, zod_1.zodResolver)(schema),
|
|
15
|
-
mode: "onSubmit",
|
|
16
|
-
});
|
|
17
|
-
const handleSubmit = (data, event) => {
|
|
18
|
-
if (onSubmit) {
|
|
19
|
-
onSubmit(data, event);
|
|
20
|
-
}
|
|
21
|
-
else {
|
|
22
|
-
// If no onSubmit is provided, use Remix's submit function
|
|
23
|
-
submit(event?.target, { method });
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
return ((0, jsx_runtime_1.jsx)(react_hook_form_1.FormProvider, { ...methods, children: (0, jsx_runtime_1.jsx)(react_1.Form, { onSubmit: methods.handleSubmit(handleSubmit), method: method, id: id, className: className, children: children }) }));
|
|
27
|
-
};
|
|
28
|
-
exports.ReactZodForm = ReactZodForm;
|
|
29
|
-
exports.default = exports.ReactZodForm;
|
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SelectField = void 0;
|
|
4
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const icons_1 = require("@zauru-sdk/icons");
|
|
6
|
-
const react_1 = require("react");
|
|
7
|
-
const index_js_1 = require("../../Skeletons/index.js");
|
|
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 = false, } = props;
|
|
11
|
-
const [value, setValue] = (0, react_1.useState)(defaultValue || null);
|
|
12
|
-
const [valueMulti, setValueMulti] = (0, react_1.useState)(defaultValueMulti);
|
|
13
|
-
const [inputValue, setInputValue] = (0, react_1.useState)(defaultValue?.label || "");
|
|
14
|
-
const [showTooltip, setShowTooltip] = (0, react_1.useState)(false);
|
|
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 { register: tempRegister, formState: { errors }, setValue: setFormValue, } = (0, react_hook_form_1.useFormContext)() || { formState: {} };
|
|
24
|
-
const error = errors ? errors[props.name ?? "-1"] : undefined;
|
|
25
|
-
const register = tempRegister
|
|
26
|
-
? tempRegister(props.name ?? "-1", {
|
|
27
|
-
required,
|
|
28
|
-
})
|
|
29
|
-
: undefined; // Solo usar register si está disponible
|
|
30
|
-
const color = error ? "red" : "gray";
|
|
31
|
-
const isReadOnly = disabled || readOnly;
|
|
32
|
-
const bgColor = isReadOnly ? "bg-gray-200" : `bg-${color}-50`;
|
|
33
|
-
const textColor = isReadOnly ? "text-gray-500" : `text-${color}-900`;
|
|
34
|
-
const borderColor = isReadOnly ? "border-gray-300" : `border-${color}-200`;
|
|
35
|
-
(0, react_1.useEffect)(() => {
|
|
36
|
-
setFilteredOptions(options);
|
|
37
|
-
}, [options]);
|
|
38
|
-
(0, react_1.useEffect)(() => {
|
|
39
|
-
const handleClickOutside = (event) => {
|
|
40
|
-
if (selectRef.current &&
|
|
41
|
-
!selectRef.current.contains(event.target)) {
|
|
42
|
-
setIsOpen(false);
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
if (defaultValue) {
|
|
46
|
-
setValue(defaultValue);
|
|
47
|
-
setInputValue(defaultValue.label);
|
|
48
|
-
if (setFormValue) {
|
|
49
|
-
setFormValue(name || "", defaultValue.value);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
document.addEventListener("mousedown", handleClickOutside);
|
|
53
|
-
return () => {
|
|
54
|
-
document.removeEventListener("mousedown", handleClickOutside);
|
|
55
|
-
};
|
|
56
|
-
}, []);
|
|
57
|
-
const handleInputChange = (e) => {
|
|
58
|
-
const newValue = e.target.value;
|
|
59
|
-
if (register) {
|
|
60
|
-
register.onChange(e);
|
|
61
|
-
}
|
|
62
|
-
setInputValue(newValue);
|
|
63
|
-
onInputChange && onInputChange(newValue);
|
|
64
|
-
setIsSearching(true);
|
|
65
|
-
setFilteredOptions(options.filter((option) => option.label.toLowerCase().includes(newValue.toLowerCase())));
|
|
66
|
-
};
|
|
67
|
-
const handleOptionClick = (option) => {
|
|
68
|
-
if (isMulti) {
|
|
69
|
-
const newValue = valueMulti.some((v) => v.value === option.value)
|
|
70
|
-
? valueMulti.filter((v) => v.value !== option.value)
|
|
71
|
-
: [...valueMulti, option];
|
|
72
|
-
setValueMulti(newValue);
|
|
73
|
-
onChangeMulti && onChangeMulti(newValue);
|
|
74
|
-
if (setFormValue) {
|
|
75
|
-
setFormValue(name || "", newValue.map((v) => v.value));
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
else {
|
|
79
|
-
setValue(option);
|
|
80
|
-
setInputValue(option.label);
|
|
81
|
-
onChange && onChange(option);
|
|
82
|
-
if (setFormValue) {
|
|
83
|
-
setFormValue(name || "", option.value);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
setIsOpen(false);
|
|
87
|
-
};
|
|
88
|
-
const handleClear = () => {
|
|
89
|
-
if (isMulti) {
|
|
90
|
-
setValueMulti([]);
|
|
91
|
-
onChangeMulti && onChangeMulti([]);
|
|
92
|
-
if (setFormValue) {
|
|
93
|
-
setFormValue(name || "", []);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
else {
|
|
97
|
-
setValue(null);
|
|
98
|
-
onChange && onChange(null);
|
|
99
|
-
if (setFormValue) {
|
|
100
|
-
setFormValue(name || "", "");
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
setInputValue("");
|
|
104
|
-
};
|
|
105
|
-
const handleBlur = () => {
|
|
106
|
-
setTimeout(() => {
|
|
107
|
-
if (isTabPressed &&
|
|
108
|
-
filteredOptions.length > 0 &&
|
|
109
|
-
!isEnterPressed &&
|
|
110
|
-
isSearching) {
|
|
111
|
-
if (highlightedIndex >= 0) {
|
|
112
|
-
handleOptionClick(filteredOptions[highlightedIndex]);
|
|
113
|
-
}
|
|
114
|
-
else {
|
|
115
|
-
handleOptionClick(filteredOptions[0]);
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
setIsTabPressed(false);
|
|
119
|
-
setIsEnterPressed(false);
|
|
120
|
-
setIsSearching(false);
|
|
121
|
-
setIsOpen(false);
|
|
122
|
-
}, 200);
|
|
123
|
-
};
|
|
124
|
-
const handleKeyDown = (e) => {
|
|
125
|
-
if (e.key === "Tab") {
|
|
126
|
-
setIsTabPressed(true);
|
|
127
|
-
}
|
|
128
|
-
else if (e.key === "ArrowDown") {
|
|
129
|
-
e.preventDefault();
|
|
130
|
-
setHighlightedIndex((prevIndex) => prevIndex < filteredOptions.length - 1 ? prevIndex + 1 : 0);
|
|
131
|
-
scrollToHighlightedOption();
|
|
132
|
-
}
|
|
133
|
-
else if (e.key === "ArrowUp") {
|
|
134
|
-
e.preventDefault();
|
|
135
|
-
setHighlightedIndex((prevIndex) => prevIndex > 0 ? prevIndex - 1 : filteredOptions.length - 1);
|
|
136
|
-
scrollToHighlightedOption();
|
|
137
|
-
}
|
|
138
|
-
else if (e.key === "Enter" && highlightedIndex !== -1) {
|
|
139
|
-
e.preventDefault();
|
|
140
|
-
setIsEnterPressed(true);
|
|
141
|
-
handleOptionClick(filteredOptions[highlightedIndex]);
|
|
142
|
-
}
|
|
143
|
-
else if (e.key === "Backspace" && (value || valueMulti.length > 0)) {
|
|
144
|
-
e.preventDefault();
|
|
145
|
-
handleClear();
|
|
146
|
-
setInputValue("");
|
|
147
|
-
setFilteredOptions(options);
|
|
148
|
-
setIsOpen(true);
|
|
149
|
-
}
|
|
150
|
-
};
|
|
151
|
-
const scrollToHighlightedOption = () => {
|
|
152
|
-
if (optionsRef.current && optionsRef.current.children[highlightedIndex]) {
|
|
153
|
-
const highlightedOption = optionsRef.current.children[highlightedIndex];
|
|
154
|
-
highlightedOption.scrollIntoView({
|
|
155
|
-
block: "center",
|
|
156
|
-
inline: "center",
|
|
157
|
-
behavior: "smooth",
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
};
|
|
161
|
-
if (loading) {
|
|
162
|
-
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 }))] }));
|
|
163
|
-
}
|
|
164
|
-
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"
|
|
165
|
-
? "text-red-700 dark:text-red-500"
|
|
166
|
-
: "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)("input", { type: "text", id: id, value: inputValue, onFocus: () => setIsOpen(true), 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...", autoComplete: "off", onChange: handleInputChange, onBlur: handleBlur, required: required }), (0, jsx_runtime_1.jsx)("input", { type: "hidden", ...(register ?? {}), name: name, value: isMulti
|
|
167
|
-
? valueMulti.map((v) => v.value).join(",")
|
|
168
|
-
: value?.value || "" }), 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
|
|
169
|
-
? valueMulti.some((v) => v.value === option.value)
|
|
170
|
-
: value?.value === option.value)
|
|
171
|
-
? "text-white bg-indigo-600"
|
|
172
|
-
: index === highlightedIndex
|
|
173
|
-
? "text-black bg-sky-200"
|
|
174
|
-
: "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 }))] }));
|
|
175
|
-
};
|
|
176
|
-
exports.SelectField = SelectField;
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TextArea = void 0;
|
|
4
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const react_1 = require("react");
|
|
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
|
-
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
|
|
15
|
-
const color = error ? "red" : "gray";
|
|
16
|
-
const isReadOnly = disabled || readOnly;
|
|
17
|
-
const bgColor = isReadOnly ? "bg-gray-200" : `bg-${color}-50`;
|
|
18
|
-
const textColor = isReadOnly ? "text-gray-500" : `text-${color}-900`;
|
|
19
|
-
const borderColor = isReadOnly ? "border-gray-300" : `border-${color}-500`;
|
|
20
|
-
(0, react_1.useEffect)(() => {
|
|
21
|
-
setValue(defaultValue);
|
|
22
|
-
}, [defaultValue]);
|
|
23
|
-
if (hidden) {
|
|
24
|
-
return ((0, jsx_runtime_1.jsx)("textarea", { id: id ?? name, value: defaultValue, readOnly: true, hidden: true, ...(register ?? {}), name: name }));
|
|
25
|
-
}
|
|
26
|
-
const handleInputChange = (event) => {
|
|
27
|
-
if (register) {
|
|
28
|
-
register.onChange(event);
|
|
29
|
-
}
|
|
30
|
-
if (stopChangeEvents) {
|
|
31
|
-
event.stopPropagation();
|
|
32
|
-
event.preventDefault();
|
|
33
|
-
}
|
|
34
|
-
setValue(event.target.value);
|
|
35
|
-
onChange && onChange(event.target.value);
|
|
36
|
-
};
|
|
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) => {
|
|
38
|
-
onKeyDown && onKeyDown(event);
|
|
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
|
-
};
|
|
41
|
-
exports.TextArea = TextArea;
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TextField = void 0;
|
|
4
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const icons_1 = require("@zauru-sdk/icons");
|
|
6
|
-
const react_1 = require("react");
|
|
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
|
-
const [showTooltip, setShowTooltip] = (0, react_1.useState)(false);
|
|
11
|
-
const [value, setValue] = (0, react_1.useState)(defaultValue);
|
|
12
|
-
const { register: tempRegister, formState: { errors }, setValue: setOnFormValue, } = (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
|
|
20
|
-
const color = error ? "red" : "gray";
|
|
21
|
-
const isReadOnly = disabled || readOnly;
|
|
22
|
-
const bgColor = isReadOnly ? "bg-gray-200" : `bg-${color}-50`;
|
|
23
|
-
const textColor = isReadOnly ? "text-gray-500" : `text-${color}-900`;
|
|
24
|
-
const borderColor = isReadOnly ? "border-gray-300" : `border-${color}-200`;
|
|
25
|
-
(0, react_1.useEffect)(() => {
|
|
26
|
-
if (setOnFormValue) {
|
|
27
|
-
setOnFormValue(name ?? "-1", defaultValue);
|
|
28
|
-
}
|
|
29
|
-
setValue(defaultValue);
|
|
30
|
-
}, [defaultValue]);
|
|
31
|
-
const handleInputChange = (event) => {
|
|
32
|
-
const newValue = event.target.value;
|
|
33
|
-
if (register) {
|
|
34
|
-
register.onChange(event);
|
|
35
|
-
}
|
|
36
|
-
if (stopChangeEvents) {
|
|
37
|
-
event.stopPropagation();
|
|
38
|
-
event.preventDefault();
|
|
39
|
-
}
|
|
40
|
-
setValue(newValue);
|
|
41
|
-
onChange && onChange(newValue, event);
|
|
42
|
-
};
|
|
43
|
-
const handleKeyDown = (event) => {
|
|
44
|
-
if (integer && type === "number") {
|
|
45
|
-
// Permitir solo números y teclas de control
|
|
46
|
-
const allowedKeys = [
|
|
47
|
-
"Backspace",
|
|
48
|
-
"ArrowLeft",
|
|
49
|
-
"ArrowRight",
|
|
50
|
-
"Delete",
|
|
51
|
-
"Enter",
|
|
52
|
-
"Tab",
|
|
53
|
-
];
|
|
54
|
-
if (!allowedKeys.includes(event.key) && !/^[0-9]$/.test(event.key)) {
|
|
55
|
-
event.preventDefault();
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
if (hidden) {
|
|
60
|
-
return ((0, jsx_runtime_1.jsx)("input", { type: type, id: id ?? name, value: value, hidden: true, ...(register ?? {}), name: name, onChange: handleInputChange }));
|
|
61
|
-
}
|
|
62
|
-
const inputComponent = ((0, jsx_runtime_1.jsx)("input", { type: type, readOnly: isReadOnly, disabled: disabled, id: id ?? name, autoComplete: "off", value: value, onWheel: (e) => {
|
|
63
|
-
e.currentTarget.blur();
|
|
64
|
-
}, step: type === "number" ? 0.01 : undefined, onKeyDown: (event) => {
|
|
65
|
-
handleKeyDown(event);
|
|
66
|
-
onKeyDown && onKeyDown(event);
|
|
67
|
-
}, 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 }));
|
|
68
|
-
if (!error && !title) {
|
|
69
|
-
return (0, jsx_runtime_1.jsx)("div", { className: `${className}`, children: inputComponent });
|
|
70
|
-
}
|
|
71
|
-
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 }))] }));
|
|
72
|
-
};
|
|
73
|
-
exports.TextField = TextField;
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FormTimePicker = void 0;
|
|
4
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const icons_1 = require("@zauru-sdk/icons");
|
|
6
|
-
const react_1 = require("react");
|
|
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
|
-
const [value, setValue] = (0, react_1.useState)(defaultValue);
|
|
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
|
|
17
|
-
const color = error ? "red" : "gray";
|
|
18
|
-
const isReadOnly = disabled;
|
|
19
|
-
const bgColor = isReadOnly ? "bg-gray-200" : `bg-${color}-50`;
|
|
20
|
-
const textColor = isReadOnly ? "text-gray-500" : `text-${color}-900`;
|
|
21
|
-
const borderColor = isReadOnly ? "border-gray-300" : `border-${color}-200`;
|
|
22
|
-
(0, react_1.useEffect)(() => {
|
|
23
|
-
setValue(defaultValue);
|
|
24
|
-
}, [defaultValue]);
|
|
25
|
-
const clearValue = () => {
|
|
26
|
-
setValue("");
|
|
27
|
-
onChange && onChange("");
|
|
28
|
-
};
|
|
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 }))] }));
|
|
37
|
-
};
|
|
38
|
-
exports.FormTimePicker = FormTimePicker;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.YesNo = void 0;
|
|
4
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const react_1 = require("react");
|
|
6
|
-
const react_hook_form_1 = require("react-hook-form");
|
|
7
|
-
const YesNo = (props) => {
|
|
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
|
|
14
|
-
const [value, setValue] = (0, react_1.useState)(defaultValue);
|
|
15
|
-
const color = error ? "red" : "gray";
|
|
16
|
-
const handleOnChange = (e) => {
|
|
17
|
-
if (disabled)
|
|
18
|
-
return; // No hacer nada si está deshabilitado
|
|
19
|
-
if (register) {
|
|
20
|
-
register.onChange(e);
|
|
21
|
-
}
|
|
22
|
-
const newValue = !value;
|
|
23
|
-
setValue(newValue);
|
|
24
|
-
onChange && onChange(newValue);
|
|
25
|
-
};
|
|
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 }))] }));
|
|
27
|
-
};
|
|
28
|
-
exports.YesNo = YesNo;
|
package/dist/cjs/Form/index.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./Checkbox/index.js"), exports);
|
|
18
|
-
__exportStar(require("./Checklist/index.js"), exports);
|
|
19
|
-
__exportStar(require("./DatePicker/index.js"), exports);
|
|
20
|
-
__exportStar(require("./DynamicBaculoForm/index.js"), exports);
|
|
21
|
-
__exportStar(require("./FieldContainer/index.js"), exports);
|
|
22
|
-
__exportStar(require("./FileUpload/index.js"), exports);
|
|
23
|
-
__exportStar(require("./FormButtons/index.js"), exports);
|
|
24
|
-
__exportStar(require("./SelectField/index.js"), exports);
|
|
25
|
-
__exportStar(require("./TextArea/index.js"), exports);
|
|
26
|
-
__exportStar(require("./TextField/index.js"), exports);
|
|
27
|
-
__exportStar(require("./TimePicker/index.js"), exports);
|
|
28
|
-
__exportStar(require("./YesNo/index.js"), exports);
|
|
29
|
-
__exportStar(require("./ReactZodForm/index.js"), exports);
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ValidateEmployeeAccess = void 0;
|
|
4
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const hooks_1 = require("@zauru-sdk/hooks");
|
|
6
|
-
const react_1 = require("@remix-run/react");
|
|
7
|
-
const ValidateEmployeeAccess = ({ children, permissionVariableName, showIfNoPermission = false, }) => {
|
|
8
|
-
const { data: employee } = (0, hooks_1.useGetEmployeeProfile)();
|
|
9
|
-
const variable_string = (0, hooks_1.useGetSessionAttribute)(permissionVariableName, "sessionVariable");
|
|
10
|
-
const variable = variable_string?.split(",");
|
|
11
|
-
const hasPermission = variable?.includes(employee?.id?.toString() || "-1");
|
|
12
|
-
if (showIfNoPermission && !hasPermission) {
|
|
13
|
-
return ((0, jsx_runtime_1.jsxs)("div", { className: "bg-gray-900 text-white min-h-screen flex flex-col items-center justify-center p-4", children: [(0, jsx_runtime_1.jsx)("img", { src: "/logo.png", alt: "Zauru Logo", className: "mb-8 h-20" }), (0, jsx_runtime_1.jsx)("h1", { className: "text-5xl font-extrabold text-red-500 mb-6", children: "\u00A1Acceso Denegado!" }), (0, jsx_runtime_1.jsx)("div", { className: "w-full max-w-2xl", children: (0, jsx_runtime_1.jsx)("p", { className: "text-2xl text-gray-300 mb-8 text-center", children: "Lo sentimos, no tienes permiso para acceder a esta p\u00E1gina." }) }), (0, jsx_runtime_1.jsx)(react_1.Link, { to: "/", className: "bg-blue-600 text-white py-3 px-8 rounded-full text-lg font-semibold hover:bg-blue-700 transition duration-300 transform hover:scale-105", children: "Regresar al inicio" }), (0, jsx_runtime_1.jsx)("div", { className: "mt-12 text-gray-500", children: (0, jsx_runtime_1.jsx)("p", { children: "Si crees que esto es un error, por favor contacta a soporte." }) })] }));
|
|
14
|
-
}
|
|
15
|
-
return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: hasPermission ? children : null });
|
|
16
|
-
};
|
|
17
|
-
exports.ValidateEmployeeAccess = ValidateEmployeeAccess;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.InfoLabel = void 0;
|
|
4
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const InfoLabel = (props) => {
|
|
6
|
-
const { description, title, className } = props;
|
|
7
|
-
return ((0, jsx_runtime_1.jsxs)("div", { className: `block ${className}`, children: [(0, jsx_runtime_1.jsx)("label", { className: "inline text-sm font-medium text-gray-700", children: `${title.toUpperCase()} ` }), (0, jsx_runtime_1.jsx)("label", { className: "inline text-sm font-medium text-gray-500", children: description })] }));
|
|
8
|
-
};
|
|
9
|
-
exports.InfoLabel = InfoLabel;
|
package/dist/cjs/Labels/index.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./InfoLabel/index.js"), exports);
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ErrorLayout = void 0;
|
|
4
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const react_1 = require("@remix-run/react");
|
|
6
|
-
const ErrorLayout = () => {
|
|
7
|
-
const error = (0, react_1.useRouteError)();
|
|
8
|
-
return ((0, jsx_runtime_1.jsxs)("html", { lang: "es", className: "bg-gray-900 text-white", children: [(0, jsx_runtime_1.jsxs)("head", { children: [(0, jsx_runtime_1.jsx)("meta", { charSet: "utf-8" }), (0, jsx_runtime_1.jsx)("meta", { name: "viewport", content: "width=device-width, initial-scale=1" }), (0, jsx_runtime_1.jsx)("title", { children: "\u00A1Ups! Algo sali\u00F3 mal" }), (0, jsx_runtime_1.jsx)(react_1.Meta, {}), (0, jsx_runtime_1.jsx)(react_1.Links, {})] }), (0, jsx_runtime_1.jsxs)("body", { className: "min-h-screen flex flex-col items-center justify-center p-4", children: [(0, jsx_runtime_1.jsx)("img", { src: "/logo.png", alt: "Zauru Logo", className: "mb-8 h-20" }), (0, jsx_runtime_1.jsx)("h1", { className: "text-5xl font-extrabold text-red-500 mb-6", children: "\u00A1Ups!" }), (0, jsx_runtime_1.jsx)("div", { className: "w-full max-w-2xl", children: (0, jsx_runtime_1.jsx)("p", { className: "text-2xl text-gray-300 mb-8 text-center", children: (0, react_1.isRouteErrorResponse)(error)
|
|
9
|
-
? `Error ${error.status}: ${error.statusText}`
|
|
10
|
-
: error instanceof Error
|
|
11
|
-
? error.message
|
|
12
|
-
: "Ha ocurrido un error inesperado" }) }), (0, jsx_runtime_1.jsx)(react_1.Link, { to: "/", className: "bg-blue-600 text-white py-3 px-8 rounded-full text-lg font-semibold hover:bg-blue-700 transition duration-300 transform hover:scale-105", children: "Regresar al inicio" }), (0, jsx_runtime_1.jsx)("div", { className: "mt-12 text-gray-500", children: (0, jsx_runtime_1.jsx)("p", { children: "Si el problema persiste, por favor contacta a soporte." }) }), (0, jsx_runtime_1.jsx)(react_1.Scripts, {})] })] }));
|
|
13
|
-
};
|
|
14
|
-
exports.ErrorLayout = ErrorLayout;
|