@colisweb/rescript-toolkit 3.1.7 → 3.2.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/.yarn/install-state.gz
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -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
|
|
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>
|
|
@@ -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
|
-
|
|
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
|
|
|
@@ -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
|
+
}
|