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