contentoh-components-library 21.3.12 → 21.3.13

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 (117) hide show
  1. package/.env.development +0 -5
  2. package/dist/assets/images/generalButton/closeIcon.svg +2 -2
  3. package/dist/components/atoms/ProgressBar/index.js +6 -36
  4. package/dist/components/atoms/ProgressBar/styles.js +3 -11
  5. package/dist/components/molecules/CustomSelect/CustomSelect.stories.js +22 -21
  6. package/dist/components/molecules/CustomSelect/SelectItem.js +1 -10
  7. package/dist/components/molecules/HeaderTop/index.js +6 -23
  8. package/dist/components/molecules/HeaderTop/styles.js +1 -1
  9. package/dist/components/molecules/ProductNameHeader/index.js +4 -6
  10. package/dist/components/organisms/FullProductNameHeader/index.js +0 -1
  11. package/dist/components/pages/Dashboard/index.js +21 -13
  12. package/dist/components/pages/ProviderProductEdition/ProviderProductEdition.stories.js +50 -65
  13. package/dist/components/pages/ProviderProductEdition/index.js +11 -15
  14. package/dist/components/pages/RetailerProductEdition/RetailerProductEdition.stories.js +86 -60
  15. package/dist/components/pages/RetailerProductEdition/index.js +12 -13
  16. package/dist/global-files/fonts.css +0 -6
  17. package/dist/global-files/variables.js +0 -2
  18. package/dist/index.js +46 -267
  19. package/package.json +1 -12
  20. package/src/assets/images/generalButton/closeIcon.svg +2 -2
  21. package/src/components/atoms/ProgressBar/index.js +5 -40
  22. package/src/components/atoms/ProgressBar/styles.js +0 -24
  23. package/src/components/molecules/CustomSelect/CustomSelect.stories.js +12 -20
  24. package/src/components/molecules/CustomSelect/SelectItem.js +0 -7
  25. package/src/components/molecules/HeaderTop/index.js +8 -29
  26. package/src/components/molecules/HeaderTop/styles.js +0 -4
  27. package/src/components/molecules/ProductNameHeader/index.js +2 -7
  28. package/src/components/organisms/FullProductNameHeader/index.js +0 -1
  29. package/src/components/pages/Dashboard/index.js +37 -31
  30. package/src/components/pages/ProviderProductEdition/ProviderProductEdition.stories.js +49 -67
  31. package/src/components/pages/ProviderProductEdition/index.js +7 -16
  32. package/src/components/pages/RetailerProductEdition/RetailerProductEdition.stories.js +85 -62
  33. package/src/components/pages/RetailerProductEdition/index.js +10 -12
  34. package/src/global-files/fonts.css +0 -6
  35. package/src/global-files/variables.js +0 -2
  36. package/src/index.js +0 -17
  37. package/src/assets/images/customSelect/starIcon.svg +0 -14
  38. package/src/assets/images/defaultImages/Spinner.gif +0 -0
  39. package/src/assets/images/defaultImages/notFound.svg +0 -124
  40. package/src/components/atoms/ButtonFileChooser/ButtonFileChooser.stories.js +0 -47
  41. package/src/components/atoms/ButtonFileChooser/index.js +0 -68
  42. package/src/components/atoms/ButtonFileChooser/styles.js +0 -4
  43. package/src/components/atoms/ButtonV2/ButtonV2.stories.js +0 -53
  44. package/src/components/atoms/ButtonV2/index.js +0 -85
  45. package/src/components/atoms/ButtonV2/styles.js +0 -217
  46. package/src/components/atoms/CustomIcon/CustomIcon.stories.js +0 -36
  47. package/src/components/atoms/CustomIcon/index.js +0 -41
  48. package/src/components/atoms/CustomIcon/styles.js +0 -85
  49. package/src/components/atoms/IconFile/IconFile.stories.js +0 -35
  50. package/src/components/atoms/IconFile/index.js +0 -119
  51. package/src/components/atoms/IconFile/styles.js +0 -67
  52. package/src/components/atoms/Image/Image.stories.js +0 -51
  53. package/src/components/atoms/Image/index.js +0 -55
  54. package/src/components/atoms/Image/styles.js +0 -34
  55. package/src/components/atoms/ImageLink/ImageLink.stories.js +0 -43
  56. package/src/components/atoms/ImageLink/index.js +0 -57
  57. package/src/components/atoms/ImageLink/styles.js +0 -30
  58. package/src/components/atoms/ImagePreview/ImagePreview.stories.js +0 -52
  59. package/src/components/atoms/ImagePreview/index.js +0 -178
  60. package/src/components/atoms/ImagePreview/styles.js +0 -77
  61. package/src/components/atoms/InputText/InputText.stories.js +0 -39
  62. package/src/components/atoms/InputText/index.js +0 -61
  63. package/src/components/atoms/InputText/styles.js +0 -89
  64. package/src/components/atoms/NotFound/NotFound.stories.js +0 -19
  65. package/src/components/atoms/NotFound/index.js +0 -52
  66. package/src/components/atoms/NotFound/styles.js +0 -55
  67. package/src/components/atoms/SelectItemV2/SelectItemV2.stories.js +0 -26
  68. package/src/components/atoms/SelectItemV2/index.js +0 -61
  69. package/src/components/atoms/SelectItemV2/styles.js +0 -90
  70. package/src/components/atoms/Tooltip/Tooltip.stories.js +0 -51
  71. package/src/components/atoms/Tooltip/index.js +0 -59
  72. package/src/components/atoms/Tooltip/styles.js +0 -42
  73. package/src/components/molecules/ButtonDownloadFile/DownloadFile.stories.js +0 -54
  74. package/src/components/molecules/ButtonDownloadFile/index.js +0 -109
  75. package/src/components/molecules/ButtonDownloadFile/styles.js +0 -66
  76. package/src/components/molecules/Dropdown/Dropdown.stories.js +0 -103
  77. package/src/components/molecules/Dropdown/index.js +0 -150
  78. package/src/components/molecules/Dropdown/styles.js +0 -75
  79. package/src/components/molecules/ImageTooltip/ImageTooltip.stories.js +0 -68
  80. package/src/components/molecules/ImageTooltip/index.js +0 -63
  81. package/src/components/molecules/ImageTooltip/styles.js +0 -18
  82. package/src/components/molecules/SelectV2/SelectV2.stories.js +0 -115
  83. package/src/components/molecules/SelectV2/index.js +0 -357
  84. package/src/components/molecules/SelectV2/styles.js +0 -105
  85. package/src/components/molecules/SelectV2/test.js +0 -61
  86. package/src/components/molecules/SelectV2/test.stories.js +0 -10
  87. package/src/components/organisms/Chat/Chat.stories.js +0 -147
  88. package/src/components/organisms/Chat/ChatLists/ChatLists.stories.js +0 -65
  89. package/src/components/organisms/Chat/ChatLists/Rotoplas.jpeg +0 -0
  90. package/src/components/organisms/Chat/ChatLists/THD.png +0 -0
  91. package/src/components/organisms/Chat/ChatLists/index.js +0 -141
  92. package/src/components/organisms/Chat/ChatLists/styles.js +0 -162
  93. package/src/components/organisms/Chat/ContainerItems/ContainerItems.stories.js +0 -142
  94. package/src/components/organisms/Chat/ContainerItems/index.js +0 -512
  95. package/src/components/organisms/Chat/ContainerItems/styles.js +0 -328
  96. package/src/components/organisms/Chat/ContentChat/ContentChat.stories.js +0 -102
  97. package/src/components/organisms/Chat/ContentChat/Rotoplas.jpeg +0 -0
  98. package/src/components/organisms/Chat/ContentChat/THD.png +0 -0
  99. package/src/components/organisms/Chat/ContentChat/index.js +0 -897
  100. package/src/components/organisms/Chat/ContentChat/styles.js +0 -41
  101. package/src/components/organisms/Chat/Footer/Footer.stories.js +0 -22
  102. package/src/components/organisms/Chat/Footer/index.js +0 -661
  103. package/src/components/organisms/Chat/Footer/styles.js +0 -286
  104. package/src/components/organisms/Chat/Header/Header.stories.js +0 -66
  105. package/src/components/organisms/Chat/Header/index.js +0 -94
  106. package/src/components/organisms/Chat/Header/styles.js +0 -49
  107. package/src/components/organisms/Chat/index.js +0 -235
  108. package/src/components/organisms/Chat/styles.js +0 -42
  109. package/src/components/organisms/Modal/Modal.stories.js +0 -55
  110. package/src/components/organisms/Modal/index.js +0 -97
  111. package/src/components/organisms/Modal/styles.js +0 -103
  112. package/src/components/organisms/RangeCalendar/RangeCalendar.stories.js +0 -16
  113. package/src/components/organisms/RangeCalendar/index.js +0 -121
  114. package/src/components/organisms/RangeCalendar/styles.js +0 -883
  115. package/src/global-files/handle_http.js +0 -225
  116. package/src/global-files/handle_userTech.js +0 -7
  117. package/src/global-files/utils.js +0 -315
