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