@zauru-sdk/components 1.0.11 → 1.0.12

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.
Files changed (164) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/Alerts/index.d.ts +3 -0
  3. package/dist/Alerts/index.js +3 -0
  4. package/dist/BlockUI/BlockUI.d.ts +8 -0
  5. package/dist/BlockUI/BlockUI.js +8 -0
  6. package/dist/BlockUI/index.d.ts +1 -0
  7. package/dist/BlockUI/index.js +1 -0
  8. package/dist/Buttons/Button.d.ts +15 -0
  9. package/dist/Buttons/Button.js +43 -0
  10. package/dist/Buttons/index.d.ts +1 -0
  11. package/dist/Buttons/index.js +1 -0
  12. package/dist/Card/Card.d.ts +8 -0
  13. package/dist/Card/Card.js +5 -0
  14. package/dist/Card/index.d.ts +1 -0
  15. package/dist/Card/index.js +1 -0
  16. package/dist/Chat/ChatLayout.d.ts +17 -0
  17. package/dist/Chat/ChatLayout.js +27 -0
  18. package/dist/Chat/ChatMessageHistory.d.ts +12 -0
  19. package/dist/Chat/ChatMessageHistory.js +53 -0
  20. package/dist/Chat/index.d.ts +2 -0
  21. package/dist/Chat/index.js +2 -0
  22. package/dist/Containers/BodyContainer.d.ts +6 -0
  23. package/dist/Containers/BodyContainer.js +5 -0
  24. package/dist/Containers/ButtonSectionContainer.d.ts +8 -0
  25. package/dist/Containers/ButtonSectionContainer.js +5 -0
  26. package/dist/Containers/Container.d.ts +10 -0
  27. package/dist/Containers/Container.js +6 -0
  28. package/dist/Containers/DoubleContainer.d.ts +9 -0
  29. package/dist/Containers/DoubleContainer.js +14 -0
  30. package/dist/Containers/MainContainer.d.ts +6 -0
  31. package/dist/Containers/MainContainer.js +5 -0
  32. package/dist/Containers/OutletContainer.d.ts +6 -0
  33. package/dist/Containers/OutletContainer.js +5 -0
  34. package/dist/Containers/SubContainer.d.ts +10 -0
  35. package/dist/Containers/SubContainer.js +6 -0
  36. package/dist/Containers/index.d.ts +7 -0
  37. package/dist/Containers/index.js +7 -0
  38. package/dist/Footer/Footer.d.ts +7 -0
  39. package/dist/Footer/Footer.js +25 -0
  40. package/dist/Footer/index.d.ts +1 -0
  41. package/dist/Footer/index.js +1 -0
  42. package/dist/Labels/InfoLabel/index.d.ts +7 -0
  43. package/dist/Labels/InfoLabel/index.js +5 -0
  44. package/dist/Labels/index.d.ts +1 -0
  45. package/dist/Labels/index.js +1 -0
  46. package/dist/Layouts/homeLayout/index.d.ts +6 -0
  47. package/dist/Layouts/homeLayout/index.js +10 -0
  48. package/dist/Layouts/index.d.ts +1 -0
  49. package/dist/Layouts/index.js +1 -0
  50. package/dist/LineSeparator/LineSeparator.d.ts +1 -0
  51. package/dist/LineSeparator/LineSeparator.js +4 -0
  52. package/dist/LineSeparator/index.d.ts +1 -0
  53. package/dist/LineSeparator/index.js +1 -0
  54. package/dist/Modal/Modal.d.ts +10 -0
  55. package/dist/Modal/Modal.js +32 -0
  56. package/dist/Modal/index.d.ts +1 -0
  57. package/dist/Modal/index.js +1 -0
  58. package/dist/NavBar/index.d.ts +3 -0
  59. package/dist/NavBar/index.js +3 -0
  60. package/dist/ProgressBar/ProgressBar.d.ts +6 -0
  61. package/dist/ProgressBar/ProgressBar.js +5 -0
  62. package/dist/ProgressBar/ProgressCircle.d.ts +6 -0
  63. package/dist/ProgressBar/ProgressCircle.js +22 -0
  64. package/dist/ProgressBar/index.d.ts +2 -0
  65. package/dist/ProgressBar/index.js +2 -0
  66. package/dist/Skeletons/LoadingInputSkeleton.d.ts +1 -0
  67. package/dist/Skeletons/LoadingInputSkeleton.js +8 -0
  68. package/dist/Skeletons/index.d.ts +1 -0
  69. package/dist/Skeletons/index.js +1 -0
  70. package/dist/Tab/Tab.d.ts +9 -0
  71. package/dist/Tab/Tab.js +19 -0
  72. package/dist/Tab/index.d.ts +1 -0
  73. package/dist/Tab/index.js +1 -0
  74. package/dist/Table/ZauruTable.d.ts +25 -0
  75. package/dist/Table/ZauruTable.js +148 -0
  76. package/dist/Table/index.d.ts +1 -0
  77. package/dist/Table/index.js +1 -0
  78. package/dist/TaskList/TaskList.d.ts +14 -0
  79. package/dist/TaskList/TaskList.js +35 -0
  80. package/dist/TaskList/index.d.ts +1 -0
  81. package/dist/TaskList/index.js +1 -0
  82. package/dist/Titles/LabelArray.d.ts +4 -0
  83. package/dist/Titles/LabelArray.js +7 -0
  84. package/dist/Titles/TableColumnTitle.d.ts +4 -0
  85. package/dist/Titles/TableColumnTitle.js +5 -0
  86. package/dist/Titles/TitleH1.d.ts +1 -0
  87. package/dist/Titles/TitleH1.js +5 -0
  88. package/dist/Titles/TitleH2.d.ts +1 -0
  89. package/dist/Titles/TitleH2.js +5 -0
  90. package/dist/Titles/TitleH3.d.ts +1 -0
  91. package/dist/Titles/TitleH3.js +5 -0
  92. package/dist/Titles/index.d.ts +5 -0
  93. package/dist/Titles/index.js +5 -0
  94. package/dist/Tooltip/Tooltip.d.ts +7 -0
  95. package/dist/Tooltip/Tooltip.js +14 -0
  96. package/dist/Tooltip/index.d.ts +1 -0
  97. package/dist/Tooltip/index.js +1 -0
  98. package/dist/WithTooltip/WithTooltip.d.ts +7 -0
  99. package/dist/WithTooltip/WithTooltip.js +5 -0
  100. package/dist/WithTooltip/index.d.ts +1 -0
  101. package/dist/WithTooltip/index.js +1 -0
  102. package/dist/Wizards/StepWizard.d.ts +14 -0
  103. package/dist/Wizards/StepWizard.js +14 -0
  104. package/dist/Wizards/index.d.ts +1 -0
  105. package/dist/Wizards/index.js +1 -0
  106. package/dist/Zendesk/Chat.d.ts +14 -0
  107. package/dist/Zendesk/Chat.js +63 -0
  108. package/dist/Zendesk/index.d.ts +2 -0
  109. package/dist/Zendesk/index.js +2 -0
  110. package/dist/Zendesk/zendesk.config.d.ts +9 -0
  111. package/dist/Zendesk/zendesk.config.js +24 -0
  112. package/dist/index.d.ts +19 -0
  113. package/dist/index.js +21 -1
  114. package/package.json +4 -2
  115. package/src/Alerts/index.ts +3 -0
  116. package/src/BlockUI/BlockUI.tsx +50 -0
  117. package/src/BlockUI/index.tsx +1 -0
  118. package/src/Buttons/Button.tsx +90 -0
  119. package/src/Buttons/index.ts +1 -0
  120. package/src/Card/Card.tsx +24 -0
  121. package/src/Card/index.ts +1 -0
  122. package/src/Containers/BodyContainer.tsx +14 -0
  123. package/src/Containers/ButtonSectionContainer.tsx +21 -0
  124. package/src/Containers/Container.tsx +39 -0
  125. package/src/Containers/DoubleContainer.tsx +48 -0
  126. package/src/Containers/MainContainer.tsx +17 -0
  127. package/src/Containers/OutletContainer.tsx +14 -0
  128. package/src/Containers/SubContainer.tsx +37 -0
  129. package/src/Containers/index.ts +7 -0
  130. package/src/Footer/Footer.tsx +61 -0
  131. package/src/Footer/index.tsx +1 -0
  132. package/src/Labels/InfoLabel/index.tsx +21 -0
  133. package/src/Labels/index.tsx +1 -0
  134. package/src/Layouts/homeLayout/index.tsx +34 -0
  135. package/src/Layouts/index.ts +1 -0
  136. package/src/LineSeparator/LineSeparator.tsx +3 -0
  137. package/src/LineSeparator/index.tsx +1 -0
  138. package/src/Modal/Modal.tsx +104 -0
  139. package/src/Modal/index.tsx +1 -0
  140. package/src/NavBar/index.tsx +5 -0
  141. package/src/ProgressBar/ProgressBar.tsx +25 -0
  142. package/src/ProgressBar/ProgressCircle.tsx +75 -0
  143. package/src/ProgressBar/index.tsx +2 -0
  144. package/src/Skeletons/LoadingInputSkeleton.tsx +12 -0
  145. package/src/Skeletons/index.ts +1 -0
  146. package/src/Tab/Tab.tsx +63 -0
  147. package/src/Tab/index.ts +1 -0
  148. package/src/Table/ZauruTable.tsx +263 -0
  149. package/src/Table/index.tsx +1 -0
  150. package/src/TaskList/TaskList.tsx +88 -0
  151. package/src/TaskList/index.ts +1 -0
  152. package/src/Titles/LabelArray.tsx +17 -0
  153. package/src/Titles/TableColumnTitle.tsx +9 -0
  154. package/src/Titles/TitleH1.tsx +11 -0
  155. package/src/Titles/TitleH2.tsx +10 -0
  156. package/src/Titles/TitleH3.tsx +10 -0
  157. package/src/Titles/index.ts +5 -0
  158. package/src/Tooltip/Tooltip.tsx +42 -0
  159. package/src/Tooltip/index.ts +1 -0
  160. package/src/WithTooltip/WithTooltip.tsx +21 -0
  161. package/src/WithTooltip/index.tsx +1 -0
  162. package/src/Wizards/StepWizard.tsx +88 -0
  163. package/src/Wizards/index.ts +1 -0
  164. package/src/index.ts +21 -0
