@granto-umbrella/umbrella-components 3.0.34 → 3.0.36
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 +165 -27
- package/dist/umbrella-components.css +1 -1
- package/dist/umbrella-components.es.js +28129 -29249
- package/dist/umbrella-components.umd.js +1234 -2181
- package/package.json +135 -106
- package/src/assets.d.ts +19 -19
- package/src/components/atoms/Badge/Badge.styles.ts +88 -86
- package/src/components/atoms/Badge/Badge.tsx +42 -44
- package/src/components/atoms/Badge/Badge.types.ts +15 -15
- package/src/components/atoms/Breadcrumb/Breadcrumb.styles.ts +43 -43
- package/src/components/atoms/Breadcrumb/Breadcrumb.tsx +46 -48
- package/src/components/atoms/Breadcrumb/Breadcrumb.types.ts +12 -12
- package/src/components/atoms/Button/Button.styles.ts +279 -280
- package/src/components/atoms/Button/Button.tsx +76 -76
- package/src/components/atoms/Button/Button.types.ts +28 -28
- package/src/components/atoms/Button/index.ts +1 -1
- package/src/components/atoms/Checkbox/Checkbox.styles.ts +72 -72
- package/src/components/atoms/Checkbox/Checkbox.tsx +36 -36
- package/src/components/atoms/Checkbox/Checkbox.types.ts +14 -14
- package/src/components/atoms/Checkbox/CheckboxGroup.tsx +30 -30
- package/src/components/atoms/Checkbox/CheckboxSelectAll.tsx +32 -32
- package/src/components/atoms/CodeInput/CodeInput.styles.tsx +38 -39
- package/src/components/atoms/CodeInput/CodeInput.tsx +13 -19
- package/src/components/atoms/CodeInput/CodeInput.types.ts +3 -3
- package/src/components/atoms/CodeInput/index.tsx +1 -1
- package/src/components/atoms/DropDownMenu/DropdownMenu.tsx +48 -48
- package/src/components/atoms/DropDownMenu/DropdownMenu.types.ts +15 -15
- package/src/components/atoms/DropDownMenu/index.tsx +5 -2
- package/src/components/atoms/ErrorMessage/ErrorMessage.styles.tsx +28 -28
- package/src/components/atoms/ErrorMessage/ErrorMessage.tsx +12 -12
- package/src/components/atoms/ErrorMessage/ErrorMessage.types.ts +6 -6
- package/src/components/atoms/ErrorMessage/index.tsx +1 -1
- package/src/components/atoms/Footer/Footer.styles.tsx +22 -22
- package/src/components/atoms/Footer/Footer.tsx +9 -9
- package/src/components/atoms/Footer/Footer.types.tsx +5 -5
- package/src/components/atoms/Footer/index.tsx +1 -1
- package/src/components/atoms/GenericContainer/GenericContainer.styles.tsx +21 -21
- package/src/components/atoms/GenericContainer/GenericContainer.tsx +9 -9
- package/src/components/atoms/GenericContainer/GenericContainer.types.ts +5 -5
- package/src/components/atoms/GenericContainer/index.tsx +1 -1
- package/src/components/atoms/Icon/Icon.styles.ts +11 -11
- package/src/components/atoms/Icon/Icon.tsx +22 -22
- package/src/components/atoms/Icon/Icon.types.ts +6 -6
- package/src/components/atoms/Icon/index.ts +1 -1
- package/src/components/atoms/Input/Input.styles.ts +106 -101
- package/src/components/atoms/Input/index.ts +1 -1
- package/src/components/atoms/Label/Label.tsx +16 -16
- package/src/components/atoms/Loading/Loading.styles.tsx +25 -25
- package/src/components/atoms/Loading/Loading.tsx +8 -8
- package/src/components/atoms/LogoContainer/LogoContainer.Types.tsx +5 -5
- package/src/components/atoms/LogoContainer/LogoContainer.styles.tsx +11 -11
- package/src/components/atoms/LogoContainer/LogoContainer.tsx +11 -11
- package/src/components/atoms/LogoContainer/index.tsx +1 -1
- package/src/components/atoms/ModalAviso/ModalAviso.styles.tsx +56 -56
- package/src/components/atoms/ModalAviso/ModalAviso.tsx +43 -37
- package/src/components/atoms/ModalAviso/ModalAviso.types.ts +5 -5
- package/src/components/atoms/ModalAviso/index.tsx +1 -1
- package/src/components/atoms/MultiSelect/MultiSelect.styles.tsx +100 -92
- package/src/components/atoms/MultiSelect/MultiSelect.tsx +346 -346
- package/src/components/atoms/MultiSelect/MultiSelect.types.ts +38 -38
- package/src/components/atoms/Pill/Pill.styles.ts +46 -46
- package/src/components/atoms/Pill/Pill.tsx +35 -36
- package/src/components/atoms/Pill/Pill.types.ts +14 -18
- package/src/components/atoms/RadioButton/RadioButton.styles.ts +44 -43
- package/src/components/atoms/RadioButton/RadioButton.tsx +31 -31
- package/src/components/atoms/ResendLink/ResendLink.styles.tsx +19 -20
- package/src/components/atoms/ResendLink/ResendLink.tsx +21 -21
- package/src/components/atoms/ResendLink/ResendLink.types.ts +8 -9
- package/src/components/atoms/ResendLink/index.tsx +1 -2
- package/src/components/atoms/Select/Select.styles.ts +153 -149
- package/src/components/atoms/Select/Select.tsx +52 -43
- package/src/components/atoms/Select/index.tsx +1 -1
- package/src/components/atoms/Subtitle/Subtitle.tsx +7 -7
- package/src/components/atoms/Subtitle/Subtitle.types.ts +5 -5
- package/src/components/atoms/Subtitle/index.tsx +1 -1
- package/src/components/atoms/Switch/Switch.tsx +25 -25
- package/src/components/atoms/TabBar/TabBar.styles.tsx +64 -57
- package/src/components/atoms/TabBar/index.tsx +2 -2
- package/src/components/atoms/Text/Text.styles.tsx +35 -35
- package/src/components/atoms/Text/Text.tsx +32 -31
- package/src/components/atoms/Text/Text.types.ts +8 -8
- package/src/components/atoms/Text/index.ts +1 -1
- package/src/components/atoms/Textarea/Textarea.styles.ts +52 -52
- package/src/components/atoms/Textarea/Textarea.tsx +31 -31
- package/src/components/atoms/Title/Title.tsx +7 -7
- package/src/components/atoms/Title/Title.types.ts +5 -5
- package/src/components/atoms/Title/index.tsx +1 -1
- package/src/components/molecules/BannerAjuda/BannerAjuda.styles.tsx +9 -9
- package/src/components/molecules/BannerAjuda/BannerAjuda.tsx +18 -19
- package/src/components/molecules/BannerAjuda/index.tsx +1 -1
- package/src/components/molecules/ButtonGroup/ButtonGroup.styles.ts +10 -10
- package/src/components/molecules/ButtonGroup/ButtonGroup.types.ts +22 -22
- package/src/components/molecules/Calendar/Calendar.styles.ts +143 -143
- package/src/components/molecules/Calendar/Calendar.tsx +31 -31
- package/src/components/molecules/CodeInputContainer/CodeInputContainer.styles.tsx +7 -7
- package/src/components/molecules/CodeInputContainer/CodeInputContainer.types.ts +13 -13
- package/src/components/molecules/CodeInputContainer/index.tsx +1 -3
- package/src/components/molecules/ExcludeModal/ExcludeModal.styles.tsx +123 -118
- package/src/components/molecules/ExcludeModal/ExcludeModal.tsx +48 -48
- package/src/components/molecules/ExcludeModal/ExcludeModal.types.ts +10 -10
- package/src/components/molecules/ExcludeModal/index.tsx +1 -1
- package/src/components/molecules/FieldSelector/FieldSelector.styles.ts +59 -0
- package/src/components/molecules/FieldSelector/FieldSelector.tsx +167 -0
- package/src/components/molecules/HighlightsCard/HighlightsCard.styles.tsx +67 -68
- package/src/components/molecules/HighlightsCard/HighlightsCard.tsx +35 -26
- package/src/components/molecules/HighlightsCard/HighlightsCard.types.ts +10 -10
- package/src/components/molecules/HighlightsCard/index.tsx +1 -1
- package/src/components/molecules/InsuranceCard/InsuranceCard.styles.tsx +237 -237
- package/src/components/molecules/InsuranceCard/index.tsx +1 -1
- package/src/components/molecules/PieChartComponent/PieChartComponent.styles.tsx +7 -8
- package/src/components/molecules/PieChartComponent/PieChartComponent.tsx +70 -73
- package/src/components/molecules/PieChartComponent/PieChartComponent.types.ts +11 -11
- package/src/components/molecules/PieChartComponent/index.tsx +1 -1
- package/src/components/molecules/Popover/Popover.styles.ts +66 -65
- package/src/components/molecules/Popover/Popover.tsx +23 -23
- package/src/components/molecules/RadioBoxGroup/RadioBoxGroup.styles.ts +11 -11
- package/src/components/molecules/RadioBoxGroup/RadioBoxGroup.tsx +43 -43
- package/src/components/molecules/RadioGroupField/RadioGroupField.styles.tsx +65 -64
- package/src/components/molecules/RadioGroupField/RadioGroupField.tsx +69 -69
- package/src/components/molecules/RadioGroupField/RadioGroupField.types.ts +17 -17
- package/src/components/molecules/RadioGroupField/index.tsx +1 -1
- package/src/components/molecules/RefuseModal/RefuseModal.styles.tsx +139 -139
- package/src/components/molecules/RefuseModal/RefuseModal.tsx +92 -76
- package/src/components/molecules/RefuseModal/RefuseModal.types.ts +15 -15
- package/src/components/molecules/RefuseModal/index.tsx +2 -2
- package/src/components/molecules/ResultsChart/ResultsChart.tsx +23 -19
- package/src/components/molecules/ResultsChart/ResultsChart.types.ts +3 -3
- package/src/components/molecules/ResultsChart/index.tsx +2 -2
- package/src/components/molecules/TabToggle/TabToggle.styles.ts +54 -54
- package/src/components/molecules/TabToggle/TabToggle.tsx +35 -35
- package/src/components/organisms/AlertDialog/AlertDialog.styles.tsx +61 -61
- package/src/components/organisms/AlertDialog/AlertDialog.tsx +70 -70
- package/src/components/organisms/Dialog/Dialog.styles.ts +107 -106
- package/src/components/organisms/Dialog/Dialog.tsx +69 -69
- package/src/components/organisms/DonutEmissionsChart/DonutEmissionsChart.styles.tsx +113 -113
- package/src/components/organisms/DonutEmissionsChart/DonutEmissionsChart.tsx +75 -71
- package/src/components/organisms/DonutEmissionsChart/DonutEmissionsChart.types.ts +9 -9
- package/src/components/organisms/DonutEmissionsChart/index.tsx +5 -2
- package/src/components/organisms/Form/Form.styles.ts +35 -35
- package/src/components/organisms/Form/Form.tsx +160 -160
- package/src/components/organisms/ListagemUltimasEmissoes/ListagemUltimasEmissoes.styles.tsx +115 -114
- package/src/components/organisms/ListagemUltimasEmissoes/ListagemUltimasEmissoes.tsx +89 -89
- package/src/components/organisms/ListagemUltimasEmissoes/ListagemUltimasEmissoes.types.ts +16 -16
- package/src/components/organisms/ListagemUltimasEmissoes/index.tsx +1 -1
- package/src/components/organisms/Navbar/Navbar.styles.tsx +243 -243
- package/src/global.d.ts +9 -9
- package/src/index.ts +2 -0
- package/src/lib/utils.ts +6 -6
- package/src/styles/tokens/borders.ts +17 -17
- package/src/styles/tokens/index.tsx +6 -6
- package/src/styles/tokens/radius.ts +22 -22
- package/src/styles/tokens/shadows.ts +22 -22
- package/src/styles/tokens/sizes.ts +60 -64
- package/src/types/radius.types.ts +1 -1
- package/src/types/shadows.types.ts +1 -1
- package/src/utils/renderHighlightsCard.tsx +21 -0
|
@@ -1,346 +1,346 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
4
|
-
import type React from 'react';
|
|
5
|
-
import Select, {
|
|
6
|
-
type StylesConfig,
|
|
7
|
-
components,
|
|
8
|
-
type GroupBase,
|
|
9
|
-
type MultiValue as ReactSelectMultiValue,
|
|
10
|
-
type SingleValue,
|
|
11
|
-
type ActionMeta,
|
|
12
|
-
} from 'react-select';
|
|
13
|
-
import { WarningCircle } from '@phosphor-icons/react';
|
|
14
|
-
import {
|
|
15
|
-
Container,
|
|
16
|
-
Label,
|
|
17
|
-
Icon,
|
|
18
|
-
Error,
|
|
19
|
-
SelectWrapper,
|
|
20
|
-
} from './MultiSelect.styles';
|
|
21
|
-
import {
|
|
22
|
-
semanticColors,
|
|
23
|
-
semanticRadius,
|
|
24
|
-
typographyTokens,
|
|
25
|
-
} from '../../../styles/tokens';
|
|
26
|
-
import type {
|
|
27
|
-
IStyledBaseProps,
|
|
28
|
-
SelectProps,
|
|
29
|
-
SelectOption,
|
|
30
|
-
} from './MultiSelect.types';
|
|
31
|
-
|
|
32
|
-
const StyledBase: React.FC<IStyledBaseProps> = ({
|
|
33
|
-
children,
|
|
34
|
-
label,
|
|
35
|
-
error,
|
|
36
|
-
errorMessage,
|
|
37
|
-
labelSize,
|
|
38
|
-
labelWeight,
|
|
39
|
-
icon,
|
|
40
|
-
sizeDisplay,
|
|
41
|
-
height,
|
|
42
|
-
}) => {
|
|
43
|
-
return (
|
|
44
|
-
<Container $sizeDisplay={sizeDisplay} height={height}>
|
|
45
|
-
<div>
|
|
46
|
-
{label && (
|
|
47
|
-
<Label fontSize={labelSize} fontWeight={labelWeight}>
|
|
48
|
-
{label}
|
|
49
|
-
</Label>
|
|
50
|
-
)}
|
|
51
|
-
<SelectWrapper>
|
|
52
|
-
{children}
|
|
53
|
-
{icon && <Icon $error={error}>{icon}</Icon>}
|
|
54
|
-
</SelectWrapper>
|
|
55
|
-
{error && errorMessage && (
|
|
56
|
-
<Error>
|
|
57
|
-
<WarningCircle size={14} /> {errorMessage}
|
|
58
|
-
</Error>
|
|
59
|
-
)}
|
|
60
|
-
</div>
|
|
61
|
-
</Container>
|
|
62
|
-
);
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
const NoOptionsMessage = (props: any) => (
|
|
66
|
-
<components.NoOptionsMessage {...props}>
|
|
67
|
-
<span>Sem dados</span>
|
|
68
|
-
</components.NoOptionsMessage>
|
|
69
|
-
);
|
|
70
|
-
|
|
71
|
-
const CustomMultiValue = (props: any) => (
|
|
72
|
-
<components.MultiValue {...props}>
|
|
73
|
-
<Custom {...props} />
|
|
74
|
-
</components.MultiValue>
|
|
75
|
-
);
|
|
76
|
-
|
|
77
|
-
const Option = (props: any) => (
|
|
78
|
-
<components.Option {...props}>
|
|
79
|
-
<Custom {...props} />
|
|
80
|
-
</components.Option>
|
|
81
|
-
);
|
|
82
|
-
|
|
83
|
-
const Custom = (props: any) => (
|
|
84
|
-
<div style={{ display: 'flex', alignItems: 'center' }}>
|
|
85
|
-
{'picture' in props.data &&
|
|
86
|
-
(props.data.picture ? (
|
|
87
|
-
<img
|
|
88
|
-
src={props.data.picture || '/placeholder.svg'}
|
|
89
|
-
alt={props.data.name || props.data.label}
|
|
90
|
-
style={{
|
|
91
|
-
width: '16px',
|
|
92
|
-
height: '16px',
|
|
93
|
-
borderRadius: '50%',
|
|
94
|
-
marginRight: '8px',
|
|
95
|
-
objectFit: 'cover',
|
|
96
|
-
}}
|
|
97
|
-
/>
|
|
98
|
-
) : (
|
|
99
|
-
<div
|
|
100
|
-
style={{
|
|
101
|
-
width: '16px',
|
|
102
|
-
height: '16px',
|
|
103
|
-
borderRadius: '50%',
|
|
104
|
-
backgroundColor: semanticColors.base.text,
|
|
105
|
-
color: semanticColors.base.background,
|
|
106
|
-
fontSize: '10px',
|
|
107
|
-
display: 'flex',
|
|
108
|
-
marginRight: '8px',
|
|
109
|
-
alignItems: 'center',
|
|
110
|
-
justifyContent: 'center',
|
|
111
|
-
flexShrink: 0,
|
|
112
|
-
}}
|
|
113
|
-
>
|
|
114
|
-
{(props.data.label as string).charAt(0).toUpperCase()}
|
|
115
|
-
</div>
|
|
116
|
-
))}
|
|
117
|
-
<span
|
|
118
|
-
style={{
|
|
119
|
-
fontSize: typographyTokens.fontSizes.bodyS,
|
|
120
|
-
lineHeight: '1.4',
|
|
121
|
-
color: 'inherit',
|
|
122
|
-
}}
|
|
123
|
-
>
|
|
124
|
-
{props.data.label}
|
|
125
|
-
</span>
|
|
126
|
-
</div>
|
|
127
|
-
);
|
|
128
|
-
|
|
129
|
-
const MultiSelect: React.FC<SelectProps> = ({
|
|
130
|
-
options,
|
|
131
|
-
placeholder,
|
|
132
|
-
height = '40px',
|
|
133
|
-
enabledClear = true,
|
|
134
|
-
multiple,
|
|
135
|
-
value,
|
|
136
|
-
disabled,
|
|
137
|
-
menuPlacement = 'auto',
|
|
138
|
-
defaultValue,
|
|
139
|
-
setValue,
|
|
140
|
-
...props
|
|
141
|
-
}) => {
|
|
142
|
-
const styles: StylesConfig<SelectOption, boolean, GroupBase<SelectOption>> = {
|
|
143
|
-
indicatorSeparator: (base: any) => ({ ...base, display: 'none' }),
|
|
144
|
-
container: (base: any) => ({
|
|
145
|
-
...base,
|
|
146
|
-
width: '100%',
|
|
147
|
-
border: 'none',
|
|
148
|
-
position: 'relative',
|
|
149
|
-
}),
|
|
150
|
-
control: (base: any, state: any) => ({
|
|
151
|
-
...base,
|
|
152
|
-
minHeight: `${height}`,
|
|
153
|
-
backgroundColor: semanticColors.base.background,
|
|
154
|
-
padding: '2px 8px',
|
|
155
|
-
borderRadius: semanticRadius.global.radius.md,
|
|
156
|
-
borderColor: state.isFocused
|
|
157
|
-
? semanticColors.branding.border.enabled
|
|
158
|
-
: semanticColors.global.border.default,
|
|
159
|
-
':hover': {
|
|
160
|
-
borderColor: semanticColors.branding.border.hover,
|
|
161
|
-
},
|
|
162
|
-
boxShadow: state.isFocused
|
|
163
|
-
? `0 0 0 1px ${semanticColors.branding.border.enabled}`
|
|
164
|
-
: 'none',
|
|
165
|
-
cursor: disabled ? 'not-allowed' : 'pointer',
|
|
166
|
-
opacity: disabled ? 0.6 : 1,
|
|
167
|
-
}),
|
|
168
|
-
dropdownIndicator: (baseStyles: any) => ({
|
|
169
|
-
...baseStyles,
|
|
170
|
-
color: semanticColors.branding.surface.enabled,
|
|
171
|
-
padding: '8px',
|
|
172
|
-
':hover': {
|
|
173
|
-
color: semanticColors.branding.surface.hover,
|
|
174
|
-
},
|
|
175
|
-
}),
|
|
176
|
-
clearIndicator: (baseStyles: any) => ({
|
|
177
|
-
...baseStyles,
|
|
178
|
-
color: semanticColors.neutral[400],
|
|
179
|
-
padding: '8px',
|
|
180
|
-
':hover': {
|
|
181
|
-
color: semanticColors.danger.text.enabled,
|
|
182
|
-
},
|
|
183
|
-
}),
|
|
184
|
-
indicatorsContainer: (base: any) => ({
|
|
185
|
-
...base,
|
|
186
|
-
alignItems: 'center',
|
|
187
|
-
}),
|
|
188
|
-
option: (baseStyle: any, state: any) => ({
|
|
189
|
-
...baseStyle,
|
|
190
|
-
color: state.isSelected
|
|
191
|
-
? semanticColors.branding.text.onSurfaceAccent.enabled
|
|
192
|
-
: semanticColors.base.text,
|
|
193
|
-
backgroundColor: state.isSelected
|
|
194
|
-
? semanticColors.branding.surface.enabled
|
|
195
|
-
: state.isFocused
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
cursor: 'pointer',
|
|
199
|
-
padding: '12px 16px',
|
|
200
|
-
':active': {
|
|
201
|
-
backgroundColor: state.isSelected
|
|
202
|
-
? semanticColors.branding.surface.pressed
|
|
203
|
-
: semanticColors.neutral[200],
|
|
204
|
-
},
|
|
205
|
-
}),
|
|
206
|
-
placeholder: (base: any) => ({
|
|
207
|
-
...base,
|
|
208
|
-
fontSize: typographyTokens.fontSizes.bodyS,
|
|
209
|
-
fontWeight: typographyTokens.fontWeights.regular,
|
|
210
|
-
color: semanticColors.neutral[400],
|
|
211
|
-
margin: 0,
|
|
212
|
-
}),
|
|
213
|
-
singleValue: (base: any) => ({
|
|
214
|
-
...base,
|
|
215
|
-
fontSize: typographyTokens.fontSizes.bodyS,
|
|
216
|
-
color: semanticColors.base.text,
|
|
217
|
-
margin: 0,
|
|
218
|
-
}),
|
|
219
|
-
multiValue: (base: any, state: any) => ({
|
|
220
|
-
...base,
|
|
221
|
-
borderRadius: semanticRadius.global.radius.full,
|
|
222
|
-
border: `1px solid ${semanticColors.global.border.default}`,
|
|
223
|
-
backgroundColor: state.data.isFixed
|
|
224
|
-
? semanticColors.global.surface.disabled
|
|
225
|
-
: semanticColors.base.background,
|
|
226
|
-
margin: '2px',
|
|
227
|
-
display: 'inline-flex',
|
|
228
|
-
alignItems: 'center',
|
|
229
|
-
padding: '0 4px',
|
|
230
|
-
}),
|
|
231
|
-
multiValueLabel: (base: any) => ({
|
|
232
|
-
...base,
|
|
233
|
-
display: 'flex',
|
|
234
|
-
alignItems: 'center',
|
|
235
|
-
padding: '0 6px',
|
|
236
|
-
fontWeight: typographyTokens.fontWeights.regular,
|
|
237
|
-
fontSize: typographyTokens.fontSizes.captionM,
|
|
238
|
-
color: semanticColors.base.text,
|
|
239
|
-
}),
|
|
240
|
-
multiValueRemove: (base: any, state: any) => {
|
|
241
|
-
return state.data.isFixed
|
|
242
|
-
? { ...base, display: 'none' }
|
|
243
|
-
: {
|
|
244
|
-
...base,
|
|
245
|
-
display: 'flex',
|
|
246
|
-
alignItems: 'center',
|
|
247
|
-
justifyContent: 'center',
|
|
248
|
-
marginLeft: '2px',
|
|
249
|
-
padding: '0',
|
|
250
|
-
color: semanticColors.neutral[400],
|
|
251
|
-
cursor: 'pointer',
|
|
252
|
-
':hover': {
|
|
253
|
-
backgroundColor: semanticColors.danger.surface.enabled,
|
|
254
|
-
color: semanticColors.danger.text.onSurface,
|
|
255
|
-
},
|
|
256
|
-
};
|
|
257
|
-
},
|
|
258
|
-
|
|
259
|
-
valueContainer: (base: any) => ({
|
|
260
|
-
...base,
|
|
261
|
-
padding: '2px 8px',
|
|
262
|
-
gap: '4px',
|
|
263
|
-
flexWrap: 'wrap',
|
|
264
|
-
}),
|
|
265
|
-
input: (base: any) => ({
|
|
266
|
-
...base,
|
|
267
|
-
margin: 0,
|
|
268
|
-
padding: 0,
|
|
269
|
-
fontSize: typographyTokens.fontSizes.bodyS,
|
|
270
|
-
}),
|
|
271
|
-
menuList: (base: any) => ({
|
|
272
|
-
...base,
|
|
273
|
-
padding: 0,
|
|
274
|
-
'::-webkit-scrollbar': {
|
|
275
|
-
width: '6px',
|
|
276
|
-
},
|
|
277
|
-
'::-webkit-scrollbar-track': {
|
|
278
|
-
background: semanticColors.neutral[200],
|
|
279
|
-
},
|
|
280
|
-
'::-webkit-scrollbar-thumb': {
|
|
281
|
-
background: semanticColors.branding.surface.enabled,
|
|
282
|
-
borderRadius: '20px',
|
|
283
|
-
},
|
|
284
|
-
'::-webkit-scrollbar-thumb:hover': {
|
|
285
|
-
background: semanticColors.branding.surface.hover,
|
|
286
|
-
},
|
|
287
|
-
}),
|
|
288
|
-
menu: (base: any) => ({
|
|
289
|
-
...base,
|
|
290
|
-
borderRadius: semanticRadius.global.radius.md,
|
|
291
|
-
boxShadow:
|
|
292
|
-
'0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)',
|
|
293
|
-
border: `1px solid ${semanticColors.global.border.default}`,
|
|
294
|
-
overflow: 'hidden',
|
|
295
|
-
}),
|
|
296
|
-
};
|
|
297
|
-
|
|
298
|
-
const handleChange = (
|
|
299
|
-
newValue: ReactSelectMultiValue<SelectOption> | SingleValue<SelectOption>,
|
|
300
|
-
actionMeta: ActionMeta<SelectOption>
|
|
301
|
-
) => {
|
|
302
|
-
if (setValue) {
|
|
303
|
-
setValue(newValue, actionMeta);
|
|
304
|
-
}
|
|
305
|
-
};
|
|
306
|
-
|
|
307
|
-
return (
|
|
308
|
-
<StyledBase height={'fit-content'} {...props}>
|
|
309
|
-
<Select<SelectOption, boolean, GroupBase<SelectOption>>
|
|
310
|
-
theme={(selectTheme) => ({
|
|
311
|
-
...selectTheme,
|
|
312
|
-
colors: {
|
|
313
|
-
...selectTheme.colors,
|
|
314
|
-
primary: semanticColors.branding.surface.enabled,
|
|
315
|
-
primary75: semanticColors.branding.surface.hover,
|
|
316
|
-
primary50: semanticColors.branding.surface.disabled,
|
|
317
|
-
primary25: semanticColors.neutral[100],
|
|
318
|
-
},
|
|
319
|
-
spacing: {
|
|
320
|
-
baseUnit: 4,
|
|
321
|
-
menuGutter: 8,
|
|
322
|
-
controlHeight: parseInt(height.replace('px', '')) || 40,
|
|
323
|
-
},
|
|
324
|
-
})}
|
|
325
|
-
isClearable={enabledClear}
|
|
326
|
-
isMulti={multiple}
|
|
327
|
-
defaultValue={defaultValue}
|
|
328
|
-
options={options}
|
|
329
|
-
placeholder={placeholder}
|
|
330
|
-
isDisabled={disabled}
|
|
331
|
-
value={value}
|
|
332
|
-
isSearchable
|
|
333
|
-
onChange={handleChange}
|
|
334
|
-
styles={styles}
|
|
335
|
-
menuPlacement={menuPlacement}
|
|
336
|
-
components={{
|
|
337
|
-
NoOptionsMessage,
|
|
338
|
-
MultiValue: CustomMultiValue,
|
|
339
|
-
Option,
|
|
340
|
-
}}
|
|
341
|
-
/>
|
|
342
|
-
</StyledBase>
|
|
343
|
-
);
|
|
344
|
-
};
|
|
345
|
-
|
|
346
|
-
export default MultiSelect;
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
4
|
+
import type React from 'react';
|
|
5
|
+
import Select, {
|
|
6
|
+
type StylesConfig,
|
|
7
|
+
components,
|
|
8
|
+
type GroupBase,
|
|
9
|
+
type MultiValue as ReactSelectMultiValue,
|
|
10
|
+
type SingleValue,
|
|
11
|
+
type ActionMeta,
|
|
12
|
+
} from 'react-select';
|
|
13
|
+
import { WarningCircle } from '@phosphor-icons/react';
|
|
14
|
+
import {
|
|
15
|
+
Container,
|
|
16
|
+
Label,
|
|
17
|
+
Icon,
|
|
18
|
+
Error,
|
|
19
|
+
SelectWrapper,
|
|
20
|
+
} from './MultiSelect.styles';
|
|
21
|
+
import {
|
|
22
|
+
semanticColors,
|
|
23
|
+
semanticRadius,
|
|
24
|
+
typographyTokens,
|
|
25
|
+
} from '../../../styles/tokens';
|
|
26
|
+
import type {
|
|
27
|
+
IStyledBaseProps,
|
|
28
|
+
SelectProps,
|
|
29
|
+
SelectOption,
|
|
30
|
+
} from './MultiSelect.types';
|
|
31
|
+
|
|
32
|
+
const StyledBase: React.FC<IStyledBaseProps> = ({
|
|
33
|
+
children,
|
|
34
|
+
label,
|
|
35
|
+
error,
|
|
36
|
+
errorMessage,
|
|
37
|
+
labelSize,
|
|
38
|
+
labelWeight,
|
|
39
|
+
icon,
|
|
40
|
+
sizeDisplay,
|
|
41
|
+
height,
|
|
42
|
+
}) => {
|
|
43
|
+
return (
|
|
44
|
+
<Container $sizeDisplay={sizeDisplay} height={height}>
|
|
45
|
+
<div>
|
|
46
|
+
{label && (
|
|
47
|
+
<Label fontSize={labelSize} fontWeight={labelWeight}>
|
|
48
|
+
{label}
|
|
49
|
+
</Label>
|
|
50
|
+
)}
|
|
51
|
+
<SelectWrapper>
|
|
52
|
+
{children}
|
|
53
|
+
{icon && <Icon $error={error}>{icon}</Icon>}
|
|
54
|
+
</SelectWrapper>
|
|
55
|
+
{error && errorMessage && (
|
|
56
|
+
<Error>
|
|
57
|
+
<WarningCircle size={14} /> {errorMessage}
|
|
58
|
+
</Error>
|
|
59
|
+
)}
|
|
60
|
+
</div>
|
|
61
|
+
</Container>
|
|
62
|
+
);
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const NoOptionsMessage = (props: any) => (
|
|
66
|
+
<components.NoOptionsMessage {...props}>
|
|
67
|
+
<span>Sem dados</span>
|
|
68
|
+
</components.NoOptionsMessage>
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
const CustomMultiValue = (props: any) => (
|
|
72
|
+
<components.MultiValue {...props}>
|
|
73
|
+
<Custom {...props} />
|
|
74
|
+
</components.MultiValue>
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
const Option = (props: any) => (
|
|
78
|
+
<components.Option {...props}>
|
|
79
|
+
<Custom {...props} />
|
|
80
|
+
</components.Option>
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
const Custom = (props: any) => (
|
|
84
|
+
<div style={{ display: 'flex', alignItems: 'center' }}>
|
|
85
|
+
{'picture' in props.data &&
|
|
86
|
+
(props.data.picture ? (
|
|
87
|
+
<img
|
|
88
|
+
src={props.data.picture || '/placeholder.svg'}
|
|
89
|
+
alt={props.data.name || props.data.label}
|
|
90
|
+
style={{
|
|
91
|
+
width: '16px',
|
|
92
|
+
height: '16px',
|
|
93
|
+
borderRadius: '50%',
|
|
94
|
+
marginRight: '8px',
|
|
95
|
+
objectFit: 'cover',
|
|
96
|
+
}}
|
|
97
|
+
/>
|
|
98
|
+
) : (
|
|
99
|
+
<div
|
|
100
|
+
style={{
|
|
101
|
+
width: '16px',
|
|
102
|
+
height: '16px',
|
|
103
|
+
borderRadius: '50%',
|
|
104
|
+
backgroundColor: semanticColors.base.text,
|
|
105
|
+
color: semanticColors.base.background,
|
|
106
|
+
fontSize: '10px',
|
|
107
|
+
display: 'flex',
|
|
108
|
+
marginRight: '8px',
|
|
109
|
+
alignItems: 'center',
|
|
110
|
+
justifyContent: 'center',
|
|
111
|
+
flexShrink: 0,
|
|
112
|
+
}}
|
|
113
|
+
>
|
|
114
|
+
{(props.data.label as string).charAt(0).toUpperCase()}
|
|
115
|
+
</div>
|
|
116
|
+
))}
|
|
117
|
+
<span
|
|
118
|
+
style={{
|
|
119
|
+
fontSize: typographyTokens.fontSizes.bodyS,
|
|
120
|
+
lineHeight: '1.4',
|
|
121
|
+
color: 'inherit',
|
|
122
|
+
}}
|
|
123
|
+
>
|
|
124
|
+
{props.data.label}
|
|
125
|
+
</span>
|
|
126
|
+
</div>
|
|
127
|
+
);
|
|
128
|
+
|
|
129
|
+
const MultiSelect: React.FC<SelectProps> = ({
|
|
130
|
+
options,
|
|
131
|
+
placeholder,
|
|
132
|
+
height = '40px',
|
|
133
|
+
enabledClear = true,
|
|
134
|
+
multiple,
|
|
135
|
+
value,
|
|
136
|
+
disabled,
|
|
137
|
+
menuPlacement = 'auto',
|
|
138
|
+
defaultValue,
|
|
139
|
+
setValue,
|
|
140
|
+
...props
|
|
141
|
+
}) => {
|
|
142
|
+
const styles: StylesConfig<SelectOption, boolean, GroupBase<SelectOption>> = {
|
|
143
|
+
indicatorSeparator: (base: any) => ({ ...base, display: 'none' }),
|
|
144
|
+
container: (base: any) => ({
|
|
145
|
+
...base,
|
|
146
|
+
width: '100%',
|
|
147
|
+
border: 'none',
|
|
148
|
+
position: 'relative',
|
|
149
|
+
}),
|
|
150
|
+
control: (base: any, state: any) => ({
|
|
151
|
+
...base,
|
|
152
|
+
minHeight: `${height}`,
|
|
153
|
+
backgroundColor: semanticColors.base.background,
|
|
154
|
+
padding: '2px 8px',
|
|
155
|
+
borderRadius: semanticRadius.global.radius.md,
|
|
156
|
+
borderColor: state.isFocused
|
|
157
|
+
? semanticColors.branding.border.enabled
|
|
158
|
+
: semanticColors.global.border.default,
|
|
159
|
+
':hover': {
|
|
160
|
+
borderColor: semanticColors.branding.border.hover,
|
|
161
|
+
},
|
|
162
|
+
boxShadow: state.isFocused
|
|
163
|
+
? `0 0 0 1px ${semanticColors.branding.border.enabled}`
|
|
164
|
+
: 'none',
|
|
165
|
+
cursor: disabled ? 'not-allowed' : 'pointer',
|
|
166
|
+
opacity: disabled ? 0.6 : 1,
|
|
167
|
+
}),
|
|
168
|
+
dropdownIndicator: (baseStyles: any) => ({
|
|
169
|
+
...baseStyles,
|
|
170
|
+
color: semanticColors.branding.surface.enabled,
|
|
171
|
+
padding: '8px',
|
|
172
|
+
':hover': {
|
|
173
|
+
color: semanticColors.branding.surface.hover,
|
|
174
|
+
},
|
|
175
|
+
}),
|
|
176
|
+
clearIndicator: (baseStyles: any) => ({
|
|
177
|
+
...baseStyles,
|
|
178
|
+
color: semanticColors.neutral[400],
|
|
179
|
+
padding: '8px',
|
|
180
|
+
':hover': {
|
|
181
|
+
color: semanticColors.danger.text.enabled,
|
|
182
|
+
},
|
|
183
|
+
}),
|
|
184
|
+
indicatorsContainer: (base: any) => ({
|
|
185
|
+
...base,
|
|
186
|
+
alignItems: 'center',
|
|
187
|
+
}),
|
|
188
|
+
option: (baseStyle: any, state: any) => ({
|
|
189
|
+
...baseStyle,
|
|
190
|
+
color: state.isSelected
|
|
191
|
+
? semanticColors.branding.text.onSurfaceAccent.enabled
|
|
192
|
+
: semanticColors.base.text,
|
|
193
|
+
backgroundColor: state.isSelected
|
|
194
|
+
? semanticColors.branding.surface.enabled
|
|
195
|
+
: state.isFocused
|
|
196
|
+
? semanticColors.neutral[100]
|
|
197
|
+
: 'transparent',
|
|
198
|
+
cursor: 'pointer',
|
|
199
|
+
padding: '12px 16px',
|
|
200
|
+
':active': {
|
|
201
|
+
backgroundColor: state.isSelected
|
|
202
|
+
? semanticColors.branding.surface.pressed
|
|
203
|
+
: semanticColors.neutral[200],
|
|
204
|
+
},
|
|
205
|
+
}),
|
|
206
|
+
placeholder: (base: any) => ({
|
|
207
|
+
...base,
|
|
208
|
+
fontSize: typographyTokens.fontSizes.bodyS,
|
|
209
|
+
fontWeight: typographyTokens.fontWeights.regular,
|
|
210
|
+
color: semanticColors.neutral[400],
|
|
211
|
+
margin: 0,
|
|
212
|
+
}),
|
|
213
|
+
singleValue: (base: any) => ({
|
|
214
|
+
...base,
|
|
215
|
+
fontSize: typographyTokens.fontSizes.bodyS,
|
|
216
|
+
color: semanticColors.base.text,
|
|
217
|
+
margin: 0,
|
|
218
|
+
}),
|
|
219
|
+
multiValue: (base: any, state: any) => ({
|
|
220
|
+
...base,
|
|
221
|
+
borderRadius: semanticRadius.global.radius.full,
|
|
222
|
+
border: `1px solid ${semanticColors.global.border.default}`,
|
|
223
|
+
backgroundColor: state.data.isFixed
|
|
224
|
+
? semanticColors.global.surface.disabled
|
|
225
|
+
: semanticColors.base.background,
|
|
226
|
+
margin: '2px',
|
|
227
|
+
display: 'inline-flex',
|
|
228
|
+
alignItems: 'center',
|
|
229
|
+
padding: '0 4px',
|
|
230
|
+
}),
|
|
231
|
+
multiValueLabel: (base: any) => ({
|
|
232
|
+
...base,
|
|
233
|
+
display: 'flex',
|
|
234
|
+
alignItems: 'center',
|
|
235
|
+
padding: '0 6px',
|
|
236
|
+
fontWeight: typographyTokens.fontWeights.regular,
|
|
237
|
+
fontSize: typographyTokens.fontSizes.captionM,
|
|
238
|
+
color: semanticColors.base.text,
|
|
239
|
+
}),
|
|
240
|
+
multiValueRemove: (base: any, state: any) => {
|
|
241
|
+
return state.data.isFixed
|
|
242
|
+
? { ...base, display: 'none' }
|
|
243
|
+
: {
|
|
244
|
+
...base,
|
|
245
|
+
display: 'flex',
|
|
246
|
+
alignItems: 'center',
|
|
247
|
+
justifyContent: 'center',
|
|
248
|
+
marginLeft: '2px',
|
|
249
|
+
padding: '0',
|
|
250
|
+
color: semanticColors.neutral[400],
|
|
251
|
+
cursor: 'pointer',
|
|
252
|
+
':hover': {
|
|
253
|
+
backgroundColor: semanticColors.danger.surface.enabled,
|
|
254
|
+
color: semanticColors.danger.text.onSurface,
|
|
255
|
+
},
|
|
256
|
+
};
|
|
257
|
+
},
|
|
258
|
+
|
|
259
|
+
valueContainer: (base: any) => ({
|
|
260
|
+
...base,
|
|
261
|
+
padding: '2px 8px',
|
|
262
|
+
gap: '4px',
|
|
263
|
+
flexWrap: 'wrap',
|
|
264
|
+
}),
|
|
265
|
+
input: (base: any) => ({
|
|
266
|
+
...base,
|
|
267
|
+
margin: 0,
|
|
268
|
+
padding: 0,
|
|
269
|
+
fontSize: typographyTokens.fontSizes.bodyS,
|
|
270
|
+
}),
|
|
271
|
+
menuList: (base: any) => ({
|
|
272
|
+
...base,
|
|
273
|
+
padding: 0,
|
|
274
|
+
'::-webkit-scrollbar': {
|
|
275
|
+
width: '6px',
|
|
276
|
+
},
|
|
277
|
+
'::-webkit-scrollbar-track': {
|
|
278
|
+
background: semanticColors.neutral[200],
|
|
279
|
+
},
|
|
280
|
+
'::-webkit-scrollbar-thumb': {
|
|
281
|
+
background: semanticColors.branding.surface.enabled,
|
|
282
|
+
borderRadius: '20px',
|
|
283
|
+
},
|
|
284
|
+
'::-webkit-scrollbar-thumb:hover': {
|
|
285
|
+
background: semanticColors.branding.surface.hover,
|
|
286
|
+
},
|
|
287
|
+
}),
|
|
288
|
+
menu: (base: any) => ({
|
|
289
|
+
...base,
|
|
290
|
+
borderRadius: semanticRadius.global.radius.md,
|
|
291
|
+
boxShadow:
|
|
292
|
+
'0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)',
|
|
293
|
+
border: `1px solid ${semanticColors.global.border.default}`,
|
|
294
|
+
overflow: 'hidden',
|
|
295
|
+
}),
|
|
296
|
+
};
|
|
297
|
+
|
|
298
|
+
const handleChange = (
|
|
299
|
+
newValue: ReactSelectMultiValue<SelectOption> | SingleValue<SelectOption>,
|
|
300
|
+
actionMeta: ActionMeta<SelectOption>
|
|
301
|
+
) => {
|
|
302
|
+
if (setValue) {
|
|
303
|
+
setValue(newValue, actionMeta);
|
|
304
|
+
}
|
|
305
|
+
};
|
|
306
|
+
|
|
307
|
+
return (
|
|
308
|
+
<StyledBase height={'fit-content'} {...props}>
|
|
309
|
+
<Select<SelectOption, boolean, GroupBase<SelectOption>>
|
|
310
|
+
theme={(selectTheme) => ({
|
|
311
|
+
...selectTheme,
|
|
312
|
+
colors: {
|
|
313
|
+
...selectTheme.colors,
|
|
314
|
+
primary: semanticColors.branding.surface.enabled,
|
|
315
|
+
primary75: semanticColors.branding.surface.hover,
|
|
316
|
+
primary50: semanticColors.branding.surface.disabled,
|
|
317
|
+
primary25: semanticColors.neutral[100],
|
|
318
|
+
},
|
|
319
|
+
spacing: {
|
|
320
|
+
baseUnit: 4,
|
|
321
|
+
menuGutter: 8,
|
|
322
|
+
controlHeight: parseInt(height.replace('px', '')) || 40,
|
|
323
|
+
},
|
|
324
|
+
})}
|
|
325
|
+
isClearable={enabledClear}
|
|
326
|
+
isMulti={multiple}
|
|
327
|
+
defaultValue={defaultValue}
|
|
328
|
+
options={options}
|
|
329
|
+
placeholder={placeholder}
|
|
330
|
+
isDisabled={disabled}
|
|
331
|
+
value={value}
|
|
332
|
+
isSearchable
|
|
333
|
+
onChange={handleChange}
|
|
334
|
+
styles={styles}
|
|
335
|
+
menuPlacement={menuPlacement}
|
|
336
|
+
components={{
|
|
337
|
+
NoOptionsMessage,
|
|
338
|
+
MultiValue: CustomMultiValue,
|
|
339
|
+
Option,
|
|
340
|
+
}}
|
|
341
|
+
/>
|
|
342
|
+
</StyledBase>
|
|
343
|
+
);
|
|
344
|
+
};
|
|
345
|
+
|
|
346
|
+
export default MultiSelect;
|