@colisweb/rescript-toolkit 4.10.2 → 4.10.4
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 +12 -12
- package/src/decoders/Toolkit__Decoders.res +3 -3
- package/src/form/ReSchemaI18n.res +11 -11
- package/src/form/Reform.res +1 -6
- package/src/form/Toolkit__FormValidationFunctions.res +0 -18
- package/src/primitives/Toolkit__Primitives.res +3 -3
- package/src/router/Toolkit__Router.res +1 -3
- package/src/ui/Toolkit__Ui_TextInput.res +2 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@colisweb/rescript-toolkit",
|
|
3
|
-
"version": "4.10.
|
|
3
|
+
"version": "4.10.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"clean": "rescript clean",
|
|
@@ -30,9 +30,9 @@
|
|
|
30
30
|
"@colisweb/bs-react-intl-extractor-bin": "0.12.2",
|
|
31
31
|
"@colisweb/react-day-picker": "7.4.16",
|
|
32
32
|
"@colisweb/restorative": "1.0.0",
|
|
33
|
-
"@datadog/browser-rum": "4.
|
|
34
|
-
"@headlessui/react": "1.7.
|
|
35
|
-
"@headlessui/tailwindcss": "0.
|
|
33
|
+
"@datadog/browser-rum": "4.46.0",
|
|
34
|
+
"@headlessui/react": "1.7.16",
|
|
35
|
+
"@headlessui/tailwindcss": "0.2.0",
|
|
36
36
|
"@reach/auto-id": "0.18.0",
|
|
37
37
|
"@rescript/react": "0.11.0",
|
|
38
38
|
"autoprefixer": "10.4.14",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"lenses-ppx": "6.1.10",
|
|
48
48
|
"list-selectors": "2.0.1",
|
|
49
49
|
"lodash": "4.17.21",
|
|
50
|
-
"postcss": "8.4.
|
|
50
|
+
"postcss": "8.4.27",
|
|
51
51
|
"postcss-preset-env": "8.0.1",
|
|
52
52
|
"prismjs": "1.29.0",
|
|
53
53
|
"react": "18.2.0",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"react-icons": "4.10.1",
|
|
60
60
|
"react-intl": "6.4.4",
|
|
61
61
|
"react-portal": "4.2.2",
|
|
62
|
-
"react-select": "5.7.
|
|
62
|
+
"react-select": "5.7.4",
|
|
63
63
|
"react-table": "7.8.0",
|
|
64
64
|
"react-use": "17.4.0",
|
|
65
65
|
"reason-promise": "1.1.5",
|
|
@@ -69,17 +69,17 @@
|
|
|
69
69
|
"rescript-react-update": "5.0.0",
|
|
70
70
|
"sanitize-html": "1.27.4",
|
|
71
71
|
"swr": "2.2.0",
|
|
72
|
-
"tailwindcss": "3.3.
|
|
72
|
+
"tailwindcss": "3.3.3",
|
|
73
73
|
"use-local-storage-state": "18.3.3"
|
|
74
74
|
},
|
|
75
75
|
"devDependencies": {
|
|
76
|
-
"@babel/core": "7.22.
|
|
76
|
+
"@babel/core": "7.22.9",
|
|
77
77
|
"@jihchi/vite-plugin-rescript": "5.3.0",
|
|
78
78
|
"@mdx-js/mdx": "2.3.0",
|
|
79
79
|
"@mdx-js/react": "2.3.0",
|
|
80
80
|
"@mdx-js/rollup": "2.3.0",
|
|
81
|
-
"@originjs/vite-plugin-commonjs": "
|
|
82
|
-
"@vitejs/plugin-react": "4.0.
|
|
81
|
+
"@originjs/vite-plugin-commonjs": "1.0.3",
|
|
82
|
+
"@vitejs/plugin-react": "4.0.3",
|
|
83
83
|
"babel-loader": "8.2.5",
|
|
84
84
|
"highlight.js": "11.8.0",
|
|
85
85
|
"husky": "8.0.3",
|
|
@@ -90,8 +90,8 @@
|
|
|
90
90
|
"rehype-autolink-headings": "^6.1.1",
|
|
91
91
|
"rehype-highlight": "^6.0.0",
|
|
92
92
|
"rehype-slug": "^5.1.0",
|
|
93
|
-
"sass": "1.
|
|
94
|
-
"vite": "4.
|
|
93
|
+
"sass": "1.64.1",
|
|
94
|
+
"vite": "4.4.7"
|
|
95
95
|
},
|
|
96
96
|
"packageManager": "yarn@3.3.1"
|
|
97
97
|
}
|
|
@@ -419,12 +419,12 @@ module UnitMeasure = {
|
|
|
419
419
|
|
|
420
420
|
module StringArray = {
|
|
421
421
|
let encoder = (encoder, value) =>
|
|
422
|
-
value->Array.map(encoder)
|
|
422
|
+
value->Array.map(encoder)->Js.Array2.joinWith(",")->Decco.stringToJson
|
|
423
423
|
|
|
424
424
|
let decoder = (decoder, json) =>
|
|
425
|
-
switch json
|
|
425
|
+
switch json->Decco.stringFromJson {
|
|
426
426
|
| Ok(string) =>
|
|
427
|
-
let resultArray =
|
|
427
|
+
let resultArray = string->Js.String2.split(",")->Array.map(e => e->Js.Json.string->decoder)
|
|
428
428
|
let error = resultArray->Array.getBy(Result.isError)
|
|
429
429
|
switch error {
|
|
430
430
|
| Some(_) => Decco.error(~path="", "Invalid content", json)
|
|
@@ -13,22 +13,22 @@ type t = {
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
let default = {
|
|
16
|
-
false_: () => "
|
|
17
|
-
true_: () => "
|
|
16
|
+
false_: () => "Cette valeur doit être fausse",
|
|
17
|
+
true_: () => "Cette valeur doit être vraie",
|
|
18
18
|
intMin: (~value as _value, ~min) =>
|
|
19
|
-
|
|
19
|
+
`Cette valeur doit être supérieur ou égale à ${min->Int.toString}`,
|
|
20
20
|
intMax: (~value as _value, ~max) =>
|
|
21
|
-
|
|
21
|
+
`Cette valeur doit être inférieur ou égale à ${max->Int.toString}`,
|
|
22
22
|
floatMin: (~value as _value, ~min) =>
|
|
23
|
-
|
|
23
|
+
`Cette valeur doit être supérieur ou égale à ${min->Js.Float.toString}`,
|
|
24
24
|
floatMax: (~value as _value, ~max) =>
|
|
25
|
-
|
|
26
|
-
email: (~value) => value
|
|
27
|
-
stringNonEmpty: (~value as _) => "
|
|
25
|
+
`Cette valeur doit être supérieur ou égale à ${max->Js.Float.toString}`,
|
|
26
|
+
email: (~value) => `${value} n'est pas un e-mail valide`,
|
|
27
|
+
stringNonEmpty: (~value as _) => "Champs requis",
|
|
28
28
|
stringRegExp: (~value as _value, ~pattern) =>
|
|
29
|
-
|
|
29
|
+
`Cette valeur doit correspondre à ce pattern /${pattern}/`,
|
|
30
30
|
stringMin: (~value as _value, ~min) =>
|
|
31
|
-
|
|
31
|
+
`Le champ doit avoir au minimum ${min->Int.toString} caractères.`,
|
|
32
32
|
stringMax: (~value as _value, ~max) =>
|
|
33
|
-
|
|
33
|
+
`Le champ doit avoir au maximum ${max->Int.toString} caractères.`,
|
|
34
34
|
}
|
package/src/form/Reform.res
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
open ReactIntl
|
|
2
|
-
|
|
3
1
|
module type Config = {
|
|
4
2
|
type field<'a>
|
|
5
3
|
type state
|
|
@@ -180,13 +178,10 @@ module Make = (Config: Config) => {
|
|
|
180
178
|
~schema=[]: Validation.schema,
|
|
181
179
|
~onSubmit,
|
|
182
180
|
~onSubmitFail=ignore,
|
|
183
|
-
~i18n
|
|
181
|
+
~i18n: ReSchemaI18n.t=ReSchemaI18n.default,
|
|
184
182
|
~validationStrategy=OnChange,
|
|
185
183
|
(),
|
|
186
184
|
) => {
|
|
187
|
-
let intl = useIntl()
|
|
188
|
-
let i18n = i18n->Option.getWithDefault(Toolkit__FormValidationFunctions.i18n(intl))
|
|
189
|
-
|
|
190
185
|
let (state, send) = ReactUpdate.useReducerWithMapState(
|
|
191
186
|
(state, action) => {
|
|
192
187
|
switch action {
|
|
@@ -395,21 +395,3 @@ let required14Digits = (intl, value) => {
|
|
|
395
395
|
}
|
|
396
396
|
}
|
|
397
397
|
}
|
|
398
|
-
|
|
399
|
-
let i18n = intl => {
|
|
400
|
-
...ReSchemaI18n.default,
|
|
401
|
-
stringNonEmpty: (~value as _) => intl->Intl.formatMessage(Msg.stringNonEmpty),
|
|
402
|
-
intMin: (~value as _: int, ~min: int) =>
|
|
403
|
-
intl->Intl.formatMessageWithValues(Msg.minValue, {"value": min}),
|
|
404
|
-
intMax: (~value as _: int, ~max: int) =>
|
|
405
|
-
intl->Intl.formatMessageWithValues(Msg.maxValue, {"value": max}),
|
|
406
|
-
floatMin: (~value as _: float, ~min: float) =>
|
|
407
|
-
intl->Intl.formatMessageWithValues(Msg.minValue, {"value": min}),
|
|
408
|
-
floatMax: (~value as _: float, ~max: float) =>
|
|
409
|
-
intl->Intl.formatMessageWithValues(Msg.maxValue, {"value": max}),
|
|
410
|
-
email: (~value as _: string) => intl->Intl.formatMessage(Msg.email),
|
|
411
|
-
stringMin: (~value as _: string, ~min: int) =>
|
|
412
|
-
intl->Intl.formatMessageWithValues(Msg.stringMin, {"value": min}),
|
|
413
|
-
stringMax: (~value as _: string, ~max: int) =>
|
|
414
|
-
intl->Intl.formatMessageWithValues(Msg.stringMax, {"value": max}),
|
|
415
|
-
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
module String = {
|
|
2
2
|
let joinNonEmty = (~separator=", ", parts: array<string>): string =>
|
|
3
|
-
parts->Array.keep(str => str !== "")
|
|
3
|
+
parts->Array.keep(str => str !== "")->Js.Array2.joinWith(separator)
|
|
4
4
|
|
|
5
5
|
@ocaml.doc(" TODO: remove ")
|
|
6
6
|
let join = joinNonEmty
|
|
@@ -39,7 +39,7 @@ module Option = {
|
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
let join = (~separator=" ", parts) =>
|
|
42
|
-
|
|
42
|
+
parts->Array.keepMap(v => v)->Js.Array2.joinWith(separator)->fromString
|
|
43
43
|
|
|
44
44
|
let mapString = opt => opt->Option.flatMap(fromString)
|
|
45
45
|
|
|
@@ -61,7 +61,7 @@ module Option = {
|
|
|
61
61
|
|
|
62
62
|
module Array = {
|
|
63
63
|
let joinNonEmpty = (~separator=", ", parts: array<string>): string =>
|
|
64
|
-
parts->Array.keep(str => str !== "")
|
|
64
|
+
parts->Array.keep(str => str !== "")->Js.Array2.joinWith(separator)
|
|
65
65
|
|
|
66
66
|
let tail = array => array->Array.get(array->Array.length - 1)
|
|
67
67
|
let tailExn = array => array->Array.getExn(array->Array.length - 1)
|
|
@@ -32,9 +32,7 @@ module Make = (Config: RouterConfig) => {
|
|
|
32
32
|
let previousRoute = Toolkit__Hooks.usePrevious(currentRoute)
|
|
33
33
|
|
|
34
34
|
React.useLayoutEffect1(() => {
|
|
35
|
-
let watcherID = RescriptReactRouter.watchUrl(url =>
|
|
36
|
-
setCurrentRoute(_ => url |> Config.make)
|
|
37
|
-
)
|
|
35
|
+
let watcherID = RescriptReactRouter.watchUrl(url => setCurrentRoute(_ => url->Config.make))
|
|
38
36
|
Some(() => RescriptReactRouter.unwatchUrl(watcherID))
|
|
39
37
|
}, [setCurrentRoute])
|
|
40
38
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
@react.component
|
|
2
2
|
let make = React.forwardRef((
|
|
3
3
|
~id: string,
|
|
4
|
+
~accept: option<string>=?,
|
|
4
5
|
~name: option<string>=?,
|
|
5
6
|
~value: option<string>=?,
|
|
6
7
|
~defaultValue: option<string>=?,
|
|
@@ -34,6 +35,7 @@ let make = React.forwardRef((
|
|
|
34
35
|
isInvalid->Option.getWithDefault(false) ? "border-danger-500 shadow-danger-500" : "",
|
|
35
36
|
])}
|
|
36
37
|
id
|
|
38
|
+
?accept
|
|
37
39
|
?style
|
|
38
40
|
?name
|
|
39
41
|
?value
|