@@ -0,0 +1,104 @@
1
+ import React from "react";
2
+ import { createRoot } from "react-dom/client";
3
+
4
+ export type ModalOption = "OK" | "CANCEL" | null;
5
+
6
+ type ModalParams = {
7
+ title: string;
8
+ description: React.ReactNode;
9
+ okButtonText?: string;
10
+ showOptions?: boolean;
11
+ };
12
+
13
+ export const createModal = ({
14
+ title,
15
+ description,
16
+ okButtonText,
17
+ showOptions = true,
18
+ }: ModalParams): Promise<ModalOption> => {
19
+ return new Promise((resolve) => {
20
+ const handleClose = () => {
21
+ resolve(null);
22
+ removeModal();
23
+ };
24
+
25
+ const handleOk = () => {
26
+ resolve("OK");
27
+ removeModal();
28
+ };
29
+
30
+ const handleCancel = () => {
31
+ resolve("CANCEL");
32
+ removeModal();
33
+ };
34
+
35
+ const removeModal = () => {
36
+ document.body.removeChild(modalWrapper);
37
+ document.body.removeChild(modalOverlay);
38
+ };
39
+
40
+ const modalWrapper = document.createElement("div");
41
+ modalWrapper.classList.add(
42
+ "justify-center",
43
+ "items-center",
44
+ "flex",
45
+ "overflow-x-hidden",
46
+ "overflow-y-auto",
47
+ "fixed",
48
+ "inset-0",
49
+ "z-50",
50
+ "outline-none",
51
+ "focus:outline-none"
52
+ );
53
+
54
+ // Crear capa de fondo detrás del modal
55
+ const modalOverlay = document.createElement("div");
56
+ modalOverlay.classList.add(
57
+ "fixed",
58
+ "inset-0",
59
+ "bg-black",
60
+ "opacity-50",
61
+ "z-40"
62
+ );
63
+
64
+ document.body.appendChild(modalOverlay);
65
+ document.body.appendChild(modalWrapper);
66
+
67
+ const ModalContent = () => (
68
+ <div className="relative w-auto my-6 mx-auto max-w-3xl">
69
+ <div className="border-0 rounded-lg shadow-lg relative flex flex-col w-full bg-white outline-none focus:outline-none">
70
+ <div className="flex items-start justify-between p-5 border-b border-solid border-slate-200 rounded-t">
71
+ <h3 className="text-3xl font-semibold">{title}</h3>
72
+ <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">
73
+ <span className="close-button" onClick={handleClose}>
74
+ &times;
75
+ </span>
76
+ </button>
77
+ </div>
78
+ <div className="relative p-6 flex-auto">{description}</div>
79
+ {showOptions && (
80
+ <div className="flex items-center justify-end p-6 border-t border-solid border-slate-200 rounded-b">
81
+ <button
82
+ 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"
83
+ type="button"
84
+ onClick={handleCancel}
85
+ >
86
+ Cancelar
87
+ </button>
88
+ <button
89
+ 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"
90
+ type="button"
91
+ onClick={handleOk}
92
+ >
93
+ {okButtonText ?? "Aceptar"}
94
+ </button>
95
+ </div>
96
+ )}
97
+ </div>
98
+ </div>
99
+ );
100
+
101
+ const root = createRoot(modalWrapper);
102
+ root.render(<ModalContent />);
103
+ });
104
+ };
@@ -0,0 +1 @@
1
+ export * from "./Modal";
@@ -0,0 +1,5 @@
1
+ export * from "./NavBar";
2
+
3
+ export * from "./NavBar.types";
4
+
5
+ export * from "./NavBar.utils";
@@ -0,0 +1,25 @@
1
+ import React from "react";
2
+
3
+ type Props = {
4
+ title?: string;
5
+ percent?: string;
6
+ };
7
+
8
+ export const ProgressBar = (props: Props) => {
9
+ const { title, percent } = props;
10
+ return (
11
+ <>
12
+ {percent && (
13
+ <>
14
+ {title && <div className="mb-1 text-lg font-medium">{title}</div>}
15
+ <div className="w-full h-6 bg-gray-200 rounded-full">
16
+ <div
17
+ className="h-6 bg-blue-600 rounded-full"
18
+ style={{ width: `${percent}%` }}
19
+ ></div>
20
+ </div>
21
+ </>
22
+ )}
23
+ </>
24
+ );
25
+ };
@@ -0,0 +1,75 @@
1
+ import React, { useEffect, useState } from "react";
2
+
3
+ export const ProgressCircle = ({
4
+ total,
5
+ completed,
6
+ description,
7
+ title,
8
+ }: {
9
+ total: number;
10
+ completed: number;
11
+ description: string;
12
+ title?: string;
13
+ }) => {
14
+ const [percentage, setPercentage] = useState(0);
15
+ const strokeDasharray = 2 * Math.PI * 42; // radio del circulo
16
+ const progressColor = `rgba(${255 - 2.55 * percentage}, ${
17
+ 2.55 * percentage
18
+ }, 0)`;
19
+
20
+ useEffect(() => {
21
+ if (total > 0) {
22
+ setPercentage((completed / total) * 100);
23
+ } else {
24
+ setPercentage(100);
25
+ }
26
+ }, [total, completed]);
27
+
28
+ return (
29
+ <div className="flex flex-col items-center justify-center">
30
+ {title && (
31
+ <h2 className="mb-4 text-xl text-center text-gray-700">{title}</h2>
32
+ )}
33
+ <svg width="100" height="100" className="relative">
34
+ <circle
35
+ r="42"
36
+ cx="50"
37
+ cy="50"
38
+ fill="transparent"
39
+ stroke="#eee"
40
+ strokeWidth="8"
41
+ />
42
+ <circle
43
+ r="42"
44
+ cx="50"
45
+ cy="50"
46
+ fill="transparent"
47
+ stroke={progressColor}
48
+ strokeWidth="8"
49
+ strokeDasharray={strokeDasharray}
50
+ strokeDashoffset={
51
+ strokeDasharray - strokeDasharray * (percentage / 100)
52
+ }
53
+ strokeLinecap="round"
54
+ style={{
55
+ transform: "rotate(-90deg)",
56
+ transformOrigin: "50% 50%",
57
+ }}
58
+ />
59
+ <text
60
+ x="50"
61
+ y="55"
62
+ textAnchor="middle"
63
+ fill={progressColor}
64
+ style={{
65
+ fontSize: "16px",
66
+ fontWeight: "bold",
67
+ }}
68
+ >
69
+ {`${Math.round(percentage)}%`}
70
+ </text>
71
+ </svg>
72
+ <p className="mt-2 text-center text-gray-500">{description}</p>
73
+ </div>
74
+ );
75
+ };
@@ -0,0 +1,2 @@
1
+ export * from "./ProgressBar";
2
+ export * from "./ProgressCircle";
@@ -0,0 +1,12 @@
1
+ export const LoadingInputSkeleton = () => {
2
+ return (
3
+ <div
4
+ className="w-full h-full bg-gray-300 animate-pulse rounded"
5
+ style={{
6
+ maxWidth: "100%",
7
+ height: "40px",
8
+ boxShadow: "0px 0px 0px 1px rgba(0, 0, 0, 0.1)",
9
+ }}
10
+ />
11
+ );
12
+ };
@@ -0,0 +1 @@
1
+ export * from "./LoadingInputSkeleton";
@@ -0,0 +1,63 @@
1
+ import { redirect } from "@remix-run/node";
2
+ import { Outlet } from "@remix-run/react";
3
+ import React from "react";
4
+
5
+ export type TabItem = { title: string; link: string };
6
+
7
+ type Props = {
8
+ items: Array<TabItem>;
9
+ };
10
+
11
+ //<reference> https://www.creative-tim.com/learning-lab/tailwind-starter-kit/documentation/react/tabs/text
12
+ export const Tabs = (props: Props) => {
13
+ const { items } = props;
14
+ const [openTab, setOpenTab] = React.useState(1);
15
+ return (
16
+ <>
17
+ <div className="flex flex-wrap">
18
+ <div className="w-full">
19
+ <ul
20
+ className="flex mb-0 list-none flex-wrap pt-3 pb-4 flex-row"
21
+ role="tablist"
22
+ >
23
+ {items?.map((item: TabItem, index: number) => {
24
+ return (
25
+ <li
26
+ key={index}
27
+ className="mb-px mr-2 last:mr-0 flex-auto text-center"
28
+ >
29
+ <a
30
+ key={index}
31
+ className={
32
+ "text-xs font-bold uppercase px-5 py-3 shadow-lg rounded block leading-normal " +
33
+ (openTab === index
34
+ ? "text-white bg-red-600"
35
+ : "text-red-600 bg-white")
36
+ }
37
+ onClick={(e) => {
38
+ e.preventDefault();
39
+ setOpenTab(index);
40
+ redirect(item.link);
41
+ }}
42
+ data-toggle="tab"
43
+ href={item.link}
44
+ role="tablist"
45
+ >
46
+ {item.title}
47
+ </a>
48
+ </li>
49
+ );
50
+ })}
51
+ </ul>
52
+ <div className="relative flex flex-col min-w-0 break-words bg-white w-full mb-6 shadow-lg rounded">
53
+ <div className="px-4 py-5 flex-auto">
54
+ <div className="tab-content tab-space">
55
+ <Outlet />
56
+ </div>
57
+ </div>
58
+ </div>
59
+ </div>
60
+ </div>
61
+ </>
62
+ );
63
+ };
@@ -0,0 +1 @@
1
+ export * from "./Tab";
@@ -0,0 +1,263 @@
1
+ import { useSearchParams } from "@remix-run/react";
2
+ import { useEffect, useState } from "react";
3
+ import type {
4
+ PaginationOptions,
5
+ TableProps,
6
+ TableStyles,
7
+ } from "react-data-table-component";
8
+ import DataTable, { createTheme } from "react-data-table-component";
9
+ import { SearchSVG } from "../Icons/Icons";
10
+ import { ExpandableRowsComponent } from "react-data-table-component/dist/DataTable/types";
11
+
12
+ const customStyles: TableStyles = {
13
+ headCells: {
14
+ style: {
15
+ color: "#202124",
16
+ fontSize: "14px",
17
+ justifyContent: "left", // Alinea el texto a la izquierda
18
+ whiteSpace: "normal", // Permite el ajuste de texto
19
+ wordBreak: "break-word", // Asegura que las palabras se rompan correctamente para evitar desbordamientos
20
+ maxWidth: "150px", // Establece un ancho máximo para las celdas del encabezado
21
+ },
22
+ },
23
+ rows: {
24
+ highlightOnHoverStyle: {
25
+ backgroundColor: "rgb(230, 244, 244)",
26
+ borderBottomColor: "#FFFFFF",
27
+ borderRadius: "25px",
28
+ outline: "1px solid #FFFFFF",
29
+ },
30
+ },
31
+ pagination: {
32
+ style: {
33
+ border: "none",
34
+ },
35
+ },
36
+ };
37
+
38
+ createTheme("solarized", {
39
+ text: {
40
+ primary: "#002b36",
41
+ secondary: "#002b36",
42
+ },
43
+ background: {
44
+ default: "#f9f9f9",
45
+ },
46
+ context: {
47
+ background: "#cb4b16",
48
+ text: "#555555",
49
+ },
50
+ divider: {
51
+ default: "#e2e4ff",
52
+ },
53
+ action: {
54
+ button: "rgba(0,0,0,.54)",
55
+ hover: "rgba(0,0,0,.08)",
56
+ disabled: "rgba(0,0,0,.12)",
57
+ },
58
+ headRow: {
59
+ background: "black",
60
+ },
61
+ });
62
+
63
+ createTheme("subTable", {
64
+ text: {
65
+ primary: "#002b36",
66
+ secondary: "#002b36",
67
+ },
68
+ background: {
69
+ default: "#e9e9e9",
70
+ },
71
+ context: {
72
+ background: "#cb4b16",
73
+ text: "#555555",
74
+ },
75
+ divider: {
76
+ default: "#e2e4ff",
77
+ },
78
+ action: {
79
+ button: "rgba(0,0,0,.54)",
80
+ hover: "rgba(0,0,0,.08)",
81
+ disabled: "rgba(0,0,0,.12)",
82
+ },
83
+ headRow: {
84
+ background: "black",
85
+ },
86
+ });
87
+
88
+ type Props = TableProps<any> & {
89
+ columns: any;
90
+ conditionalRowStyles?: any;
91
+ data: any[];
92
+ loading?: boolean;
93
+ pagination?: {
94
+ totalRows: number;
95
+ rowsPerPageOptions: number[];
96
+ };
97
+ whitOutPagination?: boolean;
98
+ offlineSearch?: string[];
99
+ search?: {
100
+ placeholderSearch?: string;
101
+ };
102
+ expandable?: {
103
+ expandableRowExpanded?: (row: any) => boolean;
104
+ expandableRowsComponent?: ExpandableRowsComponent<any>;
105
+ };
106
+ theme?: "solarized" | "subTable";
107
+ className?: string;
108
+ };
109
+
110
+ //Documentación de la tabla https://react-data-table-component.netlify.app/?path=/docs/getting-started-intro--docs
111
+ export const ZauruTable = (props: Props) => {
112
+ const {
113
+ columns,
114
+ conditionalRowStyles,
115
+ data,
116
+ loading = false,
117
+ pagination,
118
+ search,
119
+ expandable,
120
+ theme,
121
+ className,
122
+ offlineSearch = [],
123
+ whitOutPagination = false,
124
+ ...others
125
+ } = props;
126
+
127
+ const [, setSearchParams] = useSearchParams({
128
+ page: "1",
129
+ perPage: "10",
130
+ search: "",
131
+ });
132
+ const [filteredData, setFilteredData] = useState(data);
133
+
134
+ const [showTable, setShowTable] = useState<boolean>(false);
135
+
136
+ useEffect(() => {
137
+ setShowTable(true);
138
+ }, []);
139
+
140
+ useEffect(() => {
141
+ setFilteredData(data);
142
+ }, [data]);
143
+
144
+ const subHeaderComponentMemo = (
145
+ <>
146
+ <input
147
+ name="search"
148
+ type="text"
149
+ placeholder={search?.placeholderSearch ?? "Filtrar"}
150
+ aria-label="Search Input"
151
+ className="bg-gray-50 border border-gray-300 text-gray-900 rounded-lg px-2"
152
+ onChange={(event) => {
153
+ const searchTerm = event.target.value;
154
+ if (offlineSearch.length > 0) {
155
+ filterData(searchTerm);
156
+ }
157
+ }}
158
+ onBlur={(event) => {
159
+ const searchTerm = event.target.value;
160
+ if (offlineSearch.length <= 0 && search) {
161
+ setSearchParams((prevState: URLSearchParams) => ({
162
+ ...Object.fromEntries(prevState),
163
+ search: searchTerm,
164
+ }));
165
+ }
166
+ }}
167
+ />
168
+ <button type="button" name="search" className="px-2 font-bold">
169
+ <SearchSVG />
170
+ </button>
171
+ </>
172
+ );
173
+
174
+ const filterData = (searchTerm: string) => {
175
+ if (!searchTerm || !offlineSearch || offlineSearch.length === 0) {
176
+ setFilteredData(data);
177
+ return;
178
+ }
179
+
180
+ const filtered = data.filter((item) =>
181
+ offlineSearch.some(
182
+ (field) =>
183
+ item[field] &&
184
+ item[field]
185
+ .toString()
186
+ .toLowerCase()
187
+ .includes(searchTerm.toLowerCase())
188
+ )
189
+ );
190
+
191
+ setFilteredData(filtered);
192
+ };
193
+
194
+ const handlePageChange = (page: number) => {
195
+ //hacer el fetch de más datos
196
+ setSearchParams((prevState: URLSearchParams) => ({
197
+ ...Object.fromEntries(prevState),
198
+ page: page.toString(),
199
+ }));
200
+ };
201
+
202
+ const handlePerRowsChange = async (newPerPage: number, page: number) => {
203
+ //hacer el fetch de más datos
204
+ setSearchParams((prevState: URLSearchParams) => ({
205
+ ...Object.fromEntries(prevState),
206
+ perPage: newPerPage.toString(),
207
+ }));
208
+ };
209
+
210
+ if (!showTable) {
211
+ return <>Loading...</>;
212
+ }
213
+
214
+ //Textos en español de la tabla
215
+ const paginationComponentOptions = {
216
+ rowsPerPageText: "Filas por página",
217
+ rangeSeparatorText: "de",
218
+ selectAllRowsItem: true,
219
+ selectAllRowsItemText: "Todos",
220
+ } as PaginationOptions;
221
+
222
+ const loadSubHeader = !!(search || offlineSearch.length > 0);
223
+ const subHeaderComponent = loadSubHeader ? subHeaderComponentMemo : undefined;
224
+
225
+ return (
226
+ <DataTable
227
+ className={className}
228
+ subHeaderWrap
229
+ theme={theme ?? "solarized"}
230
+ columns={columns}
231
+ conditionalRowStyles={conditionalRowStyles}
232
+ data={filteredData}
233
+ customStyles={customStyles}
234
+ progressPending={loading}
235
+ highlightOnHover
236
+ pointerOnHover
237
+ dense
238
+ striped
239
+ pagination={!whitOutPagination}
240
+ persistTableHead
241
+ responsive
242
+ noHeader
243
+ expandableRows={!!expandable}
244
+ expandableRowExpanded={
245
+ expandable ? expandable.expandableRowExpanded : undefined
246
+ }
247
+ expandableRowsComponent={
248
+ expandable ? expandable.expandableRowsComponent : undefined
249
+ }
250
+ subHeader={loadSubHeader}
251
+ subHeaderComponent={subHeaderComponent}
252
+ paginationServer={!!pagination}
253
+ paginationTotalRows={pagination ? pagination.totalRows : undefined}
254
+ onChangeRowsPerPage={pagination ? handlePerRowsChange : undefined}
255
+ onChangePage={pagination ? handlePageChange : undefined}
256
+ paginationComponentOptions={paginationComponentOptions}
257
+ paginationRowsPerPageOptions={
258
+ pagination?.rowsPerPageOptions ? pagination.rowsPerPageOptions : [10]
259
+ }
260
+ {...others}
261
+ />
262
+ );
263
+ };
@@ -0,0 +1 @@
1
+ export * from "./ZauruTable";
@@ -0,0 +1,88 @@
1
+ import React, { useState } from "react";
2
+
3
+ export type TaskType = {
4
+ title: string;
5
+ description?: string;
6
+ status: "waiting" | "processing" | "done" | "error";
7
+ };
8
+
9
+ type TaskProps = {
10
+ task: TaskType;
11
+ };
12
+
13
+ export const Task = ({ task }: TaskProps) => {
14
+ const [isDescriptionOpen, setIsDescriptionOpen] = useState(false);
15
+ let statusIcon;
16
+ let taskStyle = {};
17
+ let bgColor;
18
+
19
+ switch (task.status) {
20
+ case "waiting":
21
+ statusIcon = "🕗"; // Icono de reloj (como un ejemplo, puedes reemplazarlo con un ícono o SVG real)
22
+ taskStyle = { opacity: 0.5 }; // estilo disabled
23
+ bgColor = "bg-gray-200"; // Color de fondo gris
24
+ break;
25
+ case "processing":
26
+ statusIcon = "⏳"; // Icono de reloj de arena
27
+ taskStyle = { fontWeight: "bold" }; // estilo negrita
28
+ bgColor = "bg-blue-200"; // Color de fondo azul
29
+ break;
30
+ case "done":
31
+ statusIcon = "✅"; // Icono de check
32
+ bgColor = "bg-green-200"; // Color de fondo verde
33
+ break;
34
+ case "error":
35
+ statusIcon = "❌"; // Icono de cruz
36
+ taskStyle = { color: "red" }; // estilo color rojo
37
+ bgColor = "bg-red-200"; // Color de fondo rojo
38
+ break;
39
+ }
40
+
41
+ return (
42
+ <div
43
+ style={taskStyle}
44
+ className={`${bgColor} rounded-lg p-3 mb-3 ${
45
+ task.description ? "cursor-pointer" : ""
46
+ }`}
47
+ onClick={() =>
48
+ task.description && setIsDescriptionOpen(!isDescriptionOpen)
49
+ }
50
+ >
51
+ <div className="flex justify-between">
52
+ <div>
53
+ {statusIcon} {task.title}{" "}
54
+ {`${task.status === "processing" ? "..." : ""}`}
55
+ </div>
56
+ {task.description && <div>▼</div>}
57
+ </div>
58
+ {task.description && isDescriptionOpen && (
59
+ <div className="mt-2">{task.description}</div>
60
+ )}
61
+ </div>
62
+ );
63
+ };
64
+
65
+ type TaskModalProps = {
66
+ tasks: TaskType[];
67
+ };
68
+
69
+ export const TaskList = ({ tasks }: TaskModalProps) => {
70
+ const completedTasks = tasks.filter(
71
+ (task) => task.status === "done" || task.status === "error"
72
+ ).length;
73
+ const progressPercentage = (completedTasks / tasks.length) * 100;
74
+
75
+ return (
76
+ <div>
77
+ {tasks.map((task, index) => (
78
+ <Task key={index} task={task} />
79
+ ))}
80
+ <div className="h-2 bg-gray-200 rounded-lg mt-3">
81
+ <div
82
+ className="bg-green-500 h-full rounded-lg"
83
+ style={{ width: `${progressPercentage}%`, transition: "width 0.5s" }}
84
+ ></div>
85
+ </div>
86
+ </div>
87
+ );
88
+ };
@@ -0,0 +1 @@
1
+ export * from "./TaskList";
@@ -0,0 +1,17 @@
1
+ import { SelectFieldOption } from "@zauru-sdk/types";
2
+
3
+ //Component to show all information in an array
4
+ export const LabelArray = ({ info }: { info: SelectFieldOption[] }) => {
5
+ return (
6
+ <div className="divide-y divide-gray-100">
7
+ {info?.map((x: any) => {
8
+ return (
9
+ <div key={x?.label} className="my-1 pt-2">
10
+ <p className="inline font-bold text-lg">{x?.label}: </p>
11
+ <p className="inline text-lg">{x?.value}</p>
12
+ </div>
13
+ );
14
+ })}
15
+ </div>
16
+ );
17
+ };
@@ -0,0 +1,9 @@
1
+ export type tableColumnTitleProps = {
2
+ textContent: String;
3
+ };
4
+ //column title for datatables
5
+ export const TableColumnTitle = ({ textContent }: tableColumnTitleProps) => {
6
+ return (
7
+ <p className="font-bold text-sm line-clamp-3 text-center">{textContent}</p>
8
+ );
9
+ };