@lets-events/react 8.0.0 → 9.0.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.
Files changed (39) hide show
  1. package/.eslintrc.json +2 -2
  2. package/.turbo/turbo-build.log +18 -19
  3. package/CHANGELOG.md +13 -1
  4. package/dist/index.d.mts +377 -6
  5. package/dist/index.d.ts +377 -6
  6. package/dist/index.js +277 -734
  7. package/dist/index.mjs +213 -671
  8. package/package.json +3 -1
  9. package/src/components/Alert.tsx +303 -303
  10. package/src/components/Avatar.tsx +55 -55
  11. package/src/components/Badge.tsx +128 -128
  12. package/src/components/Box.tsx +3 -3
  13. package/src/components/Button/index.tsx +12 -12
  14. package/src/components/Button/styledComponents.ts +250 -250
  15. package/src/components/ButtonGroup.tsx +484 -484
  16. package/src/components/Calendar/index.tsx +136 -132
  17. package/src/components/Calendar/styledComponents.ts +208 -208
  18. package/src/components/Card.tsx +69 -69
  19. package/src/components/CheckboxGroup.tsx +214 -214
  20. package/src/components/Container.tsx +39 -39
  21. package/src/components/Dropdown.tsx +167 -167
  22. package/src/components/Filter.tsx +164 -164
  23. package/src/components/Flex.tsx +118 -118
  24. package/src/components/Grid.tsx +137 -137
  25. package/src/components/Icon.tsx +47 -47
  26. package/src/components/Modal.tsx +103 -109
  27. package/src/components/RadioGroup.tsx +210 -210
  28. package/src/components/Section.tsx +33 -33
  29. package/src/components/Step.tsx +164 -164
  30. package/src/components/Switch.tsx +108 -108
  31. package/src/components/Text.tsx +30 -30
  32. package/src/components/TextField.tsx +299 -299
  33. package/src/components/TextareaField.tsx +101 -101
  34. package/src/components/TimePicker.tsx +239 -213
  35. package/src/hooks/useOnClickOutside.tsx +20 -20
  36. package/src/index.tsx +31 -31
  37. package/src/styles/index.ts +38 -38
  38. package/src/types/typographyValues.ts +178 -178
  39. package/tsconfig.json +3 -3
