@colisweb/rescript-toolkit 2.1.0 → 2.4.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
@@ -4,12 +4,12 @@ include:
4
4
  # -----------------------------------------------
5
5
  # Test
6
6
  # -----------------------------------------------
7
- test compilation:
7
+ rescript compilation:
8
8
  tags:
9
9
  - aws
10
10
  extends: .rules-except-for-tags
11
11
  stage: test
12
- image: node:lts-buster
12
+ image: node:lts-bullseye
13
13
  cache:
14
14
  key: "yarn-$CI_COMMIT_REF_SLUG"
15
15
  paths:
@@ -29,7 +29,7 @@ version:
29
29
  # Publish npm
30
30
  # -----------------------------------------------
31
31
  publish rescript-toolkit:
32
- image: node:lts-buster
32
+ image: node:lts-bullseye
33
33
  extends: .rules-only-for-tags
34
34
  tags:
35
35
  - aws
@@ -49,7 +49,7 @@ pages:
49
49
  tags:
50
50
  - aws
51
51
  stage: deploy
52
- image: node:lts-buster
52
+ image: node:lts-bullseye
53
53
  script:
54
54
  - export NPM_TOKEN=${NPM_TOKEN:-undefined}
55
55
  - yarn
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@colisweb/rescript-toolkit",
3
- "version": "2.1.0",
3
+ "version": "2.4.0",
4
4
  "scripts": {
5
5
  "clean": "rescript clean",
6
6
  "build": "rescript build",
7
7
  "watch": "rescript build -w",
8
8
  "dev": "rescript build -w",
9
- "test": "rescript build",
9
+ "test": "rescript build -with-deps",
10
10
  "build:reacticons": "node tools/extract-react-icons.js",
11
11
  "build:datetimeinput": "node tools/build-datepicker-style.js",
12
12
  "storybook": "STORYBOOK=true start-storybook -p 6006 --no-manager-cache",
@@ -24,20 +24,20 @@
24
24
  "dependencies": {
25
25
  "@colisweb/react-day-picker": "7.4.16",
26
26
  "@reach/accordion": "0.16.1",
27
- "@reach/alert-dialog": "0.16.0",
27
+ "@reach/alert-dialog": "0.16.2",
28
28
  "@reach/auto-id": "0.16.0",
29
- "@reach/combobox": "0.16.1",
30
- "@reach/dialog": "0.16.0",
31
- "@reach/disclosure": "0.16.0",
32
- "@reach/listbox": "0.16.1",
33
- "@reach/menu-button": "0.16.1",
34
- "@reach/popover": "0.16.0",
35
- "@reach/portal": "0.16.0",
36
- "@reach/tabs": "0.16.1",
37
- "@reach/tooltip": "0.16.0",
29
+ "@reach/combobox": "0.16.5",
30
+ "@reach/dialog": "0.16.2",
31
+ "@reach/disclosure": "0.16.2",
32
+ "@reach/listbox": "0.16.2",
33
+ "@reach/menu-button": "0.16.2",
34
+ "@reach/popover": "0.16.2",
35
+ "@reach/portal": "0.16.2",
36
+ "@reach/tabs": "0.16.4",
37
+ "@reach/tooltip": "0.16.2",
38
38
  "@reach/visually-hidden": "0.16.0",
39
39
  "@rescript/react": "0.10.3",
40
- "autoprefixer": "10.3.6",
40
+ "autoprefixer": "10.4.0",
41
41
  "axios": "0.24.0",
42
42
  "bs-axios": "0.0.43",
43
43
  "bs-css": "13.4.0",
@@ -45,36 +45,34 @@
45
45
  "case": "1.6.3",
46
46
  "click-outside-hook": "1.1.0",
47
47
  "copy-to-clipboard": "3.3.1",
48
- "date-fns": "2.24.0",
48
+ "date-fns": "2.27.0",
49
49
  "decco": "1.5.0",
50
50
  "dedent": "0.7.0",
51
51
  "downshift": "5.2.5",
52
- "highlight.js": "10.7.2",
53
52
  "lenses-ppx": "6.1.10",
54
53
  "list-selectors": "2.0.0",
55
- "postcss": "8.2.13",
54
+ "postcss": "8.4.5",
56
55
  "postcss-loader": "4.2.0",
57
56
  "postcss-preset-env": "6.7.0",
58
- "prismjs": "1.23.0",
59
- "react-datepicker": "3.8.0",
57
+ "prismjs": "1.25.0",
60
58
  "react-icons": "4.3.1",
61
- "react-select": "4.3.1",
59
+ "react-select": "5.2.1",
62
60
  "react-table": "7.7.0",
63
61
  "react-use": "17.3.1",
64
- "reason-promise": "1.1.4",
62
+ "reason-promise": "1.1.5",
65
63
  "reason-react": "0.9.1",
66
64
  "reschema": "1.3.1",
67
65
  "rescript": "9.1.4",
68
66
  "rescript-classnames": "6.0.0",
69
- "rescript-logger": "2.0.0",
70
- "rescript-react-update": "4.0.0",
67
+ "rescript-logger": "2.0.2",
68
+ "rescript-react-update": "5.0.0",
71
69
  "restorative": "0.4.0-beta.1",
72
- "string.prototype.matchall": "4.0.5",
73
- "swr": "1.0.1",
74
- "tailwindcss": "2.2.19"
70
+ "swr": "1.1.1",
71
+ "tailwindcss": "3.0.2"
75
72
  },
76
73
  "devDependencies": {
77
- "@babel/core": "7.16.0",
74
+ "highlight.js": "11.3.1",
75
+ "@babel/core": "7.16.5",
78
76
  "@storybook/addon-actions": "6.1.21",
79
77
  "@storybook/addon-essentials": "6.1.21",
80
78
  "@storybook/addon-knobs": "6.1.21",
@@ -82,11 +80,11 @@
82
80
  "@storybook/addons": "6.1.21",
83
81
  "@storybook/react": "6.1.21",
84
82
  "@storybook/theming": "6.1.21",
85
- "babel-loader": "8.2.2",
83
+ "babel-loader": "8.2.3",
86
84
  "raw-loader": "4.0.2",
87
85
  "react": "17.0.2",
88
86
  "react-dom": "17.0.2",
89
87
  "react-is": "17.0.2",
90
- "sass": "1.42.1"
88
+ "sass": "1.45.0"
91
89
  }
92
90
  }
