@colisweb/rescript-toolkit 5.26.0 → 5.26.2
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
package/src/form/ReSchema.res
CHANGED
|
@@ -71,7 +71,11 @@ module Make = (Lenses: Lenses) => {
|
|
|
71
71
|
}): t
|
|
72
72
|
| True({field: Lenses.field<bool>, error: option<string>}): t
|
|
73
73
|
| False({field: Lenses.field<bool>, error: option<string>}): t
|
|
74
|
-
| OptionNonEmpty({
|
|
74
|
+
| OptionNonEmpty({
|
|
75
|
+
field: Lenses.field<option<'a>>,
|
|
76
|
+
optionalPredicate?: Lenses.state => bool,
|
|
77
|
+
error: option<string>,
|
|
78
|
+
}): t
|
|
75
79
|
| ArrayNonEmpty({field: Lenses.field<array<'a>>, error: option<string>}): t
|
|
76
80
|
|
|
77
81
|
type schema = array<t>
|
|
@@ -96,7 +100,9 @@ module Make = (Lenses: Lenses) => {
|
|
|
96
100
|
[CustomNestedSchema2({field, predicate})]
|
|
97
101
|
}
|
|
98
102
|
|
|
99
|
-
let optionNonEmpty = (~error=?, field) => [
|
|
103
|
+
let optionNonEmpty = (~error=?, ~optionalPredicate=?, field) => [
|
|
104
|
+
OptionNonEmpty({field, ?optionalPredicate, error}),
|
|
105
|
+
]
|
|
100
106
|
|
|
101
107
|
let arrayNonEmpty = (~error=?, field) => [ArrayNonEmpty({field, error})]
|
|
102
108
|
|
|
@@ -359,14 +365,16 @@ module Make = (Lenses: Lenses) => {
|
|
|
359
365
|
|
|
360
366
|
(Field(field), NestedErrors2(results))
|
|
361
367
|
}
|
|
362
|
-
| Validation.OptionNonEmpty({field, error}) => {
|
|
368
|
+
| Validation.OptionNonEmpty({field, error} as props) => {
|
|
363
369
|
let value = Lenses.get(values, field)
|
|
364
370
|
|
|
365
371
|
(
|
|
366
372
|
Field(field),
|
|
367
|
-
value
|
|
368
|
-
|
|
369
|
-
|
|
373
|
+
switch value {
|
|
374
|
+
| _ if props.optionalPredicate->Option.mapWithDefault(false, fn => fn(values)) => Valid
|
|
375
|
+
| None => Error(error->Belt.Option.getWithDefault(i18n.stringNonEmpty(~value="")))
|
|
376
|
+
| Some(_) => Valid
|
|
377
|
+
},
|
|
370
378
|
)
|
|
371
379
|
}
|
|
372
380
|
| Validation.ArrayNonEmpty({field, error}) => {
|
|
@@ -738,6 +738,11 @@ module Make = (StateLenses: Config) => {
|
|
|
738
738
|
</Toolkit__Ui_Label>
|
|
739
739
|
<ReactPhoneNumberInput
|
|
740
740
|
international
|
|
741
|
+
className={cx([
|
|
742
|
+
"bg-white border rounded",
|
|
743
|
+
error->Option.isSome ? "border-danger-500" : "",
|
|
744
|
+
])}
|
|
745
|
+
id
|
|
741
746
|
value
|
|
742
747
|
countryCallingCodeEditable={false}
|
|
743
748
|
defaultCountry
|
package/src/ui/styles.css
CHANGED
|
@@ -33,6 +33,8 @@
|
|
|
33
33
|
|
|
34
34
|
:root {
|
|
35
35
|
--reach-dialog: 1;
|
|
36
|
+
--PhoneInputCountrySelectArrow-width: 0.5em;
|
|
37
|
+
--PhoneInputCountryFlag-height: 0.85em;
|
|
36
38
|
}
|
|
37
39
|
|
|
38
40
|
body {
|
|
@@ -260,16 +262,15 @@ input[type="number"] {
|
|
|
260
262
|
-moz-appearance: textfield;
|
|
261
263
|
}
|
|
262
264
|
|
|
263
|
-
.PhoneInput {
|
|
264
|
-
@apply bg-white border rounded;
|
|
265
|
-
}
|
|
266
|
-
|
|
267
265
|
.PhoneInputCountry {
|
|
268
|
-
@apply
|
|
266
|
+
@apply pr-2 m-2 border-r;
|
|
269
267
|
}
|
|
270
268
|
|
|
271
269
|
.PhoneInputInput {
|
|
272
270
|
@apply rounded-r py-2;
|
|
273
271
|
}
|
|
272
|
+
.PhoneInputCountrySelectArrow {
|
|
273
|
+
@apply relative -top-px ml-2 text-neutral-600;
|
|
274
|
+
}
|
|
274
275
|
|
|
275
276
|
/* purgecss end ignore */
|