@@ -1,225 +0,0 @@
1
- import axios from "axios";
2
-
3
- //============================================================
4
- /**
5
- * funcion que realiza un axios GET
6
- *
7
- * Si <body> es undefined significa que hubo error
8
-
9
- * @returns { Promise<{
10
- * body: {} | undefined ,
11
- * message: string,
12
- * errorDetail: string
13
- * }> }
14
- *
15
- */
16
- //============================================================
17
- export const fetchGET = (
18
- endpoint = "",
19
- paramsQuery = {},
20
- paramsHeaders = {}
21
- ) => {
22
- return new Promise(async (response) => {
23
- try {
24
- let URL = endpoint;
25
- const keysParamsQuery = Object.keys(paramsQuery);
26
- // agregar cada param query a la URL
27
- keysParamsQuery.forEach((key, index) => {
28
- if (index == 0) {
29
- URL += `?${key}=${paramsQuery[key]}`;
30
- } else {
31
- URL += `&${key}=${paramsQuery[key]}`;
32
- }
33
- });
34
- const respHTTPjson = await axios.get(URL, { headers: paramsHeaders });
35
- // verificar si existe un error en la peticion realizada
36
- if (respHTTPjson.status !== 200) {
37
- return response({
38
- message: "No fue posible llevar a cabo la operación",
39
- errorDetail: respHTTPjson.statusText,
40
- });
41
- }
42
- // obtener body backend
43
- const body = JSON.parse(respHTTPjson.data.body);
44
-
45
- // verificar si existe error desde el backend
46
- if (respHTTPjson.data.statusCode !== 200) {
47
- return response({
48
- message: body.message ?? "",
49
- errorDetail: body.errorDetail ?? "",
50
- });
51
- }
52
- // success
53
- return response({ body });
54
- } catch (err) {
55
- return response({
56
- message: "Error al obtener los datos",
57
- errorDetail: err.message,
58
- });
59
- }
60
- });
61
- };
62
-
63
- //============================================================
64
- /**
65
- * funcion que realiza un axios POST
66
- *
67
- * Si <body> es undefined significa que hubo error
68
-
69
- * @returns { Promise<{
70
- * body: {} | undefined ,
71
- * message: string,
72
- * errorDetail: string
73
- * }> }
74
- *
75
- */
76
- //============================================================
77
- export const fetchPOST = (
78
- endpoint = "",
79
- paramsBody = {},
80
- paramsHeaders = {}
81
- ) => {
82
- return new Promise(async (response) => {
83
- try {
84
- const respHTTPjson = await axios.post(endpoint, paramsBody, {
85
- headers: paramsHeaders,
86
- });
87
-
88
- // verificar si existe un error en la peticion realizada
89
- if (respHTTPjson.status !== 200) {
90
- return response({
91
- message: "No fue posible llevar a cabo la operación",
92
- errorDetail: respHTTPjson.statusText,
93
- });
94
- }
95
- // obtener body backend
96
- const body = JSON.parse(respHTTPjson.data.body);
97
-
98
- // verificar si existe error desde el backend
99
- if (respHTTPjson.data.statusCode !== 200) {
100
- return response({
101
- message: body.message ?? "",
102
- errorDetail: body.errorDetail ?? "",
103
- });
104
- }
105
- // success
106
- return response({ body });
107
- } catch (err) {
108
- return response({
109
- message: "Error al guardar los datos",
110
- errorDetail: err.message,
111
- });
112
- }
113
- });
114
- };
115
-
116
- //============================================================
117
- /**
118
- * funcion que realiza un axios GET
119
- *
120
- * Si <body> es undefined significa que hubo error
121
-
122
- * @returns { Promise<{
123
- * body: {} | undefined ,
124
- * message: string,
125
- * errorDetail: string
126
- * }> }
127
- *
128
- */
129
- //============================================================
130
- export const fetchPUT = (
131
- endpoint = "",
132
- paramsBody = {},
133
- paramsHeaders = {}
134
- ) => {
135
- return new Promise(async (response) => {
136
- try {
137
- const respHTTPjson = await axios.put(endpoint, paramsBody, {
138
- headers: paramsHeaders,
139
- });
140
-
141
- // verificar si existe un error en la peticion realizada
142
- if (respHTTPjson.status !== 200) {
143
- return response({
144
- message: "No fue posible llevar a cabo la operación",
145
- errorDetail: respHTTPjson.statusText,
146
- });
147
- }
148
-
149
- // obtener body backend
150
- const body = JSON.parse(respHTTPjson.data.body);
151
-
152
- // verificar si existe error desde el backend
153
- if (respHTTPjson.data.statusCode !== 200) {
154
- return response({
155
- message: body.message ?? "",
156
- errorDetail: body.errorDetail ?? "",
157
- });
158
- }
159
-
160
- // success
161
- return response({ body });
162
- } catch (err) {
163
- return response({
164
- message: "Error al actualizar los datos",
165
- errorDetail: err.message,
166
- });
167
- }
168
- });
169
- };
170
-
171
- //============================================================
172
- /**
173
- * funcion que realiza un axios GET
174
- *
175
- * Si <body> es undefined significa que hubo error
176
-
177
- * @returns { Promise<{
178
- * body: {} | undefined ,
179
- * message: string,
180
- * errorDetail: string
181
- * }> }
182
- *
183
- */
184
- //============================================================
185
- export const fetchDELETE = (
186
- endpoint = "",
187
- paramsBody = {},
188
- paramsHeaders = {}
189
- ) => {
190
- return new Promise(async (response) => {
191
- try {
192
- const respHTTPjson = await axios.delete(endpoint, {
193
- data: paramsBody,
194
- headers: paramsHeaders,
195
- });
196
-
197
- // verificar si existe un error en la peticion realizada
198
- if (respHTTPjson.status !== 200) {
199
- return response({
200
- message: "No fue posible llevar a cabo la operación",
201
- errorDetail: respHTTPjson.statusText,
202
- });
203
- }
204
-
205
- // obtener body backend
206
- const body = JSON.parse(respHTTPjson.data.body);
207
-
208
- // verificar si existe error desde el backend
209
- if (respHTTPjson.data.statusCode !== 200) {
210
- return response({
211
- message: body.message ?? "",
212
- errorDetail: body.errorDetail ?? "",
213
- });
214
- }
215
-
216
- // success
217
- return response({ body });
218
- } catch (err) {
219
- return response({
220
- message: "Error al actualizar los datos",
221
- errorDetail: err.message,
222
- });
223
- }
224
- });
225
- };
@@ -1,7 +0,0 @@
1
- export const isUserTech = (value = "") => {
2
- return ["AS", "ADMIN-AS", "ADMIN"].includes(value);
3
- };
4
-
5
- export const isUserAdminTech = (value = "") => {
6
- return ["ADMIN-AS", "ADMIN"].includes(value);
7
- };
@@ -1,315 +0,0 @@
1
- import { Base64 } from "js-base64";
2
- import moment from "moment";
3
-
4
- /*====================================================================
5
- UTILERIAS PARA EL MANEJO DE ARCHIVOS
6
- ======================================================================*/
7
- /*------------------------
8
- devolver el base64
9
- completo de un file
10
- --------------------------*/
11
- export const getBase64 = async (file) => {
12
- return new Promise((success) => {
13
- const reader = new FileReader();
14
- reader.addEventListener("loadend", () => {
15
- success(reader.result);
16
- });
17
- reader.readAsDataURL(file);
18
- });
19
- };
20
-
21
- /*------------------------
22
- devolver la data de un string base64
23
- --------------------------*/
24
- export const getDataBase64 = (base64Full) => {
25
- //const base64 = reader.result.replace(/^data:\w+\/\w+.*;base64,/, "");
26
- try {
27
- const base64 = base64Full.split("base64,");
28
- return base64.length ? base64[1] : undefined;
29
- } catch (err) {
30
- return undefined;
31
- }
32
- };
33
-
34
- /*------------------------
35
- devolver un data Buffer a partir
36
- de un data base64
37
- --------------------------*/
38
- export const getDataBuffer = (dataBase64) => {
39
- try {
40
- const dataBuffer = Buffer.from(dataBase64, "base64");
41
- return dataBuffer;
42
- } catch (err) {
43
- return undefined;
44
- }
45
- };
46
-
47
- /*------------------------
48
- devolver la extension de un file
49
- a partir de un string: "name.ext"
50
- --------------------------*/
51
- export const getFileExtension = (fileName = "") => {
52
- const nameParts = fileName.split(".");
53
- let ext = "";
54
- nameParts.forEach((part, index) => {
55
- if (index !== 0) {
56
- if (index + 1 === nameParts.length) ext += part;
57
- else ext += part + ".";
58
- }
59
- });
60
- return ext === "" ? undefined : ext;
61
- };
62
-
63
- /*------------------------
64
- devolver el nombre de un file
65
- a partir de un string: "name.ext"
66
- --------------------------*/
67
- export const getFileName = (fileName = "") => {
68
- const nameParts = fileName.split(".");
69
- if (nameParts.length) return nameParts[0];
70
- return undefined;
71
- };
72
-
73
- /*------------------------
74
- obtener la URL de una imagen
75
- con un peso mas pequeño al
76
- peso original pasando como
77
- parametros:
78
- => bucket: <string> bucket en donde se ecuentra la img
79
- => key: <string> ruta y nombre completa de la img (keyS3)
80
- => width: <number> largo de la img en px
81
- => height: <number> altura de la img en px
82
- --------------------------*/
83
- export const getImageURL = (bucket, key, width, height) => {
84
- try {
85
- const configAWS = {
86
- bucket: bucket,
87
- key: key,
88
- edits: {
89
- resize: {
90
- width: width,
91
- height: height,
92
- fit: "contain",
93
- background: { r: 255, g: 255, b: 255, alpha: 0 },
94
- },
95
- },
96
- };
97
- let url = "https://d24s337exbt5zr.cloudfront.net/";
98
- url += Base64.encode(JSON.stringify(configAWS));
99
- return url;
100
- } catch (err) {
101
- console.log(`ERROR al obtener la URL de la imagen (${key})`, err.message);
102
- return undefined;
103
- }
104
- };
105
-
106
- /*------------------------
107
- obtener la dimension de una imagen
108
- a partir de un objeto <File>
109
- retorno: {
110
- => width: <number> largo de la img en px
111
- => height: <number> altura de la img en px
112
- }
113
- NOTA regresa <undefined> si no se pudo
114
- obtener la dimension de la imagen
115
- --------------------------*/
116
- export const getImageSize = (file) => {
117
- return new Promise(async (response) => {
118
- const img = new Image();
119
- img.onload = () => response({ width: img.width, height: img.height });
120
- img.onerror = () => response(undefined);
121
- const base64 = await getBase64(file);
122
- img.src = base64;
123
- });
124
- };
125
-
126
- /*------------------------
127
- obtener una redimension (height) proporcional
128
- a la dimension original (height) a partir de
129
- un width deseado
130
- retorno:
131
- => newHeight: <number> altura de la img en px
132
- NOTA regresa <undefined> si no se pudo
133
- obtener el nuevo <height> de la imagen
134
- --------------------------*/
135
- export const getResizeImgHeight = (originalWidth, originalHeight, newWidth) => {
136
- const scale = (newWidth * 100) / originalWidth / 100;
137
- return Math.ceil(originalHeight * scale);
138
- };
139
-
140
- /*====================================================================
141
- UTILERIAS PARA EL MANEJO DE FECHAS
142
- ======================================================================*/
143
- /*------------------------
144
- nombres de los dias de la semana
145
- --------------------------*/
146
- const weekdayName = {
147
- 1: { short: "Dom", full: "Domingo" },
148
- 2: { short: "Lun", full: "Lunes" },
149
- 3: { short: "Mar", full: "Martes" },
150
- 4: { short: "Mié", full: "Miércoles" },
151
- 5: { short: "Jue", full: "Jueves" },
152
- 6: { short: "Vie", full: "Viernes" },
153
- 7: { short: "Sab", full: "Sabado" },
154
- };
155
- /*------------------------
156
- nombres de los meses
157
- --------------------------*/
158
- const monthName = {
159
- 1: { short: "Ene", full: "Enero" },
160
- 2: { short: "Feb", full: "Febrero" },
161
- 3: { short: "Mar", full: "Marzo" },
162
- 4: { short: "Abr", full: "Abril" },
163
- 5: { short: "May", full: "Mayo" },
164
- 6: { short: "Jun", full: "Junio" },
165
- 7: { short: "Jul", full: "Julio" },
166
- 8: { short: "Ago", full: "Agosto" },
167
- 9: { short: "Sep", full: "Septiembre" },
168
- 10: { short: "Oct", full: "Octubre" },
169
- 11: { short: "Nov", full: "Noviembre" },
170
- 12: { short: "Dic", full: "Diciembre" },
171
- };
172
-
173
- /*------------------------
174
- Obtener una fecha a partir de
175
- un objeto Date() en formato:
176
- 'DDD dd MMM aaaa'
177
- ejemplo: 'Ene 12 Jul 2022'
178
- --------------------------*/
179
- export const getFullDate = (date = new Date()) => {
180
- if (isNaN(date)) return undefined;
181
- let dateString = `${weekdayName[date.getDay() + 1].short} `;
182
- dateString += date.getDate() + " ";
183
- dateString += `${monthName[date.getMonth() + 1].short} `;
184
- dateString += date.getFullYear();
185
- return dateString;
186
- };
187
-
188
- /*------------------------
189
- Obtener una fecha a partir de
190
- un objeto Date() en formato:
191
- 'dd de MMMM del aaaa'
192
- ejemplo: '12 de octubre del 2022'
193
- => si es la fecha del dia actual:
194
- devolvera 'Hoy'
195
- => si es la fecha del dia de ayer:
196
- devolvera 'Ayer'
197
- => si es fecha del mismo año:
198
- devolvera '12 de octubre'
199
- --------------------------*/
200
- export const getCustomDate = (date = new Date()) => {
201
- if (isNaN(date)) return "";
202
- let dateString = date.getDate() + " de ";
203
- dateString += `${monthName[date.getMonth() + 1].full}`;
204
- const today = new Date();
205
- const yesterday = new Date();
206
- yesterday.setDate(today.getDate() - 1);
207
-
208
- // fecha de Hoy
209
- if (
210
- date.getDate() === today.getDate() &&
211
- date.getMonth() === today.getMonth() &&
212
- date.getFullYear() === today.getFullYear()
213
- ) {
214
- return "Hoy";
215
- }
216
- // fecha de Ayer
217
- if (
218
- date.getDate() === yesterday.getDate() &&
219
- date.getMonth() === yesterday.getMonth() &&
220
- date.getFullYear() === yesterday.getFullYear()
221
- ) {
222
- return "Ayer";
223
- }
224
- // fechas del mismo año
225
- if (date.getFullYear() === today.getFullYear()) return dateString;
226
- // fechas de diferente año
227
- return dateString + " del " + date.getFullYear();
228
- };
229
-
230
- /*------------------------
231
- Obtener una hora a partir de
232
- una fecha string (current_timestamp)
233
- en formato: 'hh:mm PM/AM'
234
- ejemplo: '12:34 PM'
235
- --------------------------*/
236
- export const getTime = (time = "") => {
237
- if ([undefined, null, ""].includes(time))
238
- return moment(new Date()).format("LT");
239
- return moment(time).format("LT");
240
- };
241
-
242
- /*====================================================================
243
- UTILERIAS PARA EL MANEJO DE VALIDACIONES
244
- ======================================================================*/
245
- /*------------------------
246
- recibe un number o string
247
- y determina si es numero natural
248
- 0,1,2,...
249
- --------------------------*/
250
- export const isValidNaturalNumber = (number) => {
251
- if ([undefined, null, ""].includes(number)) return false;
252
- if (!["string", "number"].includes(typeof number)) return false;
253
- try {
254
- const numberString = number + "";
255
- for (let i = 0; i < numberString.length; i++) {
256
- if ("0123456789".indexOf(numberString.charAt(i)) === -1) return false;
257
- }
258
- return true;
259
- } catch (err) {
260
- return false;
261
- }
262
- };
263
-
264
- /*------------------------
265
- recibe un array y determina si
266
- el array esta vacio []
267
- --------------------------*/
268
- export const isArrayEmpty = (array) => {
269
- if (Array.isArray(array) && array.length) return false;
270
- return true;
271
- };
272
-
273
- /*------------------------
274
- recibe un string y determina si
275
- esta vacio ""
276
- --------------------------*/
277
- export const isStringEmpty = (cad) => {
278
- if (cad && typeof cad === "string" && cad.trim().length !== 0) return false;
279
- return true;
280
- };
281
-
282
- /*------------------------
283
- recibe un string JSON y lo
284
- decodifica a su valor original
285
- --------------------------*/
286
- export const decodeJSON = (valueJSON) => {
287
- try {
288
- const decodeValue = JSON.parse(valueJSON);
289
- return decodeValue;
290
- } catch (err) {
291
- return valueJSON;
292
- }
293
- };
294
-
295
- /*------------------------
296
- recibe un dato y determina si
297
- es objeto JS
298
- --------------------------*/
299
- export const isObject = (obj) => {
300
- if (obj && typeof obj === "object" && !Array.isArray(obj)) return true;
301
- return false;
302
- };
303
-
304
- /*------------------------
305
- recibe un value y lo codifica
306
- primero a JSON y luego a URI
307
- --------------------------*/
308
- export const encodeUriJson = (value) => {
309
- try {
310
- const encodeValue = encodeURIComponent(JSON.stringify(value));
311
- return encodeValue;
312
- } catch (err) {
313
- return undefined;
314
- }
315
- };