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