@liftitapp/wa-conversations 0.4.0 → 0.6.0
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/README.md +55 -0
- package/dist/element/index.js +553 -140
- package/dist/react/index.d.ts +106 -1
- package/dist/react/index.js +1227 -273
- package/package.json +6 -3
package/dist/react/index.js
CHANGED
|
@@ -1,5 +1,35 @@
|
|
|
1
|
-
import { useCallback, useEffect, useId, useLayoutEffect, useRef, useState } from "react";
|
|
2
|
-
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
1
|
+
import { Fragment, useCallback, useEffect, useId, useLayoutEffect, useRef, useState } from "react";
|
|
2
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
//#region src/core/initials.ts
|
|
4
|
+
/**
|
|
5
|
+
* Las iniciales del avatar de una persona (diseño .pen de DEV-5053).
|
|
6
|
+
*
|
|
7
|
+
* 🔴 **Hay UNA sola función y vive acá, fuera de `list/` y de `thread/`, porque la usan los dos
|
|
8
|
+
* paneles**: la fila del inbox y el header del hilo. Dos implementaciones se desincronizan a la
|
|
9
|
+
* primera corrección de un caso raro, y la misma persona termina saliendo con iniciales distintas
|
|
10
|
+
* en la izquierda y en la derecha de la misma pantalla.
|
|
11
|
+
*
|
|
12
|
+
* 🔴 El `name` lo origina el perfil de WhatsApp de la persona: es entrada NO confiable. El
|
|
13
|
+
* resultado entra al DOM **sólo como hijo de texto**, que React escapa — jamás en un `className`,
|
|
14
|
+
* en un `style`, en un atributo estructural ni en un selector (mismo criterio T-03-02 que ya rige
|
|
15
|
+
* para `service_state`).
|
|
16
|
+
*
|
|
17
|
+
* La degradación es la misma regla que ya usa `ConversationRow`: sin nombre útil se cae al
|
|
18
|
+
* teléfono, jamás a la cadena `"null"` ni a un «(sin nombre)» inventado.
|
|
19
|
+
*/
|
|
20
|
+
/** Un token sirve si tiene al menos una letra: «—», «·» o un emoji suelto no son un nombre. */
|
|
21
|
+
const HAS_LETTER = /\p{L}/u;
|
|
22
|
+
function initials(name, phone) {
|
|
23
|
+
if (typeof name === "string") {
|
|
24
|
+
const letters = name.split(/\s+/).filter((token) => HAS_LETTER.test(token)).map((token) => Array.from(token).find((char) => HAS_LETTER.test(char))).filter((char) => char !== void 0);
|
|
25
|
+
const chosen = letters.length > 1 ? [letters[0], letters[letters.length - 1]] : letters.slice(0, 1);
|
|
26
|
+
if (chosen.length > 0) return chosen.join("").toLocaleUpperCase();
|
|
27
|
+
}
|
|
28
|
+
const digits = typeof phone === "string" ? phone.replace(/\D/g, "") : "";
|
|
29
|
+
if (digits !== "") return digits.slice(-2);
|
|
30
|
+
return "#";
|
|
31
|
+
}
|
|
32
|
+
//#endregion
|
|
3
33
|
//#region src/core/list/relative-time.ts
|
|
4
34
|
/**
|
|
5
35
|
* La hora de la fila del inbox, en español y **siempre relativa**.
|
|
@@ -18,8 +48,8 @@ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
|
18
48
|
* **No se exporta desde el barrel del core.** Es detalle interno de la fila; lo que sale del barrel
|
|
19
49
|
* es API pública del entry `./react` y renombrarlo rompería el import de `lms-web-app` (PKG-04).
|
|
20
50
|
*/
|
|
21
|
-
const MINUTE = 6e4;
|
|
22
|
-
const HOUR = 60 * MINUTE;
|
|
51
|
+
const MINUTE$1 = 6e4;
|
|
52
|
+
const HOUR = 60 * MINUTE$1;
|
|
23
53
|
const DAY = 24 * HOUR;
|
|
24
54
|
const WEEK = 7 * DAY;
|
|
25
55
|
/** Aproximaciones a propósito: es una distancia legible, no un cálculo de calendario. */
|
|
@@ -40,8 +70,8 @@ function relativeTime(iso, now = Date.now()) {
|
|
|
40
70
|
const at = Date.parse(iso);
|
|
41
71
|
if (Number.isNaN(at)) return "";
|
|
42
72
|
const elapsed = now - at;
|
|
43
|
-
if (elapsed < MINUTE) return "ahora";
|
|
44
|
-
if (elapsed < HOUR) return `hace ${Math.floor(elapsed / MINUTE)} min`;
|
|
73
|
+
if (elapsed < MINUTE$1) return "ahora";
|
|
74
|
+
if (elapsed < HOUR) return `hace ${Math.floor(elapsed / MINUTE$1)} min`;
|
|
45
75
|
if (elapsed < DAY) return `hace ${Math.floor(elapsed / HOUR)} h`;
|
|
46
76
|
if (elapsed < WEEK) return `hace ${Math.floor(elapsed / DAY)} d`;
|
|
47
77
|
if (elapsed < MONTH) return `hace ${Math.floor(elapsed / WEEK)} sem`;
|
|
@@ -58,29 +88,46 @@ function ConversationRow({ item, selected, onSelect }) {
|
|
|
58
88
|
className: "wa-list__row",
|
|
59
89
|
"aria-current": selected ? "true" : void 0,
|
|
60
90
|
onClick: () => onSelect(item),
|
|
61
|
-
children: [
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
91
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
92
|
+
className: "wa-list__avatar",
|
|
93
|
+
"aria-hidden": "true",
|
|
94
|
+
children: initials(item.name, item.phone)
|
|
95
|
+
}), /* @__PURE__ */ jsxs("span", {
|
|
96
|
+
className: "wa-list__middle",
|
|
97
|
+
children: [
|
|
98
|
+
/* @__PURE__ */ jsxs("span", {
|
|
99
|
+
className: "wa-list__head",
|
|
100
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
101
|
+
className: "wa-list__title",
|
|
102
|
+
children: item.name ?? item.phone
|
|
103
|
+
}), /* @__PURE__ */ jsx("time", {
|
|
104
|
+
className: "wa-list__time",
|
|
105
|
+
dateTime: item.last_message_at,
|
|
106
|
+
title: item.last_message_at,
|
|
107
|
+
children: relativeTime(item.last_message_at)
|
|
108
|
+
})]
|
|
109
|
+
}),
|
|
110
|
+
item.name !== null && /* @__PURE__ */ jsx("span", {
|
|
111
|
+
className: "wa-list__phone",
|
|
112
|
+
children: item.phone
|
|
113
|
+
}),
|
|
114
|
+
item.last_message !== null && /* @__PURE__ */ jsx("span", {
|
|
115
|
+
className: "wa-list__preview",
|
|
116
|
+
children: item.last_message
|
|
117
|
+
}),
|
|
118
|
+
item.service_state !== null && /* @__PURE__ */ jsx("span", {
|
|
119
|
+
className: "wa-list__state",
|
|
120
|
+
title: item.service_state,
|
|
121
|
+
children: item.service_state
|
|
122
|
+
}),
|
|
123
|
+
typeof item.taken_by === "string" && item.taken_by !== "" && /* @__PURE__ */ jsx("span", {
|
|
124
|
+
className: "wa-list__taken",
|
|
125
|
+
"data-mine": item.taken_by_me === true || void 0,
|
|
126
|
+
title: `Tomada por ${item.taken_by}`,
|
|
127
|
+
children: item.taken_by_me === true ? "La tomaste tú" : `Tomada por ${item.taken_by}`
|
|
128
|
+
})
|
|
129
|
+
]
|
|
130
|
+
})]
|
|
84
131
|
})
|
|
85
132
|
});
|
|
86
133
|
}
|
|
@@ -100,8 +147,10 @@ function ConversationRow({ item, selected, onSelect }) {
|
|
|
100
147
|
* DOM: un selector de elemento suelto (`ul`, `button`, `input`) le pisaría los estilos al host, y
|
|
101
148
|
* `backoffice-v2-lite` no perdona eso. Tampoco hay `:host` acá — eso es del entry del elemento.
|
|
102
149
|
* - **Sin tokens del LMS, sin variables, sin `@import`, sin fuentes remotas** (C-04/LIST-05). El
|
|
103
|
-
* paquete monta en tres hosts con temas distintos
|
|
104
|
-
*
|
|
150
|
+
* paquete monta en tres hosts con temas distintos. La paleta de acá (índigo #4F5AED, grises
|
|
151
|
+
* #F4F5F7/#E4E7EE) NO es un tema inventado: viene del diseño aprobado de DEV-5053 (.pen), y
|
|
152
|
+
* sigue sin depender de tokens del host. `Inter` va sólo como primer nombre del font stack —
|
|
153
|
+
* si el host la carga se usa, si no cae a system-ui; cero `@import`.
|
|
105
154
|
* - **El layout angosto/ancho se selecciona por `[data-layout]`, no por `@media`.** El panel va
|
|
106
155
|
* embebido y el viewport miente sobre el ancho que realmente tiene (ver `useContainerLayout`).
|
|
107
156
|
*
|
|
@@ -115,7 +164,7 @@ const LIST_CSS = `
|
|
|
115
164
|
display: flex;
|
|
116
165
|
flex-direction: column;
|
|
117
166
|
min-height: 0;
|
|
118
|
-
font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
|
|
167
|
+
font-family: Inter, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
|
|
119
168
|
font-size: 14px;
|
|
120
169
|
line-height: 1.5;
|
|
121
170
|
color: #1f2933;
|
|
@@ -144,34 +193,143 @@ const LIST_CSS = `
|
|
|
144
193
|
padding: 10px 12px;
|
|
145
194
|
border-bottom: 1px solid #e4e7eb;
|
|
146
195
|
}
|
|
147
|
-
|
|
196
|
+
/* Etiqueta sólo para lectores de pantalla: el buscador y las fechas se explican solos a la vista
|
|
197
|
+
(placeholder e icono), pero sin <label> asociado un input no tiene nombre accesible. */
|
|
198
|
+
.wa-list__sr-only {
|
|
199
|
+
position: absolute;
|
|
200
|
+
width: 1px;
|
|
201
|
+
height: 1px;
|
|
202
|
+
padding: 0;
|
|
203
|
+
margin: -1px;
|
|
204
|
+
border: 0;
|
|
205
|
+
clip-path: inset(50%);
|
|
206
|
+
overflow: hidden;
|
|
207
|
+
white-space: nowrap;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/* El buscador del diseño: campo relleno con la lupa adentro, no un input con etiqueta encima. */
|
|
211
|
+
.wa-list__search {
|
|
212
|
+
position: relative;
|
|
148
213
|
display: flex;
|
|
149
|
-
flex: 1 1
|
|
214
|
+
flex: 1 1 100%;
|
|
215
|
+
align-items: center;
|
|
150
216
|
min-width: 0;
|
|
151
|
-
flex-direction: column;
|
|
152
|
-
gap: 2px;
|
|
153
217
|
}
|
|
154
|
-
.wa-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
218
|
+
.wa-list__search-icon {
|
|
219
|
+
position: absolute;
|
|
220
|
+
left: 10px;
|
|
221
|
+
color: #8A93A3;
|
|
222
|
+
pointer-events: none;
|
|
159
223
|
}
|
|
160
|
-
.wa-
|
|
224
|
+
.wa-list__search input {
|
|
161
225
|
min-width: 0;
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
border
|
|
226
|
+
width: 100%;
|
|
227
|
+
padding: 8px 10px 8px 30px;
|
|
228
|
+
border: 1px solid #E4E7EE;
|
|
229
|
+
border-radius: 8px;
|
|
165
230
|
font: inherit;
|
|
231
|
+
font-size: 13px;
|
|
166
232
|
color: inherit;
|
|
233
|
+
background: #F4F5F7;
|
|
234
|
+
}
|
|
235
|
+
.wa-list__search input::placeholder {
|
|
236
|
+
color: #8A93A3;
|
|
237
|
+
}
|
|
238
|
+
/* La X nativa del type=search: Chrome la pinta con su propio gris y su propio tamaño. */
|
|
239
|
+
.wa-list__search input::-webkit-search-cancel-button {
|
|
240
|
+
cursor: pointer;
|
|
241
|
+
opacity: 0.5;
|
|
242
|
+
}
|
|
243
|
+
/* Los chips de preset de fecha (DEV-5053): fila propia, ancho completo del formulario. */
|
|
244
|
+
.wa-list__presets {
|
|
245
|
+
display: flex;
|
|
246
|
+
flex: 1 1 100%;
|
|
247
|
+
flex-wrap: wrap;
|
|
248
|
+
gap: 6px;
|
|
249
|
+
}
|
|
250
|
+
.wa-list__preset {
|
|
251
|
+
padding: 4px 12px;
|
|
252
|
+
border: 1px solid #E4E7EE;
|
|
253
|
+
border-radius: 999px;
|
|
254
|
+
font: inherit;
|
|
255
|
+
font-size: 12px;
|
|
256
|
+
color: #52606d;
|
|
167
257
|
background: #ffffff;
|
|
258
|
+
cursor: pointer;
|
|
259
|
+
}
|
|
260
|
+
.wa-list__preset:hover {
|
|
261
|
+
background: #f5f7fa;
|
|
262
|
+
}
|
|
263
|
+
/* El activo se marca por el MISMO atributo que lo anuncia a un lector de pantalla: si alguien
|
|
264
|
+
saca el aria-pressed, el resaltado se va con él y el bug se ve (mismo criterio que la fila). */
|
|
265
|
+
.wa-list__preset[aria-pressed='true'] {
|
|
266
|
+
border-color: #C9D2F5;
|
|
267
|
+
font-weight: 600;
|
|
268
|
+
color: #4F5AED;
|
|
269
|
+
background: #EEF1FE;
|
|
168
270
|
}
|
|
169
|
-
|
|
271
|
+
|
|
272
|
+
/* El rango en una sola fila. Los dos campos reparten el ancho para que la flecha quede al medio
|
|
273
|
+
sin posicionarla a mano. */
|
|
274
|
+
.wa-list__range {
|
|
170
275
|
display: flex;
|
|
171
|
-
|
|
276
|
+
flex: 1 1 100%;
|
|
277
|
+
align-items: center;
|
|
172
278
|
gap: 8px;
|
|
279
|
+
min-width: 0;
|
|
280
|
+
}
|
|
281
|
+
.wa-list__range-sep {
|
|
282
|
+
flex: 0 0 auto;
|
|
283
|
+
font-size: 12px;
|
|
284
|
+
color: #8A93A3;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
/* Domar el <input type="date">.
|
|
288
|
+
Un date input nativo se delata por tres cosas: la fuente del user-agent, el alto propio y el
|
|
289
|
+
icono azul del picker de Chrome. Las tres se pueden corregir; el CALENDARIO que se despliega al
|
|
290
|
+
hacer clic NO — lo pinta el navegador y ningún CSS lo alcanza. Eso es aceptable: es la ventana
|
|
291
|
+
que la persona ya conoce de su sistema, y reemplazarla exigiría un date picker propio, o sea
|
|
292
|
+
una dependencia (prohibido) o cientos de líneas de calendario a mano. */
|
|
293
|
+
.wa-list__date {
|
|
294
|
+
flex: 1 1 0;
|
|
295
|
+
min-width: 0;
|
|
296
|
+
padding: 7px 10px;
|
|
297
|
+
border: 1px solid #E4E7EE;
|
|
298
|
+
border-radius: 8px;
|
|
299
|
+
font: inherit;
|
|
300
|
+
font-size: 12.5px;
|
|
301
|
+
color: #52606d;
|
|
302
|
+
background: #ffffff;
|
|
303
|
+
}
|
|
304
|
+
.wa-list__date:hover {
|
|
305
|
+
border-color: #C9D2F5;
|
|
306
|
+
}
|
|
307
|
+
/* El indicador del picker: gris como el resto del formulario en vez del azul de Chrome. */
|
|
308
|
+
.wa-list__date::-webkit-calendar-picker-indicator {
|
|
309
|
+
cursor: pointer;
|
|
310
|
+
opacity: 0.45;
|
|
311
|
+
}
|
|
312
|
+
.wa-list__date::-webkit-calendar-picker-indicator:hover {
|
|
313
|
+
opacity: 0.8;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
/* «Limpiar filtros»: enlace discreto, no un botón que compita con los chips. Sólo se renderiza
|
|
317
|
+
cuando hay filtros puestos, así que no necesita estado deshabilitado. */
|
|
318
|
+
.wa-list__clear {
|
|
319
|
+
flex: 0 0 auto;
|
|
320
|
+
padding: 0;
|
|
321
|
+
border: 0;
|
|
322
|
+
font: inherit;
|
|
323
|
+
font-size: 12px;
|
|
324
|
+
color: #6B7280;
|
|
325
|
+
background: none;
|
|
326
|
+
text-decoration: underline;
|
|
327
|
+
cursor: pointer;
|
|
328
|
+
}
|
|
329
|
+
.wa-list__clear:hover {
|
|
330
|
+
color: #4F5AED;
|
|
173
331
|
}
|
|
174
|
-
|
|
332
|
+
|
|
175
333
|
.wa-list__more {
|
|
176
334
|
padding: 6px 10px;
|
|
177
335
|
border: 1px solid #cbd2d9;
|
|
@@ -181,7 +339,6 @@ const LIST_CSS = `
|
|
|
181
339
|
background: #ffffff;
|
|
182
340
|
cursor: pointer;
|
|
183
341
|
}
|
|
184
|
-
.wa-list__actions button:hover,
|
|
185
342
|
.wa-list__more:hover {
|
|
186
343
|
background: #f5f7fa;
|
|
187
344
|
}
|
|
@@ -202,72 +359,141 @@ const LIST_CSS = `
|
|
|
202
359
|
list-style: none;
|
|
203
360
|
}
|
|
204
361
|
|
|
362
|
+
/* La fila del diseño (.pen de DEV-5053): avatar a la izquierda y la columna de contenido a la
|
|
363
|
+
derecha. */
|
|
205
364
|
.wa-list__row {
|
|
206
365
|
display: flex;
|
|
207
|
-
flex-direction:
|
|
208
|
-
|
|
366
|
+
flex-direction: row;
|
|
367
|
+
align-items: center;
|
|
368
|
+
gap: 12px;
|
|
209
369
|
width: 100%;
|
|
210
|
-
padding:
|
|
370
|
+
padding: 12px 16px;
|
|
211
371
|
border: 0;
|
|
212
|
-
border-bottom: 1px solid #
|
|
372
|
+
border-bottom: 1px solid #EEF0F3;
|
|
213
373
|
font: inherit;
|
|
214
374
|
color: inherit;
|
|
215
375
|
text-align: left;
|
|
216
|
-
background:
|
|
376
|
+
background: #ffffff;
|
|
217
377
|
cursor: pointer;
|
|
218
378
|
}
|
|
219
379
|
.wa-list__row:hover {
|
|
220
|
-
background: #
|
|
380
|
+
background: #F7F8FC;
|
|
221
381
|
}
|
|
222
382
|
/* El seleccionado se marca por el MISMO atributo que lo anuncia a un lector de pantalla: si un día
|
|
223
383
|
alguien saca el aria-current, el resaltado se va con él y el bug se ve. */
|
|
224
384
|
.wa-list__row[aria-current='true'] {
|
|
225
|
-
background: #
|
|
385
|
+
background: #F5F7FE;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
/* El avatar de iniciales: círculo de 36px, índigo suave. Es decoración (\`aria-hidden\` en el
|
|
389
|
+
TSX): el nombre está al lado. Su CONTENIDO son las iniciales que devuelve initials(), como
|
|
390
|
+
texto — jamás en una clase ni en un selector. */
|
|
391
|
+
.wa-list__avatar {
|
|
392
|
+
display: flex;
|
|
393
|
+
flex: 0 0 auto;
|
|
394
|
+
align-items: center;
|
|
395
|
+
justify-content: center;
|
|
396
|
+
width: 36px;
|
|
397
|
+
height: 36px;
|
|
398
|
+
border-radius: 50%;
|
|
399
|
+
font-size: 13px;
|
|
400
|
+
font-weight: 700;
|
|
401
|
+
color: #4E5BEF;
|
|
402
|
+
background: #EEF1FE;
|
|
403
|
+
}
|
|
404
|
+
/* El sólido de la fila seleccionada cuelga del MISMO aria-current que el resaltado de la fila, y
|
|
405
|
+
no de una clase calculada en JS: un solo gancho para el resaltado y para el lector de pantalla. */
|
|
406
|
+
.wa-list__row[aria-current='true'] .wa-list__avatar {
|
|
407
|
+
color: #ffffff;
|
|
408
|
+
background: #4E5BEF;
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
/* La columna de contenido. \`min-width: 0\` es lo que deja que el ellipsis del título y del
|
|
412
|
+
preview funcione dentro de un flex item. */
|
|
413
|
+
.wa-list__middle {
|
|
414
|
+
display: flex;
|
|
415
|
+
flex: 1 1 0;
|
|
416
|
+
min-width: 0;
|
|
417
|
+
flex-direction: column;
|
|
418
|
+
gap: 3px;
|
|
226
419
|
}
|
|
227
420
|
|
|
228
421
|
.wa-list__head {
|
|
229
422
|
display: flex;
|
|
230
|
-
align-items:
|
|
423
|
+
align-items: center;
|
|
231
424
|
justify-content: space-between;
|
|
232
425
|
gap: 8px;
|
|
233
426
|
}
|
|
234
427
|
.wa-list__title {
|
|
235
428
|
overflow: hidden;
|
|
236
|
-
font-
|
|
429
|
+
font-size: 14px;
|
|
430
|
+
font-weight: 700;
|
|
431
|
+
color: #2D3340;
|
|
237
432
|
text-overflow: ellipsis;
|
|
238
433
|
white-space: nowrap;
|
|
239
434
|
}
|
|
240
435
|
.wa-list__time {
|
|
241
436
|
flex: 0 0 auto;
|
|
242
|
-
font-size:
|
|
243
|
-
color: #
|
|
437
|
+
font-size: 11px;
|
|
438
|
+
color: #8A91A0;
|
|
439
|
+
}
|
|
440
|
+
/* El teléfono de la fila, verbatim (E.164 con \`+\`): formatear exige lógica por país e \`Intl\`
|
|
441
|
+
está proscrito acá. */
|
|
442
|
+
.wa-list__phone {
|
|
443
|
+
overflow: hidden;
|
|
444
|
+
font-size: 11.5px;
|
|
445
|
+
color: #8A91A0;
|
|
446
|
+
text-overflow: ellipsis;
|
|
447
|
+
white-space: nowrap;
|
|
244
448
|
}
|
|
245
449
|
.wa-list__preview {
|
|
246
450
|
overflow: hidden;
|
|
247
|
-
|
|
451
|
+
font-size: 12.5px;
|
|
452
|
+
color: #5B6472;
|
|
248
453
|
text-overflow: ellipsis;
|
|
249
454
|
white-space: nowrap;
|
|
250
455
|
}
|
|
251
|
-
/* El estado del emisor es una cadena OPACA que escribe otro servicio: se pinta como texto
|
|
252
|
-
más. Nunca se interpola su valor en un selector ni en una clase
|
|
456
|
+
/* El estado del emisor es una cadena OPACA que escribe otro servicio: se pinta como texto dentro
|
|
457
|
+
de una pill y nada más. Nunca se interpola su valor en un selector ni en una clase
|
|
458
|
+
(C-01 / T-03-02) — la pill es cosmética del contenedor, no del valor. */
|
|
253
459
|
.wa-list__state {
|
|
254
460
|
align-self: flex-start;
|
|
461
|
+
max-width: 100%;
|
|
462
|
+
padding: 2px 8px;
|
|
463
|
+
border-radius: 999px;
|
|
255
464
|
font-size: 11px;
|
|
256
|
-
|
|
465
|
+
font-weight: 600;
|
|
466
|
+
color: #6B7280;
|
|
467
|
+
background: #F1F2F5;
|
|
257
468
|
word-break: break-word;
|
|
258
469
|
}
|
|
259
470
|
|
|
260
|
-
/*
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
471
|
+
/* DEV-5061 — el chip «Tomada» de la fila. Mismo par de tonos que la barra del hilo: ambar cuando
|
|
472
|
+
la tiene otro (aviso) y anil cuando es tuya. Que las dos vistas usen la MISMA pareja no es
|
|
473
|
+
coincidencia — el operador tiene que reconocer el estado sin releer. */
|
|
474
|
+
.wa-list__taken {
|
|
475
|
+
align-self: flex-start;
|
|
476
|
+
margin-top: 2px;
|
|
477
|
+
padding: 1px 8px;
|
|
478
|
+
border-radius: 999px;
|
|
479
|
+
background: #fff7e8;
|
|
480
|
+
color: #b7791f;
|
|
481
|
+
font-size: 11px;
|
|
482
|
+
font-weight: 600;
|
|
483
|
+
/* El nombre de un operador puede ser largo y la fila es angosta: se recorta en vez de
|
|
484
|
+
empujar la columna. El completo queda en el \`title\`. */
|
|
485
|
+
max-width: 100%;
|
|
486
|
+
overflow: hidden;
|
|
487
|
+
text-overflow: ellipsis;
|
|
488
|
+
white-space: nowrap;
|
|
267
489
|
}
|
|
268
|
-
.wa-
|
|
269
|
-
|
|
490
|
+
.wa-list__taken[data-mine='true'] {
|
|
491
|
+
background: #f4f5ff;
|
|
492
|
+
color: #4f5aed;
|
|
270
493
|
}
|
|
494
|
+
|
|
495
|
+
/* Angosto: sólo se deja envolver el texto. El \`display: contents\` que antes sacaba al agrupador
|
|
496
|
+
del flujo ya no hace falta — la columna .wa-list__middle apila por sí sola. */
|
|
271
497
|
.wa-list[data-layout='narrow'] .wa-list__preview,
|
|
272
498
|
.wa-list[data-layout='narrow'] .wa-list__title {
|
|
273
499
|
white-space: normal;
|
|
@@ -694,7 +920,10 @@ async function loadThread(fetcher, request, options) {
|
|
|
694
920
|
window_expires_at: asNullableString(payload.window_expires_at),
|
|
695
921
|
phone_number_id: asString(payload.phone_number_id),
|
|
696
922
|
service: asString(payload.service),
|
|
697
|
-
can_reply: payload.can_reply === true
|
|
923
|
+
can_reply: payload.can_reply === true,
|
|
924
|
+
taken_by: asNullableString(payload.taken_by),
|
|
925
|
+
taken_until: asNullableString(payload.taken_until),
|
|
926
|
+
taken_by_me: payload.taken_by_me === true
|
|
698
927
|
};
|
|
699
928
|
}
|
|
700
929
|
/**
|
|
@@ -943,6 +1172,21 @@ function useConversations({ fetcher, filters = NO_FILTERS$1 }) {
|
|
|
943
1172
|
*/
|
|
944
1173
|
/** Identidad estable para "sin filtros": un `{}` nuevo por render reiniciaría la lista sin parar. */
|
|
945
1174
|
const NO_FILTERS = {};
|
|
1175
|
+
/**
|
|
1176
|
+
* El rango local `YYYY-MM-DD` de un preset: `to` = hoy, `from` = hoy − (days − 1) — el rango
|
|
1177
|
+
* INCLUYE hoy («7 días» son siete fechas contando la de hoy). Fechas locales con
|
|
1178
|
+
* `getFullYear/getMonth/getDate` + padStart, sin Intl (coherente con DEC-K/DEC-O). El formato es
|
|
1179
|
+
* el MISMO que ya producían los `<input type="date">`, así que DEC-J (los valores viajan tal
|
|
1180
|
+
* cual al descriptor) no cambia.
|
|
1181
|
+
*/
|
|
1182
|
+
function presetRange(days) {
|
|
1183
|
+
const format = (date) => `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, "0")}-${String(date.getDate()).padStart(2, "0")}`;
|
|
1184
|
+
const now = /* @__PURE__ */ new Date();
|
|
1185
|
+
return {
|
|
1186
|
+
from: format(new Date(now.getFullYear(), now.getMonth(), now.getDate() - (days - 1))),
|
|
1187
|
+
to: format(now)
|
|
1188
|
+
};
|
|
1189
|
+
}
|
|
946
1190
|
function ConversationList({ fetcher, selectedPhone, onSelect, className }) {
|
|
947
1191
|
const fieldId = useId();
|
|
948
1192
|
/**
|
|
@@ -955,6 +1199,11 @@ function ConversationList({ fetcher, selectedPhone, onSelect, className }) {
|
|
|
955
1199
|
const [phone, setPhone] = useState("");
|
|
956
1200
|
const [from, setFrom] = useState("");
|
|
957
1201
|
const [to, setTo] = useState("");
|
|
1202
|
+
/**
|
|
1203
|
+
* El preset de fecha activo (DEV-5053). Vive ACÁ y no en `useConversations`: es estado del
|
|
1204
|
+
* formulario — el hook sigue viendo sólo la consulta aplicada, igual que con los date inputs.
|
|
1205
|
+
*/
|
|
1206
|
+
const [datePreset, setDatePreset] = useState(null);
|
|
958
1207
|
/** La consulta vigente. Su IDENTIDAD es lo que el hook mira para reiniciar la lista. */
|
|
959
1208
|
const [filters, setFilters] = useState(NO_FILTERS);
|
|
960
1209
|
const { items, status, error, hasMore, loadMore, retry, autoLoadExhausted } = useConversations({
|
|
@@ -973,10 +1222,45 @@ function ConversationList({ fetcher, selectedPhone, onSelect, className }) {
|
|
|
973
1222
|
if (to !== "") next.to = to;
|
|
974
1223
|
setFilters(next);
|
|
975
1224
|
};
|
|
1225
|
+
/**
|
|
1226
|
+
* Un preset ≠ «Rango…» aplica AL CLIC: calcula el rango, sincroniza los date inputs (por si el
|
|
1227
|
+
* operador después abre «Rango…» para ajustar) y arma la consulta con el mismo criterio de
|
|
1228
|
+
* omisión de vacíos que `applyFilters`, conservando el teléfono tipeado.
|
|
1229
|
+
*/
|
|
1230
|
+
const applyPreset = (preset, days) => {
|
|
1231
|
+
setDatePreset(preset);
|
|
1232
|
+
const range = presetRange(days);
|
|
1233
|
+
setFrom(range.from);
|
|
1234
|
+
setTo(range.to);
|
|
1235
|
+
const next = {};
|
|
1236
|
+
if (phone.trim() !== "") next.phone = phone;
|
|
1237
|
+
next.from = range.from;
|
|
1238
|
+
next.to = range.to;
|
|
1239
|
+
setFilters(next);
|
|
1240
|
+
};
|
|
1241
|
+
/**
|
|
1242
|
+
* El rango aplica al cambiar cualquiera de las dos fechas, sin botón de confirmación. Recibe los
|
|
1243
|
+
* dos valores por parámetro y no del estado: `setFrom`/`setTo` son asíncronos, así que leer el
|
|
1244
|
+
* estado acá aplicaría el rango anterior — el clásico off-by-one-render.
|
|
1245
|
+
*
|
|
1246
|
+
* Un extremo vacío se omite (mismo criterio que `applyFilters`): media ventana es un filtro
|
|
1247
|
+
* legítimo, «desde el 1 de agosto» sin tope.
|
|
1248
|
+
*/
|
|
1249
|
+
const applyRange = (nextFrom, nextTo) => {
|
|
1250
|
+
setDatePreset("range");
|
|
1251
|
+
setFrom(nextFrom);
|
|
1252
|
+
setTo(nextTo);
|
|
1253
|
+
const next = {};
|
|
1254
|
+
if (phone.trim() !== "") next.phone = phone;
|
|
1255
|
+
if (nextFrom !== "") next.from = nextFrom;
|
|
1256
|
+
if (nextTo !== "") next.to = nextTo;
|
|
1257
|
+
setFilters(next);
|
|
1258
|
+
};
|
|
976
1259
|
const clearFilters = () => {
|
|
977
1260
|
setPhone("");
|
|
978
1261
|
setFrom("");
|
|
979
1262
|
setTo("");
|
|
1263
|
+
setDatePreset(null);
|
|
980
1264
|
setFilters(NO_FILTERS);
|
|
981
1265
|
};
|
|
982
1266
|
/**
|
|
@@ -1012,51 +1296,117 @@ function ConversationList({ fetcher, selectedPhone, onSelect, className }) {
|
|
|
1012
1296
|
onSubmit: applyFilters,
|
|
1013
1297
|
children: [
|
|
1014
1298
|
/* @__PURE__ */ jsxs("div", {
|
|
1015
|
-
className: "wa-
|
|
1016
|
-
children: [
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1299
|
+
className: "wa-list__search",
|
|
1300
|
+
children: [
|
|
1301
|
+
/* @__PURE__ */ jsx("label", {
|
|
1302
|
+
className: "wa-list__sr-only",
|
|
1303
|
+
htmlFor: `${fieldId}-phone`,
|
|
1304
|
+
children: "Buscar por nombre o teléfono"
|
|
1305
|
+
}),
|
|
1306
|
+
/* @__PURE__ */ jsxs("svg", {
|
|
1307
|
+
className: "wa-list__search-icon",
|
|
1308
|
+
viewBox: "0 0 16 16",
|
|
1309
|
+
width: "14",
|
|
1310
|
+
height: "14",
|
|
1311
|
+
"aria-hidden": "true",
|
|
1312
|
+
focusable: "false",
|
|
1313
|
+
children: [/* @__PURE__ */ jsx("circle", {
|
|
1314
|
+
cx: "7",
|
|
1315
|
+
cy: "7",
|
|
1316
|
+
r: "4.5",
|
|
1317
|
+
fill: "none",
|
|
1318
|
+
stroke: "currentColor",
|
|
1319
|
+
strokeWidth: "1.5"
|
|
1320
|
+
}), /* @__PURE__ */ jsx("path", {
|
|
1321
|
+
d: "M10.5 10.5 14 14",
|
|
1322
|
+
stroke: "currentColor",
|
|
1323
|
+
strokeWidth: "1.5",
|
|
1324
|
+
strokeLinecap: "round"
|
|
1325
|
+
})]
|
|
1326
|
+
}),
|
|
1327
|
+
/* @__PURE__ */ jsx("input", {
|
|
1328
|
+
id: `${fieldId}-phone`,
|
|
1329
|
+
type: "search",
|
|
1330
|
+
placeholder: "Buscar por nombre o teléfono",
|
|
1331
|
+
value: phone,
|
|
1332
|
+
onChange: (event) => setPhone(event.target.value)
|
|
1333
|
+
})
|
|
1334
|
+
]
|
|
1025
1335
|
}),
|
|
1026
1336
|
/* @__PURE__ */ jsxs("div", {
|
|
1027
|
-
className: "wa-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1337
|
+
className: "wa-list__presets",
|
|
1338
|
+
role: "group",
|
|
1339
|
+
"aria-label": "Filtrar por fecha",
|
|
1340
|
+
children: [
|
|
1341
|
+
/* @__PURE__ */ jsx("button", {
|
|
1342
|
+
type: "button",
|
|
1343
|
+
className: "wa-list__preset",
|
|
1344
|
+
"aria-pressed": datePreset === "today",
|
|
1345
|
+
onClick: () => applyPreset("today", 1),
|
|
1346
|
+
children: "Hoy"
|
|
1347
|
+
}),
|
|
1348
|
+
/* @__PURE__ */ jsx("button", {
|
|
1349
|
+
type: "button",
|
|
1350
|
+
className: "wa-list__preset",
|
|
1351
|
+
"aria-pressed": datePreset === "7d",
|
|
1352
|
+
onClick: () => applyPreset("7d", 7),
|
|
1353
|
+
children: "7 días"
|
|
1354
|
+
}),
|
|
1355
|
+
/* @__PURE__ */ jsx("button", {
|
|
1356
|
+
type: "button",
|
|
1357
|
+
className: "wa-list__preset",
|
|
1358
|
+
"aria-pressed": datePreset === "30d",
|
|
1359
|
+
onClick: () => applyPreset("30d", 30),
|
|
1360
|
+
children: "30 días"
|
|
1361
|
+
}),
|
|
1362
|
+
/* @__PURE__ */ jsx("button", {
|
|
1363
|
+
type: "button",
|
|
1364
|
+
className: "wa-list__preset",
|
|
1365
|
+
"aria-pressed": datePreset === "range",
|
|
1366
|
+
onClick: () => setDatePreset("range"),
|
|
1367
|
+
children: "Rango…"
|
|
1368
|
+
})
|
|
1369
|
+
]
|
|
1037
1370
|
}),
|
|
1038
|
-
/* @__PURE__ */ jsxs("div", {
|
|
1039
|
-
className: "wa-
|
|
1040
|
-
children: [
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1371
|
+
datePreset === "range" && /* @__PURE__ */ jsxs("div", {
|
|
1372
|
+
className: "wa-list__range",
|
|
1373
|
+
children: [
|
|
1374
|
+
/* @__PURE__ */ jsx("label", {
|
|
1375
|
+
className: "wa-list__sr-only",
|
|
1376
|
+
htmlFor: `${fieldId}-from`,
|
|
1377
|
+
children: "Desde"
|
|
1378
|
+
}),
|
|
1379
|
+
/* @__PURE__ */ jsx("input", {
|
|
1380
|
+
id: `${fieldId}-from`,
|
|
1381
|
+
type: "date",
|
|
1382
|
+
className: "wa-list__date",
|
|
1383
|
+
value: from,
|
|
1384
|
+
onChange: (event) => applyRange(event.target.value, to)
|
|
1385
|
+
}),
|
|
1386
|
+
/* @__PURE__ */ jsx("span", {
|
|
1387
|
+
className: "wa-list__range-sep",
|
|
1388
|
+
"aria-hidden": "true",
|
|
1389
|
+
children: "→"
|
|
1390
|
+
}),
|
|
1391
|
+
/* @__PURE__ */ jsx("label", {
|
|
1392
|
+
className: "wa-list__sr-only",
|
|
1393
|
+
htmlFor: `${fieldId}-to`,
|
|
1394
|
+
children: "Hasta"
|
|
1395
|
+
}),
|
|
1396
|
+
/* @__PURE__ */ jsx("input", {
|
|
1397
|
+
id: `${fieldId}-to`,
|
|
1398
|
+
type: "date",
|
|
1399
|
+
className: "wa-list__date",
|
|
1400
|
+
value: to,
|
|
1401
|
+
onChange: (event) => applyRange(from, event.target.value)
|
|
1402
|
+
})
|
|
1403
|
+
]
|
|
1049
1404
|
}),
|
|
1050
|
-
/* @__PURE__ */
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
}), /* @__PURE__ */ jsx("button", {
|
|
1056
|
-
type: "button",
|
|
1057
|
-
onClick: clearFilters,
|
|
1058
|
-
children: "Limpiar"
|
|
1059
|
-
})]
|
|
1405
|
+
hasFilters && /* @__PURE__ */ jsx("button", {
|
|
1406
|
+
type: "button",
|
|
1407
|
+
className: "wa-list__clear",
|
|
1408
|
+
onClick: clearFilters,
|
|
1409
|
+
children: "Limpiar filtros"
|
|
1060
1410
|
})
|
|
1061
1411
|
]
|
|
1062
1412
|
}),
|
|
@@ -1129,8 +1479,6 @@ function ConversationList({ fetcher, selectedPhone, onSelect, className }) {
|
|
|
1129
1479
|
* header del drawer del embudo de `lms-mf-lifters`, que es donde el MF ya tiene cargado el
|
|
1130
1480
|
* detalle del embudo. Acá se menciona para que el operador sepa a dónde ir — nunca se ejecuta.
|
|
1131
1481
|
*/
|
|
1132
|
-
/** A partir de acá se muestra el contador: antes es ruido, después es información. */
|
|
1133
|
-
const COUNTER_THRESHOLD = 3896;
|
|
1134
1482
|
/**
|
|
1135
1483
|
* El aviso de los envíos que no salieron.
|
|
1136
1484
|
*
|
|
@@ -1152,6 +1500,7 @@ function FailureNotice({ composer }) {
|
|
|
1152
1500
|
className: "wa-composer__failure-actions",
|
|
1153
1501
|
children: [entry.failure?.retryable === true && /* @__PURE__ */ jsx("button", {
|
|
1154
1502
|
type: "button",
|
|
1503
|
+
className: "wa-composer__failure-retry",
|
|
1155
1504
|
onClick: () => composer.retry(entry.clientMessageId),
|
|
1156
1505
|
children: "Reintentar"
|
|
1157
1506
|
}), /* @__PURE__ */ jsx("button", {
|
|
@@ -1208,17 +1557,43 @@ function ReleaseToBot({ composer }) {
|
|
|
1208
1557
|
]
|
|
1209
1558
|
});
|
|
1210
1559
|
}
|
|
1211
|
-
function Composer({ canReply, composer }) {
|
|
1560
|
+
function Composer({ canReply, composer, onRetryWindow }) {
|
|
1212
1561
|
const [draft, setDraft] = useState("");
|
|
1213
1562
|
if (!canReply) return null;
|
|
1214
1563
|
if (composer.windowState === "closed") return /* @__PURE__ */ jsxs("div", {
|
|
1215
1564
|
className: "wa-composer wa-composer--closed",
|
|
1216
1565
|
children: [
|
|
1217
1566
|
/* @__PURE__ */ jsx(FailureNotice, { composer }),
|
|
1218
|
-
/* @__PURE__ */
|
|
1219
|
-
className: "wa-
|
|
1567
|
+
/* @__PURE__ */ jsx("span", {
|
|
1568
|
+
className: "wa-composer__lock",
|
|
1569
|
+
children: /* @__PURE__ */ jsxs("svg", {
|
|
1570
|
+
width: 20,
|
|
1571
|
+
height: 20,
|
|
1572
|
+
viewBox: "0 0 20 20",
|
|
1573
|
+
fill: "none",
|
|
1574
|
+
stroke: "#8A91A0",
|
|
1575
|
+
strokeWidth: 1.6,
|
|
1576
|
+
strokeLinecap: "round",
|
|
1577
|
+
strokeLinejoin: "round",
|
|
1578
|
+
"aria-hidden": "true",
|
|
1579
|
+
children: [/* @__PURE__ */ jsx("rect", {
|
|
1580
|
+
x: "4.5",
|
|
1581
|
+
y: "9",
|
|
1582
|
+
width: "11",
|
|
1583
|
+
height: "7.5",
|
|
1584
|
+
rx: "1.5"
|
|
1585
|
+
}), /* @__PURE__ */ jsx("path", { d: "M7 9V6.5a3 3 0 0 1 6 0V9" })]
|
|
1586
|
+
})
|
|
1587
|
+
}),
|
|
1588
|
+
/* @__PURE__ */ jsxs("div", {
|
|
1220
1589
|
role: "status",
|
|
1221
|
-
children: [/* @__PURE__ */ jsx("
|
|
1590
|
+
children: [/* @__PURE__ */ jsx("p", {
|
|
1591
|
+
className: "wa-composer__cold-title",
|
|
1592
|
+
children: "La ventana de 24 horas está cerrada"
|
|
1593
|
+
}), /* @__PURE__ */ jsx("p", {
|
|
1594
|
+
className: "wa-composer__cold-explain",
|
|
1595
|
+
children: "WhatsApp solo permite responder hasta 24 h después del último mensaje del lifter. Se reabre cuando vuelva a escribir."
|
|
1596
|
+
})]
|
|
1222
1597
|
}),
|
|
1223
1598
|
/* @__PURE__ */ jsx(ReleaseToBot, { composer })
|
|
1224
1599
|
]
|
|
@@ -1232,10 +1607,24 @@ function Composer({ canReply, composer }) {
|
|
|
1232
1607
|
return /* @__PURE__ */ jsxs("div", {
|
|
1233
1608
|
className: "wa-composer",
|
|
1234
1609
|
children: [
|
|
1235
|
-
composer.windowState === "unverified" && /* @__PURE__ */
|
|
1610
|
+
composer.windowState === "unverified" && /* @__PURE__ */ jsxs("div", {
|
|
1236
1611
|
className: "wa-composer__unverified",
|
|
1237
1612
|
role: "status",
|
|
1238
|
-
children:
|
|
1613
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
1614
|
+
className: "wa-composer__unverified-text",
|
|
1615
|
+
children: [/* @__PURE__ */ jsx("p", {
|
|
1616
|
+
className: "wa-composer__unverified-title",
|
|
1617
|
+
children: "No pudimos verificar si se puede responder"
|
|
1618
|
+
}), /* @__PURE__ */ jsx("p", {
|
|
1619
|
+
className: "wa-composer__unverified-explain",
|
|
1620
|
+
children: "Es un error temporal, no una ventana cerrada."
|
|
1621
|
+
})]
|
|
1622
|
+
}), onRetryWindow !== void 0 && /* @__PURE__ */ jsx("button", {
|
|
1623
|
+
type: "button",
|
|
1624
|
+
className: "wa-composer__retry-window",
|
|
1625
|
+
onClick: onRetryWindow,
|
|
1626
|
+
children: "Reintentar"
|
|
1627
|
+
})]
|
|
1239
1628
|
}),
|
|
1240
1629
|
/* @__PURE__ */ jsx(FailureNotice, { composer }),
|
|
1241
1630
|
/* @__PURE__ */ jsxs("form", {
|
|
@@ -1258,20 +1647,27 @@ function Composer({ canReply, composer }) {
|
|
|
1258
1647
|
send();
|
|
1259
1648
|
}
|
|
1260
1649
|
}), /* @__PURE__ */ jsxs("div", {
|
|
1261
|
-
className: "wa-
|
|
1262
|
-
children: [
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1650
|
+
className: "wa-composer__hint-row",
|
|
1651
|
+
children: [
|
|
1652
|
+
/* @__PURE__ */ jsx("span", {
|
|
1653
|
+
className: "wa-composer__hint",
|
|
1654
|
+
children: "Al enviar, el bot se pausa 2 h y la conversación queda tomada por ti"
|
|
1655
|
+
}),
|
|
1656
|
+
/* @__PURE__ */ jsxs("span", {
|
|
1657
|
+
className: "wa-composer__counter",
|
|
1658
|
+
children: [
|
|
1659
|
+
draft.length,
|
|
1660
|
+
"/",
|
|
1661
|
+
REPLY_TEXT_MAX_LENGTH
|
|
1662
|
+
]
|
|
1663
|
+
}),
|
|
1664
|
+
/* @__PURE__ */ jsx("button", {
|
|
1665
|
+
type: "submit",
|
|
1666
|
+
className: "wa-composer__send",
|
|
1667
|
+
disabled: draft.trim() === "",
|
|
1668
|
+
children: "Enviar"
|
|
1669
|
+
})
|
|
1670
|
+
]
|
|
1275
1671
|
})]
|
|
1276
1672
|
})
|
|
1277
1673
|
]
|
|
@@ -1428,6 +1824,26 @@ function MediaUnavailable() {
|
|
|
1428
1824
|
children: "Adjunto no disponible"
|
|
1429
1825
|
});
|
|
1430
1826
|
}
|
|
1827
|
+
/** El icono de descarga (DEV-5053 / P6): flecha a bandeja, hereda color. La semántica la lleva
|
|
1828
|
+
* el anchor con su aria-label. */
|
|
1829
|
+
function DownloadGlyph() {
|
|
1830
|
+
return /* @__PURE__ */ jsxs("svg", {
|
|
1831
|
+
width: 16,
|
|
1832
|
+
height: 16,
|
|
1833
|
+
viewBox: "0 0 16 16",
|
|
1834
|
+
fill: "none",
|
|
1835
|
+
stroke: "currentColor",
|
|
1836
|
+
strokeWidth: 1.5,
|
|
1837
|
+
strokeLinecap: "round",
|
|
1838
|
+
strokeLinejoin: "round",
|
|
1839
|
+
"aria-hidden": "true",
|
|
1840
|
+
children: [
|
|
1841
|
+
/* @__PURE__ */ jsx("path", { d: "M8 2.5v7.5" }),
|
|
1842
|
+
/* @__PURE__ */ jsx("polyline", { points: "4.5,6.8 8,10.3 11.5,6.8" }),
|
|
1843
|
+
/* @__PURE__ */ jsx("path", { d: "M2.5 13.5h11" })
|
|
1844
|
+
]
|
|
1845
|
+
});
|
|
1846
|
+
}
|
|
1431
1847
|
/**
|
|
1432
1848
|
* Rama image: carga perezosa (no bloquea el render del hilo), miniatura clicable y lightbox
|
|
1433
1849
|
* propio, sin dependencias nuevas. Primer intento: la `media_url` del mensaje si viene; si es
|
|
@@ -1503,36 +1919,56 @@ function ImageAttachment({ message, fetcher, mediaId }) {
|
|
|
1503
1919
|
});
|
|
1504
1920
|
if (state.kind === "unavailable") return /* @__PURE__ */ jsx(MediaUnavailable, {});
|
|
1505
1921
|
const alt = attachmentLabel(message, "Imagen adjunta");
|
|
1506
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1922
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
1923
|
+
/* @__PURE__ */ jsx("button", {
|
|
1924
|
+
type: "button",
|
|
1925
|
+
className: "wa-thread__media-button",
|
|
1926
|
+
onClick: () => setOpen(true),
|
|
1927
|
+
"aria-label": "Ampliar imagen adjunta",
|
|
1928
|
+
children: /* @__PURE__ */ jsx("img", {
|
|
1929
|
+
className: "wa-thread__media-img",
|
|
1930
|
+
src: state.url,
|
|
1931
|
+
alt,
|
|
1932
|
+
onError: handleImageError
|
|
1933
|
+
})
|
|
1934
|
+
}),
|
|
1935
|
+
/* @__PURE__ */ jsxs("div", {
|
|
1936
|
+
className: "wa-thread__media-file",
|
|
1937
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
1938
|
+
className: "wa-thread__media-name",
|
|
1939
|
+
children: attachmentLabel(message, "Imagen adjunta")
|
|
1940
|
+
}), /* @__PURE__ */ jsx(DownloadAttachment, {
|
|
1941
|
+
message,
|
|
1942
|
+
fetcher,
|
|
1943
|
+
mediaId,
|
|
1944
|
+
variant: "icon"
|
|
1945
|
+
})]
|
|
1946
|
+
}),
|
|
1947
|
+
open && /* @__PURE__ */ jsx("div", {
|
|
1948
|
+
className: "wa-thread__lightbox",
|
|
1949
|
+
role: "dialog",
|
|
1950
|
+
"aria-label": "Imagen ampliada",
|
|
1951
|
+
onClick: () => setOpen(false),
|
|
1952
|
+
children: /* @__PURE__ */ jsx("img", {
|
|
1953
|
+
className: "wa-thread__lightbox-img",
|
|
1954
|
+
src: state.url,
|
|
1955
|
+
alt
|
|
1956
|
+
})
|
|
1526
1957
|
})
|
|
1527
|
-
|
|
1958
|
+
] });
|
|
1528
1959
|
}
|
|
1529
1960
|
/**
|
|
1530
1961
|
* Rama descarga ('pdf' y 'other'): un solo `<a>` plano. La url se resuelve AL MOMENTO del clic —
|
|
1531
1962
|
* así nunca está vencida; un anchor no puede detectar una firma expirada, y por eso acá no aplica
|
|
1532
1963
|
* el primer intento con `media_url`. El onClick intercepta, resuelve, setea el href y re-dispara
|
|
1533
1964
|
* el clic programático (el guard deja pasar esa segunda pasada hacia la navegación real).
|
|
1965
|
+
*
|
|
1966
|
+
* `variant` (DEV-5053 / P6): `'label'` es el comportamiento de siempre (el file_name como texto
|
|
1967
|
+
* del link); `'icon'` es el MISMO anchor —misma resolución al clic, mismo blindaje T-05-03,
|
|
1968
|
+
* mismo 404 terminal— pero con un SVG de descarga adentro y el nombre en el `aria-label`. Lo usa
|
|
1969
|
+
* la fila de archivo de la imagen.
|
|
1534
1970
|
*/
|
|
1535
|
-
function DownloadAttachment({ message, fetcher, mediaId }) {
|
|
1971
|
+
function DownloadAttachment({ message, fetcher, mediaId, variant = "label" }) {
|
|
1536
1972
|
const [unavailable, setUnavailable] = useState(false);
|
|
1537
1973
|
const anchorRef = useRef(null);
|
|
1538
1974
|
/** true sólo durante el clic programático post-resolución: esa pasada navega, no re-resuelve. */
|
|
@@ -1565,6 +2001,17 @@ function DownloadAttachment({ message, fetcher, mediaId }) {
|
|
|
1565
2001
|
});
|
|
1566
2002
|
};
|
|
1567
2003
|
if (unavailable) return /* @__PURE__ */ jsx(MediaUnavailable, {});
|
|
2004
|
+
if (variant === "icon") return /* @__PURE__ */ jsx("a", {
|
|
2005
|
+
ref: anchorRef,
|
|
2006
|
+
className: "wa-thread__media-download wa-thread__media-download--icon",
|
|
2007
|
+
href: "#",
|
|
2008
|
+
download: true,
|
|
2009
|
+
target: "_blank",
|
|
2010
|
+
rel: "noopener noreferrer",
|
|
2011
|
+
onClick: handleClick,
|
|
2012
|
+
"aria-label": `Descargar ${typeof message.file_name === "string" && message.file_name !== "" ? message.file_name : "adjunto"}`,
|
|
2013
|
+
children: /* @__PURE__ */ jsx(DownloadGlyph, {})
|
|
2014
|
+
});
|
|
1568
2015
|
return /* @__PURE__ */ jsx("a", {
|
|
1569
2016
|
ref: anchorRef,
|
|
1570
2017
|
className: "wa-thread__media-download",
|
|
@@ -1604,34 +2051,113 @@ function MediaAttachment({ message, fetcher }) {
|
|
|
1604
2051
|
});
|
|
1605
2052
|
}
|
|
1606
2053
|
//#endregion
|
|
2054
|
+
//#region src/core/thread/failure-reason-labels.ts
|
|
2055
|
+
/**
|
|
2056
|
+
* Los motivos de fallo de Meta en español (DEV-5065). Interno del hilo — NO sale al barrel.
|
|
2057
|
+
*
|
|
2058
|
+
* Por qué existe: un tick rojo que sólo dice «No entregado» no le sirve al operador. Los tres
|
|
2059
|
+
* motivos frecuentes se resuelven de forma **distinta** —número inválido (el dato está mal),
|
|
2060
|
+
* ventana de 24 h cerrada (hay que mandar plantilla) y plantilla rechazada (hay que arreglar la
|
|
2061
|
+
* plantilla)— y sin el motivo los tres se ven idénticos. Por eso las etiquetas dicen QUÉ HACER y
|
|
2062
|
+
* no sólo qué pasó: «El número no recibe WhatsApp» es accionable, «Message undeliverable» no.
|
|
2063
|
+
*
|
|
2064
|
+
* ⚠️ **FALLBACK VERBATIM**, la misma regla de seguridad que `service-state-labels.ts`: un código
|
|
2065
|
+
* que no esté en la tabla cae al `error_title` que mandó Meta, EXACTAMENTE como llegó. Meta agrega
|
|
2066
|
+
* y renombra códigos sin avisar, y mostrar el texto crudo siempre es mejor que ocultarlo o
|
|
2067
|
+
* adivinarlo. Si tampoco hay título, no se pinta nada: el «No entregado» ya está.
|
|
2068
|
+
*
|
|
2069
|
+
* ⚠️ La tabla es CONSERVADORA a propósito: sólo códigos de entrega documentados por la Cloud API
|
|
2070
|
+
* de Meta. Ante la duda, no se agrega la entrada — el fallback verbatim ya cubre el caso, y una
|
|
2071
|
+
* traducción equivocada es peor que el texto original en inglés porque el operador no puede
|
|
2072
|
+
* sospecharla. Conviene revisarla contra los `failed` reales que aparezcan en QA.
|
|
2073
|
+
*
|
|
2074
|
+
* ⚠️ La etiqueta entra SOLO como hijo de texto, que React escapa: jamás en className, style o
|
|
2075
|
+
* selector (T-03-02). El `error_title` lo origina un tercero.
|
|
2076
|
+
*/
|
|
2077
|
+
/**
|
|
2078
|
+
* La tabla es-CO, indexada por el código numérico de Meta. Se consulta SÓLO por clave propia:
|
|
2079
|
+
* nada del prototipo puede colarse (un `error_code` es un número, pero la lectura pasa por
|
|
2080
|
+
* `hasOwnProperty` igual — la disciplina no se relaja según el tipo).
|
|
2081
|
+
*/
|
|
2082
|
+
const FAILURE_REASON_LABELS = {
|
|
2083
|
+
131047: "Pasaron más de 24 h sin respuesta: hay que enviar una plantilla",
|
|
2084
|
+
131026: "El número no puede recibir mensajes de WhatsApp",
|
|
2085
|
+
131049: "Meta no lo entregó para cuidar la experiencia del usuario",
|
|
2086
|
+
131e3: "Error interno de Meta",
|
|
2087
|
+
131008: "Falta un parámetro obligatorio en el envío",
|
|
2088
|
+
131031: "La cuenta de WhatsApp está bloqueada",
|
|
2089
|
+
131042: "Problema de facturación en la cuenta de WhatsApp",
|
|
2090
|
+
131051: "Tipo de mensaje no soportado",
|
|
2091
|
+
132e3: "La plantilla no coincide con la cantidad de parámetros enviados",
|
|
2092
|
+
132001: "La plantilla no existe o no está aprobada para este idioma",
|
|
2093
|
+
132005: "El texto de la plantilla quedó demasiado largo",
|
|
2094
|
+
132007: "La plantilla viola la política de formato",
|
|
2095
|
+
132012: "Un parámetro de la plantilla no tiene el formato esperado",
|
|
2096
|
+
132015: "La plantilla está pausada por baja calidad",
|
|
2097
|
+
132016: "La plantilla está deshabilitada"
|
|
2098
|
+
};
|
|
2099
|
+
/**
|
|
2100
|
+
* El motivo humano de un `failed`, o `null` si no hay nada que decir.
|
|
2101
|
+
*
|
|
2102
|
+
* Precedencia: la tabla por código, después el `error_title` VERBATIM, después nada. Un título
|
|
2103
|
+
* que llega vacío o en blanco cuenta como nada — pintar una línea vacía debajo de «No entregado»
|
|
2104
|
+
* es peor que no pintarla.
|
|
2105
|
+
*/
|
|
2106
|
+
function failureReasonLabel(code, title) {
|
|
2107
|
+
if (typeof code === "number" && Object.prototype.hasOwnProperty.call(FAILURE_REASON_LABELS, code)) return FAILURE_REASON_LABELS[code];
|
|
2108
|
+
const verbatim = typeof title === "string" ? title.trim() : "";
|
|
2109
|
+
return verbatim === "" ? null : verbatim;
|
|
2110
|
+
}
|
|
2111
|
+
//#endregion
|
|
1607
2112
|
//#region src/core/thread/MessageBubble.tsx
|
|
1608
2113
|
/**
|
|
1609
2114
|
* El tick de una saliente. El vocabulario conocido y nada más: lo desconocido devuelve `null` y la
|
|
1610
2115
|
* burbuja simplemente no lleva tick (enum abierto — un status nuevo del cable no rompe el render).
|
|
1611
|
-
* `read` usa el MISMO
|
|
1612
|
-
* de estado, no tema del host.
|
|
2116
|
+
* `read` usa el MISMO check doble que `delivered` y se distingue por color vía `data-status`: es
|
|
2117
|
+
* semántica de estado, no tema del host.
|
|
1613
2118
|
*/
|
|
1614
2119
|
function tickFor(status) {
|
|
1615
2120
|
switch (status) {
|
|
1616
2121
|
case "pending": return {
|
|
1617
|
-
|
|
2122
|
+
kind: "clock",
|
|
1618
2123
|
label: "Pendiente"
|
|
1619
2124
|
};
|
|
1620
2125
|
case "sent": return {
|
|
1621
|
-
|
|
2126
|
+
kind: "check",
|
|
1622
2127
|
label: "Enviado"
|
|
1623
2128
|
};
|
|
1624
2129
|
case "delivered": return {
|
|
1625
|
-
|
|
2130
|
+
kind: "check-check",
|
|
1626
2131
|
label: "Entregado"
|
|
1627
2132
|
};
|
|
1628
2133
|
case "read": return {
|
|
1629
|
-
|
|
2134
|
+
kind: "check-check",
|
|
1630
2135
|
label: "Leído"
|
|
1631
2136
|
};
|
|
1632
2137
|
default: return null;
|
|
1633
2138
|
}
|
|
1634
2139
|
}
|
|
2140
|
+
/**
|
|
2141
|
+
* El glifo del tick (DEV-5053 / P5). `clock` sigue siendo texto («◷»); los checks son SVG inline
|
|
2142
|
+
* con `stroke="currentColor"`: heredan el gris del meta y el azul de `[data-status='read']` del
|
|
2143
|
+
* CSS — la distinción de color por data-status queda exactamente como antes. `aria-hidden`: la
|
|
2144
|
+
* semántica ya la lleva el span envolvente con su aria-label.
|
|
2145
|
+
*/
|
|
2146
|
+
function TickGlyph({ kind }) {
|
|
2147
|
+
if (kind === "clock") return /* @__PURE__ */ jsx(Fragment$1, { children: "◷" });
|
|
2148
|
+
return /* @__PURE__ */ jsxs("svg", {
|
|
2149
|
+
width: 16,
|
|
2150
|
+
height: 16,
|
|
2151
|
+
viewBox: "0 0 16 16",
|
|
2152
|
+
fill: "none",
|
|
2153
|
+
stroke: "currentColor",
|
|
2154
|
+
strokeWidth: 1.8,
|
|
2155
|
+
strokeLinecap: "round",
|
|
2156
|
+
strokeLinejoin: "round",
|
|
2157
|
+
"aria-hidden": "true",
|
|
2158
|
+
children: [/* @__PURE__ */ jsx("polyline", { points: "2.5,8.5 6,12 13,4.5" }), kind === "check-check" && /* @__PURE__ */ jsx("polyline", { points: "7,10.2 8.7,12 15.3,4.8" })]
|
|
2159
|
+
});
|
|
2160
|
+
}
|
|
1635
2161
|
/** La hora HH:MM local de la burbuja (DEC-O). `null` si el instante no existe o no parsea. */
|
|
1636
2162
|
function formatHour(at) {
|
|
1637
2163
|
if (typeof at !== "string") return null;
|
|
@@ -1639,12 +2165,13 @@ function formatHour(at) {
|
|
|
1639
2165
|
if (Number.isNaN(date.getTime())) return null;
|
|
1640
2166
|
return `${String(date.getHours()).padStart(2, "0")}:${String(date.getMinutes()).padStart(2, "0")}`;
|
|
1641
2167
|
}
|
|
1642
|
-
function MessageBubble({ message,
|
|
2168
|
+
function MessageBubble({ message, optimistic = false, fetcher }) {
|
|
1643
2169
|
const direction = message.direction === "out" ? "out" : "in";
|
|
1644
2170
|
const hour = formatHour(message.at);
|
|
1645
2171
|
const ctas = threadCtas(message);
|
|
1646
2172
|
const tick = direction === "out" ? tickFor(message.status) : null;
|
|
1647
2173
|
const failed = direction === "out" && message.status === "failed";
|
|
2174
|
+
const failureReason = failed ? failureReasonLabel(message.error_code, message.error_title) : null;
|
|
1648
2175
|
const author = typeof message.sent_by_name === "string" && message.sent_by_name.trim() !== "" ? message.sent_by_name : null;
|
|
1649
2176
|
/**
|
|
1650
2177
|
* COMP-03: quién habló, de un golpe. Una saliente **con** `sent_by_name` la escribió una persona;
|
|
@@ -1656,7 +2183,6 @@ function MessageBubble({ message, showServiceState, optimistic = false, fetcher
|
|
|
1656
2183
|
* definición: la acaba de escribir él.
|
|
1657
2184
|
*/
|
|
1658
2185
|
const authorKind = direction === "out" ? author !== null || optimistic ? "operator" : "bot" : void 0;
|
|
1659
|
-
const serviceState = showServiceState && typeof message.service_state === "string" && message.service_state !== "" ? message.service_state : null;
|
|
1660
2186
|
const locationFallback = message.body === null && message.message_type === "location" ? message.location_name ?? "Ubicación compartida" : null;
|
|
1661
2187
|
return /* @__PURE__ */ jsxs("div", {
|
|
1662
2188
|
className: "wa-thread__bubble",
|
|
@@ -1668,11 +2194,6 @@ function MessageBubble({ message, showServiceState, optimistic = false, fetcher
|
|
|
1668
2194
|
className: "wa-thread__author",
|
|
1669
2195
|
children: author
|
|
1670
2196
|
}),
|
|
1671
|
-
serviceState !== null && /* @__PURE__ */ jsx("span", {
|
|
1672
|
-
className: "wa-thread__state",
|
|
1673
|
-
title: serviceState,
|
|
1674
|
-
children: serviceState
|
|
1675
|
-
}),
|
|
1676
2197
|
message.body !== null && /* @__PURE__ */ jsx("p", {
|
|
1677
2198
|
className: "wa-thread__body",
|
|
1678
2199
|
children: message.body
|
|
@@ -1705,21 +2226,54 @@ function MessageBubble({ message, showServiceState, optimistic = false, fetcher
|
|
|
1705
2226
|
dateTime: message.at,
|
|
1706
2227
|
title: message.at,
|
|
1707
2228
|
children: hour
|
|
1708
|
-
}), failed ? /* @__PURE__ */
|
|
2229
|
+
}), failed ? /* @__PURE__ */ jsxs("span", {
|
|
1709
2230
|
className: "wa-thread__failed",
|
|
1710
|
-
children: "No entregado"
|
|
2231
|
+
children: ["No entregado", failureReason !== null && /* @__PURE__ */ jsxs("span", {
|
|
2232
|
+
className: "wa-thread__failed-reason",
|
|
2233
|
+
children: [" · ", failureReason]
|
|
2234
|
+
})]
|
|
1711
2235
|
}) : tick !== null && /* @__PURE__ */ jsx("span", {
|
|
1712
2236
|
className: "wa-thread__tick",
|
|
1713
2237
|
"data-status": message.status,
|
|
1714
2238
|
title: tick.label,
|
|
1715
2239
|
"aria-label": tick.label,
|
|
1716
|
-
children: tick.
|
|
2240
|
+
children: /* @__PURE__ */ jsx(TickGlyph, { kind: tick.kind })
|
|
1717
2241
|
})]
|
|
1718
2242
|
})
|
|
1719
2243
|
]
|
|
1720
2244
|
});
|
|
1721
2245
|
}
|
|
1722
2246
|
//#endregion
|
|
2247
|
+
//#region src/core/thread/service-state-labels.ts
|
|
2248
|
+
/**
|
|
2249
|
+
* Las etiquetas humanas de `service_state` para el HILO (DEV-5053 / P3). Interno del hilo —
|
|
2250
|
+
* NO sale al barrel.
|
|
2251
|
+
*
|
|
2252
|
+
* Este módulo supersede, SÓLO para el hilo, la regla «verbatim, mapeo prohibido» de THREAD-04/C-01:
|
|
2253
|
+
* DEV-5053 autorizó humanizar el paso del flujo en la píldora de transición y en el chip «Paso»
|
|
2254
|
+
* del header. La fila de la lista (`ConversationRow`) NO cambia: sigue pintando el valor crudo.
|
|
2255
|
+
*
|
|
2256
|
+
* La regla de seguridad del módulo es el FALLBACK VERBATIM: un valor sin entrada en la tabla se
|
|
2257
|
+
* devuelve EXACTAMENTE como llegó — un emisor que estrene un paso nuevo se lee crudo, nunca se
|
|
2258
|
+
* oculta ni se adivina. Y la etiqueta (humanizada o cruda) entra SOLO como hijo de texto, que
|
|
2259
|
+
* React escapa: jamás en className/style/selector (T-03-02 sigue vigente).
|
|
2260
|
+
*
|
|
2261
|
+
* Vocabulario inicial: el del fixture `contract/thread-v0.fixture.json` y el docstring de
|
|
2262
|
+
* `types.ts` — todos emitidos por `self_onboarding_whatsapp`.
|
|
2263
|
+
*/
|
|
2264
|
+
/** La tabla es-CO. Se consulta SOLO por clave propia: nada del prototipo puede colarse. */
|
|
2265
|
+
const SERVICE_STATE_LABELS = {
|
|
2266
|
+
collecting_vehicle_plate: "Placa del vehículo",
|
|
2267
|
+
collecting_vehicle_documents: "Documentos del vehículo",
|
|
2268
|
+
collecting_documents: "Documentos personales",
|
|
2269
|
+
existing_user_menu: "Menú de usuario registrado",
|
|
2270
|
+
activated: "Cuenta activada"
|
|
2271
|
+
};
|
|
2272
|
+
/** La etiqueta humana de un `service_state`, o el valor crudo VERBATIM si no hay entrada. */
|
|
2273
|
+
function serviceStateLabel(value) {
|
|
2274
|
+
return Object.prototype.hasOwnProperty.call(SERVICE_STATE_LABELS, value) ? SERVICE_STATE_LABELS[value] : value;
|
|
2275
|
+
}
|
|
2276
|
+
//#endregion
|
|
1723
2277
|
//#region src/core/thread/thread-styles.ts
|
|
1724
2278
|
/**
|
|
1725
2279
|
* El CSS del hilo, como string, para que viaje DENTRO del componente — mismas razones que
|
|
@@ -1730,8 +2284,11 @@ function MessageBubble({ message, showServiceState, optimistic = false, fetcher
|
|
|
1730
2284
|
*
|
|
1731
2285
|
* - 🔴 **Todos los selectores van prefijados con `.wa-thread`.** En el entry `./react` NO hay
|
|
1732
2286
|
* shadow DOM: un selector de elemento suelto le pisaría los estilos al host.
|
|
1733
|
-
* - **Sin tokens del LMS, sin variables, sin `@import`, sin fuentes remotas** (C-04).
|
|
1734
|
-
*
|
|
2287
|
+
* - **Sin tokens del LMS, sin variables, sin `@import`, sin fuentes remotas** (C-04). El paquete
|
|
2288
|
+
* monta en tres hosts con temas distintos. La paleta de acá (índigo #4F5AED/#EEF1FE, ámbar,
|
|
2289
|
+
* grises #F4F5F7/#E4E7EE) NO es un tema inventado: viene del diseño aprobado de DEV-5053
|
|
2290
|
+
* (.pen), y sigue sin depender de tokens del host. `Inter` va sólo como primer nombre del font
|
|
2291
|
+
* stack — si el host la carga se usa, si no cae a system-ui.
|
|
1735
2292
|
* - **El scroll del hilo VIVE en `.wa-thread__messages`** (`overflow-y: auto` + `min-height: 0`):
|
|
1736
2293
|
* es el contenedor que la paginación hacia atrás ancla en la Task 3 — moverlo de lugar rompe la
|
|
1737
2294
|
* compensación de `scrollTop`.
|
|
@@ -1743,11 +2300,11 @@ const THREAD_CSS = `
|
|
|
1743
2300
|
min-height: 0;
|
|
1744
2301
|
flex: 1 1 auto;
|
|
1745
2302
|
flex-direction: column;
|
|
1746
|
-
font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
|
|
2303
|
+
font-family: Inter, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
|
|
1747
2304
|
font-size: 14px;
|
|
1748
2305
|
line-height: 1.5;
|
|
1749
|
-
color: #
|
|
1750
|
-
background: #
|
|
2306
|
+
color: #2D3340;
|
|
2307
|
+
background: #F7F6F2;
|
|
1751
2308
|
}
|
|
1752
2309
|
.wa-thread *,
|
|
1753
2310
|
.wa-thread *::before,
|
|
@@ -1761,8 +2318,8 @@ const THREAD_CSS = `
|
|
|
1761
2318
|
flex: 1 1 auto;
|
|
1762
2319
|
min-height: 0;
|
|
1763
2320
|
flex-direction: column;
|
|
1764
|
-
gap:
|
|
1765
|
-
padding:
|
|
2321
|
+
gap: 10px;
|
|
2322
|
+
padding: 14px;
|
|
1766
2323
|
overflow-y: auto;
|
|
1767
2324
|
}
|
|
1768
2325
|
|
|
@@ -1791,56 +2348,60 @@ const THREAD_CSS = `
|
|
|
1791
2348
|
.wa-thread__group {
|
|
1792
2349
|
display: flex;
|
|
1793
2350
|
flex-direction: column;
|
|
1794
|
-
gap:
|
|
2351
|
+
gap: 10px;
|
|
1795
2352
|
}
|
|
1796
2353
|
|
|
1797
|
-
/* Separador de día:
|
|
2354
|
+
/* Separador de día: una pill discreta y centrada (diseño .pen de DEV-5053). */
|
|
1798
2355
|
.wa-thread__day {
|
|
1799
2356
|
align-self: center;
|
|
1800
|
-
margin:
|
|
1801
|
-
padding:
|
|
1802
|
-
border-radius:
|
|
1803
|
-
font-size:
|
|
1804
|
-
|
|
1805
|
-
|
|
2357
|
+
margin: 4px 0;
|
|
2358
|
+
padding: 3px 10px;
|
|
2359
|
+
border-radius: 999px;
|
|
2360
|
+
font-size: 10.5px;
|
|
2361
|
+
font-weight: 600;
|
|
2362
|
+
color: #6B7280;
|
|
2363
|
+
background: #ECEDF1;
|
|
1806
2364
|
}
|
|
1807
2365
|
|
|
2366
|
+
/* El ancho sigue siendo relativo (75%) y no los 300px fijos del frame: el visor monta en tres
|
|
2367
|
+
hosts de ancho distinto y un ancho fijo rompe el modo angosto. */
|
|
1808
2368
|
.wa-thread__bubble {
|
|
1809
2369
|
display: flex;
|
|
1810
2370
|
max-width: 75%;
|
|
1811
2371
|
flex-direction: column;
|
|
1812
|
-
gap:
|
|
1813
|
-
padding:
|
|
1814
|
-
border-radius:
|
|
2372
|
+
gap: 4px;
|
|
2373
|
+
padding: 8px 10px;
|
|
2374
|
+
border-radius: 10px;
|
|
1815
2375
|
overflow-wrap: anywhere;
|
|
1816
2376
|
}
|
|
1817
|
-
/* Entrante: a la izquierda,
|
|
2377
|
+
/* Entrante: a la izquierda, blanca. Lo desconocido cae acá (enums abiertos). */
|
|
1818
2378
|
.wa-thread__bubble[data-direction='in'] {
|
|
1819
2379
|
align-self: flex-start;
|
|
1820
2380
|
background: #ffffff;
|
|
1821
|
-
border: 1px solid #
|
|
2381
|
+
border: 1px solid #EBEDF1;
|
|
1822
2382
|
}
|
|
1823
|
-
/* Saliente: a la derecha,
|
|
2383
|
+
/* Saliente: a la derecha, el verde del diseño. */
|
|
1824
2384
|
.wa-thread__bubble[data-direction='out'] {
|
|
1825
2385
|
align-self: flex-end;
|
|
1826
|
-
background: #
|
|
1827
|
-
border: 1px solid #
|
|
1828
|
-
}
|
|
1829
|
-
/* COMP-03
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
2386
|
+
background: #E9F6EC;
|
|
2387
|
+
border: 1px solid #DDEEE2;
|
|
2388
|
+
}
|
|
2389
|
+
/* COMP-03 reconciliado con el diseño (D-01): el verde de arriba es el de TODA saliente — el
|
|
2390
|
+
diseño sólo modela mensajes del bot, así que no trae un color para el humano. Lo que distingue
|
|
2391
|
+
a la persona es el acento índigo del borde izquierdo (el mismo acento de los avatares y del CTA
|
|
2392
|
+
navegable), que se ve de un golpe y sobrevive a que la línea del nombre se scrollee. Un relleno
|
|
2393
|
+
propio quedaría inventado y chocaría con la píldora de flujo, que ya usa ese par. */
|
|
1833
2394
|
.wa-thread__bubble[data-direction='out'][data-author='operator'] {
|
|
1834
|
-
|
|
1835
|
-
border-color: #bfe0c8;
|
|
1836
|
-
border-left: 3px solid #2e7d47;
|
|
2395
|
+
border-left: 3px solid #4E5BEF;
|
|
1837
2396
|
}
|
|
1838
2397
|
.wa-thread__bubble[data-direction='out'][data-author='operator'] .wa-thread__author {
|
|
1839
|
-
color: #
|
|
2398
|
+
color: #4E5BEF;
|
|
1840
2399
|
}
|
|
1841
2400
|
|
|
1842
2401
|
.wa-thread__body {
|
|
1843
2402
|
margin: 0;
|
|
2403
|
+
font-size: 13px;
|
|
2404
|
+
color: #2D3340;
|
|
1844
2405
|
white-space: pre-wrap;
|
|
1845
2406
|
}
|
|
1846
2407
|
|
|
@@ -1848,18 +2409,24 @@ const THREAD_CSS = `
|
|
|
1848
2409
|
.wa-thread__meta {
|
|
1849
2410
|
display: flex;
|
|
1850
2411
|
align-self: flex-end;
|
|
1851
|
-
align-items:
|
|
2412
|
+
align-items: center;
|
|
2413
|
+
justify-content: flex-end;
|
|
1852
2414
|
gap: 4px;
|
|
1853
|
-
font-size:
|
|
1854
|
-
color: #
|
|
2415
|
+
font-size: 10.5px;
|
|
2416
|
+
color: #9AA1AE;
|
|
1855
2417
|
}
|
|
1856
2418
|
.wa-thread__hour {
|
|
1857
|
-
font-size:
|
|
1858
|
-
color: #
|
|
2419
|
+
font-size: 10.5px;
|
|
2420
|
+
color: #9AA1AE;
|
|
1859
2421
|
}
|
|
1860
2422
|
.wa-thread__tick {
|
|
2423
|
+
display: inline-flex;
|
|
2424
|
+
align-items: center;
|
|
1861
2425
|
letter-spacing: -0.12em;
|
|
1862
2426
|
}
|
|
2427
|
+
.wa-thread__tick svg {
|
|
2428
|
+
display: block;
|
|
2429
|
+
}
|
|
1863
2430
|
/* \`read\` se distingue por color: un azul genérico — semántica de estado, no tema del host. */
|
|
1864
2431
|
.wa-thread__tick[data-status='read'] {
|
|
1865
2432
|
color: #2f6fde;
|
|
@@ -1873,6 +2440,52 @@ const THREAD_CSS = `
|
|
|
1873
2440
|
border-color: #e5b9b6;
|
|
1874
2441
|
background: #fdf6f6;
|
|
1875
2442
|
}
|
|
2443
|
+
/* DEV-5065: el motivo, dentro del mismo bloque rojo que «No entregado». Peso normal para que la
|
|
2444
|
+
jerarquía se lea —el titular manda, el motivo explica— y sin ancho fijo: los textos crudos de
|
|
2445
|
+
Meta que caen por el fallback verbatim pueden ser largos y tienen que poder envolver. */
|
|
2446
|
+
.wa-thread__failed-reason {
|
|
2447
|
+
font-weight: 400;
|
|
2448
|
+
}
|
|
2449
|
+
|
|
2450
|
+
/* DEV-5061 — la barra de takeover, entre el header y el scroller. Ámbar cuando la tiene otro
|
|
2451
|
+
(es un aviso: no escribas encima) y añil cuando es tuya (es tu control, con su acción). Los
|
|
2452
|
+
dos tonos son los de la paleta que fijó DEV-5053. */
|
|
2453
|
+
.wa-thread__takeover {
|
|
2454
|
+
display: flex;
|
|
2455
|
+
align-items: center;
|
|
2456
|
+
justify-content: space-between;
|
|
2457
|
+
gap: 12px;
|
|
2458
|
+
flex-wrap: wrap;
|
|
2459
|
+
padding: 8px 12px;
|
|
2460
|
+
border-bottom: 1px solid #e4e7ee;
|
|
2461
|
+
background: #fff7e8;
|
|
2462
|
+
color: #b7791f;
|
|
2463
|
+
font-size: 13px;
|
|
2464
|
+
}
|
|
2465
|
+
.wa-thread__takeover[data-mine='true'] {
|
|
2466
|
+
background: #f4f5ff;
|
|
2467
|
+
color: #4f5aed;
|
|
2468
|
+
}
|
|
2469
|
+
.wa-thread__takeover-text {
|
|
2470
|
+
min-width: 0;
|
|
2471
|
+
}
|
|
2472
|
+
/* Pill, el mismo molde que el Reintentar de DEV-5053 P7. \`currentColor\` es lo que hace que el
|
|
2473
|
+
botón siga al tono de la barra sin duplicar la regla por variante. */
|
|
2474
|
+
.wa-thread__takeover-button {
|
|
2475
|
+
flex: none;
|
|
2476
|
+
padding: 4px 12px;
|
|
2477
|
+
border: 1px solid currentColor;
|
|
2478
|
+
border-radius: 999px;
|
|
2479
|
+
background: #fff;
|
|
2480
|
+
color: inherit;
|
|
2481
|
+
font: inherit;
|
|
2482
|
+
font-weight: 600;
|
|
2483
|
+
cursor: pointer;
|
|
2484
|
+
}
|
|
2485
|
+
.wa-thread__takeover-button:disabled {
|
|
2486
|
+
opacity: 0.6;
|
|
2487
|
+
cursor: default;
|
|
2488
|
+
}
|
|
1876
2489
|
|
|
1877
2490
|
/* El operador que escribió la saliente, sobre la burbuja. */
|
|
1878
2491
|
.wa-thread__author {
|
|
@@ -1881,13 +2494,88 @@ const THREAD_CSS = `
|
|
|
1881
2494
|
color: #52606d;
|
|
1882
2495
|
}
|
|
1883
2496
|
|
|
1884
|
-
/*
|
|
1885
|
-
|
|
1886
|
-
.wa-
|
|
1887
|
-
align-self:
|
|
2497
|
+
/* La píldora de flujo (DEV-5053 / P4): centrada, pinta la TRANSICIÓN de service_state con la
|
|
2498
|
+
etiqueta humanizada. El valor jamás se interpola en un selector ni en una clase (THREAD-04). */
|
|
2499
|
+
.wa-thread__flow-pill {
|
|
2500
|
+
align-self: center;
|
|
2501
|
+
margin: 2px 0;
|
|
2502
|
+
padding: 3px 10px;
|
|
2503
|
+
border-radius: 999px;
|
|
2504
|
+
font-size: 10.5px;
|
|
2505
|
+
font-weight: 600;
|
|
2506
|
+
color: #5B63C7;
|
|
2507
|
+
background: #EEF1FE;
|
|
2508
|
+
}
|
|
2509
|
+
|
|
2510
|
+
/* El header del hilo (DEV-5053): la identidad de la persona, SIEMPRE presente. Lo que aparece y
|
|
2511
|
+
desaparece con el flujo es la fila de chips, no el header. */
|
|
2512
|
+
.wa-thread__header {
|
|
2513
|
+
display: flex;
|
|
2514
|
+
flex: 0 0 auto;
|
|
2515
|
+
flex-direction: column;
|
|
2516
|
+
gap: 8px;
|
|
2517
|
+
padding: 14px 16px;
|
|
2518
|
+
border-bottom: 1px solid #EEF0F3;
|
|
2519
|
+
background: #ffffff;
|
|
2520
|
+
}
|
|
2521
|
+
.wa-thread__identity {
|
|
2522
|
+
display: flex;
|
|
2523
|
+
align-items: center;
|
|
2524
|
+
gap: 10px;
|
|
2525
|
+
}
|
|
2526
|
+
/* El avatar del header lleva el índigo SUAVE: el sólido está reservado a la fila seleccionada de
|
|
2527
|
+
la lista, que es donde significa "estás mirando ésta". */
|
|
2528
|
+
.wa-thread__avatar {
|
|
2529
|
+
display: flex;
|
|
2530
|
+
flex: 0 0 auto;
|
|
2531
|
+
align-items: center;
|
|
2532
|
+
justify-content: center;
|
|
2533
|
+
width: 36px;
|
|
2534
|
+
height: 36px;
|
|
2535
|
+
border-radius: 50%;
|
|
2536
|
+
font-size: 13px;
|
|
2537
|
+
font-weight: 700;
|
|
2538
|
+
color: #4E5BEF;
|
|
2539
|
+
background: #EEF1FE;
|
|
2540
|
+
}
|
|
2541
|
+
.wa-thread__who {
|
|
2542
|
+
display: flex;
|
|
2543
|
+
min-width: 0;
|
|
2544
|
+
flex: 1 1 auto;
|
|
2545
|
+
flex-direction: column;
|
|
2546
|
+
gap: 1px;
|
|
2547
|
+
}
|
|
2548
|
+
.wa-thread__name {
|
|
2549
|
+
overflow: hidden;
|
|
2550
|
+
font-size: 14px;
|
|
2551
|
+
font-weight: 700;
|
|
2552
|
+
color: #2D3340;
|
|
2553
|
+
text-overflow: ellipsis;
|
|
2554
|
+
white-space: nowrap;
|
|
2555
|
+
}
|
|
2556
|
+
/* Verbatim, E.164 con \`+\` (D-04): formatear exige lógica por país y un formateo equivocado
|
|
2557
|
+
mutila el dato con el que ops identifica personas. */
|
|
2558
|
+
.wa-thread__phone {
|
|
2559
|
+
overflow: hidden;
|
|
2560
|
+
font-size: 12px;
|
|
2561
|
+
color: #8A91A0;
|
|
2562
|
+
text-overflow: ellipsis;
|
|
2563
|
+
white-space: nowrap;
|
|
2564
|
+
}
|
|
2565
|
+
.wa-thread__chips {
|
|
2566
|
+
display: flex;
|
|
2567
|
+
flex-wrap: wrap;
|
|
2568
|
+
align-items: center;
|
|
2569
|
+
gap: 6px;
|
|
2570
|
+
}
|
|
2571
|
+
.wa-thread__step {
|
|
2572
|
+
display: inline-block;
|
|
2573
|
+
padding: 3px 8px;
|
|
2574
|
+
border-radius: 999px;
|
|
1888
2575
|
font-size: 11px;
|
|
1889
|
-
|
|
1890
|
-
|
|
2576
|
+
font-weight: 600;
|
|
2577
|
+
color: #6B7280;
|
|
2578
|
+
background: #F1F2F5;
|
|
1891
2579
|
}
|
|
1892
2580
|
|
|
1893
2581
|
/* El slot de media (DEV-4988): miniatura, link de descarga o el estado unavailable.
|
|
@@ -1932,6 +2620,28 @@ const THREAD_CSS = `
|
|
|
1932
2620
|
.wa-thread__media-download:hover {
|
|
1933
2621
|
text-decoration: underline;
|
|
1934
2622
|
}
|
|
2623
|
+
/* La fila de archivo bajo la miniatura (DEV-5053 / P6): nombre + icono de descarga, sin peso. */
|
|
2624
|
+
.wa-thread__media-file {
|
|
2625
|
+
display: flex;
|
|
2626
|
+
align-items: center;
|
|
2627
|
+
gap: 8px;
|
|
2628
|
+
padding-top: 4px;
|
|
2629
|
+
}
|
|
2630
|
+
.wa-thread__media-name {
|
|
2631
|
+
font-size: 12px;
|
|
2632
|
+
color: #52606d;
|
|
2633
|
+
word-break: break-word;
|
|
2634
|
+
}
|
|
2635
|
+
/* La variante icono del download: mismo anchor, cosmética de icono. */
|
|
2636
|
+
.wa-thread__media-download--icon {
|
|
2637
|
+
display: inline-flex;
|
|
2638
|
+
align-items: center;
|
|
2639
|
+
padding: 2px;
|
|
2640
|
+
border: none;
|
|
2641
|
+
color: #4F5AED;
|
|
2642
|
+
background: none;
|
|
2643
|
+
line-height: 0;
|
|
2644
|
+
}
|
|
1935
2645
|
.wa-thread__media-loading,
|
|
1936
2646
|
.wa-thread__media-unavailable {
|
|
1937
2647
|
font-size: 12px;
|
|
@@ -1955,28 +2665,36 @@ const THREAD_CSS = `
|
|
|
1955
2665
|
}
|
|
1956
2666
|
|
|
1957
2667
|
/* CTAs: los links y los inertes se pintan IGUAL de visibles — la diferencia es la navegabilidad,
|
|
1958
|
-
no la existencia (THREAD-03).
|
|
2668
|
+
no la existencia (THREAD-03). Sobre esa base, D-03 reparte los dos pills del diseño por el ÚNICO
|
|
2669
|
+
dato disponible: el índigo es el navegable (isCtaLink) y el gris el inerte. No hay campo en el
|
|
2670
|
+
contrato que diga cuál es "primario", y adivinarlo sería inventar jerarquía. */
|
|
1959
2671
|
.wa-thread__ctas {
|
|
1960
2672
|
display: flex;
|
|
1961
2673
|
flex-wrap: wrap;
|
|
1962
2674
|
gap: 6px;
|
|
1963
2675
|
}
|
|
1964
2676
|
.wa-thread__cta {
|
|
1965
|
-
padding:
|
|
1966
|
-
border: 1px solid #
|
|
1967
|
-
border-radius:
|
|
1968
|
-
font-size:
|
|
2677
|
+
padding: 4px 10px;
|
|
2678
|
+
border: 1px solid #E4E7EE;
|
|
2679
|
+
border-radius: 999px;
|
|
2680
|
+
font-size: 11.5px;
|
|
2681
|
+
font-weight: 600;
|
|
1969
2682
|
background: #ffffff;
|
|
1970
2683
|
}
|
|
1971
2684
|
.wa-thread__cta--link {
|
|
1972
|
-
color: #
|
|
2685
|
+
border-color: #C9D2F5;
|
|
2686
|
+
color: #4E5BEF;
|
|
1973
2687
|
text-decoration: none;
|
|
1974
2688
|
}
|
|
1975
2689
|
.wa-thread__cta--link:hover {
|
|
1976
2690
|
text-decoration: underline;
|
|
1977
2691
|
}
|
|
2692
|
+
/* El inerte NO tiene regla de hover y declara cursor: default a conciencia — un inerte que
|
|
2693
|
+
reacciona al puntero promete un clic que no existe. */
|
|
1978
2694
|
.wa-thread__cta--inert {
|
|
1979
|
-
color: #
|
|
2695
|
+
border-color: #E4E7EE;
|
|
2696
|
+
color: #6B7280;
|
|
2697
|
+
cursor: default;
|
|
1980
2698
|
}
|
|
1981
2699
|
|
|
1982
2700
|
.wa-thread__note {
|
|
@@ -2011,8 +2729,8 @@ const THREAD_CSS = `
|
|
|
2011
2729
|
flex: 0 0 auto;
|
|
2012
2730
|
flex-direction: column;
|
|
2013
2731
|
gap: 8px;
|
|
2014
|
-
padding: 10px
|
|
2015
|
-
border-top: 1px solid #
|
|
2732
|
+
padding: 10px 14px;
|
|
2733
|
+
border-top: 1px solid #EEF0F3;
|
|
2016
2734
|
background: #ffffff;
|
|
2017
2735
|
}
|
|
2018
2736
|
|
|
@@ -2022,40 +2740,49 @@ const THREAD_CSS = `
|
|
|
2022
2740
|
gap: 6px;
|
|
2023
2741
|
}
|
|
2024
2742
|
.wa-composer__input {
|
|
2025
|
-
padding:
|
|
2026
|
-
border: 1px solid #
|
|
2027
|
-
border-radius:
|
|
2743
|
+
padding: 9px 12px;
|
|
2744
|
+
border: 1px solid #E4E7EE;
|
|
2745
|
+
border-radius: 12px;
|
|
2028
2746
|
font: inherit;
|
|
2029
|
-
|
|
2030
|
-
|
|
2747
|
+
font-size: 13px;
|
|
2748
|
+
color: #2D3340;
|
|
2749
|
+
background: #F4F5F7;
|
|
2031
2750
|
resize: vertical;
|
|
2032
2751
|
}
|
|
2033
2752
|
.wa-composer__input:focus {
|
|
2034
|
-
border-color: #
|
|
2035
|
-
outline: 2px solid rgba(
|
|
2753
|
+
border-color: #4F5AED;
|
|
2754
|
+
outline: 2px solid rgba(79, 90, 237, 0.25);
|
|
2036
2755
|
outline-offset: 0;
|
|
2037
2756
|
}
|
|
2038
|
-
|
|
2757
|
+
/* DEV-5053 P2: hint del takeover a la izquierda; contador y Enviar a la derecha. */
|
|
2758
|
+
.wa-composer__hint-row {
|
|
2039
2759
|
display: flex;
|
|
2040
2760
|
align-items: center;
|
|
2041
|
-
justify-content:
|
|
2761
|
+
justify-content: space-between;
|
|
2042
2762
|
gap: 8px;
|
|
2043
2763
|
}
|
|
2764
|
+
.wa-composer__hint {
|
|
2765
|
+
margin-right: auto;
|
|
2766
|
+
font-size: 10.5px;
|
|
2767
|
+
color: #9AA1AE;
|
|
2768
|
+
}
|
|
2044
2769
|
.wa-composer__counter {
|
|
2045
|
-
|
|
2046
|
-
|
|
2770
|
+
flex: 0 0 auto;
|
|
2771
|
+
font-size: 10.5px;
|
|
2772
|
+
color: #C0C5CF;
|
|
2047
2773
|
}
|
|
2048
2774
|
.wa-composer__send {
|
|
2049
|
-
padding: 6px
|
|
2050
|
-
border: 1px solid #
|
|
2051
|
-
border-radius:
|
|
2775
|
+
padding: 6px 16px;
|
|
2776
|
+
border: 1px solid #4F5AED;
|
|
2777
|
+
border-radius: 999px;
|
|
2052
2778
|
font: inherit;
|
|
2053
2779
|
color: #ffffff;
|
|
2054
|
-
background: #
|
|
2780
|
+
background: #4F5AED;
|
|
2055
2781
|
cursor: pointer;
|
|
2056
2782
|
}
|
|
2057
2783
|
.wa-composer__send:hover:not(:disabled) {
|
|
2058
|
-
|
|
2784
|
+
border-color: #3F49D6;
|
|
2785
|
+
background: #3F49D6;
|
|
2059
2786
|
}
|
|
2060
2787
|
.wa-composer__send:disabled {
|
|
2061
2788
|
border-color: #cbd2d9;
|
|
@@ -2064,26 +2791,76 @@ const THREAD_CSS = `
|
|
|
2064
2791
|
cursor: default;
|
|
2065
2792
|
}
|
|
2066
2793
|
|
|
2067
|
-
/* COMP-05 — \`unverified\`: un AVISO, no un bloqueo.
|
|
2068
|
-
que la conversación esté fría, dice que no se pudo leer. */
|
|
2794
|
+
/* COMP-05 — \`unverified\`: un AVISO, no un bloqueo. Banner ámbar (DEV-5053) y no rojo a
|
|
2795
|
+
propósito: el estado no dice que la conversación esté fría, dice que no se pudo leer. */
|
|
2069
2796
|
.wa-composer__unverified {
|
|
2797
|
+
display: flex;
|
|
2798
|
+
align-items: center;
|
|
2799
|
+
justify-content: space-between;
|
|
2800
|
+
gap: 10px;
|
|
2070
2801
|
margin: 0;
|
|
2071
|
-
padding: 8px
|
|
2072
|
-
border: 1px solid #
|
|
2073
|
-
border-radius:
|
|
2802
|
+
padding: 8px 12px;
|
|
2803
|
+
border: 1px solid #F5E7C8;
|
|
2804
|
+
border-radius: 8px;
|
|
2805
|
+
font-size: 12px;
|
|
2806
|
+
color: #8A5A10;
|
|
2807
|
+
background: #FFFBF2;
|
|
2808
|
+
}
|
|
2809
|
+
.wa-composer__unverified-text {
|
|
2810
|
+
display: flex;
|
|
2811
|
+
flex-direction: column;
|
|
2812
|
+
gap: 2px;
|
|
2813
|
+
}
|
|
2814
|
+
.wa-composer__unverified-title {
|
|
2815
|
+
margin: 0;
|
|
2816
|
+
font-weight: 600;
|
|
2817
|
+
}
|
|
2818
|
+
.wa-composer__unverified-explain {
|
|
2819
|
+
margin: 0;
|
|
2820
|
+
}
|
|
2821
|
+
.wa-composer__retry-window {
|
|
2822
|
+
flex: 0 0 auto;
|
|
2823
|
+
padding: 4px 14px;
|
|
2824
|
+
border: 1px solid #F5E7C8;
|
|
2825
|
+
border-radius: 999px;
|
|
2826
|
+
font: inherit;
|
|
2074
2827
|
font-size: 12px;
|
|
2075
|
-
color: #
|
|
2076
|
-
background: #
|
|
2828
|
+
color: #8A5A10;
|
|
2829
|
+
background: #ffffff;
|
|
2830
|
+
cursor: pointer;
|
|
2831
|
+
}
|
|
2832
|
+
.wa-composer__retry-window:hover {
|
|
2833
|
+
background: #FFF7E8;
|
|
2077
2834
|
}
|
|
2078
2835
|
|
|
2079
|
-
/* COMP-04 — \`closed\`: acá NO hay textarea.
|
|
2836
|
+
/* COMP-04 — \`closed\`: acá NO hay textarea. La tarjeta centrada (DEV-5053) reemplaza al
|
|
2837
|
+
composer entero. */
|
|
2080
2838
|
.wa-composer--closed {
|
|
2081
|
-
|
|
2839
|
+
align-items: center;
|
|
2840
|
+
padding: 20px 16px;
|
|
2841
|
+
gap: 10px;
|
|
2842
|
+
text-align: center;
|
|
2843
|
+
background: #ffffff;
|
|
2082
2844
|
}
|
|
2083
|
-
.wa-
|
|
2845
|
+
.wa-composer__lock {
|
|
2846
|
+
display: flex;
|
|
2847
|
+
align-items: center;
|
|
2848
|
+
justify-content: center;
|
|
2849
|
+
width: 48px;
|
|
2850
|
+
height: 48px;
|
|
2851
|
+
border-radius: 50%;
|
|
2852
|
+
background: #F4F5F7;
|
|
2853
|
+
}
|
|
2854
|
+
.wa-composer__cold-title {
|
|
2084
2855
|
margin: 0;
|
|
2085
|
-
font-size:
|
|
2086
|
-
|
|
2856
|
+
font-size: 14px;
|
|
2857
|
+
font-weight: 700;
|
|
2858
|
+
color: #1f2933;
|
|
2859
|
+
}
|
|
2860
|
+
.wa-composer__cold-explain {
|
|
2861
|
+
margin: 4px 0 0;
|
|
2862
|
+
font-size: 12px;
|
|
2863
|
+
color: #8A91A0;
|
|
2087
2864
|
}
|
|
2088
2865
|
|
|
2089
2866
|
/* COMP-06 — devolver la conversación al bot. El texto explicativo NO es decoración: es lo que
|
|
@@ -2166,6 +2943,16 @@ const THREAD_CSS = `
|
|
|
2166
2943
|
.wa-composer__failure-actions button:hover {
|
|
2167
2944
|
background: #f5f7fa;
|
|
2168
2945
|
}
|
|
2946
|
+
/* DEV-5053 P7: el Reintentar del envío fallido es un pill blanco con borde y texto rojos. */
|
|
2947
|
+
.wa-composer__failure-actions button.wa-composer__failure-retry {
|
|
2948
|
+
padding: 4px 12px;
|
|
2949
|
+
border: 1px solid #F0C9C5;
|
|
2950
|
+
border-radius: 999px;
|
|
2951
|
+
color: #D93025;
|
|
2952
|
+
}
|
|
2953
|
+
.wa-composer__failure-actions button.wa-composer__failure-retry:hover {
|
|
2954
|
+
background: #FDF6F6;
|
|
2955
|
+
}
|
|
2169
2956
|
`;
|
|
2170
2957
|
//#endregion
|
|
2171
2958
|
//#region src/core/thread/useComposer.ts
|
|
@@ -2454,6 +3241,9 @@ function useThread({ fetcher, phone }) {
|
|
|
2454
3241
|
messages,
|
|
2455
3242
|
windowState: normalizeWindowState(thread.window_state),
|
|
2456
3243
|
canReply: thread.can_reply === true,
|
|
3244
|
+
takenBy: thread.taken_by ?? null,
|
|
3245
|
+
takenUntil: thread.taken_until ?? null,
|
|
3246
|
+
takenByMe: thread.taken_by_me === true,
|
|
2457
3247
|
status: messages.length > 0 ? "ready" : "empty",
|
|
2458
3248
|
error: null,
|
|
2459
3249
|
olderCursor: thread.older_cursor,
|
|
@@ -2468,6 +3258,9 @@ function useThread({ fetcher, phone }) {
|
|
|
2468
3258
|
messages: [],
|
|
2469
3259
|
windowState: "unverified",
|
|
2470
3260
|
canReply: false,
|
|
3261
|
+
takenBy: null,
|
|
3262
|
+
takenUntil: null,
|
|
3263
|
+
takenByMe: false,
|
|
2471
3264
|
status: "error",
|
|
2472
3265
|
error: toError(cause),
|
|
2473
3266
|
olderCursor: null,
|
|
@@ -2542,7 +3335,7 @@ function useThread({ fetcher, phone }) {
|
|
|
2542
3335
|
finish
|
|
2543
3336
|
]);
|
|
2544
3337
|
const retry = useCallback(() => {
|
|
2545
|
-
if (current !== null && current.messages.length > 0) {
|
|
3338
|
+
if (current !== null && current.status === "error" && current.messages.length > 0) {
|
|
2546
3339
|
loadOlder();
|
|
2547
3340
|
return;
|
|
2548
3341
|
}
|
|
@@ -2555,12 +3348,58 @@ function useThread({ fetcher, phone }) {
|
|
|
2555
3348
|
error: current?.error ?? null,
|
|
2556
3349
|
windowState: current?.windowState ?? "unverified",
|
|
2557
3350
|
canReply: current?.canReply ?? false,
|
|
3351
|
+
takenBy: current?.takenBy ?? null,
|
|
3352
|
+
takenUntil: current?.takenUntil ?? null,
|
|
3353
|
+
takenByMe: current?.takenByMe ?? false,
|
|
2558
3354
|
hasOlder: current?.hasOlder ?? false,
|
|
2559
3355
|
loadOlder,
|
|
2560
3356
|
retry
|
|
2561
3357
|
};
|
|
2562
3358
|
}
|
|
2563
3359
|
//#endregion
|
|
3360
|
+
//#region src/core/thread/takeover-countdown.ts
|
|
3361
|
+
/**
|
|
3362
|
+
* Cuánto le queda a un takeover, en español (DEV-5061). Interno del hilo — NO sale al barrel.
|
|
3363
|
+
*
|
|
3364
|
+
* El servidor manda un **instante** (`taken_until`) y no «minutos restantes», y este módulo es la
|
|
3365
|
+
* razón: un relativo calculado en el servidor queda viejo apenas viaja, mientras que el instante
|
|
3366
|
+
* sigue siendo verdad y el conteo se hace acá, contra el reloj de quien mira.
|
|
3367
|
+
*
|
|
3368
|
+
* `now` es un parámetro y no una lectura de `Date.now()` adentro, por lo mismo que en
|
|
3369
|
+
* `relative-time.ts`: para que el test pase su propio reloj sin contagiar timers falsos al resto
|
|
3370
|
+
* del archivo.
|
|
3371
|
+
*
|
|
3372
|
+
* ⚠️ **No se recalcula solo.** El valor se computa en el render y se queda quieto hasta el
|
|
3373
|
+
* siguiente — igual que la hora relativa de la fila del inbox. Un timer acá obligaría a un
|
|
3374
|
+
* re-render periódico del hilo entero para ganar precisión de minuto en un dato que ya es
|
|
3375
|
+
* aproximado, y el hilo se re-renderiza seguido por su cuenta. Es una decisión, no un olvido.
|
|
3376
|
+
*/
|
|
3377
|
+
const MINUTE = 6e4;
|
|
3378
|
+
/**
|
|
3379
|
+
* «1 h 42 m», «22 m», o `null` si no hay nada que contar.
|
|
3380
|
+
*
|
|
3381
|
+
* Devuelve `null` en los tres casos degenerados, y ninguno es teórico:
|
|
3382
|
+
*
|
|
3383
|
+
* - **`iso` nulo o que no parsea** — la conversación no está tomada, o el backend mandó basura.
|
|
3384
|
+
* - **Ya vencido** — el servidor filtra los vencidos contra SU reloj, pero el del operador puede
|
|
3385
|
+
* ir adelantado. «se libera en -3 m» es peor que no decir nada.
|
|
3386
|
+
* - **Menos de un minuto** — se redondea a `1 m` en vez de mostrar `0 m`, que se lee como si el
|
|
3387
|
+
* dato faltara. Ese sí devuelve texto: es el único de los tres que no es un error.
|
|
3388
|
+
*/
|
|
3389
|
+
function takeoverCountdown(iso, now = Date.now()) {
|
|
3390
|
+
if (typeof iso !== "string") return null;
|
|
3391
|
+
const until = Date.parse(iso);
|
|
3392
|
+
if (Number.isNaN(until)) return null;
|
|
3393
|
+
const left = until - now;
|
|
3394
|
+
if (left <= 0) return null;
|
|
3395
|
+
const totalMinutes = Math.max(1, Math.ceil(left / MINUTE));
|
|
3396
|
+
const hours = Math.floor(totalMinutes / 60);
|
|
3397
|
+
const minutes = totalMinutes % 60;
|
|
3398
|
+
if (hours === 0) return `${minutes} m`;
|
|
3399
|
+
if (minutes === 0) return `${hours} h`;
|
|
3400
|
+
return `${hours} h ${minutes} m`;
|
|
3401
|
+
}
|
|
3402
|
+
//#endregion
|
|
2564
3403
|
//#region src/core/thread/ConversationThread.tsx
|
|
2565
3404
|
/**
|
|
2566
3405
|
* El panel del hilo de conversación — la mitad derecha del visor (DEV-4987).
|
|
@@ -2628,8 +3467,62 @@ function serviceStateTransitions(messages) {
|
|
|
2628
3467
|
return true;
|
|
2629
3468
|
});
|
|
2630
3469
|
}
|
|
2631
|
-
|
|
2632
|
-
|
|
3470
|
+
/**
|
|
3471
|
+
* El paso ACTUAL del flujo para el chip «Paso» del header (DEV-5053 / P3): el `service_state`
|
|
3472
|
+
* no-nulo/no-vacío del ÚLTIMO mensaje que lo tenga, sobre los mensajes ya ordenados (DEC-N).
|
|
3473
|
+
* `null` si ningún mensaje trae flujo — en ese caso el header se pinta igual (lleva la identidad
|
|
3474
|
+
* de la persona) y lo que falta es la fila de chips. Sin cambio de contrato: es una lectura
|
|
3475
|
+
* derivada de lo que el hilo ya trae.
|
|
3476
|
+
*/
|
|
3477
|
+
function currentServiceState(messages) {
|
|
3478
|
+
for (let index = messages.length - 1; index >= 0; index -= 1) {
|
|
3479
|
+
const state = messages[index].service_state;
|
|
3480
|
+
if (typeof state === "string" && state !== "") return state;
|
|
3481
|
+
}
|
|
3482
|
+
return null;
|
|
3483
|
+
}
|
|
3484
|
+
/**
|
|
3485
|
+
* La barra de takeover del hilo (DEV-5061).
|
|
3486
|
+
*
|
|
3487
|
+
* El problema que resuelve: el store ya guardaba quién tomó la conversación y el bot ya se callaba,
|
|
3488
|
+
* pero nada de eso llegaba acá. Una conversación atendida por un compañero se veía **idéntica** a
|
|
3489
|
+
* una libre — el operador entraba, escribía, y recién ahí se enteraba. O no se enteraba, y dos
|
|
3490
|
+
* personas respondían el mismo hilo.
|
|
3491
|
+
*
|
|
3492
|
+
* Dos ramas, deliberadamente distintas:
|
|
3493
|
+
*
|
|
3494
|
+
* - **La tomaste vos** — se ofrece «Reactivar bot», porque es tuya y podés soltarla.
|
|
3495
|
+
* - **La tomó otro** — se dice quién y hasta cuándo, y NO se ofrece el botón. Robarle el turno a
|
|
3496
|
+
* un compañero desde un botón que parece inofensivo es peor que la ambigüedad que esta barra
|
|
3497
|
+
* vino a arreglar; quien quiera hacerlo puede responder, que renueva la toma a su nombre.
|
|
3498
|
+
*
|
|
3499
|
+
* `takenByMe` viene del SERVIDOR y no se deriva comparando `takenBy` con nadie: dos operadores
|
|
3500
|
+
* pueden llamarse igual, y confundirlos es exactamente darle a uno el botón del otro.
|
|
3501
|
+
*
|
|
3502
|
+
* El nombre entra sólo como hijo de texto, que React escapa (T-03-02).
|
|
3503
|
+
*/
|
|
3504
|
+
function TakeoverBar({ takenBy, takenUntil, takenByMe, composer }) {
|
|
3505
|
+
if (composer.releaseState === "released") return null;
|
|
3506
|
+
const left = takeoverCountdown(takenUntil);
|
|
3507
|
+
if (takenBy === null && left === null) return null;
|
|
3508
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
3509
|
+
className: "wa-thread__takeover",
|
|
3510
|
+
"data-mine": takenByMe || void 0,
|
|
3511
|
+
role: "status",
|
|
3512
|
+
children: [/* @__PURE__ */ jsxs("span", {
|
|
3513
|
+
className: "wa-thread__takeover-text",
|
|
3514
|
+
children: [takenByMe ? /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("strong", { children: "Bot en pausa" }), " — la tomaste tú"] }) : /* @__PURE__ */ jsxs(Fragment$1, { children: ["Tomada por ", /* @__PURE__ */ jsx("strong", { children: takenBy ?? "otro operador" })] }), left !== null && ` · se libera en ${left}`]
|
|
3515
|
+
}), takenByMe && /* @__PURE__ */ jsx("button", {
|
|
3516
|
+
type: "button",
|
|
3517
|
+
className: "wa-thread__takeover-button",
|
|
3518
|
+
onClick: composer.release,
|
|
3519
|
+
disabled: composer.releaseState === "releasing",
|
|
3520
|
+
children: composer.releaseState === "releasing" ? "Reactivando…" : "Reactivar bot"
|
|
3521
|
+
})]
|
|
3522
|
+
});
|
|
3523
|
+
}
|
|
3524
|
+
function ConversationThread({ fetcher, phone, displayName, className }) {
|
|
3525
|
+
const { messages: serverMessages, status, error, windowState, canReply, takenBy, takenUntil, takenByMe, hasOlder, loadOlder, retry } = useThread({
|
|
2633
3526
|
fetcher,
|
|
2634
3527
|
phone
|
|
2635
3528
|
});
|
|
@@ -2701,6 +3594,9 @@ function ConversationThread({ fetcher, phone, className }) {
|
|
|
2701
3594
|
}, [hasOlder, handleLoadOlder]);
|
|
2702
3595
|
const groups = groupByDay(messages);
|
|
2703
3596
|
const showServiceState = serviceStateTransitions(messages);
|
|
3597
|
+
const currentStep = currentServiceState(messages);
|
|
3598
|
+
/** El nombre útil: vacío o sólo espacios cuenta como ausente (D-02). */
|
|
3599
|
+
const name = typeof displayName === "string" && displayName.trim() !== "" ? displayName : null;
|
|
2704
3600
|
return /* @__PURE__ */ jsxs("div", {
|
|
2705
3601
|
className: className ? `wa-thread ${className}` : "wa-thread",
|
|
2706
3602
|
children: [
|
|
@@ -2722,6 +3618,39 @@ function ConversationThread({ fetcher, phone, className }) {
|
|
|
2722
3618
|
className: "wa-thread__note",
|
|
2723
3619
|
children: "Sin mensajes en esta conversación."
|
|
2724
3620
|
}),
|
|
3621
|
+
/* @__PURE__ */ jsxs("div", {
|
|
3622
|
+
className: "wa-thread__header",
|
|
3623
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
3624
|
+
className: "wa-thread__identity",
|
|
3625
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
3626
|
+
className: "wa-thread__avatar",
|
|
3627
|
+
"aria-hidden": "true",
|
|
3628
|
+
children: initials(name, phone)
|
|
3629
|
+
}), /* @__PURE__ */ jsxs("span", {
|
|
3630
|
+
className: "wa-thread__who",
|
|
3631
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
3632
|
+
className: "wa-thread__name",
|
|
3633
|
+
children: name ?? phone
|
|
3634
|
+
}), name !== null && /* @__PURE__ */ jsx("span", {
|
|
3635
|
+
className: "wa-thread__phone",
|
|
3636
|
+
children: phone
|
|
3637
|
+
})]
|
|
3638
|
+
})]
|
|
3639
|
+
}), currentStep !== null && /* @__PURE__ */ jsx("div", {
|
|
3640
|
+
className: "wa-thread__chips",
|
|
3641
|
+
children: /* @__PURE__ */ jsxs("span", {
|
|
3642
|
+
className: "wa-thread__step",
|
|
3643
|
+
title: currentStep,
|
|
3644
|
+
children: ["Paso: ", serviceStateLabel(currentStep)]
|
|
3645
|
+
})
|
|
3646
|
+
})]
|
|
3647
|
+
}),
|
|
3648
|
+
/* @__PURE__ */ jsx(TakeoverBar, {
|
|
3649
|
+
takenBy,
|
|
3650
|
+
takenUntil,
|
|
3651
|
+
takenByMe,
|
|
3652
|
+
composer
|
|
3653
|
+
}),
|
|
2725
3654
|
/* @__PURE__ */ jsxs("div", {
|
|
2726
3655
|
className: "wa-thread__messages",
|
|
2727
3656
|
ref: messagesRef,
|
|
@@ -2737,17 +3666,20 @@ function ConversationThread({ fetcher, phone, className }) {
|
|
|
2737
3666
|
children: [group.label !== null && /* @__PURE__ */ jsx("div", {
|
|
2738
3667
|
className: "wa-thread__day",
|
|
2739
3668
|
children: group.label
|
|
2740
|
-
}), group.items.map(({ message, position }) => /* @__PURE__ */
|
|
3669
|
+
}), group.items.map(({ message, position }) => /* @__PURE__ */ jsxs(Fragment, { children: [showServiceState[position] && typeof message.service_state === "string" && message.service_state !== "" && /* @__PURE__ */ jsxs("div", {
|
|
3670
|
+
className: "wa-thread__flow-pill",
|
|
3671
|
+
children: ["El flujo pasó a ", serviceStateLabel(message.service_state)]
|
|
3672
|
+
}), /* @__PURE__ */ jsx(MessageBubble, {
|
|
2741
3673
|
message,
|
|
2742
|
-
showServiceState: showServiceState[position],
|
|
2743
3674
|
optimistic: optimistic.has(message),
|
|
2744
3675
|
fetcher
|
|
2745
|
-
}, message.id ?? `sin-wamid-${position}`))]
|
|
3676
|
+
})] }, message.id ?? `sin-wamid-${position}`))]
|
|
2746
3677
|
}, group.key ?? `sin-dia-${groupIndex}`))]
|
|
2747
3678
|
}),
|
|
2748
3679
|
/* @__PURE__ */ jsx(Composer, {
|
|
2749
3680
|
canReply,
|
|
2750
|
-
composer
|
|
3681
|
+
composer,
|
|
3682
|
+
onRetryWindow: retry
|
|
2751
3683
|
})
|
|
2752
3684
|
]
|
|
2753
3685
|
});
|
|
@@ -2789,7 +3721,9 @@ const SHELL_CSS = `
|
|
|
2789
3721
|
height: 100%;
|
|
2790
3722
|
min-height: 0;
|
|
2791
3723
|
align-items: stretch;
|
|
2792
|
-
|
|
3724
|
+
/* Inter sólo como primer nombre (DEV-5053): si el host la carga se usa, si no cae a system-ui.
|
|
3725
|
+
Cero @import y cero fuentes remotas (C-04). */
|
|
3726
|
+
font-family: Inter, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
|
|
2793
3727
|
}
|
|
2794
3728
|
/* El ancho de la columna de la lista lo fija EL SHELL, no la lista: el data-layout de la lista
|
|
2795
3729
|
se mide de su propio ancho, así que un ancho derivado de él oscila (ver list-styles.ts). El
|
|
@@ -2797,7 +3731,7 @@ const SHELL_CSS = `
|
|
|
2797
3731
|
.wa-conversations[data-layout='wide'] > .wa-list {
|
|
2798
3732
|
width: 320px;
|
|
2799
3733
|
flex: 0 0 320px;
|
|
2800
|
-
border-right: 1px solid #
|
|
3734
|
+
border-right: 1px solid #EEF0F3;
|
|
2801
3735
|
}
|
|
2802
3736
|
.wa-conversations[data-layout='narrow'] > .wa-list {
|
|
2803
3737
|
flex: 1 1 auto;
|
|
@@ -2809,25 +3743,29 @@ const SHELL_CSS = `
|
|
|
2809
3743
|
flex: 1 1 auto;
|
|
2810
3744
|
flex-direction: column;
|
|
2811
3745
|
}
|
|
3746
|
+
/* El "Volver" toma la forma de pill del resto de la interfaz (diseño .pen de DEV-5053). */
|
|
2812
3747
|
.wa-conversations__back {
|
|
2813
3748
|
align-self: flex-start;
|
|
2814
3749
|
margin: 8px 12px 0;
|
|
2815
|
-
padding:
|
|
2816
|
-
border: 1px solid #
|
|
2817
|
-
border-radius:
|
|
3750
|
+
padding: 4px 12px;
|
|
3751
|
+
border: 1px solid #C9D2F5;
|
|
3752
|
+
border-radius: 999px;
|
|
2818
3753
|
font: inherit;
|
|
2819
|
-
|
|
3754
|
+
font-size: 11.5px;
|
|
3755
|
+
font-weight: 600;
|
|
3756
|
+
color: #4F5AED;
|
|
2820
3757
|
background: #ffffff;
|
|
2821
3758
|
cursor: pointer;
|
|
2822
3759
|
}
|
|
2823
3760
|
.wa-conversations__back:hover {
|
|
2824
|
-
background: #
|
|
3761
|
+
background: #EEF1FE;
|
|
2825
3762
|
}
|
|
2826
3763
|
.wa-conversations__empty {
|
|
2827
3764
|
margin: 0;
|
|
2828
3765
|
padding: 24px;
|
|
2829
3766
|
flex: 1 1 auto;
|
|
2830
|
-
|
|
3767
|
+
font-size: 13px;
|
|
3768
|
+
color: #8A91A0;
|
|
2831
3769
|
}
|
|
2832
3770
|
`;
|
|
2833
3771
|
function WaConversations({ fetcher, initialPhone, pinned = false, className }) {
|
|
@@ -2843,6 +3781,15 @@ function WaConversations({ fetcher, initialPhone, pinned = false, className }) {
|
|
|
2843
3781
|
* docstring de la prop — la reactividad post-mount es del key-swap del element).
|
|
2844
3782
|
*/
|
|
2845
3783
|
const [selectedPhone, setSelectedPhone] = useState(initialPhone ?? null);
|
|
3784
|
+
/**
|
|
3785
|
+
* El nombre de la conversación elegida, para el header del hilo (D-02). Vive acá porque el
|
|
3786
|
+
* `ConversationSummary` —el único lugar donde el contrato pone `name`— lo recibe ESTE shell en
|
|
3787
|
+
* su `onSelect`; el hilo no lo puede sacar de su propia respuesta.
|
|
3788
|
+
*
|
|
3789
|
+
* `initialPhone` siembra SÓLO el teléfono: sin summary no hay nombre que sembrar y no se
|
|
3790
|
+
* inventa uno. El header cae al teléfono, como la fila de la lista.
|
|
3791
|
+
*/
|
|
3792
|
+
const [selectedName, setSelectedName] = useState(null);
|
|
2846
3793
|
const rootClass = className ? `wa-conversations ${className}` : "wa-conversations";
|
|
2847
3794
|
if (fetcher === void 0) return /* @__PURE__ */ jsx("div", {
|
|
2848
3795
|
className: rootClass,
|
|
@@ -2858,18 +3805,25 @@ function WaConversations({ fetcher, initialPhone, pinned = false, className }) {
|
|
|
2858
3805
|
!anchored && (layout === "wide" || selectedPhone === null) && /* @__PURE__ */ jsx(ConversationList, {
|
|
2859
3806
|
fetcher,
|
|
2860
3807
|
selectedPhone,
|
|
2861
|
-
onSelect: (item) =>
|
|
3808
|
+
onSelect: (item) => {
|
|
3809
|
+
setSelectedPhone(item.phone);
|
|
3810
|
+
setSelectedName(item.name);
|
|
3811
|
+
}
|
|
2862
3812
|
}),
|
|
2863
3813
|
selectedPhone !== null ? /* @__PURE__ */ jsxs("div", {
|
|
2864
3814
|
className: "wa-conversations__thread",
|
|
2865
3815
|
children: [layout === "narrow" && !anchored && /* @__PURE__ */ jsx("button", {
|
|
2866
3816
|
type: "button",
|
|
2867
3817
|
className: "wa-conversations__back",
|
|
2868
|
-
onClick: () =>
|
|
3818
|
+
onClick: () => {
|
|
3819
|
+
setSelectedPhone(null);
|
|
3820
|
+
setSelectedName(null);
|
|
3821
|
+
},
|
|
2869
3822
|
children: "Volver"
|
|
2870
3823
|
}), /* @__PURE__ */ jsx(ConversationThread, {
|
|
2871
3824
|
fetcher,
|
|
2872
|
-
phone: selectedPhone
|
|
3825
|
+
phone: selectedPhone,
|
|
3826
|
+
displayName: selectedName
|
|
2873
3827
|
})]
|
|
2874
3828
|
}) : layout === "wide" && /* @__PURE__ */ jsx("p", {
|
|
2875
3829
|
className: "wa-conversations__empty",
|