@ludo.ninja/components 2.2.59 → 2.2.60
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.
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import { UseFormRegisterReturn } from
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { UseFormRegisterReturn } from "react-hook-form";
|
|
3
3
|
export type inputType = {
|
|
4
4
|
labelText?: string;
|
|
5
5
|
name: string;
|
|
@@ -17,6 +17,7 @@ interface Props {
|
|
|
17
17
|
value?: string | number;
|
|
18
18
|
withInput?: boolean;
|
|
19
19
|
innerTextInputRef?: UseFormRegisterReturn;
|
|
20
|
+
disabled?: boolean;
|
|
20
21
|
}
|
|
21
22
|
declare const CheckboxInput: React.FC<Props>;
|
|
22
23
|
export default CheckboxInput;
|
|
@@ -4,11 +4,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
7
|
-
const react_1 = require("react");
|
|
8
|
-
const styled_components_1 = __importDefault(require("styled-components"));
|
|
9
7
|
const colors_1 = require("../../../styles/colors");
|
|
10
8
|
const ErrorLabel_1 = __importDefault(require("../ErrorLabel"));
|
|
11
9
|
const Input_1 = require("../Input");
|
|
10
|
+
const constants_1 = require("@ludo.ninja/core/build/constants");
|
|
11
|
+
const react_1 = require("react");
|
|
12
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
12
13
|
const BasicCheckbox = styled_components_1.default.label `
|
|
13
14
|
display: flex;
|
|
14
15
|
align-items: center;
|
|
@@ -32,7 +33,7 @@ const BasicCheckbox = styled_components_1.default.label `
|
|
|
32
33
|
|
|
33
34
|
&:checked ~ .checkmark {
|
|
34
35
|
background-color: ${colors_1.AccentColor};
|
|
35
|
-
background-image: url(
|
|
36
|
+
background-image: url("${constants_1.staticLink}/public/forms/checkbox/checked.svg");
|
|
36
37
|
background-position: center;
|
|
37
38
|
background-repeat: no-repeat;
|
|
38
39
|
border-color: transparent;
|
|
@@ -49,16 +50,16 @@ const BasicCheckbox = styled_components_1.default.label `
|
|
|
49
50
|
border-radius: 6px;
|
|
50
51
|
}
|
|
51
52
|
`;
|
|
52
|
-
const CheckboxInput = ({ data, label, register, error, className, value, withInput, innerTextInputRef, }) => {
|
|
53
|
-
const [textInputDisabled,
|
|
53
|
+
const CheckboxInput = ({ data, label, register, error, className, value, withInput, innerTextInputRef, disabled, }) => {
|
|
54
|
+
const [textInputDisabled, setTextInputDisabled] = (0, react_1.useState)(true);
|
|
54
55
|
const renderError = () => {
|
|
55
56
|
if (error?.isNeedShowError) {
|
|
56
57
|
return (0, jsx_runtime_1.jsx)(ErrorLabel_1.default, { children: error?.message });
|
|
57
58
|
}
|
|
58
59
|
};
|
|
59
|
-
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
60
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)(BasicCheckbox, { className: className, status: error?.isNeedShowError, children: [(0, jsx_runtime_1.jsx)("input", { ...register, onChange: (e) => {
|
|
61
|
+
setTextInputDisabled(!e.target.checked);
|
|
62
|
+
register.onChange(e);
|
|
63
|
+
}, className: "input", type: "checkbox", name: data.name, value: value, disabled: disabled }), (0, jsx_runtime_1.jsx)("p", { className: "checkmark" }), label, withInput && (0, jsx_runtime_1.jsx)(Input_1.StyledInput, { status: false, ...innerTextInputRef, disabled: textInputDisabled })] }), renderError()] }));
|
|
63
64
|
};
|
|
64
65
|
exports.default = CheckboxInput;
|