@colisweb/rescript-toolkit 4.0.0 → 4.1.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/.secure_files/ci-functions-v17.2.0 +2547 -0
- package/.secure_files/ci-functions-v17.2.1 +2547 -0
- package/.secure_files/ci-functions-v17.2.2 +2547 -0
- package/.secure_files/ci-functions-v17.2.3 +2547 -0
- package/.secure_files/ci-functions-v17.2.4 +2547 -0
- package/.secure_files/ci-functions-v17.3.0 +2547 -0
- package/.secure_files/ci-functions-v17.3.1 +2547 -0
- package/.secure_files/ci-functions-v17.3.2 +2547 -0
- package/.secure_files/ci-functions-v17.3.3 +2547 -0
- package/package.json +1 -1
- package/src/form/Toolkit__Form.res +5 -5
- package/src/form/Toolkit__FormValidationFunctions.res +10 -0
- package/src/ui/Toolkit__Ui_MultiSelect.res +3 -2
- package/src/ui/Toolkit__Ui_TextInput.res +14 -1
package/package.json
CHANGED
|
@@ -45,7 +45,7 @@ module Make = (StateLenses: Config) => {
|
|
|
45
45
|
(),
|
|
46
46
|
): api => {
|
|
47
47
|
let intl = useIntl()
|
|
48
|
-
|
|
48
|
+
|
|
49
49
|
use(
|
|
50
50
|
~initialState,
|
|
51
51
|
~schema,
|
|
@@ -66,7 +66,7 @@ module Make = (StateLenses: Config) => {
|
|
|
66
66
|
~validationStrategy,
|
|
67
67
|
(),
|
|
68
68
|
)
|
|
69
|
-
|
|
69
|
+
}
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
module CustomValidation = {
|
|
@@ -143,6 +143,7 @@ module Make = (StateLenses: Config) => {
|
|
|
143
143
|
~errorClassName=?,
|
|
144
144
|
~optionalMessage: option<React.element>=?,
|
|
145
145
|
~autoComplete=?,
|
|
146
|
+
~allowWhiteSpace=false,
|
|
146
147
|
) => {
|
|
147
148
|
let (showPassword, setShowPassword) = React.useState(() => false)
|
|
148
149
|
let isPasswordType = type_->Option.mapWithDefault(false, type_ => type_ === "password")
|
|
@@ -153,8 +154,6 @@ module Make = (StateLenses: Config) => {
|
|
|
153
154
|
render={({handleChange, error, value, validate, state}) => {
|
|
154
155
|
let isInvalid = error->Option.isSome
|
|
155
156
|
|
|
156
|
-
let onChange = Helpers.handleChange(handleChange)
|
|
157
|
-
|
|
158
157
|
let onBlur = _ =>
|
|
159
158
|
switch state {
|
|
160
159
|
| Pristine => ()
|
|
@@ -195,12 +194,13 @@ module Make = (StateLenses: Config) => {
|
|
|
195
194
|
)}
|
|
196
195
|
?disabled
|
|
197
196
|
?placeholder
|
|
197
|
+
allowWhiteSpace
|
|
198
198
|
?autoFocus
|
|
199
199
|
?step
|
|
200
200
|
?min
|
|
201
201
|
?max
|
|
202
202
|
isInvalid
|
|
203
|
-
|
|
203
|
+
onChangeText={handleChange}
|
|
204
204
|
onBlur
|
|
205
205
|
/>
|
|
206
206
|
{type_->Option.mapWithDefault(React.null, type_ => {
|
|
@@ -95,6 +95,16 @@ let requiredPosFloat = (intl, value) => {
|
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
+
let requiredStrictPosFloat = (intl, value) => {
|
|
99
|
+
switch value {
|
|
100
|
+
| "" => Some(Intl.formatMessage(intl, Msg.requiredValue))
|
|
101
|
+
| value
|
|
102
|
+
if !Toolkit__Utils_Regex.Test.isPositiveIntOrFloat(value) || value->Float.fromString === Some(0.) =>
|
|
103
|
+
Some(Intl.formatMessage(intl, Msg.requiredPosIntOrFloat))
|
|
104
|
+
| _ => None
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
98
108
|
let requiredFloat = (intl, value) => {
|
|
99
109
|
switch value->Js.String2.split("-") {
|
|
100
110
|
| _ if value === "" => Some(Intl.formatMessage(intl, Msg.requiredValue))
|
|
@@ -19,8 +19,8 @@ let make = (
|
|
|
19
19
|
~allowFilter=true,
|
|
20
20
|
~defaultValue: array<item>=[],
|
|
21
21
|
~onChange: array<item> => unit,
|
|
22
|
-
~disabled: bool
|
|
23
|
-
~onClose: unit => unit
|
|
22
|
+
~disabled: option<bool>=?,
|
|
23
|
+
~onClose: option<unit => unit>=?,
|
|
24
24
|
~displaySelectOnlyOption=false,
|
|
25
25
|
) => {
|
|
26
26
|
let (selectedOptions, setSelectedOptions) = React.useState(() => defaultValue)
|
|
@@ -85,6 +85,7 @@ let make = (
|
|
|
85
85
|
id="search"
|
|
86
86
|
autoFocus={true}
|
|
87
87
|
placeholder=?{searchPlaceholder}
|
|
88
|
+
allowWhiteSpace={true}
|
|
88
89
|
onKeyDown={event => {
|
|
89
90
|
if event->ReactEvent.Keyboard.key === "Enter" && search !== "" {
|
|
90
91
|
let selectedOptions = filterOptionsBySearch(~options, ~search)
|
|
@@ -19,6 +19,8 @@ let make = React.forwardRef((
|
|
|
19
19
|
~onBlur: option<ReactEvent.Focus.t => unit>=?,
|
|
20
20
|
~onKeyDown: option<ReactEvent.Keyboard.t => unit>=?,
|
|
21
21
|
~onChange: option<ReactEvent.Form.t => unit>=?,
|
|
22
|
+
~onChangeText: option<string => unit>=?,
|
|
23
|
+
~allowWhiteSpace=false,
|
|
22
24
|
~isInvalid: option<bool>=?,
|
|
23
25
|
~className: string="",
|
|
24
26
|
~style: option<ReactDOM.style>=?,
|
|
@@ -48,7 +50,18 @@ let make = React.forwardRef((
|
|
|
48
50
|
?step
|
|
49
51
|
?min
|
|
50
52
|
?max
|
|
51
|
-
|
|
53
|
+
onChange={event => {
|
|
54
|
+
let value = (event->ReactEvent.Form.target)["value"]
|
|
55
|
+
|
|
56
|
+
onChangeText->Option.forEach(fn => {
|
|
57
|
+
if allowWhiteSpace {
|
|
58
|
+
fn(value)
|
|
59
|
+
} else {
|
|
60
|
+
fn(value->Js.String2.trim)
|
|
61
|
+
}
|
|
62
|
+
})
|
|
63
|
+
onChange->Option.forEach(fn => fn(event))
|
|
64
|
+
}}
|
|
52
65
|
?onBlur
|
|
53
66
|
?onKeyDown
|
|
54
67
|
/>
|