@liftitapp/wa-conversations 0.4.0 → 0.5.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/dist/element/index.js +485 -142
- package/dist/react/index.d.ts +16 -1
- package/dist/react/index.js +982 -267
- package/package.json +1 -1
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**.
|
|
@@ -58,29 +88,40 @@ 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
|
+
]
|
|
124
|
+
})]
|
|
84
125
|
})
|
|
85
126
|
});
|
|
86
127
|
}
|
|
@@ -100,8 +141,10 @@ function ConversationRow({ item, selected, onSelect }) {
|
|
|
100
141
|
* DOM: un selector de elemento suelto (`ul`, `button`, `input`) le pisaría los estilos al host, y
|
|
101
142
|
* `backoffice-v2-lite` no perdona eso. Tampoco hay `:host` acá — eso es del entry del elemento.
|
|
102
143
|
* - **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
|
-
*
|
|
144
|
+
* paquete monta en tres hosts con temas distintos. La paleta de acá (índigo #4F5AED, grises
|
|
145
|
+
* #F4F5F7/#E4E7EE) NO es un tema inventado: viene del diseño aprobado de DEV-5053 (.pen), y
|
|
146
|
+
* sigue sin depender de tokens del host. `Inter` va sólo como primer nombre del font stack —
|
|
147
|
+
* si el host la carga se usa, si no cae a system-ui; cero `@import`.
|
|
105
148
|
* - **El layout angosto/ancho se selecciona por `[data-layout]`, no por `@media`.** El panel va
|
|
106
149
|
* embebido y el viewport miente sobre el ancho que realmente tiene (ver `useContainerLayout`).
|
|
107
150
|
*
|
|
@@ -115,7 +158,7 @@ const LIST_CSS = `
|
|
|
115
158
|
display: flex;
|
|
116
159
|
flex-direction: column;
|
|
117
160
|
min-height: 0;
|
|
118
|
-
font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
|
|
161
|
+
font-family: Inter, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
|
|
119
162
|
font-size: 14px;
|
|
120
163
|
line-height: 1.5;
|
|
121
164
|
color: #1f2933;
|
|
@@ -144,34 +187,143 @@ const LIST_CSS = `
|
|
|
144
187
|
padding: 10px 12px;
|
|
145
188
|
border-bottom: 1px solid #e4e7eb;
|
|
146
189
|
}
|
|
147
|
-
|
|
190
|
+
/* Etiqueta sólo para lectores de pantalla: el buscador y las fechas se explican solos a la vista
|
|
191
|
+
(placeholder e icono), pero sin <label> asociado un input no tiene nombre accesible. */
|
|
192
|
+
.wa-list__sr-only {
|
|
193
|
+
position: absolute;
|
|
194
|
+
width: 1px;
|
|
195
|
+
height: 1px;
|
|
196
|
+
padding: 0;
|
|
197
|
+
margin: -1px;
|
|
198
|
+
border: 0;
|
|
199
|
+
clip-path: inset(50%);
|
|
200
|
+
overflow: hidden;
|
|
201
|
+
white-space: nowrap;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/* El buscador del diseño: campo relleno con la lupa adentro, no un input con etiqueta encima. */
|
|
205
|
+
.wa-list__search {
|
|
206
|
+
position: relative;
|
|
148
207
|
display: flex;
|
|
149
|
-
flex: 1 1
|
|
208
|
+
flex: 1 1 100%;
|
|
209
|
+
align-items: center;
|
|
150
210
|
min-width: 0;
|
|
151
|
-
flex-direction: column;
|
|
152
|
-
gap: 2px;
|
|
153
211
|
}
|
|
154
|
-
.wa-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
212
|
+
.wa-list__search-icon {
|
|
213
|
+
position: absolute;
|
|
214
|
+
left: 10px;
|
|
215
|
+
color: #8A93A3;
|
|
216
|
+
pointer-events: none;
|
|
159
217
|
}
|
|
160
|
-
.wa-
|
|
218
|
+
.wa-list__search input {
|
|
161
219
|
min-width: 0;
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
border
|
|
220
|
+
width: 100%;
|
|
221
|
+
padding: 8px 10px 8px 30px;
|
|
222
|
+
border: 1px solid #E4E7EE;
|
|
223
|
+
border-radius: 8px;
|
|
165
224
|
font: inherit;
|
|
225
|
+
font-size: 13px;
|
|
166
226
|
color: inherit;
|
|
227
|
+
background: #F4F5F7;
|
|
228
|
+
}
|
|
229
|
+
.wa-list__search input::placeholder {
|
|
230
|
+
color: #8A93A3;
|
|
231
|
+
}
|
|
232
|
+
/* La X nativa del type=search: Chrome la pinta con su propio gris y su propio tamaño. */
|
|
233
|
+
.wa-list__search input::-webkit-search-cancel-button {
|
|
234
|
+
cursor: pointer;
|
|
235
|
+
opacity: 0.5;
|
|
236
|
+
}
|
|
237
|
+
/* Los chips de preset de fecha (DEV-5053): fila propia, ancho completo del formulario. */
|
|
238
|
+
.wa-list__presets {
|
|
239
|
+
display: flex;
|
|
240
|
+
flex: 1 1 100%;
|
|
241
|
+
flex-wrap: wrap;
|
|
242
|
+
gap: 6px;
|
|
243
|
+
}
|
|
244
|
+
.wa-list__preset {
|
|
245
|
+
padding: 4px 12px;
|
|
246
|
+
border: 1px solid #E4E7EE;
|
|
247
|
+
border-radius: 999px;
|
|
248
|
+
font: inherit;
|
|
249
|
+
font-size: 12px;
|
|
250
|
+
color: #52606d;
|
|
167
251
|
background: #ffffff;
|
|
252
|
+
cursor: pointer;
|
|
253
|
+
}
|
|
254
|
+
.wa-list__preset:hover {
|
|
255
|
+
background: #f5f7fa;
|
|
256
|
+
}
|
|
257
|
+
/* El activo se marca por el MISMO atributo que lo anuncia a un lector de pantalla: si alguien
|
|
258
|
+
saca el aria-pressed, el resaltado se va con él y el bug se ve (mismo criterio que la fila). */
|
|
259
|
+
.wa-list__preset[aria-pressed='true'] {
|
|
260
|
+
border-color: #C9D2F5;
|
|
261
|
+
font-weight: 600;
|
|
262
|
+
color: #4F5AED;
|
|
263
|
+
background: #EEF1FE;
|
|
168
264
|
}
|
|
169
|
-
|
|
265
|
+
|
|
266
|
+
/* El rango en una sola fila. Los dos campos reparten el ancho para que la flecha quede al medio
|
|
267
|
+
sin posicionarla a mano. */
|
|
268
|
+
.wa-list__range {
|
|
170
269
|
display: flex;
|
|
171
|
-
|
|
270
|
+
flex: 1 1 100%;
|
|
271
|
+
align-items: center;
|
|
172
272
|
gap: 8px;
|
|
273
|
+
min-width: 0;
|
|
274
|
+
}
|
|
275
|
+
.wa-list__range-sep {
|
|
276
|
+
flex: 0 0 auto;
|
|
277
|
+
font-size: 12px;
|
|
278
|
+
color: #8A93A3;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
/* Domar el <input type="date">.
|
|
282
|
+
Un date input nativo se delata por tres cosas: la fuente del user-agent, el alto propio y el
|
|
283
|
+
icono azul del picker de Chrome. Las tres se pueden corregir; el CALENDARIO que se despliega al
|
|
284
|
+
hacer clic NO — lo pinta el navegador y ningún CSS lo alcanza. Eso es aceptable: es la ventana
|
|
285
|
+
que la persona ya conoce de su sistema, y reemplazarla exigiría un date picker propio, o sea
|
|
286
|
+
una dependencia (prohibido) o cientos de líneas de calendario a mano. */
|
|
287
|
+
.wa-list__date {
|
|
288
|
+
flex: 1 1 0;
|
|
289
|
+
min-width: 0;
|
|
290
|
+
padding: 7px 10px;
|
|
291
|
+
border: 1px solid #E4E7EE;
|
|
292
|
+
border-radius: 8px;
|
|
293
|
+
font: inherit;
|
|
294
|
+
font-size: 12.5px;
|
|
295
|
+
color: #52606d;
|
|
296
|
+
background: #ffffff;
|
|
297
|
+
}
|
|
298
|
+
.wa-list__date:hover {
|
|
299
|
+
border-color: #C9D2F5;
|
|
300
|
+
}
|
|
301
|
+
/* El indicador del picker: gris como el resto del formulario en vez del azul de Chrome. */
|
|
302
|
+
.wa-list__date::-webkit-calendar-picker-indicator {
|
|
303
|
+
cursor: pointer;
|
|
304
|
+
opacity: 0.45;
|
|
173
305
|
}
|
|
174
|
-
.wa-
|
|
306
|
+
.wa-list__date::-webkit-calendar-picker-indicator:hover {
|
|
307
|
+
opacity: 0.8;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
/* «Limpiar filtros»: enlace discreto, no un botón que compita con los chips. Sólo se renderiza
|
|
311
|
+
cuando hay filtros puestos, así que no necesita estado deshabilitado. */
|
|
312
|
+
.wa-list__clear {
|
|
313
|
+
flex: 0 0 auto;
|
|
314
|
+
padding: 0;
|
|
315
|
+
border: 0;
|
|
316
|
+
font: inherit;
|
|
317
|
+
font-size: 12px;
|
|
318
|
+
color: #6B7280;
|
|
319
|
+
background: none;
|
|
320
|
+
text-decoration: underline;
|
|
321
|
+
cursor: pointer;
|
|
322
|
+
}
|
|
323
|
+
.wa-list__clear:hover {
|
|
324
|
+
color: #4F5AED;
|
|
325
|
+
}
|
|
326
|
+
|
|
175
327
|
.wa-list__more {
|
|
176
328
|
padding: 6px 10px;
|
|
177
329
|
border: 1px solid #cbd2d9;
|
|
@@ -181,7 +333,6 @@ const LIST_CSS = `
|
|
|
181
333
|
background: #ffffff;
|
|
182
334
|
cursor: pointer;
|
|
183
335
|
}
|
|
184
|
-
.wa-list__actions button:hover,
|
|
185
336
|
.wa-list__more:hover {
|
|
186
337
|
background: #f5f7fa;
|
|
187
338
|
}
|
|
@@ -202,72 +353,117 @@ const LIST_CSS = `
|
|
|
202
353
|
list-style: none;
|
|
203
354
|
}
|
|
204
355
|
|
|
356
|
+
/* La fila del diseño (.pen de DEV-5053): avatar a la izquierda y la columna de contenido a la
|
|
357
|
+
derecha. */
|
|
205
358
|
.wa-list__row {
|
|
206
359
|
display: flex;
|
|
207
|
-
flex-direction:
|
|
208
|
-
|
|
360
|
+
flex-direction: row;
|
|
361
|
+
align-items: center;
|
|
362
|
+
gap: 12px;
|
|
209
363
|
width: 100%;
|
|
210
|
-
padding:
|
|
364
|
+
padding: 12px 16px;
|
|
211
365
|
border: 0;
|
|
212
|
-
border-bottom: 1px solid #
|
|
366
|
+
border-bottom: 1px solid #EEF0F3;
|
|
213
367
|
font: inherit;
|
|
214
368
|
color: inherit;
|
|
215
369
|
text-align: left;
|
|
216
|
-
background:
|
|
370
|
+
background: #ffffff;
|
|
217
371
|
cursor: pointer;
|
|
218
372
|
}
|
|
219
373
|
.wa-list__row:hover {
|
|
220
|
-
background: #
|
|
374
|
+
background: #F7F8FC;
|
|
221
375
|
}
|
|
222
376
|
/* El seleccionado se marca por el MISMO atributo que lo anuncia a un lector de pantalla: si un día
|
|
223
377
|
alguien saca el aria-current, el resaltado se va con él y el bug se ve. */
|
|
224
378
|
.wa-list__row[aria-current='true'] {
|
|
225
|
-
background: #
|
|
379
|
+
background: #F5F7FE;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
/* El avatar de iniciales: círculo de 36px, índigo suave. Es decoración (\`aria-hidden\` en el
|
|
383
|
+
TSX): el nombre está al lado. Su CONTENIDO son las iniciales que devuelve initials(), como
|
|
384
|
+
texto — jamás en una clase ni en un selector. */
|
|
385
|
+
.wa-list__avatar {
|
|
386
|
+
display: flex;
|
|
387
|
+
flex: 0 0 auto;
|
|
388
|
+
align-items: center;
|
|
389
|
+
justify-content: center;
|
|
390
|
+
width: 36px;
|
|
391
|
+
height: 36px;
|
|
392
|
+
border-radius: 50%;
|
|
393
|
+
font-size: 13px;
|
|
394
|
+
font-weight: 700;
|
|
395
|
+
color: #4E5BEF;
|
|
396
|
+
background: #EEF1FE;
|
|
397
|
+
}
|
|
398
|
+
/* El sólido de la fila seleccionada cuelga del MISMO aria-current que el resaltado de la fila, y
|
|
399
|
+
no de una clase calculada en JS: un solo gancho para el resaltado y para el lector de pantalla. */
|
|
400
|
+
.wa-list__row[aria-current='true'] .wa-list__avatar {
|
|
401
|
+
color: #ffffff;
|
|
402
|
+
background: #4E5BEF;
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
/* La columna de contenido. \`min-width: 0\` es lo que deja que el ellipsis del título y del
|
|
406
|
+
preview funcione dentro de un flex item. */
|
|
407
|
+
.wa-list__middle {
|
|
408
|
+
display: flex;
|
|
409
|
+
flex: 1 1 0;
|
|
410
|
+
min-width: 0;
|
|
411
|
+
flex-direction: column;
|
|
412
|
+
gap: 3px;
|
|
226
413
|
}
|
|
227
414
|
|
|
228
415
|
.wa-list__head {
|
|
229
416
|
display: flex;
|
|
230
|
-
align-items:
|
|
417
|
+
align-items: center;
|
|
231
418
|
justify-content: space-between;
|
|
232
419
|
gap: 8px;
|
|
233
420
|
}
|
|
234
421
|
.wa-list__title {
|
|
235
422
|
overflow: hidden;
|
|
236
|
-
font-
|
|
423
|
+
font-size: 14px;
|
|
424
|
+
font-weight: 700;
|
|
425
|
+
color: #2D3340;
|
|
237
426
|
text-overflow: ellipsis;
|
|
238
427
|
white-space: nowrap;
|
|
239
428
|
}
|
|
240
429
|
.wa-list__time {
|
|
241
430
|
flex: 0 0 auto;
|
|
242
|
-
font-size:
|
|
243
|
-
color: #
|
|
431
|
+
font-size: 11px;
|
|
432
|
+
color: #8A91A0;
|
|
433
|
+
}
|
|
434
|
+
/* El teléfono de la fila, verbatim (E.164 con \`+\`): formatear exige lógica por país e \`Intl\`
|
|
435
|
+
está proscrito acá. */
|
|
436
|
+
.wa-list__phone {
|
|
437
|
+
overflow: hidden;
|
|
438
|
+
font-size: 11.5px;
|
|
439
|
+
color: #8A91A0;
|
|
440
|
+
text-overflow: ellipsis;
|
|
441
|
+
white-space: nowrap;
|
|
244
442
|
}
|
|
245
443
|
.wa-list__preview {
|
|
246
444
|
overflow: hidden;
|
|
247
|
-
|
|
445
|
+
font-size: 12.5px;
|
|
446
|
+
color: #5B6472;
|
|
248
447
|
text-overflow: ellipsis;
|
|
249
448
|
white-space: nowrap;
|
|
250
449
|
}
|
|
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
|
|
450
|
+
/* El estado del emisor es una cadena OPACA que escribe otro servicio: se pinta como texto dentro
|
|
451
|
+
de una pill y nada más. Nunca se interpola su valor en un selector ni en una clase
|
|
452
|
+
(C-01 / T-03-02) — la pill es cosmética del contenedor, no del valor. */
|
|
253
453
|
.wa-list__state {
|
|
254
454
|
align-self: flex-start;
|
|
455
|
+
max-width: 100%;
|
|
456
|
+
padding: 2px 8px;
|
|
457
|
+
border-radius: 999px;
|
|
255
458
|
font-size: 11px;
|
|
256
|
-
|
|
459
|
+
font-weight: 600;
|
|
460
|
+
color: #6B7280;
|
|
461
|
+
background: #F1F2F5;
|
|
257
462
|
word-break: break-word;
|
|
258
463
|
}
|
|
259
464
|
|
|
260
|
-
/* Angosto:
|
|
261
|
-
|
|
262
|
-
.wa-list[data-layout='narrow'] .wa-list__head {
|
|
263
|
-
display: contents;
|
|
264
|
-
}
|
|
265
|
-
.wa-list[data-layout='narrow'] .wa-list__time {
|
|
266
|
-
order: 1;
|
|
267
|
-
}
|
|
268
|
-
.wa-list[data-layout='narrow'] .wa-list__state {
|
|
269
|
-
order: 2;
|
|
270
|
-
}
|
|
465
|
+
/* Angosto: sólo se deja envolver el texto. El \`display: contents\` que antes sacaba al agrupador
|
|
466
|
+
del flujo ya no hace falta — la columna .wa-list__middle apila por sí sola. */
|
|
271
467
|
.wa-list[data-layout='narrow'] .wa-list__preview,
|
|
272
468
|
.wa-list[data-layout='narrow'] .wa-list__title {
|
|
273
469
|
white-space: normal;
|
|
@@ -943,6 +1139,21 @@ function useConversations({ fetcher, filters = NO_FILTERS$1 }) {
|
|
|
943
1139
|
*/
|
|
944
1140
|
/** Identidad estable para "sin filtros": un `{}` nuevo por render reiniciaría la lista sin parar. */
|
|
945
1141
|
const NO_FILTERS = {};
|
|
1142
|
+
/**
|
|
1143
|
+
* El rango local `YYYY-MM-DD` de un preset: `to` = hoy, `from` = hoy − (days − 1) — el rango
|
|
1144
|
+
* INCLUYE hoy («7 días» son siete fechas contando la de hoy). Fechas locales con
|
|
1145
|
+
* `getFullYear/getMonth/getDate` + padStart, sin Intl (coherente con DEC-K/DEC-O). El formato es
|
|
1146
|
+
* el MISMO que ya producían los `<input type="date">`, así que DEC-J (los valores viajan tal
|
|
1147
|
+
* cual al descriptor) no cambia.
|
|
1148
|
+
*/
|
|
1149
|
+
function presetRange(days) {
|
|
1150
|
+
const format = (date) => `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, "0")}-${String(date.getDate()).padStart(2, "0")}`;
|
|
1151
|
+
const now = /* @__PURE__ */ new Date();
|
|
1152
|
+
return {
|
|
1153
|
+
from: format(new Date(now.getFullYear(), now.getMonth(), now.getDate() - (days - 1))),
|
|
1154
|
+
to: format(now)
|
|
1155
|
+
};
|
|
1156
|
+
}
|
|
946
1157
|
function ConversationList({ fetcher, selectedPhone, onSelect, className }) {
|
|
947
1158
|
const fieldId = useId();
|
|
948
1159
|
/**
|
|
@@ -955,6 +1166,11 @@ function ConversationList({ fetcher, selectedPhone, onSelect, className }) {
|
|
|
955
1166
|
const [phone, setPhone] = useState("");
|
|
956
1167
|
const [from, setFrom] = useState("");
|
|
957
1168
|
const [to, setTo] = useState("");
|
|
1169
|
+
/**
|
|
1170
|
+
* El preset de fecha activo (DEV-5053). Vive ACÁ y no en `useConversations`: es estado del
|
|
1171
|
+
* formulario — el hook sigue viendo sólo la consulta aplicada, igual que con los date inputs.
|
|
1172
|
+
*/
|
|
1173
|
+
const [datePreset, setDatePreset] = useState(null);
|
|
958
1174
|
/** La consulta vigente. Su IDENTIDAD es lo que el hook mira para reiniciar la lista. */
|
|
959
1175
|
const [filters, setFilters] = useState(NO_FILTERS);
|
|
960
1176
|
const { items, status, error, hasMore, loadMore, retry, autoLoadExhausted } = useConversations({
|
|
@@ -973,10 +1189,45 @@ function ConversationList({ fetcher, selectedPhone, onSelect, className }) {
|
|
|
973
1189
|
if (to !== "") next.to = to;
|
|
974
1190
|
setFilters(next);
|
|
975
1191
|
};
|
|
1192
|
+
/**
|
|
1193
|
+
* Un preset ≠ «Rango…» aplica AL CLIC: calcula el rango, sincroniza los date inputs (por si el
|
|
1194
|
+
* operador después abre «Rango…» para ajustar) y arma la consulta con el mismo criterio de
|
|
1195
|
+
* omisión de vacíos que `applyFilters`, conservando el teléfono tipeado.
|
|
1196
|
+
*/
|
|
1197
|
+
const applyPreset = (preset, days) => {
|
|
1198
|
+
setDatePreset(preset);
|
|
1199
|
+
const range = presetRange(days);
|
|
1200
|
+
setFrom(range.from);
|
|
1201
|
+
setTo(range.to);
|
|
1202
|
+
const next = {};
|
|
1203
|
+
if (phone.trim() !== "") next.phone = phone;
|
|
1204
|
+
next.from = range.from;
|
|
1205
|
+
next.to = range.to;
|
|
1206
|
+
setFilters(next);
|
|
1207
|
+
};
|
|
1208
|
+
/**
|
|
1209
|
+
* El rango aplica al cambiar cualquiera de las dos fechas, sin botón de confirmación. Recibe los
|
|
1210
|
+
* dos valores por parámetro y no del estado: `setFrom`/`setTo` son asíncronos, así que leer el
|
|
1211
|
+
* estado acá aplicaría el rango anterior — el clásico off-by-one-render.
|
|
1212
|
+
*
|
|
1213
|
+
* Un extremo vacío se omite (mismo criterio que `applyFilters`): media ventana es un filtro
|
|
1214
|
+
* legítimo, «desde el 1 de agosto» sin tope.
|
|
1215
|
+
*/
|
|
1216
|
+
const applyRange = (nextFrom, nextTo) => {
|
|
1217
|
+
setDatePreset("range");
|
|
1218
|
+
setFrom(nextFrom);
|
|
1219
|
+
setTo(nextTo);
|
|
1220
|
+
const next = {};
|
|
1221
|
+
if (phone.trim() !== "") next.phone = phone;
|
|
1222
|
+
if (nextFrom !== "") next.from = nextFrom;
|
|
1223
|
+
if (nextTo !== "") next.to = nextTo;
|
|
1224
|
+
setFilters(next);
|
|
1225
|
+
};
|
|
976
1226
|
const clearFilters = () => {
|
|
977
1227
|
setPhone("");
|
|
978
1228
|
setFrom("");
|
|
979
1229
|
setTo("");
|
|
1230
|
+
setDatePreset(null);
|
|
980
1231
|
setFilters(NO_FILTERS);
|
|
981
1232
|
};
|
|
982
1233
|
/**
|
|
@@ -1012,51 +1263,117 @@ function ConversationList({ fetcher, selectedPhone, onSelect, className }) {
|
|
|
1012
1263
|
onSubmit: applyFilters,
|
|
1013
1264
|
children: [
|
|
1014
1265
|
/* @__PURE__ */ jsxs("div", {
|
|
1015
|
-
className: "wa-
|
|
1016
|
-
children: [
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1266
|
+
className: "wa-list__search",
|
|
1267
|
+
children: [
|
|
1268
|
+
/* @__PURE__ */ jsx("label", {
|
|
1269
|
+
className: "wa-list__sr-only",
|
|
1270
|
+
htmlFor: `${fieldId}-phone`,
|
|
1271
|
+
children: "Buscar por nombre o teléfono"
|
|
1272
|
+
}),
|
|
1273
|
+
/* @__PURE__ */ jsxs("svg", {
|
|
1274
|
+
className: "wa-list__search-icon",
|
|
1275
|
+
viewBox: "0 0 16 16",
|
|
1276
|
+
width: "14",
|
|
1277
|
+
height: "14",
|
|
1278
|
+
"aria-hidden": "true",
|
|
1279
|
+
focusable: "false",
|
|
1280
|
+
children: [/* @__PURE__ */ jsx("circle", {
|
|
1281
|
+
cx: "7",
|
|
1282
|
+
cy: "7",
|
|
1283
|
+
r: "4.5",
|
|
1284
|
+
fill: "none",
|
|
1285
|
+
stroke: "currentColor",
|
|
1286
|
+
strokeWidth: "1.5"
|
|
1287
|
+
}), /* @__PURE__ */ jsx("path", {
|
|
1288
|
+
d: "M10.5 10.5 14 14",
|
|
1289
|
+
stroke: "currentColor",
|
|
1290
|
+
strokeWidth: "1.5",
|
|
1291
|
+
strokeLinecap: "round"
|
|
1292
|
+
})]
|
|
1293
|
+
}),
|
|
1294
|
+
/* @__PURE__ */ jsx("input", {
|
|
1295
|
+
id: `${fieldId}-phone`,
|
|
1296
|
+
type: "search",
|
|
1297
|
+
placeholder: "Buscar por nombre o teléfono",
|
|
1298
|
+
value: phone,
|
|
1299
|
+
onChange: (event) => setPhone(event.target.value)
|
|
1300
|
+
})
|
|
1301
|
+
]
|
|
1025
1302
|
}),
|
|
1026
1303
|
/* @__PURE__ */ jsxs("div", {
|
|
1027
|
-
className: "wa-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1304
|
+
className: "wa-list__presets",
|
|
1305
|
+
role: "group",
|
|
1306
|
+
"aria-label": "Filtrar por fecha",
|
|
1307
|
+
children: [
|
|
1308
|
+
/* @__PURE__ */ jsx("button", {
|
|
1309
|
+
type: "button",
|
|
1310
|
+
className: "wa-list__preset",
|
|
1311
|
+
"aria-pressed": datePreset === "today",
|
|
1312
|
+
onClick: () => applyPreset("today", 1),
|
|
1313
|
+
children: "Hoy"
|
|
1314
|
+
}),
|
|
1315
|
+
/* @__PURE__ */ jsx("button", {
|
|
1316
|
+
type: "button",
|
|
1317
|
+
className: "wa-list__preset",
|
|
1318
|
+
"aria-pressed": datePreset === "7d",
|
|
1319
|
+
onClick: () => applyPreset("7d", 7),
|
|
1320
|
+
children: "7 días"
|
|
1321
|
+
}),
|
|
1322
|
+
/* @__PURE__ */ jsx("button", {
|
|
1323
|
+
type: "button",
|
|
1324
|
+
className: "wa-list__preset",
|
|
1325
|
+
"aria-pressed": datePreset === "30d",
|
|
1326
|
+
onClick: () => applyPreset("30d", 30),
|
|
1327
|
+
children: "30 días"
|
|
1328
|
+
}),
|
|
1329
|
+
/* @__PURE__ */ jsx("button", {
|
|
1330
|
+
type: "button",
|
|
1331
|
+
className: "wa-list__preset",
|
|
1332
|
+
"aria-pressed": datePreset === "range",
|
|
1333
|
+
onClick: () => setDatePreset("range"),
|
|
1334
|
+
children: "Rango…"
|
|
1335
|
+
})
|
|
1336
|
+
]
|
|
1037
1337
|
}),
|
|
1038
|
-
/* @__PURE__ */ jsxs("div", {
|
|
1039
|
-
className: "wa-
|
|
1040
|
-
children: [
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1338
|
+
datePreset === "range" && /* @__PURE__ */ jsxs("div", {
|
|
1339
|
+
className: "wa-list__range",
|
|
1340
|
+
children: [
|
|
1341
|
+
/* @__PURE__ */ jsx("label", {
|
|
1342
|
+
className: "wa-list__sr-only",
|
|
1343
|
+
htmlFor: `${fieldId}-from`,
|
|
1344
|
+
children: "Desde"
|
|
1345
|
+
}),
|
|
1346
|
+
/* @__PURE__ */ jsx("input", {
|
|
1347
|
+
id: `${fieldId}-from`,
|
|
1348
|
+
type: "date",
|
|
1349
|
+
className: "wa-list__date",
|
|
1350
|
+
value: from,
|
|
1351
|
+
onChange: (event) => applyRange(event.target.value, to)
|
|
1352
|
+
}),
|
|
1353
|
+
/* @__PURE__ */ jsx("span", {
|
|
1354
|
+
className: "wa-list__range-sep",
|
|
1355
|
+
"aria-hidden": "true",
|
|
1356
|
+
children: "→"
|
|
1357
|
+
}),
|
|
1358
|
+
/* @__PURE__ */ jsx("label", {
|
|
1359
|
+
className: "wa-list__sr-only",
|
|
1360
|
+
htmlFor: `${fieldId}-to`,
|
|
1361
|
+
children: "Hasta"
|
|
1362
|
+
}),
|
|
1363
|
+
/* @__PURE__ */ jsx("input", {
|
|
1364
|
+
id: `${fieldId}-to`,
|
|
1365
|
+
type: "date",
|
|
1366
|
+
className: "wa-list__date",
|
|
1367
|
+
value: to,
|
|
1368
|
+
onChange: (event) => applyRange(from, event.target.value)
|
|
1369
|
+
})
|
|
1370
|
+
]
|
|
1049
1371
|
}),
|
|
1050
|
-
/* @__PURE__ */
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
}), /* @__PURE__ */ jsx("button", {
|
|
1056
|
-
type: "button",
|
|
1057
|
-
onClick: clearFilters,
|
|
1058
|
-
children: "Limpiar"
|
|
1059
|
-
})]
|
|
1372
|
+
hasFilters && /* @__PURE__ */ jsx("button", {
|
|
1373
|
+
type: "button",
|
|
1374
|
+
className: "wa-list__clear",
|
|
1375
|
+
onClick: clearFilters,
|
|
1376
|
+
children: "Limpiar filtros"
|
|
1060
1377
|
})
|
|
1061
1378
|
]
|
|
1062
1379
|
}),
|
|
@@ -1129,8 +1446,6 @@ function ConversationList({ fetcher, selectedPhone, onSelect, className }) {
|
|
|
1129
1446
|
* header del drawer del embudo de `lms-mf-lifters`, que es donde el MF ya tiene cargado el
|
|
1130
1447
|
* detalle del embudo. Acá se menciona para que el operador sepa a dónde ir — nunca se ejecuta.
|
|
1131
1448
|
*/
|
|
1132
|
-
/** A partir de acá se muestra el contador: antes es ruido, después es información. */
|
|
1133
|
-
const COUNTER_THRESHOLD = 3896;
|
|
1134
1449
|
/**
|
|
1135
1450
|
* El aviso de los envíos que no salieron.
|
|
1136
1451
|
*
|
|
@@ -1152,6 +1467,7 @@ function FailureNotice({ composer }) {
|
|
|
1152
1467
|
className: "wa-composer__failure-actions",
|
|
1153
1468
|
children: [entry.failure?.retryable === true && /* @__PURE__ */ jsx("button", {
|
|
1154
1469
|
type: "button",
|
|
1470
|
+
className: "wa-composer__failure-retry",
|
|
1155
1471
|
onClick: () => composer.retry(entry.clientMessageId),
|
|
1156
1472
|
children: "Reintentar"
|
|
1157
1473
|
}), /* @__PURE__ */ jsx("button", {
|
|
@@ -1208,17 +1524,43 @@ function ReleaseToBot({ composer }) {
|
|
|
1208
1524
|
]
|
|
1209
1525
|
});
|
|
1210
1526
|
}
|
|
1211
|
-
function Composer({ canReply, composer }) {
|
|
1527
|
+
function Composer({ canReply, composer, onRetryWindow }) {
|
|
1212
1528
|
const [draft, setDraft] = useState("");
|
|
1213
1529
|
if (!canReply) return null;
|
|
1214
1530
|
if (composer.windowState === "closed") return /* @__PURE__ */ jsxs("div", {
|
|
1215
1531
|
className: "wa-composer wa-composer--closed",
|
|
1216
1532
|
children: [
|
|
1217
1533
|
/* @__PURE__ */ jsx(FailureNotice, { composer }),
|
|
1218
|
-
/* @__PURE__ */
|
|
1219
|
-
className: "wa-
|
|
1534
|
+
/* @__PURE__ */ jsx("span", {
|
|
1535
|
+
className: "wa-composer__lock",
|
|
1536
|
+
children: /* @__PURE__ */ jsxs("svg", {
|
|
1537
|
+
width: 20,
|
|
1538
|
+
height: 20,
|
|
1539
|
+
viewBox: "0 0 20 20",
|
|
1540
|
+
fill: "none",
|
|
1541
|
+
stroke: "#8A91A0",
|
|
1542
|
+
strokeWidth: 1.6,
|
|
1543
|
+
strokeLinecap: "round",
|
|
1544
|
+
strokeLinejoin: "round",
|
|
1545
|
+
"aria-hidden": "true",
|
|
1546
|
+
children: [/* @__PURE__ */ jsx("rect", {
|
|
1547
|
+
x: "4.5",
|
|
1548
|
+
y: "9",
|
|
1549
|
+
width: "11",
|
|
1550
|
+
height: "7.5",
|
|
1551
|
+
rx: "1.5"
|
|
1552
|
+
}), /* @__PURE__ */ jsx("path", { d: "M7 9V6.5a3 3 0 0 1 6 0V9" })]
|
|
1553
|
+
})
|
|
1554
|
+
}),
|
|
1555
|
+
/* @__PURE__ */ jsxs("div", {
|
|
1220
1556
|
role: "status",
|
|
1221
|
-
children: [/* @__PURE__ */ jsx("
|
|
1557
|
+
children: [/* @__PURE__ */ jsx("p", {
|
|
1558
|
+
className: "wa-composer__cold-title",
|
|
1559
|
+
children: "La ventana de 24 horas está cerrada"
|
|
1560
|
+
}), /* @__PURE__ */ jsx("p", {
|
|
1561
|
+
className: "wa-composer__cold-explain",
|
|
1562
|
+
children: "WhatsApp solo permite responder hasta 24 h después del último mensaje del lifter. Se reabre cuando vuelva a escribir."
|
|
1563
|
+
})]
|
|
1222
1564
|
}),
|
|
1223
1565
|
/* @__PURE__ */ jsx(ReleaseToBot, { composer })
|
|
1224
1566
|
]
|
|
@@ -1232,10 +1574,24 @@ function Composer({ canReply, composer }) {
|
|
|
1232
1574
|
return /* @__PURE__ */ jsxs("div", {
|
|
1233
1575
|
className: "wa-composer",
|
|
1234
1576
|
children: [
|
|
1235
|
-
composer.windowState === "unverified" && /* @__PURE__ */
|
|
1577
|
+
composer.windowState === "unverified" && /* @__PURE__ */ jsxs("div", {
|
|
1236
1578
|
className: "wa-composer__unverified",
|
|
1237
1579
|
role: "status",
|
|
1238
|
-
children:
|
|
1580
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
1581
|
+
className: "wa-composer__unverified-text",
|
|
1582
|
+
children: [/* @__PURE__ */ jsx("p", {
|
|
1583
|
+
className: "wa-composer__unverified-title",
|
|
1584
|
+
children: "No pudimos verificar si se puede responder"
|
|
1585
|
+
}), /* @__PURE__ */ jsx("p", {
|
|
1586
|
+
className: "wa-composer__unverified-explain",
|
|
1587
|
+
children: "Es un error temporal, no una ventana cerrada."
|
|
1588
|
+
})]
|
|
1589
|
+
}), onRetryWindow !== void 0 && /* @__PURE__ */ jsx("button", {
|
|
1590
|
+
type: "button",
|
|
1591
|
+
className: "wa-composer__retry-window",
|
|
1592
|
+
onClick: onRetryWindow,
|
|
1593
|
+
children: "Reintentar"
|
|
1594
|
+
})]
|
|
1239
1595
|
}),
|
|
1240
1596
|
/* @__PURE__ */ jsx(FailureNotice, { composer }),
|
|
1241
1597
|
/* @__PURE__ */ jsxs("form", {
|
|
@@ -1258,20 +1614,27 @@ function Composer({ canReply, composer }) {
|
|
|
1258
1614
|
send();
|
|
1259
1615
|
}
|
|
1260
1616
|
}), /* @__PURE__ */ jsxs("div", {
|
|
1261
|
-
className: "wa-
|
|
1262
|
-
children: [
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1617
|
+
className: "wa-composer__hint-row",
|
|
1618
|
+
children: [
|
|
1619
|
+
/* @__PURE__ */ jsx("span", {
|
|
1620
|
+
className: "wa-composer__hint",
|
|
1621
|
+
children: "Al enviar, el bot se pausa 2 h y la conversación queda tomada por ti"
|
|
1622
|
+
}),
|
|
1623
|
+
/* @__PURE__ */ jsxs("span", {
|
|
1624
|
+
className: "wa-composer__counter",
|
|
1625
|
+
children: [
|
|
1626
|
+
draft.length,
|
|
1627
|
+
"/",
|
|
1628
|
+
REPLY_TEXT_MAX_LENGTH
|
|
1629
|
+
]
|
|
1630
|
+
}),
|
|
1631
|
+
/* @__PURE__ */ jsx("button", {
|
|
1632
|
+
type: "submit",
|
|
1633
|
+
className: "wa-composer__send",
|
|
1634
|
+
disabled: draft.trim() === "",
|
|
1635
|
+
children: "Enviar"
|
|
1636
|
+
})
|
|
1637
|
+
]
|
|
1275
1638
|
})]
|
|
1276
1639
|
})
|
|
1277
1640
|
]
|
|
@@ -1428,6 +1791,26 @@ function MediaUnavailable() {
|
|
|
1428
1791
|
children: "Adjunto no disponible"
|
|
1429
1792
|
});
|
|
1430
1793
|
}
|
|
1794
|
+
/** El icono de descarga (DEV-5053 / P6): flecha a bandeja, hereda color. La semántica la lleva
|
|
1795
|
+
* el anchor con su aria-label. */
|
|
1796
|
+
function DownloadGlyph() {
|
|
1797
|
+
return /* @__PURE__ */ jsxs("svg", {
|
|
1798
|
+
width: 16,
|
|
1799
|
+
height: 16,
|
|
1800
|
+
viewBox: "0 0 16 16",
|
|
1801
|
+
fill: "none",
|
|
1802
|
+
stroke: "currentColor",
|
|
1803
|
+
strokeWidth: 1.5,
|
|
1804
|
+
strokeLinecap: "round",
|
|
1805
|
+
strokeLinejoin: "round",
|
|
1806
|
+
"aria-hidden": "true",
|
|
1807
|
+
children: [
|
|
1808
|
+
/* @__PURE__ */ jsx("path", { d: "M8 2.5v7.5" }),
|
|
1809
|
+
/* @__PURE__ */ jsx("polyline", { points: "4.5,6.8 8,10.3 11.5,6.8" }),
|
|
1810
|
+
/* @__PURE__ */ jsx("path", { d: "M2.5 13.5h11" })
|
|
1811
|
+
]
|
|
1812
|
+
});
|
|
1813
|
+
}
|
|
1431
1814
|
/**
|
|
1432
1815
|
* Rama image: carga perezosa (no bloquea el render del hilo), miniatura clicable y lightbox
|
|
1433
1816
|
* propio, sin dependencias nuevas. Primer intento: la `media_url` del mensaje si viene; si es
|
|
@@ -1503,36 +1886,56 @@ function ImageAttachment({ message, fetcher, mediaId }) {
|
|
|
1503
1886
|
});
|
|
1504
1887
|
if (state.kind === "unavailable") return /* @__PURE__ */ jsx(MediaUnavailable, {});
|
|
1505
1888
|
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
|
-
|
|
1889
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
1890
|
+
/* @__PURE__ */ jsx("button", {
|
|
1891
|
+
type: "button",
|
|
1892
|
+
className: "wa-thread__media-button",
|
|
1893
|
+
onClick: () => setOpen(true),
|
|
1894
|
+
"aria-label": "Ampliar imagen adjunta",
|
|
1895
|
+
children: /* @__PURE__ */ jsx("img", {
|
|
1896
|
+
className: "wa-thread__media-img",
|
|
1897
|
+
src: state.url,
|
|
1898
|
+
alt,
|
|
1899
|
+
onError: handleImageError
|
|
1900
|
+
})
|
|
1901
|
+
}),
|
|
1902
|
+
/* @__PURE__ */ jsxs("div", {
|
|
1903
|
+
className: "wa-thread__media-file",
|
|
1904
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
1905
|
+
className: "wa-thread__media-name",
|
|
1906
|
+
children: attachmentLabel(message, "Imagen adjunta")
|
|
1907
|
+
}), /* @__PURE__ */ jsx(DownloadAttachment, {
|
|
1908
|
+
message,
|
|
1909
|
+
fetcher,
|
|
1910
|
+
mediaId,
|
|
1911
|
+
variant: "icon"
|
|
1912
|
+
})]
|
|
1913
|
+
}),
|
|
1914
|
+
open && /* @__PURE__ */ jsx("div", {
|
|
1915
|
+
className: "wa-thread__lightbox",
|
|
1916
|
+
role: "dialog",
|
|
1917
|
+
"aria-label": "Imagen ampliada",
|
|
1918
|
+
onClick: () => setOpen(false),
|
|
1919
|
+
children: /* @__PURE__ */ jsx("img", {
|
|
1920
|
+
className: "wa-thread__lightbox-img",
|
|
1921
|
+
src: state.url,
|
|
1922
|
+
alt
|
|
1923
|
+
})
|
|
1526
1924
|
})
|
|
1527
|
-
|
|
1925
|
+
] });
|
|
1528
1926
|
}
|
|
1529
1927
|
/**
|
|
1530
1928
|
* Rama descarga ('pdf' y 'other'): un solo `<a>` plano. La url se resuelve AL MOMENTO del clic —
|
|
1531
1929
|
* así nunca está vencida; un anchor no puede detectar una firma expirada, y por eso acá no aplica
|
|
1532
1930
|
* el primer intento con `media_url`. El onClick intercepta, resuelve, setea el href y re-dispara
|
|
1533
1931
|
* el clic programático (el guard deja pasar esa segunda pasada hacia la navegación real).
|
|
1932
|
+
*
|
|
1933
|
+
* `variant` (DEV-5053 / P6): `'label'` es el comportamiento de siempre (el file_name como texto
|
|
1934
|
+
* del link); `'icon'` es el MISMO anchor —misma resolución al clic, mismo blindaje T-05-03,
|
|
1935
|
+
* mismo 404 terminal— pero con un SVG de descarga adentro y el nombre en el `aria-label`. Lo usa
|
|
1936
|
+
* la fila de archivo de la imagen.
|
|
1534
1937
|
*/
|
|
1535
|
-
function DownloadAttachment({ message, fetcher, mediaId }) {
|
|
1938
|
+
function DownloadAttachment({ message, fetcher, mediaId, variant = "label" }) {
|
|
1536
1939
|
const [unavailable, setUnavailable] = useState(false);
|
|
1537
1940
|
const anchorRef = useRef(null);
|
|
1538
1941
|
/** true sólo durante el clic programático post-resolución: esa pasada navega, no re-resuelve. */
|
|
@@ -1565,6 +1968,17 @@ function DownloadAttachment({ message, fetcher, mediaId }) {
|
|
|
1565
1968
|
});
|
|
1566
1969
|
};
|
|
1567
1970
|
if (unavailable) return /* @__PURE__ */ jsx(MediaUnavailable, {});
|
|
1971
|
+
if (variant === "icon") return /* @__PURE__ */ jsx("a", {
|
|
1972
|
+
ref: anchorRef,
|
|
1973
|
+
className: "wa-thread__media-download wa-thread__media-download--icon",
|
|
1974
|
+
href: "#",
|
|
1975
|
+
download: true,
|
|
1976
|
+
target: "_blank",
|
|
1977
|
+
rel: "noopener noreferrer",
|
|
1978
|
+
onClick: handleClick,
|
|
1979
|
+
"aria-label": `Descargar ${typeof message.file_name === "string" && message.file_name !== "" ? message.file_name : "adjunto"}`,
|
|
1980
|
+
children: /* @__PURE__ */ jsx(DownloadGlyph, {})
|
|
1981
|
+
});
|
|
1568
1982
|
return /* @__PURE__ */ jsx("a", {
|
|
1569
1983
|
ref: anchorRef,
|
|
1570
1984
|
className: "wa-thread__media-download",
|
|
@@ -1608,30 +2022,51 @@ function MediaAttachment({ message, fetcher }) {
|
|
|
1608
2022
|
/**
|
|
1609
2023
|
* El tick de una saliente. El vocabulario conocido y nada más: lo desconocido devuelve `null` y la
|
|
1610
2024
|
* 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.
|
|
2025
|
+
* `read` usa el MISMO check doble que `delivered` y se distingue por color vía `data-status`: es
|
|
2026
|
+
* semántica de estado, no tema del host.
|
|
1613
2027
|
*/
|
|
1614
2028
|
function tickFor(status) {
|
|
1615
2029
|
switch (status) {
|
|
1616
2030
|
case "pending": return {
|
|
1617
|
-
|
|
2031
|
+
kind: "clock",
|
|
1618
2032
|
label: "Pendiente"
|
|
1619
2033
|
};
|
|
1620
2034
|
case "sent": return {
|
|
1621
|
-
|
|
2035
|
+
kind: "check",
|
|
1622
2036
|
label: "Enviado"
|
|
1623
2037
|
};
|
|
1624
2038
|
case "delivered": return {
|
|
1625
|
-
|
|
2039
|
+
kind: "check-check",
|
|
1626
2040
|
label: "Entregado"
|
|
1627
2041
|
};
|
|
1628
2042
|
case "read": return {
|
|
1629
|
-
|
|
2043
|
+
kind: "check-check",
|
|
1630
2044
|
label: "Leído"
|
|
1631
2045
|
};
|
|
1632
2046
|
default: return null;
|
|
1633
2047
|
}
|
|
1634
2048
|
}
|
|
2049
|
+
/**
|
|
2050
|
+
* El glifo del tick (DEV-5053 / P5). `clock` sigue siendo texto («◷»); los checks son SVG inline
|
|
2051
|
+
* con `stroke="currentColor"`: heredan el gris del meta y el azul de `[data-status='read']` del
|
|
2052
|
+
* CSS — la distinción de color por data-status queda exactamente como antes. `aria-hidden`: la
|
|
2053
|
+
* semántica ya la lleva el span envolvente con su aria-label.
|
|
2054
|
+
*/
|
|
2055
|
+
function TickGlyph({ kind }) {
|
|
2056
|
+
if (kind === "clock") return /* @__PURE__ */ jsx(Fragment$1, { children: "◷" });
|
|
2057
|
+
return /* @__PURE__ */ jsxs("svg", {
|
|
2058
|
+
width: 16,
|
|
2059
|
+
height: 16,
|
|
2060
|
+
viewBox: "0 0 16 16",
|
|
2061
|
+
fill: "none",
|
|
2062
|
+
stroke: "currentColor",
|
|
2063
|
+
strokeWidth: 1.8,
|
|
2064
|
+
strokeLinecap: "round",
|
|
2065
|
+
strokeLinejoin: "round",
|
|
2066
|
+
"aria-hidden": "true",
|
|
2067
|
+
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" })]
|
|
2068
|
+
});
|
|
2069
|
+
}
|
|
1635
2070
|
/** La hora HH:MM local de la burbuja (DEC-O). `null` si el instante no existe o no parsea. */
|
|
1636
2071
|
function formatHour(at) {
|
|
1637
2072
|
if (typeof at !== "string") return null;
|
|
@@ -1639,7 +2074,7 @@ function formatHour(at) {
|
|
|
1639
2074
|
if (Number.isNaN(date.getTime())) return null;
|
|
1640
2075
|
return `${String(date.getHours()).padStart(2, "0")}:${String(date.getMinutes()).padStart(2, "0")}`;
|
|
1641
2076
|
}
|
|
1642
|
-
function MessageBubble({ message,
|
|
2077
|
+
function MessageBubble({ message, optimistic = false, fetcher }) {
|
|
1643
2078
|
const direction = message.direction === "out" ? "out" : "in";
|
|
1644
2079
|
const hour = formatHour(message.at);
|
|
1645
2080
|
const ctas = threadCtas(message);
|
|
@@ -1656,7 +2091,6 @@ function MessageBubble({ message, showServiceState, optimistic = false, fetcher
|
|
|
1656
2091
|
* definición: la acaba de escribir él.
|
|
1657
2092
|
*/
|
|
1658
2093
|
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
2094
|
const locationFallback = message.body === null && message.message_type === "location" ? message.location_name ?? "Ubicación compartida" : null;
|
|
1661
2095
|
return /* @__PURE__ */ jsxs("div", {
|
|
1662
2096
|
className: "wa-thread__bubble",
|
|
@@ -1668,11 +2102,6 @@ function MessageBubble({ message, showServiceState, optimistic = false, fetcher
|
|
|
1668
2102
|
className: "wa-thread__author",
|
|
1669
2103
|
children: author
|
|
1670
2104
|
}),
|
|
1671
|
-
serviceState !== null && /* @__PURE__ */ jsx("span", {
|
|
1672
|
-
className: "wa-thread__state",
|
|
1673
|
-
title: serviceState,
|
|
1674
|
-
children: serviceState
|
|
1675
|
-
}),
|
|
1676
2105
|
message.body !== null && /* @__PURE__ */ jsx("p", {
|
|
1677
2106
|
className: "wa-thread__body",
|
|
1678
2107
|
children: message.body
|
|
@@ -1713,13 +2142,43 @@ function MessageBubble({ message, showServiceState, optimistic = false, fetcher
|
|
|
1713
2142
|
"data-status": message.status,
|
|
1714
2143
|
title: tick.label,
|
|
1715
2144
|
"aria-label": tick.label,
|
|
1716
|
-
children: tick.
|
|
2145
|
+
children: /* @__PURE__ */ jsx(TickGlyph, { kind: tick.kind })
|
|
1717
2146
|
})]
|
|
1718
2147
|
})
|
|
1719
2148
|
]
|
|
1720
2149
|
});
|
|
1721
2150
|
}
|
|
1722
2151
|
//#endregion
|
|
2152
|
+
//#region src/core/thread/service-state-labels.ts
|
|
2153
|
+
/**
|
|
2154
|
+
* Las etiquetas humanas de `service_state` para el HILO (DEV-5053 / P3). Interno del hilo —
|
|
2155
|
+
* NO sale al barrel.
|
|
2156
|
+
*
|
|
2157
|
+
* Este módulo supersede, SÓLO para el hilo, la regla «verbatim, mapeo prohibido» de THREAD-04/C-01:
|
|
2158
|
+
* DEV-5053 autorizó humanizar el paso del flujo en la píldora de transición y en el chip «Paso»
|
|
2159
|
+
* del header. La fila de la lista (`ConversationRow`) NO cambia: sigue pintando el valor crudo.
|
|
2160
|
+
*
|
|
2161
|
+
* La regla de seguridad del módulo es el FALLBACK VERBATIM: un valor sin entrada en la tabla se
|
|
2162
|
+
* devuelve EXACTAMENTE como llegó — un emisor que estrene un paso nuevo se lee crudo, nunca se
|
|
2163
|
+
* oculta ni se adivina. Y la etiqueta (humanizada o cruda) entra SOLO como hijo de texto, que
|
|
2164
|
+
* React escapa: jamás en className/style/selector (T-03-02 sigue vigente).
|
|
2165
|
+
*
|
|
2166
|
+
* Vocabulario inicial: el del fixture `contract/thread-v0.fixture.json` y el docstring de
|
|
2167
|
+
* `types.ts` — todos emitidos por `self_onboarding_whatsapp`.
|
|
2168
|
+
*/
|
|
2169
|
+
/** La tabla es-CO. Se consulta SOLO por clave propia: nada del prototipo puede colarse. */
|
|
2170
|
+
const SERVICE_STATE_LABELS = {
|
|
2171
|
+
collecting_vehicle_plate: "Placa del vehículo",
|
|
2172
|
+
collecting_vehicle_documents: "Documentos del vehículo",
|
|
2173
|
+
collecting_documents: "Documentos personales",
|
|
2174
|
+
existing_user_menu: "Menú de usuario registrado",
|
|
2175
|
+
activated: "Cuenta activada"
|
|
2176
|
+
};
|
|
2177
|
+
/** La etiqueta humana de un `service_state`, o el valor crudo VERBATIM si no hay entrada. */
|
|
2178
|
+
function serviceStateLabel(value) {
|
|
2179
|
+
return Object.prototype.hasOwnProperty.call(SERVICE_STATE_LABELS, value) ? SERVICE_STATE_LABELS[value] : value;
|
|
2180
|
+
}
|
|
2181
|
+
//#endregion
|
|
1723
2182
|
//#region src/core/thread/thread-styles.ts
|
|
1724
2183
|
/**
|
|
1725
2184
|
* El CSS del hilo, como string, para que viaje DENTRO del componente — mismas razones que
|
|
@@ -1730,8 +2189,11 @@ function MessageBubble({ message, showServiceState, optimistic = false, fetcher
|
|
|
1730
2189
|
*
|
|
1731
2190
|
* - 🔴 **Todos los selectores van prefijados con `.wa-thread`.** En el entry `./react` NO hay
|
|
1732
2191
|
* 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
|
-
*
|
|
2192
|
+
* - **Sin tokens del LMS, sin variables, sin `@import`, sin fuentes remotas** (C-04). El paquete
|
|
2193
|
+
* monta en tres hosts con temas distintos. La paleta de acá (índigo #4F5AED/#EEF1FE, ámbar,
|
|
2194
|
+
* grises #F4F5F7/#E4E7EE) NO es un tema inventado: viene del diseño aprobado de DEV-5053
|
|
2195
|
+
* (.pen), y sigue sin depender de tokens del host. `Inter` va sólo como primer nombre del font
|
|
2196
|
+
* stack — si el host la carga se usa, si no cae a system-ui.
|
|
1735
2197
|
* - **El scroll del hilo VIVE en `.wa-thread__messages`** (`overflow-y: auto` + `min-height: 0`):
|
|
1736
2198
|
* es el contenedor que la paginación hacia atrás ancla en la Task 3 — moverlo de lugar rompe la
|
|
1737
2199
|
* compensación de `scrollTop`.
|
|
@@ -1743,11 +2205,11 @@ const THREAD_CSS = `
|
|
|
1743
2205
|
min-height: 0;
|
|
1744
2206
|
flex: 1 1 auto;
|
|
1745
2207
|
flex-direction: column;
|
|
1746
|
-
font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
|
|
2208
|
+
font-family: Inter, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
|
|
1747
2209
|
font-size: 14px;
|
|
1748
2210
|
line-height: 1.5;
|
|
1749
|
-
color: #
|
|
1750
|
-
background: #
|
|
2211
|
+
color: #2D3340;
|
|
2212
|
+
background: #F7F6F2;
|
|
1751
2213
|
}
|
|
1752
2214
|
.wa-thread *,
|
|
1753
2215
|
.wa-thread *::before,
|
|
@@ -1761,8 +2223,8 @@ const THREAD_CSS = `
|
|
|
1761
2223
|
flex: 1 1 auto;
|
|
1762
2224
|
min-height: 0;
|
|
1763
2225
|
flex-direction: column;
|
|
1764
|
-
gap:
|
|
1765
|
-
padding:
|
|
2226
|
+
gap: 10px;
|
|
2227
|
+
padding: 14px;
|
|
1766
2228
|
overflow-y: auto;
|
|
1767
2229
|
}
|
|
1768
2230
|
|
|
@@ -1791,56 +2253,60 @@ const THREAD_CSS = `
|
|
|
1791
2253
|
.wa-thread__group {
|
|
1792
2254
|
display: flex;
|
|
1793
2255
|
flex-direction: column;
|
|
1794
|
-
gap:
|
|
2256
|
+
gap: 10px;
|
|
1795
2257
|
}
|
|
1796
2258
|
|
|
1797
|
-
/* Separador de día:
|
|
2259
|
+
/* Separador de día: una pill discreta y centrada (diseño .pen de DEV-5053). */
|
|
1798
2260
|
.wa-thread__day {
|
|
1799
2261
|
align-self: center;
|
|
1800
|
-
margin:
|
|
1801
|
-
padding:
|
|
1802
|
-
border-radius:
|
|
1803
|
-
font-size:
|
|
1804
|
-
|
|
1805
|
-
|
|
2262
|
+
margin: 4px 0;
|
|
2263
|
+
padding: 3px 10px;
|
|
2264
|
+
border-radius: 999px;
|
|
2265
|
+
font-size: 10.5px;
|
|
2266
|
+
font-weight: 600;
|
|
2267
|
+
color: #6B7280;
|
|
2268
|
+
background: #ECEDF1;
|
|
1806
2269
|
}
|
|
1807
2270
|
|
|
2271
|
+
/* El ancho sigue siendo relativo (75%) y no los 300px fijos del frame: el visor monta en tres
|
|
2272
|
+
hosts de ancho distinto y un ancho fijo rompe el modo angosto. */
|
|
1808
2273
|
.wa-thread__bubble {
|
|
1809
2274
|
display: flex;
|
|
1810
2275
|
max-width: 75%;
|
|
1811
2276
|
flex-direction: column;
|
|
1812
|
-
gap:
|
|
1813
|
-
padding:
|
|
1814
|
-
border-radius:
|
|
2277
|
+
gap: 4px;
|
|
2278
|
+
padding: 8px 10px;
|
|
2279
|
+
border-radius: 10px;
|
|
1815
2280
|
overflow-wrap: anywhere;
|
|
1816
2281
|
}
|
|
1817
|
-
/* Entrante: a la izquierda,
|
|
2282
|
+
/* Entrante: a la izquierda, blanca. Lo desconocido cae acá (enums abiertos). */
|
|
1818
2283
|
.wa-thread__bubble[data-direction='in'] {
|
|
1819
2284
|
align-self: flex-start;
|
|
1820
2285
|
background: #ffffff;
|
|
1821
|
-
border: 1px solid #
|
|
2286
|
+
border: 1px solid #EBEDF1;
|
|
1822
2287
|
}
|
|
1823
|
-
/* Saliente: a la derecha,
|
|
2288
|
+
/* Saliente: a la derecha, el verde del diseño. */
|
|
1824
2289
|
.wa-thread__bubble[data-direction='out'] {
|
|
1825
2290
|
align-self: flex-end;
|
|
1826
|
-
background: #
|
|
1827
|
-
border: 1px solid #
|
|
1828
|
-
}
|
|
1829
|
-
/* COMP-03
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
2291
|
+
background: #E9F6EC;
|
|
2292
|
+
border: 1px solid #DDEEE2;
|
|
2293
|
+
}
|
|
2294
|
+
/* COMP-03 reconciliado con el diseño (D-01): el verde de arriba es el de TODA saliente — el
|
|
2295
|
+
diseño sólo modela mensajes del bot, así que no trae un color para el humano. Lo que distingue
|
|
2296
|
+
a la persona es el acento índigo del borde izquierdo (el mismo acento de los avatares y del CTA
|
|
2297
|
+
navegable), que se ve de un golpe y sobrevive a que la línea del nombre se scrollee. Un relleno
|
|
2298
|
+
propio quedaría inventado y chocaría con la píldora de flujo, que ya usa ese par. */
|
|
1833
2299
|
.wa-thread__bubble[data-direction='out'][data-author='operator'] {
|
|
1834
|
-
|
|
1835
|
-
border-color: #bfe0c8;
|
|
1836
|
-
border-left: 3px solid #2e7d47;
|
|
2300
|
+
border-left: 3px solid #4E5BEF;
|
|
1837
2301
|
}
|
|
1838
2302
|
.wa-thread__bubble[data-direction='out'][data-author='operator'] .wa-thread__author {
|
|
1839
|
-
color: #
|
|
2303
|
+
color: #4E5BEF;
|
|
1840
2304
|
}
|
|
1841
2305
|
|
|
1842
2306
|
.wa-thread__body {
|
|
1843
2307
|
margin: 0;
|
|
2308
|
+
font-size: 13px;
|
|
2309
|
+
color: #2D3340;
|
|
1844
2310
|
white-space: pre-wrap;
|
|
1845
2311
|
}
|
|
1846
2312
|
|
|
@@ -1848,18 +2314,24 @@ const THREAD_CSS = `
|
|
|
1848
2314
|
.wa-thread__meta {
|
|
1849
2315
|
display: flex;
|
|
1850
2316
|
align-self: flex-end;
|
|
1851
|
-
align-items:
|
|
2317
|
+
align-items: center;
|
|
2318
|
+
justify-content: flex-end;
|
|
1852
2319
|
gap: 4px;
|
|
1853
|
-
font-size:
|
|
1854
|
-
color: #
|
|
2320
|
+
font-size: 10.5px;
|
|
2321
|
+
color: #9AA1AE;
|
|
1855
2322
|
}
|
|
1856
2323
|
.wa-thread__hour {
|
|
1857
|
-
font-size:
|
|
1858
|
-
color: #
|
|
2324
|
+
font-size: 10.5px;
|
|
2325
|
+
color: #9AA1AE;
|
|
1859
2326
|
}
|
|
1860
2327
|
.wa-thread__tick {
|
|
2328
|
+
display: inline-flex;
|
|
2329
|
+
align-items: center;
|
|
1861
2330
|
letter-spacing: -0.12em;
|
|
1862
2331
|
}
|
|
2332
|
+
.wa-thread__tick svg {
|
|
2333
|
+
display: block;
|
|
2334
|
+
}
|
|
1863
2335
|
/* \`read\` se distingue por color: un azul genérico — semántica de estado, no tema del host. */
|
|
1864
2336
|
.wa-thread__tick[data-status='read'] {
|
|
1865
2337
|
color: #2f6fde;
|
|
@@ -1881,13 +2353,88 @@ const THREAD_CSS = `
|
|
|
1881
2353
|
color: #52606d;
|
|
1882
2354
|
}
|
|
1883
2355
|
|
|
1884
|
-
/*
|
|
1885
|
-
|
|
1886
|
-
.wa-
|
|
1887
|
-
align-self:
|
|
2356
|
+
/* La píldora de flujo (DEV-5053 / P4): centrada, pinta la TRANSICIÓN de service_state con la
|
|
2357
|
+
etiqueta humanizada. El valor jamás se interpola en un selector ni en una clase (THREAD-04). */
|
|
2358
|
+
.wa-thread__flow-pill {
|
|
2359
|
+
align-self: center;
|
|
2360
|
+
margin: 2px 0;
|
|
2361
|
+
padding: 3px 10px;
|
|
2362
|
+
border-radius: 999px;
|
|
2363
|
+
font-size: 10.5px;
|
|
2364
|
+
font-weight: 600;
|
|
2365
|
+
color: #5B63C7;
|
|
2366
|
+
background: #EEF1FE;
|
|
2367
|
+
}
|
|
2368
|
+
|
|
2369
|
+
/* El header del hilo (DEV-5053): la identidad de la persona, SIEMPRE presente. Lo que aparece y
|
|
2370
|
+
desaparece con el flujo es la fila de chips, no el header. */
|
|
2371
|
+
.wa-thread__header {
|
|
2372
|
+
display: flex;
|
|
2373
|
+
flex: 0 0 auto;
|
|
2374
|
+
flex-direction: column;
|
|
2375
|
+
gap: 8px;
|
|
2376
|
+
padding: 14px 16px;
|
|
2377
|
+
border-bottom: 1px solid #EEF0F3;
|
|
2378
|
+
background: #ffffff;
|
|
2379
|
+
}
|
|
2380
|
+
.wa-thread__identity {
|
|
2381
|
+
display: flex;
|
|
2382
|
+
align-items: center;
|
|
2383
|
+
gap: 10px;
|
|
2384
|
+
}
|
|
2385
|
+
/* El avatar del header lleva el índigo SUAVE: el sólido está reservado a la fila seleccionada de
|
|
2386
|
+
la lista, que es donde significa "estás mirando ésta". */
|
|
2387
|
+
.wa-thread__avatar {
|
|
2388
|
+
display: flex;
|
|
2389
|
+
flex: 0 0 auto;
|
|
2390
|
+
align-items: center;
|
|
2391
|
+
justify-content: center;
|
|
2392
|
+
width: 36px;
|
|
2393
|
+
height: 36px;
|
|
2394
|
+
border-radius: 50%;
|
|
2395
|
+
font-size: 13px;
|
|
2396
|
+
font-weight: 700;
|
|
2397
|
+
color: #4E5BEF;
|
|
2398
|
+
background: #EEF1FE;
|
|
2399
|
+
}
|
|
2400
|
+
.wa-thread__who {
|
|
2401
|
+
display: flex;
|
|
2402
|
+
min-width: 0;
|
|
2403
|
+
flex: 1 1 auto;
|
|
2404
|
+
flex-direction: column;
|
|
2405
|
+
gap: 1px;
|
|
2406
|
+
}
|
|
2407
|
+
.wa-thread__name {
|
|
2408
|
+
overflow: hidden;
|
|
2409
|
+
font-size: 14px;
|
|
2410
|
+
font-weight: 700;
|
|
2411
|
+
color: #2D3340;
|
|
2412
|
+
text-overflow: ellipsis;
|
|
2413
|
+
white-space: nowrap;
|
|
2414
|
+
}
|
|
2415
|
+
/* Verbatim, E.164 con \`+\` (D-04): formatear exige lógica por país y un formateo equivocado
|
|
2416
|
+
mutila el dato con el que ops identifica personas. */
|
|
2417
|
+
.wa-thread__phone {
|
|
2418
|
+
overflow: hidden;
|
|
2419
|
+
font-size: 12px;
|
|
2420
|
+
color: #8A91A0;
|
|
2421
|
+
text-overflow: ellipsis;
|
|
2422
|
+
white-space: nowrap;
|
|
2423
|
+
}
|
|
2424
|
+
.wa-thread__chips {
|
|
2425
|
+
display: flex;
|
|
2426
|
+
flex-wrap: wrap;
|
|
2427
|
+
align-items: center;
|
|
2428
|
+
gap: 6px;
|
|
2429
|
+
}
|
|
2430
|
+
.wa-thread__step {
|
|
2431
|
+
display: inline-block;
|
|
2432
|
+
padding: 3px 8px;
|
|
2433
|
+
border-radius: 999px;
|
|
1888
2434
|
font-size: 11px;
|
|
1889
|
-
|
|
1890
|
-
|
|
2435
|
+
font-weight: 600;
|
|
2436
|
+
color: #6B7280;
|
|
2437
|
+
background: #F1F2F5;
|
|
1891
2438
|
}
|
|
1892
2439
|
|
|
1893
2440
|
/* El slot de media (DEV-4988): miniatura, link de descarga o el estado unavailable.
|
|
@@ -1932,6 +2479,28 @@ const THREAD_CSS = `
|
|
|
1932
2479
|
.wa-thread__media-download:hover {
|
|
1933
2480
|
text-decoration: underline;
|
|
1934
2481
|
}
|
|
2482
|
+
/* La fila de archivo bajo la miniatura (DEV-5053 / P6): nombre + icono de descarga, sin peso. */
|
|
2483
|
+
.wa-thread__media-file {
|
|
2484
|
+
display: flex;
|
|
2485
|
+
align-items: center;
|
|
2486
|
+
gap: 8px;
|
|
2487
|
+
padding-top: 4px;
|
|
2488
|
+
}
|
|
2489
|
+
.wa-thread__media-name {
|
|
2490
|
+
font-size: 12px;
|
|
2491
|
+
color: #52606d;
|
|
2492
|
+
word-break: break-word;
|
|
2493
|
+
}
|
|
2494
|
+
/* La variante icono del download: mismo anchor, cosmética de icono. */
|
|
2495
|
+
.wa-thread__media-download--icon {
|
|
2496
|
+
display: inline-flex;
|
|
2497
|
+
align-items: center;
|
|
2498
|
+
padding: 2px;
|
|
2499
|
+
border: none;
|
|
2500
|
+
color: #4F5AED;
|
|
2501
|
+
background: none;
|
|
2502
|
+
line-height: 0;
|
|
2503
|
+
}
|
|
1935
2504
|
.wa-thread__media-loading,
|
|
1936
2505
|
.wa-thread__media-unavailable {
|
|
1937
2506
|
font-size: 12px;
|
|
@@ -1955,28 +2524,36 @@ const THREAD_CSS = `
|
|
|
1955
2524
|
}
|
|
1956
2525
|
|
|
1957
2526
|
/* CTAs: los links y los inertes se pintan IGUAL de visibles — la diferencia es la navegabilidad,
|
|
1958
|
-
no la existencia (THREAD-03).
|
|
2527
|
+
no la existencia (THREAD-03). Sobre esa base, D-03 reparte los dos pills del diseño por el ÚNICO
|
|
2528
|
+
dato disponible: el índigo es el navegable (isCtaLink) y el gris el inerte. No hay campo en el
|
|
2529
|
+
contrato que diga cuál es "primario", y adivinarlo sería inventar jerarquía. */
|
|
1959
2530
|
.wa-thread__ctas {
|
|
1960
2531
|
display: flex;
|
|
1961
2532
|
flex-wrap: wrap;
|
|
1962
2533
|
gap: 6px;
|
|
1963
2534
|
}
|
|
1964
2535
|
.wa-thread__cta {
|
|
1965
|
-
padding:
|
|
1966
|
-
border: 1px solid #
|
|
1967
|
-
border-radius:
|
|
1968
|
-
font-size:
|
|
2536
|
+
padding: 4px 10px;
|
|
2537
|
+
border: 1px solid #E4E7EE;
|
|
2538
|
+
border-radius: 999px;
|
|
2539
|
+
font-size: 11.5px;
|
|
2540
|
+
font-weight: 600;
|
|
1969
2541
|
background: #ffffff;
|
|
1970
2542
|
}
|
|
1971
2543
|
.wa-thread__cta--link {
|
|
1972
|
-
color: #
|
|
2544
|
+
border-color: #C9D2F5;
|
|
2545
|
+
color: #4E5BEF;
|
|
1973
2546
|
text-decoration: none;
|
|
1974
2547
|
}
|
|
1975
2548
|
.wa-thread__cta--link:hover {
|
|
1976
2549
|
text-decoration: underline;
|
|
1977
2550
|
}
|
|
2551
|
+
/* El inerte NO tiene regla de hover y declara cursor: default a conciencia — un inerte que
|
|
2552
|
+
reacciona al puntero promete un clic que no existe. */
|
|
1978
2553
|
.wa-thread__cta--inert {
|
|
1979
|
-
color: #
|
|
2554
|
+
border-color: #E4E7EE;
|
|
2555
|
+
color: #6B7280;
|
|
2556
|
+
cursor: default;
|
|
1980
2557
|
}
|
|
1981
2558
|
|
|
1982
2559
|
.wa-thread__note {
|
|
@@ -2011,8 +2588,8 @@ const THREAD_CSS = `
|
|
|
2011
2588
|
flex: 0 0 auto;
|
|
2012
2589
|
flex-direction: column;
|
|
2013
2590
|
gap: 8px;
|
|
2014
|
-
padding: 10px
|
|
2015
|
-
border-top: 1px solid #
|
|
2591
|
+
padding: 10px 14px;
|
|
2592
|
+
border-top: 1px solid #EEF0F3;
|
|
2016
2593
|
background: #ffffff;
|
|
2017
2594
|
}
|
|
2018
2595
|
|
|
@@ -2022,40 +2599,49 @@ const THREAD_CSS = `
|
|
|
2022
2599
|
gap: 6px;
|
|
2023
2600
|
}
|
|
2024
2601
|
.wa-composer__input {
|
|
2025
|
-
padding:
|
|
2026
|
-
border: 1px solid #
|
|
2027
|
-
border-radius:
|
|
2602
|
+
padding: 9px 12px;
|
|
2603
|
+
border: 1px solid #E4E7EE;
|
|
2604
|
+
border-radius: 12px;
|
|
2028
2605
|
font: inherit;
|
|
2029
|
-
|
|
2030
|
-
|
|
2606
|
+
font-size: 13px;
|
|
2607
|
+
color: #2D3340;
|
|
2608
|
+
background: #F4F5F7;
|
|
2031
2609
|
resize: vertical;
|
|
2032
2610
|
}
|
|
2033
2611
|
.wa-composer__input:focus {
|
|
2034
|
-
border-color: #
|
|
2035
|
-
outline: 2px solid rgba(
|
|
2612
|
+
border-color: #4F5AED;
|
|
2613
|
+
outline: 2px solid rgba(79, 90, 237, 0.25);
|
|
2036
2614
|
outline-offset: 0;
|
|
2037
2615
|
}
|
|
2038
|
-
|
|
2616
|
+
/* DEV-5053 P2: hint del takeover a la izquierda; contador y Enviar a la derecha. */
|
|
2617
|
+
.wa-composer__hint-row {
|
|
2039
2618
|
display: flex;
|
|
2040
2619
|
align-items: center;
|
|
2041
|
-
justify-content:
|
|
2620
|
+
justify-content: space-between;
|
|
2042
2621
|
gap: 8px;
|
|
2043
2622
|
}
|
|
2623
|
+
.wa-composer__hint {
|
|
2624
|
+
margin-right: auto;
|
|
2625
|
+
font-size: 10.5px;
|
|
2626
|
+
color: #9AA1AE;
|
|
2627
|
+
}
|
|
2044
2628
|
.wa-composer__counter {
|
|
2045
|
-
|
|
2046
|
-
|
|
2629
|
+
flex: 0 0 auto;
|
|
2630
|
+
font-size: 10.5px;
|
|
2631
|
+
color: #C0C5CF;
|
|
2047
2632
|
}
|
|
2048
2633
|
.wa-composer__send {
|
|
2049
|
-
padding: 6px
|
|
2050
|
-
border: 1px solid #
|
|
2051
|
-
border-radius:
|
|
2634
|
+
padding: 6px 16px;
|
|
2635
|
+
border: 1px solid #4F5AED;
|
|
2636
|
+
border-radius: 999px;
|
|
2052
2637
|
font: inherit;
|
|
2053
2638
|
color: #ffffff;
|
|
2054
|
-
background: #
|
|
2639
|
+
background: #4F5AED;
|
|
2055
2640
|
cursor: pointer;
|
|
2056
2641
|
}
|
|
2057
2642
|
.wa-composer__send:hover:not(:disabled) {
|
|
2058
|
-
|
|
2643
|
+
border-color: #3F49D6;
|
|
2644
|
+
background: #3F49D6;
|
|
2059
2645
|
}
|
|
2060
2646
|
.wa-composer__send:disabled {
|
|
2061
2647
|
border-color: #cbd2d9;
|
|
@@ -2064,26 +2650,76 @@ const THREAD_CSS = `
|
|
|
2064
2650
|
cursor: default;
|
|
2065
2651
|
}
|
|
2066
2652
|
|
|
2067
|
-
/* COMP-05 — \`unverified\`: un AVISO, no un bloqueo.
|
|
2068
|
-
que la conversación esté fría, dice que no se pudo leer. */
|
|
2653
|
+
/* COMP-05 — \`unverified\`: un AVISO, no un bloqueo. Banner ámbar (DEV-5053) y no rojo a
|
|
2654
|
+
propósito: el estado no dice que la conversación esté fría, dice que no se pudo leer. */
|
|
2069
2655
|
.wa-composer__unverified {
|
|
2656
|
+
display: flex;
|
|
2657
|
+
align-items: center;
|
|
2658
|
+
justify-content: space-between;
|
|
2659
|
+
gap: 10px;
|
|
2070
2660
|
margin: 0;
|
|
2071
|
-
padding: 8px
|
|
2072
|
-
border: 1px solid #
|
|
2073
|
-
border-radius:
|
|
2661
|
+
padding: 8px 12px;
|
|
2662
|
+
border: 1px solid #F5E7C8;
|
|
2663
|
+
border-radius: 8px;
|
|
2664
|
+
font-size: 12px;
|
|
2665
|
+
color: #8A5A10;
|
|
2666
|
+
background: #FFFBF2;
|
|
2667
|
+
}
|
|
2668
|
+
.wa-composer__unverified-text {
|
|
2669
|
+
display: flex;
|
|
2670
|
+
flex-direction: column;
|
|
2671
|
+
gap: 2px;
|
|
2672
|
+
}
|
|
2673
|
+
.wa-composer__unverified-title {
|
|
2674
|
+
margin: 0;
|
|
2675
|
+
font-weight: 600;
|
|
2676
|
+
}
|
|
2677
|
+
.wa-composer__unverified-explain {
|
|
2678
|
+
margin: 0;
|
|
2679
|
+
}
|
|
2680
|
+
.wa-composer__retry-window {
|
|
2681
|
+
flex: 0 0 auto;
|
|
2682
|
+
padding: 4px 14px;
|
|
2683
|
+
border: 1px solid #F5E7C8;
|
|
2684
|
+
border-radius: 999px;
|
|
2685
|
+
font: inherit;
|
|
2074
2686
|
font-size: 12px;
|
|
2075
|
-
color: #
|
|
2076
|
-
background: #
|
|
2687
|
+
color: #8A5A10;
|
|
2688
|
+
background: #ffffff;
|
|
2689
|
+
cursor: pointer;
|
|
2690
|
+
}
|
|
2691
|
+
.wa-composer__retry-window:hover {
|
|
2692
|
+
background: #FFF7E8;
|
|
2077
2693
|
}
|
|
2078
2694
|
|
|
2079
|
-
/* COMP-04 — \`closed\`: acá NO hay textarea.
|
|
2695
|
+
/* COMP-04 — \`closed\`: acá NO hay textarea. La tarjeta centrada (DEV-5053) reemplaza al
|
|
2696
|
+
composer entero. */
|
|
2080
2697
|
.wa-composer--closed {
|
|
2081
|
-
|
|
2698
|
+
align-items: center;
|
|
2699
|
+
padding: 20px 16px;
|
|
2700
|
+
gap: 10px;
|
|
2701
|
+
text-align: center;
|
|
2702
|
+
background: #ffffff;
|
|
2703
|
+
}
|
|
2704
|
+
.wa-composer__lock {
|
|
2705
|
+
display: flex;
|
|
2706
|
+
align-items: center;
|
|
2707
|
+
justify-content: center;
|
|
2708
|
+
width: 48px;
|
|
2709
|
+
height: 48px;
|
|
2710
|
+
border-radius: 50%;
|
|
2711
|
+
background: #F4F5F7;
|
|
2082
2712
|
}
|
|
2083
|
-
.wa-composer__cold {
|
|
2713
|
+
.wa-composer__cold-title {
|
|
2084
2714
|
margin: 0;
|
|
2085
|
-
font-size:
|
|
2086
|
-
|
|
2715
|
+
font-size: 14px;
|
|
2716
|
+
font-weight: 700;
|
|
2717
|
+
color: #1f2933;
|
|
2718
|
+
}
|
|
2719
|
+
.wa-composer__cold-explain {
|
|
2720
|
+
margin: 4px 0 0;
|
|
2721
|
+
font-size: 12px;
|
|
2722
|
+
color: #8A91A0;
|
|
2087
2723
|
}
|
|
2088
2724
|
|
|
2089
2725
|
/* COMP-06 — devolver la conversación al bot. El texto explicativo NO es decoración: es lo que
|
|
@@ -2166,6 +2802,16 @@ const THREAD_CSS = `
|
|
|
2166
2802
|
.wa-composer__failure-actions button:hover {
|
|
2167
2803
|
background: #f5f7fa;
|
|
2168
2804
|
}
|
|
2805
|
+
/* DEV-5053 P7: el Reintentar del envío fallido es un pill blanco con borde y texto rojos. */
|
|
2806
|
+
.wa-composer__failure-actions button.wa-composer__failure-retry {
|
|
2807
|
+
padding: 4px 12px;
|
|
2808
|
+
border: 1px solid #F0C9C5;
|
|
2809
|
+
border-radius: 999px;
|
|
2810
|
+
color: #D93025;
|
|
2811
|
+
}
|
|
2812
|
+
.wa-composer__failure-actions button.wa-composer__failure-retry:hover {
|
|
2813
|
+
background: #FDF6F6;
|
|
2814
|
+
}
|
|
2169
2815
|
`;
|
|
2170
2816
|
//#endregion
|
|
2171
2817
|
//#region src/core/thread/useComposer.ts
|
|
@@ -2542,7 +3188,7 @@ function useThread({ fetcher, phone }) {
|
|
|
2542
3188
|
finish
|
|
2543
3189
|
]);
|
|
2544
3190
|
const retry = useCallback(() => {
|
|
2545
|
-
if (current !== null && current.messages.length > 0) {
|
|
3191
|
+
if (current !== null && current.status === "error" && current.messages.length > 0) {
|
|
2546
3192
|
loadOlder();
|
|
2547
3193
|
return;
|
|
2548
3194
|
}
|
|
@@ -2628,7 +3274,21 @@ function serviceStateTransitions(messages) {
|
|
|
2628
3274
|
return true;
|
|
2629
3275
|
});
|
|
2630
3276
|
}
|
|
2631
|
-
|
|
3277
|
+
/**
|
|
3278
|
+
* El paso ACTUAL del flujo para el chip «Paso» del header (DEV-5053 / P3): el `service_state`
|
|
3279
|
+
* no-nulo/no-vacío del ÚLTIMO mensaje que lo tenga, sobre los mensajes ya ordenados (DEC-N).
|
|
3280
|
+
* `null` si ningún mensaje trae flujo — en ese caso el header se pinta igual (lleva la identidad
|
|
3281
|
+
* de la persona) y lo que falta es la fila de chips. Sin cambio de contrato: es una lectura
|
|
3282
|
+
* derivada de lo que el hilo ya trae.
|
|
3283
|
+
*/
|
|
3284
|
+
function currentServiceState(messages) {
|
|
3285
|
+
for (let index = messages.length - 1; index >= 0; index -= 1) {
|
|
3286
|
+
const state = messages[index].service_state;
|
|
3287
|
+
if (typeof state === "string" && state !== "") return state;
|
|
3288
|
+
}
|
|
3289
|
+
return null;
|
|
3290
|
+
}
|
|
3291
|
+
function ConversationThread({ fetcher, phone, displayName, className }) {
|
|
2632
3292
|
const { messages: serverMessages, status, error, windowState, canReply, hasOlder, loadOlder, retry } = useThread({
|
|
2633
3293
|
fetcher,
|
|
2634
3294
|
phone
|
|
@@ -2701,6 +3361,9 @@ function ConversationThread({ fetcher, phone, className }) {
|
|
|
2701
3361
|
}, [hasOlder, handleLoadOlder]);
|
|
2702
3362
|
const groups = groupByDay(messages);
|
|
2703
3363
|
const showServiceState = serviceStateTransitions(messages);
|
|
3364
|
+
const currentStep = currentServiceState(messages);
|
|
3365
|
+
/** El nombre útil: vacío o sólo espacios cuenta como ausente (D-02). */
|
|
3366
|
+
const name = typeof displayName === "string" && displayName.trim() !== "" ? displayName : null;
|
|
2704
3367
|
return /* @__PURE__ */ jsxs("div", {
|
|
2705
3368
|
className: className ? `wa-thread ${className}` : "wa-thread",
|
|
2706
3369
|
children: [
|
|
@@ -2722,6 +3385,33 @@ function ConversationThread({ fetcher, phone, className }) {
|
|
|
2722
3385
|
className: "wa-thread__note",
|
|
2723
3386
|
children: "Sin mensajes en esta conversación."
|
|
2724
3387
|
}),
|
|
3388
|
+
/* @__PURE__ */ jsxs("div", {
|
|
3389
|
+
className: "wa-thread__header",
|
|
3390
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
3391
|
+
className: "wa-thread__identity",
|
|
3392
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
3393
|
+
className: "wa-thread__avatar",
|
|
3394
|
+
"aria-hidden": "true",
|
|
3395
|
+
children: initials(name, phone)
|
|
3396
|
+
}), /* @__PURE__ */ jsxs("span", {
|
|
3397
|
+
className: "wa-thread__who",
|
|
3398
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
3399
|
+
className: "wa-thread__name",
|
|
3400
|
+
children: name ?? phone
|
|
3401
|
+
}), name !== null && /* @__PURE__ */ jsx("span", {
|
|
3402
|
+
className: "wa-thread__phone",
|
|
3403
|
+
children: phone
|
|
3404
|
+
})]
|
|
3405
|
+
})]
|
|
3406
|
+
}), currentStep !== null && /* @__PURE__ */ jsx("div", {
|
|
3407
|
+
className: "wa-thread__chips",
|
|
3408
|
+
children: /* @__PURE__ */ jsxs("span", {
|
|
3409
|
+
className: "wa-thread__step",
|
|
3410
|
+
title: currentStep,
|
|
3411
|
+
children: ["Paso: ", serviceStateLabel(currentStep)]
|
|
3412
|
+
})
|
|
3413
|
+
})]
|
|
3414
|
+
}),
|
|
2725
3415
|
/* @__PURE__ */ jsxs("div", {
|
|
2726
3416
|
className: "wa-thread__messages",
|
|
2727
3417
|
ref: messagesRef,
|
|
@@ -2737,17 +3427,20 @@ function ConversationThread({ fetcher, phone, className }) {
|
|
|
2737
3427
|
children: [group.label !== null && /* @__PURE__ */ jsx("div", {
|
|
2738
3428
|
className: "wa-thread__day",
|
|
2739
3429
|
children: group.label
|
|
2740
|
-
}), group.items.map(({ message, position }) => /* @__PURE__ */
|
|
3430
|
+
}), group.items.map(({ message, position }) => /* @__PURE__ */ jsxs(Fragment, { children: [showServiceState[position] && typeof message.service_state === "string" && message.service_state !== "" && /* @__PURE__ */ jsxs("div", {
|
|
3431
|
+
className: "wa-thread__flow-pill",
|
|
3432
|
+
children: ["El flujo pasó a ", serviceStateLabel(message.service_state)]
|
|
3433
|
+
}), /* @__PURE__ */ jsx(MessageBubble, {
|
|
2741
3434
|
message,
|
|
2742
|
-
showServiceState: showServiceState[position],
|
|
2743
3435
|
optimistic: optimistic.has(message),
|
|
2744
3436
|
fetcher
|
|
2745
|
-
}, message.id ?? `sin-wamid-${position}`))]
|
|
3437
|
+
})] }, message.id ?? `sin-wamid-${position}`))]
|
|
2746
3438
|
}, group.key ?? `sin-dia-${groupIndex}`))]
|
|
2747
3439
|
}),
|
|
2748
3440
|
/* @__PURE__ */ jsx(Composer, {
|
|
2749
3441
|
canReply,
|
|
2750
|
-
composer
|
|
3442
|
+
composer,
|
|
3443
|
+
onRetryWindow: retry
|
|
2751
3444
|
})
|
|
2752
3445
|
]
|
|
2753
3446
|
});
|
|
@@ -2789,7 +3482,9 @@ const SHELL_CSS = `
|
|
|
2789
3482
|
height: 100%;
|
|
2790
3483
|
min-height: 0;
|
|
2791
3484
|
align-items: stretch;
|
|
2792
|
-
|
|
3485
|
+
/* Inter sólo como primer nombre (DEV-5053): si el host la carga se usa, si no cae a system-ui.
|
|
3486
|
+
Cero @import y cero fuentes remotas (C-04). */
|
|
3487
|
+
font-family: Inter, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
|
|
2793
3488
|
}
|
|
2794
3489
|
/* El ancho de la columna de la lista lo fija EL SHELL, no la lista: el data-layout de la lista
|
|
2795
3490
|
se mide de su propio ancho, así que un ancho derivado de él oscila (ver list-styles.ts). El
|
|
@@ -2797,7 +3492,7 @@ const SHELL_CSS = `
|
|
|
2797
3492
|
.wa-conversations[data-layout='wide'] > .wa-list {
|
|
2798
3493
|
width: 320px;
|
|
2799
3494
|
flex: 0 0 320px;
|
|
2800
|
-
border-right: 1px solid #
|
|
3495
|
+
border-right: 1px solid #EEF0F3;
|
|
2801
3496
|
}
|
|
2802
3497
|
.wa-conversations[data-layout='narrow'] > .wa-list {
|
|
2803
3498
|
flex: 1 1 auto;
|
|
@@ -2809,25 +3504,29 @@ const SHELL_CSS = `
|
|
|
2809
3504
|
flex: 1 1 auto;
|
|
2810
3505
|
flex-direction: column;
|
|
2811
3506
|
}
|
|
3507
|
+
/* El "Volver" toma la forma de pill del resto de la interfaz (diseño .pen de DEV-5053). */
|
|
2812
3508
|
.wa-conversations__back {
|
|
2813
3509
|
align-self: flex-start;
|
|
2814
3510
|
margin: 8px 12px 0;
|
|
2815
|
-
padding:
|
|
2816
|
-
border: 1px solid #
|
|
2817
|
-
border-radius:
|
|
3511
|
+
padding: 4px 12px;
|
|
3512
|
+
border: 1px solid #C9D2F5;
|
|
3513
|
+
border-radius: 999px;
|
|
2818
3514
|
font: inherit;
|
|
2819
|
-
|
|
3515
|
+
font-size: 11.5px;
|
|
3516
|
+
font-weight: 600;
|
|
3517
|
+
color: #4F5AED;
|
|
2820
3518
|
background: #ffffff;
|
|
2821
3519
|
cursor: pointer;
|
|
2822
3520
|
}
|
|
2823
3521
|
.wa-conversations__back:hover {
|
|
2824
|
-
background: #
|
|
3522
|
+
background: #EEF1FE;
|
|
2825
3523
|
}
|
|
2826
3524
|
.wa-conversations__empty {
|
|
2827
3525
|
margin: 0;
|
|
2828
3526
|
padding: 24px;
|
|
2829
3527
|
flex: 1 1 auto;
|
|
2830
|
-
|
|
3528
|
+
font-size: 13px;
|
|
3529
|
+
color: #8A91A0;
|
|
2831
3530
|
}
|
|
2832
3531
|
`;
|
|
2833
3532
|
function WaConversations({ fetcher, initialPhone, pinned = false, className }) {
|
|
@@ -2843,6 +3542,15 @@ function WaConversations({ fetcher, initialPhone, pinned = false, className }) {
|
|
|
2843
3542
|
* docstring de la prop — la reactividad post-mount es del key-swap del element).
|
|
2844
3543
|
*/
|
|
2845
3544
|
const [selectedPhone, setSelectedPhone] = useState(initialPhone ?? null);
|
|
3545
|
+
/**
|
|
3546
|
+
* El nombre de la conversación elegida, para el header del hilo (D-02). Vive acá porque el
|
|
3547
|
+
* `ConversationSummary` —el único lugar donde el contrato pone `name`— lo recibe ESTE shell en
|
|
3548
|
+
* su `onSelect`; el hilo no lo puede sacar de su propia respuesta.
|
|
3549
|
+
*
|
|
3550
|
+
* `initialPhone` siembra SÓLO el teléfono: sin summary no hay nombre que sembrar y no se
|
|
3551
|
+
* inventa uno. El header cae al teléfono, como la fila de la lista.
|
|
3552
|
+
*/
|
|
3553
|
+
const [selectedName, setSelectedName] = useState(null);
|
|
2846
3554
|
const rootClass = className ? `wa-conversations ${className}` : "wa-conversations";
|
|
2847
3555
|
if (fetcher === void 0) return /* @__PURE__ */ jsx("div", {
|
|
2848
3556
|
className: rootClass,
|
|
@@ -2858,18 +3566,25 @@ function WaConversations({ fetcher, initialPhone, pinned = false, className }) {
|
|
|
2858
3566
|
!anchored && (layout === "wide" || selectedPhone === null) && /* @__PURE__ */ jsx(ConversationList, {
|
|
2859
3567
|
fetcher,
|
|
2860
3568
|
selectedPhone,
|
|
2861
|
-
onSelect: (item) =>
|
|
3569
|
+
onSelect: (item) => {
|
|
3570
|
+
setSelectedPhone(item.phone);
|
|
3571
|
+
setSelectedName(item.name);
|
|
3572
|
+
}
|
|
2862
3573
|
}),
|
|
2863
3574
|
selectedPhone !== null ? /* @__PURE__ */ jsxs("div", {
|
|
2864
3575
|
className: "wa-conversations__thread",
|
|
2865
3576
|
children: [layout === "narrow" && !anchored && /* @__PURE__ */ jsx("button", {
|
|
2866
3577
|
type: "button",
|
|
2867
3578
|
className: "wa-conversations__back",
|
|
2868
|
-
onClick: () =>
|
|
3579
|
+
onClick: () => {
|
|
3580
|
+
setSelectedPhone(null);
|
|
3581
|
+
setSelectedName(null);
|
|
3582
|
+
},
|
|
2869
3583
|
children: "Volver"
|
|
2870
3584
|
}), /* @__PURE__ */ jsx(ConversationThread, {
|
|
2871
3585
|
fetcher,
|
|
2872
|
-
phone: selectedPhone
|
|
3586
|
+
phone: selectedPhone,
|
|
3587
|
+
displayName: selectedName
|
|
2873
3588
|
})]
|
|
2874
3589
|
}) : layout === "wide" && /* @__PURE__ */ jsx("p", {
|
|
2875
3590
|
className: "wa-conversations__empty",
|