@colisweb/rescript-toolkit 2.42.0 → 2.45.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/bsconfig.json CHANGED
@@ -23,8 +23,6 @@
23
23
  "suffix": ".bs.js",
24
24
  "namespace": false,
25
25
  "bs-dependencies": [
26
- "bs-css",
27
- "bs-css-emotion",
28
26
  "@rescript/react",
29
27
  "reason-promise",
30
28
  "decco",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@colisweb/rescript-toolkit",
3
- "version": "2.42.0",
3
+ "version": "2.45.0",
4
4
  "scripts": {
5
5
  "clean": "rescript clean",
6
6
  "build": "rescript build -with-deps",
@@ -23,6 +23,7 @@
23
23
  "dependencies": {
24
24
  "@colisweb/react-day-picker": "7.4.16",
25
25
  "@colisweb/restorative": "0.5.1",
26
+ "@datadog/browser-rum": "4.14.0",
26
27
  "@reach/accordion": "0.17.0",
27
28
  "@reach/alert-dialog": "0.17.0",
28
29
  "@reach/auto-id": "0.17.0",
@@ -40,8 +41,6 @@
40
41
  "autoprefixer": "10.4.7",
41
42
  "axios": "0.24.0",
42
43
  "bs-axios": "0.0.43",
43
- "bs-css": "13.4.0",
44
- "bs-css-emotion": "2.4.0",
45
44
  "case": "1.6.3",
46
45
  "click-outside-hook": "1.1.0",
47
46
  "copy-to-clipboard": "3.3.1",
@@ -51,12 +50,19 @@
51
50
  "downshift": "5.2.5",
52
51
  "lenses-ppx": "6.1.10",
53
52
  "list-selectors": "2.0.1",
53
+ "lodash": "4.17.21",
54
54
  "postcss": "8.4.14",
55
55
  "postcss-loader": "4.2.0",
56
56
  "postcss-preset-env": "6.7.0",
57
57
  "prismjs": "1.28.0",
58
+ "react": "18.2.0",
59
+ "react-big-calendar": "1.0.1",
58
60
  "react-datepicker": "3.8.0",
61
+ "react-dom": "18.2.0",
62
+ "react-error-boundary": "3.1.4",
63
+ "react-helmet": "6.1.0",
59
64
  "react-icons": "4.4.0",
65
+ "react-intl": "6.0.5",
60
66
  "react-select": "5.4.0",
61
67
  "react-table": "7.8.0",
62
68
  "react-use": "17.4.0",
@@ -68,14 +74,7 @@
68
74
  "rescript-react-update": "5.0.0",
69
75
  "sanitize-html": "2.7.0",
70
76
  "swr": "1.3.0",
71
- "tailwindcss": "3.1.4",
72
- "react-error-boundary": "3.1.4",
73
- "@datadog/browser-rum": "4.14.0",
74
- "react-intl": "6.0.5",
75
- "lodash": "4.17.21",
76
- "react-helmet": "6.1.0",
77
- "react": "18.2.0",
78
- "react-dom": "18.2.0"
77
+ "tailwindcss": "3.1.4"
79
78
  },
80
79
  "devDependencies": {
81
80
  "@babel/core": "7.18.6",
@@ -31,3 +31,4 @@ module SpinnerFullScreen = Toolkit__Ui_SpinnerFullScreen
31
31
  module MultiSelect = Toolkit__Ui_MultiSelect
32
32
  module Notice = Toolkit__Ui_Notice
33
33
  module NativeDatePicker = Toolkit__Ui_NativeDatePicker
34
+ module ErrorBoundary = Toolkit__Ui_ErrorBoundary
@@ -4,39 +4,9 @@ let make = (~children, ~className="", ~size: [#md | #xl]=#md) => {
4
4
  <div
5
5
  className={cx([
6
6
  className,
7
- "flex justify-center items-center rounded-full font-display bg-gray-200",
7
+ "flex justify-center items-center rounded-full font-display bg-gray-200 cw-ButtonGroup",
8
8
  isMd ? "h-6" : "h-10",
9
9
  isMd ? "text-sm" : "text-xl",
10
- {
11
- open Css
12
- style(list{
13
- selector(
14
- "& > button",
15
- list{
16
- whiteSpace(#nowrap),
17
- height(100.->pct),
18
- padding2(~v=0.75->rem, ~h=isMd ? 0.75->rem : 1.->rem),
19
- display(#flex),
20
- alignItems(#center),
21
- justifyContent(#center),
22
- borderRadius(2.->rem),
23
- selector("&:hover", list{backgroundColor("3DDEF3"->hex)}),
24
- },
25
- ),
26
- selector(
27
- "& > button.selected",
28
- list{
29
- background(
30
- linearGradient(
31
- 270.->deg,
32
- list{(0.->pct, "11a3b6"->hex), (100.->pct, "27d0dc"->hex)},
33
- ),
34
- ),
35
- color(white),
36
- },
37
- ),
38
- })
39
- },
40
10
  ])}>
41
11
  children
42
12
  </div>
@@ -79,13 +79,7 @@ module Footer = {
79
79
  @react.component
80
80
  let make = (~className="", ~children=React.null, ~customMinHeight=200) =>
81
81
  <div
82
- className={cx([
83
- className,
84
- "rounded-lg shadow-sm bg-white p-6",
85
- {
86
- open Css
87
- style(list{minHeight(customMinHeight->px)})
88
- },
89
- ])}>
82
+ style={ReactDOMStyle.make(~minHeight=`${customMinHeight->Int.toString}px`, ())}
83
+ className={cx([className, "rounded-lg shadow-sm bg-white p-6"])}>
90
84
  children
91
85
  </div>
@@ -1,19 +1,5 @@
1
1
  type size = [#xs | #sm | #md | #lg]
2
2
 
3
- module Styles = {
4
- open Css
5
-
6
- let label = style(list{
7
- selector("& > input + .checkmark", list{backgroundColor(hex("fff"))}),
8
- selector(
9
- "& > input:checked + .checkmark",
10
- list{backgroundColor(hex("15cbe3")), borderColor(hex("15cbe3"))},
11
- ),
12
- selector("& > input + .checkmark > *", list{opacity(0.)}),
13
- selector("& > input:checked + .checkmark > *", list{opacity(1.)}),
14
- })
15
- }
16
-
17
3
  @react.component
18
4
  let make = (
19
5
  ~value,
@@ -45,8 +31,7 @@ let make = (
45
31
 
46
32
  <label
47
33
  className={cx([
48
- Styles.label,
49
- "items-center",
34
+ "items-center cw-Checkbox",
50
35
  inverseLabel ? "inline-flex flex-row-reverse justify-end" : "flex flex-row",
51
36
  disabled->Option.getWithDefault(false)
52
37
  ? "cursor-not-allowed opacity-75 text-gray-600"
@@ -58,7 +43,7 @@ let make = (
58
43
  type_="checkbox"
59
44
  value
60
45
  ?defaultChecked
61
- className="hidden"
46
+ className="hidden peer"
62
47
  onChange={event => {
63
48
  let target = ReactEvent.Form.target(event)
64
49
  let checked = target["checked"]
@@ -73,7 +58,8 @@ let make = (
73
58
  />
74
59
  <span
75
60
  className={cx([
76
- "checkmark rounded border text-white border-neutral-300 transform transition-all ease-in-out flex items-center justify-center flex-shrink-0",
61
+ "peer-checked:bg-primary-500 peer-checked:border-primary-500",
62
+ "bg-white rounded border text-white border-neutral-300 transform transition-all ease-in-out flex items-center justify-center flex-shrink-0",
77
63
  switch size {
78
64
  | #xs => "w-4 h-4"
79
65
  | #sm => "w-6 h-6"
@@ -0,0 +1,45 @@
1
+ @react.component
2
+ let make = (
3
+ ~fallbackRender: ReactErrorBoundary.fallbackProps => React.element,
4
+ ~children: React.element,
5
+ ~resetKeys: option<array<'a>>=?,
6
+ ~customShouldRaiseAnError=false,
7
+ ) => {
8
+ <ReactErrorBoundary
9
+ fallbackRender
10
+ ?resetKeys
11
+ onError={err => {
12
+ switch Obj.magic(err) {
13
+ | #decodeError(requestConfig, deccoError) =>
14
+ Toolkit__BrowserLogger.error2(
15
+ `Decode error${requestConfig["url"]->Option.mapWithDefault("", url => " " ++ url)}`,
16
+ {
17
+ "deccoError": deccoError,
18
+ "requestConfig": requestConfig,
19
+ },
20
+ )
21
+ | #default(axiosError) =>
22
+ Js.Exn.message(axiosError)->Option.forEach(message => {
23
+ let message = message->Js.String2.toLowerCase
24
+ let ignoredTerms = ["timeout", "network"]
25
+
26
+ if ignoredTerms->Array.some(Js.String2.includes(message)) {
27
+ ()
28
+ } else {
29
+ Toolkit__BrowserLogger.error2(axiosError, axiosError)
30
+ }
31
+ })
32
+ | #custom(err) =>
33
+ if customShouldRaiseAnError {
34
+ Toolkit__BrowserLogger.error2("Custom error", err)
35
+ }
36
+ | err =>
37
+ switch Js.Exn.message(Obj.magic(err)) {
38
+ | None => Toolkit__BrowserLogger.error2("Unhandled error", err)
39
+ | Some(message) => Toolkit__BrowserLogger.error2(Obj.magic(message), err)
40
+ }
41
+ }
42
+ }}>
43
+ {children}
44
+ </ReactErrorBoundary>
45
+ }
@@ -2,19 +2,6 @@ type size = [#xs | #sm | #md | #lg | #custom(int)]
2
2
  type color = [#primary | #success | #danger | #neutral]
3
3
  type style = [#default | #colored(color)]
4
4
 
5
- let sizeRule = size => {
6
- let value = switch size {
7
- | #xs => 480
8
- | #sm => 600
9
- | #md => 768
10
- | #lg => 900
11
- | #custom(value) => value
12
- }
13
-
14
- open Css
15
- style(list{width(pct(100.)), important(maxWidth(px(value)))})
16
- }
17
-
18
5
  let modalStyle = (~type_) =>
19
6
  switch type_ {
20
7
  | #default => "rounded"
@@ -51,23 +38,6 @@ let closeIconStyle = (~type_) =>
51
38
  | #colored(_) => "hover:bg-white hover:text-black text-white"
52
39
  }
53
40
 
54
- let blockBody = () => {
55
- open Css
56
- global("body", list{overflow(#hidden)})
57
- }
58
- let resetBody = () => {
59
- open Css
60
- global("body", list{overflow(#auto)})
61
- }
62
- {
63
- open Css
64
- global("[data-reach-dialog-overlay]", list{important(background(rgba(74, 115, 120, #num(0.5))))})
65
- }
66
- {
67
- open Css
68
- global("[data-reach-dialog-content]", list{important(background(transparent))})
69
- }
70
-
71
41
  @react.component
72
42
  let make = (
73
43
  ~isVisible,
@@ -79,7 +49,28 @@ let make = (
79
49
  ~footer=?,
80
50
  ~ariaLabel="",
81
51
  ) =>
82
- <ReachUi.Dialog ariaLabel isOpen=isVisible onDismiss=hide className={sizeRule(size)}>
52
+ <ReachUi.Dialog
53
+ ariaLabel
54
+ isOpen=isVisible
55
+ onDismiss=hide
56
+ style={ReactDOMStyle.make(
57
+ ~maxWidth={
58
+ let value = switch size {
59
+ | #xs => 480
60
+ | #sm => 600
61
+ | #md => 768
62
+ | #lg => 900
63
+ | #custom(value) => value
64
+ }
65
+ `${value->Int.toString}px`
66
+ },
67
+ (),
68
+ )}
69
+ className={cx([
70
+ {
71
+ "w-full "
72
+ },
73
+ ])}>
83
74
  <div className={cx(["bg-white pb-5 z-40 shadow-lg w-full", modalStyle(~type_)])}>
84
75
  <header
85
76
  className={cx([
@@ -4,6 +4,7 @@ type color = [#success | #danger | #warning | #info]
4
4
  let make = (~progression: float, ~color: color=#success) =>
5
5
  <div className="flex flex-row w-full h-2 bg-neutral-300 rounded-lg">
6
6
  <div
7
+ style={ReactDOMStyle.make(~width=`${progression->Float.toString}%`, ())}
7
8
  className={cx([
8
9
  "h-full rounded-lg",
9
10
  switch color {
@@ -12,7 +13,6 @@ let make = (~progression: float, ~color: color=#success) =>
12
13
  | #warning => "bg-warning-500"
13
14
  | #info => "bg-info-500"
14
15
  },
15
- Css.style(list{Css.width(progression->#percent)}),
16
16
  ])}
17
17
  />
18
18
  </div>
@@ -1,20 +1,5 @@
1
1
  type size = [#xs | #sm | #md | #lg]
2
2
 
3
- module Styles = {
4
- open Css
5
-
6
- let label = style(list{
7
- selector("& > input + .checkmark", list{backgroundColor(hex("fff"))}),
8
- selector("& > input:focus + .checkmark", list{unsafe("boxShadow", "0px 0px 4px #15CBE3")}),
9
- selector(
10
- "& > input:checked + .checkmark",
11
- list{backgroundColor(hex("15cbe3")), borderColor(hex("15cbe3"))},
12
- ),
13
- selector("& > input + .checkmark > *", list{opacity(0.)}),
14
- selector("& > input:checked + .checkmark > *", list{opacity(1.)}),
15
- })
16
- }
17
-
18
3
  @react.component
19
4
  let make = (
20
5
  ~value,
@@ -28,7 +13,6 @@ let make = (
28
13
  ) =>
29
14
  <label
30
15
  className={cx([
31
- Styles.label,
32
16
  "flex items-center",
33
17
  disabled->Option.getWithDefault(false)
34
18
  ? "cursor-not-allowed opacity-75 text-gray-600"
@@ -38,7 +22,7 @@ let make = (
38
22
  <input
39
23
  type_="radio"
40
24
  value
41
- className="opacity-0 w-0 h-0"
25
+ className="opacity-0 w-0 h-0 peer"
42
26
  onChange={event => {
43
27
  let target = ReactEvent.Form.target(event)
44
28
  let value = target["value"]
@@ -51,6 +35,8 @@ let make = (
51
35
  />
52
36
  <span
53
37
  className={cx([
38
+ "bg-white peer-focus:shadow-sm peer-focus:shadow-primary-500",
39
+ "peer-checked:border-primary-500 peer-checked:bg-primary-500",
54
40
  "checkmark rounded-full border text-white mr-3 border-neutral-300 transform transition-all ease-in-out flex items-center justify-center",
55
41
  switch size {
56
42
  | #xs => "w-4 h-4"
@@ -38,32 +38,23 @@ let make = (
38
38
  {isVisible && canBeShowed
39
39
  ? <ReachUi.Portal>
40
40
  <div
41
- className={cx([
42
- "absolute w-0 h-0 border-gray-800",
43
- triangleClassName,
44
- {
45
- open Css
46
- style(list{
47
- unsafe("borderLeft", "10px solid transparent !important"),
48
- unsafe("borderRight", "10px solid transparent !important"),
49
- unsafe("borderBottom", "10px solid"),
50
- left(
51
- triggerRect
52
- ->Js.Nullable.toOption
53
- ->Option.mapWithDefault(0, triggerRect =>
54
- triggerRect.left - 10 + triggerRect.width / 2
55
- )
56
- ->px,
57
- ),
58
- top(
59
- triggerRect
60
- ->Js.Nullable.toOption
61
- ->Option.mapWithDefault(0, triggerRect => triggerRect.bottom + scrollY)
62
- ->px,
63
- ),
64
- })
65
- },
66
- ])}
41
+ style={ReactDOMStyle.make(
42
+ ~borderLeft="10px solid transparent",
43
+ ~borderRight="10px solid transparent",
44
+ ~borderBottom="10px solid",
45
+ ~left=`${triggerRect
46
+ ->Js.Nullable.toOption
47
+ ->Option.mapWithDefault(0, triggerRect =>
48
+ triggerRect.left - 10 + triggerRect.width / 2
49
+ )
50
+ ->Int.toString}px`,
51
+ ~top=`${triggerRect
52
+ ->Js.Nullable.toOption
53
+ ->Option.mapWithDefault(0, triggerRect => triggerRect.bottom + scrollY)
54
+ ->Int.toString}px`,
55
+ (),
56
+ )}
57
+ className={cx(["absolute w-0 h-0 border-gray-800", triangleClassName])}
67
58
  />
68
59
  </ReachUi.Portal>
69
60
  : React.null}
@@ -71,10 +62,10 @@ let make = (
71
62
  ? <Toolkit__Ui_Spread props=tooltip>
72
63
  <TooltipPopup
73
64
  label
65
+ style={ReactDOMStyle.make(~maxWidth=`${maxWidth->Int.toString}px`, ())}
74
66
  className={cx([
75
67
  "px-3 py-2 bg-gray-800 rounded text-white text-sm z-40 whitespace-pre-wrap",
76
68
  tooltipClassName,
77
- Css.style(list{Css.maxWidth(maxWidth->Css.px)}),
78
69
  ])}
79
70
  position=centered
80
71
  />
package/src/ui/styles.css CHANGED
@@ -39,12 +39,13 @@ body,
39
39
 
40
40
  [data-reach-dialog-content] {
41
41
  padding: 0 !important;
42
+ background: transparent;
42
43
  margin: 10vh auto;
43
44
  outline: 0;
44
45
  }
45
46
 
46
47
  [data-reach-dialog-overlay] {
47
- background: rgba(0, 0, 0, 0.6);
48
+ background: rgba(74, 115, 120, 0.5);
48
49
  z-index: 40;
49
50
  position: fixed;
50
51
  top: 0;
@@ -376,4 +377,20 @@ input[type=number] {
376
377
  color: #15373a;
377
378
  }
378
379
 
380
+ .cw-ButtonGroup > button {
381
+ @apply whitespace-nowrap h-full px-3 md:px-4 flex items-center justify-center rounded-3xl py-3
382
+ }
383
+ .cw-ButtonGroup > button:hover {
384
+ @apply bg-primary-300
385
+ }
386
+
387
+ .cw-ButtonGroup > button.selected {
388
+ background: linear-gradient(270deg, #11a3b6 0%, #27d0dc 100%);
389
+ color: white;
390
+ }
391
+
392
+ .cw-Checkbox > input:checked + .checkmark > * {
393
+ @apply opacity-100
394
+ }
395
+
379
396
  /* purgecss end ignore */
@@ -0,0 +1,5 @@
1
+ @module("shallow-equal")
2
+ external shallowEqualObjects: ('a, 'b) => bool = "shallowEqualObjects"
3
+
4
+ @module("shallow-equal")
5
+ external shallowEqualArrays: (array<'a>, array<'b>) => bool = "shallowEqualArrays"
@@ -28,6 +28,7 @@ module TooltipPopup = {
28
28
  external make: (
29
29
  ~className: string=?,
30
30
  ~position: (triggerRect, triggerRect) => position,
31
+ ~style: ReactDOMStyle.t=?,
31
32
  ~label: React.element,
32
33
  ) => React.element = "TooltipPopup"
33
34
  }