@@ -107,23 +107,21 @@ export const CFormCheck = forwardRef<HTMLInputElement, CFormCheckProps>(
107
107
}
108
108
} , [ indeterminate ] )
109
109
110
- const formControl = ( ) => {
111
- return (
112
- < input
113
- type = { type }
114
- className = { classNames ( button ? 'btn-check' : 'form-check-input' , {
115
- 'is-invalid' : invalid ,
116
- 'is-valid' : valid ,
117
- 'me-2' : hitArea ,
118
- } ) }
119
- id = { id }
120
- { ...rest }
121
- ref = { forkedRef }
122
- />
123
- )
124
- }
110
+ const FormControl = ( ) => (
111
+ < input
112
+ type = { type }
113
+ className = { classNames ( button ? 'btn-check' : 'form-check-input' , {
114
+ 'is-invalid' : invalid ,
115
+ 'is-valid' : valid ,
116
+ 'me-2' : hitArea ,
117
+ } ) }
118
+ id = { id }
119
+ { ...rest }
120
+ ref = { forkedRef }
121
+ />
122
+ )
125
123
126
- const formValidation = ( ) => (
124
+ const FormValidation = ( ) => (
127
125
< CFormControlValidation
128
126
describedby = { rest [ 'aria-describedby' ] }
129
127
feedback = { feedback }
@@ -136,42 +134,40 @@ export const CFormCheck = forwardRef<HTMLInputElement, CFormCheckProps>(
136
134
/>
137
135
)
138
136
139
- const formLabel = ( ) => {
140
- return (
141
- < CFormLabel
142
- customClassName = { classNames (
143
- button
144
- ? classNames (
145
- 'btn' ,
146
- button . variant ? `btn-${ button . variant } -${ button . color } ` : `btn-${ button . color } ` ,
147
- {
148
- [ `btn-${ button . size } ` ] : button . size ,
149
- } ,
150
- `${ button . shape } ` ,
151
- )
152
- : 'form-check-label' ,
153
- ) }
154
- { ...( id && { htmlFor : id } ) }
155
- >
156
- { label }
157
- </ CFormLabel >
158
- )
159
- }
137
+ const FormLabel = ( ) => (
138
+ < CFormLabel
139
+ customClassName = { classNames (
140
+ button
141
+ ? classNames (
142
+ 'btn' ,
143
+ button . variant ? `btn-${ button . variant } -${ button . color } ` : `btn-${ button . color } ` ,
144
+ {
145
+ [ `btn-${ button . size } ` ] : button . size ,
146
+ } ,
147
+ `${ button . shape } ` ,
148
+ )
149
+ : 'form-check-label' ,
150
+ ) }
151
+ { ...( id && { htmlFor : id } ) }
152
+ >
153
+ { label }
154
+ </ CFormLabel >
155
+ )
160
156
161
157
return button ? (
162
158
< >
163
- { formControl ( ) }
164
- { label && formLabel ( ) }
165
- { formValidation ( ) }
159
+ < FormControl />
160
+ { label && < FormLabel /> }
161
+ < FormValidation />
166
162
</ >
167
163
) : label ? (
168
164
hitArea ? (
169
165
< >
170
166
< CFormLabel customClassName = { className } { ...( id && { htmlFor : id } ) } >
171
- { formControl ( ) }
167
+ < FormControl />
172
168
{ label }
173
169
</ CFormLabel >
174
- { formValidation ( ) }
170
+ < FormValidation />
175
171
</ >
176
172
) : (
177
173
< div
@@ -185,13 +181,13 @@ export const CFormCheck = forwardRef<HTMLInputElement, CFormCheckProps>(
185
181
className ,
186
182
) }
187
183
>
188
- { formControl ( ) }
189
- { formLabel ( ) }
190
- { formValidation ( ) }
184
+ < FormControl />
185
+ < FormLabel />
186
+ < FormValidation />
191
187
</ div >
192
188
)
193
189
) : (
194
- formControl ( )
190
+ < FormControl />
195
191
)
196
192
} ,
197
193
)
0 commit comments