@colisweb/rescript-toolkit 2.71.0 → 3.0.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/.yarn/cache/@colisweb-restorative-npm-1.0.0-5eac899f0c-6e80ecc641.zip +0 -0
- package/.yarn/cache/@rescript-react-npm-0.11.0-687f8fa3b5-c399d114f7.zip +0 -0
- package/.yarn/cache/{rescript-npm-10.0.1-c064c63c72-59ae153c7f.zip → rescript-npm-10.1.2-eb312a329e-e70ae09da1.zip} +0 -0
- package/.yarn/install-state.gz +0 -0
- package/bsconfig.json +2 -2
- package/locale/fr.json +5 -0
- package/package.json +4 -5
- package/playground/PlaygroundApp.res +12 -0
- package/playground/PlaygroundBindings.res +106 -0
- package/playground/PlaygroundHooks.res +4 -4
- package/playground/PlaygroundRouter.res +18 -0
- package/playground/bindings/Playground_Bindings_Reach.res +143 -0
- package/playground/components/Playground_Form.res +56 -3
- package/playground/components/Playground_Modal.res +20 -5
- package/playground/components/Playground_Select.res +14 -4
- package/playground/hooks/{Playground_Clipboard.res → Playground_Hooks_Clipboard.res} +1 -1
- package/playground/hooks/{Playground_Disclosure.res → Playground_Hooks_Disclosure.res} +1 -1
- package/playground/hooks/{Playground_LazyLoad.res → Playground_Hooks_LazyLoad.res} +1 -1
- package/playground/hooks/{Playground_MediaQueries.res → Playground_Hooks_MediaQueries.res} +1 -1
- package/src/decoders/Toolkit__Decoders.res +1 -1
- package/src/form/Reform.res +8 -36
- package/src/form/Toolkit__Form.res +114 -55
- package/src/form/Toolkit__FormValidationFunctions.res +13 -0
- package/src/hooks/Toolkit__Hooks.res +1 -1
- package/src/intl/Toolkit__Intl.res +1 -1
- package/src/intl/Toolkit__Intl.resi +1 -1
- package/src/logger/Toolkit__NativeLogger.res +1 -1
- package/src/router/Toolkit__Router.res +0 -6
- package/src/ui/Toolkit__Ui.res +0 -2
- package/src/ui/Toolkit__Ui_Dropdown.res +13 -7
- package/src/ui/Toolkit__Ui_Dropdown.resi +2 -0
- package/src/ui/Toolkit__Ui_Layout.res +1 -6
- package/src/ui/Toolkit__Ui_MultiSelect.res +10 -4
- package/src/ui/Toolkit__Ui_MultiSelect.resi +5 -1
- package/src/ui/Toolkit__Ui_NativeDatePicker.res +2 -2
- package/src/ui/Toolkit__Ui_Select.res +22 -5
- package/src/ui/Toolkit__Ui_Select.resi +13 -2
- package/src/ui/Toolkit__Ui_SelectPolyvariant.res +45 -0
- package/src/ui/Toolkit__Ui_Table.res +11 -6
- package/src/ui/Toolkit__Ui_TextInput.res +2 -2
- package/src/ui/Toolkit__Ui_WeekDateFilter.res +16 -16
- package/src/utils/Toolkit__Utils_UnitMeasure.res +4 -4
- package/src/vendors/{BsCopyToClipboard.res → CopyToClipboard.res} +0 -0
- package/src/vendors/{BsDateFns.res → DateFns.res} +0 -0
- package/src/vendors/{BsJsCookie.res → JsCookie.res} +0 -0
- package/src/vendors/{BsReactDayPicker.res → ReactDayPicker.res} +0 -1
- package/src/vendors/{BsReactGoogleMaps.res → ReactGoogleMaps.res} +0 -0
- package/src/vendors/ReactIcons.res +5 -0
- package/src/vendors/{BsReactSelect.res → ReactSelect.res} +58 -58
- package/src/vendors/{BsSentryReactNative.res → SentryReactNative.res} +0 -0
- package/src/vendors/reach-ui/ReachUi_Accordion.res +12 -14
- package/src/vendors/reach-ui/ReachUi_AlertDialog.res +8 -34
- package/src/vendors/reach-ui/ReachUi_Dialog.res +7 -10
- package/src/vendors/reach-ui/ReachUi_Listbox.res +8 -9
- package/src/vendors/reach-ui/ReachUi_MenuButton.res +7 -30
- package/src/vendors/reach-ui/ReachUi_Popover.res +0 -6
- package/src/vendors/reach-ui/ReachUi_Tabs.res +18 -27
- package/.yarn/cache/@colisweb-restorative-npm-0.5.1-2ffe068813-cd8332a7eb.zip +0 -0
- package/.yarn/cache/@rescript-react-npm-0.10.3-26bd5d697f-8561282f78.zip +0 -0
- package/.yarn/cache/compute-scroll-into-view-npm-1.0.16-a8a68c1929-4334db6397.zip +0 -0
- package/.yarn/cache/downshift-npm-5.2.5-14bb33ffd8-498b4764a8.zip +0 -0
- package/src/mock/MockOverlay.resi +0 -4
- package/src/ui/Toolkit__Ui_Listbox.res +0 -123
- package/src/ui/Toolkit__Ui_ListboxInput.res +0 -673
- package/src/vendors/BsAnalytics.res +0 -34
- package/src/vendors/BsDownshift.res +0 -596
|
Binary file
|
|
Binary file
|
package/.yarn/install-state.gz
CHANGED
|
Binary file
|
package/bsconfig.json
CHANGED
package/locale/fr.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@colisweb/rescript-toolkit",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"clean": "rescript clean",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@colisweb/bs-react-intl-extractor-bin": "0.12.2",
|
|
31
31
|
"@colisweb/react-day-picker": "7.4.16",
|
|
32
|
-
"@colisweb/restorative": "0.
|
|
32
|
+
"@colisweb/restorative": "1.0.0",
|
|
33
33
|
"@datadog/browser-rum": "4.26.0",
|
|
34
34
|
"@reach/accordion": "0.18.0",
|
|
35
35
|
"@reach/alert-dialog": "0.18.0",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"@reach/tabs": "0.18.0",
|
|
45
45
|
"@reach/tooltip": "0.18.0",
|
|
46
46
|
"@reach/visually-hidden": "0.18.0",
|
|
47
|
-
"@rescript/react": "0.
|
|
47
|
+
"@rescript/react": "0.11.0",
|
|
48
48
|
"@tailwindcss/line-clamp": "0.4.2",
|
|
49
49
|
"autoprefixer": "10.4.13",
|
|
50
50
|
"axios": "0.24.0",
|
|
@@ -55,7 +55,6 @@
|
|
|
55
55
|
"date-fns": "2.29.3",
|
|
56
56
|
"decco": "1.6.0",
|
|
57
57
|
"dedent": "0.7.0",
|
|
58
|
-
"downshift": "5.2.5",
|
|
59
58
|
"lenses-ppx": "6.1.10",
|
|
60
59
|
"list-selectors": "2.0.1",
|
|
61
60
|
"lodash": "4.17.21",
|
|
@@ -76,7 +75,7 @@
|
|
|
76
75
|
"reason-promise": "1.1.5",
|
|
77
76
|
"res-react-intl": "3.1.2",
|
|
78
77
|
"reschema": "1.3.1",
|
|
79
|
-
"rescript": "10.
|
|
78
|
+
"rescript": "10.1.2",
|
|
80
79
|
"rescript-classnames": "6.0.0",
|
|
81
80
|
"rescript-react-update": "5.0.0",
|
|
82
81
|
"sanitize-html": "1.27.4",
|
|
@@ -60,6 +60,13 @@ let links: array<PlaygroundRouter.navLink> = [
|
|
|
60
60
|
route: Hooks(List),
|
|
61
61
|
}),
|
|
62
62
|
),
|
|
63
|
+
Single(
|
|
64
|
+
App({
|
|
65
|
+
label: "Bindings"->React.string,
|
|
66
|
+
icon: <ReactIcons.VscFolderLibrary size={30} />,
|
|
67
|
+
route: Bindings(List),
|
|
68
|
+
}),
|
|
69
|
+
),
|
|
63
70
|
]
|
|
64
71
|
|
|
65
72
|
@val
|
|
@@ -128,6 +135,11 @@ let make = () => {
|
|
|
128
135
|
| List => <PlaygroundHooks.List />
|
|
129
136
|
| Details(component) => <PlaygroundHooks.Details component />
|
|
130
137
|
}
|
|
138
|
+
| Bindings(component) =>
|
|
139
|
+
switch component {
|
|
140
|
+
| List => <PlaygroundBindings.List />
|
|
141
|
+
| Details(component) => <PlaygroundBindings.Details component />
|
|
142
|
+
}
|
|
131
143
|
|
|
132
144
|
| NotFound => "NotFound"->React.string
|
|
133
145
|
}}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
module type Config = {
|
|
2
|
+
let resi: string
|
|
3
|
+
let codeExample: string
|
|
4
|
+
@react.component
|
|
5
|
+
let make: unit => React.element
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
let components: array<(string, module(Config))> = [("ReachUI", module(Playground_Bindings_Reach))]
|
|
9
|
+
|
|
10
|
+
module List = {
|
|
11
|
+
module ComponentLink = {
|
|
12
|
+
@react.component
|
|
13
|
+
let make = (~name) => {
|
|
14
|
+
<PlaygroundRouter.Link
|
|
15
|
+
route={Bindings(Details(name))}
|
|
16
|
+
className="p-4 rounded-lg border bg-white hover:border-primary-700 w-64">
|
|
17
|
+
<strong className="capitalize"> {name->React.string} </strong>
|
|
18
|
+
</PlaygroundRouter.Link>
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
@react.component
|
|
23
|
+
let make = () => {
|
|
24
|
+
let (search, setSearch) = React.useState(() => "")
|
|
25
|
+
|
|
26
|
+
<div>
|
|
27
|
+
<h1 className="text-4xl font-bold font-display mb-4 flex flex-row gap-4 items-center">
|
|
28
|
+
{"Bindings"->React.string}
|
|
29
|
+
<input
|
|
30
|
+
type_="search"
|
|
31
|
+
placeholder="Search"
|
|
32
|
+
value={search}
|
|
33
|
+
onChange={event => {
|
|
34
|
+
let target = event->ReactEvent.Form.target
|
|
35
|
+
|
|
36
|
+
setSearch(_ => target["value"])
|
|
37
|
+
}}
|
|
38
|
+
className="bg-white text-sm font-sans px-4 font-normal rounded-md border border-neutral-300 focus:border-primary-700 h-10 w-60"
|
|
39
|
+
/>
|
|
40
|
+
</h1>
|
|
41
|
+
<div className="flex flex-row flex-wrap gap-4">
|
|
42
|
+
{components
|
|
43
|
+
->Array.keep(((name, _)) => name->Js.String2.toLowerCase->Js.String2.includes(search))
|
|
44
|
+
->Array.map(((name, _)) => <ComponentLink name key={name} />)
|
|
45
|
+
->React.array}
|
|
46
|
+
</div>
|
|
47
|
+
</div>
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
module Details = {
|
|
52
|
+
module Component = {
|
|
53
|
+
@react.component
|
|
54
|
+
let make = (~component: module(Config)) => {
|
|
55
|
+
let module(Config) = component
|
|
56
|
+
<div>
|
|
57
|
+
<ReachUi.Tabs>
|
|
58
|
+
<ReachUi.TabList className="mb-4">
|
|
59
|
+
<ReachUi.Tab> {"Example"->React.string} </ReachUi.Tab>
|
|
60
|
+
<ReachUi.Tab> {"Code example"->React.string} </ReachUi.Tab>
|
|
61
|
+
<ReachUi.Tab> {"API"->React.string} </ReachUi.Tab>
|
|
62
|
+
</ReachUi.TabList>
|
|
63
|
+
<ReachUi.TabPanels>
|
|
64
|
+
<ReachUi.TabPanel>
|
|
65
|
+
<Config />
|
|
66
|
+
</ReachUi.TabPanel>
|
|
67
|
+
<ReachUi.TabPanel>
|
|
68
|
+
<Playground_CodeBlock code={Config.codeExample} />
|
|
69
|
+
</ReachUi.TabPanel>
|
|
70
|
+
<ReachUi.TabPanel>
|
|
71
|
+
<Playground_CodeBlock code={Config.resi} />
|
|
72
|
+
</ReachUi.TabPanel>
|
|
73
|
+
</ReachUi.TabPanels>
|
|
74
|
+
</ReachUi.Tabs>
|
|
75
|
+
</div>
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
@react.component
|
|
80
|
+
let make = (~component: string) => {
|
|
81
|
+
PlaygroundRouter.Breadcrumb.use([
|
|
82
|
+
{
|
|
83
|
+
route: Hooks(List),
|
|
84
|
+
text: "Hooks"->React.string,
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
route: Hooks(Details(component)),
|
|
88
|
+
text: <span className="capitalize"> {`${component}`->React.string} </span>,
|
|
89
|
+
},
|
|
90
|
+
])
|
|
91
|
+
<div>
|
|
92
|
+
<h1 className="text-4xl font-bold font-display mb-4 capitalize">
|
|
93
|
+
{component->React.string}
|
|
94
|
+
</h1>
|
|
95
|
+
<div>
|
|
96
|
+
{components
|
|
97
|
+
->Array.getBy(((name, _)) => {
|
|
98
|
+
component->Js.String2.toLowerCase === name->Js.String2.toLowerCase
|
|
99
|
+
})
|
|
100
|
+
->Option.mapWithDefault("unknown"->React.string, ((_, playgroundModule)) => {
|
|
101
|
+
<Component component={playgroundModule} />
|
|
102
|
+
})}
|
|
103
|
+
</div>
|
|
104
|
+
</div>
|
|
105
|
+
}
|
|
106
|
+
}
|
|
@@ -6,10 +6,10 @@ module type Config = {
|
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
let components: array<(string, module(Config))> = [
|
|
9
|
-
("Clipboard", module(
|
|
10
|
-
("Disclosure", module(
|
|
11
|
-
("LazyLoad", module(
|
|
12
|
-
("MediaQueries", module(
|
|
9
|
+
("Clipboard", module(Playground_Hooks_Clipboard)),
|
|
10
|
+
("Disclosure", module(Playground_Hooks_Disclosure)),
|
|
11
|
+
("LazyLoad", module(Playground_Hooks_LazyLoad)),
|
|
12
|
+
("MediaQueries", module(Playground_Hooks_MediaQueries)),
|
|
13
13
|
]
|
|
14
14
|
|
|
15
15
|
module List = {
|
|
@@ -5,6 +5,9 @@ module RouterConfig = {
|
|
|
5
5
|
type hookRoutes =
|
|
6
6
|
| List
|
|
7
7
|
| Details(string)
|
|
8
|
+
type bindingRoutes =
|
|
9
|
+
| List
|
|
10
|
+
| Details(string)
|
|
8
11
|
type docRoutes =
|
|
9
12
|
| ApiDecoding
|
|
10
13
|
| Identifiers
|
|
@@ -22,6 +25,7 @@ module RouterConfig = {
|
|
|
22
25
|
| Components(componentRoutes)
|
|
23
26
|
| Hooks(hookRoutes)
|
|
24
27
|
| DesignSystem(designRoutes)
|
|
28
|
+
| Bindings(bindingRoutes)
|
|
25
29
|
| NotFound
|
|
26
30
|
|
|
27
31
|
let make = (url: RescriptReactRouter.url) => {
|
|
@@ -59,6 +63,12 @@ module RouterConfig = {
|
|
|
59
63
|
| list{component} => Hooks(Details(component))
|
|
60
64
|
| _ => NotFound
|
|
61
65
|
}
|
|
66
|
+
| list{"bindings", ...rest} =>
|
|
67
|
+
switch rest {
|
|
68
|
+
| list{} => Bindings(List)
|
|
69
|
+
| list{component} => Bindings(Details(component))
|
|
70
|
+
| _ => NotFound
|
|
71
|
+
}
|
|
62
72
|
|
|
63
73
|
| _ => NotFound
|
|
64
74
|
}
|
|
@@ -103,6 +113,14 @@ module RouterConfig = {
|
|
|
103
113
|
| Hooks(route) => {
|
|
104
114
|
let base = `${baseUrl}hooks`
|
|
105
115
|
|
|
116
|
+
switch route {
|
|
117
|
+
| List => `${base}`
|
|
118
|
+
| Details(component) => `${base}/${component}`
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
| Bindings(route) => {
|
|
122
|
+
let base = `${baseUrl}bindings`
|
|
123
|
+
|
|
106
124
|
switch route {
|
|
107
125
|
| List => `${base}`
|
|
108
126
|
| Details(component) => `${base}/${component}`
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
let resi = ""
|
|
2
|
+
|
|
3
|
+
@module("@root/playground/bindings/Playground_Bindings_Reach.res?raw")
|
|
4
|
+
external codeExample: string = "default"
|
|
5
|
+
|
|
6
|
+
module Menu = {
|
|
7
|
+
@react.component
|
|
8
|
+
let make = () => {
|
|
9
|
+
let (selected, setSelected) = React.useState(() => None)
|
|
10
|
+
<div>
|
|
11
|
+
<ReachUi.Menu>
|
|
12
|
+
<ReachUi.MenuButton>
|
|
13
|
+
<span className="border rounded-md bg-white px-2 text-neutral-700">
|
|
14
|
+
{"open menu"->React.string}
|
|
15
|
+
</span>
|
|
16
|
+
</ReachUi.MenuButton>
|
|
17
|
+
<ReachUi.MenuList
|
|
18
|
+
portal=true
|
|
19
|
+
className="focus:outline-none focus:shadow-none bg-white translate-x-[calc(-100%+31px)] shadow-lg rounded border border-gray-400 mt-1 py-1">
|
|
20
|
+
<ReachUi.MenuItem
|
|
21
|
+
className="py-1 px-2 flex items-center"
|
|
22
|
+
onSelect={() => {
|
|
23
|
+
setSelected(_ => Some("menu 1"))
|
|
24
|
+
}}>
|
|
25
|
+
{"Menu1"->React.string}
|
|
26
|
+
</ReachUi.MenuItem>
|
|
27
|
+
<ReachUi.MenuItem
|
|
28
|
+
className="py-1 px-2 flex items-center"
|
|
29
|
+
onSelect={() => {
|
|
30
|
+
setSelected(_ => Some("menu 2"))
|
|
31
|
+
}}>
|
|
32
|
+
{"Menu2"->React.string}
|
|
33
|
+
</ReachUi.MenuItem>
|
|
34
|
+
<ReachUi.MenuItem
|
|
35
|
+
className="py-1 px-2 flex items-center"
|
|
36
|
+
onSelect={() => {
|
|
37
|
+
setSelected(_ => Some("menu 3"))
|
|
38
|
+
}}>
|
|
39
|
+
{"Menu3"->React.string}
|
|
40
|
+
</ReachUi.MenuItem>
|
|
41
|
+
</ReachUi.MenuList>
|
|
42
|
+
</ReachUi.Menu>
|
|
43
|
+
{selected->Option.mapWithDefault(React.null, selected => {
|
|
44
|
+
<p> {("selected : " ++ selected)->React.string} </p>
|
|
45
|
+
})}
|
|
46
|
+
</div>
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
module Listbox = {
|
|
51
|
+
@react.component
|
|
52
|
+
let make = () => {
|
|
53
|
+
let (searchValue, setSearchValue) = React.useState(() => "")
|
|
54
|
+
let elements = [{"label": "element 1", "value": "1"}, {"label": "element 2", "value": "2"}]
|
|
55
|
+
|
|
56
|
+
<ReachUi.Listbox
|
|
57
|
+
onChange={v => Js.log(v)}
|
|
58
|
+
portal=false
|
|
59
|
+
className="searchListBox"
|
|
60
|
+
arrow={<ReactIcons.GrFormDown size=25 />}>
|
|
61
|
+
<input
|
|
62
|
+
type_="text"
|
|
63
|
+
placeholder="search placeholder"
|
|
64
|
+
value=searchValue
|
|
65
|
+
autoFocus=true
|
|
66
|
+
onChange={e => {
|
|
67
|
+
let value = (e->ReactEvent.Form.target)["value"]
|
|
68
|
+
setSearchValue(_ => value)
|
|
69
|
+
}}
|
|
70
|
+
style={ReactDOMStyle.make(~width=`calc(100% - 16px)`, ())}
|
|
71
|
+
className={cx(["m-2 bg-neutral-100 rounded-sm p-1 focus:shadow-none"])}
|
|
72
|
+
/>
|
|
73
|
+
<div className="listBoxOptionsContainer">
|
|
74
|
+
<ReachUi.ListboxOption value="default" className="hidden">
|
|
75
|
+
{"default text"->React.string}
|
|
76
|
+
</ReachUi.ListboxOption>
|
|
77
|
+
{elements
|
|
78
|
+
->Array.mapWithIndex((i, element) =>
|
|
79
|
+
<React.Fragment key={"searchListBox" ++ (element["value"] ++ i->string_of_int)}>
|
|
80
|
+
<ReachUi.ListboxOption
|
|
81
|
+
className={element["label"]
|
|
82
|
+
->Js.String.toLowerCase
|
|
83
|
+
->Js.String2.includes(searchValue->Js.String.toLowerCase)
|
|
84
|
+
? ""
|
|
85
|
+
: "hidden"}
|
|
86
|
+
value={element["value"]}>
|
|
87
|
+
{element["label"]->React.string}
|
|
88
|
+
</ReachUi.ListboxOption>
|
|
89
|
+
</React.Fragment>
|
|
90
|
+
)
|
|
91
|
+
->React.array}
|
|
92
|
+
</div>
|
|
93
|
+
</ReachUi.Listbox>
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
module AlertDialog = {
|
|
98
|
+
@react.component
|
|
99
|
+
let make = () => {
|
|
100
|
+
let leastDestructiveRef = React.useRef(Js.Nullable.null)
|
|
101
|
+
let disclosure = Toolkit__Hooks.useDisclosure()
|
|
102
|
+
|
|
103
|
+
<>
|
|
104
|
+
<Toolkit__Ui_Button onClick={_ => disclosure.show()}>
|
|
105
|
+
{"show alert dialog"->React.string}
|
|
106
|
+
</Toolkit__Ui_Button>
|
|
107
|
+
<ReachUi.AlertDialog
|
|
108
|
+
isOpen=disclosure.isOpen onDismiss={_ => disclosure.hide()} leastDestructiveRef>
|
|
109
|
+
<Toolkit__Ui_Card>
|
|
110
|
+
<Toolkit__Ui_Card.Header>
|
|
111
|
+
<ReachUi.AlertDialogLabel> {"label"->React.string} </ReachUi.AlertDialogLabel>
|
|
112
|
+
</Toolkit__Ui_Card.Header>
|
|
113
|
+
<Toolkit__Ui_Card.Body>
|
|
114
|
+
<Toolkit__Ui_Button
|
|
115
|
+
buttonRef={ReactDOM.Ref.domRef(leastDestructiveRef)}
|
|
116
|
+
className="mr-4"
|
|
117
|
+
onClick={_ => disclosure.hide()}>
|
|
118
|
+
{"close"->React.string}
|
|
119
|
+
</Toolkit__Ui_Button>
|
|
120
|
+
</Toolkit__Ui_Card.Body>
|
|
121
|
+
</Toolkit__Ui_Card>
|
|
122
|
+
</ReachUi.AlertDialog>
|
|
123
|
+
</>
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
@react.component
|
|
128
|
+
let make = () => {
|
|
129
|
+
<div className="flex flex-col gap-6">
|
|
130
|
+
<div>
|
|
131
|
+
<h2> {"Menu"->React.string} </h2>
|
|
132
|
+
<Menu />
|
|
133
|
+
</div>
|
|
134
|
+
<div>
|
|
135
|
+
<h2> {"Listbox"->React.string} </h2>
|
|
136
|
+
<Listbox />
|
|
137
|
+
</div>
|
|
138
|
+
<div>
|
|
139
|
+
<h2> {"AlertDialog"->React.string} </h2>
|
|
140
|
+
<AlertDialog />
|
|
141
|
+
</div>
|
|
142
|
+
</div>
|
|
143
|
+
}
|
|
@@ -6,12 +6,20 @@ let resi = ""
|
|
|
6
6
|
external codeExample: string = "default"
|
|
7
7
|
|
|
8
8
|
module ReformTest = {
|
|
9
|
+
@val
|
|
10
|
+
external alert: string => unit = "alert"
|
|
11
|
+
|
|
12
|
+
type userRole = [
|
|
13
|
+
| #user
|
|
14
|
+
| #admin
|
|
15
|
+
]
|
|
9
16
|
module FormState = {
|
|
10
17
|
type error = unit
|
|
11
18
|
include %lenses(
|
|
12
19
|
type state = {
|
|
13
20
|
login: string,
|
|
14
21
|
password: string,
|
|
22
|
+
role: option<userRole>,
|
|
15
23
|
}
|
|
16
24
|
)
|
|
17
25
|
}
|
|
@@ -20,7 +28,27 @@ module ReformTest = {
|
|
|
20
28
|
|
|
21
29
|
@react.component
|
|
22
30
|
let make = () => {
|
|
23
|
-
let form = FormApi.Form.use(
|
|
31
|
+
let form = FormApi.Form.use(
|
|
32
|
+
~initialState={login: "", password: "", role: None},
|
|
33
|
+
~schema=FormApi.Form.Validation.Schema([
|
|
34
|
+
StringNonEmpty(Login),
|
|
35
|
+
StringNonEmpty(Password),
|
|
36
|
+
Custom(
|
|
37
|
+
Role,
|
|
38
|
+
({role}) => {
|
|
39
|
+
switch role {
|
|
40
|
+
| None => Error("Please select a role")
|
|
41
|
+
| Some(_) => Valid
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
),
|
|
45
|
+
]),
|
|
46
|
+
~onSubmit=form => {
|
|
47
|
+
alert(form.state.values->Obj.magic->Js.Json.stringifyWithSpace(2))
|
|
48
|
+
Promise.resolved(Ok())
|
|
49
|
+
},
|
|
50
|
+
(),
|
|
51
|
+
)
|
|
24
52
|
|
|
25
53
|
<ReactIntl.IntlProvider>
|
|
26
54
|
<FormApi.Form.Provider value=form>
|
|
@@ -36,6 +64,31 @@ module ReformTest = {
|
|
|
36
64
|
type_="password"
|
|
37
65
|
/>
|
|
38
66
|
</div>
|
|
67
|
+
<div>
|
|
68
|
+
<FormApi.SelectPolyvariant
|
|
69
|
+
field={FormState.Role}
|
|
70
|
+
id="kind"
|
|
71
|
+
placeholder="Select a role"
|
|
72
|
+
options=[
|
|
73
|
+
{
|
|
74
|
+
label: "User",
|
|
75
|
+
value: #user,
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
label: "Admin",
|
|
79
|
+
value: #admin,
|
|
80
|
+
},
|
|
81
|
+
]
|
|
82
|
+
encodeValueToString={(v: userRole) => {(v :> string)}}
|
|
83
|
+
decodeValueFromString={v =>
|
|
84
|
+
switch v {
|
|
85
|
+
| "admin" => Some(#admin)
|
|
86
|
+
| "user" => Some(#user)
|
|
87
|
+
| _ => None
|
|
88
|
+
}}
|
|
89
|
+
/>
|
|
90
|
+
</div>
|
|
91
|
+
<Toolkit__Ui_Button type_="submit"> {"Submit"->React.string} </Toolkit__Ui_Button>
|
|
39
92
|
</FormApi.Wrapper>
|
|
40
93
|
</FormApi.Form.Provider>
|
|
41
94
|
</ReactIntl.IntlProvider>
|
|
@@ -43,7 +96,7 @@ module ReformTest = {
|
|
|
43
96
|
}
|
|
44
97
|
|
|
45
98
|
module DayPickerExample = {
|
|
46
|
-
open
|
|
99
|
+
open ReactDayPicker
|
|
47
100
|
|
|
48
101
|
@react.component
|
|
49
102
|
let make = () => {
|
|
@@ -111,7 +164,7 @@ let make = () => {
|
|
|
111
164
|
</div>
|
|
112
165
|
<div>
|
|
113
166
|
<h2> {"DayPickerInput"->React.string} </h2>
|
|
114
|
-
<
|
|
167
|
+
<ReactDayPicker.ReactDayPicker.DayPickerInput showOutsideDays=true firstDayOfWeek=1 />
|
|
115
168
|
</div>
|
|
116
169
|
<div>
|
|
117
170
|
<h2> {"NativeDatePicker"->React.string} </h2>
|
|
@@ -23,9 +23,12 @@ let make = () => {
|
|
|
23
23
|
id="size"
|
|
24
24
|
value={Obj.magic(size)}
|
|
25
25
|
onChange={value => {
|
|
26
|
-
setSize(_ => value)
|
|
26
|
+
setSize(_ => value->Obj.magic)
|
|
27
27
|
}}
|
|
28
|
-
options={modalSize->Array.map(
|
|
28
|
+
options={modalSize->Array.map((value): Toolkit__Ui.Select.selectOption => {
|
|
29
|
+
label: value->Obj.magic,
|
|
30
|
+
value: value->Obj.magic,
|
|
31
|
+
})}
|
|
29
32
|
/>
|
|
30
33
|
</div>
|
|
31
34
|
<div>
|
|
@@ -35,9 +38,21 @@ let make = () => {
|
|
|
35
38
|
onChange={value => {
|
|
36
39
|
setModalType(_ => value === "" ? #default : #colored(Obj.magic(value)))
|
|
37
40
|
}}
|
|
38
|
-
options={
|
|
39
|
-
|
|
40
|
-
|
|
41
|
+
options={
|
|
42
|
+
open! Toolkit__Ui.Select
|
|
43
|
+
|
|
44
|
+
[
|
|
45
|
+
{
|
|
46
|
+
label: "default",
|
|
47
|
+
value: "",
|
|
48
|
+
},
|
|
49
|
+
]->Array.concat(
|
|
50
|
+
modalColor->Array.map(value => {
|
|
51
|
+
label: value->Obj.magic,
|
|
52
|
+
value: value->Obj.magic,
|
|
53
|
+
}),
|
|
54
|
+
)
|
|
55
|
+
}
|
|
41
56
|
/>
|
|
42
57
|
</div>
|
|
43
58
|
<Button onClick={_ => setVisibility(_ => true)}> {"Show modal"->React.string} </Button>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
open Toolkit__Ui
|
|
2
|
-
open
|
|
2
|
+
open ReactSelect
|
|
3
3
|
|
|
4
4
|
@module("@root/src/ui/Toolkit__Ui_Select.resi?raw")
|
|
5
5
|
external resi: string = "default"
|
|
@@ -25,9 +25,19 @@ let make = () => {
|
|
|
25
25
|
id="test"
|
|
26
26
|
placeholder="This is a placeholder"
|
|
27
27
|
options=[
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
{
|
|
29
|
+
label: "Label1",
|
|
30
|
+
value: "1",
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
label: "Label2",
|
|
34
|
+
value: "2",
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
label: "Label3 disabled",
|
|
38
|
+
value: "3",
|
|
39
|
+
disabled: true,
|
|
40
|
+
},
|
|
31
41
|
]
|
|
32
42
|
/>
|
|
33
43
|
</div>
|
|
@@ -19,7 +19,7 @@ module Date = {
|
|
|
19
19
|
type date = Js.Date.t
|
|
20
20
|
|
|
21
21
|
let encoder: Decco.encoder<date> = date =>
|
|
22
|
-
date->
|
|
22
|
+
date->DateFns.formatWithPattern("yyyy-MM-dd")->Decco.stringToJson
|
|
23
23
|
|
|
24
24
|
let decoder: Decco.decoder<date> = json =>
|
|
25
25
|
switch Decco.stringFromJson(json) {
|