hotwire_combobox 0.1.27 → 0.1.28

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e221d9fd94697b8faa4987a7464ec3e0325df4c7afb5177252dc3ed5e84c1869
4
- data.tar.gz: 900ea551c230017aeb81525eb07599463336fb33508d2b30a25b7eaf55b5983b
3
+ metadata.gz: 8742f8a51c5eab21dc0ec69c0a3c2a232ecc43ef04342c2b16eee551dea92312
4
+ data.tar.gz: fcb66748f4d083a32641317aae3dcd788435301ce7fa4bb93edd6912dd707a52
5
5
  SHA512:
6
- metadata.gz: 1bfb3c001fb07b9d5c40ed21b7229960e24830d598f0ae5e1baf4eda1c7d865e2b3418d57b955c702a6c3937be38cc74eb376b6d717a74955aba31854bd98581
7
- data.tar.gz: e921c0714ef63f7bf32dd96257fdc3b08ccc963c6f962420c892b0afe4e4ad9f4efd94dccee9c41a8ad00e1cc8d9cd35b5748e776dcd136bb9134d7b13d722f8
6
+ metadata.gz: 1175734ef7d8052bb3dd092fbf900386e95ef2eb419b5e29564cbd5cdd7dcab8ce5df7b7bd18b9dc28edd837fce6aee0c48710b781e6004dd7f8acb03536189b
7
+ data.tar.gz: 01d02f1275c151584f3a44a82640d63d4a3fcfeeda26297b953b2b8789422127c34140a9930111b4d6e6e09311f9f165efe6a24328d22ff32ae963334a482ab0
@@ -33,9 +33,10 @@ Combobox.Dialog = Base => class extends Base {
33
33
 
34
34
  _resizeDialog = () => {
35
35
  if (window.visualViewport) {
36
- const fullHeight = window.innerHeight
37
- const viewportHeight = window.visualViewport.height
38
- this.dialogTarget.style.setProperty("--hw-dialog-bottom-padding", `${fullHeight - viewportHeight}px`)
36
+ this.dialogTarget.style.setProperty(
37
+ "--hw-visual-viewport-height",
38
+ `${window.visualViewport.height}px`
39
+ )
39
40
  }
40
41
  }
41
42
 
@@ -24,6 +24,7 @@ Combobox.Toggle = Base => class extends Base {
24
24
  closeOnClickOutside(event) {
25
25
  const target = event.target
26
26
 
27
+ if (!this._isOpen) return
27
28
  if (this.element.contains(target) && !this._isDialogDismisser(target)) return
28
29
  if (this._withinElementBounds(event)) return
29
30
 
@@ -100,6 +101,7 @@ Combobox.Toggle = Base => class extends Base {
100
101
  this._moveArtifactsInline()
101
102
  this.dialogTarget.close()
102
103
  this._restoreBodyScroll()
104
+ this._actingCombobox.scrollIntoView({ block: "center" })
103
105
  }
104
106
 
105
107
  _closeInline() {
@@ -6,7 +6,6 @@
6
6
  --hw-border-width--slim: 1px;
7
7
  --hw-border-width--thick: 2px;
8
8
 
9
- --hw-dialog-bottom-padding: 0;
10
9
  --hw-dialog-font-size: 1.25rem;
11
10
  --hw-dialog-input-height: 2.5rem;
12
11
  --hw-dialog-label-alignment: center;
@@ -37,6 +36,8 @@
37
36
 
38
37
  --hw-padding--slim: 0.375rem;
39
38
  --hw-padding--thick: 0.75rem;
39
+
40
+ --hw-visual-viewport-height: 100vh;
40
41
  }
41
42
 
42
43
  .hw-combobox {
@@ -98,6 +99,7 @@
98
99
  left: 0;
99
100
  line-height: var(--hw-line-height);
100
101
  list-style: none;
102
+ margin: 0;
101
103
  max-height: var(--hw-listbox-height);
102
104
  overflow: auto;
103
105
  padding: 0;
@@ -125,16 +127,31 @@
125
127
  background-color: var(--hw-active-bg-color);
126
128
  }
127
129
 
130
+ .hw-combobox__dialog__wrapper {
131
+ display: none;
132
+ height: 100vh;
133
+ inset-inline-start: 0;
134
+ pointer-events: none;
135
+ position: fixed;
136
+ top: 0;
137
+ width: 100%;
138
+
139
+ &:has([open]) {
140
+ display: flex;
141
+ }
142
+ }
143
+
128
144
  .hw-combobox__dialog {
129
145
  border: 0;
130
146
  font-size: var(--hw-dialog-font-size);
131
147
  height: auto;
132
148
  margin: 0;
133
- max-height: none;
149
+ max-height: calc(var(--hw-visual-viewport-height) - var(--hw-dialog-top-offset));
134
150
  max-width: none;
135
151
  overflow: hidden;
136
- padding: var(--hw-dialog-padding) var(--hw-dialog-padding) var(--hw-dialog-bottom-padding) var(--hw-dialog-padding);
137
- position: fixed;
152
+ padding: var(--hw-dialog-padding);
153
+ pointer-events: auto;
154
+ position: absolute;
138
155
  top: var(--hw-dialog-top-offset);
139
156
  width: auto;
140
157
 
@@ -146,7 +163,7 @@
146
163
  }
147
164
 
148
165
  &::backdrop {
149
- background-color: rgba(0, 0, 0, 0.6);
166
+ background-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.6) 50%, white 50%);
150
167
  }
151
168
  }
152
169
 
@@ -82,6 +82,12 @@ class HotwireCombobox::Component
82
82
  end
83
83
 
84
84
 
85
+ def dialog_wrapper_attrs
86
+ {
87
+ class: "hw-combobox__dialog__wrapper"
88
+ }
89
+ end
90
+
85
91
  def dialog_attrs
86
92
  {
87
93
  class: "hw-combobox__dialog",
@@ -1,7 +1,9 @@
1
1
  <%= tag.div **component.dialog_focus_trap_attrs %>
2
2
 
3
- <%= tag.dialog **component.dialog_attrs do %>
4
- <%= tag.label component.dialog_label, **component.dialog_label_attrs %>
5
- <%= tag.input **component.dialog_input_attrs %>
6
- <%= tag.ul **component.dialog_listbox_attrs %>
3
+ <%= tag.div **component.dialog_wrapper_attrs do %>
4
+ <%= tag.dialog **component.dialog_attrs do %>
5
+ <%= tag.label component.dialog_label, **component.dialog_label_attrs %>
6
+ <%= tag.input **component.dialog_input_attrs %>
7
+ <%= tag.ul **component.dialog_listbox_attrs %>
8
+ <% end %>
7
9
  <% end %>
@@ -1,3 +1,3 @@
1
1
  module HotwireCombobox
2
- VERSION = "0.1.27"
2
+ VERSION = "0.1.28"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hotwire_combobox
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.27
4
+ version: 0.1.28
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jose Farias
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-02-04 00:00:00.000000000 Z
11
+ date: 2024-02-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails