@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
|
@@ -3,17 +3,14 @@ import React from "react";
|
|
|
3
3
|
type Props = {
|
|
4
4
|
children: React.ReactNode;
|
|
5
5
|
className?: string;
|
|
6
|
-
whitBg?: boolean;
|
|
7
6
|
};
|
|
8
7
|
|
|
9
8
|
export const ButtonSectionContainer = (props: Props) => {
|
|
10
|
-
const { children, className
|
|
9
|
+
const { children, className } = props;
|
|
11
10
|
|
|
12
11
|
return (
|
|
13
12
|
<div
|
|
14
|
-
className={
|
|
15
|
-
whitBg ? "bg-gray-50" : ""
|
|
16
|
-
} px-4 py-3 text-right sm:px-6 ${className}`}
|
|
13
|
+
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}`}
|
|
17
14
|
>
|
|
18
15
|
{children}
|
|
19
16
|
</div>
|
|
@@ -7,8 +7,8 @@ type Props = {
|
|
|
7
7
|
export const OutletContainer = (props: Props) => {
|
|
8
8
|
const { children } = props;
|
|
9
9
|
return (
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
<div className="flex-1 overflow-x-auto" suppressHydrationWarning>
|
|
11
|
+
{children}
|
|
12
|
+
</div>
|
|
13
13
|
);
|
|
14
14
|
};
|
|
@@ -17,7 +17,6 @@ export type FormatedItem = {
|
|
|
17
17
|
|
|
18
18
|
type Props = {
|
|
19
19
|
name: string;
|
|
20
|
-
formName?: string;
|
|
21
20
|
className?: string;
|
|
22
21
|
items: FormatedItem[];
|
|
23
22
|
onChange?: (tableState?: TableStateItem[]) => void;
|
|
@@ -233,8 +232,7 @@ export const DynamicPrintTable = ({ forwardedRef, ...props }: Props) => {
|
|
|
233
232
|
return tableData?.map((rowData, rowIndex) => renderRow(rowData, rowIndex));
|
|
234
233
|
};
|
|
235
234
|
|
|
236
|
-
const
|
|
237
|
-
const borderColor = error ? "border-red-500" : "border-transparent";
|
|
235
|
+
const borderColor = "border-transparent";
|
|
238
236
|
|
|
239
237
|
useEffect(() => {
|
|
240
238
|
if (!isInitialItemAdded && items?.length > 0) {
|
|
@@ -248,7 +246,6 @@ export const DynamicPrintTable = ({ forwardedRef, ...props }: Props) => {
|
|
|
248
246
|
className={`${className} ${borderColor} border-2`}
|
|
249
247
|
style={{ overflowX: "auto" }}
|
|
250
248
|
>
|
|
251
|
-
{!!error && <div className="text-red-500 text-sm mb-2">{error}</div>}
|
|
252
249
|
<table className="w-full">
|
|
253
250
|
<thead>{renderHeader()}</thead>
|
|
254
251
|
<tbody>{renderRows()}</tbody>
|
|
@@ -566,7 +566,7 @@ export const GenericDynamicTable = (props: Props) => {
|
|
|
566
566
|
colSpan={
|
|
567
567
|
orientation === "horizontal" ? columns.length + 1 : 2
|
|
568
568
|
}
|
|
569
|
-
className="align-middle"
|
|
569
|
+
className="align-middle text-right"
|
|
570
570
|
>
|
|
571
571
|
{(!maxRows || tableData.length < maxRows) && (
|
|
572
572
|
<button
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import { TextField } from "../TextField/index.js";
|
|
2
|
-
import { TripleFieldContainer } from "../FieldContainer/index.js";
|
|
3
|
-
import { DoubleFieldContainer } from "../FieldContainer/index.js";
|
|
4
2
|
import { YesNo } from "../YesNo/index.js";
|
|
5
3
|
import { TextArea } from "../TextArea/index.js";
|
|
6
4
|
import { SelectField } from "../SelectField/index.js";
|
|
@@ -20,6 +18,7 @@ import { StaticAlert } from "../../Alerts/index.js";
|
|
|
20
18
|
import { SubContainer } from "../../Containers/index.js";
|
|
21
19
|
import { LineSeparator } from "../../LineSeparator/index.js";
|
|
22
20
|
import { z } from "zod";
|
|
21
|
+
|
|
23
22
|
export const getDynamicBaculoFormSchema = (
|
|
24
23
|
form?: FormGraphQL,
|
|
25
24
|
extraFieldValidations: { [key: string]: any } = {}
|
|
@@ -55,6 +54,8 @@ type Props = {
|
|
|
55
54
|
namesStr?: string;
|
|
56
55
|
showingRules?: { name: string; show: boolean }[];
|
|
57
56
|
readOnly?: boolean;
|
|
57
|
+
zauruBaseURL?: string;
|
|
58
|
+
setProcessing?: (processing: boolean) => void;
|
|
58
59
|
};
|
|
59
60
|
|
|
60
61
|
export function DynamicBaculoForm(props: Props) {
|
|
@@ -65,6 +66,8 @@ export function DynamicBaculoForm(props: Props) {
|
|
|
65
66
|
defaultValues = [],
|
|
66
67
|
showingRules = [],
|
|
67
68
|
readOnly = false,
|
|
69
|
+
zauruBaseURL = "",
|
|
70
|
+
setProcessing,
|
|
68
71
|
} = props;
|
|
69
72
|
|
|
70
73
|
if (!form) {
|
|
@@ -81,7 +84,29 @@ export function DynamicBaculoForm(props: Props) {
|
|
|
81
84
|
const defaultValue = defaultValues?.find(
|
|
82
85
|
(x) => x.settings_form_field.print_var_name === field.print_var_name
|
|
83
86
|
);
|
|
87
|
+
|
|
88
|
+
if (
|
|
89
|
+
field.print_var_name?.toLowerCase() === "firma_cliente" &&
|
|
90
|
+
field.field_type === "image"
|
|
91
|
+
) {
|
|
92
|
+
return (
|
|
93
|
+
<FileUploadField
|
|
94
|
+
key={field.id}
|
|
95
|
+
title={`FIRMA: ${field.required ? "*" : ""}${field.name}`}
|
|
96
|
+
name={`${namesStr}${field.form_id}_${field.id}`}
|
|
97
|
+
hint={field.hint}
|
|
98
|
+
readOnly={readOnly}
|
|
99
|
+
defaultValue={defaultValue?.value}
|
|
100
|
+
zauruBaseURL={zauruBaseURL}
|
|
101
|
+
setProcessing={setProcessing}
|
|
102
|
+
signature
|
|
103
|
+
/>
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
|
|
84
107
|
switch (field.field_type) {
|
|
108
|
+
case "zauru_data":
|
|
109
|
+
return null;
|
|
85
110
|
case "fixed_rows_table":
|
|
86
111
|
case "fixed_columns_table": {
|
|
87
112
|
const columns: GenericDynamicTableColumn[] =
|
|
@@ -98,20 +123,6 @@ export function DynamicBaculoForm(props: Props) {
|
|
|
98
123
|
</SubContainer>
|
|
99
124
|
);
|
|
100
125
|
}
|
|
101
|
-
case "zauru_data": {
|
|
102
|
-
if (field.required) {
|
|
103
|
-
return (
|
|
104
|
-
<TextField
|
|
105
|
-
key={field.id}
|
|
106
|
-
title={`${field.required ? "*" : ""}${field.name}`}
|
|
107
|
-
hint={field.hint}
|
|
108
|
-
defaultValue={defaultValue?.value ?? field.default_value}
|
|
109
|
-
disabled={true}
|
|
110
|
-
/>
|
|
111
|
-
);
|
|
112
|
-
}
|
|
113
|
-
return <></>;
|
|
114
|
-
}
|
|
115
126
|
case "hour":
|
|
116
127
|
return (
|
|
117
128
|
<FormTimePicker
|
|
@@ -144,6 +155,8 @@ export function DynamicBaculoForm(props: Props) {
|
|
|
144
155
|
readOnly={readOnly}
|
|
145
156
|
defaultValue={defaultValue?.value}
|
|
146
157
|
download={true}
|
|
158
|
+
zauruBaseURL={zauruBaseURL}
|
|
159
|
+
setProcessing={setProcessing}
|
|
147
160
|
/>
|
|
148
161
|
);
|
|
149
162
|
case "image":
|
|
@@ -157,6 +170,8 @@ export function DynamicBaculoForm(props: Props) {
|
|
|
157
170
|
fileTypes={["png", "jpg", "jpeg"]}
|
|
158
171
|
readOnly={readOnly}
|
|
159
172
|
defaultValue={defaultValue?.value}
|
|
173
|
+
zauruBaseURL={zauruBaseURL}
|
|
174
|
+
setProcessing={setProcessing}
|
|
160
175
|
/>
|
|
161
176
|
);
|
|
162
177
|
case "pdf":
|
|
@@ -171,6 +186,8 @@ export function DynamicBaculoForm(props: Props) {
|
|
|
171
186
|
readOnly={readOnly}
|
|
172
187
|
defaultValue={defaultValue?.value}
|
|
173
188
|
download={true}
|
|
189
|
+
zauruBaseURL={zauruBaseURL}
|
|
190
|
+
setProcessing={setProcessing}
|
|
174
191
|
/>
|
|
175
192
|
);
|
|
176
193
|
case "email":
|
|
@@ -324,60 +341,32 @@ export function DynamicBaculoForm(props: Props) {
|
|
|
324
341
|
|
|
325
342
|
const renderFields = () => {
|
|
326
343
|
const fields = form.settings_form_fields;
|
|
327
|
-
|
|
328
|
-
|
|
344
|
+
return (
|
|
345
|
+
<div className="flex flex-wrap gap-4 items-stretch">
|
|
346
|
+
{fields.map((field) => {
|
|
347
|
+
const rule = showingRules.find((x) => x.name === field.name);
|
|
348
|
+
if (rule && !rule.show) return null;
|
|
329
349
|
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
if (!(rule && !rule.show)) {
|
|
333
|
-
const renderedField = renderFieldComponent(field);
|
|
334
|
-
if (renderedField === null) {
|
|
335
|
-
return;
|
|
336
|
-
}
|
|
337
|
-
tempGroup.push(renderedField);
|
|
350
|
+
const renderedField = renderFieldComponent(field);
|
|
351
|
+
if (!renderedField) return null;
|
|
338
352
|
|
|
339
|
-
|
|
340
|
-
const isSectionField = field.field_type === "section";
|
|
353
|
+
const isSectionField = field.field_type === "section";
|
|
341
354
|
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
);
|
|
354
|
-
}
|
|
355
|
-
fieldGroups.push(renderedField);
|
|
356
|
-
tempGroup = [];
|
|
357
|
-
} else if (isLastField) {
|
|
358
|
-
if (tempGroup.length === 1) {
|
|
359
|
-
fieldGroups.push(tempGroup[0]);
|
|
360
|
-
} else if (tempGroup.length === 2) {
|
|
361
|
-
fieldGroups.push(
|
|
362
|
-
<DoubleFieldContainer key={i}>{tempGroup}</DoubleFieldContainer>
|
|
363
|
-
);
|
|
364
|
-
} else if (tempGroup.length === 3) {
|
|
365
|
-
fieldGroups.push(
|
|
366
|
-
<TripleFieldContainer key={i}>{tempGroup}</TripleFieldContainer>
|
|
367
|
-
);
|
|
368
|
-
}
|
|
369
|
-
tempGroup = [];
|
|
370
|
-
} else if (tempGroup.length === 3) {
|
|
371
|
-
// Si hay 3 elementos en el grupo temporal y el siguiente campo no es 'section', se agrega a fieldGroups
|
|
372
|
-
fieldGroups.push(
|
|
373
|
-
<TripleFieldContainer key={i}>{tempGroup}</TripleFieldContainer>
|
|
355
|
+
return (
|
|
356
|
+
<div
|
|
357
|
+
key={field.id}
|
|
358
|
+
className={
|
|
359
|
+
isSectionField
|
|
360
|
+
? "w-full"
|
|
361
|
+
: "flex flex-col h-full flex-grow min-w-[250px] max-w-full sm:max-w-[48%] lg:max-w-[24%]"
|
|
362
|
+
}
|
|
363
|
+
>
|
|
364
|
+
{renderedField}
|
|
365
|
+
</div>
|
|
374
366
|
);
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
});
|
|
379
|
-
|
|
380
|
-
return fieldGroups;
|
|
367
|
+
})}
|
|
368
|
+
</div>
|
|
369
|
+
);
|
|
381
370
|
};
|
|
382
371
|
|
|
383
372
|
return (
|