mitre-form-component 0.1.2 → 0.1.4
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 +33 -0
- package/dist/index.cjs +166 -139
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -1
- package/dist/index.d.ts +8 -1
- package/dist/index.js +162 -136
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -70,6 +70,7 @@ const products = JSON.parse(process.env.VITE_PRODUCT_ID!);
|
|
|
70
70
|
inputFocusBorderColor="#76B" //[Opcional]
|
|
71
71
|
inputPlaceholderColor="#FFF" //[Opcional]
|
|
72
72
|
inputTextColor="#FFF" //[Opcional]
|
|
73
|
+
showPreferenciaContato={true} //[Opcional] Exibe campo de preferência de contato
|
|
73
74
|
onSuccess={(requestBody, leadId) => console.log('Formulário enviado com sucesso!', requestBody, leadId)} //[Opcional]
|
|
74
75
|
onError={(error) => console.error('Erro ao enviar formulário:', error)} //[Opcional]
|
|
75
76
|
/>;
|
|
@@ -142,6 +143,7 @@ O `MitreFormComponent` aceita as seguintes props:
|
|
|
142
143
|
- **`inputFocusBorderColor`** (opcional, string): Cor da borda do input quando selecionado. Padrão: `#F6C76B`.
|
|
143
144
|
- **`inputPlaceholderColor`** (opcional, string): Cor do placeholder do input. Padrão: `#B6B6B6`.
|
|
144
145
|
- **`inputTextColor`** (opcional, string): Cor do texto do input. Padrão: `#2F2F2F`.
|
|
146
|
+
- **`showPreferenciaContato`** (opcional, boolean): Exibe um campo de seleção "Preferência de Contato" com as opções `Whatsapp`, `Email` e `Ligação`. Quando selecionado, o valor é enviado à API como `preferencia_contato`. Padrão: `false`.
|
|
145
147
|
- **`onSuccess`** (opcional, função): Callback executado quando o formulário é enviado com sucesso. Recebe dois parâmetros: `requestBody` (objeto com os dados enviados) e `leadId` (string com o ID do lead retornado pela API).
|
|
146
148
|
- **`onError`** (opcional, função): Callback executado quando ocorre um erro no envio do formulário. Recebe um objeto `Error` como parâmetro.
|
|
147
149
|
|
|
@@ -176,6 +178,37 @@ interface Product {
|
|
|
176
178
|
|
|
177
179
|
---
|
|
178
180
|
|
|
181
|
+
## 📞 Preferência de Contato
|
|
182
|
+
|
|
183
|
+
Quando `showPreferenciaContato={true}`, um campo de seleção é exibido no formulário com as seguintes opções:
|
|
184
|
+
|
|
185
|
+
| Valor do enum | Valor enviado à API |
|
|
186
|
+
|--------------------------|---------------------|
|
|
187
|
+
| `PreferenciaContato.Whatsapp` | `"Whatsapp"` |
|
|
188
|
+
| `PreferenciaContato.Email` | `"Email"` |
|
|
189
|
+
| `PreferenciaContato.Ligacao` | `"Ligação"` |
|
|
190
|
+
|
|
191
|
+
O campo é opcional: se o usuário não selecionar nenhuma opção, `preferencia_contato` não é enviado no body da requisição.
|
|
192
|
+
|
|
193
|
+
O enum `PreferenciaContato` é exportado pela biblioteca para uso externo, se necessário:
|
|
194
|
+
|
|
195
|
+
```tsx
|
|
196
|
+
import { MitreFormComponent, PreferenciaContato } from "mitre-form-component-next";
|
|
197
|
+
|
|
198
|
+
<MitreFormComponent
|
|
199
|
+
products={products}
|
|
200
|
+
apiUrl={process.env.NEXT_PUBLIC_REGISTER_LEADS_URL!}
|
|
201
|
+
apiToken={process.env.NEXT_PUBLIC_REGISTER_LEADS_TOKEN!}
|
|
202
|
+
showPreferenciaContato={true}
|
|
203
|
+
onSuccess={(requestBody) => {
|
|
204
|
+
// requestBody.preferencia_contato estará presente se o usuário selecionou uma opção
|
|
205
|
+
console.log(requestBody.preferencia_contato); // ex: "Whatsapp"
|
|
206
|
+
}}
|
|
207
|
+
/>
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
---
|
|
211
|
+
|
|
179
212
|
## 🚨 Componente dentro de um `ErrorBoundary`
|
|
180
213
|
|
|
181
214
|
Recomendamos que o componente `MitreFormComponent` seja sempre utilizado dentro de um `ErrorBoundary` para garantir que a aplicação não quebre em caso de falha no carregamento do componente. Também é preciso usar dynamic do next/dynamics para a importação.
|
package/dist/index.cjs
CHANGED
|
@@ -30,7 +30,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/index.ts
|
|
31
31
|
var index_exports = {};
|
|
32
32
|
__export(index_exports, {
|
|
33
|
-
MitreFormComponent: () => Form_default
|
|
33
|
+
MitreFormComponent: () => Form_default,
|
|
34
|
+
PreferenciaContato: () => PreferenciaContato
|
|
34
35
|
});
|
|
35
36
|
module.exports = __toCommonJS(index_exports);
|
|
36
37
|
|
|
@@ -336,6 +337,92 @@ var Subtitle = import_styled_components.default.p`
|
|
|
336
337
|
color: ${(props) => props.$textColor || theme.colors.black};
|
|
337
338
|
`;
|
|
338
339
|
|
|
340
|
+
// src/components/ProductSelect/styles.ts
|
|
341
|
+
var import_styled_components2 = __toESM(require("styled-components"), 1);
|
|
342
|
+
var FormLabel = import_styled_components2.default.label`
|
|
343
|
+
font-family: ${theme.fonts.primary};
|
|
344
|
+
font-style: normal;
|
|
345
|
+
font-weight: 500;
|
|
346
|
+
font-size: 1rem;
|
|
347
|
+
color: ${(props) => props.$textColor || theme.colors.black};
|
|
348
|
+
display: block;
|
|
349
|
+
margin-bottom: 0.5rem;
|
|
350
|
+
text-align: left;
|
|
351
|
+
`;
|
|
352
|
+
var Select = import_styled_components2.default.select`
|
|
353
|
+
font-family: ${theme.fonts.primary};
|
|
354
|
+
font-style: normal;
|
|
355
|
+
font-weight: 500;
|
|
356
|
+
font-size: 1rem;
|
|
357
|
+
line-height: 1.5rem;
|
|
358
|
+
background: ${(props) => props.$backgroundColor || theme.colors.white};
|
|
359
|
+
color: ${(props) => props.$textColor || theme.colors.black};
|
|
360
|
+
padding: 0.5rem 3rem 0.5rem 0.5rem; /* Aumentado padding-right para 3rem */
|
|
361
|
+
border-radius: 0.125rem;
|
|
362
|
+
border: 1px solid ${(props) => props.$borderColor || theme.colors.transparent};
|
|
363
|
+
display: block;
|
|
364
|
+
height: 3.125rem;
|
|
365
|
+
width: 100%;
|
|
366
|
+
cursor: pointer;
|
|
367
|
+
|
|
368
|
+
/* Remover a seta padrão do navegador */
|
|
369
|
+
-webkit-appearance: none;
|
|
370
|
+
-moz-appearance: none;
|
|
371
|
+
appearance: none;
|
|
372
|
+
|
|
373
|
+
/* Adicionar seta personalizada maior */
|
|
374
|
+
background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6,9 12,15 18,9'%3e%3c/polyline%3e%3c/svg%3e");
|
|
375
|
+
background-repeat: no-repeat;
|
|
376
|
+
background-position: right 1rem center; /* Posicionado a 1rem da direita */
|
|
377
|
+
background-size: 1.25rem; /* Tamanho da seta aumentado para 1.25rem */
|
|
378
|
+
|
|
379
|
+
&:focus {
|
|
380
|
+
border-radius: 0.125rem;
|
|
381
|
+
border: 2px solid ${(props) => props.$focusBorderColor || theme.colors.yellow500};
|
|
382
|
+
outline: none;
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
/* Estilo para option disabled (placeholder) */
|
|
386
|
+
option:disabled {
|
|
387
|
+
color: ${theme.colors.gray100};
|
|
388
|
+
font-weight: 800;
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
/* Estilo para options normais */
|
|
392
|
+
option:not(:disabled) {
|
|
393
|
+
color: ${(props) => props.$textColor || theme.colors.black};
|
|
394
|
+
font-weight: 500;
|
|
395
|
+
}
|
|
396
|
+
`;
|
|
397
|
+
var FormErrorMessage = import_styled_components2.default.small`
|
|
398
|
+
font-size: 0.75rem;
|
|
399
|
+
line-height: 1.125rem;
|
|
400
|
+
color: ${theme.colors.red};
|
|
401
|
+
margin-top: 0.25rem;
|
|
402
|
+
display: block;
|
|
403
|
+
`;
|
|
404
|
+
var FormControl = import_styled_components2.default.div.withConfig({
|
|
405
|
+
shouldForwardProp: (prop) => !["isInvalid"].includes(prop)
|
|
406
|
+
})`
|
|
407
|
+
${FormLabel} {
|
|
408
|
+
${(props) => props.isInvalid && import_styled_components2.css`
|
|
409
|
+
color: ${theme.colors.red};
|
|
410
|
+
`};
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
${Select} {
|
|
414
|
+
${(props) => props.isInvalid && import_styled_components2.css`
|
|
415
|
+
border: 1px solid ${theme.colors.red};
|
|
416
|
+
`};
|
|
417
|
+
|
|
418
|
+
&:focus {
|
|
419
|
+
${(props) => props.isInvalid && import_styled_components2.css`
|
|
420
|
+
border: 1px solid ${theme.colors.red};
|
|
421
|
+
`};
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
`;
|
|
425
|
+
|
|
339
426
|
// src/components/styles/FontLoader.tsx
|
|
340
427
|
var import_react2 = require("react");
|
|
341
428
|
var useMontserratFont = () => {
|
|
@@ -402,8 +489,8 @@ function date(e) {
|
|
|
402
489
|
}
|
|
403
490
|
|
|
404
491
|
// src/components/Input/styles.ts
|
|
405
|
-
var
|
|
406
|
-
var
|
|
492
|
+
var import_styled_components3 = __toESM(require("styled-components"), 1);
|
|
493
|
+
var FormLabel2 = import_styled_components3.default.label`
|
|
407
494
|
font-family: ${theme.fonts.primary};
|
|
408
495
|
font-style: normal;
|
|
409
496
|
font-weight: 500;
|
|
@@ -413,7 +500,7 @@ var FormLabel = import_styled_components2.default.label`
|
|
|
413
500
|
margin-bottom: 0.5rem;
|
|
414
501
|
text-align: left;
|
|
415
502
|
`;
|
|
416
|
-
var Input =
|
|
503
|
+
var Input = import_styled_components3.default.input`
|
|
417
504
|
font-family: ${theme.fonts.primary};
|
|
418
505
|
font-style: normal;
|
|
419
506
|
font-weight: 500;
|
|
@@ -455,24 +542,24 @@ var Input = import_styled_components2.default.input`
|
|
|
455
542
|
font-weight: 500;
|
|
456
543
|
}
|
|
457
544
|
`;
|
|
458
|
-
var
|
|
545
|
+
var FormErrorMessage2 = import_styled_components3.default.small`
|
|
459
546
|
font-size: 0.75rem;
|
|
460
547
|
line-height: 1.125rem;
|
|
461
548
|
color: ${theme.colors.red};
|
|
462
549
|
margin-top: 0.25rem;
|
|
463
550
|
display: block;
|
|
464
551
|
`;
|
|
465
|
-
var
|
|
552
|
+
var FormControl2 = import_styled_components3.default.div.withConfig({
|
|
466
553
|
shouldForwardProp: (prop) => !["isInvalid"].includes(prop)
|
|
467
554
|
})`
|
|
468
|
-
${
|
|
469
|
-
${(props) => props.isInvalid &&
|
|
555
|
+
${FormLabel2} {
|
|
556
|
+
${(props) => props.isInvalid && import_styled_components3.css`
|
|
470
557
|
color: ${theme.colors.red};
|
|
471
558
|
`};
|
|
472
559
|
}
|
|
473
560
|
|
|
474
561
|
${Input} {
|
|
475
|
-
${(props) => props.isInvalid &&
|
|
562
|
+
${(props) => props.isInvalid && import_styled_components3.css`
|
|
476
563
|
border: 1px solid ${theme.colors.red};
|
|
477
564
|
|
|
478
565
|
&:not(:focus)::placeholder {
|
|
@@ -482,7 +569,7 @@ var FormControl = import_styled_components2.default.div.withConfig({
|
|
|
482
569
|
`};
|
|
483
570
|
|
|
484
571
|
&:focus {
|
|
485
|
-
${(props) => props.isInvalid &&
|
|
572
|
+
${(props) => props.isInvalid && import_styled_components3.css`
|
|
486
573
|
border: 1px solid ${theme.colors.red};
|
|
487
574
|
`};
|
|
488
575
|
}
|
|
@@ -515,8 +602,8 @@ var InputBase = ({
|
|
|
515
602
|
},
|
|
516
603
|
[mask]
|
|
517
604
|
);
|
|
518
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
519
|
-
!!label && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
605
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(FormControl2, { isInvalid: !!error, children: [
|
|
606
|
+
!!label && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FormLabel2, { htmlFor: id, $textColor: labelTextColor, children: label }),
|
|
520
607
|
!mask ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
521
608
|
Input,
|
|
522
609
|
{
|
|
@@ -549,15 +636,15 @@ var InputBase = ({
|
|
|
549
636
|
...rest
|
|
550
637
|
}
|
|
551
638
|
),
|
|
552
|
-
!!error && showErrorMessage && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
639
|
+
!!error && showErrorMessage && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FormErrorMessage2, { "data-testid": "error-message", children: typeof error === "string" ? error : error.message })
|
|
553
640
|
] });
|
|
554
641
|
};
|
|
555
642
|
var Input2 = (0, import_react3.forwardRef)(InputBase);
|
|
556
643
|
|
|
557
644
|
// src/components/Button/styles.ts
|
|
558
645
|
var import_polished = require("polished");
|
|
559
|
-
var
|
|
560
|
-
var Icon =
|
|
646
|
+
var import_styled_components4 = __toESM(require("styled-components"), 1);
|
|
647
|
+
var Icon = import_styled_components4.default.span`
|
|
561
648
|
font-size: 0;
|
|
562
649
|
line-height: 0;
|
|
563
650
|
transition: all 0.25s ease;
|
|
@@ -567,7 +654,7 @@ var Icon = import_styled_components3.default.span`
|
|
|
567
654
|
opacity: 0;
|
|
568
655
|
margin-right: 0.625rem;
|
|
569
656
|
`;
|
|
570
|
-
var Text =
|
|
657
|
+
var Text = import_styled_components4.default.span`
|
|
571
658
|
font-family: ${theme.fonts.primary};
|
|
572
659
|
font-size: 1rem;
|
|
573
660
|
line-height: 1.5rem;
|
|
@@ -575,14 +662,14 @@ var Text = import_styled_components3.default.span`
|
|
|
575
662
|
|
|
576
663
|
transition: all 0.25s ease;
|
|
577
664
|
`;
|
|
578
|
-
var TextSubmitting =
|
|
665
|
+
var TextSubmitting = import_styled_components4.default.span`
|
|
579
666
|
font-family: ${theme.fonts.primary};
|
|
580
667
|
font-weight: 400;
|
|
581
668
|
font-size: 1rem;
|
|
582
669
|
|
|
583
670
|
transition: all 0.25s ease;
|
|
584
671
|
`;
|
|
585
|
-
var LoadingIcon =
|
|
672
|
+
var LoadingIcon = import_styled_components4.default.span.withConfig({
|
|
586
673
|
shouldForwardProp: (prop) => prop !== "hasText"
|
|
587
674
|
})`
|
|
588
675
|
display: block;
|
|
@@ -605,7 +692,7 @@ var LoadingIcon = import_styled_components3.default.span.withConfig({
|
|
|
605
692
|
}
|
|
606
693
|
}
|
|
607
694
|
`;
|
|
608
|
-
var Button =
|
|
695
|
+
var Button = import_styled_components4.default.button.withConfig({
|
|
609
696
|
shouldForwardProp: (prop) => ![
|
|
610
697
|
"hasIcon",
|
|
611
698
|
"isSubmitting",
|
|
@@ -662,14 +749,14 @@ var Button = import_styled_components3.default.button.withConfig({
|
|
|
662
749
|
}
|
|
663
750
|
|
|
664
751
|
${Text} {
|
|
665
|
-
${(props) => props.isSubmitting && !props.hasSubmittingMessage &&
|
|
752
|
+
${(props) => props.isSubmitting && !props.hasSubmittingMessage && import_styled_components4.css`
|
|
666
753
|
transform: unset;
|
|
667
754
|
opacity: 0;
|
|
668
755
|
`}
|
|
669
756
|
}
|
|
670
757
|
|
|
671
758
|
${LoadingIcon} {
|
|
672
|
-
${(props) => props.isSubmitting && !props.hasSubmittingMessage &&
|
|
759
|
+
${(props) => props.isSubmitting && !props.hasSubmittingMessage && import_styled_components4.css`
|
|
673
760
|
display: flex;
|
|
674
761
|
-webkit-box-align: center;
|
|
675
762
|
align-items: center;
|
|
@@ -713,17 +800,17 @@ function Button2({
|
|
|
713
800
|
var import_react4 = require("react");
|
|
714
801
|
|
|
715
802
|
// src/components/Alert/styles.ts
|
|
716
|
-
var
|
|
717
|
-
var fadeIn =
|
|
803
|
+
var import_styled_components5 = __toESM(require("styled-components"), 1);
|
|
804
|
+
var fadeIn = import_styled_components5.keyframes`
|
|
718
805
|
from { opacity: 0; transform: translateY(-10px); }
|
|
719
806
|
to { opacity: 1; transform: translateY(0); }
|
|
720
807
|
`;
|
|
721
|
-
var fadeOut =
|
|
808
|
+
var fadeOut = import_styled_components5.keyframes`
|
|
722
809
|
from { opacity: 1; transform: translateY(0); }
|
|
723
810
|
to { opacity: 0; transform: translateY(-10px); }
|
|
724
811
|
`;
|
|
725
812
|
var typeStyles = {
|
|
726
|
-
error:
|
|
813
|
+
error: import_styled_components5.css`
|
|
727
814
|
background-color: ${theme.colors.red};
|
|
728
815
|
border: 1px solid ${theme.colors.red};
|
|
729
816
|
color: ${theme.colors.white};
|
|
@@ -731,7 +818,7 @@ var typeStyles = {
|
|
|
731
818
|
color: ${theme.colors.white};
|
|
732
819
|
}
|
|
733
820
|
`,
|
|
734
|
-
warning:
|
|
821
|
+
warning: import_styled_components5.css`
|
|
735
822
|
background-color: ${theme.colors.yellow500};
|
|
736
823
|
border: 1px solid ${theme.colors.yellow400};
|
|
737
824
|
color: ${theme.colors.black};
|
|
@@ -739,7 +826,7 @@ var typeStyles = {
|
|
|
739
826
|
color: ${theme.colors.black};
|
|
740
827
|
}
|
|
741
828
|
`,
|
|
742
|
-
info:
|
|
829
|
+
info: import_styled_components5.css`
|
|
743
830
|
background-color: ${theme.colors.blue};
|
|
744
831
|
border: 1px solid ${theme.colors.blue};
|
|
745
832
|
color: ${theme.colors.white};
|
|
@@ -747,7 +834,7 @@ var typeStyles = {
|
|
|
747
834
|
color: ${theme.colors.white};
|
|
748
835
|
}
|
|
749
836
|
`,
|
|
750
|
-
success:
|
|
837
|
+
success: import_styled_components5.css`
|
|
751
838
|
background-color: ${theme.colors.green};
|
|
752
839
|
border: 1px solid ${theme.colors.green2};
|
|
753
840
|
color: ${theme.colors.white};
|
|
@@ -756,7 +843,7 @@ var typeStyles = {
|
|
|
756
843
|
}
|
|
757
844
|
`
|
|
758
845
|
};
|
|
759
|
-
var AlertContainer =
|
|
846
|
+
var AlertContainer = import_styled_components5.default.div`
|
|
760
847
|
position: fixed;
|
|
761
848
|
width: 500px;
|
|
762
849
|
top: 15px;
|
|
@@ -776,7 +863,7 @@ var AlertContainer = import_styled_components4.default.div`
|
|
|
776
863
|
|
|
777
864
|
${({ $type }) => typeStyles[$type]}
|
|
778
865
|
`;
|
|
779
|
-
var DismissButton =
|
|
866
|
+
var DismissButton = import_styled_components5.default.button`
|
|
780
867
|
position: absolute;
|
|
781
868
|
background: transparent;
|
|
782
869
|
right: 10px;
|
|
@@ -845,10 +932,10 @@ var Alert = ({
|
|
|
845
932
|
var import_react5 = require("react");
|
|
846
933
|
|
|
847
934
|
// src/components/PhoneInput/styles.ts
|
|
848
|
-
var
|
|
935
|
+
var import_styled_components6 = __toESM(require("styled-components"), 1);
|
|
849
936
|
var import_react_international_phone = require("react-international-phone");
|
|
850
937
|
var import_style = require("react-international-phone/style.css");
|
|
851
|
-
var
|
|
938
|
+
var FormLabel3 = import_styled_components6.default.label`
|
|
852
939
|
font-family: ${theme.fonts.primary};
|
|
853
940
|
font-style: normal;
|
|
854
941
|
font-weight: 500;
|
|
@@ -858,7 +945,7 @@ var FormLabel2 = import_styled_components5.default.label`
|
|
|
858
945
|
margin-bottom: 0.5rem;
|
|
859
946
|
text-align: left;
|
|
860
947
|
`;
|
|
861
|
-
var StyledPhoneInput = (0,
|
|
948
|
+
var StyledPhoneInput = (0, import_styled_components6.default)(import_react_international_phone.PhoneInput)`
|
|
862
949
|
width: 100%;
|
|
863
950
|
height: 3.125rem;
|
|
864
951
|
background: ${(props) => props.$backgroundColor || theme.colors.white};
|
|
@@ -904,7 +991,6 @@ var StyledPhoneInput = (0, import_styled_components5.default)(import_react_inter
|
|
|
904
991
|
outline: none;
|
|
905
992
|
border: none;
|
|
906
993
|
border-right: 1px solid ${(props) => props.$borderColor || theme.colors.transparent};
|
|
907
|
-
padding-right: 5px;
|
|
908
994
|
padding-left: 10px;
|
|
909
995
|
}
|
|
910
996
|
|
|
@@ -957,7 +1043,7 @@ var StyledPhoneInput = (0, import_styled_components5.default)(import_react_inter
|
|
|
957
1043
|
font-size: 1rem;
|
|
958
1044
|
line-height: 1.5rem;
|
|
959
1045
|
color: ${(props) => props.$placeholderColor || theme.colors.gray100};
|
|
960
|
-
font-weight:
|
|
1046
|
+
font-weight: 700;
|
|
961
1047
|
}
|
|
962
1048
|
|
|
963
1049
|
&:-webkit-autofill {
|
|
@@ -973,24 +1059,24 @@ var StyledPhoneInput = (0, import_styled_components5.default)(import_react_inter
|
|
|
973
1059
|
}
|
|
974
1060
|
}
|
|
975
1061
|
`;
|
|
976
|
-
var
|
|
1062
|
+
var FormErrorMessage3 = import_styled_components6.default.small`
|
|
977
1063
|
font-size: 0.75rem;
|
|
978
1064
|
line-height: 1.125rem;
|
|
979
1065
|
color: ${theme.colors.red};
|
|
980
1066
|
margin-top: 0.25rem;
|
|
981
1067
|
display: block;
|
|
982
1068
|
`;
|
|
983
|
-
var
|
|
1069
|
+
var FormControl3 = import_styled_components6.default.div.withConfig({
|
|
984
1070
|
shouldForwardProp: (prop) => !["isInvalid"].includes(prop)
|
|
985
1071
|
})`
|
|
986
|
-
${
|
|
987
|
-
${(props) => props.isInvalid &&
|
|
1072
|
+
${FormLabel3} {
|
|
1073
|
+
${(props) => props.isInvalid && import_styled_components6.css`
|
|
988
1074
|
color: ${theme.colors.red};
|
|
989
1075
|
`};
|
|
990
1076
|
}
|
|
991
1077
|
|
|
992
1078
|
${StyledPhoneInput} {
|
|
993
|
-
${(props) => props.isInvalid &&
|
|
1079
|
+
${(props) => props.isInvalid && import_styled_components6.css`
|
|
994
1080
|
border: 1px solid ${theme.colors.red};
|
|
995
1081
|
|
|
996
1082
|
&:not(:focus)::placeholder {
|
|
@@ -1000,7 +1086,7 @@ var FormControl2 = import_styled_components5.default.div.withConfig({
|
|
|
1000
1086
|
`};
|
|
1001
1087
|
|
|
1002
1088
|
.react-international-phone-input-container {
|
|
1003
|
-
${(props) => props.isInvalid &&
|
|
1089
|
+
${(props) => props.isInvalid && import_styled_components6.css`
|
|
1004
1090
|
border: 1px solid ${theme.colors.red};
|
|
1005
1091
|
|
|
1006
1092
|
&:not(:focus)::placeholder {
|
|
@@ -1011,7 +1097,7 @@ var FormControl2 = import_styled_components5.default.div.withConfig({
|
|
|
1011
1097
|
}
|
|
1012
1098
|
|
|
1013
1099
|
.react-international-phone-country-selector-button {
|
|
1014
|
-
${(props) => props.isInvalid &&
|
|
1100
|
+
${(props) => props.isInvalid && import_styled_components6.css`
|
|
1015
1101
|
border-right: 1px solid ${theme.colors.red};
|
|
1016
1102
|
`};
|
|
1017
1103
|
}
|
|
@@ -1034,8 +1120,8 @@ var PhoneInputBase = ({
|
|
|
1034
1120
|
value,
|
|
1035
1121
|
...rest
|
|
1036
1122
|
}, ref) => {
|
|
1037
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
1038
|
-
!!label && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1123
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(FormControl3, { isInvalid: !!error, children: [
|
|
1124
|
+
!!label && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(FormLabel3, { htmlFor: id, $textColor: labelTextColor, children: label }),
|
|
1039
1125
|
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1040
1126
|
StyledPhoneInput,
|
|
1041
1127
|
{
|
|
@@ -1070,101 +1156,13 @@ var PhoneInputBase = ({
|
|
|
1070
1156
|
$textColor: inputTextColor
|
|
1071
1157
|
}
|
|
1072
1158
|
),
|
|
1073
|
-
!!error && showErrorMessage && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1159
|
+
!!error && showErrorMessage && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(FormErrorMessage3, { "data-testid": "error-message", children: typeof error === "string" ? error : error?.message })
|
|
1074
1160
|
] });
|
|
1075
1161
|
};
|
|
1076
1162
|
var PhoneInput2 = (0, import_react5.forwardRef)(PhoneInputBase);
|
|
1077
1163
|
|
|
1078
1164
|
// src/components/ProductSelect/index.tsx
|
|
1079
1165
|
var import_react6 = require("react");
|
|
1080
|
-
|
|
1081
|
-
// src/components/ProductSelect/styles.ts
|
|
1082
|
-
var import_styled_components6 = __toESM(require("styled-components"), 1);
|
|
1083
|
-
var FormLabel3 = import_styled_components6.default.label`
|
|
1084
|
-
font-family: ${theme.fonts.primary};
|
|
1085
|
-
font-style: normal;
|
|
1086
|
-
font-weight: 500;
|
|
1087
|
-
font-size: 1rem;
|
|
1088
|
-
color: ${(props) => props.$textColor || theme.colors.black};
|
|
1089
|
-
display: block;
|
|
1090
|
-
margin-bottom: 0.5rem;
|
|
1091
|
-
text-align: left;
|
|
1092
|
-
`;
|
|
1093
|
-
var Select = import_styled_components6.default.select`
|
|
1094
|
-
font-family: ${theme.fonts.primary};
|
|
1095
|
-
font-style: normal;
|
|
1096
|
-
font-weight: 500;
|
|
1097
|
-
font-size: 1rem;
|
|
1098
|
-
line-height: 1.5rem;
|
|
1099
|
-
background: ${(props) => props.$backgroundColor || theme.colors.white};
|
|
1100
|
-
color: ${(props) => props.$textColor || theme.colors.black};
|
|
1101
|
-
padding: 0.5rem 3rem 0.5rem 0.5rem; /* Aumentado padding-right para 3rem */
|
|
1102
|
-
border-radius: 0.125rem;
|
|
1103
|
-
border: 1px solid ${(props) => props.$borderColor || theme.colors.transparent};
|
|
1104
|
-
display: block;
|
|
1105
|
-
height: 3.125rem;
|
|
1106
|
-
width: 100%;
|
|
1107
|
-
cursor: pointer;
|
|
1108
|
-
|
|
1109
|
-
/* Remover a seta padrão do navegador */
|
|
1110
|
-
-webkit-appearance: none;
|
|
1111
|
-
-moz-appearance: none;
|
|
1112
|
-
appearance: none;
|
|
1113
|
-
|
|
1114
|
-
/* Adicionar seta personalizada maior */
|
|
1115
|
-
background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6,9 12,15 18,9'%3e%3c/polyline%3e%3c/svg%3e");
|
|
1116
|
-
background-repeat: no-repeat;
|
|
1117
|
-
background-position: right 1rem center; /* Posicionado a 1rem da direita */
|
|
1118
|
-
background-size: 1.25rem; /* Tamanho da seta aumentado para 1.25rem */
|
|
1119
|
-
|
|
1120
|
-
&:focus {
|
|
1121
|
-
border-radius: 0.125rem;
|
|
1122
|
-
border: 2px solid ${(props) => props.$focusBorderColor || theme.colors.yellow500};
|
|
1123
|
-
outline: none;
|
|
1124
|
-
}
|
|
1125
|
-
|
|
1126
|
-
/* Estilo para option disabled (placeholder) */
|
|
1127
|
-
option:disabled {
|
|
1128
|
-
color: ${theme.colors.gray100};
|
|
1129
|
-
font-weight: 800;
|
|
1130
|
-
}
|
|
1131
|
-
|
|
1132
|
-
/* Estilo para options normais */
|
|
1133
|
-
option:not(:disabled) {
|
|
1134
|
-
color: ${(props) => props.$textColor || theme.colors.black};
|
|
1135
|
-
font-weight: 500;
|
|
1136
|
-
}
|
|
1137
|
-
`;
|
|
1138
|
-
var FormErrorMessage3 = import_styled_components6.default.small`
|
|
1139
|
-
font-size: 0.75rem;
|
|
1140
|
-
line-height: 1.125rem;
|
|
1141
|
-
color: ${theme.colors.red};
|
|
1142
|
-
margin-top: 0.25rem;
|
|
1143
|
-
display: block;
|
|
1144
|
-
`;
|
|
1145
|
-
var FormControl3 = import_styled_components6.default.div.withConfig({
|
|
1146
|
-
shouldForwardProp: (prop) => !["isInvalid"].includes(prop)
|
|
1147
|
-
})`
|
|
1148
|
-
${FormLabel3} {
|
|
1149
|
-
${(props) => props.isInvalid && import_styled_components6.css`
|
|
1150
|
-
color: ${theme.colors.red};
|
|
1151
|
-
`};
|
|
1152
|
-
}
|
|
1153
|
-
|
|
1154
|
-
${Select} {
|
|
1155
|
-
${(props) => props.isInvalid && import_styled_components6.css`
|
|
1156
|
-
border: 1px solid ${theme.colors.red};
|
|
1157
|
-
`};
|
|
1158
|
-
|
|
1159
|
-
&:focus {
|
|
1160
|
-
${(props) => props.isInvalid && import_styled_components6.css`
|
|
1161
|
-
border: 1px solid ${theme.colors.red};
|
|
1162
|
-
`};
|
|
1163
|
-
}
|
|
1164
|
-
}
|
|
1165
|
-
`;
|
|
1166
|
-
|
|
1167
|
-
// src/components/ProductSelect/index.tsx
|
|
1168
1166
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
1169
1167
|
var ProductSelectBase = ({
|
|
1170
1168
|
id,
|
|
@@ -1180,8 +1178,8 @@ var ProductSelectBase = ({
|
|
|
1180
1178
|
placeholder = "Selecione um produto",
|
|
1181
1179
|
...rest
|
|
1182
1180
|
}, ref) => {
|
|
1183
|
-
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
1184
|
-
!!label && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1181
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(FormControl, { isInvalid: !!error, children: [
|
|
1182
|
+
!!label && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(FormLabel, { htmlFor: id, $textColor: labelTextColor, children: label }),
|
|
1185
1183
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
1186
1184
|
Select,
|
|
1187
1185
|
{
|
|
@@ -1199,7 +1197,7 @@ var ProductSelectBase = ({
|
|
|
1199
1197
|
]
|
|
1200
1198
|
}
|
|
1201
1199
|
),
|
|
1202
|
-
!!error && showErrorMessage && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1200
|
+
!!error && showErrorMessage && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(FormErrorMessage, { "data-testid": "error-message", children: typeof error === "string" ? error : error.message })
|
|
1203
1201
|
] });
|
|
1204
1202
|
};
|
|
1205
1203
|
var ProductSelect = (0, import_react6.forwardRef)(ProductSelectBase);
|
|
@@ -1207,6 +1205,12 @@ var ProductSelect = (0, import_react6.forwardRef)(ProductSelectBase);
|
|
|
1207
1205
|
// src/components/Form/index.tsx
|
|
1208
1206
|
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
1209
1207
|
var phoneUtil = import_google_libphonenumber.PhoneNumberUtil.getInstance();
|
|
1208
|
+
var PreferenciaContato = /* @__PURE__ */ ((PreferenciaContato2) => {
|
|
1209
|
+
PreferenciaContato2["Whatsapp"] = "Whatsapp";
|
|
1210
|
+
PreferenciaContato2["Email"] = "Email";
|
|
1211
|
+
PreferenciaContato2["Ligacao"] = "Liga\xE7\xE3o";
|
|
1212
|
+
return PreferenciaContato2;
|
|
1213
|
+
})(PreferenciaContato || {});
|
|
1210
1214
|
var isPhoneValid = (phone) => {
|
|
1211
1215
|
try {
|
|
1212
1216
|
return phoneUtil.isValidNumber(phoneUtil.parseAndKeepRawInput(phone));
|
|
@@ -1253,6 +1257,7 @@ var MitreFormComponent = import_react7.default.forwardRef(({
|
|
|
1253
1257
|
inputFocusBorderColor = theme.colors.yellow500,
|
|
1254
1258
|
inputPlaceholderColor = theme.colors.gray100,
|
|
1255
1259
|
inputTextColor = theme.colors.black,
|
|
1260
|
+
showPreferenciaContato = false,
|
|
1256
1261
|
onSuccess,
|
|
1257
1262
|
onError
|
|
1258
1263
|
}, ref) => {
|
|
@@ -1321,7 +1326,7 @@ var MitreFormComponent = import_react7.default.forwardRef(({
|
|
|
1321
1326
|
setFormKey((k) => k + 1);
|
|
1322
1327
|
};
|
|
1323
1328
|
const sendMessage = async (data) => {
|
|
1324
|
-
const { name, email, phone, productId } = data;
|
|
1329
|
+
const { name, email, phone, productId, preferencia_contato } = data;
|
|
1325
1330
|
const phoneValue = phone.inputValue;
|
|
1326
1331
|
const phoneDigitsOnly = phoneValue?.replace(/\D/g, "") || "";
|
|
1327
1332
|
const message = "Gostaria de mais informa\xE7\xF5es sobre o produto";
|
|
@@ -1352,7 +1357,8 @@ var MitreFormComponent = import_react7.default.forwardRef(({
|
|
|
1352
1357
|
utm_source: utm.utm_source,
|
|
1353
1358
|
utm_campaign: utm.utm_campaign,
|
|
1354
1359
|
utm_medium: utm.utm_medium,
|
|
1355
|
-
utm_term: utm.utm_term
|
|
1360
|
+
utm_term: utm.utm_term,
|
|
1361
|
+
...showPreferenciaContato && preferencia_contato ? { preferencia_contato } : {}
|
|
1356
1362
|
};
|
|
1357
1363
|
const response = await fetch(`${apiUrl}/leads`, {
|
|
1358
1364
|
method: "POST",
|
|
@@ -1498,6 +1504,26 @@ var MitreFormComponent = import_react7.default.forwardRef(({
|
|
|
1498
1504
|
},
|
|
1499
1505
|
formKey
|
|
1500
1506
|
),
|
|
1507
|
+
showPreferenciaContato && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(FormControl, { isInvalid: !!errors.preferencia_contato, children: [
|
|
1508
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(FormLabel, { htmlFor: "preferencia_contato", $textColor: textColor, children: "Prefer\xEAncia de Contato" }),
|
|
1509
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
1510
|
+
Select,
|
|
1511
|
+
{
|
|
1512
|
+
id: "preferencia_contato",
|
|
1513
|
+
...register("preferencia_contato"),
|
|
1514
|
+
defaultValue: "",
|
|
1515
|
+
$backgroundColor: inputBackgroundColor,
|
|
1516
|
+
$borderColor: inputBorderColor,
|
|
1517
|
+
$focusBorderColor: inputFocusBorderColor,
|
|
1518
|
+
$textColor: inputTextColor,
|
|
1519
|
+
children: [
|
|
1520
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("option", { value: "", disabled: true, children: "Selecione uma op\xE7\xE3o" }),
|
|
1521
|
+
Object.values(PreferenciaContato).map((op) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("option", { value: op, children: op }, op))
|
|
1522
|
+
]
|
|
1523
|
+
}
|
|
1524
|
+
),
|
|
1525
|
+
errors.preferencia_contato && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(FormErrorMessage, { children: errors.preferencia_contato.message })
|
|
1526
|
+
] }),
|
|
1501
1527
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("h6", { children: "* Campos de preenchimento obrigat\xF3rio." }),
|
|
1502
1528
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ButtonContainer, { children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Button2, { bgColor: buttonBackgroundColor, color: buttonTextColor, type: "submit", isSubmitting: loading, children: "Enviar mensagem" }) }),
|
|
1503
1529
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("p", { children: [
|
|
@@ -1526,6 +1552,7 @@ MitreFormComponent.displayName = "MitreFormComponent";
|
|
|
1526
1552
|
var Form_default = MitreFormComponent;
|
|
1527
1553
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1528
1554
|
0 && (module.exports = {
|
|
1529
|
-
MitreFormComponent
|
|
1555
|
+
MitreFormComponent,
|
|
1556
|
+
PreferenciaContato
|
|
1530
1557
|
});
|
|
1531
1558
|
//# sourceMappingURL=index.cjs.map
|