@colisweb/rescript-toolkit 3.1.7 → 3.2.1

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.
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@colisweb/rescript-toolkit",
3
- "version": "3.1.7",
3
+ "version": "3.2.1",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "clean": "rescript clean",
@@ -71,7 +71,13 @@ let make = () => {
71
71
  <div
72
72
  key={(i + k)->Int.toString ++ "icon" ++ ((color :> string) ++ sizeText)}
73
73
  className="flex flex-col justify-center items-center">
74
- <Toolkit__Ui_Button leftIcon=module(ReactIcons.FaCheck) variant color size>
74
+ <Toolkit__Ui_Button
75
+ leftIcon=module(ReactIcons.FaCheck)
76
+ variant
77
+ color
78
+ size
79
+ confirmationLabel={"Confirmation label on click"}
80
+ onClick={_ => Js.log("test")}>
75
81
  {"hello"->React.string}
76
82
  </Toolkit__Ui_Button>
77
83
  <span className="text-xxs"> {sizeText->React.string} </span>
@@ -18,7 +18,7 @@ let make = (~title, ~description=?, ~status, ~className=?) =>
18
18
  | #error => <ReactIcons.MdWarning size=28 className="text-danger-600 flex-shrink-0" />
19
19
  | #warning =>
20
20
  <ReactIcons.FaExclamationTriangle size=28 className="text-warning-600 flex-shrink-0" />
21
- | #info => <ReactIcons.FaExclamationCircle size=28 className="text-info-600 flex-shrink-0" />
21
+ | #info => <ReactIcons.FaInfoCircle size=28 className="text-info-600 flex-shrink-0" />
22
22
  }}
23
23
  <div className="mx-3">
24
24
  <div
@@ -128,8 +128,28 @@ let make = (
128
128
  ~rightIcon: option<module(Icon)>=?,
129
129
  ~iconClassName=?,
130
130
  ~testId="",
131
+ ~confirmationLabel: option<string>=?,
131
132
  ~buttonRef: option<ReactDOM.domRef>=?,
132
133
  ) => {
134
+ let (clicked, setClicked) = React.useState(() => false)
135
+
136
+ React.useEffect1(() => {
137
+ let timeoutId = Js.Global.setTimeout(() => {
138
+ setClicked(_ => false)
139
+ }, 3000)
140
+
141
+ Some(
142
+ () => {
143
+ timeoutId->Js.Global.clearTimeout
144
+ },
145
+ )
146
+ }, [clicked])
147
+
148
+ let variant = switch (confirmationLabel, onClick) {
149
+ | (Some(_), Some(_)) => clicked ? #default : variant
150
+ | _ => variant
151
+ }
152
+
133
153
  <Toolkit__Ui_Spread props={{"data-testid": cx([testId])}}>
134
154
  <button
135
155
  ref=?{buttonRef}
@@ -143,7 +163,13 @@ let make = (
143
163
  ?tabIndex
144
164
  ?onFocus
145
165
  ?onBlur
146
- ?onClick
166
+ onClick={event => {
167
+ switch (confirmationLabel, onClick) {
168
+ | (None, Some(fn)) => fn(event)
169
+ | (Some(_), Some(fn)) => clicked ? fn(event) : setClicked(_ => true)
170
+ | _ => ()
171
+ }
172
+ }}
147
173
  className={cx([
148
174
  className,
149
175
  buttonStyle(~color, ~variant, ~size, ~disabled, ()),
@@ -164,7 +190,9 @@ let make = (
164
190
  />
165
191
  </span>
166
192
  })}
167
- children
193
+ {confirmationLabel->Option.mapWithDefault(children, confirmationLabel => {
194
+ clicked ? confirmationLabel->React.string : children
195
+ })}
168
196
  {rightIcon->Option.mapWithDefault(React.null, icon => {
169
197
  let module(Icon) = icon
170
198
 
@@ -38,5 +38,6 @@ let make: (
38
38
  ~rightIcon: module(ReactIcons.Icon)=?,
39
39
  ~iconClassName: string=?,
40
40
  ~testId: string=?,
41
+ ~confirmationLabel: string=?,
41
42
  ~buttonRef: ReactDOM.domRef=?,
42
43
  ) => React.element
@@ -6039,3 +6039,9 @@ module VscFolderLibrary = {
6039
6039
  external make: (~size: int=?, ~color: string=?, ~className: string=?) => React.element =
6040
6040
  "VscFolderLibrary"
6041
6041
  }
6042
+
6043
+ module FaRegTrashAlt = {
6044
+ @module("react-icons/fa") @react.component
6045
+ external make: (~size: int=?, ~color: string=?, ~className: string=?) => React.element =
6046
+ "FaRegTrashAlt"
6047
+ }