mitre-form-component 0.0.4 → 0.0.6
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 +171 -51
- package/dist/{index.mjs → index.cjs} +150 -112
- package/dist/index.cjs.map +1 -0
- package/dist/{index.d.mts → index.d.cts} +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +117 -144
- package/dist/index.js.map +1 -1
- package/package.json +16 -6
- package/dist/index.mjs.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,47 +1,10 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
"use client";
|
|
3
|
-
var __create = Object.create;
|
|
4
|
-
var __defProp = Object.defineProperty;
|
|
5
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
-
var __export = (target, all) => {
|
|
10
|
-
for (var name in all)
|
|
11
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
-
};
|
|
13
|
-
var __copyProps = (to, from, except, desc) => {
|
|
14
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
-
for (let key of __getOwnPropNames(from))
|
|
16
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
-
}
|
|
19
|
-
return to;
|
|
20
|
-
};
|
|
21
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
-
mod
|
|
28
|
-
));
|
|
29
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
-
|
|
31
|
-
// src/index.ts
|
|
32
|
-
var index_exports = {};
|
|
33
|
-
__export(index_exports, {
|
|
34
|
-
MitreFormComponent: () => Form_default
|
|
35
|
-
});
|
|
36
|
-
module.exports = __toCommonJS(index_exports);
|
|
37
|
-
|
|
38
1
|
// src/components/Form/index.tsx
|
|
39
|
-
|
|
2
|
+
import React3, { useState as useState3 } from "react";
|
|
40
3
|
|
|
41
4
|
// src/components/hooks/useError.ts
|
|
42
|
-
|
|
5
|
+
import { useState } from "react";
|
|
43
6
|
function useError() {
|
|
44
|
-
const [error, setError] =
|
|
7
|
+
const [error, setError] = useState(null);
|
|
45
8
|
const handleError = (err) => {
|
|
46
9
|
const errorObj = err instanceof Error ? err : new Error(String(err));
|
|
47
10
|
setError(errorObj);
|
|
@@ -52,9 +15,9 @@ function useError() {
|
|
|
52
15
|
}
|
|
53
16
|
|
|
54
17
|
// src/components/Form/index.tsx
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
18
|
+
import { useForm } from "react-hook-form";
|
|
19
|
+
import { yupResolver } from "@hookform/resolvers/yup";
|
|
20
|
+
import * as yup from "yup";
|
|
58
21
|
|
|
59
22
|
// src/components/styles/utils.ts
|
|
60
23
|
function flex(direction = "row", alignItems, justifyContent) {
|
|
@@ -77,14 +40,18 @@ var opacityEffect = `
|
|
|
77
40
|
`;
|
|
78
41
|
|
|
79
42
|
// src/components/Form/styles.ts
|
|
80
|
-
|
|
81
|
-
var FormContainer =
|
|
43
|
+
import styled from "styled-components";
|
|
44
|
+
var FormContainer = styled.div`
|
|
82
45
|
${flex("column")}
|
|
83
46
|
align-items: stretch;
|
|
84
47
|
justify-content: flex-start;
|
|
85
48
|
overflow-x: hidden;
|
|
86
49
|
overflow-y: auto;
|
|
87
50
|
|
|
51
|
+
background: ${(props) => props.$backgroundColor || " #cecece"};
|
|
52
|
+
|
|
53
|
+
padding: ${(props) => props.innerPadding || "1rem"};
|
|
54
|
+
|
|
88
55
|
/* Hide scrollbars for WebKit browsers */
|
|
89
56
|
::-webkit-scrollbar {
|
|
90
57
|
display: none;
|
|
@@ -94,11 +61,12 @@ var FormContainer = import_styled_components.default.div`
|
|
|
94
61
|
scrollbar-width: none;
|
|
95
62
|
|
|
96
63
|
box-sizing: border-box;
|
|
64
|
+
height: 100%;
|
|
97
65
|
`;
|
|
98
|
-
var HeaderContainer =
|
|
66
|
+
var HeaderContainer = styled.div`
|
|
99
67
|
margin-bottom: 1rem;
|
|
100
68
|
`;
|
|
101
|
-
var ButtonContainer =
|
|
69
|
+
var ButtonContainer = styled.div`
|
|
102
70
|
display: flex;
|
|
103
71
|
flex-direction: column;
|
|
104
72
|
align-items: center;
|
|
@@ -106,7 +74,7 @@ var ButtonContainer = import_styled_components.default.div`
|
|
|
106
74
|
width: 100%;
|
|
107
75
|
margin-top: 0.75rem;
|
|
108
76
|
`;
|
|
109
|
-
var Form =
|
|
77
|
+
var Form = styled.form`
|
|
110
78
|
label {
|
|
111
79
|
font-weight: 700;
|
|
112
80
|
}
|
|
@@ -154,14 +122,14 @@ var Form = import_styled_components.default.form`
|
|
|
154
122
|
margin-bottom: 10px;
|
|
155
123
|
}
|
|
156
124
|
`;
|
|
157
|
-
var Title =
|
|
125
|
+
var Title = styled.h2`
|
|
158
126
|
font-size: 1.25rem;
|
|
159
127
|
font-weight: 700;
|
|
160
128
|
line-height: 24px;
|
|
161
129
|
letter-spacing: 0em;
|
|
162
130
|
color: ${(props) => props.$textColor || "var(--black)"};
|
|
163
131
|
`;
|
|
164
|
-
var Text =
|
|
132
|
+
var Text = styled.p`
|
|
165
133
|
font-size: 1rem;
|
|
166
134
|
font-weight: 400;
|
|
167
135
|
line-height: 23px;
|
|
@@ -171,9 +139,9 @@ var Text = import_styled_components.default.p`
|
|
|
171
139
|
`;
|
|
172
140
|
|
|
173
141
|
// src/components/styles/global.ts
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
var GlobalStyles =
|
|
142
|
+
import { createGlobalStyle } from "styled-components";
|
|
143
|
+
import { useEffect } from "react";
|
|
144
|
+
var GlobalStyles = createGlobalStyle`
|
|
177
145
|
:root {
|
|
178
146
|
--red: #e52e4d;
|
|
179
147
|
--white: #FFF;
|
|
@@ -320,7 +288,7 @@ var GlobalStyles = import_styled_components2.createGlobalStyle`
|
|
|
320
288
|
|
|
321
289
|
`;
|
|
322
290
|
var FontLoader = () => {
|
|
323
|
-
|
|
291
|
+
useEffect(() => {
|
|
324
292
|
const link = document.createElement("link");
|
|
325
293
|
link.href = "https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;600;700&display=swap";
|
|
326
294
|
link.rel = "stylesheet";
|
|
@@ -331,7 +299,11 @@ var FontLoader = () => {
|
|
|
331
299
|
var global_default = FontLoader;
|
|
332
300
|
|
|
333
301
|
// src/components/Input/index.tsx
|
|
334
|
-
|
|
302
|
+
import {
|
|
303
|
+
forwardRef,
|
|
304
|
+
useCallback,
|
|
305
|
+
useRef
|
|
306
|
+
} from "react";
|
|
335
307
|
|
|
336
308
|
// src/components/Input/masks.ts
|
|
337
309
|
function cep(e) {
|
|
@@ -372,12 +344,12 @@ function date(e) {
|
|
|
372
344
|
}
|
|
373
345
|
|
|
374
346
|
// src/components/Input/index.tsx
|
|
375
|
-
|
|
347
|
+
import "react-phone-input-2/lib/style.css";
|
|
376
348
|
|
|
377
349
|
// src/components/Input/styles.ts
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
var FormLabel =
|
|
350
|
+
import styled2, { css } from "styled-components";
|
|
351
|
+
import PhoneInput from "react-phone-input-2";
|
|
352
|
+
var FormLabel = styled2.label`
|
|
381
353
|
font-family: "Montserrat", sans-serif;
|
|
382
354
|
font-style: normal;
|
|
383
355
|
font-weight: 500;
|
|
@@ -387,7 +359,7 @@ var FormLabel = import_styled_components3.default.label`
|
|
|
387
359
|
margin-bottom: 0.5rem;
|
|
388
360
|
text-align: left;
|
|
389
361
|
`;
|
|
390
|
-
var Input =
|
|
362
|
+
var Input = styled2.input`
|
|
391
363
|
font-family: "Montserrat", sans-serif;
|
|
392
364
|
font-style: normal;
|
|
393
365
|
font-weight: 500;
|
|
@@ -429,7 +401,7 @@ var Input = import_styled_components3.default.input`
|
|
|
429
401
|
font-weight: 500;
|
|
430
402
|
}
|
|
431
403
|
`;
|
|
432
|
-
var FormPhoneInput = (
|
|
404
|
+
var FormPhoneInput = styled2(PhoneInput)`
|
|
433
405
|
.form-control {
|
|
434
406
|
background: white;
|
|
435
407
|
color: ${(props) => props.isInvalid ? "var(--red)" : props.$textColor || "var(--black)"};
|
|
@@ -492,24 +464,24 @@ var FormPhoneInput = (0, import_styled_components3.default)(import_react_phone_i
|
|
|
492
464
|
}
|
|
493
465
|
}
|
|
494
466
|
`;
|
|
495
|
-
var FormErrorMessage =
|
|
467
|
+
var FormErrorMessage = styled2.small`
|
|
496
468
|
font-size: 0.75rem;
|
|
497
469
|
line-height: 1.125rem;
|
|
498
470
|
color: var(--red);
|
|
499
471
|
margin-top: 0.25rem;
|
|
500
472
|
display: block;
|
|
501
473
|
`;
|
|
502
|
-
var FormControl =
|
|
474
|
+
var FormControl = styled2.div.withConfig({
|
|
503
475
|
shouldForwardProp: (prop) => !["isInvalid", "$bordercolor"].includes(prop)
|
|
504
476
|
})`
|
|
505
477
|
${FormLabel} {
|
|
506
|
-
${(props) => props.isInvalid &&
|
|
478
|
+
${(props) => props.isInvalid && css`
|
|
507
479
|
color: var(--red);
|
|
508
480
|
`};
|
|
509
481
|
}
|
|
510
482
|
|
|
511
483
|
${Input} {
|
|
512
|
-
${(props) => props.isInvalid &&
|
|
484
|
+
${(props) => props.isInvalid && css`
|
|
513
485
|
border: 1px solid var(--red);
|
|
514
486
|
|
|
515
487
|
&:not(:focus)::placeholder {
|
|
@@ -519,14 +491,14 @@ var FormControl = import_styled_components3.default.div.withConfig({
|
|
|
519
491
|
`};
|
|
520
492
|
|
|
521
493
|
&:focus {
|
|
522
|
-
${(props) => props.isInvalid &&
|
|
494
|
+
${(props) => props.isInvalid && css`
|
|
523
495
|
border: 1px solid var(--red);
|
|
524
496
|
`};
|
|
525
497
|
}
|
|
526
498
|
}
|
|
527
499
|
|
|
528
500
|
${FormPhoneInput} {
|
|
529
|
-
${(props) => props.isInvalid &&
|
|
501
|
+
${(props) => props.isInvalid && css`
|
|
530
502
|
border: 1px solid var(--red);
|
|
531
503
|
|
|
532
504
|
&:not(:focus)::placeholder {
|
|
@@ -536,7 +508,7 @@ var FormControl = import_styled_components3.default.div.withConfig({
|
|
|
536
508
|
`};
|
|
537
509
|
|
|
538
510
|
&:focus {
|
|
539
|
-
${(props) => props.isInvalid &&
|
|
511
|
+
${(props) => props.isInvalid && css`
|
|
540
512
|
border: 1px solid var(--red);
|
|
541
513
|
`};
|
|
542
514
|
}
|
|
@@ -544,11 +516,11 @@ var FormControl = import_styled_components3.default.div.withConfig({
|
|
|
544
516
|
`;
|
|
545
517
|
|
|
546
518
|
// src/components/Input/index.tsx
|
|
547
|
-
|
|
519
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
548
520
|
var InputBase = ({ id, label, error, showErrorMessage = true, borderColor, textColor, mask = "", type = "text", ...rest }, ref) => {
|
|
549
|
-
const phoneInputRef =
|
|
521
|
+
const phoneInputRef = useRef(null);
|
|
550
522
|
const { onChange, name } = rest;
|
|
551
|
-
const handleKeyUp =
|
|
523
|
+
const handleKeyUp = useCallback(
|
|
552
524
|
(e) => {
|
|
553
525
|
if (mask === "cep") cep(e);
|
|
554
526
|
if (mask === "currency") currency(e);
|
|
@@ -557,15 +529,15 @@ var InputBase = ({ id, label, error, showErrorMessage = true, borderColor, textC
|
|
|
557
529
|
},
|
|
558
530
|
[mask]
|
|
559
531
|
);
|
|
560
|
-
const handlePhoneChange =
|
|
532
|
+
const handlePhoneChange = useCallback((value) => {
|
|
561
533
|
onChange?.({ target: { value, name } });
|
|
562
534
|
if (phoneInputRef.current?.input) {
|
|
563
535
|
phoneInputRef.current.input.value = value;
|
|
564
536
|
}
|
|
565
537
|
}, [onChange, name]);
|
|
566
|
-
return /* @__PURE__ */
|
|
567
|
-
!!label && /* @__PURE__ */
|
|
568
|
-
!mask ? /* @__PURE__ */
|
|
538
|
+
return /* @__PURE__ */ jsxs(FormControl, { isInvalid: !!error, children: [
|
|
539
|
+
!!label && /* @__PURE__ */ jsx(FormLabel, { htmlFor: id, $textColor: textColor, children: label }),
|
|
540
|
+
!mask ? /* @__PURE__ */ jsx(
|
|
569
541
|
Input,
|
|
570
542
|
{
|
|
571
543
|
id,
|
|
@@ -576,7 +548,7 @@ var InputBase = ({ id, label, error, showErrorMessage = true, borderColor, textC
|
|
|
576
548
|
autoComplete: rest.autoComplete || "on",
|
|
577
549
|
...rest
|
|
578
550
|
}
|
|
579
|
-
) : mask === "phone" ? /* @__PURE__ */
|
|
551
|
+
) : mask === "phone" ? /* @__PURE__ */ jsx(
|
|
580
552
|
FormPhoneInput,
|
|
581
553
|
{
|
|
582
554
|
country: "br",
|
|
@@ -603,7 +575,7 @@ var InputBase = ({ id, label, error, showErrorMessage = true, borderColor, textC
|
|
|
603
575
|
disableCountryCode: true,
|
|
604
576
|
value: rest.value
|
|
605
577
|
}
|
|
606
|
-
) : /* @__PURE__ */
|
|
578
|
+
) : /* @__PURE__ */ jsx(
|
|
607
579
|
Input,
|
|
608
580
|
{
|
|
609
581
|
id,
|
|
@@ -616,15 +588,15 @@ var InputBase = ({ id, label, error, showErrorMessage = true, borderColor, textC
|
|
|
616
588
|
...rest
|
|
617
589
|
}
|
|
618
590
|
),
|
|
619
|
-
!!error && showErrorMessage && /* @__PURE__ */
|
|
591
|
+
!!error && showErrorMessage && /* @__PURE__ */ jsx(FormErrorMessage, { "data-testid": "error-message", children: typeof error === "string" ? error : error.message })
|
|
620
592
|
] });
|
|
621
593
|
};
|
|
622
|
-
var Input2 =
|
|
594
|
+
var Input2 = forwardRef(InputBase);
|
|
623
595
|
|
|
624
596
|
// src/components/Button/styles.ts
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
var Icon =
|
|
597
|
+
import { darken } from "polished";
|
|
598
|
+
import styled3, { css as css2 } from "styled-components";
|
|
599
|
+
var Icon = styled3.span`
|
|
628
600
|
font-size: 0;
|
|
629
601
|
line-height: 0;
|
|
630
602
|
transition: all 0.25s ease;
|
|
@@ -634,7 +606,7 @@ var Icon = import_styled_components4.default.span`
|
|
|
634
606
|
opacity: 0;
|
|
635
607
|
margin-right: 0.625rem;
|
|
636
608
|
`;
|
|
637
|
-
var Text2 =
|
|
609
|
+
var Text2 = styled3.span`
|
|
638
610
|
font-family: "Montserrat", sans-serif;
|
|
639
611
|
font-size: 1rem;
|
|
640
612
|
line-height: 1.5rem;
|
|
@@ -642,14 +614,14 @@ var Text2 = import_styled_components4.default.span`
|
|
|
642
614
|
|
|
643
615
|
transition: all 0.25s ease;
|
|
644
616
|
`;
|
|
645
|
-
var TextSubmitting =
|
|
617
|
+
var TextSubmitting = styled3.span`
|
|
646
618
|
font-family: "Montserrat", sans-serif;
|
|
647
619
|
font-weight: 400;
|
|
648
620
|
font-size: 1rem;
|
|
649
621
|
|
|
650
622
|
transition: all 0.25s ease;
|
|
651
623
|
`;
|
|
652
|
-
var LoadingIcon =
|
|
624
|
+
var LoadingIcon = styled3.span.withConfig({
|
|
653
625
|
shouldForwardProp: (prop) => prop !== "hasText"
|
|
654
626
|
})`
|
|
655
627
|
display: block;
|
|
@@ -672,7 +644,7 @@ var LoadingIcon = import_styled_components4.default.span.withConfig({
|
|
|
672
644
|
}
|
|
673
645
|
}
|
|
674
646
|
`;
|
|
675
|
-
var Button =
|
|
647
|
+
var Button = styled3.button.withConfig({
|
|
676
648
|
shouldForwardProp: (prop) => ![
|
|
677
649
|
"hasIcon",
|
|
678
650
|
"isSubmitting",
|
|
@@ -683,9 +655,9 @@ var Button = import_styled_components4.default.button.withConfig({
|
|
|
683
655
|
"height"
|
|
684
656
|
].includes(prop)
|
|
685
657
|
})`
|
|
686
|
-
background: ${(props) =>
|
|
658
|
+
background: ${(props) => darken(0.1, props?.bgColor || "#F6C76B")};
|
|
687
659
|
color: ${(props) => props?.color || "#2F2F2F"};
|
|
688
|
-
border: 1px solid ${(props) =>
|
|
660
|
+
border: 1px solid ${(props) => darken(0.1, props?.bordercolor || "#F6C76B")};
|
|
689
661
|
border-radius: 2px;
|
|
690
662
|
|
|
691
663
|
display: inline-flex;
|
|
@@ -714,8 +686,8 @@ var Button = import_styled_components4.default.button.withConfig({
|
|
|
714
686
|
}
|
|
715
687
|
|
|
716
688
|
&:hover {
|
|
717
|
-
background: ${(props) =>
|
|
718
|
-
border-color: ${(props) =>
|
|
689
|
+
background: ${(props) => darken(0.2, props?.bgColor || "#F6C76B")};
|
|
690
|
+
border-color: ${(props) => darken(0.2, props?.bordercolor || "#F6C76B")};
|
|
719
691
|
|
|
720
692
|
${Icon} {
|
|
721
693
|
opacity: 1;
|
|
@@ -729,14 +701,14 @@ var Button = import_styled_components4.default.button.withConfig({
|
|
|
729
701
|
}
|
|
730
702
|
|
|
731
703
|
${Text2} {
|
|
732
|
-
${(props) => props.isSubmitting && !props.hasSubmittingMessage &&
|
|
704
|
+
${(props) => props.isSubmitting && !props.hasSubmittingMessage && css2`
|
|
733
705
|
transform: unset;
|
|
734
706
|
opacity: 0;
|
|
735
707
|
`}
|
|
736
708
|
}
|
|
737
709
|
|
|
738
710
|
${LoadingIcon} {
|
|
739
|
-
${(props) => props.isSubmitting && !props.hasSubmittingMessage &&
|
|
711
|
+
${(props) => props.isSubmitting && !props.hasSubmittingMessage && css2`
|
|
740
712
|
display: flex;
|
|
741
713
|
-webkit-box-align: center;
|
|
742
714
|
align-items: center;
|
|
@@ -746,7 +718,7 @@ var Button = import_styled_components4.default.button.withConfig({
|
|
|
746
718
|
`;
|
|
747
719
|
|
|
748
720
|
// src/components/Button/index.tsx
|
|
749
|
-
|
|
721
|
+
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
750
722
|
function Button2({
|
|
751
723
|
children,
|
|
752
724
|
icon,
|
|
@@ -756,7 +728,7 @@ function Button2({
|
|
|
756
728
|
color = "#2F2F2F",
|
|
757
729
|
...rest
|
|
758
730
|
}) {
|
|
759
|
-
return /* @__PURE__ */ (
|
|
731
|
+
return /* @__PURE__ */ jsxs2(
|
|
760
732
|
Button,
|
|
761
733
|
{
|
|
762
734
|
isSubmitting,
|
|
@@ -767,30 +739,30 @@ function Button2({
|
|
|
767
739
|
color,
|
|
768
740
|
...rest,
|
|
769
741
|
children: [
|
|
770
|
-
icon && !isSubmitting && /* @__PURE__ */ (
|
|
771
|
-
isSubmitting && /* @__PURE__ */ (
|
|
772
|
-
(!isSubmitting || submittingMessage.length === 0) && /* @__PURE__ */ (
|
|
773
|
-
isSubmitting && submittingMessage.length > 0 && /* @__PURE__ */ (
|
|
742
|
+
icon && !isSubmitting && /* @__PURE__ */ jsx2(Icon, { "data-testid": "button-icon", children: icon }),
|
|
743
|
+
isSubmitting && /* @__PURE__ */ jsx2(LoadingIcon, { hasText: submittingMessage.length > 0 }),
|
|
744
|
+
(!isSubmitting || submittingMessage.length === 0) && /* @__PURE__ */ jsx2(Text2, { className: "text", children }),
|
|
745
|
+
isSubmitting && submittingMessage.length > 0 && /* @__PURE__ */ jsx2(TextSubmitting, { children: submittingMessage })
|
|
774
746
|
]
|
|
775
747
|
}
|
|
776
748
|
);
|
|
777
749
|
}
|
|
778
750
|
|
|
779
751
|
// src/components/Alert/index.tsx
|
|
780
|
-
|
|
752
|
+
import { useEffect as useEffect2, useState as useState2, useCallback as useCallback2 } from "react";
|
|
781
753
|
|
|
782
754
|
// src/components/Alert/styles.ts
|
|
783
|
-
|
|
784
|
-
var fadeIn =
|
|
755
|
+
import styled4, { css as css3, keyframes } from "styled-components";
|
|
756
|
+
var fadeIn = keyframes`
|
|
785
757
|
from { opacity: 0; transform: translateY(-10px); }
|
|
786
758
|
to { opacity: 1; transform: translateY(0); }
|
|
787
759
|
`;
|
|
788
|
-
var fadeOut =
|
|
760
|
+
var fadeOut = keyframes`
|
|
789
761
|
from { opacity: 1; transform: translateY(0); }
|
|
790
762
|
to { opacity: 0; transform: translateY(-10px); }
|
|
791
763
|
`;
|
|
792
764
|
var typeStyles = {
|
|
793
|
-
error:
|
|
765
|
+
error: css3`
|
|
794
766
|
background-color: var(--red);
|
|
795
767
|
border: 1px solid var(--red);
|
|
796
768
|
color: var(--white);
|
|
@@ -798,7 +770,7 @@ var typeStyles = {
|
|
|
798
770
|
color: var(--white);
|
|
799
771
|
}
|
|
800
772
|
`,
|
|
801
|
-
warning:
|
|
773
|
+
warning: css3`
|
|
802
774
|
background-color: var(--yellow-500);
|
|
803
775
|
border: 1px solid var(--yellow-400);
|
|
804
776
|
color: var(--black);
|
|
@@ -806,7 +778,7 @@ var typeStyles = {
|
|
|
806
778
|
color: var(--black);
|
|
807
779
|
}
|
|
808
780
|
`,
|
|
809
|
-
info:
|
|
781
|
+
info: css3`
|
|
810
782
|
background-color: var(--blue);
|
|
811
783
|
border: 1px solid var(--blue);
|
|
812
784
|
color: var(--white);
|
|
@@ -814,7 +786,7 @@ var typeStyles = {
|
|
|
814
786
|
color: var(--white);
|
|
815
787
|
}
|
|
816
788
|
`,
|
|
817
|
-
success:
|
|
789
|
+
success: css3`
|
|
818
790
|
background-color: var(--green);
|
|
819
791
|
border: 1px solid var(--green-2);
|
|
820
792
|
color: var(--white);
|
|
@@ -823,7 +795,7 @@ var typeStyles = {
|
|
|
823
795
|
}
|
|
824
796
|
`
|
|
825
797
|
};
|
|
826
|
-
var AlertContainer =
|
|
798
|
+
var AlertContainer = styled4.div`
|
|
827
799
|
position: fixed;
|
|
828
800
|
width: 500px;
|
|
829
801
|
top: 15px;
|
|
@@ -843,7 +815,7 @@ var AlertContainer = import_styled_components5.default.div`
|
|
|
843
815
|
|
|
844
816
|
${({ $type }) => typeStyles[$type]}
|
|
845
817
|
`;
|
|
846
|
-
var DismissButton =
|
|
818
|
+
var DismissButton = styled4.button`
|
|
847
819
|
position: absolute;
|
|
848
820
|
background: transparent;
|
|
849
821
|
right: 10px;
|
|
@@ -864,8 +836,8 @@ var DismissButton = import_styled_components5.default.button`
|
|
|
864
836
|
`;
|
|
865
837
|
|
|
866
838
|
// src/components/Alert/index.tsx
|
|
867
|
-
|
|
868
|
-
|
|
839
|
+
import { HiX } from "react-icons/hi";
|
|
840
|
+
import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
869
841
|
var Alert = ({
|
|
870
842
|
type = "info",
|
|
871
843
|
children,
|
|
@@ -874,18 +846,18 @@ var Alert = ({
|
|
|
874
846
|
onDismiss,
|
|
875
847
|
autoDismiss
|
|
876
848
|
}) => {
|
|
877
|
-
const [isClosing, setIsClosing] = (
|
|
878
|
-
const handleDismiss = (
|
|
849
|
+
const [isClosing, setIsClosing] = useState2(false);
|
|
850
|
+
const handleDismiss = useCallback2(() => {
|
|
879
851
|
setIsClosing(true);
|
|
880
852
|
setTimeout(() => onDismiss?.(), 300);
|
|
881
853
|
}, [onDismiss]);
|
|
882
|
-
(
|
|
854
|
+
useEffect2(() => {
|
|
883
855
|
if (autoDismiss) {
|
|
884
856
|
const timer = setTimeout(handleDismiss, autoDismiss);
|
|
885
857
|
return () => clearTimeout(timer);
|
|
886
858
|
}
|
|
887
859
|
}, [autoDismiss, handleDismiss]);
|
|
888
|
-
return /* @__PURE__ */ (
|
|
860
|
+
return /* @__PURE__ */ jsxs3(
|
|
889
861
|
AlertContainer,
|
|
890
862
|
{
|
|
891
863
|
$type: type,
|
|
@@ -895,12 +867,12 @@ var Alert = ({
|
|
|
895
867
|
role: "alert",
|
|
896
868
|
children: [
|
|
897
869
|
children,
|
|
898
|
-
dismissible && /* @__PURE__ */ (
|
|
870
|
+
dismissible && /* @__PURE__ */ jsx3(
|
|
899
871
|
DismissButton,
|
|
900
872
|
{
|
|
901
873
|
onClick: handleDismiss,
|
|
902
874
|
"aria-label": "Dismiss alert",
|
|
903
|
-
children: /* @__PURE__ */ (
|
|
875
|
+
children: /* @__PURE__ */ jsx3(HiX, {})
|
|
904
876
|
}
|
|
905
877
|
)
|
|
906
878
|
]
|
|
@@ -909,7 +881,7 @@ var Alert = ({
|
|
|
909
881
|
};
|
|
910
882
|
|
|
911
883
|
// src/components/Form/index.tsx
|
|
912
|
-
|
|
884
|
+
import { Fragment, jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
913
885
|
var schema = yup.object().shape({
|
|
914
886
|
name: yup.string().required("Nome \xE9 obrigat\xF3rio"),
|
|
915
887
|
email: yup.string().required("Email \xE9 obrigat\xF3rio").email("Email inv\xE1lido"),
|
|
@@ -922,7 +894,7 @@ var schema = yup.object().shape({
|
|
|
922
894
|
}
|
|
923
895
|
)
|
|
924
896
|
});
|
|
925
|
-
var MitreFormComponent =
|
|
897
|
+
var MitreFormComponent = React3.forwardRef(({
|
|
926
898
|
productId,
|
|
927
899
|
apiUrl,
|
|
928
900
|
apiToken,
|
|
@@ -932,13 +904,15 @@ var MitreFormComponent = import_react5.default.forwardRef(({
|
|
|
932
904
|
utm_term,
|
|
933
905
|
showHeader = true,
|
|
934
906
|
colorPrimary = "#F6C76B",
|
|
935
|
-
textColor = "#2F2F2F"
|
|
907
|
+
textColor = "#2F2F2F",
|
|
908
|
+
backgroundColor = "#cecece",
|
|
909
|
+
innerPadding = "1rem"
|
|
936
910
|
}, ref) => {
|
|
937
|
-
const [loading, setIsLoading] = (
|
|
911
|
+
const [loading, setIsLoading] = useState3(false);
|
|
938
912
|
const { error, handleError, clearError } = useError();
|
|
939
|
-
const [successMessage, setSuccessMessage] = (
|
|
940
|
-
const { register, handleSubmit, formState: { errors }, reset, watch } =
|
|
941
|
-
resolver:
|
|
913
|
+
const [successMessage, setSuccessMessage] = useState3("");
|
|
914
|
+
const { register, handleSubmit, formState: { errors }, reset, watch } = useForm({
|
|
915
|
+
resolver: yupResolver(schema)
|
|
942
916
|
});
|
|
943
917
|
const phoneValue = watch("phone");
|
|
944
918
|
const sendMessage = async (data) => {
|
|
@@ -978,10 +952,10 @@ var MitreFormComponent = import_react5.default.forwardRef(({
|
|
|
978
952
|
setIsLoading(false);
|
|
979
953
|
}
|
|
980
954
|
};
|
|
981
|
-
return /* @__PURE__ */ (
|
|
982
|
-
/* @__PURE__ */ (
|
|
983
|
-
/* @__PURE__ */ (
|
|
984
|
-
error && /* @__PURE__ */ (
|
|
955
|
+
return /* @__PURE__ */ jsxs4(Fragment, { children: [
|
|
956
|
+
/* @__PURE__ */ jsx4(global_default, {}),
|
|
957
|
+
/* @__PURE__ */ jsx4(GlobalStyles, {}),
|
|
958
|
+
error && /* @__PURE__ */ jsx4(
|
|
985
959
|
Alert,
|
|
986
960
|
{
|
|
987
961
|
type: "error",
|
|
@@ -991,7 +965,7 @@ var MitreFormComponent = import_react5.default.forwardRef(({
|
|
|
991
965
|
children: error.message
|
|
992
966
|
}
|
|
993
967
|
),
|
|
994
|
-
successMessage && /* @__PURE__ */ (
|
|
968
|
+
successMessage && /* @__PURE__ */ jsx4(
|
|
995
969
|
Alert,
|
|
996
970
|
{
|
|
997
971
|
type: "success",
|
|
@@ -1001,13 +975,13 @@ var MitreFormComponent = import_react5.default.forwardRef(({
|
|
|
1001
975
|
children: successMessage
|
|
1002
976
|
}
|
|
1003
977
|
),
|
|
1004
|
-
/* @__PURE__ */ (
|
|
1005
|
-
showHeader && /* @__PURE__ */ (
|
|
1006
|
-
/* @__PURE__ */ (
|
|
1007
|
-
/* @__PURE__ */ (
|
|
978
|
+
/* @__PURE__ */ jsxs4(FormContainer, { $backgroundColor: backgroundColor, innerPadding, ref, children: [
|
|
979
|
+
showHeader && /* @__PURE__ */ jsxs4(HeaderContainer, { children: [
|
|
980
|
+
/* @__PURE__ */ jsx4(Title, { $textColor: textColor, children: "Atendimento por mensagem" }),
|
|
981
|
+
/* @__PURE__ */ jsx4(Text, { $textColor: textColor, children: "Informe seus dados e retornaremos a mensagem." })
|
|
1008
982
|
] }),
|
|
1009
|
-
/* @__PURE__ */ (
|
|
1010
|
-
/* @__PURE__ */ (
|
|
983
|
+
/* @__PURE__ */ jsxs4(Form, { $textColor: textColor, onSubmit: handleSubmit(sendMessage), noValidate: true, children: [
|
|
984
|
+
/* @__PURE__ */ jsx4(
|
|
1011
985
|
Input2,
|
|
1012
986
|
{
|
|
1013
987
|
id: "name",
|
|
@@ -1021,7 +995,7 @@ var MitreFormComponent = import_react5.default.forwardRef(({
|
|
|
1021
995
|
required: true
|
|
1022
996
|
}
|
|
1023
997
|
),
|
|
1024
|
-
/* @__PURE__ */ (
|
|
998
|
+
/* @__PURE__ */ jsx4(
|
|
1025
999
|
Input2,
|
|
1026
1000
|
{
|
|
1027
1001
|
id: "email",
|
|
@@ -1036,7 +1010,7 @@ var MitreFormComponent = import_react5.default.forwardRef(({
|
|
|
1036
1010
|
required: true
|
|
1037
1011
|
}
|
|
1038
1012
|
),
|
|
1039
|
-
/* @__PURE__ */ (
|
|
1013
|
+
/* @__PURE__ */ jsx4(
|
|
1040
1014
|
Input2,
|
|
1041
1015
|
{
|
|
1042
1016
|
id: "phone",
|
|
@@ -1051,12 +1025,12 @@ var MitreFormComponent = import_react5.default.forwardRef(({
|
|
|
1051
1025
|
value: phoneValue
|
|
1052
1026
|
}
|
|
1053
1027
|
),
|
|
1054
|
-
/* @__PURE__ */ (
|
|
1055
|
-
/* @__PURE__ */ (
|
|
1056
|
-
/* @__PURE__ */ (
|
|
1028
|
+
/* @__PURE__ */ jsx4("h6", { children: "* Campos de preenchimento obrigat\xF3rio." }),
|
|
1029
|
+
/* @__PURE__ */ jsx4(ButtonContainer, { children: /* @__PURE__ */ jsx4(Button2, { bgColor: colorPrimary, color: textColor, type: "submit", isSubmitting: loading, children: "Enviar mensagem" }) }),
|
|
1030
|
+
/* @__PURE__ */ jsxs4("p", { children: [
|
|
1057
1031
|
"A Mitre Realty respeita a sua privacidade e utiliza os seus dados pessoais para contat\xE1-lo por e-mail ou telefone aqui registrados. Para saber mais, acesse a nossa",
|
|
1058
1032
|
" ",
|
|
1059
|
-
/* @__PURE__ */ (
|
|
1033
|
+
/* @__PURE__ */ jsx4(
|
|
1060
1034
|
"a",
|
|
1061
1035
|
{
|
|
1062
1036
|
href: "https://www.mitrerealty.com.br/politica-de-privacidade",
|
|
@@ -1077,8 +1051,7 @@ var MitreFormComponent = import_react5.default.forwardRef(({
|
|
|
1077
1051
|
});
|
|
1078
1052
|
MitreFormComponent.displayName = "MitreFormComponent";
|
|
1079
1053
|
var Form_default = MitreFormComponent;
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
});
|
|
1054
|
+
export {
|
|
1055
|
+
Form_default as MitreFormComponent
|
|
1056
|
+
};
|
|
1084
1057
|
//# sourceMappingURL=index.js.map
|