@lets-events/react 6.0.0 → 7.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.
@@ -3,26 +3,31 @@ import { styled } from '../styles'
3
3
  import { TextField as TextFieldRadix } from "@radix-ui/themes";
4
4
  import Icon from './Icon';
5
5
  import { typographyValues } from '../types/typographyValues';
6
+ import { TextStyle } from './Text';
7
+ import { Flex } from './Flex';
6
8
 
7
9
  export const TextFieldStyled = styled(TextFieldRadix.Root, {
8
10
  height: '$40',
9
11
  fontFamily: '$default',
10
- padding: '$12 $14',
12
+ padding: '0',
11
13
  borderRadius: '$sm',
12
14
  boxSizing: 'border-box',
13
15
  color: '$dark500',
14
16
  border: '1px solid $dark300',
15
17
  position: 'relative',
16
18
  display: 'flex',
19
+ width: '100%',
20
+ alignItems: 'center',
17
21
 
18
22
  'input': {
19
23
  order: 1,
20
- border: 'none',
21
24
  outline: 'none',
22
- padding: 0,
25
+ border: 'none',
23
26
  margin: 0,
24
27
  width: '100%',
25
28
  font: 'inherit',
29
+ textAlign: 'left',
30
+ padding: '0 $14'
26
31
  },
27
32
 
28
33
  '&:has(input:focus)': {
@@ -75,6 +80,11 @@ export const TextFieldStyled = styled(TextFieldRadix.Root, {
75
80
  semibold: { fontWeight: '$semibold' },
76
81
  bold: { fontWeight: '$bold' },
77
82
  },
83
+ textAlign: {
84
+ left: { textAlign: 'left' },
85
+ center: { textAlign: 'center' },
86
+ right: { textAlign: 'right' },
87
+ },
78
88
  isValid: {
79
89
  true: {},
80
90
  false: {}
@@ -137,17 +147,24 @@ export const TextFieldSlotStyled = styled(TextFieldRadix.Slot, {
137
147
  medium: { fontWeight: '$medium' },
138
148
  semibold: { fontWeight: '$semibold' },
139
149
  bold: { fontWeight: '$bold' },
150
+ },
151
+ textAlign: {
152
+ left: { textAlign: 'left' },
153
+ right: { textAlign: 'right' },
154
+ center: { textAlign: 'center' },
140
155
  }
141
156
  }
142
157
  })
143
158
 
144
159
  export type TextFieldProps = ComponentProps<typeof TextFieldStyled> & {
160
+ addon?:string
145
161
  placeholder?: string
146
162
  children?: React.ReactNode
147
163
  isValid?: boolean
148
164
  name?: string
149
165
  typography?: string
150
166
  fontWeight?: 'regular' | 'medium' | 'semibold' | 'bold'
167
+ textAlign?: 'left' | 'right' | 'center'
151
168
  }
152
169
 
153
170
  export type TextFieldSlotProps = Omit<ComponentProps<typeof TextFieldStyled>, 'color'> & {
@@ -158,8 +175,23 @@ export type TextFieldSlotProps = Omit<ComponentProps<typeof TextFieldStyled>, 'c
158
175
  color?: "error" | "success" | undefined
159
176
  typography?: string
160
177
  fontWeight?: 'regular' | 'medium' | 'semibold' | 'bold'
178
+ textAlign?: 'left' | 'right' | 'center'
161
179
  }
162
180
 
181
+
182
+ const InputAddon = styled(TextStyle, {
183
+ boxSizing: 'border-box',
184
+ border: '1px solid $dark300',
185
+ height: '$40',
186
+ padding: '0',
187
+ color: '$dark600',
188
+ borderRadius: '$sm 0px 0px $sm',
189
+ borderRightWidth: '0px',
190
+ margin: 'auto 0',
191
+ display: 'flex',
192
+ alignItems: 'center'
193
+ })
194
+
163
195
  export function TextField({
164
196
  children,
165
197
  isValid,
@@ -167,30 +199,40 @@ export function TextField({
167
199
  color,
168
200
  typography,
169
201
  fontWeight,
202
+ addon,
203
+ textAlign = 'right',
170
204
  ...props
171
205
  }: TextFieldProps) {
172
206
  return (
173
- <TextFieldStyled
174
- color={color}
175
- isValid={isValid}
176
- name={name}
177
- typography={typography}
178
- fontWeight={fontWeight}
179
- {...props}
180
- >
181
- {children}
182
- {isValid && (
183
- <TextFieldSlot
207
+ <Flex gap={'0'} css={{width: '100%'}}>
208
+ {!!addon && (
209
+ <InputAddon typography="labelSmall">{addon}</InputAddon>
210
+ )}
211
+ <TextFieldStyled
212
+ color={color}
213
+ isValid={isValid}
214
+ name={name}
215
+ typography={typography}
216
+ fontWeight={fontWeight}
217
+ textAlign={textAlign}
218
+ style={!!addon ? {borderTopLeftRadius:'0px', borderBottomLeftRadius: '0px'}: undefined}
219
+ {...props}
220
+ >
221
+ {children}
222
+ {isValid && (
223
+ <TextFieldSlot
184
224
  position='flex-end'
185
225
  name={name}
186
226
  color={color as TextFieldSlotProps['color']}
187
227
  typography={typography}
188
228
  fontWeight={fontWeight}
189
- >
190
- <Icon name='check' />
191
- </TextFieldSlot>
192
- )}
193
- </TextFieldStyled>
229
+ textAlign={textAlign}
230
+ >
231
+ <Icon name='check' />
232
+ </TextFieldSlot>
233
+ )}
234
+ </TextFieldStyled>
235
+ </Flex>
194
236
  )
195
237
  }
196
238
 
@@ -200,11 +242,13 @@ export function TextFieldSlot({
200
242
  onClick,
201
243
  typography = 'bodyXS',
202
244
  fontWeight = 'regular',
245
+ textAlign = 'right',
203
246
  ...props
204
247
  }: TextFieldSlotProps) {
205
248
  const sharedStyles = {
206
249
  typography,
207
250
  fontWeight,
251
+ textAlign,
208
252
  ...props,
209
253
  color: undefined,
210
254
  }
@@ -216,6 +260,7 @@ export function TextFieldSlot({
216
260
  position: 'absolute',
217
261
  left: position === 'flex-end' ? 'none' : 15,
218
262
  right: position === 'flex-start' ? 'none' : 15,
263
+ textAlign: textAlign,
219
264
  padding: 13,
220
265
  zIndex: 2,
221
266
  top: 0,
@@ -233,6 +278,7 @@ export function TextFieldSlot({
233
278
  order: position === 'flex-start' ? 0 : 2,
234
279
  marginLeft: position === 'flex-start' ? 0 : 15,
235
280
  marginRight: position === 'flex-end' ? 0 : 15,
281
+ textAlign: textAlign,
236
282
  }}
237
283
  >
238
284
  {children}
@@ -0,0 +1,191 @@
1
+ import React, { useCallback, useState } from "react";
2
+ import { Dialog as TimePickerRadix } from "@radix-ui/themes";
3
+ import { Box } from "./Box";
4
+ import { Button } from "./Button";
5
+ import { TextField, TextFieldSlot } from "./TextField";
6
+ import { Text } from "./Text";
7
+ import Icon from "./Icon";
8
+ import { styled } from "../styles";
9
+
10
+ export const TimePickerStyled = styled("div", {
11
+ fontFamily: "$default",
12
+ lineHeight: "$base",
13
+ fontSize: "$14",
14
+ maxWidth: "200px",
15
+ borderRadius: "$sm",
16
+ });
17
+ export const TimePickerTitleStyled = styled(TimePickerRadix.Title, {
18
+ display: "none",
19
+ });
20
+ export const TimePickerDialogStyled = styled(TimePickerRadix.Content, {
21
+ width: "100%",
22
+ maxWidth: "8.875rem",
23
+ border: "1px solid $neutral300",
24
+ borderRadius: "$sm",
25
+ boxShadow: "0px 2px 8px 0px $shadow50",
26
+ });
27
+ export const TimePickerFooterStyled = styled("div", {
28
+ borderTop: "2px solid $neutral100",
29
+ padding: "$4 $16",
30
+ display: "flex",
31
+ justifyContent: "center",
32
+ alignItems: "center",
33
+ height: "3rem",
34
+ });
35
+ export const TimerPickerContentStyled = styled("div", {
36
+ display: "flex",
37
+ gap: "$16",
38
+ alignItems: "center",
39
+ padding: "$16 $16 $8 ",
40
+ "& > div:nth-child(2)": {
41
+ order: 2,
42
+ },
43
+ });
44
+ export type TimePickerProps = {
45
+ selected: string | undefined;
46
+ setSelected: React.Dispatch<React.SetStateAction<string | undefined>>;
47
+ };
48
+
49
+ export function TimePicker({ selected, setSelected }: TimePickerProps) {
50
+ const [hours, setHours] = useState("00");
51
+ const [minutes, setMinutes] = useState("00");
52
+
53
+ const pad = (num: number) => String(num).padStart(2, "0");
54
+
55
+ const handleInputValue = useCallback(
56
+ (time: string) => {
57
+ setSelected(time);
58
+ },
59
+ [setSelected]
60
+ );
61
+
62
+ const handleIncrement = useCallback(
63
+ (type: "hours" | "minutes") => {
64
+ if (type === "hours") {
65
+ const next = (parseInt(hours) + 1) % 24;
66
+ setHours(pad(next));
67
+ } else {
68
+ const next = (parseInt(minutes) + 1) % 60;
69
+ setMinutes(pad(next));
70
+ }
71
+ },
72
+ [hours, minutes]
73
+ );
74
+
75
+ const handleDecrement = useCallback(
76
+ (type: "hours" | "minutes") => {
77
+ if (type === "hours") {
78
+ const prev = (parseInt(hours) - 1 + 24) % 24;
79
+ setHours(pad(prev));
80
+ } else {
81
+ const prev = (parseInt(minutes) - 1 + 60) % 60;
82
+ setMinutes(pad(prev));
83
+ }
84
+ },
85
+ [hours, minutes]
86
+ );
87
+
88
+ return (
89
+ <TimePickerRadix.Root>
90
+ <TimePickerStyled>
91
+ <TimePickerRadix.Trigger>
92
+ <TextField
93
+ value={selected}
94
+ readOnly
95
+ type="text"
96
+ placeholder="00:00"
97
+ typography="labelSmall"
98
+ fontWeight="regular"
99
+ >
100
+ <TextFieldSlot>
101
+ <Icon name="clock" size="xl" />
102
+ </TextFieldSlot>
103
+ </TextField>
104
+ </TimePickerRadix.Trigger>
105
+ <TimePickerDialogStyled>
106
+ <TimePickerTitleStyled>Horário</TimePickerTitleStyled>
107
+ <TimerPickerContentStyled>
108
+ {["hours", "minutes"].map((unit) => (
109
+ <Box
110
+ key={unit}
111
+ style={{
112
+ display: "flex",
113
+ alignItems: "center",
114
+ flexDirection: "column",
115
+ }}
116
+ >
117
+ <Button
118
+ variant="text"
119
+ onClick={() => handleIncrement(unit as "hours" | "minutes")}
120
+ >
121
+ <svg
122
+ xmlns="http://www.w3.org/2000/svg"
123
+ width="32"
124
+ height="32"
125
+ viewBox="0 0 32 32"
126
+ fill="none"
127
+ >
128
+ <path
129
+ d="M0 8C0 3.58172 3.58172 0 8 0H24C28.4183 0 32 3.58172 32 8V24C32 28.4183 28.4183 32 24 32H8C3.58172 32 0 28.4183 0 24V8Z"
130
+ fill="white"
131
+ />
132
+ <path
133
+ d="M16.7063 12.2937C16.3157 11.9031 15.6813 11.9031 15.2907 12.2937L10.2907 17.2937C9.9001 17.6843 9.9001 18.3187 10.2907 18.7093C10.6813 19.1 11.3157 19.1 11.7063 18.7093L16.0001 14.4156L20.2938 18.7062C20.6845 19.0968 21.3188 19.0968 21.7095 18.7062C22.1001 18.3156 22.1001 17.6812 21.7095 17.2906L16.7095 12.2906L16.7063 12.2937Z"
134
+ fill="#808289"
135
+ />
136
+ </svg>
137
+ </Button>
138
+ <TextField
139
+ value={unit === "hours" ? hours : minutes}
140
+ onChange={(e) => handleInputValue(e.target.value)}
141
+ type="text"
142
+ placeholder="00"
143
+ typography="labelSmall"
144
+ fontWeight="regular"
145
+ textAlign="center"
146
+ style={{ padding: "4px" }}
147
+ />
148
+
149
+ <Button
150
+ variant="text"
151
+ onClick={() => handleDecrement(unit as "hours" | "minutes")}
152
+ >
153
+ <svg
154
+ xmlns="http://www.w3.org/2000/svg"
155
+ width="32"
156
+ height="32"
157
+ viewBox="0 0 32 32"
158
+ fill="none"
159
+ >
160
+ <path
161
+ d="M0 8C0 3.58172 3.58172 0 8 0H24C28.4183 0 32 3.58172 32 8V24C32 28.4183 28.4183 32 24 32H8C3.58172 32 0 28.4183 0 24V8Z"
162
+ fill="white"
163
+ />
164
+ <path
165
+ d="M15.2937 19.7063C15.6843 20.0969 16.3187 20.0969 16.7093 19.7063L21.7093 14.7063C22.0999 14.3157 22.0999 13.6813 21.7093 13.2907C21.3187 12.9 20.6843 12.9 20.2937 13.2907L15.9999 17.5844L11.7062 13.2938C11.3155 12.9032 10.6812 12.9032 10.2905 13.2938C9.8999 13.6844 9.8999 14.3188 10.2905 14.7094L15.2905 19.7094L15.2937 19.7063Z"
166
+ fill="#808289"
167
+ />
168
+ </svg>
169
+ </Button>
170
+ </Box>
171
+ ))}
172
+ <Text>:</Text>
173
+ </TimerPickerContentStyled>
174
+ <TimePickerFooterStyled>
175
+ <TimePickerRadix.Close>
176
+ <Button
177
+ variant="text"
178
+ color="brand"
179
+ onClick={() => handleInputValue(`${hours}:${minutes}`)}
180
+ typography="buttonMedium"
181
+ fontWeight="medium"
182
+ >
183
+ Aplicar
184
+ </Button>
185
+ </TimePickerRadix.Close>
186
+ </TimePickerFooterStyled>
187
+ </TimePickerDialogStyled>
188
+ </TimePickerStyled>
189
+ </TimePickerRadix.Root>
190
+ );
191
+ }
package/src/index.tsx CHANGED
@@ -15,6 +15,8 @@ export * from './components/Filter'
15
15
  export * from './components/Dropdown'
16
16
  export * from './components/Badge'
17
17
  export * from './components/Modal'
18
+ export * from './components/Calendar'
19
+ export * from './components/TimePicker'
18
20
  export * from './components/Alert'
19
21
  export * from './components/Switch'
20
22
  export * from './components/Step'