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