@lets-events/react 5.0.0 → 6.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.
@@ -1,193 +1,241 @@
1
- import { ComponentProps, useState } from 'react'
2
- import { styled } from '../styles'
3
- import { TextField as TextFieldRadix } from "@radix-ui/themes";
4
- import Icon from './Icon';
5
-
6
- export const TextFieldStyled = styled(TextFieldRadix.Root, {
7
- height: '$40',
8
- fontFamily: '$default',
9
- letterSpacing: '0px',
10
- fontSize: '$13',
11
- padding: '$12 $14',
12
- borderRadius: '$sm',
13
- boxSizing: 'border-box',
14
- color: '$dark500',
15
- border: '1px solid $dark300',
16
- position: 'relative',
17
- display: 'flex',
18
- 'input': {
19
- order: 1,
20
- border: 'none',
21
- outline: 'none',
22
- padding: 0,
23
- margin: 0,
24
- width: '100%',
25
- },
26
-
27
- '&:has(input:focus)': {
28
- border: '2px solid $brand300',
29
- },
30
- '&:has(input:disabled)': {
31
- backgroundColor: '$dark100',
32
- color: '$dark400',
33
- border: '1px solid $dark200',
34
- cursor: 'not-allowed',
35
- },
36
- variants: {
37
- color: {
38
- default: {
39
- color: '$dark400',
40
- border: '1px solid $dark200',
41
- '&:has(input:focus)': {
42
- border: '2px solid $brand300',
43
- },
44
- '&:has(input:disabled)': {
45
- backgroundColor: '$dark100',
46
- color: '$dark400',
47
- border: '1px solid $dark200',
48
- cursor: 'not-allowed',
49
- },
50
- },
51
- error:{
52
- border: '1px solid $error400',
53
- color: '$error400',
54
- 'input::placeholder': {
55
- color: '$error400',
56
- },
57
- '& hast(input:focus)': {
58
- border: '2px solid $error400',
59
- },
60
- '&:has(input:disabled)': {
61
- backgroundColor: '$error50',
62
- color: '$error300',
63
- border: '1px solid $error100',
64
- cursor: 'not-allowed',
65
- },
66
- },
67
-
68
- },
69
- isValid: {
70
- true: {},
71
- false: {
72
- }
73
- },
74
- },
75
-
76
- compoundVariants: [
77
- {
78
- isValid: false,
79
- css: {
80
- border: '1px solid $error400',
81
- color: '$error400',
82
- backgroundColor: '$error50',
83
- 'input': {
84
- '&::placeholder': {
85
- color: '$error400',
86
- },
87
- backgroundColor: '$error50',
88
- },
89
- '&:has(input:focus)': {
90
- border: '2px solid $error400',
91
- },
92
- '&:has(input:disabled)': {
93
- 'input': {
94
- backgroundColor: '$error50',
95
- },
96
- backgroundColor: '$error50',
97
- color: '$error300',
98
- border: '1px solid $error100',
99
- cursor: 'not-allowed',
100
- },
101
- }
102
- },
103
- {
104
- isValid: true,
105
- css: {
106
- '&:has(input:focus)': {
107
- border: '2px solid $success500',
108
- },
109
- '&:has(input:disabled)': {
110
- backgroundColor: '$dark100',
111
- color: '$dark400',
112
- border: '1px solid $dark200',
113
- cursor: 'not-allowed',
114
- },
115
- }
116
- }
117
- ],
118
- })
119
-
120
- export const TextFieldSlotStyled = styled(TextFieldRadix.Slot, {
121
- display: 'flex',
122
- alignItems: 'center',
123
- justifyContent: 'center',
124
- })
125
-
126
- export type TextFieldProps = ComponentProps<typeof TextFieldStyled> & {
127
- placeholder?: string
128
- children?: React.ReactNode
129
- isValid?: boolean,
130
- name?: string,
131
- }
132
-
133
- export type TextFieldSlotProps = Omit<ComponentProps<typeof TextFieldStyled>, 'color'> & {
134
- placeholder?: string
135
- children?: React.ReactNode
136
- position?: 'flex-start' | 'flex-end'
137
- onClick?: () => void,
138
- color?: "error" | "success" | undefined
139
- }
140
-
141
- export function TextField({
142
- children,
143
- isValid,
144
- name,
145
- color,
146
- ...props
147
- }: TextFieldProps) {
148
-
149
- return (
150
- <TextFieldStyled color={color} isValid={isValid} name={name} {...props}>
151
- {children}
152
- {isValid && (
153
- <TextFieldSlot position='flex-end' name={name} color={color as TextFieldSlotProps['color']}>
154
- <Icon name='check' />
155
- </TextFieldSlot>
156
- )}
157
- </TextFieldStyled>
158
- )
159
- }
160
-
161
- export function TextFieldSlot({
162
- children,
163
- position = 'flex-start',
164
- onClick,
165
- ...props
166
- }: TextFieldSlotProps) {
167
- console.log('onclick', onClick)
168
-
169
- return (
170
- <>
171
- {
172
- !!onClick ?
173
- <TextFieldSlotStyled {...{ ...props, color: undefined }} style={{
174
- position: 'absolute',
175
- left: position === 'flex-end' ? 'none' : 15,
176
- right: position === 'flex-start' ? 'none' : 15,
177
- padding: 13,
178
- zIndex: 2,
179
- top: 0,
180
- cursor: 'pointer',
181
- }} onClick={() => onClick()}>{children}</TextFieldSlotStyled>
182
- :
183
- <TextFieldSlotStyled {...{ ...props, color: undefined }} style={{
184
- float: position === 'flex-start' ? 'left' : 'right',
185
- order: position === 'flex-start' ? 0 : 2,
186
- marginLeft: position === 'flex-start' ? 0 : 15,
187
- marginRight: position === 'flex-end' ? 0 : 15,
188
- }}>{children}</TextFieldSlotStyled>
189
-
190
- }
191
- </>
192
- )
193
- }
1
+ import { ComponentProps } 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
+
7
+ export const TextFieldStyled = styled(TextFieldRadix.Root, {
8
+ height: '$40',
9
+ fontFamily: '$default',
10
+ padding: '$12 $14',
11
+ borderRadius: '$sm',
12
+ boxSizing: 'border-box',
13
+ color: '$dark500',
14
+ border: '1px solid $dark300',
15
+ position: 'relative',
16
+ display: 'flex',
17
+
18
+ 'input': {
19
+ order: 1,
20
+ border: 'none',
21
+ outline: 'none',
22
+ padding: 0,
23
+ margin: 0,
24
+ width: '100%',
25
+ font: 'inherit',
26
+ },
27
+
28
+ '&:has(input:focus)': {
29
+ border: '2px solid $brand300',
30
+ },
31
+ '&:has(input:disabled)': {
32
+ backgroundColor: '$dark100',
33
+ color: '$dark400',
34
+ border: '1px solid $dark200',
35
+ cursor: 'not-allowed',
36
+ },
37
+
38
+ variants: {
39
+ color: {
40
+ default: {
41
+ color: '$dark400',
42
+ border: '1px solid $dark200',
43
+ '&:has(input:focus)': {
44
+ border: '2px solid $brand300',
45
+ },
46
+ '&:has(input:disabled)': {
47
+ backgroundColor: '$dark100',
48
+ color: '$dark400',
49
+ border: '1px solid $dark200',
50
+ cursor: 'not-allowed',
51
+ },
52
+ },
53
+ error: {
54
+ border: '1px solid $error400',
55
+ color: '$error400',
56
+ 'input::placeholder': {
57
+ color: '$error400',
58
+ },
59
+ '&:has(input:focus)': {
60
+ border: '2px solid $error400',
61
+ },
62
+ '&:has(input:disabled)': {
63
+ backgroundColor: '$error50',
64
+ color: '$error300',
65
+ border: '1px solid $error100',
66
+ cursor: 'not-allowed',
67
+ },
68
+ }
69
+ },
70
+
71
+ typography: typographyValues,
72
+ fontWeight: {
73
+ regular: { fontWeight: '$regular' },
74
+ medium: { fontWeight: '$medium' },
75
+ semibold: { fontWeight: '$semibold' },
76
+ bold: { fontWeight: '$bold' },
77
+ },
78
+ isValid: {
79
+ true: {},
80
+ false: {}
81
+ },
82
+ },
83
+
84
+ compoundVariants: [
85
+ {
86
+ isValid: false,
87
+ css: {
88
+ border: '1px solid $error400',
89
+ color: '$error400',
90
+ backgroundColor: '$error50',
91
+ 'input': {
92
+ '&::placeholder': {
93
+ color: '$error400',
94
+ },
95
+ backgroundColor: '$error50',
96
+ },
97
+ '&:has(input:focus)': {
98
+ border: '2px solid $error400',
99
+ },
100
+ '&:has(input:disabled)': {
101
+ 'input': {
102
+ backgroundColor: '$error50',
103
+ },
104
+ backgroundColor: '$error50',
105
+ color: '$error300',
106
+ border: '1px solid $error100',
107
+ cursor: 'not-allowed',
108
+ },
109
+ }
110
+ },
111
+ {
112
+ isValid: true,
113
+ css: {
114
+ '&:has(input:focus)': {
115
+ border: '2px solid $success500',
116
+ },
117
+ '&:has(input:disabled)': {
118
+ backgroundColor: '$dark100',
119
+ color: '$dark400',
120
+ border: '1px solid $dark200',
121
+ cursor: 'not-allowed',
122
+ },
123
+ }
124
+ }
125
+ ],
126
+ })
127
+
128
+ export const TextFieldSlotStyled = styled(TextFieldRadix.Slot, {
129
+ display: 'flex',
130
+ alignItems: 'center',
131
+ justifyContent: 'center',
132
+
133
+ variants: {
134
+ typography: typographyValues,
135
+ fontWeight: {
136
+ regular: { fontWeight: '$regular' },
137
+ medium: { fontWeight: '$medium' },
138
+ semibold: { fontWeight: '$semibold' },
139
+ bold: { fontWeight: '$bold' },
140
+ }
141
+ }
142
+ })
143
+
144
+ export type TextFieldProps = ComponentProps<typeof TextFieldStyled> & {
145
+ placeholder?: string
146
+ children?: React.ReactNode
147
+ isValid?: boolean
148
+ name?: string
149
+ typography?: string
150
+ fontWeight?: 'regular' | 'medium' | 'semibold' | 'bold'
151
+ }
152
+
153
+ export type TextFieldSlotProps = Omit<ComponentProps<typeof TextFieldStyled>, 'color'> & {
154
+ placeholder?: string
155
+ children?: React.ReactNode
156
+ position?: 'flex-start' | 'flex-end'
157
+ onClick?: () => void
158
+ color?: "error" | "success" | undefined
159
+ typography?: string
160
+ fontWeight?: 'regular' | 'medium' | 'semibold' | 'bold'
161
+ }
162
+
163
+ export function TextField({
164
+ children,
165
+ isValid,
166
+ name,
167
+ color,
168
+ typography,
169
+ fontWeight,
170
+ ...props
171
+ }: TextFieldProps) {
172
+ 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
184
+ position='flex-end'
185
+ name={name}
186
+ color={color as TextFieldSlotProps['color']}
187
+ typography={typography}
188
+ fontWeight={fontWeight}
189
+ >
190
+ <Icon name='check' />
191
+ </TextFieldSlot>
192
+ )}
193
+ </TextFieldStyled>
194
+ )
195
+ }
196
+
197
+ export function TextFieldSlot({
198
+ children,
199
+ position = 'flex-start',
200
+ onClick,
201
+ typography = 'bodyXS',
202
+ fontWeight = 'regular',
203
+ ...props
204
+ }: TextFieldSlotProps) {
205
+ const sharedStyles = {
206
+ typography,
207
+ fontWeight,
208
+ ...props,
209
+ color: undefined,
210
+ }
211
+
212
+ return !!onClick ? (
213
+ <TextFieldSlotStyled
214
+ {...sharedStyles}
215
+ style={{
216
+ position: 'absolute',
217
+ left: position === 'flex-end' ? 'none' : 15,
218
+ right: position === 'flex-start' ? 'none' : 15,
219
+ padding: 13,
220
+ zIndex: 2,
221
+ top: 0,
222
+ cursor: 'pointer',
223
+ }}
224
+ onClick={() => onClick()}
225
+ >
226
+ {children}
227
+ </TextFieldSlotStyled>
228
+ ) : (
229
+ <TextFieldSlotStyled
230
+ {...sharedStyles}
231
+ style={{
232
+ float: position === 'flex-start' ? 'left' : 'right',
233
+ order: position === 'flex-start' ? 0 : 2,
234
+ marginLeft: position === 'flex-start' ? 0 : 15,
235
+ marginRight: position === 'flex-end' ? 0 : 15,
236
+ }}
237
+ >
238
+ {children}
239
+ </TextFieldSlotStyled>
240
+ )
241
+ }
package/src/index.tsx CHANGED
@@ -1,27 +1,27 @@
1
- // Icon
2
- export * from './components/Icon'
3
-
4
- // Text
5
- export * from './components/Text'
6
-
7
- // Components
8
- export * from './components/Button'
9
- export * from './components/ButtonGroup'
10
- export * from './components/Avatar'
11
- export * from './components/TextField'
12
- export * from './components/RadioGroup'
13
- export * from './components/CheckboxGroup'
14
- export * from './components/Filter'
15
- export * from './components/Dropdown'
16
- export * from './components/Badge'
17
- export * from './components/Modal'
18
- export * from './components/Alert'
19
- export * from './components/Switch'
20
- export * from './components/Step'
21
-
22
- // Layouts
23
- export * from './components/Flex'
24
- export * from './components/Box'
25
- export * from './components/Grid'
26
- export * from './components/Container'
27
- export * from './components/Section'
1
+ // Icon
2
+ export * from './components/Icon'
3
+
4
+ // Text
5
+ export * from './components/Text'
6
+
7
+ // Components
8
+ export * from './components/Button'
9
+ export * from './components/ButtonGroup'
10
+ export * from './components/Avatar'
11
+ export * from './components/TextField'
12
+ export * from './components/RadioGroup'
13
+ export * from './components/CheckboxGroup'
14
+ export * from './components/Filter'
15
+ export * from './components/Dropdown'
16
+ export * from './components/Badge'
17
+ export * from './components/Modal'
18
+ export * from './components/Alert'
19
+ export * from './components/Switch'
20
+ export * from './components/Step'
21
+
22
+ // Layouts
23
+ export * from './components/Flex'
24
+ export * from './components/Box'
25
+ export * from './components/Grid'
26
+ export * from './components/Container'
27
+ export * from './components/Section'
@@ -1,38 +1,38 @@
1
- import {
2
- colors,
3
- fontSizes,
4
- fontWeights,
5
- fonts,
6
- lineHeights,
7
- radii,
8
- space,
9
- } from '@lets-events/tokens'
10
-
11
- import { createStitches, defaultThemeMap } from '@stitches/react'
12
-
13
- export const {
14
- styled,
15
- css,
16
- globalCss,
17
- keyframes,
18
- getCssText,
19
- theme,
20
- createTheme,
21
- config,
22
- } = createStitches({
23
- themeMap: {
24
- ...defaultThemeMap,
25
- height: 'space',
26
- width: 'space',
27
- gap: 'space'
28
- },
29
- theme: {
30
- colors,
31
- fontSizes,
32
- fonts,
33
- fontWeights,
34
- lineHeights,
35
- radii,
36
- space,
37
- },
38
- })
1
+ import {
2
+ colors,
3
+ fontSizes,
4
+ fontWeights,
5
+ fonts,
6
+ lineHeights,
7
+ radii,
8
+ space,
9
+ } from '@lets-events/tokens'
10
+
11
+ import { createStitches, defaultThemeMap } from '@stitches/react'
12
+
13
+ export const {
14
+ styled,
15
+ css,
16
+ globalCss,
17
+ keyframes,
18
+ getCssText,
19
+ theme,
20
+ createTheme,
21
+ config,
22
+ } = createStitches({
23
+ themeMap: {
24
+ ...defaultThemeMap,
25
+ height: 'space',
26
+ width: 'space',
27
+ gap: 'space'
28
+ },
29
+ theme: {
30
+ colors,
31
+ fontSizes,
32
+ fonts,
33
+ fontWeights,
34
+ lineHeights,
35
+ radii,
36
+ space,
37
+ },
38
+ })