@colisweb/rescript-toolkit 2.46.0 → 2.46.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/.gitlab-ci.yml CHANGED
@@ -35,6 +35,7 @@ publish rescript-toolkit:
35
35
  script:
36
36
  - export NPM_TOKEN=${NPM_TOKEN:-undefined}
37
37
  - npm --no-git-tag-version version $(echo $CI_COMMIT_TAG | sed -e 's/^v//')
38
+ - yarn
38
39
  - npm publish
39
40
  cache:
40
41
  key: "yarn-$CI_COMMIT_REF_SLUG"
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env sh
2
+ . "$(dirname -- "$0")/_/husky.sh"
3
+
4
+ yarn intl:extract && yarn intl:check
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@colisweb/rescript-toolkit",
3
- "version": "2.46.0",
3
+ "version": "2.46.4",
4
4
  "scripts": {
5
5
  "clean": "rescript clean",
6
6
  "build": "rescript build -with-deps",
@@ -11,7 +11,8 @@
11
11
  "storybook": "STORYBOOK=true start-storybook -p 6006 --no-manager-cache",
12
12
  "build-storybook": "TAILWIND_MODE=build STORYBOOK=true build-storybook",
13
13
  "intl:check": "node src/intl/check.js",
14
- "intl:extract": "node src/intl/extract.js"
14
+ "intl:extract": "node src/intl/extract.js",
15
+ "prepare": "is-ci || husky install"
15
16
  },
16
17
  "keywords": [
17
18
  "ReScript",
@@ -41,6 +42,7 @@
41
42
  "@reach/tooltip": "0.17.0",
42
43
  "@reach/visually-hidden": "0.17.0",
43
44
  "@rescript/react": "0.10.3",
45
+ "@tailwindcss/line-clamp": "0.4.0",
44
46
  "autoprefixer": "10.4.7",
45
47
  "axios": "0.24.0",
46
48
  "bs-axios": "0.0.43",
@@ -91,6 +93,8 @@
91
93
  "@storybook/theming": "6.1.21",
92
94
  "babel-loader": "8.2.5",
93
95
  "highlight.js": "11.3.1",
96
+ "husky": "8.0.0",
97
+ "is-ci": "3.0.1",
94
98
  "raw-loader": "4.0.2",
95
99
  "react-is": "17.0.2",
96
100
  "sass": "1.45.0"
@@ -228,11 +228,15 @@ module UnitMeasure = {
228
228
  | Some([_match, None, _unit]) => Decco.error(`${errorPrefix} unhandled no value`, jsonString)
229
229
  | Some([Some(_match), Some(value), Some(unit)]) => {
230
230
  let value = value->Js.Float.fromString
231
- switch unit->Js.Json.string->Config.unitEnum_decode {
231
+ switch unit
232
+ ->Js.String2.replaceByRe(%re("/\s/"), "")
233
+ ->Js.Json.string
234
+ ->Config.unitEnum_decode {
232
235
  | Ok(unit) => Config.wrapValue(unit, value)->Ok
233
236
  | Error(_) => Decco.error(`${errorPrefix} unhandled unit '${unit}'`, jsonString)
234
237
  }
235
238
  }
239
+
236
240
  | Some(_) => Decco.error(`${errorPrefix} regex capture group error`, jsonString)
237
241
  }
238
242
  }
@@ -11,7 +11,8 @@ module.exports = {
11
11
  },
12
12
  boxShadow: {
13
13
  sidenav: "inset 0 0 1px 2px rgba(0, 0, 0, 0.2)",
14
- sm: "0px 2px 1px -1px rgba(0,0,0,0.1), 0px 1px 1px 0px rgba(0,0,0,0.1), 0px 1px 3px 0px rgba(0,0,0,0.1)",
14
+ sm:
15
+ "0px 2px 1px -1px rgba(0,0,0,0.1), 0px 1px 1px 0px rgba(0,0,0,0.1), 0px 1px 3px 0px rgba(0,0,0,0.1)",
15
16
  },
16
17
  borderColor: {
17
18
  currentColor: "currentColor",
@@ -149,6 +150,7 @@ module.exports = {
149
150
  },
150
151
  },
151
152
  },
153
+ plugins: [require("@tailwindcss/line-clamp")],
152
154
  content: [
153
155
  "public/index.html",
154
156
  "lib/es6_global/src/**/**.js",
@@ -18,18 +18,20 @@ let make = (
18
18
  ~buttonVariant: Toolkit__Ui_Button.variant=#default,
19
19
  ~position=#bottom,
20
20
  ) => {
21
- let ref = React.useRef(Js.Nullable.null)
21
+ let dropDownRef = React.useRef(Js.Nullable.null)
22
+ let buttonRef = React.useRef(Js.Nullable.null)
22
23
  let (position, setPosition) = React.useState(() => position)
23
24
  let {isOpen, hide, toggle} = Toolkit__Hooks.useDisclosure(~defaultIsOpen, ())
24
25
 
25
- Toolkit__Hooks.useOnClickOutside(ref, _ => {
26
+ Toolkit__Hooks.useOnClickOutside(buttonRef, _ => {
26
27
  hide()
27
28
  })
29
+
28
30
  let (adjustmentStyle, setAdjustmentStyle) = React.useState(() => None)
29
31
 
30
32
  React.useEffect2(() => {
31
33
  if isOpen {
32
- ref.current
34
+ dropDownRef.current
33
35
  ->Js.Nullable.toOption
34
36
  ->Option.forEach(dom => {
35
37
  let {left, right} = dom->Browser.DomElement.getBoundingClientRect
@@ -52,7 +54,7 @@ let make = (
52
54
  setAdjustmentStyle(_ => None)
53
55
  }
54
56
  None
55
- }, (isOpen, ref))
57
+ }, (isOpen, dropDownRef))
56
58
 
57
59
  <div className={cx(["relative", containerClassName])}>
58
60
  <Toolkit__Ui_Button
@@ -60,11 +62,12 @@ let make = (
60
62
  size=buttonSize
61
63
  type_="button"
62
64
  color=buttonColor
65
+ buttonRef={ReactDOM.Ref.domRef(buttonRef)}
63
66
  onClick={event => {
64
- switch ref.current->Js.Nullable.toOption {
67
+ switch dropDownRef.current->Js.Nullable.toOption {
65
68
  | None => toggle()
66
- | Some(domRef) => {
67
- let isInDropdown = ReactEvent.Mouse.currentTarget(event)["contains"](. domRef)
69
+ | Some(dropDownRef) => {
70
+ let isInDropdown = ReactEvent.Mouse.currentTarget(event)["contains"](. dropDownRef)
68
71
  if !isInDropdown {
69
72
  toggle()
70
73
  }
@@ -75,7 +78,7 @@ let make = (
75
78
  label
76
79
  {isOpen
77
80
  ? <div
78
- ref={ReactDOM.Ref.domRef(ref)}
81
+ ref={ReactDOM.Ref.domRef(dropDownRef)}
79
82
  className={cx([
80
83
  "dropdown",
81
84
  "absolute z-20 bg-white p-2 transform shadow rounded text-base font-normal text-neutral-700 opacity-0",
@@ -45,6 +45,7 @@ module Core = {
45
45
  ~className="",
46
46
  ~emptyMessage,
47
47
  ~additionalRow: option<(ReactTable.instanceRow<'a>, 'a) => React.element>=?,
48
+ ~trClassName="",
48
49
  ) =>
49
50
  <div className={cx([className, "flex flex-auto w-full overflow-x-auto relative"])}>
50
51
  <Toolkit__Ui_Spread props={table.getTableProps()}>
@@ -98,7 +99,7 @@ module Core = {
98
99
 
99
100
  <React.Fragment key={"tr" ++ index->Int.toString}>
100
101
  <Toolkit__Ui_Spread props={row.getRowProps()}>
101
- <tr className={"block even:bg-gray-200 min-h-[5.5rem]"}>
102
+ <tr className={cx([trClassName, "block even:bg-gray-200 min-h-[5.5rem]"])}>
102
103
  {row.cells
103
104
  ->Array.mapWithIndex((index, cell) =>
104
105
  <Toolkit__Ui_Spread
@@ -10,6 +10,7 @@ module Core: {
10
10
  ~className: string=?,
11
11
  ~emptyMessage: string,
12
12
  ~additionalRow: (ReactTable.instanceRow<'a>, 'a) => React.element=?,
13
+ ~trClassName: string=?,
13
14
  ) => React.element
14
15
  }
15
16
 
@@ -24,8 +24,8 @@ module Unit = (Config: UnitConfig) => {
24
24
  @decco
25
25
  type unitEnum = @decco.codec(codec) Config.unitEnum
26
26
 
27
- let unitEnumToString = v => v->Config.unitEnumToJs
28
- let unitEnumFromString = v => v->Config.unitEnumFromJs
27
+ let unitEnumToString = Config.unitEnumToJs
28
+ let unitEnumFromString = Config.unitEnumFromJs
29
29
  }
30
30
 
31
31
  module Weight = {