@liguelead/design-system 0.0.9 → 0.0.11
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/components/Button/Button.appearance.ts +66 -62
- package/components/Button/Button.sizes.ts +42 -41
- package/components/Button/Button.styles.ts +46 -50
- package/components/Button/Button.tsx +76 -76
- package/components/Button/Button.types.ts +23 -23
- package/components/Button/index.ts +1 -1
- package/components/Checkbox/Checkbox.styles.ts +115 -66
- package/components/Checkbox/Checkbox.tsx +97 -40
- package/components/Checkbox/Checkbox.types.ts +12 -11
- package/components/Checkbox/index.tsx +2 -2
- package/components/DatePicker/DatePicker.styles.ts +66 -66
- package/components/DatePicker/DatePicker.tsx +135 -135
- package/components/DatePicker/DatePicker.types.ts +29 -29
- package/components/DatePicker/index.ts +1 -1
- package/components/IconButton/IconButton.sizes.ts +34 -41
- package/components/IconButton/IconButton.tsx +70 -70
- package/components/IconButton/index.ts +1 -1
- package/components/InputOpt/InputOpt.styles.ts +75 -0
- package/components/InputOpt/InputOpt.tsx +153 -0
- package/components/InputOpt/InputOpt.types.ts +14 -0
- package/components/InputOpt/index.ts +1 -0
- package/components/InputOpt/utils/focusManagement.ts +31 -0
- package/components/InputOpt/utils/index.ts +2 -0
- package/components/InputOpt/utils/inputValidation.ts +14 -0
- package/components/LinkButton/LinkButton.size.ts +39 -0
- package/components/LinkButton/LinkButton.style.ts +45 -0
- package/components/LinkButton/LinkButton.tsx +75 -0
- package/components/LinkButton/LinkButton.types.ts +11 -0
- package/components/LinkButton/index.ts +1 -0
- package/components/PageWrapper/PageWrapper.tsx +31 -31
- package/components/PageWrapper/index.ts +1 -1
- package/components/RadioButton/RadioButton.inputVariants.ts +133 -0
- package/components/RadioButton/RadioButton.styles.ts +78 -0
- package/components/RadioButton/RadioButton.tsx +88 -0
- package/components/RadioButton/RadioButton.types.ts +33 -0
- package/components/RadioButton/RadioButton.variants.ts +67 -0
- package/components/RadioButton/index.ts +1 -0
- package/components/SegmentedButton/SegmentedButton.styles.ts +29 -29
- package/components/SegmentedButton/SegmentedButton.tsx +43 -49
- package/components/SegmentedButton/SegmentedButton.types.ts +20 -20
- package/components/SegmentedButton/index.ts +1 -1
- package/components/Select/Select.sizes.ts +55 -56
- package/components/Select/Select.states.tsx +40 -69
- package/components/Select/Select.styles.ts +162 -148
- package/components/Select/Select.tsx +152 -144
- package/components/Select/Select.types.ts +35 -36
- package/components/Select/index.ts +1 -1
- package/components/Text/Text.styles.ts +46 -43
- package/components/Text/Text.tsx +27 -27
- package/components/Text/Text.types.ts +44 -42
- package/components/Text/index.ts +1 -1
- package/components/TextField/TextField.sizes.ts +52 -58
- package/components/TextField/TextField.states.tsx +53 -76
- package/components/TextField/TextField.styles.ts +85 -98
- package/components/TextField/TextField.tsx +108 -108
- package/components/TextField/TextField.types.ts +22 -21
- package/components/TextField/index.ts +2 -2
- package/components/TextField/utils/getState.ts +7 -0
- package/components/ThemeProvider/ThemeProvider.tsx +21 -21
- package/components/ThemeProvider/index.ts +1 -1
- package/components/ThemeProvider/style.ts +969 -969
- package/components/Wizard/StepContent.tsx +28 -28
- package/components/Wizard/StepMenuItem.tsx +33 -33
- package/components/Wizard/Wizard.context.tsx +76 -76
- package/components/Wizard/Wizard.styles.ts +126 -126
- package/components/Wizard/Wizard.tsx +55 -55
- package/components/Wizard/index.ts +1 -1
- package/components/index.ts +14 -11
- package/package.json +41 -41
- package/scripts/createTypes.js +70 -70
- package/utils/colorDarken.ts +10 -10
- package/utils/colorLighten.ts +10 -10
- package/utils/darkenOrLighen.ts +19 -19
- package/utils/getTextColor.ts +12 -12
- package/utils/index.ts +5 -5
- package/utils/parseColor.ts +7 -7
|
@@ -1,148 +1,162 @@
|
|
|
1
|
-
import styled from 'styled-components'
|
|
2
|
-
import { TextFieldSizeType, StateInterface } from './Select.types'
|
|
3
|
-
import {
|
|
4
|
-
fontSize,
|
|
5
|
-
fontWeight,
|
|
6
|
-
lineHeight,
|
|
7
|
-
spacing
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
font-
|
|
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
|
-
border:
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
& .RadixSelectViewport {
|
|
77
|
-
max-height: 200px; /* Limite de altura do dropdown */
|
|
78
|
-
overflow-y: auto; /* Adiciona o scroll quando necessário */
|
|
79
|
-
scrollbar-width: thin; /* Personaliza a largura do scroll (opcional) */
|
|
80
|
-
}
|
|
81
|
-
`
|
|
82
|
-
|
|
83
|
-
export const StyledItem = styled(Item)`
|
|
84
|
-
padding: ${spacing.spacing12}px ${spacing.spacing20}px;
|
|
85
|
-
display: flex;
|
|
86
|
-
align-items: center;
|
|
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
|
-
|
|
1
|
+
import styled from 'styled-components'
|
|
2
|
+
import { TextFieldSizeType, StateInterface } from './Select.types'
|
|
3
|
+
import {
|
|
4
|
+
fontSize,
|
|
5
|
+
fontWeight,
|
|
6
|
+
lineHeight,
|
|
7
|
+
spacing,
|
|
8
|
+
shadow
|
|
9
|
+
} from '@liguelead/foundation'
|
|
10
|
+
import { parseColor } from '../../utils'
|
|
11
|
+
import { Content, Item } from '@radix-ui/react-select'
|
|
12
|
+
|
|
13
|
+
interface StyledInputProps {
|
|
14
|
+
size: TextFieldSizeType
|
|
15
|
+
$themefication: StateInterface
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const InputWrapper = styled.div`
|
|
19
|
+
position: relative;
|
|
20
|
+
width: 100%;
|
|
21
|
+
`
|
|
22
|
+
|
|
23
|
+
export const Label = styled.label`
|
|
24
|
+
display: block;
|
|
25
|
+
font-weight: ${fontWeight.fontWeight600};
|
|
26
|
+
margin-bottom: ${spacing.spacing4}px;
|
|
27
|
+
font-size: ${fontSize.fontSize14}px;
|
|
28
|
+
`
|
|
29
|
+
|
|
30
|
+
export const HelperText = styled.span<{ error?: boolean }>`
|
|
31
|
+
font-size: ${fontSize.fontSize12}px;
|
|
32
|
+
line-height: ${lineHeight.lineHeight12}px;
|
|
33
|
+
`
|
|
34
|
+
|
|
35
|
+
export const IconWrapper = styled.div<{
|
|
36
|
+
$right?: boolean;
|
|
37
|
+
$error?: boolean;
|
|
38
|
+
$disabled?: boolean;
|
|
39
|
+
}>` ${({theme, $error, $disabled, $right }) =>`
|
|
40
|
+
display: flex;
|
|
41
|
+
align-items: center;
|
|
42
|
+
justify-content: space-between;
|
|
43
|
+
position: absolute;
|
|
44
|
+
top: 0px;
|
|
45
|
+
height: 100%;
|
|
46
|
+
cursor: pointer;
|
|
47
|
+
${$right ? 'right: 0px;' : 'left: 0px;'}
|
|
48
|
+
padding: 0px ${spacing.spacing16}px;
|
|
49
|
+
|
|
50
|
+
& svg {
|
|
51
|
+
width: 16px;
|
|
52
|
+
height: 16px;
|
|
53
|
+
fill: ${$error
|
|
54
|
+
? parseColor(theme.colors.danger200)
|
|
55
|
+
: $disabled
|
|
56
|
+
? parseColor(theme.colors.neutral400)
|
|
57
|
+
: parseColor(theme.colors.neutral800)};
|
|
58
|
+
transition: fill 0.2s ease;
|
|
59
|
+
cursor: ${$disabled ? 'not-allowed' : 'pointer'};
|
|
60
|
+
}
|
|
61
|
+
`}
|
|
62
|
+
`
|
|
63
|
+
|
|
64
|
+
export const StyledContent = styled(Content)`
|
|
65
|
+
padding: 0px;
|
|
66
|
+
background-color: #fff;
|
|
67
|
+
min-width: var(--radix-select-trigger-width, auto);
|
|
68
|
+
width: 100%;
|
|
69
|
+
box-shadow: 0px 4px 4px 0px rgba(0, 0, 0, 0.25);
|
|
70
|
+
border: 1px solid ${({ theme }) => parseColor(theme.colors.neutral500)};
|
|
71
|
+
border-top: 0px;
|
|
72
|
+
max-height: var(--radix-select-content-height, 314px);
|
|
73
|
+
overflow-y: scroll !important;
|
|
74
|
+
z-index: 10;
|
|
75
|
+
|
|
76
|
+
& .RadixSelectViewport {
|
|
77
|
+
max-height: 200px; /* Limite de altura do dropdown */
|
|
78
|
+
overflow-y: auto; /* Adiciona o scroll quando necessário */
|
|
79
|
+
scrollbar-width: thin; /* Personaliza a largura do scroll (opcional) */
|
|
80
|
+
}
|
|
81
|
+
`
|
|
82
|
+
|
|
83
|
+
export const StyledItem = styled(Item)`
|
|
84
|
+
padding: ${spacing.spacing12}px ${spacing.spacing20}px;
|
|
85
|
+
display: flex;
|
|
86
|
+
align-items: center;
|
|
87
|
+
justify-content: space-between;
|
|
88
|
+
gap: 8px; /* mantém espaçamento interno caso adicionemos ícones à esquerda futuramente */
|
|
89
|
+
transition: all 0.2s ease;
|
|
90
|
+
cursor: pointer;
|
|
91
|
+
|
|
92
|
+
&:hover {
|
|
93
|
+
background-color: ${({ theme }) => parseColor(theme.colors.primaryLight)};
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
&[data-state='checked'] {
|
|
97
|
+
background-color: ${({ theme }) =>
|
|
98
|
+
parseColor(theme.colors.primary)};
|
|
99
|
+
color: ${({ theme }) => parseColor(theme.colors.white)};
|
|
100
|
+
}
|
|
101
|
+
`
|
|
102
|
+
|
|
103
|
+
export const StyledInput = styled.input.withConfig({
|
|
104
|
+
shouldForwardProp: prop => !['control', 'errors', 'rules'].includes(prop)
|
|
105
|
+
})`
|
|
106
|
+
width: 100%;
|
|
107
|
+
border-radius: 4px;
|
|
108
|
+
outline: none;
|
|
109
|
+
transition: border-color 0.2s ease;
|
|
110
|
+
background: transparent;
|
|
111
|
+
cursor: pointer;
|
|
112
|
+
|
|
113
|
+
&:focus {
|
|
114
|
+
box-shadow: ${shadow.focusShadow}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
&.is-open {
|
|
118
|
+
border-color: ${({ theme }) =>
|
|
119
|
+
parseColor(theme.colors.neutral800)} !important;
|
|
120
|
+
box-shadow: ${shadow.focusShadow}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
&:disabled {
|
|
124
|
+
cursor: not-allowed;
|
|
125
|
+
}
|
|
126
|
+
`
|
|
127
|
+
|
|
128
|
+
export const BorderWrapper = styled.div`
|
|
129
|
+
position: absolute;
|
|
130
|
+
top: 0;
|
|
131
|
+
left: 0;
|
|
132
|
+
right: 0;
|
|
133
|
+
bottom: 0;
|
|
134
|
+
pointer-events: none;
|
|
135
|
+
border: 2px solid #ccc;
|
|
136
|
+
border-radius: 4px;
|
|
137
|
+
background-color: transparent;
|
|
138
|
+
z-index: -1;
|
|
139
|
+
|
|
140
|
+
${StyledInput}:focus ~ & {
|
|
141
|
+
border-color: ${({ theme }) => theme.colors.primary};
|
|
142
|
+
}
|
|
143
|
+
`
|
|
144
|
+
|
|
145
|
+
export const Wrapper = styled.div<StyledInputProps>`
|
|
146
|
+
position: relative;
|
|
147
|
+
width: 100%;
|
|
148
|
+
cursor: pointer;
|
|
149
|
+
${({ $themefication, size }) => `
|
|
150
|
+
${StyledInput} {
|
|
151
|
+
${$themefication.input}
|
|
152
|
+
${size.input}
|
|
153
|
+
}
|
|
154
|
+
${HelperText} {
|
|
155
|
+
${$themefication.helperText}
|
|
156
|
+
}
|
|
157
|
+
${Label} {
|
|
158
|
+
${$themefication.label}
|
|
159
|
+
${size.label}
|
|
160
|
+
}
|
|
161
|
+
`}
|
|
162
|
+
`
|
|
@@ -1,144 +1,152 @@
|
|
|
1
|
-
import { forwardRef, useState } from 'react'
|
|
2
|
-
import * as RadixSelect from '@radix-ui/react-select'
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
} from './Select.styles'
|
|
14
|
-
import { SelectStates } from './Select.states'
|
|
15
|
-
import { textFieldSizes } from './Select.sizes'
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
|
|
19
|
-
const Select = forwardRef<HTMLInputElement, SelectProps>(
|
|
20
|
-
(
|
|
21
|
-
{
|
|
22
|
-
label,
|
|
23
|
-
defaultValue,
|
|
24
|
-
error,
|
|
25
|
-
helperText,
|
|
26
|
-
leftIcon,
|
|
27
|
-
size = 'md',
|
|
28
|
-
options,
|
|
29
|
-
className,
|
|
30
|
-
disabled = false,
|
|
31
|
-
handleLeftIcon,
|
|
32
|
-
register
|
|
33
|
-
},
|
|
34
|
-
ref
|
|
35
|
-
) => {
|
|
36
|
-
const [selectValue, setSelectValue] = useState(
|
|
37
|
-
defaultValue ?? options[0]?.value
|
|
38
|
-
)
|
|
39
|
-
const [open, setOpen] = useState(false)
|
|
40
|
-
|
|
41
|
-
const handleOnChange = (value: string) => {
|
|
42
|
-
if (value) {
|
|
43
|
-
setSelectValue(value)
|
|
44
|
-
register?.onChange({
|
|
45
|
-
target: {
|
|
46
|
-
name: register.name,
|
|
47
|
-
value
|
|
48
|
-
}
|
|
49
|
-
})
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
const state = getState(disabled, !!error)
|
|
54
|
-
const textFieldState: StateInterface = SelectStates(state)
|
|
55
|
-
const textFieldSize = textFieldSizes(size, !!leftIcon, false)
|
|
56
|
-
const selectedLabel =
|
|
57
|
-
options.find(option => option.value === selectValue)?.label ?? ''
|
|
58
|
-
|
|
59
|
-
return (
|
|
60
|
-
<Wrapper
|
|
61
|
-
className={className}
|
|
62
|
-
size={textFieldSize}
|
|
63
|
-
$themefication={textFieldState}>
|
|
64
|
-
<input
|
|
65
|
-
type="hidden"
|
|
66
|
-
value={selectValue}
|
|
67
|
-
ref={instance => {
|
|
68
|
-
if (typeof ref === 'function') {
|
|
69
|
-
ref(instance)
|
|
70
|
-
} else if (ref) {
|
|
71
|
-
ref.current = instance
|
|
72
|
-
}
|
|
73
|
-
register?.ref(instance)
|
|
74
|
-
}}
|
|
75
|
-
onChange={register?.onChange}
|
|
76
|
-
onBlur={register?.onBlur}
|
|
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
|
-
|
|
1
|
+
import { forwardRef, useState } from 'react'
|
|
2
|
+
import * as RadixSelect from '@radix-ui/react-select'
|
|
3
|
+
import { CaretDownIcon, CheckIcon } from '@phosphor-icons/react'
|
|
4
|
+
import {
|
|
5
|
+
HelperText,
|
|
6
|
+
IconWrapper,
|
|
7
|
+
InputWrapper,
|
|
8
|
+
StyledContent,
|
|
9
|
+
StyledInput,
|
|
10
|
+
StyledItem,
|
|
11
|
+
Wrapper,
|
|
12
|
+
Label
|
|
13
|
+
} from './Select.styles'
|
|
14
|
+
import { SelectStates } from './Select.states'
|
|
15
|
+
import { textFieldSizes } from './Select.sizes'
|
|
16
|
+
import { SelectProps, StateInterface } from './Select.types'
|
|
17
|
+
import getState from '../TextField/utils/getState'
|
|
18
|
+
|
|
19
|
+
const Select = forwardRef<HTMLInputElement, SelectProps>(
|
|
20
|
+
(
|
|
21
|
+
{
|
|
22
|
+
label,
|
|
23
|
+
defaultValue,
|
|
24
|
+
error,
|
|
25
|
+
helperText,
|
|
26
|
+
leftIcon,
|
|
27
|
+
size = 'md',
|
|
28
|
+
options,
|
|
29
|
+
className,
|
|
30
|
+
disabled = false,
|
|
31
|
+
handleLeftIcon,
|
|
32
|
+
register
|
|
33
|
+
},
|
|
34
|
+
ref
|
|
35
|
+
) => {
|
|
36
|
+
const [selectValue, setSelectValue] = useState(
|
|
37
|
+
defaultValue ?? options[0]?.value
|
|
38
|
+
)
|
|
39
|
+
const [open, setOpen] = useState(false)
|
|
40
|
+
|
|
41
|
+
const handleOnChange = (value: string) => {
|
|
42
|
+
if (value) {
|
|
43
|
+
setSelectValue(value)
|
|
44
|
+
register?.onChange({
|
|
45
|
+
target: {
|
|
46
|
+
name: register.name,
|
|
47
|
+
value
|
|
48
|
+
}
|
|
49
|
+
})
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const state = getState(disabled, !!error)
|
|
54
|
+
const textFieldState: StateInterface = SelectStates(state)
|
|
55
|
+
const textFieldSize = textFieldSizes(size, !!leftIcon, false)
|
|
56
|
+
const selectedLabel =
|
|
57
|
+
options.find(option => option.value === selectValue)?.label ?? ''
|
|
58
|
+
|
|
59
|
+
return (
|
|
60
|
+
<Wrapper
|
|
61
|
+
className={className}
|
|
62
|
+
size={textFieldSize}
|
|
63
|
+
$themefication={textFieldState}>
|
|
64
|
+
<input
|
|
65
|
+
type="hidden"
|
|
66
|
+
value={selectValue}
|
|
67
|
+
ref={instance => {
|
|
68
|
+
if (typeof ref === 'function') {
|
|
69
|
+
ref(instance)
|
|
70
|
+
} else if (ref) {
|
|
71
|
+
ref.current = instance
|
|
72
|
+
}
|
|
73
|
+
register?.ref(instance)
|
|
74
|
+
}}
|
|
75
|
+
onChange={register?.onChange}
|
|
76
|
+
onBlur={register?.onBlur}
|
|
77
|
+
/>
|
|
78
|
+
<Label>{label}</Label>
|
|
79
|
+
{disabled ? (
|
|
80
|
+
<InputWrapper className="is-disabled">
|
|
81
|
+
{leftIcon && (
|
|
82
|
+
<IconWrapper onClick={handleLeftIcon} $disabled={disabled}>
|
|
83
|
+
{leftIcon}
|
|
84
|
+
</IconWrapper>
|
|
85
|
+
)}
|
|
86
|
+
<IconWrapper $right $error={!!error} $disabled={disabled}>
|
|
87
|
+
<CaretDownIcon weight="fill" size={14} />
|
|
88
|
+
</IconWrapper>
|
|
89
|
+
<StyledInput
|
|
90
|
+
disabled
|
|
91
|
+
readOnly
|
|
92
|
+
value={selectedLabel}
|
|
93
|
+
className="is-disabled"
|
|
94
|
+
/>
|
|
95
|
+
</InputWrapper>
|
|
96
|
+
) : (
|
|
97
|
+
<RadixSelect.Root
|
|
98
|
+
value={selectValue}
|
|
99
|
+
onOpenChange={open => setOpen(open)}
|
|
100
|
+
defaultValue={defaultValue}
|
|
101
|
+
onValueChange={(value: string) =>
|
|
102
|
+
handleOnChange(value)
|
|
103
|
+
}>
|
|
104
|
+
<RadixSelect.Trigger asChild disabled={disabled}>
|
|
105
|
+
<InputWrapper>
|
|
106
|
+
{leftIcon && (
|
|
107
|
+
<IconWrapper onClick={handleLeftIcon}>
|
|
108
|
+
{leftIcon}
|
|
109
|
+
</IconWrapper>
|
|
110
|
+
)}
|
|
111
|
+
<IconWrapper $right $error={!!error}>
|
|
112
|
+
<CaretDownIcon weight="fill" size={14} />
|
|
113
|
+
</IconWrapper>
|
|
114
|
+
<StyledInput
|
|
115
|
+
readOnly
|
|
116
|
+
style={{ cursor: 'pointer !important' }}
|
|
117
|
+
value={selectedLabel}
|
|
118
|
+
className={open ? 'is-open' : ''}
|
|
119
|
+
/>
|
|
120
|
+
</InputWrapper>
|
|
121
|
+
</RadixSelect.Trigger>
|
|
122
|
+
<StyledContent
|
|
123
|
+
asChild
|
|
124
|
+
sideOffset={0}
|
|
125
|
+
position="popper"
|
|
126
|
+
align="start"
|
|
127
|
+
className="RadixSelectContent">
|
|
128
|
+
<RadixSelect.Viewport className="RadixSelectViewport">
|
|
129
|
+
{options.map(option => (
|
|
130
|
+
<StyledItem
|
|
131
|
+
key={option.value}
|
|
132
|
+
value={option.value}
|
|
133
|
+
>
|
|
134
|
+
<span>{option.label}</span>
|
|
135
|
+
{option.value === selectValue && (
|
|
136
|
+
<CheckIcon weight="bold" />
|
|
137
|
+
)}
|
|
138
|
+
</StyledItem>
|
|
139
|
+
))}
|
|
140
|
+
</RadixSelect.Viewport>
|
|
141
|
+
</StyledContent>
|
|
142
|
+
</RadixSelect.Root>
|
|
143
|
+
)}
|
|
144
|
+
{(helperText || error) && (
|
|
145
|
+
<HelperText>{error?.message || helperText}</HelperText>
|
|
146
|
+
)}
|
|
147
|
+
</Wrapper>
|
|
148
|
+
)
|
|
149
|
+
}
|
|
150
|
+
)
|
|
151
|
+
|
|
152
|
+
export default Select
|