@lets-events/react 12.10.17 → 12.11.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 (97) hide show
  1. package/.eslintrc.json +2 -2
  2. package/.turbo/turbo-build.log +21 -19
  3. package/CHANGELOG.md +6 -0
  4. package/dist/index.d.mts +17 -6
  5. package/dist/index.d.ts +17 -6
  6. package/dist/index.js +348 -253
  7. package/dist/index.mjs +325 -230
  8. package/package.json +1 -1
  9. package/src/components/Alert.tsx +303 -303
  10. package/src/components/Avatar.tsx +55 -55
  11. package/src/components/Badge.tsx +132 -132
  12. package/src/components/Box.tsx +3 -3
  13. package/src/components/Button/index.tsx +85 -85
  14. package/src/components/Button/styledComponents.ts +361 -361
  15. package/src/components/ButtonGroup.tsx +484 -484
  16. package/src/components/Calendar/index.tsx +168 -168
  17. package/src/components/Calendar/styledComponents.ts +480 -480
  18. package/src/components/Card.tsx +74 -74
  19. package/src/components/CheckboxGroup.tsx +176 -176
  20. package/src/components/Container.tsx +39 -39
  21. package/src/components/Divider.tsx +7 -7
  22. package/src/components/DoubleCalendar/index.tsx +204 -204
  23. package/src/components/Drawer/index.tsx +113 -113
  24. package/src/components/Drawer/styledComponents.ts +97 -97
  25. package/src/components/Dropdown.tsx +302 -302
  26. package/src/components/Filter.tsx +164 -164
  27. package/src/components/Flex.tsx +130 -130
  28. package/src/components/FormFields/AddressFormFields/CityFormField.tsx +111 -111
  29. package/src/components/FormFields/AddressFormFields/CountryFormField.tsx +33 -33
  30. package/src/components/FormFields/AddressFormFields/PostalCodeFormField.tsx +39 -39
  31. package/src/components/FormFields/AddressFormFields/StateFormField.tsx +32 -32
  32. package/src/components/FormFields/AddressFormFields/index.tsx +141 -141
  33. package/src/components/FormFields/BirthDateFormField.tsx +84 -84
  34. package/src/components/FormFields/CNPJFormField.tsx +87 -87
  35. package/src/components/FormFields/CPFFormField.tsx +78 -78
  36. package/src/components/FormFields/CalendarFormField.tsx +98 -98
  37. package/src/components/FormFields/CheckboxGroupFormField.tsx +91 -91
  38. package/src/components/FormFields/DateAndTimeFormField.tsx +217 -217
  39. package/src/components/FormFields/DoubleCalendarFormField.tsx +96 -96
  40. package/src/components/FormFields/EmailFormField.tsx +27 -27
  41. package/src/components/FormFields/Form.tsx +39 -39
  42. package/src/components/FormFields/IdentityDocumentNumberFormField.tsx +32 -32
  43. package/src/components/FormFields/MultiSelectFormField.tsx +64 -64
  44. package/src/components/FormFields/PhoneFormField.tsx +40 -40
  45. package/src/components/FormFields/RadioGroupFormField.tsx +88 -88
  46. package/src/components/FormFields/RichEditorFormField.tsx +128 -128
  47. package/src/components/FormFields/SelectFormField.tsx +113 -113
  48. package/src/components/FormFields/SwitchFormField.tsx +46 -46
  49. package/src/components/FormFields/TextAreaFormField.tsx +61 -61
  50. package/src/components/FormFields/TextFormField.tsx +112 -112
  51. package/src/components/FormFields/TimePickerFormField.tsx +88 -88
  52. package/src/components/FormFields/subComponents/ErrorFormMessage.tsx +36 -36
  53. package/src/components/FormFields/subComponents/FormLabel.tsx +36 -36
  54. package/src/components/FormFields/utils/validation.ts +23 -23
  55. package/src/components/Grid.tsx +137 -137
  56. package/src/components/Icon.tsx +47 -47
  57. package/src/components/MenuDropdown/index.tsx +38 -38
  58. package/src/components/MenuDropdown/styledComponents.ts +31 -31
  59. package/src/components/Modal.tsx +130 -114
  60. package/src/components/MultiSelect/index.tsx +417 -305
  61. package/src/components/MultiSelect/styledComponents.ts +176 -160
  62. package/src/components/RadioGroup.tsx +210 -210
  63. package/src/components/RichEditor/QuillComponent.tsx +419 -419
  64. package/src/components/RichEditor/RichEditor.tsx +53 -53
  65. package/src/components/RichEditor/RichTextPresenter.tsx +18 -18
  66. package/src/components/RichEditor/editorConfig.ts +149 -149
  67. package/src/components/RichEditor/index.ts +3 -3
  68. package/src/components/RichEditor/styledComponents.ts +1175 -1175
  69. package/src/components/RichEditor/types.ts +12 -12
  70. package/src/components/Section.tsx +33 -33
  71. package/src/components/Step.tsx +164 -164
  72. package/src/components/Switch.tsx +108 -108
  73. package/src/components/Text.tsx +54 -54
  74. package/src/components/TextField.tsx +423 -423
  75. package/src/components/TextareaField.tsx +116 -116
  76. package/src/components/TimePicker.tsx +357 -357
  77. package/src/components/Toast/components/ToastItem.tsx +41 -41
  78. package/src/components/Toast/components/ToastProvider.tsx +63 -63
  79. package/src/components/Toast/hooks/useToast.ts +12 -12
  80. package/src/components/Toast/index.tsx +5 -5
  81. package/src/components/Toast/styles/index.ts +135 -135
  82. package/src/components/Toast/types/index.ts +46 -46
  83. package/src/components/ToggleElement/index.tsx +58 -58
  84. package/src/components/Tooltip/index.tsx +73 -73
  85. package/src/components/Tooltip/styles.ts +77 -77
  86. package/src/hooks/useCountries.ts +41 -41
  87. package/src/hooks/useImageUpload.ts +139 -139
  88. package/src/hooks/useMediaQuery.ts +19 -0
  89. package/src/hooks/useOnClickOutside.tsx +42 -42
  90. package/src/index.tsx +72 -72
  91. package/src/styles/index.ts +41 -41
  92. package/src/types/typographyValues.ts +178 -178
  93. package/src/utils/getNestedValue.ts +3 -3
  94. package/src/utils/states.ts +29 -29
  95. package/src/utils/uploadService.ts +180 -180
  96. package/tsconfig.json +3 -3
  97. package/tsup.config.ts +38 -38
