@adatechnology/conversations-ui 0.16.0 → 0.17.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 +23 -0
- package/dist/{chunk-Y326LLEP.js → chunk-7OLYCCLX.js} +1 -1
- package/dist/{chunk-WCZNIJ3M.js → chunk-Z7U22M3K.js} +7 -0
- package/dist/flows/index.d.ts +19 -3
- package/dist/flows/index.js +426 -238
- package/dist/index.d.ts +34 -3
- package/dist/index.js +88 -23
- package/dist/participant/index.js +1 -1
- package/dist/preview/index.js +2 -2
- package/package.json +2 -2
- package/src/flows/FlowNodeCard.tsx +17 -7
- package/src/flows/FlowNodePanel.tsx +10 -0
- package/src/flows/FlowPossibleNextField.tsx +89 -0
- package/src/flows/FlowRunnerFields.tsx +70 -16
- package/src/flows/flowCanvasModel.ts +16 -1
- package/src/flows/flowEditorOps.ts +19 -2
- package/src/flows/flowGraph.ts +37 -7
- package/src/flows/flowPossibleNext.test.ts +70 -0
- package/src/flows/labels.ts +28 -1
- package/src/index.ts +2 -1
- package/src/lib/phone.test.ts +20 -0
- package/src/lib/phone.ts +13 -0
- package/src/workspace/ConversationPane.tsx +13 -2
- package/src/workspace/ConversationsWorkspace.tsx +117 -18
- package/src/workspace/index.ts +1 -0
- package/src/workspace/labels.ts +2 -0
- package/src/workspace/workspaceTestContactDom.test.tsx +96 -0
package/README.md
CHANGED
|
@@ -3,6 +3,29 @@
|
|
|
3
3
|
Telas de conversa parametrizáveis por endpoint, tema e capacidades. Subpaths: `.` (inbox/mensagens),
|
|
4
4
|
`/flows`, `/whatsapp`, `/preview`, `/participant` e `/styles.css`.
|
|
5
5
|
|
|
6
|
+
## Workspace: simulador e painel de contexto
|
|
7
|
+
|
|
8
|
+
```tsx
|
|
9
|
+
<ConversationsWorkspace
|
|
10
|
+
simulator={{
|
|
11
|
+
transports: { whatsapp: ({ conversationId, handle }) => createBridgeClient({ conversationId, handle }) },
|
|
12
|
+
// Liga "Novo contato de teste" no cabeçalho: abre o simulador sem conversa selecionada.
|
|
13
|
+
createTestContact: () => ({ handle: `0${Date.now()}` }),
|
|
14
|
+
}}
|
|
15
|
+
contextEntriesOf={(context) => toEntries(context)}
|
|
16
|
+
contextLabels={{ title: 'Dados da reserva', empty: 'Nada informado ainda.', notCollected: 'a informar' }}
|
|
17
|
+
/>
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
- **Novo contato de teste:** `createTestContact` devolve `{ handle, channel?, conversationId? }`. O painel
|
|
21
|
+
abre com o transporte do canal, sem conversa selecionada; quando a conversa do contato aparece na lista
|
|
22
|
+
(primeiro envio), ela é selecionada e o painel segue sobre ela. Sem a prop, o botão não existe.
|
|
23
|
+
- **Número de teste:** número só de dígitos começando com `0` (nenhum país usa) não é mascarado como
|
|
24
|
+
telefone: aparece como "Contato de teste 1234" na lista, no cabeçalho e no simulador
|
|
25
|
+
(`isTestContactNumber`, `TEST_CONTACT_LABEL`).
|
|
26
|
+
- **`contextLabels`** troca o vocabulário do painel de contexto embutido (`title`, `empty`,
|
|
27
|
+
`notCollected`, ...), sem precisar desenhar o resumo em `renderAboveTranscript`.
|
|
28
|
+
|
|
6
29
|
## Visão do participante (`/participant`)
|
|
7
30
|
|
|
8
31
|
Tela de conversa do lado de **quem conversa com a empresa** (app de campo, portal do cliente). Não usa
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
// src/lib/phone.ts
|
|
2
|
+
var TEST_CONTACT_LABEL = "Contato de teste";
|
|
3
|
+
function isTestContactNumber(number) {
|
|
4
|
+
return /^0\d{3,}$/.test(number.replace(/[\s()+-]/g, ""));
|
|
5
|
+
}
|
|
2
6
|
function formatPhone(number) {
|
|
3
7
|
const digits = number.replace(/\D/g, "");
|
|
8
|
+
if (isTestContactNumber(number)) return `${TEST_CONTACT_LABEL} ${digits.slice(-4)}`;
|
|
4
9
|
if (digits.length === 13) {
|
|
5
10
|
return `+${digits.slice(0, 2)} (${digits.slice(2, 4)}) ${digits.slice(4, 9)}-${digits.slice(9, 13)}`;
|
|
6
11
|
}
|
|
@@ -247,6 +252,8 @@ function resolveRecordingFormat() {
|
|
|
247
252
|
}
|
|
248
253
|
|
|
249
254
|
export {
|
|
255
|
+
TEST_CONTACT_LABEL,
|
|
256
|
+
isTestContactNumber,
|
|
250
257
|
formatPhone,
|
|
251
258
|
phoneInitials,
|
|
252
259
|
CONVERSATION_CHANNEL,
|
package/dist/flows/index.d.ts
CHANGED
|
@@ -45,12 +45,15 @@ declare const WHATSAPP_LIMITS: {
|
|
|
45
45
|
* runner do módulo, para a prévia mostrar o que o cliente vai ver.
|
|
46
46
|
*/
|
|
47
47
|
declare function rendersAsButtons(options: [string, string][] | undefined, optionDetails?: Record<string, FlowOptionDetail>): boolean;
|
|
48
|
-
|
|
48
|
+
type FlowNodeTarget = {
|
|
49
49
|
target: string;
|
|
50
50
|
optionId?: string;
|
|
51
51
|
keyword?: string;
|
|
52
52
|
isDefault?: boolean;
|
|
53
|
-
|
|
53
|
+
/** Destino de `possibleNext`: a action pode escolher, não é garantido. */
|
|
54
|
+
isPossible?: boolean;
|
|
55
|
+
};
|
|
56
|
+
declare function targetsOf(node: FlowNodeData): FlowNodeTarget[];
|
|
54
57
|
type GraphIssue = {
|
|
55
58
|
severity: 'error' | 'warning';
|
|
56
59
|
nodeId?: string;
|
|
@@ -73,6 +76,7 @@ declare function validateGraph(graph: FlowGraphData, issueText: {
|
|
|
73
76
|
descriptionTooLong?: (id: string, label: string) => string;
|
|
74
77
|
dynamicChoiceWithoutProvider?: (id: string) => string;
|
|
75
78
|
choiceDefaultIgnored?: (id: string) => string;
|
|
79
|
+
possibleNextIgnored?: (id: string) => string;
|
|
76
80
|
}): GraphIssue[];
|
|
77
81
|
/**
|
|
78
82
|
* Auto-layout em cascata: avança para a direita a cada passo do fluxo e desce a cada card.
|
|
@@ -108,6 +112,15 @@ interface FlowRunnerFieldLabels {
|
|
|
108
112
|
maxInvalidAnswersHint: string;
|
|
109
113
|
minDateToday: string;
|
|
110
114
|
afterContextKey: string;
|
|
115
|
+
minTime?: string;
|
|
116
|
+
maxTime?: string;
|
|
117
|
+
timeWindowsContextKey?: string;
|
|
118
|
+
timeWindowsContextKeyHint?: string;
|
|
119
|
+
possibleNext?: string;
|
|
120
|
+
possibleNextHint?: string;
|
|
121
|
+
addPossibleNext?: string;
|
|
122
|
+
removePossibleNext?: string;
|
|
123
|
+
possibleNextRowLabel?: string;
|
|
111
124
|
minValue: string;
|
|
112
125
|
maxValue: string;
|
|
113
126
|
minLength: string;
|
|
@@ -148,7 +161,10 @@ interface FlowEditorLabels {
|
|
|
148
161
|
edgeFallbackLabel: string;
|
|
149
162
|
actionKindLabels: Record<string, string>;
|
|
150
163
|
conditionOperatorLabels: Record<FlowConditionOperator, string>;
|
|
151
|
-
|
|
164
|
+
/** `time` opcional: quem já passava a lista inteira continua compilando; ausente, vale o padrão. */
|
|
165
|
+
questionTypeLabels: Record<Exclude<FlowQuestionType, 'time'>, string> & {
|
|
166
|
+
time?: string;
|
|
167
|
+
};
|
|
152
168
|
/** Opcional para não quebrar quem monta os textos à mão; ausente, vale o padrão pt-BR. */
|
|
153
169
|
runnerFields?: FlowRunnerFieldLabels;
|
|
154
170
|
nodePanel: {
|