@liftitapp/wa-conversations 0.12.0 → 0.13.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 +8 -4
- package/dist/element/index.js +55 -15
- package/dist/react/index.d.ts +34 -5
- package/dist/react/index.js +175 -54
- package/package.json +1 -1
package/dist/react/index.d.ts
CHANGED
|
@@ -362,11 +362,14 @@ interface ConversationsResponse {
|
|
|
362
362
|
interface TemplateOption {
|
|
363
363
|
name: string;
|
|
364
364
|
language: string;
|
|
365
|
-
/** El texto del
|
|
365
|
+
/** El texto del chip de acción. `null` ⇒ se muestra `name`. */
|
|
366
366
|
label: string | null;
|
|
367
367
|
/** Cuántos parámetros posicionales (`{{1}}…{{n}}`) exige el cuerpo. 0–10. */
|
|
368
368
|
body_param_count: number;
|
|
369
|
-
/**
|
|
369
|
+
/**
|
|
370
|
+
* El cuerpo aprobado con sus `{{n}}`. Puede no llegar, y entonces la plantilla no se envía
|
|
371
|
+
* (`canSendTemplate`): el operador no sabría qué manda.
|
|
372
|
+
*/
|
|
370
373
|
body_text: string | null;
|
|
371
374
|
}
|
|
372
375
|
/** El 200 de `GET .../templates`, ya coercionado. */
|
|
@@ -417,7 +420,7 @@ type TemplatesState = {
|
|
|
417
420
|
* - `loading` / `unavailable`: la lista todavía no llegó o falló.
|
|
418
421
|
* - `read_only`: el store dijo `can_start: false` — se ve, no se envía (392).
|
|
419
422
|
* - `no_templates`: el número no tiene ninguna plantilla habilitada (392).
|
|
420
|
-
* - `form`:
|
|
423
|
+
* - `form`: chips, parámetros que faltan, vista previa y «Enviar mensaje» (391/392/393).
|
|
421
424
|
*/
|
|
422
425
|
type TemplateOfferMode = 'none' | 'loading' | 'unavailable' | 'read_only' | 'no_templates' | 'form';
|
|
423
426
|
interface TemplateOfferInput {
|
|
@@ -443,9 +446,35 @@ declare function templateOffer(input: TemplateOfferInput): TemplateOfferMode;
|
|
|
443
446
|
/**
|
|
444
447
|
* ¿Los parámetros que tipeó el operador pasan las reglas del contrato? Es la misma validación que
|
|
445
448
|
* hace el store (422 `invalid_template_params`) y se repite acá sólo para no habilitar «Enviar
|
|
446
|
-
*
|
|
449
|
+
* mensaje» con algo que va a volver rechazado. El store sigue siendo quien decide.
|
|
447
450
|
*/
|
|
448
451
|
declare function templateParamsValid(params: readonly string[], expectedCount: number): boolean;
|
|
452
|
+
/** Los parámetros de una plantilla repartidos entre lo que pone el host y lo que se pide. */
|
|
453
|
+
interface HostTemplateParams {
|
|
454
|
+
/** Largo = `body_param_count`: el valor que el host conoce, o `''` donde se pide. */
|
|
455
|
+
values: string[];
|
|
456
|
+
/** Índices 0-based que el operador tiene que llenar, ascendentes. */
|
|
457
|
+
asked: number[];
|
|
458
|
+
}
|
|
459
|
+
/**
|
|
460
|
+
* Qué parámetros pone el host y cuáles tiene que escribir el operador (DEV-8832, D-2).
|
|
461
|
+
*
|
|
462
|
+
* El host sólo conoce el parámetro 1: el primer nombre del contacto. Si lo tiene, no se pide —
|
|
463
|
+
* pedirle al operador algo que ya está en pantalla es el formulario técnico que este issue saca—.
|
|
464
|
+
* Si el nombre es nulo o está en blanco, el 1 se pide; los parámetros 2..n se piden siempre.
|
|
465
|
+
*
|
|
466
|
+
* 🔴 Es la ÚNICA fuente de esta decisión: el panel no la repite, sólo pinta un input por índice de
|
|
467
|
+
* `asked`.
|
|
468
|
+
*/
|
|
469
|
+
declare function hostTemplateParams(count: number, contactName: string | null): HostTemplateParams;
|
|
470
|
+
/**
|
|
471
|
+
* ¿Se puede enviar esta plantilla con estos parámetros? (DEV-8832, D-4).
|
|
472
|
+
*
|
|
473
|
+
* Sin el texto aprobado (Meta no lo devolvió para ese número) el operador no sabría qué manda, y
|
|
474
|
+
* cada plantilla se cobra: nunca a ciegas. Con texto, mandan las reglas del contrato
|
|
475
|
+
* (`templateParamsValid`).
|
|
476
|
+
*/
|
|
477
|
+
declare function canSendTemplate(template: Pick<TemplateOption, 'body_text' | 'body_param_count'> | null, params: readonly string[]): boolean;
|
|
449
478
|
/**
|
|
450
479
|
* La vista previa: el `body_text` aprobado con cada `{{n}}` reemplazado por su parámetro. Un
|
|
451
480
|
* parámetro vacío deja el `{{n}}` a la vista, para que se note qué falta. Sin `body_text`, `null`.
|
|
@@ -1436,4 +1465,4 @@ declare const WA_CONVERSATIONS_TAG = "wa-conversations";
|
|
|
1436
1465
|
*/
|
|
1437
1466
|
declare const SAVE_DOCUMENT_EVENT = "wa-conversations:save-document";
|
|
1438
1467
|
//#endregion
|
|
1439
|
-
export { type ContainerLayout, type ConversationFilters, ConversationList, type ConversationListProps, type ConversationSummary, ConversationThread, type ConversationThreadProps, type ConversationsRequest, type ConversationsResponse, type ConversationsStatus, DEFAULT_REFRESH_INTERVAL_MS, type DiscardSuggestionRequest, type DiscardSuggestionResponse, type DocumentScope, type DocumentScopeKind, type DocumentTypeOption, type LeadThreadResponse, type LeadWindowState, type MediaFormat, NARROW_MAX_WIDTH, type OperatorReplyRequest, type OutgoingMessage, type OutgoingStatus, REPLY_TEXT_MAX_LENGTH, type ReleaseRequest, type ReleaseResponse, type ReleaseState, type ReleaseStatus, type ReplyRequest, SAVE_DOCUMENT_EVENT, SUGGESTION_STATUS, type SaveDocumentConfig, type SaveDocumentEventDetail, type SaveDocumentInput, type SaveDocumentRequest, type SavedDocumentMark, type SendErrorCode, type SendErrorResponse, type SendFailure, type StartConversationRequest, type StartConversationResponse, type SuggestionState, type TemplateOfferInput, type TemplateOfferMode, type TemplateOption, type TemplatesRequest, type TemplatesResponse, type TemplatesState, type ThreadCta, type ThreadCtaKind, type ThreadDirection, type ThreadMessage, type ThreadMessageType, type ThreadRequest, type ThreadStatus, type ThreadViewStatus, type UseComposerOptions, type UseComposerResult, type UseConversationsOptions, type UseConversationsResult, type UseSuggestionOptions, type UseSuggestionResult, type UseThreadOptions, type UseThreadResult, WA_CONVERSATIONS_TAG, WaConversations, type WaConversationsProps, WaFetchError, type WaFetchOptions, type WaFetcher, type WaRequest, dedupeByWamid, discardSuggestion, isCtaLink, isNoThreadError, isSuggestion, loadConversations, loadTemplates, loadThread, mergeThread, mergeThreadPage, newClientMessageId, normalizeReplyMessage, normalizeStartResponse, normalizeTemplates, normalizeWindowState, readSendError, releaseConversation, renderTemplatePreview, sendFailureCopy, sendReply, startConversation, templateOffer, templateParamsValid, threadCtas, useComposer, useContainerLayout, useConversations, useSuggestion, useThread };
|
|
1468
|
+
export { type ContainerLayout, type ConversationFilters, ConversationList, type ConversationListProps, type ConversationSummary, ConversationThread, type ConversationThreadProps, type ConversationsRequest, type ConversationsResponse, type ConversationsStatus, DEFAULT_REFRESH_INTERVAL_MS, type DiscardSuggestionRequest, type DiscardSuggestionResponse, type DocumentScope, type DocumentScopeKind, type DocumentTypeOption, type HostTemplateParams, type LeadThreadResponse, type LeadWindowState, type MediaFormat, NARROW_MAX_WIDTH, type OperatorReplyRequest, type OutgoingMessage, type OutgoingStatus, REPLY_TEXT_MAX_LENGTH, type ReleaseRequest, type ReleaseResponse, type ReleaseState, type ReleaseStatus, type ReplyRequest, SAVE_DOCUMENT_EVENT, SUGGESTION_STATUS, type SaveDocumentConfig, type SaveDocumentEventDetail, type SaveDocumentInput, type SaveDocumentRequest, type SavedDocumentMark, type SendErrorCode, type SendErrorResponse, type SendFailure, type StartConversationRequest, type StartConversationResponse, type SuggestionState, type TemplateOfferInput, type TemplateOfferMode, type TemplateOption, type TemplatesRequest, type TemplatesResponse, type TemplatesState, type ThreadCta, type ThreadCtaKind, type ThreadDirection, type ThreadMessage, type ThreadMessageType, type ThreadRequest, type ThreadStatus, type ThreadViewStatus, type UseComposerOptions, type UseComposerResult, type UseConversationsOptions, type UseConversationsResult, type UseSuggestionOptions, type UseSuggestionResult, type UseThreadOptions, type UseThreadResult, WA_CONVERSATIONS_TAG, WaConversations, type WaConversationsProps, WaFetchError, type WaFetchOptions, type WaFetcher, type WaRequest, canSendTemplate, dedupeByWamid, discardSuggestion, hostTemplateParams, isCtaLink, isNoThreadError, isSuggestion, loadConversations, loadTemplates, loadThread, mergeThread, mergeThreadPage, newClientMessageId, normalizeReplyMessage, normalizeStartResponse, normalizeTemplates, normalizeWindowState, readSendError, releaseConversation, renderTemplatePreview, sendFailureCopy, sendReply, startConversation, templateOffer, templateParamsValid, threadCtas, useComposer, useContainerLayout, useConversations, useSuggestion, useThread };
|
package/dist/react/index.js
CHANGED
|
@@ -994,7 +994,7 @@ function templateOffer(input) {
|
|
|
994
994
|
/**
|
|
995
995
|
* ¿Los parámetros que tipeó el operador pasan las reglas del contrato? Es la misma validación que
|
|
996
996
|
* hace el store (422 `invalid_template_params`) y se repite acá sólo para no habilitar «Enviar
|
|
997
|
-
*
|
|
997
|
+
* mensaje» con algo que va a volver rechazado. El store sigue siendo quien decide.
|
|
998
998
|
*/
|
|
999
999
|
function templateParamsValid(params, expectedCount) {
|
|
1000
1000
|
if (params.length !== expectedCount) return false;
|
|
@@ -1005,6 +1005,45 @@ function templateParamsValid(params, expectedCount) {
|
|
|
1005
1005
|
return !/ {5,}/.test(value);
|
|
1006
1006
|
});
|
|
1007
1007
|
}
|
|
1008
|
+
/** El primer nombre del contacto: «Nelson Chaves» ⇒ «Nelson». Sin nombre, `''`. */
|
|
1009
|
+
function firstName$1(name) {
|
|
1010
|
+
return (typeof name === "string" ? name.trim().split(/\s+/)[0] : "") ?? "";
|
|
1011
|
+
}
|
|
1012
|
+
/**
|
|
1013
|
+
* Qué parámetros pone el host y cuáles tiene que escribir el operador (DEV-8832, D-2).
|
|
1014
|
+
*
|
|
1015
|
+
* El host sólo conoce el parámetro 1: el primer nombre del contacto. Si lo tiene, no se pide —
|
|
1016
|
+
* pedirle al operador algo que ya está en pantalla es el formulario técnico que este issue saca—.
|
|
1017
|
+
* Si el nombre es nulo o está en blanco, el 1 se pide; los parámetros 2..n se piden siempre.
|
|
1018
|
+
*
|
|
1019
|
+
* 🔴 Es la ÚNICA fuente de esta decisión: el panel no la repite, sólo pinta un input por índice de
|
|
1020
|
+
* `asked`.
|
|
1021
|
+
*/
|
|
1022
|
+
function hostTemplateParams(count, contactName) {
|
|
1023
|
+
const known = firstName$1(contactName);
|
|
1024
|
+
const values = [];
|
|
1025
|
+
const asked = [];
|
|
1026
|
+
for (let index = 0; index < count; index += 1) if (index === 0 && known !== "") values.push(known);
|
|
1027
|
+
else {
|
|
1028
|
+
values.push("");
|
|
1029
|
+
asked.push(index);
|
|
1030
|
+
}
|
|
1031
|
+
return {
|
|
1032
|
+
values,
|
|
1033
|
+
asked
|
|
1034
|
+
};
|
|
1035
|
+
}
|
|
1036
|
+
/**
|
|
1037
|
+
* ¿Se puede enviar esta plantilla con estos parámetros? (DEV-8832, D-4).
|
|
1038
|
+
*
|
|
1039
|
+
* Sin el texto aprobado (Meta no lo devolvió para ese número) el operador no sabría qué manda, y
|
|
1040
|
+
* cada plantilla se cobra: nunca a ciegas. Con texto, mandan las reglas del contrato
|
|
1041
|
+
* (`templateParamsValid`).
|
|
1042
|
+
*/
|
|
1043
|
+
function canSendTemplate(template, params) {
|
|
1044
|
+
if (template === null || template.body_text === null) return false;
|
|
1045
|
+
return templateParamsValid(params, template.body_param_count);
|
|
1046
|
+
}
|
|
1008
1047
|
/**
|
|
1009
1048
|
* La vista previa: el `body_text` aprobado con cada `{{n}}` reemplazado por su parámetro. Un
|
|
1010
1049
|
* parámetro vacío deja el `{{n}}` a la vista, para que se note qué falta. Sin `body_text`, `null`.
|
|
@@ -4099,7 +4138,9 @@ const THREAD_CSS = `
|
|
|
4099
4138
|
}
|
|
4100
4139
|
|
|
4101
4140
|
/* DEV-8758 — «Iniciar con plantilla» (tableros 391/392): con la ventana cerrada o sin hilo, el
|
|
4102
|
-
composer es un formulario de plantilla. Mismo fondo y bordes que el composer de texto.
|
|
4141
|
+
composer es un formulario de plantilla. Mismo fondo y bordes que el composer de texto.
|
|
4142
|
+
DEV-8832 (tablero 393) cambió el selector por chips de acción y agregó la vista previa con su
|
|
4143
|
+
rótulo y su nota. */
|
|
4103
4144
|
.wa-composer--template {
|
|
4104
4145
|
gap: 10px;
|
|
4105
4146
|
}
|
|
@@ -4162,7 +4203,41 @@ const THREAD_CSS = `
|
|
|
4162
4203
|
font-weight: 600;
|
|
4163
4204
|
color: #616e7c;
|
|
4164
4205
|
}
|
|
4165
|
-
.wa-
|
|
4206
|
+
.wa-template__chips {
|
|
4207
|
+
display: flex;
|
|
4208
|
+
flex-wrap: wrap;
|
|
4209
|
+
gap: 6px;
|
|
4210
|
+
}
|
|
4211
|
+
.wa-template__chip {
|
|
4212
|
+
display: inline-flex;
|
|
4213
|
+
align-items: center;
|
|
4214
|
+
gap: 4px;
|
|
4215
|
+
padding: 4px 12px;
|
|
4216
|
+
border: 1px solid #E4E7EE;
|
|
4217
|
+
border-radius: 999px;
|
|
4218
|
+
font: inherit;
|
|
4219
|
+
font-size: 12px;
|
|
4220
|
+
color: #52606d;
|
|
4221
|
+
background: #ffffff;
|
|
4222
|
+
cursor: pointer;
|
|
4223
|
+
}
|
|
4224
|
+
/* El resaltado cuelga del MISMO atributo que lo anuncia al lector de pantalla: no puede verse
|
|
4225
|
+
elegido un chip que el lector anuncia como no elegido, ni al revés. */
|
|
4226
|
+
.wa-template__chip[aria-pressed='true'] {
|
|
4227
|
+
border-color: #4F5AED;
|
|
4228
|
+
font-weight: 600;
|
|
4229
|
+
color: #4F5AED;
|
|
4230
|
+
background: #EEF1FE;
|
|
4231
|
+
}
|
|
4232
|
+
.wa-template__chip:disabled {
|
|
4233
|
+
cursor: default;
|
|
4234
|
+
opacity: 0.6;
|
|
4235
|
+
}
|
|
4236
|
+
.wa-template__chip-check {
|
|
4237
|
+
width: 12px;
|
|
4238
|
+
height: 12px;
|
|
4239
|
+
flex: none;
|
|
4240
|
+
}
|
|
4166
4241
|
.wa-template__input {
|
|
4167
4242
|
padding: 7px 10px;
|
|
4168
4243
|
border: 1px solid #E4E7EE;
|
|
@@ -4172,7 +4247,6 @@ const THREAD_CSS = `
|
|
|
4172
4247
|
color: #2D3340;
|
|
4173
4248
|
background: #F4F5F7;
|
|
4174
4249
|
}
|
|
4175
|
-
.wa-template__select:focus,
|
|
4176
4250
|
.wa-template__input:focus {
|
|
4177
4251
|
border-color: #4F5AED;
|
|
4178
4252
|
outline: 2px solid rgba(79, 90, 237, 0.25);
|
|
@@ -4186,12 +4260,17 @@ const THREAD_CSS = `
|
|
|
4186
4260
|
border-radius: 12px 12px 4px 12px;
|
|
4187
4261
|
background: #EEF1FE;
|
|
4188
4262
|
}
|
|
4189
|
-
.wa-template__preview-
|
|
4190
|
-
|
|
4191
|
-
margin-bottom: 4px;
|
|
4192
|
-
font-size: 10.5px;
|
|
4263
|
+
.wa-template__preview-label {
|
|
4264
|
+
font-size: 11px;
|
|
4193
4265
|
font-weight: 600;
|
|
4194
|
-
color: #
|
|
4266
|
+
color: #616e7c;
|
|
4267
|
+
}
|
|
4268
|
+
/* Alineada con la burbuja, a la derecha. */
|
|
4269
|
+
.wa-template__preview-note {
|
|
4270
|
+
align-self: flex-end;
|
|
4271
|
+
margin: 0;
|
|
4272
|
+
font-size: 10.5px;
|
|
4273
|
+
color: #9AA1AE;
|
|
4195
4274
|
}
|
|
4196
4275
|
.wa-template__preview-body {
|
|
4197
4276
|
margin: 0;
|
|
@@ -5150,35 +5229,47 @@ function useSuggestion({ fetcher, phone, messages, outgoing = [], onPrefill }) {
|
|
|
5150
5229
|
* «Iniciar con plantilla» (DEV-8758) — el composer cuando WhatsApp sólo deja escribir con una
|
|
5151
5230
|
* plantilla aprobada: ventana de 24 h cerrada (tablero 391) o sin hilo (tablero 392).
|
|
5152
5231
|
*
|
|
5232
|
+
* DEV-8832 (tablero 393) rehízo el formulario para que el operador lo entienda: un chip por acción
|
|
5233
|
+
* en vez del selector técnico, sin pedir lo que el host ya sabe (el primer nombre) y con la vista
|
|
5234
|
+
* previa obligatoria de lo que le llega a la persona.
|
|
5235
|
+
*
|
|
5153
5236
|
* Presentacional: qué modo se pinta lo decide `templateOffer` y la red vive en `useTemplateStart`.
|
|
5154
5237
|
* Interno del hilo — NO sale al barrel (mismo criterio que `Composer`).
|
|
5155
5238
|
*
|
|
5156
5239
|
* 🔴 Todo lo que viene del store (`label`, `body_text`) y el nombre del contacto entran como hijos
|
|
5157
5240
|
* de texto, que React escapa. Nada de `dangerouslySetInnerHTML`.
|
|
5158
5241
|
*/
|
|
5159
|
-
/**
|
|
5160
|
-
function
|
|
5161
|
-
return
|
|
5242
|
+
/** La clave estable de una plantilla: el mismo nombre puede existir en dos idiomas. */
|
|
5243
|
+
function templateKey(option) {
|
|
5244
|
+
return `${option.name}#${option.language}`;
|
|
5245
|
+
}
|
|
5246
|
+
/** La etiqueta de un parámetro que se pide, sin el marcador técnico (D-2). */
|
|
5247
|
+
function askedParamLabel(index) {
|
|
5248
|
+
return index === 0 ? "Nombre de la persona" : `Dato ${index + 1}`;
|
|
5162
5249
|
}
|
|
5163
5250
|
function TemplateStartPanel({ mode, start, noThread, phone, contactName, senderLabel }) {
|
|
5164
|
-
const
|
|
5251
|
+
const chipsLabelId = useId();
|
|
5165
5252
|
const items = start.response?.items ?? [];
|
|
5166
|
-
|
|
5167
|
-
|
|
5253
|
+
/** La acción que tocó el operador (`templateKey`). Con una sola plantilla no hace falta tocar. */
|
|
5254
|
+
const [picked, setPicked] = useState(null);
|
|
5255
|
+
/** Lo que tipeó el operador, por plantilla: cambiar de acción no mezcla parámetros. */
|
|
5168
5256
|
const [typed, setTyped] = useState({});
|
|
5169
5257
|
if (mode === "none") return null;
|
|
5170
|
-
const template = items
|
|
5171
|
-
const
|
|
5172
|
-
const
|
|
5258
|
+
const template = items.length === 1 ? items[0] ?? null : items.find((item) => templateKey(item) === picked) ?? null;
|
|
5259
|
+
const key = template !== null ? templateKey(template) : "";
|
|
5260
|
+
const host = hostTemplateParams(template?.body_param_count ?? 0, contactName);
|
|
5261
|
+
const typedForTemplate = typed[key] ?? [];
|
|
5262
|
+
const params = host.values.map((value, index) => host.asked.includes(index) ? typedForTemplate[index] ?? "" : value);
|
|
5173
5263
|
const sending = start.sendState === "sending";
|
|
5174
|
-
const canSend = mode === "form" &&
|
|
5264
|
+
const canSend = mode === "form" && !sending && canSendTemplate(template, params);
|
|
5175
5265
|
const preview = template !== null ? renderTemplatePreview(template.body_text, params) : null;
|
|
5266
|
+
const recipient = firstName$1(contactName);
|
|
5176
5267
|
const setParam = (index, value) => {
|
|
5177
|
-
const next = [...
|
|
5268
|
+
const next = [...typedForTemplate];
|
|
5178
5269
|
next[index] = value;
|
|
5179
5270
|
setTyped({
|
|
5180
5271
|
...typed,
|
|
5181
|
-
[
|
|
5272
|
+
[key]: next
|
|
5182
5273
|
});
|
|
5183
5274
|
};
|
|
5184
5275
|
const submit = () => {
|
|
@@ -5244,57 +5335,87 @@ function TemplateStartPanel({ mode, start, noThread, phone, contactName, senderL
|
|
|
5244
5335
|
className: "wa-template__note",
|
|
5245
5336
|
children: "No hay plantillas habilitadas para este número."
|
|
5246
5337
|
}),
|
|
5247
|
-
mode === "form" &&
|
|
5338
|
+
mode === "form" && /* @__PURE__ */ jsxs("form", {
|
|
5248
5339
|
className: "wa-template__form",
|
|
5249
5340
|
onSubmit: (event) => {
|
|
5250
5341
|
event.preventDefault();
|
|
5251
5342
|
submit();
|
|
5252
5343
|
},
|
|
5253
5344
|
children: [
|
|
5254
|
-
/* @__PURE__ */ jsxs("
|
|
5345
|
+
/* @__PURE__ */ jsxs("div", {
|
|
5255
5346
|
className: "wa-template__field",
|
|
5256
|
-
htmlFor: selectId,
|
|
5257
5347
|
children: [/* @__PURE__ */ jsx("span", {
|
|
5258
5348
|
className: "wa-template__label",
|
|
5259
|
-
|
|
5260
|
-
|
|
5261
|
-
|
|
5262
|
-
className: "wa-
|
|
5263
|
-
|
|
5264
|
-
|
|
5265
|
-
|
|
5266
|
-
|
|
5267
|
-
|
|
5268
|
-
|
|
5269
|
-
|
|
5349
|
+
id: chipsLabelId,
|
|
5350
|
+
children: "¿Qué quieres hacer?"
|
|
5351
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
5352
|
+
className: "wa-template__chips",
|
|
5353
|
+
role: "group",
|
|
5354
|
+
"aria-labelledby": chipsLabelId,
|
|
5355
|
+
children: items.map((item) => {
|
|
5356
|
+
const itemKey = templateKey(item);
|
|
5357
|
+
const pressed = template !== null && templateKey(template) === itemKey;
|
|
5358
|
+
return /* @__PURE__ */ jsxs("button", {
|
|
5359
|
+
type: "button",
|
|
5360
|
+
className: "wa-template__chip",
|
|
5361
|
+
"aria-pressed": pressed,
|
|
5362
|
+
disabled: sending,
|
|
5363
|
+
onClick: () => setPicked(itemKey),
|
|
5364
|
+
children: [pressed && /* @__PURE__ */ jsx("svg", {
|
|
5365
|
+
className: "wa-template__chip-check",
|
|
5366
|
+
viewBox: "0 0 16 16",
|
|
5367
|
+
"aria-hidden": "true",
|
|
5368
|
+
focusable: "false",
|
|
5369
|
+
children: /* @__PURE__ */ jsx("path", {
|
|
5370
|
+
d: "M3.5 8.5l3 3 6-7",
|
|
5371
|
+
fill: "none",
|
|
5372
|
+
stroke: "currentColor",
|
|
5373
|
+
strokeWidth: "2",
|
|
5374
|
+
strokeLinecap: "round",
|
|
5375
|
+
strokeLinejoin: "round"
|
|
5376
|
+
})
|
|
5377
|
+
}), item.label ?? item.name]
|
|
5378
|
+
}, itemKey);
|
|
5379
|
+
})
|
|
5270
5380
|
})]
|
|
5271
5381
|
}),
|
|
5272
|
-
|
|
5382
|
+
template !== null && template.body_text === null && /* @__PURE__ */ jsx("p", {
|
|
5383
|
+
className: "wa-template__note",
|
|
5384
|
+
role: "status",
|
|
5385
|
+
children: "Esta acción no está disponible en este número"
|
|
5386
|
+
}),
|
|
5387
|
+
template !== null && template.body_text !== null && host.asked.map((index) => /* @__PURE__ */ jsxs("label", {
|
|
5273
5388
|
className: "wa-template__field",
|
|
5274
|
-
children: [/* @__PURE__ */
|
|
5389
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
5275
5390
|
className: "wa-template__label",
|
|
5276
|
-
children:
|
|
5277
|
-
index === 0 ? "Nombre del lifter" : "Parámetro",
|
|
5278
|
-
" · ",
|
|
5279
|
-
`{{${index + 1}}}`
|
|
5280
|
-
]
|
|
5391
|
+
children: askedParamLabel(index)
|
|
5281
5392
|
}), /* @__PURE__ */ jsx("input", {
|
|
5282
5393
|
className: "wa-template__input",
|
|
5283
|
-
value,
|
|
5394
|
+
value: typedForTemplate[index] ?? "",
|
|
5284
5395
|
maxLength: 1024,
|
|
5285
5396
|
disabled: sending,
|
|
5286
5397
|
onChange: (event) => setParam(index, event.target.value)
|
|
5287
5398
|
})]
|
|
5288
5399
|
}, index)),
|
|
5289
5400
|
preview !== null && /* @__PURE__ */ jsxs("div", {
|
|
5290
|
-
className: "wa-
|
|
5291
|
-
children: [
|
|
5292
|
-
|
|
5293
|
-
|
|
5294
|
-
|
|
5295
|
-
|
|
5296
|
-
|
|
5297
|
-
|
|
5401
|
+
className: "wa-template__field",
|
|
5402
|
+
children: [
|
|
5403
|
+
/* @__PURE__ */ jsx("span", {
|
|
5404
|
+
className: "wa-template__preview-label",
|
|
5405
|
+
children: recipient !== "" ? `Así le llega a ${recipient}` : "Así le llega"
|
|
5406
|
+
}),
|
|
5407
|
+
/* @__PURE__ */ jsx("div", {
|
|
5408
|
+
className: "wa-template__preview",
|
|
5409
|
+
children: /* @__PURE__ */ jsx("p", {
|
|
5410
|
+
className: "wa-template__preview-body",
|
|
5411
|
+
children: preview
|
|
5412
|
+
})
|
|
5413
|
+
}),
|
|
5414
|
+
/* @__PURE__ */ jsx("p", {
|
|
5415
|
+
className: "wa-template__preview-note",
|
|
5416
|
+
children: "Mensaje aprobado por WhatsApp"
|
|
5417
|
+
})
|
|
5418
|
+
]
|
|
5298
5419
|
}),
|
|
5299
5420
|
start.sendState === "error" && start.failure !== null && /* @__PURE__ */ jsxs("div", {
|
|
5300
5421
|
className: "wa-template__error",
|
|
@@ -5312,7 +5433,7 @@ function TemplateStartPanel({ mode, start, noThread, phone, contactName, senderL
|
|
|
5312
5433
|
start.sendState === "sent" && /* @__PURE__ */ jsx("p", {
|
|
5313
5434
|
className: "wa-template__sent",
|
|
5314
5435
|
role: "status",
|
|
5315
|
-
children: "
|
|
5436
|
+
children: "Mensaje enviado. El bot quedó en pausa."
|
|
5316
5437
|
}),
|
|
5317
5438
|
/* @__PURE__ */ jsxs("div", {
|
|
5318
5439
|
className: "wa-template__footer",
|
|
@@ -5323,7 +5444,7 @@ function TemplateStartPanel({ mode, start, noThread, phone, contactName, senderL
|
|
|
5323
5444
|
type: "submit",
|
|
5324
5445
|
className: "wa-composer__send",
|
|
5325
5446
|
disabled: !canSend,
|
|
5326
|
-
children: sending ? "Enviando…" : "Enviar
|
|
5447
|
+
children: sending ? "Enviando…" : "Enviar mensaje"
|
|
5327
5448
|
})]
|
|
5328
5449
|
})
|
|
5329
5450
|
]
|
|
@@ -6490,4 +6611,4 @@ const WA_CONVERSATIONS_TAG = "wa-conversations";
|
|
|
6490
6611
|
*/
|
|
6491
6612
|
const SAVE_DOCUMENT_EVENT = "wa-conversations:save-document";
|
|
6492
6613
|
//#endregion
|
|
6493
|
-
export { ConversationList, ConversationThread, DEFAULT_REFRESH_INTERVAL_MS, NARROW_MAX_WIDTH, REPLY_TEXT_MAX_LENGTH, SAVE_DOCUMENT_EVENT, SUGGESTION_STATUS, WA_CONVERSATIONS_TAG, WaConversations, WaFetchError, dedupeByWamid, discardSuggestion, isCtaLink, isNoThreadError, isSuggestion, loadConversations, loadTemplates, loadThread, mergeThread, mergeThreadPage, newClientMessageId, normalizeReplyMessage, normalizeStartResponse, normalizeTemplates, normalizeWindowState, readSendError, releaseConversation, renderTemplatePreview, sendFailureCopy, sendReply, startConversation, templateOffer, templateParamsValid, threadCtas, useComposer, useContainerLayout, useConversations, useSuggestion, useThread };
|
|
6614
|
+
export { ConversationList, ConversationThread, DEFAULT_REFRESH_INTERVAL_MS, NARROW_MAX_WIDTH, REPLY_TEXT_MAX_LENGTH, SAVE_DOCUMENT_EVENT, SUGGESTION_STATUS, WA_CONVERSATIONS_TAG, WaConversations, WaFetchError, canSendTemplate, dedupeByWamid, discardSuggestion, hostTemplateParams, isCtaLink, isNoThreadError, isSuggestion, loadConversations, loadTemplates, loadThread, mergeThread, mergeThreadPage, newClientMessageId, normalizeReplyMessage, normalizeStartResponse, normalizeTemplates, normalizeWindowState, readSendError, releaseConversation, renderTemplatePreview, sendFailureCopy, sendReply, startConversation, templateOffer, templateParamsValid, threadCtas, useComposer, useContainerLayout, useConversations, useSuggestion, useThread };
|
package/package.json
CHANGED