@colisweb/rescript-toolkit 5.4.1 → 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
|
@@ -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
|