@zauru-sdk/components 2.0.202 → 2.0.204
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/dist/Containers/ButtonSectionContainer.d.ts +0 -1
- package/dist/DynamicTable/DynamicPrintTable.d.ts +0 -1
- package/dist/Form/DynamicBaculoForm/index.d.ts +2 -0
- package/dist/Form/FileUpload/index.d.ts +2 -1
- package/dist/Form/TimePicker/index.d.ts +0 -1
- package/dist/Form/YesNo/index.d.ts +0 -1
- package/dist/Modal/ItemModal.d.ts +1 -1
- package/dist/esm/BlockUI/BlockUI.js +1 -1
- package/dist/esm/Buttons/Button.js +7 -8
- package/dist/esm/Containers/ButtonSectionContainer.js +2 -2
- package/dist/esm/Containers/OutletContainer.js +2 -2
- package/dist/esm/DynamicTable/DynamicPrintTable.js +13 -14
- package/dist/esm/DynamicTable/GenericDynamicTable.js +1 -1
- package/dist/esm/Form/DynamicBaculoForm/index.js +21 -57
- package/dist/esm/Form/FileUpload/index.js +197 -103
- package/dist/esm/Layouts/errorLayout/index.js +3 -5
- package/dist/esm/Modal/ItemModal.js +21 -10
- package/dist/esm/Skeletons/LoadingWindow.js +8 -0
- package/package.json +6 -6
- package/src/BlockUI/BlockUI.tsx +2 -4
- package/src/Buttons/Button.tsx +28 -32
- package/src/Containers/ButtonSectionContainer.tsx +2 -5
- package/src/Containers/OutletContainer.tsx +3 -3
- package/src/DynamicTable/DynamicPrintTable.tsx +1 -4
- package/src/DynamicTable/GenericDynamicTable.tsx +1 -1
- package/src/Form/DynamicBaculoForm/index.tsx +55 -66
- package/src/Form/FileUpload/index.tsx +365 -150
- package/src/Form/TimePicker/index.tsx +0 -1
- package/src/Form/YesNo/index.tsx +0 -1
- package/src/Layouts/errorLayout/index.tsx +4 -11
- package/src/Modal/ItemModal.tsx +44 -13
- package/src/Skeletons/LoadingWindow.tsx +11 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,22 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [2.0.204](https://github.com/intuitiva/zauru-typescript-sdk/compare/v2.0.203...v2.0.204) (2025-03-27)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @zauru-sdk/components
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## [2.0.203](https://github.com/intuitiva/zauru-typescript-sdk/compare/v2.0.202...v2.0.203) (2025-03-27)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @zauru-sdk/components
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
6
22
|
## [2.0.202](https://github.com/intuitiva/zauru-typescript-sdk/compare/v2.0.201...v2.0.202) (2025-03-20)
|
|
7
23
|
|
|
8
24
|
**Note:** Version bump only for package @zauru-sdk/components
|
|
@@ -22,6 +22,8 @@ type Props = {
|
|
|
22
22
|
show: boolean;
|
|
23
23
|
}[];
|
|
24
24
|
readOnly?: boolean;
|
|
25
|
+
zauruBaseURL?: string;
|
|
26
|
+
setProcessing?: (processing: boolean) => void;
|
|
25
27
|
};
|
|
26
28
|
export declare function DynamicBaculoForm(props: Props): import("react/jsx-runtime").JSX.Element;
|
|
27
29
|
export {};
|
|
@@ -2,7 +2,6 @@ import React from "react";
|
|
|
2
2
|
type Props = {
|
|
3
3
|
id?: string;
|
|
4
4
|
name: string;
|
|
5
|
-
formName?: string;
|
|
6
5
|
title?: string;
|
|
7
6
|
helpText?: string;
|
|
8
7
|
hint?: string;
|
|
@@ -16,6 +15,8 @@ type Props = {
|
|
|
16
15
|
required?: boolean;
|
|
17
16
|
optimizeImages?: boolean;
|
|
18
17
|
zauruBaseURL?: string;
|
|
18
|
+
setProcessing?: (processing: boolean) => void;
|
|
19
|
+
signature?: boolean;
|
|
19
20
|
};
|
|
20
21
|
export declare const FileUploadField: (props: Props) => import("react/jsx-runtime").JSX.Element;
|
|
21
22
|
export {};
|
|
@@ -4,5 +4,5 @@ export const BlockUI = (props) => {
|
|
|
4
4
|
if (!active) {
|
|
5
5
|
return _jsx(_Fragment, { children: children });
|
|
6
6
|
}
|
|
7
|
-
return (_jsx("div", { children: _jsxs("div", { className: "relative", children: [_jsx("div", { className: "absolute bg-gray-100 bg-opacity-
|
|
7
|
+
return (_jsx("div", { children: _jsxs("div", { className: "relative", children: [_jsx("div", { className: "absolute bg-gray-100 bg-opacity-80 z-10 h-full w-full flex items-center justify-center", children: _jsxs("div", { className: "flex items-center", children: [_jsx("span", { className: "text-3xl mr-4", children: loadingText }), _jsxs("svg", { className: "animate-spin h-36 w-36 text-gray-600", xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", children: [_jsx("circle", { className: "opacity-25", cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "4" }), _jsx("path", { className: "opacity-75", fill: "currentColor", d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z" })] })] }) }), children] }) }));
|
|
8
8
|
};
|
|
@@ -44,19 +44,18 @@ export const Button = (props) => {
|
|
|
44
44
|
},
|
|
45
45
|
};
|
|
46
46
|
const color = COLORS[selectedColor];
|
|
47
|
-
const inside = children ?? title;
|
|
48
47
|
const errorMessage = formHasErrors
|
|
49
48
|
? Object.values(formErrors)
|
|
50
49
|
.map((error) => error?.message?.toString())
|
|
51
50
|
.join(", ")
|
|
52
51
|
: "";
|
|
53
|
-
const buttonContent = (_jsx(
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
52
|
+
const buttonContent = (_jsx("button", { type: type, name: "action", value: name, disabled: loading || disabled || (enableFormErrorsValidation && formHasErrors), onClick: onClickSave, className: `${loading || disabled || (enableFormErrorsValidation && formHasErrors)
|
|
53
|
+
? " bg-opacity-25 "
|
|
54
|
+
: ""} ${loading
|
|
55
|
+
? " cursor-progress"
|
|
56
|
+
: `${disabled || (enableFormErrorsValidation && formHasErrors)
|
|
57
|
+
? ""
|
|
58
|
+
: `hover:${color.bg700}`}`} inline-flex justify-center rounded-md border border-transparent ${color.bg600} py-2 px-4 text-sm font-medium text-white shadow-sm focus:outline-none focus:ring-2 focus:${color.ring500} focus:ring-offset-2 ${className}`, children: loading ? children ?? loadingText : children ?? title }));
|
|
60
59
|
return (_jsxs(_Fragment, { children: [(enableFormErrorsValidation && formHasErrors && errorMessage) ||
|
|
61
60
|
(enableFormErrorsDescriptions && errorMessage) ? (_jsx("div", { className: "flex flex-col items-end mb-2", children: _jsx("div", { className: "p-2 bg-red-100 border border-red-400 text-red-700 rounded-md shadow-sm", children: _jsx("p", { className: "text-sm", children: errorMessage }) }) })) : null, buttonContent] }));
|
|
62
61
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
export const ButtonSectionContainer = (props) => {
|
|
3
|
-
const { children, className
|
|
4
|
-
return (_jsx("div", { className:
|
|
3
|
+
const { children, className } = props;
|
|
4
|
+
return (_jsx("div", { className: `mt-5 flex flex-col md:flex-row md:justify-end md:items-center space-x-0 space-y-4 md:space-y-0 md:space-x-4 ${className}`, children: children }));
|
|
5
5
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { jsx as _jsx
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
export const OutletContainer = (props) => {
|
|
3
3
|
const { children } = props;
|
|
4
|
-
return (_jsx(
|
|
4
|
+
return (_jsx("div", { className: "flex-1 overflow-x-auto", suppressHydrationWarning: true, children: children }));
|
|
5
5
|
};
|
|
@@ -108,24 +108,23 @@ export const DynamicPrintTable = ({ forwardedRef, ...props }) => {
|
|
|
108
108
|
const renderRows = () => {
|
|
109
109
|
return tableData?.map((rowData, rowIndex) => renderRow(rowData, rowIndex));
|
|
110
110
|
};
|
|
111
|
-
const
|
|
112
|
-
const borderColor = error ? "border-red-500" : "border-transparent";
|
|
111
|
+
const borderColor = "border-transparent";
|
|
113
112
|
useEffect(() => {
|
|
114
113
|
if (!isInitialItemAdded && items?.length > 0) {
|
|
115
114
|
insertItems([items[0]]);
|
|
116
115
|
setIsInitialItemAdded(true);
|
|
117
116
|
}
|
|
118
117
|
}, [isInitialItemAdded, items, insertItems]);
|
|
119
|
-
return (
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
118
|
+
return (_jsx("div", { className: `${className} ${borderColor} border-2`, style: { overflowX: "auto" }, children: _jsxs("table", { className: "w-full", children: [_jsx("thead", { children: renderHeader() }), _jsx("tbody", { children: renderRows() }), _jsx("tfoot", { children: _jsxs("tr", { children: [_jsx("td", { className: "align-middle", children: _jsx("button", { className: "bg-blue-500 hover:bg-blue-600 font-bold py-2 px-4 rounded", onClick: (event) => {
|
|
119
|
+
event.preventDefault();
|
|
120
|
+
event.stopPropagation();
|
|
121
|
+
addRow();
|
|
122
|
+
}, type: "button", children: "+" }) }), _jsxs("td", { colSpan: 2, children: ["Total de etiquetas a imprimir:", " ", tableData?.reduce((sum, x) => {
|
|
123
|
+
const val = React.isValidElement(x[1])
|
|
124
|
+
? x[1]?.props?.defaultValue
|
|
125
|
+
: undefined;
|
|
126
|
+
if (!sum)
|
|
127
|
+
return val;
|
|
128
|
+
return sum + val;
|
|
129
|
+
}, 0)] })] }) })] }) }));
|
|
131
130
|
};
|
|
@@ -301,7 +301,7 @@ export const GenericDynamicTable = (props) => {
|
|
|
301
301
|
};
|
|
302
302
|
return (_jsxs(_Fragment, { children: [name && (_jsxs(_Fragment, { children: [_jsx(GenericDynamicTableErrorComponent, { name: name }), _jsx("input", { name: name, type: "hidden", value: JSON.stringify(tableData), hidden: true }), _jsx("input", { name: `deleted_${name}`, type: "hidden", value: JSON.stringify(deletedData), hidden: true })] })), _jsxs("div", { className: `${className}`, children: [searcheables.length > 0 && (_jsx("div", { children: _jsx(TextField, { className: "mb-2", name: "search", title: `Buscar por: ${searcheables
|
|
303
303
|
.map((x) => x.label)
|
|
304
|
-
.join(", ")}`, onChange: handleChangeSearch, disabled: loading || readOnly }) })), _jsxs("table", { className: "w-full", children: [orientation === "horizontal" && _jsx("thead", { children: renderHeader() }), _jsx("tbody", { children: renderRows() }), isEditable && (_jsx("tfoot", { children: _jsx("tr", { children: _jsx("td", { colSpan: orientation === "horizontal" ? columns.length + 1 : 2, className: "align-middle", children: (!maxRows || tableData.length < maxRows) && (_jsx("button", { className: "bg-blue-500 hover:bg-blue-600 font-bold py-2 px-4 rounded", onClick: (event) => {
|
|
304
|
+
.join(", ")}`, onChange: handleChangeSearch, disabled: loading || readOnly }) })), _jsxs("table", { className: "w-full", children: [orientation === "horizontal" && _jsx("thead", { children: renderHeader() }), _jsx("tbody", { children: renderRows() }), isEditable && (_jsx("tfoot", { children: _jsx("tr", { children: _jsx("td", { colSpan: orientation === "horizontal" ? columns.length + 1 : 2, className: "align-middle text-right", children: (!maxRows || tableData.length < maxRows) && (_jsx("button", { className: "bg-blue-500 hover:bg-blue-600 font-bold py-2 px-4 rounded", onClick: (event) => {
|
|
305
305
|
event.preventDefault();
|
|
306
306
|
event.stopPropagation();
|
|
307
307
|
if (addRowButtonHandler) {
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import { jsx as _jsx,
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { TextField } from "../TextField/index.js";
|
|
3
|
-
import { TripleFieldContainer } from "../FieldContainer/index.js";
|
|
4
|
-
import { DoubleFieldContainer } from "../FieldContainer/index.js";
|
|
5
3
|
import { YesNo } from "../YesNo/index.js";
|
|
6
4
|
import { TextArea } from "../TextArea/index.js";
|
|
7
5
|
import { SelectField } from "../SelectField/index.js";
|
|
@@ -38,13 +36,19 @@ export const getDynamicBaculoFormSchema = (form, extraFieldValidations = {}) =>
|
|
|
38
36
|
return z.object(fieldValidations).passthrough(); // Iniciar con un esquema que deja pasar todo.
|
|
39
37
|
};
|
|
40
38
|
export function DynamicBaculoForm(props) {
|
|
41
|
-
const { form, options = { showDescription: false, showTitle: false }, namesStr = "", defaultValues = [], showingRules = [], readOnly = false, } = props;
|
|
39
|
+
const { form, options = { showDescription: false, showTitle: false }, namesStr = "", defaultValues = [], showingRules = [], readOnly = false, zauruBaseURL = "", setProcessing, } = props;
|
|
42
40
|
if (!form) {
|
|
43
41
|
return (_jsx(StaticAlert, { title: "No se encontr\u00F3 el formulario din\u00E1mico", description: `Ocurrió un error encontrando el formulario, contacte al administrador con este mensaje de error.`, type: "info" }));
|
|
44
42
|
}
|
|
45
43
|
const renderFieldComponent = (field) => {
|
|
46
44
|
const defaultValue = defaultValues?.find((x) => x.settings_form_field.print_var_name === field.print_var_name);
|
|
45
|
+
if (field.print_var_name?.toLowerCase() === "firma_cliente" &&
|
|
46
|
+
field.field_type === "image") {
|
|
47
|
+
return (_jsx(FileUploadField, { title: `FIRMA: ${field.required ? "*" : ""}${field.name}`, name: `${namesStr}${field.form_id}_${field.id}`, hint: field.hint, readOnly: readOnly, defaultValue: defaultValue?.value, zauruBaseURL: zauruBaseURL, setProcessing: setProcessing, signature: true }, field.id));
|
|
48
|
+
}
|
|
47
49
|
switch (field.field_type) {
|
|
50
|
+
case "zauru_data":
|
|
51
|
+
return null;
|
|
48
52
|
case "fixed_rows_table":
|
|
49
53
|
case "fixed_columns_table": {
|
|
50
54
|
const columns = field.settings_form_field_table_headers?.map((x) => {
|
|
@@ -56,22 +60,16 @@ export function DynamicBaculoForm(props) {
|
|
|
56
60
|
}) ?? [];
|
|
57
61
|
return (_jsx(SubContainer, { title: field.name, children: _jsx(GenericDynamicTable, { name: "fixed_columns_table", columns: columns }) }, field.id));
|
|
58
62
|
}
|
|
59
|
-
case "zauru_data": {
|
|
60
|
-
if (field.required) {
|
|
61
|
-
return (_jsx(TextField, { title: `${field.required ? "*" : ""}${field.name}`, hint: field.hint, defaultValue: defaultValue?.value ?? field.default_value, disabled: true }, field.id));
|
|
62
|
-
}
|
|
63
|
-
return _jsx(_Fragment, {});
|
|
64
|
-
}
|
|
65
63
|
case "hour":
|
|
66
64
|
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));
|
|
67
65
|
case "date":
|
|
68
66
|
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));
|
|
69
67
|
case "file":
|
|
70
|
-
return (_jsx(FileUploadField, { title: `${field.required ? "*" : ""}${field.name}`, name: `${namesStr}${field.form_id}_${field.id}`, hint: field.hint, readOnly: readOnly, defaultValue: defaultValue?.value, download: true }, field.id));
|
|
68
|
+
return (_jsx(FileUploadField, { title: `${field.required ? "*" : ""}${field.name}`, name: `${namesStr}${field.form_id}_${field.id}`, hint: field.hint, readOnly: readOnly, defaultValue: defaultValue?.value, download: true, zauruBaseURL: zauruBaseURL, setProcessing: setProcessing }, field.id));
|
|
71
69
|
case "image":
|
|
72
|
-
return (_jsx(FileUploadField, { title: `${field.required ? "*" : ""}${field.name}`, name: `${namesStr}${field.form_id}_${field.id}`, hint: field.hint, showAvailableTypes: true, fileTypes: ["png", "jpg", "jpeg"], readOnly: readOnly, defaultValue: defaultValue?.value }, field.id));
|
|
70
|
+
return (_jsx(FileUploadField, { title: `${field.required ? "*" : ""}${field.name}`, name: `${namesStr}${field.form_id}_${field.id}`, hint: field.hint, showAvailableTypes: true, fileTypes: ["png", "jpg", "jpeg"], readOnly: readOnly, defaultValue: defaultValue?.value, zauruBaseURL: zauruBaseURL, setProcessing: setProcessing }, field.id));
|
|
73
71
|
case "pdf":
|
|
74
|
-
return (_jsx(FileUploadField, { title: `${field.required ? "*" : ""}${field.name}`, name: `${namesStr}${field.form_id}_${field.id}`, hint: field.hint, showAvailableTypes: true, fileTypes: ["pdf"], readOnly: readOnly, defaultValue: defaultValue?.value, download: true }, field.id));
|
|
72
|
+
return (_jsx(FileUploadField, { title: `${field.required ? "*" : ""}${field.name}`, name: `${namesStr}${field.form_id}_${field.id}`, hint: field.hint, showAvailableTypes: true, fileTypes: ["pdf"], readOnly: readOnly, defaultValue: defaultValue?.value, download: true, zauruBaseURL: zauruBaseURL, setProcessing: setProcessing }, field.id));
|
|
75
73
|
case "email":
|
|
76
74
|
case "url":
|
|
77
75
|
case "text":
|
|
@@ -117,52 +115,18 @@ export function DynamicBaculoForm(props) {
|
|
|
117
115
|
};
|
|
118
116
|
const renderFields = () => {
|
|
119
117
|
const fields = form.settings_form_fields;
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
if (!(rule && !rule.show)) {
|
|
118
|
+
return (_jsx("div", { className: "flex flex-wrap gap-4 items-stretch", children: fields.map((field) => {
|
|
119
|
+
const rule = showingRules.find((x) => x.name === field.name);
|
|
120
|
+
if (rule && !rule.show)
|
|
121
|
+
return null;
|
|
125
122
|
const renderedField = renderFieldComponent(field);
|
|
126
|
-
if (renderedField
|
|
127
|
-
return;
|
|
128
|
-
}
|
|
129
|
-
tempGroup.push(renderedField);
|
|
130
|
-
const isLastField = i === fields.length - 1;
|
|
123
|
+
if (!renderedField)
|
|
124
|
+
return null;
|
|
131
125
|
const isSectionField = field.field_type === "section";
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
}
|
|
137
|
-
else if (tempGroup.length === 2) {
|
|
138
|
-
fieldGroups.push(_jsx(DoubleFieldContainer, { children: tempGroup }, i));
|
|
139
|
-
}
|
|
140
|
-
else if (tempGroup.length === 3) {
|
|
141
|
-
fieldGroups.push(_jsx(TripleFieldContainer, { children: tempGroup }, i));
|
|
142
|
-
}
|
|
143
|
-
fieldGroups.push(renderedField);
|
|
144
|
-
tempGroup = [];
|
|
145
|
-
}
|
|
146
|
-
else if (isLastField) {
|
|
147
|
-
if (tempGroup.length === 1) {
|
|
148
|
-
fieldGroups.push(tempGroup[0]);
|
|
149
|
-
}
|
|
150
|
-
else if (tempGroup.length === 2) {
|
|
151
|
-
fieldGroups.push(_jsx(DoubleFieldContainer, { children: tempGroup }, i));
|
|
152
|
-
}
|
|
153
|
-
else if (tempGroup.length === 3) {
|
|
154
|
-
fieldGroups.push(_jsx(TripleFieldContainer, { children: tempGroup }, i));
|
|
155
|
-
}
|
|
156
|
-
tempGroup = [];
|
|
157
|
-
}
|
|
158
|
-
else if (tempGroup.length === 3) {
|
|
159
|
-
// Si hay 3 elementos en el grupo temporal y el siguiente campo no es 'section', se agrega a fieldGroups
|
|
160
|
-
fieldGroups.push(_jsx(TripleFieldContainer, { children: tempGroup }, i));
|
|
161
|
-
tempGroup = [];
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
});
|
|
165
|
-
return fieldGroups;
|
|
126
|
+
return (_jsx("div", { className: isSectionField
|
|
127
|
+
? "w-full"
|
|
128
|
+
: "flex flex-col h-full flex-grow min-w-[250px] max-w-full sm:max-w-[48%] lg:max-w-[24%]", children: renderedField }, field.id));
|
|
129
|
+
}) }));
|
|
166
130
|
};
|
|
167
131
|
return (_jsx(SubContainer, { title: options?.showTitle ? form.name : undefined, description: options?.showDescription ? form.description : undefined, children: renderFields() }));
|
|
168
132
|
}
|