@colisweb/rescript-toolkit 4.15.0 → 4.15.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": "4.15.0",
3
+ "version": "4.15.1",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "clean": "rescript clean",
@@ -82,9 +82,10 @@ let make = (
82
82
  onClick={event => {
83
83
  switch dropDownRef.current->Js.Nullable.toOption {
84
84
  | None => toggle()
85
- | Some(_dropDownRef) => {
86
- let isButton = ReactEvent.Mouse.target(event)["tagName"] === "BUTTON"
87
- if isButton {
85
+ | Some(dropDownRef) => {
86
+ let clickedElement = event->ReactEvent.Mouse.target->Browser.DomElement.toDomElement
87
+
88
+ if !(dropDownRef->Browser.DomElement.Node.contains(clickedElement)) {
88
89
  toggle()
89
90
  }
90
91
  }
@@ -101,6 +101,7 @@ let make = (
101
101
  ~disabled: option<bool>=?,
102
102
  ~onCancel: option<unit => unit>=?,
103
103
  ~validateMessage: option<React.element>=?,
104
+ ~showCarret=true,
104
105
  ) => {
105
106
  let (selectedOption, setSelectedOption) = React.useState(() => defaultValue)
106
107
  let previousDefaultValue = Toolkit__Hooks.usePrevious(defaultValue)
@@ -139,9 +140,11 @@ let make = (
139
140
  <span className="table-cell truncate text-left w-full">
140
141
  {selectedOption.itemLabel->Option.getWithDefault(selectedOption.label->React.string)}
141
142
  </span>
142
- <span className="absolute inset-y-0 right-2 flex items-center">
143
- <ReactIcons.FaAngleDown />
144
- </span>
143
+ {showCarret
144
+ ? <span className="absolute inset-y-0 right-2 flex items-center">
145
+ <ReactIcons.FaAngleDown />
146
+ </span>
147
+ : React.null}
145
148
  </div>
146
149
  }}>
147
150
  <div className="py-2 pl-2 pr-1 max-h-[300px] overflow-y-scroll">
@@ -20,4 +20,5 @@ let make: (
20
20
  ~disabled: bool=?,
21
21
  ~onCancel: unit => unit=?,
22
22
  ~validateMessage: React.element=?,
23
+ ~showCarret: bool=?,
23
24
  ) => React.element
@@ -48,6 +48,18 @@ module DomElement = {
48
48
  @send external getBoundingClientRect: Dom.element => rect = "getBoundingClientRect"
49
49
 
50
50
  @send external focus: Dom.element => unit = "focus"
51
+
52
+ external toDomElement: 'a => Dom.element = "%identity"
53
+
54
+ module ClassList = {
55
+ @send @scope("classList")
56
+ external contains: (Dom.element, string) => bool = "contains"
57
+ }
58
+
59
+ module Node = {
60
+ @send
61
+ external contains: (Dom.element, Dom.element) => bool = "contains"
62
+ }
51
63
  }
52
64
 
53
65
  @val
@@ -34,6 +34,17 @@ module DomElement: {
34
34
  }
35
35
  let getBoundingClientRect: Dom.element => rect
36
36
  let focus: Dom.element => unit
37
+
38
+ external toDomElement: 'a => Dom.element = "%identity"
39
+
40
+ module ClassList: {
41
+ @send @scope("classList")
42
+ external contains: (Dom.element, string) => bool = "contains"
43
+ }
44
+ module Node: {
45
+ @send
46
+ external contains: (Dom.element, Dom.element) => bool = "contains"
47
+ }
37
48
  }
38
49
 
39
50
  let innerWidth: int