@colisweb/rescript-toolkit 2.16.0 → 2.18.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.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@colisweb/rescript-toolkit",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.18.1",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"clean": "rescript clean",
|
|
6
6
|
"build": "rescript build",
|
|
@@ -86,6 +86,7 @@
|
|
|
86
86
|
"raw-loader": "4.0.2",
|
|
87
87
|
"react": "17.0.2",
|
|
88
88
|
"react-dom": "17.0.2",
|
|
89
|
+
"react-intl": "5.24.7",
|
|
89
90
|
"react-is": "17.0.2",
|
|
90
91
|
"sass": "1.45.0"
|
|
91
92
|
}
|
|
@@ -100,9 +100,13 @@ module Make = (StateLenses: Config) => {
|
|
|
100
100
|
~inputRightAddon=?,
|
|
101
101
|
~errorClassName=?,
|
|
102
102
|
~optionalMessage: option<React.element>=?,
|
|
103
|
-
) =>
|
|
103
|
+
) => {
|
|
104
|
+
let (showPassword, setShowPassword) = React.useState(() => false)
|
|
105
|
+
let isPasswordType = type_->Option.mapWithDefault(false, type_ => type_ === "password")
|
|
106
|
+
|
|
104
107
|
<Form.Field
|
|
105
108
|
field
|
|
109
|
+
key={showPassword->string_of_bool}
|
|
106
110
|
render={({handleChange, error, value, validate, state}) => {
|
|
107
111
|
let isInvalid = error->Option.isSome
|
|
108
112
|
|
|
@@ -137,12 +141,14 @@ module Make = (StateLenses: Config) => {
|
|
|
137
141
|
<Toolkit__Ui.TextInput
|
|
138
142
|
className={cx([
|
|
139
143
|
inputClassName,
|
|
140
|
-
inputRightAddon->Option.isSome ? "rounded-r-none" : "",
|
|
144
|
+
inputRightAddon->Option.isSome || isPasswordType ? "rounded-r-none" : "",
|
|
141
145
|
])}
|
|
142
146
|
id
|
|
143
147
|
value
|
|
144
148
|
?name
|
|
145
|
-
|
|
149
|
+
type_=?{type_->Option.map(type_ =>
|
|
150
|
+
type_ === "password" && showPassword ? "text" : type_
|
|
151
|
+
)}
|
|
146
152
|
?disabled
|
|
147
153
|
?placeholder
|
|
148
154
|
?autoFocus
|
|
@@ -153,6 +159,29 @@ module Make = (StateLenses: Config) => {
|
|
|
153
159
|
onChange
|
|
154
160
|
onBlur
|
|
155
161
|
/>
|
|
162
|
+
{type_->Option.mapWithDefault(React.null, type_ => {
|
|
163
|
+
switch type_ {
|
|
164
|
+
| "password" =>
|
|
165
|
+
<Toolkit__Ui_Tooltip
|
|
166
|
+
label={showPassword
|
|
167
|
+
? <ReactIntl.FormattedMessage
|
|
168
|
+
id="toolkit.hidePassword" defaultMessage="Hide password"
|
|
169
|
+
/>
|
|
170
|
+
: <ReactIntl.FormattedMessage
|
|
171
|
+
id="toolkit.showPassword" defaultMessage="Show password"
|
|
172
|
+
/>}>
|
|
173
|
+
<button
|
|
174
|
+
type_="button"
|
|
175
|
+
className="p-1 bg-neutral-300 rounded-r border border-gray-300 text-neutral-800"
|
|
176
|
+
onClick={_ => setShowPassword(v => !v)}>
|
|
177
|
+
{showPassword
|
|
178
|
+
? <BsReactIcons.AiFillEyeInvisible size={26} />
|
|
179
|
+
: <BsReactIcons.AiFillEye size={26} />}
|
|
180
|
+
</button>
|
|
181
|
+
</Toolkit__Ui_Tooltip>
|
|
182
|
+
| _ => React.null
|
|
183
|
+
}
|
|
184
|
+
})}
|
|
156
185
|
{inputRightAddon->Option.getWithDefault(React.null)}
|
|
157
186
|
</div>
|
|
158
187
|
</div>
|
|
@@ -160,5 +189,6 @@ module Make = (StateLenses: Config) => {
|
|
|
160
189
|
</>
|
|
161
190
|
}}
|
|
162
191
|
/>
|
|
192
|
+
}
|
|
163
193
|
}
|
|
164
194
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
@react.component
|
|
2
2
|
let make = (~htmlFor, ~className="", ~optionalMessage=?, ~children) =>
|
|
3
|
-
<label htmlFor className={cx(["block text-
|
|
3
|
+
<label htmlFor className={cx(["block text-neutral-700 font-semibold leading-5 mb-1", className])}>
|
|
4
4
|
children
|
|
5
5
|
{optionalMessage->Option.mapWithDefault(React.null, message =>
|
|
6
6
|
<span className="ml-2 text-neutral-500 italic text-sm"> message </span>
|
|
@@ -20,7 +20,7 @@ let modalStyle = (~type_) =>
|
|
|
20
20
|
| #default => "rounded"
|
|
21
21
|
| #colored(color) =>
|
|
22
22
|
switch color {
|
|
23
|
-
| #primary => "rounded-lg
|
|
23
|
+
| #primary => "rounded-lg"
|
|
24
24
|
| #success => "rounded-lg border-2 border-success-500"
|
|
25
25
|
| #danger => "rounded-lg border-4 border-danger-700"
|
|
26
26
|
| #neutral => "rounded-lg"
|
|
@@ -32,7 +32,7 @@ let headerStyle = (~type_) =>
|
|
|
32
32
|
| #default => ""
|
|
33
33
|
| #colored(color) =>
|
|
34
34
|
switch color {
|
|
35
|
-
| #primary => "bg-primary-
|
|
35
|
+
| #primary => "bg-primary-700 rounded-t"
|
|
36
36
|
| #success => "bg-success-500 rounded-t"
|
|
37
37
|
| #danger => "bg-danger-700"
|
|
38
38
|
| #neutral => "bg-neutral-700 rounded-t-lg"
|
|
@@ -5899,3 +5899,12 @@ module IoIosCloseCircle = {
|
|
|
5899
5899
|
external make: (~size: int=?, ~color: string=?, ~className: string=?) => React.element =
|
|
5900
5900
|
"IoIosCloseCircle"
|
|
5901
5901
|
}
|
|
5902
|
+
|
|
5903
|
+
module AiFillEyeInvisible = {
|
|
5904
|
+
@module("react-icons/ai") @react.component
|
|
5905
|
+
external make: (~size: int=?) => React.element = "AiFillEyeInvisible"
|
|
5906
|
+
}
|
|
5907
|
+
module AiFillEye = {
|
|
5908
|
+
@module("react-icons/ai") @react.component
|
|
5909
|
+
external make: (~size: int=?) => React.element = "AiFillEye"
|
|
5910
|
+
}
|