@colisweb/rescript-toolkit 1.26.1 → 1.28.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/package.json +8 -9
- package/src/fetcher/Toolkit__Fetcher.res +2 -5
- package/src/hooks/Toolkit__Hooks.res +8 -24
- package/src/ui/Toolkit__Ui.res +1 -0
- package/src/ui/Toolkit__Ui_Checkbox.res +1 -1
- package/src/ui/Toolkit__Ui_Dropdown.res +2 -1
- package/src/ui/Toolkit__Ui_Dropdown.resi +1 -0
- package/src/ui/Toolkit__Ui_MultiSelect.res +13 -6
- package/src/ui/Toolkit__Ui_NativeDatePicker.res +23 -0
- package/src/ui/Toolkit__Ui_NativeDatePicker.resi +9 -0
- package/src/ui/Toolkit__Ui_Select.res +2 -2
- package/src/ui/Toolkit__Ui_Snackbar.res +103 -71
- package/src/ui/Toolkit__Ui_Snackbar.resi +3 -2
- package/src/vendors/BsDateFns.res +3 -0
- package/src/vendors/BsReactIcons.res +6 -0
- package/src/vendors/{BsSwr.res → Swr.res} +17 -8
- package/src/vendors/Msw.res +0 -96
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@colisweb/rescript-toolkit",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.28.0",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"clean": "rescript clean",
|
|
6
6
|
"build": "rescript build",
|
|
@@ -23,7 +23,6 @@
|
|
|
23
23
|
"license": "MIT",
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@colisweb/react-day-picker": "7.4.16",
|
|
26
|
-
"@openapi-contrib/openapi-schema-to-json-schema": "3.0.4",
|
|
27
26
|
"@reach/accordion": "0.16.1",
|
|
28
27
|
"@reach/alert-dialog": "0.16.0",
|
|
29
28
|
"@reach/auto-id": "0.16.0",
|
|
@@ -38,15 +37,15 @@
|
|
|
38
37
|
"@reach/tooltip": "0.16.0",
|
|
39
38
|
"@reach/visually-hidden": "0.16.0",
|
|
40
39
|
"@rescript/react": "0.10.3",
|
|
41
|
-
"autoprefixer": "10.3.
|
|
42
|
-
"axios": "0.
|
|
40
|
+
"autoprefixer": "10.3.6",
|
|
41
|
+
"axios": "0.22.0",
|
|
43
42
|
"bs-axios": "0.0.43",
|
|
44
43
|
"bs-css": "13.4.0",
|
|
45
44
|
"bs-css-emotion": "2.4.0",
|
|
46
45
|
"case": "1.6.3",
|
|
47
46
|
"click-outside-hook": "1.1.0",
|
|
48
47
|
"copy-to-clipboard": "3.3.1",
|
|
49
|
-
"date-fns": "2.
|
|
48
|
+
"date-fns": "2.24.0",
|
|
50
49
|
"decco": "1.5.0",
|
|
51
50
|
"dedent": "0.7.0",
|
|
52
51
|
"downshift": "5.2.5",
|
|
@@ -58,7 +57,7 @@
|
|
|
58
57
|
"postcss-preset-env": "6.7.0",
|
|
59
58
|
"prismjs": "1.23.0",
|
|
60
59
|
"react-datepicker": "3.8.0",
|
|
61
|
-
"react-icons": "4.
|
|
60
|
+
"react-icons": "4.3.1",
|
|
62
61
|
"react-select": "4.3.1",
|
|
63
62
|
"react-table": "7.7.0",
|
|
64
63
|
"react-use": "17.3.1",
|
|
@@ -71,8 +70,8 @@
|
|
|
71
70
|
"rescript-react-update": "4.0.0",
|
|
72
71
|
"restorative": "0.4.0-beta.1",
|
|
73
72
|
"string.prototype.matchall": "4.0.5",
|
|
74
|
-
"swr": "0.
|
|
75
|
-
"tailwindcss": "2.2.
|
|
73
|
+
"swr": "1.0.1",
|
|
74
|
+
"tailwindcss": "2.2.16"
|
|
76
75
|
},
|
|
77
76
|
"devDependencies": {
|
|
78
77
|
"@babel/core": "7.15.5",
|
|
@@ -88,6 +87,6 @@
|
|
|
88
87
|
"react": "17.0.2",
|
|
89
88
|
"react-dom": "17.0.2",
|
|
90
89
|
"react-is": "17.0.2",
|
|
91
|
-
"sass": "1.
|
|
90
|
+
"sass": "1.42.1"
|
|
92
91
|
}
|
|
93
92
|
}
|
|
@@ -4,16 +4,13 @@ module type Config = {
|
|
|
4
4
|
}
|
|
5
5
|
|
|
6
6
|
module Make = (Config: Config) => {
|
|
7
|
-
let updateData = (key: Config.Request.argument, ~shouldRevalidate=false, ~data): unit =>
|
|
8
|
-
Toolkit__Hooks.updateFetcherData(Config.key(key), data, shouldRevalidate)
|
|
9
|
-
|
|
10
7
|
let trigger = (key: Config.Request.argument): unit =>
|
|
11
8
|
Toolkit__Hooks.triggerFetcher(Config.key(key))
|
|
12
9
|
|
|
13
10
|
let key: Config.Request.argument => array<string> = Config.key
|
|
14
11
|
|
|
15
12
|
let use = (
|
|
16
|
-
~options: option<
|
|
13
|
+
~options: option<Swr.fetcherOptions>=?,
|
|
17
14
|
key: option<Config.Request.argument>,
|
|
18
15
|
): Toolkit__Hooks.fetcher<Config.Request.response> =>
|
|
19
16
|
Toolkit__Hooks.useFetcher(~options?, key->Option.map(Config.key), () => {
|
|
@@ -23,7 +20,7 @@ module Make = (Config: Config) => {
|
|
|
23
20
|
})
|
|
24
21
|
|
|
25
22
|
let useOptional = (
|
|
26
|
-
~options: option<
|
|
23
|
+
~options: option<Swr.fetcherOptions>=?,
|
|
27
24
|
key: option<Config.Request.argument>,
|
|
28
25
|
): Toolkit__Hooks.fetcher<option<Config.Request.response>> =>
|
|
29
26
|
Toolkit__Hooks.useOptionalFetcher(~options?, key->Option.map(Config.key), () => {
|
|
@@ -57,18 +57,12 @@ let useInitialPreviousDistinct = (~compare=(a, b) => a === b, value) => {
|
|
|
57
57
|
// useFetcher
|
|
58
58
|
// ----------------------
|
|
59
59
|
|
|
60
|
-
type fetcherOptions = BsSwr.fetcherOptions
|
|
61
|
-
|
|
62
|
-
let fetcherOptions = BsSwr.fetcherOptions
|
|
63
|
-
|
|
64
60
|
type fetcher<'data> = ('data, bool, unit => Promise.t<result<bool, Js.Promise.error>>)
|
|
65
61
|
|
|
66
|
-
let
|
|
67
|
-
|
|
68
|
-
let triggerFetcher = BsSwr.trigger
|
|
62
|
+
let triggerFetcher = Swr.trigger
|
|
69
63
|
|
|
70
|
-
let useFetcher = (~options: option<fetcherOptions>=?, key: 'key, fn: 'fn): fetcher<'data> => {
|
|
71
|
-
let
|
|
64
|
+
let useFetcher = (~options: option<Swr.fetcherOptions>=?, key: 'key, fn: 'fn): fetcher<'data> => {
|
|
65
|
+
let {data, isValidating, mutate} = Swr.useSwr(
|
|
72
66
|
key,
|
|
73
67
|
fn,
|
|
74
68
|
Js.Obj.assign(
|
|
@@ -80,18 +74,13 @@ let useFetcher = (~options: option<fetcherOptions>=?, key: 'key, fn: 'fn): fetch
|
|
|
80
74
|
),
|
|
81
75
|
)
|
|
82
76
|
|
|
83
|
-
(
|
|
84
|
-
fetcher.data->Obj.magic,
|
|
85
|
-
fetcher.isValidating,
|
|
86
|
-
() =>
|
|
87
|
-
fetcher.revalidate(BsSwr.revalidateOptions())->Promise.Js.fromBsPromise->Promise.Js.toResult,
|
|
88
|
-
)
|
|
77
|
+
(data->Obj.magic, isValidating, () => Promise.Js.fromBsPromise(mutate(.))->Promise.Js.toResult)
|
|
89
78
|
}
|
|
90
79
|
|
|
91
|
-
let useOptionalFetcher = (~options: option<fetcherOptions>=?, key: 'key, fn: 'fn): fetcher<
|
|
80
|
+
let useOptionalFetcher = (~options: option<Swr.fetcherOptions>=?, key: 'key, fn: 'fn): fetcher<
|
|
92
81
|
'data,
|
|
93
82
|
> => {
|
|
94
|
-
let
|
|
83
|
+
let {data, isValidating, mutate} = Swr.useSwrOptional(
|
|
95
84
|
key,
|
|
96
85
|
fn,
|
|
97
86
|
Js.Obj.assign(
|
|
@@ -103,12 +92,7 @@ let useOptionalFetcher = (~options: option<fetcherOptions>=?, key: 'key, fn: 'fn
|
|
|
103
92
|
),
|
|
104
93
|
)
|
|
105
94
|
|
|
106
|
-
(
|
|
107
|
-
fetcher.data->Obj.magic,
|
|
108
|
-
fetcher.isValidating,
|
|
109
|
-
() =>
|
|
110
|
-
fetcher.revalidate(BsSwr.revalidateOptions())->Promise.Js.fromBsPromise->Promise.Js.toResult,
|
|
111
|
-
)
|
|
95
|
+
(data->Obj.magic, isValidating, () => mutate(.)->Promise.Js.fromBsPromise->Promise.Js.toResult)
|
|
112
96
|
}
|
|
113
97
|
|
|
114
98
|
// ----------------------
|
|
@@ -148,7 +132,7 @@ let useClipboard = (~onCopyNotificationMessage: option<string>=?, value: string)
|
|
|
148
132
|
let (hasCopied, setHasCopied) = React.useState(() => false)
|
|
149
133
|
let onCopy = React.useCallback1(() => {
|
|
150
134
|
onCopyNotificationMessage->Option.forEach(message =>
|
|
151
|
-
Toolkit__Ui_Snackbar.show(~title=message, ~variant=#success, ())
|
|
135
|
+
Toolkit__Ui_Snackbar.show(~title=message, ~variant=#success, ())->ignore
|
|
152
136
|
)
|
|
153
137
|
|
|
154
138
|
let didCopy = BsCopyToClipboard.copy(value)
|
package/src/ui/Toolkit__Ui.res
CHANGED
|
@@ -51,7 +51,7 @@ let make = (
|
|
|
51
51
|
/>
|
|
52
52
|
<span
|
|
53
53
|
className={cx([
|
|
54
|
-
"checkmark rounded border text-white mr-3 border-neutral-300 transform transition-all ease-in-out flex items-center justify-center",
|
|
54
|
+
"checkmark rounded border text-white mr-3 border-neutral-300 transform transition-all ease-in-out flex items-center justify-center flex-shrink-0",
|
|
55
55
|
switch size {
|
|
56
56
|
| #xs => "w-4 h-4"
|
|
57
57
|
| #sm => "w-6 h-6"
|
|
@@ -11,6 +11,7 @@ let make = (
|
|
|
11
11
|
~children,
|
|
12
12
|
~dropdownClassName="",
|
|
13
13
|
~buttonClassName="",
|
|
14
|
+
~containerClassName="",
|
|
14
15
|
~defaultIsOpen=false,
|
|
15
16
|
~buttonColor: Toolkit__Ui_Button.color=#white,
|
|
16
17
|
~buttonSize: Toolkit__Ui_Button.size=#md,
|
|
@@ -53,7 +54,7 @@ let make = (
|
|
|
53
54
|
None
|
|
54
55
|
}, (isOpen, ref))
|
|
55
56
|
|
|
56
|
-
<div className="relative">
|
|
57
|
+
<div className={cx(["relative", containerClassName])}>
|
|
57
58
|
<Toolkit__Ui_Button
|
|
58
59
|
variant=buttonVariant
|
|
59
60
|
size=buttonSize
|
|
@@ -41,13 +41,20 @@ let make = (
|
|
|
41
41
|
position=#bottom
|
|
42
42
|
label={switch selectedOptions {
|
|
43
43
|
| [] =>
|
|
44
|
-
<
|
|
45
|
-
placeholder
|
|
46
|
-
|
|
44
|
+
<p className="flex flex-row gap-2 w-full items-center">
|
|
45
|
+
<span className="ml-1"> {placeholder} </span>
|
|
46
|
+
<span className="absolute inset-y-0 right-0 flex items-center px-2">
|
|
47
|
+
<BsReactIcons.FaAngleDown />
|
|
48
|
+
</span>
|
|
49
|
+
</p>
|
|
47
50
|
| options =>
|
|
48
|
-
<
|
|
49
|
-
|
|
50
|
-
|
|
51
|
+
<div
|
|
52
|
+
className="table table-fixed w-full"
|
|
53
|
+
title={options->Array.map(({label}) => label)->Js.Array2.joinWith(", ")}>
|
|
54
|
+
<span className="table-cell truncate text-left">
|
|
55
|
+
{options->Array.map(({label}) => label)->Js.Array2.joinWith(", ")->React.string}
|
|
56
|
+
</span>
|
|
57
|
+
</div>
|
|
51
58
|
}}>
|
|
52
59
|
<div className="py-2 pl-2 pr-1">
|
|
53
60
|
{allowFilter
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
@react.component
|
|
2
|
+
let make = (~onChange, ~value=?, ~id=?, ~disabled=false, ~isInvalid=false, ~className="") =>
|
|
3
|
+
<div className="relative">
|
|
4
|
+
<input
|
|
5
|
+
?id
|
|
6
|
+
value=?{value->Option.map(d => d->BsDateFns.formatWithPattern("yyyy-MM-dd"))}
|
|
7
|
+
disabled
|
|
8
|
+
ariaDisabled={disabled}
|
|
9
|
+
onChange={event => {
|
|
10
|
+
let value = ReactEvent.Form.target(event)["value"]
|
|
11
|
+
onChange(Some(Js.Date.fromString(value))->Option.keep(BsDateFns.isValid))
|
|
12
|
+
}}
|
|
13
|
+
className={cx([
|
|
14
|
+
"h-[38px] border rounded transition-all duration-150 ease-in-out py-2 pl-4 pr-8 appearance-none w-full bg-white text-gray-800 leading-tight focus:outline-none focus:shadow-none focus:border-info-500 disabled:bg-gray-200 disabled:text-gray-700 focus:z30 relative border-gray-300",
|
|
15
|
+
switch isInvalid {
|
|
16
|
+
| true => "border-danger-500 shadow-danger-500"
|
|
17
|
+
| _ => "border-gray-300"
|
|
18
|
+
},
|
|
19
|
+
className,
|
|
20
|
+
])}
|
|
21
|
+
type_="date"
|
|
22
|
+
/>
|
|
23
|
+
</div>
|
|
@@ -32,7 +32,7 @@ let make = (
|
|
|
32
32
|
onChange(value)
|
|
33
33
|
}}>
|
|
34
34
|
{placeholder->Option.mapWithDefault(React.null, placeholder =>
|
|
35
|
-
<option> {placeholder->React.string} </option>
|
|
35
|
+
<option value=""> {placeholder->React.string} </option>
|
|
36
36
|
)}
|
|
37
37
|
{options
|
|
38
38
|
->Array.mapWithIndex((i, (label, value, enabled)) =>
|
|
@@ -44,6 +44,6 @@ let make = (
|
|
|
44
44
|
</select>
|
|
45
45
|
<div
|
|
46
46
|
className="pointer-events-none absolute inset-y-0 right-0 flex items-center px-2 text-gray-800">
|
|
47
|
-
<BsReactIcons.
|
|
47
|
+
<BsReactIcons.FaAngleDown />
|
|
48
48
|
</div>
|
|
49
49
|
</div>
|
|
@@ -1,30 +1,43 @@
|
|
|
1
|
-
type rec state = {
|
|
2
|
-
isVisible: bool,
|
|
3
|
-
options: option<options>,
|
|
4
|
-
}
|
|
1
|
+
type rec state = {list: array<options>}
|
|
5
2
|
and options = {
|
|
3
|
+
id: id,
|
|
4
|
+
isVisible: bool,
|
|
6
5
|
title: string,
|
|
7
6
|
description: option<React.element>,
|
|
8
7
|
closable: bool,
|
|
9
8
|
variant: variant,
|
|
10
9
|
timeout: int,
|
|
11
10
|
}
|
|
11
|
+
and id
|
|
12
12
|
and variant = [#success | #warning | #danger]
|
|
13
13
|
|
|
14
14
|
type action =
|
|
15
15
|
| Show(options)
|
|
16
|
-
| Hide
|
|
16
|
+
| Hide(id)
|
|
17
|
+
| Remove(id)
|
|
17
18
|
|
|
18
|
-
let store = Restorative.createStore({
|
|
19
|
+
let store = Restorative.createStore({list: []}, (state, action) =>
|
|
19
20
|
switch action {
|
|
20
|
-
| Show(options) => {
|
|
21
|
-
| Hide => {
|
|
21
|
+
| Show(options) => {list: state.list->Array.concat([options])}
|
|
22
|
+
| Hide(id) => {
|
|
23
|
+
list: state.list->Array.map(e =>
|
|
24
|
+
if e.id === id {
|
|
25
|
+
{...e, isVisible: false}
|
|
26
|
+
} else {
|
|
27
|
+
e
|
|
28
|
+
}
|
|
29
|
+
),
|
|
30
|
+
}
|
|
31
|
+
| Remove(id) => {list: state.list->Array.keep(e => e.id !== id)}
|
|
22
32
|
}
|
|
23
33
|
)
|
|
24
34
|
|
|
25
|
-
let show = (~title, ~description=?, ~closable=true, ~variant, ~timeout=5000, ()) =>
|
|
35
|
+
let show = (~title, ~description=?, ~closable=true, ~variant, ~timeout=5000, ()) => {
|
|
36
|
+
let id: id = Js.Math.random()->Js.Float.toString->Obj.magic
|
|
26
37
|
store.dispatch(
|
|
27
38
|
Show({
|
|
39
|
+
id: id,
|
|
40
|
+
isVisible: true,
|
|
28
41
|
title: title,
|
|
29
42
|
description: description,
|
|
30
43
|
closable: closable,
|
|
@@ -32,76 +45,95 @@ let show = (~title, ~description=?, ~closable=true, ~variant, ~timeout=5000, ())
|
|
|
32
45
|
timeout: timeout,
|
|
33
46
|
}),
|
|
34
47
|
)
|
|
35
|
-
|
|
48
|
+
id
|
|
49
|
+
}
|
|
36
50
|
|
|
37
|
-
|
|
51
|
+
let remove = id => store.dispatch(Remove(id))
|
|
52
|
+
let hide = id => {
|
|
53
|
+
store.dispatch(Hide(id))
|
|
54
|
+
Js.Global.setTimeout(() => {
|
|
55
|
+
remove(id)
|
|
56
|
+
}, 160)->ignore
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
module Item = {
|
|
38
60
|
@react.component
|
|
39
|
-
let make = () => {
|
|
40
|
-
let {isVisible,
|
|
41
|
-
let timeoutRef = React.useRef(None)
|
|
61
|
+
let make = (~options) => {
|
|
62
|
+
let {id, isVisible, variant, title, description, closable, timeout} = options
|
|
42
63
|
|
|
43
|
-
React.
|
|
44
|
-
if isVisible {
|
|
45
|
-
timeoutRef.current->Option.map(timeoutRef => timeoutRef->Js.Global.clearTimeout)->ignore
|
|
64
|
+
let (mounted, setMounted) = React.useState(() => false)
|
|
46
65
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
)
|
|
66
|
+
React.useEffect0(() => {
|
|
67
|
+
setMounted(_ => true)
|
|
68
|
+
let timeoutId = Js.Global.setTimeout(() => {
|
|
69
|
+
hide(id)
|
|
70
|
+
}, timeout)
|
|
71
|
+
Some(() => Js.Global.clearTimeout(timeoutId))
|
|
72
|
+
})
|
|
51
73
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
74
|
+
<div
|
|
75
|
+
className={cx([
|
|
76
|
+
"bg-white p-3 rounded shadow transition duration-500 ease-in-out mt-3 transform",
|
|
77
|
+
{
|
|
78
|
+
open Css
|
|
79
|
+
style(list{bottom(40->px)})
|
|
80
|
+
},
|
|
81
|
+
mounted ? "-translate-y-14 opacity-1" : "opacity-0",
|
|
82
|
+
isVisible ? "opacity-100 z-50" : "opacity-0 translate-x-[200px]",
|
|
83
|
+
{
|
|
84
|
+
switch variant {
|
|
85
|
+
| #success => "bg-success-500 text-white"
|
|
86
|
+
| #warning => "bg-warning-500 text-white"
|
|
87
|
+
| #danger => "bg-danger-500 text-white"
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
])}>
|
|
91
|
+
<div className="flex flex-gap-3">
|
|
92
|
+
<div>
|
|
93
|
+
{switch variant {
|
|
94
|
+
| #success => <BsReactIcons.MdCheckCircle size=28 />
|
|
95
|
+
| #warning => <BsReactIcons.MdWarning size=28 />
|
|
96
|
+
| #danger => <BsReactIcons.MdError size=28 />
|
|
97
|
+
}}
|
|
98
|
+
</div>
|
|
99
|
+
<div>
|
|
100
|
+
<strong> {title->React.string} </strong>
|
|
101
|
+
{description->Option.mapWithDefault(React.null, description =>
|
|
102
|
+
<p
|
|
103
|
+
className={cx([
|
|
104
|
+
"text-sm",
|
|
105
|
+
{
|
|
106
|
+
open Css
|
|
107
|
+
style(list{maxWidth(250->px)})
|
|
108
|
+
},
|
|
109
|
+
])}>
|
|
110
|
+
description
|
|
111
|
+
</p>
|
|
112
|
+
)}
|
|
113
|
+
</div>
|
|
114
|
+
{closable
|
|
115
|
+
? <button className="self-start" onClick={_ => hide(id)}>
|
|
116
|
+
<BsReactIcons.MdClose />
|
|
117
|
+
</button>
|
|
118
|
+
: React.null}
|
|
119
|
+
</div>
|
|
120
|
+
</div>
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
module Provider = {
|
|
125
|
+
@react.component
|
|
126
|
+
let make = () => {
|
|
127
|
+
let {list} = store.useStore()
|
|
56
128
|
|
|
57
129
|
<ReachUi.Portal>
|
|
58
130
|
<div
|
|
59
|
-
className=
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
isVisible ? "opacity-100 translate-y-0 z-50" : "opacity-0 translate-y-10",
|
|
66
|
-
options->Option.mapWithDefault("", options =>
|
|
67
|
-
switch options.variant {
|
|
68
|
-
| #success => "bg-success-500 text-white"
|
|
69
|
-
| #warning => "bg-warning-500 text-white"
|
|
70
|
-
| #danger => "bg-danger-500 text-white"
|
|
71
|
-
}
|
|
72
|
-
),
|
|
73
|
-
])}>
|
|
74
|
-
{options->Option.mapWithDefault(React.null, options =>
|
|
75
|
-
<div className="flex flex-gap-3">
|
|
76
|
-
<div>
|
|
77
|
-
{switch options.variant {
|
|
78
|
-
| #success => <BsReactIcons.MdCheckCircle size=28 />
|
|
79
|
-
| #warning => <BsReactIcons.MdWarning size=28 />
|
|
80
|
-
| #danger => <BsReactIcons.MdError size=28 />
|
|
81
|
-
}}
|
|
82
|
-
</div>
|
|
83
|
-
<div>
|
|
84
|
-
<strong> {options.title->React.string} </strong>
|
|
85
|
-
{options.description->Option.mapWithDefault(React.null, description =>
|
|
86
|
-
<p
|
|
87
|
-
className={cx([
|
|
88
|
-
"text-sm",
|
|
89
|
-
{
|
|
90
|
-
open Css
|
|
91
|
-
style(list{maxWidth(250->px)})
|
|
92
|
-
},
|
|
93
|
-
])}>
|
|
94
|
-
description
|
|
95
|
-
</p>
|
|
96
|
-
)}
|
|
97
|
-
</div>
|
|
98
|
-
{options.closable
|
|
99
|
-
? <button className="self-start" onClick={_ => hide()}>
|
|
100
|
-
<BsReactIcons.MdClose />
|
|
101
|
-
</button>
|
|
102
|
-
: React.null}
|
|
103
|
-
</div>
|
|
104
|
-
)}
|
|
131
|
+
className="fixed right-0 top-0 transform translate-y-14 h-full p-4 flex flex-col items-end justify-end">
|
|
132
|
+
{list
|
|
133
|
+
->Array.map(e => {
|
|
134
|
+
<Item key={e.id->Obj.magic} options=e />
|
|
135
|
+
})
|
|
136
|
+
->React.array}
|
|
105
137
|
</div>
|
|
106
138
|
</ReachUi.Portal>
|
|
107
139
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
type variant = [#success | #warning | #danger]
|
|
2
|
+
type id
|
|
2
3
|
|
|
3
4
|
let show: (
|
|
4
5
|
~title: string,
|
|
@@ -7,8 +8,8 @@ let show: (
|
|
|
7
8
|
~variant: variant,
|
|
8
9
|
~timeout: int=?, // default: 5000
|
|
9
10
|
unit,
|
|
10
|
-
) =>
|
|
11
|
-
let hide:
|
|
11
|
+
) => id
|
|
12
|
+
let hide: id => unit
|
|
12
13
|
|
|
13
14
|
module Provider: {
|
|
14
15
|
@react.component
|
|
@@ -5887,3 +5887,9 @@ module GoPrimitiveDot = {
|
|
|
5887
5887
|
external make: (~size: int=?, ~color: string=?, ~className: string=?) => React.element =
|
|
5888
5888
|
"GoPrimitiveDot"
|
|
5889
5889
|
}
|
|
5890
|
+
|
|
5891
|
+
module FaFilter = {
|
|
5892
|
+
@module("react-icons/fa") @react.component
|
|
5893
|
+
external make: (~size: int=?, ~color: string=?, ~className: string=?) => React.element =
|
|
5894
|
+
"FaFilter"
|
|
5895
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
type revalidateOptions
|
|
2
2
|
|
|
3
3
|
@obj
|
|
4
|
-
external
|
|
4
|
+
external makeRevalidateOptions: (
|
|
5
5
|
~retryCount: option<int>=?,
|
|
6
6
|
~dedupe: option<bool>=?,
|
|
7
7
|
unit,
|
|
@@ -10,10 +10,10 @@ external revalidateOptions: (
|
|
|
10
10
|
type fetcherOptions
|
|
11
11
|
|
|
12
12
|
@obj
|
|
13
|
-
external
|
|
13
|
+
external makeFetcherOptions: (
|
|
14
14
|
~suspense: bool=?,
|
|
15
15
|
~fetcher: 'fetcher=?,
|
|
16
|
-
~
|
|
16
|
+
~fallbackData: 'data=?,
|
|
17
17
|
~revalidateOnFocus: bool=?,
|
|
18
18
|
~revalidateOnMount: bool=?,
|
|
19
19
|
~revalidateOnReconnect: bool=?,
|
|
@@ -43,7 +43,7 @@ type fetcher<'data> = {
|
|
|
43
43
|
data: option<'data>,
|
|
44
44
|
error: option<Js.Exn.t>,
|
|
45
45
|
isValidating: bool,
|
|
46
|
-
|
|
46
|
+
mutate: (. unit) => Js.Promise.t<bool>,
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
@module("swr")
|
|
@@ -54,11 +54,20 @@ external useSwrOptional: ('key, 'fn, 'fetcherOptions) => fetcher<option<'data>>
|
|
|
54
54
|
|
|
55
55
|
@module("swr") external trigger: 'key => unit = "trigger"
|
|
56
56
|
|
|
57
|
-
@module("swr") external mutate: ('key, 'data, bool) => unit = "mutate"
|
|
58
|
-
|
|
59
|
-
@module("swr") external mutate0: 'key => unit = "mutate"
|
|
60
|
-
|
|
61
57
|
type cache
|
|
62
58
|
@module("swr") external cache: cache = "cache"
|
|
63
59
|
@send external clear: cache => unit = "clear"
|
|
64
60
|
@send external delete: (cache, 'key) => unit = "delete"
|
|
61
|
+
|
|
62
|
+
module SwrConfig = {
|
|
63
|
+
type t
|
|
64
|
+
|
|
65
|
+
@send
|
|
66
|
+
external mutate0: (t, 'key) => unit = "mutate"
|
|
67
|
+
|
|
68
|
+
@send
|
|
69
|
+
external mutate: (t, 'key, 'data, bool) => unit = "mutate"
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
@module("swr")
|
|
73
|
+
external useSWRConfig: unit => SwrConfig.t = "useSWRConfig"
|
package/src/vendors/Msw.res
DELETED
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
type mockedResponse
|
|
2
|
-
external mockedResponse: 'a => Js.Null.t<mockedResponse> = "%identity"
|
|
3
|
-
|
|
4
|
-
@get external body: mockedResponse => string = "body"
|
|
5
|
-
|
|
6
|
-
type responseTransformer = mockedResponse => mockedResponse
|
|
7
|
-
|
|
8
|
-
type headers
|
|
9
|
-
@send external setHeader: (headers, string, 'value) => unit = "set"
|
|
10
|
-
@send external getHeader: (headers, string) => 'value = "get"
|
|
11
|
-
|
|
12
|
-
type params
|
|
13
|
-
|
|
14
|
-
type request = {
|
|
15
|
-
url: string,
|
|
16
|
-
method: string,
|
|
17
|
-
headers: headers,
|
|
18
|
-
params: params,
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
type context
|
|
22
|
-
|
|
23
|
-
type response
|
|
24
|
-
|
|
25
|
-
@send
|
|
26
|
-
external response: (
|
|
27
|
-
response,
|
|
28
|
-
Js.null<'a>,
|
|
29
|
-
array<responseTransformer>,
|
|
30
|
-
) => Js.Null.t<mockedResponse> = "apply"
|
|
31
|
-
let response = (res, responseTransformers) => response(res, Js.null, responseTransformers)
|
|
32
|
-
|
|
33
|
-
type responseResolver = (request, response, context) => Js.Promise.t<Js.Null.t<mockedResponse>>
|
|
34
|
-
|
|
35
|
-
@send
|
|
36
|
-
external status: (context, string) => responseTransformer = "status"
|
|
37
|
-
|
|
38
|
-
@send external json: (context, 'data) => responseTransformer = "json"
|
|
39
|
-
|
|
40
|
-
@send external text: (context, 'data) => responseTransformer = "text"
|
|
41
|
-
|
|
42
|
-
@send external xml: (context, 'data) => responseTransformer = "xml"
|
|
43
|
-
|
|
44
|
-
@send external delay: (context, int) => responseTransformer = "delay"
|
|
45
|
-
|
|
46
|
-
type requestHandler
|
|
47
|
-
|
|
48
|
-
type rest = {
|
|
49
|
-
get: (string, responseResolver) => requestHandler,
|
|
50
|
-
post: (string, responseResolver) => requestHandler,
|
|
51
|
-
put: (string, responseResolver) => requestHandler,
|
|
52
|
-
patch: (string, responseResolver) => requestHandler,
|
|
53
|
-
delete: (string, responseResolver) => requestHandler,
|
|
54
|
-
options: (string, responseResolver) => requestHandler,
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
@module("msw") external rest: rest = "rest"
|
|
58
|
-
|
|
59
|
-
@module("msw")
|
|
60
|
-
external restDict: Js.Dict.t<(string, responseResolver) => requestHandler> = "rest"
|
|
61
|
-
|
|
62
|
-
type worker
|
|
63
|
-
|
|
64
|
-
@module("msw") @variadic
|
|
65
|
-
external setupWorker: array<requestHandler> => worker = "setupWorker"
|
|
66
|
-
|
|
67
|
-
@send external start: worker => unit = "start"
|
|
68
|
-
|
|
69
|
-
@send external stop: worker => unit = "stop"
|
|
70
|
-
|
|
71
|
-
@send @variadic
|
|
72
|
-
external use: (worker, array<requestHandler>) => unit = "use"
|
|
73
|
-
|
|
74
|
-
@send external restoreHandlers: worker => unit = "restoreHandlers"
|
|
75
|
-
|
|
76
|
-
@send @variadic
|
|
77
|
-
external resetHandlers: (worker, array<requestHandler>) => unit = "resetHandlers"
|
|
78
|
-
|
|
79
|
-
module Node = {
|
|
80
|
-
type server
|
|
81
|
-
|
|
82
|
-
@module("msw/node") @variadic
|
|
83
|
-
external setupServer: array<requestHandler> => server = "setupServer"
|
|
84
|
-
|
|
85
|
-
@send external listen: server => unit = "listen"
|
|
86
|
-
|
|
87
|
-
@send external close: server => unit = "close"
|
|
88
|
-
|
|
89
|
-
@send @variadic
|
|
90
|
-
external use: (server, array<requestHandler>) => unit = "use"
|
|
91
|
-
|
|
92
|
-
@send external restoreHandlers: server => unit = "restoreHandlers"
|
|
93
|
-
|
|
94
|
-
@send @variadic
|
|
95
|
-
external resetHandlers: (server, array<requestHandler>) => unit = "resetHandlers"
|
|
96
|
-
}
|