@@ -3,70 +3,79 @@ import { Text } from "src/components/typography"
33import useCheckBoxStyles from "./use-styles-checkbox"
44import useCheckbox from "./use-checkbox"
55
6- import { CheckboxContainer , HiddenCheckboxInput , LabelText , StyledCheckbox , StyledIcon , StyledLabel } from "./styled"
6+ import {
7+ CheckboxContainer ,
8+ HiddenCheckboxInput ,
9+ LabelText ,
10+ StyledCheckbox ,
11+ StyledIcon ,
12+ StyledLabel ,
13+ } from "./styled"
714
8- export const Checkbox = forwardRef ( (
9- {
10- checked,
11- "data-testid" : testId ,
12- disabled,
13- className,
14- labelPosition,
15- label,
16- indeterminate,
17- margin,
18- alignSelf,
19- iconProps,
20- Label,
21- ...props
22- } ,
15+ export const Checkbox = forwardRef (
16+ (
17+ {
18+ alignSelf,
19+ checked,
20+ className,
21+ "data-testid" : testId ,
22+ disabled,
23+ iconProps,
24+ indeterminate,
25+ Label,
26+ label,
27+ labelPosition,
28+ margin,
29+ ...props
30+ } ,
2331 ref
24- ) => {
25- const { styles } = useCheckBoxStyles ( { disabled } )
26- const { getInputProps, getCheckBoxProps } = useCheckbox ( {
27- disabled ,
28- checked ,
29- indeterminate,
30- ...props ,
31- } )
32+ ) => {
33+ const { styles } = useCheckBoxStyles ( { disabled } )
34+ const { getInputProps, getCheckBoxProps } = useCheckbox ( {
35+ checked ,
36+ disabled ,
37+ indeterminate,
38+ ...props ,
39+ } )
3240
33- return (
34- < StyledLabel
35- data-testid = { testId }
36- disabled = { disabled }
37- className = { className }
38- margin = { margin }
39- alignSelf = { alignSelf }
40- >
41- { label && labelPosition === "left" && (
42- < LabelText as = { Label } left >
43- { label }
44- </ LabelText >
45- ) }
46- < CheckboxContainer >
47- < HiddenCheckboxInput data-testid = "checkbox-input" { ...getInputProps ( ref , props ) } />
48- < StyledCheckbox
49- data-testid = "styled-checkbox"
50- { ...styles . styledCheckbox }
51- { ...getCheckBoxProps ( ) }
52- >
53- < StyledIcon
54- name = { indeterminate ? "checkmark_partial_s" : "checkmark_s" }
55- disabled = { disabled }
56- { ...iconProps }
57- />
58- </ StyledCheckbox >
59- </ CheckboxContainer >
60- { label && labelPosition === "right" && (
61- < LabelText as = { Label } right >
62- { label }
63- </ LabelText >
64- ) }
65- </ StyledLabel >
66- )
67- } )
41+ return (
42+ < StyledLabel
43+ alignSelf = { alignSelf }
44+ className = { className }
45+ data-testid = { testId }
46+ disabled = { disabled }
47+ margin = { margin }
48+ >
49+ { label && labelPosition === "left" && (
50+ < LabelText as = { Label } disabled = { disabled } left >
51+ { label }
52+ </ LabelText >
53+ ) }
54+ < CheckboxContainer >
55+ < HiddenCheckboxInput data-testid = "checkbox-input" { ...getInputProps ( ref , props ) } />
56+ < StyledCheckbox
57+ data-testid = "styled-checkbox"
58+ { ...styles . styledCheckbox }
59+ { ...getCheckBoxProps ( ) }
60+ >
61+ < StyledIcon
62+ disabled = { disabled }
63+ name = { indeterminate ? "checkmark_partial_s" : "checkmark_s" }
64+ { ...iconProps }
65+ />
66+ </ StyledCheckbox >
67+ </ CheckboxContainer >
68+ { label && labelPosition === "right" && (
69+ < LabelText as = { Label } disabled = { disabled } right >
70+ { label }
71+ </ LabelText >
72+ ) }
73+ </ StyledLabel >
74+ )
75+ }
76+ )
6877
6978Checkbox . defaultProps = {
70- labelPosition : "right" ,
7179 Label : Text ,
80+ labelPosition : "right" ,
7281}
0 commit comments