package/postcss.config.js CHANGED
@@ -1,6 +1,5 @@
1
1
  const path = require("path");
2
2
  const glob = require("glob");
3
- const matchAll = require("string.prototype.matchall");
4
3
 
5
4
  const tailwindConfig = path.join(__dirname, "src/tailwind/tailwind.config.js");
6
5
 
@@ -5,16 +5,21 @@ module type RouterConfig = {
5
5
  }
6
6
 
7
7
  module Make = (Config: RouterConfig) => {
8
+ type contextState = {
9
+ currentRoute: Config.t,
10
+ previousRoute: option<Config.t>,
11
+ }
8
12
  let navigate = (route: Config.t) => RescriptReactRouter.push(route->Config.toString)
9
13
 
10
14
  let replace = (route: Config.t) => RescriptReactRouter.replace(route->Config.toString)
11
15
 
12
- let routerContext = React.createContext(
13
- RescriptReactRouter.dangerouslyGetInitialUrl()->Config.make,
14
- )
16
+ let routerContext = React.createContext({
17
+ currentRoute: RescriptReactRouter.dangerouslyGetInitialUrl()->Config.make,
18
+ previousRoute: None,
19
+ })
15
20
 
16
21
  module RouterContextProvider = {
17
- let makeProps = (~value: Config.t, ~children, ()) =>
22
+ let makeProps = (~value: contextState, ~children, ()) =>
18
23
  {
19
24
  "value": value,
20
25
  "children": children,
@@ -30,6 +35,8 @@ module Make = (Config: RouterConfig) => {
30
35
  RescriptReactRouter.dangerouslyGetInitialUrl()->Config.make
31
36
  )
32
37
 
38
+ let previousRoute = Toolkit__Hooks.usePrevious(currentRoute)
39
+
33
40
  React.useLayoutEffect1(() => {
34
41
  let watcherID = RescriptReactRouter.watchUrl(url =>
35
42
  setCurrentRoute(_ => url |> Config.make)
@@ -37,7 +44,14 @@ module Make = (Config: RouterConfig) => {
37
44
  Some(() => RescriptReactRouter.unwatchUrl(watcherID))
38
45
  }, [setCurrentRoute])
39
46
 
40
- <RouterContextProvider value=currentRoute> {children(~currentRoute)} </RouterContextProvider>
47
+ let contextValue: contextState = {
48
+ previousRoute: previousRoute,
49
+ currentRoute: currentRoute,
50
+ }
51
+
52
+ <RouterContextProvider value={contextValue}>
53
+ {children(~currentRoute)}
54
+ </RouterContextProvider>
41
55
  }
42
56
  }
43
57
 
@@ -47,7 +61,7 @@ module Make = (Config: RouterConfig) => {
47
61
  routeA->Config.toString === routeB->Config.toString
48
62
 
49
63
  let useIsCurrentRoute = (route: Config.t): bool => {
50
- let currentRoute = React.useContext(routerContext)
64
+ let {currentRoute} = React.useContext(routerContext)
51
65
  isRouteEqual(currentRoute, route)
52
66
  }
53
67
 
@@ -214,6 +228,7 @@ module Make = (Config: RouterConfig) => {
214
228
  ~links: array<link>,
215
229
  ~isNavOpen: bool,
216
230
  ~onLinkClick=() => (),
231
+ ~openMenu,
217
232
  ) => {
218
233
  let (isOpen, setIsOpen) = React.useState(() => false)
219
234
 
@@ -227,7 +242,12 @@ module Make = (Config: RouterConfig) => {
227
242
  }, [isNavOpen])
228
243
 
229
244
  <>
230
- <button onClick=toggle className={cx([commonClassName, "flex items-center w-full"])}>
245
+ <button
246
+ onClick={_ => {
247
+ openMenu()
248
+ toggle()
249
+ }}
250
+ className={cx([commonClassName, "flex items-center w-full sidenav-link"])}>
231
251
  <span className={cx(["mr-2 text-neutral-800", isNavOpen ? "pl-2" : "px-2"])}>
232
252
  groupInfo.icon
233
253
  </span>
@@ -247,6 +267,12 @@ module Make = (Config: RouterConfig) => {
247
267
  ])}
248
268
  />
249
269
  </span>
270
+ {isNavOpen
271
+ ? React.null
272
+ : <div
273
+ className="sidenav-link-tooltip absolute left-0 p-2 bg-neutral-700 text-white rounded transform top-1/2 -translate-y-1/2 transition-all duration-200 ease-in-out opacity-0 invisible ml-16 whitespace-nowrap">
274
+ groupInfo.label
275
+ </div>}
250
276
  </button>
251
277
  <div
252
278
  className={cx([
@@ -1,55 +1,6 @@
1
- const { colors: defaultColors } = require("tailwindcss/defaultTheme");
2
- const plugin = require("tailwindcss/plugin");
3
-
4
- const flexGapPlugin = plugin(({ addUtilities, theme, variants }) => {
5
- const newUtilities = Object.keys(theme("spacing")).reduce(
6
- (acc, key) => ({
7
- ...acc,
8
- [`.flex-gap-${key}`]: {
9
- marginBottom: "-" + theme(`spacing.${key}`),
10
- marginLeft: "-" + theme(`spacing.${key}`),
11
- [` > *`]: {
12
- paddingBottom: theme(`spacing.${key}`),
13
- paddingLeft: theme(`spacing.${key}`),
14
- },
15
- },
16
- [`.flex-col-gap-${key}`]: {
17
- marginLeft: "-" + theme(`spacing.${key}`),
18
- [` > *`]: {
19
- paddingLeft: theme(`spacing.${key}`),
20
- },
21
- },
22
- [`.flex-row-gap-${key}`]: {
23
- marginBottom: "-" + theme(`spacing.${key}`),
24
- [` > *`]: {
25
- paddingBottom: theme(`spacing.${key}`),
26
- },
27
- },
28
- }),
29
- {}
30
- );
31
-
32
- addUtilities(newUtilities, variants("flexGap"));
33
- });
34
-
35
- const boxShadowColorPlugin = plugin(({ addUtilities, theme, variants }) => {
36
- const newUtilities = Object.keys(theme("colors")).reduce(
37
- (acc, key) =>
38
- theme("colors")[key][500]
39
- ? {
40
- ...acc,
41
- [`.shadow-${key}-500`]: {
42
- boxShadow: `${theme("colors")[key][500]} 0px 0px 0px 1px;`,
43
- },
44
- }
45
- : acc,
46
- {}
47
- );
48
- addUtilities(newUtilities, variants("boxShadowColor"));
49
- });
1
+ const defaultColors = require("tailwindcss/colors");
50
2
 
51
3
  module.exports = {
52
- mode: "jit",
53
4
  theme: {
54
5
  extend: {
55
6
  screens: {
@@ -189,29 +140,7 @@ module.exports = {
189
140
  },
190
141
  },
191
142
  },
192
-
193
- variants: {
194
- textColor: ["responsive", "hover", "focus", "disabled"],
195
- backgroundColor: [
196
- "responsive",
197
- "hover",
198
- "focus",
199
- "disabled",
200
- "active",
201
- "even",
202
- ],
203
- margin: ["responsive", "last"],
204
- padding: ["responsive", "last"],
205
- borderWidth: ["responsive", "last"],
206
- zIndex: ["responsive", "focus"],
207
- width: ["responsive", "hover"],
208
- overflow: ["responsive", "hover"],
209
- /* Custom */
210
- flexGap: ["responsive"],
211
- boxShadowColor: ["responsive", "hover", "focus"],
212
- },
213
- plugins: [flexGapPlugin, boxShadowColorPlugin],
214
- purge: [
143
+ content: [
215
144
  "public/index.html",
216
145
  "lib/es6_global/src/**/**.js",
217
146
  "src/**/**.js",
@@ -84,10 +84,17 @@ module App = {
84
84
  type sideNavRender = {
85
85
  onLinkClick: unit => unit,
86
86
  isNavOpen: bool,
87
+ openMenu: unit => unit,
87
88
  }
88
89
 
89
90
  @react.component
90
- let make = (~isNavOpen, ~bottom=?, ~hideMenu, ~children: sideNavRender => React.element) => {
91
+ let make = (
92
+ ~isNavOpen,
93
+ ~bottom=?,
94
+ ~hideMenu,
95
+ ~children: sideNavRender => React.element,
96
+ ~openMenu,
97
+ ) => {
91
98
  let {isLg} = Toolkit__Hooks.useMediaQuery()
92
99
 
93
100
  let onLinkClick = () => isLg ? () : hideMenu()
@@ -99,17 +106,13 @@ module App = {
99
106
  "lg:flex border-r px-2 py-3 fixed flex-col bg-white justify-between transition-all duration-300 ease-in-out z-40",
100
107
  isNavOpen ? "w-64 overflow-y-auto" : "w-16 hidden sidenav--closed",
101
108
  ])}>
102
- {children({onLinkClick: onLinkClick, isNavOpen: isNavOpen})}
109
+ {children({onLinkClick: onLinkClick, isNavOpen: isNavOpen, openMenu: openMenu})}
103
110
  {bottom->Option.mapWithDefault(React.null, content =>
104
111
  <div className={!isNavOpen ? "overflow-hidden" : ""}>
105
112
  <div
106
113
  className={cx([
107
- "flex flex-col justify-end transition-all duration-300 ease-in-out",
114
+ "flex flex-col justify-end transition-all duration-300 ease-in-out w-[14.75rem]",
108
115
  isNavOpen ? "opacity-100" : "opacity-0",
109
- {
110
- open Css
111
- style(list{width(14.75->rem)})
112
- },
113
116
  ])}>
114
117
  content
115
118
  </div>
@@ -161,12 +164,15 @@ module App = {
161
164
  )
162
165
 
163
166
  let hideMenu = React.useCallback(_ => setOpen(_ => false))
167
+ let openMenu = React.useCallback(_ => setOpen(_ => true))
164
168
 
165
169
  <NavOpenContext.Provider value={isNavOpen}>
166
170
  <div>
167
171
  <TopNavigationBar username logout logoutLabel toggleMenu onLogoClick />
168
172
  <div className="flex">
169
- <LeftNavigationBar isNavOpen ?bottom hideMenu> sideNavRender </LeftNavigationBar>
173
+ <LeftNavigationBar isNavOpen ?bottom hideMenu openMenu>
174
+ {sideNavRender}
175
+ </LeftNavigationBar>
170
176
  <main
171
177
  className={cx([
172
178
  className,
@@ -60,7 +60,8 @@ module Core = {
60
60
  className="px-2 pt-2 border-b border-r border-gray-300 h-20"
61
61
  key={"thead-thd" ++ index->Int.toString}>
62
62
  <Toolkit__Ui_Spread props={column.getSortByToggleProps()}>
63
- <p className="font-semibold text-sm mb-1 text-primary-800 pr-2 relative">
63
+ <div
64
+ className="font-semibold text-sm mb-1 text-primary-800 pr-2 relative">
64
65
  {column.render("header", ())}
65
66
  {column.isSorted
66
67
  ? column.isSortedDesc->Option.mapWithDefault(React.null, v =>
@@ -71,7 +72,7 @@ module Core = {
71
72
  </span>
72
73
  )
73
74
  : React.null}
74
- </p>
75
+ </div>
75
76
  </Toolkit__Ui_Spread>
76
77
  <Toolkit__Ui_Spread props={column.getResizerProps()}>
77
78
  <div className={"resizer" ++ (column.isResizing ? " isResizing" : "")} />
package/src/ui/styles.css CHANGED
@@ -225,10 +225,11 @@ iframe:not([tabindex="-1"]):focus,
225
225
 
226
226
  .cw-Tabs [data-selected] {
227
227
  background: linear-gradient(270deg, #11a3b6 0%, #27d0dc 100%);
228
- @apply text-white;
228
+ color: white;
229
229
  }
230
230
  .cw-Tabs [data-selected]:hover {
231
- @apply text-white bg-primary-500;
231
+ color: white;
232
+ @apply bg-primary-500;
232
233
  }
233
234
 
234
235
  .cw-Tabs [data-reach-tab] {