@colisweb/rescript-toolkit 2.60.0 → 2.61.1
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.
|
|
3
|
+
"version": "2.61.1",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"clean": "rescript clean",
|
|
6
6
|
"build": "rescript build -with-deps",
|
|
@@ -78,7 +78,7 @@
|
|
|
78
78
|
"rescript-classnames": "6.0.0",
|
|
79
79
|
"rescript-react-update": "5.0.0",
|
|
80
80
|
"sanitize-html": "1.27.4",
|
|
81
|
-
"swr": "
|
|
81
|
+
"swr": "2.0.0",
|
|
82
82
|
"tailwindcss": "3.2.4"
|
|
83
83
|
},
|
|
84
84
|
"devDependencies": {
|
|
@@ -4,19 +4,16 @@ module type Config = {
|
|
|
4
4
|
}
|
|
5
5
|
|
|
6
6
|
module Make = (Config: Config) => {
|
|
7
|
-
let key: Config.Request.argument => Swr.SwrKey.t =
|
|
7
|
+
let key: Config.Request.argument => Swr.SwrKey.t = arr =>
|
|
8
|
+
Config.key(arr)->Js.Array2.joinWith("--")->Swr.SwrKey.make
|
|
8
9
|
|
|
9
10
|
let use = (
|
|
10
11
|
~options: option<Swr.fetcherOptions>=?,
|
|
11
12
|
argument: option<Config.Request.argument>,
|
|
12
13
|
): Toolkit__Hooks.fetcher<Config.Request.response> =>
|
|
13
|
-
Toolkit__Hooks.useFetcher(
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
() => {
|
|
17
|
-
Config.Request.exec(argument->Option.getExn)->Promise.Js.fromResult
|
|
18
|
-
},
|
|
19
|
-
)
|
|
14
|
+
Toolkit__Hooks.useFetcher(~options?, argument->Option.map(key), () => {
|
|
15
|
+
Config.Request.exec(argument->Option.getExn)->Promise.Js.fromResult
|
|
16
|
+
})
|
|
20
17
|
|
|
21
18
|
let useOptional = (
|
|
22
19
|
~options: option<Swr.fetcherOptions>=?,
|
|
@@ -26,3 +23,28 @@ module Make = (Config: Config) => {
|
|
|
26
23
|
Config.Request.exec(argument->Option.getExn)->Promise.Js.fromResult
|
|
27
24
|
})
|
|
28
25
|
}
|
|
26
|
+
|
|
27
|
+
module type MutationConfig = {
|
|
28
|
+
module Request: Toolkit__Request.Config
|
|
29
|
+
let key: string
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
module MakeMutation = (Config: MutationConfig) => {
|
|
33
|
+
let key = Config.key->Swr.SwrKey.make
|
|
34
|
+
|
|
35
|
+
let useMutation = (
|
|
36
|
+
~options: option<Swr.mutationFetcherOptions<Config.Request.response>>=?,
|
|
37
|
+
key: string,
|
|
38
|
+
) => {
|
|
39
|
+
Swr.useSwrMutation(
|
|
40
|
+
Swr.SwrKey.make(key),
|
|
41
|
+
(_url, {arg}) => {
|
|
42
|
+
Config.Request.exec(arg)->Promise.Js.fromResult
|
|
43
|
+
},
|
|
44
|
+
switch options {
|
|
45
|
+
| Some(options) => options->Obj.magic
|
|
46
|
+
| None => {revalidate: true}
|
|
47
|
+
},
|
|
48
|
+
)
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -60,21 +60,23 @@ module App = {
|
|
|
60
60
|
</a>
|
|
61
61
|
</div>
|
|
62
62
|
<Menu>
|
|
63
|
-
|
|
64
|
-
<
|
|
65
|
-
<
|
|
66
|
-
|
|
67
|
-
<
|
|
68
|
-
<div> <BsReactIcons.MdKeyboardArrowDown size=18 /> </div>
|
|
63
|
+
<MenuButton>
|
|
64
|
+
<div className="flex items-center flex-col-gap-2 text-neutral-800">
|
|
65
|
+
<span className="font-semibold"> {username->React.string} </span>
|
|
66
|
+
<div>
|
|
67
|
+
<BsReactIcons.MdAccountCircle size=28 />
|
|
69
68
|
</div>
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
69
|
+
<div>
|
|
70
|
+
<BsReactIcons.MdKeyboardArrowDown size=18 />
|
|
71
|
+
</div>
|
|
72
|
+
</div>
|
|
73
|
+
</MenuButton>
|
|
74
|
+
<MenuList
|
|
75
|
+
className="focus:outline-none focus:shadow-none bg-white z-50 shadow-lg rounded border py-2 ml-2 mt-2 w-48">
|
|
76
|
+
<MenuItem className="text-lg py-2 px-4 flex items-center" onSelect=logout>
|
|
77
|
+
logoutLabel
|
|
78
|
+
</MenuItem>
|
|
79
|
+
</MenuList>
|
|
78
80
|
</Menu>
|
|
79
81
|
</div>
|
|
80
82
|
}
|
|
@@ -106,7 +108,7 @@ module App = {
|
|
|
106
108
|
"lg:flex border-r px-2 py-3 fixed flex-col bg-white justify-between transition-all duration-300 ease-in-out z-40",
|
|
107
109
|
isNavOpen ? "w-64 overflow-y-auto" : "w-16 hidden sidenav--closed",
|
|
108
110
|
])}>
|
|
109
|
-
{children({onLinkClick
|
|
111
|
+
{children({onLinkClick, isNavOpen, openMenu})}
|
|
110
112
|
{bottom->Option.mapWithDefault(React.null, content =>
|
|
111
113
|
<div className={!isNavOpen ? "overflow-hidden" : ""}>
|
|
112
114
|
<div
|
package/src/vendors/Swr.res
CHANGED
|
@@ -12,6 +12,7 @@ type fetcherOptions
|
|
|
12
12
|
@obj
|
|
13
13
|
external makeFetcherOptions: (
|
|
14
14
|
~suspense: bool=?,
|
|
15
|
+
~keepPreviousData: bool=?,
|
|
15
16
|
~fetcher: 'fetcher=?,
|
|
16
17
|
~fallbackData: 'data=?,
|
|
17
18
|
~revalidateOnFocus: bool=?,
|
|
@@ -43,16 +44,39 @@ type fetcher<'data> = {
|
|
|
43
44
|
data: option<'data>,
|
|
44
45
|
error: option<Js.Exn.t>,
|
|
45
46
|
isValidating: bool,
|
|
47
|
+
isLoading: bool,
|
|
46
48
|
mutate: (. unit) => Js.Promise.t<bool>,
|
|
47
49
|
}
|
|
48
50
|
|
|
51
|
+
type mutationFetcherOptions<'optimisticData> = {
|
|
52
|
+
optimisticData?: 'optimisticData => 'optimisticData,
|
|
53
|
+
revalidate?: bool,
|
|
54
|
+
populateCache?: bool,
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
type mutationFetcher<'params, 'data, 'error> = {
|
|
58
|
+
data: option<'data>,
|
|
59
|
+
error: option<Js.Exn.t>,
|
|
60
|
+
isMutating: bool,
|
|
61
|
+
trigger: 'params => Promise.Js.t<'data, 'error>,
|
|
62
|
+
}
|
|
63
|
+
|
|
49
64
|
module SwrKey = Toolkit__Identifier.MakeString()
|
|
50
65
|
|
|
51
66
|
@module("swr")
|
|
52
67
|
external useSwr: (option<SwrKey.t>, 'fn, 'fetcherOptions) => fetcher<'data> = "default"
|
|
53
68
|
|
|
69
|
+
type mutationParams<'params> = {arg: 'params}
|
|
70
|
+
@module("swr/mutation")
|
|
71
|
+
external useSwrMutation: (
|
|
72
|
+
SwrKey.t,
|
|
73
|
+
(string, mutationParams<'params>) => 'response,
|
|
74
|
+
mutationFetcherOptions<'optimisticData>,
|
|
75
|
+
) => mutationFetcher<'params, 'data, 'error> = "default"
|
|
76
|
+
|
|
54
77
|
@module("swr")
|
|
55
|
-
external useSwrOptional: (option<SwrKey.t>, 'fn, 'fetcherOptions) => fetcher<option<'data>> =
|
|
78
|
+
external useSwrOptional: (option<SwrKey.t>, 'fn, 'fetcherOptions) => fetcher<option<'data>> =
|
|
79
|
+
"default"
|
|
56
80
|
|
|
57
81
|
type cache
|
|
58
82
|
@module("swr") external cache: cache = "cache"
|
|
@@ -4,7 +4,7 @@ module Menu = {
|
|
|
4
4
|
type renderProps = {isOpen: bool}
|
|
5
5
|
|
|
6
6
|
@module("@reach/menu-button") @react.component
|
|
7
|
-
external make: (~children:
|
|
7
|
+
external make: (~children: React.element) => React.element = "Menu"
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
module MenuButton = {
|