@@ -1,132 +1,136 @@
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";
23
- action?: boolean;
24
- actionText?: string;
25
- };
26
-
27
- function formatToDateMask(value: string): string {
28
- const numeric = value.replace(/\D/g, "").slice(0, 8);
29
- const parts = numeric.match(/^(\d{0,2})(\d{0,2})(\d{0,4})$/);
30
- if (!parts) return "";
31
- const [, day, month, year] = parts;
32
- return [day, month, year].filter(Boolean).join("/");
33
- }
34
-
35
- export function Calendar({
36
- action,
37
- actionText,
38
- calendarLayout,
39
- selected,
40
- setSelected,
41
- position = "bottom",
42
- ...props
43
- }: CalendarProps) {
44
- const [inputValue, setInputValue] = useState("");
45
- const [showContainer, setShowCalendar] = useState(false);
46
-
47
- const dropdownRef = useRef<HTMLDivElement>(null);
48
-
49
- useOnClickOutside(dropdownRef, () => {
50
- setShowCalendar(false);
51
- });
52
- const today = new Date();
53
- const maxDate = addYears(today, 20);
54
-
55
- useEffect(() => {
56
- if (selected) {
57
- setInputValue(format(selected, "dd/MM/yyyy"));
58
- } else {
59
- setInputValue("");
60
- }
61
- }, [selected]);
62
-
63
- const handleInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {
64
- const masked = formatToDateMask(e.target.value);
65
- setInputValue(masked);
66
-
67
- const parsed = parse(masked, "dd/MM/yyyy", new Date());
68
- if (isValid(parsed)) {
69
- setSelected(parsed);
70
- } else {
71
- console.warn("Data inválida inserida no input:", masked);
72
- }
73
- };
74
-
75
- return (
76
- <div>
77
- <CalendarStyled {...props} ref={dropdownRef}>
78
- <CalendarButtonStyled onClick={() => setShowCalendar((prev) => !prev)}>
79
- <TextField
80
- placeholder="00/00/0000"
81
- type="text"
82
- value={inputValue}
83
- onChange={handleInputChange}
84
- inputMode="numeric"
85
- textAlign={"right"}
86
- >
87
- <TextFieldSlot>
88
- <Icon name="calendar" size={"xl"} />
89
- </TextFieldSlot>
90
- </TextField>
91
- </CalendarButtonStyled>
92
- {showContainer && (
93
- <CalendarContentStyled
94
- style={position === "top" ? { bottom: "110%" } : { top: "110%" }}
95
- >
96
- <Box>
97
- <DayPickerWrapperStyled>
98
- <DayPicker
99
- mode="single"
100
- captionLayout={calendarLayout}
101
- selected={selected}
102
- onSelect={setSelected}
103
- required
104
- locale={ptBR}
105
- disabled={{ before: today }}
106
- startMonth={today}
107
- endMonth={maxDate}
108
- />
109
- </DayPickerWrapperStyled>
110
- </Box>
111
-
112
- {action && (
113
- <CalendarFooterStyled>
114
- <Button
115
- variant="text"
116
- color="brand"
117
- onClick={() => {
118
- setShowCalendar(false);
119
- }}
120
- typography="buttonMedium"
121
- fontWeight="medium"
122
- >
123
- {actionText ?? "Aplicar"}
124
- </Button>
125
- </CalendarFooterStyled>
126
- )}
127
- </CalendarContentStyled>
128
- )}
129
- </CalendarStyled>
130
- </div>
131
- );
132
- }
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";
23
+ action?: boolean;
24
+ actionText?: string;
25
+ };
26
+
27
+ function formatToDateMask(value: string): string {
28
+ const numeric = value.replace(/\D/g, "").slice(0, 8);
29
+ const parts = numeric.match(/^(\d{0,2})(\d{0,2})(\d{0,4})$/);
30
+ if (!parts) return "";
31
+ const [, day, month, year] = parts;
32
+ return [day, month, year].filter(Boolean).join("/");
33
+ }
34
+
35
+ export function Calendar({
36
+ action,
37
+ actionText,
38
+ calendarLayout,
39
+ selected,
40
+ setSelected,
41
+ position = "bottom",
42
+ ...props
43
+ }: CalendarProps) {
44
+ const [inputValue, setInputValue] = useState("");
45
+ const [showContainer, setShowCalendar] = useState(false);
46
+
47
+ const dropdownRef = useRef<HTMLDivElement>(null);
48
+
49
+ useOnClickOutside(dropdownRef, () => {
50
+ setShowCalendar(false);
51
+ });
52
+ const today = new Date();
53
+ const maxDate = addYears(today, 20);
54
+
55
+ useEffect(() => {
56
+ if (selected) {
57
+ setInputValue(format(selected, "dd/MM/yyyy"));
58
+ } else {
59
+ setInputValue("");
60
+ }
61
+ }, [selected]);
62
+
63
+ const handleInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {
64
+ const masked = formatToDateMask(e.target.value);
65
+ setInputValue(masked);
66
+
67
+ const parsed = parse(masked, "dd/MM/yyyy", new Date());
68
+ if (isValid(parsed)) {
69
+ setSelected(parsed);
70
+ } else {
71
+ console.warn("Data inválida inserida no input:", masked);
72
+ }
73
+ };
74
+
75
+ return (
76
+ <div>
77
+ <CalendarStyled {...props} ref={dropdownRef}>
78
+ <CalendarButtonStyled
79
+ type="button"
80
+ onClick={() => setShowCalendar((prev) => !prev)}
81
+ >
82
+ <TextField
83
+ placeholder="00/00/0000"
84
+ type="text"
85
+ value={inputValue}
86
+ onChange={handleInputChange}
87
+ inputMode="numeric"
88
+ textAlign={"right"}
89
+ >
90
+ <TextFieldSlot>
91
+ <Icon name="calendar" size={"xl"} />
92
+ </TextFieldSlot>
93
+ </TextField>
94
+ </CalendarButtonStyled>
95
+ {showContainer && (
96
+ <CalendarContentStyled
97
+ style={position === "top" ? { bottom: "110%" } : { top: "110%" }}
98
+ >
99
+ <Box>
100
+ <DayPickerWrapperStyled>
101
+ <DayPicker
102
+ mode="single"
103
+ captionLayout={calendarLayout}
104
+ selected={selected}
105
+ onSelect={setSelected}
106
+ required
107
+ locale={ptBR}
108
+ disabled={{ before: today }}
109
+ startMonth={today}
110
+ endMonth={maxDate}
111
+ />
112
+ </DayPickerWrapperStyled>
113
+ </Box>
114
+
115
+ {action && (
116
+ <CalendarFooterStyled>
117
+ <Button
118
+ variant="text"
119
+ color="brand"
120
+ type="button"
121
+ onClick={() => {
122
+ setShowCalendar(false);
123
+ }}
124
+ typography="buttonMedium"
125
+ fontWeight="medium"
126
+ >
127
+ {actionText ?? "Aplicar"}
128
+ </Button>
129
+ </CalendarFooterStyled>
130
+ )}
131
+ </CalendarContentStyled>
132
+ )}
133
+ </CalendarStyled>
134
+ </div>
135
+ );
136
+ }