@colisweb/rescript-toolkit 2.33.3 → 2.36.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.33.3",
3
+ "version": "2.36.0",
4
4
  "scripts": {
5
5
  "clean": "rescript clean",
6
6
  "build": "rescript build",
@@ -100,6 +100,7 @@ module Make = (StateLenses: Config) => {
100
100
  ~inputRightAddon=?,
101
101
  ~errorClassName=?,
102
102
  ~optionalMessage: option<React.element>=?,
103
+ ~autocomplete: option<string>=?,
103
104
  ) => {
104
105
  let (showPassword, setShowPassword) = React.useState(() => false)
105
106
  let isPasswordType = type_->Option.mapWithDefault(false, type_ => type_ === "password")
@@ -138,27 +139,36 @@ module Make = (StateLenses: Config) => {
138
139
  </Toolkit__Ui.Label>
139
140
  }}
140
141
  <div className={cx(["flex flex-row", inputContainerClassName])}>
141
- <Toolkit__Ui.TextInput
142
- className={cx([
143
- inputClassName,
144
- inputRightAddon->Option.isSome || isPasswordType ? "rounded-r-none" : "",
145
- ])}
146
- id
147
- value
148
- ?name
149
- type_=?{type_->Option.map(type_ =>
150
- type_ === "password" && showPassword ? "text" : type_
151
- )}
152
- ?disabled
153
- ?placeholder
154
- ?autoFocus
155
- ?step
156
- ?min
157
- ?max
158
- isInvalid
159
- onChange
160
- onBlur
161
- />
142
+ <Toolkit__Ui_Spread
143
+ props={autocomplete->Option.mapWithDefault(Js.Obj.empty(), (
144
+ autocomplete: string,
145
+ ) =>
146
+ {
147
+ "autocomplete": autocomplete,
148
+ }
149
+ )}>
150
+ <Toolkit__Ui.TextInput
151
+ className={cx([
152
+ inputClassName,
153
+ inputRightAddon->Option.isSome || isPasswordType ? "rounded-r-none" : "",
154
+ ])}
155
+ id
156
+ value
157
+ ?name
158
+ type_=?{type_->Option.map(type_ =>
159
+ type_ === "password" && showPassword ? "text" : type_
160
+ )}
161
+ ?disabled
162
+ ?placeholder
163
+ ?autoFocus
164
+ ?step
165
+ ?min
166
+ ?max
167
+ isInvalid
168
+ onChange
169
+ onBlur
170
+ />
171
+ </Toolkit__Ui_Spread>
162
172
  {type_->Option.mapWithDefault(React.null, type_ => {
163
173
  switch type_ {
164
174
  | "password" =>
@@ -22,6 +22,7 @@ let make = (
22
22
  ~onChange=?,
23
23
  ~name=?,
24
24
  ~checked=?,
25
+ ~defaultChecked=?,
25
26
  ~className="",
26
27
  ~size: size=#sm,
27
28
  ~checkboxClassName="",
@@ -31,6 +32,17 @@ let make = (
31
32
  ~hideLabel=false,
32
33
  ) => {
33
34
  let (isChecked, setChecked) = React.useState(() => checked->Option.getWithDefault(false))
35
+ let previousChecked = Toolkit__Hooks.usePrevious(isChecked)
36
+
37
+ React.useEffect2(() => {
38
+ switch (previousChecked, checked) {
39
+ | (Some(previous), Some(checked)) if previous != checked => setChecked(_ => checked)
40
+ | _ => ()
41
+ }
42
+
43
+ None
44
+ }, (previousChecked, checked))
45
+
34
46
  <label
35
47
  className={cx([
36
48
  Styles.label,
@@ -45,6 +57,7 @@ let make = (
45
57
  <input
46
58
  type_="checkbox"
47
59
  value
60
+ ?defaultChecked
48
61
  className="hidden"
49
62
  onChange={event => {
50
63
  let target = ReactEvent.Form.target(event)
@@ -8,6 +8,7 @@ let make: (
8
8
  ~onChange: (bool, string) => unit=?,
9
9
  ~name: string=?,
10
10
  ~checked: bool=?,
11
+ ~defaultChecked: bool=?,
11
12
  ~className: string=?,
12
13
  ~size: size=?,
13
14
  ~checkboxClassName: string=?,
@@ -43,3 +43,7 @@ module ControlledAccordionMultiple = {
43
43
  ~readOnly: option<bool>=?,
44
44
  ) => React.element = "Accordion"
45
45
  }
46
+
47
+ type accordionContext = {isExpanded: bool, index: int}
48
+ @module("@reach/accordion")
49
+ external useAccordionItemContext: unit => accordionContext = "useAccordionItemContext"