-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathCheckBox.js
116 lines (110 loc) · 2.99 KB
/
CheckBox.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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
import React, { Fragment } from "react";
import { SVG } from "./SVG";
import StringManipulator from "./StringManipulator";
import PropTypes from "prop-types";
import { useTranslation } from "react-i18next";
const CheckBox = ({
onChange,
label,
value,
disabled,
ref,
checked,
inputRef,
pageType,
style,
index,
isLabelFirst,
customLabelMarkup,
...props
}) => {
const { t } = useTranslation();
const userType = pageType || window?.Digit?.SessionStorage.get("userType");
let styles = props.styles;
const sentenceCaseLabel = StringManipulator("TOSENTENCECASE", label);
return (
<div
className={`digit-checkbox-container ${
!isLabelFirst ? "checkboxFirst" : "labelFirst"
} ${disabled ? "disabled" : " "} ${props.mainClassName}`}
>
{isLabelFirst ? (
<p className={`label ${labelClassName} `} style={{ maxWidth: "100%", width: "auto" ,marginRight:"0rem"}} onClick={props.onLabelClick}>
{customLabelMarkup ? (
<>
<span>{t("COMMON_CERTIFY_ONE")}</span>
<br />
<span>
<b> {t("ES_COMMON_NOTE")}</b>
{t("COMMON_CERTIFY_TWO")}
</span>
</>
) : (
sentenceCaseLabel
)}
</p>
) : null}
<div style={{ cursor: "pointer", display: "flex", position: "relative" }} className={props.inputWrapperClassName}>
<input
type="checkbox"
className={`input ${userType === "employee" ? "input-emp" : ""} ${props.inputClassName} `}
onChange={onChange}
value={value || label}
{...props}
ref={inputRef}
disabled={disabled}
checked={checked}
/>
<p
className={`digit-custom-checkbox ${
userType === "employee" ? "digit-custom-checkbox-emp" : ""
} ${props.inputIconClassname} `}
>
<SVG.Check fill={props.iconFill || (disabled ? "#C5C5C5" : "#C84C0E")} />
</p>
</div>
{!isLabelFirst ? (
<p className={`label ${props.labelClassName} `} style={{ maxWidth: "100%", width: "100%",marginRight:"0rem" }} onClick={props.onLabelClick}>
{customLabelMarkup ? (
<>
<span>{t("COMMON_CERTIFY_ONE")}</span>
<br />
<span>
<b> {t("ES_COMMON_NOTE")}</b>
{t("COMMON_CERTIFY_TWO")}
</span>
</>
) : (
sentenceCaseLabel
)}
</p>
) : null}
</div>
);
};
CheckBox.propTypes = {
/**
* CheckBox content
*/
label: PropTypes.string.isRequired,
/**
* onChange func
*/
onChange: PropTypes.func,
/**
* input ref
*/
ref: PropTypes.func,
userType: PropTypes.string,
};
CheckBox.defaultProps = {
label: "Default",
isLabelFirst: false,
onChange: () => console.log("CLICK"),
value: "",
checked: false,
ref: "ww",
// pageType: "EMPLOYEE",
index: 0,
};
export default CheckBox;