@zauru-sdk/components 1.0.54 → 1.0.60
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 +48 -0
- package/LICENCE.md +11 -11
- package/package.json +7 -7
- package/src/Alerts/ErrorBoundaryAlert/ErrorBoundaryAlert.tsx +66 -66
- package/src/Alerts/StaticAlert.tsx +121 -121
- package/src/Alerts/index.ts +2 -2
- package/src/BlockUI/BlockUI.tsx +50 -50
- package/src/BlockUI/index.tsx +1 -1
- package/src/Buttons/Button.tsx +90 -90
- package/src/Buttons/index.ts +1 -1
- package/src/Card/Card.tsx +24 -24
- package/src/Card/index.ts +1 -1
- package/src/Chat/ChatLayout.tsx +131 -131
- package/src/Chat/ChatMessageHistory.tsx +142 -142
- package/src/Chat/index.ts +2 -2
- package/src/ConnectionState/ConnectionState.tsx +27 -27
- package/src/ConnectionState/index.tsx +1 -1
- package/src/Containers/BodyContainer.tsx +14 -14
- package/src/Containers/ButtonSectionContainer.tsx +21 -21
- package/src/Containers/Container.tsx +39 -39
- package/src/Containers/DoubleContainer.tsx +48 -48
- package/src/Containers/MainContainer.tsx +17 -17
- package/src/Containers/OutletContainer.tsx +14 -14
- package/src/Containers/SubContainer.tsx +37 -37
- package/src/Containers/index.ts +7 -7
- package/src/DynamicTable/BasicPrintDynamicTable.tsx +73 -73
- package/src/DynamicTable/DynamicPrintTable.tsx +288 -288
- package/src/DynamicTable/DynamicTable.tsx +405 -405
- package/src/DynamicTable/GenericDynamicTable.tsx +456 -456
- package/src/DynamicTable/index.tsx +4 -4
- package/src/Footer/Footer.tsx +50 -50
- package/src/Footer/index.tsx +1 -1
- package/src/Form/Checkbox/index.tsx +96 -96
- package/src/Form/Checklist/index.tsx +35 -35
- package/src/Form/DatePicker/index.tsx +132 -132
- package/src/Form/DynamicBaculoForm/index.tsx +361 -361
- package/src/Form/FieldContainer/DoubleFieldContainer.tsx +35 -35
- package/src/Form/FieldContainer/QuadrupleFieldContainer.tsx +36 -36
- package/src/Form/FieldContainer/TripleFieldContainer.tsx +35 -35
- package/src/Form/FieldContainer/index.ts +3 -3
- package/src/Form/FileUpload/index.tsx +184 -184
- package/src/Form/FormButtons/index.tsx +78 -78
- package/src/Form/FormLayout/index.tsx +37 -37
- package/src/Form/SelectField/index.tsx +237 -237
- package/src/Form/TextArea/index.tsx +125 -125
- package/src/Form/TextField/index.tsx +194 -194
- package/src/Form/TimePicker/index.tsx +127 -127
- package/src/Form/YesNo/index.tsx +77 -77
- package/src/Form/index.ts +13 -13
- package/src/Labels/InfoLabel/index.tsx +21 -21
- package/src/Labels/index.tsx +1 -1
- package/src/Layouts/homeLayout/index.tsx +34 -34
- package/src/Layouts/index.ts +1 -1
- package/src/LineSeparator/LineSeparator.tsx +3 -3
- package/src/LineSeparator/index.tsx +1 -1
- package/src/Modal/Modal.tsx +104 -104
- package/src/Modal/index.tsx +1 -1
- package/src/NavBar/NavBar.tsx +223 -223
- package/src/NavBar/NavBar.types.ts +64 -64
- package/src/NavBar/NavBar.utils.ts +58 -58
- package/src/NavBar/index.tsx +5 -5
- package/src/ProgressBar/ProgressBar.tsx +25 -25
- package/src/ProgressBar/ProgressCircle.tsx +75 -75
- package/src/ProgressBar/index.tsx +2 -2
- package/src/Skeletons/LoadingInputSkeleton.tsx +12 -12
- package/src/Skeletons/index.ts +1 -1
- package/src/Tab/Tab.tsx +63 -63
- package/src/Tab/index.ts +1 -1
- package/src/Table/ZauruTable.tsx +265 -265
- package/src/Table/index.tsx +1 -1
- package/src/TaskList/TaskList.tsx +88 -88
- package/src/TaskList/index.ts +1 -1
- package/src/Titles/LabelArray.tsx +17 -17
- package/src/Titles/TableColumnTitle.tsx +9 -9
- package/src/Titles/TitleH1.tsx +10 -10
- package/src/Titles/TitleH2.tsx +10 -10
- package/src/Titles/TitleH3.tsx +10 -10
- package/src/Titles/index.ts +5 -5
- package/src/Tooltip/Tooltip.tsx +42 -42
- package/src/Tooltip/index.ts +1 -1
- package/src/WithTooltip/WithTooltip.tsx +21 -21
- package/src/WithTooltip/index.tsx +1 -1
- package/src/Wizards/StepWizard.tsx +88 -88
- package/src/Wizards/index.ts +1 -1
- package/src/Zendesk/Chat.tsx +83 -83
- package/src/Zendesk/index.ts +2 -2
- package/src/Zendesk/zendesk.config.ts +40 -40
- package/src/index.ts +24 -24
- package/src/postcss.config.mjs +5 -5
- package/src/tailwind.config.ts +10 -10
- package/src/tailwind.css +3 -3
- package/tsconfig.cjs.json +8 -8
- package/tsconfig.esm.json +11 -11
- package/tsconfig.json +17 -17
package/src/Buttons/Button.tsx
CHANGED
|
@@ -1,90 +1,90 @@
|
|
|
1
|
-
import type { ColorInterface } from "../NavBar/NavBar.types.js";
|
|
2
|
-
|
|
3
|
-
type Props = {
|
|
4
|
-
type?: "reset" | "button" | "submit" | undefined;
|
|
5
|
-
title?: string;
|
|
6
|
-
name?: string;
|
|
7
|
-
onClickSave?: (e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;
|
|
8
|
-
//Cargando...
|
|
9
|
-
loading?: boolean;
|
|
10
|
-
loadingText?: string;
|
|
11
|
-
selectedColor?: "indigo" | "green" | "red" | "yellow";
|
|
12
|
-
children?: React.ReactNode;
|
|
13
|
-
className?: string;
|
|
14
|
-
disabled?: boolean;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export const Button = (props: Props) => {
|
|
18
|
-
const {
|
|
19
|
-
type = "submit",
|
|
20
|
-
loading = false,
|
|
21
|
-
loadingText = "Guardando...",
|
|
22
|
-
title = "Guardar",
|
|
23
|
-
name = "save",
|
|
24
|
-
onClickSave,
|
|
25
|
-
selectedColor = "indigo",
|
|
26
|
-
children,
|
|
27
|
-
className = "",
|
|
28
|
-
disabled = false,
|
|
29
|
-
} = props;
|
|
30
|
-
|
|
31
|
-
const COLORS = {
|
|
32
|
-
green: {
|
|
33
|
-
bg900: "bg-green-900",
|
|
34
|
-
bg700: "bg-green-700",
|
|
35
|
-
bg600: "bg-green-600",
|
|
36
|
-
bg500: "bg-green-500",
|
|
37
|
-
ring600: "ring-green-600",
|
|
38
|
-
ring500: "ring-green-500",
|
|
39
|
-
},
|
|
40
|
-
indigo: {
|
|
41
|
-
bg900: "bg-indigo-900",
|
|
42
|
-
bg700: "bg-indigo-700",
|
|
43
|
-
bg600: "bg-indigo-600",
|
|
44
|
-
bg500: "bg-indigo-500",
|
|
45
|
-
ring600: "ring-indigo-600",
|
|
46
|
-
ring500: "ring-indigo-500",
|
|
47
|
-
},
|
|
48
|
-
red: {
|
|
49
|
-
bg900: "bg-red-900",
|
|
50
|
-
bg700: "bg-red-700",
|
|
51
|
-
bg600: "bg-red-600",
|
|
52
|
-
bg500: "bg-red-500",
|
|
53
|
-
ring600: "ring-red-600",
|
|
54
|
-
ring500: "ring-red-500",
|
|
55
|
-
},
|
|
56
|
-
yellow: {
|
|
57
|
-
bg900: "bg-yellow-900",
|
|
58
|
-
bg700: "bg-yellow-700",
|
|
59
|
-
bg600: "bg-yellow-600",
|
|
60
|
-
bg500: "bg-yellow-500",
|
|
61
|
-
ring600: "ring-yellow-600",
|
|
62
|
-
ring500: "ring-yellow-500",
|
|
63
|
-
},
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
const color: ColorInterface = COLORS[selectedColor];
|
|
67
|
-
|
|
68
|
-
const inside = children ?? title;
|
|
69
|
-
|
|
70
|
-
return (
|
|
71
|
-
<button
|
|
72
|
-
type={type}
|
|
73
|
-
name="action"
|
|
74
|
-
disabled={loading || disabled}
|
|
75
|
-
value={name}
|
|
76
|
-
onClick={onClickSave}
|
|
77
|
-
className={`ml-2 ${loading || disabled ? " bg-opacity-25 " : ""} ${
|
|
78
|
-
loading
|
|
79
|
-
? " cursor-progress"
|
|
80
|
-
: `${disabled ? "" : `hover:${color.bg700}`}`
|
|
81
|
-
} inline-flex justify-center rounded-md border border-transparent ${
|
|
82
|
-
color.bg600
|
|
83
|
-
} py-2 px-4 text-sm font-medium text-white shadow-sm focus:outline-none focus:ring-2 focus:${
|
|
84
|
-
color.ring500
|
|
85
|
-
} focus:ring-offset-2 ${className}`}
|
|
86
|
-
>
|
|
87
|
-
{loading ? loadingText : inside}
|
|
88
|
-
</button>
|
|
89
|
-
);
|
|
90
|
-
};
|
|
1
|
+
import type { ColorInterface } from "../NavBar/NavBar.types.js";
|
|
2
|
+
|
|
3
|
+
type Props = {
|
|
4
|
+
type?: "reset" | "button" | "submit" | undefined;
|
|
5
|
+
title?: string;
|
|
6
|
+
name?: string;
|
|
7
|
+
onClickSave?: (e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;
|
|
8
|
+
//Cargando...
|
|
9
|
+
loading?: boolean;
|
|
10
|
+
loadingText?: string;
|
|
11
|
+
selectedColor?: "indigo" | "green" | "red" | "yellow";
|
|
12
|
+
children?: React.ReactNode;
|
|
13
|
+
className?: string;
|
|
14
|
+
disabled?: boolean;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export const Button = (props: Props) => {
|
|
18
|
+
const {
|
|
19
|
+
type = "submit",
|
|
20
|
+
loading = false,
|
|
21
|
+
loadingText = "Guardando...",
|
|
22
|
+
title = "Guardar",
|
|
23
|
+
name = "save",
|
|
24
|
+
onClickSave,
|
|
25
|
+
selectedColor = "indigo",
|
|
26
|
+
children,
|
|
27
|
+
className = "",
|
|
28
|
+
disabled = false,
|
|
29
|
+
} = props;
|
|
30
|
+
|
|
31
|
+
const COLORS = {
|
|
32
|
+
green: {
|
|
33
|
+
bg900: "bg-green-900",
|
|
34
|
+
bg700: "bg-green-700",
|
|
35
|
+
bg600: "bg-green-600",
|
|
36
|
+
bg500: "bg-green-500",
|
|
37
|
+
ring600: "ring-green-600",
|
|
38
|
+
ring500: "ring-green-500",
|
|
39
|
+
},
|
|
40
|
+
indigo: {
|
|
41
|
+
bg900: "bg-indigo-900",
|
|
42
|
+
bg700: "bg-indigo-700",
|
|
43
|
+
bg600: "bg-indigo-600",
|
|
44
|
+
bg500: "bg-indigo-500",
|
|
45
|
+
ring600: "ring-indigo-600",
|
|
46
|
+
ring500: "ring-indigo-500",
|
|
47
|
+
},
|
|
48
|
+
red: {
|
|
49
|
+
bg900: "bg-red-900",
|
|
50
|
+
bg700: "bg-red-700",
|
|
51
|
+
bg600: "bg-red-600",
|
|
52
|
+
bg500: "bg-red-500",
|
|
53
|
+
ring600: "ring-red-600",
|
|
54
|
+
ring500: "ring-red-500",
|
|
55
|
+
},
|
|
56
|
+
yellow: {
|
|
57
|
+
bg900: "bg-yellow-900",
|
|
58
|
+
bg700: "bg-yellow-700",
|
|
59
|
+
bg600: "bg-yellow-600",
|
|
60
|
+
bg500: "bg-yellow-500",
|
|
61
|
+
ring600: "ring-yellow-600",
|
|
62
|
+
ring500: "ring-yellow-500",
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
const color: ColorInterface = COLORS[selectedColor];
|
|
67
|
+
|
|
68
|
+
const inside = children ?? title;
|
|
69
|
+
|
|
70
|
+
return (
|
|
71
|
+
<button
|
|
72
|
+
type={type}
|
|
73
|
+
name="action"
|
|
74
|
+
disabled={loading || disabled}
|
|
75
|
+
value={name}
|
|
76
|
+
onClick={onClickSave}
|
|
77
|
+
className={`ml-2 ${loading || disabled ? " bg-opacity-25 " : ""} ${
|
|
78
|
+
loading
|
|
79
|
+
? " cursor-progress"
|
|
80
|
+
: `${disabled ? "" : `hover:${color.bg700}`}`
|
|
81
|
+
} inline-flex justify-center rounded-md border border-transparent ${
|
|
82
|
+
color.bg600
|
|
83
|
+
} py-2 px-4 text-sm font-medium text-white shadow-sm focus:outline-none focus:ring-2 focus:${
|
|
84
|
+
color.ring500
|
|
85
|
+
} focus:ring-offset-2 ${className}`}
|
|
86
|
+
>
|
|
87
|
+
{loading ? loadingText : inside}
|
|
88
|
+
</button>
|
|
89
|
+
);
|
|
90
|
+
};
|
package/src/Buttons/index.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from "./Button.js";
|
|
1
|
+
export * from "./Button.js";
|
package/src/Card/Card.tsx
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
|
|
3
|
-
type Props = {
|
|
4
|
-
children: React.ReactNode;
|
|
5
|
-
title?: string;
|
|
6
|
-
className?: string;
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
export const Card = (props: Props) => {
|
|
10
|
-
const { children, title, className } = props;
|
|
11
|
-
|
|
12
|
-
return (
|
|
13
|
-
<div
|
|
14
|
-
className={`p-4 space-y-3 shadow sm:overflow-hidden sm:rounded-md ${className}`}
|
|
15
|
-
>
|
|
16
|
-
{title && (
|
|
17
|
-
<label className="inline text-lg font-medium text-gray-700">
|
|
18
|
-
{`${title.toUpperCase()}`}
|
|
19
|
-
</label>
|
|
20
|
-
)}
|
|
21
|
-
{children}
|
|
22
|
-
</div>
|
|
23
|
-
);
|
|
24
|
-
};
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
type Props = {
|
|
4
|
+
children: React.ReactNode;
|
|
5
|
+
title?: string;
|
|
6
|
+
className?: string;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export const Card = (props: Props) => {
|
|
10
|
+
const { children, title, className } = props;
|
|
11
|
+
|
|
12
|
+
return (
|
|
13
|
+
<div
|
|
14
|
+
className={`p-4 space-y-3 shadow sm:overflow-hidden sm:rounded-md ${className}`}
|
|
15
|
+
>
|
|
16
|
+
{title && (
|
|
17
|
+
<label className="inline text-lg font-medium text-gray-700">
|
|
18
|
+
{`${title.toUpperCase()}`}
|
|
19
|
+
</label>
|
|
20
|
+
)}
|
|
21
|
+
{children}
|
|
22
|
+
</div>
|
|
23
|
+
);
|
|
24
|
+
};
|
package/src/Card/index.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from "./Card.js";
|
|
1
|
+
export * from "./Card.js";
|
package/src/Chat/ChatLayout.tsx
CHANGED
|
@@ -1,131 +1,131 @@
|
|
|
1
|
-
import React, { useRef, useState } from "react";
|
|
2
|
-
import { TextField } from "../Form/TextField/index.js";
|
|
3
|
-
import { Form } from "@remix-run/react";
|
|
4
|
-
import { FormDocumentType } from "@zauru-sdk/types";
|
|
5
|
-
import { LoadingInputSkeleton } from "../Skeletons/LoadingInputSkeleton.js";
|
|
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
|
-
export 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
|
-
};
|
|
1
|
+
import React, { useRef, useState } from "react";
|
|
2
|
+
import { TextField } from "../Form/TextField/index.js";
|
|
3
|
+
import { Form } from "@remix-run/react";
|
|
4
|
+
import { FormDocumentType } from "@zauru-sdk/types";
|
|
5
|
+
import { LoadingInputSkeleton } from "../Skeletons/LoadingInputSkeleton.js";
|
|
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
|
+
export 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
|
+
};
|