@colisweb/rescript-toolkit 4.10.2 → 4.10.3

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@colisweb/rescript-toolkit",
3
- "version": "4.10.2",
3
+ "version": "4.10.3",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "clean": "rescript clean",
@@ -419,12 +419,12 @@ module UnitMeasure = {
419
419
 
420
420
  module StringArray = {
421
421
  let encoder = (encoder, value) =>
422
- value->Array.map(encoder) |> Js.Array.joinWith(",") |> Decco.stringToJson
422
+ value->Array.map(encoder)->Js.Array2.joinWith(",")->Decco.stringToJson
423
423
 
424
424
  let decoder = (decoder, json) =>
425
- switch json |> Decco.stringFromJson {
425
+ switch json->Decco.stringFromJson {
426
426
  | Ok(string) =>
427
- let resultArray = (string |> Js.String.split(","))->Array.map(e => e->Js.Json.string->decoder)
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_: () => "This value should be false",
17
- true_: () => "This value should be true",
16
+ false_: () => "Cette valeur doit être fausse",
17
+ true_: () => "Cette valeur doit être vraie",
18
18
  intMin: (~value as _value, ~min) =>
19
- "This value must be greater than or equal to " ++ string_of_int(min),
19
+ `Cette valeur doit être supérieur ou égale à ${min->Int.toString}`,
20
20
  intMax: (~value as _value, ~max) =>
21
- "This value must be less than or equal to " ++ string_of_int(max),
21
+ `Cette valeur doit être inférieur ou égale à ${max->Int.toString}`,
22
22
  floatMin: (~value as _value, ~min) =>
23
- "This value must be greater than or equal to " ++ Js.Float.toString(min),
23
+ `Cette valeur doit être supérieur ou égale à ${min->Js.Float.toString}`,
24
24
  floatMax: (~value as _value, ~max) =>
25
- "This value must be less than or equal to " ++ Js.Float.toString(max),
26
- email: (~value) => value ++ " is not a valid email",
27
- stringNonEmpty: (~value as _) => "String must not be empty",
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
- "This value must match the following: /" ++ pattern ++ "/",
29
+ `Cette valeur doit correspondre à ce pattern /${pattern}/`,
30
30
  stringMin: (~value as _value, ~min) =>
31
- "This value must be at least " ++ string_of_int(min) ++ " characters",
31
+ `Le champ doit avoir au minimum ${min->Int.toString} caractères.`,
32
32
  stringMax: (~value as _value, ~max) =>
33
- "This value must be at most " ++ string_of_int(max) ++ " characters",
33
+ `Le champ doit avoir au maximum ${max->Int.toString} caractères.`,
34
34
  }
@@ -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 !== "") |> Js.Array.joinWith(separator)
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
- (parts->Array.keepMap(v => v) |> Js.Array.joinWith(separator))->fromString
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 !== "") |> Js.Array.joinWith(separator)
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