@lets-events/react 10.0.1 → 10.1.1
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/.eslintrc.json +2 -2
- package/.turbo/turbo-build.log +19 -18
- package/CHANGELOG.md +12 -0
- package/dist/index.d.mts +426 -1
- package/dist/index.d.ts +426 -1
- package/dist/index.js +340 -20
- package/dist/index.mjs +331 -19
- package/package.json +3 -1
- package/src/components/Alert.tsx +303 -303
- package/src/components/Avatar.tsx +55 -55
- package/src/components/Badge.tsx +128 -128
- package/src/components/Box.tsx +3 -3
- package/src/components/Button/index.tsx +12 -12
- package/src/components/Button/styledComponents.ts +250 -250
- package/src/components/ButtonGroup.tsx +484 -484
- package/src/components/Calendar/index.tsx +136 -136
- package/src/components/Calendar/styledComponents.ts +208 -208
- package/src/components/Card.tsx +69 -69
- package/src/components/CheckboxGroup.tsx +214 -214
- package/src/components/Container.tsx +39 -39
- package/src/components/Dropdown.tsx +167 -167
- package/src/components/Filter.tsx +164 -164
- package/src/components/Flex.tsx +118 -118
- package/src/components/Grid.tsx +137 -137
- package/src/components/Icon.tsx +47 -47
- package/src/components/Modal.tsx +90 -90
- package/src/components/RadioGroup.tsx +210 -210
- package/src/components/Section.tsx +33 -33
- package/src/components/Step.tsx +164 -164
- package/src/components/Switch.tsx +108 -108
- package/src/components/Text.tsx +30 -30
- package/src/components/TextField.tsx +299 -299
- package/src/components/TextareaField.tsx +101 -101
- package/src/components/TimePicker.tsx +280 -239
- package/src/components/Toast/components/ToastItem.tsx +41 -0
- package/src/components/Toast/components/ToastProvider.tsx +63 -0
- package/src/components/Toast/hooks/useToast.ts +12 -0
- package/src/components/Toast/index.tsx +5 -0
- package/src/components/Toast/styles/index.ts +135 -0
- package/src/components/Toast/types/index.ts +46 -0
- package/src/components/Tooltip/index.tsx +67 -0
- package/src/components/Tooltip/styles.ts +78 -0
- package/src/hooks/useOnClickOutside.tsx +20 -20
- package/src/index.tsx +33 -31
- package/src/styles/index.ts +38 -38
- package/src/types/typographyValues.ts +178 -178
- package/tsconfig.json +3 -3
|
@@ -1,299 +1,299 @@
|
|
|
1
|
-
import { ComponentProps, ReactNode } from 'react'
|
|
2
|
-
import { styled } from '../styles'
|
|
3
|
-
import { TextField as TextFieldRadix } from '@radix-ui/themes'
|
|
4
|
-
import Icon from './Icon'
|
|
5
|
-
import { typographyValues } from '../types/typographyValues'
|
|
6
|
-
import { TextStyle } from './Text'
|
|
7
|
-
import { Flex } from './Flex'
|
|
8
|
-
import { format, MaskOptions, useMask, unformat } from '@react-input/mask'
|
|
9
|
-
|
|
10
|
-
export const TextFieldStyled = styled(TextFieldRadix.Root, {
|
|
11
|
-
height: '$40',
|
|
12
|
-
fontFamily: '$default',
|
|
13
|
-
borderRadius: '$sm',
|
|
14
|
-
boxSizing: 'border-box',
|
|
15
|
-
color: '$dark500',
|
|
16
|
-
border: '1px solid $dark300',
|
|
17
|
-
position: 'relative',
|
|
18
|
-
display: 'flex',
|
|
19
|
-
width: '100%',
|
|
20
|
-
alignItems: 'center',
|
|
21
|
-
padding: '0 $14',
|
|
22
|
-
gap: '$14',
|
|
23
|
-
input: {
|
|
24
|
-
order: 1,
|
|
25
|
-
outline: 'none',
|
|
26
|
-
border: 'none',
|
|
27
|
-
margin: 0,
|
|
28
|
-
width: '100%',
|
|
29
|
-
font: 'inherit',
|
|
30
|
-
textAlign: 'left',
|
|
31
|
-
},
|
|
32
|
-
|
|
33
|
-
'&:has(input:focus)': {
|
|
34
|
-
border: '2px solid $brand300',
|
|
35
|
-
},
|
|
36
|
-
'&:has(input:disabled)': {
|
|
37
|
-
backgroundColor: '$dark100',
|
|
38
|
-
color: '$dark400',
|
|
39
|
-
border: '1px solid $dark200',
|
|
40
|
-
cursor: 'not-allowed',
|
|
41
|
-
},
|
|
42
|
-
|
|
43
|
-
variants: {
|
|
44
|
-
color: {
|
|
45
|
-
default: {
|
|
46
|
-
color: '$dark400',
|
|
47
|
-
border: '1px solid $dark200',
|
|
48
|
-
'&:has(input:focus)': {
|
|
49
|
-
border: '2px solid $brand300',
|
|
50
|
-
},
|
|
51
|
-
'&:has(input:disabled)': {
|
|
52
|
-
backgroundColor: '$dark100',
|
|
53
|
-
color: '$dark400',
|
|
54
|
-
border: '1px solid $dark200',
|
|
55
|
-
cursor: 'not-allowed',
|
|
56
|
-
},
|
|
57
|
-
},
|
|
58
|
-
error: {
|
|
59
|
-
border: '1px solid $error400',
|
|
60
|
-
color: '$error400',
|
|
61
|
-
'input::placeholder': {
|
|
62
|
-
color: '$error400',
|
|
63
|
-
},
|
|
64
|
-
'&:has(input:focus)': {
|
|
65
|
-
border: '2px solid $error400',
|
|
66
|
-
},
|
|
67
|
-
'&:has(input:disabled)': {
|
|
68
|
-
backgroundColor: '$error50',
|
|
69
|
-
color: '$error300',
|
|
70
|
-
border: '1px solid $error100',
|
|
71
|
-
cursor: 'not-allowed',
|
|
72
|
-
},
|
|
73
|
-
},
|
|
74
|
-
},
|
|
75
|
-
|
|
76
|
-
typography: typographyValues,
|
|
77
|
-
fontWeight: {
|
|
78
|
-
regular: { fontWeight: '$regular' },
|
|
79
|
-
medium: { fontWeight: '$medium' },
|
|
80
|
-
semibold: { fontWeight: '$semibold' },
|
|
81
|
-
bold: { fontWeight: '$bold' },
|
|
82
|
-
},
|
|
83
|
-
textAlign: {
|
|
84
|
-
left: { textAlign: 'left' },
|
|
85
|
-
center: { textAlign: 'center' },
|
|
86
|
-
right: { textAlign: 'right' },
|
|
87
|
-
},
|
|
88
|
-
isValid: {
|
|
89
|
-
true: {},
|
|
90
|
-
false: {},
|
|
91
|
-
},
|
|
92
|
-
},
|
|
93
|
-
|
|
94
|
-
compoundVariants: [
|
|
95
|
-
{
|
|
96
|
-
isValid: false,
|
|
97
|
-
css: {
|
|
98
|
-
border: '1px solid $error400',
|
|
99
|
-
color: '$error400',
|
|
100
|
-
backgroundColor: '$error50',
|
|
101
|
-
input: {
|
|
102
|
-
'&::placeholder': {
|
|
103
|
-
color: '$error400',
|
|
104
|
-
},
|
|
105
|
-
backgroundColor: '$error50',
|
|
106
|
-
},
|
|
107
|
-
'&:has(input:focus)': {
|
|
108
|
-
border: '2px solid $error400',
|
|
109
|
-
},
|
|
110
|
-
'&:has(input:disabled)': {
|
|
111
|
-
input: {
|
|
112
|
-
backgroundColor: '$error50',
|
|
113
|
-
},
|
|
114
|
-
backgroundColor: '$error50',
|
|
115
|
-
color: '$error300',
|
|
116
|
-
border: '1px solid $error100',
|
|
117
|
-
cursor: 'not-allowed',
|
|
118
|
-
},
|
|
119
|
-
},
|
|
120
|
-
},
|
|
121
|
-
{
|
|
122
|
-
isValid: true,
|
|
123
|
-
css: {
|
|
124
|
-
'&:has(input:focus)': {
|
|
125
|
-
border: '2px solid $success500',
|
|
126
|
-
},
|
|
127
|
-
'&:has(input:disabled)': {
|
|
128
|
-
backgroundColor: '$dark100',
|
|
129
|
-
color: '$dark400',
|
|
130
|
-
border: '1px solid $dark200',
|
|
131
|
-
cursor: 'not-allowed',
|
|
132
|
-
},
|
|
133
|
-
},
|
|
134
|
-
},
|
|
135
|
-
],
|
|
136
|
-
})
|
|
137
|
-
|
|
138
|
-
export const TextFieldSlotStyled = styled(TextFieldRadix.Slot, {
|
|
139
|
-
display: 'flex',
|
|
140
|
-
alignItems: 'center',
|
|
141
|
-
justifyContent: 'center',
|
|
142
|
-
padding: 4,
|
|
143
|
-
|
|
144
|
-
variants: {
|
|
145
|
-
typography: typographyValues,
|
|
146
|
-
fontWeight: {
|
|
147
|
-
regular: { fontWeight: '$regular' },
|
|
148
|
-
medium: { fontWeight: '$medium' },
|
|
149
|
-
semibold: { fontWeight: '$semibold' },
|
|
150
|
-
bold: { fontWeight: '$bold' },
|
|
151
|
-
},
|
|
152
|
-
textAlign: {
|
|
153
|
-
left: { textAlign: 'left' },
|
|
154
|
-
right: { textAlign: 'right' },
|
|
155
|
-
center: { textAlign: 'center' },
|
|
156
|
-
},
|
|
157
|
-
},
|
|
158
|
-
})
|
|
159
|
-
|
|
160
|
-
export type TextFieldProps = ComponentProps<typeof TextFieldStyled> & {
|
|
161
|
-
addon?: ReactNode
|
|
162
|
-
placeholder?: string
|
|
163
|
-
children?: React.ReactNode
|
|
164
|
-
isValid?: boolean
|
|
165
|
-
name?: string
|
|
166
|
-
typography?: string
|
|
167
|
-
fontWeight?: 'regular' | 'medium' | 'semibold' | 'bold'
|
|
168
|
-
textAlign?: 'left' | 'right' | 'center'
|
|
169
|
-
mask?: MaskOptions
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
export type TextFieldSlotProps = Omit<
|
|
173
|
-
ComponentProps<typeof TextFieldStyled>,
|
|
174
|
-
'color'
|
|
175
|
-
> & {
|
|
176
|
-
placeholder?: string
|
|
177
|
-
children?: React.ReactNode
|
|
178
|
-
position?: 'flex-start' | 'flex-end'
|
|
179
|
-
onClick?: () => void
|
|
180
|
-
color?: 'error' | 'success' | undefined
|
|
181
|
-
typography?: string
|
|
182
|
-
fontWeight?: 'regular' | 'medium' | 'semibold' | 'bold'
|
|
183
|
-
textAlign?: 'left' | 'right' | 'center'
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
const InputAddon = styled(TextStyle, {
|
|
187
|
-
boxSizing: 'border-box',
|
|
188
|
-
border: '1px solid $dark300',
|
|
189
|
-
height: '$40',
|
|
190
|
-
padding: '0 $12',
|
|
191
|
-
margin: '0 auto',
|
|
192
|
-
|
|
193
|
-
color: '$dark600',
|
|
194
|
-
whiteSpace: 'nowrap',
|
|
195
|
-
borderRadius: '$sm 0px 0px $sm',
|
|
196
|
-
borderRightWidth: '0px',
|
|
197
|
-
display: 'flex',
|
|
198
|
-
flexWrap: 'nowrap',
|
|
199
|
-
alignItems: 'center',
|
|
200
|
-
lineHeight: 1,
|
|
201
|
-
})
|
|
202
|
-
export const maskFormat = format
|
|
203
|
-
export const maskUnformat = unformat
|
|
204
|
-
|
|
205
|
-
export function TextField({
|
|
206
|
-
children,
|
|
207
|
-
isValid,
|
|
208
|
-
name,
|
|
209
|
-
color,
|
|
210
|
-
typography,
|
|
211
|
-
fontWeight,
|
|
212
|
-
addon,
|
|
213
|
-
textAlign = 'left',
|
|
214
|
-
mask,
|
|
215
|
-
...props
|
|
216
|
-
}: TextFieldProps) {
|
|
217
|
-
const maskRef = mask ? useMask(mask) : undefined
|
|
218
|
-
|
|
219
|
-
return (
|
|
220
|
-
<Flex gap={'0'} css={{ width: '100%' }}>
|
|
221
|
-
{!!addon && <InputAddon typography="labelSmall">{addon}</InputAddon>}
|
|
222
|
-
|
|
223
|
-
<TextFieldStyled
|
|
224
|
-
color={color}
|
|
225
|
-
isValid={isValid}
|
|
226
|
-
name={name}
|
|
227
|
-
typography={typography}
|
|
228
|
-
fontWeight={fontWeight}
|
|
229
|
-
textAlign={textAlign}
|
|
230
|
-
ref={maskRef}
|
|
231
|
-
{...props}
|
|
232
|
-
style={
|
|
233
|
-
addon
|
|
234
|
-
? { borderTopLeftRadius: '0px', borderBottomLeftRadius: '0px' }
|
|
235
|
-
: undefined
|
|
236
|
-
}
|
|
237
|
-
>
|
|
238
|
-
{children}
|
|
239
|
-
{isValid && (
|
|
240
|
-
<TextFieldSlot
|
|
241
|
-
position="flex-end"
|
|
242
|
-
name={name}
|
|
243
|
-
color={color as TextFieldSlotProps['color']}
|
|
244
|
-
typography={typography}
|
|
245
|
-
fontWeight={fontWeight}
|
|
246
|
-
textAlign={textAlign}
|
|
247
|
-
>
|
|
248
|
-
<Icon name="check" />
|
|
249
|
-
</TextFieldSlot>
|
|
250
|
-
)}
|
|
251
|
-
</TextFieldStyled>
|
|
252
|
-
</Flex>
|
|
253
|
-
)
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
export function TextFieldSlot({
|
|
257
|
-
children,
|
|
258
|
-
position = 'flex-start',
|
|
259
|
-
onClick,
|
|
260
|
-
typography = 'bodyXS',
|
|
261
|
-
fontWeight = 'regular',
|
|
262
|
-
textAlign = 'right',
|
|
263
|
-
...props
|
|
264
|
-
}: TextFieldSlotProps) {
|
|
265
|
-
const sharedStyles = {
|
|
266
|
-
typography,
|
|
267
|
-
fontWeight,
|
|
268
|
-
textAlign,
|
|
269
|
-
...props,
|
|
270
|
-
color: undefined,
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
return onClick ? (
|
|
274
|
-
<TextFieldSlotStyled
|
|
275
|
-
{...sharedStyles}
|
|
276
|
-
style={{
|
|
277
|
-
float: position === 'flex-start' ? 'left' : 'right',
|
|
278
|
-
order: position === 'flex-start' ? 0 : 2,
|
|
279
|
-
textAlign,
|
|
280
|
-
zIndex: 2,
|
|
281
|
-
cursor: 'pointer',
|
|
282
|
-
}}
|
|
283
|
-
onClick={() => onClick()}
|
|
284
|
-
>
|
|
285
|
-
{children}
|
|
286
|
-
</TextFieldSlotStyled>
|
|
287
|
-
) : (
|
|
288
|
-
<TextFieldSlotStyled
|
|
289
|
-
{...sharedStyles}
|
|
290
|
-
style={{
|
|
291
|
-
float: position === 'flex-start' ? 'left' : 'right',
|
|
292
|
-
order: position === 'flex-start' ? 0 : 2,
|
|
293
|
-
textAlign,
|
|
294
|
-
}}
|
|
295
|
-
>
|
|
296
|
-
{children}
|
|
297
|
-
</TextFieldSlotStyled>
|
|
298
|
-
)
|
|
299
|
-
}
|
|
1
|
+
import { ComponentProps, ReactNode } from 'react'
|
|
2
|
+
import { styled } from '../styles'
|
|
3
|
+
import { TextField as TextFieldRadix } from '@radix-ui/themes'
|
|
4
|
+
import Icon from './Icon'
|
|
5
|
+
import { typographyValues } from '../types/typographyValues'
|
|
6
|
+
import { TextStyle } from './Text'
|
|
7
|
+
import { Flex } from './Flex'
|
|
8
|
+
import { format, MaskOptions, useMask, unformat } from '@react-input/mask'
|
|
9
|
+
|
|
10
|
+
export const TextFieldStyled = styled(TextFieldRadix.Root, {
|
|
11
|
+
height: '$40',
|
|
12
|
+
fontFamily: '$default',
|
|
13
|
+
borderRadius: '$sm',
|
|
14
|
+
boxSizing: 'border-box',
|
|
15
|
+
color: '$dark500',
|
|
16
|
+
border: '1px solid $dark300',
|
|
17
|
+
position: 'relative',
|
|
18
|
+
display: 'flex',
|
|
19
|
+
width: '100%',
|
|
20
|
+
alignItems: 'center',
|
|
21
|
+
padding: '0 $14',
|
|
22
|
+
gap: '$14',
|
|
23
|
+
input: {
|
|
24
|
+
order: 1,
|
|
25
|
+
outline: 'none',
|
|
26
|
+
border: 'none',
|
|
27
|
+
margin: 0,
|
|
28
|
+
width: '100%',
|
|
29
|
+
font: 'inherit',
|
|
30
|
+
textAlign: 'left',
|
|
31
|
+
},
|
|
32
|
+
|
|
33
|
+
'&:has(input:focus)': {
|
|
34
|
+
border: '2px solid $brand300',
|
|
35
|
+
},
|
|
36
|
+
'&:has(input:disabled)': {
|
|
37
|
+
backgroundColor: '$dark100',
|
|
38
|
+
color: '$dark400',
|
|
39
|
+
border: '1px solid $dark200',
|
|
40
|
+
cursor: 'not-allowed',
|
|
41
|
+
},
|
|
42
|
+
|
|
43
|
+
variants: {
|
|
44
|
+
color: {
|
|
45
|
+
default: {
|
|
46
|
+
color: '$dark400',
|
|
47
|
+
border: '1px solid $dark200',
|
|
48
|
+
'&:has(input:focus)': {
|
|
49
|
+
border: '2px solid $brand300',
|
|
50
|
+
},
|
|
51
|
+
'&:has(input:disabled)': {
|
|
52
|
+
backgroundColor: '$dark100',
|
|
53
|
+
color: '$dark400',
|
|
54
|
+
border: '1px solid $dark200',
|
|
55
|
+
cursor: 'not-allowed',
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
error: {
|
|
59
|
+
border: '1px solid $error400',
|
|
60
|
+
color: '$error400',
|
|
61
|
+
'input::placeholder': {
|
|
62
|
+
color: '$error400',
|
|
63
|
+
},
|
|
64
|
+
'&:has(input:focus)': {
|
|
65
|
+
border: '2px solid $error400',
|
|
66
|
+
},
|
|
67
|
+
'&:has(input:disabled)': {
|
|
68
|
+
backgroundColor: '$error50',
|
|
69
|
+
color: '$error300',
|
|
70
|
+
border: '1px solid $error100',
|
|
71
|
+
cursor: 'not-allowed',
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
|
|
76
|
+
typography: typographyValues,
|
|
77
|
+
fontWeight: {
|
|
78
|
+
regular: { fontWeight: '$regular' },
|
|
79
|
+
medium: { fontWeight: '$medium' },
|
|
80
|
+
semibold: { fontWeight: '$semibold' },
|
|
81
|
+
bold: { fontWeight: '$bold' },
|
|
82
|
+
},
|
|
83
|
+
textAlign: {
|
|
84
|
+
left: { textAlign: 'left' },
|
|
85
|
+
center: { textAlign: 'center' },
|
|
86
|
+
right: { textAlign: 'right' },
|
|
87
|
+
},
|
|
88
|
+
isValid: {
|
|
89
|
+
true: {},
|
|
90
|
+
false: {},
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
|
|
94
|
+
compoundVariants: [
|
|
95
|
+
{
|
|
96
|
+
isValid: false,
|
|
97
|
+
css: {
|
|
98
|
+
border: '1px solid $error400',
|
|
99
|
+
color: '$error400',
|
|
100
|
+
backgroundColor: '$error50',
|
|
101
|
+
input: {
|
|
102
|
+
'&::placeholder': {
|
|
103
|
+
color: '$error400',
|
|
104
|
+
},
|
|
105
|
+
backgroundColor: '$error50',
|
|
106
|
+
},
|
|
107
|
+
'&:has(input:focus)': {
|
|
108
|
+
border: '2px solid $error400',
|
|
109
|
+
},
|
|
110
|
+
'&:has(input:disabled)': {
|
|
111
|
+
input: {
|
|
112
|
+
backgroundColor: '$error50',
|
|
113
|
+
},
|
|
114
|
+
backgroundColor: '$error50',
|
|
115
|
+
color: '$error300',
|
|
116
|
+
border: '1px solid $error100',
|
|
117
|
+
cursor: 'not-allowed',
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
isValid: true,
|
|
123
|
+
css: {
|
|
124
|
+
'&:has(input:focus)': {
|
|
125
|
+
border: '2px solid $success500',
|
|
126
|
+
},
|
|
127
|
+
'&:has(input:disabled)': {
|
|
128
|
+
backgroundColor: '$dark100',
|
|
129
|
+
color: '$dark400',
|
|
130
|
+
border: '1px solid $dark200',
|
|
131
|
+
cursor: 'not-allowed',
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
],
|
|
136
|
+
})
|
|
137
|
+
|
|
138
|
+
export const TextFieldSlotStyled = styled(TextFieldRadix.Slot, {
|
|
139
|
+
display: 'flex',
|
|
140
|
+
alignItems: 'center',
|
|
141
|
+
justifyContent: 'center',
|
|
142
|
+
padding: 4,
|
|
143
|
+
|
|
144
|
+
variants: {
|
|
145
|
+
typography: typographyValues,
|
|
146
|
+
fontWeight: {
|
|
147
|
+
regular: { fontWeight: '$regular' },
|
|
148
|
+
medium: { fontWeight: '$medium' },
|
|
149
|
+
semibold: { fontWeight: '$semibold' },
|
|
150
|
+
bold: { fontWeight: '$bold' },
|
|
151
|
+
},
|
|
152
|
+
textAlign: {
|
|
153
|
+
left: { textAlign: 'left' },
|
|
154
|
+
right: { textAlign: 'right' },
|
|
155
|
+
center: { textAlign: 'center' },
|
|
156
|
+
},
|
|
157
|
+
},
|
|
158
|
+
})
|
|
159
|
+
|
|
160
|
+
export type TextFieldProps = ComponentProps<typeof TextFieldStyled> & {
|
|
161
|
+
addon?: ReactNode
|
|
162
|
+
placeholder?: string
|
|
163
|
+
children?: React.ReactNode
|
|
164
|
+
isValid?: boolean
|
|
165
|
+
name?: string
|
|
166
|
+
typography?: string
|
|
167
|
+
fontWeight?: 'regular' | 'medium' | 'semibold' | 'bold'
|
|
168
|
+
textAlign?: 'left' | 'right' | 'center'
|
|
169
|
+
mask?: MaskOptions
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
export type TextFieldSlotProps = Omit<
|
|
173
|
+
ComponentProps<typeof TextFieldStyled>,
|
|
174
|
+
'color'
|
|
175
|
+
> & {
|
|
176
|
+
placeholder?: string
|
|
177
|
+
children?: React.ReactNode
|
|
178
|
+
position?: 'flex-start' | 'flex-end'
|
|
179
|
+
onClick?: () => void
|
|
180
|
+
color?: 'error' | 'success' | undefined
|
|
181
|
+
typography?: string
|
|
182
|
+
fontWeight?: 'regular' | 'medium' | 'semibold' | 'bold'
|
|
183
|
+
textAlign?: 'left' | 'right' | 'center'
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
const InputAddon = styled(TextStyle, {
|
|
187
|
+
boxSizing: 'border-box',
|
|
188
|
+
border: '1px solid $dark300',
|
|
189
|
+
height: '$40',
|
|
190
|
+
padding: '0 $12',
|
|
191
|
+
margin: '0 auto',
|
|
192
|
+
|
|
193
|
+
color: '$dark600',
|
|
194
|
+
whiteSpace: 'nowrap',
|
|
195
|
+
borderRadius: '$sm 0px 0px $sm',
|
|
196
|
+
borderRightWidth: '0px',
|
|
197
|
+
display: 'flex',
|
|
198
|
+
flexWrap: 'nowrap',
|
|
199
|
+
alignItems: 'center',
|
|
200
|
+
lineHeight: 1,
|
|
201
|
+
})
|
|
202
|
+
export const maskFormat = format
|
|
203
|
+
export const maskUnformat = unformat
|
|
204
|
+
|
|
205
|
+
export function TextField({
|
|
206
|
+
children,
|
|
207
|
+
isValid,
|
|
208
|
+
name,
|
|
209
|
+
color,
|
|
210
|
+
typography,
|
|
211
|
+
fontWeight,
|
|
212
|
+
addon,
|
|
213
|
+
textAlign = 'left',
|
|
214
|
+
mask,
|
|
215
|
+
...props
|
|
216
|
+
}: TextFieldProps) {
|
|
217
|
+
const maskRef = mask ? useMask(mask) : undefined
|
|
218
|
+
|
|
219
|
+
return (
|
|
220
|
+
<Flex gap={'0'} css={{ width: '100%' }}>
|
|
221
|
+
{!!addon && <InputAddon typography="labelSmall">{addon}</InputAddon>}
|
|
222
|
+
|
|
223
|
+
<TextFieldStyled
|
|
224
|
+
color={color}
|
|
225
|
+
isValid={isValid}
|
|
226
|
+
name={name}
|
|
227
|
+
typography={typography}
|
|
228
|
+
fontWeight={fontWeight}
|
|
229
|
+
textAlign={textAlign}
|
|
230
|
+
ref={maskRef}
|
|
231
|
+
{...props}
|
|
232
|
+
style={
|
|
233
|
+
addon
|
|
234
|
+
? { borderTopLeftRadius: '0px', borderBottomLeftRadius: '0px' }
|
|
235
|
+
: undefined
|
|
236
|
+
}
|
|
237
|
+
>
|
|
238
|
+
{children}
|
|
239
|
+
{isValid && (
|
|
240
|
+
<TextFieldSlot
|
|
241
|
+
position="flex-end"
|
|
242
|
+
name={name}
|
|
243
|
+
color={color as TextFieldSlotProps['color']}
|
|
244
|
+
typography={typography}
|
|
245
|
+
fontWeight={fontWeight}
|
|
246
|
+
textAlign={textAlign}
|
|
247
|
+
>
|
|
248
|
+
<Icon name="check" />
|
|
249
|
+
</TextFieldSlot>
|
|
250
|
+
)}
|
|
251
|
+
</TextFieldStyled>
|
|
252
|
+
</Flex>
|
|
253
|
+
)
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
export function TextFieldSlot({
|
|
257
|
+
children,
|
|
258
|
+
position = 'flex-start',
|
|
259
|
+
onClick,
|
|
260
|
+
typography = 'bodyXS',
|
|
261
|
+
fontWeight = 'regular',
|
|
262
|
+
textAlign = 'right',
|
|
263
|
+
...props
|
|
264
|
+
}: TextFieldSlotProps) {
|
|
265
|
+
const sharedStyles = {
|
|
266
|
+
typography,
|
|
267
|
+
fontWeight,
|
|
268
|
+
textAlign,
|
|
269
|
+
...props,
|
|
270
|
+
color: undefined,
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
return onClick ? (
|
|
274
|
+
<TextFieldSlotStyled
|
|
275
|
+
{...sharedStyles}
|
|
276
|
+
style={{
|
|
277
|
+
float: position === 'flex-start' ? 'left' : 'right',
|
|
278
|
+
order: position === 'flex-start' ? 0 : 2,
|
|
279
|
+
textAlign,
|
|
280
|
+
zIndex: 2,
|
|
281
|
+
cursor: 'pointer',
|
|
282
|
+
}}
|
|
283
|
+
onClick={() => onClick()}
|
|
284
|
+
>
|
|
285
|
+
{children}
|
|
286
|
+
</TextFieldSlotStyled>
|
|
287
|
+
) : (
|
|
288
|
+
<TextFieldSlotStyled
|
|
289
|
+
{...sharedStyles}
|
|
290
|
+
style={{
|
|
291
|
+
float: position === 'flex-start' ? 'left' : 'right',
|
|
292
|
+
order: position === 'flex-start' ? 0 : 2,
|
|
293
|
+
textAlign,
|
|
294
|
+
}}
|
|
295
|
+
>
|
|
296
|
+
{children}
|
|
297
|
+
</TextFieldSlotStyled>
|
|
298
|
+
)
|
|
299
|
+
}
|