@colisweb/rescript-toolkit 2.37.0 → 2.38.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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@colisweb/rescript-toolkit",
3
- "version": "2.37.0",
3
+ "version": "2.38.2",
4
4
  "scripts": {
5
5
  "clean": "rescript clean",
6
6
  "build": "rescript build",
@@ -242,3 +242,29 @@ let useOnClickOutside = (ref: React.ref<Js.Nullable.t<Dom.element>>, handler) =>
242
242
  }
243
243
 
244
244
  let useIntersection = ReactUse.useIntersection
245
+
246
+ let useIsVisibleOnViewport = (~options: option<ReactUse.intersectionOptions<'a>>=?, domRef) => {
247
+ let (isVisible, setIsVisible) = React.useState(() => false)
248
+ let intersection = useIntersection(
249
+ domRef,
250
+ options->Option.getWithDefault({
251
+ root: Js.Nullable.null,
252
+ rootMargin: "0px",
253
+ threshold: 1.,
254
+ }),
255
+ )
256
+
257
+ React.useEffect1(() => {
258
+ intersection
259
+ ->Js.Nullable.toOption
260
+ ->Option.forEach(intersection => {
261
+ if intersection.intersectionRatio >= 1. {
262
+ setIsVisible(_ => true)
263
+ }
264
+ })
265
+
266
+ None
267
+ }, [intersection])
268
+
269
+ isVisible
270
+ }
@@ -2,49 +2,45 @@ open BsSentryReactNative
2
2
 
3
3
  @val external isDev: bool = "__DEV__"
4
4
 
5
- let debugStyle = "background-color: #208E9C; color: white; padding: 5px; font-size: 10px;"
6
- let warningStyle = "background-color: #FFAD2D; color: white; padding: 5px; font-size: 10px;"
7
- let errorStyle = "background-color: #FF4714; color: white; padding: 5px; font-size: 10px;"
8
-
9
5
  let debug = str => {
10
6
  if isDev {
11
- Js.Console.log3("%cDEBUG", debugStyle, str)
7
+ Js.Console.log2("DEBUG", str)
12
8
  }
13
9
  }
14
10
 
15
11
  let debug2 = (str, str2) => {
16
12
  if isDev {
17
- Js.Console.log4("%cDEBUG", debugStyle, str, str2)
13
+ Js.Console.log3("DEBUG", str, str2)
18
14
  }
19
15
  }
20
16
 
21
17
  let debugMany = (arr: array<string>) => {
22
18
  if isDev {
23
- Js.Console.logMany(["%cDEBUG", debugStyle]->Array.concat(arr))
19
+ Js.Console.logMany(["DEBUG"]->Array.concat(arr))
24
20
  }
25
21
  }
26
22
 
27
23
  let warning = str => {
28
24
  if isDev {
29
- Js.Console.log3("%cWARN", warningStyle, str)
25
+ Js.Console.log2("WARN", str)
30
26
  }
31
27
  }
32
28
 
33
29
  let warning2 = (str, str2) => {
34
30
  if isDev {
35
- Js.Console.log4("%cWARN", warningStyle, str, str2)
31
+ Js.Console.log3("WARN", str, str2)
36
32
  }
37
33
  }
38
34
 
39
35
  let warningMany = (arr: array<string>) => {
40
36
  if isDev {
41
- Js.Console.logMany(["%cWARN", warningStyle]->Array.concat(arr))
37
+ Js.Console.logMany(["WARN"]->Array.concat(arr))
42
38
  }
43
39
  }
44
40
 
45
41
  let error = str => {
46
42
  if isDev {
47
- Js.Console.log3("%cERROR", errorStyle, str)
43
+ Js.Console.log2("ERROR", str)
48
44
  } else {
49
45
  open Sentry
50
46
  withScope(_scope => {
@@ -55,7 +51,7 @@ let error = str => {
55
51
 
56
52
  let error2 = (str, str2) => {
57
53
  if isDev {
58
- Js.Console.log4("%cERROR", errorStyle, str, str2)
54
+ Js.Console.log3("ERROR", str, str2)
59
55
  } else {
60
56
  open Sentry
61
57
  withScope(scope => {
@@ -69,7 +65,7 @@ let errorMany = (arr: array<string>) => {
69
65
  let message = arr[0]
70
66
  let data = arr->Array.length > 1 ? arr->Array.sliceToEnd(1) : []
71
67
  if isDev {
72
- Js.Console.logMany(["%cERROR", errorStyle]->Array.concat(arr))
68
+ Js.Console.logMany(["ERROR"]->Array.concat(arr))
73
69
  } else {
74
70
  open Sentry
75
71
  withScope(scope => {
@@ -1,7 +1,7 @@
1
1
  @module("lodash/flatten")
2
2
  external flatten: array<array<'a>> => array<'a> = "default"
3
3
  @module("lodash/groupBy")
4
- external groupBy: (array<'a>, 'a => 'b) => Js.Dict.t<'a> = "default"
4
+ external groupBy: (array<'a>, 'a => 'b) => Js.Dict.t<array<'a>> = "default"
5
5
  @module("lodash/sortBy")
6
6
  external sortBy: (array<'a>, 'a => 'b) => array<'a> = "default"
7
7
  @module("lodash/uniq")