mitre-form-component 0.1.4 → 2.1.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 +131 -28
- package/dist/index.cjs +439 -70
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +53 -3
- package/dist/index.d.ts +53 -3
- package/dist/index.js +427 -58
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -5,15 +5,24 @@ interface Product {
|
|
|
5
5
|
name: string;
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
+
type Ambiente = "homol" | "prod";
|
|
9
|
+
|
|
8
10
|
declare enum PreferenciaContato {
|
|
9
11
|
Whatsapp = "Whatsapp",
|
|
10
12
|
Email = "Email",
|
|
11
13
|
Ligacao = "Liga\u00E7\u00E3o"
|
|
12
14
|
}
|
|
15
|
+
|
|
16
|
+
type Canal = "form" | "chat" | "whatsapp";
|
|
13
17
|
interface MitreFormComponentProps {
|
|
14
18
|
products: Product[];
|
|
15
|
-
|
|
16
|
-
|
|
19
|
+
/**
|
|
20
|
+
* Define de qual config interno o componente lê `apiUrl`, `apiToken`,
|
|
21
|
+
* `whatsappPhone` e `chatUrl`. Default `"homol"`.
|
|
22
|
+
*/
|
|
23
|
+
ambiente?: Ambiente;
|
|
24
|
+
/** Default `"form"`. Ver doc/canal-feature.md. */
|
|
25
|
+
canal?: Canal;
|
|
17
26
|
showHeader?: boolean;
|
|
18
27
|
title?: string;
|
|
19
28
|
subtitle?: string;
|
|
@@ -28,7 +37,28 @@ interface MitreFormComponentProps {
|
|
|
28
37
|
inputTextColor?: string;
|
|
29
38
|
inputPlaceholderColor?: string;
|
|
30
39
|
showPreferenciaContato?: boolean;
|
|
40
|
+
/** Opcional. Repassado no body do POST /leads e no `virtual_obj` (modo chat). */
|
|
41
|
+
idProdutoTerceiro?: string | number;
|
|
42
|
+
/** Opcional. Repassado no body do POST /leads e no `virtual_obj` (modo chat). */
|
|
43
|
+
idEmpreendimento?: string | number;
|
|
44
|
+
/**
|
|
45
|
+
* Default: `true` em `canal === "chat"` / `"whatsapp"` (paridade com `atendimento.html`),
|
|
46
|
+
* `false` em `canal === "form"`. Passe `false` para forçar criação do evento.
|
|
47
|
+
*/
|
|
48
|
+
naoCriarEvento?: boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Callback chamado após o POST `/leads` retornar sucesso, em qualquer canal.
|
|
51
|
+
* Útil para tracking (GTM, Analytics), redirect customizado ou logging na landing.
|
|
52
|
+
* O componente continua exibindo a UI de sucesso (mensagem em `canal=form`, modal
|
|
53
|
+
* em `canal=whatsapp`/`canal=chat`) independente do callback.
|
|
54
|
+
*/
|
|
31
55
|
onSuccess?: (requestBody: RequestBody, leadId: string) => void;
|
|
56
|
+
/**
|
|
57
|
+
* Callback chamado quando o POST `/leads` falha, em qualquer canal. Útil para
|
|
58
|
+
* tracking de erro (Sentry, Datadog, GTM). O componente continua exibindo a UI
|
|
59
|
+
* de erro (alert em `canal=form`, modal em `canal=whatsapp`/`canal=chat`)
|
|
60
|
+
* independente do callback.
|
|
61
|
+
*/
|
|
32
62
|
onError?: (error: Error) => void;
|
|
33
63
|
}
|
|
34
64
|
interface RequestBody {
|
|
@@ -42,7 +72,27 @@ interface RequestBody {
|
|
|
42
72
|
utm_campaign?: string;
|
|
43
73
|
utm_term?: string;
|
|
44
74
|
preferencia_contato?: string;
|
|
75
|
+
/** Presente quando `canal !== "form"`. */
|
|
76
|
+
canal?: Canal;
|
|
77
|
+
/**
|
|
78
|
+
* Presente (e sempre `true`) quando `canal !== "form"`. Paridade com o fluxo legado
|
|
79
|
+
* `atendimento.html`, cujo `<form id="chat-form">` enviava o hidden `is_chat=true`
|
|
80
|
+
* em ambos os canais (chat e whatsapp).
|
|
81
|
+
*/
|
|
82
|
+
is_chat?: boolean;
|
|
83
|
+
/** Presente quando `canal !== "form"`. `window.location.href` no momento do submit. */
|
|
84
|
+
pagina?: string;
|
|
85
|
+
/** Presente quando a prop homônima for informada e `canal !== "form"`. */
|
|
86
|
+
idProdutoTerceiro?: string | number;
|
|
87
|
+
/** Presente quando a prop homônima for informada e `canal !== "form"`. */
|
|
88
|
+
idEmpreendimento?: string | number;
|
|
89
|
+
/**
|
|
90
|
+
* Presente quando o flag efetivo é `true`. Por default vai `true` em
|
|
91
|
+
* `canal === "chat"` / `canal === "whatsapp"`; pode ser desligado com
|
|
92
|
+
* `naoCriarEvento={false}`.
|
|
93
|
+
*/
|
|
94
|
+
naoCriarEvento?: boolean;
|
|
45
95
|
}
|
|
46
96
|
declare const MitreFormComponent: React.ForwardRefExoticComponent<MitreFormComponentProps & React.RefAttributes<HTMLDivElement>>;
|
|
47
97
|
|
|
48
|
-
export { MitreFormComponent, type MitreFormComponentProps, PreferenciaContato, type RequestBody };
|
|
98
|
+
export { type Ambiente, type Canal, MitreFormComponent, type MitreFormComponentProps, PreferenciaContato, type RequestBody };
|