@yakad/ui 1.2.110-beta → 1.2.111-beta
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/checkbox/checkbox.d.ts
CHANGED
package/checkbox/checkbox.js
CHANGED
|
@@ -5,14 +5,13 @@ import styles from "./checkbox.module.css";
|
|
|
5
5
|
import { joinClassNames } from "@yakad/lib";
|
|
6
6
|
export default function Chekbox(props) {
|
|
7
7
|
const joinedClassNames = joinClassNames(styles.checkbox, props.label ? styles.labeled : "");
|
|
8
|
-
const [checked, setChecked] = React.useState();
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
setChecked(targetInputElement.checked);
|
|
8
|
+
const [checked, setChecked] = React.useState(props.checked ? props.checked : false);
|
|
9
|
+
const onClickCheckboxHandler = () => {
|
|
10
|
+
setChecked((value) => !value);
|
|
12
11
|
};
|
|
13
12
|
return (React.createElement("div", { className: joinedClassNames },
|
|
14
13
|
props.label ? (React.createElement("label", { className: styles.label, htmlFor: props.name }, props.label)) : null,
|
|
15
|
-
React.createElement(Button, { disabled: props.disabled, icon: checked ? "check_box" : "check_box_outline_blank" }),
|
|
16
|
-
React.createElement("input", { ...props, className: styles.input, type: "checkbox", name: props.name, disabled: props.disabled
|
|
14
|
+
React.createElement(Button, { disabled: props.disabled, icon: checked ? "check_box" : "check_box_outline_blank", onClick: (event) => onClickCheckboxHandler() }),
|
|
15
|
+
React.createElement("input", { ...props, className: styles.input, type: "checkbox", name: props.name, checked: checked, disabled: props.disabled })));
|
|
17
16
|
}
|
|
18
17
|
//# sourceMappingURL=checkbox.js.map
|
package/checkbox/checkbox.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkbox.js","sourceRoot":"","sources":["checkbox.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,KAAmB,MAAM,OAAO,CAAC;AACxC,OAAO,MAAM,MAAM,kBAAkB,CAAC;AACtC,OAAO,MAAM,M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AAE,GAC9C;QACF,kCACQ,KAAK,EACT,SAAS,EAAE,MAAM,CAAC,KAAK,EACvB,IAAI,EAAC,UAAU,EACf,IAAI,EAAE,KAAK,CAAC,IAAI,EAChB,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,KAAK,CAAC,QAAQ,GAC1B,CACA,CACT,CAAC;AACN,CAAC"}
|
|
@@ -1,27 +1,22 @@
|
|
|
1
1
|
.checkbox {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
height: 4rem;
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-direction: row;
|
|
4
|
+
width: 4rem;
|
|
5
|
+
height: 4rem;
|
|
7
6
|
}
|
|
8
7
|
.checkbox.labeled {
|
|
9
|
-
|
|
8
|
+
width: 100%;
|
|
10
9
|
}
|
|
11
10
|
|
|
12
11
|
.input {
|
|
13
|
-
|
|
14
|
-
opacity: 0;
|
|
15
|
-
width: 100%;
|
|
16
|
-
height: 100%;
|
|
17
|
-
margin: 0;
|
|
12
|
+
display: none;
|
|
18
13
|
}
|
|
19
14
|
|
|
20
15
|
.label {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
16
|
+
display: block;
|
|
17
|
+
width: auto;
|
|
18
|
+
margin: 0.9rem 1rem;
|
|
19
|
+
margin-inline-end: auto;
|
|
20
|
+
line-height: 2.2rem;
|
|
21
|
+
font-size: 1.4rem;
|
|
27
22
|
}
|
package/checkbox/checkbox.tsx
CHANGED
|
@@ -8,6 +8,7 @@ import { joinClassNames } from "@yakad/lib";
|
|
|
8
8
|
export interface CheckboxProps extends React.HTMLAttributes<HTMLInputElement> {
|
|
9
9
|
name?: string;
|
|
10
10
|
label?: string;
|
|
11
|
+
checked?: boolean;
|
|
11
12
|
disabled?: boolean;
|
|
12
13
|
}
|
|
13
14
|
|
|
@@ -17,12 +18,11 @@ export default function Chekbox(props: CheckboxProps) {
|
|
|
17
18
|
props.label ? styles.labeled : ""
|
|
18
19
|
);
|
|
19
20
|
|
|
20
|
-
const [checked, setChecked] = React.useState<boolean>(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
) => {
|
|
24
|
-
|
|
25
|
-
setChecked(targetInputElement.checked);
|
|
21
|
+
const [checked, setChecked] = React.useState<boolean>(
|
|
22
|
+
props.checked ? props.checked : false
|
|
23
|
+
);
|
|
24
|
+
const onClickCheckboxHandler = () => {
|
|
25
|
+
setChecked((value) => !value);
|
|
26
26
|
};
|
|
27
27
|
|
|
28
28
|
return (
|
|
@@ -35,14 +35,15 @@ export default function Chekbox(props: CheckboxProps) {
|
|
|
35
35
|
<Button
|
|
36
36
|
disabled={props.disabled}
|
|
37
37
|
icon={checked ? "check_box" : "check_box_outline_blank"}
|
|
38
|
+
onClick={(event) => onClickCheckboxHandler()}
|
|
38
39
|
/>
|
|
39
40
|
<input
|
|
40
41
|
{...props}
|
|
41
42
|
className={styles.input}
|
|
42
43
|
type="checkbox"
|
|
43
44
|
name={props.name}
|
|
45
|
+
checked={checked}
|
|
44
46
|
disabled={props.disabled}
|
|
45
|
-
onChange={(event) => onChangeCheckboxHandler(event)}
|
|
46
47
|
/>
|
|
47
48
|
</div>
|
|
48
49
|
);
|