@colisweb/rescript-toolkit 5.4.0 → 5.4.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
|
@@ -361,6 +361,17 @@ module Make = (Lenses: Lenses) => {
|
|
|
361
361
|
)
|
|
362
362
|
}
|
|
363
363
|
|
|
364
|
+
let rec getIsNestedStateErrored = nestedErrors2 =>
|
|
365
|
+
nestedErrors2->Array.some(form => {
|
|
366
|
+
form->Array.some(((_, fieldState)) => {
|
|
367
|
+
switch fieldState {
|
|
368
|
+
| Error(_)
|
|
369
|
+
| NestedErrors(_) => true
|
|
370
|
+
| NestedErrors2(nextLevel) => getIsNestedStateErrored(nextLevel)
|
|
371
|
+
| _ => false
|
|
372
|
+
}
|
|
373
|
+
})
|
|
374
|
+
})
|
|
364
375
|
let validate = (~i18n=ReSchemaI18n.default, values: Lenses.state, schema: Validation.schema) => {
|
|
365
376
|
let validationList =
|
|
366
377
|
schema->Belt.Array.map(validator => validateField(~validator, ~values, ~i18n))
|
|
@@ -370,24 +381,7 @@ module Make = (Lenses: Lenses) => {
|
|
|
370
381
|
| Error(_) as e => Some((field, e))
|
|
371
382
|
| NestedErrors(_) as e => Some((field, e))
|
|
372
383
|
| NestedErrors2(nestedErrors2) as e =>
|
|
373
|
-
|
|
374
|
-
let rec getIsErrored = nestedErrors2 =>
|
|
375
|
-
nestedErrors2->Array.some(form => {
|
|
376
|
-
form->Array.some(
|
|
377
|
-
((_, fieldState)) => {
|
|
378
|
-
switch fieldState {
|
|
379
|
-
| Error(_)
|
|
380
|
-
| NestedErrors(_) => true
|
|
381
|
-
| NestedErrors2(nextLevel) => getIsErrored(nextLevel)
|
|
382
|
-
| _ => false
|
|
383
|
-
}
|
|
384
|
-
},
|
|
385
|
-
)
|
|
386
|
-
})
|
|
387
|
-
getIsErrored(nestedErrors2)
|
|
388
|
-
}
|
|
389
|
-
? Some((field, e))
|
|
390
|
-
: None
|
|
384
|
+
getIsNestedStateErrored(nestedErrors2) ? Some((field, e)) : None
|
|
391
385
|
| _ => None
|
|
392
386
|
}
|
|
393
387
|
)
|
|
@@ -5,13 +5,6 @@ module String = {
|
|
|
5
5
|
@ocaml.doc(" TODO: remove ")
|
|
6
6
|
let join = joinNonEmty
|
|
7
7
|
|
|
8
|
-
let includes = (str1, str2) => {
|
|
9
|
-
str1
|
|
10
|
-
->Js.String2.toLowerCase
|
|
11
|
-
->Js.String2.normalizeByForm("NFD")
|
|
12
|
-
->Js.String2.includes(str2->Js.String2.toLowerCase->Js.String2.normalizeByForm("NFD"))
|
|
13
|
-
}
|
|
14
|
-
|
|
15
8
|
/**
|
|
16
9
|
*Normalize NFD*: replace by re remove split by commponents the accent letters
|
|
17
10
|
and deletes the accent component only, leaving the un-accented letter
|
|
@@ -23,8 +16,8 @@ module String = {
|
|
|
23
16
|
->Js.String2.replaceByRe(%re("/[\u0300-\u036f]/g"), "")
|
|
24
17
|
}
|
|
25
18
|
|
|
26
|
-
let
|
|
27
|
-
str->normalizeForSearch->Js.String2.includes(search)
|
|
19
|
+
let normalizedIncludes = (str, search) => {
|
|
20
|
+
str->normalizeForSearch->Js.String2.includes(search->normalizeForSearch)
|
|
28
21
|
}
|
|
29
22
|
}
|
|
30
23
|
|
|
@@ -46,12 +46,7 @@ let make = (
|
|
|
46
46
|
let filterOptionsBySearch = (~options, ~search) => {
|
|
47
47
|
options->Array.keep(({label}) =>
|
|
48
48
|
// normalize nfd -> replace by re remove split by commponents the accent letters and deletes the accent component only, leaving the un-accented letter
|
|
49
|
-
search == "" ||
|
|
50
|
-
label
|
|
51
|
-
->Js.String2.toLowerCase
|
|
52
|
-
->Js.String2.normalizeByForm("NFD")
|
|
53
|
-
->Js.String2.replaceByRe(%re("/[\u0300-\u036f]/g"), "")
|
|
54
|
-
->Js.String2.includes(search)
|
|
49
|
+
search == "" || Toolkit__Primitives.String.normalizedIncludes(label, search)
|
|
55
50
|
)
|
|
56
51
|
}
|
|
57
52
|
|
|
@@ -99,12 +94,7 @@ let make = (
|
|
|
99
94
|
onChange={event => {
|
|
100
95
|
let target = event->ReactEvent.Form.currentTarget
|
|
101
96
|
// normalize nfd -> replace by re remove split by commponents the accent letters and deletes the accent component only, leaving the un-accented letter
|
|
102
|
-
setSearch(_ =>
|
|
103
|
-
target["value"]
|
|
104
|
-
->Js.String2.toLowerCase
|
|
105
|
-
->Js.String2.normalizeByForm("NFD")
|
|
106
|
-
->Js.String2.replaceByRe(%re("/[\u0300-\u036f]/g"), "")
|
|
107
|
-
)
|
|
97
|
+
setSearch(_ => target["value"])
|
|
108
98
|
}}
|
|
109
99
|
/>
|
|
110
100
|
</div>
|
|
@@ -112,12 +102,7 @@ let make = (
|
|
|
112
102
|
{options
|
|
113
103
|
->Array.keep(({label}) =>
|
|
114
104
|
// normalize nfd -> replace by re remove split by commponents the accent letters and deletes the accent component only, leaving the un-accented letter
|
|
115
|
-
search == "" ||
|
|
116
|
-
label
|
|
117
|
-
->Js.String2.toLowerCase
|
|
118
|
-
->Js.String2.normalizeByForm("NFD")
|
|
119
|
-
->Js.String2.replaceByRe(%re("/[\u0300-\u036f]/g"), "")
|
|
120
|
-
->Js.String2.includes(search)
|
|
105
|
+
search == "" || Toolkit__Primitives.String.normalizedIncludes(label, search)
|
|
121
106
|
)
|
|
122
107
|
->Array.mapWithIndex((i, item) => {
|
|
123
108
|
let {label, value} = item
|
|
@@ -121,12 +121,7 @@ let make = (
|
|
|
121
121
|
let filterOptionsBySearch = (~options, ~search) => {
|
|
122
122
|
options->Array.keep(({label}) =>
|
|
123
123
|
// normalize nfd -> replace by re remove split by commponents the accent letters and deletes the accent component only, leaving the un-accented letter
|
|
124
|
-
search == "" ||
|
|
125
|
-
label
|
|
126
|
-
->Js.String2.toLowerCase
|
|
127
|
-
->Js.String2.normalizeByForm("NFD")
|
|
128
|
-
->Js.String2.replaceByRe(%re("/[\u0300-\u036f]/g"), "")
|
|
129
|
-
->Js.String2.includes(search)
|
|
124
|
+
search == "" || Toolkit__Primitives.String.normalizedIncludes(label, search)
|
|
130
125
|
)
|
|
131
126
|
}
|
|
132
127
|
|
|
@@ -173,7 +168,7 @@ let make = (
|
|
|
173
168
|
onChange={event => {
|
|
174
169
|
let target = event->ReactEvent.Form.currentTarget
|
|
175
170
|
|
|
176
|
-
setSearch(_ => target["value"]
|
|
171
|
+
setSearch(_ => target["value"])
|
|
177
172
|
}}
|
|
178
173
|
/>
|
|
179
174
|
</div>
|
|
@@ -50,8 +50,7 @@ module Options = {
|
|
|
50
50
|
let make = (~options, ~deferredSearch, ~itemClassName, ~setSelectedOption, ~selectedOption) => {
|
|
51
51
|
options
|
|
52
52
|
->Array.keep(({label}) =>
|
|
53
|
-
deferredSearch == "" ||
|
|
54
|
-
label->Toolkit__Primitives.String.normalizeForSearch->Js.String2.includes(deferredSearch)
|
|
53
|
+
deferredSearch == "" || Toolkit__Primitives.String.normalizedIncludes(label, deferredSearch)
|
|
55
54
|
)
|
|
56
55
|
->Array.mapWithIndex((i, item) => {
|
|
57
56
|
let {label, value} = item
|