@zauru-sdk/components 1.0.52 → 1.0.53
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/dist/Alerts/ErrorBoundaryAlert/ErrorBoundaryAlert.d.ts +6 -0
- package/dist/Alerts/StaticAlert.d.ts +11 -0
- package/dist/Alerts/index.d.ts +2 -0
- package/dist/BlockUI/BlockUI.d.ts +8 -0
- package/dist/BlockUI/index.d.ts +1 -0
- package/dist/Buttons/Button.d.ts +15 -0
- package/dist/Buttons/index.d.ts +1 -0
- package/dist/Card/Card.d.ts +8 -0
- package/dist/Card/index.d.ts +1 -0
- package/dist/Chat/ChatLayout.d.ts +17 -0
- package/dist/Chat/ChatMessageHistory.d.ts +12 -0
- package/dist/Chat/index.d.ts +2 -0
- package/dist/ConnectionState/ConnectionState.d.ts +1 -0
- package/dist/ConnectionState/index.d.ts +1 -0
- package/dist/Containers/BodyContainer.d.ts +6 -0
- package/dist/Containers/ButtonSectionContainer.d.ts +8 -0
- package/dist/Containers/Container.d.ts +10 -0
- package/dist/Containers/DoubleContainer.d.ts +9 -0
- package/dist/Containers/MainContainer.d.ts +6 -0
- package/dist/Containers/OutletContainer.d.ts +6 -0
- package/dist/Containers/SubContainer.d.ts +10 -0
- package/dist/Containers/index.d.ts +7 -0
- package/dist/DynamicTable/BasicPrintDynamicTable.d.ts +10 -0
- package/dist/DynamicTable/DynamicPrintTable.d.ts +23 -0
- package/dist/DynamicTable/DynamicTable.d.ts +24 -0
- package/dist/DynamicTable/GenericDynamicTable.d.ts +21 -0
- package/dist/DynamicTable/index.d.ts +4 -0
- package/dist/Footer/Footer.d.ts +7 -0
- package/dist/Footer/index.d.ts +1 -0
- package/dist/Form/Checkbox/index.d.ts +17 -0
- package/dist/Form/Checklist/index.d.ts +14 -0
- package/dist/Form/DatePicker/index.d.ts +18 -0
- package/dist/Form/DynamicBaculoForm/index.d.ts +18 -0
- package/dist/Form/FieldContainer/DoubleFieldContainer.d.ts +8 -0
- package/dist/Form/FieldContainer/QuadrupleFieldContainer.d.ts +7 -0
- package/dist/Form/FieldContainer/TripleFieldContainer.d.ts +7 -0
- package/dist/Form/FieldContainer/index.d.ts +3 -0
- package/dist/Form/FileUpload/index.d.ts +21 -0
- package/dist/Form/FormButtons/index.d.ts +16 -0
- package/dist/Form/FormLayout/index.d.ts +11 -0
- package/dist/Form/SelectField/index.d.ts +27 -0
- package/dist/Form/TextArea/index.d.ts +23 -0
- package/dist/Form/TextField/index.d.ts +25 -0
- package/dist/Form/TimePicker/index.d.ts +16 -0
- package/dist/Form/YesNo/index.d.ts +12 -0
- package/dist/Form/index.d.ts +13 -0
- package/dist/Labels/InfoLabel/index.d.ts +7 -0
- package/dist/Labels/index.d.ts +1 -0
- package/dist/Layouts/homeLayout/index.d.ts +6 -0
- package/dist/Layouts/index.d.ts +1 -0
- package/dist/LineSeparator/LineSeparator.d.ts +1 -0
- package/dist/LineSeparator/index.d.ts +1 -0
- package/dist/Modal/Modal.d.ts +10 -0
- package/dist/Modal/index.d.ts +1 -0
- package/dist/NavBar/NavBar.d.ts +2 -0
- package/dist/NavBar/NavBar.types.d.ts +50 -0
- package/dist/NavBar/NavBar.utils.d.ts +58 -0
- package/dist/NavBar/index.d.ts +3 -0
- package/dist/ProgressBar/ProgressBar.d.ts +6 -0
- package/dist/ProgressBar/ProgressCircle.d.ts +6 -0
- package/dist/ProgressBar/index.d.ts +2 -0
- package/dist/Skeletons/LoadingInputSkeleton.d.ts +1 -0
- package/dist/Skeletons/index.d.ts +1 -0
- package/dist/Tab/Tab.d.ts +9 -0
- package/dist/Tab/index.d.ts +1 -0
- package/dist/Table/ZauruTable.d.ts +25 -0
- package/dist/Table/index.d.ts +1 -0
- package/dist/TaskList/TaskList.d.ts +14 -0
- package/dist/TaskList/index.d.ts +1 -0
- package/dist/Titles/LabelArray.d.ts +4 -0
- package/dist/Titles/TableColumnTitle.d.ts +4 -0
- package/dist/Titles/TitleH1.d.ts +1 -0
- package/dist/Titles/TitleH2.d.ts +1 -0
- package/dist/Titles/TitleH3.d.ts +1 -0
- package/dist/Titles/index.d.ts +5 -0
- package/dist/Tooltip/Tooltip.d.ts +7 -0
- package/dist/Tooltip/index.d.ts +1 -0
- package/dist/WithTooltip/WithTooltip.d.ts +7 -0
- package/dist/WithTooltip/index.d.ts +1 -0
- package/dist/Wizards/StepWizard.d.ts +14 -0
- package/dist/Wizards/index.d.ts +1 -0
- package/dist/Zendesk/Chat.d.ts +14 -0
- package/dist/Zendesk/index.d.ts +2 -0
- package/dist/Zendesk/zendesk.config.d.ts +9 -0
- package/dist/cjs/Alerts/ErrorBoundaryAlert/ErrorBoundaryAlert.js +9 -0
- package/dist/cjs/Alerts/StaticAlert.js +32 -0
- package/dist/cjs/Alerts/index.js +18 -0
- package/dist/cjs/BlockUI/BlockUI.js +12 -0
- package/dist/cjs/BlockUI/index.js +17 -0
- package/dist/cjs/Buttons/Button.js +47 -0
- package/dist/cjs/Buttons/index.js +17 -0
- package/dist/cjs/Card/Card.js +9 -0
- package/dist/cjs/Card/index.js +17 -0
- package/dist/cjs/Chat/ChatLayout.js +31 -0
- package/dist/cjs/Chat/ChatMessageHistory.js +57 -0
- package/dist/cjs/Chat/index.js +18 -0
- package/dist/cjs/ConnectionState/ConnectionState.js +25 -0
- package/dist/cjs/ConnectionState/index.js +17 -0
- package/dist/cjs/Containers/BodyContainer.js +9 -0
- package/dist/cjs/Containers/ButtonSectionContainer.js +9 -0
- package/dist/cjs/Containers/Container.js +10 -0
- package/dist/cjs/Containers/DoubleContainer.js +18 -0
- package/dist/cjs/Containers/MainContainer.js +9 -0
- package/dist/cjs/Containers/OutletContainer.js +9 -0
- package/dist/cjs/Containers/SubContainer.js +10 -0
- package/dist/cjs/Containers/index.js +23 -0
- package/dist/cjs/DynamicTable/BasicPrintDynamicTable.js +31 -0
- package/dist/cjs/DynamicTable/DynamicPrintTable.js +158 -0
- package/dist/cjs/DynamicTable/DynamicTable.js +219 -0
- package/dist/cjs/DynamicTable/GenericDynamicTable.js +200 -0
- package/dist/cjs/DynamicTable/index.js +20 -0
- package/dist/cjs/Footer/Footer.js +20 -0
- package/dist/cjs/Footer/index.js +17 -0
- package/dist/cjs/Form/Checkbox/index.js +39 -0
- package/dist/cjs/Form/Checklist/index.js +14 -0
- package/dist/cjs/Form/DatePicker/index.js +36 -0
- package/dist/cjs/Form/DynamicBaculoForm/index.js +144 -0
- package/dist/cjs/Form/FieldContainer/DoubleFieldContainer.js +18 -0
- package/dist/cjs/Form/FieldContainer/QuadrupleFieldContainer.js +18 -0
- package/dist/cjs/Form/FieldContainer/TripleFieldContainer.js +18 -0
- package/dist/cjs/Form/FieldContainer/index.js +19 -0
- package/dist/cjs/Form/FileUpload/index.js +59 -0
- package/dist/cjs/Form/FormButtons/index.js +9 -0
- package/dist/cjs/Form/FormLayout/index.js +11 -0
- package/dist/cjs/Form/SelectField/index.js +102 -0
- package/dist/cjs/Form/TextArea/index.js +41 -0
- package/dist/cjs/Form/TextField/index.js +75 -0
- package/dist/cjs/Form/TimePicker/index.js +36 -0
- package/dist/cjs/Form/YesNo/index.js +22 -0
- package/dist/cjs/Form/index.js +29 -0
- package/dist/cjs/Labels/InfoLabel/index.js +9 -0
- package/dist/cjs/Labels/index.js +17 -0
- package/dist/cjs/Layouts/homeLayout/index.js +14 -0
- package/dist/cjs/Layouts/index.js +17 -0
- package/dist/cjs/LineSeparator/LineSeparator.js +8 -0
- package/dist/cjs/LineSeparator/index.js +17 -0
- package/dist/cjs/Modal/Modal.js +36 -0
- package/dist/cjs/Modal/index.js +17 -0
- package/dist/cjs/NavBar/NavBar.js +36 -0
- package/dist/cjs/NavBar/NavBar.types.js +2 -0
- package/dist/cjs/NavBar/NavBar.utils.js +61 -0
- package/dist/cjs/NavBar/index.js +19 -0
- package/dist/cjs/ProgressBar/ProgressBar.js +9 -0
- package/dist/cjs/ProgressBar/ProgressCircle.js +26 -0
- package/dist/cjs/ProgressBar/index.js +18 -0
- package/dist/cjs/Skeletons/LoadingInputSkeleton.js +12 -0
- package/dist/cjs/Skeletons/index.js +17 -0
- package/dist/cjs/Tab/Tab.js +26 -0
- package/dist/cjs/Tab/index.js +17 -0
- package/dist/cjs/Table/ZauruTable.js +177 -0
- package/dist/cjs/Table/index.js +17 -0
- package/dist/cjs/TaskList/TaskList.js +40 -0
- package/dist/cjs/TaskList/index.js +17 -0
- package/dist/cjs/Titles/LabelArray.js +11 -0
- package/dist/cjs/Titles/TableColumnTitle.js +9 -0
- package/dist/cjs/Titles/TitleH1.js +9 -0
- package/dist/cjs/Titles/TitleH2.js +9 -0
- package/dist/cjs/Titles/TitleH3.js +9 -0
- package/dist/cjs/Titles/index.js +21 -0
- package/dist/cjs/Tooltip/Tooltip.js +18 -0
- package/dist/cjs/Tooltip/index.js +17 -0
- package/dist/cjs/WithTooltip/WithTooltip.js +9 -0
- package/dist/cjs/WithTooltip/index.js +17 -0
- package/dist/cjs/Wizards/StepWizard.js +18 -0
- package/dist/cjs/Wizards/index.js +17 -0
- package/dist/cjs/Zendesk/Chat.js +69 -0
- package/dist/cjs/Zendesk/index.js +18 -0
- package/dist/cjs/Zendesk/zendesk.config.js +31 -0
- package/dist/cjs/index.js +40 -0
- package/dist/cjs/tailwind.config.js +9 -0
- package/dist/esm/Alerts/ErrorBoundaryAlert/ErrorBoundaryAlert.js +5 -0
- package/dist/esm/Alerts/StaticAlert.js +28 -0
- package/dist/esm/Alerts/index.js +2 -0
- package/dist/esm/BlockUI/BlockUI.js +8 -0
- package/dist/esm/BlockUI/index.js +1 -0
- package/dist/esm/Buttons/Button.js +43 -0
- package/dist/esm/Buttons/index.js +1 -0
- package/dist/esm/Card/Card.js +5 -0
- package/dist/esm/Card/index.js +1 -0
- package/dist/esm/Chat/ChatLayout.js +27 -0
- package/dist/esm/Chat/ChatMessageHistory.js +53 -0
- package/dist/esm/Chat/index.js +2 -0
- package/dist/esm/ConnectionState/ConnectionState.js +21 -0
- package/dist/esm/ConnectionState/index.js +1 -0
- package/dist/esm/Containers/BodyContainer.js +5 -0
- package/dist/esm/Containers/ButtonSectionContainer.js +5 -0
- package/dist/esm/Containers/Container.js +6 -0
- package/dist/esm/Containers/DoubleContainer.js +14 -0
- package/dist/esm/Containers/MainContainer.js +5 -0
- package/dist/esm/Containers/OutletContainer.js +5 -0
- package/dist/esm/Containers/SubContainer.js +6 -0
- package/dist/esm/Containers/index.js +7 -0
- package/dist/esm/DynamicTable/BasicPrintDynamicTable.js +27 -0
- package/dist/esm/DynamicTable/DynamicPrintTable.js +131 -0
- package/dist/esm/DynamicTable/DynamicTable.js +192 -0
- package/dist/esm/DynamicTable/GenericDynamicTable.js +196 -0
- package/dist/esm/DynamicTable/index.js +4 -0
- package/dist/esm/Footer/Footer.js +16 -0
- package/dist/esm/Footer/index.js +1 -0
- package/dist/esm/Form/Checkbox/index.js +34 -0
- package/dist/esm/Form/Checklist/index.js +10 -0
- package/dist/esm/Form/DatePicker/index.js +31 -0
- package/dist/esm/Form/DynamicBaculoForm/index.js +140 -0
- package/dist/esm/Form/FieldContainer/DoubleFieldContainer.js +14 -0
- package/dist/esm/Form/FieldContainer/QuadrupleFieldContainer.js +14 -0
- package/dist/esm/Form/FieldContainer/TripleFieldContainer.js +14 -0
- package/dist/esm/Form/FieldContainer/index.js +3 -0
- package/dist/esm/Form/FileUpload/index.js +54 -0
- package/dist/esm/Form/FormButtons/index.js +5 -0
- package/dist/esm/Form/FormLayout/index.js +7 -0
- package/dist/esm/Form/SelectField/index.js +74 -0
- package/dist/esm/Form/TextArea/index.js +36 -0
- package/dist/esm/Form/TextField/index.js +70 -0
- package/dist/esm/Form/TimePicker/index.js +31 -0
- package/dist/esm/Form/YesNo/index.js +18 -0
- package/dist/esm/Form/index.js +13 -0
- package/dist/esm/Labels/InfoLabel/index.js +5 -0
- package/dist/esm/Labels/index.js +1 -0
- package/dist/esm/Layouts/homeLayout/index.js +10 -0
- package/dist/esm/Layouts/index.js +1 -0
- package/dist/esm/LineSeparator/LineSeparator.js +4 -0
- package/dist/esm/LineSeparator/index.js +1 -0
- package/dist/esm/Modal/Modal.js +32 -0
- package/dist/esm/Modal/index.js +1 -0
- package/dist/esm/NavBar/NavBar.js +32 -0
- package/dist/esm/NavBar/NavBar.types.js +1 -0
- package/dist/esm/NavBar/NavBar.utils.js +58 -0
- package/dist/esm/NavBar/index.js +3 -0
- package/dist/esm/ProgressBar/ProgressBar.js +5 -0
- package/dist/esm/ProgressBar/ProgressCircle.js +22 -0
- package/dist/esm/ProgressBar/index.js +2 -0
- package/dist/esm/Skeletons/LoadingInputSkeleton.js +8 -0
- package/dist/esm/Skeletons/index.js +1 -0
- package/dist/esm/Tab/Tab.js +19 -0
- package/dist/esm/Tab/index.js +1 -0
- package/dist/esm/Table/ZauruTable.js +150 -0
- package/dist/esm/Table/index.js +1 -0
- package/dist/esm/TaskList/TaskList.js +35 -0
- package/dist/esm/TaskList/index.js +1 -0
- package/dist/esm/Titles/LabelArray.js +7 -0
- package/dist/esm/Titles/TableColumnTitle.js +5 -0
- package/dist/esm/Titles/TitleH1.js +5 -0
- package/dist/esm/Titles/TitleH2.js +5 -0
- package/dist/esm/Titles/TitleH3.js +5 -0
- package/dist/esm/Titles/index.js +5 -0
- package/dist/esm/Tooltip/Tooltip.js +14 -0
- package/dist/esm/Tooltip/index.js +1 -0
- package/dist/esm/WithTooltip/WithTooltip.js +5 -0
- package/dist/esm/WithTooltip/index.js +1 -0
- package/dist/esm/Wizards/StepWizard.js +14 -0
- package/dist/esm/Wizards/index.js +1 -0
- package/dist/esm/Zendesk/Chat.js +63 -0
- package/dist/esm/Zendesk/index.js +2 -0
- package/dist/esm/Zendesk/zendesk.config.js +24 -0
- package/dist/esm/index.js +24 -0
- package/dist/esm/tailwind.config.js +8 -0
- package/dist/index.d.ts +24 -0
- package/dist/tailwind.config.d.ts +1 -0
- package/package.json +4 -3
- package/src/Table/ZauruTable.tsx +4 -2
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { TextField, TextFieldWithoutValidation } from "../TextField/index.js";
|
|
3
|
+
import { TripleFieldContainer } from "../FieldContainer/index.js";
|
|
4
|
+
import { DoubleFieldContainer } from "../FieldContainer/index.js";
|
|
5
|
+
import { YesNo } from "../YesNo/index.js";
|
|
6
|
+
import { TextArea } from "../TextArea/index.js";
|
|
7
|
+
import { SelectField } from "../SelectField/index.js";
|
|
8
|
+
import { FileUploadField } from "../FileUpload/index.js";
|
|
9
|
+
import { FormDatePicker } from "../DatePicker/index.js";
|
|
10
|
+
import { FormTimePicker } from "../TimePicker/index.js";
|
|
11
|
+
import { GenericDynamicTable } from "../../DynamicTable/GenericDynamicTable.js";
|
|
12
|
+
import { getDepSelectOptions, getMunSelectOptions } from "@zauru-sdk/common";
|
|
13
|
+
import { StaticAlert } from "../../Alerts/index.js";
|
|
14
|
+
import { SubContainer } from "../../Containers/index.js";
|
|
15
|
+
import { LineSeparator } from "../../LineSeparator/index.js";
|
|
16
|
+
export function DynamicBaculoForm(props) {
|
|
17
|
+
const { form, options = { showDescription: false, showTitle: false }, formName = "", namesStr = "", defaultValues = [], showingRules = [], readOnly = false, } = props;
|
|
18
|
+
if (!form) {
|
|
19
|
+
return (_jsx(StaticAlert, { title: "No se encontr\u00F3 el formulario din\u00E1mico", description: `Ocurrió un error encontrando el formulario para ${formName}, contacte al administrador con este mensaje de error.`, type: "info" }));
|
|
20
|
+
}
|
|
21
|
+
const renderFieldComponent = (field) => {
|
|
22
|
+
const defaultValue = defaultValues?.find((x) => x.settings_form_field.print_var_name === field.print_var_name);
|
|
23
|
+
switch (field.field_type) {
|
|
24
|
+
case "fixed_rows_table":
|
|
25
|
+
case "fixed_columns_table": {
|
|
26
|
+
const columns = field.settings_form_field_table_headers?.map((x) => {
|
|
27
|
+
return {
|
|
28
|
+
label: x.name,
|
|
29
|
+
name: `${namesStr}${x.id}_${field.id}`,
|
|
30
|
+
type: x.cell_type === "yes_no" ? "checkbox" : "textField",
|
|
31
|
+
};
|
|
32
|
+
}) ?? [];
|
|
33
|
+
return (_jsx(SubContainer, { title: field.name, children: _jsx(GenericDynamicTable, { name: "fixed_columns_table", columns: columns }) }, field.id));
|
|
34
|
+
}
|
|
35
|
+
case "zauru_data":
|
|
36
|
+
return (_jsx(TextFieldWithoutValidation, { title: `${field.required ? "*" : ""}${field.name}`, hint: field.hint, defaultValue: defaultValue?.value ?? field.default_value, disabled: true }, field.id));
|
|
37
|
+
case "hour":
|
|
38
|
+
return (_jsx(FormTimePicker, { title: `${field.required ? "*" : ""}${field.name}`, name: `${namesStr}${field.form_id}_${field.id}`, hint: field.hint, disabled: readOnly, defaultValue: defaultValue?.value }, field.id));
|
|
39
|
+
case "date":
|
|
40
|
+
return (_jsx(FormDatePicker, { title: `${field.required ? "*" : ""}${field.name}`, name: `${namesStr}${field.form_id}_${field.id}`, hint: field.hint, disabled: readOnly, defaultValue: defaultValue?.value }, field.id));
|
|
41
|
+
case "file":
|
|
42
|
+
return (_jsx(FileUploadField, { title: `${field.required ? "*" : ""}${field.name}`, name: `${namesStr}${field.form_id}_${field.id}`, hint: field.hint, disabled: readOnly, defaultValue: defaultValue?.value, download: true }, field.id));
|
|
43
|
+
case "image":
|
|
44
|
+
return (_jsx(FileUploadField, { title: `${field.required ? "*" : ""}${field.name}`, name: `${namesStr}${field.form_id}_${field.id}`, hint: field.hint, showAvailableTypes: true, fileTypes: ["png", "jpg", "jpeg"], disabled: readOnly, defaultValue: defaultValue?.value }, field.id));
|
|
45
|
+
case "pdf":
|
|
46
|
+
return (_jsx(FileUploadField, { title: `${field.required ? "*" : ""}${field.name}`, name: `${namesStr}${field.form_id}_${field.id}`, hint: field.hint, showAvailableTypes: true, fileTypes: ["pdf"], disabled: readOnly, defaultValue: defaultValue?.value, download: true }, field.id));
|
|
47
|
+
case "email":
|
|
48
|
+
case "url":
|
|
49
|
+
case "text":
|
|
50
|
+
case "currency":
|
|
51
|
+
case "country":
|
|
52
|
+
return (_jsx(TextField, { title: `${field.required ? "*" : ""}${field.name}`, name: `${namesStr}${field.form_id}_${field.id}`, hint: field.hint, defaultValue: defaultValue?.value ?? field.default_value, disabled: readOnly }, field.id));
|
|
53
|
+
case "percentage":
|
|
54
|
+
case "number":
|
|
55
|
+
return (_jsx(TextField, { title: `${field.required ? "*" : ""}${field.name}`, name: `${namesStr}${field.form_id}_${field.id}`, hint: field.hint, defaultValue: defaultValue?.value ?? field.default_value, type: "number", disabled: readOnly }, field.id));
|
|
56
|
+
case "yes_no":
|
|
57
|
+
return (_jsx(YesNo, { title: `${field.required ? "*" : ""}${field.name}`, name: `${namesStr}${field.form_id}_${field.id}`, disabled: readOnly, defaultValue: field.default_value === "true" || defaultValue?.value === "true" }, field.id));
|
|
58
|
+
case "section":
|
|
59
|
+
return (_jsxs("div", { children: [_jsx(LineSeparator, {}), _jsx("h3", { className: "mb-10 text-3xl font-bold leading-8 text-gray-900", children: field.name })] }, field.id));
|
|
60
|
+
case "multi_line_text":
|
|
61
|
+
return (_jsx(TextArea, { title: `${field.required ? "*" : ""}${field.name}`, name: `${namesStr}${field.form_id}_${field.id}`, defaultValue: defaultValue?.value ?? field.default_value, hint: field.hint, disabled: readOnly }, field.id));
|
|
62
|
+
case "gt_departamentos": {
|
|
63
|
+
const optionsDep = getDepSelectOptions();
|
|
64
|
+
return (_jsx(SelectField, { title: `${field.required ? "*" : ""}${field.name}`, name: `${namesStr}${field.form_id}_${field.id}`, hint: field.hint, isClearable: !field.required, options: optionsDep, disabled: readOnly, defaultValue: optionsDep.find((x) => x.value === defaultValue?.value) }, field.id));
|
|
65
|
+
}
|
|
66
|
+
case "gt_municipios": {
|
|
67
|
+
const options = getMunSelectOptions();
|
|
68
|
+
return (_jsx(SelectField, { title: `${field.required ? "*" : ""}${field.name}`, name: `${namesStr}${field.form_id}_${field.id}`, hint: field.hint, isClearable: !field.required, options: options, disabled: readOnly, defaultValue: options.find((x) => x.value === defaultValue?.value) }, field.id));
|
|
69
|
+
}
|
|
70
|
+
case "single_select_options": {
|
|
71
|
+
const formFieldOptions = field.settings_form_field_options?.map((x) => {
|
|
72
|
+
return { label: x.label, value: x.value };
|
|
73
|
+
}) ?? [];
|
|
74
|
+
return (_jsx(SelectField, { title: `${field.required ? "*" : ""}${field.name}`, name: `${namesStr}${field.form_id}_${field.id}`, hint: field.hint, isClearable: !field.required, options: formFieldOptions, disabled: readOnly, defaultValue: formFieldOptions.find((x) => x.value === defaultValue?.value) }, field.id));
|
|
75
|
+
}
|
|
76
|
+
case "multi_select_options": {
|
|
77
|
+
const formFieldOptions2 = field.settings_form_field_options?.map((x) => {
|
|
78
|
+
return { label: x.label, value: x.value };
|
|
79
|
+
}) ?? [];
|
|
80
|
+
const defaultValuesMulti = (() => {
|
|
81
|
+
const values = defaultValue?.value?.split(",").map((str) => str.trim()) ?? [];
|
|
82
|
+
return formFieldOptions2.filter((x) => values.includes(x.value));
|
|
83
|
+
})();
|
|
84
|
+
return (_jsx(SelectField, { title: `${field.required ? "*" : ""}${field.name}`, name: `${namesStr}${field.form_id}_${field.id}`, hint: field.hint, isClearable: !field.required, isMulti: true, options: formFieldOptions2, defaultValueMulti: defaultValuesMulti, disabled: readOnly }, field.id));
|
|
85
|
+
}
|
|
86
|
+
default:
|
|
87
|
+
return (_jsxs("div", { children: ["Componente no encontrado para: ", field.field_type] }, field.id)); // o algún componente por defecto si lo prefieres
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
const renderFields = () => {
|
|
91
|
+
const fields = form.settings_form_fields;
|
|
92
|
+
const fieldGroups = [];
|
|
93
|
+
let tempGroup = [];
|
|
94
|
+
fields.forEach((field, i) => {
|
|
95
|
+
const rule = showingRules.find((x) => x.name === field.name);
|
|
96
|
+
if (!(rule && !rule.show)) {
|
|
97
|
+
const renderedField = renderFieldComponent(field);
|
|
98
|
+
if (renderedField === null) {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
tempGroup.push(renderedField);
|
|
102
|
+
const isLastField = i === fields.length - 1;
|
|
103
|
+
const isSectionField = field.field_type === "section";
|
|
104
|
+
if (isSectionField) {
|
|
105
|
+
tempGroup.pop();
|
|
106
|
+
if (tempGroup.length === 1) {
|
|
107
|
+
fieldGroups.push(tempGroup[0]);
|
|
108
|
+
}
|
|
109
|
+
else if (tempGroup.length === 2) {
|
|
110
|
+
fieldGroups.push(_jsx(DoubleFieldContainer, { children: tempGroup }, i));
|
|
111
|
+
}
|
|
112
|
+
else if (tempGroup.length === 3) {
|
|
113
|
+
fieldGroups.push(_jsx(TripleFieldContainer, { children: tempGroup }, i));
|
|
114
|
+
}
|
|
115
|
+
fieldGroups.push(renderedField);
|
|
116
|
+
tempGroup = [];
|
|
117
|
+
}
|
|
118
|
+
else if (isLastField) {
|
|
119
|
+
if (tempGroup.length === 1) {
|
|
120
|
+
fieldGroups.push(tempGroup[0]);
|
|
121
|
+
}
|
|
122
|
+
else if (tempGroup.length === 2) {
|
|
123
|
+
fieldGroups.push(_jsx(DoubleFieldContainer, { children: tempGroup }, i));
|
|
124
|
+
}
|
|
125
|
+
else if (tempGroup.length === 3) {
|
|
126
|
+
fieldGroups.push(_jsx(TripleFieldContainer, { children: tempGroup }, i));
|
|
127
|
+
}
|
|
128
|
+
tempGroup = [];
|
|
129
|
+
}
|
|
130
|
+
else if (tempGroup.length === 3) {
|
|
131
|
+
// Si hay 3 elementos en el grupo temporal y el siguiente campo no es 'section', se agrega a fieldGroups
|
|
132
|
+
fieldGroups.push(_jsx(TripleFieldContainer, { children: tempGroup }, i));
|
|
133
|
+
tempGroup = [];
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
return fieldGroups;
|
|
138
|
+
};
|
|
139
|
+
return (_jsx(SubContainer, { title: options?.showTitle ? form.name : undefined, description: options?.showDescription ? form.description : undefined, children: renderFields() }));
|
|
140
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
export const DoubleFieldContainer = (props) => {
|
|
3
|
+
const { children, className, alignCenter = true } = props;
|
|
4
|
+
const getChildren = (index) => {
|
|
5
|
+
if (children && Array.isArray(children) && children[index]) {
|
|
6
|
+
return children[index];
|
|
7
|
+
}
|
|
8
|
+
if (children && index === 0) {
|
|
9
|
+
return children;
|
|
10
|
+
}
|
|
11
|
+
return _jsx(_Fragment, {});
|
|
12
|
+
};
|
|
13
|
+
return (_jsx(_Fragment, { children: _jsxs("div", { className: `grid md:grid-cols-2 sm:grid-cols-1 gap-4 ${className}`, style: alignCenter ? { alignItems: "center" } : {}, children: [_jsx("div", { className: "col-span-1", children: getChildren(0) }), _jsx("div", { className: "col-span-1", children: getChildren(1) })] }) }));
|
|
14
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
export const QuadrupleFieldContainer = (props) => {
|
|
3
|
+
const { children, className } = props;
|
|
4
|
+
const getChildren = (index) => {
|
|
5
|
+
if (children && Array.isArray(children) && children[index]) {
|
|
6
|
+
return children[index];
|
|
7
|
+
}
|
|
8
|
+
if (children && index === 0) {
|
|
9
|
+
return children;
|
|
10
|
+
}
|
|
11
|
+
return _jsx(_Fragment, {});
|
|
12
|
+
};
|
|
13
|
+
return (_jsx(_Fragment, { children: _jsxs("div", { className: `grid lg:grid-cols-4 sm:grid-cols-2 xs:grid-cols-1 gap-4 ${className}`, style: { alignItems: "center" }, children: [_jsx("div", { className: "col-span-1", children: getChildren(0) }), _jsx("div", { className: "col-span-1", children: getChildren(1) }), _jsx("div", { className: "col-span-1", children: getChildren(2) }), _jsx("div", { className: "col-span-1", children: getChildren(3) })] }) }));
|
|
14
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
export const TripleFieldContainer = (props) => {
|
|
3
|
+
const { children, className } = props;
|
|
4
|
+
const getChildren = (index) => {
|
|
5
|
+
if (children && Array.isArray(children) && children[index]) {
|
|
6
|
+
return children[index];
|
|
7
|
+
}
|
|
8
|
+
if (children && index === 0) {
|
|
9
|
+
return children;
|
|
10
|
+
}
|
|
11
|
+
return _jsx(_Fragment, {});
|
|
12
|
+
};
|
|
13
|
+
return (_jsx(_Fragment, { children: _jsxs("div", { className: `grid sm:grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4 ${className}`, style: { alignItems: "center" }, children: [_jsx("div", { className: "col-span-1", children: getChildren(0) }), _jsx("div", { className: "col-span-1", children: getChildren(1) }), _jsx("div", { className: "col-span-1", children: getChildren(2) })] }) }));
|
|
14
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { DownloadIconSVG, IdeaIconSVG } from "@zauru-sdk/icons";
|
|
3
|
+
import { useAppSelector } from "@zauru-sdk/redux";
|
|
4
|
+
import { useState } from "react";
|
|
5
|
+
export const FileUploadFieldWithoutValidation = (props) => {
|
|
6
|
+
const { id, name, title, helpText, hint, onChange, disabled = false, readOnly = false, error, fileTypes = [], showAvailableTypes = false, className, defaultValue = undefined, download = false, } = props;
|
|
7
|
+
const [showTooltip, setShowTooltip] = useState(false);
|
|
8
|
+
if (typeof defaultValue == "string") {
|
|
9
|
+
if (download) {
|
|
10
|
+
return (_jsxs("div", { role: "button", tabIndex: 0, onClick: () => {
|
|
11
|
+
window.open(defaultValue, "_blank");
|
|
12
|
+
}, onKeyDown: (event) => {
|
|
13
|
+
// Permite que el evento se active con la tecla Enter
|
|
14
|
+
if (event.key === "Enter") {
|
|
15
|
+
window.open(defaultValue, "_blank");
|
|
16
|
+
}
|
|
17
|
+
}, children: [title && (_jsx("label", { htmlFor: name, className: "block mb-1 text-sm font-medium text-gray-700", children: title })), " ", _jsx(DownloadIconSVG, {})] }));
|
|
18
|
+
}
|
|
19
|
+
return (_jsxs("div", { className: `col-span-6 sm:col-span-3 ${className}`, children: [title && (_jsx("label", { htmlFor: name, className: `block mb-1 text-sm font-medium text-gray-700`, children: title })), " ", _jsx("div", { role: "button", tabIndex: 0, onClick: () => {
|
|
20
|
+
window.open(defaultValue, "_blank");
|
|
21
|
+
}, onKeyDown: (event) => {
|
|
22
|
+
// Permite que el evento se active con la tecla Enter
|
|
23
|
+
if (event.key === "Enter") {
|
|
24
|
+
window.open(defaultValue, "_blank");
|
|
25
|
+
}
|
|
26
|
+
}, children: _jsx("img", { src: defaultValue, alt: name, className: `h-48 w-48 inline mr-1 pb-1`, style: {
|
|
27
|
+
stroke: "currentColor",
|
|
28
|
+
strokeWidth: 2,
|
|
29
|
+
strokeLinecap: "round",
|
|
30
|
+
strokeLinejoin: "round",
|
|
31
|
+
fill: "none",
|
|
32
|
+
backgroundColor: "transparent",
|
|
33
|
+
} }) })] }));
|
|
34
|
+
}
|
|
35
|
+
const handleInputChange = (event) => {
|
|
36
|
+
onChange && onChange(event);
|
|
37
|
+
};
|
|
38
|
+
let hintMessage = hint;
|
|
39
|
+
if (showAvailableTypes && fileTypes.length > 0) {
|
|
40
|
+
hintMessage = `${hint} Archivos permitidos: ${fileTypes.join(", ")}`;
|
|
41
|
+
}
|
|
42
|
+
const color = error ? "red" : "gray";
|
|
43
|
+
const isReadOnly = disabled || readOnly;
|
|
44
|
+
const bgColor = isReadOnly ? "bg-gray-200" : `bg-${color}-50`;
|
|
45
|
+
const textColor = isReadOnly ? "text-gray-500" : `text-${color}-900`;
|
|
46
|
+
const borderColor = isReadOnly ? "border-gray-300" : `border-${color}-500`;
|
|
47
|
+
return (_jsxs("div", { className: `col-span-6 sm:col-span-3 ${className}`, children: [title && (_jsx("label", { htmlFor: name, className: `block mb-1 text-sm font-medium text-${color}-700`, children: title })), _jsxs("div", { className: "flex relative items-center", children: [_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 && (_jsx("div", { className: "flex items-center relative ml-3", children: _jsxs("div", { className: "relative cursor-pointer", onMouseEnter: () => setShowTooltip(true), onMouseLeave: () => setShowTooltip(false), children: [_jsx(IdeaIconSVG, {}), showTooltip && (_jsx("div", { className: "absolute -left-48 top-0 mt-8 p-2 bg-white border rounded shadow text-black z-50", children: helpText }))] }) }))] }), error && (_jsxs("p", { className: `mt-2 text-sm text-${color}-600`, children: [_jsx("span", { className: "font-medium", children: "Oops!" }), " ", error] })), !error && hintMessage && (_jsx("p", { className: `mt-2 italic text-sm text-${color}-500`, children: hintMessage }))] }));
|
|
48
|
+
};
|
|
49
|
+
export const FileUploadField = (props) => {
|
|
50
|
+
const { formValidations } = useAppSelector((state) => state.formValidation);
|
|
51
|
+
const error = formValidations[props.formName ?? "-1"]?.[props.name ?? "-1"];
|
|
52
|
+
props = { ...props, error };
|
|
53
|
+
return _jsx(FileUploadFieldWithoutValidation, { ...props });
|
|
54
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
export const FormButtons = (props) => {
|
|
3
|
+
const { saveTitle = "Guardar", saveName = "save", cancelTitle = "Cancelar", cancelName = "cancel", showCancel = true, showClear = false, clearName = "clear", clearTitle = "Limpiar", loading = false, onClickSave, loadingSaveText = "Guardando...", } = props;
|
|
4
|
+
return (_jsxs(_Fragment, { children: [showClear && (_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 && (_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 })), _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 })] }));
|
|
5
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Form } from "@remix-run/react";
|
|
3
|
+
import { ButtonSectionContainer } from "../../Containers/index.js";
|
|
4
|
+
export const FormLayout = (props) => {
|
|
5
|
+
const { title, children, buttons, method, formId } = props;
|
|
6
|
+
return (_jsxs(Form, { id: formId, name: formId, method: method ?? "post", children: [title && (_jsx("label", { className: "block text-sm font-medium text-gray-700 mb-3", children: title })), _jsxs("div", { className: "shadow sm:overflow-hidden sm:rounded-md", children: [_jsx("div", { className: "space-y-6 bg-white px-4 py-5 sm:p-6", children: children }), buttons && (_jsx(ButtonSectionContainer, { children: buttons }))] })] }, formId));
|
|
7
|
+
};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { IdeaIconSVG } from "@zauru-sdk/icons";
|
|
3
|
+
import { useAppSelector } from "@zauru-sdk/redux";
|
|
4
|
+
import { useEffect, useState } from "react";
|
|
5
|
+
import Select, { components } from "react-select";
|
|
6
|
+
import { LoadingInputSkeleton } from "../../Skeletons/index.js";
|
|
7
|
+
const Input = (props) => (_jsx(components.Input, { ...props, readOnly: props.selectProps.isReadOnly }));
|
|
8
|
+
export const SelectFieldWithoutValidation = (props) => {
|
|
9
|
+
const { id, name, title, defaultValue, defaultValueMulti = [], helpText, hint, options, onChange, onChangeMulti, isClearable = false, error = false, disabled = false, readOnly = false, isMulti = false, loading = false, className = "", onInputChange, } = props;
|
|
10
|
+
const [value, setValue] = useState(defaultValue || null);
|
|
11
|
+
const [valueMulti, setValueMulti] = useState(defaultValueMulti);
|
|
12
|
+
const [inputValue, setInputValue] = useState("");
|
|
13
|
+
const [showTooltip, setShowTooltip] = useState(false);
|
|
14
|
+
const [isClient, setIsClient] = useState(typeof window !== "undefined");
|
|
15
|
+
const menuIsOpen = readOnly ? false : props?.menuIsOpen;
|
|
16
|
+
const color = error ? "red" : "gray";
|
|
17
|
+
let documentRef = null;
|
|
18
|
+
const isReadOnly = disabled || readOnly;
|
|
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}-500`;
|
|
22
|
+
if (typeof window !== "undefined") {
|
|
23
|
+
documentRef = document;
|
|
24
|
+
}
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
setValue(defaultValue || null);
|
|
27
|
+
}, [defaultValue]);
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
setIsClient(true);
|
|
30
|
+
}, []);
|
|
31
|
+
if (!isClient || loading || !documentRef) {
|
|
32
|
+
return (_jsxs(_Fragment, { children: [title && (_jsx("label", { htmlFor: error ? `${name}-error` : `${name}-success`, className: `block text-sm font-medium text-${color}-700 dark:text-${color}-500`, children: title })), _jsx(LoadingInputSkeleton, {}), helpText && (_jsx("p", { className: `mt-2 italic text-sm text-${color}-500 dark:text-${color}-400`, children: helpText }))] }));
|
|
33
|
+
}
|
|
34
|
+
const handleOnChange = (selection) => {
|
|
35
|
+
// Verificar si el valor de selección es un objeto con propiedades 'value' y 'label'
|
|
36
|
+
if (typeof selection === "object" &&
|
|
37
|
+
selection !== null &&
|
|
38
|
+
"value" in selection &&
|
|
39
|
+
"label" in selection) {
|
|
40
|
+
setValue(selection);
|
|
41
|
+
onChange && onChange(selection);
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
setValue(null);
|
|
45
|
+
onChange && onChange(null);
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
const handleOnChangeMulti = (selection) => {
|
|
49
|
+
if (Array.isArray(selection)) {
|
|
50
|
+
setValueMulti(selection);
|
|
51
|
+
onChangeMulti &&
|
|
52
|
+
onChangeMulti(selection);
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
setValueMulti([]);
|
|
56
|
+
onChangeMulti && onChangeMulti([]);
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
const selectComponent = (_jsxs(_Fragment, { children: [_jsx(Select, { className: `block w-full rounded-md ${bgColor} ${borderColor} ${textColor} shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm`, id: isMulti ? undefined : id, instanceId: isMulti ? undefined : id, isDisabled: disabled, name: isMulti ? undefined : name, options: options, onChange: isMulti ? handleOnChangeMulti : handleOnChange, defaultValue: isMulti ? valueMulti : value, onInputChange: (newValue, actionMeta) => {
|
|
60
|
+
setInputValue(newValue);
|
|
61
|
+
onInputChange && onInputChange(newValue, actionMeta);
|
|
62
|
+
}, inputValue: inputValue, onMenuOpen: () => { }, onMenuClose: () => { }, menuPortalTarget: documentRef?.body, styles: { menuPortal: (base) => ({ ...base, zIndex: 9999 }) }, isClearable: isClearable, isSearchable: true, components: { Input }, menuIsOpen: menuIsOpen,
|
|
63
|
+
//windowThreshold={50}
|
|
64
|
+
isMulti: isMulti }), isMulti && (_jsx("input", { hidden: true, readOnly: true, name: name, value: valueMulti.map((x) => x?.value).join(","), id: id }))] }));
|
|
65
|
+
return (_jsxs("div", { className: `col-span-6 sm:col-span-3 ${className}`, children: [title && (_jsx("label", { htmlFor: error ? `${name}-error` : `${name}-success`, className: `block text-sm font-medium ${color === "red"
|
|
66
|
+
? "text-red-700 dark:text-red-500"
|
|
67
|
+
: "text-gray-700 dark:text-gray-500"}`, children: title })), _jsxs("div", { className: "flex relative items-center", children: [selectComponent, helpText && (_jsx("div", { className: "flex items-center relative ml-3", children: _jsxs("div", { className: "relative cursor-pointer", onMouseEnter: () => setShowTooltip(true), onMouseLeave: () => setShowTooltip(false), children: [_jsx(IdeaIconSVG, {}), showTooltip && (_jsx("div", { className: "absolute -left-48 top-0 mt-8 p-2 bg-white border rounded shadow text-black z-50", children: helpText }))] }) }))] }), error && (_jsxs("p", { className: `mt-2 text-sm text-${color}-600 dark:text-${color}-500`, children: [_jsx("span", { className: "font-medium", children: "Oops!" }), " ", error] })), !error && hint && (_jsx("p", { className: `mt-2 italic text-sm text-${color}-500 dark:text-${color}-400`, children: hint }))] }));
|
|
68
|
+
};
|
|
69
|
+
export const SelectField = (props) => {
|
|
70
|
+
const { formValidations } = useAppSelector((state) => state.formValidation);
|
|
71
|
+
const error = formValidations[props.formName ?? "-1"]?.[props.name ?? "-1"];
|
|
72
|
+
props = { ...props, error };
|
|
73
|
+
return _jsx(SelectFieldWithoutValidation, { ...props });
|
|
74
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useAppSelector } from "@zauru-sdk/redux";
|
|
3
|
+
import { useEffect, useState } from "react";
|
|
4
|
+
export const TextAreaWithoutValidation = (props) => {
|
|
5
|
+
const { id, name, title, defaultValue = "", hidden, hint, onChange, onKeyDown, disabled = false, error = false, readOnly = false, rows, cols, stopChangeEvents, className = "", } = props;
|
|
6
|
+
const [value, setValue] = useState(defaultValue);
|
|
7
|
+
const color = error ? "red" : "gray";
|
|
8
|
+
const isReadOnly = disabled || readOnly;
|
|
9
|
+
const bgColor = isReadOnly ? "bg-gray-200" : `bg-${color}-50`;
|
|
10
|
+
const textColor = isReadOnly ? "text-gray-500" : `text-${color}-900`;
|
|
11
|
+
const borderColor = isReadOnly ? "border-gray-300" : `border-${color}-500`;
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
setValue(defaultValue);
|
|
14
|
+
}, [defaultValue]);
|
|
15
|
+
if (hidden) {
|
|
16
|
+
return (_jsx("textarea", { id: id ?? name, name: name, value: defaultValue, readOnly: true, hidden: true }));
|
|
17
|
+
}
|
|
18
|
+
const handleInputChange = (event) => {
|
|
19
|
+
if (stopChangeEvents) {
|
|
20
|
+
event.stopPropagation();
|
|
21
|
+
event.preventDefault();
|
|
22
|
+
}
|
|
23
|
+
setValue(event.target.value);
|
|
24
|
+
onChange && onChange(event.target.value);
|
|
25
|
+
};
|
|
26
|
+
return (_jsxs("div", { className: `col-span-6 sm:col-span-3 ${className}`, children: [title && (_jsx("label", { htmlFor: error ? `${name}-error` : `${name}-success`, className: `block text-sm font-medium text-${color}-700 dark:text-${color}-500`, children: title })), _jsx("textarea", { name: name, readOnly: readOnly, disabled: disabled, id: id ?? name, autoComplete: "given-name", value: value, rows: rows, cols: cols, onChange: handleInputChange, onKeyDown: (event) => {
|
|
27
|
+
onKeyDown && onKeyDown(event);
|
|
28
|
+
}, className: `mt-1 block w-full rounded-md ${bgColor} ${borderColor} ${textColor} shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm` }), error && (_jsxs("p", { className: `mt-2 text-sm text-${color}-600 dark:text-${color}-500`, children: [_jsx("span", { className: "font-medium", children: "Oops!" }), " ", error] })), !error && hint && (_jsx("p", { className: `mt-2 italic text-sm text-${color}-500 dark:text-${color}-400`, children: hint }))] }));
|
|
29
|
+
};
|
|
30
|
+
//<reference> https://tailwindui.com/components/application-ui/forms/form-layouts
|
|
31
|
+
export const TextArea = (props) => {
|
|
32
|
+
const { formValidations } = useAppSelector((state) => state.formValidation);
|
|
33
|
+
const error = formValidations[props.formName ?? "-1"]?.[props.name ?? "-1"];
|
|
34
|
+
props = { ...props, error };
|
|
35
|
+
return _jsx(TextAreaWithoutValidation, { ...props });
|
|
36
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { IdeaIconSVG } from "@zauru-sdk/icons";
|
|
3
|
+
import { useAppSelector } from "@zauru-sdk/redux";
|
|
4
|
+
import { useEffect, useState } from "react";
|
|
5
|
+
export const TextFieldWithoutValidation = (props) => {
|
|
6
|
+
const { id, name, defaultValue = "", hidden, type = "text", onChange, onKeyDown, disabled = false, readOnly = false, min, integer = false, stopChangeEvents, style, error, title, helpText, className, hint, } = props;
|
|
7
|
+
const [showTooltip, setShowTooltip] = useState(false);
|
|
8
|
+
const [value, setValue] = useState(defaultValue);
|
|
9
|
+
const color = error ? "red" : "gray";
|
|
10
|
+
const isReadOnly = disabled || readOnly;
|
|
11
|
+
const bgColor = isReadOnly ? "bg-gray-200" : `bg-${color}-50`;
|
|
12
|
+
const textColor = isReadOnly ? "text-gray-500" : `text-${color}-900`;
|
|
13
|
+
const borderColor = isReadOnly ? "border-gray-300" : `border-${color}-500`;
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
setValue(defaultValue);
|
|
16
|
+
}, [defaultValue]);
|
|
17
|
+
if (hidden) {
|
|
18
|
+
return (_jsx("input", { type: type, id: id ?? name, name: name, value: defaultValue, readOnly: true, hidden: true }));
|
|
19
|
+
}
|
|
20
|
+
const handleInputChange = (event) => {
|
|
21
|
+
if (stopChangeEvents) {
|
|
22
|
+
event.stopPropagation();
|
|
23
|
+
event.preventDefault();
|
|
24
|
+
}
|
|
25
|
+
if (integer && type === "number") {
|
|
26
|
+
const value = event.target.value;
|
|
27
|
+
const isInteger = /^[0-9]*$/.test(value);
|
|
28
|
+
if (isInteger || value === "") {
|
|
29
|
+
setValue(value);
|
|
30
|
+
onChange && onChange(value, event);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
setValue(event.target.value);
|
|
35
|
+
onChange && onChange(event.target.value, event);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
const handleKeyDown = (event) => {
|
|
39
|
+
if (integer && type === "number") {
|
|
40
|
+
// Permitir solo números y teclas de control
|
|
41
|
+
const allowedKeys = [
|
|
42
|
+
"Backspace",
|
|
43
|
+
"ArrowLeft",
|
|
44
|
+
"ArrowRight",
|
|
45
|
+
"Delete",
|
|
46
|
+
"Enter",
|
|
47
|
+
"Tab",
|
|
48
|
+
];
|
|
49
|
+
if (!allowedKeys.includes(event.key) && !/^[0-9]$/.test(event.key)) {
|
|
50
|
+
event.preventDefault();
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
const inputComponent = (_jsx("input", { type: type, name: name, readOnly: readOnly, disabled: disabled, id: id ?? name, autoComplete: "given-name", value: value, onWheel: (e) => {
|
|
55
|
+
e.currentTarget.blur();
|
|
56
|
+
}, step: type === "number" ? 0.01 : undefined, onChange: handleInputChange, onKeyDown: (event) => {
|
|
57
|
+
handleKeyDown(event);
|
|
58
|
+
onKeyDown && onKeyDown(event);
|
|
59
|
+
}, min: min, style: style, className: `block w-full rounded-md ${bgColor} ${borderColor} ${textColor} shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm` }));
|
|
60
|
+
if (!error && !title) {
|
|
61
|
+
return _jsx("div", { className: `${className}`, children: inputComponent });
|
|
62
|
+
}
|
|
63
|
+
return (_jsxs("div", { className: `col-span-6 sm:col-span-3 ${className}`, children: [title && (_jsx("label", { htmlFor: error ? `${name}-error` : `${name}-success`, className: `block mb-1 text-sm font-medium text-${color}-700 dark:text-${color}-500`, children: title })), _jsxs("div", { className: "flex relative items-center", children: [inputComponent, helpText && (_jsx("div", { className: "flex items-center relative ml-3", children: _jsxs("div", { className: "relative cursor-pointer", onMouseEnter: () => setShowTooltip(true), onMouseLeave: () => setShowTooltip(false), children: [_jsx(IdeaIconSVG, {}), showTooltip && (_jsx("div", { className: "absolute -left-48 top-0 mt-8 p-2 bg-white border rounded shadow text-black z-50", children: helpText }))] }) }))] }), error && (_jsxs("p", { className: `mt-2 text-sm text-${color}-600 dark:text-${color}-500`, children: [_jsx("span", { className: "font-medium", children: "Oops!" }), " ", error] })), !error && hint && (_jsx("p", { className: `mt-2 italic text-sm text-${color}-500 dark:text-${color}-400`, children: hint }))] }));
|
|
64
|
+
};
|
|
65
|
+
export const TextField = (props) => {
|
|
66
|
+
const { formValidations } = useAppSelector((state) => state.formValidation);
|
|
67
|
+
const error = formValidations[props.formName ?? "-1"]?.[props.name ?? "-1"];
|
|
68
|
+
props = { ...props, error };
|
|
69
|
+
return _jsx(TextFieldWithoutValidation, { ...props });
|
|
70
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { ClockIconSVG, CloseSvgIcon, IdeaIconSVG } from "@zauru-sdk/icons";
|
|
3
|
+
import { useAppSelector } from "@zauru-sdk/redux";
|
|
4
|
+
import { useEffect, useState } from "react";
|
|
5
|
+
export const FormTimePickerWithoutValidation = (props) => {
|
|
6
|
+
const { id, name, title, defaultValue = "", hint, helpText, onChange, tabIndex, error, disabled = false, } = props;
|
|
7
|
+
const [value, setValue] = useState(defaultValue);
|
|
8
|
+
const [showTooltip, setShowTooltip] = useState(false);
|
|
9
|
+
const color = error ? "red" : "gray";
|
|
10
|
+
const isReadOnly = disabled;
|
|
11
|
+
const bgColor = isReadOnly ? "bg-gray-200" : `bg-${color}-50`;
|
|
12
|
+
const textColor = isReadOnly ? "text-gray-500" : `text-${color}-500`;
|
|
13
|
+
const borderColor = isReadOnly ? "border-gray-300" : `border-${color}-200`;
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
setValue(defaultValue);
|
|
16
|
+
}, [defaultValue]);
|
|
17
|
+
const clearValue = () => {
|
|
18
|
+
setValue("");
|
|
19
|
+
onChange && onChange("");
|
|
20
|
+
};
|
|
21
|
+
return (_jsxs(_Fragment, { children: [title && (_jsx("label", { htmlFor: error ? `${name}-error` : `${name}-success`, className: `block text-sm font-medium ${textColor}`, children: title })), _jsxs("div", { className: "flex relative items-center", children: [_jsx("div", { className: "absolute left-0 flex items-center pl-3 pointer-events-none", children: _jsx(ClockIconSVG, {}) }), _jsx("input", { id: id, name: name, tabIndex: tabIndex, type: "time", onChange: (e) => {
|
|
22
|
+
setValue(e.target.value);
|
|
23
|
+
onChange && onChange(e.target.value);
|
|
24
|
+
}, 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` }), value && (_jsx("button", { type: "button", onClick: clearValue, className: "absolute right-0 mr-10", children: _jsx(CloseSvgIcon, {}) })), helpText && (_jsx("div", { className: "flex items-center relative ml-3", children: _jsxs("div", { className: "relative cursor-pointer", onMouseEnter: () => setShowTooltip(true), onMouseLeave: () => setShowTooltip(false), children: [_jsx(IdeaIconSVG, {}), showTooltip && (_jsx("div", { className: "absolute -left-48 top-0 mt-8 p-2 bg-white border rounded shadow text-black", children: helpText }))] }) }))] }), error && (_jsxs("p", { className: `mt-2 text-sm text-${color}-600 dark:text-${color}-500`, children: [_jsx("span", { className: "font-medium", children: "Oops!" }), " ", error] })), !error && hint && (_jsx("p", { className: `mt-2 italic text-sm text-${color}-500 dark:text-${color}-400`, children: hint }))] }));
|
|
25
|
+
};
|
|
26
|
+
export const FormTimePicker = (props) => {
|
|
27
|
+
const { formValidations } = useAppSelector((state) => state.formValidation);
|
|
28
|
+
const error = formValidations[props.formName ?? "-1"]?.[props.name ?? "-1"];
|
|
29
|
+
props = { ...props, error };
|
|
30
|
+
return _jsx(FormTimePickerWithoutValidation, { ...props });
|
|
31
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useAppSelector } from "@zauru-sdk/redux";
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
export const YesNo = (props) => {
|
|
5
|
+
const { id, name, title, defaultValue = false, helpText, onChange, disabled, } = props;
|
|
6
|
+
const { formValidations } = useAppSelector((state) => state.formValidation);
|
|
7
|
+
const error = formValidations[props.formName ?? "-1"]?.[props.name ?? "-1"];
|
|
8
|
+
const [value, setValue] = useState(defaultValue);
|
|
9
|
+
const color = error ? "red" : "gray";
|
|
10
|
+
const handleOnChange = () => {
|
|
11
|
+
if (disabled)
|
|
12
|
+
return; // No hacer nada si está deshabilitado
|
|
13
|
+
const newValue = !value;
|
|
14
|
+
setValue(newValue);
|
|
15
|
+
onChange && onChange(newValue);
|
|
16
|
+
};
|
|
17
|
+
return (_jsxs(_Fragment, { children: [_jsxs("label", { className: `relative inline-flex items-center cursor-pointer ${disabled ? "opacity-50" : ""}`, children: [_jsx("input", { type: "checkbox", id: id ?? name, name: name, checked: value, value: value.toString(), className: "sr-only peer", onChange: handleOnChange, disabled: disabled }), value.toString() === "false" && (_jsx("input", { type: "hidden", name: name, value: "false" })), _jsx("div", { className: "w-11 h-6 bg-gray-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-blue-300 rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-blue-600" }), _jsx("span", { className: "ml-3 text-sm font-medium text-gray-900", children: title })] }), error && (_jsxs("p", { className: `mt-2 text-sm text-${color}-600 dark:text-${color}-500`, children: [_jsx("span", { className: "font-medium", children: "Oops!" }), " ", error] })), !error && helpText && (_jsx("p", { className: `mt-2 italic text-sm text-${color}-500 dark:text-${color}-400`, children: helpText }))] }));
|
|
18
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export * from "./Checkbox/index.js";
|
|
2
|
+
export * from "./Checklist/index.js";
|
|
3
|
+
export * from "./DatePicker/index.js";
|
|
4
|
+
export * from "./DynamicBaculoForm/index.js";
|
|
5
|
+
export * from "./FieldContainer/index.js";
|
|
6
|
+
export * from "./FileUpload/index.js";
|
|
7
|
+
export * from "./FormButtons/index.js";
|
|
8
|
+
export * from "./FormLayout/index.js";
|
|
9
|
+
export * from "./SelectField/index.js";
|
|
10
|
+
export * from "./TextArea/index.js";
|
|
11
|
+
export * from "./TextField/index.js";
|
|
12
|
+
export * from "./TimePicker/index.js";
|
|
13
|
+
export * from "./YesNo/index.js";
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
export const InfoLabel = (props) => {
|
|
3
|
+
const { description, title, className } = props;
|
|
4
|
+
return (_jsxs("div", { className: `block ${className}`, children: [_jsx("label", { className: "inline text-sm font-medium text-gray-700", children: `${title.toUpperCase()} ` }), _jsx("label", { className: "inline text-sm font-medium text-gray-500", children: description })] }));
|
|
5
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./InfoLabel/index.js";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
export const HomeLayout = ({ title, description }) => {
|
|
3
|
+
return (_jsx("div", { className: "bg-cover bg-center h-screen", style: { backgroundImage: 'url("/wallpaper.webp")' }, children: _jsxs("div", { className: "flex flex-col h-screen justify-center items-center", children: [_jsx("h1", { className: "text-6xl md:text-7xl lg:text-8xl text-white font-bold mb-6 text-center", style: {
|
|
4
|
+
textShadow: "0.5px 0.5px 1px #000000",
|
|
5
|
+
WebkitTextStroke: "2px #000000",
|
|
6
|
+
}, children: title ?? _jsx(_Fragment, { children: "Bienvenido, inicie sesi\u00F3n para continuar." }) }), _jsx("p", { className: "text-xl md:text-2xl lg:text-3xl text-white text-center max-w-md mb-12", style: {
|
|
7
|
+
textShadow: "0.5px 0.5px 1px #000000",
|
|
8
|
+
WebkitTextStroke: "1px #000000",
|
|
9
|
+
}, children: description ?? _jsx(_Fragment, { children: "Web app, realizada en Zauru." }) })] }) }));
|
|
10
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./homeLayout/index.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./LineSeparator.js";
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { createRoot } from "react-dom/client";
|
|
3
|
+
export const createModal = ({ title, description, okButtonText, showOptions = true, }) => {
|
|
4
|
+
return new Promise((resolve) => {
|
|
5
|
+
const handleClose = () => {
|
|
6
|
+
resolve(null);
|
|
7
|
+
removeModal();
|
|
8
|
+
};
|
|
9
|
+
const handleOk = () => {
|
|
10
|
+
resolve("OK");
|
|
11
|
+
removeModal();
|
|
12
|
+
};
|
|
13
|
+
const handleCancel = () => {
|
|
14
|
+
resolve("CANCEL");
|
|
15
|
+
removeModal();
|
|
16
|
+
};
|
|
17
|
+
const removeModal = () => {
|
|
18
|
+
document.body.removeChild(modalWrapper);
|
|
19
|
+
document.body.removeChild(modalOverlay);
|
|
20
|
+
};
|
|
21
|
+
const modalWrapper = document.createElement("div");
|
|
22
|
+
modalWrapper.classList.add("justify-center", "items-center", "flex", "overflow-x-hidden", "overflow-y-auto", "fixed", "inset-0", "z-50", "outline-none", "focus:outline-none");
|
|
23
|
+
// Crear capa de fondo detrás del modal
|
|
24
|
+
const modalOverlay = document.createElement("div");
|
|
25
|
+
modalOverlay.classList.add("fixed", "inset-0", "bg-black", "opacity-50", "z-40");
|
|
26
|
+
document.body.appendChild(modalOverlay);
|
|
27
|
+
document.body.appendChild(modalWrapper);
|
|
28
|
+
const ModalContent = () => (_jsx("div", { className: "relative w-auto my-6 mx-auto max-w-3xl", children: _jsxs("div", { className: "border-0 rounded-lg shadow-lg relative flex flex-col w-full bg-white outline-none focus:outline-none", children: [_jsxs("div", { className: "flex items-start justify-between p-5 border-b border-solid border-slate-200 rounded-t", children: [_jsx("h3", { className: "text-3xl font-semibold", children: title }), _jsx("button", { className: "p-1 ml-auto bg-transparent border-0 text-black float-right text-3xl leading-none font-semibold outline-none focus:outline-none", children: _jsx("span", { className: "close-button", onClick: handleClose, children: "\u00D7" }) })] }), _jsx("div", { className: "relative p-6 flex-auto", children: description }), showOptions && (_jsxs("div", { className: "flex items-center justify-end p-6 border-t border-solid border-slate-200 rounded-b", children: [_jsx("button", { className: "cancel-button text-red-700 background-transparent font-bold uppercase px-6 py-2 text-sm outline-none focus:outline-none mr-1 mb-1 ease-linear transition-all duration-150", type: "button", onClick: handleCancel, children: "Cancelar" }), _jsx("button", { className: "ok-button bg-emerald-700 text-white active:bg-emerald-600 font-bold uppercase text-sm px-6 py-3 rounded shadow hover:shadow-lg outline-none focus:outline-none mr-1 mb-1 ease-linear transition-all duration-150", type: "button", onClick: handleOk, children: okButtonText ?? "Aceptar" })] }))] }) }));
|
|
29
|
+
const root = createRoot(modalWrapper);
|
|
30
|
+
root.render(_jsx(ModalContent, {}));
|
|
31
|
+
});
|
|
32
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Modal.js";
|