@zauru-sdk/components 1.0.13 → 1.0.14
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/Chat/ChatLayout.d.ts +17 -0
- package/dist/Chat/ChatLayout.js +28 -0
- package/dist/Chat/ChatMessageHistory.d.ts +12 -0
- package/dist/Chat/ChatMessageHistory.js +53 -0
- package/dist/Chat/index.d.ts +2 -0
- package/dist/Chat/index.js +2 -0
- package/dist/ConnectionState/ConnectionState.d.ts +2 -0
- package/dist/ConnectionState/ConnectionState.js +22 -0
- package/dist/ConnectionState/index.d.ts +1 -0
- package/dist/ConnectionState/index.js +1 -0
- package/dist/DynamicTable/BasicPrintDynamicTable.d.ts +10 -0
- package/dist/DynamicTable/BasicPrintDynamicTable.js +27 -0
- package/dist/DynamicTable/DynamicPrintTable.d.ts +23 -0
- package/dist/DynamicTable/DynamicPrintTable.js +132 -0
- package/dist/DynamicTable/GenericDynamicTable.d.ts +21 -0
- package/dist/DynamicTable/GenericDynamicTable.js +195 -0
- package/dist/DynamicTable/index.d.ts +24 -0
- package/dist/DynamicTable/index.js +193 -0
- package/dist/Footer/Footer.js +2 -2
- package/dist/Form/Checkbox/index.d.ts +17 -0
- package/dist/Form/Checkbox/index.js +34 -0
- package/dist/Form/Checklist/index.d.ts +14 -0
- package/dist/Form/Checklist/index.js +10 -0
- package/dist/Form/DatePicker/index.d.ts +18 -0
- package/dist/Form/DatePicker/index.js +31 -0
- package/dist/Form/DynamicBaculoForm/index.d.ts +18 -0
- package/dist/Form/DynamicBaculoForm/index.js +138 -0
- package/dist/Form/FieldContainer/DoubleFieldContainer.d.ts +8 -0
- package/dist/Form/FieldContainer/DoubleFieldContainer.js +14 -0
- package/dist/Form/FieldContainer/QuadrupleFieldContainer.d.ts +7 -0
- package/dist/Form/FieldContainer/QuadrupleFieldContainer.js +14 -0
- package/dist/Form/FieldContainer/TripleFieldContainer.d.ts +7 -0
- package/dist/Form/FieldContainer/TripleFieldContainer.js +14 -0
- package/dist/Form/FieldContainer/index.d.ts +3 -0
- package/dist/Form/FieldContainer/index.js +3 -0
- package/dist/Form/FileUpload/index.d.ts +21 -0
- package/dist/Form/FileUpload/index.js +54 -0
- package/dist/Form/FormButtons/index.d.ts +16 -0
- package/dist/Form/FormButtons/index.js +5 -0
- package/dist/Form/FormLayout/index.d.ts +11 -0
- package/dist/Form/FormLayout/index.js +7 -0
- package/dist/Form/SelectField/index.d.ts +27 -0
- package/dist/Form/SelectField/index.js +74 -0
- package/dist/Form/TextArea/index.d.ts +23 -0
- package/dist/Form/TextArea/index.js +36 -0
- package/dist/Form/TextField/index.d.ts +25 -0
- package/dist/Form/TextField/index.js +70 -0
- package/dist/Form/TimePicker/index.d.ts +16 -0
- package/dist/Form/TimePicker/index.js +31 -0
- package/dist/Form/YesNo/index.d.ts +12 -0
- package/dist/Form/YesNo/index.js +19 -0
- package/dist/Form/index.d.ts +13 -0
- package/dist/Form/index.js +13 -0
- package/dist/Zendesk/Chat.d.ts +14 -0
- package/dist/Zendesk/Chat.js +64 -0
- package/dist/Zendesk/index.d.ts +2 -0
- package/dist/Zendesk/index.js +2 -0
- package/dist/Zendesk/zendesk.config.d.ts +9 -0
- package/dist/Zendesk/zendesk.config.js +24 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -2
- package/package.json +5 -5
- package/src/Chat/ChatLayout.tsx +133 -0
- package/src/Chat/ChatMessageHistory.tsx +142 -0
- package/src/Chat/index.ts +2 -0
- package/src/ConnectionState/ConnectionState.tsx +29 -0
- package/src/ConnectionState/index.tsx +1 -0
- package/src/DynamicTable/BasicPrintDynamicTable.tsx +73 -0
- package/src/DynamicTable/DynamicPrintTable.tsx +290 -0
- package/src/DynamicTable/GenericDynamicTable.tsx +455 -0
- package/src/DynamicTable/index.tsx +407 -0
- package/src/Footer/Footer.tsx +3 -3
- package/src/Form/Checkbox/index.tsx +96 -0
- package/src/Form/Checklist/index.tsx +35 -0
- package/src/Form/DatePicker/index.tsx +132 -0
- package/src/Form/DynamicBaculoForm/index.tsx +359 -0
- package/src/Form/FieldContainer/DoubleFieldContainer.tsx +35 -0
- package/src/Form/FieldContainer/QuadrupleFieldContainer.tsx +36 -0
- package/src/Form/FieldContainer/TripleFieldContainer.tsx +35 -0
- package/src/Form/FieldContainer/index.ts +3 -0
- package/src/Form/FileUpload/index.tsx +184 -0
- package/src/Form/FormButtons/index.tsx +78 -0
- package/src/Form/FormLayout/index.tsx +37 -0
- package/src/Form/SelectField/index.tsx +237 -0
- package/src/Form/TextArea/index.tsx +125 -0
- package/src/Form/TextField/index.tsx +194 -0
- package/src/Form/TimePicker/index.tsx +127 -0
- package/src/Form/YesNo/index.tsx +79 -0
- package/src/Form/index.ts +13 -0
- package/src/Zendesk/Chat.tsx +85 -0
- package/src/Zendesk/index.ts +2 -0
- package/src/Zendesk/zendesk.config.ts +40 -0
- package/src/index.ts +4 -2
package/dist/index.js
CHANGED
|
@@ -2,9 +2,11 @@ export * from "./Alerts";
|
|
|
2
2
|
export * from "./BlockUI";
|
|
3
3
|
export * from "./Buttons";
|
|
4
4
|
export * from "./Card";
|
|
5
|
-
|
|
5
|
+
export * from "./ConnectionState";
|
|
6
|
+
export * from "./Chat";
|
|
6
7
|
export * from "./Containers";
|
|
7
8
|
export * from "./Footer";
|
|
9
|
+
export * from "./Form";
|
|
8
10
|
export * from "./Labels";
|
|
9
11
|
export * from "./Layouts";
|
|
10
12
|
export * from "./LineSeparator";
|
|
@@ -18,4 +20,4 @@ export * from "./Titles";
|
|
|
18
20
|
export * from "./Tooltip";
|
|
19
21
|
export * from "./WithTooltip";
|
|
20
22
|
export * from "./Wizards";
|
|
21
|
-
|
|
23
|
+
export * from "./Zendesk";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zauru-sdk/components",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.14",
|
|
4
4
|
"description": "Componentes reutilizables en las WebApps de Zauru.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
"author": "Oscar Cuéllar",
|
|
16
16
|
"license": "MIT",
|
|
17
17
|
"devDependencies": {
|
|
18
|
+
"@types/jsonwebtoken": "^9.0.2",
|
|
18
19
|
"@types/react": "^18.2.20",
|
|
19
20
|
"@types/react-dom": "^18.2.7",
|
|
20
21
|
"eslint": "^8.38.0",
|
|
@@ -32,13 +33,12 @@
|
|
|
32
33
|
"@reduxjs/toolkit": "^2.2.1",
|
|
33
34
|
"@remix-run/react": "^2.8.1",
|
|
34
35
|
"@zauru-sdk/common": "^1.0.13",
|
|
35
|
-
"@zauru-sdk/
|
|
36
|
+
"@zauru-sdk/hooks": "^1.0.13",
|
|
36
37
|
"@zauru-sdk/icons": "^1.0.13",
|
|
37
|
-
"@zauru-sdk/services": "^1.0.13",
|
|
38
38
|
"@zauru-sdk/types": "^1.0.13",
|
|
39
39
|
"@zauru-sdk/utils": "^1.0.13",
|
|
40
40
|
"framer-motion": "^11.0.8",
|
|
41
|
-
"jsonwebtoken": "9.0.2",
|
|
41
|
+
"jsonwebtoken": "^9.0.2",
|
|
42
42
|
"react": "^18.2.0",
|
|
43
43
|
"react-dom": "^18.2.0",
|
|
44
44
|
"react-is": "^18.2.0",
|
|
@@ -48,5 +48,5 @@
|
|
|
48
48
|
"engines": {
|
|
49
49
|
"node": ">=18.0.0"
|
|
50
50
|
},
|
|
51
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "47cb7f76fbc0d2b66e4caf7294ed1cc067a19f0f"
|
|
52
52
|
}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import React, { useRef, useState } from "react";
|
|
2
|
+
import { TextField } from "../Form";
|
|
3
|
+
import { Form } from "@remix-run/react";
|
|
4
|
+
import { FormDocumentType } from "@zauru-sdk/types";
|
|
5
|
+
import { LoadingInputSkeleton } from "src";
|
|
6
|
+
import {
|
|
7
|
+
AttachmentIconSVG,
|
|
8
|
+
SendMessageIcon,
|
|
9
|
+
SpinnerSvg,
|
|
10
|
+
} from "@zauru-sdk/icons";
|
|
11
|
+
|
|
12
|
+
interface ChatLayoutProps {
|
|
13
|
+
children?: React.ReactNode;
|
|
14
|
+
sendingMessage?: boolean;
|
|
15
|
+
formConfig?: {
|
|
16
|
+
document_type: FormDocumentType;
|
|
17
|
+
form_id: number;
|
|
18
|
+
document_id: number;
|
|
19
|
+
id_number?: string;
|
|
20
|
+
reference?: string;
|
|
21
|
+
attachmentFieldId: number;
|
|
22
|
+
messageFieldId: number;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const ChatLayout: React.FC<ChatLayoutProps> = ({
|
|
27
|
+
children,
|
|
28
|
+
sendingMessage = false,
|
|
29
|
+
formConfig = undefined,
|
|
30
|
+
}) => {
|
|
31
|
+
const refAttachment = useRef<HTMLInputElement>(null);
|
|
32
|
+
const [formValues, setFormValues] = useState<{ image: any }>({ image: null });
|
|
33
|
+
|
|
34
|
+
const handleAttachmentClick = () => {
|
|
35
|
+
if (refAttachment.current) {
|
|
36
|
+
refAttachment.current.click();
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<div className="flex flex-col h-full">
|
|
42
|
+
<div className="flex flex-col-reverse overflow-y-auto p-4 bg-gray-100 border border-gray-200 rounded-lg grow max-h-[65vh]">
|
|
43
|
+
{children}
|
|
44
|
+
</div>
|
|
45
|
+
<Form id="formRef" encType="multipart/form-data" method="post">
|
|
46
|
+
{formConfig ? (
|
|
47
|
+
<>
|
|
48
|
+
<TextField
|
|
49
|
+
hidden
|
|
50
|
+
name="reference"
|
|
51
|
+
defaultValue={formConfig.reference ?? ""}
|
|
52
|
+
/>
|
|
53
|
+
<TextField
|
|
54
|
+
hidden
|
|
55
|
+
name="form_id"
|
|
56
|
+
defaultValue={formConfig.form_id}
|
|
57
|
+
/>
|
|
58
|
+
<TextField
|
|
59
|
+
hidden
|
|
60
|
+
name="document_id"
|
|
61
|
+
defaultValue={formConfig.document_id}
|
|
62
|
+
/>
|
|
63
|
+
<TextField
|
|
64
|
+
hidden
|
|
65
|
+
name="document_type"
|
|
66
|
+
defaultValue={formConfig.document_type}
|
|
67
|
+
/>
|
|
68
|
+
<TextField
|
|
69
|
+
hidden
|
|
70
|
+
name="id_number"
|
|
71
|
+
defaultValue={formConfig?.id_number ?? ""}
|
|
72
|
+
/>
|
|
73
|
+
</>
|
|
74
|
+
) : (
|
|
75
|
+
<></>
|
|
76
|
+
)}
|
|
77
|
+
<div className="mt-4 flex">
|
|
78
|
+
{sendingMessage ? (
|
|
79
|
+
<LoadingInputSkeleton />
|
|
80
|
+
) : (
|
|
81
|
+
<input
|
|
82
|
+
name={`message${
|
|
83
|
+
formConfig?.messageFieldId
|
|
84
|
+
? `_${formConfig?.messageFieldId}`
|
|
85
|
+
: ""
|
|
86
|
+
}`}
|
|
87
|
+
type="text"
|
|
88
|
+
placeholder="Escribe un mensaje..."
|
|
89
|
+
className="form-input px-4 py-2 border border-gray-300 rounded-l-lg grow"
|
|
90
|
+
/>
|
|
91
|
+
)}
|
|
92
|
+
<button
|
|
93
|
+
onClick={handleAttachmentClick}
|
|
94
|
+
className={`${
|
|
95
|
+
formValues?.image ? "bg-blue-500" : ""
|
|
96
|
+
} hover:bg-blue-700 text-white font-bold py-2 px-4`}
|
|
97
|
+
type="button"
|
|
98
|
+
>
|
|
99
|
+
<AttachmentIconSVG />
|
|
100
|
+
</button>
|
|
101
|
+
<button
|
|
102
|
+
className="bg-green-500 hover:bg-green-700 text-white font-bold py-2 px-4 rounded-r-lg"
|
|
103
|
+
type="submit"
|
|
104
|
+
name="action"
|
|
105
|
+
value="sendMessage"
|
|
106
|
+
>
|
|
107
|
+
{sendingMessage ? <SpinnerSvg /> : <SendMessageIcon />}
|
|
108
|
+
</button>
|
|
109
|
+
</div>
|
|
110
|
+
<input
|
|
111
|
+
ref={refAttachment}
|
|
112
|
+
hidden
|
|
113
|
+
name={`attachment${
|
|
114
|
+
formConfig?.attachmentFieldId
|
|
115
|
+
? `_${formConfig?.attachmentFieldId}`
|
|
116
|
+
: ""
|
|
117
|
+
}`}
|
|
118
|
+
type="file"
|
|
119
|
+
accept=".jpg, .png, .jpeg, .png"
|
|
120
|
+
onChange={(e) => {
|
|
121
|
+
if (e.target.value && e.target.value !== "") {
|
|
122
|
+
setFormValues({ ...formValues, image: e.target.value });
|
|
123
|
+
} else {
|
|
124
|
+
setFormValues({ ...formValues, image: null });
|
|
125
|
+
}
|
|
126
|
+
}}
|
|
127
|
+
/>
|
|
128
|
+
</Form>
|
|
129
|
+
</div>
|
|
130
|
+
);
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
export default ChatLayout;
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { CheckIconSVG, PencilSvg } from "@zauru-sdk/icons";
|
|
2
|
+
import { useState, useEffect, useRef } from "react";
|
|
3
|
+
|
|
4
|
+
type Props = {
|
|
5
|
+
author: string;
|
|
6
|
+
content: string;
|
|
7
|
+
date?: string;
|
|
8
|
+
onLike?: (like: boolean) => void;
|
|
9
|
+
onUpdateComment?: (text: string, itsNew?: boolean) => void;
|
|
10
|
+
id: string;
|
|
11
|
+
commentOwner?: boolean;
|
|
12
|
+
imageLink?: string;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export const ChatMessageHistory = (props: Props) => {
|
|
16
|
+
const {
|
|
17
|
+
author,
|
|
18
|
+
content,
|
|
19
|
+
onLike,
|
|
20
|
+
onUpdateComment,
|
|
21
|
+
id,
|
|
22
|
+
commentOwner = false,
|
|
23
|
+
date,
|
|
24
|
+
imageLink,
|
|
25
|
+
} = props;
|
|
26
|
+
|
|
27
|
+
const initials = author ? author[0].toUpperCase() : "A";
|
|
28
|
+
const [isUpdating, setIsUpdating] = useState(false);
|
|
29
|
+
const [updatedContent, setUpdatedContent] = useState(content);
|
|
30
|
+
const textAreaRef = useRef<HTMLTextAreaElement | null>(null);
|
|
31
|
+
const [shouldPulse, setShouldPulse] = useState(false);
|
|
32
|
+
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
if (isUpdating && textAreaRef.current) {
|
|
35
|
+
textAreaRef.current.style.height = "auto";
|
|
36
|
+
textAreaRef.current.style.height = `${textAreaRef.current.scrollHeight}px`;
|
|
37
|
+
textAreaRef.current.focus();
|
|
38
|
+
}
|
|
39
|
+
}, [isUpdating]);
|
|
40
|
+
|
|
41
|
+
// Efecto secundario que se ejecuta cada vez que 'isUpdating' cambia
|
|
42
|
+
useEffect(() => {
|
|
43
|
+
// Activar la animación
|
|
44
|
+
setShouldPulse(true);
|
|
45
|
+
|
|
46
|
+
// Establecer un temporizador para eliminar la clase después de que la animación se haya completado
|
|
47
|
+
const timer = setTimeout(() => {
|
|
48
|
+
setShouldPulse(false);
|
|
49
|
+
}, 15000); // Tiempo total de la animación
|
|
50
|
+
|
|
51
|
+
// Limpiar el temporizador si el componente se desmonta o si 'isUpdating' cambia de nuevo antes de que la animación se complete
|
|
52
|
+
return () => clearTimeout(timer);
|
|
53
|
+
}, [isUpdating]);
|
|
54
|
+
|
|
55
|
+
const handleUpdate = (e: React.ChangeEvent<HTMLTextAreaElement>) => {
|
|
56
|
+
if (e.target.value.length <= 254) {
|
|
57
|
+
setUpdatedContent(e.target.value);
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const handleUpdateClick = () => {
|
|
62
|
+
if (isUpdating) {
|
|
63
|
+
if (textAreaRef.current) {
|
|
64
|
+
textAreaRef.current.blur();
|
|
65
|
+
}
|
|
66
|
+
//onUpdateComment && onUpdateComment(updatedContent, itsNew);
|
|
67
|
+
}
|
|
68
|
+
setIsUpdating(!isUpdating);
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
return (
|
|
72
|
+
<div className="p-1 rounded-xl flex items-center space-x-4 relative">
|
|
73
|
+
{commentOwner && (
|
|
74
|
+
<div className="absolute top-2 right-2">
|
|
75
|
+
<button
|
|
76
|
+
onClick={handleUpdateClick}
|
|
77
|
+
className={`${shouldPulse ? "animate-custom-pulse" : ""}`}
|
|
78
|
+
>
|
|
79
|
+
{isUpdating ? <CheckIconSVG /> : <PencilSvg />}
|
|
80
|
+
</button>
|
|
81
|
+
</div>
|
|
82
|
+
)}
|
|
83
|
+
<div
|
|
84
|
+
className={`w-[0%] lg:w-[8%] h-16 bg-purple-300 rounded-full flex items-center justify-center overflow-hidden text-white text-xl font-bold`}
|
|
85
|
+
>
|
|
86
|
+
{initials}
|
|
87
|
+
</div>
|
|
88
|
+
<div className="flex flex-col justify-between h-full w-[92%]">
|
|
89
|
+
<div>
|
|
90
|
+
<div className="flex flex-row space-x-2">
|
|
91
|
+
<div className="text-xl font-medium text-black">{author}</div>
|
|
92
|
+
<div className="text-xl font-medium text-gray-500">
|
|
93
|
+
{date && <> - {date}</>}
|
|
94
|
+
</div>
|
|
95
|
+
</div>
|
|
96
|
+
{isUpdating ? (
|
|
97
|
+
<textarea
|
|
98
|
+
ref={textAreaRef}
|
|
99
|
+
className="bg-gray-100 rounded p-2 w-full resize-none"
|
|
100
|
+
value={updatedContent}
|
|
101
|
+
onChange={handleUpdate}
|
|
102
|
+
maxLength={254}
|
|
103
|
+
placeholder="Deja tus buenos deseos..."
|
|
104
|
+
/>
|
|
105
|
+
) : (
|
|
106
|
+
<p className="text-gray-500">{updatedContent}</p>
|
|
107
|
+
)}
|
|
108
|
+
</div>
|
|
109
|
+
<div className="flex justify-end items-center">
|
|
110
|
+
<button onClick={() => {}}>
|
|
111
|
+
<></>
|
|
112
|
+
</button>
|
|
113
|
+
</div>
|
|
114
|
+
</div>
|
|
115
|
+
{imageLink && (
|
|
116
|
+
<div
|
|
117
|
+
className={`w-[25%] flex items-center justify-center overflow-hidden text-white text-xl font-bold`}
|
|
118
|
+
>
|
|
119
|
+
<div
|
|
120
|
+
onClick={() => {
|
|
121
|
+
return window.open(imageLink, "_blank");
|
|
122
|
+
}}
|
|
123
|
+
>
|
|
124
|
+
<img
|
|
125
|
+
src={imageLink}
|
|
126
|
+
alt={"IMG_CHAT"}
|
|
127
|
+
className={`h-48 w-48 inline mr-1 pb-1`}
|
|
128
|
+
style={{
|
|
129
|
+
stroke: "currentColor",
|
|
130
|
+
strokeWidth: 2,
|
|
131
|
+
strokeLinecap: "round",
|
|
132
|
+
strokeLinejoin: "round",
|
|
133
|
+
fill: "none",
|
|
134
|
+
backgroundColor: "transparent",
|
|
135
|
+
}}
|
|
136
|
+
/>
|
|
137
|
+
</div>
|
|
138
|
+
</div>
|
|
139
|
+
)}
|
|
140
|
+
</div>
|
|
141
|
+
);
|
|
142
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { useIsOnline } from "@zauru-sdk/hooks";
|
|
2
|
+
|
|
3
|
+
const ConnectionState = () => {
|
|
4
|
+
const isOnline = useIsOnline();
|
|
5
|
+
|
|
6
|
+
// Definir estilos
|
|
7
|
+
const styles = {
|
|
8
|
+
container: {
|
|
9
|
+
padding: "10px",
|
|
10
|
+
borderRadius: "5px",
|
|
11
|
+
backgroundColor: isOnline ? "#d4edda" : "#f8d7da",
|
|
12
|
+
color: isOnline ? "#155724" : "#721c24",
|
|
13
|
+
fontWeight: "bold",
|
|
14
|
+
},
|
|
15
|
+
text: {
|
|
16
|
+
fontSize: "16px",
|
|
17
|
+
margin: 0,
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
// Renderizar el estado de conexión
|
|
22
|
+
return (
|
|
23
|
+
<div style={styles.container}>
|
|
24
|
+
<p style={styles.text}>{isOnline ? "ONLINE ✅🌐" : "OFFLINE ❌🌐"}</p>
|
|
25
|
+
</div>
|
|
26
|
+
);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export default ConnectionState;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./ConnectionState";
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { isNumeric } from "@zauru-sdk/common";
|
|
2
|
+
import { GenericDynamicTableColumn } from "@zauru-sdk/types";
|
|
3
|
+
|
|
4
|
+
//TABLA PARA LA IMPRESION:
|
|
5
|
+
export const BasicTableHTML = (props: {
|
|
6
|
+
data: { [key: string]: string }[];
|
|
7
|
+
headers: GenericDynamicTableColumn[];
|
|
8
|
+
footer: { [key: string]: string };
|
|
9
|
+
}) => {
|
|
10
|
+
const { data, footer, headers } = props;
|
|
11
|
+
return (
|
|
12
|
+
<table style={{ borderCollapse: "collapse", width: "100%" }}>
|
|
13
|
+
<thead>
|
|
14
|
+
<tr>
|
|
15
|
+
{headers?.map((titulo, index) => (
|
|
16
|
+
<th
|
|
17
|
+
key={index}
|
|
18
|
+
style={{
|
|
19
|
+
border: "1px solid black",
|
|
20
|
+
padding: "10px",
|
|
21
|
+
textAlign: "center",
|
|
22
|
+
whiteSpace: "normal",
|
|
23
|
+
}}
|
|
24
|
+
>
|
|
25
|
+
{titulo.label}
|
|
26
|
+
</th>
|
|
27
|
+
))}
|
|
28
|
+
</tr>
|
|
29
|
+
</thead>
|
|
30
|
+
<tbody>
|
|
31
|
+
{data?.map((fila, index) => (
|
|
32
|
+
<tr key={index}>
|
|
33
|
+
{headers?.map((titulo, index) => (
|
|
34
|
+
<td
|
|
35
|
+
key={index}
|
|
36
|
+
style={{
|
|
37
|
+
border: "1px solid black",
|
|
38
|
+
padding: "1px",
|
|
39
|
+
textAlign: "center",
|
|
40
|
+
whiteSpace: "normal",
|
|
41
|
+
fontSize: isNumeric((fila as any)[titulo.name])
|
|
42
|
+
? "2em"
|
|
43
|
+
: "1em",
|
|
44
|
+
}}
|
|
45
|
+
>
|
|
46
|
+
{(fila as any)[titulo.name]}
|
|
47
|
+
</td>
|
|
48
|
+
))}
|
|
49
|
+
</tr>
|
|
50
|
+
))}
|
|
51
|
+
</tbody>
|
|
52
|
+
<tfoot>
|
|
53
|
+
<tr>
|
|
54
|
+
{headers?.map((titulo, index) => (
|
|
55
|
+
<td
|
|
56
|
+
key={index}
|
|
57
|
+
style={{
|
|
58
|
+
padding: "10px",
|
|
59
|
+
textAlign: "center",
|
|
60
|
+
whiteSpace: "normal",
|
|
61
|
+
fontSize: isNumeric((footer as any)[titulo.name])
|
|
62
|
+
? "2em"
|
|
63
|
+
: "1em",
|
|
64
|
+
}}
|
|
65
|
+
>
|
|
66
|
+
{(footer as any)[titulo.name]}
|
|
67
|
+
</td>
|
|
68
|
+
))}
|
|
69
|
+
</tr>
|
|
70
|
+
</tfoot>
|
|
71
|
+
</table>
|
|
72
|
+
);
|
|
73
|
+
};
|