@colisweb/rescript-toolkit 2.36.2 → 2.38.0

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/.gitlab-ci.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  include:
2
- - "https://colisweb-open-source.gitlab.io/ci-common/v13.11.1/templates/colisweb.yml"
2
+ - "https://colisweb-idl.gitlab.io/colisweb-open-source/ci-common/v13.18.1/templates/colisweb.yml"
3
3
 
4
4
  # -----------------------------------------------
5
5
  # Test
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@colisweb/rescript-toolkit",
3
- "version": "2.36.2",
3
+ "version": "2.38.0",
4
4
  "scripts": {
5
5
  "clean": "rescript clean",
6
6
  "build": "rescript build",
@@ -240,3 +240,31 @@ let useOnClickOutside = (ref: React.ref<Js.Nullable.t<Dom.element>>, handler) =>
240
240
  )
241
241
  }, (ref, handler))
242
242
  }
243
+
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
+ }
@@ -0,0 +1,30 @@
1
+ open ReactIntl
2
+
3
+ module Msg = {
4
+ @@intl.messages
5
+ let copied = {
6
+ id: "clipboard.copied",
7
+ defaultMessage: "Copied to clipboard",
8
+ }
9
+ }
10
+
11
+ @react.component
12
+ let make = (~children, ~textToCopy, ~className="", ~intl) => {
13
+ let ref1Clipboard = Toolkit.Hooks.useClipboard(
14
+ textToCopy,
15
+ ~onCopyNotificationMessage=intl->Intl.formatMessage(Msg.copied),
16
+ )
17
+
18
+ <div className={cx(["rounded-md border border-info-500 bg-info-50", className])}>
19
+ <div className="relative w-full">
20
+ <div
21
+ className="absolute -right-2 top-1 p-1 bg-info-50 text-info-500"
22
+ onClick={_ => {
23
+ ref1Clipboard.copy()
24
+ }}>
25
+ <BsReactIcons.MdContentCopy size=10 />
26
+ </div>
27
+ <div className="py-1 px-2 pr-4"> {children} </div>
28
+ </div>
29
+ </div>
30
+ }
@@ -5902,11 +5902,13 @@ module IoIosCloseCircle = {
5902
5902
 
5903
5903
  module AiFillEyeInvisible = {
5904
5904
  @module("react-icons/ai") @react.component
5905
- external make: (~size: int=?) => React.element = "AiFillEyeInvisible"
5905
+ external make: (~size: int=?, ~color: string=?, ~className: string=?) => React.element =
5906
+ "AiFillEyeInvisible"
5906
5907
  }
5907
5908
  module AiFillEye = {
5908
5909
  @module("react-icons/ai") @react.component
5909
- external make: (~size: int=?) => React.element = "AiFillEye"
5910
+ external make: (~size: int=?, ~color: string=?, ~className: string=?) => React.element =
5911
+ "AiFillEye"
5910
5912
  }
5911
5913
 
5912
5914
  module FaCalendarCheck = {
@@ -5920,3 +5922,55 @@ module FaUserCog = {
5920
5922
  external make: (~size: int=?, ~color: string=?, ~className: string=?) => React.element =
5921
5923
  "FaUserCog"
5922
5924
  }
5925
+
5926
+ module FaRedo = {
5927
+ @module("react-icons/fa") @react.component
5928
+ external make: (~size: int=?, ~color: string=?, ~className: string=?) => React.element = "FaRedo"
5929
+ }
5930
+
5931
+ module FaWarehouse = {
5932
+ @module("react-icons/fa") @react.component
5933
+ external make: (~size: int=?, ~color: string=?, ~className: string=?) => React.element =
5934
+ "FaWarehouse"
5935
+ }
5936
+
5937
+ module FaRecycle = {
5938
+ @module("react-icons/fa") @react.component
5939
+ external make: (~size: int=?, ~color: string=?, ~className: string=?) => React.element =
5940
+ "FaRecycle"
5941
+ }
5942
+ module FaPlug = {
5943
+ @module("react-icons/fa") @react.component
5944
+ external make: (~size: int=?, ~color: string=?, ~className: string=?) => React.element =
5945
+ "FaRecycle"
5946
+ }
5947
+ module FaTools = {
5948
+ @module("react-icons/fa") @react.component
5949
+ external make: (~size: int=?, ~color: string=?, ~className: string=?) => React.element = "FaTools"
5950
+ }
5951
+
5952
+ module MdOutlineFileDownload = {
5953
+ @module("react-icons/md") @react.component
5954
+ external make: (~size: int=?, ~color: string=?, ~className: string=?) => React.element =
5955
+ "MdOutlineFileDownload"
5956
+ }
5957
+
5958
+ module FaServer = {
5959
+ @module("react-icons/fa") @react.component
5960
+ external make: (~size: int=?, ~color: string=?, ~className: string=?) => React.element =
5961
+ "FaServer"
5962
+ }
5963
+ module FaLockOpen = {
5964
+ @module("react-icons/fa") @react.component
5965
+ external make: (~size: int=?, ~color: string=?, ~className: string=?) => React.element =
5966
+ "FaLockOpen"
5967
+ }
5968
+ module FaLock = {
5969
+ @module("react-icons/fa") @react.component
5970
+ external make: (~size: int=?, ~color: string=?, ~className: string=?) => React.element = "FaLock"
5971
+ }
5972
+
5973
+ module FaCog = {
5974
+ @module("react-icons/fa") @react.component
5975
+ external make: (~size: int=?, ~color: string=?, ~className: string=?) => React.element = "FaCog"
5976
+ }
@@ -46,3 +46,17 @@ external useGetSet: (unit => 'a) => ('a, 'a => 'a) = "useGetSet"
46
46
 
47
47
  @module("react-use")
48
48
  external useHover: React.element => (React.element, bool) = "useHover"
49
+
50
+ type intersectionObserver = {intersectionRatio: float}
51
+
52
+ type intersectionOptions<'domElement> = {
53
+ root: Js.Nullable.t<'domElement>,
54
+ rootMargin: string,
55
+ threshold: float,
56
+ }
57
+
58
+ @module("react-use")
59
+ external useIntersection: (
60
+ React.ref<'a>,
61
+ intersectionOptions<'domElement>,
62
+ ) => Js.Nullable.t<intersectionObserver> = "useIntersection"