@lets-events/react 6.0.0 → 6.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lets-events/react",
3
- "version": "6.0.0",
3
+ "version": "6.1.0",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -32,6 +32,7 @@
32
32
  "@fortawesome/free-solid-svg-icons": "^6.7.2",
33
33
  "@fortawesome/react-fontawesome": "^0.2.2",
34
34
  "@radix-ui/themes": "^3.2.1",
35
- "@stitches/react": "^1.2.8"
35
+ "@stitches/react": "^1.2.8",
36
+ "react-day-picker": "^9.6.7"
36
37
  }
37
38
  }
@@ -0,0 +1,13 @@
1
+ import { ComponentProps } from 'react'
2
+ import { ButtonStyled } from './styledComponents'
3
+ import { Button as ButtonRadix } from '@radix-ui/themes'
4
+
5
+
6
+ export interface ButtonProps extends ComponentProps<typeof ButtonStyled> {
7
+ asChild?: boolean,
8
+ }
9
+
10
+ export function Button({ asChild, ...props }: ButtonProps) {
11
+ const Component = asChild ? ButtonRadix : 'button'
12
+ return <ButtonStyled as={Component} {...props} />
13
+ }
@@ -0,0 +1,359 @@
1
+ import { Button as ButtonRadix } from '@radix-ui/themes'
2
+ import { typographyButtonValues } from '../../types/typographyValues'
3
+
4
+ import { styled } from "../../styles"
5
+
6
+ export const ButtonStyled = styled(ButtonRadix, {
7
+ fontFamily: '$default',
8
+ letterSpacing: 0,
9
+ border: 0,
10
+ transition: 'all 300ms ease-out',
11
+ cursor: 'pointer',
12
+ borderRadius: '$xs',
13
+ boxShadow: '0px 4px 4px 0px rgba(35, 53, 67, 0.08), 0px 2px 4px 0px rgba(35, 53, 67, 0.16)',
14
+ display: 'flex',
15
+ alignItems: 'center',
16
+ justifyContent: 'center',
17
+ gap: '$10',
18
+ padding: '$6 $16',
19
+ '&:disabled': {
20
+ cursor: 'not-allowed',
21
+ transition: 'none',
22
+ },
23
+ variants: {
24
+ color: {
25
+ brand: {},
26
+ neutral: {},
27
+ purple: {},
28
+ },
29
+ variant: {
30
+ text: {
31
+ backgroundColor: 'transparent',
32
+ boxShadow: 'none',
33
+ padding: 0,
34
+ border: 0,
35
+ },
36
+ contained: {
37
+ '&:hover': {
38
+ borderWidth: '1px',
39
+ borderStyle: 'solid',
40
+ },
41
+
42
+ '&:active': {
43
+ borderWidth: '2px',
44
+ },
45
+ '&:disabled': {
46
+ boxShadow: 'none',
47
+ }
48
+ },
49
+ outlined: {
50
+ borderWidth: '1px',
51
+ borderStyle: 'solid',
52
+ '&:disabled': {
53
+ color: '$neutral400',
54
+ boxShadow: 'none',
55
+ }
56
+ }
57
+ },
58
+ typography: typographyButtonValues,
59
+ fontWeight: {
60
+ regular: { fontWeight: '$regular' },
61
+ medium: { fontWeight: '$medium' },
62
+ semibold: { fontWeight: '$semibold' },
63
+ bold: { fontWeight: '$bold' },
64
+ },
65
+ outlinedBgColor: {
66
+ neutral: {},
67
+ transparent: {},
68
+ },
69
+ radii: {
70
+ 'full': {
71
+ borderRadius: '$full',
72
+ }
73
+ },
74
+ },
75
+
76
+ defaultVariants: {
77
+ variant: 'contained',
78
+ typography: 'buttonMedium',
79
+ color: 'brand',
80
+ },
81
+
82
+ compoundVariants: [
83
+ {
84
+ variant: 'text',
85
+ color: 'brand',
86
+ css: {
87
+ color: '$brand500',
88
+ '&:hover': { color: '$brand600' },
89
+ '&:focus': { color: '$brand700' },
90
+ '&:active': { color: '$brand500' },
91
+ '&:disabled': { color: '$dark400' },
92
+ }
93
+ },
94
+ {
95
+ variant: 'text',
96
+ color: 'neutral',
97
+ css: {
98
+ color: '$neutral600',
99
+ '&:hover': { color: '$neutral700' },
100
+ '&:focus': { color: '$neutral800' },
101
+ '&:active': { color: '$neutral500' },
102
+ '&:disabled': { color: '$dark400' },
103
+ }
104
+ },
105
+ {
106
+ variant: 'text',
107
+ color: 'purple',
108
+ css: {
109
+ color: '$purple500',
110
+ '&:hover': { color: '$purple600' },
111
+ '&:focus': { color: '$purple700' },
112
+ '&:active': { color: '$purple500' },
113
+ '&:disabled': { color: '$dark400' },
114
+ }
115
+ },
116
+ {
117
+ variant: 'text',
118
+ color: 'green',
119
+ css: {
120
+ color: '$green500',
121
+ '&:hover': { color: '$green600' },
122
+ '&:focus': { color: '$green700' },
123
+ '&:active': { color: '$green500' },
124
+ '&:disabled': { color: '$dark400' },
125
+ }
126
+ },
127
+ {
128
+ variant: 'text',
129
+ color: 'blue',
130
+ css: {
131
+ color: '$blue500',
132
+ '&:hover': { color: '$blue600' },
133
+ '&:focus': { color: '$blue700' },
134
+ '&:active': { color: '$blue500' },
135
+ '&:disabled': { color: '$dark400' },
136
+ }
137
+ },
138
+ {
139
+ variant: 'text',
140
+ color: 'red',
141
+ css: {
142
+ color: '$red500',
143
+ '&:hover': { color: '$red600' },
144
+ '&:focus': { color: '$red700' },
145
+ '&:active': { color: '$red500' },
146
+ '&:disabled': { color: '$dark400' },
147
+ }
148
+ },
149
+
150
+ // contained
151
+ {
152
+ variant: 'contained',
153
+ color: 'brand',
154
+ css: {
155
+ color: '$grey50',
156
+ backgroundColor: '$brand500',
157
+ borderWidth: '2px',
158
+ borderStyle: 'solid',
159
+ borderColor: 'transparent',
160
+ '&:hover': {
161
+ borderColor: '$brand700',
162
+ backgroundColor: '$blue600',
163
+ },
164
+ '&:focus': {
165
+ backgroundColor: '$blue700',
166
+ },
167
+ '&:active': {
168
+ borderColor: '$brand300',
169
+ backgroundColor: '$blue500',
170
+ },
171
+ '&:disabled': {
172
+ borderColor: '$brand50',
173
+ backgroundColor: '$brand50',
174
+ color: '$neutral400',
175
+ }
176
+ }
177
+ },
178
+ {
179
+ variant: 'contained',
180
+ color: 'neutral',
181
+ css: {
182
+ backgroundColor: '$neutral600',
183
+ color: '$grey50',
184
+ '&:hover': {
185
+ backgroundColor: '$neutral700',
186
+ borderColor: '$neutral800',
187
+ },
188
+ '&:focus': {
189
+ backgroundColor: '$neutral800',
190
+ },
191
+ '&:active': {
192
+ backgroundColor: '$neutral500',
193
+ borderColor: '$neutral400',
194
+ },
195
+ '&:disabled': {
196
+ backgroundColor: '$neutral50',
197
+ borderColor: '$neutral200',
198
+ color: '$neutral400',
199
+ }
200
+ }
201
+ },
202
+ {
203
+ variant: 'contained',
204
+ color: 'purple',
205
+ css: {
206
+ backgroundColor: '$purple500',
207
+ color: '$grey50',
208
+ '&:hover': {
209
+ backgroundColor: '$purple600',
210
+ borderColor: '$purple700',
211
+ },
212
+ '&:focus': {
213
+ backgroundColor: '$purple700',
214
+ },
215
+ '&:active': {
216
+ borderColor: '$purple300',
217
+ backgroundColor: '$purple500',
218
+ },
219
+ '&:disabled': {
220
+ borderColor: '$purple200',
221
+ backgroundColor: '$purple200',
222
+ color: '$neutral400',
223
+ }
224
+ }
225
+ },
226
+
227
+
228
+
229
+ // outlined
230
+ {
231
+ variant: 'outlined',
232
+ color: 'brand',
233
+ outlinedBgColor: 'neutral',
234
+ css: {
235
+ color: '$brand500',
236
+ border: '1px solid $brand300',
237
+ backgroundColor: '$grey50',
238
+ '&:hover': {
239
+ borderColor: '$brand400',
240
+ backgroundColor: '$brand50',
241
+ },
242
+ '&:focus': {
243
+ borderColor: '$brand400',
244
+ backgroundColor: '$brand50',
245
+ },
246
+ '&:disabled': {
247
+ borderColor: '$brand200',
248
+ backgroundColor: '$neutral200',
249
+ }
250
+ }
251
+ },
252
+ {
253
+ variant: 'outlined',
254
+ color: 'neutral',
255
+ outlinedBgColor: 'neutral',
256
+ css: {
257
+ color: '$neutral600',
258
+ border: '1px solid $neutral300',
259
+ backgroundColor: '$grey50',
260
+ '&:hover': {
261
+ borderColor: '$neutral400',
262
+ backgroundColor: '$grey100',
263
+ },
264
+ '&:focus': {
265
+ borderColor: '$neutral400',
266
+ backgroundColor: '$grey100',
267
+ },
268
+ '&:disabled': {
269
+ borderColor: '$neutral200',
270
+ backgroundColor: '$neutral200',
271
+ }
272
+ }
273
+ },
274
+ {
275
+ variant: 'outlined',
276
+ color: 'purple',
277
+ outlinedBgColor: 'neutral',
278
+ css: {
279
+ color: '$purple500',
280
+ backgroundColor: '$grey50',
281
+ border: '1px solid $purple300',
282
+ '&:hover': {
283
+ borderColor: '$purple400',
284
+ backgroundColor: '$purple50',
285
+ },
286
+ '&:focus': {
287
+ borderColor: '$purple400',
288
+ backgroundColor: '$purple50',
289
+ },
290
+ '&:disabled': {
291
+ borderColor: '$purple200',
292
+ backgroundColor: '$neutral200',
293
+ }
294
+ }
295
+ },
296
+ // outlined transparent
297
+ {
298
+ variant: 'outlined',
299
+ color: 'brand',
300
+ outlinedBgColor: 'transparent',
301
+ css: {
302
+ color: '$brand500',
303
+ border: '1px solid $brand300',
304
+ backgroundColor: 'transparent',
305
+ '&:hover': {
306
+ borderColor: '$brand400',
307
+ opacity: '0.8',
308
+ },
309
+ '&:focus': {
310
+ borderColor: '$brand400',
311
+ },
312
+ '&:disabled': {
313
+ borderColor: '$brand200',
314
+ }
315
+ }
316
+ },
317
+ {
318
+ variant: 'outlined',
319
+ color: 'neutral',
320
+ outlinedBgColor: 'transparent',
321
+ css: {
322
+ color: '$neutral600',
323
+ border: '1px solid $neutral300',
324
+ backgroundColor: 'transparent',
325
+ '&:hover': {
326
+ borderColor: '$neutral400',
327
+ opacity: '0.8',
328
+ },
329
+ '&:focus': {
330
+ borderColor: '$neutral400',
331
+ },
332
+ '&:disabled': {
333
+ borderColor: '$neutral200',
334
+ }
335
+ }
336
+ },
337
+ {
338
+ variant: 'outlined',
339
+ color: 'purple',
340
+ outlinedBgColor: 'transparent',
341
+ css: {
342
+ color: '$purple500',
343
+ backgroundColor: 'transparent',
344
+ border: '1px solid $purple300',
345
+ '&:hover': {
346
+ borderColor: '$purple400',
347
+ opacity: '0.8',
348
+ },
349
+ '&:focus': {
350
+ borderColor: '$purple400',
351
+ },
352
+ '&:disabled': {
353
+ borderColor: '$purple200',
354
+ }
355
+ }
356
+ },
357
+ ]
358
+ })
359
+
@@ -41,7 +41,7 @@ export const ButtonGroupStyled = styled(Flex, {
41
41
  },
42
42
  contained: {
43
43
  [`& ${ButtonItemStyled}`]: {
44
- borderWidth: '$1',
44
+ borderWidth: '1px',
45
45
  borderStyle: 'solid',
46
46
  '&:disabled': {
47
47
  boxShadow: 'none',
@@ -50,7 +50,7 @@ export const ButtonGroupStyled = styled(Flex, {
50
50
  },
51
51
  outlined: {
52
52
  [`& ${ButtonItemStyled}`]: {
53
- borderWidth: '$1',
53
+ borderWidth: '1px',
54
54
  borderStyle: 'solid',
55
55
  '&:disabled': {
56
56
  color: '$neutral400',
@@ -0,0 +1,122 @@
1
+ import React, { ComponentProps, useEffect, useState } from 'react'
2
+ import { DayPicker } from 'react-day-picker';
3
+ import { ptBR } from 'date-fns/locale';
4
+ import { Dialog as Calendaradix } from "@radix-ui/themes";
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
+ } from './styledComponents';
16
+
17
+ export type CalendarProps = ComponentProps<typeof CalendarStyled> & {
18
+ calendarLayout?: "label" | "dropdown" | "dropdown-months" | "dropdown-years"
19
+ selected: Date | undefined
20
+ setSelected: React.Dispatch<React.SetStateAction<Date | undefined>>
21
+ action?: boolean
22
+ actionText?: string
23
+ onAction?: () => void
24
+ }
25
+
26
+ function formatToDateMask(value: string): string {
27
+ const numeric = value.replace(/\D/g, '').slice(0, 8)
28
+ const parts = numeric.match(/^(\d{0,2})(\d{0,2})(\d{0,4})$/)
29
+ if (!parts) return ''
30
+ const [, day, month, year] = parts
31
+ return [day, month, year].filter(Boolean).join('/')
32
+ }
33
+
34
+ export function Calendar({
35
+ action,
36
+ actionText,
37
+ calendarLayout,
38
+ selected,
39
+ setSelected,
40
+ onAction,
41
+ ...props
42
+ }: CalendarProps) {
43
+ const [inputValue, setInputValue] = useState('')
44
+
45
+ const today = new Date()
46
+ const maxDate = addYears(today, 20)
47
+
48
+ useEffect(() => {
49
+ console.log('selected', selected)
50
+ if (selected) {
51
+ setInputValue(format(selected, 'dd/MM/yyyy'))
52
+ } else {
53
+ setInputValue('')
54
+ }
55
+ }, [selected])
56
+
57
+ const handleInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {
58
+ const masked = formatToDateMask(e.target.value)
59
+ setInputValue(masked)
60
+
61
+ const parsed = parse(masked, 'dd/MM/yyyy', new Date())
62
+ if (isValid(parsed)) {
63
+ setSelected(parsed)
64
+ } else {
65
+ console.warn('Data inválida inserida no input:', masked)
66
+ }
67
+ }
68
+
69
+ return (
70
+ <Calendaradix.Root >
71
+ <CalendarStyled {...props}>
72
+ <Calendaradix.Trigger>
73
+ <TextField
74
+ placeholder="00/00/0000"
75
+ type="text"
76
+ value={inputValue}
77
+ onChange={handleInputChange}
78
+ inputMode="numeric"
79
+ >
80
+ <TextFieldSlot>
81
+ <Icon name="calendar" size={'xl'} />
82
+ </TextFieldSlot>
83
+ </TextField>
84
+ </Calendaradix.Trigger>
85
+
86
+ <CalendarContentStyled>
87
+ <Box>
88
+ <DayPickerWrapperStyled>
89
+ <DayPicker
90
+ mode="single"
91
+ captionLayout={calendarLayout}
92
+ selected={selected}
93
+ onSelect={setSelected}
94
+ required
95
+ locale={ptBR}
96
+ disabled={{ before: today }}
97
+ startMonth={today}
98
+ endMonth={maxDate}
99
+ />
100
+ </DayPickerWrapperStyled>
101
+ </Box>
102
+
103
+ {action && onAction && (
104
+ <CalendarFooterStyled>
105
+ <Calendaradix.Close>
106
+ <Button
107
+ variant='text'
108
+ color='brand'
109
+ onClick={onAction}
110
+ typography='buttonMedium'
111
+ fontWeight='medium'
112
+ >
113
+ {actionText ?? 'Aplicar'}
114
+ </Button>
115
+ </Calendaradix.Close>
116
+ </CalendarFooterStyled>
117
+ )}
118
+ </CalendarContentStyled>
119
+ </CalendarStyled>
120
+ </Calendaradix.Root>
121
+ )
122
+ }