@colisweb/rescript-toolkit 2.19.0 → 2.20.0
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/package.json
CHANGED
|
@@ -25,15 +25,21 @@ let make = (
|
|
|
25
25
|
~className="",
|
|
26
26
|
~size: size=#sm,
|
|
27
27
|
~checkboxClassName="",
|
|
28
|
-
|
|
28
|
+
~checkedClassname="",
|
|
29
|
+
~checkedCheckboxClassName="",
|
|
30
|
+
~inverseLabel=false,
|
|
31
|
+
) => {
|
|
32
|
+
let (isChecked, setChecked) = React.useState(() => checked->Option.getWithDefault(false))
|
|
29
33
|
<label
|
|
30
34
|
className={cx([
|
|
31
35
|
Styles.label,
|
|
32
|
-
"
|
|
36
|
+
"items-center",
|
|
37
|
+
inverseLabel ? "inline-flex flex-row-reverse justify-end" : "flex flex-row",
|
|
33
38
|
disabled->Option.getWithDefault(false)
|
|
34
39
|
? "cursor-not-allowed opacity-75 text-gray-600"
|
|
35
40
|
: "cursor-pointer",
|
|
36
41
|
className,
|
|
42
|
+
isChecked ? checkedClassname : "",
|
|
37
43
|
])}>
|
|
38
44
|
<input
|
|
39
45
|
type_="checkbox"
|
|
@@ -44,6 +50,7 @@ let make = (
|
|
|
44
50
|
let checked = target["checked"]
|
|
45
51
|
let value = target["value"]
|
|
46
52
|
|
|
53
|
+
setChecked(_ => checked)
|
|
47
54
|
onChange->Option.forEach(fn => fn(checked, value))
|
|
48
55
|
}}
|
|
49
56
|
?disabled
|
|
@@ -52,14 +59,16 @@ let make = (
|
|
|
52
59
|
/>
|
|
53
60
|
<span
|
|
54
61
|
className={cx([
|
|
55
|
-
"checkmark rounded border text-white
|
|
62
|
+
"checkmark rounded border text-white border-neutral-300 transform transition-all ease-in-out flex items-center justify-center flex-shrink-0",
|
|
56
63
|
switch size {
|
|
57
64
|
| #xs => "w-4 h-4"
|
|
58
65
|
| #sm => "w-6 h-6"
|
|
59
66
|
| #md => "w-8 h-8"
|
|
60
67
|
| #lg => "w-10 h-10"
|
|
61
68
|
},
|
|
69
|
+
inverseLabel ? "ml-3" : "mr-3",
|
|
62
70
|
checkboxClassName,
|
|
71
|
+
isChecked ? checkedCheckboxClassName : "",
|
|
63
72
|
])}>
|
|
64
73
|
<BsReactIcons.FaCheck
|
|
65
74
|
className="transform transition-all ease-in-out"
|
|
@@ -73,3 +82,4 @@ let make = (
|
|
|
73
82
|
</span>
|
|
74
83
|
{children->Option.getWithDefault(React.null)}
|
|
75
84
|
</label>
|
|
85
|
+
}
|