@colisweb/rescript-toolkit 2.67.1 → 2.68.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.
Files changed (31) hide show
  1. package/.yarn/install-state.gz +0 -0
  2. package/package.json +1 -1
  3. package/playground/PlaygroundComponents.res +10 -0
  4. package/playground/PlaygroundRouter.res +14 -6
  5. package/playground/components/Playground_Accordion.res +31 -0
  6. package/playground/components/Playground_Alert.res +25 -0
  7. package/playground/components/Playground_Button.res +75 -0
  8. package/playground/components/Playground_ButtonGroup.res +40 -0
  9. package/playground/components/Playground_Label.res +16 -0
  10. package/playground/components/Playground_Modal.res +53 -0
  11. package/playground/components/Playground_MultiSelect.res +91 -0
  12. package/playground/components/Playground_Notice.res +34 -0
  13. package/playground/components/Playground_Snackbar.res +43 -0
  14. package/playground/components/Playground_Spinner.res +48 -0
  15. package/playground/components/Playground_Switch.res +2 -2
  16. package/playground/custom.css +4 -1
  17. package/playground/docs/Setup.mdx +3 -10
  18. package/src/router/Toolkit__Router.res +2 -1
  19. package/src/ui/Toolkit__Ui_MultiSelect.res +21 -0
  20. package/src/ui/styles.css +6 -3
  21. package/vite.config.js +2 -1
  22. package/playground/stories/Toolkit__UI_AccordionStory.res +0 -34
  23. package/playground/stories/Toolkit__UI_AlertStory.res +0 -111
  24. package/playground/stories/Toolkit__UI_LabelStory.res +0 -39
  25. package/playground/stories/Toolkit__UI_ModalStory.res +0 -211
  26. package/playground/stories/Toolkit__UI_MultiSelectStory.res +0 -132
  27. package/playground/stories/Toolkit__UI_NoticeStory.res +0 -66
  28. package/playground/stories/Toolkit__UI_SnackbarStory.res +0 -209
  29. package/playground/stories/Toolkit__UI_SpinnerStory.res +0 -65
  30. package/playground/stories/Toolkit__Ui_ButtonGroupStory.res +0 -77
  31. package/playground/stories/Toolkit__Ui_ButtonStory.res +0 -324
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@colisweb/rescript-toolkit",
3
- "version": "2.67.1",
3
+ "version": "2.68.1",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "clean": "rescript clean",
@@ -8,6 +8,16 @@ module type Config = {
8
8
  let components: array<(string, module(Config))> = [
9
9
  ("card", module(Playground_Card)),
10
10
  ("switch", module(Playground_Switch)),
11
+ ("button", module(Playground_Button)),
12
+ ("label", module(Playground_Label)),
13
+ ("alert", module(Playground_Alert)),
14
+ ("modal", module(Playground_Modal)),
15
+ ("multiselect", module(Playground_MultiSelect)),
16
+ ("accordion", module(Playground_Accordion)),
17
+ ("buttonGroup", module(Playground_ButtonGroup)),
18
+ ("spinner", module(Playground_Spinner)),
19
+ ("notice", module(Playground_Notice)),
20
+ ("snackbar", module(Playground_Snackbar)),
11
21
  ]
12
22
 
13
23
  module List = {
@@ -21,7 +21,12 @@ module RouterConfig = {
21
21
  | NotFound
22
22
 
23
23
  let make = (url: RescriptReactRouter.url) => {
24
- switch url.path {
24
+ let path = switch url.path {
25
+ | list{"colisweb-open-source", "rescript-toolkit", ...routes} => routes
26
+ | path => path
27
+ }
28
+
29
+ switch path {
25
30
  | list{} => Home
26
31
  | list{"docs", ...rest} =>
27
32
  switch rest {
@@ -49,11 +54,14 @@ module RouterConfig = {
49
54
  }
50
55
  }
51
56
 
57
+ @val
58
+ external baseUrl: string = "import.meta.env.BASE_URL"
59
+
52
60
  let toString = (route: t) =>
53
61
  switch route {
54
- | Home => "/"
62
+ | Home => baseUrl
55
63
  | Docs(doc) => {
56
- let base = "/docs"
64
+ let base = `${baseUrl}docs`
57
65
 
58
66
  switch doc {
59
67
  | ApiDecoding => `${base}/api-decoding`
@@ -64,7 +72,7 @@ module RouterConfig = {
64
72
  }
65
73
 
66
74
  | DesignSystem(designRoute) => {
67
- let base = "/design"
75
+ let base = `${baseUrl}design`
68
76
 
69
77
  switch designRoute {
70
78
  | Fonts => `${base}/fonts`
@@ -74,7 +82,7 @@ module RouterConfig = {
74
82
  }
75
83
 
76
84
  | Components(route) => {
77
- let base = "/components"
85
+ let base = `${baseUrl}components`
78
86
 
79
87
  switch route {
80
88
  | List => `${base}`
@@ -82,7 +90,7 @@ module RouterConfig = {
82
90
  }
83
91
  }
84
92
 
85
- | NotFound => "/404"
93
+ | NotFound => `${baseUrl}404`
86
94
  }
87
95
  }
88
96
 
@@ -0,0 +1,31 @@
1
+ open ReachUi
2
+
3
+ let resi = ""
4
+
5
+ @module("@root/playground/components/Playground_Accordion.res?raw")
6
+ external codeExample: string = "default"
7
+
8
+ @react.component
9
+ let make = () =>
10
+ <div>
11
+ <Accordion>
12
+ <AccordionItem>
13
+ {"title"->React.string}
14
+ <AccordionButton>
15
+ <span className="cw-accordion-icon">
16
+ <BsReactIcons.MdKeyboardArrowRight />
17
+ </span>
18
+ </AccordionButton>
19
+ <AccordionPanel> {"content"->React.string} </AccordionPanel>
20
+ </AccordionItem>
21
+ <AccordionItem>
22
+ <AccordionButton className="flex items-center">
23
+ {"title"->React.string}
24
+ <span className="cw-accordion-icon">
25
+ <BsReactIcons.MdKeyboardArrowRight />
26
+ </span>
27
+ </AccordionButton>
28
+ <AccordionPanel> {"content"->React.string} </AccordionPanel>
29
+ </AccordionItem>
30
+ </Accordion>
31
+ </div>
@@ -0,0 +1,25 @@
1
+ open Toolkit__Ui
2
+
3
+ @module("@root/src/ui/Toolkit__Ui_Alert.resi?raw")
4
+ external resi: string = "default"
5
+
6
+ @module("@root/playground/components/Playground_Alert.res?raw")
7
+ external codeExample: string = "default"
8
+
9
+ @react.component
10
+ let make = () => {
11
+ let variants: array<Alert.status> = [#success, #error, #info, #warning]
12
+
13
+ <div className="flex flex-col gap-8">
14
+ {variants
15
+ ->Array.map(variant => {
16
+ <div key={(variant :> string)}>
17
+ <h3> {(variant :> string)->React.string} </h3>
18
+ <Alert
19
+ title={"Title"->React.string} description={"Description"->React.string} status=variant
20
+ />
21
+ </div>
22
+ })
23
+ ->React.array}
24
+ </div>
25
+ }
@@ -0,0 +1,75 @@
1
+ @module("@root/src/ui/Toolkit__Ui_Button.resi?raw")
2
+ external resi: string = "default"
3
+
4
+ @module("@root/playground/components/Playground_Button.res?raw")
5
+ external codeExample: string = "default"
6
+
7
+ @react.component
8
+ let make = () => {
9
+ let colors: array<Toolkit__Ui_Button.color> = [
10
+ #primary,
11
+ #black,
12
+ #white,
13
+ #gray,
14
+ #success,
15
+ #info,
16
+ #danger,
17
+ #warning,
18
+ #neutral,
19
+ #neutralLight,
20
+ ]
21
+
22
+ let sizes = Js.Dict.fromArray([("xs", #xs), ("sm", #sm), ("md", #md), ("lg", #lg)])
23
+ let variants = Js.Dict.fromArray([
24
+ ("default", #default),
25
+ ("text", #text),
26
+ ("link", #link),
27
+ ("outline", #outline),
28
+ ("pill", #pill),
29
+ ])
30
+
31
+ <div>
32
+ {colors
33
+ ->Array.mapWithIndex((i, color) =>
34
+ <div
35
+ key={i->Int.toString ++ (color :> string)}
36
+ className="flex flex-col gap-4 first:border-0 border-t pt-4 first:pt-0 border-neutral-500">
37
+ <h2> {(color :> string)->React.string} </h2>
38
+ <div className="flex flex-row flex-wrap gap-8">
39
+ {variants
40
+ ->Js.Dict.entries
41
+ ->Array.map(((variantText, variant)) => {
42
+ <div>
43
+ <h4> {variantText->React.string} </h4>
44
+ <div className="flex flex-col">
45
+ {[false, true]
46
+ ->Array.mapWithIndex(
47
+ (j, disabled) =>
48
+ <div className="flex items-center gap-1 mb-2">
49
+ {sizes
50
+ ->Js.Dict.entries
51
+ ->Array.mapWithIndex(
52
+ (k, (sizeText, size)) =>
53
+ <div
54
+ key={(i + j + k)->Int.toString ++ ((color :> string) ++ sizeText)}
55
+ className="flex flex-col justify-center items-center">
56
+ <Toolkit__Ui_Button variant color size disabled>
57
+ {"hello"->React.string}
58
+ </Toolkit__Ui_Button>
59
+ <span className="text-xxs"> {sizeText->React.string} </span>
60
+ </div>,
61
+ )
62
+ ->React.array}
63
+ </div>,
64
+ )
65
+ ->React.array}
66
+ </div>
67
+ </div>
68
+ })
69
+ ->React.array}
70
+ </div>
71
+ </div>
72
+ )
73
+ ->React.array}
74
+ </div>
75
+ }
@@ -0,0 +1,40 @@
1
+ @module("@root/src/ui/Toolkit__Ui_ButtonGroup.resi?raw")
2
+ external resi: string = "default"
3
+
4
+ @module("@root/playground/components/Playground_ButtonGroup.res?raw")
5
+ external codeExample: string = "default"
6
+
7
+ @react.component
8
+ let make = () => {
9
+ let sizes = Js.Dict.fromArray([("md", #md), ("lg", #xl)])
10
+
11
+ let (selectedOption, setSelectedOption) = React.useState(() => #option1)
12
+
13
+ <div>
14
+ {sizes
15
+ ->Js.Dict.entries
16
+ ->Array.mapWithIndex((i, (sizeText, size)) =>
17
+ <div key={i->Int.toString ++ sizeText} className="flex flex-row mb-4 items-center">
18
+ <strong className="w-40"> {sizeText->React.string} </strong>
19
+ <Toolkit__Ui_ButtonGroup className="my-4 self-center" size>
20
+ <button
21
+ className={selectedOption === #option1 ? "selected" : ""}
22
+ onClick={_ => setSelectedOption(_ => #option1)}>
23
+ {"Option 1"->React.string}
24
+ </button>
25
+ <button
26
+ className={selectedOption === #option2 ? "selected" : ""}
27
+ onClick={_ => setSelectedOption(_ => #option2)}>
28
+ {"Option 2"->React.string}
29
+ </button>
30
+ <button
31
+ className={selectedOption === #option3 ? "selected" : ""}
32
+ onClick={_ => setSelectedOption(_ => #option3)}>
33
+ {"Option 3"->React.string}
34
+ </button>
35
+ </Toolkit__Ui_ButtonGroup>
36
+ </div>
37
+ )
38
+ ->React.array}
39
+ </div>
40
+ }
@@ -0,0 +1,16 @@
1
+ open Toolkit__Ui
2
+
3
+ @module("@root/src/ui/Toolkit__Ui_Label.resi?raw")
4
+ external resi: string = "default"
5
+
6
+ @module("@root/playground/components/Playground_Label.res?raw")
7
+ external codeExample: string = "default"
8
+
9
+ @react.component
10
+ let make = () =>
11
+ <div>
12
+ <Label htmlFor="test"> {"Label"->React.string} </Label>
13
+ <Label htmlFor="test" optionalMessage={"Optional"->React.string}>
14
+ {"Label"->React.string}
15
+ </Label>
16
+ </div>
@@ -0,0 +1,53 @@
1
+ open Toolkit__Ui
2
+
3
+ @module("@root/src/ui/Toolkit__Ui_Modal.resi?raw")
4
+ external resi: string = "default"
5
+
6
+ @module("@root/playground/components/Playground_Modal.res?raw")
7
+ external codeExample: string = "default"
8
+
9
+ @react.component
10
+ let make = () => {
11
+ let modalSize: array<Modal.size> = [#lg, #md, #sm, #xs]
12
+
13
+ let modalColor: array<Modal.color> = [#primary, #success, #danger, #neutral]
14
+
15
+ let (isVisible, setVisibility) = React.useState(() => false)
16
+ let (size, setSize) = React.useState(() => #md)
17
+ let (modalType, setModalType) = React.useState(() => #default)
18
+
19
+ <div className="flex flex-col gap-4 items-start">
20
+ <div>
21
+ <Toolkit__Ui_Label htmlFor="size"> {"Size :"->React.string} </Toolkit__Ui_Label>
22
+ <Toolkit__Ui.Select
23
+ id="size"
24
+ value={Obj.magic(size)}
25
+ onChange={value => {
26
+ setSize(_ => value)
27
+ }}
28
+ options={modalSize->Array.map(value => (value->Obj.magic, value->Obj.magic, true))}
29
+ />
30
+ </div>
31
+ <div>
32
+ <Toolkit__Ui_Label htmlFor="color"> {"Color :"->React.string} </Toolkit__Ui_Label>
33
+ <Toolkit__Ui.Select
34
+ id="size"
35
+ onChange={value => {
36
+ setModalType(_ => value === "" ? #default : #colored(Obj.magic(value)))
37
+ }}
38
+ options={[("default", "", true)]->Array.concat(
39
+ modalColor->Array.map(value => (value->Obj.magic, value->Obj.magic, true)),
40
+ )}
41
+ />
42
+ </div>
43
+ <Button onClick={_ => setVisibility(_ => true)}> {"Show modal"->React.string} </Button>
44
+ <Modal
45
+ isVisible
46
+ title={"title"->React.string}
47
+ body={"Body"->React.string}
48
+ hide={() => setVisibility(_ => false)}
49
+ size
50
+ type_=modalType
51
+ />
52
+ </div>
53
+ }
@@ -0,0 +1,91 @@
1
+ @module("@root/src/ui/Toolkit__Ui_MultiSelect.resi?raw")
2
+ external resi: string = "default"
3
+
4
+ @module("@root/playground/components/Playground_MultiSelect.res?raw")
5
+ external codeExample: string = "default"
6
+
7
+ @react.component
8
+ let make = () => {
9
+ let options1: array<Toolkit__Ui_MultiSelect.item> = [
10
+ {
11
+ itemLabel: <p className="flex flex-row text-danger-500">
12
+ <BsReactIcons.FaAngleDown />
13
+ {"test"->React.string}
14
+ </p>,
15
+ label: "Test",
16
+ value: "test",
17
+ },
18
+ {
19
+ itemLabel: <p> {"test2"->React.string} </p>,
20
+ label: "Test2",
21
+ value: "test2",
22
+ },
23
+ {
24
+ itemLabel: <p> {"test3"->React.string} </p>,
25
+ label: "Test3",
26
+ value: "test3",
27
+ },
28
+ {
29
+ itemLabel: <p> {"test4"->React.string} </p>,
30
+ label: "Test4",
31
+ value: "test4",
32
+ },
33
+ ]
34
+ let options2: array<Toolkit__Ui_MultiSelect.item> = [
35
+ {
36
+ itemLabel: <p> {"test4"->React.string} </p>,
37
+ label: "Test4",
38
+ value: "test4",
39
+ },
40
+ ]
41
+
42
+ let tmp = Toolkit__Hooks.useDisclosure()
43
+
44
+ let options = tmp.isOpen ? options2 : options1
45
+
46
+ <div className="flex flex-col gap-8 items-start">
47
+ <Toolkit__Ui_Button onClick={_ => tmp.toggle()}>
48
+ {"Change options"->React.string}
49
+ </Toolkit__Ui_Button>
50
+ <Toolkit__Ui_MultiSelect
51
+ searchPlaceholder="Filter"
52
+ buttonClassName={"w-48"}
53
+ dropdownClassName="w-60"
54
+ placeholder={<span> {"Select me"->React.string} </span>}
55
+ onChange={Js.log}
56
+ options
57
+ />
58
+ <div>
59
+ <h3 className="mb-2"> {"Preselected options"->React.string} </h3>
60
+ <Toolkit__Ui_MultiSelect
61
+ searchPlaceholder="Filter"
62
+ buttonClassName={"w-48"}
63
+ dropdownClassName="w-60"
64
+ defaultValue={options}
65
+ placeholder={<span> {"Select me"->React.string} </span>}
66
+ onChange={Js.log}
67
+ options
68
+ />
69
+ </div>
70
+ <div>
71
+ <h3 className="mb-2"> {"Search"->React.string} </h3>
72
+ <p className="mb-1">
73
+ {"Search input is displayed when there are more than 5 options"->React.string}
74
+ </p>
75
+ <Toolkit__Ui_MultiSelect
76
+ searchPlaceholder="Filter"
77
+ buttonClassName={"w-48"}
78
+ dropdownClassName="w-60 max-h-[300px] overflow-auto"
79
+ options={Array.makeBy(10, (i): Toolkit__Ui.MultiSelect.item => {
80
+ {
81
+ itemLabel: <p> {`label ${i->Int.toString}`->React.string} </p>,
82
+ label: `label ${i->Int.toString}`,
83
+ value: `label ${i->Int.toString}`,
84
+ }
85
+ })}
86
+ placeholder={<span> {"Select me"->React.string} </span>}
87
+ onChange={Js.log}
88
+ />
89
+ </div>
90
+ </div>
91
+ }
@@ -0,0 +1,34 @@
1
+ open Toolkit__Ui
2
+
3
+ @module("@root/src/ui/Toolkit__Ui_Notice.resi?raw")
4
+ external resi: string = "default"
5
+
6
+ @module("@root/playground/components/Playground_Notice.res?raw")
7
+ external codeExample: string = "default"
8
+
9
+ @react.component
10
+ let make = () => {
11
+ let pRef = React.useRef(Js.Nullable.null)
12
+ let noticeRef2 = React.useRef(Js.Nullable.null)
13
+ let (noticeVisible1, setNoticeVisible1) = React.useState(() => false)
14
+ let (noticeVisible2, setNoticeVisible2) = React.useState(() => false)
15
+
16
+ <div>
17
+ <div className="flex flex-row items-center">
18
+ <Button onClick={_ => setNoticeVisible1(v => !v)}> {"Toggle notice 1"->React.string} </Button>
19
+ <Button onClick={_ => setNoticeVisible2(v => !v)}> {"Toggle notice 2"->React.string} </Button>
20
+ </div>
21
+ <p className="text-center" ref={ReactDOM.Ref.domRef(pRef)}>
22
+ {"example notice 1"->React.string}
23
+ </p>
24
+ <div ref={ReactDOM.Ref.domRef(noticeRef2)} className="w-40 h-40 bg-danger-300 ml-20 mt-20">
25
+ {"notice 2"->React.string}
26
+ </div>
27
+ <Notice visible=noticeVisible1 baseElementRef=pRef className="bg-info-700 p-2 rounded">
28
+ <p className="text-white"> {"Some text there"->React.string} </p>
29
+ </Notice>
30
+ <Notice visible=noticeVisible2 baseElementRef=noticeRef2 className="bg-info-700 p-2 rounded">
31
+ <p className="text-white"> {"Some text there"->React.string} </p>
32
+ </Notice>
33
+ </div>
34
+ }
@@ -0,0 +1,43 @@
1
+ open Toolkit__Ui
2
+
3
+ @module("@root/src/ui/Toolkit__Ui_Snackbar.resi?raw")
4
+ external resi: string = "default"
5
+
6
+ @module("@root/playground/components/Playground_Snackbar.res?raw")
7
+ external codeExample: string = "default"
8
+
9
+ @react.component
10
+ let make = () => {
11
+ let variants: array<Toolkit__Ui_Snackbar.variant> = [#success, #warning, #danger]
12
+
13
+ <div>
14
+ <Snackbar.Provider />
15
+ <div className="flex flex-col gap-4">
16
+ {variants
17
+ ->Array.map(variant => {
18
+ let variantAsString = (variant :> string)
19
+
20
+ <div className="flex flex-row gap-4">
21
+ <span>
22
+ <Button onClick={_ => Snackbar.show(~title=variantAsString, ~variant, ())->ignore}>
23
+ {`Trigger ${variantAsString} variant`->React.string}
24
+ </Button>
25
+ </span>
26
+ <span>
27
+ <Button
28
+ onClick={_ =>
29
+ Snackbar.show(
30
+ ~title=variantAsString,
31
+ ~content="Description"->React.string,
32
+ ~variant,
33
+ (),
34
+ )->ignore}>
35
+ {`Trigger ${variantAsString} variant with description`->React.string}
36
+ </Button>
37
+ </span>
38
+ </div>
39
+ })
40
+ ->React.array}
41
+ </div>
42
+ </div>
43
+ }
@@ -0,0 +1,48 @@
1
+ open Toolkit__Ui
2
+
3
+ @module("@root/src/ui/Toolkit__Ui_Spinner.resi?raw")
4
+ external resi: string = "default"
5
+
6
+ @module("@root/playground/components/Playground_Spinner.res?raw")
7
+ external codeExample: string = "default"
8
+
9
+ @react.component
10
+ let make = () => {
11
+ let colors = Js.Dict.fromArray([
12
+ ("current", #current),
13
+ ("black", #black),
14
+ ("white", #white),
15
+ ("gray", #gray),
16
+ ("success", #success),
17
+ ("primary", #primary),
18
+ ("warning", #warning),
19
+ ("info", #info),
20
+ ("danger", #danger),
21
+ ])
22
+
23
+ let sizes = Js.Dict.fromArray([("sm", #sm), ("md", #md), ("lg", #lg), ("xl", #xl)])
24
+
25
+ <div>
26
+ {colors
27
+ ->Js.Dict.entries
28
+ ->Array.mapWithIndex((i, (colorText, color)) =>
29
+ <div key={i->Int.toString ++ colorText} className="flex flex-row items-center">
30
+ <strong className="w-40"> {colorText->React.string} </strong>
31
+ <div className="flex flex-row items-center gap-8 mb-4">
32
+ {sizes
33
+ ->Js.Dict.entries
34
+ ->Array.mapWithIndex((k, (sizeText, size)) =>
35
+ <div
36
+ key={(i + k)->Int.toString ++ (colorText ++ sizeText)}
37
+ className="flex flex-col items-center">
38
+ <Spinner color size />
39
+ <span className="text-xxs"> {sizeText->React.string} </span>
40
+ </div>
41
+ )
42
+ ->React.array}
43
+ </div>
44
+ </div>
45
+ )
46
+ ->React.array}
47
+ </div>
48
+ }
@@ -1,9 +1,9 @@
1
1
  open Toolkit__Ui
2
2
 
3
- @module("../../../../src/ui/Toolkit__Ui_Switch.resi?raw")
3
+ @module("@root/src/ui/Toolkit__Ui_Switch.resi?raw")
4
4
  external resi: string = "default"
5
5
 
6
- @module("../../../../playground/components/Playground_Switch.res?raw")
6
+ @module("@root/playground/components/Playground_Switch.res?raw")
7
7
  external codeExample: string = "default"
8
8
 
9
9
  @react.component
@@ -155,9 +155,12 @@
155
155
  }
156
156
 
157
157
  h2 {
158
- @apply text-2xl font-display font-bold;
158
+ @apply text-3xl font-display font-bold;
159
159
  }
160
160
  h3 {
161
+ @apply text-2xl font-display font-bold;
162
+ }
163
+ h4 {
161
164
  @apply text-xl font-display font-bold;
162
165
  }
163
166
 
@@ -30,16 +30,15 @@ We share a postcss config that you can include to your webpack config
30
30
 
31
31
  ## Usage
32
32
 
33
- The bindings in the _vendors_ are **globaly accessible**. Everything else is scoped into the `Toolkit` namespace.
33
+ The bindings in the _vendors_ are **globaly accessible**.
34
34
 
35
35
  ```rescript
36
- open Toolkit;
37
36
 
38
37
  @react.component
39
38
  let make = () => {
40
- let dialog = Hooks.useDisclosure();
39
+ let dialog = Toolkit.Hooks.useDisclosure();
41
40
 
42
- <div className=Tw.(style([bgWhite])) />
41
+ <div className="bg-white" />
43
42
  };
44
43
  ```
45
44
 
@@ -50,9 +49,3 @@ Run bsb
50
49
  ```bash
51
50
  npm run dev
52
51
  ```
53
-
54
- Run storybook
55
-
56
- ```bash
57
- npm run storybook
58
- ```
@@ -252,7 +252,7 @@ module Make = (Config: RouterConfig) => {
252
252
  <a
253
253
  href=url
254
254
  target="_blank"
255
- className={cx([commonClassName, "sidenav-link", isSubLink ? "ml-3" : ""])}>
255
+ className={cx([commonClassName, "py-3 sidenav-link", isSubLink ? "ml-3" : ""])}>
256
256
  <span className="overflow-hidden flex">
257
257
  {config.icon->Option.mapWithDefault(React.null, icon =>
258
258
  <div className={cx(["text-neutral-800", isNavOpen ? "pl-2" : "px-2"])}> icon </div>
@@ -280,6 +280,7 @@ module Make = (Config: RouterConfig) => {
280
280
  className={cx([
281
281
  commonClassName,
282
282
  isSubLink ? "ml-3" : "",
283
+ config.icon->Option.isNone ? "py-5" : "",
283
284
  "sidenav-link",
284
285
  isActive ? "bg-primary-100/75 text-neutral-700" : "",
285
286
  ])}
@@ -36,6 +36,18 @@ let make = (
36
36
  None
37
37
  }, (previousDefaultValue, defaultValue))
38
38
 
39
+ let filterOptionsBySearch = (~options, ~search) => {
40
+ options->Array.keep(({label}) =>
41
+ // normalize nfd -> replace by re remove split by commponents the accent letters and deletes the accent component only, leaving the un-accented letter
42
+ search == "" ||
43
+ label
44
+ ->Js.String2.toLowerCase
45
+ ->Js.String2.normalizeByForm("NFD")
46
+ ->Js.String2.replaceByRe(%re("/[\u0300-\u036f]/g"), "")
47
+ ->Js.String2.includes(search)
48
+ )
49
+ }
50
+
39
51
  <Toolkit__Ui_Dropdown
40
52
  buttonClassName
41
53
  dropdownClassName
@@ -64,6 +76,15 @@ let make = (
64
76
  id="search"
65
77
  autoFocus={true}
66
78
  placeholder=?{searchPlaceholder}
79
+ onKeyDown={event => {
80
+ if event->ReactEvent.Keyboard.key === "Enter" && search !== "" {
81
+ let selectedOptions = filterOptionsBySearch(~options, ~search)
82
+ onChange(selectedOptions)
83
+ setSelectedOptions(_ => {
84
+ selectedOptions
85
+ })
86
+ }
87
+ }}
67
88
  onChange={event => {
68
89
  let target = event->ReactEvent.Form.currentTarget
69
90
  // normalize nfd -> replace by re remove split by commponents the accent letters and deletes the accent component only, leaving the un-accented letter