@lets-events/react 12.5.0 → 12.5.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/.eslintrc.json +2 -2
- package/.turbo/turbo-build.log +24 -0
- package/CHANGELOG.md +584 -578
- package/dist/index.d.mts +15402 -0
- package/dist/index.d.ts +15402 -0
- package/dist/index.js +13384 -0
- package/dist/index.mjs +13278 -0
- package/package.json +49 -49
- package/src/components/Alert.tsx +303 -303
- package/src/components/Avatar.tsx +55 -55
- package/src/components/Badge.tsx +125 -125
- package/src/components/Box.tsx +3 -3
- package/src/components/Button/index.tsx +45 -45
- package/src/components/Button/styledComponents.ts +313 -313
- package/src/components/ButtonGroup.tsx +484 -484
- package/src/components/Calendar/index.tsx +148 -148
- package/src/components/Calendar/styledComponents.ts +259 -259
- package/src/components/Card.tsx +67 -67
- package/src/components/CheckboxGroup.tsx +176 -176
- package/src/components/Container.tsx +39 -39
- package/src/components/Divider.tsx +7 -7
- package/src/components/DoubleCalendar/index.tsx +170 -170
- package/src/components/Drawer/index.tsx +100 -100
- package/src/components/Drawer/styledComponents.ts +103 -103
- package/src/components/Dropdown.tsx +302 -302
- package/src/components/Filter.tsx +164 -164
- package/src/components/Flex.tsx +118 -118
- package/src/components/FormFields/AddressFormFields/CityFormField.tsx +111 -111
- package/src/components/FormFields/AddressFormFields/CountryFormField.tsx +33 -33
- package/src/components/FormFields/AddressFormFields/PostalCodeFormField.tsx +39 -39
- package/src/components/FormFields/AddressFormFields/StateFormField.tsx +32 -32
- package/src/components/FormFields/AddressFormFields/index.tsx +141 -141
- package/src/components/FormFields/BirthDateFormField.tsx +84 -84
- package/src/components/FormFields/CNPJFormField.tsx +87 -87
- package/src/components/FormFields/CPFFormField.tsx +78 -78
- package/src/components/FormFields/CalendarFormField.tsx +95 -95
- package/src/components/FormFields/CheckboxGroupFormField.tsx +91 -91
- package/src/components/FormFields/DoubleCalendarFormField.tsx +93 -93
- package/src/components/FormFields/EmailFormField.tsx +27 -27
- package/src/components/FormFields/Form.tsx +39 -39
- package/src/components/FormFields/IdentityDocumentNumberFormField.tsx +32 -32
- package/src/components/FormFields/MultiSelectFormField.tsx +64 -64
- package/src/components/FormFields/PhoneFormField.tsx +40 -40
- package/src/components/FormFields/RadioGroupFormField.tsx +84 -84
- package/src/components/FormFields/RichEditorFormField.tsx +103 -103
- package/src/components/FormFields/SelectFormField.tsx +93 -93
- package/src/components/FormFields/SwitchFormField.tsx +46 -46
- package/src/components/FormFields/TextAreaFormField.tsx +61 -59
- package/src/components/FormFields/TextFormField.tsx +112 -112
- package/src/components/FormFields/TimePickerFormField.tsx +88 -88
- package/src/components/FormFields/subComponents/ErrorFormMessage.tsx +36 -36
- package/src/components/FormFields/subComponents/FormLabel.tsx +29 -29
- package/src/components/FormFields/utils/validation.ts +23 -23
- package/src/components/Grid.tsx +137 -137
- package/src/components/Icon.tsx +47 -47
- package/src/components/MenuDropdown/index.tsx +38 -38
- package/src/components/MenuDropdown/styledComponents.ts +31 -31
- package/src/components/Modal.tsx +110 -110
- package/src/components/MultiSelect/index.tsx +243 -243
- package/src/components/MultiSelect/styledComponents.ts +160 -160
- package/src/components/RadioGroup.tsx +210 -210
- package/src/components/RichEditor/QuillComponent.tsx +457 -457
- package/src/components/RichEditor/RichEditor.tsx +49 -49
- package/src/components/RichEditor/index.ts +2 -2
- package/src/components/RichEditor/styledComponents.ts +1151 -1151
- package/src/components/Section.tsx +33 -33
- package/src/components/Step.tsx +164 -164
- package/src/components/Switch.tsx +108 -108
- package/src/components/Text.tsx +38 -38
- package/src/components/TextField.tsx +372 -372
- package/src/components/TextareaField.tsx +116 -138
- package/src/components/TimePicker.tsx +328 -328
- package/src/components/Toast/components/ToastItem.tsx +41 -41
- package/src/components/Toast/components/ToastProvider.tsx +63 -63
- package/src/components/Toast/hooks/useToast.ts +12 -12
- package/src/components/Toast/index.tsx +5 -5
- package/src/components/Toast/styles/index.ts +135 -135
- package/src/components/Toast/types/index.ts +46 -46
- package/src/components/Tooltip/index.tsx +66 -66
- package/src/components/Tooltip/styles.ts +77 -77
- package/src/hooks/useCountries.ts +41 -41
- package/src/hooks/useImageUpload.ts +139 -139
- package/src/hooks/useOnClickOutside.tsx +42 -42
- package/src/index.tsx +71 -71
- package/src/styles/index.ts +41 -41
- package/src/types/typographyValues.ts +178 -178
- package/src/utils/getNestedValue.ts +3 -3
- package/src/utils/states.ts +29 -29
- package/src/utils/uploadService.ts +180 -180
- package/tsconfig.json +3 -3
- package/tsup.config.ts +38 -38
|
@@ -1,148 +1,148 @@
|
|
|
1
|
-
import React, { ComponentProps, useRef, useEffect, useState } from "react";
|
|
2
|
-
import { useOnClickOutside } from "../../hooks/useOnClickOutside";
|
|
3
|
-
import { DayPicker } from "react-day-picker";
|
|
4
|
-
import { ptBR } from "date-fns/locale";
|
|
5
|
-
import { parse, isValid, format, addYears } from "date-fns";
|
|
6
|
-
import { Button } from "../Button";
|
|
7
|
-
import { Box } from "../Box";
|
|
8
|
-
import { TextField, TextFieldSlot } from "../TextField";
|
|
9
|
-
import Icon from "../Icon";
|
|
10
|
-
import {
|
|
11
|
-
CalendarContentStyled,
|
|
12
|
-
CalendarFooterStyled,
|
|
13
|
-
CalendarStyled,
|
|
14
|
-
DayPickerWrapperStyled,
|
|
15
|
-
CalendarButtonStyled,
|
|
16
|
-
} from "./styledComponents";
|
|
17
|
-
|
|
18
|
-
export type CalendarProps = ComponentProps<typeof CalendarStyled> & {
|
|
19
|
-
calendarLayout?: "label" | "dropdown" | "dropdown-months" | "dropdown-years";
|
|
20
|
-
selected: Date | undefined;
|
|
21
|
-
setSelected: React.Dispatch<React.SetStateAction<Date | undefined>>;
|
|
22
|
-
position?: "top" | "bottom" | "top-right" | "bottom-right";
|
|
23
|
-
action?: boolean;
|
|
24
|
-
actionText?: string;
|
|
25
|
-
hasError?: boolean;
|
|
26
|
-
expand?: boolean;
|
|
27
|
-
allowPastDates?: boolean;
|
|
28
|
-
maxYearsFromNow?: number;
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
function formatToDateMask(value: string): string {
|
|
32
|
-
const numeric = value.replace(/\D/g, "").slice(0, 8);
|
|
33
|
-
const parts = numeric.match(/^(\d{0,2})(\d{0,2})(\d{0,4})$/);
|
|
34
|
-
if (!parts) return "";
|
|
35
|
-
const [, day, month, year] = parts;
|
|
36
|
-
return [day, month, year].filter(Boolean).join("/");
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export function Calendar({
|
|
40
|
-
action,
|
|
41
|
-
actionText,
|
|
42
|
-
calendarLayout,
|
|
43
|
-
selected,
|
|
44
|
-
setSelected,
|
|
45
|
-
position = "bottom",
|
|
46
|
-
hasError,
|
|
47
|
-
expand,
|
|
48
|
-
allowPastDates = false,
|
|
49
|
-
maxYearsFromNow = 20,
|
|
50
|
-
...props
|
|
51
|
-
}: CalendarProps) {
|
|
52
|
-
const [inputValue, setInputValue] = useState("");
|
|
53
|
-
const [showContainer, setShowCalendar] = useState(false);
|
|
54
|
-
|
|
55
|
-
const dropdownRef = useRef<HTMLDivElement>(null);
|
|
56
|
-
|
|
57
|
-
useOnClickOutside(dropdownRef, () => {
|
|
58
|
-
setShowCalendar(false);
|
|
59
|
-
});
|
|
60
|
-
const today = new Date();
|
|
61
|
-
const maxDate = addYears(today, maxYearsFromNow);
|
|
62
|
-
|
|
63
|
-
useEffect(() => {
|
|
64
|
-
if (selected) {
|
|
65
|
-
setInputValue(format(selected, "dd/MM/yyyy"));
|
|
66
|
-
} else {
|
|
67
|
-
setInputValue("");
|
|
68
|
-
}
|
|
69
|
-
}, [selected]);
|
|
70
|
-
|
|
71
|
-
const handleInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
72
|
-
const masked = formatToDateMask(e.target.value);
|
|
73
|
-
setInputValue(masked);
|
|
74
|
-
|
|
75
|
-
const parsed = parse(masked, "dd/MM/yyyy", new Date());
|
|
76
|
-
if (isValid(parsed)) {
|
|
77
|
-
if (!allowPastDates && parsed < today) {
|
|
78
|
-
console.warn("Datas passadas não são permitidas:", masked);
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
setSelected(parsed);
|
|
82
|
-
} else {
|
|
83
|
-
console.warn("Data inválida inserida no input:", masked);
|
|
84
|
-
}
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
return (
|
|
88
|
-
<div>
|
|
89
|
-
<CalendarStyled {...props} expand={expand} ref={dropdownRef}>
|
|
90
|
-
<CalendarButtonStyled
|
|
91
|
-
expand={expand}
|
|
92
|
-
type="button"
|
|
93
|
-
onClick={() => setShowCalendar((prev) => !prev)}
|
|
94
|
-
>
|
|
95
|
-
<TextField
|
|
96
|
-
placeholder="00/00/0000"
|
|
97
|
-
type="text"
|
|
98
|
-
value={inputValue}
|
|
99
|
-
onChange={handleInputChange}
|
|
100
|
-
inputMode="numeric"
|
|
101
|
-
textAlign={"right"}
|
|
102
|
-
color={hasError ? "error" : "default"}
|
|
103
|
-
>
|
|
104
|
-
<TextFieldSlot>
|
|
105
|
-
<Icon name="calendar" size={"xl"} />
|
|
106
|
-
</TextFieldSlot>
|
|
107
|
-
</TextField>
|
|
108
|
-
</CalendarButtonStyled>
|
|
109
|
-
{showContainer && (
|
|
110
|
-
<CalendarContentStyled position={position}>
|
|
111
|
-
<Box>
|
|
112
|
-
<DayPickerWrapperStyled>
|
|
113
|
-
<DayPicker
|
|
114
|
-
mode="single"
|
|
115
|
-
captionLayout={calendarLayout}
|
|
116
|
-
selected={selected}
|
|
117
|
-
onSelect={setSelected}
|
|
118
|
-
required
|
|
119
|
-
locale={ptBR}
|
|
120
|
-
disabled={allowPastDates ? undefined : { before: today }}
|
|
121
|
-
startMonth={allowPastDates ? undefined : today}
|
|
122
|
-
endMonth={maxDate}
|
|
123
|
-
/>
|
|
124
|
-
</DayPickerWrapperStyled>
|
|
125
|
-
</Box>
|
|
126
|
-
|
|
127
|
-
{action && (
|
|
128
|
-
<CalendarFooterStyled>
|
|
129
|
-
<Button
|
|
130
|
-
variant="text"
|
|
131
|
-
color="brand"
|
|
132
|
-
type="button"
|
|
133
|
-
onClick={() => {
|
|
134
|
-
setShowCalendar(false);
|
|
135
|
-
}}
|
|
136
|
-
size={"medium"}
|
|
137
|
-
fontWeight="medium"
|
|
138
|
-
>
|
|
139
|
-
{actionText ?? "Aplicar"}
|
|
140
|
-
</Button>
|
|
141
|
-
</CalendarFooterStyled>
|
|
142
|
-
)}
|
|
143
|
-
</CalendarContentStyled>
|
|
144
|
-
)}
|
|
145
|
-
</CalendarStyled>
|
|
146
|
-
</div>
|
|
147
|
-
);
|
|
148
|
-
}
|
|
1
|
+
import React, { ComponentProps, useRef, useEffect, useState } from "react";
|
|
2
|
+
import { useOnClickOutside } from "../../hooks/useOnClickOutside";
|
|
3
|
+
import { DayPicker } from "react-day-picker";
|
|
4
|
+
import { ptBR } from "date-fns/locale";
|
|
5
|
+
import { parse, isValid, format, addYears } from "date-fns";
|
|
6
|
+
import { Button } from "../Button";
|
|
7
|
+
import { Box } from "../Box";
|
|
8
|
+
import { TextField, TextFieldSlot } from "../TextField";
|
|
9
|
+
import Icon from "../Icon";
|
|
10
|
+
import {
|
|
11
|
+
CalendarContentStyled,
|
|
12
|
+
CalendarFooterStyled,
|
|
13
|
+
CalendarStyled,
|
|
14
|
+
DayPickerWrapperStyled,
|
|
15
|
+
CalendarButtonStyled,
|
|
16
|
+
} from "./styledComponents";
|
|
17
|
+
|
|
18
|
+
export type CalendarProps = ComponentProps<typeof CalendarStyled> & {
|
|
19
|
+
calendarLayout?: "label" | "dropdown" | "dropdown-months" | "dropdown-years";
|
|
20
|
+
selected: Date | undefined;
|
|
21
|
+
setSelected: React.Dispatch<React.SetStateAction<Date | undefined>>;
|
|
22
|
+
position?: "top" | "bottom" | "top-right" | "bottom-right";
|
|
23
|
+
action?: boolean;
|
|
24
|
+
actionText?: string;
|
|
25
|
+
hasError?: boolean;
|
|
26
|
+
expand?: boolean;
|
|
27
|
+
allowPastDates?: boolean;
|
|
28
|
+
maxYearsFromNow?: number;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
function formatToDateMask(value: string): string {
|
|
32
|
+
const numeric = value.replace(/\D/g, "").slice(0, 8);
|
|
33
|
+
const parts = numeric.match(/^(\d{0,2})(\d{0,2})(\d{0,4})$/);
|
|
34
|
+
if (!parts) return "";
|
|
35
|
+
const [, day, month, year] = parts;
|
|
36
|
+
return [day, month, year].filter(Boolean).join("/");
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function Calendar({
|
|
40
|
+
action,
|
|
41
|
+
actionText,
|
|
42
|
+
calendarLayout,
|
|
43
|
+
selected,
|
|
44
|
+
setSelected,
|
|
45
|
+
position = "bottom",
|
|
46
|
+
hasError,
|
|
47
|
+
expand,
|
|
48
|
+
allowPastDates = false,
|
|
49
|
+
maxYearsFromNow = 20,
|
|
50
|
+
...props
|
|
51
|
+
}: CalendarProps) {
|
|
52
|
+
const [inputValue, setInputValue] = useState("");
|
|
53
|
+
const [showContainer, setShowCalendar] = useState(false);
|
|
54
|
+
|
|
55
|
+
const dropdownRef = useRef<HTMLDivElement>(null);
|
|
56
|
+
|
|
57
|
+
useOnClickOutside(dropdownRef, () => {
|
|
58
|
+
setShowCalendar(false);
|
|
59
|
+
});
|
|
60
|
+
const today = new Date();
|
|
61
|
+
const maxDate = addYears(today, maxYearsFromNow);
|
|
62
|
+
|
|
63
|
+
useEffect(() => {
|
|
64
|
+
if (selected) {
|
|
65
|
+
setInputValue(format(selected, "dd/MM/yyyy"));
|
|
66
|
+
} else {
|
|
67
|
+
setInputValue("");
|
|
68
|
+
}
|
|
69
|
+
}, [selected]);
|
|
70
|
+
|
|
71
|
+
const handleInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
72
|
+
const masked = formatToDateMask(e.target.value);
|
|
73
|
+
setInputValue(masked);
|
|
74
|
+
|
|
75
|
+
const parsed = parse(masked, "dd/MM/yyyy", new Date());
|
|
76
|
+
if (isValid(parsed)) {
|
|
77
|
+
if (!allowPastDates && parsed < today) {
|
|
78
|
+
console.warn("Datas passadas não são permitidas:", masked);
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
setSelected(parsed);
|
|
82
|
+
} else {
|
|
83
|
+
console.warn("Data inválida inserida no input:", masked);
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
return (
|
|
88
|
+
<div>
|
|
89
|
+
<CalendarStyled {...props} expand={expand} ref={dropdownRef}>
|
|
90
|
+
<CalendarButtonStyled
|
|
91
|
+
expand={expand}
|
|
92
|
+
type="button"
|
|
93
|
+
onClick={() => setShowCalendar((prev) => !prev)}
|
|
94
|
+
>
|
|
95
|
+
<TextField
|
|
96
|
+
placeholder="00/00/0000"
|
|
97
|
+
type="text"
|
|
98
|
+
value={inputValue}
|
|
99
|
+
onChange={handleInputChange}
|
|
100
|
+
inputMode="numeric"
|
|
101
|
+
textAlign={"right"}
|
|
102
|
+
color={hasError ? "error" : "default"}
|
|
103
|
+
>
|
|
104
|
+
<TextFieldSlot>
|
|
105
|
+
<Icon name="calendar" size={"xl"} />
|
|
106
|
+
</TextFieldSlot>
|
|
107
|
+
</TextField>
|
|
108
|
+
</CalendarButtonStyled>
|
|
109
|
+
{showContainer && (
|
|
110
|
+
<CalendarContentStyled position={position}>
|
|
111
|
+
<Box>
|
|
112
|
+
<DayPickerWrapperStyled>
|
|
113
|
+
<DayPicker
|
|
114
|
+
mode="single"
|
|
115
|
+
captionLayout={calendarLayout}
|
|
116
|
+
selected={selected}
|
|
117
|
+
onSelect={setSelected}
|
|
118
|
+
required
|
|
119
|
+
locale={ptBR}
|
|
120
|
+
disabled={allowPastDates ? undefined : { before: today }}
|
|
121
|
+
startMonth={allowPastDates ? undefined : today}
|
|
122
|
+
endMonth={maxDate}
|
|
123
|
+
/>
|
|
124
|
+
</DayPickerWrapperStyled>
|
|
125
|
+
</Box>
|
|
126
|
+
|
|
127
|
+
{action && (
|
|
128
|
+
<CalendarFooterStyled>
|
|
129
|
+
<Button
|
|
130
|
+
variant="text"
|
|
131
|
+
color="brand"
|
|
132
|
+
type="button"
|
|
133
|
+
onClick={() => {
|
|
134
|
+
setShowCalendar(false);
|
|
135
|
+
}}
|
|
136
|
+
size={"medium"}
|
|
137
|
+
fontWeight="medium"
|
|
138
|
+
>
|
|
139
|
+
{actionText ?? "Aplicar"}
|
|
140
|
+
</Button>
|
|
141
|
+
</CalendarFooterStyled>
|
|
142
|
+
)}
|
|
143
|
+
</CalendarContentStyled>
|
|
144
|
+
)}
|
|
145
|
+
</CalendarStyled>
|
|
146
|
+
</div>
|
|
147
|
+
);
|
|
148
|
+
}
|