@liftitapp/wa-conversations 0.13.0 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +55 -1
- package/dist/element/index.js +86 -6
- package/dist/react/index.d.ts +13 -0
- package/dist/react/index.js +211 -30
- package/package.json +1 -1
package/dist/react/index.d.ts
CHANGED
|
@@ -727,6 +727,12 @@ type DocumentScope = {
|
|
|
727
727
|
kind: 'person';
|
|
728
728
|
name: string;
|
|
729
729
|
id?: string | null;
|
|
730
|
+
/**
|
|
731
|
+
* Rol de la persona en el caso, escrito por el host (p. ej. «Tenedor» o «Conductor · esta
|
|
732
|
+
* conversación») — DEV-9645. El visor lo pinta VERBATIM en la pill de la fila y en el aviso;
|
|
733
|
+
* no le agrega ni le quita nada.
|
|
734
|
+
*/
|
|
735
|
+
role?: string | null;
|
|
730
736
|
};
|
|
731
737
|
/** Un tipo de documento del catálogo del host (`code` es opaco para el visor). */
|
|
732
738
|
interface DocumentTypeOption {
|
|
@@ -738,6 +744,13 @@ interface DocumentTypeOption {
|
|
|
738
744
|
requested?: boolean;
|
|
739
745
|
/** Subtítulo verbatim del host: «Del vehículo BQT-664 · la Cola lo pidió hace 2 h». */
|
|
740
746
|
detail?: string | null;
|
|
747
|
+
/**
|
|
748
|
+
* DEV-9645: si viene, el tipo solo se habilita en los destinos cuyo `id` esté en la lista (y cuya
|
|
749
|
+
* clase admita `scopes`). Sin él, decide `scopes`, como hoy. `[]` no habilita a nadie, y un valor
|
|
750
|
+
* que no sea array cuenta como ausente. Como `documentTypeOptions` deduplica por `code`, el host
|
|
751
|
+
* junta en una sola opción los ids de un mismo código.
|
|
752
|
+
*/
|
|
753
|
+
scopeIds?: string[] | null;
|
|
741
754
|
}
|
|
742
755
|
/** La marca que confirma el guardado (D-6): la LEE el visor, nunca la afirma por su cuenta. */
|
|
743
756
|
interface SavedDocumentMark {
|
package/dist/react/index.js
CHANGED
|
@@ -1981,15 +1981,27 @@ function documentTypeOptions(types, query) {
|
|
|
1981
1981
|
};
|
|
1982
1982
|
}
|
|
1983
1983
|
/**
|
|
1984
|
+
* DEV-9645: `true` si el tipo restringe por `scopeIds` (array) y el destino trae un `id` string no
|
|
1985
|
+
* vacío incluido en la lista — comparación exacta. Sin `scopeIds` no filtra por `id`. Un destino
|
|
1986
|
+
* sin `id` nunca coincide: falla cerrado (T-9645-01).
|
|
1987
|
+
*/
|
|
1988
|
+
function matchesScopeIds(type, scope) {
|
|
1989
|
+
if (!Array.isArray(type.scopeIds)) return true;
|
|
1990
|
+
const id = scope.id;
|
|
1991
|
+
if (typeof id !== "string" || id === "") return false;
|
|
1992
|
+
return type.scopeIds.includes(id);
|
|
1993
|
+
}
|
|
1994
|
+
/**
|
|
1984
1995
|
* El tipo define el alcance (D-4): las opciones son los alcances VÁLIDOS del host (se descartan
|
|
1985
|
-
* los que no traen el dato que su `kind` exige); habilitadas sólo las que el tipo admite
|
|
1986
|
-
*
|
|
1987
|
-
* `type` null no se selecciona nada — no hay de
|
|
1996
|
+
* los que no traen el dato que su `kind` exige); habilitadas sólo las que el tipo admite por clase
|
|
1997
|
+
* y, si trae `scopeIds`, además por `id` (DEV-9645); seleccionada la actual si sigue permitida, si
|
|
1998
|
+
* no la primera permitida en el orden del host. Con `type` null no se selecciona nada — no hay de
|
|
1999
|
+
* qué derivar el alcance.
|
|
1988
2000
|
*/
|
|
1989
2001
|
function resolveScope(type, scopes, current) {
|
|
1990
2002
|
const options = (Array.isArray(scopes) ? scopes.filter(isValidScope) : []).map((scope) => ({
|
|
1991
2003
|
scope,
|
|
1992
|
-
allowed: type !== null && type.scopes.includes(scope.kind)
|
|
2004
|
+
allowed: type !== null && type.scopes.includes(scope.kind) && matchesScopeIds(type, scope)
|
|
1993
2005
|
}));
|
|
1994
2006
|
if (type === null) return {
|
|
1995
2007
|
options,
|
|
@@ -2007,6 +2019,15 @@ function resolveScope(type, scopes, current) {
|
|
|
2007
2019
|
};
|
|
2008
2020
|
}
|
|
2009
2021
|
/**
|
|
2022
|
+
* DEV-9645 (DC-4): el modal pinta «De quién es» como lista de destinos (tablero 553) si algún tipo
|
|
2023
|
+
* válido trae `scopeIds` como array o alguna persona válida trae un `role` no vacío. Si no, es el
|
|
2024
|
+
* input de hoy y se pinta el modal del tablero 196, sin cambios (C-7).
|
|
2025
|
+
*/
|
|
2026
|
+
function usesTargetList(types, scopes) {
|
|
2027
|
+
if (Array.isArray(types) && types.some((type) => isValidType(type) && Array.isArray(type.scopeIds))) return true;
|
|
2028
|
+
return Array.isArray(scopes) && scopes.some((scope) => isValidScope(scope) && scope.kind === "person" && typeof scope.role === "string" && scope.role.trim() !== "");
|
|
2029
|
+
}
|
|
2030
|
+
/**
|
|
2010
2031
|
* La marca de la burbuja (D-6): sólo lee `saved[messageId]` — el visor no AFIRMA el guardado, lo
|
|
2011
2032
|
* LEE (mismo principio que la barra de takeover, DEV-5190). Un `messageId` ausente o una entrada
|
|
2012
2033
|
* sin `typeName` útil no pinta marca: es mejor no mostrar nada que inventar un «Guardado como».
|
|
@@ -2962,6 +2983,11 @@ function MessageBubble({ message, optimistic = false, fetcher, savedDocument = n
|
|
|
2962
2983
|
* `code`; radios de alcance con `data-scope-kind`; envío `.wa-thread__save-submit`; error
|
|
2963
2984
|
* `[role="alert"]`.
|
|
2964
2985
|
*
|
|
2986
|
+
* DEV-9645 (tablero 553): cuando `usesTargetList` da true, «De quién es» es una lista de destinos
|
|
2987
|
+
* `.wa-thread__save-targets`; cada fila es `.wa-thread__save-target` (con `data-selected` en la
|
|
2988
|
+
* elegida y `data-disabled` en las que el tipo no admite) y lleva su nota corta en
|
|
2989
|
+
* `.wa-thread__save-target-note`. El `id` del destino es opaco y NUNCA se pinta en el DOM.
|
|
2990
|
+
*
|
|
2965
2991
|
* 🔴 Todo texto que origina el host o el lifter (nombres de tipo, `detail`, placa, nombre,
|
|
2966
2992
|
* `file_name`, el mensaje de error) entra como hijo de texto, que React escapa — nunca
|
|
2967
2993
|
* `dangerouslySetInnerHTML` (T-no6-04).
|
|
@@ -2990,6 +3016,42 @@ function sentWhenLabel(at) {
|
|
|
2990
3016
|
const day = key === dayKey((/* @__PURE__ */ new Date()).toISOString()) ? "hoy" : dayLabel(at);
|
|
2991
3017
|
return hour !== null ? `${day} ${hour}` : day;
|
|
2992
3018
|
}
|
|
3019
|
+
/**
|
|
3020
|
+
* La nota corta de una fila de la lista de destinos (DEV-9645, DC-2). Sin tipo no hay nota; la
|
|
3021
|
+
* elegida dice «Se guarda aquí»; una habilitada sin elegir no lleva nota; una deshabilitada dice
|
|
3022
|
+
* por qué: la clase no coincide, o coincide pero el destino queda fuera de `scopeIds`.
|
|
3023
|
+
*/
|
|
3024
|
+
function targetNote(type, target, allowed, selected) {
|
|
3025
|
+
if (type === null) return null;
|
|
3026
|
+
if (selected) return "Se guarda aquí";
|
|
3027
|
+
if (allowed) return null;
|
|
3028
|
+
return type.scopes.includes(target.kind) ? "No tiene este documento" : "No aplica a este tipo";
|
|
3029
|
+
}
|
|
3030
|
+
/** El rol de una persona tal cual lo escribió el host (DC-1), o null si no trae uno útil. */
|
|
3031
|
+
function targetRole(target) {
|
|
3032
|
+
if (target.kind !== "person") return null;
|
|
3033
|
+
return typeof target.role === "string" && target.role.trim() !== "" ? target.role : null;
|
|
3034
|
+
}
|
|
3035
|
+
/** Cómo nombra el copy a un destino (DEV-9645): «‹nombre› (‹rol›)», el nombre a secas o el vehículo. */
|
|
3036
|
+
function targetLabel(target) {
|
|
3037
|
+
if (target.kind === "vehicle") return `el vehículo ${target.plate}`;
|
|
3038
|
+
const role = targetRole(target);
|
|
3039
|
+
return role !== null ? `${target.name} (${role})` : target.name;
|
|
3040
|
+
}
|
|
3041
|
+
/**
|
|
3042
|
+
* El hint bajo la lista de destinos (DEV-9645), generado de los datos: a cuántos destinos aplica el
|
|
3043
|
+
* tipo y, si hay filas deshabilitadas junto a alguna permitida, por qué se ven así.
|
|
3044
|
+
*/
|
|
3045
|
+
function targetListHint(type, options) {
|
|
3046
|
+
const allowed = options.filter((option) => option.allowed);
|
|
3047
|
+
if (allowed.length === 0) return `Ningún destino de este caso tiene ${type.name}: elige otro tipo.`;
|
|
3048
|
+
const lead = allowed.length === 1 ? `El tipo define a quién se guarda: ${type.name} solo aplica a ${targetLabel(allowed[0].scope)}.` : `El tipo define a quién se guarda: ${type.name} aplica a ${allowed.length} destinos, elige uno.`;
|
|
3049
|
+
return allowed.length < options.length ? `${lead} Quien no tiene ese documento aparece deshabilitado.` : lead;
|
|
3050
|
+
}
|
|
3051
|
+
/** La primera frase del aviso en modo lista (DEV-9645): nombra el expediente del destino elegido. */
|
|
3052
|
+
function targetNoticeLead(target) {
|
|
3053
|
+
return `Se guarda en el expediente ${target.kind === "vehicle" ? `del vehículo ${target.plate}` : `de ${targetLabel(target)}`} como carga manual, sin OCR, y queda pendiente de decisión.`;
|
|
3054
|
+
}
|
|
2993
3055
|
function DocumentGlyph() {
|
|
2994
3056
|
return /* @__PURE__ */ jsxs("svg", {
|
|
2995
3057
|
width: 20,
|
|
@@ -3127,6 +3189,7 @@ function SaveDocumentDialog({ message, phone, input, onClose }) {
|
|
|
3127
3189
|
const showCatalog = search.trim() !== "" || requested.length === 0;
|
|
3128
3190
|
const { options: scopeOptions, selected: resolvedScope } = resolveScope(type, input.scopes, scope);
|
|
3129
3191
|
const allowedScopeCount = scopeOptions.filter((option) => option.allowed).length;
|
|
3192
|
+
const targetList = usesTargetList(input.types, input.scopes);
|
|
3130
3193
|
const handleTypeChange = (next) => {
|
|
3131
3194
|
setType(next);
|
|
3132
3195
|
};
|
|
@@ -3157,6 +3220,7 @@ function SaveDocumentDialog({ message, phone, input, onClose }) {
|
|
|
3157
3220
|
onClose();
|
|
3158
3221
|
};
|
|
3159
3222
|
const sentWhen = sentWhenLabel(message.at);
|
|
3223
|
+
const noticeLead = targetList && resolvedScope !== null ? targetNoticeLead(resolvedScope) : "Se guarda en el expediente como carga manual, sin OCR, y queda pendiente de decisión.";
|
|
3160
3224
|
return /* @__PURE__ */ jsx("div", {
|
|
3161
3225
|
className: "wa-thread__save-overlay",
|
|
3162
3226
|
onClick: handleOverlayClick,
|
|
@@ -3271,39 +3335,76 @@ function SaveDocumentDialog({ message, phone, input, onClose }) {
|
|
|
3271
3335
|
}),
|
|
3272
3336
|
/* @__PURE__ */ jsxs("fieldset", {
|
|
3273
3337
|
className: "wa-thread__save-scopes",
|
|
3274
|
-
children: [
|
|
3275
|
-
|
|
3276
|
-
scopeOptions.map(({ scope:
|
|
3277
|
-
|
|
3278
|
-
|
|
3279
|
-
|
|
3280
|
-
|
|
3281
|
-
|
|
3282
|
-
|
|
3283
|
-
|
|
3284
|
-
|
|
3285
|
-
|
|
3286
|
-
|
|
3287
|
-
|
|
3288
|
-
|
|
3289
|
-
|
|
3290
|
-
|
|
3291
|
-
|
|
3292
|
-
|
|
3293
|
-
|
|
3294
|
-
|
|
3295
|
-
|
|
3296
|
-
|
|
3297
|
-
|
|
3338
|
+
children: [/* @__PURE__ */ jsx("legend", { children: "De quién es" }), targetList ? /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("div", {
|
|
3339
|
+
className: "wa-thread__save-targets",
|
|
3340
|
+
children: scopeOptions.map(({ scope: target, allowed }, index) => {
|
|
3341
|
+
const selected = resolvedScope === target;
|
|
3342
|
+
const role = targetRole(target);
|
|
3343
|
+
const note = targetNote(type, target, allowed, selected);
|
|
3344
|
+
return /* @__PURE__ */ jsxs("label", {
|
|
3345
|
+
className: "wa-thread__save-scope-option wa-thread__save-target",
|
|
3346
|
+
"data-selected": selected || void 0,
|
|
3347
|
+
"data-disabled": !allowed || void 0,
|
|
3348
|
+
children: [
|
|
3349
|
+
/* @__PURE__ */ jsx("input", {
|
|
3350
|
+
type: "radio",
|
|
3351
|
+
name: "wa-save-document-scope",
|
|
3352
|
+
"data-scope-kind": target.kind,
|
|
3353
|
+
checked: selected,
|
|
3354
|
+
disabled: !allowed || submitting,
|
|
3355
|
+
onChange: () => setScope(target)
|
|
3356
|
+
}),
|
|
3357
|
+
/* @__PURE__ */ jsx("span", {
|
|
3358
|
+
"aria-hidden": "true",
|
|
3359
|
+
children: target.kind === "vehicle" ? /* @__PURE__ */ jsx(VehicleGlyph, {}) : /* @__PURE__ */ jsx(PersonGlyph, {})
|
|
3360
|
+
}),
|
|
3361
|
+
/* @__PURE__ */ jsx("span", {
|
|
3362
|
+
className: "wa-thread__save-target-name",
|
|
3363
|
+
children: target.kind === "vehicle" ? `Vehículo · ${target.plate}` : target.name
|
|
3364
|
+
}),
|
|
3365
|
+
role !== null && /* @__PURE__ */ jsx("span", {
|
|
3366
|
+
className: "wa-thread__save-target-role",
|
|
3367
|
+
children: role
|
|
3368
|
+
}),
|
|
3369
|
+
note !== null && /* @__PURE__ */ jsx("span", {
|
|
3370
|
+
className: "wa-thread__save-target-note",
|
|
3371
|
+
children: note
|
|
3372
|
+
})
|
|
3373
|
+
]
|
|
3374
|
+
}, index);
|
|
3298
3375
|
})
|
|
3299
|
-
|
|
3376
|
+
}), type !== null && /* @__PURE__ */ jsx("p", {
|
|
3377
|
+
className: "wa-thread__save-scope-explain",
|
|
3378
|
+
children: targetListHint(type, scopeOptions)
|
|
3379
|
+
})] }) : /* @__PURE__ */ jsxs(Fragment$1, { children: [scopeOptions.map(({ scope: scopeOption, allowed }, index) => /* @__PURE__ */ jsxs("label", {
|
|
3380
|
+
className: "wa-thread__save-scope-option",
|
|
3381
|
+
"data-selected": resolvedScope === scopeOption || void 0,
|
|
3382
|
+
children: [
|
|
3383
|
+
/* @__PURE__ */ jsx("input", {
|
|
3384
|
+
type: "radio",
|
|
3385
|
+
name: "wa-save-document-scope",
|
|
3386
|
+
"data-scope-kind": scopeOption.kind,
|
|
3387
|
+
checked: resolvedScope === scopeOption,
|
|
3388
|
+
disabled: !allowed || submitting,
|
|
3389
|
+
onChange: () => setScope(scopeOption)
|
|
3390
|
+
}),
|
|
3391
|
+
/* @__PURE__ */ jsx("span", {
|
|
3392
|
+
"aria-hidden": "true",
|
|
3393
|
+
children: scopeOption.kind === "vehicle" ? /* @__PURE__ */ jsx(VehicleGlyph, {}) : /* @__PURE__ */ jsx(PersonGlyph, {})
|
|
3394
|
+
}),
|
|
3395
|
+
scopeOption.kind === "vehicle" ? `Vehículo · ${scopeOption.plate}` : `Persona · ${scopeOption.name}`
|
|
3396
|
+
]
|
|
3397
|
+
}, index)), type !== null && /* @__PURE__ */ jsx("p", {
|
|
3398
|
+
className: "wa-thread__save-scope-explain",
|
|
3399
|
+
children: allowedScopeCount <= 1 ? `El tipo define el alcance: ${type.name} es ${resolvedScope?.kind === "person" ? "de la persona" : "del vehículo"}. Solo se puede cambiar en los tipos que admiten los dos.` : `${type.name} admite los dos alcances — elige de quién es este documento.`
|
|
3400
|
+
})] })]
|
|
3300
3401
|
}),
|
|
3301
3402
|
/* @__PURE__ */ jsxs("div", {
|
|
3302
3403
|
className: "wa-thread__save-notice",
|
|
3303
3404
|
children: [/* @__PURE__ */ jsx("span", {
|
|
3304
3405
|
"aria-hidden": "true",
|
|
3305
3406
|
children: /* @__PURE__ */ jsx(InfoGlyph, {})
|
|
3306
|
-
}), /* @__PURE__ */ jsxs("span", { children: [
|
|
3407
|
+
}), /* @__PURE__ */ jsxs("span", { children: [noticeLead, type !== null && (type.requested === true ? ` Cumple la solicitud abierta de ${type.name} y queda a tu nombre.` : " Queda a tu nombre.")] })]
|
|
3307
3408
|
}),
|
|
3308
3409
|
error !== null && /* @__PURE__ */ jsx("p", {
|
|
3309
3410
|
role: "alert",
|
|
@@ -4786,6 +4887,86 @@ const THREAD_CSS = `
|
|
|
4786
4887
|
background: #f5f7fa;
|
|
4787
4888
|
cursor: default;
|
|
4788
4889
|
}
|
|
4890
|
+
|
|
4891
|
+
/*
|
|
4892
|
+
* DEV-9645: lista de destinos (tablero 553). Solo aplica cuando el host manda \`scopeIds\` o
|
|
4893
|
+
* \`role\`; la base de cada fila es \`.wa-thread__save-scope-option\` y estos modificadores van
|
|
4894
|
+
* encadenados a ella para ganarle en especificidad a \`:has(input:disabled)\` de arriba.
|
|
4895
|
+
*/
|
|
4896
|
+
.wa-thread__save-targets {
|
|
4897
|
+
display: flex;
|
|
4898
|
+
flex-direction: column;
|
|
4899
|
+
gap: 6px;
|
|
4900
|
+
}
|
|
4901
|
+
.wa-thread__save-target {
|
|
4902
|
+
position: relative;
|
|
4903
|
+
}
|
|
4904
|
+
/* La radio queda oculta a la vista pero accesible: el estado lo cuenta la fila. */
|
|
4905
|
+
.wa-thread__save-target input[type='radio'] {
|
|
4906
|
+
position: absolute;
|
|
4907
|
+
width: 1px;
|
|
4908
|
+
height: 1px;
|
|
4909
|
+
margin: -1px;
|
|
4910
|
+
padding: 0;
|
|
4911
|
+
overflow: hidden;
|
|
4912
|
+
clip: rect(0 0 0 0);
|
|
4913
|
+
white-space: nowrap;
|
|
4914
|
+
border: 0;
|
|
4915
|
+
}
|
|
4916
|
+
.wa-thread__save-scope-option.wa-thread__save-target:has(input:focus-visible) {
|
|
4917
|
+
outline: 2px solid #4E5BEF;
|
|
4918
|
+
outline-offset: 2px;
|
|
4919
|
+
}
|
|
4920
|
+
.wa-thread__save-target-name {
|
|
4921
|
+
min-width: 0;
|
|
4922
|
+
font-size: 13px;
|
|
4923
|
+
font-weight: 600;
|
|
4924
|
+
}
|
|
4925
|
+
.wa-thread__save-target-role {
|
|
4926
|
+
flex: 0 0 auto;
|
|
4927
|
+
padding: 2px 8px;
|
|
4928
|
+
border-radius: 999px;
|
|
4929
|
+
font-size: 10.5px;
|
|
4930
|
+
font-weight: 600;
|
|
4931
|
+
color: #6B7280;
|
|
4932
|
+
background: #EEF0F3;
|
|
4933
|
+
}
|
|
4934
|
+
.wa-thread__save-target-note {
|
|
4935
|
+
flex: 0 0 auto;
|
|
4936
|
+
margin-left: auto;
|
|
4937
|
+
font-size: 11px;
|
|
4938
|
+
color: #9AA1AE;
|
|
4939
|
+
}
|
|
4940
|
+
/* Elegida: borde de 2px con el padding compensado para que la fila no salte. */
|
|
4941
|
+
.wa-thread__save-scope-option.wa-thread__save-target[data-selected='true'] {
|
|
4942
|
+
padding: 9px 11px;
|
|
4943
|
+
border: 2px solid #4E5BEF;
|
|
4944
|
+
color: #2D3340;
|
|
4945
|
+
background: #EEF0FE;
|
|
4946
|
+
}
|
|
4947
|
+
.wa-thread__save-target[data-selected='true'] .wa-thread__save-target-role {
|
|
4948
|
+
color: #4E5BEF;
|
|
4949
|
+
background: #FFFFFF;
|
|
4950
|
+
}
|
|
4951
|
+
.wa-thread__save-target[data-selected='true'] .wa-thread__save-target-note {
|
|
4952
|
+
font-weight: 600;
|
|
4953
|
+
color: #3A44C7;
|
|
4954
|
+
}
|
|
4955
|
+
/* Deshabilitada: colores explícitos del tablero, sin la opacidad genérica de 0.55. */
|
|
4956
|
+
.wa-thread__save-scope-option.wa-thread__save-target[data-disabled='true'] {
|
|
4957
|
+
border: 1px solid #E3E6EB;
|
|
4958
|
+
color: #9AA1AE;
|
|
4959
|
+
background: #F8F9FB;
|
|
4960
|
+
cursor: default;
|
|
4961
|
+
opacity: 1;
|
|
4962
|
+
}
|
|
4963
|
+
.wa-thread__save-target[data-disabled='true'] svg {
|
|
4964
|
+
color: #B6BCC6;
|
|
4965
|
+
}
|
|
4966
|
+
.wa-thread__save-target[data-disabled='true'] .wa-thread__save-target-role {
|
|
4967
|
+
color: #9AA1AE;
|
|
4968
|
+
background: #EEF0F3;
|
|
4969
|
+
}
|
|
4789
4970
|
`;
|
|
4790
4971
|
//#endregion
|
|
4791
4972
|
//#region src/core/thread/useComposer.ts
|
package/package.json
CHANGED