@@ -1,305 +1,417 @@
1
- import React, { useCallback, useRef, useState } from "react";
2
- import { DropdownMenu, Theme } from "@radix-ui/themes";
3
- import { CheckboxGroup, CheckboxItem } from "../CheckboxGroup";
4
- import { Text } from "../Text";
5
- import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
6
- import {
7
- faChevronDown,
8
- faChevronUp,
9
- faSquareXmark,
10
- } from "@fortawesome/free-solid-svg-icons";
11
- import { colors } from "@lets-events/tokens";
12
- import { ComponentProps, useMemo } from "react";
13
- import { Flex } from "../Flex";
14
- import { Button } from "../Button";
15
- import { CloseBtnStyled, ButtonSelectAllStyled, itemStyle, StyledContent, StyledFlexSelectedItems, StyledFlexWithMaxHeight, StyledItem, StyledText, StyledTrigger } from "./styledComponents";
16
-
17
- export type MultiSelectProps = ComponentProps<typeof StyledTrigger> & {
18
- placeholder?: string;
19
- value?: string[];
20
- onValueChange?: (v: string[]) => void;
21
- options: Array<{
22
- label: string;
23
- value: string;
24
- }>;
25
- width?: string;
26
- zIndex?: string;
27
- showSelectedValues?: boolean;
28
- singleSelect?: boolean;
29
- selectedOrientation?: "row" | "column";
30
- disabled?: boolean;
31
- maxHeight?: string;
32
- selectedAllOptions?: boolean;
33
- selectedAllText?: string;
34
- selectedScroll?: boolean;
35
- showMoreButton?: boolean;
36
- showMoreButtonLabel?: string;
37
- showMoreButtonOnClick?: () => void;
38
- };
39
-
40
- export const MultiSelect = React.forwardRef<HTMLDivElement, MultiSelectProps>(
41
- (
42
- {
43
- placeholder,
44
- value: selectedValues = [],
45
- onValueChange,
46
- options,
47
- color,
48
- width = "100%",
49
- zIndex = "auto",
50
- showSelectedValues = true,
51
- singleSelect = false,
52
- selectedOrientation = "column",
53
- disabled = false,
54
- maxHeight,
55
- selectedAllOptions = false,
56
- selectedAllText,
57
- selectedScroll = false,
58
- showMoreButton = false,
59
- showMoreButtonLabel = "Carregar mais",
60
- showMoreButtonOnClick
61
- },
62
- fowardedRef
63
- ) => {
64
- const [isOpen, setIsOpen] = useState(false);
65
- const triggerRef = useRef<HTMLDivElement>(null);
66
- const [allOptionsSelected, setAllOptionsSelected] = useState(false)
67
- const labelByValue = useMemo(() => {
68
- return options.reduce<{ [key: string]: string }>((prev, curr) => {
69
- return {
70
- ...prev,
71
- [curr.value]: curr.label,
72
- };
73
- }, {});
74
- }, [options]);
75
-
76
- const handleRemove = useCallback(
77
- (value: string) => {
78
- const newValue = selectedValues.filter((v) => v !== value);
79
- onValueChange?.(newValue);
80
- },
81
- [selectedValues, onValueChange]
82
- );
83
-
84
- const handleSelectAll = useCallback(
85
- (e: React.MouseEvent) => {
86
- e.preventDefault();
87
- e.stopPropagation();
88
- const allSelected = selectedValues.length === options.length;
89
- if (allSelected) {
90
- onValueChange?.([]);
91
- setAllOptionsSelected(false)
92
- } else {
93
- onValueChange?.(options.map((o) => o.value));
94
- setAllOptionsSelected(true)
95
- }
96
- },
97
- [selectedValues, options, onValueChange]
98
- );
99
-
100
- const text = useMemo(() => {
101
- if (selectedValues.length > 0 && singleSelect) {
102
- const value = selectedValues[0];
103
- return labelByValue[value];
104
- }
105
- return placeholder ?? "Selecione";
106
- }, [selectedValues, placeholder, singleSelect]);
107
-
108
- const handleItemClick = (v: string) => {
109
- onValueChange?.([v]);
110
- setIsOpen(false);
111
- };
112
-
113
- const handleToggle = useCallback(
114
- (e: React.MouseEvent) => {
115
- e.preventDefault();
116
- e.stopPropagation();
117
- if (disabled) return;
118
- setIsOpen((prev) => !prev);
119
- },
120
- [disabled]
121
- );
122
-
123
- return (
124
- <Theme style={width !== "100%" ? { width } : undefined}>
125
- <DropdownMenu.Root open={isOpen} onOpenChange={setIsOpen}>
126
- <DropdownMenu.Trigger>
127
- <StyledTrigger
128
- ref={(r) => {
129
- if (!r) return;
130
- triggerRef.current = r;
131
- if (fowardedRef) {
132
- if (typeof fowardedRef === "function") fowardedRef(r);
133
- else fowardedRef.current = r;
134
- }
135
- }}
136
- color={color}
137
- disabled={disabled}
138
- style={width !== "100%" ? { width } : undefined}
139
- onClick={handleToggle}
140
- >
141
- <StyledText
142
- typography={"labelMedium"}
143
- color={disabled ? "dark400" : undefined}
144
- >
145
- {text}
146
- </StyledText>
147
- <FontAwesomeIcon
148
- icon={isOpen ? faChevronUp : faChevronDown}
149
- size="sm"
150
- color={disabled ? colors.dark400 : colors.dark600}
151
- />
152
- </StyledTrigger>
153
- </DropdownMenu.Trigger>
154
- <StyledContent
155
- css={{
156
- width: "100%",
157
- zIndex: zIndex === "auto" ? 999999 : zIndex,
158
- }}
159
- >
160
- {!singleSelect ? (
161
- <CheckboxGroup
162
- value={selectedValues}
163
- onValueChange={(v) => {
164
- onValueChange?.(v);
165
- setAllOptionsSelected((v || []).length === options.length);
166
- }}
167
- >
168
- <StyledFlexWithMaxHeight
169
- direction={"column"}
170
- gap={8}
171
- hasMaxHeight={!!maxHeight}
172
- style={maxHeight ? { maxHeight } : undefined}
173
- >
174
- {selectedAllOptions && (
175
- <ButtonSelectAllStyled
176
- css={itemStyle}
177
- onClick={(e) => { handleSelectAll(e), setIsOpen(false) }}
178
- type="button"
179
- >
180
- <div className={allOptionsSelected ? "checked" : ""}></div>
181
- <Text typography="labelSmall">
182
- {selectedAllText ? selectedAllText : "Selecionar Todos"}
183
- </Text>
184
- </ButtonSelectAllStyled>
185
- )}
186
-
187
- {options.map(({ value, label }, i) => (
188
- <CheckboxItem value={value} css={itemStyle} key={i}>
189
- <Text typography={"labelSmall"}>{label}</Text>
190
- </CheckboxItem>
191
- ))}
192
- {showMoreButton && showMoreButtonOnClick && (
193
- <Button
194
- variant="menuDropdownItem"
195
- color="brand"
196
- onClick={showMoreButtonOnClick}
197
- fontWeight="semibold"
198
- type="button"
199
- css={{
200
- justifyContent: "flex-start",
201
- color: "var(--colors-brand500)!important",
202
- }}
203
- >
204
- {showMoreButtonLabel}
205
- </Button>
206
- )}
207
- </StyledFlexWithMaxHeight>
208
- </CheckboxGroup>
209
- ) : (
210
- <StyledFlexWithMaxHeight
211
- direction={"column"}
212
- gap={8}
213
- hasMaxHeight={!!maxHeight}
214
- style={maxHeight ? { maxHeight } : undefined}
215
- >
216
- {options.map(({ value, label }, i) => (
217
- <StyledItem key={i} onClick={() => handleItemClick(value)}>
218
- <Text typography={"labelSmall"}>{label}</Text>
219
- </StyledItem>
220
- ))}
221
- {showMoreButton && showMoreButtonOnClick && (
222
- <Button
223
- variant="menuDropdownItem"
224
- color="brand"
225
- onClick={showMoreButtonOnClick}
226
- fontWeight="semibold"
227
- type="button"
228
- css={{
229
- justifyContent: "flex-start",
230
- color: "var(--colors-brand500)!important",
231
- }}
232
- >
233
- {showMoreButtonLabel}
234
- </Button>
235
- )}
236
- </StyledFlexWithMaxHeight>
237
- )}
238
- </StyledContent>
239
- </DropdownMenu.Root>
240
- {selectedValues.length > 0 && showSelectedValues && (
241
- <StyledFlexSelectedItems
242
- direction={selectedOrientation}
243
- gap={8}
244
- align={selectedOrientation === "column" ? "start" : "center"}
245
- justify={"start"}
246
- css={{ ...(selectedScroll && { maxHeight: maxHeight || "400px" }) }}
247
- >
248
- {allOptionsSelected ? (
249
- <Flex
250
- key="all-selected"
251
- gap={4}
252
- align={"center"}
253
- css={{ flexWrap: "wrap" }}
254
- >
255
- <CloseBtnStyled
256
- onClick={(e) => {
257
- e.stopPropagation();
258
- onValueChange?.([]);
259
- setAllOptionsSelected(false);
260
- }}
261
- type="button"
262
- >
263
- <FontAwesomeIcon icon={faSquareXmark} size="sm" />
264
- </CloseBtnStyled>
265
- <Text
266
- typography={"captionMedium"}
267
- fontWeight={"regular"}
268
- color="dark600"
269
- >
270
- {"Todos selecionados"}
271
- </Text>
272
- </Flex>
273
- ) : (
274
- selectedValues.map((value) => (
275
- <Flex
276
- key={value}
277
- gap={4}
278
- align={"center"}
279
- css={{ flexWrap: "wrap" }}
280
- >
281
- <CloseBtnStyled
282
- onClick={(e) => {
283
- e.stopPropagation();
284
- handleRemove(value);
285
- }}
286
- type="button"
287
- >
288
- <FontAwesomeIcon icon={faSquareXmark} size="sm" />
289
- </CloseBtnStyled>
290
- <Text
291
- typography={"captionMedium"}
292
- fontWeight={"regular"}
293
- color="dark600"
294
- >
295
- {labelByValue[value]}
296
- </Text>
297
- </Flex>
298
- ))
299
- )}
300
- </StyledFlexSelectedItems>
301
- )}
302
- </Theme>
303
- );
304
- }
305
- );
1
+ import React, { useCallback, useRef, useState } from "react";
2
+ import { DropdownMenu, Theme } from "@radix-ui/themes";
3
+ import { CheckboxGroup, CheckboxItem } from "../CheckboxGroup";
4
+ import { Text } from "../Text";
5
+ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
6
+ import {
7
+ faChevronDown,
8
+ faChevronUp,
9
+ faSquareXmark,
10
+ } from "@fortawesome/free-solid-svg-icons";
11
+ import { colors } from "@lets-events/tokens";
12
+ import { ComponentProps, useMemo } from "react";
13
+ import { Flex } from "../Flex";
14
+ import { Button } from "../Button";
15
+ import { Modal } from "../Modal";
16
+ import { useMediaQuery } from "../../hooks/useMediaQuery";
17
+ import {
18
+ CloseBtnStyled,
19
+ ButtonSelectAllStyled,
20
+ itemStyle,
21
+ StyledContent,
22
+ StyledFlexSelectedItems,
23
+ StyledFlexWithMaxHeight,
24
+ StyledItem,
25
+ StyledModalOptionsWrapper,
26
+ StyledSectionDivider,
27
+ StyledSectionTitle,
28
+ StyledText,
29
+ StyledTrigger,
30
+ } from "./styledComponents";
31
+
32
+ const MOBILE_MODAL_MAX_HEIGHT = "90vh";
33
+ const MOBILE_MODAL_HEADER_OFFSET = "65px";
34
+
35
+ const MOBILE_BREAKPOINT = "(max-width: 840px)";
36
+
37
+ export type MultiSelectOption = {
38
+ label: string;
39
+ value: string;
40
+ };
41
+
42
+ export type MultiSelectSection = {
43
+ name: string;
44
+ options: MultiSelectOption[];
45
+ };
46
+
47
+ export type MultiSelectProps = ComponentProps<typeof StyledTrigger> & {
48
+ placeholder?: string;
49
+ value?: string[];
50
+ onValueChange?: (v: string[]) => void;
51
+ options?: MultiSelectOption[];
52
+ optionsBySection?: MultiSelectSection[];
53
+ width?: string;
54
+ zIndex?: string;
55
+ showSelectedValues?: boolean;
56
+ singleSelect?: boolean;
57
+ selectedOrientation?: "row" | "column";
58
+ disabled?: boolean;
59
+ maxHeight?: string;
60
+ selectedAllOptions?: boolean;
61
+ selectedAllText?: string;
62
+ selectedScroll?: boolean;
63
+ showMoreButton?: boolean;
64
+ showMoreButtonLabel?: string;
65
+ showMoreButtonOnClick?: () => void;
66
+ helperTextAfterField?: string;
67
+ };
68
+
69
+ export const MultiSelect = React.forwardRef<HTMLDivElement, MultiSelectProps>(
70
+ (
71
+ {
72
+ placeholder,
73
+ value: selectedValues = [],
74
+ onValueChange,
75
+ options = [],
76
+ optionsBySection,
77
+ color,
78
+ width = "100%",
79
+ zIndex = "auto",
80
+ showSelectedValues = true,
81
+ singleSelect = false,
82
+ selectedOrientation = "column",
83
+ disabled = false,
84
+ maxHeight,
85
+ selectedAllOptions = false,
86
+ selectedAllText,
87
+ selectedScroll = false,
88
+ showMoreButton = false,
89
+ showMoreButtonLabel = "Carregar mais",
90
+ showMoreButtonOnClick,
91
+ helperTextAfterField = "",
92
+ },
93
+ fowardedRef
94
+ ) => {
95
+ const [isOpen, setIsOpen] = useState(false);
96
+ const triggerRef = useRef<HTMLDivElement>(null);
97
+ const [allOptionsSelected, setAllOptionsSelected] = useState(false);
98
+ const isMobile = useMediaQuery(MOBILE_BREAKPOINT);
99
+ const hasSections = !!optionsBySection?.length;
100
+
101
+ const resolvedOptions = useMemo((): MultiSelectOption[] => {
102
+ if (hasSections) {
103
+ return optionsBySection!.reduce<MultiSelectOption[]>(
104
+ (acc, section) => acc.concat(section.options),
105
+ []
106
+ );
107
+ }
108
+ return options;
109
+ }, [hasSections, options, optionsBySection]);
110
+
111
+ const labelByValue = useMemo(() => {
112
+ return resolvedOptions.reduce<{ [key: string]: string }>((prev, curr) => {
113
+ return {
114
+ ...prev,
115
+ [curr.value]: curr.label,
116
+ };
117
+ }, {});
118
+ }, [resolvedOptions]);
119
+
120
+ const handleRemove = useCallback(
121
+ (value: string) => {
122
+ const newValue = selectedValues.filter((v) => v !== value);
123
+ onValueChange?.(newValue);
124
+ },
125
+ [selectedValues, onValueChange]
126
+ );
127
+
128
+ const handleSelectAll = useCallback(
129
+ (e: React.MouseEvent) => {
130
+ e.preventDefault();
131
+ e.stopPropagation();
132
+ const allSelected = selectedValues.length === resolvedOptions.length;
133
+ if (allSelected) {
134
+ onValueChange?.([]);
135
+ setAllOptionsSelected(false)
136
+ } else {
137
+ onValueChange?.(resolvedOptions.map((o) => o.value));
138
+ setAllOptionsSelected(true)
139
+ }
140
+ },
141
+ [selectedValues, resolvedOptions, onValueChange]
142
+ );
143
+
144
+ const text = useMemo(() => {
145
+ if (selectedValues.length > 0 && singleSelect) {
146
+ const value = selectedValues[0];
147
+ return labelByValue[value];
148
+ }
149
+ return placeholder ?? "Selecione";
150
+ }, [selectedValues, placeholder, singleSelect, labelByValue]);
151
+
152
+ const handleItemClick = (v: string) => {
153
+ onValueChange?.([v]);
154
+ setIsOpen(false);
155
+ };
156
+
157
+ const handleToggle = useCallback(
158
+ (e: React.MouseEvent) => {
159
+ e.preventDefault();
160
+ e.stopPropagation();
161
+ if (disabled) return;
162
+ setIsOpen((prev) => !prev);
163
+ },
164
+ [disabled]
165
+ );
166
+
167
+ const triggerElement = (
168
+ <StyledTrigger
169
+ ref={(r) => {
170
+ if (!r) return;
171
+ triggerRef.current = r;
172
+ if (fowardedRef) {
173
+ if (typeof fowardedRef === "function") fowardedRef(r);
174
+ else fowardedRef.current = r;
175
+ }
176
+ }}
177
+ color={color}
178
+ disabled={disabled}
179
+ style={width !== "100%" ? { width } : undefined}
180
+ onClick={!isMobile ? handleToggle : undefined}
181
+ >
182
+ <StyledText
183
+ typography={"labelMedium"}
184
+ color={disabled ? "dark400" : undefined}
185
+ >
186
+ {text}
187
+ </StyledText>
188
+ <FontAwesomeIcon
189
+ icon={isOpen ? faChevronUp : faChevronDown}
190
+ size="sm"
191
+ color={disabled ? colors.dark400 : colors.dark600}
192
+ />
193
+ </StyledTrigger>
194
+ );
195
+
196
+ const selectAllBlock = selectedAllOptions && (
197
+ <>
198
+ <ButtonSelectAllStyled
199
+ css={itemStyle}
200
+ onClick={(e) => {
201
+ handleSelectAll(e);
202
+ setIsOpen(false);
203
+ }}
204
+ type="button"
205
+ >
206
+ <div className={allOptionsSelected ? "checked" : ""}></div>
207
+ <Text typography="labelSmall">
208
+ {selectedAllText ? selectedAllText : "Selecionar Todos"}
209
+ </Text>
210
+ </ButtonSelectAllStyled>
211
+ <StyledSectionDivider />
212
+ </>
213
+ );
214
+
215
+ const showMoreButtonBlock = showMoreButton && showMoreButtonOnClick && (
216
+ <Button
217
+ variant="menuDropdownItem"
218
+ color="brand"
219
+ onClick={showMoreButtonOnClick}
220
+ fontWeight="semibold"
221
+ type="button"
222
+ css={{
223
+ justifyContent: "flex-start",
224
+ color: "var(--colors-brand500)!important",
225
+ }}
226
+ >
227
+ {showMoreButtonLabel}
228
+ </Button>
229
+ );
230
+
231
+ const renderCheckboxOptions = () => {
232
+ if (hasSections) {
233
+ return optionsBySection!.map((section, sectionIndex) => (
234
+ <React.Fragment key={section.name}>
235
+ {sectionIndex > 0 && <StyledSectionDivider />}
236
+ <StyledSectionTitle typography="labelSmall" fontWeight="semibold" color="dark600">
237
+ {section.name}
238
+ </StyledSectionTitle>
239
+ {section.options.map(({ value, label }, i) => (
240
+ <CheckboxItem value={value} css={itemStyle} key={`${section.name}-${i}`}>
241
+ <Text typography={"labelSmall"}>{label}</Text>
242
+ </CheckboxItem>
243
+ ))}
244
+ </React.Fragment>
245
+ ));
246
+ }
247
+
248
+ return resolvedOptions.map(({ value, label }, i) => (
249
+ <CheckboxItem value={value} css={itemStyle} key={i}>
250
+ <Text typography={"labelSmall"}>{label}</Text>
251
+ </CheckboxItem>
252
+ ));
253
+ };
254
+
255
+ const renderSingleSelectOptions = () => {
256
+ if (hasSections) {
257
+ return optionsBySection!.map((section, sectionIndex) => (
258
+ <React.Fragment key={section.name}>
259
+ {sectionIndex > 0 && <StyledSectionDivider />}
260
+ <StyledSectionTitle typography="labelSmall" fontWeight="semibold" color="dark600">
261
+ {section.name}
262
+ </StyledSectionTitle>
263
+ {section.options.map(({ value, label }, i) => (
264
+ <StyledItem key={`${section.name}-${i}`} onClick={() => handleItemClick(value)}>
265
+ <Text typography={"labelSmall"}>{label}</Text>
266
+ </StyledItem>
267
+ ))}
268
+ </React.Fragment>
269
+ ));
270
+ }
271
+
272
+ return resolvedOptions.map(({ value, label }, i) => (
273
+ <StyledItem key={i} onClick={() => handleItemClick(value)}>
274
+ <Text typography={"labelSmall"}>{label}</Text>
275
+ </StyledItem>
276
+ ));
277
+ };
278
+
279
+ const optionsContent = !singleSelect ? (
280
+ <CheckboxGroup
281
+ value={selectedValues}
282
+ onValueChange={(v) => {
283
+ onValueChange?.(v);
284
+ setAllOptionsSelected((v || []).length === resolvedOptions.length);
285
+ }}
286
+ >
287
+ <StyledFlexWithMaxHeight
288
+ direction={"column"}
289
+ gap={8}
290
+ hasMaxHeight={!!maxHeight && !isMobile}
291
+ style={maxHeight && !isMobile ? { maxHeight } : undefined}
292
+ >
293
+ {selectAllBlock}
294
+ {renderCheckboxOptions()}
295
+ {showMoreButtonBlock}
296
+ </StyledFlexWithMaxHeight>
297
+ </CheckboxGroup>
298
+ ) : (
299
+ <StyledFlexWithMaxHeight
300
+ direction={"column"}
301
+ gap={8}
302
+ hasMaxHeight={!!maxHeight && !isMobile}
303
+ style={maxHeight && !isMobile ? { maxHeight } : undefined}
304
+ >
305
+ {renderSingleSelectOptions()}
306
+ {showMoreButtonBlock}
307
+ </StyledFlexWithMaxHeight>
308
+ );
309
+
310
+ const modalZIndex =
311
+ zIndex === "auto" ? undefined : Number(zIndex);
312
+
313
+ return (
314
+ <Theme style={width !== "100%" ? { width } : undefined}>
315
+ {isMobile ? (
316
+ <Modal
317
+ open={disabled ? false : isOpen}
318
+ onOpenChange={(open) => !disabled && setIsOpen(open)}
319
+ trigger={triggerElement}
320
+ title={placeholder ?? "Selecione"}
321
+ maxHeight={MOBILE_MODAL_MAX_HEIGHT}
322
+ zIndex={modalZIndex}
323
+ preventAutoFocus
324
+ fitContent
325
+ >
326
+ <StyledModalOptionsWrapper
327
+ css={{ maxHeight: `calc(${MOBILE_MODAL_MAX_HEIGHT} - ${MOBILE_MODAL_HEADER_OFFSET})` }}
328
+ >
329
+ {optionsContent}
330
+ </StyledModalOptionsWrapper>
331
+ </Modal>
332
+ ) : (
333
+ <DropdownMenu.Root open={isOpen} onOpenChange={setIsOpen}>
334
+ <DropdownMenu.Trigger>{triggerElement}</DropdownMenu.Trigger>
335
+ <StyledContent
336
+ css={{
337
+ width: "100%",
338
+ zIndex: zIndex === "auto" ? 999999 : zIndex,
339
+ }}
340
+ >
341
+ {optionsContent}
342
+ </StyledContent>
343
+ </DropdownMenu.Root>
344
+ )}
345
+ <div style={{ padding: '4px 8px 0 0' }}>
346
+ {helperTextAfterField && (
347
+ <Text typography="captionMedium" fontWeight="regular" color="dark600">
348
+ {helperTextAfterField}
349
+ </Text>
350
+ )}
351
+ {selectedValues.length > 0 && showSelectedValues && (
352
+ <StyledFlexSelectedItems
353
+ direction={selectedOrientation}
354
+ gap={8}
355
+ align={selectedOrientation === "column" ? "start" : "center"}
356
+ justify={"start"}
357
+ css={{ ...(selectedScroll && { maxHeight: maxHeight || "400px" }) }}
358
+ >
359
+ {allOptionsSelected ? (
360
+ <Flex
361
+ key="all-selected"
362
+ gap={4}
363
+ align={"center"}
364
+ css={{ flexWrap: "wrap" }}
365
+ >
366
+ <CloseBtnStyled
367
+ onClick={(e) => {
368
+ e.stopPropagation();
369
+ onValueChange?.([]);
370
+ setAllOptionsSelected(false);
371
+ }}
372
+ type="button"
373
+ >
374
+ <FontAwesomeIcon icon={faSquareXmark} size="sm" />
375
+ </CloseBtnStyled>
376
+ <Text
377
+ typography={"captionMedium"}
378
+ fontWeight={"regular"}
379
+ color="dark600"
380
+ >
381
+ {"Todos selecionados"}
382
+ </Text>
383
+ </Flex>
384
+ ) : (
385
+ selectedValues.map((value) => (
386
+ <Flex
387
+ key={value}
388
+ gap={4}
389
+ align={"center"}
390
+ css={{ flexWrap: "wrap" }}
391
+ >
392
+ <CloseBtnStyled
393
+ onClick={(e) => {
394
+ e.stopPropagation();
395
+ handleRemove(value);
396
+ }}
397
+ type="button"
398
+ >
399
+ <FontAwesomeIcon icon={faSquareXmark} size="sm" />
400
+ </CloseBtnStyled>
401
+ <Text
402
+ typography={"captionMedium"}
403
+ fontWeight={"regular"}
404
+ color="dark600"
405
+ >
406
+ {labelByValue[value]}
407
+ </Text>
408
+ </Flex>
409
+ ))
410
+ )}
411
+ </StyledFlexSelectedItems>
412
+ )}
413
+ </div>
414
+ </Theme>
415
+ );
416
+ }
417
+ );