cherry-styled-components 0.1.1 → 0.1.2
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/.claude/settings.local.json +1 -3
- package/.prettierignore +5 -0
- package/.prettierrc +2 -2
- package/.supermaven/config.json +6 -1
- package/dist/cherry.js +697 -613
- package/dist/cherry.umd.cjs +80 -80
- package/dist/lib/input.d.ts +1 -0
- package/dist/lib/range.d.ts +1 -0
- package/dist/lib/select.d.ts +1 -0
- package/dist/lib/textarea.d.ts +1 -0
- package/dist/lib/toggle.d.ts +1 -0
- package/package.json +2 -2
- package/src/App.tsx +101 -80
- package/src/lib/box.tsx +26 -26
- package/src/lib/button.tsx +162 -162
- package/src/lib/col.tsx +48 -45
- package/src/lib/container.tsx +69 -59
- package/src/lib/flex.tsx +99 -92
- package/src/lib/grid.tsx +76 -64
- package/src/lib/index.ts +15 -15
- package/src/lib/input.tsx +418 -384
- package/src/lib/max-width.tsx +53 -50
- package/src/lib/range.tsx +234 -208
- package/src/lib/select.tsx +136 -121
- package/src/lib/space.tsx +55 -52
- package/src/lib/styled-components/index.ts +2 -2
- package/src/lib/styled-components/registry.tsx +29 -26
- package/src/lib/styled-components/theme-provider.tsx +50 -49
- package/src/lib/textarea.tsx +115 -94
- package/src/lib/toggle.tsx +158 -147
- package/src/lib/utils/global.tsx +95 -95
- package/src/lib/utils/icons.tsx +84 -84
- package/src/lib/utils/index.ts +5 -5
- package/src/lib/utils/mixins.tsx +108 -95
- package/src/lib/utils/theme.ts +289 -289
- package/src/lib/utils/typography.tsx +204 -204
- package/src/main.tsx +19 -14
- package/src/toggle-theme.tsx +25 -25
- package/src/vite-env.d.ts +8 -8
- package/vite.config.js +18 -18
package/src/lib/input.tsx
CHANGED
|
@@ -1,384 +1,418 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import React, { forwardRef } from "react";
|
|
3
|
-
import styled, { css } from "styled-components";
|
|
4
|
-
import type { IStyledComponent } from "styled-components";
|
|
5
|
-
import {
|
|
6
|
-
Theme,
|
|
7
|
-
IconCheck,
|
|
8
|
-
formElementHeightStyles,
|
|
9
|
-
fullWidthStyles,
|
|
10
|
-
resetButton,
|
|
11
|
-
resetInput,
|
|
12
|
-
statusBorderStyles,
|
|
13
|
-
IconCalendar,
|
|
14
|
-
} from "./utils";
|
|
15
|
-
|
|
16
|
-
interface InputProps extends React.InputHTMLAttributes<HTMLInputElement> {
|
|
17
|
-
children?: React.ReactNode;
|
|
18
|
-
$
|
|
19
|
-
$
|
|
20
|
-
$
|
|
21
|
-
$
|
|
22
|
-
$
|
|
23
|
-
$
|
|
24
|
-
$
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
$
|
|
31
|
-
$
|
|
32
|
-
$
|
|
33
|
-
$
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
{props
|
|
374
|
-
|
|
375
|
-
{props.$
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
1
|
+
"use client";
|
|
2
|
+
import React, { forwardRef } from "react";
|
|
3
|
+
import styled, { css } from "styled-components";
|
|
4
|
+
import type { IStyledComponent } from "styled-components";
|
|
5
|
+
import {
|
|
6
|
+
Theme,
|
|
7
|
+
IconCheck,
|
|
8
|
+
formElementHeightStyles,
|
|
9
|
+
fullWidthStyles,
|
|
10
|
+
resetButton,
|
|
11
|
+
resetInput,
|
|
12
|
+
statusBorderStyles,
|
|
13
|
+
IconCalendar,
|
|
14
|
+
} from "./utils";
|
|
15
|
+
|
|
16
|
+
interface InputProps extends React.InputHTMLAttributes<HTMLInputElement> {
|
|
17
|
+
children?: React.ReactNode;
|
|
18
|
+
$wrapperClassName?: string;
|
|
19
|
+
$label?: string;
|
|
20
|
+
$size?: "default" | "big";
|
|
21
|
+
$error?: boolean;
|
|
22
|
+
$success?: boolean;
|
|
23
|
+
$fullWidth?: boolean;
|
|
24
|
+
$icon?: React.ReactNode;
|
|
25
|
+
$iconPosition?: "left" | "right";
|
|
26
|
+
theme?: Theme;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
interface LabelProps extends React.LabelHTMLAttributes<HTMLLabelElement> {
|
|
30
|
+
$label?: string;
|
|
31
|
+
$size?: "default" | "big";
|
|
32
|
+
$error?: boolean;
|
|
33
|
+
$success?: boolean;
|
|
34
|
+
$fullWidth?: boolean;
|
|
35
|
+
theme?: Theme;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export const StyledInputWrapper: IStyledComponent<
|
|
39
|
+
"web",
|
|
40
|
+
React.HTMLAttributes<HTMLSpanElement> &
|
|
41
|
+
Pick<InputProps, "$label" | "$fullWidth" | "type">
|
|
42
|
+
> = styled.span<Pick<InputProps, "$label" | "$fullWidth" | "type">>`
|
|
43
|
+
display: inline-flex;
|
|
44
|
+
flex-wrap: ${({ type }) =>
|
|
45
|
+
type === "checkbox" || type === "radio" ? "nowrap" : "wrap"};
|
|
46
|
+
align-items: center;
|
|
47
|
+
|
|
48
|
+
${({ $label }) =>
|
|
49
|
+
$label &&
|
|
50
|
+
css`
|
|
51
|
+
gap: 5px;
|
|
52
|
+
align-items: flex-start;
|
|
53
|
+
`}
|
|
54
|
+
|
|
55
|
+
& .icon-calendar {
|
|
56
|
+
position: absolute;
|
|
57
|
+
top: 50%;
|
|
58
|
+
right: 17px;
|
|
59
|
+
left: initial;
|
|
60
|
+
transform: translateY(-50%);
|
|
61
|
+
pointer-events: none;
|
|
62
|
+
width: 24px;
|
|
63
|
+
height: 24px;
|
|
64
|
+
|
|
65
|
+
@supports (-moz-appearance: none) {
|
|
66
|
+
display: none;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
${({ $fullWidth }) => fullWidthStyles($fullWidth ? true : false)}
|
|
71
|
+
`;
|
|
72
|
+
|
|
73
|
+
export const StyledLabel: IStyledComponent<"web", LabelProps> =
|
|
74
|
+
styled.label<LabelProps>`
|
|
75
|
+
display: inline-block;
|
|
76
|
+
color: ${({ theme }) => theme.colors.grayDark};
|
|
77
|
+
font-size: ${({ theme }) => theme.fontSizes.small.lg};
|
|
78
|
+
line-height: ${({ theme }) => theme.lineHeights.small.lg};
|
|
79
|
+
`;
|
|
80
|
+
|
|
81
|
+
const StyledInput = styled.input<InputProps>`
|
|
82
|
+
${resetButton};
|
|
83
|
+
${resetInput};
|
|
84
|
+
font-family: inherit;
|
|
85
|
+
display: inline-block;
|
|
86
|
+
padding: 17px 15px;
|
|
87
|
+
border-radius: ${({ theme }) => theme.spacing.radius.xs};
|
|
88
|
+
font-weight: 400;
|
|
89
|
+
white-space: nowrap;
|
|
90
|
+
hyphens: auto;
|
|
91
|
+
color: ${({ theme }) => theme.colors.dark};
|
|
92
|
+
background: ${({ theme }) => theme.colors.light};
|
|
93
|
+
border: solid 2px ${({ theme }) => theme.colors.grayLight};
|
|
94
|
+
box-shadow: 0 0 0 0px ${({ theme }) => theme.colors.primaryLight};
|
|
95
|
+
transition: all 0.3s ease;
|
|
96
|
+
word-break: keep-all;
|
|
97
|
+
white-space: nowrap;
|
|
98
|
+
display: inline-flex;
|
|
99
|
+
|
|
100
|
+
&[type="date"] {
|
|
101
|
+
padding: 17px 45px 17px 15px;
|
|
102
|
+
|
|
103
|
+
@supports (-moz-appearance: none) {
|
|
104
|
+
padding: 13px 15px;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
&::-webkit-datetime-edit {
|
|
109
|
+
padding: 0;
|
|
110
|
+
margin: 0;
|
|
111
|
+
vertical-align: middle;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
&::-webkit-datetime-edit-fields-wrapper {
|
|
115
|
+
padding: 4px 0;
|
|
116
|
+
margin: 0;
|
|
117
|
+
vertical-align: middle;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
&::-webkit-calendar-picker-indicator {
|
|
121
|
+
background: transparent;
|
|
122
|
+
cursor: pointer;
|
|
123
|
+
position: absolute;
|
|
124
|
+
right: 15px;
|
|
125
|
+
top: 50%;
|
|
126
|
+
transform: translateY(-50%);
|
|
127
|
+
width: 24px;
|
|
128
|
+
height: 24px;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
&::-webkit-datetime-edit-text {
|
|
132
|
+
color: ${({ theme }) => theme.colors.gray};
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
&::-webkit-datetime-edit-month-field {
|
|
136
|
+
&:focus {
|
|
137
|
+
background: ${({ theme }) => theme.colors.primary};
|
|
138
|
+
color: ${({ theme }) => theme.colors.light};
|
|
139
|
+
border-radius: 4px;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
&::-webkit-datetime-edit-day-field {
|
|
144
|
+
&:focus {
|
|
145
|
+
background: ${({ theme }) => theme.colors.primary};
|
|
146
|
+
color: ${({ theme }) => theme.colors.light};
|
|
147
|
+
border-radius: 4px;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
&::-webkit-datetime-edit-year-field {
|
|
152
|
+
&:focus {
|
|
153
|
+
background: ${({ theme }) => theme.colors.primary};
|
|
154
|
+
color: ${({ theme }) => theme.colors.light};
|
|
155
|
+
border-radius: 4px;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
&::placeholder {
|
|
160
|
+
color: ${({ theme }) => theme.colors.gray};
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
@media (hover: hover) {
|
|
164
|
+
&:hover:not([disabled]) {
|
|
165
|
+
border-color: ${({ theme }) => theme.colors.primary};
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
&:focus:not([disabled]) {
|
|
170
|
+
box-shadow: 0 0 0 4px ${({ theme }) => theme.colors.primaryLight};
|
|
171
|
+
border-color: ${({ theme }) => theme.colors.primary};
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
&:active:not([disabled]) {
|
|
175
|
+
box-shadow: 0 0 0 2px ${({ theme }) => theme.colors.primaryLight};
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
${({ $size }) => formElementHeightStyles($size)}
|
|
179
|
+
|
|
180
|
+
${({ $size, theme }) =>
|
|
181
|
+
$size === "big"
|
|
182
|
+
? `font-size: ${theme.fontSizes.inputBig.lg};
|
|
183
|
+
line-height: ${theme.lineHeights.inputBig.lg};
|
|
184
|
+
`
|
|
185
|
+
: `font-size: ${theme.fontSizes.input.lg};
|
|
186
|
+
line-height: ${theme.lineHeights.input.lg};`}
|
|
187
|
+
|
|
188
|
+
${({ $error, $success, theme }) => {
|
|
189
|
+
return statusBorderStyles(
|
|
190
|
+
$error ? true : false,
|
|
191
|
+
$success ? true : false,
|
|
192
|
+
theme,
|
|
193
|
+
);
|
|
194
|
+
}}
|
|
195
|
+
|
|
196
|
+
${({ disabled, theme }) =>
|
|
197
|
+
disabled &&
|
|
198
|
+
`cursor: not-allowed;
|
|
199
|
+
background: ${theme.colors.grayLight};
|
|
200
|
+
border-color: ${theme.colors.gray};
|
|
201
|
+
color: ${theme.colors.gray};
|
|
202
|
+
`}
|
|
203
|
+
|
|
204
|
+
${({ $fullWidth }) => fullWidthStyles($fullWidth ? true : false)}
|
|
205
|
+
`;
|
|
206
|
+
|
|
207
|
+
const StyledIconWrapper = styled.span<InputProps>`
|
|
208
|
+
display: inline-flex;
|
|
209
|
+
position: relative;
|
|
210
|
+
line-height: 0;
|
|
211
|
+
min-width: fit-content;
|
|
212
|
+
|
|
213
|
+
& em {
|
|
214
|
+
display: block;
|
|
215
|
+
border-radius: 50%;
|
|
216
|
+
background: ${({ theme }) => theme.colors.primary};
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
& svg,
|
|
220
|
+
& em {
|
|
221
|
+
object-fit: contain;
|
|
222
|
+
position: absolute;
|
|
223
|
+
top: 50%;
|
|
224
|
+
left: 50%;
|
|
225
|
+
transform: translate(-50%, -50%) scale(0.7);
|
|
226
|
+
opacity: 0;
|
|
227
|
+
pointer-events: none;
|
|
228
|
+
transition: all 0.3s ease;
|
|
229
|
+
}
|
|
230
|
+
`;
|
|
231
|
+
|
|
232
|
+
const StyledRadioCheckboxInput = styled.input<InputProps>`
|
|
233
|
+
${resetButton};
|
|
234
|
+
display: inline-block;
|
|
235
|
+
border: solid 2px ${({ theme }) => theme.colors.grayLight};
|
|
236
|
+
box-shadow: 0 0 0 0px ${({ theme }) => theme.colors.primaryLight};
|
|
237
|
+
transition: all 0.3s ease;
|
|
238
|
+
|
|
239
|
+
@media (hover: hover) {
|
|
240
|
+
&:hover:not([disabled]) {
|
|
241
|
+
border-color: ${({ theme }) => theme.colors.primary};
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
&:focus:not([disabled]) {
|
|
246
|
+
box-shadow: 0 0 0 4px ${({ theme }) => theme.colors.primaryLight};
|
|
247
|
+
border-color: ${({ theme }) => theme.colors.primary};
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
&:active:not([disabled]) {
|
|
251
|
+
box-shadow: 0 0 0 2px ${({ theme }) => theme.colors.primaryLight};
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
${({ type, theme }) =>
|
|
255
|
+
type === "checkbox"
|
|
256
|
+
? `border-radius: ${theme.spacing.radius.xs};`
|
|
257
|
+
: `border-radius: 50%;`}
|
|
258
|
+
|
|
259
|
+
${({ disabled, theme }) =>
|
|
260
|
+
disabled &&
|
|
261
|
+
`cursor: not-allowed;
|
|
262
|
+
background: ${theme.colors.grayLight};
|
|
263
|
+
border: solid 2px ${theme.colors.gray};
|
|
264
|
+
color: ${theme.colors.gray};
|
|
265
|
+
`}
|
|
266
|
+
|
|
267
|
+
${({ $error, $success, theme }) => {
|
|
268
|
+
return statusBorderStyles(
|
|
269
|
+
$error ? true : false,
|
|
270
|
+
$success ? true : false,
|
|
271
|
+
theme,
|
|
272
|
+
);
|
|
273
|
+
}}
|
|
274
|
+
|
|
275
|
+
${({ $size }) => {
|
|
276
|
+
if ($size === "big") {
|
|
277
|
+
return `
|
|
278
|
+
min-width: 32px;
|
|
279
|
+
width: 32px;
|
|
280
|
+
min-height: 32px;
|
|
281
|
+
height: 32px;
|
|
282
|
+
|
|
283
|
+
& ~ svg {
|
|
284
|
+
min-width: 18px;
|
|
285
|
+
width: 18px;
|
|
286
|
+
min-height: 18px;
|
|
287
|
+
height: 18px;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
& ~ em {
|
|
291
|
+
min-width: 14px;
|
|
292
|
+
width: 14px;
|
|
293
|
+
min-height: 14px;
|
|
294
|
+
height: 14px;
|
|
295
|
+
}
|
|
296
|
+
`;
|
|
297
|
+
} else {
|
|
298
|
+
return `
|
|
299
|
+
min-width: 22px;
|
|
300
|
+
width: 22px;
|
|
301
|
+
min-height: 22px;
|
|
302
|
+
height: 22px;
|
|
303
|
+
|
|
304
|
+
& ~ svg {
|
|
305
|
+
min-width: 12px;
|
|
306
|
+
width: 12px;
|
|
307
|
+
min-height: 12px;
|
|
308
|
+
height: 12px;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
& ~ em {
|
|
312
|
+
min-width: 8px;
|
|
313
|
+
width: 8px;
|
|
314
|
+
min-height: 8px;
|
|
315
|
+
height: 8px;
|
|
316
|
+
}
|
|
317
|
+
`;
|
|
318
|
+
}
|
|
319
|
+
}}
|
|
320
|
+
|
|
321
|
+
&:checked ~ svg,
|
|
322
|
+
&:checked ~ em {
|
|
323
|
+
opacity: 1;
|
|
324
|
+
transform: translate(-50%, -50%) scale(1);
|
|
325
|
+
}
|
|
326
|
+
`;
|
|
327
|
+
|
|
328
|
+
const StyledCustomIconWrapper = styled.span<InputProps>`
|
|
329
|
+
position: relative;
|
|
330
|
+
${({ $fullWidth }) => fullWidthStyles($fullWidth ? true : false)};
|
|
331
|
+
|
|
332
|
+
& svg {
|
|
333
|
+
position: absolute;
|
|
334
|
+
top: 50%;
|
|
335
|
+
transform: translateY(-50%);
|
|
336
|
+
pointer-events: none;
|
|
337
|
+
width: 24px;
|
|
338
|
+
height: 24px;
|
|
339
|
+
object-fit: contain;
|
|
340
|
+
color: ${({ theme }) => theme.colors.primary};
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
${({ $icon, $iconPosition }) =>
|
|
344
|
+
$icon && $iconPosition === "right"
|
|
345
|
+
? css`
|
|
346
|
+
& svg {
|
|
347
|
+
right: 16px;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
& input {
|
|
351
|
+
padding-right: 50px;
|
|
352
|
+
}
|
|
353
|
+
`
|
|
354
|
+
: css`
|
|
355
|
+
& svg {
|
|
356
|
+
left: 16px;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
& svg ~ input {
|
|
360
|
+
padding-left: 50px;
|
|
361
|
+
}
|
|
362
|
+
`}
|
|
363
|
+
`;
|
|
364
|
+
|
|
365
|
+
function LocalInput(
|
|
366
|
+
{ ...props }: InputProps,
|
|
367
|
+
ref: React.Ref<HTMLInputElement>,
|
|
368
|
+
) {
|
|
369
|
+
if (props.type === "checkbox" || props.type === "radio") {
|
|
370
|
+
return (
|
|
371
|
+
<StyledInputWrapper
|
|
372
|
+
$fullWidth={props.$fullWidth}
|
|
373
|
+
type={props.type}
|
|
374
|
+
$label={props.$label}
|
|
375
|
+
className={props.$wrapperClassName}
|
|
376
|
+
>
|
|
377
|
+
<StyledIconWrapper>
|
|
378
|
+
<StyledRadioCheckboxInput {...props} ref={ref} />
|
|
379
|
+
{!props.disabled && props.type === "checkbox" ? (
|
|
380
|
+
<IconCheck />
|
|
381
|
+
) : (
|
|
382
|
+
<em />
|
|
383
|
+
)}
|
|
384
|
+
</StyledIconWrapper>
|
|
385
|
+
{props.$label && (
|
|
386
|
+
<StyledLabel htmlFor={props.id}>{props.$label}</StyledLabel>
|
|
387
|
+
)}
|
|
388
|
+
</StyledInputWrapper>
|
|
389
|
+
);
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
return (
|
|
393
|
+
<StyledInputWrapper
|
|
394
|
+
$fullWidth={props.$fullWidth}
|
|
395
|
+
type={props.type}
|
|
396
|
+
$label={props.$label}
|
|
397
|
+
className={props.$wrapperClassName}
|
|
398
|
+
>
|
|
399
|
+
{props.$label && (
|
|
400
|
+
<StyledLabel htmlFor={props.id}>{props.$label}</StyledLabel>
|
|
401
|
+
)}
|
|
402
|
+
<StyledCustomIconWrapper
|
|
403
|
+
$fullWidth={props.$fullWidth}
|
|
404
|
+
$iconPosition={props.$iconPosition}
|
|
405
|
+
$icon={props.$icon}
|
|
406
|
+
>
|
|
407
|
+
{props.$iconPosition !== "right" && props.$icon && props.$icon}
|
|
408
|
+
<StyledInput {...props} ref={ref} />
|
|
409
|
+
{props.$iconPosition === "right" && props.$icon && props.$icon}
|
|
410
|
+
{props.type === "date" && <IconCalendar className="icon-calendar" />}
|
|
411
|
+
</StyledCustomIconWrapper>
|
|
412
|
+
</StyledInputWrapper>
|
|
413
|
+
);
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
const Input = forwardRef(LocalInput);
|
|
417
|
+
|
|
418
|
+
export { Input };
|