@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/.turbo/turbo-build.log +8 -8
- package/CHANGELOG.md +6 -0
- package/dist/index.d.mts +1876 -3
- package/dist/index.d.ts +1876 -3
- package/dist/index.js +4641 -304
- package/dist/index.mjs +4604 -272
- package/package.json +3 -2
- package/src/components/Button/index.tsx +13 -0
- package/src/components/Button/styledComponents.ts +359 -0
- package/src/components/ButtonGroup.tsx +2 -2
- package/src/components/Calendar/index.tsx +122 -0
- package/src/components/Calendar/styledComponents.ts +195 -0
- package/src/components/TextField.tsx +20 -0
- package/src/components/TimePicker.tsx +125 -0
- package/src/index.tsx +2 -0
- package/src/components/Button.tsx +0 -329
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import { Dialog as Calendaradix } from "@radix-ui/themes";
|
|
2
|
+
|
|
3
|
+
import { styled } from "../../styles"
|
|
4
|
+
|
|
5
|
+
export const CalendarStyled = styled('div', {
|
|
6
|
+
fontFamily: '$default',
|
|
7
|
+
lineHeight: '$base',
|
|
8
|
+
fontSize: '$14',
|
|
9
|
+
maxWidth: '200px',
|
|
10
|
+
borderRadius: '$sm',
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
export const CalendarContentStyled = styled(Calendaradix.Content, {
|
|
14
|
+
fontFamily: '$default',
|
|
15
|
+
lineHeight: '$base',
|
|
16
|
+
fontSize: '$14',
|
|
17
|
+
width: '100%',
|
|
18
|
+
maxWidth: 'fit-content',
|
|
19
|
+
border: '1px solid $neutral300',
|
|
20
|
+
borderRadius: '$sm',
|
|
21
|
+
boxShadow: '0px 2px 8px 0px $shadow50',
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
export const CalendarFooterStyled = styled('div', {
|
|
25
|
+
borderTop: '2px solid $neutral100',
|
|
26
|
+
padding: '$4 $16',
|
|
27
|
+
display: 'flex',
|
|
28
|
+
justifyContent: 'center',
|
|
29
|
+
alignItems: 'center',
|
|
30
|
+
height: '3rem',
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
export const DayPickerWrapperStyled = styled('div', {
|
|
34
|
+
'.rt-TextFieldInput': {
|
|
35
|
+
fontFamily: '$default',
|
|
36
|
+
fontSize: '$14',
|
|
37
|
+
color: '$dark500',
|
|
38
|
+
},
|
|
39
|
+
'.rdp-root': {
|
|
40
|
+
padding: '$16',
|
|
41
|
+
},
|
|
42
|
+
'.rdp-today .rdp-day_button': {
|
|
43
|
+
color: '$brand500',
|
|
44
|
+
textDecoration: 'underline',
|
|
45
|
+
},
|
|
46
|
+
'.rdp-day.rdp-disabled .rdp-day_button': {
|
|
47
|
+
color: '$dark400'
|
|
48
|
+
},
|
|
49
|
+
'.rdp-day_button': {
|
|
50
|
+
height: '32px',
|
|
51
|
+
width: '32px',
|
|
52
|
+
borderRadius: '$sm',
|
|
53
|
+
fontSize: '$14',
|
|
54
|
+
color: '$text',
|
|
55
|
+
backgroundColor: 'transparent',
|
|
56
|
+
border: '1px solid transparent',
|
|
57
|
+
transition: 'all 0.2s ease-in-out',
|
|
58
|
+
cursor: 'pointer',
|
|
59
|
+
},
|
|
60
|
+
'.rdp-day_button:hover': {
|
|
61
|
+
backgroundColor: '$dark100',
|
|
62
|
+
borderColor: '$brand500',
|
|
63
|
+
},
|
|
64
|
+
'.rdp-day.rdp-disabled .rdp-day_button:hover': {
|
|
65
|
+
backgroundColor: 'transparent',
|
|
66
|
+
borderColor: 'transparent',
|
|
67
|
+
},
|
|
68
|
+
'.rdp-nav': {
|
|
69
|
+
display: 'flex',
|
|
70
|
+
justifyContent: 'space-between',
|
|
71
|
+
width: '100%',
|
|
72
|
+
},
|
|
73
|
+
'.rdp-nav .rdp-chevron': {
|
|
74
|
+
display: 'none',
|
|
75
|
+
},
|
|
76
|
+
'.rdp-nav .rdp-button_previous': {
|
|
77
|
+
display: 'block',
|
|
78
|
+
backgroundImage: 'url("data:image/svg+xml,%3Csvg%20xmlns=\'http://www.w3.org/2000/svg\'%20width=\'32\'%20height=\'32\'%20viewBox=\'0%200%2032%2032\'%20fill=\'none\'%3E%3Cg%20transform=\'scale(-1,1)%20translate(-32,0)\'%3E%3Cpath%20d=\'M0%208C0%203.58172%203.58172%200%208%200H24C28.4183%200%2032%203.58172%2032%208V24C32%2028.4183%2028.4183%2032%2024%2032H8C3.58172%2032%200%2028.4183%200%2024V8Z\'%20fill=\'white\'/%3E%3Cpath%20d=\'M19.7062%2015.2938C20.0969%2015.6844%2020.0969%2016.3188%2019.7062%2016.7094L14.7062%2021.7094C14.3156%2022.1%2013.6812%2022.1%2013.2906%2021.7094C12.9%2021.3188%2012.9%2020.6844%2013.2906%2020.2938L17.5844%2016L13.2937%2011.7063C12.9031%2011.3156%2012.9031%2010.6813%2013.2937%2010.2906C13.6844%209.90002%2014.3187%209.90002%2014.7094%2010.2906L19.7094%2015.2906L19.7062%2015.2938Z\'%20fill=\'%23808289\'/%3E%3C/g%3E%3C/svg%3E")',
|
|
79
|
+
backgroundRepeat: 'no-repeat',
|
|
80
|
+
backgroundPosition: 'center',
|
|
81
|
+
backgroundSize: 'cover',
|
|
82
|
+
width: '32px',
|
|
83
|
+
height: '32px',
|
|
84
|
+
|
|
85
|
+
},
|
|
86
|
+
'.rdp-nav .rdp-button_next': {
|
|
87
|
+
display: 'block',
|
|
88
|
+
backgroundImage: 'url("data:image/svg+xml,%3Csvg%20xmlns=\'http://www.w3.org/2000/svg\'%20width=\'32\'%20height=\'32\'%20viewBox=\'0%200%2032%2032\'%20fill=\'none\'%3E%3Cpath%20d=\'M0%208C0%203.58172%203.58172%200%208%200H24C28.4183%200%2032%203.58172%2032%208V24C32%2028.4183%2028.4183%2032%2024%2032H8C3.58172%2032%200%2028.4183%200%2024V8Z\'%20fill=\'white\'/%3E%3Cpath%20d=\'M19.7062%2015.2938C20.0969%2015.6844%2020.0969%2016.3188%2019.7062%2016.7094L14.7062%2021.7094C14.3156%2022.1%2013.6812%2022.1%2013.2906%2021.7094C12.9%2021.3188%2012.9%2020.6844%2013.2906%2020.2938L17.5844%2016L13.2937%2011.7063C12.9031%2011.3156%2012.9031%2010.6813%2013.2937%2010.2906C13.6844%209.90002%2014.3187%209.90002%2014.7094%2010.2906L19.7094%2015.2906L19.7062%2015.2938Z\'%20fill=\'%23808289\'/%3E%3C/svg%3E")',
|
|
89
|
+
backgroundRepeat: 'no-repeat',
|
|
90
|
+
backgroundPosition: 'center',
|
|
91
|
+
backgroundSize: 'cover',
|
|
92
|
+
width: '32px',
|
|
93
|
+
height: '32px',
|
|
94
|
+
},
|
|
95
|
+
'.rdp-nav .rdp-button_previous:hover': {
|
|
96
|
+
backgroundImage: 'url("data:image/svg+xml,%3Csvg%20xmlns=\'http://www.w3.org/2000/svg\'%20width=\'32\'%20height=\'32\'%20viewBox=\'0%200%2032%2032\'%20fill=\'none\'%3E%3Cpath%20d=\'M0%208C0%203.58172%203.58172%200%208%200H24C28.4183%200%2032%203.58172%2032%208V24C32%2028.4183%2028.4183%2032%2024%2032H8C3.58172%2032%200%2028.4183%200%2024V8Z\'%20fill=\'%23F4F4F4\'/%3E%3Cpath%20d=\'M12.2937%2015.2938C11.9031%2015.6844%2011.9031%2016.3188%2012.2937%2016.7094L17.2937%2021.7094C17.6844%2022.1%2018.3187%2022.1%2018.7094%2021.7094C19.1%2021.3188%2019.1%2020.6844%2018.7094%2020.2938L14.4156%2016L18.7062%2011.7063C19.0969%2011.3156%2019.0969%2010.6813%2018.7062%2010.2906C18.3156%209.90002%2017.6812%209.90002%2017.2906%2010.2906L12.2906%2015.2906L12.2937%2015.2938Z\'%20fill=\'%23808289\'/%3E%3C/svg%3E")',
|
|
97
|
+
transition: 'all 0.2s ease-in-out',
|
|
98
|
+
},
|
|
99
|
+
'.rdp-nav .rdp-button_next:hover': {
|
|
100
|
+
backgroundImage: 'url("data:image/svg+xml,%3Csvg%20xmlns=\'http://www.w3.org/2000/svg\'%20width=\'32\'%20height=\'32\'%20viewBox=\'0%200%2032%2032\'%20fill=\'none\'%3E%3Cpath%20d=\'M0%208C0%203.58172%203.58172%200%208%200H24C28.4183%200%2032%203.58172%2032%208V24C32%2028.4183%2028.4183%2032%2024%2032H8C3.58172%2032%200%2028.4183%200%2024V8Z\'%20fill=\'%23F4F4F4\'/%3E%3Cpath%20d=\'M19.7062%2015.2938C20.0969%2015.6844%2020.0969%2016.3188%2019.7062%2016.7094L14.7062%2021.7094C14.3156%2022.1%2013.6812%2022.1%2013.2906%2021.7094C12.9%2021.3188%2012.9%2020.6844%2013.2906%2020.2938L17.5844%2016L13.2937%2011.7063C12.9031%2011.3156%2012.9031%2010.6813%2013.2937%2010.2906C13.6844%209.90002%2014.3187%209.90002%2014.7094%2010.2906L19.7094%2015.2906L19.7062%2015.2938Z\'%20fill=\'%23808289\'/%3E%3C/svg%3E")',
|
|
101
|
+
transition: 'all 0.2s ease-in-out',
|
|
102
|
+
},
|
|
103
|
+
'.rdp-nav button': {
|
|
104
|
+
border: 'none',
|
|
105
|
+
backgroundColor: 'transparent',
|
|
106
|
+
cursor: 'pointer',
|
|
107
|
+
},
|
|
108
|
+
'.rdp-month': {
|
|
109
|
+
marginTop: '-24px',
|
|
110
|
+
},
|
|
111
|
+
'.rdp-month_caption': {
|
|
112
|
+
display: 'flex',
|
|
113
|
+
alignItems: 'center',
|
|
114
|
+
justifyContent: 'center',
|
|
115
|
+
width: 'calc(100% - 64px)',
|
|
116
|
+
margin: '0 auto',
|
|
117
|
+
columnGap: '12px',
|
|
118
|
+
},
|
|
119
|
+
'.rdp-dropdowns span, .rdp-caption_label': {
|
|
120
|
+
fontSize: '$16',
|
|
121
|
+
fontWeight: '$regular',
|
|
122
|
+
lineHeight: '$20',
|
|
123
|
+
textTransform: 'capitalize',
|
|
124
|
+
},
|
|
125
|
+
'.rdp-day.rdp-selected .rdp-day_button': {
|
|
126
|
+
backgroundColor: '$brand500',
|
|
127
|
+
color: '$neutral50',
|
|
128
|
+
borderColor: '$brand500',
|
|
129
|
+
},
|
|
130
|
+
'.rdp-dropdowns': {
|
|
131
|
+
display: 'flex',
|
|
132
|
+
alignItems: 'center',
|
|
133
|
+
justifyContent: 'center',
|
|
134
|
+
width: 'calc(100% - 64px)',
|
|
135
|
+
columnGap: '12px',
|
|
136
|
+
},
|
|
137
|
+
'.rdp-dropdowns .rdp-caption_label': {
|
|
138
|
+
display: 'none',
|
|
139
|
+
},
|
|
140
|
+
'.rdp-dropdown.rdp-months_dropdown, .rdp-dropdown.rdp-years_dropdown': {
|
|
141
|
+
border: 'none',
|
|
142
|
+
backgroundColor: 'transparent',
|
|
143
|
+
textTransform: 'capitalize',
|
|
144
|
+
height: '1.25rem',
|
|
145
|
+
position: 'relative',
|
|
146
|
+
fontFamily: '$default',
|
|
147
|
+
fontSize: '$16',
|
|
148
|
+
lineHeight: '1.25rem',
|
|
149
|
+
appearance: 'none',
|
|
150
|
+
WebkitAppearance: 'none',
|
|
151
|
+
MozAppearance: 'none',
|
|
152
|
+
paddingRight: '1.25rem',
|
|
153
|
+
zIndex: '3',
|
|
154
|
+
},
|
|
155
|
+
'.rdp-dropdown:focus, .rdp-dropdown:focus-visible, .rdp-dropdown:active': {
|
|
156
|
+
border: 'none',
|
|
157
|
+
outline: 'none',
|
|
158
|
+
boxShadow: 'none',
|
|
159
|
+
},
|
|
160
|
+
'.rdp-dropdown.rdp-months_dropdown:focus, .rdp-dropdown.rdp-years_dropdown:focus': {
|
|
161
|
+
border: 'none',
|
|
162
|
+
},
|
|
163
|
+
'.rdp-dropdown_root': {
|
|
164
|
+
position: 'relative'
|
|
165
|
+
},
|
|
166
|
+
'.rdp-dropdown_root::after': {
|
|
167
|
+
content: '',
|
|
168
|
+
height: '1.25rem',
|
|
169
|
+
width: '1.25rem',
|
|
170
|
+
position: 'absolute',
|
|
171
|
+
top: '0',
|
|
172
|
+
right: '0',
|
|
173
|
+
display: 'block',
|
|
174
|
+
backgroundColor: '$neutral50',
|
|
175
|
+
backgroundImage: 'url("data:image/svg+xml,%3Csvg%20xmlns=\'http://www.w3.org/2000/svg\'%20width=\'11\'%20height=\'20\'%20viewBox=\'0%200%2011%2020\'%20fill=\'none\'%3E%3Crect%20width=\'11\'%20height=\'20\'%20fill=\'white\'/%3E%3Cpath%20d=\'M5.9414%202.68359C5.69726%202.43945%205.30077%202.43945%205.05663%202.68359L2.55663%205.18359C2.37695%205.36328%202.32421%205.63086%202.42187%205.86523C2.51952%206.09961%202.74609%206.25195%202.99999%206.25195H7.99999C8.25195%206.25195%208.48046%206.09961%208.57812%205.86523C8.67578%205.63086%208.62109%205.36328%208.44335%205.18359L5.94335%202.68359H5.9414Z\'%20fill=\'%23808289\'/%3E%3Cpath%20d=\'M5.05858%2017.3164C5.30272%2017.5605%205.69921%2017.5605%205.94335%2017.3164L8.44335%2014.8164C8.62304%2014.6367%208.67577%2014.3691%208.57811%2014.1348C8.48046%2013.9004%208.25389%2013.748%207.99999%2013.748L2.99999%2013.75C2.74804%2013.75%202.51952%2013.9023%202.42186%2014.1367C2.32421%2014.3711%202.37889%2014.6387%202.55663%2014.8184L5.05663%2017.3184L5.05858%2017.3164Z\'%20fill=\'%23808289\'/%3E%3C/svg%3E")',
|
|
176
|
+
backgroundRepeat: 'no-repeat',
|
|
177
|
+
backgroundPosition: 'center',
|
|
178
|
+
borderRadius: '0.5rem',
|
|
179
|
+
zIndex: '2',
|
|
180
|
+
},
|
|
181
|
+
'.rdp-weekday': {
|
|
182
|
+
textTransform: 'uppercase',
|
|
183
|
+
fontWeight: '$regular',
|
|
184
|
+
fontSize: '0px',
|
|
185
|
+
|
|
186
|
+
},
|
|
187
|
+
'.rdp-weekday::first-letter': {
|
|
188
|
+
fontSize: '$14',
|
|
189
|
+
},
|
|
190
|
+
'.rdp-month_grid': {
|
|
191
|
+
marginTop: '$16',
|
|
192
|
+
paddingTop: '$16',
|
|
193
|
+
borderTop: '2px solid $neutral100',
|
|
194
|
+
},
|
|
195
|
+
})
|
|
@@ -23,6 +23,7 @@ export const TextFieldStyled = styled(TextFieldRadix.Root, {
|
|
|
23
23
|
margin: 0,
|
|
24
24
|
width: '100%',
|
|
25
25
|
font: 'inherit',
|
|
26
|
+
textAlign: 'inherit',
|
|
26
27
|
},
|
|
27
28
|
|
|
28
29
|
'&:has(input:focus)': {
|
|
@@ -75,6 +76,11 @@ export const TextFieldStyled = styled(TextFieldRadix.Root, {
|
|
|
75
76
|
semibold: { fontWeight: '$semibold' },
|
|
76
77
|
bold: { fontWeight: '$bold' },
|
|
77
78
|
},
|
|
79
|
+
textAlign: {
|
|
80
|
+
left: { textAlign: 'left' },
|
|
81
|
+
center: { textAlign: 'center' },
|
|
82
|
+
right: { textAlign: 'right' },
|
|
83
|
+
},
|
|
78
84
|
isValid: {
|
|
79
85
|
true: {},
|
|
80
86
|
false: {}
|
|
@@ -137,6 +143,11 @@ export const TextFieldSlotStyled = styled(TextFieldRadix.Slot, {
|
|
|
137
143
|
medium: { fontWeight: '$medium' },
|
|
138
144
|
semibold: { fontWeight: '$semibold' },
|
|
139
145
|
bold: { fontWeight: '$bold' },
|
|
146
|
+
},
|
|
147
|
+
textAlign: {
|
|
148
|
+
left: { textAlign: 'left' },
|
|
149
|
+
right: { textAlign: 'right' },
|
|
150
|
+
center: { textAlign: 'center' },
|
|
140
151
|
}
|
|
141
152
|
}
|
|
142
153
|
})
|
|
@@ -148,6 +159,7 @@ export type TextFieldProps = ComponentProps<typeof TextFieldStyled> & {
|
|
|
148
159
|
name?: string
|
|
149
160
|
typography?: string
|
|
150
161
|
fontWeight?: 'regular' | 'medium' | 'semibold' | 'bold'
|
|
162
|
+
textAlign?: 'left' | 'right' | 'center'
|
|
151
163
|
}
|
|
152
164
|
|
|
153
165
|
export type TextFieldSlotProps = Omit<ComponentProps<typeof TextFieldStyled>, 'color'> & {
|
|
@@ -158,6 +170,7 @@ export type TextFieldSlotProps = Omit<ComponentProps<typeof TextFieldStyled>, 'c
|
|
|
158
170
|
color?: "error" | "success" | undefined
|
|
159
171
|
typography?: string
|
|
160
172
|
fontWeight?: 'regular' | 'medium' | 'semibold' | 'bold'
|
|
173
|
+
textAlign?: 'left' | 'right' | 'center'
|
|
161
174
|
}
|
|
162
175
|
|
|
163
176
|
export function TextField({
|
|
@@ -167,6 +180,7 @@ export function TextField({
|
|
|
167
180
|
color,
|
|
168
181
|
typography,
|
|
169
182
|
fontWeight,
|
|
183
|
+
textAlign = 'right',
|
|
170
184
|
...props
|
|
171
185
|
}: TextFieldProps) {
|
|
172
186
|
return (
|
|
@@ -176,6 +190,7 @@ export function TextField({
|
|
|
176
190
|
name={name}
|
|
177
191
|
typography={typography}
|
|
178
192
|
fontWeight={fontWeight}
|
|
193
|
+
textAlign={textAlign}
|
|
179
194
|
{...props}
|
|
180
195
|
>
|
|
181
196
|
{children}
|
|
@@ -186,6 +201,7 @@ export function TextField({
|
|
|
186
201
|
color={color as TextFieldSlotProps['color']}
|
|
187
202
|
typography={typography}
|
|
188
203
|
fontWeight={fontWeight}
|
|
204
|
+
textAlign={textAlign}
|
|
189
205
|
>
|
|
190
206
|
<Icon name='check' />
|
|
191
207
|
</TextFieldSlot>
|
|
@@ -200,11 +216,13 @@ export function TextFieldSlot({
|
|
|
200
216
|
onClick,
|
|
201
217
|
typography = 'bodyXS',
|
|
202
218
|
fontWeight = 'regular',
|
|
219
|
+
textAlign = 'right',
|
|
203
220
|
...props
|
|
204
221
|
}: TextFieldSlotProps) {
|
|
205
222
|
const sharedStyles = {
|
|
206
223
|
typography,
|
|
207
224
|
fontWeight,
|
|
225
|
+
textAlign,
|
|
208
226
|
...props,
|
|
209
227
|
color: undefined,
|
|
210
228
|
}
|
|
@@ -216,6 +234,7 @@ export function TextFieldSlot({
|
|
|
216
234
|
position: 'absolute',
|
|
217
235
|
left: position === 'flex-end' ? 'none' : 15,
|
|
218
236
|
right: position === 'flex-start' ? 'none' : 15,
|
|
237
|
+
textAlign: textAlign,
|
|
219
238
|
padding: 13,
|
|
220
239
|
zIndex: 2,
|
|
221
240
|
top: 0,
|
|
@@ -233,6 +252,7 @@ export function TextFieldSlot({
|
|
|
233
252
|
order: position === 'flex-start' ? 0 : 2,
|
|
234
253
|
marginLeft: position === 'flex-start' ? 0 : 15,
|
|
235
254
|
marginRight: position === 'flex-end' ? 0 : 15,
|
|
255
|
+
textAlign: textAlign,
|
|
236
256
|
}}
|
|
237
257
|
>
|
|
238
258
|
{children}
|
|
@@ -0,0 +1,125 @@
|
|
|
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 TimePickerDialogStyled = styled(TimePickerRadix.Content, {
|
|
18
|
+
width: '100%',
|
|
19
|
+
maxWidth: '8.875rem',
|
|
20
|
+
border: '1px solid $neutral300',
|
|
21
|
+
borderRadius: '$sm',
|
|
22
|
+
boxShadow: '0px 2px 8px 0px $shadow50',
|
|
23
|
+
})
|
|
24
|
+
export const TimePickerFooterStyled = styled('div', {
|
|
25
|
+
borderTop: '2px solid $neutral100',
|
|
26
|
+
padding: '$4 $16',
|
|
27
|
+
display: 'flex',
|
|
28
|
+
justifyContent: 'center',
|
|
29
|
+
alignItems: 'center',
|
|
30
|
+
height: '3rem',
|
|
31
|
+
})
|
|
32
|
+
export const TimerPickerContentStyled = styled('div', {
|
|
33
|
+
display: 'flex',
|
|
34
|
+
gap: '$16',
|
|
35
|
+
alignItems: 'center',
|
|
36
|
+
padding: '$16 $16 $8 ',
|
|
37
|
+
'& > div:nth-child(2)': {
|
|
38
|
+
order: 2
|
|
39
|
+
}
|
|
40
|
+
})
|
|
41
|
+
export type TimePickerProps = {
|
|
42
|
+
selected: string | undefined
|
|
43
|
+
setSelected: React.Dispatch<React.SetStateAction<string | undefined>>
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function TimePicker({ selected, setSelected }: TimePickerProps) {
|
|
47
|
+
const [hours, setHours] = useState('00')
|
|
48
|
+
const [minutes, setMinutes] = useState('00')
|
|
49
|
+
|
|
50
|
+
const pad = (num: number) => String(num).padStart(2, '0')
|
|
51
|
+
|
|
52
|
+
const handleInputValue = useCallback((time: string) => {
|
|
53
|
+
setSelected(time)
|
|
54
|
+
}, [setSelected])
|
|
55
|
+
|
|
56
|
+
const handleIncrement = useCallback((type: 'hours' | 'minutes') => {
|
|
57
|
+
if (type === 'hours') {
|
|
58
|
+
const next = (parseInt(hours) + 1) % 24
|
|
59
|
+
setHours(pad(next))
|
|
60
|
+
} else {
|
|
61
|
+
const next = (parseInt(minutes) + 1) % 60
|
|
62
|
+
setMinutes(pad(next))
|
|
63
|
+
}
|
|
64
|
+
}, [hours, minutes])
|
|
65
|
+
|
|
66
|
+
const handleDecrement = useCallback((type: 'hours' | 'minutes') => {
|
|
67
|
+
if (type === 'hours') {
|
|
68
|
+
const prev = (parseInt(hours) - 1 + 24) % 24
|
|
69
|
+
setHours(pad(prev))
|
|
70
|
+
} else {
|
|
71
|
+
const prev = (parseInt(minutes) - 1 + 60) % 60
|
|
72
|
+
setMinutes(pad(prev))
|
|
73
|
+
}
|
|
74
|
+
}, [hours, minutes])
|
|
75
|
+
|
|
76
|
+
return (
|
|
77
|
+
<TimePickerRadix.Root>
|
|
78
|
+
<TimePickerStyled >
|
|
79
|
+
<TimePickerRadix.Trigger>
|
|
80
|
+
<TextField value={selected} readOnly type="text" placeholder="00:00" typography="labelSmall" fontWeight="regular">
|
|
81
|
+
<TextFieldSlot>
|
|
82
|
+
<Icon name="clock" size="xl" />
|
|
83
|
+
</TextFieldSlot>
|
|
84
|
+
</TextField>
|
|
85
|
+
</TimePickerRadix.Trigger>
|
|
86
|
+
<TimePickerDialogStyled>
|
|
87
|
+
<TimerPickerContentStyled>
|
|
88
|
+
{['hours', 'minutes'].map((unit) => (
|
|
89
|
+
<Box key={unit} style={{ display: 'flex', alignItems: 'center', flexDirection: 'column' }}>
|
|
90
|
+
<Button variant='text' onClick={() => handleIncrement(unit as 'hours' | 'minutes')}>
|
|
91
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32" fill="none">
|
|
92
|
+
<path 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" fill="white" />
|
|
93
|
+
<path 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" fill="#808289" />
|
|
94
|
+
</svg>
|
|
95
|
+
</Button>
|
|
96
|
+
<TextField value={unit === 'hours' ? hours : minutes} onChange={(e) => handleInputValue(e.target.value)} type="text" placeholder="00" typography="labelSmall" fontWeight="regular" textAlign="center" style={{ padding: '4px' }} />
|
|
97
|
+
|
|
98
|
+
<Button variant='text' onClick={() => handleDecrement(unit as 'hours' | 'minutes')}>
|
|
99
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32" fill="none">
|
|
100
|
+
<path 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" fill="white" />
|
|
101
|
+
<path 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" fill="#808289" />
|
|
102
|
+
</svg>
|
|
103
|
+
</Button>
|
|
104
|
+
</Box>
|
|
105
|
+
))}
|
|
106
|
+
<Text >:</Text>
|
|
107
|
+
</TimerPickerContentStyled>
|
|
108
|
+
<TimePickerFooterStyled>
|
|
109
|
+
<TimePickerRadix.Close>
|
|
110
|
+
<Button
|
|
111
|
+
variant='text'
|
|
112
|
+
color='brand'
|
|
113
|
+
onClick={() => handleInputValue(`${hours}:${minutes}`)}
|
|
114
|
+
typography='buttonMedium'
|
|
115
|
+
fontWeight='medium'
|
|
116
|
+
>
|
|
117
|
+
Aplicar
|
|
118
|
+
</Button>
|
|
119
|
+
</TimePickerRadix.Close>
|
|
120
|
+
</TimePickerFooterStyled>
|
|
121
|
+
</TimePickerDialogStyled>
|
|
122
|
+
</TimePickerStyled>
|
|
123
|
+
</TimePickerRadix.Root>
|
|
124
|
+
)
|
|
125
|
+
}
|
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'
|