@adatechnology/conversations-ui 0.16.0 → 0.18.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 +52 -6
- package/dist/flows/index.js +470 -245
- package/dist/index.d.ts +77 -3
- package/dist/index.js +148 -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/FlowsWorkspace.tsx +8 -2
- package/src/flows/flowCanvasModel.ts +16 -1
- package/src/flows/flowEditorOps.ts +19 -2
- package/src/flows/flowGraph.ts +108 -11
- package/src/flows/flowLabelValidation.test.ts +92 -0
- package/src/flows/flowPossibleNext.test.ts +70 -0
- package/src/flows/index.ts +3 -0
- package/src/flows/labels.ts +39 -1
- package/src/index.ts +11 -1
- package/src/lib/phone.test.ts +20 -0
- package/src/lib/phone.ts +13 -0
- package/src/quickReplies/createMetaWhatsAppQuickRepliesClient.test.ts +113 -0
- package/src/quickReplies/createMetaWhatsAppQuickRepliesClient.ts +111 -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
|
@@ -35,22 +35,42 @@ declare const WHATSAPP_LIMITS: {
|
|
|
35
35
|
readonly MAX_BUTTONS: 3;
|
|
36
36
|
readonly MAX_LIST_ROWS: 10;
|
|
37
37
|
readonly BUTTON_TITLE_MAX: 20;
|
|
38
|
+
readonly LIST_BUTTON_LABEL_MAX: 20;
|
|
38
39
|
readonly LIST_ROW_TITLE_MAX: 24;
|
|
39
40
|
readonly LIST_ROW_DESCRIPTION_MAX: 72;
|
|
40
41
|
readonly LIST_SECTION_TITLE_MAX: 24;
|
|
41
42
|
readonly BODY_MAX: 1024;
|
|
42
43
|
};
|
|
44
|
+
type MeasuredLabel = {
|
|
45
|
+
/** Caracteres do texto como o cliente o leria; sem exemplo para uma variável, ela vale 0 (mínimo certo). */
|
|
46
|
+
readonly length: number;
|
|
47
|
+
/** `true` quando alguma `{{variável}}` ficou sem exemplo: o tamanho real só se sabe em tempo de execução. */
|
|
48
|
+
readonly isApproximate: boolean;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Mede um rótulo com `{{variável}}` sobre o texto interpolado com o exemplo da variável. Sem exemplo,
|
|
52
|
+
* mede o texto sem ela — contar a marcação escrita daria erro falso (`{{nome}}` vale 8 e a variável
|
|
53
|
+
* real pode ter 4).
|
|
54
|
+
*/
|
|
55
|
+
declare function measureLabel(label: string, variableExamples?: Readonly<Record<string, string>>): MeasuredLabel;
|
|
56
|
+
type ValidateGraphOptions = {
|
|
57
|
+
/** Valor de exemplo por variável (`{ buttonName: 'Pernoite' }`), usado para medir rótulos de botão e linha de lista. */
|
|
58
|
+
readonly variableExamples?: Readonly<Record<string, string>>;
|
|
59
|
+
};
|
|
43
60
|
/**
|
|
44
61
|
* Botão com até 3 opções simples; opção com descrição ou seção força lista — é a mesma regra do
|
|
45
62
|
* runner do módulo, para a prévia mostrar o que o cliente vai ver.
|
|
46
63
|
*/
|
|
47
64
|
declare function rendersAsButtons(options: [string, string][] | undefined, optionDetails?: Record<string, FlowOptionDetail>): boolean;
|
|
48
|
-
|
|
65
|
+
type FlowNodeTarget = {
|
|
49
66
|
target: string;
|
|
50
67
|
optionId?: string;
|
|
51
68
|
keyword?: string;
|
|
52
69
|
isDefault?: boolean;
|
|
53
|
-
|
|
70
|
+
/** Destino de `possibleNext`: a action pode escolher, não é garantido. */
|
|
71
|
+
isPossible?: boolean;
|
|
72
|
+
};
|
|
73
|
+
declare function targetsOf(node: FlowNodeData): FlowNodeTarget[];
|
|
54
74
|
type GraphIssue = {
|
|
55
75
|
severity: 'error' | 'warning';
|
|
56
76
|
nodeId?: string;
|
|
@@ -73,7 +93,12 @@ declare function validateGraph(graph: FlowGraphData, issueText: {
|
|
|
73
93
|
descriptionTooLong?: (id: string, label: string) => string;
|
|
74
94
|
dynamicChoiceWithoutProvider?: (id: string) => string;
|
|
75
95
|
choiceDefaultIgnored?: (id: string) => string;
|
|
76
|
-
|
|
96
|
+
possibleNextIgnored?: (id: string) => string;
|
|
97
|
+
buttonTitleMayBeTooLong?: (id: string, label: string) => string;
|
|
98
|
+
listTitleMayBeTooLong?: (id: string, label: string) => string;
|
|
99
|
+
listButtonLabelTooLong?: (id: string, label: string) => string;
|
|
100
|
+
listButtonLabelMayBeTooLong?: (id: string, label: string) => string;
|
|
101
|
+
}, settings?: ValidateGraphOptions): GraphIssue[];
|
|
77
102
|
/**
|
|
78
103
|
* Auto-layout em cascata: avança para a direita a cada passo do fluxo e desce a cada card.
|
|
79
104
|
*
|
|
@@ -108,6 +133,15 @@ interface FlowRunnerFieldLabels {
|
|
|
108
133
|
maxInvalidAnswersHint: string;
|
|
109
134
|
minDateToday: string;
|
|
110
135
|
afterContextKey: string;
|
|
136
|
+
minTime?: string;
|
|
137
|
+
maxTime?: string;
|
|
138
|
+
timeWindowsContextKey?: string;
|
|
139
|
+
timeWindowsContextKeyHint?: string;
|
|
140
|
+
possibleNext?: string;
|
|
141
|
+
possibleNextHint?: string;
|
|
142
|
+
addPossibleNext?: string;
|
|
143
|
+
removePossibleNext?: string;
|
|
144
|
+
possibleNextRowLabel?: string;
|
|
111
145
|
minValue: string;
|
|
112
146
|
maxValue: string;
|
|
113
147
|
minLength: string;
|
|
@@ -148,7 +182,10 @@ interface FlowEditorLabels {
|
|
|
148
182
|
edgeFallbackLabel: string;
|
|
149
183
|
actionKindLabels: Record<string, string>;
|
|
150
184
|
conditionOperatorLabels: Record<FlowConditionOperator, string>;
|
|
151
|
-
|
|
185
|
+
/** `time` opcional: quem já passava a lista inteira continua compilando; ausente, vale o padrão. */
|
|
186
|
+
questionTypeLabels: Record<Exclude<FlowQuestionType, 'time'>, string> & {
|
|
187
|
+
time?: string;
|
|
188
|
+
};
|
|
152
189
|
/** Opcional para não quebrar quem monta os textos à mão; ausente, vale o padrão pt-BR. */
|
|
153
190
|
runnerFields?: FlowRunnerFieldLabels;
|
|
154
191
|
nodePanel: {
|
|
@@ -300,6 +337,10 @@ interface FlowValidationLabels {
|
|
|
300
337
|
descriptionTooLong?: (id: string, label: string) => string;
|
|
301
338
|
dynamicChoiceWithoutProvider?: (id: string) => string;
|
|
302
339
|
choiceDefaultIgnored?: (id: string) => string;
|
|
340
|
+
buttonTitleMayBeTooLong?: (id: string, label: string) => string;
|
|
341
|
+
listTitleMayBeTooLong?: (id: string, label: string) => string;
|
|
342
|
+
listButtonLabelTooLong?: (id: string, label: string) => string;
|
|
343
|
+
listButtonLabelMayBeTooLong?: (id: string, label: string) => string;
|
|
303
344
|
}
|
|
304
345
|
declare const DEFAULT_FLOW_EDITOR_LABELS: FlowEditorLabels;
|
|
305
346
|
declare function mergeFlowEditorLabels(override?: Partial<FlowEditorLabels>): FlowEditorLabels;
|
|
@@ -644,6 +685,11 @@ interface FlowsWorkspaceProps {
|
|
|
644
685
|
* pacote a adivinhar a escala tipográfica de cada produto.
|
|
645
686
|
*/
|
|
646
687
|
readonly showHeader?: boolean;
|
|
688
|
+
/**
|
|
689
|
+
* Valor de exemplo por variável usada em rótulo de botão e linha de lista (`{ buttonName: 'Pernoite' }`).
|
|
690
|
+
* Com exemplo, o validador mede o texto interpolado; sem, só avisa quando a marcação escrita passa do limite.
|
|
691
|
+
*/
|
|
692
|
+
readonly variableExamples?: Readonly<Record<string, string>>;
|
|
647
693
|
readonly className?: string;
|
|
648
694
|
}
|
|
649
695
|
/**
|
|
@@ -654,7 +700,7 @@ interface FlowsWorkspaceProps {
|
|
|
654
700
|
* versão diferente do mesmo editor. Customização entra por `labels`, `actionOptions` e
|
|
655
701
|
* `renderMediaPicker` — nunca por cópia do arquivo.
|
|
656
702
|
*/
|
|
657
|
-
declare function FlowsWorkspace({ api, rootFlowKey, labels: labelsOverride, actionOptions, renderMediaPicker, livePollIntervalMs, showHeader, className, }: FlowsWorkspaceProps): react.JSX.Element;
|
|
703
|
+
declare function FlowsWorkspace({ api, rootFlowKey, labels: labelsOverride, actionOptions, renderMediaPicker, livePollIntervalMs, showHeader, variableExamples, className, }: FlowsWorkspaceProps): react.JSX.Element;
|
|
658
704
|
|
|
659
705
|
/**
|
|
660
706
|
* Copyright (c) 2026 Ada Technology. MIT License.
|
|
@@ -727,4 +773,4 @@ declare function applyConnection(node: FlowNodeData, resolved: ResolvedConnectio
|
|
|
727
773
|
*/
|
|
728
774
|
declare function isGraphDirty(working: FlowGraphData | undefined, published: FlowGraphData | undefined): boolean;
|
|
729
775
|
|
|
730
|
-
export { BUILT_IN_ACTION_KINDS, CONDITION_OPERATORS, CROSS_FLOW_PREFIX, type CollectionChain, type ConnectionRequest, type CreateFlowInput, DEFAULT_FLOW_EDITOR_LABELS, FlowConnectionEdge, type FlowEdgeKind, type FlowEdgeSpec, type FlowEditorLabels, FlowGroupFrame, type FlowGroupFrameData, FlowGroupHeader, type FlowGroupHeaderData, FlowLegend, type FlowLiveNodeCount, type FlowLivePosition, type FlowLivePositionInput, FlowMapCanvas, type FlowMapCanvasProps, FlowMapNode, type FlowMapNodeData, FlowNodeCard, type FlowNodeCardData, FlowNodePanel, type FlowNodePanelProps, type FlowNodePosition, FlowPalette, type FlowPaletteActionOption, FlowPaletteMenu, type FlowPaletteProps, FlowPortalNode, type FlowPortalNodeData, type FlowValidationLabels, FlowWhatsAppPreview, type FlowWhatsAppPreviewProps, FlowsWorkspace, type FlowsWorkspaceApi, type FlowsWorkspaceProps, GROUP_HEADER_NODE_ID, type GraphIssue, NODE_CARD_WIDTH, type NewNodeSpec, PASS_THROUGH_ACTION_KINDS, type ResolvedConnection, WHATSAPP_LIMITS, applyConnection, buildFlowEdges, chainFrameBounds, chainFrameNodeId, computeAutoLayout, computeFlowMapLayout, computeMergedLayout, countLiveByNode, crossFlowKey, crossFlowTargetsOf, detachedNodeIds, estimateNodeHeight, findCollectionChains, flowEdgeTypes, flowGroupFrameNodeTypes, flowGroupHeaderNodeTypes, flowMapNodeTypes, flowNodeTypes, flowPortalNodeTypes, isCrossFlowTarget, isGraphDirty, mergeFlowEditorLabels, mergedFlowKeysFrom, namespaceNodeId, newNodeFromSpec, nodeLabel, parseNamespacedId, portalNodeId, removeNodeAndCleanRefs, rendersAsButtons, resolveConnection, slugifyNodeId, targetsOf, validateGraph };
|
|
776
|
+
export { BUILT_IN_ACTION_KINDS, CONDITION_OPERATORS, CROSS_FLOW_PREFIX, type CollectionChain, type ConnectionRequest, type CreateFlowInput, DEFAULT_FLOW_EDITOR_LABELS, FlowConnectionEdge, type FlowEdgeKind, type FlowEdgeSpec, type FlowEditorLabels, FlowGroupFrame, type FlowGroupFrameData, FlowGroupHeader, type FlowGroupHeaderData, FlowLegend, type FlowLiveNodeCount, type FlowLivePosition, type FlowLivePositionInput, FlowMapCanvas, type FlowMapCanvasProps, FlowMapNode, type FlowMapNodeData, FlowNodeCard, type FlowNodeCardData, FlowNodePanel, type FlowNodePanelProps, type FlowNodePosition, FlowPalette, type FlowPaletteActionOption, FlowPaletteMenu, type FlowPaletteProps, FlowPortalNode, type FlowPortalNodeData, type FlowValidationLabels, FlowWhatsAppPreview, type FlowWhatsAppPreviewProps, FlowsWorkspace, type FlowsWorkspaceApi, type FlowsWorkspaceProps, GROUP_HEADER_NODE_ID, type GraphIssue, type MeasuredLabel, NODE_CARD_WIDTH, type NewNodeSpec, PASS_THROUGH_ACTION_KINDS, type ResolvedConnection, type ValidateGraphOptions, WHATSAPP_LIMITS, applyConnection, buildFlowEdges, chainFrameBounds, chainFrameNodeId, computeAutoLayout, computeFlowMapLayout, computeMergedLayout, countLiveByNode, crossFlowKey, crossFlowTargetsOf, detachedNodeIds, estimateNodeHeight, findCollectionChains, flowEdgeTypes, flowGroupFrameNodeTypes, flowGroupHeaderNodeTypes, flowMapNodeTypes, flowNodeTypes, flowPortalNodeTypes, isCrossFlowTarget, isGraphDirty, measureLabel, mergeFlowEditorLabels, mergedFlowKeysFrom, namespaceNodeId, newNodeFromSpec, nodeLabel, parseNamespacedId, portalNodeId, removeNodeAndCleanRefs, rendersAsButtons, resolveConnection, slugifyNodeId, targetsOf, validateGraph };
|